| 1 | <?php
 | 
  
    | 2 | /**
 | 
  
    | 3 |  *
 | 
  
    | 4 |  * @category        backend
 | 
  
    | 5 |  * @package         installation
 | 
  
    | 6 |  * @author          WebsiteBaker Project
 | 
  
    | 7 |  * @copyright       2004-2009, Ryan Djurovich
 | 
  
    | 8 |  * @copyright       2009-2011, Website Baker Org. e.V.
 | 
  
    | 9 |  * @link			http://www.websitebaker2.org/
 | 
  
    | 10 |  * @license         http://www.gnu.org/licenses/gpl.html
 | 
  
    | 11 |  * @platform        WebsiteBaker 2.8.x
 | 
  
    | 12 |  * @requirements    PHP 5.2.2 and higher
 | 
  
    | 13 |  * @version         $Id: upgrade-script.php 1423 2011-01-30 14:48:40Z DarkViper $
 | 
  
    | 14 |  * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/upgrade-script.php $
 | 
  
    | 15 |  * @lastmodified    $Date: 2011-01-30 15:48:40 +0100 (Sun, 30 Jan 2011) $
 | 
  
    | 16 |  *
 | 
  
    | 17 |  */
 | 
  
    | 18 | 
 | 
  
    | 19 | @require_once('config.php');
 | 
  
    | 20 | 
 | 
  
    | 21 | // this function checks the basic configurations of an existing WB intallation
 | 
  
    | 22 | function status_msg($message, $class='check', $element='span') {
 | 
  
    | 23 | 	// returns a status message
 | 
  
    | 24 | 	echo '<'.$element .' class="' .$class .'">' .$message .'</' .$element.'>';
 | 
  
    | 25 | }
 | 
  
    | 26 | 
 | 
  
    | 27 | $version = '2.8.2';
 | 
  
    | 28 | // database tables including in WB package
 | 
  
    | 29 | $table_list = array (
 | 
  
    | 30 |     'settings','groups','addons','pages','sections','search','users',
 | 
  
    | 31 |     'mod_captcha_control','mod_code','mod_droplets','mod_form_fields',
 | 
  
    | 32 |     'mod_form_settings','mod_form_submissions','mod_jsadmin','mod_menu_link',
 | 
  
    | 33 |     'mod_news_comments','mod_news_groups','mod_news_posts','mod_news_settings',
 | 
  
    | 34 |     'mod_output_filter','mod_wrapper','mod_wysiwyg'
 | 
  
    | 35 | );
 | 
  
    | 36 | 
 | 
  
    | 37 | // analyze/check database tables
 | 
  
    | 38 | function mysqlCheckTables( $dbName )
 | 
  
    | 39 | {
 | 
  
    | 40 |     global $table_list;
 | 
  
    | 41 |     $table_prefix = TABLE_PREFIX;
 | 
  
    | 42 |     $sql = "SHOW TABLES FROM " . $dbName;
 | 
  
    | 43 |     $result = @mysql_query( $sql );
 | 
  
    | 44 |     $data = array();
 | 
  
    | 45 |     $x = 0;
 | 
  
    | 46 | 
 | 
  
    | 47 |     while( ( $row = @mysql_fetch_array( $result, MYSQL_NUM ) ) == true )
 | 
  
    | 48 |     {
 | 
  
    | 49 |         $tmp = str_replace($table_prefix, '', $row[0]);
 | 
  
    | 50 | 
 | 
  
    | 51 |         if( stristr( $row[0], $table_prefix )&& in_array($tmp,$table_list) )
 | 
  
    | 52 |         {
 | 
  
    | 53 |             $sql = "CHECK TABLE " . $dbName . '.' . $row[0];
 | 
  
    | 54 |             $analyze = @mysql_query( $sql );
 | 
  
    | 55 |             $rowFetch = @mysql_fetch_array( $analyze, MYSQL_ASSOC );
 | 
  
    | 56 |             $data[$x]['Op'] = $rowFetch["Op"];
 | 
  
    | 57 |             $data[$x]['Msg_type'] = $rowFetch["Msg_type"];
 | 
  
    | 58 |             $msgColor = '<span class="error">';
 | 
  
    | 59 |             $data[$x]['Table'] = $row[0];
 | 
  
    | 60 |            // print  " ";
 | 
  
    | 61 |             $msgColor = ($rowFetch["Msg_text"] == 'OK') ? '<span class="ok">' : '<span class="error">';
 | 
  
    | 62 |             $data[$x]['Msg_text'] = $msgColor.$rowFetch["Msg_text"].'</span>';
 | 
  
    | 63 |            // print  "<br />";
 | 
  
    | 64 |             $x++;
 | 
  
    | 65 |         }
 | 
  
    | 66 |     }
 | 
  
    | 67 | 
 | 
  
    | 68 | 
 | 
  
    | 69 | 
 | 
  
    | 70 | 
 | 
  
    | 71 |     return $data;
 | 
  
    | 72 | }
 | 
  
    | 73 | 
 | 
  
    | 74 | 
 | 
  
    | 75 | // check existings tables for upgrade or install
 | 
  
    | 76 | function check_wb_tables()
 | 
  
    | 77 | {
 | 
  
    | 78 |     global $database,$table_list;
 | 
  
    | 79 | 
 | 
  
    | 80 |  // if prefix inludes '_' or '%'
 | 
  
    | 81 |  $search_for = addcslashes ( TABLE_PREFIX, '%_' );
 | 
  
    | 82 |  $get_result = $database->query( 'SHOW TABLES LIKE "'.$search_for.'%"');
 | 
  
    | 83 | 
 | 
  
    | 84 |         // $get_result = $database->query( "SHOW TABLES FROM ".DB_NAME);
 | 
  
    | 85 |         $all_tables = array();
 | 
  
    | 86 |         if($get_result->numRows() > 0)
 | 
  
    | 87 |         {
 | 
  
    | 88 |             while ($data = $get_result->fetchRow())
 | 
  
    | 89 |             {
 | 
  
    | 90 |                 $tmp = str_replace(TABLE_PREFIX, '', $data[0]);
 | 
  
    | 91 |                 if(in_array($tmp,$table_list))
 | 
  
    | 92 |                 {
 | 
  
    | 93 |                     $all_tables[] = $tmp;
 | 
  
    | 94 |                 }
 | 
  
    | 95 |             }
 | 
  
    | 96 |         }
 | 
  
    | 97 |      return $all_tables;
 | 
  
    | 98 | }
 | 
  
    | 99 | 
 | 
  
    | 100 | // check existing tables
 | 
  
    | 101 | $all_tables = check_wb_tables();
 | 
  
    | 102 | 
 | 
  
    | 103 | // only for array tests
 | 
  
    | 104 | function show_array($array=array())
 | 
  
    | 105 | {
 | 
  
    | 106 |     print '<pre>';
 | 
  
    | 107 |     print_r ($array);
 | 
  
    | 108 |     print '</pre>';
 | 
  
    | 109 | }
 | 
  
    | 110 | 
 | 
  
    | 111 | ?>
 | 
  
    | 112 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 | 
  
    | 113 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 | 
  
    | 114 | <head>
 | 
  
    | 115 | <title>Upgrade script</title>
 | 
  
    | 116 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
  
    | 117 | <style type="text/css">
 | 
  
    | 118 | html { overflow: -moz-scrollbars-vertical; /* Force firefox to always show room for a vertical scrollbar */ }
 | 
  
    | 119 | 
 | 
  
    | 120 | body {
 | 
  
    | 121 | 	margin:0;
 | 
  
    | 122 | 	padding:0;
 | 
  
    | 123 | 	border:0;
 | 
  
    | 124 | 	background: #EBF7FC;
 | 
  
    | 125 | 	color:#000;
 | 
  
    | 126 | 	font-family: 'Trebuchet MS', Verdana, Arial, Helvetica, Sans-Serif;
 | 
  
    | 127 | 	font-size: small;
 | 
  
    | 128 | 	height:101%;
 | 
  
    | 129 | }
 | 
  
    | 130 | 
 | 
  
    | 131 | #container {
 | 
  
    | 132 | 	width:85%;
 | 
  
    | 133 | 	background: #A8BCCB url(templates/wb_theme/images/background.png) repeat-x;
 | 
  
    | 134 | 	border:1px solid #000;
 | 
  
    | 135 | 	color:#000;
 | 
  
    | 136 | 	margin:2em auto;
 | 
  
    | 137 | 	padding:0 15px;
 | 
  
    | 138 | 	min-height: 500px;
 | 
  
    | 139 | 	text-align:left;
 | 
  
    | 140 | }
 | 
  
    | 141 | 
 | 
  
    | 142 | p { line-height:1.5em; }
 | 
  
    | 143 | 
 | 
  
    | 144 | h1,h2,h3,h4,h5,h6 {
 | 
  
    | 145 | 	font-family: Verdana, Arial, Helvetica, sans-serif;
 | 
  
    | 146 | 	color: #369;
 | 
  
    | 147 | 	margin-top: 1.0em;
 | 
  
    | 148 | 	margin-bottom: 0.1em;
 | 
  
    | 149 | }
 | 
  
    | 150 | 
 | 
  
    | 151 | h1 { font-size:150%; }
 | 
  
    | 152 | h2 { font-size: 130%; border-bottom: 1px #CCC solid; }
 | 
  
    | 153 | h3 { font-size: 120%; }
 | 
  
    | 154 | 
 | 
  
    | 155 | .ok, .error { font-weight:bold; }
 | 
  
    | 156 | .ok { color:green; }
 | 
  
    | 157 | .error { color:red; }
 | 
  
    | 158 | .check { color:#555; }
 | 
  
    | 159 | 
 | 
  
    | 160 | .warning {
 | 
  
    | 161 | 	width: 98%;
 | 
  
    | 162 | 	background:#FFDBDB;
 | 
  
    | 163 | 	padding:0.2em;
 | 
  
    | 164 | 	margin-top:0.5em;
 | 
  
    | 165 | 	border: 1px solid black;
 | 
  
    | 166 | }
 | 
  
    | 167 | .info {
 | 
  
    | 168 | 	width: 98%;
 | 
  
    | 169 | 	background:#99CC99;
 | 
  
    | 170 | 	padding:0.2em;
 | 
  
    | 171 | 	margin-top:0.5em;
 | 
  
    | 172 | 	border: 1px solid black;
 | 
  
    | 173 | }
 | 
  
    | 174 | 
 | 
  
    | 175 | </style>
 | 
  
    | 176 | </head>
 | 
  
    | 177 | <body>
 | 
  
    | 178 | <div id="container">
 | 
  
    | 179 | <img src="templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
 | 
  
    | 180 | 
 | 
  
    | 181 | <h1>WebsiteBaker Upgrade</h1>
 | 
  
    | 182 | <p>This script upgrades an existing WebsiteBaker <strong>Version 2.7 and higher</strong> installation to the <strong>Version <?php echo $version ?></strong>. The upgrade script alters the existing WB database to reflect the changes introduced with WB 2.8.x</p>
 | 
  
    | 183 | 
 | 
  
    | 184 | <?php
 | 
  
    | 185 | /**
 | 
  
    | 186 |  * Check if disclaimer was accepted
 | 
  
    | 187 |  */
 | 
  
    | 188 | if (!(isset($_POST['backup_confirmed']) && $_POST['backup_confirmed'] == 'confirmed')) { ?>
 | 
  
    | 189 | <h2>Step 1: Backup your files</h2>
 | 
  
    | 190 | <p>It is highly recommended to <strong>create a manual backup</strong> of the entire <strong>/pages 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>
 | 
  
    | 191 | 
 | 
  
    | 192 | <form name="send" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
 | 
  
    | 193 | <textarea cols="80" 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 /pages folder (including all files and subfolders contained in it) and backup of the entire WebsiteBaker MySQL database was created before you can proceed.</textarea>
 | 
  
    | 194 | <br /><br /><input name="backup_confirmed" type="checkbox" value="confirmed" /> I confirm that a manual backup of the /pages folder and the MySQL database was created.
 | 
  
    | 195 | <br /><br /><input name="send" type="submit" value="Start upgrade script" />
 | 
  
    | 196 | </form>
 | 
  
    | 197 | <br />
 | 
  
    | 198 | 
 | 
  
    | 199 | <?php
 | 
  
    | 200 | 	status_msg('<strong>Notice:</strong><br />You need to confirm that you have created a manual backup of the /pages directory and the MySQL database before you can proceed.', 'warning', 'div');
 | 
  
    | 201 | 	echo '<br /><br />';
 | 
  
    | 202 |     echo "</div>
 | 
  
    | 203 |     </body>
 | 
  
    | 204 |     </html>
 | 
  
    | 205 |     ";
 | 
  
    | 206 | 	exit();
 | 
  
    | 207 | }
 | 
  
    | 208 | 
 | 
  
    | 209 | echo '<h2>Step 2: Updating database entries</h2>';
 | 
  
    | 210 | 
 | 
  
    | 211 | require_once(WB_PATH.'/framework/functions.php');
 | 
  
    | 212 | require_once(WB_PATH.'/framework/class.admin.php');
 | 
  
    | 213 | $admin = new admin('Addons', 'modules', false, false);
 | 
  
    | 214 | 
 | 
  
    | 215 | $OK   = '<span class="ok">OK</span>';
 | 
  
    | 216 | $FAIL = '<span class="error">FAILED</span>';
 | 
  
    | 217 | 
 | 
  
    | 218 | // function to add a var/value-pair into settings-table
 | 
  
    | 219 | function db_add_key_value($key, $value) {
 | 
  
    | 220 | 	global $database; global $OK; global $FAIL;
 | 
  
    | 221 | 	$table = TABLE_PREFIX.'settings';
 | 
  
    | 222 | 	$query = $database->query("SELECT value FROM $table WHERE name = '$key' LIMIT 1");
 | 
  
    | 223 | 	if($query->numRows() > 0) {
 | 
  
    | 224 | 		echo "$key: already exists. $OK.<br />";
 | 
  
    | 225 | 		return true;
 | 
  
    | 226 | 	} else {
 | 
  
    | 227 | 		$database->query("INSERT INTO $table (name,value) VALUES ('$key', '$value')");
 | 
  
    | 228 | 		echo (mysql_error()?mysql_error().'<br />':'');
 | 
  
    | 229 | 		$query = $database->query("SELECT value FROM $table WHERE name = '$key' LIMIT 1");
 | 
  
    | 230 | 		if($query->numRows() > 0) {
 | 
  
    | 231 | 			echo "$key: $OK.<br />";
 | 
  
    | 232 | 			return true;
 | 
  
    | 233 | 		} else {
 | 
  
    | 234 | 			echo "$key: $FAIL!<br />";
 | 
  
    | 235 | 			return false;
 | 
  
    | 236 | 		}
 | 
  
    | 237 | 	}
 | 
  
    | 238 | }
 | 
  
    | 239 | 
 | 
  
    | 240 | // function to add a new field into a table
 | 
  
    | 241 | function db_add_field($field, $table, $desc) {
 | 
  
    | 242 | 	global $database; global $OK; global $FAIL;
 | 
  
    | 243 | 	$table = TABLE_PREFIX.$table;
 | 
  
    | 244 | 	$query = $database->query("DESCRIBE $table '$field'");
 | 
  
    | 245 | 	if($query->numRows() == 0) { // add field
 | 
  
    | 246 | 		$query = $database->query("ALTER TABLE $table ADD $field $desc");
 | 
  
    | 247 | 		echo (mysql_error()?mysql_error().'<br />':'');
 | 
  
    | 248 | 		$query = $database->query("DESCRIBE $table '$field'");
 | 
  
    | 249 | 		echo (mysql_error()?mysql_error().'<br />':'');
 | 
  
    | 250 | 		if($query->numRows() > 0) {
 | 
  
    | 251 | 			echo "'$field' added. $OK.<br />";
 | 
  
    | 252 | 		} else {
 | 
  
    | 253 | 			echo "adding '$field' $FAIL!<br />";
 | 
  
    | 254 | 		}
 | 
  
    | 255 | 	} else {
 | 
  
    | 256 | 		echo "'$field' already exists. $OK.<br />";
 | 
  
    | 257 | 	}
 | 
  
    | 258 | }
 | 
  
    | 259 | 
 | 
  
    | 260 | /**********************************************************
 | 
  
    | 261 |  *  - Adding field default_theme to settings table
 | 
  
    | 262 |  */
 | 
  
    | 263 | echo "<br />Adding default_theme to settings table<br />";
 | 
  
    | 264 | $cfg = array(
 | 
  
    | 265 | 	'default_theme' => 'wb_theme'
 | 
  
    | 266 | );
 | 
  
    | 267 | 
 | 
  
    | 268 | foreach($cfg as $key=>$value) {
 | 
  
    | 269 | 	db_add_key_value($key, $value);
 | 
  
    | 270 | }
 | 
  
    | 271 | 
 | 
  
    | 272 | /**********************************************************
 | 
  
    | 273 |  *  - install droplets
 | 
  
    | 274 |  */
 | 
  
    | 275 |     $drops = (!in_array ( "mod_droplets", $all_tables)) ? "<br />Install droplets<br />" : "<br />Upgrade droplets<br />";
 | 
  
    | 276 |     echo $drops;
 | 
  
    | 277 | 
 | 
  
    | 278 |      $file_name = (!in_array ( "mod_droplets", $all_tables)) ? "install.php" : "upgrade.php";
 | 
  
    | 279 |      require_once (WB_PATH."/modules/droplets/".$file_name);
 | 
  
    | 280 | 
 | 
  
    | 281 | // check again all tables, to get a new array
 | 
  
    | 282 |  if(sizeof($all_tables) < 22) { $all_tables = check_wb_tables(); }
 | 
  
    | 283 | /**********************************************************
 | 
  
    | 284 |  *  - check tables comin with WebsiteBaker
 | 
  
    | 285 |  */
 | 
  
    | 286 |     $check_text = 'total ';
 | 
  
    | 287 |     // $check_tables = mysqlCheckTables( DB_NAME ) ;
 | 
  
    | 288 | 
 | 
  
    | 289 |     if(sizeof($all_tables) == 22)
 | 
  
    | 290 |     {
 | 
  
    | 291 |         echo '<h4>NOTICE: Your database '.DB_NAME.' has '.sizeof($all_tables).' '.$check_text.' tables from '.sizeof($table_list).' included in package '.$OK.'</h4>';
 | 
  
    | 292 |     }
 | 
  
    | 293 |     else
 | 
  
    | 294 |     {
 | 
  
    | 295 |         status_msg('<strong>WARNING:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
 | 
  
    | 296 |     	echo '<h4>Missing required tables. You can install them in backend->addons->modules->advanced. Then again run upgrade-script.php</h4>';
 | 
  
    | 297 |         $result = array_diff ( $table_list, $all_tables );
 | 
  
    | 298 |         echo '<h4 class="warning"><br />';
 | 
  
    | 299 |         while ( list ( $key, $val ) = each ( $result ) )
 | 
  
    | 300 |         {
 | 
  
    | 301 |             echo TABLE_PREFIX.$val.' '.$FAIL.'<br>';
 | 
  
    | 302 |         }
 | 
  
    | 303 |         echo '<br /></h4>';
 | 
  
    | 304 |     	echo '<br /><form action="'. $_SERVER['PHP_SELF'] .'">';
 | 
  
    | 305 |     	echo '<input type="submit" value="kick me back" style="float:left;" />';
 | 
  
    | 306 |     	echo '</form>';
 | 
  
    | 307 |         if(defined('ADMIN_URL'))
 | 
  
    | 308 |         {
 | 
  
    | 309 |         	echo '<form action="'.ADMIN_URL.'" target="_self">';
 | 
  
    | 310 |         	echo ' <input type="submit" value="kick me to the Backend" />';
 | 
  
    | 311 |         	echo '</form>';
 | 
  
    | 312 |         }
 | 
  
    | 313 |         echo "<br /><br /></div>
 | 
  
    | 314 |         </body>
 | 
  
    | 315 |         </html>
 | 
  
    | 316 |         ";
 | 
  
    | 317 |         exit();
 | 
  
    | 318 |     }
 | 
  
    | 319 | 
 | 
  
    | 320 | /**********************************************************
 | 
  
    | 321 |  *  - Adding field sec_anchor to settings table
 | 
  
    | 322 |  */
 | 
  
    | 323 | 
 | 
  
    | 324 | echo "<br />Adding sec_anchor to settings table<br />";
 | 
  
    | 325 | $cfg = array(
 | 
  
    | 326 | 	'sec_anchor' => 'wb_'
 | 
  
    | 327 | );
 | 
  
    | 328 | foreach($cfg as $key=>$value) {
 | 
  
    | 329 | 	db_add_key_value($key, $value);
 | 
  
    | 330 | }
 | 
  
    | 331 | 
 | 
  
    | 332 | /**********************************************************
 | 
  
    | 333 |  *  - Adding redirect timer to settings table
 | 
  
    | 334 |  */
 | 
  
    | 335 | echo "<br />Adding redirect timer to settings table<br />";
 | 
  
    | 336 | $cfg = array(
 | 
  
    | 337 | 	'redirect_timer' => '1500'
 | 
  
    | 338 | );
 | 
  
    | 339 | foreach($cfg as $key=>$value) {
 | 
  
    | 340 | 	db_add_key_value($key, $value);
 | 
  
    | 341 | }
 | 
  
    | 342 | 
 | 
  
    | 343 | /**********************************************************
 | 
  
    | 344 |  *  - Adding mediasettings to settings table
 | 
  
    | 345 |  */
 | 
  
    | 346 | echo "<br />Adding mediasettings to settings table<br />";
 | 
  
    | 347 | $cfg = array(
 | 
  
    | 348 | 	'mediasettings' => ''
 | 
  
    | 349 | );
 | 
  
    | 350 | foreach($cfg as $key=>$value) {
 | 
  
    | 351 | 	db_add_key_value($key, $value);
 | 
  
    | 352 | }
 | 
  
    | 353 | 
 | 
  
    | 354 | /**********************************************************
 | 
  
    | 355 |  *  - Adding fingerprint_with_ip_octets to settings table
 | 
  
    | 356 |  */
 | 
  
    | 357 | echo "<br />Adding fingerprint_with_ip_octets to settings table<br />";
 | 
  
    | 358 | $cfg = array(
 | 
  
    | 359 | 	'fingerprint_with_ip_octets' => '3'
 | 
  
    | 360 | );
 | 
  
    | 361 | foreach($cfg as $key=>$value) {
 | 
  
    | 362 | 	db_add_key_value($key, $value);
 | 
  
    | 363 | }
 | 
  
    | 364 | 
 | 
  
    | 365 | /**********************************************************
 | 
  
    | 366 |  *  - Add field "redirect_type" to table "mod_menu_link"
 | 
  
    | 367 |  */
 | 
  
    | 368 | echo "<br />Adding field redirect_type to mod_menu_link table<br />";
 | 
  
    | 369 | db_add_field('redirect_type', 'mod_menu_link', "INT NOT NULL DEFAULT '302' AFTER `target_page_id`");
 | 
  
    | 370 | 
 | 
  
    | 371 | 
 | 
  
    | 372 | 
 | 
  
    | 373 | if (version_compare(WB_VERSION, '2.8.0') < 0)
 | 
  
    | 374 | {
 | 
  
    | 375 |     /**********************************************************
 | 
  
    | 376 |      *  - Update search no results database filed to create
 | 
  
    | 377 |      *  valid XHTML if search is empty
 | 
  
    | 378 |      */
 | 
  
    | 379 |     echo "<br />Updating database field `no_results` of search table: ";
 | 
  
    | 380 |     $search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
 | 
  
    | 381 |     $sql = "UPDATE `" . TABLE_PREFIX . "search` SET `value` = '$search_no_results' WHERE `name`= 'no_results'";
 | 
  
    | 382 |     $database->query($sql);
 | 
  
    | 383 |     echo ($database->query($sql)) ? " $OK<br />" : " $FAIL<br />";
 | 
  
    | 384 |     /**********************************************************
 | 
  
    | 385 |      *  - Update settings of News Modul
 | 
  
    | 386 |      */
 | 
  
    | 387 | 
 | 
  
    | 388 |     // These are the default setting
 | 
  
    | 389 |     $header = '<table cellpadding=\"0\" cellspacing=\"0\" class=\"loop-header\">'."\n";
 | 
  
    | 390 |     $post_loop = '<tr class=\"post_top\">
 | 
  
    | 391 | <td class=\"post_title\"><a href=\"[LINK]\">[TITLE]</a></td>
 | 
  
    | 392 | <td class=\"post_date\">[PUBLISHED_TIME], [PUBLISHED_DATE]</td>
 | 
  
    | 393 | </tr>
 | 
  
    | 394 | <tr>
 | 
  
    | 395 | <td class=\"post_short\" colspan=\"2\">
 | 
  
    | 396 | [SHORT]
 | 
  
    | 397 | <span style=\"visibility:[SHOW_READ_MORE];\"><a href=\"[LINK]\">[TEXT_READ_MORE]</a></span>
 | 
  
    | 398 | </td>
 | 
  
    | 399 | </tr>';
 | 
  
    | 400 |     $footer = '</table>
 | 
  
    | 401 | <table cellpadding="0" cellspacing="0" class="page-header" style="display: [DISPLAY_PREVIOUS_NEXT_LINKS]">
 | 
  
    | 402 | <tr>
 | 
  
    | 403 | <td class="page-left">[PREVIOUS_PAGE_LINK]</td>
 | 
  
    | 404 | <td class="page-center">[OF]</td>
 | 
  
    | 405 | <td class="page-right">[NEXT_PAGE_LINK]</td>
 | 
  
    | 406 | </tr>
 | 
  
    | 407 | </table>';
 | 
  
    | 408 |     $post_header = addslashes('<table cellpadding="0" cellspacing="0" class="post-header">
 | 
  
    | 409 | <tr>
 | 
  
    | 410 | <td><h1>[TITLE]</h1></td>
 | 
  
    | 411 | <td rowspan="3" style="display: [DISPLAY_IMAGE]">[GROUP_IMAGE]</td>
 | 
  
    | 412 | </tr>
 | 
  
    | 413 | <tr>
 | 
  
    | 414 | <td class="public-info"><b>[TEXT_POSTED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [PUBLISHED_DATE]</b></td>
 | 
  
    | 415 | </tr>
 | 
  
    | 416 | <tr style="display: [DISPLAY_GROUP]">
 | 
  
    | 417 | <td class="group-page"><a href="[BACK]">[PAGE_TITLE]</a> >> <a href="[BACK]?g=[GROUP_ID]">[GROUP_TITLE]</a></td>
 | 
  
    | 418 | </tr>
 | 
  
    | 419 | </table>');
 | 
  
    | 420 |     $post_footer = '<p>[TEXT_LAST_CHANGED]: [MODI_DATE] [TEXT_AT] [MODI_TIME]</p>
 | 
  
    | 421 | <a href=\"[BACK]\">[TEXT_BACK]</a>';
 | 
  
    | 422 |     $comments_header = addslashes('<br /><br />
 | 
  
    | 423 | <h2>[TEXT_COMMENTS]</h2>
 | 
  
    | 424 | <table cellpadding="2" cellspacing="0" class="comment-header">');
 | 
  
    | 425 |     $comments_loop = addslashes('<tr>
 | 
  
    | 426 | <td class="comment_title">[TITLE]</td>
 | 
  
    | 427 | <td class="comment_info">[TEXT_BY] [DISPLAY_NAME] [TEXT_ON] [DATE] [TEXT_AT] [TIME]</td>
 | 
  
    | 428 | </tr>
 | 
  
    | 429 | <tr>
 | 
  
    | 430 | <td colspan="2" class="comment_text">[COMMENT]</td>
 | 
  
    | 431 | </tr>');
 | 
  
    | 432 |     $comments_footer = '</table>
 | 
  
    | 433 | <br /><a href=\"[ADD_COMMENT_URL]\">[TEXT_ADD_COMMENT]</a>';
 | 
  
    | 434 |     $comments_page = '<h1>[TEXT_COMMENT]</h1>
 | 
  
    | 435 | <h2>[POST_TITLE]</h2>
 | 
  
    | 436 | <br />';
 | 
  
    | 437 | 
 | 
  
    | 438 | if(in_array('mod_news_settings', $all_tables))
 | 
  
    | 439 | {
 | 
  
    | 440 |    // Insert default settings into database
 | 
  
    | 441 |    $query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0");
 | 
  
    | 442 |    if($query_dates->numRows() > 1)
 | 
  
    | 443 |    {
 | 
  
    | 444 |         while($result = $query_dates->fetchRow())
 | 
  
    | 445 |         {
 | 
  
    | 446 | 
 | 
  
    | 447 |         	echo "<br /><u>Add default settings to database for news section_id= ".$result['section_id']."</u><br />";
 | 
  
    | 448 |         	$section_id = $result['section_id'];
 | 
  
    | 449 | 
 | 
  
    | 450 |         	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `header` = '$header' WHERE `section_id` = $section_id")) {
 | 
  
    | 451 |         		echo 'Database data header added successfully';
 | 
  
    | 452 |         	}
 | 
  
    | 453 |         	echo mysql_error().'<br />';
 | 
  
    | 454 | 
 | 
  
    | 455 |         	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_loop` = '$post_loop' WHERE `section_id` = $section_id")) {
 | 
  
    | 456 |         		echo 'Database data post_loop added successfully';
 | 
  
    | 457 |         	}
 | 
  
    | 458 |         	echo mysql_error().'<br />';
 | 
  
    | 459 | 
 | 
  
    | 460 |         	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `footer` = '$footer' WHERE `section_id` = $section_id")) {
 | 
  
    | 461 |         		echo 'Database data footer added successfully';
 | 
  
    | 462 |         	}
 | 
  
    | 463 |         	echo mysql_error().'<br />';
 | 
  
    | 464 | 
 | 
  
    | 465 |         	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_header` = '$post_header' WHERE `section_id` = $section_id")) {
 | 
  
    | 466 |         		echo 'Database data post_header added successfully';
 | 
  
    | 467 |         	}
 | 
  
    | 468 |         	echo mysql_error().'<br />';
 | 
  
    | 469 | 
 | 
  
    | 470 |         	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_footer` = '$post_footer' WHERE `section_id` = $section_id")) {
 | 
  
    | 471 |         		echo 'Database data post_footer added successfully';
 | 
  
    | 472 |         	}
 | 
  
    | 473 |         	echo mysql_error().'<br />';
 | 
  
    | 474 | 
 | 
  
    | 475 |         	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_header` = '$comments_header' WHERE `section_id` = $section_id")) {
 | 
  
    | 476 |         		echo 'Database data comments_header added successfully';
 | 
  
    | 477 |         	}
 | 
  
    | 478 |         	echo mysql_error().'<br />';
 | 
  
    | 479 | 
 | 
  
    | 480 |         	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_loop` = '$comments_loop' WHERE `section_id` = $section_id")) {
 | 
  
    | 481 |         		echo 'Database data comments_loop added successfully';
 | 
  
    | 482 |         	}
 | 
  
    | 483 |         	echo mysql_error().'<br />';
 | 
  
    | 484 | 
 | 
  
    | 485 |         	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_footer` = '$comments_footer' WHERE `section_id` = $section_id")) {
 | 
  
    | 486 |         		echo 'Database data comments_footer added successfully';
 | 
  
    | 487 |         	}
 | 
  
    | 488 |         	echo mysql_error().'<br />';
 | 
  
    | 489 | 
 | 
  
    | 490 |         	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_page` = '$comments_page' WHERE `section_id` = $section_id")) {
 | 
  
    | 491 |         		echo 'Database data comments_page added successfully';
 | 
  
    | 492 |         	}
 | 
  
    | 493 |         	echo mysql_error().'<br />';
 | 
  
    | 494 | 
 | 
  
    | 495 |         }
 | 
  
    | 496 | 
 | 
  
    | 497 | 
 | 
  
    | 498 |       if ((version_compare(WB_VERSION, '2.8.1') <= 0) && file_exists(WB_PATH."/modules/news/upgrade.php"))
 | 
  
    | 499 |       {
 | 
  
    | 500 |               echo '<h4>Upgrade existings postfiles to new format</h4><br />';
 | 
  
    | 501 |               // change old postfiles to new postfiles
 | 
  
    | 502 |               require_once(WB_PATH."/modules/news/upgrade.php");
 | 
  
    | 503 |       }
 | 
  
    | 504 |     }
 | 
  
    | 505 | 
 | 
  
    | 506 |    }
 | 
  
    | 507 | 
 | 
  
    | 508 | }
 | 
  
    | 509 | 
 | 
  
    | 510 | /**********************************************************
 | 
  
    | 511 |  *  - Set Version to WB 2.8.2
 | 
  
    | 512 |  */
 | 
  
    | 513 | echo "<br />Update database version number to 2.8.2 : ";
 | 
  
    | 514 | echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value` = '$version' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />";
 | 
  
    | 515 | 
 | 
  
    | 516 | /**********************************************************
 | 
  
    | 517 |  *  - Reload all addons
 | 
  
    | 518 |  */
 | 
  
    | 519 | 
 | 
  
    | 520 | //delete modules
 | 
  
    | 521 | $database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
 | 
  
    | 522 | // Load all modules
 | 
  
    | 523 | if($handle = opendir(WB_PATH.'/modules/')) {
 | 
  
    | 524 | 	while(false !== ($file = readdir($handle))) {
 | 
  
    | 525 | 		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
 | 
  
    | 526 | 			load_module(WB_PATH.'/modules/'.$file);
 | 
  
    | 527 | 		}
 | 
  
    | 528 | 	}
 | 
  
    | 529 | 	closedir($handle);
 | 
  
    | 530 | }
 | 
  
    | 531 | echo '<br />Modules reloaded<br />';
 | 
  
    | 532 | 
 | 
  
    | 533 | //delete templates		
 | 
  
    | 534 | $database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
 | 
  
    | 535 | // Load all templates
 | 
  
    | 536 | if($handle = opendir(WB_PATH.'/templates/')) {
 | 
  
    | 537 | 	while(false !== ($file = readdir($handle))) {
 | 
  
    | 538 | 		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
 | 
  
    | 539 | 			load_template(WB_PATH.'/templates/'.$file);
 | 
  
    | 540 | 		}
 | 
  
    | 541 | 	}
 | 
  
    | 542 | 	closedir($handle);
 | 
  
    | 543 | }
 | 
  
    | 544 | echo '<br />Templates reloaded<br />';
 | 
  
    | 545 | 
 | 
  
    | 546 | //delete languages
 | 
  
    | 547 | $database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
 | 
  
    | 548 | // Load all languages
 | 
  
    | 549 | if($handle = opendir(WB_PATH.'/languages/')) {
 | 
  
    | 550 | 	while(false !== ($file = readdir($handle))) {
 | 
  
    | 551 | 		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
 | 
  
    | 552 | 			load_language(WB_PATH.'/languages/'.$file);
 | 
  
    | 553 | 		}
 | 
  
    | 554 | 	}
 | 
  
    | 555 | 	closedir($handle);
 | 
  
    | 556 | }
 | 
  
    | 557 | echo '<br />Languages reloaded<br />';
 | 
  
    | 558 | 
 | 
  
    | 559 | 
 | 
  
    | 560 | /**********************************************************
 | 
  
    | 561 |  *  - End of upgrade script
 | 
  
    | 562 |  */
 | 
  
    | 563 | 
 | 
  
    | 564 | // require(WB_PATH.'/framework/initialize.php');
 | 
  
    | 565 | 
 | 
  
    | 566 | if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', 'wb_theme'); }
 | 
  
    | 567 | if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
 | 
  
    | 568 | 
 | 
  
    | 569 | echo '<p style="font-size:120%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
 | 
  
    | 570 | status_msg('<strong>Warning:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
 | 
  
    | 571 | // show buttons to go to the backend or frontend
 | 
  
    | 572 | echo '<br />';
 | 
  
    | 573 | if(defined('WB_URL')) {
 | 
  
    | 574 | 	echo '<form action="'.WB_URL.'">';
 | 
  
    | 575 | 	echo '<input type="submit" value="kick me to the Frontend" style="float:left;" />';
 | 
  
    | 576 | 	echo '</form>';
 | 
  
    | 577 | }
 | 
  
    | 578 | if(defined('ADMIN_URL')) {
 | 
  
    | 579 | 	echo '<form action="'.ADMIN_URL.'">';
 | 
  
    | 580 | 	echo ' <input type="submit" value="kick me to the Backend" />';
 | 
  
    | 581 | 	echo '</form>';
 | 
  
    | 582 | }
 | 
  
    | 583 | echo '<p> </p>';
 | 
  
    | 584 | 
 | 
  
    | 585 | ?>
 | 
  
    | 586 | </div>
 | 
  
    | 587 | </body>
 | 
  
    | 588 | </html>
 |