[Openfirst-cvscommit] base/config auth.php,1.2,1.3 first.php,1.11,1.12 globals-default.php,1.2,1.3 g
Brought to you by:
xtimg
Update of /cvsroot/openfirst/base/config In directory sc8-pr-cvs1:/tmp/cvs-serv28393/config Modified Files: auth.php first.php globals-default.php globals.php index.php install.php modules.php Log Message: Convert code to comply with openFIRST coding standards, fix incorrect headers, add more verbosity to some descriptions and explanations where they might be useful. Index: auth.php =================================================================== RCS file: /cvsroot/openfirst/base/config/auth.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** auth.php 21 Jun 2003 15:48:35 -0000 1.2 --- auth.php 28 Jun 2003 17:29:29 -0000 1.3 *************** *** 32,36 **** // Provide functions for the various encryption types... ! // syntax: cryptpassword(password, encryption-type, salt); function cryptpassword ($password, $encryption = "md5", $salt="") { --- 32,36 ---- // Provide functions for the various encryption types... ! // syntax: cryptpassword(password, encryption-type, salt); function cryptpassword ($password, $encryption = "md5", $salt="") { *************** *** 47,71 **** } - function membersmenu($membertype) { - global $basepath; - $basep = $basepath; - // Show a members area menu. - echo("<p><a href='$basep/members'>Members Home</a> - - <a href='$basep/awards/admin/'>Manage Awards</a> - <a href='$basep/members/profile.php'>Members Profiles</a> - <a href='$basep/members/updateprofile.php'>Update Profile</a> - <a href='$basep/members/skills.php'>Update Skills</a> - <a href='$basep/members/logout.php'>Logout</a>"); - if($membertype == "administrator") { - echo("<br /><b>Admin</b>: <a href='$basep/config/'>Configuration Area</a> <a href='$basep/members/adduser.php'>Add User</a>"); - if(is_readable("$basep/news/addnews.php") == true) { - echo(" <a href='$basep/news/addnews.php'>Add news</a>"); - } - echo ("</p>"); - } - return(0); - } - function showlogin () { // Show a login form for the user. --- 47,50 ---- *************** *** 87,175 **** $query = mysql_query("SELECT * FROM ofirst_members WHERE authcode='$authcode';"); if(mysql_errno() == 0 && mysql_num_rows($query) == 1) { ! $user = mysql_fetch_object($query); } else { ! unset($_SESSION['authcode']); ! ! $query = mysql_query("SELECT * FROM ofirst_members WHERE user='" . $_POST["login"] . "';"); ! if(mysql_errno() == 0) { ! $user = mysql_fetch_object($query); ! if(mysql_num_rows($query) == 1) { ! if(cryptpassword($_POST["password"], $encryption, $user->password) == $user->password) { ! session_register("authcode"); ! $_SESSION["authcode"] = rand(1,50000000); ! $aquery = mysql_query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); ! } else { ! unset($user); ! } ! }} } ! } elseif(isset($_POST["login"]) == true && isset($_POST["password"]) == true) { ! $query = mysql_query("SELECT * FROM ofirst_members WHERE user='" . $_POST["login"] . "';"); if(mysql_errno() == 0) { ! $user = mysql_fetch_object($query); ! if(mysql_num_rows($query) == 1) { ! if(cryptpassword($_POST["password"], $encryption, $user->password) == $user->password) { ! session_register("authcode"); ! $_SESSION["authcode"] = rand(1,50000000); ! $aquery = mysql_query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); ! } else { ! unset($user); ! } ! } } ! } if(mysql_errno() != 0) { ! // There was an error, check if it's because they didn't create the ! // members table. ! if(mysql_errno() == 1146) { ! echo("<p>Members table does not exist, therefore I am creating it.</p>"); ! $query = mysql_query("CREATE TABLE ofirst_members ( ! UNIQUE(user), ! user CHAR(128), ! firstname TINYTEXT, ! lastname TINYTEXT, ! lastseen TINYTEXT, ! ip TINYTEXT, ! password TEXT, ! authcode TEXT, ! membertype TINYTEXT, ! division TINYTEXT, ! year INTEGER, ! email TEXT, ! icq INTEGER, ! aim TINYTEXT, ! msn TINYTEXT, ! yim TINYTEXT, ! description TEXT, ! signature TINYTEXT, ! dateregistered TINYTEXT, ! picturelocation TINYTEXT, ! team INTEGER, ! skills TEXT ! );"); ! if(mysql_errno() == 0) { ! // Insert a default user 'administrator' and set them to have ! // administrative access and some password. ! ! $query = mysql_query("INSERT INTO ofirst_members (user, ! membertype, password) VALUES('admin', 'administrator', '" . ! cryptpassword("openfirst", $encryption) ."');"); ! echo("<p>Members table has been created. Please login as <b>admin</b> using the password <b>openfirst</b> to set configuration options.</p>"); ! showlogin(); ! die(); ! } else { ! die(mysql_error()); ! } ! } } ! if(isset($user->user)) { ! $query = "UPDATE ofirst_members SET lastseen='" . date("h:m:s M d, Y") . "' WHERE user='$user->user';"; ! $q = mysql_query($query); ! unset($q); ! } ! ?> --- 66,153 ---- $query = mysql_query("SELECT * FROM ofirst_members WHERE authcode='$authcode';"); if(mysql_errno() == 0 && mysql_num_rows($query) == 1) { ! $user = mysql_fetch_object($query); } else { ! unset($_SESSION['authcode']); + $query = mysql_query("SELECT * FROM ofirst_members WHERE user='" . $_POST["login"] . "';"); + if(mysql_errno() == 0) { + $user = mysql_fetch_object($query); + if(mysql_num_rows($query) == 1) { + if(cryptpassword($_POST["password"], $encryption, $user->password) == $user->password) { + session_register("authcode"); + $_SESSION["authcode"] = rand(1,50000000); + $aquery = mysql_query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); + } else { + unset($user); + } + } + } } ! } elseif(isset($_POST["login"]) == true && isset($_POST["password"]) == true) { ! $query = mysql_query("SELECT * FROM ofirst_members WHERE user='" . $_POST["login"] . "';"); if(mysql_errno() == 0) { ! $user = mysql_fetch_object($query); ! if(mysql_num_rows($query) == 1) { ! if(cryptpassword($_POST["password"], $encryption, $user->password) == $user->password) { ! session_register("authcode"); ! $_SESSION["authcode"] = rand(1,50000000); ! $aquery = mysql_query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); ! } else { ! unset($user); ! } ! } } ! } if(mysql_errno() != 0) { ! // There was an error, check if it's because they didn't create the ! // members table. ! if(mysql_errno() == 1146) { ! echo("<p>Members table does not exist, therefore I am creating it.</p>"); ! $query = mysql_query("CREATE TABLE ofirst_members ( ! UNIQUE(user), ! user CHAR(128), ! firstname TINYTEXT, ! lastname TINYTEXT, ! lastseen TINYTEXT, ! ip TINYTEXT, ! password TEXT, ! authcode TEXT, ! membertype TINYTEXT, ! division TINYTEXT, ! year INTEGER, ! email TEXT, ! icq INTEGER, ! aim TINYTEXT, ! msn TINYTEXT, ! yim TINYTEXT, ! description TEXT, ! signature TINYTEXT, ! dateregistered TINYTEXT, ! picturelocation TINYTEXT, ! team INTEGER, ! skills TEXT ! );"); ! if(mysql_errno() == 0) { ! // Insert a default user 'administrator' and set them to have ! // administrative access and some password. ! $query = mysql_query("INSERT INTO ofirst_members (user, ! membertype, password) VALUES('admin', 'administrator', '" . ! cryptpassword("openfirst", $encryption) ."');"); ! echo("<p>Members table has been created. Please login as <b>admin</b> using the password <b>openfirst</b> to set configuration options.</p>"); ! showlogin(); ! die(); ! } else { ! die(mysql_error()); ! } ! } } ! if(isset($user->user)) { ! $query = "UPDATE ofirst_members SET lastseen='" . date("h:m:s M d, Y") . "' WHERE user='$user->user';"; ! $q = mysql_query($query); ! unset($q); ! } ! ?> \ No newline at end of file Index: first.php =================================================================== RCS file: /cvsroot/openfirst/base/config/first.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** first.php 27 Jun 2003 23:55:29 -0000 1.11 --- first.php 28 Jun 2003 17:29:29 -0000 1.12 *************** *** 33,48 **** if(isset($_POST["login"])) { ! // User is attempting to login for the first time. ! die("You have successfully logged in. ! <a href='index.php'>Access Administrative Configuration Options</a>"); } if(isset($_POST["ostype"])) { ! // They have submitted the form, write a new globals.php file and test ! // options. ! if(is_writable("./globals.php")) { ! $of = fopen("./globals.php", "w"); ! fputs($of, "<?php ! /* * OpenFIRST base configuration file * This file has been automatically generated by first.php. --- 33,47 ---- if(isset($_POST["login"])) { ! // User is attempting to login for the first time. ! die("You have successfully logged in. <a href='index.php'>Access Administrative Configuration Options</a> (you will be prompted for your password again)"); } if(isset($_POST["ostype"])) { ! // They have submitted the form, write a new globals.php file and test ! // options. ! if(is_writable("./globals.php")) { ! $of = fopen("./globals.php", "w"); ! fputs($of, "<?php ! /* * OpenFIRST base configuration file * This file has been automatically generated by first.php. *************** *** 93,141 **** if(mysql_errno() == 0) { // Begin to loop through modules from the databaes ! while(\$module = mysql_fetch_object(\$incl)) { ! // Check if the value is try, if it is then run an include ! if( (bool) \$module->active == true) { ! // Check if there are includes that need to be included ! if(! \$module->includes == \"\"){ ! // If the list is not empty then explode the value and put it into inclist ! \$inclist = explode(\",\",\$module->includes); ! // This is to remove an error that you have if you don't check if there are more then 2 ! if(count(\$inclist) >= 2){ ! // Loop through the inclist and add them according to their paths ! foreach(\$inclist As \$inc){ ! include(\"\$fbasepath/\$module->modulename/\$inc\"); ! } ! } else { ! // If there is only 1 include available then use this line to include it instead ! include(\"\$fbasepath/\$module->modulename/\$module->includes\"); ! } ! } ! // If the module has requested to be shown on the menu then add it ! if( (bool) \$module->showonmenu == true) { ! // If it is the current module then color the item ! if (\$currentmodule == \$module->modulename){ ! \$headers .= \" » <font color='red'><b><a class='menu' href='\$basepath/\$module->modulename'>\".ucwords(\$module->modulename).\"</a></b></font> |\"; ! // Declare important variables so that headers can pick them up and preview them ! \$adminnav = str_replace(\"\\\$basepath\", \$basepath, \$module->adminnavigation); ! \$subnav = str_replace(\"\\\$basepath\", \$basepath, \$module->modulenavigation); ! }else{ ! \$headers .= \" » <a class='menu' href='\$basepath/\$module->modulename'>\".ucwords(\$module->modulename).\"</a> |\"; ! } ! } ! } ! } ! } ! session_write_close(); ?>"); fclose($of); include("../config/globals.php"); include("$header"); ! echo("<h1>OpenFIRST Software Configured</h1> <p>If this page does not display errors elsewhere, then your openFIRST has now been successfully configured. If there are errors, check your configuration options and try again. You may now --- 92,140 ---- if(mysql_errno() == 0) { // Begin to loop through modules from the databaes ! while(\$module = mysql_fetch_object(\$incl)) { ! // Check if the value is try, if it is then run an include ! if( (bool) \$module->active == true) { ! // Check if there are includes that need to be included ! if(! \$module->includes == \"\"){ ! // If the list is not empty then explode the value and put it into inclist ! \$inclist = explode(\",\",\$module->includes); ! // This is to remove an error that you have if you don't check if there are more then 2 ! if(count(\$inclist) >= 2){ ! // Loop through the inclist and add them according to their paths ! foreach(\$inclist As \$inc){ ! include(\"\$fbasepath/\$module->modulename/\$inc\"); ! } ! } else { ! // If there is only 1 include available then use this line to include it instead ! include(\"\$fbasepath/\$module->modulename/\$module->includes\"); ! } ! } ! // If the module has requested to be shown on the menu then add it ! if( (bool) \$module->showonmenu == true) { ! // If it is the current module then color the item ! if (\$currentmodule == \$module->modulename){ ! \$headers .= \" » <font color='red'><b><a class='menu' href='\$basepath/\$module->modulename'>\".ucwords(\$module->modulename).\"</a></b></font> |\"; ! // Declare important variables so that headers can pick them up and preview them ! \$adminnav = str_replace(\"\\\$basepath\", \$basepath, \$module->adminnavigation); ! \$subnav = str_replace(\"\\\$basepath\", \$basepath, \$module->modulenavigation); ! } else { ! \$headers .= \" » <a class='menu' href='\$basepath/\$module->modulename'>\".ucwords(\$module->modulename).\"</a> |\"; ! } ! } ! } ! } ! } ! session_write_close(); ?>"); fclose($of); include("../config/globals.php"); include("$header"); ! echo("<h1>OpenFIRST Software Configured</h1> <p>If this page does not display errors elsewhere, then your openFIRST has now been successfully configured. If there are errors, check your configuration options and try again. You may now *************** *** 143,155 **** options. You should be able to login below using the username <b>admin</b> and the password <b>openfirst</b>, if not, then either the password for that account has been changed, or the ! MySQL settings are incorrect.</p> ! "); ! showlogin(); die(include("$footer")); ! } else { if(is_readable("config/headers.php")) { ! include("config/headers.php"); } else { ! include("../config/headers.php"); } echo("<h1>Base Configuration Error</h1> --- 142,153 ---- options. You should be able to login below using the username <b>admin</b> and the password <b>openfirst</b>, if not, then either the password for that account has been changed, or the ! MySQL settings are incorrect.</p>"); ! showlogin(); die(include("$footer")); ! } else { if(is_readable("config/headers.php")) { ! include("config/headers.php"); } else { ! include("../config/headers.php"); } echo("<h1>Base Configuration Error</h1> *************** *** 162,179 **** cd config <br />chmod 666 globals.php ! </code></p> ! "); ! } } else { ! if(is_readable("config/headers.php")) { ! include("config/headers.php"); ! } else { ! include("../config/headers.php"); ! } ! // User is visiting the configuration page, present them with a form ! // of options to fill out. ?> <h1>Base Configuration</h1> ! <p>Congratulations on your choice of OpenFIRST software. Please proceed through this setup wizard to get your new OpenFIRST portal software set up and working quickly and painlessly.</p> <table> --- 160,176 ---- cd config <br />chmod 666 globals.php ! </code></p>"); ! } ! } else { ! if(is_readable("config/headers.php")) { ! include("config/headers.php"); } else { ! include("../config/headers.php"); ! } ! // User is visiting the configuration page, present them with a form ! // of options to fill out. ?> <h1>Base Configuration</h1> ! <p>Congratulations on your choice of OpenFIRST software. Please proceed through this setup wizard to get your new OpenFIRST portal software set up and working quickly and painlessly.</p> <table> *************** *** 215,221 **** } if(is_readable("config/footers.php")) { ! include("config/footers.php"); } else { ! include("../config/footers.php"); } ! ?> --- 212,218 ---- } if(is_readable("config/footers.php")) { ! include("config/footers.php"); } else { ! include("../config/footers.php"); } ! ?> \ No newline at end of file Index: globals-default.php =================================================================== RCS file: /cvsroot/openfirst/base/config/globals-default.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** globals-default.php 24 Jun 2003 13:22:26 -0000 1.2 --- globals-default.php 28 Jun 2003 17:29:29 -0000 1.3 *************** *** 7,15 **** */ if(file_exists("../config/first.php")) { ! header("Location: ../config/first.php"); } elseif(file_exists("config/first.php")) { ! header("Location: config/first.php"); } elseif(file_exists("../../config/first.php")) { ! header("Location: ../../config/first.php"); } ! ?> --- 7,15 ---- */ if(file_exists("../config/first.php")) { ! header("Location: ../config/first.php"); } elseif(file_exists("config/first.php")) { ! header("Location: config/first.php"); } elseif(file_exists("../../config/first.php")) { ! header("Location: ../../config/first.php"); } ! ?> \ No newline at end of file Index: globals.php =================================================================== RCS file: /cvsroot/openfirst/base/config/globals.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** globals.php 24 Jun 2003 13:22:26 -0000 1.2 --- globals.php 28 Jun 2003 17:29:29 -0000 1.3 *************** *** 7,15 **** */ if(file_exists("../config/first.php")) { ! header("Location: ../config/first.php"); } elseif(file_exists("config/first.php")) { ! header("Location: config/first.php"); } elseif(file_exists("../../config/first.php")) { ! header("Location: ../../config/first.php"); } ! ?> --- 7,15 ---- */ if(file_exists("../config/first.php")) { ! header("Location: ../config/first.php"); } elseif(file_exists("config/first.php")) { ! header("Location: config/first.php"); } elseif(file_exists("../../config/first.php")) { ! header("Location: ../../config/first.php"); } ! ?> \ No newline at end of file Index: index.php =================================================================== RCS file: /cvsroot/openfirst/base/config/index.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** index.php 28 Jun 2003 15:37:58 -0000 1.3 --- index.php 28 Jun 2003 17:29:29 -0000 1.4 *************** *** 33,44 **** ?> <h1>OpenFIRST Configuration Area</h1> ! <p><a href="install.php">Install Component</a> - required to install several new openFIRST modules.</p> ! <p><a href="modules.php">Module Administrator</a> - required to manage openFIRST modules.</p> <?php } else { ! showlogin(); } include($footer); ! ?> --- 33,44 ---- ?> <h1>OpenFIRST Configuration Area</h1> ! <p><a href="install.php">Install Component</a> - required to install several new openFIRST modules.</p> ! <p><a href="modules.php">Module Administrator</a> - required to manage openFIRST modules.</p> <?php } else { ! showlogin(); } include($footer); ! ?> \ No newline at end of file Index: install.php =================================================================== RCS file: /cvsroot/openfirst/base/config/install.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** install.php 28 Jun 2003 15:37:58 -0000 1.11 --- install.php 28 Jun 2003 17:29:29 -0000 1.12 *************** *** 30,42 **** include("../config/globals.php"); include($header); - - membersmenu($user->membertype); - ?> ! <h1>SQL Install</h1> <p>This utility will create the tables required for certain openFIRST ! components to run. Select the SQL scripts you would like to ! install...</p> <form method="post" action="install.php"> --- 30,40 ---- include("../config/globals.php"); include($header); ?> ! <h1>Module Install</h1> <p>This utility will create the tables required for certain openFIRST ! components to run. Select the modules you would like to ! install. Once installed, modules must be enabled from the ! <a href="modules.php"><strong>Module Administrator</strong></a>.</p> <form method="post" action="install.php"> *************** *** 50,55 **** if(isset($_POST[$dir]) == true && $_POST[$dir] == "on") { ! $q = mysql_query("CREATE table IF NOT EXISTS `ofirst_config` (`modulename` CHAR(25) NOT NULL, ! `showonmenu` BOOL, `active` BOOL, `adminnavigation` TEXT, `modulenavigation` TEXT, `includes` TEXT, PRIMARY KEY (`modulename`));"); --- 48,53 ---- if(isset($_POST[$dir]) == true && $_POST[$dir] == "on") { ! $q = mysql_query("CREATE table IF NOT EXISTS `ofirst_config` (`modulename` CHAR(25) NOT NULL, ! `showonmenu` BOOL, `active` BOOL, `adminnavigation` TEXT, `modulenavigation` TEXT, `includes` TEXT, PRIMARY KEY (`modulename`));"); *************** *** 61,65 **** } } ! echo(" - <b>Submitted, and added.</b>"); fclose($sf); } --- 59,63 ---- } } ! echo(" - <b>Submitted, and added.</b> - This module must be configured in the module administrator to show up on menus."); fclose($sf); } *************** *** 79,84 **** if(isset($_POST[$dir]) == true && $_POST[$dir] == "on") { ! $q = mysql_query("CREATE table IF NOT EXISTS `ofirst_config` (`modulename` CHAR(25) NOT NULL, ! `showonmenu` BOOL, `active` BOOL, `adminnavigation` TEXT, `modulenavigation` TEXT, `includes` TEXT, PRIMARY KEY (`modulename`));"); --- 77,82 ---- if(isset($_POST[$dir]) == true && $_POST[$dir] == "on") { ! $q = mysql_query("CREATE table IF NOT EXISTS `ofirst_config` (`modulename` CHAR(25) NOT NULL, ! `showonmenu` BOOL, `active` BOOL, `adminnavigation` TEXT, `modulenavigation` TEXT, `includes` TEXT, PRIMARY KEY (`modulename`));"); *************** *** 107,111 **** showlogin(); } - include($footer); ?> --- 105,108 ---- Index: modules.php =================================================================== RCS file: /cvsroot/openfirst/base/config/modules.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** modules.php 28 Jun 2003 15:37:58 -0000 1.3 --- modules.php 28 Jun 2003 17:29:29 -0000 1.4 *************** *** 1,9 **** <?php /* ! * openFIRST.base - config/install.php * * Copyright (C) 2003, * openFIRST Project ! * Original Author: Tim Ginn <tim...@po...> * * This program is free software; you can redistribute it and/or modify --- 1,9 ---- <?php /* ! * openFIRST.base - config/modules.php * * Copyright (C) 2003, * openFIRST Project ! * Original Author: Dave DiBiase <dav...@ea...> * * This program is free software; you can redistribute it and/or modify *************** *** 26,30 **** * */ ! // Purpose: set up OpenFIRST modules -- currently only installs MySQL tables include("../config/globals.php"); --- 26,30 ---- * */ ! // Purpose: configure OpenFIRST modules, including their position on menus include("../config/globals.php"); *************** *** 34,80 **** if($user->membertype == "administrator") { ! // Check if user wishes to make updates ! if(ISSET($_POST['update'])){ ! // Query for current module information and loop through with while ! $query = mysql_query("SELECT * FROM ofirst_config"); ! while($module = mysql_fetch_object($query)){ ! // Set values to update db for checkboxes ! if(ISSET($_POST[$module->modulename.'-active'])){ $active = "1"; }else{ $active = "0"; } ! if(ISSET($_POST[$module->modulename.'-showonmenu'])){ $showonmenu = "1"; }else{ $showonmenu = "0"; } ! ! // Creater query string then update information in database ! mysql_query("UPDATE ofirst_config SET ! modulename = '".$_POST[$module->modulename.'-modulename']."', ! includes = '".$_POST[$module->modulename.'-includes']."', ! showonmenu = '".$showonmenu."', ! active = '".$active."' WHERE modulename = '".$module->modulename."'") or die(mysql_error()); ! } ! // Successful creation response and die with footers. ! echo "<br><br><center>Module information has been updated, thank you. [ <a href='modules.php'>Modules</a> ]<br><br>"; ! die(include($footer)); ! ! } ?> <h1>Module Administrator</h1> ! <p>This utility will allow you to manage modules for certain openFIRST components. ! You may find the options below:</p> <form method="post" action="modules.php"> ! <table width="52%" align="center"> <tr> ! <td width="32%">Module Name</td> ! <td width="14%">Activate</td> ! <td width="19%">Show Menu</td> ! <td width="35%">Includes</td> </tr> ! <?php ! $query = mysql_query("SELECT * FROM ofirst_config"); ! while($module = mysql_fetch_object($query)){ ! ?> ! <tr> <td><input name="<?php echo $module->modulename; ?>-modulename" type="text" id="modulename" value="<?php echo $module->modulename; ?>"></td> <td><input name="<?php echo $module->modulename; ?>-active" type="checkbox" id="active" value="checkbox" <?php if((bool) $module->active == true){ echo "checked"; } ?>></td> --- 34,78 ---- if($user->membertype == "administrator") { ! // Check if user wishes to make updates ! if(isset($_POST['update'])) { ! // Query for current module information and loop through with while ! $query = mysql_query("SELECT * FROM ofirst_config"); ! while($module = mysql_fetch_object($query)){ ! // Set values to update db for checkboxes ! if(isset($_POST[$module->modulename.'-active'])) { $active = "1"; } else { $active = "0"; } ! if(isset($_POST[$module->modulename.'-showonmenu'])){ $showonmenu = "1"; } else { $showonmenu = "0"; } ! // Creater query string then update information in database ! mysql_query("UPDATE ofirst_config SET ! modulename = '".$_POST[$module->modulename.'-modulename']."', ! includes = '".$_POST[$module->modulename.'-includes']."', ! showonmenu = '".$showonmenu."', ! active = '".$active."' WHERE modulename = '".$module->modulename."'") or die(mysql_error()); ! } ! // Successful creation response and die with footers. ! echo "<p>Module information has been updated, thank you. [ <a href='modules.php'>Modules</a> ]</p>"; ! die(include($footer)); ! ! } ?> <h1>Module Administrator</h1> ! <p>This utility will allow you to manage modules for certain openFIRST components. This includes enabling them, and setting them to be displayed on the menus.</p> <form method="post" action="modules.php"> ! <table> <tr> ! <th>Module Name</th> ! <th>Activate</th> ! <th>Show Menu</th> ! <th>Includes</th> </tr> ! <?php ! $query = mysql_query("SELECT * FROM ofirst_config"); ! while($module = mysql_fetch_object($query)){ ! ?> ! <tr> <td><input name="<?php echo $module->modulename; ?>-modulename" type="text" id="modulename" value="<?php echo $module->modulename; ?>"></td> <td><input name="<?php echo $module->modulename; ?>-active" type="checkbox" id="active" value="checkbox" <?php if((bool) $module->active == true){ echo "checked"; } ?>></td> *************** *** 82,95 **** <td><input name="<?php echo $module->modulename; ?>-includes" type="text" id="includes" value="<?php echo $module->includes; ?>" size="30"></td> </tr> ! <?php } ?> </table> - <br /> <input type="submit" name="update" value="Update Values" /> </form> ! <?php } else { ! showlogin(); ! } ! ! ! include($footer); ?> --- 80,93 ---- <td><input name="<?php echo $module->modulename; ?>-includes" type="text" id="includes" value="<?php echo $module->includes; ?>" size="30"></td> </tr> ! <?php ! } ! ?> </table> <input type="submit" name="update" value="Update Values" /> </form> ! <?php ! } else { ! showlogin(); ! } ! include($footer); ?> \ No newline at end of file |