[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 #$DONT_LOAD_DB=1; 20 $LOAD_ALL_MODULES=1; 21 $USE_OLD_ADODB=1; 22 23 require_once(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR."fileloc.php"); 24 require_once(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR."include.php"); 25 26 load_backwards_compatibility(); 27 28 //Do module autoupgrades 29 function module_autoupgrade() 30 { 31 global $gCms; 32 $db =& $gCms->GetDB(); 33 34 foreach ($gCms->modules as $modulename=>$value) 35 { 36 if ($gCms->modules[$modulename]['object']->AllowAutoUpgrade() == true) 37 { 38 //Check to see what version we currently have in the database (if it's installed) 39 $module_version = false; 40 41 $query = "SELECT version from ".cms_db_prefix()."modules WHERE module_name = ?"; 42 $result = $db->Execute($query, array($modulename)); 43 while ($row = $result->FetchRow()) 44 { 45 $module_version = $row['version']; 46 } 47 48 //Check to see what version we have in the file system 49 $file_version = $gCms->modules[$modulename]['object']->GetVersion(); 50 51 if ($module_version != false) 52 { 53 if (version_compare($file_version, $module_version) == 1) 54 { 55 echo "<p>Upgrading $modulename module from $module_version to $file_version..."; 56 $gCms->modules[$modulename]['object']->Upgrade($module_version, $file_version); 57 $query = "UPDATE ".cms_db_prefix()."modules SET version = ?, admin_only = ? WHERE module_name = ?"; 58 $result = $db->Execute($query, array($file_version, ($gCms->modules[$modulename]['object']->IsAdminOnly()==true?1:0), $modulename)); 59 Events::SendEvent('Core', 'ModuleUpgraded', array('name' => $modulename, 'oldversion' => $module_version, 'newversion' => $file_version)); 60 echo "[Done]</p>"; 61 } 62 } 63 } 64 } 65 } 66 67 ?> 68 69 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 70 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 71 <head> 72 <title>CMS Made Simple Upgrade</title> 73 <link rel="stylesheet" type="text/css" href="install.css" /> 74 </head> 75 76 <body> 77 78 <div class="body"> 79 80 <img src="../images/cms/cmsbanner.jpg" width="800" height="100" alt="CMS Banner Logo" /> 81 82 <div class="headerish"> 83 84 <h1>Upgrade System</h1> 85 86 </div> 87 88 <div class="main"> 89 90 <?php 91 92 clearstatcache(); 93 if (!is_writable(TMP_TEMPLATES_C_LOCATION) || !is_writable(TMP_CACHE_LOCATION)) 94 { 95 echo '<p>The following directories must be writable by the web server:<br />'; 96 echo 'tmp/cache<br />'; 97 echo 'tmp/templates_c<br /></p>'; 98 echo '<p>Please correct by executing:<br /><em>chmod 777 tmp/cache<br />chmod 777 tmp/templates_c</em><br />or the equivilent for your platform before continuing.</p>'; 99 echo '</div></div>'; 100 echo '</body></html>'; 101 exit; 102 } 103 104 if (!isset($_GET["doupgrade"])) { 105 echo "<h3>Welcome to the CMS Upgrade System!</h3>"; 106 107 echo "<p>In order to upgrade properly, upgrade needs to have write access to your config.php file. This is so any extra settings that have been introduced in this version can be set to their defaults.</p>"; 108 } 109 110 if (!is_writable(CONFIG_FILE_LOCATION)) 111 { 112 ?> 113 <p><strong>Problem:</strong> config.php is not writable by the web server. Please fix the permissions and click the button below to check again.</p> 114 115 <p> 116 <form action="upgrade.php" method="post"> 117 <input type="submit" name="submitbutton" value="Try Again" /> 118 </form> 119 </p> 120 <?php 121 } 122 else 123 { 124 echo "<p>Upgrading config.php..."; 125 126 cms_config_upgrade(); 127 $config = cms_config_load(true, true); 128 cms_config_save($config); 129 130 echo "[done]</p>"; 131 132 echo "<p>Cleaning cache dirs..."; 133 134 @clearstatcache(); 135 136 //Clear cache dirs 137 $cpath = TMP_CACHE_LOCATION; 138 $handle=opendir($cpath); 139 while ($cfile = readdir($handle)) { 140 #echo $cpath.$cfile . '--' . var_export(is_file($cpath.DIRECTORY_SEPARATOR.$cfile), true) . "<br />"; 141 if ($cfile != "." && $cfile != ".." && is_file($cpath.DIRECTORY_SEPARATOR.$cfile)) { 142 unlink($cpath.DIRECTORY_SEPARATOR.$cfile); 143 } 144 } 145 $cpath = TMP_TEMPLATES_C_LOCATION; 146 $handle=opendir($cpath); 147 while ($cfile = readdir($handle)) { 148 #echo $cpath.$cfile . '--' . var_export(is_file($cpath.DIRECTORY_SEPARATOR.$cfile), true) . "<br />"; 149 if ($cfile != "." && $cfile != ".." && is_file($cpath.DIRECTORY_SEPARATOR.$cfile)) { 150 unlink($cpath.DIRECTORY_SEPARATOR.$cfile); 151 } 152 } 153 154 echo "[done]</p>"; 155 156 $db = &ADONewConnection($config["dbms"], 'pear:date:extend:transaction'); 157 $db->Connect($config["db_hostname"],$config["db_username"],$config["db_password"],$config["db_name"]); 158 if (!$db) die("Connection failed"); 159 $db->SetFetchMode(ADODB_FETCH_ASSOC); 160 global $gCms; 161 $gCms->db = &$db; 162 163 $current_version = 1; 164 165 $query = "SELECT version from ".cms_db_prefix()."version"; 166 $result = $db->Execute($query); 167 while($result && $row = $result->FetchRow()) 168 { 169 $current_version = $row["version"]; 170 } 171 172 if (!isset($_GET["doupgrade"])) 173 { 174 if ($current_version < $CMS_SCHEMA_VERSION) 175 { 176 echo "<p>CMS is in need of an upgrade.</p><p>You are now running schema version ".$current_version." and you need to be upgraded to version ".$CMS_SCHEMA_VERSION.'.</p><p class="important">Please click <a href="upgrade.php?doupgrade=true">here</a> to complete the upgrade.</p>'; 177 } 178 else 179 { 180 module_autoupgrade(); 181 182 echo "<p>Please review config.php, modify any new settings as necessary and then reset it's permissions back to a locked state. You should also check that all of your modules are up to date, by going to the Extensions -> Modules page and looking for any listed as 'Needs Upgrade'.</p>"; 183 echo "<p>The CMS database is up to date using schema version ".$current_version.". Please remove this file when possible. Click <a href=\"../index.php\">here</a> to go to your CMS site.</p><br />"; 184 } 185 186 } 187 else 188 { 189 while ($current_version < $CMS_SCHEMA_VERSION) 190 { 191 $filename = "upgrades".DIRECTORY_SEPARATOR."upgrade.".$current_version.".to.".($current_version+1).".php"; 192 include($filename); 193 $current_version++; 194 } 195 196 module_autoupgrade(); 197 198 199 echo "<p>Please review config.php, modify any new settings as necessary and then reset it's permissions back to a locked state.</p>"; 200 echo "<p>CMS is up to date. Please click <a href=\"../index.php\">here</a> to go to your CMS site or you can <a href=\"../".$config["admin_dir"]."/\">go to the Admin Panel</a>.</p>"; 201 202 } 203 204 if (file_exists(TMP_CACHE_LOCATION.DIRECTORY_SEPARATOR."SITEDOWN")) 205 { 206 if (!unlink(TMP_CACHE_LOCATION.DIRECTORY_SEPARATOR."SITEDOWN")) 207 { 208 echo "<p class=\"error\"><strong>Error:</strong> Could not remove the tmp/cache/SITEDOWN file. Please remove manually or you will continue to show a \"Site Down for Maintainence\" message on your site.</p>"; 209 } 210 } 211 } 212 213 ?> 214 215 </div> 216 217 </div> 218 219 </body> 220 </html> 221 <?php 222 # vim:ts=4 sw=4 noet 223 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |