[Openfirst-cvscommit] update install.php,1.4,1.5 selectinstalldir.php,1.4,1.5
Brought to you by:
xtimg
From: Tim G. <xt...@us...> - 2004-12-01 22:17:04
|
Update of /cvsroot/openfirst/update In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14890 Modified Files: install.php selectinstalldir.php Log Message: Make everything sort of work (or at least be closer to the stage of working) Index: selectinstalldir.php =================================================================== RCS file: /cvsroot/openfirst/update/selectinstalldir.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** selectinstalldir.php 1 Dec 2004 17:52:40 -0000 1.4 --- selectinstalldir.php 1 Dec 2004 22:16:55 -0000 1.5 *************** *** 17,21 **** } ! ftp_chdir($ftpreachable, $system->installdirectory . "/config/"); --- 17,21 ---- } ! ftp_mkdir($ftpreachable, $system->installdirectory . "/config/"); ftp_chdir($ftpreachable, $system->installdirectory . "/config/"); Index: install.php =================================================================== RCS file: /cvsroot/openfirst/update/install.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** install.php 1 Dec 2004 17:52:40 -0000 1.4 --- install.php 1 Dec 2004 22:16:54 -0000 1.5 *************** *** 15,27 **** if(isset($_REQUEST["version"])) { ! $sq = mysql_query("SELECT id, displayname FROM ofirst_systems WHERE owner='$user->id';"); while($s = mysql_fetch_object($sq)) { if(isset($_REQUEST["$s->id"])) { if(mysql_num_rows(mysql_query("SELECT * FROM ofirst_system_software WHERE system='$s->id' AND package='" ! . $_REQUEST["id"] . "'")) == 0) { $q = mysql_query("INSERT INTO ofirst_system_software (system, package, version) VALUES ('$s->id', '" . $_REQUEST["id"] . "', '" . $_REQUEST["version"] . "');"); echo "Added package to $s->displayname<br>"; ! // TODO: Do install here ! } else { --- 15,142 ---- if(isset($_REQUEST["version"])) { ! $sq = mysql_query("SELECT * FROM ofirst_systems WHERE owner='$user->id';"); while($s = mysql_fetch_object($sq)) { if(isset($_REQUEST["$s->id"])) { if(mysql_num_rows(mysql_query("SELECT * FROM ofirst_system_software WHERE system='$s->id' AND package='" ! . $_REQUEST["id"] . "'")) == 0) { ! ! $system = $s; ! ! $ftpreachable = ftp_connect($system->ftpserver); ! if($ftpreachable) { ! $loginokay = @ftp_login($ftpreachable, $system->ftpusername, $system->ftppassword); ! } ! if(! $ftpreachable || ! $loginokay) { ! echo "FTP server is unreachable or cannot login properly."; ! include_once($footer); ! die(); ! } ! ! ! $q = mysql_query("INSERT INTO ofirst_system_software (system, package, version) VALUES ('$s->id', '" . $_REQUEST["id"] . "', '" . $_REQUEST["version"] . "');"); echo "Added package to $s->displayname<br>"; ! flush(); ! $p = mysql_fetch_object(mysql_query("SELECT * FROM ofirst_directory_software_versions WHERE id='" . $_REQUEST["id"] . "';")); ! ! //fetch file ! echo "Getting file...<br>"; ! flush(); ! if(! is_readable("/tmp/systems/")) { ! mkdir("/tmp/systems"); ! } ! if(! is_readable("/tmp/systems/$s->id")) { ! mkdir("/tmp/systems/$s->id"); ! } ! if(! is_readable("/tmp/systems/$s->id/$p->id")) { ! mkdir("/tmp/systems/$s->id/$p->id"); ! } ! // system("wget $p->packageaddress -O /tmp/systems/$s->id/$p->id/pkg.tgz"); ! echo "done."; ! flush(); ! echo "Extracting file...<br>"; ! flush(); ! // extract file ! chdir("/tmp/systems/$s->id/$p->id/"); ! system("tar xzf pkg.tgz"); ! ! // remove globals ! @unlink("base/config/globals.php"); ! @unlink("openfirst/config/globals.php"); ! system("mv base/* .; rm -rf base/"); ! system("mv openfirst/* .; rm -rf openfirst/"); ! @unlink("pkg.tgz"); ! ! echo "done."; ! flush(); ! ! // upload files ! ! ! function rglob($sDir, $sPattern, $nFlags = NULL) { ! $sDir = escapeshellcmd($sDir); ! ! $aFiles = glob("$sDir/$sPattern", $nFlags); ! ! foreach (glob("$sDir/*", GLOB_ONLYDIR) as $sSubDir) { ! // Do not follow symbolic links, as this can cause infinite recursion as this can cause infinite recursion if a link within a directory points to its parent. ! if(! is_link($sSubDir)) { ! $aSubFiles = rglob($sSubDir, $sPattern, $nFlags); ! $aFiles = array_merge($aFiles, $aSubFiles); ! } ! } ! ! // The array we return contains the files we found, and the ! // files all of our children found. ! ! return $aFiles; ! } ! ! ! echo "Creating directory skeleton\n"; ! flush; ! foreach (rglob("/tmp/systems/$s->id/$p->id/", "*") as $filename) { ! if(is_dir($filename) && ! is_link($filename)) { ! ftp_mkdir($ftpreachable, $s->installdirectory . "/" . str_replace("/tmp/systems/$s->id/$p->id/", "", $filename)); ! unset($filename); ! } ! } ! echo "done\n"; ! flush; ! echo "Upload files\n"; ! flush; ! foreach (rglob("/tmp/systems/$s->id/$p->id/", "*") as $filename) { ! if(is_file($filename) && ! is_link($filename)) { ! $ftp = fopen($filename, 'r'); ! @ftp_fput($ftpreachable, $s->installdirectory . "/" . str_replace("/tmp/systems/$s->id/$p->id/", "", $filename), $ftp, FTP_BINARY); ! fclose($ftp); ! unset($filename); ! } ! } ! echo "done"; ! flush; ! ! ! ! ! ! ! ! ! ! ! ! echo "Uploading database installer."; ! flush(); ! // upload sql installer ! $ftp = fopen('/home/ofirst/public_html/update/test/update/sql.php', 'r'); ! ftp_fput($ftpreachable, $s->installdirectory . "/config/sql.php", $ftp, FTP_BINARY); ! fclose($ftp); ! flush(); ! echo "installing databases.<br>"; ! flush(); ! // run sql installer ! include_once("http://$s->home" . $s->basepath . "/config/sql.php"); ! flush(); } else { |