Revision 2097
Added by darkviper almost 11 years ago
upgrade-script.php | ||
---|---|---|
34 | 34 |
* @deprecated |
35 | 35 |
* @description xyz |
36 | 36 |
*/ |
37 |
include_once(dirname(__FILE__).'/framework/UpgradeHelper.php'); |
|
38 | 37 |
// PHP less then 5.3.2 is prohibited --- |
39 | 38 |
if (version_compare(PHP_VERSION, '5.3.2', '<')) { |
40 | 39 |
$sMsg = '<p style="color: #ff0000;">WebsiteBaker 2.8.4 and above is not able to run with PHP-Version less then 5.3.2!!<br />' |
... | ... | |
43 | 42 |
. 'The very best solution is the use of PHP-5.4 and up</p>'; |
44 | 43 |
die($sMsg); |
45 | 44 |
} |
45 |
// --- load UpgradeHelper --- |
|
46 |
if (!class_exists('UpgradeHelper', false)) { |
|
47 |
require(__DIR__.'/framework/UpgradeHelper.php'); |
|
48 |
} |
|
46 | 49 |
// --- delete fatal disturbing files before upgrade starts ------------------------------- |
47 | 50 |
$aPreDeleteFiles = array( |
48 | 51 |
// list of files |
49 | 52 |
dirname(__FILE__).'/framework/PasswordHash.php' |
50 | 53 |
); |
51 |
if(sizeof($aPreDeleteFiles > 0))
|
|
52 |
{ |
|
54 |
$sMsg = '';
|
|
55 |
if (sizeof($aPreDeleteFiles > 0)) {
|
|
53 | 56 |
// if there are files defined |
54 |
$sMsg = ''; |
|
55 |
foreach($aPreDeleteFiles as $sFileToDelete) |
|
56 |
{ |
|
57 |
foreach ($aPreDeleteFiles as $sFileToDelete) { |
|
57 | 58 |
// iterate the list |
58 |
if(file_exists($sFileToDelete)) |
|
59 |
{ |
|
60 |
if(!is_writeable($sFileToDelete) || !@unlink($sFileToDelete)) |
|
61 |
{ |
|
59 |
if (file_exists($sFileToDelete)) { |
|
60 |
if (!is_writeable($sFileToDelete) || !@unlink($sFileToDelete)) { |
|
62 | 61 |
// notice if deleting fails |
63 | 62 |
$sMsg .= '<span style="color:red;">FAILED</span> deleting: ' |
64 | 63 |
. $sFileToDelete.'<br />'.PHP_EOL; |
65 | 64 |
} |
66 | 65 |
} |
67 | 66 |
} |
68 |
if($sMsg) { |
|
67 |
if ($sMsg) {
|
|
69 | 68 |
// stop script if there's an error occured |
70 |
$sMsg = $sMsg.'<br />'.PHP_EOL.'Please delete all of the files above manually!';
|
|
71 |
UpgradeHelper::dieWithMessage($sMsg);
|
|
69 |
$sMsg .= '<br />'.PHP_EOL.'Please delete all of the files above manually!';
|
|
70 |
$sMsg .= '<br />'.PHP_EOL.'----------------------------------------------';
|
|
72 | 71 |
} |
73 | 72 |
} |
73 |
if ($sMsg) { |
|
74 |
// stop script if there's an error occured |
|
75 |
$sMsg = $sMsg.'<br />'.PHP_EOL.'Please delete all of the files above manually!'; |
|
76 |
UpgradeHelper::dieWithMessage($sMsg); |
|
77 |
} |
|
74 | 78 |
unset($aPreDeleteFiles); |
75 | 79 |
$sMsg = ''; |
76 | 80 |
// --------------------------------------------------------------------------------------- |
77 | 81 |
// Include config file |
78 |
$config_file = dirname(__FILE__).'/config.php';
|
|
82 |
$config_file = __DIR__.'/config.php';
|
|
79 | 83 |
if (is_readable($config_file) && !defined('WB_URL')) { |
80 | 84 |
require_once($config_file); |
81 | 85 |
} |
86 |
$oDb = WbDatabase::getInstance(); |
|
82 | 87 |
$oReg = WbAdaptor::getInstance(); |
83 |
UpgradeHelper::checkSetupFiles(dirname(__FILE__).'/'); |
|
84 |
|
|
85 |
if (!class_exists('admin', false)) { |
|
86 |
include(WB_PATH.'/framework/class.admin.php'); |
|
88 |
UpgradeHelper::checkSetupFiles(str_replace('\\', '/', __DIR__).'/'); |
|
89 |
// --- set DEFAULT_THEME and restart if needed ------------------------------------------- |
|
90 |
if (isset($oReg->DefaultTheme) && $oReg->DefaultTheme != 'WbTheme') { |
|
91 |
db_update_key_value('settings', 'default_theme', 'WbTheme'); |
|
92 |
$sLocation = 'Location: '.$oReg->AppUrl.filename(__FILE__); |
|
93 |
header($sLocation); |
|
94 |
exit; |
|
87 | 95 |
} |
96 |
// --------------------------------------------------------------------------------------- |
|
97 |
//if (!class_exists('admin', false)) { |
|
98 |
// include(WB_PATH.'/framework/class.admin.php'); |
|
99 |
//} |
|
88 | 100 |
$admin = new admin('Addons', 'modules', false, false); |
89 | 101 |
// solved wrong pages_directory value before creating access files |
90 | 102 |
$sql = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` ' |
91 | 103 |
. 'WHERE `name`=\'pages_directory\''; |
92 |
$sPagesDirectory = WbDatabase::getInstance()->get_one($sql);
|
|
104 |
$sPagesDirectory = $oDb->getOne($sql);
|
|
93 | 105 |
$sTmp = trim($sPagesDirectory, '/'); |
94 | 106 |
$sTmpDir = ($sTmp == '' ? '' : '/'.$sTmp); |
95 | 107 |
if($sTmp != $sPagesDirectory) { |
96 |
$sql = 'UPDATE `'.TABLE_PREFIX.'settings` '
|
|
97 |
. 'SET `value` = \''.$sTmpDir.'\' '
|
|
108 |
$sql = 'UPDATE `'.$oDb->TablePrefix.'settings` '
|
|
109 |
. 'SET `value`=\''.$sTmpDir.'\' '
|
|
98 | 110 |
. 'WHERE `name`=\'pages_directory\' '; |
99 |
WbDatabase::getInstance()->query($sql); |
|
111 |
$oDb->doQuery($sql); |
|
112 |
// WbDatabase::getInstance()->query($sql); |
|
100 | 113 |
} |
101 | 114 |
require_once(WB_PATH.'/framework/functions.php'); |
102 | 115 |
// require_once(WB_PATH.'/framework/Database.php'); |
... | ... | |
1113 | 1126 |
$iFound = 0; |
1114 | 1127 |
$iLoaded = 0; |
1115 | 1128 |
////delete templates |
1116 |
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
|
|
1129 |
$oDb->doQuery('DELETE FROM `'.$oDb->TablePrefix.'addons` WHERE `type`=\'template\'');
|
|
1117 | 1130 |
// Load all templates |
1118 | 1131 |
if( ($handle = opendir(WB_PATH.'/templates/')) ) { |
1119 | 1132 |
while(false !== ($file = readdir($handle))) { |
1120 | 1133 |
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') { |
1121 |
|
|
1122 | 1134 |
$iFound++; |
1123 | 1135 |
$iLoaded = (load_template(WB_PATH.'/templates/'.$file)==true) ? $iLoaded+1 : $iLoaded; |
1124 |
|
|
1125 | 1136 |
} |
1126 | 1137 |
} |
1127 | 1138 |
closedir($handle); |
Also available in: Unified diff
! upgrade-script.php >> new classes activated and little corrections
! WbAdaptor::getWbConstants() >> PageIconDir added