Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         wrapper
6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2013, 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.php 2070 2014-01-03 01:21:42Z darkviper $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/wrapper/upgrade.php $
14
 * @lastmodified    $Date: 2014-01-03 02:21:42 +0100 (Fri, 03 Jan 2014) $
15
 *
16
 */
17
/* -------------------------------------------------------- */
18
// Must include code to stop this file being accessed directly
19
if(!defined('WB_URL')) {
20
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
21
	throw new IllegalFileException();
22
}
23
/* -------------------------------------------------------- */
24

    
25
	function mod_wrapper_upgrade($bDebug=false) {
26
		global $OK ,$FAIL;
27
		$database=WbDatabase::getInstance();
28
		$msg = array();
29
		$callingScript = $_SERVER["SCRIPT_NAME"];
30
		// check if upgrade startet by upgrade-script to echo a message
31
		$tmp = 'upgrade-script.php';
32
		$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
33
// check for missing tables, if true stop the upgrade
34
		$aTable = array('mod_wrapper');
35
		$aPackage = UpgradeHelper::existsAllTables($aTable);
36
		if( sizeof($aPackage) > 0){
37
			$msg[] =  'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ',$aPackage).' missing! '.$FAIL;
38
			$msg[] = 'Mod_Wrapper upgrade failed'." $FAIL";
39
			if($globalStarted) {
40
				echo '<strong>'.implode('<br />',$msg).'</strong><br />';
41
			}
42
			return ( ($globalStarted==true ) ? $globalStarted : $msg);
43
		} else {
44
			for($x=0; $x<sizeof($aTable);$x++) {
45
				if(($sOldType = $database->getTableEngine($database->TablePrefix.$aTable[$x]))) {
46
					if(('myisam' != strtolower($sOldType))) {
47
						if(!$database->query('ALTER TABLE `'.$database->TablePrefix.$aTable[$x].'` Engine = \'MyISAM\' ')) {
48
							$msg[] = $database->get_error();
49
						} else{
50
							$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` changed to Engine = \'MyISAM\''." $OK";
51
						}
52
					} else {
53
						$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` has Engine = \'MyISAM\''." $OK";
54
					}
55
				} else {
56
					$msg[] = $database->get_error();
57
				}
58
			}
59
// only for upgrade-script
60
			if($globalStarted) {
61
				if($bDebug) {
62
					echo '<strong>'.implode('<br />',$msg).'</strong><br />';
63
				}
64
			}
65
		}
66
		$msg[] = 'Mod_Wrapper upgrade successfull finished '." $OK";
67
		if($globalStarted) {
68
			echo "<strong>Mod_Wrapper upgrade successfull finished $OK</strong><br />";
69
		}
70
		return ( ($globalStarted==true ) ? $globalStarted : $msg);
71
	}
72
// ------------------------------------
73

    
74
$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
75
// Don't show the messages twice
76
if( is_array($msg = mod_wrapper_upgrade($bDebugModus)) ) {
77
	echo '<strong>'.implode('<br />',$msg).'</strong><br />';
78
}
(9-9/10)