. */ include("./include/include.php"); admin_header(); if( !in_array("setup_view", $_SESSION['sess_functions']) ) { echoln("You are not authorized to see this page."); }else { if( in_array("setup_chair", $_SESSION['sess_functions']) ) $accessField = "chair"; elseif( in_array("setup_localorg", $_SESSION['sess_functions']) ) $accessField = "localorg"; elseif( in_array("setup_registration", $_SESSION['sess_functions']) ) $accessField = "registration"; elseif( in_array("setup_jc", $_SESSION['sess_functions']) ) $accessField = "jc"; elseif( in_array("setup_audit", $_SESSION['sess_functions']) ) $accessField = "audit"; else $accessField = "view"; echoln("

Setup

"); $Cancel_process=false; $id=get_int("id"); $Value = get_var("Value"); $Explanation = get_var("Explanation"); $Ac_view = get_var("ac_view"); $Ac_edit = get_var("ac_edit"); $Ac_audit = get_var("ac_audit"); $Ac_jc = get_var("ac_jc"); $Ac_registration = get_var("ac_registration"); $Ac_localorg = get_var("ac_localorg"); $Ac_chair = get_var("ac_chair"); $Default = get_var("Default"); $Empty = get_var("empty"); // Action= is the default if( !isset($_REQUEST['cmd']) || !in_array($_REQUEST['cmd'], array("info", "edit", "save", "setcategory")) ) $_REQUEST['cmd']=""; if( in_array($_REQUEST['cmd'], array("info", "edit", "save")) AND !$Cancel_process ) { ################# ### Load Data ### ################# $query="SELECT `Name`, `Value`, `RegEx`, `Explanation`, `ac_view`, `ac_edit`, `ac_audit`, `ac_jc`, `ac_registration`, `ac_localorg`, `ac_chair`, ".(in_array("setup_admin", $_SESSION['sess_functions']) ? "'edit'" : "`ac_".$accessField."`")." AS `access`, `default`, `empty` FROM `setup` WHERE `id`=".addslashes($id); if( @mysql_num_rows( $res=doquery($query) )==1 ) { // Ok, load data $row=mysql_fetch_array($res); if( $_REQUEST['cmd']=="info" || $row['access']=="edit" ) { $Name=$row['Name']; if( $_REQUEST['cmd']=="info" || $_REQUEST['cmd']=="edit" ) $Value=$row['Value']; // Only load value when editing $RegEx=$row['RegEx']; if( !($_REQUEST['cmd']=="save" AND in_array("setup_admin", $_SESSION['sess_functions'])) ) { $Explanation=$row['Explanation']; $Ac_view=$row['ac_view']; $Ac_edit=$row['ac_edit']; $Ac_audit=$row['ac_audit']; $Ac_jc=$row['ac_jc']; $Ac_registration=$row['ac_registration']; $Ac_localorg=$row['ac_localorg']; $Ac_chair=$row['ac_chair']; } if( (!($_REQUEST['cmd']=="save" AND in_array("setup_admin", $_SESSION['sess_functions']))) OR !in_array("setup_admin", $_SESSION['sess_functions']) ) { $Default=$row['default']; $Empty=$row['empty']; } }else { echoln("You are not authorized to edit this entry."); $Cancel_process=true; } }else { // No result, error loading data echoln("Unable to find data for this entry."); $Cancel_process=true; } } if( ($_REQUEST['cmd']=="save") AND (!$Cancel_process) ) { ################### ### ERROR CHECK ### ################### $Error_msg = array(); $Error=false; // Check for errors before saving switch( $RegEx ) { // /(^ $)/ case "[url]": $re="/(^http(s)?:\/\/(\w|-|_)+(\.(\w|-|_)+)*\.[a-zA-Z]{2,}(:\d{1,5})?\/.*$)/"; $re_msg="This is not a valid url. Please supply a valid one."; break; case "[email]": $re="/(^(\w|\.|-|\+)+@(\w|-)+(\.(\w|-)+)*\.[a-zA-Z]{2,}$)/"; $re_msg="This is not a valid e-mail address. Please supply a valid one."; break; case "[int]": $re="/(^-?\d+$)/"; $re_msg="This is not an integer. Please supply an integer."; break; case "[date]": $re="/^(([0-2][0-9])|30|31)\.((0[0-9])|(1[0-2]))\.(19|20)[0-9]{2}$/"; $re_msg="This is not a valid date. Please supply the date as 'dd.mm.yyyy'."; break; case "[datetime]": $re = "/^(([0-2][0-9])|30|31)\.((0[0-9])|(1[0-2]))\.(19|20)[0-9]{2} [0-2][0-9]:[0-5][0-9]$/"; $re_msg = "This is not a valid date and time. Please supply the date as 'dd.mm.yyyy hh:mm'."; break; case "[phone]": $re="/(^(\+)?(\d| |-){6,50}$)/"; $re_msg="This is not a valid telephone number. Please supply a valid one (starting with + and containing only numbers, spaces and dashes."; break; case "[bool]": $re="/(^(true|false)$)/"; $re_msg="Please choose one of the options given."; break; case "[text]"; $re="/.*/"; break; default: $re1="/(^\[.+(\|.+)+\]$)/"; $re2="/(^\/.+\/$)/"; if( preg_match($re1,$RegEx) ) { // [ | | ] $re="/(^".substr($RegEx, 1, -1)."$)/"; $re_msg="Please choose one of the options given."; }elseif( preg_match($re2,$RegEx) ) { // RegEx provided $re=$RegEx; $re_msg="The value provided is not valid."; }elseif( !strlen($RegEx) ) { // No restrictions $re="/(^.*$)/"; }else { // Unknown $Error_msg[] = "Unknown kind of value. Contact the webmaster."; $Error=true; } } if( !$Error AND !preg_match($re, $Value) ) { if( $Empty=="yes" AND $Value=="" ) { // empty value, this is allowed for this item }else { // Error in value $Error_msg[] = $re_msg; $Error=true; } } if( in_array("setup_admin", $_SESSION['sess_functions']) AND !$Error AND !preg_match($re, $Default) ) { if( $Default=="" ) { // empty default, this is allowed for this item }else { // Error in value $Error_msg[] = "$re_msg"; $Error=true; } } if( !$Error ) { ################# ### SAVE DATA ### ################# if( in_array("setup_admin", $_SESSION['sess_functions']) ) $query="UPDATE `setup` SET `Value`='".addslashes($Value)."', `Explanation`='".addslashes($Explanation)."', `ac_view`='".addslashes($Ac_view)."', `ac_edit`='".addslashes($Ac_edit)."', `ac_audit`='".addslashes($Ac_audit)."', `ac_jc`='".addslashes($Ac_jc)."', `ac_registration`='".addslashes($Ac_registration)."', `ac_localorg`='".addslashes($Ac_localorg)."', `ac_chair`='".addslashes($Ac_chair)."', `default`='".addslashes($Default)."', `empty`='".addslashes($Empty)."' WHERE `id`=".addslashes($id); else $query="UPDATE `setup` SET `Value`='".addslashes($Value)."' WHERE `id`=".addslashes($id); if( doquery($query) ) { // Saving succeeded echoln("Option saved successfully."); }else { // Saving failed echoln("Unable to update option."); $Cancel_process=true; } }else { // Error found, reshow form echoln(""); $_REQUEST['cmd']="edit"; $Cancel_process=false; } }elseif( !$Cancel_process ) { // Not save action, so there were no errors $Error=false; } if( $_REQUEST['cmd']=="setcategory" ) { ################ ### Category ### ################ if( isset($_REQUEST['category']) ) $_SESSION['setup_category']=$_REQUEST['category']; } if( ($_REQUEST['cmd']=="edit" || $_REQUEST['cmd']=="info") AND (!$Cancel_process) ) { ################# ### Show form ### ################# echoln("Back

"); if( $_REQUEST['cmd']=="edit" ) { echoln("

"); echoln(" "); echoln(" "); } echoln(" "); echoln(" "); $readonly = ($_REQUEST['cmd']=="info"); switch( $RegEx ) { case "[url]": case "[email]": case "[int]": case "[date]": case "[datetime]": case "[phone]": if( $Value=="" OR $Value==null ) { if( $RegEx=="[url]" ) $Value="http://"; elseif( $RegEx=="[phone]" ) $Value="+"; } echoln(" "); break; case "[text]": echoln(" "); break; case "[bool]": $RegEx="[true|false]"; default: $re1="/(^\[.+(\|.+)+\]$)/"; $re2="/(^\/.+\/$)/"; if( preg_match($re1,$RegEx) ) { // [ | | ] echoln(" "); }elseif( preg_match($re2,$RegEx) OR !strlen($RegEx) ) { echoln(" "); }else { // Unknown echoln(" "); } } echoln(" "); if( in_array("setup_admin", $_SESSION['sess_functions']) ) echoln(" "); else echoln(" "); echoln(" "); $a = array("view", "edit", "audit", "jc", "registration", "localorg", "chair"); $b = array("no", "view", "edit"); for( $i=0; $i"); else echoln(" "); echoln(" "); echoln(" "); echoln(" "); } if( in_array("setup_admin", $_SESSION['sess_functions']) ) { echoln(" "); echoln(" "); switch( $RegEx ) { case "[url]": case "[email]": case "[int]": case "[date]": case "[datetime]": case "[phone]": if( $Default=="" OR $Default==null ) { #if( $RegEx=="[url]" ) $Default="http://"; #elseif( $RegEx=="[phone]" ) $Default="+"; } echoln(" "); break; case "[text]": echoln(" "); break; case "[bool]": $RegEx="[true|false]"; default: $re1="/(^\[.+(\|.+)+\]$)/"; $re2="/(^\/.+\/$)/"; if( preg_match($re1,$RegEx) ) { // [ | | ] echoln(" "); }elseif( preg_match($re2,$RegEx) OR !strlen($RegEx) ) { echoln(" "); }else { // Unknown echoln(" "); } } echoln(" "); echoln(" "); } echoln("
".$Name.":"); $a=1; while( $b=strpos($RegEx, "|", $a) ) { $var=substr($RegEx, $a, $b-$a); echoln("
"); $a=$b+1; } $var=substr($RegEx, $a, -1); echoln("
Unknown kind of value
".$Explanation."
Access rights for this entry
".ucwords($a[$i])." access:
Other options for this entry
Default for new application:"); $a=1; while( $b=strpos($RegEx, "|", $a) ) { $var=substr($RegEx, $a, $b-$a); echoln("
"); $a=$b+1; } $var=substr($RegEx, $a, -1); echoln("
"); echoln(" "); echoln("
Unknown kind of value
Empty allowed:"); echoln("   "); echoln("
"); if( $_REQUEST['cmd']=="edit" ) { echoln("

"); echoln("   "); echoln(" "); echoln("

"); echoln("
"); echoln(""); } }else { ################# ### Show list ### ################# if( $_SESSION['setup_category'] == "jc" && !$setup['CandidateAdminOpen'] ) { echoln("
Warning: master lock on candidatures in place. When configuration is done, contact the webmaster to have the lock removed. Candidating will not be available with this lock.
"); }elseif( $_SESSION['setup_category'] != "jc" && !$setup['ApplicationAdminOpen'] ) { echoln("
Warning: master lock on applications in place. When configuration is done, contact the webmaster to have the lock removed. Applying will not be available with this lock.
"); } // Category $query="SELECT `category` FROM `setup` ".(in_array("setup_admin", $_SESSION['sess_functions']) ? "" : "WHERE `ac_".$accessField."`='edit' OR `ac_".$accessField."`='view' ")."GROUP BY `category` ORDER BY `category`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { echoln("

"); echoln(" "); echoln(" "); echoln(" "); echoln("
"); $QW="WHERE `category`='".addslashes($_SESSION['setup_category'])."' ".(in_array("setup_admin", $_SESSION['sess_functions']) ? "" : "AND (`ac_".$accessField."`='edit' OR `ac_".$accessField."`='view')"); }else { $QW=""; } $query="SELECT `id`, `Name`, `Value`, `Explanation`, ".(in_array("setup_admin", $_SESSION['sess_functions']) ? "'edit'" : "`ac_".$accessField."`")." AS `access`, `empty`, `default` FROM `setup` $QW ORDER BY `Name`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { echoln("

"); echoln(" "); echoln(" "); echoln(" "); echoln(" "); if( in_array("setup_admin", $_SESSION['sess_functions']) ) echoln(" "); if( in_array("setup_admin", $_SESSION['sess_functions']) ) echoln(" "); echoln(" "); echoln(" "); $i = 0; while( $row=mysql_fetch_array($res) ) { $i++; if( $_REQUEST['cmd']=="save" AND $id==$row['id'] ) echoln(" "); elseif( ($i%2)==1 ) echoln(" "); else echoln(" "); echoln(" "); echoln(" "); echoln(" "); if( in_array("setup_admin", $_SESSION['sess_functions']) ) echoln(" "); if( in_array("setup_admin", $_SESSION['sess_functions']) ) echoln(" "); if( $row['access']=="edit" ) echoln(" "); else echoln(" "); echoln(" "); } echoln("
NameValueExplanationemptydefault 
".$row['Name']."".wordwrap($row['Value'], 30, " ", true)."".$row['Explanation']."".$row['empty']."".wordwrap($row['default'], 30, " ", true)."editinfo
"); }else { // Query failed echoln("Unable to load setup."); } } } admin_footer(); ?>