| 1 | 1428 | Luisehahne | <?php
 | 
      
        | 2 |  |  | /**
 | 
      
        | 3 |  |  |  *
 | 
      
        | 4 |  |  |  * @category        modules
 | 
      
        | 5 | 1535 | Luisehahne |  * @package         code
 | 
      
        | 6 | 1428 | Luisehahne |  * @author          WebsiteBaker Project
 | 
      
        | 7 | 1915 | Luisehahne |  * @copyright       2009-2013, WebsiteBaker Org. e.V.
 | 
      
        | 8 |  |  |  * @link            http://www.websitebaker.org/
 | 
      
        | 9 | 1428 | Luisehahne |  * @license         http://www.gnu.org/licenses/gpl.html
 | 
      
        | 10 | 1915 | Luisehahne |  * @platform        WebsiteBaker 2.8.4
 | 
      
        | 11 | 1428 | Luisehahne |  * @requirements    PHP 5.2.2 and higher
 | 
      
        | 12 | 2070 | darkviper |  * @version         $Id$
 | 
      
        | 13 |  |  |  * @filesource      $HeadURL$
 | 
      
        | 14 |  |  |  * @lastmodified    $Date$
 | 
      
        | 15 | 1428 | Luisehahne |  *
 | 
      
        | 16 |  |  |  */
 | 
      
        | 17 |  |  | // Must include code to stop this file being access directly
 | 
      
        | 18 | 1535 | Luisehahne | /* -------------------------------------------------------- */
 | 
      
        | 19 | 1890 | Luisehahne | // Must include code to stop this file being accessed directly
 | 
      
        | 20 |  |  | if(!defined('WB_URL')) {
 | 
      
        | 21 |  |  | 	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
 | 
      
        | 22 |  |  | 	throw new IllegalFileException();
 | 
      
        | 23 | 1535 | Luisehahne | }
 | 
      
        | 24 |  |  | /* -------------------------------------------------------- */
 | 
      
        | 25 | 1428 | Luisehahne | 
 | 
      
        | 26 | 1890 | Luisehahne | 	function mod_code_upgrade($bDebug=false) {
 | 
      
        | 27 |  |  | 		global $OK ,$FAIL;
 | 
      
        | 28 |  |  | 		$database=WbDatabase::getInstance();
 | 
      
        | 29 |  |  | 		$msg = array();
 | 
      
        | 30 |  |  | 		$callingScript = $_SERVER["SCRIPT_NAME"];
 | 
      
        | 31 |  |  | 		// check if upgrade startet by upgrade-script to echo a message
 | 
      
        | 32 |  |  | 		$tmp = 'upgrade-script.php';
 | 
      
        | 33 |  |  | 		$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
 | 
      
        | 34 |  |  | // check for missing tables, if true stop the upgrade
 | 
      
        | 35 |  |  | 		$aTable = array('mod_code');
 | 
      
        | 36 |  |  | 		$aPackage = UpgradeHelper::existsAllTables($aTable);
 | 
      
        | 37 |  |  | 		if( sizeof($aPackage) > 0){
 | 
      
        | 38 |  |  | 			$msg[] =  'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ',$aPackage).' missing! '.$FAIL;
 | 
      
        | 39 |  |  | 			$msg[] = 'Code upgrade failed'." $FAIL";
 | 
      
        | 40 |  |  | 			if($globalStarted) {
 | 
      
        | 41 |  |  | 				echo '<strong>'.implode('<br />',$msg).'</strong><br />';
 | 
      
        | 42 |  |  | 			}
 | 
      
        | 43 |  |  | 			return ( ($globalStarted==true ) ? $globalStarted : $msg);
 | 
      
        | 44 |  |  | 		} else {
 | 
      
        | 45 |  |  | 			for($x=0; $x<sizeof($aTable);$x++) {
 | 
      
        | 46 |  |  | 				if(($sOldType = $database->getTableEngine($database->TablePrefix.$aTable[$x]))) {
 | 
      
        | 47 |  |  | 					if(('myisam' != strtolower($sOldType))) {
 | 
      
        | 48 |  |  | 						if(!$database->query('ALTER TABLE `'.$database->TablePrefix.$aTable[$x].'` Engine = \'MyISAM\' ')) {
 | 
      
        | 49 |  |  | 							$msg[] = $database->get_error();
 | 
      
        | 50 |  |  | 						} else{
 | 
      
        | 51 |  |  | 							$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` changed to Engine = \'MyISAM\''." $OK";
 | 
      
        | 52 |  |  | 						}
 | 
      
        | 53 |  |  | 					} else {
 | 
      
        | 54 |  |  | 						$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` has Engine = \'MyISAM\''." $OK";
 | 
      
        | 55 |  |  | 					}
 | 
      
        | 56 |  |  | 				} else {
 | 
      
        | 57 |  |  | 					$msg[] = $database->get_error();
 | 
      
        | 58 |  |  | 				}
 | 
      
        | 59 |  |  | 			}
 | 
      
        | 60 |  |  | // only for upgrade-script
 | 
      
        | 61 |  |  | 			if($globalStarted) {
 | 
      
        | 62 |  |  | 				if($bDebug) {
 | 
      
        | 63 |  |  | 					echo '<strong>'.implode('<br />',$msg).'</strong><br />';
 | 
      
        | 64 |  |  | 				}
 | 
      
        | 65 |  |  | 			}
 | 
      
        | 66 | 1535 | Luisehahne | 		}
 | 
      
        | 67 | 1890 | Luisehahne | 		$msg[] = 'Code upgrade successfull finished '." $OK";
 | 
      
        | 68 |  |  | 		if($globalStarted) {
 | 
      
        | 69 |  |  | 			echo "<strong>Code upgrade successfull finished $OK</strong><br />";
 | 
      
        | 70 |  |  | 		}
 | 
      
        | 71 |  |  | 		return ( ($globalStarted==true ) ? $globalStarted : $msg);
 | 
      
        | 72 | 1535 | Luisehahne | 	}
 | 
      
        | 73 | 1890 | Luisehahne | // ------------------------------------
 | 
      
        | 74 |  |  | 
 | 
      
        | 75 |  |  | $bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
 | 
      
        | 76 |  |  | // Don't show the messages twice
 | 
      
        | 77 |  |  | if( is_array($msg = mod_code_upgrade($bDebugModus)) ) {
 | 
      
        | 78 |  |  | 	echo '<strong>'.implode('<br />',$msg).'</strong><br />';
 | 
      
        | 79 | 1535 | Luisehahne | }
 |