X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fforms.php;h=f3efadde088efac316225c31747fd8ebf4a97936;hb=4d30c1b7147f2df7abdd687e48abea2c7ceb94f5;hp=bf540d1dc87457e3c02f57098356b289e0170cd4;hpb=10ff256e1bfb6cb6c674fa7977fa99896c098756;p=squirrelmail.git diff --git a/functions/forms.php b/functions/forms.php index bf540d1d..f3efadde 100644 --- a/functions/forms.php +++ b/functions/forms.php @@ -8,8 +8,9 @@ * Functions to build HTML forms in a safe and consistent manner. * All name, value attributes are htmlentitied. * - * $Id$ + * @version $Id$ * @package squirrelmail + * @subpackage forms */ /** @@ -18,16 +19,16 @@ */ function addInputField($type, $name = null, $value = null, $attributes = '') { return '\n"; + ($name !== null ? ' name="'.htmlspecialchars($name).'"' : ''). + ($value !== null ? ' value="'.htmlspecialchars($value).'"' : ''). + $attributes . " />\n"; } /** * Password input field */ -function addPwField($name) { - return addInputField('password', $name); +function addPwField($name , $value = null) { + return addInputField('password', $name , $value); } @@ -36,7 +37,7 @@ function addPwField($name) { */ function addCheckBox($name, $checked = false, $value='') { return addInputField('checkbox', $name, $value, - ($checked ? ' checked' : '')); + ($checked ? ' checked="checked"' : '')); } /** @@ -44,7 +45,7 @@ function addCheckBox($name, $checked = false, $value='') { */ function addRadioBox($name, $checked = false, $value='') { return addInputField('radio', $name, $value, - ($checked ? ' checked' : '')); + ($checked ? ' checked="checked"' : '')); } /** @@ -85,16 +86,16 @@ function addSelect($name, $values, $default = null, $usekeys = false) if(count($values) == 1) { $k = key($values); $v = array_pop($values); return addHidden($name, ($usekeys ? $k:$v)). - htmlentities($v) . "\n"; + htmlspecialchars($v) . "\n"; } - $ret = '\n"; foreach ($values as $k => $v) { if(!$usekeys) $k = $v; $ret .= '\n"; + htmlspecialchars( $k ) . '"' . + (($default == $k) ? ' selected="selected"':'') . + '>' . htmlspecialchars($v) ."\n"; } $ret .= "\n"; @@ -119,9 +120,9 @@ function addReset($value) { * Textarea form element. */ function addTextArea($name, $text = '', $cols = 40, $rows = 10, $attr = '') { - return '\n"; + $attr . '">'.htmlspecialchars($text) ."\n"; } /** @@ -143,4 +144,4 @@ function addForm($action, $method = 'POST', $name = '', $enctype = '', $charset $enctype . $name . $charset . "\">\n"; } - +?> \ No newline at end of file