1 |
1538
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category modules
|
5 |
|
|
* @package wrapper
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
1896
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8 |
|
|
* @link http://www.websitebaker2.org/
|
9 |
1538
|
Luisehahne
|
* @license http://www.gnu.org/licenses/gpl.html
|
10 |
|
|
* @platform WebsiteBaker 2.8.x
|
11 |
|
|
* @requirements PHP 5.2.2 and higher
|
12 |
1896
|
Luisehahne
|
* @version $Id$
|
13 |
|
|
* @filesource $HeadURL$
|
14 |
1538
|
Luisehahne
|
* @lastmodified $Date$
|
15 |
|
|
*
|
16 |
|
|
*/
|
17 |
|
|
/* -------------------------------------------------------- */
|
18 |
1896
|
Luisehahne
|
// 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 |
1538
|
Luisehahne
|
}
|
23 |
|
|
/* -------------------------------------------------------- */
|
24 |
|
|
|
25 |
1896
|
Luisehahne
|
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 |
1538
|
Luisehahne
|
}
|
66 |
1896
|
Luisehahne
|
$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 |
1538
|
Luisehahne
|
}
|
72 |
1896
|
Luisehahne
|
// ------------------------------------
|
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 |
1538
|
Luisehahne
|
}
|