| 1 | <?php
 | 
  
    | 2 | /**
 | 
  
    | 3 |  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 | 
  
    | 4 |  *
 | 
  
    | 5 |  * This program is free software: you can redistribute it and/or modify
 | 
  
    | 6 |  * it under the terms of the GNU General Public License as published by
 | 
  
    | 7 |  * the Free Software Foundation, either version 3 of the License, or
 | 
  
    | 8 |  * (at your option) any later version.
 | 
  
    | 9 |  *
 | 
  
    | 10 |  * This program is distributed in the hope that it will be useful,
 | 
  
    | 11 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
  
    | 12 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
  
    | 13 |  * GNU General Public License for more details.
 | 
  
    | 14 |  *
 | 
  
    | 15 |  * You should have received a copy of the GNU General Public License
 | 
  
    | 16 |  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
  
    | 17 |  */
 | 
  
    | 18 | 
 | 
  
    | 19 | /**
 | 
  
    | 20 |  * 
 | 
  
    | 21 |  * 
 | 
  
    | 22 |  * @category     Core
 | 
  
    | 23 |  * @package      Core_service
 | 
  
    | 24 |  * @subpackage   upgrade-script
 | 
  
    | 25 |  * @author       Dietmar Wöllbrink <dietmar.woellbrink@websitebaker.org>
 | 
  
    | 26 |  * @author       Werner v.d.Decken <wkl@isteam.de>
 | 
  
    | 27 |  * @copyright    Werner v.d.Decken <wkl@isteam.de>
 | 
  
    | 28 |  * @license      http://www.gnu.org/licenses/gpl.html   GPL License
 | 
  
    | 29 |  * @version      0.0.1
 | 
  
    | 30 |  * @revision     $Revision: 2097 $
 | 
  
    | 31 |  * @link         $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/upgrade-script.php $
 | 
  
    | 32 |  * @lastmodified $Date: 2014-02-11 02:25:41 +0100 (Tue, 11 Feb 2014) $
 | 
  
    | 33 |  * @since        File available since 17.01.2013
 | 
  
    | 34 |  * @deprecated   
 | 
  
    | 35 |  * @description  xyz
 | 
  
    | 36 |  */
 | 
  
    | 37 | // PHP less then 5.3.2 is prohibited ---
 | 
  
    | 38 | if (version_compare(PHP_VERSION, '5.3.2', '<')) {
 | 
  
    | 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 />'
 | 
  
    | 40 |           . 'Please change your PHP-Version to any kind from 5.3.2 and up!<br />'
 | 
  
    | 41 |           . 'If you have problems to solve that, ask your hosting provider for it.<br  />'
 | 
  
    | 42 |           . 'The very best solution is the use of PHP-5.4 and up</p>';
 | 
  
    | 43 |     die($sMsg);
 | 
  
    | 44 | }
 | 
  
    | 45 | // --- load UpgradeHelper ---
 | 
  
    | 46 | if (!class_exists('UpgradeHelper', false)) {
 | 
  
    | 47 |     require(__DIR__.'/framework/UpgradeHelper.php');
 | 
  
    | 48 | }
 | 
  
    | 49 | // --- delete fatal disturbing files before upgrade starts -------------------------------
 | 
  
    | 50 | $aPreDeleteFiles = array(
 | 
  
    | 51 | // list of files
 | 
  
    | 52 | 	dirname(__FILE__).'/framework/PasswordHash.php'
 | 
  
    | 53 | );
 | 
  
    | 54 | $sMsg = '';
 | 
  
    | 55 | if (sizeof($aPreDeleteFiles > 0)) {
 | 
  
    | 56 | // if there are files defined
 | 
  
    | 57 | 	foreach ($aPreDeleteFiles as $sFileToDelete) {
 | 
  
    | 58 | 	// iterate the list
 | 
  
    | 59 | 		if (file_exists($sFileToDelete)) {
 | 
  
    | 60 | 			if (!is_writeable($sFileToDelete) || !@unlink($sFileToDelete)) {
 | 
  
    | 61 | 			// notice if deleting fails
 | 
  
    | 62 | 				$sMsg .= '<span style="color:red;">FAILED</span> deleting: '
 | 
  
    | 63 | 				       . $sFileToDelete.'<br />'.PHP_EOL;
 | 
  
    | 64 | 			}
 | 
  
    | 65 | 		}
 | 
  
    | 66 | 	}
 | 
  
    | 67 | 	if ($sMsg) {
 | 
  
    | 68 | 	// stop script if there's an error occured
 | 
  
    | 69 | 		$sMsg .= '<br />'.PHP_EOL.'Please delete all of the files above manually!';
 | 
  
    | 70 | 		$sMsg .= '<br />'.PHP_EOL.'----------------------------------------------';
 | 
  
    | 71 | 	}
 | 
  
    | 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 | }
 | 
  
    | 78 | unset($aPreDeleteFiles);
 | 
  
    | 79 | $sMsg = '';
 | 
  
    | 80 | // ---------------------------------------------------------------------------------------
 | 
  
    | 81 | // Include config file
 | 
  
    | 82 | $config_file = __DIR__.'/config.php';
 | 
  
    | 83 | if (is_readable($config_file) && !defined('WB_URL')) {
 | 
  
    | 84 | 	require_once($config_file);
 | 
  
    | 85 | }
 | 
  
    | 86 | $oDb  = WbDatabase::getInstance();
 | 
  
    | 87 | $oReg = WbAdaptor::getInstance();
 | 
  
    | 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;
 | 
  
    | 95 | }
 | 
  
    | 96 | // ---------------------------------------------------------------------------------------
 | 
  
    | 97 | //if (!class_exists('admin', false)) {
 | 
  
    | 98 | //	include(WB_PATH.'/framework/class.admin.php');
 | 
  
    | 99 | //}
 | 
  
    | 100 | $admin = new admin('Addons', 'modules', false, false);
 | 
  
    | 101 | // solved wrong pages_directory value before creating access files
 | 
  
    | 102 | $sql  = 'SELECT `value` FROM `'.TABLE_PREFIX.'settings` '
 | 
  
    | 103 |       . 'WHERE `name`=\'pages_directory\'';
 | 
  
    | 104 | $sPagesDirectory = $oDb->getOne($sql);
 | 
  
    | 105 | $sTmp = trim($sPagesDirectory, '/');
 | 
  
    | 106 | $sTmpDir = ($sTmp == '' ? '' : '/'.$sTmp);
 | 
  
    | 107 | if($sTmp != $sPagesDirectory) {
 | 
  
    | 108 | 	$sql = 'UPDATE `'.$oDb->TablePrefix.'settings` '
 | 
  
    | 109 | 		 . 'SET `value`=\''.$sTmpDir.'\' '
 | 
  
    | 110 | 		 . 'WHERE `name`=\'pages_directory\' ';
 | 
  
    | 111 | 	$oDb->doQuery($sql);
 | 
  
    | 112 | //	WbDatabase::getInstance()->query($sql);
 | 
  
    | 113 | }
 | 
  
    | 114 | require_once(WB_PATH.'/framework/functions.php');
 | 
  
    | 115 | // require_once(WB_PATH.'/framework/Database.php');
 | 
  
    | 116 | 
 | 
  
    | 117 | $oldVersion  = 'Version '.WB_VERSION;
 | 
  
    | 118 | $oldVersion .= (defined('WB_SP') ? WB_SP : '');
 | 
  
    | 119 | $oldRevision = (defined('WB_REVISION') ? ' Revision ['.WB_REVISION.'] ' : '') ;
 | 
  
    | 120 | $newVersion  = 'Version '.VERSION;
 | 
  
    | 121 | $newVersion .= (defined('SP') ? SP : '');
 | 
  
    | 122 | $newRevision = (defined('REVISION') ? ' Revision ['.REVISION.'] ' : '');
 | 
  
    | 123 | 
 | 
  
    | 124 | $bDebugModus = false;
 | 
  
    | 125 | 
 | 
  
    | 126 | // set addition settings if not exists, otherwise upgrade will be breaks
 | 
  
    | 127 | if(!defined('WB_SP')) { define('WB_SP',''); }
 | 
  
    | 128 | if(!defined('WB_REVISION')) { define('WB_REVISION',''); }
 | 
  
    | 129 | // database tables including in WB package
 | 
  
    | 130 | $aPackage = array (
 | 
  
    | 131 |     'settings','groups','addons','pages','sections','search','users',
 | 
  
    | 132 |     'mod_captcha_control','mod_jsadmin','mod_menu_link','mod_output_filter','mod_wrapper','mod_wysiwyg'
 | 
  
    | 133 | );
 | 
  
    | 134 | 
 | 
  
    | 135 | $OK            = ' <span class="ok">OK</span> ';
 | 
  
    | 136 | $FAIL          = ' <span class="error">FAILED</span> ';
 | 
  
    | 137 | $DEFAULT_THEME = 'WbTheme';
 | 
  
    | 138 | 
 | 
  
    | 139 | $stepID = 1;
 | 
  
    | 140 | $dirRemove = array(
 | 
  
    | 141 | //			'[TEMPLATE]allcss/',
 | 
  
    | 142 | //			'[TEMPLATE]blank/',
 | 
  
    | 143 | //			'[TEMPLATE]round/',
 | 
  
    | 144 | //			'[TEMPLATE]simple/',
 | 
  
    | 145 |             '[TEMPLATE]wb_theme/',
 | 
  
    | 146 | 			'[ADMIN]themes/'
 | 
  
    | 147 | 		 );
 | 
  
    | 148 | 
 | 
  
    | 149 | $aRemoveSingleFiles = array(
 | 
  
    | 150 | 			'[ADMIN]preferences/details.php',
 | 
  
    | 151 | 			'[ADMIN]preferences/email.php',
 | 
  
    | 152 | 			'[ADMIN]preferences/password.php',
 | 
  
    | 153 | 			'[ADMIN]pages/settings2.php',
 | 
  
    | 154 | 			'[ADMIN]users/users.php',
 | 
  
    | 155 | 			'[ADMIN]groups/add.php',
 | 
  
    | 156 | 			'[ADMIN]groups/groups.php',
 | 
  
    | 157 | 			'[ADMIN]groups/save.php',
 | 
  
    | 158 | 			'[ADMIN]skel/themes/htt/groups.htt',
 | 
  
    | 159 | 
 | 
  
    | 160 | 			'[FRAMEWORK]class.msg_queue.php',
 | 
  
    | 161 | 			'[FRAMEWORK]class.logfile.php',
 | 
  
    | 162 | 			'[FRAMEWORK]PasswordHash.php',
 | 
  
    | 163 | 			'[MODULES]droplets/js/mdcr.js'
 | 
  
    | 164 | );
 | 
  
    | 165 | // deleting files below only from less 2.8.4 stable
 | 
  
    | 166 | if(version_compare(WB_VERSION, '2.8.4', '<'))
 | 
  
    | 167 | {
 | 
  
    | 168 | 	$aRemoveOldTemplates = array(
 | 
  
    | 169 | 			'[TEMPLATE]argos_theme/templates/access.htt',
 | 
  
    | 170 | 			'[TEMPLATE]argos_theme/templates/addons.htt',
 | 
  
    | 171 | 			'[TEMPLATE]argos_theme/templates/admintools.htt',
 | 
  
    | 172 | 			'[TEMPLATE]argos_theme/templates/error.htt',
 | 
  
    | 173 | 			'[TEMPLATE]argos_theme/templates/groups.htt',
 | 
  
    | 174 | 			'[TEMPLATE]argos_theme/templates/groups_form.htt',
 | 
  
    | 175 | 			'[TEMPLATE]argos_theme/templates/languages.htt',
 | 
  
    | 176 | 			'[TEMPLATE]argos_theme/templates/languages_details.htt',
 | 
  
    | 177 | 			'[TEMPLATE]argos_theme/templates/login.htt',
 | 
  
    | 178 | 			'[TEMPLATE]argos_theme/templates/login_forgot.htt',
 | 
  
    | 179 | 			'[TEMPLATE]argos_theme/templates/media.htt',
 | 
  
    | 180 | 			'[TEMPLATE]argos_theme/templates/media_browse.htt',
 | 
  
    | 181 | 			'[TEMPLATE]argos_theme/templates/media_rename.htt',
 | 
  
    | 182 | 			'[TEMPLATE]argos_theme/templates/modules.htt',
 | 
  
    | 183 | 			'[TEMPLATE]argos_theme/templates/modules_details.htt',
 | 
  
    | 184 | 			'[TEMPLATE]argos_theme/templates/pages.htt',
 | 
  
    | 185 | 			'[TEMPLATE]argos_theme/templates/pages_modify.htt',
 | 
  
    | 186 | 			'[TEMPLATE]argos_theme/templates/pages_sections.htt',
 | 
  
    | 187 | 			'[TEMPLATE]argos_theme/templates/pages_settings.htt',
 | 
  
    | 188 | 			'[TEMPLATE]argos_theme/templates/preferences.htt',
 | 
  
    | 189 | 			'[TEMPLATE]argos_theme/templates/setparameter.htt',
 | 
  
    | 190 | 			'[TEMPLATE]argos_theme/templates/settings.htt',
 | 
  
    | 191 | 			'[TEMPLATE]argos_theme/templates/start.htt',
 | 
  
    | 192 | 			'[TEMPLATE]argos_theme/templates/success.htt',
 | 
  
    | 193 | 			'[TEMPLATE]argos_theme/templates/templates.htt',
 | 
  
    | 194 | 			'[TEMPLATE]argos_theme/templates/templates_details.htt',
 | 
  
    | 195 | 			'[TEMPLATE]argos_theme/templates/users.htt',
 | 
  
    | 196 | 			'[TEMPLATE]argos_theme/templates/users_form.htt'
 | 
  
    | 197 | 	);
 | 
  
    | 198 | }else {
 | 
  
    | 199 | 	$aRemoveOldTemplates = array();
 | 
  
    | 200 | }
 | 
  
    | 201 | $aFilesToRemove = array_merge($aRemoveSingleFiles, $aRemoveOldTemplates);
 | 
  
    | 202 | unset($aRemoveSingleFiles);
 | 
  
    | 203 | unset($aRemoveOldTemplates);
 | 
  
    | 204 | /* display a status message on the screen **************************************
 | 
  
    | 205 |  * @param string $message: the message to show
 | 
  
    | 206 |  * @param string $class:   kind of message as a css-class
 | 
  
    | 207 |  * @param string $element: witch HTML-tag use to cover the message
 | 
  
    | 208 |  * @return void
 | 
  
    | 209 |  */
 | 
  
    | 210 | function status_msg($message, $class='check', $element='div')
 | 
  
    | 211 | {
 | 
  
    | 212 | 	// returns a status message
 | 
  
    | 213 | 	$msg  = '<'.$element.' class="'.$class.'">';
 | 
  
    | 214 | 	$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong>';
 | 
  
    | 215 | 	$msg .= $message.'</'.$element.'>';
 | 
  
    | 216 | 	echo $msg;
 | 
  
    | 217 | }
 | 
  
    | 218 | 
 | 
  
    | 219 | /**
 | 
  
    | 220 |  * add_modify_field_in_database()
 | 
  
    | 221 |  *
 | 
  
    | 222 |  * @param mixed $sTable
 | 
  
    | 223 |  * @param mixed $sField
 | 
  
    | 224 |  * @param mixed $sDescription
 | 
  
    | 225 |  * @return
 | 
  
    | 226 |  */
 | 
  
    | 227 | function add_modify_field_in_database($sTable,$sField,$sDescription){
 | 
  
    | 228 | 	global $OK,$FAIL,$bDebugModus;
 | 
  
    | 229 | 	$database=WbDatabase::getInstance();
 | 
  
    | 230 | 	$aDebugMessage = array();
 | 
  
    | 231 | 	if(!$database->field_exists($sTable,$sField)) {
 | 
  
    | 232 | 		$aDebugMessage[] = "<span>Adding field $sField to $sTable table</span>";
 | 
  
    | 233 | 		$aDebugMessage[] = ($database->field_add($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 234 | 	} else {
 | 
  
    | 235 | 		$aDebugMessage[] = "<span>Modify field $sField to $sTable table</span>";
 | 
  
    | 236 | 		$aDebugMessage[] = ($database->field_modify($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 237 | 	}
 | 
  
    | 238 | 	if($bDebugModus) {
 | 
  
    | 239 | 		echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 240 | 	}
 | 
  
    | 241 | return;
 | 
  
    | 242 | }
 | 
  
    | 243 | 
 | 
  
    | 244 | ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
  
    | 245 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 | 
  
    | 246 | <head>
 | 
  
    | 247 | <title>Upgrade script</title>
 | 
  
    | 248 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
  
    | 249 | <style type="text/css">
 | 
  
    | 250 | html { overflow-y: scroll; /* Force firefox to always show room for a vertical scrollbar */ }
 | 
  
    | 251 | 
 | 
  
    | 252 | body {
 | 
  
    | 253 | 	margin:0;
 | 
  
    | 254 | 	padding:0;
 | 
  
    | 255 | 	border:0;
 | 
  
    | 256 | 	background: #EBF7FC;
 | 
  
    | 257 | 	color:#000;
 | 
  
    | 258 | 	font-family: 'Trebuchet MS', Verdana, Arial, Helvetica, Sans-Serif;
 | 
  
    | 259 | 	font-size: small;
 | 
  
    | 260 | 	height:101%;
 | 
  
    | 261 | }
 | 
  
    | 262 | 
 | 
  
    | 263 | #container {
 | 
  
    | 264 | 	min-width:48em;
 | 
  
    | 265 |     width: 70%;
 | 
  
    | 266 | 	background: #A8BCCB url(<?php echo WB_URL; ?>/templates/<?php echo $DEFAULT_THEME; ?>/images/background.png) repeat-x;
 | 
  
    | 267 | 	border:1px solid #000;
 | 
  
    | 268 | 	color:#000;
 | 
  
    | 269 | 	margin:2em auto;
 | 
  
    | 270 | 	padding:0 20px;
 | 
  
    | 271 | 	min-height: 500px;
 | 
  
    | 272 | 	text-align:left;
 | 
  
    | 273 | }
 | 
  
    | 274 | .page {
 | 
  
    | 275 | 	width:100%;
 | 
  
    | 276 |     overflow: hidden;
 | 
  
    | 277 | }
 | 
  
    | 278 | .content {
 | 
  
    | 279 |     padding: 10px;
 | 
  
    | 280 | }
 | 
  
    | 281 | p { line-height:1.5em; }
 | 
  
    | 282 | 
 | 
  
    | 283 | form {
 | 
  
    | 284 | 	display: inline-block;
 | 
  
    | 285 | 	line-height: 20px;
 | 
  
    | 286 | 	vertical-align: baseline;
 | 
  
    | 287 | }
 | 
  
    | 288 | input[type="submit"].restart {
 | 
  
    | 289 | 	background-color: #FFDBDB;
 | 
  
    | 290 | 	font-weight: bold;
 | 
  
    | 291 | }
 | 
  
    | 292 | 
 | 
  
    | 293 | h1,h2,h3,h4,h5,h6 {
 | 
  
    | 294 | 	font-family: Verdana, Arial, Helvetica, sans-serif;
 | 
  
    | 295 | 	color: #26527D;
 | 
  
    | 296 | 	margin-top: 1.0em;
 | 
  
    | 297 | 	margin-bottom: 0.1em;
 | 
  
    | 298 | }
 | 
  
    | 299 | 
 | 
  
    | 300 | h1 { font-size:150%; }
 | 
  
    | 301 | h2 { font-size: 130%; border-bottom: 1px #CCC solid; }
 | 
  
    | 302 | h3 { font-size: 110%; font-weight: bold; }
 | 
  
    | 303 | 
 | 
  
    | 304 | textarea {
 | 
  
    | 305 | 	width:100%;
 | 
  
    | 306 | 	border: 2px groove #0F1D44;
 | 
  
    | 307 | 	padding: 2px;
 | 
  
    | 308 | 	color: #000;
 | 
  
    | 309 | 	font-weight: normal;
 | 
  
    | 310 | }
 | 
  
    | 311 | .ok, .error { font-weight:bold; }
 | 
  
    | 312 | .ok { color:green; }
 | 
  
    | 313 | .error { color:red; }
 | 
  
    | 314 | .check { color:#555; }
 | 
  
    | 315 | 
 | 
  
    | 316 | span.ok,
 | 
  
    | 317 | span.error {
 | 
  
    | 318 |     margin-left: 0em;
 | 
  
    | 319 | }
 | 
  
    | 320 | 
 | 
  
    | 321 | .warning {
 | 
  
    | 322 | 	background:#FFDBDB;
 | 
  
    | 323 | 	padding:1em;
 | 
  
    | 324 | 	margin-top:0.5em;
 | 
  
    | 325 | 	border: 1px solid #DB0909;
 | 
  
    | 326 | }
 | 
  
    | 327 | .info {
 | 
  
    | 328 | 	background:#C7F4C7;
 | 
  
    | 329 | 	padding:1em;
 | 
  
    | 330 | 	margin-top:0.5em;
 | 
  
    | 331 | 	border: 1px solid #277A29;
 | 
  
    | 332 | }
 | 
  
    | 333 | 
 | 
  
    | 334 | </style>
 | 
  
    | 335 | </head>
 | 
  
    | 336 | <body>
 | 
  
    | 337 | <div id="container">
 | 
  
    | 338 | <div class="page">
 | 
  
    | 339 | <img src="<?php echo WB_URL; ?>/templates/<?php echo $DEFAULT_THEME; ?>/images/logo.png" alt="WebsiteBaker Project" />
 | 
  
    | 340 | <div class="content">
 | 
  
    | 341 | <h1>WebsiteBaker Upgrade</h1>
 | 
  
    | 342 | <?php
 | 
  
    | 343 | 	if( version_compare( WB_VERSION, '2.7', '<' )) {
 | 
  
    | 344 | 		status_msg('<br />It is not possible to upgrade from WebsiteBaker Versions before 2.7.<br />For upgrading to version '.VERSION.' you must upgrade first to v.2.7 at least!!!', 'warning', 'div');
 | 
  
    | 345 | 		echo "</div>
 | 
  
    | 346 | 		</div>
 | 
  
    | 347 | 		</div>
 | 
  
    | 348 | 		</body>
 | 
  
    | 349 | 		</html>
 | 
  
    | 350 | 		";
 | 
  
    | 351 | 		exit();
 | 
  
    | 352 | 	}
 | 
  
    | 353 | if($admin->get_user_id()!=1){
 | 
  
    | 354 | 	status_msg('<br /><h3>WebsiteBaker upgrading is not possible!<br />Before upgrading '
 | 
  
    | 355 | 	          .'to Revision '.REVISION.' you have to login as System-Administrator!</h3>',
 | 
  
    | 356 | 	           'warning', 'div');
 | 
  
    | 357 | 	echo '<br /><br />';
 | 
  
    | 358 | // delete remember key of current user from database
 | 
  
    | 359 | 	//if (isset($_SESSION['USER_ID']) && isset($database)) {
 | 
  
    | 360 | 	//	$table = TABLE_PREFIX . 'users';
 | 
  
    | 361 | 	//	$sql = "UPDATE `$table` SET `remember_key` = '' WHERE `user_id` = '" . (int) $_SESSION['USER_ID'] . "'";
 | 
  
    | 362 | 	//	$database->query($sql);
 | 
  
    | 363 | 	//}
 | 
  
    | 364 | // delete remember key cookie if set
 | 
  
    | 365 | 	if (isset($_COOKIE['REMEMBER_KEY']) && !headers_sent() ) {
 | 
  
    | 366 | 		setcookie('REMEMBER_KEY', '', time() - 3600, '/');
 | 
  
    | 367 | 	}
 | 
  
    | 368 | 	// delete most critical session variables manually
 | 
  
    | 369 | 	$_SESSION['USER_ID'] = null;
 | 
  
    | 370 | 	$_SESSION['GROUP_ID'] = null;
 | 
  
    | 371 | 	$_SESSION['GROUPS_ID'] = null;
 | 
  
    | 372 | 	$_SESSION['USERNAME'] = null;
 | 
  
    | 373 | 	$_SESSION['PAGE_PERMISSIONS'] = null;
 | 
  
    | 374 | 	$_SESSION['SYSTEM_PERMISSIONS'] = null;
 | 
  
    | 375 | 	// overwrite session array
 | 
  
    | 376 | 	$_SESSION = array();
 | 
  
    | 377 | 	// delete session cookie if set
 | 
  
    | 378 | 	if (isset($_COOKIE[session_name()]) && !headers_sent()) {
 | 
  
    | 379 | 		setcookie(session_name(), '', time() - 42000, '/');
 | 
  
    | 380 | 	}
 | 
  
    | 381 | 	// delete the session itself
 | 
  
    | 382 | 	session_destroy();
 | 
  
    | 383 | 	status_msg('<br /><h3>You have to login as System-Adminstrator start '
 | 
  
    | 384 | 	          .'upgrade-script.php again!</h3>',
 | 
  
    | 385 | 	           'info', 'div');
 | 
  
    | 386 | 	echo '<br /><br />';
 | 
  
    | 387 | 	if(defined('ADMIN_URL')) {
 | 
  
    | 388 | 		echo '<form action="'.ADMIN_URL.'/index.php" method="post">'
 | 
  
    | 389 | 		    .' <input name="backend_send" type="submit" value="Kick me to the Login" />'
 | 
  
    | 390 | 		    .'</form>';
 | 
  
    | 391 | 	}
 | 
  
    | 392 | 	echo '<br /><br /></div>'
 | 
  
    | 393 | 	    .'</div>'
 | 
  
    | 394 | 	    .'</div>'
 | 
  
    | 395 | 	    .'</body>'
 | 
  
    | 396 | 	    .'</html>';
 | 
  
    | 397 | 	exit();
 | 
  
    | 398 | }
 | 
  
    | 399 | 
 | 
  
    | 400 | ?>
 | 
  
    | 401 | <p class="info">This script upgrades an existing WebsiteBaker <strong> <?php echo $oldRevision; ?></strong> installation to the <strong> <?php echo $newRevision ?> </strong>.<br />The upgrade script alters the existing WB database to reflect the changes introduced with WB 2.8.x</p>
 | 
  
    | 402 | 
 | 
  
    | 403 | <?php
 | 
  
    | 404 | 
 | 
  
    | 405 | /**
 | 
  
    | 406 |  * Check if disclaimer was accepted
 | 
  
    | 407 |  */
 | 
  
    | 408 | $bDebugModus = false;
 | 
  
    | 409 | $bDebugModus = ( (isset($_POST['debug_confirmed']) && $_POST['debug_confirmed'] == 'debug') ? true : false);
 | 
  
    | 410 | if (!(isset($_POST['backup_confirmed']) && $_POST['backup_confirmed'] == 'confirmed')) { ?>
 | 
  
    | 411 | <h2>Step 1: Backup your files</h2>
 | 
  
    | 412 | <h5 class="warning">It is highly recommended to <strong>create a manual backup</strong> of the entire <strong class="error"><?php echo  PAGES_DIRECTORY ?>/</strong> folder and the <strong>MySQL database</strong> before proceeding.</h5>
 | 
  
    | 413 | <p><strong class="error">Note: </strong>The upgrade script alters some settings of your existing database!!! You need to confirm the disclaimer before proceeding.</p>
 | 
  
    | 414 | 
 | 
  
    | 415 | <form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
 | 
  
    | 416 | <textarea cols="92" rows="5">DISCLAIMER: The WebsiteBaker upgrade script 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. One needs to confirm that a manual backup of the <?php echo  PAGES_DIRECTORY ?>/ folder (including all files and subfolders contained in it) and backup of the entire WebsiteBaker MySQL database was created before you can proceed.</textarea>
 | 
  
    | 417 | <br /><br /><input name="backup_confirmed" type="checkbox" value="confirmed" /> <strong>I confirm that a manual backup of the <?php echo  PAGES_DIRECTORY ?>/ folder and the MySQL database was created.</strong>
 | 
  
    | 418 | <br /><br /><input name="debug_confirmed" type="checkbox" value="debug" /> <strong>Here you can get more details during running upgrade.</strong>
 | 
  
    | 419 | <br /><br /><input name="send" type="submit" value="Start upgrade script" />
 | 
  
    | 420 | </form>
 | 
  
    | 421 | <br />
 | 
  
    | 422 | 
 | 
  
    | 423 | <?php
 | 
  
    | 424 | 	status_msg('<strong> Notice:</strong><br />You need to confirm that you have created '
 | 
  
    | 425 | 			  .'a manual backup of the '.PAGES_DIRECTORY.'/ directory and the MySQL '
 | 
  
    | 426 | 	          .'database before you can proceed.',
 | 
  
    | 427 | 	           'warning', 'div');
 | 
  
    | 428 | 	echo '<br /><br /></div>'
 | 
  
    | 429 | 	    .'</div>'
 | 
  
    | 430 | 	    .'</div>'
 | 
  
    | 431 | 	    .'</body>'
 | 
  
    | 432 | 	    .'</html>';
 | 
  
    | 433 | 	exit();
 | 
  
    | 434 | }
 | 
  
    | 435 | 
 | 
  
    | 436 | /**********************************************************
 | 
  
    | 437 |  *  - check tables coming with WebsiteBaker
 | 
  
    | 438 |  */
 | 
  
    | 439 | 	$aMissingTables = UpgradeHelper::getMissingTables($aPackage);
 | 
  
    | 440 | 	if( sizeof($aMissingTables) == 0){
 | 
  
    | 441 |         echo '<h4 style="margin-left:0;">NOTICE: '.sizeof($aPackage).' total tables '
 | 
  
    | 442 | 		    .'included in package are successfully installed into your database `'
 | 
  
    | 443 | 		    .$database->DbName.'` '.$OK.'</h4>';
 | 
  
    | 444 |     } else {
 | 
  
    | 445 |         status_msg('<strong>:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
 | 
  
    | 446 |         echo '<h4>Missing required tables. You can install them in backend->addons->modules.<br />'
 | 
  
    | 447 |             .'Or if you uploaded per FTP install possible by backend->addons->modules->advanced.<br />'
 | 
  
    | 448 |             .'First rename or delete the upgrade-script.php, so the script can\'t start automatically by backend<br />'
 | 
  
    | 449 |             .'After installing missing tables upload and run again upgrade-script.php<br /><br /></h4>'
 | 
  
    | 450 |             .'<h4 class="warning">'
 | 
  
    | 451 |             .'Missing required tables.<br /><br />'
 | 
  
    | 452 |             .'TABLE `'.implode('` missing! '.$FAIL.'<br />TABLE `',$aMissingTables).'` missing! '.$FAIL
 | 
  
    | 453 |             .'<br /><br /></h4>'
 | 
  
    | 454 |             .'<br /><br />';
 | 
  
    | 455 |         if(isset($_SERVER['SCRIPT_NAME'])) {
 | 
  
    | 456 |         	echo '<form action="'.$_SERVER['SCRIPT_NAME'].'/">'
 | 
  
    | 457 |         	    .' <input type="submit" value="Start upgrade again" />'
 | 
  
    | 458 |         	    .'</form>';
 | 
  
    | 459 |         }
 | 
  
    | 460 |         if(defined('ADMIN_URL')) {
 | 
  
    | 461 |         	echo '<form action="'.ADMIN_URL.'/index.php" method="post">'
 | 
  
    | 462 |         	    .' <input name="backend_send" type="submit" value="kick me to the Backend" />'
 | 
  
    | 463 |         	    .'</form>';
 | 
  
    | 464 |         }
 | 
  
    | 465 |         echo '<br /><br /></div>'
 | 
  
    | 466 |             .'</div>'
 | 
  
    | 467 |             .'</div>'
 | 
  
    | 468 |             .'</body>'
 | 
  
    | 469 |             .'</html>';
 | 
  
    | 470 | 		exit();
 | 
  
    | 471 | 	}
 | 
  
    | 472 | 
 | 
  
    | 473 | 	echo '<h3>Step '.(++$stepID).': Setting default_theme</h3>';
 | 
  
    | 474 | 	$aDebugMessage = array();
 | 
  
    | 475 | 	/**********************************************************
 | 
  
    | 476 | 	 *  - Adding field default_theme to settings table
 | 
  
    | 477 | 	 */
 | 
  
    | 478 | 	$aDebugMessage[] = '<div style="margin-left:2em;">';
 | 
  
    | 479 | 	$aDebugMessage[] = "<span><strong>Adding default_theme to table settings</strong></span>";
 | 
  
    | 480 | 	// db_update_key_value('settings', 'default_theme', $DEFAULT_THEME);
 | 
  
    | 481 | 	$cfg = array(
 | 
  
    | 482 | 		'default_theme' => $DEFAULT_THEME
 | 
  
    | 483 | 	);
 | 
  
    | 484 | 	$aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 485 | 	$aDebugMessage[] = '</div>';
 | 
  
    | 486 | 
 | 
  
    | 487 | 	echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 488 | 
 | 
  
    | 489 | 	$aDebugMessage = array();
 | 
  
    | 490 | 	echo'<h3>Step '.(++$stepID).': Updating core table included in package</h3>';
 | 
  
    | 491 | 	/**********************************************************
 | 
  
    | 492 | 	 *  - Adding field sec_anchor to settings table
 | 
  
    | 493 | 	 */
 | 
  
    | 494 | 	echo '<div style="margin-left:2em;">';
 | 
  
    | 495 | 	echo "<h4>Adding/updating entries on table settings</h4>";
 | 
  
    | 496 | 	$aDebugMessage[] = "<span>Adding/updating sec_anchor to settings table</span>";
 | 
  
    | 497 | 	$cfg = array(
 | 
  
    | 498 | 		'sec_anchor' => defined( 'SEC_ANCHOR' )&& (SEC_ANCHOR!='') ? SEC_ANCHOR : 'Sec'
 | 
  
    | 499 | 	);
 | 
  
    | 500 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 501 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 502 | 
 | 
  
    | 503 | 	/**********************************************************
 | 
  
    | 504 | 	 *  - Adding redirect timer to settings table
 | 
  
    | 505 | 	 */
 | 
  
    | 506 | 	$aDebugMessage[] = "<span>Adding/updating redirect timer to settings table</span>";
 | 
  
    | 507 | 	$cfg = array(
 | 
  
    | 508 | 		'redirect_timer' => defined('REDIRECT_TIMER')&& (REDIRECT_TIMER!='') ? REDIRECT_TIMER : '1500'
 | 
  
    | 509 | 	);
 | 
  
    | 510 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 511 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 512 | 
 | 
  
    | 513 | 	/**********************************************************
 | 
  
    | 514 | 	 *  - Adding default_time_formatr to settings table
 | 
  
    | 515 | 	 */
 | 
  
    | 516 | 	$aDebugMessage[] = "<span>Adding/updating default_time_format to settings table</span>";
 | 
  
    | 517 | 	$cfg = array(
 | 
  
    | 518 | 		'default_time_format' => defined('DEFAULT_TIME_FORMAT')&& (DEFAULT_TIME_FORMAT!='') ? DEFAULT_TIME_FORMAT : 'h:i A'
 | 
  
    | 519 | 	);
 | 
  
    | 520 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 521 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 522 | 
 | 
  
    | 523 | 	/**********************************************************
 | 
  
    | 524 | 	 *  - Adding rename_files_on_upload to settings table
 | 
  
    | 525 | 	 */
 | 
  
    | 526 | 	$aDebugMessage[] = "<span>Adding/Updating rename_files_on_upload to settings table</span>";
 | 
  
    | 527 | 	$cfg = array(
 | 
  
    | 528 | 	    'rename_files_on_upload' => (defined('RENAME_FILES_ON_UPLOAD')&& (RENAME_FILES_ON_UPLOAD!='') ? RENAME_FILES_ON_UPLOAD : 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js')
 | 
  
    | 529 | 	);
 | 
  
    | 530 | 	if( version_compare( WB_VERSION, '2.8.2', '<' )) {
 | 
  
    | 531 | 		$cfg = array(
 | 
  
    | 532 | 		    'rename_files_on_upload' => 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js'
 | 
  
    | 533 | 		);
 | 
  
    | 534 | 	}
 | 
  
    | 535 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 536 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 537 | 
 | 
  
    | 538 | 	/**********************************************************
 | 
  
    | 539 | 	 *  - Adding mediasettings to settings table
 | 
  
    | 540 | 	 */
 | 
  
    | 541 | 	$aDebugMessage[] = "<span>Adding/updating mediasettings to settings table</span>";
 | 
  
    | 542 | 	$cfg = array(
 | 
  
    | 543 | 		'mediasettings' => (defined('MEDIASETTINGS')&& (MEDIASETTINGS!='') ? MEDIASETTINGS : ''),
 | 
  
    | 544 | 	);
 | 
  
    | 545 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 546 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 547 | 
 | 
  
    | 548 | 	/**********************************************************
 | 
  
    | 549 | 	 *  - Adding fingerprint_with_ip_octets to settings table
 | 
  
    | 550 | 	 */
 | 
  
    | 551 | 	$aDebugMessage[] = "<span>Adding/updating fingerprint_with_ip_octets to settings table</span>";
 | 
  
    | 552 | 	$cfg = array(
 | 
  
    | 553 | 		'fingerprint_with_ip_octets' => (defined('FINGERPRINT_WITH_IP_OCTETS') ? FINGERPRINT_WITH_IP_OCTETS : '2'),
 | 
  
    | 554 | 		'secure_form_module' => (defined('SECURE_FORM_MODULE') ? SECURE_FORM_MODULE : '')
 | 
  
    | 555 | 	);
 | 
  
    | 556 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 557 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 558 | 
 | 
  
    | 559 | 	/**********************************************************
 | 
  
    | 560 | 	 *  - Adding page_icon_dir to settings table
 | 
  
    | 561 | 	 */
 | 
  
    | 562 | 	$aDebugMessage[] = "<span>Adding/updating page_icon_dir to settings table</span>";
 | 
  
    | 563 | 	$cfg = array(
 | 
  
    | 564 | 		'page_icon_dir' => (defined('PAGE_ICON_DIR')&& (PAGE_ICON_DIR!='') ? PAGE_ICON_DIR : '/templates/*/title_images'),
 | 
  
    | 565 | 	);
 | 
  
    | 566 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 567 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 568 | 	/**********************************************************
 | 
  
    | 569 | 	 *  - Adding page_extended to settings table
 | 
  
    | 570 | 	 */
 | 
  
    | 571 | 	$aDebugMessage[] = "<span>Adding/updating page_extendet to settings table</span>";
 | 
  
    | 572 | 	$cfg = array(
 | 
  
    | 573 | 		'page_extendet' => (defined('PAGE_EXTENDET') ? PAGE_EXTENDET : 'true'),
 | 
  
    | 574 | 	);
 | 
  
    | 575 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 576 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 577 | 
 | 
  
    | 578 | 	/**********************************************************
 | 
  
    | 579 | 	 *  - Adding wbmail_signature to settings table
 | 
  
    | 580 | 	 */
 | 
  
    | 581 | 	$aDebugMessage[] = "<span>Adding/updating wbmail_signature to settings table</span>";
 | 
  
    | 582 | 	$cfg = array(
 | 
  
    | 583 | 		'wbmail_signature' => (defined('WBMAIL_SIGNATURE')&& (WBMAIL_SIGNATURE!='') ? WBMAIL_SIGNATURE : '')
 | 
  
    | 584 | 	);
 | 
  
    | 585 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 586 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 587 | 
 | 
  
    | 588 | 	/**********************************************************
 | 
  
    | 589 | 	 *  - Adding confirmed_registration to settings table
 | 
  
    | 590 | 	 */
 | 
  
    | 591 | 	$aDebugMessage[] = "<span>Adding/updating confirmed_registration to settings table</span>";
 | 
  
    | 592 | 	$cfg = array(
 | 
  
    | 593 | 		'confirmed_registration' => (defined('CONFIRMED_REGISTRATION') ? CONFIRMED_REGISTRATION : '0')
 | 
  
    | 594 | 	);
 | 
  
    | 595 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 596 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 597 | 
 | 
  
    | 598 | 	/**********************************************************
 | 
  
    | 599 | 	 *  - Adding dev_infos to settings table
 | 
  
    | 600 | 	 */
 | 
  
    | 601 | 	$aDebugMessage[] = "<span>Adding/updating dev_infos to settings table</span>";
 | 
  
    | 602 | 	$cfg = array(
 | 
  
    | 603 | 		'dev_infos' => (defined('DEV_INFOS') ? DEV_INFOS : 'false')
 | 
  
    | 604 | 	);
 | 
  
    | 605 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 606 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 607 | 
 | 
  
    | 608 | 	/**********************************************************
 | 
  
    | 609 | 	 *  - Adding server_timezone to settings table
 | 
  
    | 610 | 	 */
 | 
  
    | 611 | 	$aDebugMessage[] = "<span>Adding/updating server_timezone to settings table</span>";
 | 
  
    | 612 | 	$cfg = array(
 | 
  
    | 613 | 		'server_timezone' => (defined('SERVER_TIMEZONE') ? SERVER_TIMEZONE : 'UTC')
 | 
  
    | 614 | 	);
 | 
  
    | 615 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 616 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 617 | 
 | 
  
    | 618 | 	/**********************************************************
 | 
  
    | 619 | 	 *  - Adding password settings to table settings
 | 
  
    | 620 | 	 */
 | 
  
    | 621 | 	$aDebugMessage[] = "<span>Adding/updating password settings to settings table</span>";
 | 
  
    | 622 | 	$cfg = array();
 | 
  
    | 623 | 	$cfg['password_crypt_loops'] = (defined('PASSWORD_CRYPT_LOOPS') ? PASSWORD_CRYPT_LOOPS : '12');
 | 
  
    | 624 | 	$cfg['password_hash_type'] = (defined('PASSWORD_HASH_TYPES') ? PASSWORD_HASH_TYPES : 'false');
 | 
  
    | 625 | 	$cfg['password_length'] = (defined('PASSWORD_LENGTH') ? PASSWORD_LENGTH : '10');
 | 
  
    | 626 | 	$cfg['password_use_types'] = (defined('PASSWORD_USE_TYPES') ? PASSWORD_USE_TYPES : (int)0xFFFF);
 | 
  
    | 627 | 	$bLogStatus = (db_update_key_value( 'settings', $cfg ) ? true : false );
 | 
  
    | 628 | 	$aDebugMessage[] = ( ($bLogStatus==true ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 629 | 
 | 
  
    | 630 | if($bDebugModus) {
 | 
  
    | 631 |     echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 632 | } else {
 | 
  
    | 633 |         echo '<strong>Successfully upgraded</strong>'." $OK<br />";	   
 | 
  
    | 634 | 	}
 | 
  
    | 635 | echo '</div>';
 | 
  
    | 636 | 
 | 
  
    | 637 | $aDebugMessage = array();
 | 
  
    | 638 | if(version_compare(WB_REVISION, REVISION, '<='))
 | 
  
    | 639 | {
 | 
  
    | 640 | 	echo '<div style="margin-left:2em;">';
 | 
  
    | 641 | 	/**********************************************************
 | 
  
    | 642 | 	 *  - Update search no results database filed to create
 | 
  
    | 643 | 	 *  valid XHTML if search is empty
 | 
  
    | 644 | 	 */
 | 
  
    | 645 | 	if (version_compare(WB_VERSION, '2.8', '<'))
 | 
  
    | 646 | 	{
 | 
  
    | 647 | 		echo "<h4>Adding/updating fields on table search</h4>";
 | 
  
    | 648 | 		echo "Updating database field `no_results` on search table: ";
 | 
  
    | 649 | 		$search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
 | 
  
    | 650 | 		$sql  = 'UPDATE `'.TABLE_PREFIX.'search` ';
 | 
  
    | 651 | 		$sql .= 'SET `value`=\''.$search_no_results.'\' ';
 | 
  
    | 652 | 		$sql .= 'WHERE `name`=\'no_results\'';
 | 
  
    | 653 | 		echo ($database->query($sql)) ? " $OK<br />" : " $FAIL!<br />";
 | 
  
    | 654 | 	}
 | 
  
    | 655 | 
 | 
  
    | 656 | 	$aDebugMessage = array();
 | 
  
    | 657 | 	echo "<h4>Adding/updating field on table pages</h4>";
 | 
  
    | 658 | 	/**********************************************************
 | 
  
    | 659 | 	 *  - Add field "page_trail" to table "pages"
 | 
  
    | 660 | 	 */
 | 
  
    | 661 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 662 | 	$field_name = 'page_trail';
 | 
  
    | 663 | 	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
 | 
  
    | 664 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 665 | 
 | 
  
    | 666 | 	/**********************************************************
 | 
  
    | 667 | 	 *  - Add field "page_icon" to table "pages"
 | 
  
    | 668 | 	 */
 | 
  
    | 669 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 670 | 	$field_name = 'page_icon';
 | 
  
    | 671 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `page_title`";
 | 
  
    | 672 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 673 | 
 | 
  
    | 674 | 	/**********************************************************
 | 
  
    | 675 | 	 *  - Add field "menu_icon_0" to table "pages"
 | 
  
    | 676 | 	 */
 | 
  
    | 677 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 678 | 	$field_name = 'menu_icon_0';
 | 
  
    | 679 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_title`";
 | 
  
    | 680 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 681 | 
 | 
  
    | 682 | 	/**********************************************************
 | 
  
    | 683 | 	 *  - Add field "menu_icon_1" to table "pages"
 | 
  
    | 684 | 	 */
 | 
  
    | 685 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 686 | 	$field_name = 'menu_icon_1';
 | 
  
    | 687 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_0`";
 | 
  
    | 688 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 689 | 
 | 
  
    | 690 | 	/**********************************************************
 | 
  
    | 691 | 	 *  - Add field "tooltip" to table "pages"
 | 
  
    | 692 | 	 */
 | 
  
    | 693 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 694 | 	$field_name = 'tooltip';
 | 
  
    | 695 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_1`";
 | 
  
    | 696 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 697 | 
 | 
  
    | 698 | 	/**********************************************************
 | 
  
    | 699 | 	 *  - Add field "admin_groups" to table "pages"
 | 
  
    | 700 | 	 */
 | 
  
    | 701 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 702 | 	$field_name = 'admin_groups';
 | 
  
    | 703 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
 | 
  
    | 704 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 705 | 
 | 
  
    | 706 | 	/**********************************************************
 | 
  
    | 707 | 	 *  - Add field "admin_users" to table "pages"
 | 
  
    | 708 | 	 */
 | 
  
    | 709 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 710 | 	$field_name = 'admin_users';
 | 
  
    | 711 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
 | 
  
    | 712 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 713 | 
 | 
  
    | 714 | 	/**********************************************************
 | 
  
    | 715 | 	 *  - Add field "viewing_groups" to table "pages"
 | 
  
    | 716 | 	 */
 | 
  
    | 717 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 718 | 	$field_name = 'viewing_groups';
 | 
  
    | 719 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
 | 
  
    | 720 | 	 add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 721 | 
 | 
  
    | 722 | 	/**********************************************************
 | 
  
    | 723 | 	 *  - Add field "viewing_users" to table "pages"
 | 
  
    | 724 | 	 */
 | 
  
    | 725 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 726 | 	$field_name = 'viewing_users';
 | 
  
    | 727 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
 | 
  
    | 728 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 729 | 
 | 
  
    | 730 | 	/**********************************************************
 | 
  
    | 731 | 	 *  - Add field "custom01" to table "pages"
 | 
  
    | 732 | 	 */
 | 
  
    | 733 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 734 | 	$field_name = 'custom01';
 | 
  
    | 735 | 	$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
 | 
  
    | 736 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 737 | 
 | 
  
    | 738 | 	/**********************************************************
 | 
  
    | 739 | 	 *  - Add field "custom02" to table "pages"
 | 
  
    | 740 | 	 */
 | 
  
    | 741 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 742 | 	$field_name = 'custom02';
 | 
  
    | 743 | 	$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
 | 
  
    | 744 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 745 | 
 | 
  
    | 746 | 	if($bDebugModus) {
 | 
  
    | 747 | 		echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 748 | 	} else {
 | 
  
    | 749 |         echo '<strong>Successfully upgraded</strong>'." $OK<br />";	   
 | 
  
    | 750 | 	}
 | 
  
    | 751 | 
 | 
  
    | 752 | 	$aDebugMessage = array();
 | 
  
    | 753 | 	/**********************************************************
 | 
  
    | 754 | 	 * modify wrong strucre on table sections
 | 
  
    | 755 | 	 * wrong structure let crash wb
 | 
  
    | 756 | 	 */
 | 
  
    | 757 | 	echo "<h4>Change field structure on table sections</h4>";
 | 
  
    | 758 | 	$table_name = TABLE_PREFIX.'sections';
 | 
  
    | 759 | 	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
 | 
  
    | 760 | 	$aDebugMessage[] = "<span>Modify field module on sections table</span>";
 | 
  
    | 761 | 	$aDebugMessage[] = ($database->field_modify($table_name, 'module', $description) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 762 | 	$aDebugMessage[] = "<span>Modify field block on sections table</span>";
 | 
  
    | 763 | 	$description = "int(11) NOT NULL DEFAULT '1'";
 | 
  
    | 764 | 	$aDebugMessage[] = ($database->field_modify($table_name, 'block', $description) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 765 | 	$description = "int(11) NOT NULL DEFAULT '0'";
 | 
  
    | 766 | 	$aDebugMessage[] = "<span>Modify field publ_start on sections table</span>";
 | 
  
    | 767 | 	$aDebugMessage[] = ($database->field_modify($table_name, 'publ_start', $description) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 768 | 	$aDebugMessage[] = "<span>Modify field publ_end on sections table</span>";
 | 
  
    | 769 | 	$aDebugMessage[] = ($database->field_modify($table_name, 'publ_end', $description) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 770 | 
 | 
  
    | 771 | 	if($bDebugModus) {
 | 
  
    | 772 | 		echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 773 | 	} else {
 | 
  
    | 774 |         echo '<strong>Successfully upgraded</strong>'." $OK<br />";	   
 | 
  
    | 775 | 	}
 | 
  
    | 776 | 	echo '</div>';
 | 
  
    | 777 | }
 | 
  
    | 778 | if(version_compare(WB_REVISION, REVISION, '<='))
 | 
  
    | 779 | {
 | 
  
    | 780 | 	$aDebugMessage = array();
 | 
  
    | 781 | 	echo '<h3>Step '.(++$stepID).': Updating structure in table users/groups</h3>';
 | 
  
    | 782 | 	/**********************************************************
 | 
  
    | 783 | 	 * Modify Administrator on groups table
 | 
  
    | 784 | 	 */
 | 
  
    | 785 | 	echo '<div style="margin-left:2em;">';
 | 
  
    | 786 | 	echo "<h4>Updating Administrator group permissions on table groups</h4>";
 | 
  
    | 787 | 	$aDebugMessage[] = "<span>Modify Administrator on groups table</span>";
 | 
  
    | 788 | 	$sModulePermissions = '';
 | 
  
    | 789 | 	$sTemplatePermissions = '';
 | 
  
    | 790 | 	$sSystemPermissions  = 'access,addons,admintools,admintools_view,groups,groups_add,groups_delete,groups_modify,groups_view,';
 | 
  
    | 791 | 	$sSystemPermissions .= 'languages,languages_install,languages_uninstall,languages_view,media,media_create,media_delete,media_rename,media_upload,media_view,';
 | 
  
    | 792 | 	$sSystemPermissions .= 'modules,modules_advanced,modules_install,modules_uninstall,modules_view,pages,pages_add,pages_add_l0,pages_delete,pages_intro,pages_modify,pages_settings,pages_view,';
 | 
  
    | 793 | 	$sSystemPermissions .= 'preferences,preferences_view,settings,settings_advanced,settings_basic,settings_view,templates,templates_install,templates_uninstall,templates_view,users,users_add,users_delete,users_modify,users_view';
 | 
  
    | 794 | 
 | 
  
    | 795 | 	$sql  = 'UPDATE `'.TABLE_PREFIX.'groups` ';
 | 
  
    | 796 | 	$sql .= 'SET `name` = \'Administrators\', ';
 | 
  
    | 797 | 	$sql .= '`system_permissions` = \''.$sSystemPermissions.'\', ';
 | 
  
    | 798 | 	$sql .= '`module_permissions` = \''.$sModulePermissions.'\', ';
 | 
  
    | 799 | 	$sql .= '`template_permissions` = \''.$sTemplatePermissions.'\' ';
 | 
  
    | 800 | 	$sql .= 'WHERE `group_id` = \'1\' ';
 | 
  
    | 801 | 	$aDebugMessage[] = ($database->query($sql)) ? " $OK<br />" : " $FAIL!<br />";
 | 
  
    | 802 | 	if( ($admin->is_authenticated() == true) && ($admin->ami_group_member('1') ) ) {
 | 
  
    | 803 | 	    $_SESSION['SYSTEM_PERMISSIONS'] = array_merge($_SESSION['SYSTEM_PERMISSIONS'], explode(',', $sSystemPermissions));
 | 
  
    | 804 | 	}
 | 
  
    | 805 | 
 | 
  
    | 806 | 	if($bDebugModus) {
 | 
  
    | 807 | 		echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 808 | 	} else {
 | 
  
    | 809 |         echo '<strong>Successfully upgraded</strong>'." $OK<br />";	   
 | 
  
    | 810 | 	}
 | 
  
    | 811 | 	echo '</div>';
 | 
  
    | 812 | 	$aDebugMessage = array();
 | 
  
    | 813 | 	/**********************************************************
 | 
  
    | 814 | 	 *   `confirm_code` VARCHAR(32) NOT NULL DEFAULT '',
 | 
  
    | 815 | 	 *   `confirm_timeout` INT(11) NOT NULL DEFAULT '0',
 | 
  
    | 816 | 	 */
 | 
  
    | 817 | 	echo '<div style="margin-left:2em;">';
 | 
  
    | 818 | 	echo "<h4>Change field structure on table users</h4>";
 | 
  
    | 819 | 	$table_name = TABLE_PREFIX.'users';
 | 
  
    | 820 | 	$field_name = 'confirm_code';
 | 
  
    | 821 | 	$description = "VARCHAR( 32 ) NOT NULL DEFAULT '' AFTER `password` ";
 | 
  
    | 822 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 823 | 
 | 
  
    | 824 | 	$table_name = TABLE_PREFIX.'users';
 | 
  
    | 825 | 	$field_name = 'confirm_timeout';
 | 
  
    | 826 | 	$description = "INT(11) NOT NULL DEFAULT '0' AFTER `confirm_code` ";
 | 
  
    | 827 | 	add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 828 | 
 | 
  
    | 829 | 	if($bDebugModus) {
 | 
  
    | 830 | 	    echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 831 | 	} else {
 | 
  
    | 832 |         echo '<strong>Successfully upgraded</strong>'." $OK<br />";	   
 | 
  
    | 833 | 	}
 | 
  
    | 834 | 	echo '</div>';
 | 
  
    | 835 | 
 | 
  
    | 836 | 	$aDebugMessage = array();
 | 
  
    | 837 | 	/**********************************************************
 | 
  
    | 838 | 	* Updating group_id in table users
 | 
  
    | 839 | 	*/
 | 
  
    | 840 | 	echo '<div style="margin-left:2em;">';
 | 
  
    | 841 | 	echo "<h4>Updating users groups permissions on table groups</h4>";
 | 
  
    | 842 | 	    $aUsers = array();
 | 
  
    | 843 | 		// Get existing values
 | 
  
    | 844 |         $sql  = 'SELECT * FROM `'.TABLE_PREFIX.'users` ' ;
 | 
  
    | 845 |         $sql .= 'WHERE `user_id` != 1 ';
 | 
  
    | 846 |         if($oUser = $database->query($sql)){
 | 
  
    | 847 |             $iTotalUsers = $oUser->numRows();
 | 
  
    | 848 |             while($Users = $oUser->fetchRow(MYSQL_ASSOC)) {
 | 
  
    | 849 |                 $aUsers[$Users['user_id']]['groups_id'] = $Users['groups_id'];
 | 
  
    | 850 |                 $aUsers[$Users['user_id']]['display_name'] = $Users['display_name'];
 | 
  
    | 851 |             }
 | 
  
    | 852 |         } else {
 | 
  
    | 853 |             $aDebugMessage[] = $database->is_error()==false ? " $OK<br />" : " $FAIL!<br />";
 | 
  
    | 854 |         }
 | 
  
    | 855 |         foreach($aUsers AS $user_id => $value){
 | 
  
    | 856 |                 // choose group_id from groups_id - workaround for still remaining calls to group_id (to be cleaned-up)
 | 
  
    | 857 |                 $aGroups_id = explode(',', $aUsers[$user_id]['groups_id']);
 | 
  
    | 858 |                 $groups_id = $aUsers[$user_id]['groups_id'];
 | 
  
    | 859 |                 $group_id = 0;
 | 
  
    | 860 |                 //if user is in administrator-group, get this group else just get the first one
 | 
  
    | 861 |                 if($admin->is_group_match($aGroups_id,'1')) { $group_id = 1; $groups_id = '1'; } else { $group_id = intval($aGroups_id[0]); }
 | 
  
    | 862 |                 $sMessage = "<span>Updating group_id ".$TEXT['DISPLAY_NAME']." " .$aUsers[$user_id]['display_name']."</span>";
 | 
  
    | 863 |                 $sql  = 'UPDATE `'.TABLE_PREFIX.'users` ';
 | 
  
    | 864 |                 $sql .= 'SET `group_id`  = '.$group_id.', ';
 | 
  
    | 865 |                 $sql .=     '`groups_id` = \''.$groups_id.'\' ';
 | 
  
    | 866 |                 $sql .= 'WHERE `user_id` = '.intval($user_id);
 | 
  
    | 867 |                 if($oRes = $database->query($sql)){  }
 | 
  
    | 868 |                 $aDebugMessage[] = $database->is_error()==false ? $sMessage." $OK<br />" : $sMessage." $FAIL!<br />";
 | 
  
    | 869 |         }
 | 
  
    | 870 |         unset($aUsers);
 | 
  
    | 871 | 	$aDebugMessage[] = '</div>';
 | 
  
    | 872 | 
 | 
  
    | 873 | 	if($bDebugModus) {
 | 
  
    | 874 | 	// $aDebugMessage[] =
 | 
  
    | 875 | 	    echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 876 | 	}else {
 | 
  
    | 877 | 	    echo '<span><strong>'.$iTotalUsers.' users updating the groups</strong></span>'." $OK<br />";
 | 
  
    | 878 | 	    echo '</div>';
 | 
  
    | 879 | 	}
 | 
  
    | 880 | }
 | 
  
    | 881 | 
 | 
  
    | 882 | $aDebugMessage = array();
 | 
  
    | 883 | echo '<h3>Step '.(++$stepID).': Updating access files in folders</h3>';
 | 
  
    | 884 | 
 | 
  
    | 885 | echo '<div style="margin-left:2em;">';
 | 
  
    | 886 | 	/**********************************************************
 | 
  
    | 887 | 	* upgrade media directory index protect files
 | 
  
    | 888 | 	*/
 | 
  
    | 889 | //	echo '<h4>Upgrade media directory '.MEDIA_DIRECTORY.'/ index.php protect files</h4>';
 | 
  
    | 890 | //	$aDebugMessage = rebuildFolderProtectFile();
 | 
  
    | 891 | //	if( sizeof( $aDebugMessage ) ){
 | 
  
    | 892 | //		echo '<span><strong>Upgrade '.sizeof( $aDebugMessage ).' directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $OK<br />";
 | 
  
    | 893 | //	} else {
 | 
  
    | 894 | //		echo '<span><strong>Upgrade directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $FAIL!<br />";
 | 
  
    | 895 | //		echo implode ('<br />',$aDebugMessage);
 | 
  
    | 896 | //	}
 | 
  
    | 897 | //
 | 
  
    | 898 | //    $aDebugMessage = array();
 | 
  
    | 899 |     /**********************************************************
 | 
  
    | 900 |      * upgrade pages directory index access files
 | 
  
    | 901 |      */
 | 
  
    | 902 | 	echo '<h4>Upgrade pages directory '.PAGES_DIRECTORY.'/  access files</h4>';
 | 
  
    | 903 | 
 | 
  
    | 904 | 	/**********************************************************
 | 
  
    | 905 | 	 * Repair inconsistent PageTree
 | 
  
    | 906 | 	 */
 | 
  
    | 907 | 	$iCount = UpgradeHelper::sanitizePagesTreeLinkStructure();
 | 
  
    | 908 | 	if (false === $iCount) {
 | 
  
    | 909 | 		echo '<span><strong>Repair PageTree links </strong></span> '.$FAIL.'<br />';
 | 
  
    | 910 | 	} else {
 | 
  
    | 911 | 		echo '<span><strong>'.$iCount.' PageTree links repaired.</strong></span> '.$OK.'<br />';
 | 
  
    | 912 | 	}
 | 
  
    | 913 |     /**********************************************************
 | 
  
    | 914 |      *  - Reformat/rebuild all existing access files
 | 
  
    | 915 |      */
 | 
  
    | 916 |     $msg = rebuild_all_accessfiles($bDebugModus);
 | 
  
    | 917 | 	echo '<strong>'.implode ('<br />',$msg).'</strong>';
 | 
  
    | 918 |     echo '</div>';
 | 
  
    | 919 | 
 | 
  
    | 920 | 	/* *****************************************************************************
 | 
  
    | 921 | 	 * - check for deprecated / never needed files
 | 
  
    | 922 | 	 */
 | 
  
    | 923 | 	$iLoaded = sizeof($aFilesToRemove);
 | 
  
    | 924 | 	if($iLoaded) {
 | 
  
    | 925 | 		echo '<h3>Step '.(++$stepID).': Remove deprecated and outdated files</h3>';
 | 
  
    | 926 | 		$iFailed = 0;
 | 
  
    | 927 | 		$iFound = 0;
 | 
  
    | 928 | 		$searches = array(
 | 
  
    | 929 | 			'[ADMIN]',
 | 
  
    | 930 | 			'[MEDIA]',
 | 
  
    | 931 | 			'[PAGES]',
 | 
  
    | 932 | 			'[FRAMEWORK]',
 | 
  
    | 933 | 			'[MODULES]',
 | 
  
    | 934 | 			'[TEMPLATE]'
 | 
  
    | 935 | 		);
 | 
  
    | 936 | 		$replacements = array(
 | 
  
    | 937 |             $oReg->AcpDir,
 | 
  
    | 938 |             $oReg->MediaDir,
 | 
  
    | 939 |             $oReg->PagesDir,
 | 
  
    | 940 | 			'framework/',
 | 
  
    | 941 | 			'modules/',
 | 
  
    | 942 | 			'templates/'
 | 
  
    | 943 | 		);
 | 
  
    | 944 | 
 | 
  
    | 945 | 		$msg = '';
 | 
  
    | 946 | 		echo '<div style="margin-left:2em;">';
 | 
  
    | 947 | 		echo '<h4>Search '.$iLoaded.' deprecated and outdated files</h4>';
 | 
  
    | 948 | 		foreach( $aFilesToRemove as $file )
 | 
  
    | 949 | 		{
 | 
  
    | 950 | 			$file = str_replace($searches, $replacements, $file);
 | 
  
    | 951 | 			if( is_writable($oReg->AppDir.$file) ) {
 | 
  
    | 952 | 				$iFound++;
 | 
  
    | 953 | 				// try to unlink file
 | 
  
    | 954 | 				if(!unlink($oReg->AppDir.$file)) {
 | 
  
    | 955 | 					$iFailed++;
 | 
  
    | 956 | 				}
 | 
  
    | 957 | 			}
 | 
  
    | 958 | 			if( is_readable($oReg->AppDir.$file) ) {
 | 
  
    | 959 | 				// save in err-list, if failed
 | 
  
    | 960 | 				$msg .= $file.'<br />';
 | 
  
    | 961 | 			}
 | 
  
    | 962 | 		}
 | 
  
    | 963 | 		$iRemove = $iFound-$iFailed;
 | 
  
    | 964 | 		echo '<strong>Remove '.$iRemove.' from '.$iFound.' founded</strong> ';
 | 
  
    | 965 | 		echo ($iFailed == 0) ? $OK : $FAIL;
 | 
  
    | 966 | 		echo '</div>';
 | 
  
    | 967 | 
 | 
  
    | 968 | 		if($msg != '')
 | 
  
    | 969 | 		{
 | 
  
    | 970 | 			$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
 | 
  
    | 971 | 				    can not be removed automatically.<br /><br />Please delete them
 | 
  
    | 972 | 					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
 | 
  
    | 973 | 			status_msg($msg, 'error warning', 'div');
 | 
  
    | 974 | 			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
 | 
  
    | 975 | 
 | 
  
    | 976 | 			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
 | 
  
    | 977 | 			echo ' <input name="send" type="submit" value="Restart upgrade script" />';
 | 
  
    | 978 | 			echo '</form>';
 | 
  
    | 979 | 			echo "<br /><br /></div>
 | 
  
    | 980 | 			</div>
 | 
  
    | 981 | 			</div>
 | 
  
    | 982 | 			</body>
 | 
  
    | 983 | 			</html>";
 | 
  
    | 984 | 			exit;
 | 
  
    | 985 | 		}
 | 
  
    | 986 | 	}
 | 
  
    | 987 | 
 | 
  
    | 988 | 
 | 
  
    | 989 | 	/**********************************************************
 | 
  
    | 990 | 	 * - check for deprecated / never needed folders
 | 
  
    | 991 | 	 */
 | 
  
    | 992 | 	$iLoaded = sizeof($dirRemove);
 | 
  
    | 993 | 	if($iLoaded) {
 | 
  
    | 994 | 		echo '<h3>Step  '.(++$stepID).': Remove deprecated and outdated folders</h3>';
 | 
  
    | 995 | 		$iFailed = 0;
 | 
  
    | 996 | 		$iFound = 0;
 | 
  
    | 997 | 		$searches = array(
 | 
  
    | 998 | 			'[ADMIN]',
 | 
  
    | 999 | 			'[MEDIA]',
 | 
  
    | 1000 | 			'[PAGES]',
 | 
  
    | 1001 | 			'[FRAMEWORK]',
 | 
  
    | 1002 | 			'[MODULES]',
 | 
  
    | 1003 | 			'[TEMPLATE]'
 | 
  
    | 1004 | 		);
 | 
  
    | 1005 | 		$replacements = array(
 | 
  
    | 1006 |             $oReg->AcpDir,
 | 
  
    | 1007 |             $oReg->MediaDir,
 | 
  
    | 1008 |             $oReg->PagesDir,
 | 
  
    | 1009 | 			'framework/',
 | 
  
    | 1010 | 			'modules/',
 | 
  
    | 1011 | 			'templates/'
 | 
  
    | 1012 | 		);
 | 
  
    | 1013 | 		$msg = '';
 | 
  
    | 1014 | 		echo '<div style="margin-left:2em;">';
 | 
  
    | 1015 | 		echo '<h4>Search '.$iLoaded.' deprecated and outdated folders</h4>';
 | 
  
    | 1016 | 		foreach( $dirRemove as $sRootDir ) {
 | 
  
    | 1017 | 			$sRootDir = str_replace($searches, $replacements, $sRootDir);
 | 
  
    | 1018 |             if (file_exists($oReg->AppPath.$sRootDir)) {
 | 
  
    | 1019 |                 if (!UpgradeHelper::delTree($oReg->AppPath.$sRootDir, UpgradeHelper::DEL_ROOT_DELETE)) {
 | 
  
    | 1020 |                     $iFailed = sizeof(($msg = UpgradeHelper::getDelTreeLog()));
 | 
  
    | 1021 |                     $msg = implode('<br />', $msg);
 | 
  
    | 1022 |                 }
 | 
  
    | 1023 |             }
 | 
  
    | 1024 |         }
 | 
  
    | 1025 | 		echo ($iFailed == 0) ? $OK : $FAIL;
 | 
  
    | 1026 | 		echo '</div>';
 | 
  
    | 1027 | 		if($msg != '') {
 | 
  
    | 1028 | 			$msg = '<br /><br />Following directories are deprecated, outdated or a security risk and
 | 
  
    | 1029 | 					can not be removed automatically.<br /><br />Please delete them
 | 
  
    | 1030 | 					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
 | 
  
    | 1031 | 			status_msg($msg, 'error warning', 'div');
 | 
  
    | 1032 | 			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
 | 
  
    | 1033 | 			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
 | 
  
    | 1034 | 			echo ' <input name="send" type="submit" value="Restart upgrade script" />';
 | 
  
    | 1035 | 			echo '</form>';
 | 
  
    | 1036 | 			echo "<br /><br /></div>
 | 
  
    | 1037 | 			</div>
 | 
  
    | 1038 | 			</div>
 | 
  
    | 1039 | 			</body>
 | 
  
    | 1040 | 			</html>";
 | 
  
    | 1041 | 			exit;
 | 
  
    | 1042 | 		}
 | 
  
    | 1043 | 	}
 | 
  
    | 1044 | 
 | 
  
    | 1045 | 	/**********************************************************
 | 
  
    | 1046 | 	 * upgrade modules if newer version is available
 | 
  
    | 1047 | 	 * $aModuleList list of proofed modules
 | 
  
    | 1048 | 	 */
 | 
  
    | 1049 | 	$aProofedModuleList = array(
 | 
  
    | 1050 | 	              'captcha_control','code','droplets','form','jsadmin',
 | 
  
    | 1051 | 	              'menu_link','news','output_filter','wrapper','wysiwyg','MultiLingual');
 | 
  
    | 1052 | 	if(sizeof($aProofedModuleList)) 
 | 
  
    | 1053 | 	{
 | 
  
    | 1054 | 		echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>';
 | 
  
    | 1055 | 		foreach($aProofedModuleList as $sModul) {
 | 
  
    | 1056 | 			if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
 | 
  
    | 1057 | 				$currModulVersion = get_modul_version ($sModul, false);
 | 
  
    | 1058 | 				$newModulVersion =  get_modul_version ($sModul, true);
 | 
  
    | 1059 | 				if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
 | 
  
    | 1060 | 					echo '<div style="margin-left:2em;">';
 | 
  
    | 1061 | 					echo '<h4>'.'Upgrade module \''.$sModul.'\' version '.$newModulVersion.'</h4>';
 | 
  
    | 1062 | 					require(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
 | 
  
    | 1063 | 					echo '</div>';
 | 
  
    | 1064 | 				}
 | 
  
    | 1065 | 			}
 | 
  
    | 1066 | 		}
 | 
  
    | 1067 | 	}
 | 
  
    | 1068 | 
 | 
  
    | 1069 | 	/**********************************************************
 | 
  
    | 1070 | 	 * Reformat/rebuild all existing moules access files
 | 
  
    | 1071 | 	 * $aModuleList list of modules
 | 
  
    | 1072 | 	 */
 | 
  
    | 1073 | 	$aModuleList = array('bakery','topics','news');
 | 
  
    | 1074 | 	if(sizeof($aModuleList)) 
 | 
  
    | 1075 | 	{
 | 
  
    | 1076 | 		echo '<h3>Step '.(++$stepID).': Create/Reorg Accessfiles from modules</h3>';
 | 
  
    | 1077 | 		foreach($aModuleList as $sModul) {
 | 
  
    | 1078 | 			$aReturnMsg = array();
 | 
  
    | 1079 | 			$sModulReorg = 'm_'.$sModul.'_Reorg';
 | 
  
    | 1080 | 			if(class_exists($sModulReorg)) {
 | 
  
    | 1081 | 				$sModulVersion =  get_modul_version ($sModul, true);
 | 
  
    | 1082 | 				echo '<div style="margin-left:2em;">';
 | 
  
    | 1083 | 				echo '<h4>'.'Create/Reorg Accessfiles for module \''.$sModul.'\' version '.$sModulVersion.'</h4>';
 | 
  
    | 1084 | 				$oReorg = new $sModulReorg(ModuleReorgAbstract::LOG_EXTENDED);
 | 
  
    | 1085 | 				$aReturnMsg = $oReorg->execute(); // show details
 | 
  
    | 1086 |                 $aReport = $oReorg->getReport();
 | 
  
    | 1087 |                 unset($oReorg);
 | 
  
    | 1088 |                 if($bDebugModus) {
 | 
  
    | 1089 |                     foreach($aReport['Failed'] as $sValue) {
 | 
  
    | 1090 |                         echo $sValue.'<br />';
 | 
  
    | 1091 |                     }
 | 
  
    | 1092 |                     foreach($aReport['Success'] as $sValue) {
 | 
  
    | 1093 |                         echo $sValue.'<br />';
 | 
  
    | 1094 |                     }
 | 
  
    | 1095 |     			}
 | 
  
    | 1096 | //				echo '<strong>'.$aReport['FilesDeleted'].' Files successful deleted</strong><br />';
 | 
  
    | 1097 | 				echo '<strong>Number of new formated access files: '.$aReport['FilesCreated'].'</strong><br />';
 | 
  
    | 1098 | 
 | 
  
    | 1099 | 				echo '</div>';
 | 
  
    | 1100 | 			}
 | 
  
    | 1101 | 		}
 | 
  
    | 1102 | 	}
 | 
  
    | 1103 | /**********************************************************
 | 
  
    | 1104 |  *  - Reload all addons
 | 
  
    | 1105 |  */
 | 
  
    | 1106 | 
 | 
  
    | 1107 | 	echo '<h3>Step '.(++$stepID).' : Reload all addons database entry (no upgrade)</h3><br />';
 | 
  
    | 1108 | 	echo '<div style="margin-left:2em;">';
 | 
  
    | 1109 | 	$iFound = 0;
 | 
  
    | 1110 | 	$iLoaded = 0;
 | 
  
    | 1111 | 	////delete modules
 | 
  
    | 1112 | 	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
 | 
  
    | 1113 | 	// Load all modules
 | 
  
    | 1114 | 	if( ($handle = opendir(WB_PATH.'/modules/')) ) {
 | 
  
    | 1115 | 		while(false !== ($file = readdir($handle))) {
 | 
  
    | 1116 | 			if($file != '' && substr($file, 0, 1) != '.' && is_dir(WB_PATH.'/modules/'.$file) ) {
 | 
  
    | 1117 | 				$iFound++;
 | 
  
    | 1118 | 				$iLoaded = load_module(WB_PATH.'/modules/'.$file ) ? $iLoaded+1 : $iLoaded;
 | 
  
    | 1119 | // 	upgrade_module($file, true);
 | 
  
    | 1120 | 			}
 | 
  
    | 1121 | 		}
 | 
  
    | 1122 | 		closedir($handle);
 | 
  
    | 1123 | 	}
 | 
  
    | 1124 | 	echo '<strong><span>'.$iLoaded.' Modules reloaded,</span> found '.$iFound.' directories in folder /modules/</strong><br />';
 | 
  
    | 1125 | 
 | 
  
    | 1126 | 	$iFound = 0;
 | 
  
    | 1127 | 	$iLoaded = 0;
 | 
  
    | 1128 | 	////delete templates
 | 
  
    | 1129 | 	$oDb->doQuery('DELETE FROM `'.$oDb->TablePrefix.'addons` WHERE `type`=\'template\'');
 | 
  
    | 1130 | 	// Load all templates
 | 
  
    | 1131 | 	if( ($handle = opendir(WB_PATH.'/templates/')) ) {
 | 
  
    | 1132 | 		while(false !== ($file = readdir($handle))) {
 | 
  
    | 1133 | 			if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
 | 
  
    | 1134 | 				$iFound++;
 | 
  
    | 1135 | 				$iLoaded = (load_template(WB_PATH.'/templates/'.$file)==true) ? $iLoaded+1 : $iLoaded;
 | 
  
    | 1136 | 			}
 | 
  
    | 1137 | 		}
 | 
  
    | 1138 | 		closedir($handle);
 | 
  
    | 1139 | 	}
 | 
  
    | 1140 | 	echo '<strong><span>'.$iLoaded.' Templates reloaded,</span> found '.$iFound.' directories in folder /templates/</strong><br />';
 | 
  
    | 1141 | 	$iFound = 0;
 | 
  
    | 1142 | 	$iLoaded = 0;
 | 
  
    | 1143 | 	////delete languages
 | 
  
    | 1144 | 	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
 | 
  
    | 1145 | 	// Load all languages
 | 
  
    | 1146 | 	if( ($handle = opendir(WB_PATH.'/languages/')) ) {
 | 
  
    | 1147 | 		while(false !== ($file = readdir($handle))) {
 | 
  
    | 1148 | 			if($file != '' AND (preg_match('#^([A-Z]{2}.php)#', basename($file)))) {
 | 
  
    | 1149 | 				$iFound++;
 | 
  
    | 1150 | 				$iLoaded = load_language(WB_PATH.'/languages/'.$file) ? $iLoaded+1 : $iLoaded;
 | 
  
    | 1151 | 			}
 | 
  
    | 1152 | 		}
 | 
  
    | 1153 | 		closedir($handle);
 | 
  
    | 1154 | 	}
 | 
  
    | 1155 | 	echo '<strong><span>'.$iLoaded.' Languages reloaded,</span> found '.$iFound.' files in folder /languages/</strong><br />';
 | 
  
    | 1156 | 	$sTransCachePath = WB_PATH.'/temp/TranslationTable/cache/';
 | 
  
    | 1157 | 	if (is_writeable($sTransCachePath)) {
 | 
  
    | 1158 | 		if (rm_full_dir($sTransCachePath, true)) {
 | 
  
    | 1159 | 			echo '<strong><span>Translation Cache cleaned</span></strong> '.$OK.'<br />';
 | 
  
    | 1160 | 		} else {
 | 
  
    | 1161 | 			echo '<strong><span>Clean Translation Cache</span></strong> '.$FAIL.'<br />';
 | 
  
    | 1162 | 		}
 | 
  
    | 1163 | 	}
 | 
  
    | 1164 | 	echo '</div>';
 | 
  
    | 1165 | 
 | 
  
    | 1166 | /**********************************************************
 | 
  
    | 1167 |  *  - install new droplets
 | 
  
    | 1168 | 	$drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />";
 | 
  
    | 1169 | 	echo $drops;
 | 
  
    | 1170 | 	$file_name = (!in_array ( "mod_droplets", $all_tables) ? "install.php" : "upgrade.php");
 | 
  
    | 1171 | 	require_once (WB_PATH."/modules/droplets/".$file_name);
 | 
  
    | 1172 | ********************************************************** */
 | 
  
    | 1173 | 
 | 
  
    | 1174 | /**********************************************************
 | 
  
    | 1175 |  *  - End of upgrade script
 | 
  
    | 1176 |  */
 | 
  
    | 1177 | 	if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
 | 
  
    | 1178 | 	if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
 | 
  
    | 1179 | /**********************************************************
 | 
  
    | 1180 |  *  - Set Version to new Version
 | 
  
    | 1181 |  */
 | 
  
    | 1182 | echo '<h3>Step '.(++$stepID).': Update database version number </h3>';
 | 
  
    | 1183 | echo '<div style="margin-left:2em;">';
 | 
  
    | 1184 | 
 | 
  
    | 1185 | $cfg = array(
 | 
  
    | 1186 | 	'wb_version' => VERSION,
 | 
  
    | 1187 | 	'wb_revision' => REVISION,
 | 
  
    | 1188 | 	'wb_sp' => SP
 | 
  
    | 1189 | );
 | 
  
    | 1190 | echo '<br /><span><strong>Set WebsiteBaker version number to '.VERSION.' '.SP.' '.' Revision ['.REVISION.'] : </strong></span>';
 | 
  
    | 1191 | echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 1192 | echo '</div>';
 | 
  
    | 1193 | 
 | 
  
    | 1194 | echo '<p style="font-size:140%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
 | 
  
    | 1195 | status_msg('<strong>:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
 | 
  
    | 1196 | // show buttons to go to the backend or frontend
 | 
  
    | 1197 | echo '<br />';
 | 
  
    | 1198 | 
 | 
  
    | 1199 | if(defined('WB_URL')) {
 | 
  
    | 1200 | 	echo '<form action="'.WB_URL.'/">';
 | 
  
    | 1201 | 	echo ' <input type="submit" value="kick me to the Frontend" />';
 | 
  
    | 1202 | 	echo '</form>';
 | 
  
    | 1203 | }
 | 
  
    | 1204 | if(defined('ADMIN_URL')) {
 | 
  
    | 1205 | 	echo '<form action="'.ADMIN_URL.'/">';
 | 
  
    | 1206 | 	echo ' <input type="submit" value="kick me to the Backend" />';
 | 
  
    | 1207 | 	echo '</form>';
 | 
  
    | 1208 | }
 | 
  
    | 1209 | 
 | 
  
    | 1210 | echo "<br /><br /></div>
 | 
  
    | 1211 | </div>
 | 
  
    | 1212 | </div>
 | 
  
    | 1213 | </body>
 | 
  
    | 1214 | </html>
 | 
  
    | 1215 | ";
 | 
  
    | 1216 | exit();
 |