[Openfirst-cvscommit] config auth.php,NONE,1.1 first.php,NONE,1.1 globals-default.php,NONE,1.1 index
Brought to you by:
xtimg
Update of /cvsroot/openfirst/config In directory sc8-pr-cvs1:/tmp/cvs-serv25864 Modified Files: README.txt globals.php Added Files: auth.php first.php globals-default.php index.php install.php Log Message: Update config module to have an easy to use graphical wizard that will guide you through setup, and to include module install capabilities. --- NEW FILE: auth.php --- <?php /* * openFIRST.config - auth.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Tim Ginn <tim...@po...> * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * 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; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ if(isset($encryption) == false) { $encryption = "crypt"; } mysql_select_db($sqldatabase,$sqlconnection); // Provide functions for the various encryption types... // syntax: cryptpassword(password, encryption-type, salt); function cryptpassword ($password, $encryption = "md5", $salt="") { if ($encryption == "crc32") { return(crc32($password)); } elseif ($encryption == "sha1") { return(sha1($password)); } elseif ($encryption == "crypt") { return(crypt($password, $salt)); } else { return(md5($password)); } } function membersmenu($membertype) { echo("<p><a href='../members'>Members Home</a> <a href='../awards/manage.php'>Manage Awards</a> <a href='../members/profile.php'>Members Profiles</a> <a href='../members/updateprofile.php'>Update Profile</a> <a href='../members/skills.php'>Update Skills</a> "); if($membertype == "administrator") { echo("<a href='../members/sqlinstall.php'>Install SQL Tables</a> <a href='../members/adduser.php'>Add User</a>"); if(is_readable("../news/addnews.php") == true) { echo(" <a href='../news/addnews.php'>Add news</a>"); } } echo(" <a href='../members/logout.php'>Logout</a></p>"); return(0); } function showlogin () { echo("<form action='".$_SERVER["PHP_SELF"] . "' method='post'> Login: <input name='login' type='text' /> <br />Password: <input name='password' type='password' /> <br /><input type='submit' value='Login'> </form>"); return(0); } // Determine if the user has already logged in with this session. If // they have, set variables indicating this. If they have not, make a // note of this so that components requiring them to log in are disabled. if(isset($_SESSION['authcode'])) { $authcode = $_SESSION['authcode']; $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); } ?> --- NEW FILE: first.php --- <?php if(isset($_POST["login"])) { die("You have successfully logged in. <a href='index.php'>Access Administrative Configuration Options</a>"); } if(isset($_POST["ostype"])) { 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. * it contains the basic configuration options required to * operate the OpenFIRST web portal software. Note, that * most configuration options are now stored in the MySQL * database, in the ofirst_config table. */ \$ostype = '" . $_POST["ostype"] . "'; if (\$ostype == \"windows\") { ini_set(\"include_path\",\"../config/;.\"); } else { ini_set(\"include_path\",\"../config/:.\"); } \$title = '" . $_POST["title"] . "'; \$version = '" . $_POST["version"] . "'; \$sqlserver = '" . $_POST["sqlserver"] . "'; \$sqluser = '" . $_POST["sqluser"] . "'; \$sqlpassword = '" . $_POST["sqlpassword"] . "'; \$sqldatabase = '" . $_POST["sqldatabase"] . "'; \$sqlconnection = mysql_connect(\"\$sqlserver\",\"\$sqluser\",\"\$sqlpassword\"); \$home = '" . $_POST["home"] . "'; \$header = '" . $_POST["header"] . "'; \$footer = '" . $_POST["footer"] . "'; \$mailnotify = '" . $_POST["mailnotify"] . "'; \$mailfrom = '" . $_POST["mailfrom"] . "'; \$basepath = '" . $_POST["basepath"] . "'; session_start(); include('auth.php'); 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 wish to change the permissions on <b>globals.php</b> to prevent unwanted changes to the configuration 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(); include("$footer"); } else { include("../config/headers.php"); echo("<h1>Base Configuration Error</h1> <p>Cannot write to configuration file. Please check permissions on <b>globals.php</b> and ensure that the web user has the ability to write to this file.</p> <p>For unix, this would typically require the command: <br /> <code> chmod 655 globals.php </code></p> "); } } else { include("../config/headers.php"); ?> <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> <form action="../config/first.php" method="post"> <tr><th>Option</th><th>Value</th></tr> <tr><td>Operating System of Web Server</td><td><select name="ostype"> <option value="unix" selected="selected">UNIX</option> <option value="windows">Windows</option> </select> (UNIX includes variants, such as Linux, Mac OS X, and BeOS) </td></tr> <tr><td>Title of Software</td><td><input type="text" name="title" value="openFIRST" /></td></tr> <tr><td>Version of Software</td><td><input type="text" name="version" value="CVS" /></td></tr> <tr><td>MySQL Server Address</td><td><input type="text" name="sqlserver" value="localhost" /></td></tr> <tr><td>MySQL User Name</td><td><input type="text" name="sqluser" value="sqluser" /></td></tr> <tr><td>MySQL User Password</td><td><input type="password" name="sqlpassword" /></td></tr> <tr><td>MySQL Database Name</td><td><input type="text" name="sqldatabase" value="openfirst" /></td></tr> <tr><td>Home site (the address scripts will use for linking to your main page)</td><td> <input type="text" name="home" value="http://openfirst.sourceforge.net"></td></tr> <tr><td>Header file</td><td><input type="text" name="header" value="headers.php" /></td></tr> <tr><td>Footer file</td><td><input type="text" name="footer" value="footers.php" /></td></tr> <tr><td>Mail Notification (the e-mail address used to notify you when significant events occur)</td><td><input type="text" name="mailnotify" value="nobody@localhost"></td></tr> <tr><td>Mail From (the e-mail address that mail from the openFIRST site should appear to be from</td><td><input type="text" name="mailfrom" value="no...@op..."></td></tr> <tr><td>The base path to the OpenFIRST software</td><td><input type="text" name="basepath" value="/openfirst/"></td></tr> <tr><td></td><td><input type="submit" value="Set up OpenFIRST"></td></tr> </form> </table> <?php } include("../config/footers.php"); ?> --- NEW FILE: globals-default.php --- <?php /* * openFIRST globals.php * This is a placeholder file. It will be recreated * by first.php when you first access and configure * your OpenFIRST portal software. */ die(include("../config/first.php")); ?> --- NEW FILE: index.php --- <?php include("./globals.php"); include($header); if(isset($user->user) == true && $user->membertype == "administrator") { membersmenu($user->membertype); ?> <h1>OpenFIRST Configuration Area</h1> <p><a href="install.php">Install Component</a> - required to install several new openFIRST modules.</p> <?php } else { showlogin(); } include($footer); ?> --- NEW FILE: install.php --- <?php /* * openFIRST.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 * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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. * 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; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ include("../config/globals.php"); include($header); membersmenu($user->membertype); if($user->membertype == "administrator") { ?> <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"> <?php if(function_exists(glob)) { foreach (glob("../*/config/*.mysql") as $filename) { $sqlf = str_replace(".", "-", str_replace(".sql", "",substr(strrchr($filename, "/"), 1))); echo("<br /> <input type='checkbox' name='$sqlf'>$sqlf</input>"); if($_POST[$sqlf] == "on") { // This doesn't quite work. I'm not sure why. $sf = fopen($filename, "r"); $query = ""; while($line = fgets($sf)) { if(substr($line, 0, 2) != "--" && substr($line, 0, 1) != "#") { $query = $query . $line; } } $q = mysql_query(trim($query)); echo(" - <b>Submitted, and added.</b>"); } } } else { echo("<p>Sorry, but your version of PHP does not have the <b>glob</b> function required by this module. Please submit a bug report.</p>"); } ?> <br /><input type="submit" value="Create Tables" /> </form> <?php } else { showlogin(); } include($footer); ?> Index: README.txt =================================================================== RCS file: /cvsroot/openfirst/config/README.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README.txt 31 May 2003 00:26:19 -0000 1.2 --- README.txt 7 Jun 2003 15:26:25 -0000 1.3 *************** *** 1,16 **** openFIRST.config ! ======================== This module allows the configuration of all modules and of the appearance of the openFIRST software. Configuration ! =========== ! - Tables Used ! ========== ! - openFIRST.config is distributed under the GNU GPL. For more information, see --- 1,19 ---- openFIRST.config ! ================ This module allows the configuration of all modules and of the appearance of the openFIRST software. Configuration ! ============= ! Access an openFIRST page without having changed globals.php and a configuration ! wizard will pop up. Tables Used ! =========== ! ofirst_config ! ofirst_members ! openFIRST.config is distributed under the GNU GPL. For more information, see Index: globals.php =================================================================== RCS file: /cvsroot/openfirst/config/globals.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** globals.php 6 Jun 2003 21:34:27 -0000 1.10 --- globals.php 7 Jun 2003 15:26:25 -0000 1.11 *************** *** 2,107 **** /* * openFIRST globals.php ! * ! * Copyright (C) 2003, ! * openFIRST Project ! * Original Author: Tim Ginn <tim...@po...> ! * ! * 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; either version 2 of the License, or ! * (at your option) any later version. ! * ! * 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. ! * 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; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! * ! */ ! ! // OS Type, uncomment the line ! // appropriate to the Operating System ! // of your web server. Either Windows ! // or UNIX (includes Linux, FreeBSD, etc.). ! ! // $ostype = "windows"; ! // $ostype = "unix"; ! ! if (ISSET($ostype)){ ! if ($ostype == "windows") { ! ini_set("include_path","../config/;."); ! } else { ! ini_set("include_path","../config/:."); ! } ! }else{ ! die("<center>Configuration error. OS Type is not specified. Please edit ! the <a href='http://openfirst.sourceforge.net'>openFIRST</a> ! configuration file <b>globals.php</b> to fix this error.</center>"); ! } ! ! $title = "openFIRST"; // Title of software ! $version = "CVS"; // Version of software ! $sqlserver = "localhost"; // Change this to the MySQL Server Address ! $sqluser = "sqluser"; // Change this to the MySQL Server User ! $sqlpassword = "sqlpassword"; //Change this to the MySQL Server Password ! $sqldatabase = "sqldatabase"; //Change this to the MySQL Database ! $home = "http://openfirst.sourceforge.net"; // The address scripts will use for ! // linking to your main page. PLEASE NOTE: do not place ! // a slash after the link. You will get broken links if you do. ! $header = "headers.php"; // Change this to the location of a file ! // containing the headers for your pages. ! $footer = "footers.php"; // Change this to the location of a file ! // containing the footers for your pages. ! $mailnotify = "nobody@localhost"; // Change this to the e-mail ! // address that should be ! // notified when significant ! // events occur. ! $mailfrom = "no...@op...";// Change this to the e-mail ! // address that mail should be ! // directed from. ! $domain = "openfirst.sourceforge.net"; // Change this to the domain that ! // scripts will refer people to. ! ! $sqlconnection = mysql_connect("$sqlserver","$sqluser","$sqlpassword"); // Connect to the ! // SQL database ! ! session_start(); ! ! //MODULE ACTIVATION - To activate any ! // of these modules simply extract them into the appropriate ! // directory. If they require SQL tables to set up, then ! // place double slashes infront of their repective include() ! // line, and set them up in the members area by logging in as ! // an administrator and selecting SQL Tables Install, then ! // remove the double slashes. ! ! if(file_exists("../logger/logger.php") == true) { ! include("../logger/logger.php"); ! } ! ! if(file_exists("../messenger/messenger.php") == true) { ! include("../messenger/messenger.php"); ! } ! ! if(file_exists("../emoticon/emoticonf.php") == true) { ! include("../emoticon/emoticonf.php"); ! } ! ! if(file_exists("../members/auth.php") == true) { ! // Set the type of encryption to use for members passwords. ! ! $encryption = "crypt"; // You should probably leave this ! // available values are: ! // md5, sha1, crypt, crc32 ! include("../members/auth.php"); ! } ! ! session_write_close(); ?> --- 2,9 ---- /* * openFIRST globals.php ! * This is a placeholder file. It will be recreated ! * by first.php when you first access and configure ! * your OpenFIRST portal software. ! */ ! die(include("../config/first.php")); ?> |