Update of /cvsroot/openfirst/update
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15011
Added Files:
sql.php
Log Message:
Add sql.php which just installs databases (it's called remotely)
--- NEW FILE: sql.php ---
<?php
/*
* FTP Installer created file for installing database files.
*
* Copyright (C) 2004,
* openFIRST Project
* Original Author: Tim Ginn <ti...@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: set up OpenFIRST modules
include("../config/globals.php");
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(function_exists("glob")) {
foreach (glob("../*/setup/*.$dbasetype") as $filename) {
$sqlf = str_replace(".", "-", str_replace(".$dbasetype", "",substr(strrchr($filename, "/"), 1)));
$dir = str_replace(".", "-", str_replace(".$dbasetype", "", substr(strchr($filename, "/"), 1)));
echo("<tr><td><br /> <input type='checkbox' name='$dir'>$sqlf - $dir</input></td>");
$q = ofirst_dbquery("CREATE table IF NOT EXISTS `ofirst_config` (`modulename` CHAR(25) NOT NULL,
`showonmenu` BOOL, `active` BOOL, `adminnavigation` TEXT,
`modulenavigation` TEXT, `includes` TEXT, PRIMARY KEY (`modulename`));");
$sf = fopen($filename, "r");
$query = "";
while($line = fgets($sf)) {
if(substr($line, 0, 2) != "--" && substr($line, 0, 1) != "#" && strlen($line) > 0) {
$q = ofirst_dbquery(trim($line));
}
}
fclose($sf);
echo("<td><b><font color='Green'>Module Installed</font></b></td></tr>");
}
} else {
chdir("..");
$handle=@opendir(getcwd());
while ($file = readdir($handle)){
if(is_dir("$file") && $file != "." && $file != "..") {
$handl=@opendir(getcwd() . "/$file/setup/");
while ($fil = @readdir($handl)){
if($fil != ".." && $fil != "." && $fil != "" && strpos($fil, $dbasetype) > 0) {
$filename = "../$file/setup/$fil";
$sqlf = str_replace(".", "-", str_replace(".$dbasetype", "",substr(strrchr($filename, "/"), 1)));
$dir = str_replace(".", "-", str_replace(".$dbasetype", "", substr(strchr($filename, "/"), 1)));
echo("<br /> <input type='checkbox' name='$dir'>$sqlf - $dir</input>");
$q = ofirst_dbquery("CREATE table IF NOT EXISTS `ofirst_config` (`modulename` CHAR(25) NOT NULL,
`showonmenu` BOOL, `active` BOOL, `adminnavigation` TEXT,
`modulenavigation` TEXT, `includes` TEXT, PRIMARY KEY (`modulename`));");
$filename = "$file/setup/$fil";
$sf = fopen($filename, "r");
$query = "";
while($line = fgets($sf, 4096)) {
if(substr($line, 0, 2) != "--" && substr($line, 0, 1) != "#" && strlen($line) > 0) {
$q = ofirst_dbquery(trim($line));
}
}
echo(" - <b>Submitted, and added.</b>");
fclose($sf);
$filename = "../$file/setup/$fil";
}
}
}
}
?>
</table>
|