| 1 | 
        
            1538
         | 
        
            Luisehahne
         | 
        <?php
  | 
      
      
        | 2 | 
        
         | 
        
         | 
        /**
  | 
      
      
        | 3 | 
        
         | 
        
         | 
         *
  | 
      
      
        | 4 | 
        
         | 
        
         | 
         * @category        modules
  | 
      
      
        | 5 | 
        
         | 
        
         | 
         * @package         wysiwyg
  | 
      
      
        | 6 | 
        
         | 
        
         | 
         * @author          WebsiteBaker Project
  | 
      
      
        | 7 | 
        
            1576
         | 
        
            darkviper
         | 
         * @copyright       2009-2012, Website Baker Org. e.V.
  | 
      
      
        | 8 | 
        
            1538
         | 
        
            Luisehahne
         | 
         * @link			http://www.websitebaker2.org/
  | 
      
      
        | 9 | 
        
         | 
        
         | 
         * @license         http://www.gnu.org/licenses/gpl.html
  | 
      
      
        | 10 | 
        
            1652
         | 
        
            Luisehahne
         | 
         * @platform        WebsiteBaker 2.8.3
  | 
      
      
        | 11 | 
        
            1538
         | 
        
            Luisehahne
         | 
         * @requirements    PHP 5.2.2 and higher
  | 
      
      
        | 12 | 
        
         | 
        
         | 
         * @version      	$Id$
  | 
      
      
        | 13 | 
        
         | 
        
         | 
         * @filesource		$HeadURL$
  | 
      
      
        | 14 | 
        
         | 
        
         | 
         * @lastmodified    $Date$
  | 
      
      
        | 15 | 
        
         | 
        
         | 
         *
  | 
      
      
        | 16 | 
        
         | 
        
         | 
         */
  | 
      
      
        | 17 | 
        
         | 
        
         | 
        /* -------------------------------------------------------- */
  | 
      
      
        | 18 | 
        
            1576
         | 
        
            darkviper
         | 
        // Must include code to stop this file being accessed directly
  | 
      
      
        | 19 | 
        
         | 
        
         | 
        if(!defined('WB_PATH')) {
 | 
      
      
        | 20 | 
        
            1652
         | 
        
            Luisehahne
         | 
        	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
  | 
      
      
        | 21 | 
        
            1576
         | 
        
            darkviper
         | 
        	throw new IllegalFileException();
  | 
      
      
        | 22 | 
        
            1538
         | 
        
            Luisehahne
         | 
        }
  | 
      
      
        | 23 | 
        
         | 
        
         | 
        /* -------------------------------------------------------- */
  | 
      
      
        | 24 | 
        
            1754
         | 
        
            Luisehahne
         | 
        
  | 
      
      
        | 25 | 
        
            1765
         | 
        
            Luisehahne
         | 
        if(!function_exists('mod_wysiwyg_upgrade'))
 | 
      
      
        | 26 | 
        
         | 
        
         | 
        {
 | 
      
      
        | 27 | 
        
            1875
         | 
        
            Luisehahne
         | 
        	function mod_wysiwyg_upgrade () {
 | 
      
      
        | 28 | 
        
         | 
        
         | 
        		global $database,$bDebugModus;
  | 
      
      
        | 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 | 
        
            1754
         | 
        
            Luisehahne
         | 
        
  | 
      
      
        | 34 | 
        
            1875
         | 
        
            Luisehahne
         | 
        		$msg = array();
  | 
      
      
        | 35 | 
        
         | 
        
         | 
        		$aTable = array('mod_wysiwyg');
 | 
      
      
        | 36 | 
        
         | 
        
         | 
        		for($x=0; $x<sizeof($aTable);$x++) {
 | 
      
      
        | 37 | 
        
         | 
        
         | 
        			if(($sOldType = $database->getTableEngine(TABLE_PREFIX.$aTable[$x]))) {
 | 
      
      
        | 38 | 
        
         | 
        
         | 
        				if(('myisam' != strtolower($sOldType))) {
 | 
      
      
        | 39 | 
        
         | 
        
         | 
        					if(!$database->query('ALTER TABLE `'.TABLE_PREFIX.$aTable[$x].'` Engine = \'MyISAM\' ')) {
 | 
      
      
        | 40 | 
        
         | 
        
         | 
        						$msg[] = $database->get_error();
  | 
      
      
        | 41 | 
        
         | 
        
         | 
        					} else{
 | 
      
      
        | 42 | 
        
         | 
        
         | 
        						$msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` changed to Engine = \'MyISAM\'';
  | 
      
      
        | 43 | 
        
         | 
        
         | 
        					}
  | 
      
      
        | 44 | 
        
         | 
        
         | 
        				} else {
 | 
      
      
        | 45 | 
        
         | 
        
         | 
        					 $msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` has Engine = \'MyISAM\'';
  | 
      
      
        | 46 | 
        
         | 
        
         | 
        				}
  | 
      
      
        | 47 | 
        
         | 
        
         | 
        			} else {
 | 
      
      
        | 48 | 
        
         | 
        
         | 
        				$msg[] = $database->get_error();
  | 
      
      
        | 49 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 50 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 51 | 
        
            1754
         | 
        
            Luisehahne
         | 
        
  | 
      
      
        | 52 | 
        
            1875
         | 
        
            Luisehahne
         | 
        		$sTable = TABLE_PREFIX.'mod_wysiwyg';
  | 
      
      
        | 53 | 
        
         | 
        
         | 
        		if($database->index_exists($sTable, 'PRIMARY')) {
 | 
      
      
        | 54 | 
        
         | 
        
         | 
        			$sql = 'ALTER TABLE `'.$database->DbName.'`.`'.$sTable.'` DROP PRIMARY KEY';
  | 
      
      
        | 55 | 
        
         | 
        
         | 
        			if(!$database->query($sql)) {
 | 
      
      
        | 56 | 
        
         | 
        
         | 
        			    $msg[] = ''.$database->get_error().'';
  | 
      
      
        | 57 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 58 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 59 | 
        
            1765
         | 
        
            Luisehahne
         | 
        
  | 
      
      
        | 60 | 
        
            1875
         | 
        
            Luisehahne
         | 
        		if(!$database->index_add($sTable, '', 'section_id', 'PRIMARY')) {
 | 
      
      
        | 61 | 
        
         | 
        
         | 
        			$msg[] = ''.$database->get_error().'';
  | 
      
      
        | 62 | 
        
         | 
        
         | 
        		} else {
 | 
      
      
        | 63 | 
        
         | 
        
         | 
        		    $msg[] = 'Create PRIMARY KEY ( `section_id` )';
  | 
      
      
        | 64 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 65 | 
        
            1765
         | 
        
            Luisehahne
         | 
        
  | 
      
      
        | 66 | 
        
            1875
         | 
        
            Luisehahne
         | 
        		// change internal absolute links into relative links
  | 
      
      
        | 67 | 
        
         | 
        
         | 
        		$sTable = TABLE_PREFIX.'mod_wysiwyg';
  | 
      
      
        | 68 | 
        
         | 
        
         | 
        		$sql  = 'UPDATE `'.$sTable.'` ';
  | 
      
      
        | 69 | 
        
         | 
        
         | 
        		$sql .= 'SET `content` = REPLACE(`content`, \'"'.WB_URL.MEDIA_DIRECTORY.'\', \'"{SYSVAR:MEDIA_REL}\')';
 | 
      
      
        | 70 | 
        
         | 
        
         | 
        		if (!$database->query($sql)) {
 | 
      
      
        | 71 | 
        
         | 
        
         | 
        			$msg[] = ''.$database->get_error().'';
  | 
      
      
        | 72 | 
        
         | 
        
         | 
        		} else {
 | 
      
      
        | 73 | 
        
         | 
        
         | 
        		    $msg[] = 'Change internal absolute links into relative links';
  | 
      
      
        | 74 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 75 | 
        
         | 
        
         | 
        		// only for $callingScript upgrade-script.php
  | 
      
      
        | 76 | 
        
         | 
        
         | 
        		if($globalStarted) {
 | 
      
      
        | 77 | 
        
         | 
        
         | 
        			if($bDebugModus) {
 | 
      
      
        | 78 | 
        
         | 
        
         | 
        				foreach($msg as $title) {
 | 
      
      
        | 79 | 
        
         | 
        
         | 
        				    echo '<strong>'.$title.'</strong><br />';
  | 
      
      
        | 80 | 
        
         | 
        
         | 
        				}
  | 
      
      
        | 81 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 82 | 
        
         | 
        
         | 
        		}
  | 
      
      
        | 83 | 
        
         | 
        
         | 
        		return $msg;
  | 
      
      
        | 84 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 85 | 
        
            1576
         | 
        
            darkviper
         | 
        }
  | 
      
      
        | 86 | 
        
            1765
         | 
        
            Luisehahne
         | 
        // ------------------------------------
  | 
      
      
        | 87 | 
        
            1576
         | 
        
            darkviper
         | 
        
  | 
      
      
        | 88 | 
        
            1765
         | 
        
            Luisehahne
         | 
        $msg = mod_wysiwyg_upgrade();
  |