| [ Index ] |
|
Code source de Phorum 5.1.25 |
1 <?php 2 3 /////////////////////////////////////////////////////////////////////////////// 4 // // 5 // Copyright (C) 2006 Phorum Development Team // 6 // http://www.phorum.org // 7 // // 8 // This program is free software. You can redistribute it and/or modify // 9 // it under the terms of either the current Phorum License (viewable at // 10 // phorum.org) or the Phorum License that was distributed with this file // 11 // // 12 // This program is distributed in the hope that it will be useful, // 13 // but WITHOUT ANY WARRANTY, without even the implied warranty of // 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // 15 // // 16 // You should have received a copy of the Phorum License // 17 // along with this program. // 18 /////////////////////////////////////////////////////////////////////////////// 19 define("phorum_page", "console_upgrade"); 20 define("PHORUM_ADMIN", 1); 21 22 // I guess the phorum-directory is one level up. if you move the script to 23 // somewhere else you'll need to change that. 24 $PHORUM_DIRECTORY="../"; 25 26 // change directory to the main-dir so we can use common.php 27 if(file_exists($PHORUM_DIRECTORY."/common.php")) { 28 chdir($PHORUM_DIRECTORY); 29 } else { 30 echo "Can't find common.php in the given directory. Please check the \$PHORUM_DIRECTORY -setting in console_upgrade.php\n"; 31 exit(); 32 } 33 34 // include required files 35 include_once './common.php'; 36 include_once './include/users.php'; 37 38 // if we are running in the webserver, bail out 39 if (isset($_SERVER["REMOTE_ADDR"])) { 40 echo $PHORUM["DATA"]["LANG"]["CannotBeRunFromBrowser"]; 41 return; 42 } 43 44 // no database connection? 45 if(!phorum_db_check_connection()){ 46 echo "A database connection could not be established. Please edit include/db/config.php.\n"; 47 return; 48 } else { 49 echo "Database connection confirmed, we will start the upgrade.\n"; 50 flush(); 51 } 52 53 // no need for upgrade 54 if(isset($PHORUM['internal_version']) && $PHORUM['internal_version'] == PHORUMINTERNAL){ 55 echo "Your install is already up-to-date. No database-upgrade needed.\n"; 56 return; 57 } 58 59 if (! ini_get('safe_mode')) { 60 echo "Trying to reset the timeout and rise the memory-limit ...\n"; 61 set_time_limit(0); 62 ini_set("memory_limit","64M"); 63 } 64 65 $fromversion=$PHORUM['internal_version']; 66 67 $upgradepath="./include/db/upgrade/{$PHORUM['DBCONFIG']['type']}/"; 68 69 // read in all existing files 70 $dh=opendir($upgradepath); 71 $upgradefiles=array(); 72 while ($file = readdir ($dh)) { 73 if (substr($file,-4,4) == ".php") { 74 $upgradefiles[]=$file; 75 } 76 } 77 unset($file); 78 closedir($dh); 79 80 // sorting by number 81 sort($upgradefiles,SORT_NUMERIC); 82 reset($upgradefiles); 83 84 // advance to current version 85 while(list($key,$val)=each($upgradefiles)) { 86 if($val == $fromversion.".php") 87 break; 88 } 89 90 91 while(list($dump,$file) = each($upgradefiles)) { 92 93 // extract the pure version, needed as internal version 94 $pure_version = basename($file,".php"); 95 96 if(empty($pure_version)){ 97 die("Something is wrong with the upgrade script. Please contact the Phorum Dev Team. ($fromversion,$pure_version)"); 98 } 99 100 101 $upgradefile=$upgradepath.$file; 102 103 if(file_exists($upgradefile)) { 104 echo "Upgrading from db-version $fromversion to $pure_version ... \n"; 105 flush(); 106 107 if (! is_readable($upgradefile)) 108 die("$upgradefile is not readable. Make sure the file has got the neccessary permissions and try again."); 109 110 111 $upgrade_queries=array(); 112 include($upgradefile); 113 $err=phorum_db_run_queries($upgrade_queries); 114 if($err){ 115 echo "an error occured: $err ... try to continue.\n"; 116 } else { 117 echo "done.\n"; 118 } 119 $GLOBALS["PHORUM"]["internal_version"]=$pure_version; 120 phorum_db_update_settings(array("internal_version"=>$pure_version)); 121 } else { 122 echo "Ooops, the upgradefile is missing. How could this happen?\n"; 123 } 124 125 $fromversion=$pure_version; 126 127 } 128 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Thu Nov 29 12:22:27 2007 | par Balluche grâce à PHPXref 0.7 |
|