- Add number checking (and parsing) to the config editor

- Change the type of $config['regfee'] to 'number'
This commit is contained in:
dave 2008-01-28 21:48:44 +00:00
parent 8b38f44501
commit 414a85ccb2
5 changed files with 22 additions and 8 deletions

View File

@ -30,7 +30,7 @@ ogram; see the file COPYING. If not, write to
require("judges.inc.php"); require("judges.inc.php");
require("judges_schedulerconfig_check.inc.php"); require("judges_schedulerconfig_check.inc.php");
$action = config_editor_handle_actions($config['FAIRYEAR'], "var"); $action = config_editor_handle_actions("Judge Scheduler", $config['FAIRYEAR'], "var");
if($action == 'update') { if($action == 'update') {
header("Location: judges_schedulerconfig.php"); header("Location: judges_schedulerconfig.php");
exit; exit;

View File

@ -35,7 +35,7 @@ ogram; see the file COPYING. If not, write to
exit; exit;
} }
$action = config_editor_handle_actions( $config['FAIRYEAR'], "var"); $action = config_editor_handle_actions("Tour Assigner", $config['FAIRYEAR'], "var");
if($action == 'update') { if($action == 'update') {
header('Location: tours_sa_config.php'); header('Location: tours_sa_config.php');
exit; exit;

View File

@ -117,11 +117,13 @@ function config_update_variables($fairyear=NULL, $lastfairyear=NULL)
$config_editor_actions_done = false; $config_editor_actions_done = false;
$config_editor_updated = false; $config_editor_updated = false;
function config_editor_handle_actions($year, $array_name) function config_editor_handle_actions($category, $year, $array_name)
{ {
global $config; global $config;
global $config_editor_actions_done; global $config_editor_actions_done;
$config_vars = config_editor_load($category, $year);
$config_editor_actions_done = true; $config_editor_actions_done = true;
$updated = false; $updated = false;
if($_POST['action']=="update") { if($_POST['action']=="update") {
@ -133,9 +135,20 @@ function config_editor_handle_actions($year, $array_name)
else else
$val = $var[$k]; $val = $var[$k];
/* If it hasn't changed, don't update it */ /* If it hasn't changed, don't update it (do a string
if($config[$k] == $val) continue; * compare so numbers aren't interpreted.. php thinks
// echo $config[$k]." ==? $val"; * "1.0" == "1") */
if(strcmp($config[$k], $val) == 0) continue;
switch($config_vars[$k]['type']) {
case 'number':
if(ereg("[0-9]+(\.[0-9]+)?", $val, $regs)) {
$val = $regs[0];
} else {
$val = 0;
}
break;
}
/* Prep for MySQL update */ /* Prep for MySQL update */
$val = mysql_escape_string($val); $val = mysql_escape_string($val);
@ -169,7 +182,7 @@ function config_editor($category, $year, $array_name, $self)
global $config_editor_actions_done, $config_editor_updated; global $config_editor_actions_done, $config_editor_updated;
if($config_editor_actions_done == false) { if($config_editor_actions_done == false) {
config_editor_handle_actions($year, $array_name); config_editor_handle_actions($category, $year, $array_name);
} }
if(is_array($_SESSION['messages'])) { if(is_array($_SESSION['messages'])) {

View File

@ -1 +1 @@
102 103

1
db/db.update.103.sql Normal file
View File

@ -0,0 +1 @@
UPDATE `config` SET `type` = 'number' WHERE `var` = 'regfee';