openfirst-cvscommit Mailing List for openFIRST (Page 10)
Brought to you by:
xtimg
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(41) |
Jun
(210) |
Jul
(39) |
Aug
(153) |
Sep
(147) |
Oct
(173) |
Nov
(81) |
Dec
(163) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(33) |
Feb
(18) |
Mar
|
Apr
(62) |
May
|
Jun
(100) |
Jul
(38) |
Aug
(58) |
Sep
(1) |
Oct
|
Nov
(25) |
Dec
(172) |
2005 |
Jan
(31) |
Feb
(12) |
Mar
(67) |
Apr
(92) |
May
(247) |
Jun
(34) |
Jul
(36) |
Aug
(192) |
Sep
(15) |
Oct
(42) |
Nov
(92) |
Dec
(4) |
2006 |
Jan
|
Feb
(21) |
Mar
|
Apr
|
May
|
Jun
(53) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
(4) |
Apr
(4) |
May
|
Jun
(15) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Jamie <ast...@us...> - 2005-10-16 22:48:28
|
Update of /cvsroot/openfirst/base/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11453/config Modified Files: index.php install.php modules.php version.php Log Message: - use new User methods - sorta updated for module system (install.php, modules.php, & version.php still need updates) Index: install.php =================================================================== RCS file: /cvsroot/openfirst/base/config/install.php,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** install.php 23 Aug 2005 18:01:20 -0000 1.26 --- install.php 16 Oct 2005 22:48:15 -0000 1.27 *************** *** 1,118 **** ! <?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 ! * 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 ! * ! */ ! // Purpose: set up OpenFIRST modules ! ! include("../includes/globals.php"); ! include($Header); ! ! ini_set("max_execution_time", 600); // Bypass problem of timeouts when many modules are installed ! // 10 minutes should be sufficient, even for remote database servers ! ! if(isset($user->user) == true && $user->membertype == "administrator") { ! ?> ! ! <h1>Module Installer</h1> ! <p>This utility will create the tables required for certain openFIRST components ! to run.<br /> ! Select the modules you would like to install.<br /> ! <br /> ! <span style="color:red;">Once installed, modules must be enabled from the <a href="modules.php"><strong>Module ! Administrator</strong></a>.</span></p> ! ! <p class="error">The file <tt class="file">config/install.php</tt> needs to be updated for the new ! Module system.</p> ! ! <form method="post" action="install.php"> ! <table id="moduleInstall"> ! <colgroup> ! <col /> ! <col /> ! <col class="file" /> ! </colgroup> ! <colgroup> ! <col /> ! </colgroup> ! <thead> ! <tr><th colspan="3">Module Name</th><th>Status</th></tr> ! </thead> ! <tbody> ! <?php ! ! $InstalledModules = $ogModuleManager->getDirs(); ! ! $Modules = array(); ! ! $files = glob("$fBasePath/*/openfirst.info.xml"); ! if (count($files) < 1) { ! ?> ! <p class="error">You have no modules to install or are misconfigured. You can go to <a href="http://www.openfirst.org/">openFIRST.org</a> ! to download them.</p> ! <?php ! include($Footer); ! die(); ! } ! ! # Get the meta data ! foreach($Modules as $code => $info) { ! $dir = "$fBasePath/$code"; ! $sqlf = "$dir/setup/setup.$DBaseType"; ! $WasInstalled = $IsInstalled = array_key_exists($code, $InstalledModules); ! $InstallFailed = false; ! if(isset($_POST[$code]) == true && $_POST[$code] == "on" && !$IsInstalled) { ! if (ofirst_dbexec_file($sqlf)) { ! $IsInstalled = true; ! } else { ! $InstallFailed = true; ! } ! } ! echo '<tr><td><input type="checkbox" name="'.htmlentities($code).'" '; ! if ($IsInstalled) echo 'checked="checked" '; ! echo '/><label for="'.htmlentities($code).'">'.htmlentities($info['name']).'</label></td> ! <td>('.htmlentities($info['ver']).')'.'</td> ! <td>'.htmlentities($code)."</td>"; ! ! if ($IsInstalled && !$WasInstalled) { ! echo('<td style="background-color: lime; color:black; font-weight:bold;">Module Installation succeeded!</td></tr>'); ! } else if ($InstallFailed) { ! echo('<td style="background-color: red; color:black; font-weight:bold;">Module Installation failed!</td></tr>'); ! } else if ($IsInstalled && $WasInstalled) { ! echo('<td style="background-color: green; color:white;">Module Installed</td></tr>'); ! } else { ! echo('<td style="background-color: gray; color:white;">Module available</td></tr>'); ! } ! } ! ?> ! </table> ! <br /><input type="submit" value="Create Tables" /> ! </form> ! ! <?php } else { ! showlogin(); ! } ! ! include($Footer); ?> --- 1,127 ---- ! <?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 ! * 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 ! * ! */ ! // Purpose: set up OpenFIRST modules ! ! include_once("../includes/globals.php"); ! $ogUser->mustBeAdmin(); ! include_once('xmlModule.php'); ! include_once($Header); ! ! ini_set("max_execution_time", 600); // Bypass problem of timeouts when many modules are installed ! // 10 minutes should be sufficient, even for remote database servers ! ! ?> ! ! <h1>Module Installer</h1> ! <p>This utility will create the tables required for certain openFIRST components ! to run.<br /> ! Select the modules you would like to install.<br /> ! <br /> ! <span style="color:red;">Once installed, modules must be enabled from the <a href="modules.php"><strong>Module ! Administrator</strong></a>.</span></p> ! ! <?php ! ! $InstalledModules = $ogModuleManager->getDirs(); ! ! $Modules = array(); ! ! $files = glob("$fBasePath/*/openfirst.info.xml"); ! if (count($files) < 1) { ! ?> ! <p class="error">You have no modules to install or are misconfigured. You can go to <a href="http://www.openfirst.org/">openFIRST.org</a> ! to download them.</p> ! <?php ! include($Footer); ! die(); ! } ! ! foreach($files as $file) { ! $mod = xmlModule::createFromFile($file); ! $Modules[$mod->getDir()] = $mod; ! } ! ! ?> ! <form method="post" action="install.php"> ! <table id="moduleInstall"> ! <colgroup> ! <col /> ! <col /> ! <col class="file" /> ! </colgroup> ! <colgroup> ! <col /> ! </colgroup> ! <thead> ! <tr><th colspan="3">Module</th><th>Status</th></tr> ! </thead> ! <tbody> ! <?php ! ! # Get the meta data ! foreach($Modules as $mod) { ! if ($mod->isBase()) { ! // Hide openfirst.base ! continue; ! } ! ! $dir = $mod->getDir(); ! ! $WasInstalled = $IsInstalled = in_array($dir, $InstalledModules); ! $InstallFailed = $UpgradeFailed = false; ! if(isset($_POST[$dir]) && $_POST[$dir] == "on" && !$IsInstalled) { ! if ($mod->install()) { ! $IsInstalled = true; ! } else { ! $InstallFailed = true; ! } ! } ! echo '<tr><td><input type="checkbox" name="'.htmlentities($dir).'" '; ! if ($IsInstalled) echo 'checked="checked" '; ! echo '/><label for="'.htmlentities($dir).'">'.htmlentities($mod->getName()).'</label></td> ! <td>('.htmlentities($mod->getVersion()).')'.'</td> ! <td>'.htmlentities($dir)."</td>"; ! ! if ($IsInstalled && !$WasInstalled) { ! echo('<td style="background-color: lime; color:black; font-weight:bold;">Module Installation succeeded!</td></tr>'); ! } else if ($InstallFailed) { ! echo('<td style="background-color: red; color:black; font-weight:bold;">Module Installation failed!</td></tr>'); ! } else if ($IsInstalled && $WasInstalled) { ! echo('<td style="background-color: green; color:white;">Module Installed</td></tr>'); ! } else { ! echo('<td style="background-color: gray; color:white;">Module available</td></tr>'); ! } ! } ! ?> ! </table> ! <br /><input type="submit" value="Install Modules" /> ! </form> ! ! <?php ! include($Footer); ! ?> \ No newline at end of file Index: version.php =================================================================== RCS file: /cvsroot/openfirst/base/config/version.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** version.php 26 May 2005 21:00:02 -0000 1.10 --- version.php 16 Oct 2005 22:48:15 -0000 1.11 *************** *** 29,36 **** include("../includes/globals.php"); include($Header); - if(isset($user->user) == true && $user->membertype == "administrator") { - // Recursive glob functionality based on original code from: // st...@to... --- 29,35 ---- include("../includes/globals.php"); + $ogUser->mustBeAdmin(); include($Header); // Recursive glob functionality based on original code from: // st...@to... *************** *** 38,42 **** function rglob($sDir, $sPattern, $nFlags = NULL) { ! $sDir = escapeshellcmd($sDir); $aFiles = glob("$sDir/$sPattern", $nFlags); --- 37,41 ---- function rglob($sDir, $sPattern, $nFlags = NULL) { ! #$sDir = escapeshellcmd($sDir); //???? $aFiles = glob("$sDir/$sPattern", $nFlags); *************** *** 68,71 **** --- 67,72 ---- <p>The version as displayed on your pages is <?php echo htmlentities("$Title $Version"); ?></p> + <p class="warning">This page is broken, and will remain so until the server-side module manager is + written</p> <table> *************** *** 75,80 **** <tbody> <?php ! foreach($Modules as $code=>$info) { ! @include('http://update.openfirst.org/versions.php?version=2&module='.urlencode($code).'&ver='.urlencode($info['ver'])); } ?> --- 76,82 ---- <tbody> <?php ! foreach($ogModuleManager->getDirs() as $dir) { ! $mod = $ogModuleManager->getModuleFromDir($dir); ! @include('http://update.openfirst.org/versions.php?version=2&module='.urlencode($mod->getDir()).'&ver='.urlencode($mod->getVersion())); } ?> *************** *** 82,88 **** </table> ! <?php } else { ! showlogin(); ! } ! ! include($Footer); ?> --- 84,88 ---- </table> ! <?php ! include($Footer); ! ?> \ No newline at end of file Index: modules.php =================================================================== RCS file: /cvsroot/openfirst/base/config/modules.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** modules.php 26 May 2005 21:00:02 -0000 1.9 --- modules.php 16 Oct 2005 22:48:15 -0000 1.10 *************** *** 29,37 **** include("../includes/globals.php"); include($Header); - // Check if user is actually an admin - if(isset($user) && $user->membertype == "administrator") { - // Check if user wishes to make updates if(isset($_POST['update'])) { --- 29,35 ---- include("../includes/globals.php"); + $ogUser->mustBeAdmin(); include($Header); // Check if user wishes to make updates if(isset($_POST['update'])) { *************** *** 54,58 **** // 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)); } --- 52,57 ---- // Successful creation response and die with footers. echo "<p>Module information has been updated, thank you. [ <a href='modules.php'>Modules</a> ]</p>"; ! include($Footer); ! die; } *************** *** 63,66 **** --- 62,76 ---- This includes enabling them, and setting them to be displayed on the menus.</p> + <?php + // Get module information and output values + $mods = $ogModuleManager->getDirs(); + // Make sure that module exists (bug #124) + if (count($mods) == 0) + { + echo "<p class='error'>Please install modules before administrating them! [ <a href='install.php'>Install Component</a> ]</p>"; + include($footer); + die; + } + ?> <form method="post" action="modules.php"> <table> *************** *** 69,90 **** <th>Activate</th> <th>Show Menu</th> - <th>Includes</th> </tr> <?php ! // Get module information and output values ! $query = ofirst_dbquery("SELECT * FROM ofirst_config"); ! // Make sure that module exists (bug #124) ! if (! isset($query)) ! { ! echo "</table>Please install modules before administrating them! [ <a href='install.php'>Install Component</a> ]"; ! die(include($footer)); ! } ! while($module = ofirst_dbfetch_object($query)){ ?> <tr> ! <td><input name="<?php echo $module->modulename; ?>-modulename" type="text" id="modulename" value="<?php echo $module->modulename; ?>"></td> ! <td bgcolor='<?php if((bool) $module->active == true){ echo "#00FF00"; }else{ echo "red"; } ?>'><input name="<?php echo $module->modulename; ?>-active" type="checkbox" id="active" value="checkbox" <?php if((bool) $module->active == true){ echo "checked"; } ?>></td> ! <td bgcolor='<?php if((bool) $module->showonmenu == true){ echo "#00FF00"; }else{ echo "red"; } ?>'><input name="<?php echo $module->modulename; ?>-showonmenu" type="checkbox" id="showonmenu" value="checkbox" <?php if((bool) $module->showonmenu == true){ echo "checked"; } ?>></td> ! <td><input name="<?php echo $module->modulename; ?>-includes" type="text" id="includes" value="<?php echo $module->includes; ?>" size="30"></td> </tr> <?php --- 79,91 ---- <th>Activate</th> <th>Show Menu</th> </tr> <?php ! foreach($mods as $dir) { ! $mod = $ogModuleManager->getModuleFromDir($dir); ?> <tr> ! <td><input name="<?php echo $mod->getDir(); ?>-modulename" type="text" id="modulename" value="<?php echo $mod->getName(); ?>"></td> ! <td bgcolor='<?php if ($mod->getActive()){ echo "#00FF00"; } else { echo "red"; } ?>'><input name="<?php echo $mod->getDir(); ?>-active" type="checkbox" id="active" value="checkbox" <?php if ($mod->getActive()) { echo "checked='checked'"; } ?>></td> ! <td bgcolor='<?php if ($mod->getShowOnMenu()) { echo "#00FF00"; } else { echo "red"; } ?>'><input name="<?php echo $mod->getDir(); ?>-showonmenu" type="checkbox" id="showonmenu" value="checkbox" <?php if($module->getShowOnMenu()) { echo "checked='checked'"; } ?>></td> </tr> <?php *************** *** 97,102 **** <?php ! } else { ! showlogin(); ! } ! include($Footer); ?> --- 98,100 ---- <?php ! include($Footer); ?> \ No newline at end of file Index: index.php =================================================================== RCS file: /cvsroot/openfirst/base/config/index.php,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** index.php 23 Aug 2005 17:59:45 -0000 1.15 --- index.php 16 Oct 2005 22:48:15 -0000 1.16 *************** *** 1,96 **** ! <?php ! /* ! * openFIRST.base - config/index.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 ! * ! */ ! // Purpose: Provide a control center for configuration activities. ! ! include("../includes/globals.php"); ! include($Header); ! if(isset($user->user) == true && $user->membertype == "administrator") { ! ?> ! <h1>openFIRST Configuration Area</h1> ! ! <table width="50%"> ! <tr> ! <th>Administrative Options</th> ! </tr> ! </table> ! ! <?php ! if(is_writable("$fBasePath/includes/sitesettings.php") && file_exists("$fBasePath/includes/first.php")) { ! echo("<p><strong>Warning</strong>: Your sitesettings.php file is writable by the web user. Also, first.php is still in existance. After you have setup the openFIRST web portal system, it is safe to remove first.php. Removing first.php prevents the accidental reset of configuration information and prevents external users from altering your configuration. For maximal security, you should also change the filesystem permissions so that sitesettings.php is not writable by the web user."); ! } elseif(is_writable("$fBasePath/includes/sitesettings.php")) { ! echo("<p><strong>Warning</strong>: Your sitesettings.php file is writable by the web user. For maximal security, you should change the filesystem permissions to correct this.</p>"); ! } ! ?> ! ! <table> ! <tr> ! <th colspan="2">Statistics</th> ! </tr> ! <tr> ! <th>Database Version</th><td> ! <?php ! // The statistics feature is loosely inspired by that of phpBB. ! echo $ogDB->getVersion(); ! ?></td> ! </tr> ! <tr> ! <th>Database Size</th><td> ! <?php ! echo $ogDB->getSize(); ! ?> ! </td> ! </tr> ! <tr><th>openFIRST Project Statistics</th><td> ! <script type='application/x-javascript' src='http://bugzilla.openfirst.org/openfirst/bugcrushers.php?style=js'></script> ! </td></tr> ! </table> ! ! <br> ! <table width="50%"> ! <tr> ! <td width="30%" valign="top"><a href="version.php">Version Check</a></td> ! <td width="70%" valign="top">Ensure that your version of the openFIRST web ! portal software and any 3rd party extensions is up to date</td> ! </tr> ! <tr> ! <td valign="top"><a href="install.php">Install Component</a></td> ! <td valign="top">Required to install several new openFIRST modules.</td> ! </tr> ! <tr> ! <td valign="top"><a href="modules.php">Module Administrator</a></td> ! <td valign="top">Required to manage openFIRST modules.</td> ! </tr> ! </table> ! <p> ! <?php ! } else { ! showlogin(); ! } ! include($Footer); ! ?> ! </p> --- 1,92 ---- ! <?php ! /* ! * openFIRST.base - config/index.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 ! * ! */ ! // Purpose: Provide a control center for configuration activities. ! ! include("../includes/globals.php"); ! $ogUser->mustBeAdmin(); ! include_once($Header); ! ! ?> ! <h1>openFIRST Configuration Area</h1> ! ! <table width="50%"> ! <tr> ! <th>Administrative Options</th> ! </tr> ! </table> ! ! <?php ! if(is_writable("$fBasePath/includes/sitesettings.php") && file_exists("$fBasePath/includes/first.php")) { ! echo("<p><strong>Warning</strong>: Your sitesettings.php file is writable by the web user. Also, first.php is still in existance. After you have setup the openFIRST web portal system, it is safe to remove first.php. Removing first.php prevents the accidental reset of configuration information and prevents external users from altering your configuration. For maximal security, you should also change the filesystem permissions so that sitesettings.php is not writable by the web user."); ! } elseif(is_writable("$fBasePath/includes/sitesettings.php")) { ! echo("<p><strong>Warning</strong>: Your sitesettings.php file is writable by the web user. For maximal security, you should change the filesystem permissions to correct this.</p>"); ! } ! ?> ! ! <table> ! <tr> ! <th colspan="2">Statistics</th> ! </tr> ! <tr> ! <th>Database Version</th><td> ! <?php ! // The statistics feature is loosely inspired by that of phpBB. ! echo $ogDB->getVersion(); ! ?></td> ! </tr> ! <tr> ! <th>Database Size</th><td> ! <?php ! echo $ogDB->getSize(); ! ?> ! </td> ! </tr> ! <tr><th>openFIRST Project Statistics</th><td> ! <script type='application/x-javascript' src='http://bugzilla.openfirst.org/openfirst/bugcrushers.php?style=js'></script> ! </td></tr> ! </table> ! ! <br> ! <table width="50%"> ! <tr> ! <td width="30%" valign="top"><a href="version.php">Version Check</a></td> ! <td width="70%" valign="top">Ensure that your version of the openFIRST web ! portal software and any 3rd party extensions is up to date</td> ! </tr> ! <tr> ! <td valign="top"><a href="install.php">Install Component</a></td> ! <td valign="top">Required to install several new openFIRST modules.</td> ! </tr> ! <tr> ! <td valign="top"><a href="modules.php">Module Administrator</a></td> ! <td valign="top">Required to manage openFIRST modules.</td> ! </tr> ! </table> ! <?php ! include($Footer); ! ?> \ No newline at end of file |
From: Jamie <ast...@us...> - 2005-10-16 22:44:21
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11002/includes Modified Files: globals.php Log Message: - use User class for auth and sessions - added new global vars: $ogServerName, $ogProto, $ogServer, $ogCookiePath, $ogCookieDomain - include User.php - added some defaults - added replacements for globals vars: $ogSQLTablePrefix, $ogDataBaseType, $ogSQLServer, $ogSQLUser, $ogSQLPassword, $ogSQLDatabase, $ogPasswordSaveEnabled, $ogEncryptionType - use BaseModule - Commented out the session matcher thing (for now). I don't really believe that it should be there. (ie, we should get a unique session cookie instead) Index: globals.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/globals.php,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** globals.php 15 Oct 2005 19:21:01 -0000 1.15 --- globals.php 16 Oct 2005 22:44:10 -0000 1.16 *************** *** 66,69 **** --- 66,99 ---- require_once('compatibility.php'); + /** URL of the server. It will be automaticly build including https mode */ + $ogServer = ''; + + if( isset( $_SERVER['SERVER_NAME'] ) ) { + $ogServerName = $_SERVER['SERVER_NAME']; + } elseif( isset( $_SERVER['HOSTNAME'] ) ) { + $ogServerName = $_SERVER['HOSTNAME']; + } elseif( isset( $_SERVER['HTTP_HOST'] ) ) { + $ogServerName = $_SERVER['HTTP_HOST']; + } elseif( isset( $_SERVER['SERVER_ADDR'] ) ) { + $ogServerName = $_SERVER['SERVER_ADDR']; + } else { + $ogServerName = 'localhost'; + } + + # check if server use https: + $ogProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; + + $ogServer = $ogProto.'://' . $ogServerName; + # If the port is a non-standard one, add it to the URL + if( isset( $_SERVER['SERVER_PORT'] ) + && ( ( $ogProto == 'http' && $_SERVER['SERVER_PORT'] != 80 ) + || ( $ogProto == 'https' && $_SERVER['SERVER_PORT'] != 443 ) ) ) { + + $ogServer .= ":" . $_SERVER['SERVER_PORT']; + } + + $ogCookiePath = '/'; + $ogCookieDomain = ''; + set_include_path( get_include_path().PATH_SEPARATOR."$configdir/".PATH_SEPARATOR."."); unset($configdir); *************** *** 73,76 **** --- 103,107 ---- require_once('dbase.php'); require_once('auth.php'); + require_once('User.php'); } if (!defined('OPENFIRST_INSTALLATION_SCRIPT')) { *************** *** 85,100 **** $DBaseType = dbMYSQL; $sqlServer = $sqlUser = $sqlPassword = false; if (!defined('OPENFIRST_INSTALLATION_SCRIPT')) require_once('sitesettings.php'); if (!defined('OPENFIRST_NO_INSTALLATION')) { ! $ogDB = ofCreateDataBase($DBaseType, $sqlServer, $sqlUser, $sqlPassword); ! $ogDB->selectDB($sqlDatabase, $sqlTablePrefix); } ! if (!defined('OPENFIRST_INSTALLATION_SCRIPT')) ! InitUser(); // Determine what module the user is viewing --- 116,153 ---- $DBaseType = dbMYSQL; $sqlServer = $sqlUser = $sqlPassword = false; + $sqlDatabase = 'openfirst'; + $pass_save_disabled = false; + $ogPasswordSaveEnabled = true; + $ogEncryptionType = $encryption = eCRYPT; if (!defined('OPENFIRST_INSTALLATION_SCRIPT')) require_once('sitesettings.php'); + $ogSQLTablePrefix = $sqlTablePrefix; + $ogDataBaseType = $DBaseType; + $ogSQLServer = $sqlServer; + $ogSQLUser = $sqlUser; + $ogSQLPassword = $sqlPassword; + $ogSQLDatabase = $sqlDatabase; + + $ogPasswordSaveEnabled = !$pass_save_disabled; + $ogEncryptionType = $encryption; + if (!defined('OPENFIRST_NO_INSTALLATION')) { ! $ogDB = ofCreateDataBase($ogDataBaseType, $ogSQLServer, $ogSQLUser, $ogSQLPassword); ! $ogDB->selectDB($ogSQLDatabase, $ogSQLTablePrefix); } ! if (!defined('OPENFIRST_INSTALLATION_SCRIPT')) { ! User::SetupSession(); ! /* ofDebugVar($_SESSION); ! ofDebugVar($_COOKIE);*/ ! if (User::canLogIn()) { ! $ogUser = User::logIn(); ! } else { ! $ogUser = User::loadFromSession(); ! } ! } // Determine what module the user is viewing *************** *** 114,118 **** $headers = ''; ! $ogCurrentModule = null; if (!defined('OPENFIRST_INSTALLATION_SCRIPT')) { --- 167,171 ---- $headers = ''; ! $ogCurrentModule = new BaseModule; if (!defined('OPENFIRST_INSTALLATION_SCRIPT')) { *************** *** 147,155 **** ! if (!preg_match('/\A[a-zA-Z0-9]+\z/',session_id())) { session_regenerate_id(); ! } session_write_close(); } ! ?> --- 200,211 ---- ! /* if (!preg_match('/\A[a-zA-Z0-9]+\z/',session_id())) { session_regenerate_id(); ! }*/ + $ogUser->saveData(); + /* ofDebugVar($_SESSION); + ofDebugVar($_COOKIE);*/ session_write_close(); } ! ?> \ No newline at end of file |
From: Jamie <ast...@us...> - 2005-10-16 22:39:35
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10077/includes Modified Files: auth.php Added Files: User.php Log Message: - Created User class (whoooo!!!) - Added $ogUser ($user is no longer defined) - changed function names to ofCryptPassword() and ofShowLogin() - Moved session handling, etc. to User class - Added encryption constants Index: auth.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/auth.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** auth.php 24 Aug 2005 02:31:17 -0000 1.5 --- auth.php 16 Oct 2005 22:39:26 -0000 1.6 *************** *** 1,202 **** ! <?php ! /* ! * openFIRST.base - 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 ! * ! */ ! // Purpose: Deal with authorization of users. ! /** ! * @TODO Change $user to $ogUser ! * @TODO Create User class ! * @TODO Generalize sessioning & authentication and move into classes. ! */ ! ! require_once('dbase.php'); ! ! if(isset($encryption) == false) { $encryption = "crypt"; } ! ! // Provide functions for the various encryption types... ! // syntax: cryptpassword(password, encryption-type, salt); ! ! function cryptpassword ($password, $enctype = false, $salt="") { ! global $encryption; ! if ($enctype === false) $enctype = $encryption; ! ! // Encrypt passwords using whatever algorithm is preferred. ! if ($enctype == "crc32") { ! return(crc32($password)); ! } else if ($enctype == "sha1") { ! return(sha1($password)); ! } else if ($enctype == "crypt") { ! return(crypt($password, $salt)); ! } else { ! return(md5($password)); ! } ! } ! ! function logout(){ ! global $ogDB; ! if(isset($GLOBALS["user"]->user)) { ! #FIXME: Bad SQL Handling ! $q = $ogDB->query("UPDATE ofirst_members SET authcode = NULL WHERE user='".$GLOBALS["user"]->user."';"); ! } ! } ! ! function showlogin () { ! ! // Show a login form for the user. ! echo("<br /><br />"); ! ! if (isset($_POST["login"]) && !isset($user)) { ! echo '<div class="error">Invalid username or password!</div>'; ! } ! ! echo "<form action='". $_SERVER["PHP_SELF"] . "' method='post'>"; ! if(isset($_SERVER["HTTP_REFERER"])){ ! echo("<input name='referer' type='hidden' value='".$_SERVER["HTTP_REFERER"]."'/>"); ! } ! echo "<table width='200' class='center' id='login'> ! <caption>Account Login</caption> ! <tr> ! <td><div align='right'>Username:</div></td> ! <td><input name='login' type='text' /> ! </td> ! </tr> ! <tr> ! <td><div align='right'>Password:</div></td> ! <td> <input name='password' type='password' /></td> ! </tr> ! <tr> ! <td colspan='2'><input type=\"submit\" value=\"Login\" />"; ! global $pass_save_disabled; ! if(!(isset($pass_save_disabled) && $pass_save_disabled)){ ! echo " <br /><input type=checkbox name=savepass id=savepass value=1 checked /><label for=savepass>Save Password</label>"; ! } ! global $BasePath; ! echo "</td></tr> ! <tr><td colspan='2'><a href=\"".htmlentities($BasePath)."/members/forgotten.php\">Forgot Password</a></td></tr> ! </table>"; ! ! // Include anything else in the post, so it is forwarded to the actual form ! unset($_POST['login'], $_POST['password']); ! foreach($_POST as $name => $value) { ! echo '<input type="hidden" name="'.htmlentities($name).'" value="'.htmlentities($value).'" />'; ! } ! echo "</form><br /><br />"; ! return(0); ! } ! ! ! function InitUser() { ! global $pass_save_disabled, $encryption, $user, $ogDB; ! // 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'])) || ! (isset($_COOKIE["openFIRSTlogin"]) && !$pass_save_disabled) ! ) { ! ! if (isset($_SESSION['authcode'])) { ! $authcode = $_SESSION['authcode']; ! } else if (isset($_COOKIE["openFIRSTlogin"]) && $_COOKIE["openFIRSTlogin"] != 0) { ! $authcode = $_COOKIE["openFIRSTlogin"]; ! $_SESSION['authcode'] = $authcode; ! //renew cookie ! setcookie("openFIRSTlogin", $authcode, time()+2592000, "/"); ! } else { ! $authcode = 0; ! } ! ! #FIXME: Bad SQL handling ! $query = $ogDB->query("SELECT * FROM ofirst_members WHERE authcode='$authcode';"); ! if ($ogDB->errorNumber() == 0 && $ogDB->numberOfRows($query) == 1 && $authcode != 0 ) { ! $user = $ogDB->fetchObject($query); ! } else { ! unset($_SESSION['authcode']); ! if(!isset($pass_save_disabled)){ ! //delete cookie ! setcookie("openFIRSTlogin"," ",time()-3600,"/"); ! } ! if (isset($_POST["login"])){ ! #FIXME: Bad SQL handling ! $query = $ogDB->query("SELECT * FROM ofirst_members WHERE user='" . $_POST["login"] . "';"); ! if ($ogDB->errorNumber() == 0) { ! $user = $ogDB->fetchObject($query); ! if ($ogDB->numberOfRows($query) == 1) { ! if (cryptpassword($_POST["password"], false, $user->password) == $user->password) { ! session_register("authcode"); ! mt_srand(microtime() * 1000000); ! $_SESSION["authcode"] = (microtime()|mt_rand(1,mt_getrandmax())).substr(gethostbyaddr($_SERVER["REMOTE_ADDR"]),0,40); ! #FIXME: Bad SQL handling ! $aquery = $ogDB->query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); ! } else { ! unset($user); ! } ! } ! } ! } ! } ! } elseif (isset($_POST["login"]) && isset($_POST["password"])) { ! ! #FIXME: Bad SQL handling ! $query = $ogDB->query("SELECT * FROM ofirst_members WHERE user='{$_POST['login']}';"); ! if ($ogDB->errorNumber() == 0) { ! $user = $ogDB->fetchObject($query); ! if ($ogDB->numberOfRows($query) == 1) { ! if (cryptpassword($_POST["password"], $encryption, $user->password) == $user->password) { ! session_register("authcode"); ! mt_srand(microtime() * 1000000); ! $_SESSION["authcode"] = (microtime()|mt_rand(1,mt_getrandmax())).$_SERVER['REMOTE_ADDR']; ! #FIXME: Bad SQL handling ! $aquery = $ogDB->query("UPDATE ofirst_members SET authcode='" . $_SESSION["authcode"] . "' WHERE user='" . $_POST["login"] . "';"); ! if(!isset($pass_save_disabled)){ ! if(isset($_POST["savepass"])&&$_POST["savepass"]="1"){ ! //save authcode in a cookie ! setcookie("openFIRSTlogin",$_SESSION["authcode"],time()+2592000,"/"); ! } else { ! //delete cookie ! setcookie("openFIRSTlogin"," ",time()-3600,"/"); ! unset($_COOKIE["openFIRSTlogin"]); ! } ! } ! } else { ! # invalid password! ! unset($user); ! } ! } ! } else { ! # invalid user! ! unset($user); ! } ! } ! ! if(isset($user->user)){ ! #FIXME: Bad SQL handling ! $query = "UPDATE ofirst_members SET lastseen='" . date("h:i:s M d, Y") . "' WHERE user='$user->user';"; ! $q = $ogDB->query($query); ! unset($q); ! } ! } ! ?> --- 1,104 ---- ! <?php ! /* ! * openFIRST.base - includes/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 ! * ! */ ! // Purpose: Deal with authorization of users. ! /** ! * @TODO Generalize sessioning & authentication and move into classes. ! */ ! ! require_once('dbase.php'); ! ! define('eCRYPT', 'crypt'); ! define('eCRC32', 'crc32'); ! define('eSHA1', 'sha1'); ! define('eMD5', 'md5'); ! ! if(isset($encryption) == false) { $encryption = eCRYPT; } ! ! // Provide functions for the various encryption types... ! // syntax: ofCryptPassword(password, encryption-type, salt); ! ! function ofCryptPassword ($password, $enctype = false, $salt="") { ! global $ogEncryptionType; ! if ($enctype === false) $enctype = $ogEncryptionType; ! ! // Encrypt passwords using whatever algorithm is preferred. ! if ($enctype == "crc32") { ! return(crc32($password)); ! } else if ($enctype == "sha1") { ! return(sha1($password)); ! } else if ($enctype == "crypt") { ! return(crypt($password, $salt)); ! } else { ! return(md5($password)); ! } ! } ! ! // Move to skin. ! function ofShowLogin ($target=false) { ! if ($target == false) $target = $_SERVER["PHP_SELF"]; ! // Show a login form for the user. ! echo("<br /><br />"); ! ! if (isset($_POST["login"]) && !isset($user)) { ! echo '<div class="error">Invalid username or password!</div>'; ! } ! ! echo "<form action='". htmlentities($target) . "' method='post'>"; ! if(isset($_SERVER["HTTP_REFERER"])){ ! echo("<input name='referer' type='hidden' value='".$_SERVER["HTTP_REFERER"]."'/>"); ! } ! echo "<table width='200' class='center' id='login'> ! <caption>Account Login</caption> ! <tr> ! <td><div align='right'><label for='login'>Username:</label></div></td> ! <td><input name='login' type='text' /> ! </td> ! </tr> ! <tr> ! <td><div align='right'><label for='password'>Password:</label></div></td> ! <td><input name='password' type='password' /></td> ! </tr> ! <tr> ! <td colspan='2'><input type=\"submit\" value=\"Login\" />"; ! global $ogPasswordSaveEnabled; ! if($ogPasswordSaveEnabled){ ! echo " <br /><input type='checkbox' name='savepass' id='savepass' value='1' checked='checked' /><label for='savepass'>Save Password</label>"; ! } ! global $BasePath; ! echo "</td></tr> ! <tr><td colspan='2'><a href=\"".htmlentities($BasePath)."/members/forgotten.php\">Forgot Password</a></td></tr> ! </table>"; // FIXME: Reference to module in base ! ! // Include anything else in the post, so it is forwarded to the actual form ! unset($_POST['login'], $_POST['password']); ! foreach($_POST as $name => $value) { ! echo '<input type="hidden" name="'.htmlentities($name).'" value="'.htmlentities($value).'" />'; ! } ! echo "</form><br /><br />"; ! } ! ?> \ No newline at end of file --- NEW FILE: User.php --- <?php /* * openFIRST.base - includes/User.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Jamie Bliss <ast...@gm...> * * 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 * */ // Purpose: Define the User class require_once('dbase.php'); # Serialized record version, increment when User is not backwards-compatible define( 'OF_USER_VERSION', 1 ); define('utNONE', ''); // Not logged in define('utNORMAL', 'user'); // Normal user define('utADMIN', 'administrator'); // Administrator class User { /**#@+ * @access private */ var $mName; var $mPassword; var $mGroups; // From members.membertype var $mDataLoaded; var $mDirty; var $mFirstName; var $mLastName; var $mLastSeen; var $mIP; var $mAuthCode; var $mDivision; var $mYear; var $mScreenNames; var $mDesc; var $mSig; var $mRegDate; var $mPic; var $mTeam; var $mSkills; var $mVersion; // serialized version var $mType; function User($name=false) { header('X-openFIRST-User: called('.$name.')'); $this->loadDefaults(); $this->mVersion = OF_USER_VERSION; if ($name !== false) { $this->mName = $name; } } /** * Set properties to default * Used at construction. */ function loadDefaults() { $this->mName = ''; $this->mEmail = ''; $this->mFirstName = $this->mLastName = ''; $this->mPassword = ''; $this->mAuthCode = 0; $this->mGroups = array(); $this->mIP = $_SERVER['REMOTE_ADDR']; $this->mDivision = $this->mYear = 0; $this->mScreenNames = array(); $this->mDesc = $this->mSig = ''; $this->mTeam = 0; $this->mSkills = array(); $this->mType = utNONE; $this->mDataLoaded = false; $this->mDirty = false; $this->mLastSeen = time(); } /** * Static factory method * @param string $name Username, validated by Title:newFromText() * @return User * @static */ function &newFromName( $name ) { return new User($name); } /** * Serialze sleep function, for better cache efficiency and avoidance of * silly "incomplete type" errors when skins are cached */ function __sleep() { return array( 'mName', 'mPassword', 'mGroups', 'mDataLoaded', 'mFirstName', 'mLastName', 'mLastSeen', 'mIP', 'mAuthCode', 'mType', 'mDivision', 'mYear', 'mScreenNames', 'mDesc', 'mSig', 'mRegDate', 'mPic', 'mTeam', 'mSkills', 'mVersion' ); } /** Whether or not this is a logged-in user. */ function isLoggedIn() { $val = $this->mType != utNONE; header('X-openFIRST-logged-in: '.($val ? 'yes' : 'no')); return $val; } function isAdmin() { return $this->mType == utADMIN; } function mustBeAdmin() { header('X-openFIRST-user-type: '.$this->mType); if (!$this->isAdmin()) { global $Header, $Footer; include_once($Header); ofShowLogin(); include($Footer); die; } } /** * does the string match roughly an email address ? * * From MediaWiki v1.5 * * @todo Check for RFC 2822 compilance * * @param string $addr email address * @static * @return bool */ /*static*/ function isValidEmailAddr ( $addr ) { return ( trim( $addr ) != '' ) && (false !== strpos( $addr, '@' ) ); } /** * probably return a random password * @return string probably a random password * @static * @todo Check what is doing really [AV] */ /*static*/ function randomPassword() { $pwchars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz'; $l = strlen( $pwchars ) - 1; $np = $pwchars{mt_rand( 0, $l )} . $pwchars{mt_rand( 0, $l )} . $pwchars{mt_rand( 0, $l )} . $pwchars{mt_rand( 0, $l )} . $pwchars{mt_rand( 0, $l )} . $pwchars{mt_rand( 0, $l )} . $pwchars{mt_rand( 0, $l )}; return $np; } /** * Initialise php session * From MediaWiki v1.5 */ function SetupSession() { global $ogCookiePath, $ogCookieDomain; if( 'files' != ini_get( 'session.save_handler' ) ) { # If it's left on 'user' or another setting from another # application, it will end up failing. Try to recover. ini_set ( 'session.save_handler', 'files' ); } // session_set_cookie_params( 0, $ogCookiePath, $ogCookieDomain ); session_cache_limiter( 'private, must-revalidate' ); @session_start(); } /** * Read datas from session * @todo Add unique prefix to avoid cookie collisions. * @static */ /*static*/ function &loadFromSession() { global $ogPasswordSaveEnabled, $ogEncryptionType, $ogDB; global $ogCookiePath, $ogCookieDomain; // 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. $user = new User; // If stored in session or has explicit cookie (and password saving's OK) if ( isset($_SESSION['authcode']) || ( isset($_COOKIE["openFIRSTlogin"]) && $ogPasswordSaveEnabled ) ) { if (isset($_SESSION['authcode'])) { $authcode = $_SESSION['authcode']; } else if ( $ogPasswordSaveEnabled && isset($_COOKIE["openFIRSTlogin"]) && $_COOKIE["openFIRSTlogin"] != 0 ) { $authcode = $_COOKIE["openFIRSTlogin"]; $_SESSION['authcode'] = $authcode; //renew cookie setcookie("openFIRSTlogin", $authcode, time()+2592000, $ogCookiePath, $ogCookieDomain); } else { $authcode = 0; } #$user = new User; if ($user->loadFromDatabaseByAuthcode($authcode) && $user->isLoggedIn()) { // Yeah! Logged in, happy, etc. } else { $user = new User; unset($_SESSION['authcode']); if(!$ogPasswordSaveEnabled){ //delete cookie setcookie("openFIRSTlogin",0,time()-3600, $ogCookiePath, $ogCookieDomain); unset($_COOKIE["openFIRSTlogin"]); } } } else { // Not logged in #$user = new User; #$user->loadFromDatabaseByAuthCode(); } $user->updateLastSeen(); return $user; } /** Initializes a session based on POST info. * Also a User constructor. * @static * @return User The user that just logged in. */ /*static*/ function &logIn() { header('X-openFIRST-logging-in: yes'); global $ogPasswordSaveEnabled, $ogEncryptionType, $ogDB; global $ogCookiePath, $ogCookieDomain; if (User::canLogIn()) { $user = new User; if ($user->loadFromDatabaseByName($_POST['login'])) { if (ofCryptPassword($_POST['password'], $ogEncryptionType, $user->mPassword) == $user->mPassword) { session_register('authcode'); // Seed the Mersenne Twister, done automactically since PHP v4.2.0 #mt_srand(microtime() * 1000000); // Generate auth code $user->mAuthCode = $_SESSION['authcode'] = ( microtime() | mt_rand(1, mt_getrandmax()) ) . $_SERVER['REMOTE_ADDR']; // update the authcode $ogDB->update( 'members', array( 'authcode' => $user->mAuthCode ), array( 'user' => $user->mName ) ); // if we save the password, do that, too if ( $ogPasswordSaveEnabled && isset($_POST["savepass"]) && ofConvert2Bool($_POST['savepass']) ) { //save authcode in a cookie setcookie("openFIRSTlogin", $user->mAuthCode, time()+2592000, $ogCookiePath, $ogCookieDomain); } else { //delete cookie setcookie("openFIRSTlogin", 0, time()-3600, $ogCookiePath, $ogCookieDomain); unset($_COOKIE["openFIRSTlogin"]); } } else { // Invalid password $user = new User; } } else { // Invalid user $user = new User; } } else { // Didn't actually POST... $user = new User; } $user->updateLastSeen(); return $user; } /** Checks to make sure there is actually a POST to login from. */ /*static*/ function canLogIn() { $val = isset($_POST['login']) && isset($_POST['password']); header('X-openFIRST-can-log-in: '.$val?'yes':'no'); return $val; } /** * Load a user from the database based on user name */ function loadFromDatabaseByName($name=false) { if ( $this->mDataLoaded ) { return true; } if ($name !== false) $this->mName = $name; /** Anonymous user */ if ( !$this->mName ) { /** Get rights */ $this->mType = utNONE; $this->mDataLoaded = true; return true; } # the following stuff is for users only global $ogDB; $r = $ogDB->select( 'members', '*', array( 'user' => $this->mName ) ); if ($ogDB->errorNumber() != 0) { return false; // Error } if ($ogDB->numberOfRows($r) > 1) { return false; // Invalid user name } $s = $ogDB->fetchObject($r); $ogDB->freeResult($r); if ( $s !== false ) { $this->mPassword = $s->password; $this->mType = $s->membertype; //TODO: get real groups $this->mGroups = array( $s->membertype ); $this->mFirstName = $s->firstname; $this->mLastName = $s->lastname; $this->mIP = $s->ip; $this->mAuthCode = $s->authcode; $this->mLastSeen = $s->lastseen; $this->mDivision = $s->division; $this->mYear = $s->year; $this->mDesc = $s->description; $this->mSig = $s->signature; $this->mRegDate = $s->dateregistered; $this->mPic = $s->picturelocation; $this->mTeam = $s->team; // Using ofDecodeQuery() breaks backwords compatibility but simplifies things. $this->mSkills = ofDecodeQuery($s->skills); // TODO: Make this a single field. $this->mScreenNames = array(); $this->mScreenNames['email'] = $s->email; $this->mScreenNames['icq'] = $s->icq; $this->mScreenNames['aim'] = $s->aim; $this->mScreenNames['msn'] = $s->msn; $this->mScreenNames['yim'] = $s->yim; $this->mDataLoaded = true; $this->mDirty = false; return true; } else { return false; } } /** * Load a user from the database based on authcode */ function loadFromDatabaseByAuthCode($code=false) { if ( $this->mDataLoaded ) { #echo "User::loadFromDatabaseByAuthCode(): Already loaded\n"; return true; } if ($code !== false) $this->mAuthCode = $code; /** Anonymous user */ if( !isset($this->mAuthCode) || $this->mAuthCode == 0) { $this->mType = utNONE; $this->mDataLoaded = true; #echo "User::loadFromDatabaseByAuthCode(): Not logged in.\n"; return true; } // the following stuff is for users only global $ogDB; $r = $ogDB->select( 'members', '*', array( 'authcode' => $this->mAuthCode ) ); $s = $ogDB->fetchObject($r); $ogDB->freeResult($r); if ( $s !== false ) { $this->mName = $s->user; $this->mPassword = $s->password; $this->mType = $s->membertype; //TODO: get real groups $this->mGroups = array( $s->membertype ); $this->mFirstName = $s->firstname; $this->mLastName = $s->lastname; $this->mIP = $s->ip; $this->mLastSeen = $s->lastseen; $this->mDivision = $s->division; $this->mYear = $s->year; $this->mDesc = $s->description; $this->mSig = $s->signature; $this->mRegDate = $s->dateregistered; $this->mPic = $s->picturelocation; $this->mTeam = $s->team; // Using ofDecodeQuery() breaks backwords compatibility but simplifies things. $this->mSkills = ofDecodeQuery($s->skills); // TODO: Make this a single field. $this->mScreenNames = array(); $this->mScreenNames['email'] = $s->email; $this->mScreenNames['icq'] = $s->icq; $this->mScreenNames['aim'] = $s->aim; $this->mScreenNames['msn'] = $s->msn; $this->mScreenNames['yim'] = $s->yim; } $this->mDataLoaded = true; $this->mDirty = false; return true; } /** Saves all the data back to DB. * Doesn't save password, ip, and authcode */ function saveData() { if ($this->mDirty && $this->isLoggedIn()) { global $ogDB; $ogDB->update( 'members', array( 'membertype' => $this->mGroups[0], #FIXME 'firstname' => $this->mFirstName, 'lastname' => $this->mLastName, 'division' => $this->mDivision, 'year' => $this->mYear, 'description' => $this->mDesc, 'signature' => $this->mSig, 'dateregistered' => $this->mRegDate, 'picturelocation' => $this->mPic, 'team' => $this->mTeam, 'skills' => ofEncodeQuery($this->mSkills), 'email' => $this->mScreenNames['email'], #FIXME 'icq' => $this->mScreenNames['icq'], #FIXME 'aim' => $this->mScreenNames['aim'], #FIXME 'msn' => $this->mScreenNames['msn'], #FIXME 'yim' => $this->mScreenNames['yim'], #FIXME //'lastseen' => $this->mLastSeen ), array( 'user' => $this->mName ) ); } $this->mDirty = false; } function inGroup($group) { return in_array($group, $this->mGroups); } function getAllGroups() { return $this->mGroups; } /** Will eventually add this user to a group. * Can't do that yet because of DB restrictions. */ function addGroup($group) { #Can't have multiple groups!!! //trigger_error("User can't have more than 1 group (yet)!", E_USER_ERROR); //kludge $this->mGroups = array($group); $this->mDirty = true; return $this->mGroups[] = $group; $this->mDirty = true; } function removeGroup($group) { // Cheap kludge until DB schema fixed. $this->mGroups = array( 'user' ); return; $key = array_search($this->mGroups, $group); if ($key === false) { return; } unset($this->mGroups[$key]); $this->mDirty = true; } function setGroups($groups) { #Can't have multiple groups!!! if (count($groups) > 1) { trigger_error("User can't have more than 1 group (yet)!", E_USER_ERROR); } $this->mGroups = $groups; $this->mDirty = true; } function lastSeen() { return $this->mLastSeen; } function getFirstName() { return $this->mFirstName; } function setFirstName($value) { $this->mFirstName = $value; $this->mDirty = true; } function getLastName() { return $this->mLastName; } function setLastName($value) { $this->mLastName = $value; $this->mDirty = true; } function getDivision() { return $this->mDivision; } function setDivision($value) { $this->mDivision = $value; $this->mDirty = true; } function getYear() { return $this->mYear; } function setYear($value) { $this->mYear = intval($value); $this->mDirty = true; } function getDescription() { return $this->mDesc; } function setDescription($value) { $this->mDesc = $value; $this->mDirty = true; } function getSignature() { return $this->mSig; } function setSignature($value) { $this->mSig = $value; $this->mDirty = true; } function getDateRegistered() { return $this->mRegDate; } function setDateRegistered($value) { $this->mRegDate = $value; $this->mDirty = true; } function getPictureLocation() { return $this->mPic; } function setPictureLocation($value) { $this->mPic = $value; $this->mDirty = true; } function getTeam() { return $this->mTeam; } function setTeam($value) { $this->mTeam = intval($value); $this->mDirty = true; } function hasScreenName($medium) { return in_array($medium, $this->mScreenNames) && $this->mScreenNames[$mediums] != ''; } function getScreenName($medium) { if (!$this->hasScreenName($medium)) { return false; } return $this->mScreenNames[$medium]; } function setScreenName($medium, $sn) { $this->mScreenNames[$medium] = $sn; } function deleteScreenName($medium) { # KLUDGE $this->mScreenNames[$medium] = ''; return; unset($this->mScreenNames[$medium]); } function listScreenNameMediums() { return array_keys($this->mScreenNames); } function hasSkill($skill) { return isset($this->mSkills[$skill]) && $this->mSkills[$skill]; } function getSkill($skill) { if (!$this->hasSkill($skill)) { return false; } return $this->mSkills[$skill]; } function setSkill($skill, $val) { $this->mSkills[$skill] = $val; } function deleteSkill($skill) { unset($this->mSkills[$skill]); } function logOut() { if($this->isLoggedIn()) { global $ogDB; $ogDB->update( 'members', array( 'authcode' => NULL ), array( 'user' => $this->mName ) ); } } function updateLastSeen() { if ( !$this->isLoggedIn() ) return; global $ogDB; $this->mLastSeen = date("h:i:s M d, Y"); $ogDB->update( 'members', array( 'lastseen' => $this->mLastSeen ), array( 'user' => $this->mName ) ); // Don't set $this->mDirty because we saved the changes. } function &getSettingsObject($module=false) { return new UserSettings($module,$this); } } ?> |
From: Jamie <ast...@us...> - 2005-10-16 22:22:57
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6949/includes Modified Files: dbase.php Log Message: - Added support for '*' in DataBase::quoateField() - Added DataBase::makeSelectOptions(), so LIMIT can be used Index: dbase.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/dbase.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dbase.php 16 Oct 2005 19:32:40 -0000 1.10 --- dbase.php 16 Oct 2005 22:22:49 -0000 1.11 *************** *** 195,199 **** function quoteField($name, $delimiter = ',') { ! return $this->quoteName($name, $delimiter); } --- 195,203 ---- function quoteField($name, $delimiter = ',') { ! if ($name == '*') { ! return '*'; ! } else { ! return $this->quoteName($name, $delimiter); ! } } *************** *** 227,233 **** } /** SELECT wrapper. * Copied from MediaWiki. ! * $options does nothing, currently. */ function select( $table, $vars, $conds='', $options = array() ) --- 231,278 ---- } + /** + * Returns an optional USE INDEX clause to go after the table, and a + * string to go at the end of the query + * + * From MediaWiki v1.5 + * + * @access private + * + * @param array $options an associative array of options to be turned into + * an SQL query, valid keys are listed in the function. + * @return array + */ + /*private*/ function makeSelectOptions( $options ) { + $tailOpts = ''; + + if ( isset( $options['GROUP BY'] ) ) { + $tailOpts .= " GROUP BY {$options['GROUP BY']}"; + } + if ( isset( $options['ORDER BY'] ) ) { + $tailOpts .= " ORDER BY {$options['ORDER BY']}"; + } + if ( isset( $options['LIMIT'] ) ) { + $tailOpts .= " LIMIT {$options['LIMIT']}"; + } + + if ( is_numeric( array_search( 'FOR UPDATE', $options ) ) ) { + $tailOpts .= ' FOR UPDATE'; + } + + if ( is_numeric( array_search( 'LOCK IN SHARE MODE', $options ) ) ) { + $tailOpts .= ' LOCK IN SHARE MODE'; + } + + /* if ( isset( $options['USE INDEX'] ) ) { + $useIndex = $this->useIndexClause( $options['USE INDEX'] ); + } else*/ { + $useIndex = ''; + } + return array( $useIndex, $tailOpts ); + } + /** SELECT wrapper. * Copied from MediaWiki. ! * $options is feed to DataBase::makeSelectOptions() */ function select( $table, $vars, $conds='', $options = array() ) *************** *** 242,247 **** } ! #list( $useIndex, $tailOpts ) = $this->makeSelectOptions( (array)$options ); ! $useIndex = $tailOpts = ''; $cols = $this->quoteField($vars); --- 287,291 ---- } ! list( $useIndex, $tailOpts ) = $this->makeSelectOptions( (array)$options ); $cols = $this->quoteField($vars); |
From: Jamie <ast...@us...> - 2005-10-16 22:21:23
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6493/includes Modified Files: functions.php Log Message: Added ofDebugVar() Index: functions.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/functions.php,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** functions.php 15 Oct 2005 21:51:37 -0000 1.10 --- functions.php 16 Oct 2005 22:21:15 -0000 1.11 *************** *** 179,181 **** --- 179,190 ---- return implode('&', $rtn); } + + function ofDebugVar($var) { + ob_start(); + var_dump($var); + $text = ob_get_clean(); + echo '<pre>'; + echo htmlentities($text); + echo "</pre>\n"; + } ?> \ No newline at end of file |
From: Jamie <ast...@us...> - 2005-10-16 22:20:50
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6320/includes Modified Files: Module.php xmlModule.php Added Files: BaseModule.php Log Message: - Added BaseModule for openfirst.base - Uses SQL wrapper methods - Added Module::isBase() - Added xmlModule::install(), xmlModule::upgrade(), and xmlModule::uninstall() (still need implementing). Index: xmlModule.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/xmlModule.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** xmlModule.php 12 Sep 2005 01:37:51 -0000 1.6 --- xmlModule.php 16 Oct 2005 22:20:39 -0000 1.7 *************** *** 183,186 **** --- 183,209 ---- /*** PUBLIC FUNCTIONS ***/ + /** + * @todo Write. + */ + /*public*/ function install() { + # + return false; + } + + /** + * @todo Write. + */ + /*public*/ function upgrade() { + # + return false; + } + + /** + * @todo Write. + */ + /*public*/ function unintstall() { + # + return false; + } /*** PRIVATE FUNCTIONS ***/ Index: Module.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/Module.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Module.php 15 Oct 2005 19:39:53 -0000 1.9 --- Module.php 16 Oct 2005 22:20:39 -0000 1.10 *************** *** 40,44 **** /*private*/ var $ids, $dirs, $modules; ! /** Returns the ID of the module in the dir */ /*public*/ function getIDFromDir($dir) { --- 40,45 ---- /*private*/ var $ids, $dirs, $modules; ! /** Returns the ID of the module in the dir. ! * @return mixed The ID of the given dir, or false if it isn't installed. */ /*public*/ function getIDFromDir($dir) { *************** *** 46,57 **** #$dir = strtolower($dir); //Should I do this? if (!isset($this->dirs[$dir])) { ! $sql = 'SELECT '.$ogDB->quoteField('modulename'). ! ' FROM '.$ogDB->quoteTable('config'). ! ' WHERE '.$ogDB->quoteFDPairs(array('dir'=>$dir), ' AND '). ! ' LIMIT 0,1'; ! $res = $ogDB->query($sql); ! $row = $ogDB->fetchObject($res); ! $ogDB->freeResult($res); ! $this->dirs[$dir] = $row->modulename; } return $this->dirs[$dir]; --- 47,58 ---- #$dir = strtolower($dir); //Should I do this? if (!isset($this->dirs[$dir])) { ! $res = $ogDB->select('config', 'modulename', array('dir'=>$dir), array('LIMIT' => '0,1')); ! if ($ogDB->numberOfRows($res) > 1) { ! $row = $ogDB->fetchObject($res); ! $ogDB->freeResult($res); ! $this->dirs[$dir] = $row->modulename; ! } else { ! $this->dirs[$dir] = false; ! } } return $this->dirs[$dir]; *************** *** 61,71 **** global $ogDB; if (!isset($this->ids[$ID])) { ! $sql = 'SELECT '.$ogDB->quoteField('dir'). ! ' FROM '.$ogDB->quoteTable('config'). ! ' WHERE '.$ogDB->quoteFDPairs(array('modulename'=>$ID), ' AND '); ! $res = $ogDB->query($sql); $this->ids[$ID] = array(); ! while ($row = $ogDB->fetchObject($res)) { ! $this->ids[$ID][] = $row->dir; } $ogDB->freeResult($res); --- 62,71 ---- global $ogDB; if (!isset($this->ids[$ID])) { ! $res = $ogDB->select('config', 'dir', array('modulename'=>$ID)); $this->ids[$ID] = array(); ! if ($ogDB->numberOfRows($res) > 1) { ! while ($row = $ogDB->fetchObject($res)) { ! $this->ids[$ID][] = $row->dir; ! } } $ogDB->freeResult($res); *************** *** 85,88 **** --- 85,89 ---- $dir = $mod->getDir(); $id = $mod->getID(); + if (!isset($this->ids[$id])) $this->ids[$id] = array(); $this->ids[$id][] = $dir; $this->dirs[$dir] = $id; *************** *** 94,97 **** --- 95,99 ---- $dir = $mod->getDir(); $id = $mod->getID(); + if (!isset($this->ids[$id])) $this->ids[$id] = array(); $this->ids[$id][] = $dir; $this->dirs[$dir] = $id; *************** *** 133,137 **** } $this->mNavBar = ofReplaceVariables($mod->modulenavigation, $this->getDir()); ! $this->mAdminBar = ofReplaceVariables($mod->adminnavigation.' <a href="http://bugzilla.openfirst.org/">Report Bug</a>', $this->getDir()); $this->mShow = $mod->showonmenu; $this->mActive = $mod->active; --- 135,139 ---- } $this->mNavBar = ofReplaceVariables($mod->modulenavigation, $this->getDir()); ! $this->mAdminBar = ofReplaceVariables($mod->adminnavigation.' | <a href="http://bugzilla.openfirst.org/">Report Bug</a>', $this->getDir()); $this->mShow = $mod->showonmenu; $this->mActive = $mod->active; *************** *** 154,157 **** --- 156,163 ---- /*** PUBLIC PROPERTIES ***/ + /*public*/ function isBase() { + return $this->mID == 'openfirst.base'; + } + /*public*/ function getName() { return $this->mName; *************** *** 222,224 **** */ } ! ?> --- 228,232 ---- */ } ! ! require_once('BaseModule.php'); ! ?> \ No newline at end of file --- NEW FILE: BaseModule.php --- <?php /* * openFIRST.base - includes/BaseModule.php * * Copyright (C) 2005, * openFIRST Project * Original Author: Jamie Bliss <ja...@op...> * * 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. * * 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 * */ // Purpose: Defines the BaseModule class, which extends Module for openfirst.base // and serves as a default for $ogCurrentModule. require_once('Module.php'); class BaseModule extends Module { function BaseModule($dir=false) { $this->mName = 'openFIRST'; $this->mID = 'openfirst.base'; $this->mDir = '/config'; $this->mVersion = 'CVS'; $this->mDate = time(); // Definitive date please? $this->mAuthor = 'The openFIRST Team'; $this->mMaintainer = 'The openFIRST Team'; $this->mIncludes = array(); $this->mNavBar = false; $this->mAdminBar = ofReplaceVariables('<a href="$BasePath/config/index.php">Configuration</a> | <a href="$BasePath/config/version.php">Version Check</a> | <a href="$BasePath/config/install.php">Install Module</a> | <a href="$BasePath/config/modules.php">Module Admin</a> | <a href="http://bugzilla.openfirst.org/">Report Bug</a>', $this->getDir()); $this->mShow = false; $this->mActive = true; } /*static*/ function createFromDir($Dir) { return new BaseModule($Dir); } } ?> |
From: Jamie <ast...@us...> - 2005-10-16 19:35:41
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6416/includes Modified Files: settings.php Log Message: Added SiteSettings::del() and UserSettings::del() Index: settings.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/settings.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** settings.php 15 Oct 2005 21:51:37 -0000 1.2 --- settings.php 16 Oct 2005 19:35:30 -0000 1.3 *************** *** 51,81 **** function get($name, $default=null) { - $modname = $this->mod; global $ogDB; $res = $ogDB->select( 'sitesettings', 'ss_value', ! array( 'ss_module' => $modname, ! 'ss_setting' => $name) ); ! $row = $ogDB->fetchObject($res); ! ! if (isset($row->ss_value)) ! return unserialize($row->ss_value); ! else return $default; } function set($name, $value) { - $modname = $this->mod; global $ogDB; $res = $ogDB->replace( 'sitesettings', ! array( 'ss_module' => $modname, 'ss_setting' => $name, ! 'ss_value' => serialize($value) ) ); } ! /* function del($name) { ! # ! }*/ } --- 51,91 ---- function get($name, $default=null) { global $ogDB; $res = $ogDB->select( 'sitesettings', 'ss_value', ! array( 'ss_module' => $this->mod, ! 'ss_setting' => $name ! ) ); ! if ($ogDB->numberOfRows($res) >= 1) { ! $row = $ogDB->fetchObject($res); ! ! if (isset($row->ss_value)) { ! return unserialize($row->ss_value); ! } else { ! return $default; ! } ! } else { return $default; + } } function set($name, $value) { global $ogDB; $res = $ogDB->replace( 'sitesettings', ! array( 'ss_module' => $this->mod, 'ss_setting' => $name, ! 'ss_value' => serialize($value) ! ) ); } ! function del($name) { ! global $ogDB; ! $ogDB->delete( 'sitesettings', ! array( 'ss_module' => $this->mod, ! 'ss_setting' => $name ! ) ! ); ! } } *************** *** 98,104 **** if ($user == false) { ! $this->user = $GLOBALS['user']->user; } else if (is_object($user)) { ! $this->user = $user->user; } else { $this->user = $user; --- 108,115 ---- if ($user == false) { ! global $ogUser; ! $this->user = $ogUser->getuserName(); } else if (is_object($user)) { ! $this->user = $user->getuserName(); } else { $this->user = $user; *************** *** 107,141 **** function get($name, $default=null) { - $modname = $this->mod; - $username = $this->user; global $ogDB; $res = $ogDB->select( 'usersettings', 'us_value', ! array( 'us_user' => $username, ! 'us_module' => $modname, ! 'us_setting' => $name) ); ! $row = $ogDB->fetchObject($res); ! ! if (isset($row->ss_value)) ! return unserialize($row->ss_value); ! else return $default; } function set($name, $value) { - $modname = $this->mod; - $username = $this->user; global $ogDB; $ogDB->replace( 'usersettings', ! array( 'us_user' => $username, ! 'us_module' => $modname, 'us_setting' => $name, ! 'us_value' => serialize($value) ) ! ); } ! /* function del($name) { ! # ! }*/ } --- 118,161 ---- function get($name, $default=null) { global $ogDB; $res = $ogDB->select( 'usersettings', 'us_value', ! array( 'us_user' => $this->user, ! 'us_module' => $this->mod, ! 'us_setting' => $name ! ) ); ! if ($ogDB->numberOfRows($res) >= 1) { ! $row = $ogDB->fetchObject($res); ! ! if (isset($row->us_value)) { ! return unserialize($row->us_value); ! } else { ! return $default; ! } ! } else { return $default; + } } function set($name, $value) { global $ogDB; $ogDB->replace( 'usersettings', ! array( 'us_user' => $this->user, ! 'us_module' => $this->mod, 'us_setting' => $name, ! 'us_value' => serialize($value) ! ) ! ); } ! function del($name) { ! global $ogDB; ! $ogDB->delete( 'usersettings', ! array( 'us_user' => $this->user, ! 'us_module' => $this->mod, ! 'us_setting' => $name ! ) ! ); ! } } |
From: Jamie <ast...@us...> - 2005-10-16 19:32:54
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5619/includes Modified Files: dbase.php Log Message: Added DataBase::delete(), and some comments for another method Index: dbase.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/dbase.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dbase.php 15 Oct 2005 19:21:01 -0000 1.9 --- dbase.php 16 Oct 2005 19:32:40 -0000 1.10 *************** *** 264,268 **** * @param array $values An array of values to SET * @param array $conds An array of conditions (WHERE) ! * @param array $options Nothing (was an array of UPDATE options, can be one or * more of IGNORE, LOW_PRIORITY) */ --- 264,268 ---- * @param array $values An array of values to SET * @param array $conds An array of conditions (WHERE) ! * @param array $options Nothing (was: an array of UPDATE options, can be one or * more of IGNORE, LOW_PRIORITY) */ *************** *** 291,294 **** --- 291,312 ---- return $this->query( $sql ); } + + /** + * DELETE query wrapper + * + * Use $conds == "*" to delete all rows + */ + function delete( $table, $conds ) { + if ( !$conds ) { + //ofDebugDieBacktrace( 'Database::delete() called with no conditions' ); + trigger_error(E_USER_ERROR, 'DataBase::delete() called with no conditions'); + } + $table = $this->quoteTable( $table ); + $sql = "DELETE FROM $table"; + if ( $conds != '*' ) { + $sql .= ' WHERE ' . $this->quoteFDPairs( $conds ); + } + return $this->query( $sql ); + } } ?> \ No newline at end of file |
From: Jamie <ast...@us...> - 2005-10-15 21:51:45
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22982/includes Modified Files: functions.php settings.php Log Message: Added comments Index: functions.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/functions.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** functions.php 15 Oct 2005 21:48:22 -0000 1.9 --- functions.php 15 Oct 2005 21:51:37 -0000 1.10 *************** *** 150,153 **** --- 150,154 ---- /** Returns an associative array based on the given URL query. + * @todo Add arrays */ function ofDecodeQuery($query) { *************** *** 165,168 **** --- 166,170 ---- /** Reverse of ofDecodeQuery() + * @todo Add arrays */ function ofEncodeQuery($vars) { Index: settings.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/settings.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** settings.php 24 Aug 2005 02:34:43 -0000 1.1 --- settings.php 15 Oct 2005 21:51:37 -0000 1.2 *************** *** 1,137 **** ! <?php ! /* ! * openFIRST.base - includes/settings.php ! * ! * Copyright (C) 2003, ! * openFIRST Project ! * Original Author: Jamie Bliss <ja...@op...> ! * ! * 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 ! * ! */ ! ! // Purpose: Define functions for modules to load and save settings ! ! /** Handles storing, retrieving, and deleting per-module, site-wide settings. ! */ ! class SiteSettings { ! /*private*/ var $mod; ! ! function SiteSettings($module=false) { ! if ($module == false) { ! global $ogCurrentModule; ! $this->mod = $ogCurrentModule->getDir(); ! } else if (is_object($module) && is_a($module, Module)) { ! $this->mod = $module->getDir(); ! } else { ! $this->mod = $module; ! } ! } ! ! function get($name, $default=null) { ! $modname = $this->mod; ! global $ogDB; ! $res = $ogDB->select( 'sitesettings', 'ss_value', ! array( 'ss_module' => $modname, ! 'ss_setting' => $name) ! ); ! $row = $ogDB->fetchObject($res); ! ! if (isset($row->ss_value)) ! return unserialize($row->ss_value); ! else ! return $default; ! } ! ! function set($name, $value) { ! $modname = $this->mod; ! global $ogDB; ! $res = $ogDB->replace( 'sitesettings', ! array( 'ss_module' => $modname, ! 'ss_setting' => $name, ! 'ss_value' => serialize($value) ) ! ); ! } ! ! /* function del($name) { ! # ! }*/ ! } ! ! //User settings ! /** Handles storing, retrieving, and deleting per-module, site-wide settings. ! */ ! class UserSettings { ! /*private*/ var $mod, $user; ! ! function UserSettings($module=false,$user=false) { ! if ($module == false) { ! global $ogCurrentModule; ! $this->mod = $ogCurrentModule->getDir(); ! } else if (is_object($module) && is_a($module, Module)) { ! global $ogModuleManager; ! $this->mod = $module->getDir(); ! } else { ! $this->mod = $module; ! } ! ! if ($user == false) { ! $this->user = $GLOBALS['user']->user; ! } else if (is_object($user)) { ! $this->user = $user->user; ! } else { ! $this->user = $user; ! } ! } ! ! function get($name, $default=null) { ! $modname = $this->mod; ! $username = $this->user; ! global $ogDB; ! $res = $ogDB->select( 'usersettings', 'us_value', ! array( 'us_user' => $username, ! 'us_module' => $modname, ! 'us_setting' => $name) ! ); ! $row = $ogDB->fetchObject($res); ! ! if (isset($row->ss_value)) ! return unserialize($row->ss_value); ! else ! return $default; ! } ! ! function set($name, $value) { ! $modname = $this->mod; ! $username = $this->user; ! global $ogDB; ! $ogDB->replace( 'usersettings', ! array( 'us_user' => $username, ! 'us_module' => $modname, ! 'us_setting' => $name, ! 'us_value' => serialize($value) ) ! ); ! } ! ! /* function del($name) { ! # ! }*/ ! } ! ?> \ No newline at end of file --- 1,142 ---- ! <?php ! /* ! * openFIRST.base - includes/settings.php ! * ! * Copyright (C) 2003, ! * openFIRST Project ! * Original Author: Jamie Bliss <ja...@op...> ! * ! * 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 ! * ! */ ! ! // Purpose: Define functions for modules to load and save settings ! ! /* ! We use a single row for every setting so that we don't have to parse ! a big huge string to get settings. ! */ ! ! /** Handles storing, retrieving, and deleting per-module, site-wide settings. ! */ ! class SiteSettings { ! /*private*/ var $mod; ! ! function SiteSettings($module=false) { ! if ($module == false) { ! global $ogCurrentModule; ! $this->mod = $ogCurrentModule->getDir(); ! } else if (is_object($module) && is_a($module, Module)) { ! $this->mod = $module->getDir(); ! } else { ! $this->mod = $module; ! } ! } ! ! function get($name, $default=null) { ! $modname = $this->mod; ! global $ogDB; ! $res = $ogDB->select( 'sitesettings', 'ss_value', ! array( 'ss_module' => $modname, ! 'ss_setting' => $name) ! ); ! $row = $ogDB->fetchObject($res); ! ! if (isset($row->ss_value)) ! return unserialize($row->ss_value); ! else ! return $default; ! } ! ! function set($name, $value) { ! $modname = $this->mod; ! global $ogDB; ! $res = $ogDB->replace( 'sitesettings', ! array( 'ss_module' => $modname, ! 'ss_setting' => $name, ! 'ss_value' => serialize($value) ) ! ); ! } ! ! /* function del($name) { ! # ! }*/ ! } ! ! //User settings ! /** Handles storing, retrieving, and deleting per-module, site-wide settings. ! */ ! class UserSettings { ! /*private*/ var $mod, $user; ! ! function UserSettings($module=false,$user=false) { ! if ($module == false) { ! global $ogCurrentModule; ! $this->mod = $ogCurrentModule->getDir(); ! } else if (is_object($module) && is_a($module, Module)) { ! global $ogModuleManager; ! $this->mod = $module->getDir(); ! } else { ! $this->mod = $module; ! } ! ! if ($user == false) { ! $this->user = $GLOBALS['user']->user; ! } else if (is_object($user)) { ! $this->user = $user->user; ! } else { ! $this->user = $user; ! } ! } ! ! function get($name, $default=null) { ! $modname = $this->mod; ! $username = $this->user; ! global $ogDB; ! $res = $ogDB->select( 'usersettings', 'us_value', ! array( 'us_user' => $username, ! 'us_module' => $modname, ! 'us_setting' => $name) ! ); ! $row = $ogDB->fetchObject($res); ! ! if (isset($row->ss_value)) ! return unserialize($row->ss_value); ! else ! return $default; ! } ! ! function set($name, $value) { ! $modname = $this->mod; ! $username = $this->user; ! global $ogDB; ! $ogDB->replace( 'usersettings', ! array( 'us_user' => $username, ! 'us_module' => $modname, ! 'us_setting' => $name, ! 'us_value' => serialize($value) ) ! ); ! } ! ! /* function del($name) { ! # ! }*/ ! } ! ?> \ No newline at end of file |
From: Jamie <ast...@us...> - 2005-10-15 21:48:29
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22510/includes Modified Files: functions.php Log Message: Added ofDecodeQuery() and ofEncodeQuery() to handle foo=bar&baz=quux type strings, and converting to/from associative arrays. Index: functions.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/functions.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** functions.php 12 Sep 2005 01:36:05 -0000 1.8 --- functions.php 15 Oct 2005 21:48:22 -0000 1.9 *************** *** 148,150 **** return end(array_keys($array)); } ! ?> --- 148,179 ---- return end(array_keys($array)); } ! ! /** Returns an associative array based on the given URL query. ! */ ! function ofDecodeQuery($query) { ! $parts = explode('&', $query); ! $rtn = array(); ! foreach($parts as $part) { ! $items = explode('=', $part, 2); ! $name = rawurldecode($items[0]); ! $value = true; ! if (isset($items[1])) $value = rawurldecode($items[1]); ! $rtn[$name] = $value; ! } ! return $rtn; ! } ! ! /** Reverse of ofDecodeQuery() ! */ ! function ofEncodeQuery($vars) { ! $rtn = array(); ! foreach($vars as $name => $val) { ! $str = rawurlencode($name); ! if ($val !== true) { ! $str .= '='.rawurlencode($val); ! } ! $rtn[] = $str; ! } ! return implode('&', $rtn); ! } ! ?> \ No newline at end of file |
From: Jamie <ast...@us...> - 2005-10-15 19:40:01
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv734/includes Modified Files: Module.php Log Message: Fixed a bug where an error was generated if an ID doesn't exist. Index: Module.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/Module.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Module.php 22 Aug 2005 15:10:19 -0000 1.8 --- Module.php 15 Oct 2005 19:39:53 -0000 1.9 *************** *** 65,68 **** --- 65,69 ---- ' WHERE '.$ogDB->quoteFDPairs(array('modulename'=>$ID), ' AND '); $res = $ogDB->query($sql); + $this->ids[$ID] = array(); while ($row = $ogDB->fetchObject($res)) { $this->ids[$ID][] = $row->dir; |
From: Jamie <ast...@us...> - 2005-10-15 19:39:24
|
Update of /cvsroot/openfirst/base In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv656 Modified Files: index.php Log Message: Updated for new DB objects, still has a long way to go. Index: index.php =================================================================== RCS file: /cvsroot/openfirst/base/index.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** index.php 30 Jun 2005 03:28:26 -0000 1.18 --- index.php 15 Oct 2005 19:39:15 -0000 1.19 *************** *** 1,125 **** ! <?php ! /* ! * openFIRST.base - index.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 ! * ! */ ! ! // Purpose: provide a basic starting point for the OpenFIRST web portal. ! ! require_once("includes/globals.php"); ! include($Header); ! ! $count = 0; ! global $Modules; ! ?> ! <h1>openFIRST Web Portal</h1> ! <table> ! <tr> ! <?php ! if(isset($Headers) == false) { ! echo("You may: <a href='config/'>login to configure openFIRST options</a>."); ! } ! ! echo("<tr valign=top>"); ! echo("<th>Welcome to $Title Web Site!</th>"); ! echo("<td rowspan=3 valign=top>"); ! ! if(isset($user->user)){ ! echo("<table width=200><tr><th>Welcome</th><td class=sub>Welcome, ".ucfirst($user->user)."!</td></tr></table><br />"); ! } ! ! if(function_exists("latest_posts")) { ! echo("<table width=200><tr><th>Latest Posts in Forum</th></tr><tr><td>"); ! latest_posts(5); ! echo("</td></tr></table><br />"); ! } ! ! if (is_readable("guestbook/") && ofirst_dbnum_rows(ofirst_dbquery("SELECT * FROM ofirst_config WHERE modulename='guestbook' AND active='1';")) > 0) { ! $qu = ofirst_dbquery("SELECT guest, date FROM ofirst_guestbook ORDER BY guest LIMIT 5;"); ! if(ofirst_dbnum_rows($qu)!=0){ ! echo("<table width=200><tr><th>Guestbook</th></tr><tr><td><div>Last records in our <a href=\"$BasePath/guestbook\">guestbook</a>: </div>"); ! while($q = ofirst_dbfetch_object($qu)) { ! echo("<sub><strong><a href='/guestbook/' target='_content'>$q->guest</a></strong><br />$q->date</sub><br />"); ! } ! echo("</td></tr></table><br />"); ! } ! } ! ! #FIXME: Bad SQL handling ! if (is_readable("awards/") && $ogDB->numberOfRows($ogDB->query("SELECT * FROM ofirst_config WHERE modulename='awards' AND active='1';")) > 0) { ! $qu = ofirst_dbquery("SELECT AwardName FROM ofirst_awards;"); ! if(ofirst_dbnum_rows($qu)!=0){ ! echo("<table width=200><tr><th>Awards</th></tr><tr><td><div>Our team has received the following <a href=\"$BasePath/awards\">awards</a>: </div>"); ! while($q = ofirst_dbfetch_object($qu)) { ! echo("<sub><a href='$BasePath/awards' target='_content'>$q->AwardName</a></sub><br />"); ! } ! echo("</td></tr></table><br />"); ! } ! } ! ! # Features ! echo ' ! <table width=200> ! <tr><th>Features</th></tr> ! <tr><td><div>This portal has the following features: </div> ! '; ! echo '<ul> ! '; ! foreach($ogModuleManager->getDirs() as $dir) { ! $mod =& $ogModuleManager->getModuleFromDir($dir); ! if ($mod->getActive() ! #&& $mod->getShowOnMenu() ! ) { ! echo '<li><a href="'.htmlentities("$BasePath/$dir").'">'.htmlentities($mod->getName()).'</a></li> ! '; ! } ! } ! echo '</ul>'; ! ! echo '</td></tr></table><br />'; ! if(function_exists("get_visitors")) { ! echo("<table width=200><tr><th>Stats</th></tr><tr><td><div>Website <a href=\"$BasePath/logger/stats.php\">usage statistics</a>: </div>"); ! echo("<sub><strong>".get_totalpages()." pages served to ".get_visitors()." visitors</strong></sub>"); ! echo("</td></tr></table><br />"); ! } ! echo("</td></tr>"); ! echo("<tr><td class=sub>Welcome to the $Title portal.</td></tr>"); ! echo("<tr><td valign=top>"); ! if(function_exists("shownews")) { ! echo("<h2 style=\"margin-bottom:0px;margin-top:15px\">Latest News</h2>"); ! $admin=false; ! if (isset($user->membertype)){ ! $admin=($user->membertype == "administrator"); ! } ! shownews(5,$admin); ! //are there more news? ! if(ofirst_dbnum_rows(ofirst_dbquery("SELECT * FROM ofirst_news"))>5){ ! echo("<div class=\"right\">[ <b><a href=\"$BasePath/news/index.php?show=all\">More News</a></b> ]</div>"); ! } ! } ! echo(" </td></tr></table>"); ! ! include($Footer); ! ?> --- 1,125 ---- ! <?php ! /* ! * openFIRST.base - index.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 ! * ! */ ! ! // Purpose: provide a basic starting point for the OpenFIRST web portal. ! ! require_once("includes/globals.php"); ! include($Header); ! ! $count = 0; ! global $Modules; ! ?> ! <h1>openFIRST Web Portal</h1> ! <table> ! <tr> ! <?php ! if(isset($Headers) == false) { ! echo("You may: <a href='config/'>login to configure openFIRST options</a>."); ! } ! ! echo("<tr valign=top>"); ! echo("<th>Welcome to $Title Web Site!</th>"); ! echo("<td rowspan=3 valign=top>"); ! ! if(isset($user->user)){ ! echo("<table width=200><tr><th>Welcome</th><td class=sub>Welcome, ".ucfirst($user->user)."!</td></tr></table><br />"); ! } ! ! if(function_exists("latest_posts")) { ! echo("<table width=200><tr><th>Latest Posts in Forum</th></tr><tr><td>"); ! latest_posts(5); ! echo("</td></tr></table><br />"); ! } ! ! #FIXME: Bad SQL handling ! if ( count($ogModuleManager->getDirsFromID('openfirst.guestbook')) >= 1) { ! $qu = $ogDB->query("SELECT guest, date FROM ofirst_guestbook ORDER BY guest LIMIT 5;"); ! if($ogDB->numberOfRows($qu)!=0){ ! echo("<table width=200><tr><th>Guestbook</th></tr><tr><td><div>Last records in our <a href=\"$BasePath/guestbook\">guestbook</a>: </div>"); ! while($q = $ogDB->fetch_object($qu)) { ! echo("<sub><strong><a href='/guestbook/' target='_content'>$q->guest</a></strong><br />$q->date</sub><br />"); ! } ! echo("</td></tr></table><br />"); ! } ! } ! ! #FIXME: Bad SQL handling ! if ( count($ogModuleManager->getDirsFromID('openfirst.awards')) >= 1) { ! $qu = $ogDB->query("SELECT AwardName FROM ofirst_awards;"); ! if($ogDB->numberOfRows($qu) != 0){ ! echo("<table width=200><tr><th>Awards</th></tr><tr><td><div>Our team has received the following <a href=\"$BasePath/awards\">awards</a>: </div>"); ! while($q = $ogDB->fetchObject($qu)) { ! echo("<sub><a href='$BasePath/awards' target='_content'>$q->AwardName</a></sub><br />"); ! } ! echo("</td></tr></table><br />"); ! } ! } ! ! # Features ! echo ' ! <table width=200> ! <tr><th>Features</th></tr> ! <tr><td><div>This portal has the following features: </div> ! '; ! echo '<ul> ! '; ! foreach($ogModuleManager->getDirs() as $dir) { ! $mod =& $ogModuleManager->getModuleFromDir($dir); ! if ($mod->getActive() ! #&& $mod->getShowOnMenu() ! ) { ! echo '<li><a href="'.htmlentities("$BasePath/$dir").'">'.htmlentities($mod->getName()).'</a></li> ! '; ! } ! } ! echo '</ul>'; ! ! echo '</td></tr></table><br />'; ! if(function_exists("get_visitors")) { ! echo("<table width=200><tr><th>Stats</th></tr><tr><td><div>Website <a href=\"$BasePath/logger/stats.php\">usage statistics</a>: </div>"); ! echo("<sub><strong>".get_totalpages()." pages served to ".get_visitors()." visitors</strong></sub>"); ! echo("</td></tr></table><br />"); ! } ! echo("</td></tr>"); ! echo("<tr><td class=sub>Welcome to the $Title portal.</td></tr>"); ! echo("<tr><td valign=top>"); ! if(function_exists("shownews")) { ! echo("<h2 style=\"margin-bottom:0px;margin-top:15px\">Latest News</h2>"); ! $admin=false; ! if (isset($user->membertype)){ ! $admin=($user->membertype == "administrator"); ! } ! //are there more news? ! if ( shownews(5,$admin) ){ ! echo("<div class=\"right\">[ <b><a href=\"$BasePath/news/index.php?show=all\">More News</a></b> ]</div>"); ! } ! } ! echo(" </td></tr></table>"); ! ! include($Footer); ! ?> |
From: Jamie <ast...@us...> - 2005-10-15 19:21:11
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30346/includes Modified Files: MSSQLDataBase.php MySQLDataBase.php dbase.php globals.php Added Files: ODBCDataBase.php Log Message: True-blue OOP for DataBase - Completed move to seperate implementations - Some more functions added (eg, DataBase::factory()) - Of course default behavior/compatibility issues. Index: MSSQLDataBase.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/MSSQLDataBase.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MSSQLDataBase.php 7 Oct 2005 18:15:34 -0000 1.1 --- MSSQLDataBase.php 15 Oct 2005 19:21:01 -0000 1.2 *************** *** 29,33 **** /*private*/ var $type, $connection, $lastquery, $db; // Wrapper for database selection. ! function MSSQLDataBase($type = dbMSSQL, $server = false, $username = false, $password = false, $newlink = false, $intclientflags = false) { $this->type = dbMSSQL; global $sqlTablePrefix; --- 29,33 ---- /*private*/ var $type, $connection, $lastquery, $db; // Wrapper for database selection. ! function MSSQLDataBase($type = dbMSSQL, $server = false, $username = false, $password = false, $newlink = false, $flags = false) { $this->type = dbMSSQL; global $sqlTablePrefix; *************** *** 37,42 **** } ! function selectDB($databasename) { $this->db = $databasename; $this->checkForFunction('mssql_select_db'); return mssql_select_db($databasename, $this->connection); --- 37,54 ---- } ! /*static*/ function &factory($server = false, $username = false, $password = false, $newlink = false, $flags = false) { ! return new MSSQLDataBase(dbMSSQL, $server, $username, $password); ! } ! ! /*public*/ function getTypeName() { ! return 'Microsoft SQL'; ! } ! ! function selectDB($databasename, $prefix=false) { $this->db = $databasename; + if ($prefix !== false) { + $this->prefix = $prefix; + } + $this->checkForFunction('mssql_select_db'); return mssql_select_db($databasename, $this->connection); *************** *** 108,112 **** function freeResult($resource) { $this->checkForFunction('mssql_free_result'); ! if (!is_resource($resource)) return false; return mssql_free_result($resource); } --- 120,124 ---- function freeResult($resource) { $this->checkForFunction('mssql_free_result'); ! if (!is_resource($resource)) return true; return mssql_free_result($resource); } --- NEW FILE: ODBCDataBase.php --- <?php /* * openFIRST.base - includes/ODBCDataBase.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Jamie Bliss <ja...@op...> * * 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. * * 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 * */ // Purpose: Provide implementation of DataBase for ODBC require_once('dbase.php'); class ODBCDataBase extends DataBase { /*private*/ var $type, $connection, $lastquery, $db, $prefix; // Wrapper for database selection. function ODBCDataBase($type = dbMYSQL, $server = '', $username = '', $password = '', $newlink = false, $flags = null) { $this->type = $type; global $sqlTablePrefix; $this->prefix = $sqlTablePrefix; $this->checkForFunction('odbc_connect'); if($newlink !== false) { $this->connection = odbc_connect($server, $username, $password, $newlink); } else { $this->connection = odbc_connect($server, $username, $password); } } /*static*/ function &factory($server = false, $username = false, $password = false, $newlink = false, $flags = false) { return new MySQLDataBase(dbODBC, $server, $username, $password, $newlink); } /*public*/ function getTypeName() { return 'ODBC'; } function selectDB($databasename, $prefix=false) { $this->db = $databasename; if ($prefix !== false) { $this->prefix = $prefix; } //ODBC does not require slecting a DB } function errorNumber() { $this->checkForFunction('odbc_error'); return odbc_error($this->connection); } function errorString() { $this->checkForFunction('odbc_errormsg'); return odbc_errormsg($this->connection); } function query($string, $batchsize = false) { global $ogLastQuery; $ogLastQuery = $this->lastquery = "\$string = \"$string\", \$linkidentifier = \"{$this->connection}\", \$batchsize = \"$batchsize\""; $this->checkForFunction('odbc_exec'); return odbc_exec($this->connection, $string); } function fetchObject($resource, $rownumber = false) { $this->checkForFunction('odbc_fetch_object'); if($rownumber !== false) { return odbc_fetch_object($resource, $rownumber); } else { return odbc_fetch_object($resource); } } function numberOfRows($resource) { $this->checkForFunction('odbc_num_rows'); if (!is_resource($resource)) return -1; return odbc_num_rows($resource); } function freeResult($resource) { $this->checkForFunction('odbc_free_result'); if (!is_resource($resource)) return true; return odbc_free_result($resource); } # Check if there the connection is valid function check() { #TODO: Write me! } #Does ODBC support backticks???? /* function quoteName($name, $delimiter = ',') { if (is_array($name)) { $value = ''; foreach ($name as $text) { $value .= $this->quoteName($text).$delimiter; } $value = substr($value, 0, -strlen($delimiter)); return $value; } else { return '`'.$this->escape($name).'`'; } }*/ # Does ODBC support REPLACE???? /* function replace( $table, $unique, $values ) { $sql = "REPLACE INTO ".$this->quoteTable($table)." SET ".$this->quoteFDPairs($values); return $this->query( $sql ); }*/ } ?> Index: dbase.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/dbase.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dbase.php 7 Oct 2005 18:15:34 -0000 1.8 --- dbase.php 15 Oct 2005 19:21:01 -0000 1.9 *************** *** 29,90 **** define('dbMSSQL', 'MSSQL'); define('dbODBC', 'ODBC'); $ogLastQuery = ''; - if (!isset($DBaseType)) { $DBaseType = dbMYSQL; } class DataBase { /*private*/ var $type, $connection, $lastquery, $db, $prefix; // Wrapper for database selection. ! function DataBase($type = dbMYSQL, $server = '', $username = '', $password = '', $newlink = '', $intclientflags = '') { $this->type = $type; global $sqlTablePrefix; $this->prefix = $sqlTablePrefix; - switch ($this->type) { - case dbMYSQL: - $this->checkForFunction('mysql_connect'); - if($intclientflags != '') { - $this->connection = mysql_connect($server, $username, $password, $newlink, $intclientflags); - } elseif($newlink != '') { - $this->connection = mysql_connect($server, $username, $password, $newlink); - } else { - $this->connection = mysql_connect($server, $username, $password); - } - break; - - case dbMSSQL: - $this->checkForFunction('mssql_connect'); - $this->connection = mssql_connect($server, $username, $password); - break; - - case dbODBC: - $this->checkForFunction('odbc_connect'); - if($newlink != '') { - $this->connection = odbc_connect($server, $username, $password, $newlink); - } else { - $this->connection = odbc_connect($server, $username, $password); - } - break; - - default: - $this->badDBType(); - } } /*public*/ function getTypeName() { ! $typetext = $this->type; ! switch ($this->type) { ! case dbMYSQL: ! $typetext = 'MySQL'; ! break; ! ! case dbMSSQL: ! $typetext = 'Microsoft SQL'; ! break; ! ! case dbODBC: ! $typetext = 'ODBC'; ! break; ! } ! return $typetext; } --- 29,67 ---- define('dbMSSQL', 'MSSQL'); define('dbODBC', 'ODBC'); + define('dbUNKNOWN', '?'); $ogLastQuery = ''; + function &ofCreateDataBase($type, $server, $password, $newlink = false, $flags = false) { + $class = "{$type}DataBase"; + if (!class_exists($class)) { + // This assumption is only for DataBase implementations + require_once("{$class}.php"); + } + //$obj =& $class::factory($server, $password, $newlink, $flags); + $obj =& call_user_func(array($class, 'factory'), $server, $password, $newlink, $flags); + return $obj; + } + + /** Base class for actual implementation. + * Performs default actions and provides the interface definition. + */ class DataBase { /*private*/ var $type, $connection, $lastquery, $db, $prefix; // Wrapper for database selection. ! function DataBase($type = dbUNKNOWN, $server = '', $username = '', $password = '', $newlink = '', $flags = '') { $this->type = $type; global $sqlTablePrefix; $this->prefix = $sqlTablePrefix; } + /*static*/ function &factory($server = false, $username = false, $password = false, $newlink = false, $flags = false) { + # Override + } + + /** Returns the display name for this type of database. + */ /*public*/ function getTypeName() { ! return $this->type; } *************** *** 101,166 **** } ! function selectDB($databasename) { $this->db = $databasename; ! switch ($this->type) { ! case dbMYSQL: ! $this->checkForFunction('mysql_select_db'); ! return mysql_select_db($databasename, $this->connection); ! break; ! ! case dbMSSQL: ! $this->checkForFunction('mssql_select_db'); ! return mssql_select_db($databasename, $this->connection); ! break; ! ! case dbODBC: ! //ODBC does not require slecting a DB ! break; ! ! default: ! $this->badDBType(); } } function errorNumber() { ! switch ($this->type) { ! case dbMYSQL: ! $this->checkForFunction('mysql_errno'); ! return mysql_errno($this->connection); ! break; ! ! case dbMSSQL: ! // MSSQL doesn't have an equivelent function ! return 0; ! break; ! ! case dbODBC: ! $this->checkForFunction('odbc_error'); ! return odbc_error($this->connection); ! break; ! ! default: ! $this->badDBType(); ! } } function errorString() { ! switch ($this->type) { ! case dbMYSQL: ! $this->checkForFunction('mysql_error'); ! return mysql_error($this->connection); ! break; ! ! case dbMSSQL: ! return ''; ! break; ! ! case dbODBC: ! $this->checkForFunction('odbc_errormsg'); ! return odbc_errormsg($this->connection); ! ! default: ! $this->badDBType(); ! } } --- 78,95 ---- } ! function selectDB($databasename, $prefix=false) { $this->db = $databasename; ! if ($prefix !== false) { ! $this->prefix = $prefix; } + # Override } function errorNumber() { ! # Override } function errorString() { ! # Override } *************** *** 170,348 **** $ogLastQuery = $this->lastquery = "\$string = \"$string\", \$linkidentifier = \"{$this->connection}\", \$batchsize = \"$batchsize\""; ! switch ($this->type) { ! case dbMYSQL: ! $this->checkForFunction('mysql_query'); ! return mysql_query($string, $this->connection); ! break; ! ! case dbMSSQL: ! $this->checkForFunction('mssql_query'); ! if($batchsize !== false) { ! return mssql_query($string, $this->connection, $batchsize); ! } else { ! return mssql_query($string, $this->connection); ! } ! break; ! ! case dbODBC: ! $this->checkForFunction('odbc_exec'); ! // Note: this may be misleading, the variable names are not reflective of their content in this particular line, as the odbc function uses an order different from the other databases. ! return odbc_exec($string, $this->connection); ! ! default: ! $this->badDBType(); ! } } function fetchObject($resource, $rownumber = false) { ! switch ($this->type) { ! case dbMYSQL: ! $this->checkForFunction('mysql_fetch_object'); ! return mysql_fetch_object($resource); ! break; ! ! case dbMSSQL: ! $this->checkForFunction('mssql_fetch_object'); ! return mssql_fetch_object($resource); ! break; ! ! case dbODBC: ! $this->checkForFunction('odbc_fetch_object'); ! // Note that odbc_fetch_object() is not documented ! if($rownumber !== false) { ! return odbc_fetch_object($resource, $rownumber); ! } else { ! return odbc_fetch_object($resource); ! } ! break; ! ! default: ! $this->badDBType(); ! } } function numberOfRows($resource) { ! switch ($this->type) { ! case dbMYSQL: ! $this->checkForFunction('mysql_num_rows'); ! if (!is_resource($resource)) return -1; ! return mysql_num_rows($resource); ! break; ! ! case dbMSSQL: ! $this->checkForFunction('mssql_num_rows'); ! if (!is_resource($resource)) return -1; ! return mssql_num_rows($resource); ! break; ! ! case dbODBC: ! $this->checkForFunction('odbc_num_rows'); ! if($resource != "") { ! if (!is_resource($resource)) return -1; ! return(odbc_num_rows($resource)); ! } else { ! return(odbc_num_rows()); ! } ! break; ! ! default: ! $this->badDBType(); ! } } function freeResult($resource) { ! switch ($this->type) { ! case dbMYSQL: ! $this->checkForFunction('mysql_free_result'); ! if (!is_resource($resource)) return false; ! return mysql_free_result($resource); ! break; ! ! case dbMSSQL: ! $this->checkForFunction('mssql_free_result'); ! if (!is_resource($resource)) return false; ! return mssql_free_result($resource); ! ! case dbODBC: ! $this->checkForFunction('odbc_free_result'); ! if (!is_resource($resource)) return false; ! return odbc_free_result($resource); ! ! default: ! $this->badDBType(); ! } } function getVersion() { ! switch ($this->type) { ! case dbMYSQL: ! $res = $this->query('SELECT VERSION() AS mysql_version'); ! $v = $this->fetchObject($res); ! $this->freeResult($res); ! return $this->getTypeName().' '.$v->mysql_version; ! break; ! ! case dbMSSQL: ! $res = $this->query('SELECT @@VERSION'); ! $v = $this->fetchObject($res); ! $this->freeResult($res); ! ob_start(); ! print_r($v); ! $ver = ob_get_contents(); ! ob_end_clean(); ! return $this->getTypeName().' '.$ver.' <br /><strong>Warning:</strong> unconfirmed.'; ! break; ! ! case dbODBC: ! return $this->getTypeName(); ! break; ! ! default: ! return 'Unknown DB type: '.$this->getTypeName(); ! } } function getSize() { ! $sqlDatabase = $this->db; ! switch ($this->type) { ! case dbMYSQL: ! $dbsize = 0; ! $dq = $this->query('SHOW TABLE STATUS FROM '.$this->quoteDatabase($sqlDatabase)); ! while($d = $this->fetchObject($dq)) { ! $dbsize += $d->Data_length; ! $dbsize += $d->Index_length; ! $dbsize += $d->Data_free; //Overhead ! } ! $this->freeResult($dq); ! return ofFormatSize($dbsize); ! break; ! ! case dbMSSQL: ! $res = $this->query('SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles'); ! $s = $this->fetchObject($res); ! $this->freeResult($res); ! return ofFormatSize($s->dbsize); ! ! default: ! return 'Size not supported'; ! } } # Check if there the connection is valid function check() { ! #TODO: Write me! ! switch ($this->type) { ! case dbMYSQL: ! break; ! ! case dbMSSQL: ! break; ! ! case dbODBC: ! break; ! ! default: ! $this->badDBType(); ! } } --- 99,128 ---- $ogLastQuery = $this->lastquery = "\$string = \"$string\", \$linkidentifier = \"{$this->connection}\", \$batchsize = \"$batchsize\""; ! # Override } function fetchObject($resource, $rownumber = false) { ! # Override } function numberOfRows($resource) { ! # Override } function freeResult($resource) { ! # Override } function getVersion() { ! return 'Unknown DB type: '.$this->getTypeName(); } function getSize() { ! return 'Size not supported'; } # Check if there the connection is valid function check() { ! # Override } *************** *** 371,383 **** function escape($text) { ! switch ($this->type) { ! case dbMYSQL: ! return mysql_real_escape_string($text); ! break; ! ! # MSSQL and ODBC don't have specific escaping functions. ! default: ! return addslashes($text); ! } } --- 151,156 ---- function escape($text) { ! # Override, if able ! return addslashes($text); } *************** *** 389,392 **** --- 162,166 ---- #Used for quoting field and DB names + # Should we use something other than backticks? function quoteName($name, $delimiter = ',') { if (is_array($name)) { *************** *** 507,510 **** --- 281,286 ---- * Copied from MediaWiki (but removed the fancy stuff). * + * Should this be changed to an alternate form by default? + * * @param string $table The table to perform it on. * @param array $unique An array of unique values that distinquish a row. *************** *** 516,518 **** } } ! ?> --- 292,294 ---- } } ! ?> \ No newline at end of file Index: globals.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/globals.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** globals.php 24 Aug 2005 02:57:44 -0000 1.14 --- globals.php 15 Oct 2005 19:21:01 -0000 1.15 *************** *** 65,70 **** require_once('compatibility.php'); - if (!defined('OPENFIRST_NO_INSTALLATION')) - require_once('dbase.php'); set_include_path( get_include_path().PATH_SEPARATOR."$configdir/".PATH_SEPARATOR."."); --- 65,68 ---- *************** *** 72,77 **** require_once('functions.php'); ! if (!defined('OPENFIRST_NO_INSTALLATION')) require_once('auth.php'); if (!defined('OPENFIRST_INSTALLATION_SCRIPT')) { require_once('Module.php'); --- 70,77 ---- require_once('functions.php'); ! if (!defined('OPENFIRST_NO_INSTALLATION')) { ! require_once('dbase.php'); require_once('auth.php'); + } if (!defined('OPENFIRST_INSTALLATION_SCRIPT')) { require_once('Module.php'); *************** *** 83,86 **** --- 83,88 ---- $sqlTablePrefix = 'ofirst_'; + $DBaseType = dbMYSQL; + $sqlServer = $sqlUser = $sqlPassword = false; if (!defined('OPENFIRST_INSTALLATION_SCRIPT')) *************** *** 88,93 **** if (!defined('OPENFIRST_NO_INSTALLATION')) { ! $ogDB = new DataBase($DBaseType, $sqlServer, $sqlUser, $sqlPassword); ! $ogDB->selectDB($sqlDatabase); } --- 90,95 ---- if (!defined('OPENFIRST_NO_INSTALLATION')) { ! $ogDB = ofCreateDataBase($DBaseType, $sqlServer, $sqlUser, $sqlPassword); ! $ogDB->selectDB($sqlDatabase, $sqlTablePrefix); } Index: MySQLDataBase.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/MySQLDataBase.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MySQLDataBase.php 7 Oct 2005 18:15:34 -0000 1.1 --- MySQLDataBase.php 15 Oct 2005 19:21:01 -0000 1.2 *************** *** 29,39 **** /*private*/ var $type, $connection, $lastquery, $db, $prefix; // Wrapper for database selection. ! function MySQLDataBase($type = dbMYSQL, $server = false, $username = false, $password = false, $newlink = false, $intclientflags = false) { $this->type = dbMYSQL; global $sqlTablePrefix; $this->prefix = $sqlTablePrefix; $this->checkForFunction('mysql_connect'); ! if($intclientflags !== false) { ! $this->connection = mysql_connect($server, $username, $password, $newlink, $intclientflags); } elseif($newlink !== false) { $this->connection = mysql_connect($server, $username, $password, $newlink); --- 29,39 ---- /*private*/ var $type, $connection, $lastquery, $db, $prefix; // Wrapper for database selection. ! function MySQLDataBase($type = dbMYSQL, $server = false, $username = false, $password = false, $newlink = false, $flags = false) { $this->type = dbMYSQL; global $sqlTablePrefix; $this->prefix = $sqlTablePrefix; $this->checkForFunction('mysql_connect'); ! if($flags !== false) { ! $this->connection = mysql_connect($server, $username, $password, $newlink, $flags); } elseif($newlink !== false) { $this->connection = mysql_connect($server, $username, $password, $newlink); *************** *** 43,52 **** } ! /*static*/ function &factory($server = false, $username = false, $password = false, $newlink = false, $intclientflags = false) { ! return new MySQLDataBase(dbMYSQL, $server, $username, $password, $intclientflags); } ! function selectDB($databasename) { $this->db = $databasename; $this->checkForFunction('mysql_select_db'); return mysql_select_db($databasename, $this->connection); --- 43,60 ---- } ! /*static*/ function &factory($server = false, $username = false, $password = false, $newlink = false, $flags = false) { ! return new MySQLDataBase(dbMYSQL, $server, $username, $password, $newlink, $flags); } ! /*public*/ function getTypeName() { ! return 'MySQL'; ! } ! ! function selectDB($databasename, $prefix=false) { $this->db = $databasename; + if ($prefix !== false) { + $this->prefix = $prefix; + } + $this->checkForFunction('mysql_select_db'); return mysql_select_db($databasename, $this->connection); *************** *** 85,89 **** function freeResult($resource) { $this->checkForFunction('mysql_free_result'); ! if (!is_resource($resource)) return false; return mysql_free_result($resource); } --- 93,97 ---- function freeResult($resource) { $this->checkForFunction('mysql_free_result'); ! if (!is_resource($resource)) return true; return mysql_free_result($resource); } |
From: Tim G. <xt...@us...> - 2005-10-08 19:26:21
|
Update of /cvsroot/openfirst/www/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1063 Modified Files: downloads.php files.php news.php Log Message: Remove remnants of old database setup. Index: downloads.php =================================================================== RCS file: /cvsroot/openfirst/www/htdocs/downloads.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** downloads.php 25 May 2005 18:46:28 -0000 1.5 --- downloads.php 8 Oct 2005 19:26:13 -0000 1.6 *************** *** 18,22 **** <?php - mysql_selectdb("openfirst"); $q = mysql_query("SELECT * FROM files ORDER BY id LIMIT 5;"); --- 18,21 ---- *************** *** 95,97 **** is *not* updated with the latest system until there is an official release prepared. This process ensures that there are stable releases available while at the same time new features may be prepared and/or tested using the CVS or nightly ! build versions. <b>If you're a first time user, you probably don't want a nightly build or a version directly from CVS.</b></p> \ No newline at end of file --- 94,96 ---- is *not* updated with the latest system until there is an official release prepared. This process ensures that there are stable releases available while at the same time new features may be prepared and/or tested using the CVS or nightly ! build versions. <b>If you're a first time user, you probably don't want a nightly build or a version directly from CVS.</b></p> Index: files.php =================================================================== RCS file: /cvsroot/openfirst/www/htdocs/files.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** files.php 25 May 2005 18:49:31 -0000 1.2 --- files.php 8 Oct 2005 19:26:13 -0000 1.3 *************** *** 7,13 **** include_once("../inc/headers.php"); - mysql_selectdb("openfirst"); - - $inf = fopen("http://sourceforge.net/export/rss2_projfiles.php?group_id=78233", "r"); --- 7,10 ---- Index: news.php =================================================================== RCS file: /cvsroot/openfirst/www/htdocs/news.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** news.php 25 May 2005 18:11:18 -0000 1.2 --- news.php 8 Oct 2005 19:26:13 -0000 1.3 *************** *** 7,13 **** include_once("../inc/headers.php"); - mysql_selectdb("openfirst"); - - $inf = fopen("http://sourceforge.net/export/rss2_projnews.php?group_id=78233&rss_limit=5", "r"); --- 7,10 ---- |
From: Tim G. <xt...@us...> - 2005-10-08 19:21:45
|
Update of /cvsroot/openfirst/www/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32738 Modified Files: index.php Log Message: Remove remnant from old database settings. Index: index.php =================================================================== RCS file: /cvsroot/openfirst/www/htdocs/index.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** index.php 20 Jul 2005 23:44:26 -0000 1.8 --- index.php 8 Oct 2005 19:21:37 -0000 1.9 *************** *** 6,11 **** alt="" title=""> News & Updates</h1> <?php - mysql_selectdb("openfirst"); - $q = mysql_query("SELECT * FROM news ORDER BY id LIMIT 5;"); --- 6,9 ---- |
From: Tim G. <xt...@us...> - 2005-10-08 19:21:00
|
Update of /cvsroot/openfirst/www/inc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32575 Modified Files: headers.php Log Message: Upgrade to using Source Forge's MySQL 4 database server Index: headers.php =================================================================== RCS file: /cvsroot/openfirst/www/inc/headers.php,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** headers.php 18 Sep 2005 22:09:06 -0000 1.26 --- headers.php 8 Oct 2005 19:20:52 -0000 1.27 *************** *** 2,11 **** if($_SERVER["PHP_SELF"] != "/installer/index.php") { ! $sqlserver = 'mysql-o.sourceforge.net'; ! $sqluser = 'openfirst'; ! $sqlpassword = 'EJBi4NvnFS8'; ! $sqldatabase = 'openfirst'; $sqlconnection = mysql_connect("$sqlserver","$sqluser","$sqlpassword"); include("versions.php"); --- 2,12 ---- if($_SERVER["PHP_SELF"] != "/installer/index.php") { ! $sqlserver = 'mysql4-o.sourceforge.net'; ! $sqluser = 'o78233rw'; ! $sqlpassword = 'cXOHLIvh'; ! $sqldatabase = 'o78233_www'; $sqlconnection = mysql_connect("$sqlserver","$sqluser","$sqlpassword"); + mysql_selectdb($sqldatabase); include("versions.php"); |
From: Jamie <ast...@us...> - 2005-10-07 18:15:44
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26880/includes Modified Files: dbase.php Added Files: MSSQLDataBase.php MySQLDataBase.php Log Message: Added seperate implementations for MySQL and MSSQL. Need to integrate and clean. (Need help determining actual differences between DBMSs.) also, a few methods changed, so ported that to dbase.php. --- NEW FILE: MSSQLDataBase.php --- <?php /* * openFIRST.base - includes/MySQLDataBase.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Jamie Bliss <ja...@op...> * * 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. * * 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 * */ // Purpose: Provide implementation of DataBase for MS SQL require_once('dbase.php'); class MSSQLDataBase extends DataBase { /*private*/ var $type, $connection, $lastquery, $db; // Wrapper for database selection. function MSSQLDataBase($type = dbMSSQL, $server = false, $username = false, $password = false, $newlink = false, $intclientflags = false) { $this->type = dbMSSQL; global $sqlTablePrefix; $this->prefix = $sqlTablePrefix; $this->checkForFunction('mssql_connect'); $this->connection = mssql_connect($server, $username, $password); } function selectDB($databasename) { $this->db = $databasename; $this->checkForFunction('mssql_select_db'); return mssql_select_db($databasename, $this->connection); } function errorNumber() { // MSSQL doesn't have an equivelent function // <http://us3.php.net/manual/en/function.mssql-get-last-message.php#53572> $sql = "select @@ERROR as code"; $result = mssql_query($sql, $con); $row = mssql_fetch_array($result); $code = $row["code"]; // error code mssql_free_result($result); return $code; } function errorString() { // <http://us3.php.net/manual/en/function.mssql-get-last-message.php#53572> $sql = "select @@ERROR as code"; $result = mssql_query($sql, $con); $row = mssql_fetch_array($result); $code = $row["code"]; // error code mssql_free_result($result); $lang = 1033; //en /* Some language codes ("Locale ID"): 0 - "language neutral" 1031 - German 1033 - English See <http://msdn.microsoft.com/library/en-us/script56/html/vsmsclcid.asp> for a more complete list. */ $sql = "SELECT CAST(description AS varchar(255)) AS errtxt FROM master.dbo.sysmessages WHERE error=$code AND msglangid=$lang"; $result = mssql_query($sql, $con); $row = mssql_fetch_array($result); if ($row) { $text = $row["errtxt"]; // error text (with placeholders) } else { $text = "unknown error"; } mssql_free_result($result); return $text; } function query($string, $batchsize = false) { global $ogLastQuery; $ogLastQuery = $this->lastquery = "\$string = \"$string\", \$linkidentifier = \"{$this->connection}\", \$batchsize = \"$batchsize\""; $this->checkForFunction('mssql_query'); if($batchsize !== false) { return mssql_query($string, $this->connection, $batchsize); } else { return mssql_query($string, $this->connection); } } function fetchObject($resource, $rownumber = false) { $this->checkForFunction('mssql_fetch_object'); return mssql_fetch_object($resource); } function numberOfRows($resource) { $this->checkForFunction('mssql_num_rows'); if (!is_resource($resource)) return -1; return mssql_num_rows($resource); } function freeResult($resource) { $this->checkForFunction('mssql_free_result'); if (!is_resource($resource)) return false; return mssql_free_result($resource); } function getVersion() { $res = $this->query('SELECT @@VERSION AS version'); $v = $this->fetchObject($res); $this->freeResult($res); ob_start(); print_r($v); $ver = ob_get_contents(); ob_end_clean(); return $this->getTypeName().' '.$ver.' <br /><strong>Warning:</strong> unconfirmed.'; } function getSize() { $sqlDatabase = $this->db; $res = $this->query('SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles'); $s = $this->fetchObject($res); $this->freeResult($res); return ofFormatSize($s->dbsize); } # Check if there the connection is valid function check() { #TODO: Write me! } function escape($text) { # MSSQL doesn't have a specific escaping function. return addslashes($text); } /** SQL escaping and quoting. * These functions escape various kinds of literals. * If an array is passed, it is assumed to be a list * of things to be passed and is merged. */ #Used for quoting field and DB names # FIXME: I don't think MSSQL takes ` as a quote. function quoteName($name, $delimiter = ',') { if (is_array($name)) { $value = ''; foreach ($name as $text) { $value .= $this->quoteName($text).$delimiter; } $value = substr($value, 0, -strlen($delimiter)); return $value; } else { return '`'.$this->escape($name).'`'; } } #Used for quoting table names. Includes table prefix. function quoteTable($name, $delimiter = ',') { global $sqlTablePrefix; if (is_array($name)) { $value = ''; foreach ($name as $text) { $value .= $this->quoteTable($text).$delimiter; } $value = substr($value, 0, -strlen($delimiter)); return $value; } else { return $this->quoteName("{$this->prefix}{$name}"); } } function quoteDatabase($name, $delimiter = ',') { return $this->quoteName($name, $delimiter); } function quoteField($name, $delimiter = ',') { return $this->quoteName($name, $delimiter); } #Used for quoting data function quoteData($data, $delimiter = ',') { if (is_array($data)) { $value = ''; foreach ($data as $text) { $value .= $this->quoteData($text).$delimiter; } $value = substr($value, 0, -strlen($delimiter)); return $value; } else { return "'".$this->escape($data)."'"; } } #Used to quote field-data pairs in the form of `field`='data' #passed like: # array( 'field' => 'data' ) function quoteFDPairs($pairs, $delimiter = ',') { $value = ''; foreach ($pairs as $field => $data) { $value .= $this->quoteField($field); $value .= '='; $value .= $this->quoteData($data); $value .= $delimiter; } $value = substr($value, 0, -strlen($delimiter)); return $value; } /** SELECT wrapper. * Copied from MediaWiki. * $options does nothing, currently. */ function select( $table, $vars, $conds='', $options = array() ) { $vars = $this->quoteField( $vars ); if( is_array( $table ) ) { $from = ' FROM ' . $this->quoteTable( $table ); } elseif ($table!='') { $from = ' FROM ' . $this->quoteTable( $table ); } else { $from = ''; } #list( $useIndex, $tailOpts ) = $this->makeSelectOptions( (array)$options ); $useIndex = $tailOpts = ''; $cols = $this->quoteField($vars); if( !empty( $conds ) ) { if ( is_array( $conds ) ) { $conds = $this->quoteFDPairs( $conds, ' AND ' ); } $sql = "SELECT $cols $from $useIndex WHERE $conds $tailOpts"; } else { $sql = "SELECT $cols $from $useIndex $tailOpts"; } return $this->query( $sql ); } /** UPDATE wrapper, takes a condition array and a SET array. * Copied from MediaWiki. * * @param string $table The table to UPDATE * @param array $values An array of values to SET * @param mixed $conds An array of conditions (WHERE), or a string of them. * @param array $options Nothing (was an array of UPDATE options, can be one or * more of IGNORE, LOW_PRIORITY) */ function update( $table, $values, $conds, $options = array() ) { $table = $this->quoteTable( $table ); #$opts = $this->makeUpdateOptions( $options ); $opts = ''; $sql = "UPDATE $opts $table SET " . $this->quoteFDPairs( $values ); if ( $conds != '*' && is_array($conds) ) { $sql .= " WHERE " . $this->quoteFDPairs( $conds, ' AND ' ); } else if ( $conds != '*' ) { $sql .= " WHERE " . $conds; } return $this->query( $sql ); } /** REPLACE query wrapper. * Copied from MediaWiki (but removed the fancy stuff). * * @param string $table The table to perform it on. * @param array $unique An array of unique values that distinquish a row. * @param array $values An array of values to use in a SET clause. * * @todo Insert REPLACE substitute. */ function replace( $table, $unique, $values ) { $sql = "REPLACE INTO ".$this->quoteTable($table)." SET ".$this->quoteFDPairs($values); return $this->query( $sql ); } } ?> Index: dbase.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/dbase.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** dbase.php 24 Aug 2005 02:32:42 -0000 1.7 --- dbase.php 7 Oct 2005 18:15:34 -0000 1.8 *************** *** 26,32 **** // without having to be completely rewritten or released as two // different versions. ! define('dbMYSQL', 'mysql'); ! define('dbMSSQL', 'mssql'); ! define('dbODBC', 'odbc'); $ogLastQuery = ''; --- 26,32 ---- // without having to be completely rewritten or released as two // different versions. ! define('dbMYSQL', 'MySQL'); ! define('dbMSSQL', 'MSSQL'); ! define('dbODBC', 'ODBC'); $ogLastQuery = ''; *************** *** 34,41 **** class DataBase { ! /*private*/ var $type, $connection, $lastquery, $db; // Wrapper for database selection. ! function DataBase($type = 'mysql', $server = '', $username = '', $password = '', $newlink = '', $intclientflags = '') { $this->type = $type; switch ($this->type) { case dbMYSQL: --- 34,43 ---- class DataBase { ! /*private*/ var $type, $connection, $lastquery, $db, $prefix; // Wrapper for database selection. ! function DataBase($type = dbMYSQL, $server = '', $username = '', $password = '', $newlink = '', $intclientflags = '') { $this->type = $type; + global $sqlTablePrefix; + $this->prefix = $sqlTablePrefix; switch ($this->type) { case dbMYSQL: *************** *** 402,406 **** #Used for quoting table names. Includes table prefix. function quoteTable($name, $delimiter = ',') { - global $sqlTablePrefix; if (is_array($name)) { $value = ''; --- 404,407 ---- *************** *** 411,415 **** return $value; } else { ! return $this->quoteName("$sqlTablePrefix$name"); } } --- 412,416 ---- return $value; } else { ! return $this->quoteName("{$this->prefix}{$name}"); } } *************** *** 507,516 **** * * @param string $table The table to perform it on. * @param array $values An array of values to use in a SET clause. */ ! function replace( $table, $values ) { ! $table = $this->quoteTable( $table ); ! ! $sql = "REPLACE INTO $table SET ".$this->quoteFDPairs($values); return $this->query( $sql ); } --- 508,516 ---- * * @param string $table The table to perform it on. + * @param array $unique An array of unique values that distinquish a row. * @param array $values An array of values to use in a SET clause. */ ! function replace( $table, $unique, $values ) { ! $sql = "REPLACE INTO ".$this->quoteTable($table)." SET ".$this->quoteFDPairs($values); return $this->query( $sql ); } --- NEW FILE: MySQLDataBase.php --- <?php /* * openFIRST.base - includes/MySQLDataBase.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Jamie Bliss <ja...@op...> * * 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. * * 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 * */ // Purpose: Provide implementation of DataBase for MySQL require_once('dbase.php'); class MySQLDataBase extends DataBase { /*private*/ var $type, $connection, $lastquery, $db, $prefix; // Wrapper for database selection. function MySQLDataBase($type = dbMYSQL, $server = false, $username = false, $password = false, $newlink = false, $intclientflags = false) { $this->type = dbMYSQL; global $sqlTablePrefix; $this->prefix = $sqlTablePrefix; $this->checkForFunction('mysql_connect'); if($intclientflags !== false) { $this->connection = mysql_connect($server, $username, $password, $newlink, $intclientflags); } elseif($newlink !== false) { $this->connection = mysql_connect($server, $username, $password, $newlink); } else { $this->connection = mysql_connect($server, $username, $password); } } /*static*/ function &factory($server = false, $username = false, $password = false, $newlink = false, $intclientflags = false) { return new MySQLDataBase(dbMYSQL, $server, $username, $password, $intclientflags); } function selectDB($databasename) { $this->db = $databasename; $this->checkForFunction('mysql_select_db'); return mysql_select_db($databasename, $this->connection); } function errorNumber() { $this->checkForFunction('mysql_errno'); return mysql_errno($this->connection); } function errorString() { $this->checkForFunction('mysql_error'); return mysql_error($this->connection); } function query($string, $batchsize = false) { global $ogLastQuery; $ogLastQuery = $this->lastquery = "\$string = \"$string\", \$linkidentifier = \"{$this->connection}\", \$batchsize = \"$batchsize\""; $this->checkForFunction('mysql_query'); return mysql_query($string, $this->connection); } function fetchObject($resource, $rownumber = false) { $this->checkForFunction('mysql_fetch_object'); return mysql_fetch_object($resource); } function numberOfRows($resource) { $this->checkForFunction('mysql_num_rows'); if (!is_resource($resource)) return -1; return mysql_num_rows($resource); } function freeResult($resource) { $this->checkForFunction('mysql_free_result'); if (!is_resource($resource)) return false; return mysql_free_result($resource); } function getVersion() { $res = $this->query('SELECT VERSION() AS mysql_version'); $v = $this->fetchObject($res); $this->freeResult($res); return $this->getTypeName().' '.$v->mysql_version; } function getSize() { $sqlDatabase = $this->db; $dbsize = 0; $dq = $this->query('SHOW TABLE STATUS FROM '.$this->quoteDatabase($sqlDatabase)); while($d = $this->fetchObject($dq)) { $dbsize += $d->Data_length; $dbsize += $d->Index_length; $dbsize += $d->Data_free; //Overhead } $this->freeResult($dq); return ofFormatSize($dbsize); } # Check if there the connection is valid function check() { #TODO: Write me! } function escape($text) { return mysql_real_escape_string($text); } /** SQL escaping and quoting. * These functions escape various kinds of literals. * If an array is passed, it is assumed to be a list * of things to be passed and is merged. */ #Used for quoting field and DB names function quoteName($name, $delimiter = ',') { if (is_array($name)) { $value = ''; foreach ($name as $text) { $value .= $this->quoteName($text).$delimiter; } $value = substr($value, 0, -strlen($delimiter)); return $value; } else { return '`'.$this->escape($name).'`'; } } #Used for quoting table names. Includes table prefix. function quoteTable($name, $delimiter = ',') { if (is_array($name)) { $value = ''; foreach ($name as $text) { $value .= $this->quoteTable($text).$delimiter; } $value = substr($value, 0, -strlen($delimiter)); return $value; } else { return $this->quoteName("{$this->prefix}{$name}"); } } #Used for quoting data function quoteData($data, $delimiter = ',') { if (is_array($data)) { $value = ''; foreach ($data as $text) { $value .= $this->quoteData($text).$delimiter; } $value = substr($value, 0, -strlen($delimiter)); return $value; } else { return "'".$this->escape($data)."'"; } } #Used to quote field-data pairs in the form of `field`='data' #passed like: # array( 'field' => 'data' ) function quoteFDPairs($pairs, $delimiter = ',') { $value = ''; foreach ($pairs as $field => $data) { $value .= $this->quoteField($field); $value .= '='; $value .= $this->quoteData($data); $value .= $delimiter; } $value = substr($value, 0, -strlen($delimiter)); return $value; } /** SELECT wrapper. * Copied from MediaWiki. * $options does nothing, currently. */ function select( $table, $vars, $conds='', $options = array() ) { $vars = $this->quoteField( $vars ); if( is_array( $table ) ) { $from = ' FROM ' . $this->quoteTable( $table ); } elseif ($table!='') { $from = ' FROM ' . $this->quoteTable( $table ); } else { $from = ''; } #list( $useIndex, $tailOpts ) = $this->makeSelectOptions( (array)$options ); $useIndex = $tailOpts = ''; $cols = $this->quoteField($vars); if( !empty( $conds ) ) { if ( is_array( $conds ) ) { $conds = $this->quoteFDPairs( $conds, ' AND ' ); } $sql = "SELECT $cols $from $useIndex WHERE $conds $tailOpts"; } else { $sql = "SELECT $cols $from $useIndex $tailOpts"; } return $this->query( $sql ); } /** UPDATE wrapper, takes a condition array and a SET array. * Copied from MediaWiki. * * @param string $table The table to UPDATE * @param array $values An array of values to SET * @param array $conds An array of conditions (WHERE) * @param array $options Nothing (was an array of UPDATE options, can be one or * more of IGNORE, LOW_PRIORITY) */ function update( $table, $values, $conds, $options = array() ) { $table = $this->quoteTable( $table ); #$opts = $this->makeUpdateOptions( $options ); $opts = ''; $sql = "UPDATE $opts $table SET " . $this->quoteFDPairs( $values ); if ( $conds != '*' ) { $sql .= " WHERE " . $this->quoteFDPairs( $conds, ' AND ' ); } return $this->query( $sql ); } /** REPLACE query wrapper. * Copied from MediaWiki (but removed the fancy stuff). * * @param string $table The table to perform it on. * @param array $unique An array of unique values that distinquish a row. * @param array $values An array of values to use in a SET clause. */ function replace( $table, $unique, $values ) { $sql = "REPLACE INTO ".$this->quoteTable($table)." SET ".$this->quoteFDPairs($values); return $this->query( $sql ); } } ?> |
From: Jamie <ast...@us...> - 2005-09-18 22:09:18
|
Update of /cvsroot/openfirst/www/inc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12514/www/inc Modified Files: headers.php Log Message: Commit for Dan. Index: headers.php =================================================================== RCS file: /cvsroot/openfirst/www/inc/headers.php,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** headers.php 11 Sep 2005 05:45:23 -0000 1.25 --- headers.php 18 Sep 2005 22:09:06 -0000 1.26 *************** *** 86,90 **** </div> <div> ! <a href="http://www.usfirst.org"><img alt="USFIRST Logo" src="/oflogo.php?img=firstlogo&type=1" style="border: none;"></a> <br /> <br /> --- 86,90 ---- </div> <div> ! <a href="http://www.usfirst.org"><img alt="USFIRST Logo" src="/oflogo.php?img=firstlogo&type=1" style="border: none;" width="125" /></a> <br /> <br /> |
From: Jamie <ast...@us...> - 2005-09-12 01:43:04
|
Update of /cvsroot/openfirst/awards In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2884/awards Modified Files: openfirst.info.xml Log Message: -Added XML namespace -Fixed typo Index: openfirst.info.xml =================================================================== RCS file: /cvsroot/openfirst/awards/openfirst.info.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** openfirst.info.xml 23 Aug 2005 18:20:11 -0000 1.7 --- openfirst.info.xml 12 Sep 2005 01:42:55 -0000 1.8 *************** *** 1,4 **** <?xml version="1.0"?> ! <module id="openfirst.awards"> <!-- Info --> <!-- This is not used, except as meta data --> --- 1,4 ---- <?xml version="1.0"?> ! <module xmlns="http://openfirst.org/xml/module/1.0" id="openfirst.awards"> <!-- Info --> <!-- This is not used, except as meta data --> *************** *** 46,50 **** <table name="firstawards"> <fields><!--The longest is currently 42 chars--> ! <field name="fa_id" null="no" autoincremented="yes"><type>int</type></field> <field name="AwardName" null="no"><type>tinytext</type></field> <field name="Description"><type>text</type></field> --- 46,50 ---- <table name="firstawards"> <fields><!--The longest is currently 42 chars--> ! <field name="fa_id" null="no" autoincrement="yes"><type>int</type></field> <field name="AwardName" null="no"><type>tinytext</type></field> <field name="Description"><type>text</type></field> *************** *** 171,173 **** </table> </db> ! </module> --- 171,173 ---- </table> </db> ! </module> \ No newline at end of file |
From: Jamie <ast...@us...> - 2005-09-12 01:40:59
|
Update of /cvsroot/openfirst/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2721/modules Modified Files: index.php Added Files: extended.php Log Message: New page: extended.php (Full information on module XML) --- NEW FILE: extended.php --- <?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 * 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 * */ // Purpose: set up openFIRST modules include("../includes/globals.php"); include("xmlModule.php"); $dirs = array_keys($_GET); function mapDirs($x) { return basename(dirname($x)); } function checkDir($x) { global $files; return in_array($x, $files); } $files = glob("$fBasePath/*/openfirst.info.xml"); $files = array_map('mapDirs', $files); if (count($dirs) < 1) { $dirs = $files; } else { $dirs = array_filter($dirs, 'checkDir'); } function outputTable($table) { echo '<fieldset class="db-table">'; echo '<legend>'.htmlentities($table->getName()).'</legend>'; /*** Columns ***/ echo '<table class="table-columns"> <cpation>Columns</caption> <thead> <tr> <th>Name</th> <th colspan="2">Type</th> <th>Length</th> <th>Default</th> <th>Null</th> <th>Unsigned</th> <th>Zerofill</th> <th>AutoIncrement</th> </tr> </thead> <tbody>'; foreach($table->getCols() as $colname) { $col = $table->getCol($colname); echo '<tr>'; echo '<th><code>'.htmlentities($col->getName()).'</code></th>'; if (($values = $col->getValues()) !== false) { echo '<td><code>'.htmlentities($col->getType()).'</code></td>'; echo '<td><ul>'; foreach($values as $val) { echo '<li><code>'.htmlentities($val).'</code></li>'; } echo '</ul></td>'; } else { echo '<td colspan="2"><code>'.htmlentities($col->getType()).'</code></td>'; } echo '<td>'; if ($col->hasLength()) { echo htmlentities($col->getLength()); } echo '</td>'; echo '<td>'; if ($col->hasDefault()) { echo '<code>'.htmlentities(print_r($col->getDefault(), true)).'</code>'; } echo '</td>'; echo '<td>'; if ($col->hasNull()) { echo $col->getNull() ? 'Yes' : 'No'; } echo '</td>'; echo '<td>'; if ($col->hasUnsigned()) { echo $col->getUnsigned() ? 'Yes' : 'No'; } echo '</td>'; echo '<td>'; if ($col->hasZerofill()) { echo $col->getZerofill() ? 'Yes' : 'No'; } echo '</td>'; echo '<td>'; if ($col->hasAutoIncrement()) { echo $col->getAutoIncrement() ? 'Yes' : 'No'; } echo '</td>'; echo '</tr> '; } echo ' </tbody> </table> '; /*** Keys ***/ if (count($table->getKeys()) >= 1) { echo '<table class="table-keys"> <cpation>Keys</caption> <thead> <tr> <th rowspan="2">Name</th> <th rowspan="2">Type</th> <th colspan="3">Columns</th> </tr> <tr> <th>Name</th> <th class="not-implemented">Null</th> <th>Part</th> </tr> </thead>'; foreach($table->getKeys() as $keyname) { $key = $table->getKey($keyname); $height = max( count($key->getCols()) , 1 ); echo '<tbody> <tr> '; echo '<th rowspan="'.$height.'"><code>'.htmlentities($key->getName()).'</code></th> <td rowspan="'.$height.'"><code>'.htmlentities($key->getType()).'</code></td> '; $colrows = array(); foreach($key->getCols() as $col) { $colrows[] = '<th><code>'.htmlentities($col).'</code></th> <td></td> <td>'.( $key->getColLength($col) ? 'Yes' : 'No' ).'</td> '; } echo implode('</tr><tr>', $colrows); echo '</tr> </tbody> '; } echo '</table>'; } /*** Data ***/ if (count($rows = $table->getRows()) >= 1) { $cols = $table->getCols(); echo '<table class="table-data"> <cpation>Data</caption> <thead> <tr>'; foreach($cols as $col) { echo '<th><code>'.htmlentities($col).'</code></th>'; } echo ' </tr> </thead>'; echo '<tbody>'; foreach($rows as $row) { echo '<tr> '; foreach($cols as $col) { echo '<td>'; if ($row->hasValue($col)) { echo '<code>'.$row->getValue($col).'</code>'; } echo '</td>'; } echo '</tr> '; } echo ' </tbody> </table>'; } echo '</fieldset>'; } $ogMoreStyles = <<<ENDSTYLESHEET .base-module { border: thin solid blue; padding: 0 1em; } .not-implemented { text-decoration: line-through; } ENDSTYLESHEET; include($Header); if (count($dirs) < 1) { ?> <p class="error">You have no valid modules selected.</p> <?php include($Footer); die(); } echo '<div class="left"> '; $hbasepath = htmlentities($BasePath); foreach($dirs as $dir) { $mod = xmlModule::createFromDir($dir); if ($mod->isBase()) { #echo '<div class="base-module">'; echo '<fieldset class="base-module">'; } else { echo '<fieldset>'; } $hdir = htmlentities($mod->getDir()); echo "<legend><a title=\"Full Info\" href=\"$hbasepath/modules/extended.php?$hdir\">$hdir</a></legend>"; /* echo '<h2>'.htmlentities($mod->getDir()).'</h2>';*/ echo '<dl>'; echo '<dt>Name</dt>'; echo '<dd>'.htmlentities($mod->getName()).'</dd>'; echo '<dt>ID</dt>'; echo '<dd><tt>'.htmlentities($mod->getID()).'</tt></dd>'; echo '<dt>Version</dt>'; echo '<dd>'.htmlentities($mod->getVersion()).'</dd>'; echo '<dt>Author</dt>'; echo '<dd>'.htmlentities($mod->getAuthor()).'</dd>'; echo '<dt>Maintainer</dt>'; echo '<dd>'.htmlentities($mod->getMaintainer()).'</dd>'; $incs = $mod->getIncludes(); if (count($incs) == 1) { echo '<dt>Include</dt>'; echo '<dd><tt class="file">'.htmlentities($incs[0]).'</tt></dd>'; } else if (count($incs) > 1) { echo '<dt>Includes</dt>'; echo '<dd><ul>'; foreach($incs as $inc) { echo '<li><tt class="file">'.htmlentities($inc).'</tt></li>'; } echo '</ul></dd>'; } if ($mod->getNavBar() != '') { echo '<dt>Navigation bar</dt>'; echo '<dd><pre>'.htmlentities($mod->getNavBar()).'</pre></dd>'; } if ($mod->getAdminBar() != '') { echo '<dt>Admin bar</dt>'; echo '<dd><pre>'.htmlentities($mod->getAdminBar()).'</pre></dd>'; } if ($mod->getSetupScript() != '') { echo '<dt>Setup script</dt>'; echo '<dd><tt class="file">'.htmlentities($mod->getSetupScript()).'</tt></dd>'; } if ($mod->getRemoveScript() != '') { echo '<dt>Remove script</dt>'; echo '<dd><tt class="file">'.htmlentities($mod->getRemoveScript()).'</tt></dd>'; } if ($mod->getUpgradeScript() != '') { echo '<dt>Upgrade script</dt>'; echo '<dd><tt class="file">'.htmlentities($mod->getUpgradeScript()).'</tt></dd>'; } $tables = $mod->getTables(); if (count($tables) >= 1) { // Output the DB echo '<dt>Tables</dt><dd>'; foreach ($tables as $table) { outputTable($mod->getTable($table)); } echo '</dd>'; } echo '</dl>'; echo '</fieldset> '; if ($mod->isBase()) { echo '</div>'; } } echo '</div>'; include($Footer); ?> Index: index.php =================================================================== RCS file: /cvsroot/openfirst/modules/index.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** index.php 23 Aug 2005 18:22:19 -0000 1.5 --- index.php 12 Sep 2005 01:40:50 -0000 1.6 *************** *** 1,144 **** ! <?php ! /* ! * openFIRST.modules - index.php ! * ! * Copyright (C) 2005, ! * openFIRST Project ! * Original Author: Jamie Bliss <ja...@op...> ! * ! * 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. ! * ! * 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 ! * ! */ ! require_once('../includes/globals.php'); ! require_once('xmlModule.php'); ! ! $files = glob("$fBasePath/*/openfirst.info.xml"); ! ! $oMods = array(); ! ! foreach($files as $file) { ! $oMods[] =& xmlModule::createFromFile($file); ! } ! ! include($Header); ?> ! <p class="intro">Below is a table showing the modules available in this installation. The data is ! loaded from the <tt class="file">openfirst.info.xml</tt> file distrubuted with each module. ! This allows you to test your XML and debug module installation issues.</p> ! <table> ! <thead> ! <tr> ! <th>Dir</th> ! <th>ID</th> ! <th>Name</th> ! <th>Version</th> ! <th>Author</th> ! <th>Maintainer</th> ! <th>Includes</th> ! <th>Navbar</th> ! <th>Adminbar</th> ! <th>Setup script</th> ! <th>Remove script</th> ! <th>Upgrade script</th> ! </tr> ! </thead> ! <tbody> ! <?php foreach($oMods as $mod) { ! echo ' <tr> ! '; ! ! echo ' <th><tt class="file">'; ! echo htmlentities($mod->getDir()); ! echo '</tt></th> ! '; ! ! echo ' <td><code class="ID">'; ! echo htmlentities($mod->getID()); ! echo '</code></td> ! '; ! ! echo ' <td>'; ! echo htmlentities($mod->getName()); ! echo '</td> ! '; ! ! echo ' <td>'; ! echo htmlentities($mod->getVersion()); ! echo '</td> ! '; ! ! echo ' <td>'; ! echo htmlentities($mod->getAuthor()); ! echo '</td> ! '; ! ! echo ' <td>'; ! echo htmlentities($mod->getMaintainer()); ! echo '</td> ! '; ! ! echo ' <td>'; ! $incs = $mod->getIncludes(); ! if (count($incs) <= 0) { ! echo ' '; ! } else { ! echo ' ! <ul> ! '; ! foreach($incs as $inc) { ! echo ' <li><code class="file">'; ! echo htmlentities($inc); ! echo '</code></li> ! '; ! } ! echo ' </ul> ! '; ! } ! echo '</td> ! '; ! ! echo ' <td><pre>'; ! echo htmlentities($mod->getNavBar()); ! echo '</pre></td> ! '; ! ! echo ' <td><pre>'; ! echo htmlentities($mod->getAdminBar()); ! echo '</pre></td> ! '; ! ! echo ' <td><tt class="file">'; ! echo htmlentities($mod->getSetupScript()); ! echo '</tt></td> ! '; ! ! echo ' <td><tt class="file">'; ! echo htmlentities($mod->getRemoveScript()); ! echo '</tt></td> ! '; ! ! echo ' <td><tt class="file">'; ! echo htmlentities($mod->getUpgradeScript()); ! echo '</tt></td> ! '; ! ! echo ' </tr> ! '; ! } ! ?> ! </tbody> ! </table> ! <?php ! include($Footer); ! ?> --- 1,148 ---- ! <?php ! /* ! * openFIRST.modules - index.php ! * ! * Copyright (C) 2005, ! * openFIRST Project ! * Original Author: Jamie Bliss <ja...@op...> ! * ! * 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. ! * ! * 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 ! * ! */ ! require_once('../includes/globals.php'); ! require_once('xmlModule.php'); ! ! $files = glob("$fBasePath/*/openfirst.info.xml"); ! ! $oMods = array(); ! ! foreach($files as $file) { ! $oMods[] =& xmlModule::createFromFile($file); ! } ! ! include($Header); ?> ! <p class="intro">Below is a table showing the modules available in this installation. The data is ! loaded from the <tt class="file">openfirst.info.xml</tt> file distrubuted with each module. ! This allows you to test your XML and debug module installation issues.</p> ! <table> ! <thead> ! <tr> ! <th>Dir</th> ! <th>ID</th> ! <th>Name</th> ! <th>Version</th> ! <th>Author</th> ! <th>Maintainer</th> ! <th>Includes</th> ! <th>Navbar</th> ! <th>Adminbar</th> ! <th>Setup script</th> ! <th>Remove script</th> ! <th>Upgrade script</th> ! </tr> ! </thead> ! <tbody> ! <?php ! $hbasepath = htmlentities($BasePath); ! ! foreach($oMods as $mod) { ! echo ' <tr> ! '; ! ! $hdir = htmlentities($mod->getDir()); ! echo ' <th><a title="Full Info" href="'.$hbasepath.'/modules/extended.php?'.$hdir.'"><tt class="file">'; ! echo $hdir; ! echo '</tt></a></th> ! '; ! ! echo ' <td><code class="ID">'; ! echo htmlentities($mod->getID()); ! echo '</code></td> ! '; ! ! echo ' <td>'; ! echo htmlentities($mod->getName()); ! echo '</td> ! '; ! ! echo ' <td>'; ! echo htmlentities($mod->getVersion()); ! echo '</td> ! '; ! ! echo ' <td>'; ! echo htmlentities($mod->getAuthor()); ! echo '</td> ! '; ! ! echo ' <td>'; ! echo htmlentities($mod->getMaintainer()); ! echo '</td> ! '; ! ! echo ' <td>'; ! $incs = $mod->getIncludes(); ! if (count($incs) <= 0) { ! echo ' '; ! } else { ! echo ' ! <ul> ! '; ! foreach($incs as $inc) { ! echo ' <li><code class="file">'; ! echo htmlentities($inc); ! echo '</code></li> ! '; ! } ! echo ' </ul> ! '; ! } ! echo '</td> ! '; ! ! echo ' <td><pre>'; ! echo htmlentities($mod->getNavBar()); ! echo '</pre></td> ! '; ! ! echo ' <td><pre>'; ! echo htmlentities($mod->getAdminBar()); ! echo '</pre></td> ! '; ! ! echo ' <td><tt class="file">'; ! echo htmlentities($mod->getSetupScript()); ! echo '</tt></td> ! '; ! ! echo ' <td><tt class="file">'; ! echo htmlentities($mod->getRemoveScript()); ! echo '</tt></td> ! '; ! ! echo ' <td><tt class="file">'; ! echo htmlentities($mod->getUpgradeScript()); ! echo '</tt></td> ! '; ! ! echo ' </tr> ! '; ! } ! ?> ! </tbody> ! </table> ! <?php ! include($Footer); ! ?> \ No newline at end of file |
From: Jamie <ast...@us...> - 2005-09-12 01:40:17
|
Update of /cvsroot/openfirst/base/style In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2570/style Modified Files: style.css Log Message: Added <tt> Index: style.css =================================================================== RCS file: /cvsroot/openfirst/base/style/style.css,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** style.css 18 Jul 2005 22:34:33 -0000 1.5 --- style.css 12 Sep 2005 01:40:09 -0000 1.6 *************** *** 1,317 **** ! /* Basic elements */ ! bold { ! font-weight: bold; ! } ! ! big { ! font-size: large; ! } ! ! input[type=text], select { ! text-align: left; ! } ! ! input[type=checkbox], input[type=radio] { ! margin-right: .3em; ! vertical-align: middle; ! } ! ! caption { ! text-align: center; ! font-size: medium; ! padding: .25em; ! font-weight: bold; ! } ! ! pre, code { ! font-weight: normal; ! } ! ! pre { ! text-align: left; ! } ! ! /* classes and IDs */ ! #content { ! padding: 1em; ! text-align: center; ! margin-left: auto; ! margin-right: auto; ! } ! #content table { ! margin-left: auto; ! margin-right: auto; ! text-align: center; ! } ! ! #adminmenu { ! color: white; ! background-image: url(images/back-admin.png); ! text-align: left; ! } ! #adminmenu a:link { ! color: white; ! } ! #adminmenu a:visited { ! color: white; ! } ! #adminmenu a:active { ! color: white; ! } ! #adminmenu a:hover { ! color: white; ! } ! ! a:link { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: underline; ! } ! a:visited { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: underline; ! } ! a:active { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: underline; ! } ! a:hover { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: underline; ! } ! ! #topmenu, caption { ! text-align: left; ! background-image: url(images/back.gif); ! color: #cecece; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! #topmenu a:link { ! color: #cecece; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! #topmenu a:visited { ! color: #bebebe; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! #topmenu a:active { ! color: #cecece; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! #topmenu a:hover { ! color: #bed8ff; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! ! #toplogo { ! text-align: left; ! } ! ! .nav1 { ! width:100%; ! border: none 0px; ! margin-left: -2px; ! margin-right: -2px; ! margin-bottom: 0; ! } ! .nav1 td, .nav1 th { ! margin: 0; ! padding: 6px; ! border: none 0px; ! } ! .nav1 tr { ! margin: 0px; ! padding: 2px; ! } ! ! .nav2 table { ! border-left:solid #999999 1px; ! border-right:solid #999999 1px; ! border-bottom:solid #999999 1px; ! margin-left:auto; ! margin-right:auto; ! } ! ! .center, .center > * { ! margin-left: auto; ! margin-right: auto; ! text-align: center; ! } ! ! .right, .right > * { ! margin-left: auto; ! margin-right: 0; ! text-align: right; ! } ! ! .left, .left > * { ! margin-left: 0; ! margin-right: auto; ! text-align: left; ! } ! ! .contentleft, .contentleft > * { ! margin-left: auto; ! margin-right: auto; ! text-align: left; ! } ! ! .file { ! font-family: monospace; ! } ! ! td { ! padding: 5px; ! } ! th { ! padding: 5px; ! } ! table.menu { ! border-left:0px; ! border-right:0px; ! border-bottom:0px; ! } ! td.menu { ! border-left:0px; ! border-right:0px; ! border-bottom:0px; ! } ! body { ! color: black; ! font-weight: bolder; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration:none; ! margin: 0px; ! padding: 2px; ! text-align: center; ! } ! td { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! td.navigation { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! th { ! background-color: #999999; ! color: #333333; ! background-image: url(images/back-light.gif); ! } ! ! td.sub { ! background-color: #999999; ! color: #333333; ! background-image: url(images/back-lighter.gif); ! } ! ! .menu.selected { ! color: red; ! text-decoration: underline; ! } ! ! .small { ! font-size:small; ! } ! ! fieldset { ! margin: 1em 1.5em; ! } ! ! LEGEND { ! font-size: 1.5em; ! font-weight: bold; ! } ! ! dl.setup { ! text-align: left; ! } ! dl.setup dd { ! margin-left: 0; ! } ! dl.setup dd label { ! clear: left; ! font-weight: bold; ! width: 12em; ! float: left; ! text-align: right; ! padding-right: 1em; ! } ! dl.setup dt { ! clear: left; ! font-size: 0.8em; ! margin-left: 10em; ! /* margin-right: 200px; */ ! margin-bottom: 2em; ! } ! .error, .warning { ! color: red; ! } ! ul.plain { ! list-style: none; ! clear: both; ! margin-left: 12em; ! } ! dl.setup input:not([type=checkbox]) { ! width: 25em; ! } ! ! table.center caption { ! margin-left:auto; ! margin-right:auto; ! } ! ! hr { ! width: 80%; ! border: 1px; ! height: 1px; ! } ! ! #copyright { ! background=image: url(images/back-light.gif); ! } ! ! #footer p { ! margin: 0; ! } ! ! .logo, .logo img, ! .valid, .valid img { ! border: 0; ! } ! ! #moduleInstall * { ! text-align: left; ! } ! ! .no-space, ! table.no-space tr, table.no-space td, table.no-space th { ! margin: 0; ! padding: 0; ! } ! ! margin: 0; ! padding: 0; ! } --- 1,317 ---- ! /* Basic elements */ ! bold { ! font-weight: bold; ! } ! ! big { ! font-size: large; ! } ! ! input[type=text], select { ! text-align: left; ! } ! ! input[type=checkbox], input[type=radio] { ! margin-right: .3em; ! vertical-align: middle; ! } ! ! caption { ! text-align: center; ! font-size: medium; ! padding: .25em; ! font-weight: bold; ! } ! ! pre, code, tt { ! font-weight: normal; ! } ! ! pre { ! text-align: left; ! } ! ! /* classes and IDs */ ! #content { ! padding: 1em; ! text-align: center; ! margin-left: auto; ! margin-right: auto; ! } ! #content table { ! margin-left: auto; ! margin-right: auto; ! text-align: center; ! } ! ! #adminmenu { ! color: white; ! background-image: url(images/back-admin.png); ! text-align: left; ! } ! #adminmenu a:link { ! color: white; ! } ! #adminmenu a:visited { ! color: white; ! } ! #adminmenu a:active { ! color: white; ! } ! #adminmenu a:hover { ! color: white; ! } ! ! a:link { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: underline; ! } ! a:visited { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: underline; ! } ! a:active { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: underline; ! } ! a:hover { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: underline; ! } ! ! #topmenu, caption { ! text-align: left; ! background-image: url(images/back.gif); ! color: #cecece; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! #topmenu a:link { ! color: #cecece; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! #topmenu a:visited { ! color: #bebebe; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! #topmenu a:active { ! color: #cecece; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! #topmenu a:hover { ! color: #bed8ff; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! ! #toplogo { ! text-align: left; ! } ! ! .nav1 { ! width:100%; ! border: none 0px; ! margin-left: -2px; ! margin-right: -2px; ! margin-bottom: 0; ! } ! .nav1 td, .nav1 th { ! margin: 0; ! padding: 6px; ! border: none 0px; ! } ! .nav1 tr { ! margin: 0px; ! padding: 2px; ! } ! ! .nav2 table { ! border-left:solid #999999 1px; ! border-right:solid #999999 1px; ! border-bottom:solid #999999 1px; ! margin-left:auto; ! margin-right:auto; ! } ! ! .center, .center > * { ! margin-left: auto; ! margin-right: auto; ! text-align: center; ! } ! ! .right, .right > * { ! margin-left: auto; ! margin-right: 0; ! text-align: right; ! } ! ! .left, .left > * { ! margin-left: 0; ! margin-right: auto; ! text-align: left; ! } ! ! .contentleft, .contentleft > * { ! margin-left: auto; ! margin-right: auto; ! text-align: left; ! } ! ! .file { ! font-family: monospace; ! } ! ! td { ! padding: 5px; ! } ! th { ! padding: 5px; ! } ! table.menu { ! border-left:0px; ! border-right:0px; ! border-bottom:0px; ! } ! td.menu { ! border-left:0px; ! border-right:0px; ! border-bottom:0px; ! } ! body { ! color: black; ! font-weight: bolder; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration:none; ! margin: 0px; ! padding: 2px; ! text-align: center; ! } ! td { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! td.navigation { ! color: black; ! font-size: 12px; ! font-family: sans-serif; ! text-decoration: none; ! } ! th { ! background-color: #999999; ! color: #333333; ! background-image: url(images/back-light.gif); ! } ! ! td.sub { ! background-color: #999999; ! color: #333333; ! background-image: url(images/back-lighter.gif); ! } ! ! .menu.selected { ! color: red; ! text-decoration: underline; ! } ! ! .small { ! font-size:small; ! } ! ! fieldset { ! margin: 1em 1.5em; ! } ! ! LEGEND { ! font-size: 1.5em; ! font-weight: bold; ! } ! ! dl.setup { ! text-align: left; ! } ! dl.setup dd { ! margin-left: 0; ! } ! dl.setup dd label { ! clear: left; ! font-weight: bold; ! width: 12em; ! float: left; ! text-align: right; ! padding-right: 1em; ! } ! dl.setup dt { ! clear: left; ! font-size: 0.8em; ! margin-left: 10em; ! /* margin-right: 200px; */ ! margin-bottom: 2em; ! } ! .error, .warning { ! color: red; ! } ! ul.plain { ! list-style: none; ! clear: both; ! margin-left: 12em; ! } ! dl.setup input:not([type=checkbox]) { ! width: 25em; ! } ! ! table.center caption { ! margin-left:auto; ! margin-right:auto; ! } ! ! hr { ! width: 80%; ! border: 1px; ! height: 1px; ! } ! ! #copyright { ! background=image: url(images/back-light.gif); ! } ! ! #footer p { ! margin: 0; ! } ! ! .logo, .logo img, ! .valid, .valid img { ! border: 0; ! } ! ! #moduleInstall * { ! text-align: left; ! } ! ! .no-space, ! table.no-space tr, table.no-space td, table.no-space th { ! margin: 0; ! padding: 0; ! } ! ! margin: 0; ! padding: 0; ! } |
From: Jamie <ast...@us...> - 2005-09-12 01:39:33
|
Update of /cvsroot/openfirst/base/style In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2450/style Modified Files: headers.php Log Message: - Charset is explicitly set to UTF-8 - Header generation more robust - Added $ogMoreStyles for page-specific CSS Index: headers.php =================================================================== RCS file: /cvsroot/openfirst/base/style/headers.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** headers.php 30 Jun 2005 02:35:50 -0000 1.6 --- headers.php 12 Sep 2005 01:39:25 -0000 1.7 *************** *** 1,129 **** ! <?php ! if(! isset($BasePath)){ ! $BasePath = 'http://openfirst.sourceforge.net'; ! $title = "openFIRST Team"; ! } else { ! foreach($ogModuleManager->getDirs() as $dir) { ! $module =& $ogModuleManager->getModuleFromDir($dir); ! if ($module->getActive()) { ! if ($module->getShowOnMenu()) { ! if ($curmodule == $dir){ ! $CurrentModule =& $thisModule; ! $headers .= ' » <a class="menu selected" href="'.htmlentities("$BasePath/$dir").'">'.htmlentities($module->getName()).'</a> | ! '; ! ! $adminnav = $module->getAdminBar(); ! $subnav = $module->getNavBar(); ! ! } else { ! $headers .= ' » <a class="menu" href="'.htmlentities("$BasePath/$dir").'">'.htmlentities($module->getName()).'</a> | ! '; ! } ! } ! } ! } ! ! $headers = substr($headers, 0, -strlen(' | ! ')); ! } ! ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ! <html> ! <head> ! <title><?php echo htmlentities($Title); ?></title> ! <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> ! <meta http-equiv="Content-Language" content="en" /> ! <meta name="copyright" content="© 2003 openFIRST http://openfirst.sf.net." /> ! <meta name="author" content="openFIRST - http://openfirst.sf.net" /> ! <meta name="generator" content="openFIRST - http://openfirst.sf.net" /> ! <link rel="stylesheet" type="text/css" href="<?php echo htmlentities($StylePath); ?>/style.css" /> ! </head> ! <body> ! ! <table class="nav1"> ! <tr id="toplogo"> ! <td> ! <img src="<?php echo htmlentities($BasePath); ?>/style/images/openfirst.png" alt="openFIRST Portal System" /> ! </td> ! </tr> ! <tr> ! <th id="topmenu"> ! <?php ! if(ISSET($headers)){ ! echo("» <a accesskey='h' href='$Home'><u>H</u>ome</a> | " . $headers); ! }else{ ! ?> ! » <a accesskey="h" href="http://openfirst.sourceforge.net"><u>H</u>ome</a> ! | » <a accesskey="d" href="http://openfirst.sourceforge.net/downloads.php"><u>D</u>ownloads</a> ! | » <a accesskey="r" href="http://openfirst.sourceforge.net/release.php"><u>R</u>elease Notes</a> ! | » <a accesskey="m" href="http://openfirst.sourceforge.net/modules.php"><u>M</u>odules</a> ! | » <a accesskey="l" href="http://openfirst.sourceforge.net/license.php"><u>L</u>icense</a> ! | » <a accesskey="b" href="http://openfirst.sourceforge.net/bugreports.php"><u>B</u>ug Reports</a> ! | » <a accesskey="c" href="http://openfirst.sourceforge.net/contact.php"><u>C</u>ontact Us</a> ! | » <a accesskey="a" href="http://openfirst.sourceforge.net/about.php"><u>A</u>bout openFIRST</a> ! | » <a accesskey="e" href="http://openfirst.sourceforge.net/developers.php">D<u>e</u>velopers</a> ! <?php } ?> ! </th> ! </tr> ! <tr> ! <td class="nav2" style="background-image: url('<?php echo htmlentities($StylePath); ?>/images/back-light.gif'); "> ! <table width="100%" border="0" cellspacing="0" ! cellpadding="0"> ! <tr> ! <td class="left"> ! <?php ! ! // Check if module name has been set then echo ! if(isset($CurrentModule)){ ! echo '<b>'.htmlentities($CurrentModule->getName()).'</b> – '; ! } ! ! // Check if navigation bar option is set then echo options ! if(isset($subnav)){ ! ! // Output module navigation bar ! echo $subnav; ! } ! ?> ! </td> ! <td class="right" style="color: #333333;"> ! <?php ! ! // Check if messenger module has activated usersonline option then echo value ! if(isset($usersonline)){ ! echo $usersonline; ! } else { ! echo "Welcome to the <b>$Title</b> website!"; ! } ! ! ?> ! </td> ! </tr> ! </table></td> ! </tr> ! <?php ! ! if (isset($user) && isset($user->user)){ ! if(isset($adminnav) && (strcasecmp($user->membertype, 'administrator') == 0)) { ! ! ?> ! <tr> ! <td id="adminmenu"><b>Admin Options</b> – ! <?php ! // Print admin navigation bar ! echo $adminnav; ! ?></td> ! </tr> ! <?php ! ! } ! } ! ! ?> ! </table><div id="content"> ! <?php ! ! if ($BasePath == 'http://openfirst.sourceforge.net') { ! unset($BasePath); ! } ! ! ?> --- 1,139 ---- ! <?php ! header('content-type: text/html; charset=utf-8'); ! ! if(! isset($BasePath)){ ! $BasePath = 'http://openfirst.sourceforge.net'; ! $title = "openFIRST Team"; ! } else { ! $headerlinks = array(); ! foreach($ogModuleManager->getDirs() as $dir) { ! $module =& $ogModuleManager->getModuleFromDir($dir); ! if ($module->getActive()) { ! if ($module->getShowOnMenu()) { ! if ($curmodule == $dir){ ! $CurrentModule =& $thisModule; ! $headerlinks[] = ' » <a class="menu selected" href="'.htmlentities("$BasePath/$dir").'">'.htmlentities($module->getName()).'</a> ! '; ! $adminnav = $module->getAdminBar(); ! $subnav = $module->getNavBar(); ! ! } else { ! $headerlinks[] .= ' » <a class="menu" href="'.htmlentities("$BasePath/$dir").'">'.htmlentities($module->getName()).'</a> ! '; ! } ! } ! } ! } ! ! $headers = implode(' |', $headerlinks); ! unset($headerlinks); ! } ! ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ! <html> ! <head> ! <title><?php echo htmlentities($Title); ?></title> ! <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> ! <meta http-equiv="Content-Language" content="en" /> ! <meta name="copyright" content="© 2003 openFIRST http://openfirst.sf.net." /> ! <meta name="author" content="openFIRST - http://openfirst.sf.net" /> ! <meta name="generator" content="openFIRST - http://openfirst.sf.net" /> ! <link rel="stylesheet" type="text/css" href="<?php echo htmlentities($StylePath); ?>/style.css" /> ! <?php ! if (isset($ogMoreStyles) && trim($ogMoreStyles) != '') { ! echo '<style type="text/css"> ! '.htmlentities($ogMoreStyles).' ! </style> ! '; ! } ! ?> ! </head> ! <body> ! ! <table class="nav1"> ! <tr id="toplogo"> ! <td> ! <img src="<?php echo htmlentities($BasePath); ?>/style/images/openfirst.png" alt="openFIRST Portal System" /> ! </td> ! </tr> ! <tr> ! <th id="topmenu"> ! <?php ! if(ISSET($headers)){ ! echo("» <a accesskey='h' href='$Home'><u>H</u>ome</a> | " . $headers); ! }else{ ! ?> ! » <a accesskey="h" href="http://openfirst.sourceforge.net"><u>H</u>ome</a> ! | » <a accesskey="d" href="http://openfirst.sourceforge.net/downloads.php"><u>D</u>ownloads</a> ! | » <a accesskey="r" href="http://openfirst.sourceforge.net/release.php"><u>R</u>elease Notes</a> ! | » <a accesskey="m" href="http://openfirst.sourceforge.net/modules.php"><u>M</u>odules</a> ! | » <a accesskey="l" href="http://openfirst.sourceforge.net/license.php"><u>L</u>icense</a> ! | » <a accesskey="b" href="http://openfirst.sourceforge.net/bugreports.php"><u>B</u>ug Reports</a> ! | » <a accesskey="c" href="http://openfirst.sourceforge.net/contact.php"><u>C</u>ontact Us</a> ! | » <a accesskey="a" href="http://openfirst.sourceforge.net/about.php"><u>A</u>bout openFIRST</a> ! | » <a accesskey="e" href="http://openfirst.sourceforge.net/developers.php">D<u>e</u>velopers</a> ! <?php } ?> ! </th> ! </tr> ! <tr> ! <td class="nav2" style="background-image: url('<?php echo htmlentities($StylePath); ?>/images/back-light.gif'); "> ! <table width="100%" border="0" cellspacing="0" ! cellpadding="0"> ! <tr> ! <td class="left"> ! <?php ! ! // Check if module name has been set then echo ! if(isset($CurrentModule)){ ! echo '<b>'.htmlentities($CurrentModule->getName()).'</b> – '; ! } ! ! // Check if navigation bar option is set then echo options ! if(isset($subnav)){ ! ! // Output module navigation bar ! echo $subnav; ! } ! ?> ! </td> ! <td class="right" style="color: #333333;"> ! <?php ! ! // Check if messenger module has activated usersonline option then echo value ! if(isset($usersonline)){ ! echo $usersonline; ! } else { ! echo "Welcome to the <b>$Title</b> website!"; ! } ! ! ?> ! </td> ! </tr> ! </table></td> ! </tr> ! <?php ! ! if (isset($user) && isset($user->user)){ ! if(isset($adminnav) && (strcasecmp($user->membertype, 'administrator') == 0)) { ! ! ?> ! <tr> ! <td id="adminmenu"><b>Admin Options</b> – ! <?php ! // Print admin navigation bar ! echo $adminnav; ! ?></td> ! </tr> ! <?php ! ! } ! } ! ! ?> ! </table><div id="content"> ! <?php ! ! if ($BasePath == 'http://openfirst.sourceforge.net') { ! unset($BasePath); ! } ! ! ?> |
From: Jamie <ast...@us...> - 2005-09-12 01:38:01
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2092/includes Modified Files: xmlModule.php Log Message: Parser almost entirely finnished (Only small details like Null Key Columns to do) Also made DB data stored in OOPy structure Index: xmlModule.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/xmlModule.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** xmlModule.php 11 Sep 2005 14:19:57 -0000 1.5 --- xmlModule.php 12 Sep 2005 01:37:51 -0000 1.6 *************** *** 92,95 **** --- 92,96 ---- /** Creates a xmlModule object from a directory in the oF directory. + * This is the preferred method */ /*static*/ function createFromDir($Dir) { *************** *** 111,114 **** --- 112,121 ---- /*** PUBLIC PROPERTIES ***/ + /** Is this the big openfirst.base module? + */ + /*public*/ function isBase() { + return $this->mID == 'openfirst.base'; + } + /*public*/ function getName() { return $this->mName; *************** *** 136,140 **** /*public*/ function getIncludes() { ! return $this->mIncludes; } --- 143,151 ---- /*public*/ function getIncludes() { ! if (is_array($this->mIncludes)) { ! return $this->mIncludes; ! } else { ! return array(); ! } } *************** *** 148,152 **** /*public*/ function getTables() { ! return $this->mTables; } --- 159,171 ---- /*public*/ function getTables() { ! if (is_array($this->mTables)) { ! return array_keys($this->mTables); ! } else { ! return array(); ! } ! } ! ! /*public*/ function getTable($name) { ! return $this->mTables[$name]; } *************** *** 191,194 **** --- 210,217 ---- } + $par_name = false; + if (count($this->mTagStack) > 1) + $par_name = $this->mTagStack[count($this->mTagStack)-2]; // One for the zero start, one for second from end + if ($name == 'MODULE') { if (isset($attrs['ID'])) $this->mID = $attrs['ID']; *************** *** 211,265 **** trigger_error('The table tag must always have a name attribute.', E_USER_ERROR); } ! $this->mxmlCurTable = $attrs['NAME']; ! $this->mTables[$this->mxmlCurTable] = ! array( 'name' => $this->mxmlCurTable, ! 'fields' => array(), ! 'keys' => array() ! ); } ! else if ($name == 'FIELD' && in_array('TABLE', $this->mTagStack)) { ! $field = array(); ! $this->mxmlCurField = $field['name'] = $attrs['NAME']; ! if (isset($attrs['null'])) ! $field['null'] = ofConvert2Bool($attrs['NULL'], array('null')); ! if (isset($attrs['autoincrement'])) ! $field['auto'] = ofConvert2Bool($attrs['AUTOINCREMENT'], array('autoincrement')); ! $this->mTables[$this->mxmlCurTable]['fields'][$this->mxmlCurField] = $field; } else if ($name == 'KEY' && $this->mxmlCurTable) { ! $key = array(); ! $key['type'] = 'index'; ! $key['name'] = $key['type'] = false; ! if (isset($attrs['TYPE'])) $key['type'] = $attrs['TYPE']; ! if (isset($attrs['NAME'])) $this->mxmlCurKey = $key['name'] = $attrs['NAME']; ! if ( (strcasecmp($key['type'], 'primary') == 0) || (strcasecmp($key['name'], 'primary') == 0) ) { ! $key['type'] = 'primary'; ! $this->mxmlCurKey = $key['name'] = 'PRIMARY'; ! } ! ! $key['cols'] = array(); ! $this->mTables[$this->mxmlCurTable]['keys'][$this->mxmlCurKey] = $key; } else if ($name == 'TYPE' && $this->mxmlCurField) { if (isset($attrs['LENGTH'])) ! $this->mTables[$this->mxmlCurTable]['fields'][$this->mxmlCurField]['length'] = $attrs['LENGTH']; if (isset($attrs['UNSIGNED'])) ! $this->mTables[$this->mxmlCurTable]['fields'][$this->mxmlCurField]['unsigned'] = ofConvert2Bool($attrs['UNSIGNED']); } else if (($name == 'SET' || $name == 'ENUM') && in_array('FIELD', $this->mTagStack)) { ! $this->mTables[$this->mxmlCurTable]['fields'][$this->mxmlCurField]['type'] = $name; ! $this->mTables[$this->mxmlCurTable]['fields'][$this->mxmlCurField]['values'] = array(); } else if ($name == 'ROW' && in_array('ROWS', $this->mTagStack)) { ! $this->mxmlCurRow = array(); } else if ($name == 'ROWS' && in_array('TABLE', $this->mTagStack)) { ! $this->mTables[$this->mxmlCurTable]['data'] = array(); } ! else if (in_array('ROW', $this->mTagStack)) { ! if (isset($attrs['NAME'])) $this->mxmlCurField = $attrs['NAME']; ! } } --- 234,277 ---- trigger_error('The table tag must always have a name attribute.', E_USER_ERROR); } ! $tname = $attrs['NAME']; ! $this->mTables[$tname] = new xmlTable($tname); ! $this->mxmlCurTable =& $this->mTables[$tname]; } ! else if ($name == 'FIELD' && $this->mxmlCurTable) { ! $fname = $attrs['NAME']; ! $this->mxmlCurField =& $this->mxmlCurTable->setCol(new xmlColumn($fname)); ! if (isset($attrs['NULL'])) ! $this->mxmlCurField->setNull( ofConvert2Bool($attrs['NULL'], array('NULL')) ); ! ! if (isset($attrs['AUTOINCREMENT'])) ! $this->mxmlCurField->setAutoIncrement( ofConvert2Bool($attrs['AUTOINCREMENT'], array('AUTOINCREMENT')) ); } else if ($name == 'KEY' && $this->mxmlCurTable) { ! $kargs = array(); ! // @todo FIXME: A little screwed up. ! if (isset($attrs['NAME'])) $kargs[] = $attrs['NAME']; ! if (isset($attrs['TYPE'])) $kargs[] = $attrs['TYPE']; ! $this->mxmlCurKey =& $this->mxmlCurTable->setKey( new xmlKey($kargs) ); } else if ($name == 'TYPE' && $this->mxmlCurField) { if (isset($attrs['LENGTH'])) ! $this->mxmlCurField->setLength($attrs['LENGTH']); if (isset($attrs['UNSIGNED'])) ! $this->mxmlCurField->setUnsigned( ofConvert2Bool($attrs['UNSIGNED'], array('UNSIGNED')) ); } else if (($name == 'SET' || $name == 'ENUM') && in_array('FIELD', $this->mTagStack)) { ! $this->mxmlCurField->setType( $name ); } else if ($name == 'ROW' && in_array('ROWS', $this->mTagStack)) { ! $this->mxmlCurRow =& $this->mxmlCurTable->addRow(new xmlRow()); } else if ($name == 'ROWS' && in_array('TABLE', $this->mTagStack)) { ! # } ! /* else if (in_array('ROW', $this->mTagStack)) { ! $this->mxmlCurField = $attrs['NAME']; // Save this for later ! } */ } *************** *** 271,305 **** if ($name == 'NAME') { $this->mName = $this->mxmlCurTag->getTextContents(); ! } else if ($name == 'VERSION') { $this->mVersion = $this->mxmlCurTag->getTextContents(); ! } else if ($name == 'AUTHOR') { $this->mAuthor = $this->mxmlCurTag->getTextContents(); ! } else if ($name == 'MAINTAINER') { $this->mMaintainer = $this->mxmlCurTag->getTextContents(); ! } else if ($name == 'NAVBAR') { $this->mNavBar = $this->mxmlCurTag->getTextContents(); ! } else if ($name == 'ADMINBAR') { $this->mAdminBar = $this->mxmlCurTag->getTextContents(); ! } else if ($name == 'INCLUDE') { ! $this->mIncludes[] = $file = $this->mxmlCurTag->getTextContents(); ! } else if ($name == 'TABLE') { ! $this->mxmlCurTable = false; ! } else if ($name == 'FIELD') { ! $this->mxmlCurField = false; ! } else if ($name == 'KEY') { ! $this->mxmlCurKey = false; ! } else if ($name == 'TYPE' && $this->mxmlCurField) { ! $this->mTables[$this->mxmlCurTable]['fields'][$this->mxmlCurField]['type'] = $this->mxmlCurTag->getTextContents(); ! } else if ($name == 'DEFAULT' && $this->mxmlCurField) { ! $this->mTables[$this->mxmlCurTable]['fields'][$this->mxmlCurField]['default'] = $this->mxmlCurTag->getTextContents(); ! } else if ($name == 'COL' && $this->mxmlCurKey) { ! $this->mTables[$this->mxmlCurTable]['keys'][$this->mxmlCurKey]['cols'][] = $this->mxmlCurTag->getTextContents(); ! } else if ($par_name == 'SET' || $par_name == 'ENUM') { ! $this->mTables[$this->mxmlCurTable]['fields'][$this->mxmlCurField]['values'][] = $this->mxmlCurTag->getTextContents(); ! } else if ($name == 'ROW') { ! $this->mTables[$this->mxmlCurTable]['data'][] = $this->mxmlCurRow; ! $this->mxmlCurRow = false; ! } else if ($par_name == 'ROW') { ! $this->mxmlCurRow[$this->mxmlCurField] = $this->mxmlCurTag->getTextContents(); } --- 283,331 ---- if ($name == 'NAME') { $this->mName = $this->mxmlCurTag->getTextContents(); ! } ! else if ($name == 'VERSION') { $this->mVersion = $this->mxmlCurTag->getTextContents(); ! } ! else if ($name == 'AUTHOR') { $this->mAuthor = $this->mxmlCurTag->getTextContents(); ! } ! else if ($name == 'MAINTAINER') { $this->mMaintainer = $this->mxmlCurTag->getTextContents(); ! } ! else if ($name == 'NAVBAR') { $this->mNavBar = $this->mxmlCurTag->getTextContents(); ! } ! else if ($name == 'ADMINBAR') { $this->mAdminBar = $this->mxmlCurTag->getTextContents(); ! } ! else if ($name == 'INCLUDE') { ! $this->mIncludes[] = $this->mxmlCurTag->getTextContents(); ! } ! else if ($name == 'TABLE') { ! unset($this->mxmlCurTable); ! } ! else if ($name == 'FIELD') { ! unset($this->mxmlCurField); ! } ! else if ($name == 'KEY') { ! unset($this->mxmlCurKey); ! } ! else if ($name == 'TYPE' && isset($this->mxmlCurField)) { ! $this->mxmlCurField->setType( $this->mxmlCurTag->getTextContents() ); ! } ! else if ($name == 'DEFAULT' && isset($this->mxmlCurField)) { ! $this->mxmlCurField->setDefault( $this->mxmlCurTag->getTextContents() ); ! } ! else if ($name == 'COL' && isset($this->mxmlCurKey)) { ! $this->mxmlCurKey->addCol( $this->mxmlCurTag->getTextContents() ); ! } ! else if ($par_name == 'SET' || $par_name == 'ENUM') { ! $this->mxmlCurField->addValue( $this->mxmlCurTag->getTextContents() ); ! } ! else if ($name == 'ROW') { ! unset($this->mxmlCurRow); ! } ! else if ($par_name == 'ROW') { ! $this->mxmlCurRow->setValue( $this->mxmlCurTag->Attributes['NAME'] , $this->mxmlCurTag->getTextContents() ); } *************** *** 313,316 **** --- 339,714 ---- } + /** A table loaded from an XML file + */ + class xmlTable { + var $mCols, $mKeys, $mRows, $mName; + function xmlTable($name) { + $this->mName = $name; + $this->mCols = array(); + $this->mKeys = array(); + $this->mRows = array(); + } + + function getName() { + return $this->mName; + } + function &setCol($value) { + return $this->mCols[$value->getName()] = $value; + } + + function getCol($name) { + if (isset($this->mCols[$name])) { + return $this->mCols[$name]; + } else { + return false; + } + } + + function getCols() { + return array_keys($this->mCols); + } + + function deleteCol($name) { + unset($this->mCols[$name]); + } + + function &setKey($value) { + return $this->mKeys[$value->getName()] = $value; + } + + function getKey($name) { + if (isset($this->mKeys[$name])) { + return $this->mKeys[$name]; + } else { + return false; + } + } + + function getKeys() { + return array_keys($this->mKeys); + } + + + function deleteKey($name) { + unset($this->mKeys[$name]); + } + + function &addRow($values) { + if (is_array($values)) { + return $this->mRows[] = new xmlRow($values); + } else if (is_object($values)) { + return $this->mRows[] = $values; + } else { + return $this->mRows[] = new xmlRow(); + } + } + + function clearRows($values) { + $this->mRows = array(); + } + + function addValue2LastRow() { + $args = func_get_args(); + $key = ofGetLastKey($this->mRows); + + if (count($args) == 1) { + $vals = $args[0]; + } else if (count($args) > 1) { + $vals = array($args[0] => $args[1]); + } else { + return; + } + + $this->mRows[$key]->addValues($vals); + } + + function getRows() { + return $this->mRows; + } + } + + /** A column for a table loaded from XML + */ + class xmlColumn { + // $mValues is an associative array, with the keys and values the same. + var $mName, $mType, $mValues, $mLength, $mDefault; + var $mNull, $mUnsigned, $mZerofill, $mAutoIncrement; + + function xmlColumn($name) { + $this->mName = $name; + } + + function getName() { + return $this->mName; + } + + function getType() { + return $this->mType; + } + + function setType($value) { + $this->mType = strtoupper($value); + if ( ($this->mType == 'SET' || $this->mType == 'ENUM') ) { + $this->mValues = array(); + } else { + $this->mValues = false; + } + } + + function getValues() { + if (is_array($this->mValues)) { + return array_keys($this->mValues); + } else { + return false; + } + } + + function setValues($values) { + if ($this->mType != 'SET' && $this->mType != 'ENUM') return; + + if (!is_array($values)) $values = array($values); + + $this->mValues = array_combine($values, $values); + } + + function addValue($value) { + if ($this->mType != 'SET' && $this->mType != 'ENUM') return; + + if (is_array($value)) { + $vals = array_combine($values, $values); + } else { + $vals = array((string)$value => (string)$value); + } + + $this->mValues = $vals + $this->mValues; // Union operator won't overwrite values + } + + function removeValue($value) { + unset($this->mValues[$value]); + } + + function removeAllValues() { + $this->mValues = array(); + } + + function getLength() { + return $this->mLength; + } + function setLength($value) { + $value = (int)$value; + if ($value < 0) { + // Raise some kind of error? + return; + } + $this->mLength = $value; + } + function deleteLength() { + $this->mLength = NULL; + } + function hasLength() { + return ($this->mLength !== NULL); + } + + function getDefault() { + return $this->mDefault; + } + function setDefault($value) { + return $this->mDefault; + } + function deleteDefault() { + unset($this->mDefault); + } + function hasDefault() { + // Use property_exists() so that NULL can be specified as a default + // Or do so if you only want to support PHP v5.1! + return isset($this->mDefault); + } + + function getNull() { + return $this->mNull; + } + function setNull($value) { + $this->mNull = (boolean)$value; + } + function hasNull() { + return isset($this->mNull); + } + function deleteNull() { + unset($this->mNull); + } + + // 'UNSIGNED' is MySQL-specific + function getUnsigned() { + return $this->mUnsigned; + } + function setUnsigned($value) { + $this->mUnsigned = (boolean)$value; + } + function hasUnsigned() { + return isset($this->mUnsigned); + } + function deleteUnsigned() { + unset($this->mUnsigned); + } + + function getZerofill() { + return $this->mZerofill; + } + function setZerofill($value) { + $this->mZerofill = (boolean)$value; + } + function hasZerofill() { + return isset($this->mZerofill); + } + function deleteZerofill() { + unset($this->mZerofill); + } + + function getAutoIncrement() { + return $this->mAutoIncrement; + } + function setAutoIncrement($value) { + $this->mAutoIncrement = (boolean)$value; + } + function hasAutoIncrement() { + return isset($this->mAutoIncrement); + } + function deleteAutoIncrement() { + unset($this->mAutoIncrement); + } + } + + /** A key for a table loaded from XML + */ + class xmlKey { + // $mValues is an associative array, with the keys and values the same. + var $mType, $mCols, $mName; + var $mLengths; // Seperate lengths array to simplify implementation + + function xmlKey() { + $args = func_get_args(); + + if (is_array($args[0])) $args = $args[0]; + + $this->mName = $this->mType = false; + if (isset($args[0])) $this->mName = $args[0]; + if (isset($args[1])) $this->mType = $args[1]; + + if ( (strcasecmp($this->mType, 'primary') == 0) || (strcasecmp($this->mName, 'primary') == 0) ) { + $this->mType = 'primary'; + $this->mName = 'PRIMARY'; + } + $this->mCols = array(); + $this->mLengths = array(); + } + + function getName() { + return $this->mName; + } + + function getType() { + return $this->mType; + } + + function setType($value) { + $this->mType = strtoupper($value); + + if ( $this->mType == 'PRIMARY' ) { + $this->mType = 'primary'; + $this->mName = 'PRIMARY'; + } + } + + function getCols() { + return array_keys($this->mCols); + } + + function setCols($values) { + if (!is_array($values)) $values = array($values); + + $this->mCols = array_combine($values, $values); + } + + function addCol($value) { + if (is_array($value)) { + $vals = array_combine($values, $values); + $this->mCols = $vals + $this->mCols; // Union operator won't overwrite values + } else { + $this->mCols[(string)$value] = (string)$value; + } + } + + function removeCol($value) { + unset($this->mCols[(string)$value]); + } + + function removeAllCols() { + $this->mCols = array(); + } + + function setColLength($col, $len) { + $this->mLengths[(string)$col] = $len; + } + + function getColLength($col) { + $col = (string)$col; + if (isset($this->mLengths[$col])) { + return $this->mLengths[$col]; + } else { + return NULL; + } + } + + function hasColLength($col) { + return isset($this->mLengths[$col]); + } + + function deleteColLength($col) { + unset($this->mLengths[$col]); + } + } + + /** A data row for a table loaded from XML + */ + class xmlRow { + var $mValues; + + function xmlRow($values = array()) { + $this->mValues = $values; + } + + function setValues($values) { + $this->mValues = $values; + } + + function addValues($values) { + $this->mValues = $values + $this->mValues; // Union operator won't overwrite values + } + + function setValue($name, $value) { + $this->mValues[$name] = $value; + } + + function getValues() { + return array_keys($this->mValues); + } + + function getValue($name) { + return $this->mValues[$name]; + } + + function hasValue($name) { + return key_exists($name, $this->mValues); + } + + function deleteValue($name) { + unset($this->mValues[$name]); + } + + function deleteAllValues() { + $this->mValues = array(); + } + } + /** * Used internally when parsing the XML document as *************** *** 318,321 **** --- 716,720 ---- * * Should not be used elsewhere. + * @private */ class xmlElement { *************** *** 364,366 **** } ! ?> --- 763,765 ---- } ! ?> \ No newline at end of file |
From: Jamie <ast...@us...> - 2005-09-12 01:36:13
|
Update of /cvsroot/openfirst/base/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1897/includes Modified Files: functions.php Log Message: Added ofGetLastKey() Index: functions.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/functions.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** functions.php 17 Aug 2005 17:28:40 -0000 1.7 --- functions.php 12 Sep 2005 01:36:05 -0000 1.8 *************** *** 1,143 **** ! <?php ! /* ! * openFIRST.base - includes/functions.php ! * ! * Copyright (C) 2003, ! * openFIRST Project ! * Original Author: Jamie Bliss <ja...@op...> ! * ! * 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 ! * ! */ ! ! // Purpose: Provide global functions to openFIRST ! ! /** Replaces standard vars in config text. ! * Currently includes $BasePath, $fBasePath, ! * $StylePath, $fStylePath, $ModPath, and $fModPath. ! */ ! function ofReplaceVariables($text, $ModuleDir = false) { ! if ($ModuleDir === false) { ! global $CurrentModule; ! if (is_object($CurrentModule)) $ModuleDir == $CurrentModule->getDir(); ! } ! ! global $BasePath, $fBasePath, $StylePath, $fStylePath; ! ! $find = array('$BasePath', ! '$fBasePath', ! '$StylePath', ! '$fStylePath', ! '$ModPath', ! '$fModPath', ! '$DirName' ! ); ! ! $replace = array($BasePath, ! $fBasePath, ! $StylePath, ! $fStylePath, ! "$BasePath/$ModuleDir", ! "$fBasePath/$ModuleDir", ! "$ModuleDir" ! ); ! ! return str_ireplace($find, $replace, $text); ! ! } ! ! ! /** Formats the size of computer data. ! * Uses the units: KB, MB, GB, etc. ! * Uses 1024 definition (1 KB = 1024 B) ! */ ! function ofFormatSize($size) { ! $base = 1024; ! $units = array( ! 'B', ! 'KB', ! 'MB', ! 'GB', ! 'TB', ! 'PB', ! 'EB', ! 'ZB', ! 'YB', ! 'XB', ! false, ! 'VB' ! ); ! ! $units = array_reverse($units, true); ! reset($units); ! while (list($pow, $unit) = each($units)) { ! if ($unit === false) continue; ! if ($size >= pow($base, $pow)) { ! $unitsize = $size/pow($base, $pow); ! $unitsize = rtrim($unitsize, '0'); ! if (substr($unitsize, -1) == '.') $unitsize = substr($unitsize, 0, -1); ! return number_format($unitsize, 2, '.', '').' '.$unit; ! } ! } ! } ! ! /** Strip line comment. ! * Given a string and an array of commentors (in PHP, it would be array('#', '//')), ! * remove all end-of-line comments. ! * Now handles multiple lines ! */ ! function ofStripLineComment($commentors, $text) { ! $rtn = array(); ! $lines = explode(array("\r\n","\n","\r"), $text); ! foreach($lines as $line) { ! $parts = explode($commentors, $line, 2); ! $rtn[] = $parts[0]; ! } ! return implode(PHP_EOL, $rtn); ! } ! ! /** Converts input to boolean ! * returns true on: yes, y, true, 1 ! * returns false on: no, n, false, 0 ! * returns nothing if neither (return;). ! * if a value is in both $moretrue and $morefalse, it is treated as true ! * case-insensitive ! */ ! function ofConvert2Bool($text, $moretrue=array(), $morefalse=array()) { ! $yesvals = $moretrue; ! $yesvals[] = 'yes'; ! $yesvals[] = 'y'; ! $yesvals[] = 'true'; ! $yesvals[] = '1'; ! ! $novals = $morefalse; ! $novals[] = 'no'; ! $novals[] = 'n'; ! $novals[] = 'false'; ! $novals[] = '0'; ! ! foreach ($yesvals as $val) { ! if (strcasecmp($text, $val) == 0) return true; ! } ! foreach ($novals as $val) { ! if (strcasecmp($text, $val) == 0) return false; ! } ! return; ! } ! ?> --- 1,150 ---- ! <?php ! /* ! * openFIRST.base - includes/functions.php ! * ! * Copyright (C) 2003, ! * openFIRST Project ! * Original Author: Jamie Bliss <ja...@op...> ! * ! * 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 ! * ! */ ! ! // Purpose: Provide global functions to openFIRST ! ! /** Replaces standard vars in config text. ! * Currently includes $BasePath, $fBasePath, ! * $StylePath, $fStylePath, $ModPath, and $fModPath. ! */ ! function ofReplaceVariables($text, $ModuleDir = false) { ! if ($ModuleDir === false) { ! global $CurrentModule; ! if (is_object($CurrentModule)) $ModuleDir == $CurrentModule->getDir(); ! } ! ! global $BasePath, $fBasePath, $StylePath, $fStylePath; ! ! $find = array('$BasePath', ! '$fBasePath', ! '$StylePath', ! '$fStylePath', ! '$ModPath', ! '$fModPath', ! '$DirName' ! ); ! ! $replace = array($BasePath, ! $fBasePath, ! $StylePath, ! $fStylePath, ! "$BasePath/$ModuleDir", ! "$fBasePath/$ModuleDir", ! "$ModuleDir" ! ); ! ! return str_ireplace($find, $replace, $text); ! ! } ! ! ! /** Formats the size of computer data. ! * Uses the units: KB, MB, GB, etc. ! * Uses 1024 definition (1 KB = 1024 B) ! */ ! function ofFormatSize($size) { ! $base = 1024; ! $units = array( ! 'B', ! 'KB', ! 'MB', ! 'GB', ! 'TB', ! 'PB', ! 'EB', ! 'ZB', ! 'YB', ! 'XB', ! false, ! 'VB' ! ); ! ! $units = array_reverse($units, true); ! reset($units); ! while (list($pow, $unit) = each($units)) { ! if ($unit === false) continue; ! if ($size >= pow($base, $pow)) { ! $unitsize = $size/pow($base, $pow); ! $unitsize = rtrim($unitsize, '0'); ! if (substr($unitsize, -1) == '.') $unitsize = substr($unitsize, 0, -1); ! return number_format($unitsize, 2, '.', '').' '.$unit; ! } ! } ! } ! ! /** Strip line comment. ! * Given a string and an array of commentors (in PHP, it would be array('#', '//')), ! * remove all end-of-line comments. ! * Now handles multiple lines ! */ ! function ofStripLineComment($commentors, $text) { ! $rtn = array(); ! $lines = explode(array("\r\n","\n","\r"), $text); ! foreach($lines as $line) { ! $parts = explode($commentors, $line, 2); ! $rtn[] = $parts[0]; ! } ! return implode(PHP_EOL, $rtn); ! } ! ! /** Converts input to boolean ! * returns true on: yes, y, true, 1 ! * returns false on: no, n, false, 0 ! * returns nothing if neither (return;). ! * if a value is in both $moretrue and $morefalse, it is treated as true ! * case-insensitive ! */ ! function ofConvert2Bool($text, $moretrue=array(), $morefalse=array()) { ! $yesvals = $moretrue; ! $yesvals[] = 'yes'; ! $yesvals[] = 'y'; ! $yesvals[] = 'true'; ! $yesvals[] = '1'; ! ! $novals = $morefalse; ! $novals[] = 'no'; ! $novals[] = 'n'; ! $novals[] = 'false'; ! $novals[] = '0'; ! ! foreach ($yesvals as $val) { ! if (strcasecmp($text, $val) == 0) return true; ! } ! foreach ($novals as $val) { ! if (strcasecmp($text, $val) == 0) return false; ! } ! return; ! } ! ! /** Returns the last key of an array. ! * @param $array array The array to get the key of ! */ ! function ofGetLastKey($array) { ! return end(array_keys($array)); ! } ! ?> |
From: Jamie <ast...@us...> - 2005-09-12 01:35:40
|
Update of /cvsroot/openfirst/base/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1808/config Modified Files: openfirst.info.xml Log Message: -Added XML namespace -Added numeric IDs for Modules and Users Index: openfirst.info.xml =================================================================== RCS file: /cvsroot/openfirst/base/config/openfirst.info.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** openfirst.info.xml 23 Aug 2005 18:03:45 -0000 1.5 --- openfirst.info.xml 12 Sep 2005 01:35:29 -0000 1.6 *************** *** 1,72 **** ! <?xml version="1.0"?> ! <module id="openfirst.base"> ! <!-- NOTE: This file defines the basic DB layout when installing or upgrading. ! openfirst.base is a psuedo-module for the oF core. --> ! <name>openFIRST portal system</name> ! <version>CVS</version> ! <author>The openFIRST Team</author> ! ! <includes> ! <include>$fBasePath/includes/settings.php</include> ! <include>$fBasePath/includes/slug.php</include> ! </includes> ! ! <!-- Database setup --> ! <db> ! <table name="config"> ! <fields> ! <!-- Empty tags with no attributes serve as flags. Should be self explainatory --> ! <field name="modulename" null="no"><type length="25">varchar</type> <default></default></field> ! <field name="dir" null="no"><type length="25">varchar</type></field> ! <field name="UpdateDate" null="no"><type>datetime</type></field> ! <field name="label" ><type length="25">varchar</type></field> ! <field name="Author" ><type>tinytext</type></field> ! <field name="Maintainer" ><type>tinytext</type></field> ! <field name="version" null="no"><type length="10">varchar</type> <default>CVS</default></field> ! <field name="showonmenu" null="no"><type>BOOL</type> <default>0</default></field> ! <field name="active" null="no"><type>BOOL</type> <default>0</default></field> ! <field name="adminnavigation" ><type>text</type></field> ! <field name="modulenavigation" ><type>text</type></field> ! <field name="includes" ><type>text</type></field> ! </fields> ! <keys> ! <key type="primary"> ! <col>dir</col> ! </key> ! </keys> ! </table> ! ! <table name="members"> ! <fields> ! <field name="user" null="no"><type length="128">varchar</type></field> ! <field name="firstname"><type>tinytext</type></field> ! <field name="lastname"><type>tinytext</type></field> ! <field name="lastseen"><type>datetime</type></field> ! <field name="ip"><type>tinytext</type></field> ! <field name="password"><type>text</type></field> ! <field name="authcode"><type>text</type></field> ! <field name="membertype"><type>tinytext</type></field> ! <field name="division"><type>tinytext</type></field> ! <field name="year"><type>year</type></field> ! <field name="email"><type>text</type></field> ! <field name="icq"><type length="11">int</type></field> ! <field name="aim"><type>tinytext</type></field> ! <field name="msn"><type>tinytext</type></field> ! <field name="yim"><type>tinytext</type></field> ! <field name="jabber"><type>tinytext</type></field> ! <field name="description"><type>text</type></field> ! <field name="signature"><type>tinytext</type></field> ! <field name="dateregistered"><type>datetime</type></field> ! <field name="picturelocation"><type>tinytext</type></field> ! <field name="team"><type length="11">int</type></field> ! <field name="skills"><type>text</type></field> ! </fields> ! <keys> ! <key name="user" type="unique"> ! <col>user</col> ! </key> ! </keys> ! </table> ! ! </db> ! </module> --- 1,103 ---- ! <?xml version="1.0"?> ! <module xmlns="http://openfirst.org/xml/module/1.0" id="openfirst.base"> ! <!-- NOTE: This file defines the basic DB layout when installing or upgrading. ! openfirst.base is a psuedo-module for the oF core. --> ! <name>openFIRST portal system</name> ! <version>CVS</version> ! <author>The openFIRST Team</author> ! ! <includes> ! <include>$fBasePath/includes/settings.php</include> ! <include>$fBasePath/includes/slug.php</include> ! </includes> ! ! <!-- Database setup --> ! <db> ! <table name="config"> ! <fields> ! <field name="c_id" null="no" autoincrement="yes"><type unsigned="yes">int</type></field> ! <field name="modulename" null="no"><type length="25">varchar</type> <default></default></field> ! <field name="dir" null="no"><type length="25">varchar</type></field> ! <field name="UpdateDate" null="no"><type>datetime</type></field> ! <field name="label" ><type length="25">varchar</type></field> ! <field name="Author" ><type>tinytext</type></field> ! <field name="Maintainer" ><type>tinytext</type></field> ! <field name="version" null="no"><type length="10">varchar</type> <default>CVS</default></field> ! <field name="showonmenu" null="no"><type>BOOL</type> <default>0</default></field> ! <field name="active" null="no"><type>BOOL</type> <default>0</default></field> ! <field name="adminnavigation" ><type>text</type></field> ! <field name="modulenavigation" ><type>text</type></field> ! <field name="includes" ><type>text</type></field> ! </fields> ! <keys> ! <key type="primary"> ! <col>dir</col> ! </key> ! </keys> ! </table> ! ! <table name="members"> ! <fields> ! <field name="m_id" null="no" autoincrement="yes"><type unsigned="yes">int</type></field> ! <field name="user" null="no"><type length="128">varchar</type></field> ! <field name="firstname"><type>tinytext</type></field> ! <field name="lastname"><type>tinytext</type></field> ! <field name="lastseen"><type>datetime</type></field> ! <field name="ip"><type>tinytext</type></field> ! <field name="password"><type>text</type></field> ! <field name="authcode"><type>text</type></field> ! <field name="membertype"><type>tinytext</type></field> ! <field name="division"><type>tinytext</type></field> ! <field name="year"><type>year</type></field> ! <field name="email"><type>text</type></field> ! <field name="icq"><type length="11">int</type></field> ! <field name="aim"><type>tinytext</type></field> ! <field name="msn"><type>tinytext</type></field> ! <field name="yim"><type>tinytext</type></field> ! <field name="jabber"><type>tinytext</type></field> ! <field name="description"><type>text</type></field> ! <field name="signature"><type>tinytext</type></field> ! <field name="dateregistered"><type>datetime</type></field> ! <field name="picturelocation"><type>tinytext</type></field> ! <field name="team"><type length="11">int</type></field> ! <field name="skills"><type>text</type></field> ! </fields> ! <keys> ! <key name="user" type="unique"> ! <col>user</col> ! </key> ! </keys> ! </table> ! ! <table name="sitesettings"> ! <fields> ! <field name="ss_module" null="no"><type unsigned="yes">int</type></field> ! <field name="ss_setting" null="no"><type length="25">varchar</type></field> ! <field name="ss_value"><type>longtext</type><default></default></field> ! </fields> ! <keys> ! <key name="PRIMARY"> ! <col>ss_module</col> ! <col>ss_setting</col> ! </key> ! </keys> ! </table> ! ! <table name="usersettings"> ! <fields> ! <field name="us_user" null="no"><type unsigned="yes">int</type></field> ! <field name="us_module" null="no"><type unsigned="yes">int</type></field> ! <field name="us_setting" null="no"><type length="25">varchar</type></field> ! <field name="us_value"><type>longtext</type><default></default></field> ! </fields> ! <keys> ! <key name="PRIMARY"> ! <col>us_user</col> ! <col>us_module</col> ! <col>us_setting</col> ! </key> ! </keys> ! </table> ! ! </db> ! </module> |