1 |
1475
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category modules
|
5 |
|
|
* @package output_filter
|
6 |
1520
|
darkviper
|
* @author Christian Sommer, WB-Project, Werner v.d. Decken
|
7 |
1892
|
Luisehahne
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
8 |
|
|
* @link http://www.websitebaker2.org/
|
9 |
1475
|
Luisehahne
|
* @license http://www.gnu.org/licenses/gpl.html
|
10 |
1520
|
darkviper
|
* @platform WebsiteBaker 2.8.2
|
11 |
1475
|
Luisehahne
|
* @requirements PHP 5.2.2 and higher
|
12 |
|
|
* @version $Id$
|
13 |
1892
|
Luisehahne
|
* @filesource $HeadURL$
|
14 |
1475
|
Luisehahne
|
* @lastmodified $Date$
|
15 |
|
|
*
|
16 |
|
|
*/
|
17 |
1538
|
Luisehahne
|
// Must include code to stop this file being access directly
|
18 |
1520
|
darkviper
|
/* -------------------------------------------------------- */
|
19 |
1892
|
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 |
1538
|
Luisehahne
|
}
|
24 |
1520
|
darkviper
|
/* -------------------------------------------------------- */
|
25 |
1538
|
Luisehahne
|
|
26 |
1892
|
Luisehahne
|
function mod_output_filter_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_output_filter');
|
36 |
|
|
$aPackage = UpgradeHelper::existsAllTables($aTable);
|
37 |
|
|
if( sizeof($aPackage) > 0){
|
38 |
|
|
$msg[] = 'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ',$aPackage).' missing! '.$FAIL;
|
39 |
|
|
$msg[] = 'Output_filter 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 |
2074
|
darkviper
|
// change table structure
|
61 |
1892
|
Luisehahne
|
$table_name = $database->TablePrefix.'mod_output_filter';
|
62 |
|
|
$field_name = 'sys_rel';
|
63 |
|
|
$description = 'INT(11) NOT NULL DEFAULT \'0\' FIRST';
|
64 |
2074
|
darkviper
|
if(!$database->isField($table_name,$field_name)) {
|
65 |
|
|
$database->addField($table_name, $field_name, $description);
|
66 |
|
|
$msg[] = 'Add field `'.$field_name.'` FIRST'." $OK";
|
67 |
1892
|
Luisehahne
|
} else {
|
68 |
2074
|
darkviper
|
$msg[] = 'Field `'.$field_name.'` already exists'." $OK";
|
69 |
1892
|
Luisehahne
|
}
|
70 |
2074
|
darkviper
|
$field_name = 'opf';
|
71 |
|
|
if(!$database->isField($table_name,$field_name)) {
|
72 |
|
|
$database->addField($table_name, $field_name, $description);
|
73 |
|
|
$msg[] = 'Add field `'.$field_name.'` FIRST'." $OK";
|
74 |
|
|
} else {
|
75 |
|
|
$msg[] = 'Field `'.$field_name.'` already exists'." $OK";
|
76 |
|
|
}
|
77 |
1892
|
Luisehahne
|
$sTable = $database->TablePrefix.'mod_output_filter';
|
78 |
|
|
$sDescription = 'int(11) NOT NULL DEFAULT \'0\'';
|
79 |
|
|
$sFieldName = 'sys_rel';
|
80 |
|
|
if(!$database->field_modify($sTable,$sFieldName,$sDescription)) {
|
81 |
|
|
$msg[] = ''.$database->get_error();
|
82 |
|
|
} else {
|
83 |
|
|
$msg[] = 'Field ( `sys_rel` ) description has been changed successfully'." $OK";
|
84 |
|
|
}
|
85 |
|
|
$sDescription = 'int(11) NOT NULL DEFAULT \'1\'';
|
86 |
|
|
$sFieldName = 'email_filter';
|
87 |
|
|
if(!$database->field_modify($sTable,$sFieldName,$sDescription)) {
|
88 |
|
|
$msg[] = ''.$database->get_error();
|
89 |
|
|
} else {
|
90 |
|
|
$msg[] = 'Field ( `email_filter` ) description has been changed successfully'." $OK";
|
91 |
|
|
}
|
92 |
|
|
$sFieldName = 'mailto_filter';
|
93 |
|
|
if(!$database->field_modify($sTable,$sFieldName,$sDescription)) {
|
94 |
|
|
$msg[] = ''.$database->get_error();
|
95 |
|
|
} else {
|
96 |
|
|
$msg[] = 'Field ( `mailto_filter` ) description has been changed successfully'." $OK";
|
97 |
|
|
}
|
98 |
|
|
// only for upgrade-script
|
99 |
|
|
if($globalStarted) {
|
100 |
|
|
if($bDebug) {
|
101 |
|
|
echo '<strong>'.implode('<br />',$msg).'</strong><br />';
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
1538
|
Luisehahne
|
}
|
105 |
1892
|
Luisehahne
|
$msg[] = 'Output_filter upgrade successfull finished '." $OK";
|
106 |
|
|
if($globalStarted) {
|
107 |
|
|
echo "<strong>Output_filter upgrade successfull finished $OK</strong><br />";
|
108 |
|
|
}
|
109 |
|
|
return ( ($globalStarted==true ) ? $globalStarted : $msg);
|
110 |
1538
|
Luisehahne
|
}
|
111 |
1892
|
Luisehahne
|
// ------------------------------------
|
112 |
|
|
|
113 |
|
|
$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
|
114 |
|
|
// Don't show the messages twice
|
115 |
|
|
if( is_array($msg = mod_output_filter_upgrade($bDebugModus)) ) {
|
116 |
|
|
echo '<strong>'.implode('<br />',$msg).'</strong><br />';
|
117 |
1538
|
Luisehahne
|
}
|