2005-01-24 18:00:03 +00:00
< ?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website : http :// www . sfiab . ca
Copyright ( C ) 2005 Sci - Tech Ontario Inc < info @ scitechontario . org >
Copyright ( C ) 2005 James Grant < james @ lightbox . org >
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation , version 2.
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; see the file COPYING . If not , write to
the Free Software Foundation , Inc . , 59 Temple Place - Suite 330 ,
Boston , MA 02111 - 1307 , USA .
*/
?>
2004-12-20 16:00:43 +00:00
< ?
require ( " ../common.inc.php " );
2005-02-16 22:50:43 +00:00
auth_required ( 'config' );
2004-12-20 16:00:43 +00:00
send_header ( " Configuration - Variables " );
2004-12-20 16:35:15 +00:00
echo " <a href= \" index.php \" ><< " . i18n ( " Back to Configuration " ) . " </a><br /> " ;
2004-12-20 16:00:43 +00:00
2005-11-24 20:12:06 +00:00
$q = mysql_query ( " SELECT * FROM config WHERE year='-1' " );
while ( $r = mysql_fetch_object ( $q ))
{
mysql_query ( " INSERT INTO config (var,val,description,year) VALUES (
'".mysql_escape_string($r->var)."' ,
'".mysql_escape_string($r->val)."' ,
'".mysql_escape_string($r->description)."' ,
'".$config[' FAIRYEAR ']."' ) " );
}
2004-12-20 16:00:43 +00:00
if ( $_POST [ 'action' ] == " save " )
{
if ( $_POST [ 'specialconfig' ])
{
foreach ( $_POST [ 'specialconfig' ] as $key => $val )
{
mysql_query ( " UPDATE config SET val=' " . mysql_escape_string ( stripslashes ( $val )) . " ' WHERE year='0' AND var=' $key ' " );
}
}
if ( $_POST [ 'saveconfig' ])
{
foreach ( $_POST [ 'saveconfig' ] as $key => $val )
{
mysql_query ( " UPDATE config SET val=' " . mysql_escape_string ( stripslashes ( $val )) . " ' WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' AND var=' $key ' " );
}
}
echo happy ( i18n ( " Configuration successfully saved " ));
}
$q = mysql_query ( " SELECT * FROM config WHERE year=0 ORDER BY var " );
2005-01-14 15:44:36 +00:00
echo " <form method= \" post \" action= \" variables.php \" > " ;
2004-12-20 16:00:43 +00:00
echo " <input type= \" hidden \" name= \" action \" value= \" save \" > \n " ;
echo " <table> " ;
echo " <tr><td colspan= \" 3 \" ><h3> " . i18n ( " Global configuration settings " ) . " </h3></td></tr> " ;
while ( $r = mysql_fetch_object ( $q ))
{
2005-06-07 21:12:01 +00:00
if ( $r -> var == " FAIRYEAR " || $r -> var == " DBVERSION " )
2005-06-06 17:07:35 +00:00
{
echo " <tr><td> $r->var </td><td> " . i18n ( $r -> description ) . " </td><td> $r->val </td></tr> " ;
}
else
{
echo " <tr><td> $r->var </td><td> " . i18n ( $r -> description ) . " </td><td><input type= \" text \" name= \" specialconfig[ $r->var ] \" value= \" $r->val\ " /></ td ></ tr > " ;
}
2004-12-20 16:00:43 +00:00
}
2006-01-19 17:15:07 +00:00
echo " <tr><td colspan= \" 3 \" ><hr /><br /><h3> " . i18n ( " Configuration settings for fair year %1 " , array ( $config [ 'FAIRYEAR' ]), array ( " fair year " )) . " </h3></td></tr> " ;
2004-12-20 16:00:43 +00:00
$q = mysql_query ( " SELECT * FROM config WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' ORDER BY var " );
while ( $r = mysql_fetch_object ( $q ))
{
echo " <tr><td> $r->var </td><td> " . i18n ( $r -> description ) . " </td><td><input type= \" text \" name= \" saveconfig[ $r->var ] \" value= \" $r->val\ " /></ td ></ tr > " ;
}
echo " </table> " ;
echo " <input type= \" submit \" value= \" " . i18n ( " Save Configuration " ) . " \" /> \n " ;
echo " </form> " ;
send_footer ();
?>