Clean all preferences, fixes setting preferences

This commit is contained in:
Chris Morgan
2006-06-19 21:28:45 +00:00
committed by WineHQ
parent 84b5a86e11
commit bc9d2bcefe

View File

@@ -21,6 +21,15 @@ $aClean['ext_realname'] = makeSafe($REQUEST['ext_realname']);
$aClean['CVSrelease'] = makeSafe($REQUEST['CVSrelease']); $aClean['CVSrelease'] = makeSafe($REQUEST['CVSrelease']);
$aClean['ext_hasadmin'] = makeSafe($POST['ext_hasadmin']); $aClean['ext_hasadmin'] = makeSafe($POST['ext_hasadmin']);
/* filter all of the preferences */
while(list($key, $value) = each($_REQUEST))
{
if(ereg("^pref_(.+)$", $key, $arr))
$aClean[$key] = makeSafe($value);
}
if(!$_SESSION['current']->isLoggedIn()) if(!$_SESSION['current']->isLoggedIn())
{ {
@@ -47,11 +56,11 @@ function build_prefs_list()
global $oUser; global $oUser;
$result = query_appdb("SELECT * FROM prefs_list ORDER BY id"); $result = query_appdb("SELECT * FROM prefs_list ORDER BY id");
while($result && $r = mysql_fetch_object($result)) while($result && $r = mysql_fetch_object($result))
{ {
//skip admin options //skip admin options
//TODO: add a field to prefs_list to flag the user level for the pref //TODO: add a field to prefs_list to flag the user level for the pref
if(!$_SESSION['current']->hasPriv("admin")) if(!$_SESSION['current']->hasPriv("admin"))
{ {
if($r->name == "query:mode") if($r->name == "query:mode")
continue; continue;
if($r->name == "sidebar") if($r->name == "sidebar")
@@ -64,12 +73,12 @@ function build_prefs_list()
continue; continue;
if($r->name == "debug") if($r->name == "debug")
continue; continue;
} }
$input = html_select("pref_$r->name", explode('|', $r->value_list), $input = html_select("pref_$r->name", explode('|', $r->value_list),
$oUser->getpref($r->name, $r->def_value)); $oUser->getpref($r->name, $r->def_value));
echo html_tr(array("  $r->description", $input)); echo html_tr(array("  $r->description", $input));
} }
} }
function show_user_fields() function show_user_fields()
@@ -94,11 +103,13 @@ function show_user_fields()
if($_POST) if($_POST)
{ {
while(list($key, $value) = each($aClean)) while(list($key, $value) = each($aClean))
{ {
if(!ereg("^pref_(.+)$", $key, $arr)) /* if a parameter lacks 'pref_' at its head it isn't a */
continue; /* preference so skip over processing it */
$oUser->setPref($arr[1], $value); if(!ereg("^pref_(.+)$", $key, $arr))
} continue;
$oUser->setPref($arr[1], $value);
}
if ($aClean['ext_password'] == $aClean['ext_password2']) if ($aClean['ext_password'] == $aClean['ext_password2'])
{ {