| 1 | <?php
 | 
  
    | 2 | /**
 | 
  
    | 3 |  *
 | 
  
    | 4 |  * @category        backend
 | 
  
    | 5 |  * @package         installation
 | 
  
    | 6 |  * @author          WebsiteBaker Project
 | 
  
    | 7 |  * @copyright       2009-2012, WebsiteBaker Org. e.V.
 | 
  
    | 8 |  * @link            http://www.websitebaker2.org/
 | 
  
    | 9 |  * @license         http://www.gnu.org/licenses/gpl.html
 | 
  
    | 10 |  * @platform        WebsiteBaker 2.8.x
 | 
  
    | 11 |  * @requirements    PHP 5.2.2 and higher
 | 
  
    | 12 |  * @version         $Id: upgrade-script.php 1772 2012-09-27 23:31:16Z Luisehahne $
 | 
  
    | 13 |  * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/upgrade-script.php $
 | 
  
    | 14 |  * @lastmodified    $Date: 2012-09-28 01:31:16 +0200 (Fri, 28 Sep 2012) $
 | 
  
    | 15 |  *
 | 
  
    | 16 |  */
 | 
  
    | 17 | 
 | 
  
    | 18 | require_once('config.php');
 | 
  
    | 19 | 
 | 
  
    | 20 | require_once(WB_PATH.'/framework/functions.php');
 | 
  
    | 21 | require_once(WB_PATH.'/framework/class.admin.php');
 | 
  
    | 22 | // require_once(WB_PATH.'/framework/Database.php');
 | 
  
    | 23 | $admin = new admin('Addons', 'modules', false, false);
 | 
  
    | 24 | 
 | 
  
    | 25 | $oldVersion  = 'Version '.WB_VERSION;
 | 
  
    | 26 | $oldVersion .= (defined('WB_SP') ? WB_SP : '');
 | 
  
    | 27 | $oldRevision = (defined('WB_REVISION') ? ' Revision ['.WB_REVISION.'] ' : '') ;
 | 
  
    | 28 | $newVersion  = 'Version '.VERSION;
 | 
  
    | 29 | $newVersion .= (defined('SP') ? SP : '');
 | 
  
    | 30 | $newRevision = (defined('REVISION') ? ' Revision ['.REVISION.'] ' : '');
 | 
  
    | 31 | 
 | 
  
    | 32 | $bDebugModus = false;
 | 
  
    | 33 | 
 | 
  
    | 34 | // set addition settings if not exists, otherwise upgrade will be breaks
 | 
  
    | 35 | if(!defined('WB_SP')) { define('WB_SP',''); }
 | 
  
    | 36 | if(!defined('WB_REVISION')) { define('WB_REVISION',''); }
 | 
  
    | 37 | 
 | 
  
    | 38 | // database tables including in WB package
 | 
  
    | 39 | $aPackage = array (
 | 
  
    | 40 |     'settings','groups','addons','pages','sections','search','users',
 | 
  
    | 41 |     'mod_captcha_control','mod_code','mod_droplets','mod_form_fields',
 | 
  
    | 42 |     'mod_form_settings','mod_form_submissions','mod_jsadmin','mod_menu_link',
 | 
  
    | 43 |     'mod_news_comments','mod_news_groups','mod_news_posts','mod_news_settings',
 | 
  
    | 44 |     'mod_output_filter','mod_wrapper','mod_wysiwyg'
 | 
  
    | 45 | );
 | 
  
    | 46 | 
 | 
  
    | 47 | $OK            = ' <span class="ok">OK</span> ';
 | 
  
    | 48 | $FAIL          = ' <span class="error">FAILED</span> ';
 | 
  
    | 49 | $DEFAULT_THEME = 'wb_theme';
 | 
  
    | 50 | 
 | 
  
    | 51 | $stepID = 0;
 | 
  
    | 52 | $aFilesToRemove = array();
 | 
  
    | 53 | $dirRemove = array(
 | 
  
    | 54 | /*
 | 
  
    | 55 | 			'[TEMPLATE]/allcss/',
 | 
  
    | 56 | 			'[TEMPLATE]/blank/',
 | 
  
    | 57 | 			'[TEMPLATE]/round/',
 | 
  
    | 58 | 			'[TEMPLATE]/simple/',
 | 
  
    | 59 | */
 | 
  
    | 60 | 			'[ADMIN]/themes/',
 | 
  
    | 61 | 		 );
 | 
  
    | 62 | 
 | 
  
    | 63 | if(version_compare(WB_REVISION, '1762', '<'))
 | 
  
    | 64 | {
 | 
  
    | 65 |     $filesRemove['0'] = array(
 | 
  
    | 66 | 
 | 
  
    | 67 | 			'[ADMIN]/preferences/details.php',
 | 
  
    | 68 | 			'[ADMIN]/preferences/email.php',
 | 
  
    | 69 | 			'[ADMIN]/preferences/password.php',
 | 
  
    | 70 | 			'[ADMIN]/pages/settings2.php',
 | 
  
    | 71 | 
 | 
  
    | 72 | 			'[FRAMEWORK]/class.msg_queue.php',
 | 
  
    | 73 | 			'[FRAMEWORK]/class.logfile.php',
 | 
  
    | 74 | //			'[FRAMEWORK]/class.database.php',
 | 
  
    | 75 | 
 | 
  
    | 76 | 		 );
 | 
  
    | 77 | 
 | 
  
    | 78 | 	$filesRemove['1'] = array(
 | 
  
    | 79 | 
 | 
  
    | 80 | 			'[TEMPLATE]/argos_theme/templates/access.htt',
 | 
  
    | 81 | 			'[TEMPLATE]/argos_theme/templates/addons.htt',
 | 
  
    | 82 | 			'[TEMPLATE]/argos_theme/templates/admintools.htt',
 | 
  
    | 83 | 			'[TEMPLATE]/argos_theme/templates/error.htt',
 | 
  
    | 84 | 			'[TEMPLATE]/argos_theme/templates/groups.htt',
 | 
  
    | 85 | 			'[TEMPLATE]/argos_theme/templates/groups_form.htt',
 | 
  
    | 86 | 			'[TEMPLATE]/argos_theme/templates/languages.htt',
 | 
  
    | 87 | 			'[TEMPLATE]/argos_theme/templates/languages_details.htt',
 | 
  
    | 88 | 	/*
 | 
  
    | 89 | 			'[TEMPLATE]/argos_theme/templates/login.htt',
 | 
  
    | 90 | 			'[TEMPLATE]/argos_theme/templates/login_forgot.htt',
 | 
  
    | 91 | 	*/
 | 
  
    | 92 | 			'[TEMPLATE]/argos_theme/templates/media.htt',
 | 
  
    | 93 | 			'[TEMPLATE]/argos_theme/templates/media_browse.htt',
 | 
  
    | 94 | 			'[TEMPLATE]/argos_theme/templates/media_rename.htt',
 | 
  
    | 95 | 			'[TEMPLATE]/argos_theme/templates/modules.htt',
 | 
  
    | 96 | 			'[TEMPLATE]/argos_theme/templates/modules_details.htt',
 | 
  
    | 97 | 			'[TEMPLATE]/argos_theme/templates/pages.htt',
 | 
  
    | 98 | 			'[TEMPLATE]/argos_theme/templates/pages_modify.htt',
 | 
  
    | 99 | 			'[TEMPLATE]/argos_theme/templates/pages_sections.htt',
 | 
  
    | 100 | 			'[TEMPLATE]/argos_theme/templates/pages_settings.htt',
 | 
  
    | 101 | 			'[TEMPLATE]/argos_theme/templates/preferences.htt',
 | 
  
    | 102 | 			'[TEMPLATE]/argos_theme/templates/setparameter.htt',
 | 
  
    | 103 | 			'[TEMPLATE]/argos_theme/templates/settings.htt',
 | 
  
    | 104 | 			'[TEMPLATE]/argos_theme/templates/start.htt',
 | 
  
    | 105 | 			'[TEMPLATE]/argos_theme/templates/success.htt',
 | 
  
    | 106 | 			'[TEMPLATE]/argos_theme/templates/templates.htt',
 | 
  
    | 107 | 			'[TEMPLATE]/argos_theme/templates/templates_details.htt',
 | 
  
    | 108 | 			'[TEMPLATE]/argos_theme/templates/users.htt',
 | 
  
    | 109 | 			'[TEMPLATE]/argos_theme/templates/users_form.htt',
 | 
  
    | 110 | 
 | 
  
    | 111 | 			'[TEMPLATE]/wb_theme/templates/access.htt',
 | 
  
    | 112 | 			'[TEMPLATE]/wb_theme/templates/addons.htt',
 | 
  
    | 113 | 			'[TEMPLATE]/wb_theme/templates/admintools.htt',
 | 
  
    | 114 | 			'[TEMPLATE]/wb_theme/templates/error.htt',
 | 
  
    | 115 | 			'[TEMPLATE]/wb_theme/templates/groups.htt',
 | 
  
    | 116 | 			'[TEMPLATE]/wb_theme/templates/groups_form.htt',
 | 
  
    | 117 | 			'[TEMPLATE]/wb_theme/templates/languages.htt',
 | 
  
    | 118 | 			'[TEMPLATE]/wb_theme/templates/languages_details.htt',
 | 
  
    | 119 | 
 | 
  
    | 120 | 	/*
 | 
  
    | 121 | 			'[TEMPLATE]/wb_theme/templates/login.htt',
 | 
  
    | 122 | 			'[TEMPLATE]/wb_theme/templates/login_forgot.htt',
 | 
  
    | 123 | 	*/
 | 
  
    | 124 | 
 | 
  
    | 125 | 			'[TEMPLATE]/wb_theme/templates/media.htt',
 | 
  
    | 126 | 			'[TEMPLATE]/wb_theme/templates/media_browse.htt',
 | 
  
    | 127 | 			'[TEMPLATE]/wb_theme/templates/media_rename.htt',
 | 
  
    | 128 | 			'[TEMPLATE]/wb_theme/templates/modules.htt',
 | 
  
    | 129 | 			'[TEMPLATE]/wb_theme/templates/modules_details.htt',
 | 
  
    | 130 | 			'[TEMPLATE]/wb_theme/templates/pages.htt',
 | 
  
    | 131 | 			'[TEMPLATE]/wb_theme/templates/pages_modify.htt',
 | 
  
    | 132 | 			'[TEMPLATE]/wb_theme/templates/pages_sections.htt',
 | 
  
    | 133 | 			'[TEMPLATE]/wb_theme/templates/pages_settings.htt',
 | 
  
    | 134 | 			'[TEMPLATE]/wb_theme/templates/preferences.htt',
 | 
  
    | 135 | 			'[TEMPLATE]/wb_theme/templates/setparameter.htt',
 | 
  
    | 136 | 			'[TEMPLATE]/wb_theme/templates/settings.htt',
 | 
  
    | 137 | 			'[TEMPLATE]/wb_theme/templates/start.htt',
 | 
  
    | 138 | 			'[TEMPLATE]/wb_theme/templates/success.htt',
 | 
  
    | 139 | 			'[TEMPLATE]/wb_theme/templates/templates.htt',
 | 
  
    | 140 | 			'[TEMPLATE]/wb_theme/templates/templates_details.htt',
 | 
  
    | 141 | 			'[TEMPLATE]/wb_theme/templates/users.htt',
 | 
  
    | 142 | 			'[TEMPLATE]/wb_theme/templates/users_form.htt',
 | 
  
    | 143 | 		 );
 | 
  
    | 144 | 
 | 
  
    | 145 |     $aFilesToRemove = array_merge($filesRemove['0'],$filesRemove['1']);
 | 
  
    | 146 | 
 | 
  
    | 147 | }
 | 
  
    | 148 | 
 | 
  
    | 149 | /* display a status message on the screen **************************************
 | 
  
    | 150 |  * @param string $message: the message to show
 | 
  
    | 151 |  * @param string $class:   kind of message as a css-class
 | 
  
    | 152 |  * @param string $element: witch HTML-tag use to cover the message
 | 
  
    | 153 |  * @return void
 | 
  
    | 154 |  */
 | 
  
    | 155 | function status_msg($message, $class='check', $element='div')
 | 
  
    | 156 | {
 | 
  
    | 157 | 	// returns a status message
 | 
  
    | 158 | 	$msg  = '<'.$element.' class="'.$class.'">';
 | 
  
    | 159 | 	$msg .= '<strong>'.strtoupper(strtok($class, ' ')).'</strong>';
 | 
  
    | 160 | 	$msg .= $message.'</'.$element.'>';
 | 
  
    | 161 | 	echo $msg;
 | 
  
    | 162 | }
 | 
  
    | 163 | 
 | 
  
    | 164 | /**
 | 
  
    | 165 |  * add_modify_field_in_database()
 | 
  
    | 166 |  *
 | 
  
    | 167 |  * @param mixed $sTable
 | 
  
    | 168 |  * @param mixed $sField
 | 
  
    | 169 |  * @param mixed $sDescription
 | 
  
    | 170 |  * @return
 | 
  
    | 171 |  */
 | 
  
    | 172 | function add_modify_field_in_database($sTable,$sField,$sDescription){
 | 
  
    | 173 |     global $database,$OK,$FAIL,$bDebugModus;
 | 
  
    | 174 |     $aDebugMessage = array();
 | 
  
    | 175 | 	if(!$database->field_exists($sTable,$sField)) {
 | 
  
    | 176 | 		$aDebugMessage[] = "<span>Adding field $sField to $sTable table</span>";
 | 
  
    | 177 | 		$aDebugMessage[] = ($database->field_add($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 178 | 	} else {
 | 
  
    | 179 | 		$aDebugMessage[] = "<span>Modify field $sField to $sTable table</span>";
 | 
  
    | 180 | 		$aDebugMessage[] = ($database->field_modify($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 181 | 	}
 | 
  
    | 182 |     if($bDebugModus) {
 | 
  
    | 183 |         echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 184 |     }
 | 
  
    | 185 |     return;
 | 
  
    | 186 | }
 | 
  
    | 187 | 
 | 
  
    | 188 | /**
 | 
  
    | 189 |  * check existings tables for upgrade or install
 | 
  
    | 190 |  *
 | 
  
    | 191 |  * check_wb_tables()
 | 
  
    | 192 |  *
 | 
  
    | 193 |  * @return
 | 
  
    | 194 |  */
 | 
  
    | 195 | function check_wb_tables()
 | 
  
    | 196 | {
 | 
  
    | 197 |     global $database,$aPackage;
 | 
  
    | 198 | 
 | 
  
    | 199 | // if prefix inludes '_' or '%'
 | 
  
    | 200 |     $search_for = addcslashes ( TABLE_PREFIX, '%_' );
 | 
  
    | 201 |     $get_result = $database->query( 'SHOW TABLES LIKE "'.$search_for.'%"');
 | 
  
    | 202 | 
 | 
  
    | 203 |     // $get_result = $database->query( "SHOW TABLES FROM ".DB_NAME);
 | 
  
    | 204 |     $all_tables = array();
 | 
  
    | 205 |     $aTable = array();
 | 
  
    | 206 |     if($get_result->numRows() > 0)
 | 
  
    | 207 |     {
 | 
  
    | 208 |         while ($data = $get_result->fetchRow()) {
 | 
  
    | 209 |             $tmp = str_replace(TABLE_PREFIX, '', $data[0]);
 | 
  
    | 210 |             if(in_array($tmp,$aPackage)) {
 | 
  
    | 211 |                 $all_tables[] = $tmp;
 | 
  
    | 212 |             } else {
 | 
  
    | 213 |                 $aTable[] = $tmp;
 | 
  
    | 214 |             }
 | 
  
    | 215 |         }
 | 
  
    | 216 |     }
 | 
  
    | 217 | 
 | 
  
    | 218 |     return array_merge ( $all_tables, $aTable );
 | 
  
    | 219 | }
 | 
  
    | 220 | 
 | 
  
    | 221 | // check existing tables
 | 
  
    | 222 | $all_tables = check_wb_tables();
 | 
  
    | 223 | 
 | 
  
    | 224 | ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
  
    | 225 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 | 
  
    | 226 | <head>
 | 
  
    | 227 | <title>Upgrade script</title>
 | 
  
    | 228 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
  
    | 229 | <style type="text/css">
 | 
  
    | 230 | html { overflow-y: scroll; /* Force firefox to always show room for a vertical scrollbar */ }
 | 
  
    | 231 | 
 | 
  
    | 232 | body {
 | 
  
    | 233 | 	margin:0;
 | 
  
    | 234 | 	padding:0;
 | 
  
    | 235 | 	border:0;
 | 
  
    | 236 | 	background: #EBF7FC;
 | 
  
    | 237 | 	color:#000;
 | 
  
    | 238 | 	font-family: 'Trebuchet MS', Verdana, Arial, Helvetica, Sans-Serif;
 | 
  
    | 239 | 	font-size: small;
 | 
  
    | 240 | 	height:101%;
 | 
  
    | 241 | }
 | 
  
    | 242 | 
 | 
  
    | 243 | #container {
 | 
  
    | 244 | 	min-width:48em;
 | 
  
    | 245 |     width: 70%;
 | 
  
    | 246 | 	background: #A8BCCB url(templates/wb_theme/images/background.png) repeat-x;
 | 
  
    | 247 | 	border:1px solid #000;
 | 
  
    | 248 | 	color:#000;
 | 
  
    | 249 | 	margin:2em auto;
 | 
  
    | 250 | 	padding:0 20px;
 | 
  
    | 251 | 	min-height: 500px;
 | 
  
    | 252 | 	text-align:left;
 | 
  
    | 253 | }
 | 
  
    | 254 | .page {
 | 
  
    | 255 | 	width:100%;
 | 
  
    | 256 |     overflow: hidden;
 | 
  
    | 257 | }
 | 
  
    | 258 | .content {
 | 
  
    | 259 |     padding: 10px;
 | 
  
    | 260 | }
 | 
  
    | 261 | p { line-height:1.5em; }
 | 
  
    | 262 | 
 | 
  
    | 263 | form {
 | 
  
    | 264 | 	display: inline-block;
 | 
  
    | 265 | 	line-height: 20px;
 | 
  
    | 266 | 	vertical-align: baseline;
 | 
  
    | 267 | }
 | 
  
    | 268 | input[type="submit"].restart {
 | 
  
    | 269 | 	background-color: #FFDBDB;
 | 
  
    | 270 | 	font-weight: bold;
 | 
  
    | 271 | }
 | 
  
    | 272 | 
 | 
  
    | 273 | h1,h2,h3,h4,h5,h6 {
 | 
  
    | 274 | 	font-family: Verdana, Arial, Helvetica, sans-serif;
 | 
  
    | 275 | 	color: #26527D;
 | 
  
    | 276 | 	margin-top: 1.0em;
 | 
  
    | 277 | 	margin-bottom: 0.1em;
 | 
  
    | 278 | }
 | 
  
    | 279 | 
 | 
  
    | 280 | h1 { font-size:150%; }
 | 
  
    | 281 | h2 { font-size: 130%; border-bottom: 1px #CCC solid; }
 | 
  
    | 282 | h3 { font-size: 110%; font-weight: bold; }
 | 
  
    | 283 | 
 | 
  
    | 284 | textarea {
 | 
  
    | 285 | 	width:100%;
 | 
  
    | 286 |     border: 2px groove #0F1D44;
 | 
  
    | 287 |     padding: 2px;
 | 
  
    | 288 |     color: #000;
 | 
  
    | 289 |     font-weight: normal;
 | 
  
    | 290 | }
 | 
  
    | 291 | .ok, .error { font-weight:bold; }
 | 
  
    | 292 | .ok { color:green; }
 | 
  
    | 293 | .error { color:red; }
 | 
  
    | 294 | .check { color:#555; }
 | 
  
    | 295 | 
 | 
  
    | 296 | span.ok,
 | 
  
    | 297 | span.error {
 | 
  
    | 298 |     margin-left: 0em;
 | 
  
    | 299 | }
 | 
  
    | 300 | 
 | 
  
    | 301 | .warning {
 | 
  
    | 302 | 	background:#FFDBDB;
 | 
  
    | 303 | 	padding:1em;
 | 
  
    | 304 | 	margin-top:0.5em;
 | 
  
    | 305 | 	border: 1px solid #DB0909;
 | 
  
    | 306 | }
 | 
  
    | 307 | .info {
 | 
  
    | 308 | 	background:#C7F4C7;
 | 
  
    | 309 | 	padding:1em;
 | 
  
    | 310 | 	margin-top:0.5em;
 | 
  
    | 311 | 	border: 1px solid #277A29;
 | 
  
    | 312 | }
 | 
  
    | 313 | 
 | 
  
    | 314 | </style>
 | 
  
    | 315 | </head>
 | 
  
    | 316 | <body>
 | 
  
    | 317 | <div id="container">
 | 
  
    | 318 | <div class="page">
 | 
  
    | 319 | <img src="templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
 | 
  
    | 320 | <div class="content">
 | 
  
    | 321 | <h1>WebsiteBaker Upgrade</h1>
 | 
  
    | 322 | <?php
 | 
  
    | 323 | 	if( version_compare( WB_VERSION, '2.7', '<' )) {
 | 
  
    | 324 | 		status_msg('<strong>Warning:</strong><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');
 | 
  
    | 325 | 		echo '<br /><br />';
 | 
  
    | 326 | 		echo "</div>
 | 
  
    | 327 |         </div>
 | 
  
    | 328 |         </div>
 | 
  
    | 329 | 		</body>
 | 
  
    | 330 | 		</html>
 | 
  
    | 331 | 		";
 | 
  
    | 332 | 		exit();
 | 
  
    | 333 | 	}
 | 
  
    | 334 | 
 | 
  
    | 335 | ?>
 | 
  
    | 336 | <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>
 | 
  
    | 337 | 
 | 
  
    | 338 | <?php
 | 
  
    | 339 | /**
 | 
  
    | 340 |  * Check if disclaimer was accepted
 | 
  
    | 341 |  */
 | 
  
    | 342 | $bDebugModus = false;
 | 
  
    | 343 | $bDebugModus = ( (isset($_POST['debug_confirmed']) && $_POST['debug_confirmed'] == 'debug') ? true : false);
 | 
  
    | 344 | if (!(isset($_POST['backup_confirmed']) && $_POST['backup_confirmed'] == 'confirmed')) { ?>
 | 
  
    | 345 | <h2>Step 1: Backup your files</h2>
 | 
  
    | 346 | <p>It is highly recommended to <strong>create a manual backup</strong> of the entire <strong><?php echo  PAGES_DIRECTORY ?>/ folder</strong> and the <strong>MySQL database</strong> before proceeding.<br /><strong class="error">Note: </strong>The upgrade script alters some settings of your existing database!!! You need to confirm the disclaimer before proceeding.</p>
 | 
  
    | 347 | 
 | 
  
    | 348 | <form name="send" action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
 | 
  
    | 349 | <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>
 | 
  
    | 350 | <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>
 | 
  
    | 351 | <br /><br /><input name="debug_confirmed" type="checkbox" value="debug" /> <strong>Here you can get more details during running upgrade.</strong>
 | 
  
    | 352 | <br /><br /><input name="send" type="submit" value="Start upgrade script" />
 | 
  
    | 353 | </form>
 | 
  
    | 354 | <br />
 | 
  
    | 355 | 
 | 
  
    | 356 | <?php
 | 
  
    | 357 | 	status_msg('<strong> Notice:</strong><br />You need to confirm that you have created a manual backup of the '.PAGES_DIRECTORY.'/ directory and the MySQL database before you can proceed.', 'warning', 'div');
 | 
  
    | 358 | 	echo '<br /><br />';
 | 
  
    | 359 |     echo "</div>
 | 
  
    | 360 |     </div>
 | 
  
    | 361 |     </div>
 | 
  
    | 362 |     </body>
 | 
  
    | 363 |     </html>
 | 
  
    | 364 |     ";
 | 
  
    | 365 | 	exit();
 | 
  
    | 366 | }
 | 
  
    | 367 | 
 | 
  
    | 368 | // check again all tables, to get a new array
 | 
  
    | 369 | // if(sizeof($all_tables) < sizeof($aTable)) { $all_tables = check_wb_tables(); }
 | 
  
    | 370 | /**********************************************************
 | 
  
    | 371 |  *  - check tables coming with WebsiteBaker
 | 
  
    | 372 |  */
 | 
  
    | 373 |     $check_text = 'total ';
 | 
  
    | 374 |     // $check_tables = mysqlCheckTables( DB_NAME ) ;
 | 
  
    | 375 |     $aTable = array();
 | 
  
    | 376 |     foreach ($all_tables as $data) {
 | 
  
    | 377 |         $tmp = str_replace(TABLE_PREFIX, '', $data);
 | 
  
    | 378 |         if(in_array($tmp,$aPackage)) {
 | 
  
    | 379 |             $aTable[] = $tmp;
 | 
  
    | 380 |         }
 | 
  
    | 381 |     }
 | 
  
    | 382 | 
 | 
  
    | 383 |     if( (sizeof($all_tables) >= sizeof($aPackage)) && (sizeof($aTable) == sizeof($aPackage)) )
 | 
  
    | 384 |     {
 | 
  
    | 385 |         echo '<h4 style="margin-left:0;">NOTICE: Your database '.DB_NAME.' has '.sizeof($all_tables).' '.$check_text.' tables from '.sizeof($aPackage).' included in package '.$OK.'</h4>';
 | 
  
    | 386 |     }
 | 
  
    | 387 |     else
 | 
  
    | 388 |     {
 | 
  
    | 389 |         status_msg('<strong>:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
 | 
  
    | 390 |         echo '<h4>Missing required tables. You can install them in backend->addons->modules.<br />';
 | 
  
    | 391 |         echo 'Or if you uploaded per FTP install possible by backend->addons->modules->advanced.<br />';
 | 
  
    | 392 |         echo 'After installing missing tables again run upgrade-script.php</h4>';
 | 
  
    | 393 |         $result = array_diff ( $aPackage, $aTable );
 | 
  
    | 394 | 
 | 
  
    | 395 |         echo '<h4 class="warning"><br />';
 | 
  
    | 396 |         while ( list ( $key, $val ) = each ( $result ) )
 | 
  
    | 397 |         {
 | 
  
    | 398 |             echo 'TABLE ´'.TABLE_PREFIX.$val.'´ '.$FAIL.'<br>';
 | 
  
    | 399 |         }
 | 
  
    | 400 | 
 | 
  
    | 401 |         echo '<br /></h4>';
 | 
  
    | 402 |         echo '<br /><br />';
 | 
  
    | 403 |         if(isset($_SERVER['SCRIPT_NAME'])) {
 | 
  
    | 404 |         	echo '<form action="'.$_SERVER['SCRIPT_NAME'].'/">';
 | 
  
    | 405 |         	echo ' <input type="submit" value="Start upgrade again" />';
 | 
  
    | 406 |         	echo '</form>';
 | 
  
    | 407 |         }
 | 
  
    | 408 |         if(defined('ADMIN_URL')) {
 | 
  
    | 409 |         	echo '<form action="'.ADMIN_URL.'/">';
 | 
  
    | 410 |         	echo ' <input type="submit" value="kick me to the Backend" />';
 | 
  
    | 411 |         	echo '</form>';
 | 
  
    | 412 |         }
 | 
  
    | 413 | 
 | 
  
    | 414 |         echo "<br /><br /></div>
 | 
  
    | 415 |         </div>
 | 
  
    | 416 |         </div>
 | 
  
    | 417 |         </body>
 | 
  
    | 418 |         </html>
 | 
  
    | 419 |         ";
 | 
  
    | 420 | 
 | 
  
    | 421 |         exit();
 | 
  
    | 422 |     }
 | 
  
    | 423 | 
 | 
  
    | 424 | echo '<h3>Step '.(++$stepID).': Setting default_theme</h3>';
 | 
  
    | 425 | $aDebugMessage = array();
 | 
  
    | 426 |     /**********************************************************
 | 
  
    | 427 |      *  - Adding field default_theme to settings table
 | 
  
    | 428 |      */
 | 
  
    | 429 |     $aDebugMessage[] = '<div style="margin-left:2em;">';
 | 
  
    | 430 |     $aDebugMessage[] = "<br /><span><strong>Adding default_theme to settings table</strong></span>";
 | 
  
    | 431 |     // db_update_key_value('settings', 'default_theme', $DEFAULT_THEME);
 | 
  
    | 432 |     $aDebugMessage[] = (db_update_key_value( 'settings', 'default_theme', $DEFAULT_THEME ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 433 |     $aDebugMessage[] = '</div>';
 | 
  
    | 434 | 
 | 
  
    | 435 | if($bDebugModus) {
 | 
  
    | 436 |     echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 437 | }
 | 
  
    | 438 | $aDebugMessage = array();
 | 
  
    | 439 | echo'<h3>Step '.(++$stepID).': Updating core tables</h3>';
 | 
  
    | 440 |     /**********************************************************
 | 
  
    | 441 |      *  - Adding field sec_anchor to settings table
 | 
  
    | 442 |      */
 | 
  
    | 443 |     echo '<div style="margin-left:2em;">';
 | 
  
    | 444 |     echo "<h4>Adding/updating entries on table settings</h4>";
 | 
  
    | 445 |     $aDebugMessage[] = "<span>Adding/updating sec_anchor to settings table</span>";
 | 
  
    | 446 |     $cfg = array(
 | 
  
    | 447 |     	'sec_anchor' => defined('SEC_ANCHOR') ? SEC_ANCHOR : 'section_'
 | 
  
    | 448 |     );
 | 
  
    | 449 |    $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 450 | 
 | 
  
    | 451 |     /**********************************************************
 | 
  
    | 452 |      *  - Adding redirect timer to settings table
 | 
  
    | 453 |      */
 | 
  
    | 454 |     $aDebugMessage[] = "<span>Adding/updating redirect timer to settings table</span>";
 | 
  
    | 455 |     $cfg = array(
 | 
  
    | 456 |     	'redirect_timer' => defined('REDIRECT_TIMER') ? REDIRECT_TIMER : '1500'
 | 
  
    | 457 |     );
 | 
  
    | 458 |     $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 459 | 
 | 
  
    | 460 |     /**********************************************************
 | 
  
    | 461 |      *  - Adding rename_files_on_upload to settings table
 | 
  
    | 462 |      */
 | 
  
    | 463 |     $aDebugMessage[] = "<span>Adding/Updating rename_files_on_upload to settings table</span>";
 | 
  
    | 464 |     $cfg = array(
 | 
  
    | 465 |     	'rename_files_on_upload' => (defined('RENAME_FILES_ON_UPLOAD') ? RENAME_FILES_ON_UPLOAD : 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js')
 | 
  
    | 466 |     );
 | 
  
    | 467 |     $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 468 | 
 | 
  
    | 469 |     /**********************************************************
 | 
  
    | 470 |      *  - Adding mediasettings to settings table
 | 
  
    | 471 |      */
 | 
  
    | 472 |     $aDebugMessage[] = "<span>Adding/updating mediasettings to settings table</span>";
 | 
  
    | 473 |     $cfg = array(
 | 
  
    | 474 |     	'mediasettings' => (defined('MEDIASETTINGS') ? MEDIASETTINGS : ''),
 | 
  
    | 475 |     );
 | 
  
    | 476 | 
 | 
  
    | 477 |     $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 478 | 
 | 
  
    | 479 |     /**********************************************************
 | 
  
    | 480 |      *  - Adding fingerprint_with_ip_octets to settings table
 | 
  
    | 481 |      */
 | 
  
    | 482 |     $aDebugMessage[] = "<span>Adding/updating fingerprint_with_ip_octets to settings table</span>";
 | 
  
    | 483 |     $cfg = array(
 | 
  
    | 484 |     	'fingerprint_with_ip_octets' => (defined('FINGERPRINT_WITH_IP_OCTETS') ? FINGERPRINT_WITH_IP_OCTETS : '2'),
 | 
  
    | 485 |     	'secure_form_module' => (defined('SECURE_FORM_MODULE') ? SECURE_FORM_MODULE : '')
 | 
  
    | 486 |     );
 | 
  
    | 487 | 
 | 
  
    | 488 |     $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 489 | 
 | 
  
    | 490 |     /**********************************************************
 | 
  
    | 491 |      *  - Adding page_icon_dir to settings table
 | 
  
    | 492 |      */
 | 
  
    | 493 |     $aDebugMessage[] = "<span>Adding/updating page_icon_dir to settings table</span>";
 | 
  
    | 494 |     $cfg = array(
 | 
  
    | 495 |     	'page_icon_dir' => (defined('PAGE_ICON_DIR') ? PAGE_ICON_DIR : '/templates/*/title_images'),
 | 
  
    | 496 |     );
 | 
  
    | 497 | 
 | 
  
    | 498 |     $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 499 |     /**********************************************************
 | 
  
    | 500 |      *  - Adding page_extended to settings table
 | 
  
    | 501 |      */
 | 
  
    | 502 |     $aDebugMessage[] = "<span>Adding/updating page_extended to settings table</span>";
 | 
  
    | 503 |     $cfg = array(
 | 
  
    | 504 |     	'page_extended' => (defined('PAGE_EXTENDED') ? PAGE_EXTENDED : 'true'),
 | 
  
    | 505 |     );
 | 
  
    | 506 | 
 | 
  
    | 507 |     $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 508 | 
 | 
  
    | 509 |     /**********************************************************
 | 
  
    | 510 |      *  - Adding website_signature to settings table
 | 
  
    | 511 |      */
 | 
  
    | 512 |     $aDebugMessage[] = "<span>Adding/updating website_signature to settings table</span>";
 | 
  
    | 513 |     $cfg = array(
 | 
  
    | 514 |     	'website_signature' => (defined('WEBSITE_SIGNATURE') && (WEBSITE_SIGNATURE=='') ? '' : WEBSITE_SIGNATURE)
 | 
  
    | 515 |     );
 | 
  
    | 516 | 
 | 
  
    | 517 |     $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 518 | 
 | 
  
    | 519 |     /**********************************************************
 | 
  
    | 520 |      *  - Adding confirmed_registration to settings table
 | 
  
    | 521 |      */
 | 
  
    | 522 |     $aDebugMessage[] = "<span>Adding/updating confirmed_registration to settings table</span>";
 | 
  
    | 523 |     $cfg = array(
 | 
  
    | 524 |     	'confirmed_registration' => (defined('CONFIRMED_REGISTRATION') && (CONFIRMED_REGISTRATION=='') ? '' : CONFIRMED_REGISTRATION)
 | 
  
    | 525 |     );
 | 
  
    | 526 | 
 | 
  
    | 527 |     $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 528 | 
 | 
  
    | 529 |     /**********************************************************
 | 
  
    | 530 |      *  - Adding dev_infos to settings table
 | 
  
    | 531 |      */
 | 
  
    | 532 |     $aDebugMessage[] = "<span>Adding/updating dev_infos to settings table</span>";
 | 
  
    | 533 |     $cfg = array(
 | 
  
    | 534 |     	'dev_infos' => (defined('DEV_INFOS') ? DEV_INFOS : 'false')
 | 
  
    | 535 |     );
 | 
  
    | 536 | 
 | 
  
    | 537 |     $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 538 | 
 | 
  
    | 539 |     /**********************************************************
 | 
  
    | 540 |      *  - Adding dev_infos to settings table
 | 
  
    | 541 |      */
 | 
  
    | 542 |     $aDebugMessage[] = "<span>Adding/updating modules_upgrade_list to settings table</span>";
 | 
  
    | 543 |     $cfg = array(
 | 
  
    | 544 |     	'modules_upgrade_list' => (defined('MODULES_UPGRADE_LIST') ? MODULES_UPGRADE_LIST : 'news')
 | 
  
    | 545 |     );
 | 
  
    | 546 | 
 | 
  
    | 547 |     $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 548 | 
 | 
  
    | 549 | 
 | 
  
    | 550 | if($bDebugModus) {
 | 
  
    | 551 |     echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 552 | }
 | 
  
    | 553 | echo '</div>';
 | 
  
    | 554 | 
 | 
  
    | 555 | $aDebugMessage = array();
 | 
  
    | 556 | if(version_compare(WB_REVISION, REVISION, '<='))
 | 
  
    | 557 | {
 | 
  
    | 558 |     echo '<div style="margin-left:2em;">';
 | 
  
    | 559 | 	/**********************************************************
 | 
  
    | 560 | 	 *  - Update search no results database filed to create
 | 
  
    | 561 | 	 *  valid XHTML if search is empty
 | 
  
    | 562 | 	 */
 | 
  
    | 563 | 	if (version_compare(WB_VERSION, '2.8', '<'))
 | 
  
    | 564 | 	{
 | 
  
    | 565 |         echo "<h4>Adding/updating fields on table search</h4>";
 | 
  
    | 566 | 	    echo "Updating database field `no_results` on search table: ";
 | 
  
    | 567 | 	    $search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
 | 
  
    | 568 | 	    $sql  = 'UPDATE `'.TABLE_PREFIX.'search` ';
 | 
  
    | 569 | 		$sql .= 'SET `value`=\''.$search_no_results.'\' ';
 | 
  
    | 570 | 		$sql .= 'WHERE `name`=\'no_results\'';
 | 
  
    | 571 | 	    echo ($database->query($sql)) ? " $OK<br />" : " $FAIL!<br />";
 | 
  
    | 572 | 	}
 | 
  
    | 573 | 
 | 
  
    | 574 |     echo "<h4>Adding/updating field on table mod_menu_link</h4>";
 | 
  
    | 575 | 	/**********************************************************
 | 
  
    | 576 |      *  - Add field "redirect_type" to table "mod_menu_link"
 | 
  
    | 577 |      *  has to be moved later to upgrade.php in modul menu_link, because modul can be removed
 | 
  
    | 578 |      */
 | 
  
    | 579 | 	$table_name = TABLE_PREFIX.'mod_menu_link';
 | 
  
    | 580 | 	$field_name = 'redirect_type';
 | 
  
    | 581 | 	$description = "INT NOT NULL DEFAULT '301' AFTER `target_page_id`";
 | 
  
    | 582 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 583 | 
 | 
  
    | 584 |     if($bDebugModus) {
 | 
  
    | 585 |         echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 586 |         $aDebugMessage = array();
 | 
  
    | 587 |     }
 | 
  
    | 588 | 
 | 
  
    | 589 |     echo "<h4>Adding/updating field on table pages</h4>";
 | 
  
    | 590 | 	/**********************************************************
 | 
  
    | 591 | 	 *  - Add field "page_trail" to table "pages"
 | 
  
    | 592 | 	 */
 | 
  
    | 593 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 594 | 	$field_name = 'page_trail';
 | 
  
    | 595 | 	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
 | 
  
    | 596 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 597 | 
 | 
  
    | 598 | 	/**********************************************************
 | 
  
    | 599 |      *  - Add field "page_icon" to table "pages"
 | 
  
    | 600 |      */
 | 
  
    | 601 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 602 | 	$field_name = 'page_icon';
 | 
  
    | 603 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `page_title`";
 | 
  
    | 604 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 605 | 
 | 
  
    | 606 | 	/**********************************************************
 | 
  
    | 607 | 	 *  - Add field "page_code" to table "pages"
 | 
  
    | 608 | 	 */
 | 
  
    | 609 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 610 | 	$field_name = 'page_code';
 | 
  
    | 611 | 	$description = "INT NOT NULL DEFAULT '0' AFTER `language`";
 | 
  
    | 612 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 613 | 
 | 
  
    | 614 | 	/**********************************************************
 | 
  
    | 615 |      *  - Add field "menu_icon_0" to table "pages"
 | 
  
    | 616 |      */
 | 
  
    | 617 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 618 | 	$field_name = 'menu_icon_0';
 | 
  
    | 619 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_title`";
 | 
  
    | 620 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 621 | 
 | 
  
    | 622 | 	/**********************************************************
 | 
  
    | 623 | 	 *  - Add field "menu_icon_1" to table "pages"
 | 
  
    | 624 |      */
 | 
  
    | 625 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 626 | 	$field_name = 'menu_icon_1';
 | 
  
    | 627 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_0`";
 | 
  
    | 628 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 629 | 
 | 
  
    | 630 | 	/**********************************************************
 | 
  
    | 631 | 	 *  - Add field "tooltip" to table "pages"
 | 
  
    | 632 |      */
 | 
  
    | 633 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 634 | 	$field_name = 'tooltip';
 | 
  
    | 635 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_1`";
 | 
  
    | 636 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 637 | 
 | 
  
    | 638 | 	/**********************************************************
 | 
  
    | 639 | 	 *  - Add field "admin_groups" to table "pages"
 | 
  
    | 640 |      */
 | 
  
    | 641 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 642 | 	$field_name = 'admin_groups';
 | 
  
    | 643 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
 | 
  
    | 644 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 645 | 
 | 
  
    | 646 | 	/**********************************************************
 | 
  
    | 647 | 	 *  - Add field "admin_users" to table "pages"
 | 
  
    | 648 | 	 */
 | 
  
    | 649 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 650 | 	$field_name = 'admin_users';
 | 
  
    | 651 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
 | 
  
    | 652 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 653 | 
 | 
  
    | 654 | 	/**********************************************************
 | 
  
    | 655 | 	 *  - Add field "viewing_groups" to table "pages"
 | 
  
    | 656 | 	 */
 | 
  
    | 657 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 658 | 	$field_name = 'viewing_groups';
 | 
  
    | 659 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
 | 
  
    | 660 | //	echo "<span>Modify field viewing_groups to pages table</span>";
 | 
  
    | 661 | //	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 662 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 663 | 
 | 
  
    | 664 | 	/**********************************************************
 | 
  
    | 665 | 	 *  - Add field "viewing_users" to table "pages"
 | 
  
    | 666 | 	 */
 | 
  
    | 667 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 668 | 	$field_name = 'viewing_users';
 | 
  
    | 669 | 	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
 | 
  
    | 670 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 671 | 
 | 
  
    | 672 | 	/**********************************************************
 | 
  
    | 673 |      *  - Add field "custom01" to table "pages"
 | 
  
    | 674 |      */
 | 
  
    | 675 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 676 | 	$field_name = 'custom01';
 | 
  
    | 677 | 	$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
 | 
  
    | 678 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 679 | 
 | 
  
    | 680 | 	/**********************************************************
 | 
  
    | 681 |      *  - Add field "custom02" to table "pages"
 | 
  
    | 682 |      */
 | 
  
    | 683 | 	$table_name = TABLE_PREFIX.'pages';
 | 
  
    | 684 | 	$field_name = 'custom02';
 | 
  
    | 685 | 	$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
 | 
  
    | 686 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 687 | 
 | 
  
    | 688 |     if($bDebugModus) {
 | 
  
    | 689 |         echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 690 |         $aDebugMessage = array();
 | 
  
    | 691 |     }
 | 
  
    | 692 | 
 | 
  
    | 693 |     /**********************************************************
 | 
  
    | 694 |      * modify wrong strucre on table sections
 | 
  
    | 695 |      * wrong structure let crash wb
 | 
  
    | 696 |      */
 | 
  
    | 697 | 	echo "<h4>Change field structure on table sections</h4>";
 | 
  
    | 698 | 	$table_name = TABLE_PREFIX.'sections';
 | 
  
    | 699 | 	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
 | 
  
    | 700 | 	$aDebugMessage[] = "<span>Modify field module on sections table</span>";
 | 
  
    | 701 | 	$aDebugMessage[] = ($database->field_modify($table_name, 'module', $description) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 702 | 	$aDebugMessage[] = "<span>Modify field block on sections table</span>";
 | 
  
    | 703 | 	$aDebugMessage[] = ($database->field_modify($table_name, 'block', $description) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 704 | 	$aDebugMessage[] = "<span>Modify field publ_start on sections table</span>";
 | 
  
    | 705 | 	$aDebugMessage[] = ($database->field_modify($table_name, 'publ_start', $description) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 706 | 	$aDebugMessage[] = "<span>Modify field publ_end on sections table</span>";
 | 
  
    | 707 | 	$aDebugMessage[] = ($database->field_modify($table_name, 'publ_end', $description) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 708 | 
 | 
  
    | 709 |     if($bDebugModus) {
 | 
  
    | 710 |         echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 711 |         $aDebugMessage = array();
 | 
  
    | 712 |     }
 | 
  
    | 713 | 
 | 
  
    | 714 | 	/**********************************************************
 | 
  
    | 715 |      *   `confirm_code` VARCHAR(32) NOT NULL DEFAULT '',
 | 
  
    | 716 |      *   `confirm_timeout` INT(11) NOT NULL DEFAULT '0',
 | 
  
    | 717 |      */
 | 
  
    | 718 | 	echo "<h4>Change field structure on table users</h4>";
 | 
  
    | 719 | 	$table_name = TABLE_PREFIX.'users';
 | 
  
    | 720 | 	$field_name = 'confirm_code';
 | 
  
    | 721 | 	$description = "VARCHAR( 32 ) NOT NULL DEFAULT '' AFTER `password` ";
 | 
  
    | 722 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 723 | 
 | 
  
    | 724 | 	$table_name = TABLE_PREFIX.'users';
 | 
  
    | 725 | 	$field_name = 'confirm_timeout';
 | 
  
    | 726 | 	$description = "INT(11) NOT NULL DEFAULT '0' AFTER `confirm_code` ";
 | 
  
    | 727 |     add_modify_field_in_database($table_name,$field_name,$description);
 | 
  
    | 728 | 
 | 
  
    | 729 |     if($bDebugModus) {
 | 
  
    | 730 |         echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 731 |     }
 | 
  
    | 732 |     echo '</div>';
 | 
  
    | 733 | 
 | 
  
    | 734 | }
 | 
  
    | 735 | 
 | 
  
    | 736 | $aDebugMessage = array();
 | 
  
    | 737 | /**********************************************************
 | 
  
    | 738 |  * This part with changing in mod_wysiwyg will be removed in the final version
 | 
  
    | 739 |  * special workout for the tester
 | 
  
    | 740 |  *  - Remove/add PRIMARY KEY from/to "section_id" from table "mod_wysiwygs"
 | 
  
    | 741 |  */
 | 
  
    | 742 |     $aDebugMessage[] = '<div style="margin-left:2em;">';
 | 
  
    | 743 | 
 | 
  
    | 744 |     $sTable = TABLE_PREFIX.'mod_wysiwyg';
 | 
  
    | 745 |     $field_name = 'wysiwyg_id';
 | 
  
    | 746 |     if($database->field_exists($sTable, 'wysiwyg_id')) {
 | 
  
    | 747 |         if($database->index_exists($sTable, 'PRIMARY')) {
 | 
  
    | 748 |             $aDebugMessage[] = "<span>Remove PRIMARY KEY from table mod_wysiwyg.wysiwyg_id</span>";
 | 
  
    | 749 |             $aDebugMessage[] = $database->index_remove($sTable, 'PRIMARY') ? " $OK<br />" : " $FAIL!<br />";
 | 
  
    | 750 |         }
 | 
  
    | 751 |         $aDebugMessage[] = "<span>Remove field 'wysiwyg_id' from table mod_wysiwyg</span>";
 | 
  
    | 752 |         $aDebugMessage[] = $database->field_remove($sTable, 'wysiwyg_id') ? " $OK<br />" : " $FAIL!<br />";
 | 
  
    | 753 |     }
 | 
  
    | 754 | 
 | 
  
    | 755 |     $aDebugMessage[] = "<br /><span>Create PRIMARY KEY ( `section_id` ) on table mod_wysiwygs.</span>";
 | 
  
    | 756 |     $aDebugMessage[] = $database->index_add($sTable, '', 'section_id', 'PRIMARY') ? " $OK<br />" : " $FAIL!<br />";
 | 
  
    | 757 |     $aDebugMessage[] = '</div>';
 | 
  
    | 758 | 
 | 
  
    | 759 | if($bDebugModus) {
 | 
  
    | 760 | // $aDebugMessage[] =
 | 
  
    | 761 |     echo implode(PHP_EOL,$aDebugMessage);
 | 
  
    | 762 | }
 | 
  
    | 763 | $aDebugMessage = array();
 | 
  
    | 764 | 
 | 
  
    | 765 | echo '<h3>Step '.(++$stepID).': Updating acess and protected files in folders</h3>';
 | 
  
    | 766 | 
 | 
  
    | 767 | echo '<div style="margin-left:2em;">';
 | 
  
    | 768 |     /**********************************************************
 | 
  
    | 769 |     * upgrade media directory index protect files
 | 
  
    | 770 |     */
 | 
  
    | 771 |     $dir = (WB_PATH.MEDIA_DIRECTORY);
 | 
  
    | 772 |     echo '<h4>Upgrade media directory '.MEDIA_DIRECTORY.'/ index.php protect files</h4>';
 | 
  
    | 773 |     $array = rebuildFolderProtectFile($dir);
 | 
  
    | 774 |     if( sizeof( $array ) ){
 | 
  
    | 775 |     	print '<span><strong>Upgrade '.sizeof( $array ).' directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $OK<br />";
 | 
  
    | 776 |     } else {
 | 
  
    | 777 |     	print '<span><strong>Upgrade directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $FAIL!<br />";
 | 
  
    | 778 |     	print implode ('<br />',$array);
 | 
  
    | 779 |     }
 | 
  
    | 780 | 
 | 
  
    | 781 |     /**********************************************************
 | 
  
    | 782 |      * upgrade pages directory index access files
 | 
  
    | 783 |      */
 | 
  
    | 784 | 	echo '<h4>Upgrade pages directory '.PAGES_DIRECTORY.'/  protect and access files</h4>';
 | 
  
    | 785 | 
 | 
  
    | 786 |     /**********************************************************
 | 
  
    | 787 |      *  - Reformat/rebuild all existing access files
 | 
  
    | 788 |      */
 | 
  
    | 789 |     $sPagePath = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
 | 
  
    | 790 |     $msg = rebuild_all_accessfiles();
 | 
  
    | 791 | 
 | 
  
    | 792 | 	print implode ('<br />',$msg);
 | 
  
    | 793 |     echo '</div>';
 | 
  
    | 794 |     /* *****************************************************************************
 | 
  
    | 795 |      * - check for deprecated / never needed files
 | 
  
    | 796 |      */
 | 
  
    | 797 |     if(sizeof($aFilesToRemove)) {
 | 
  
    | 798 |     	echo '<h3>Step '.(++$stepID).': Remove deprecated and old files</h3>';
 | 
  
    | 799 |     	$searches = array(
 | 
  
    | 800 |     		'[ADMIN]',
 | 
  
    | 801 |     		'[MEDIA]',
 | 
  
    | 802 |     		'[PAGES]',
 | 
  
    | 803 |     		'[FRAMEWORK]',
 | 
  
    | 804 |     		'[MODULES]',
 | 
  
    | 805 |     		'[TEMPLATE]'
 | 
  
    | 806 |     	);
 | 
  
    | 807 |     	$replacements = array(
 | 
  
    | 808 |     		'/'.substr(ADMIN_PATH, strlen(WB_PATH)+1),
 | 
  
    | 809 |     		MEDIA_DIRECTORY,
 | 
  
    | 810 |     		PAGES_DIRECTORY,
 | 
  
    | 811 |     		'/framework',
 | 
  
    | 812 |     		'/modules',
 | 
  
    | 813 |     		'/templates'
 | 
  
    | 814 |     	);
 | 
  
    | 815 | 
 | 
  
    | 816 | 		$msg = '';
 | 
  
    | 817 |     	foreach( $aFilesToRemove as $file )
 | 
  
    | 818 |     	{
 | 
  
    | 819 | 			$file = str_replace($searches, $replacements, $file);
 | 
  
    | 820 | 			if( is_writable(WB_PATH.'/'.$file) ) {
 | 
  
    | 821 | 				// try to unlink file
 | 
  
    | 822 | 				if(!unlink(WB_PATH.$file)) {
 | 
  
    | 823 | 					// save in err-list, if failed
 | 
  
    | 824 | 					$msg .= $file.'<br />';
 | 
  
    | 825 | 				} else {
 | 
  
    | 826 | 					$msg .= $file.'<br />';
 | 
  
    | 827 |     			}
 | 
  
    | 828 | 			}
 | 
  
    | 829 |     	}
 | 
  
    | 830 | 
 | 
  
    | 831 | 		if($msg != '')
 | 
  
    | 832 | 		{
 | 
  
    | 833 | 			$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
 | 
  
    | 834 | 				    can not be removed automatically.<br /><br />Please delete them
 | 
  
    | 835 | 					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
 | 
  
    | 836 | 	        status_msg($msg, 'error warning', 'div');
 | 
  
    | 837 | 			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
 | 
  
    | 838 | 
 | 
  
    | 839 | 			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
 | 
  
    | 840 | 			echo ' <input name="send" type="submit" value="Restart upgrade script" />';
 | 
  
    | 841 | 			echo '</form>';
 | 
  
    | 842 |             echo "<br /><br /></div>
 | 
  
    | 843 |             </div>
 | 
  
    | 844 |             </div>
 | 
  
    | 845 |             </body>
 | 
  
    | 846 |             </html>
 | 
  
    | 847 |             ";
 | 
  
    | 848 | 			exit;
 | 
  
    | 849 | 		}
 | 
  
    | 850 |     }
 | 
  
    | 851 | 
 | 
  
    | 852 | 
 | 
  
    | 853 | /**********************************************************
 | 
  
    | 854 |  * - check for deprecated / never needed files
 | 
  
    | 855 |  */
 | 
  
    | 856 | 	if(sizeof($dirRemove)) {
 | 
  
    | 857 | 		echo '<h3>Step  '.(++$stepID).': Remove deprecated and old folders</h3>';
 | 
  
    | 858 | 		$searches = array(
 | 
  
    | 859 | 			'[ADMIN]',
 | 
  
    | 860 | 			'[MEDIA]',
 | 
  
    | 861 | 			'[PAGES]',
 | 
  
    | 862 | 			'[TEMPLATE]'
 | 
  
    | 863 | 		);
 | 
  
    | 864 | 		$replacements = array(
 | 
  
    | 865 | 			substr(ADMIN_PATH, strlen(WB_PATH)+1),
 | 
  
    | 866 | 			MEDIA_DIRECTORY,
 | 
  
    | 867 | 			PAGES_DIRECTORY,
 | 
  
    | 868 | 			'/templates',
 | 
  
    | 869 | 		);
 | 
  
    | 870 | 		$msg = '';
 | 
  
    | 871 | 		foreach( $dirRemove as $dir ) {
 | 
  
    | 872 | 			$dir = str_replace($searches, $replacements, $dir);
 | 
  
    | 873 | 			$dir = WB_PATH.'/'.$dir;
 | 
  
    | 874 | 			if( is_dir( $dir )) {
 | 
  
    | 875 | 			// try to delete dir
 | 
  
    | 876 | 				if(!is_writable( $dir ) || !rm_full_dir($dir)) {
 | 
  
    | 877 | 				// save in err-list, if failed
 | 
  
    | 878 | 					$msg .= str_replace(WB_PATH,'',$dir).'<br />';
 | 
  
    | 879 | 				}
 | 
  
    | 880 | 			}
 | 
  
    | 881 | 		}
 | 
  
    | 882 | 
 | 
  
    | 883 | 		if($msg != '') {
 | 
  
    | 884 | 			$msg = '<br /><br />Following directories are deprecated, outdated or a security risk and
 | 
  
    | 885 | 					can not be removed automatically.<br /><br />Please delete them
 | 
  
    | 886 | 					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
 | 
  
    | 887 | 			status_msg($msg, 'error warning', 'div');
 | 
  
    | 888 | 			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
 | 
  
    | 889 | 			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
 | 
  
    | 890 | 			echo ' <input name="send" type="submit" value="Restart upgrade script" />';
 | 
  
    | 891 | 			echo '</form>';
 | 
  
    | 892 |             echo "<br /><br /></div>
 | 
  
    | 893 |             </div>
 | 
  
    | 894 |             </div>
 | 
  
    | 895 |             </body>
 | 
  
    | 896 |             </html>
 | 
  
    | 897 |             ";
 | 
  
    | 898 | 			exit;
 | 
  
    | 899 | 		}
 | 
  
    | 900 | 	}
 | 
  
    | 901 | 
 | 
  
    | 902 |     /**********************************************************
 | 
  
    | 903 |      * upgrade modules if newer version is available
 | 
  
    | 904 |      * $aModuleList list of proofed modules
 | 
  
    | 905 |      */
 | 
  
    | 906 |     $sModuleList = 'news,wysiwyg,form,any';
 | 
  
    | 907 |     $aModuleList = explode(',', (defined('MODULES_UPGRADE_LIST') ? MODULES_UPGRADE_LIST : $sModuleList));
 | 
  
    | 908 |     echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>';
 | 
  
    | 909 | //	$aModuleList = array('news');
 | 
  
    | 910 | 	foreach($aModuleList as $sModul) {
 | 
  
    | 911 | 		if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
 | 
  
    | 912 | 			$currModulVersion = get_modul_version ($sModul, false);
 | 
  
    | 913 | 			$newModulVersion =  get_modul_version ($sModul, true);
 | 
  
    | 914 | 			if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
 | 
  
    | 915 |                 echo '<div style="margin-left:2em;">';
 | 
  
    | 916 | 				echo '<h4>'.'Upgrade module \''.$sModul.'\' version '.$newModulVersion.'</h4>';
 | 
  
    | 917 | 				require_once(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
 | 
  
    | 918 |                 echo '</div>';
 | 
  
    | 919 | 			}
 | 
  
    | 920 | 		}
 | 
  
    | 921 | 	}
 | 
  
    | 922 | 
 | 
  
    | 923 | /**********************************************************
 | 
  
    | 924 |  *  - Reload all addons
 | 
  
    | 925 |  */
 | 
  
    | 926 | 
 | 
  
    | 927 | 	echo '<h3>Step '.(++$stepID).' : Reload all addons database entry (no upgrade)</h3><br />';
 | 
  
    | 928 |     echo '<div style="margin-left:2em;">';
 | 
  
    | 929 |     $iFound = 0;
 | 
  
    | 930 |     $iLoaded = 0;
 | 
  
    | 931 | 	////delete modules
 | 
  
    | 932 | 	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
 | 
  
    | 933 | 	// Load all modules
 | 
  
    | 934 | 	if( ($handle = opendir(WB_PATH.'/modules/')) ) {
 | 
  
    | 935 | 		while(false !== ($file = readdir($handle))) {
 | 
  
    | 936 | 			if($file != '' && substr($file, 0, 1) != '.' && is_dir(WB_PATH.'/modules/'.$file) ) {
 | 
  
    | 937 |                 $iFound++;
 | 
  
    | 938 | 				$iLoaded = load_module(WB_PATH.'/modules/'.$file ) ? $iLoaded+1 : $iLoaded;
 | 
  
    | 939 | 			   // 	upgrade_module($file, true);
 | 
  
    | 940 | 			}
 | 
  
    | 941 | 		}
 | 
  
    | 942 | 		closedir($handle);
 | 
  
    | 943 | 	}
 | 
  
    | 944 | 	echo '<span><strong>'.$iLoaded.' Modules reloaded,</span> found '.$iFound.' directories in folder /modules/</strong><br />';
 | 
  
    | 945 | 
 | 
  
    | 946 |     $iFound = 0;
 | 
  
    | 947 |     $iLoaded = 0;
 | 
  
    | 948 | 	////delete templates
 | 
  
    | 949 | 	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
 | 
  
    | 950 | 	// Load all templates
 | 
  
    | 951 | 	if( ($handle = opendir(WB_PATH.'/templates/')) ) {
 | 
  
    | 952 | 		while(false !== ($file = readdir($handle))) {
 | 
  
    | 953 | 			if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
 | 
  
    | 954 | 
 | 
  
    | 955 |                 $iFound++;
 | 
  
    | 956 | 				$iLoaded = (load_template(WB_PATH.'/templates/'.$file)==true) ? $iLoaded+1 : $iLoaded;
 | 
  
    | 957 | 
 | 
  
    | 958 | 			}
 | 
  
    | 959 | 		}
 | 
  
    | 960 | 		closedir($handle);
 | 
  
    | 961 | 	}
 | 
  
    | 962 | 	echo '<span><strong>'.$iLoaded.' Templates reloaded,</span> found '.$iFound.' directories in folder /templates/</strong><br />';
 | 
  
    | 963 | 
 | 
  
    | 964 |     $iFound = 0;
 | 
  
    | 965 |     $iLoaded = 0;
 | 
  
    | 966 | 	////delete languages
 | 
  
    | 967 | 	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
 | 
  
    | 968 | 	// Load all languages
 | 
  
    | 969 | 	if( ($handle = opendir(WB_PATH.'/languages/')) ) {
 | 
  
    | 970 | 		while(false !== ($file = readdir($handle))) {
 | 
  
    | 971 | 			if($file != '' AND (preg_match('#^([A-Z]{2}.php)#', basename($file)))) {
 | 
  
    | 972 |                 $iFound++;
 | 
  
    | 973 | 				$iLoaded = load_language(WB_PATH.'/languages/'.$file) ? $iLoaded+1 : $iLoaded;
 | 
  
    | 974 | 			}
 | 
  
    | 975 | 		}
 | 
  
    | 976 | 		closedir($handle);
 | 
  
    | 977 | 	}
 | 
  
    | 978 | 	echo '<span><strong>'.$iLoaded.' Languages reloaded,</span> found '.$iFound.' files in folder /languages/</strong><br />';
 | 
  
    | 979 |     echo '</div>';
 | 
  
    | 980 | 
 | 
  
    | 981 | /**********************************************************
 | 
  
    | 982 |  *  - install new droplets
 | 
  
    | 983 | 	$drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />";
 | 
  
    | 984 | 	echo $drops;
 | 
  
    | 985 | 	$file_name = (!in_array ( "mod_droplets", $all_tables) ? "install.php" : "upgrade.php");
 | 
  
    | 986 | 	require_once (WB_PATH."/modules/droplets/".$file_name);
 | 
  
    | 987 | ********************************************************** */
 | 
  
    | 988 | 
 | 
  
    | 989 | /**********************************************************
 | 
  
    | 990 |  *  - End of upgrade script
 | 
  
    | 991 |  */
 | 
  
    | 992 | 	if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
 | 
  
    | 993 | 	if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
 | 
  
    | 994 | /**********************************************************
 | 
  
    | 995 |  *  - Set Version to new Version
 | 
  
    | 996 |  */
 | 
  
    | 997 | echo '<h3>Step '.(++$stepID).': Update database version number </h3>';
 | 
  
    | 998 | echo '<div style="margin-left:2em;">';
 | 
  
    | 999 | 
 | 
  
    | 1000 | $cfg = array(
 | 
  
    | 1001 | 	'wb_version' => VERSION,
 | 
  
    | 1002 | 	'wb_revision' => REVISION,
 | 
  
    | 1003 | 	'wb_sp' => SP
 | 
  
    | 1004 | );
 | 
  
    | 1005 | echo '<br /><span><strong>Set database version number to '.VERSION.' '.SP.' '.' Revision ['.REVISION.'] : </strong></span>';
 | 
  
    | 1006 | echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
 | 
  
    | 1007 | echo '</div>';
 | 
  
    | 1008 | 
 | 
  
    | 1009 | echo '<p style="font-size:140%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
 | 
  
    | 1010 | status_msg('<strong>:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
 | 
  
    | 1011 | // show buttons to go to the backend or frontend
 | 
  
    | 1012 | echo '<br />';
 | 
  
    | 1013 | 
 | 
  
    | 1014 | if(defined('WB_URL')) {
 | 
  
    | 1015 | 	echo '<form action="'.WB_URL.'/">';
 | 
  
    | 1016 | 	echo ' <input type="submit" value="kick me to the Frontend" />';
 | 
  
    | 1017 | 	echo '</form>';
 | 
  
    | 1018 | }
 | 
  
    | 1019 | if(defined('ADMIN_URL')) {
 | 
  
    | 1020 | 	echo '<form action="'.ADMIN_URL.'/">';
 | 
  
    | 1021 | 	echo ' <input type="submit" value="kick me to the Backend" />';
 | 
  
    | 1022 | 	echo '</form>';
 | 
  
    | 1023 | }
 | 
  
    | 1024 | 
 | 
  
    | 1025 | echo "<br /><br /></div>
 | 
  
    | 1026 | </div>
 | 
  
    | 1027 | </div>
 | 
  
    | 1028 | </body>
 | 
  
    | 1029 | </html>
 | 
  
    | 1030 | ";
 | 
  
    | 1031 | exit();
 |