Revision 1866
Added by Luisehahne over 12 years ago
| branches/2.8.x/wb/upgrade-script.php | ||
|---|---|---|
| 1 | 1 |
<?php |
| 2 | 2 |
/** |
| 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
| 3 | 4 |
* |
| 4 |
* @category backend |
|
| 5 |
* @package installation |
|
| 6 |
* @author WebsiteBaker Project |
|
| 7 |
* @copyright 2009-2012, 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$ |
|
| 13 |
* @filesource $HeadURL$ |
|
| 14 |
* @lastmodified $Date$ |
|
| 5 |
* This program is free software: you can redistribute it and/or modify |
|
| 6 |
* it under the terms of the GNU General Public License as published by |
|
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
|
| 8 |
* (at your option) any later version. |
|
| 15 | 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
|
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 13 |
* GNU General Public License for more details. |
|
| 14 |
* |
|
| 15 |
* You should have received a copy of the GNU General Public License |
|
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 16 | 17 |
*/ |
| 17 | 18 |
|
| 19 |
/** |
|
| 20 |
* |
|
| 21 |
* |
|
| 22 |
* @category Module |
|
| 23 |
* @package Module_bakery |
|
| 24 |
* @subpackage Name of the subpackage if needed |
|
| 25 |
* @author Dietmar W?llbrink <dietmar.woellbrink@websitebaker.org> |
|
| 26 |
* @author Werner v.d.Decken <wkl@isteam.de> |
|
| 27 |
* @copyright Werner v.d.Decken <wkl@isteam.de> |
|
| 28 |
* @license http://www.gnu.org/licenses/gpl.html GPL License |
|
| 29 |
* @version 0.0.1 |
|
| 30 |
* @revision $Revision$ |
|
| 31 |
* @link $HeadURL$ |
|
| 32 |
* @lastmodified $Date$ |
|
| 33 |
* @since File available since 17.01.2013 |
|
| 34 |
* @deprecated |
|
| 35 |
* @description xyz |
|
| 36 |
*/ |
|
| 18 | 37 |
// Include config file |
| 19 | 38 |
$config_file = realpath('config.php');
|
| 20 | 39 |
if(file_exists($config_file) && !defined('WB_URL'))
|
| ... | ... | |
| 44 | 63 |
// database tables including in WB package |
| 45 | 64 |
$aPackage = array ( |
| 46 | 65 |
'settings','groups','addons','pages','sections','search','users', |
| 47 |
'mod_captcha_control','mod_code','mod_droplets','mod_form_fields',
|
|
| 48 |
'mod_form_settings','mod_form_submissions','mod_jsadmin','mod_menu_link',
|
|
| 49 |
'mod_news_comments','mod_news_groups','mod_news_posts','mod_news_settings',
|
|
| 50 |
'mod_output_filter','mod_wrapper','mod_wysiwyg'
|
|
| 66 |
'mod_captcha_control','mod_code','mod_droplets', |
|
| 67 |
'mod_jsadmin','mod_menu_link','mod_output_filter','mod_wrapper','mod_wysiwyg',
|
|
| 68 |
// 'mod_form_fields','mod_form_settings','mod_form_submissions',
|
|
| 69 |
// 'mod_news_comments','mod_news_groups','mod_news_posts','mod_news_settings',
|
|
| 51 | 70 |
); |
| 52 | 71 |
|
| 53 | 72 |
$OK = ' <span class="ok">OK</span> '; |
| ... | ... | |
| 65 | 84 |
*/ |
| 66 | 85 |
'[ADMIN]/themes/', |
| 67 | 86 |
); |
| 87 |
// |
|
| 88 |
$filesRemove['0'] = array( |
|
| 68 | 89 |
|
| 69 |
if(version_compare(WB_REVISION, VERSION, '<=')) |
|
| 70 |
{
|
|
| 71 |
$filesRemove['0'] = array( |
|
| 72 |
|
|
| 73 | 90 |
'[ADMIN]/preferences/details.php', |
| 74 | 91 |
'[ADMIN]/preferences/email.php', |
| 75 | 92 |
'[ADMIN]/preferences/password.php', |
| 76 | 93 |
'[ADMIN]/pages/settings2.php', |
| 77 | 94 |
'[ADMIN]/users/users.php', |
| 95 |
'[ADMIN]/skel/themes/htt/groups.htt', |
|
| 78 | 96 |
|
| 79 | 97 |
'[FRAMEWORK]/class.msg_queue.php', |
| 80 | 98 |
'[FRAMEWORK]/class.logfile.php', |
| 81 | 99 |
'[MODULES]/droplets/js/mdcr.js', |
| 82 | 100 |
|
| 83 | 101 |
); |
| 102 |
$aFilesToRemove = array_merge($filesRemove['0']); |
|
| 84 | 103 |
|
| 104 |
// deleting files below only from less 2.8.4 stable |
|
| 105 |
if(version_compare(WB_REVISION, REVISION, '<=')) |
|
| 106 |
{
|
|
| 85 | 107 |
$filesRemove['1'] = array( |
| 86 | 108 |
|
| 87 | 109 |
'[TEMPLATE]/argos_theme/templates/access.htt', |
| ... | ... | |
| 92 | 114 |
'[TEMPLATE]/argos_theme/templates/groups_form.htt', |
| 93 | 115 |
'[TEMPLATE]/argos_theme/templates/languages.htt', |
| 94 | 116 |
'[TEMPLATE]/argos_theme/templates/languages_details.htt', |
| 95 |
/* |
|
| 96 | 117 |
'[TEMPLATE]/argos_theme/templates/login.htt', |
| 97 | 118 |
'[TEMPLATE]/argos_theme/templates/login_forgot.htt', |
| 98 |
*/ |
|
| 99 | 119 |
'[TEMPLATE]/argos_theme/templates/media.htt', |
| 100 | 120 |
'[TEMPLATE]/argos_theme/templates/media_browse.htt', |
| 101 | 121 |
'[TEMPLATE]/argos_theme/templates/media_rename.htt', |
| ... | ... | |
| 123 | 143 |
'[TEMPLATE]/wb_theme/templates/groups_form.htt', |
| 124 | 144 |
'[TEMPLATE]/wb_theme/templates/languages.htt', |
| 125 | 145 |
'[TEMPLATE]/wb_theme/templates/languages_details.htt', |
| 126 |
|
|
| 127 |
/* |
|
| 128 | 146 |
'[TEMPLATE]/wb_theme/templates/login.htt', |
| 129 | 147 |
'[TEMPLATE]/wb_theme/templates/login_forgot.htt', |
| 130 |
*/ |
|
| 131 |
|
|
| 132 | 148 |
'[TEMPLATE]/wb_theme/templates/media.htt', |
| 133 | 149 |
'[TEMPLATE]/wb_theme/templates/media_browse.htt', |
| 134 | 150 |
'[TEMPLATE]/wb_theme/templates/media_rename.htt', |
| ... | ... | |
| 146 | 162 |
'[TEMPLATE]/wb_theme/templates/templates.htt', |
| 147 | 163 |
'[TEMPLATE]/wb_theme/templates/templates_details.htt', |
| 148 | 164 |
'[TEMPLATE]/wb_theme/templates/users.htt', |
| 149 |
'[TEMPLATE]/wb_theme/templates/users_form.htt',
|
|
| 165 |
'[TEMPLATE]/wb_theme/templates/users_form.htt' |
|
| 150 | 166 |
); |
| 151 | 167 |
|
| 152 |
$aFilesToRemove = array_merge($filesRemove['0'],$filesRemove['1']);
|
|
| 168 |
$aFilesToRemove = array_merge($aFilesToRemove,$filesRemove['1']);
|
|
| 153 | 169 |
|
| 154 | 170 |
} |
| 155 |
|
|
| 156 | 171 |
/* display a status message on the screen ************************************** |
| 157 | 172 |
* @param string $message: the message to show |
| 158 | 173 |
* @param string $class: kind of message as a css-class |
| ... | ... | |
| 177 | 192 |
* @return |
| 178 | 193 |
*/ |
| 179 | 194 |
function add_modify_field_in_database($sTable,$sField,$sDescription){
|
| 180 |
global $database,$OK,$FAIL,$bDebugModus;
|
|
| 181 |
$aDebugMessage = array();
|
|
| 195 |
global $database,$OK,$FAIL,$bDebugModus;
|
|
| 196 |
$aDebugMessage = array();
|
|
| 182 | 197 |
if(!$database->field_exists($sTable,$sField)) {
|
| 183 | 198 |
$aDebugMessage[] = "<span>Adding field $sField to $sTable table</span>"; |
| 184 | 199 |
$aDebugMessage[] = ($database->field_add($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />"); |
| ... | ... | |
| 186 | 201 |
$aDebugMessage[] = "<span>Modify field $sField to $sTable table</span>"; |
| 187 | 202 |
$aDebugMessage[] = ($database->field_modify($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />"); |
| 188 | 203 |
} |
| 189 |
if($bDebugModus) {
|
|
| 190 |
echo implode(PHP_EOL,$aDebugMessage);
|
|
| 191 |
}
|
|
| 192 |
return;
|
|
| 204 |
if($bDebugModus) {
|
|
| 205 |
echo implode(PHP_EOL,$aDebugMessage);
|
|
| 206 |
}
|
|
| 207 |
return; |
|
| 193 | 208 |
} |
| 194 | 209 |
|
| 195 | 210 |
/** |
| ... | ... | |
| 201 | 216 |
*/ |
| 202 | 217 |
function check_wb_tables() |
| 203 | 218 |
{
|
| 204 |
global $database,$aPackage;
|
|
| 219 |
global $database,$aPackage;
|
|
| 205 | 220 |
|
| 206 | 221 |
// if prefix inludes '_' or '%' |
| 207 |
$search_for = addcslashes ( TABLE_PREFIX, '%_' );
|
|
| 208 |
$get_result = $database->query( 'SHOW TABLES LIKE "'.$search_for.'%"');
|
|
| 222 |
$search_for = addcslashes ( TABLE_PREFIX, '%_' );
|
|
| 223 |
$get_result = $database->query( 'SHOW TABLES LIKE "'.$search_for.'%"');
|
|
| 209 | 224 |
|
| 210 |
// $get_result = $database->query( "SHOW TABLES FROM ".DB_NAME);
|
|
| 225 |
// $get_result = $database->query( "SHOW TABLES FROM ".DB_NAME);
|
|
| 211 | 226 |
$all_tables = array(); |
| 212 | 227 |
$aTable = array(); |
| 213 | 228 |
if($get_result->numRows() > 0) |
| ... | ... | |
| 250 | 265 |
#container {
|
| 251 | 266 |
min-width:48em; |
| 252 | 267 |
width: 70%; |
| 253 |
background: #A8BCCB url(templates/wb_theme/images/background.png) repeat-x; |
|
| 268 |
background: #A8BCCB url(<?php echo WB_URL; ?>/templates/wb_theme/images/background.png) repeat-x;
|
|
| 254 | 269 |
border:1px solid #000; |
| 255 | 270 |
color:#000; |
| 256 | 271 |
margin:2em auto; |
| ... | ... | |
| 290 | 305 |
|
| 291 | 306 |
textarea {
|
| 292 | 307 |
width:100%; |
| 293 |
border: 2px groove #0F1D44;
|
|
| 294 |
padding: 2px;
|
|
| 295 |
color: #000;
|
|
| 296 |
font-weight: normal;
|
|
| 308 |
border: 2px groove #0F1D44;
|
|
| 309 |
padding: 2px;
|
|
| 310 |
color: #000;
|
|
| 311 |
font-weight: normal;
|
|
| 297 | 312 |
} |
| 298 | 313 |
.ok, .error { font-weight:bold; }
|
| 299 | 314 |
.ok { color:green; }
|
| ... | ... | |
| 323 | 338 |
<body> |
| 324 | 339 |
<div id="container"> |
| 325 | 340 |
<div class="page"> |
| 326 |
<img src="templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" /> |
|
| 341 |
<img src="<?php echo WB_URL; ?>/templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
|
|
| 327 | 342 |
<div class="content"> |
| 328 | 343 |
<h1>WebsiteBaker Upgrade</h1> |
| 329 | 344 |
<?php |
| ... | ... | |
| 331 | 346 |
status_msg('<strong>Warning:</strong><br />It is not possible to upgrade from WebsiteBaker Versions before 2.7.<br />For upgrading to version '.VERSION.' you must upgrade first to v.2.7 at least!!!', 'warning', 'div');
|
| 332 | 347 |
echo '<br /><br />'; |
| 333 | 348 |
echo "</div> |
| 334 |
</div>
|
|
| 335 |
</div>
|
|
| 349 |
</div>
|
|
| 350 |
</div>
|
|
| 336 | 351 |
</body> |
| 337 | 352 |
</html> |
| 338 | 353 |
"; |
| ... | ... | |
| 353 | 368 |
<h5 class="warning">It is highly recommended to <strong>create a manual backup</strong> of the entire <strong class="error"><?php echo PAGES_DIRECTORY ?>/</strong> folder and the <strong>MySQL database</strong> before proceeding.</h5> |
| 354 | 369 |
<p><strong class="error">Note: </strong>The upgrade script alters some settings of your existing database!!! You need to confirm the disclaimer before proceeding.</p> |
| 355 | 370 |
|
| 356 |
<form name="send" action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
|
|
| 371 |
<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post"> |
|
| 357 | 372 |
<textarea cols="92" rows="5">DISCLAIMER: The WebsiteBaker upgrade script is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. One needs to confirm that a manual backup of the <?php echo PAGES_DIRECTORY ?>/ folder (including all files and subfolders contained in it) and backup of the entire WebsiteBaker MySQL database was created before you can proceed.</textarea> |
| 358 | 373 |
<br /><br /><input name="backup_confirmed" type="checkbox" value="confirmed" /> <strong>I confirm that a manual backup of the <?php echo PAGES_DIRECTORY ?>/ folder and the MySQL database was created.</strong> |
| 359 | 374 |
<br /><br /><input name="debug_confirmed" type="checkbox" value="debug" /> <strong>Here you can get more details during running upgrade.</strong> |
| ... | ... | |
| 363 | 378 |
|
| 364 | 379 |
<?php |
| 365 | 380 |
status_msg('<strong> Notice:</strong><br />You need to confirm that you have created a manual backup of the '.PAGES_DIRECTORY.'/ directory and the MySQL database before you can proceed.', 'warning', 'div');
|
| 366 |
echo '<br /><br />'; |
|
| 367 |
echo "</div> |
|
| 368 |
</div> |
|
| 369 |
</div> |
|
| 370 |
</body> |
|
| 371 |
</html> |
|
| 372 |
"; |
|
| 381 |
echo "<br /><br /></div> |
|
| 382 |
</div> |
|
| 383 |
</div> |
|
| 384 |
</body> |
|
| 385 |
</html>"; |
|
| 373 | 386 |
exit(); |
| 374 | 387 |
} |
| 375 | 388 |
|
| ... | ... | |
| 397 | 410 |
status_msg('<strong>:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
|
| 398 | 411 |
echo '<h4>Missing required tables. You can install them in backend->addons->modules.<br />'; |
| 399 | 412 |
echo 'Or if you uploaded per FTP install possible by backend->addons->modules->advanced.<br />'; |
| 400 |
echo 'After installing missing tables again run upgrade-script.php</h4>'; |
|
| 413 |
echo 'First rename or delete the upgrade-script.php, so the script can\'t start automatically by backend<br />'; |
|
| 414 |
echo 'After installing missing tables upload and run again upgrade-script.php</h4>'; |
|
| 401 | 415 |
$result = array_diff ( $aPackage, $aTable ); |
| 402 | 416 |
|
| 403 | 417 |
echo '<h4 class="warning"><br />'; |
| ... | ... | |
| 414 | 428 |
echo '</form>'; |
| 415 | 429 |
} |
| 416 | 430 |
if(defined('ADMIN_URL')) {
|
| 417 |
echo '<form action="'.ADMIN_URL.'/">'; |
|
| 418 |
echo ' <input type="submit" value="kick me to the Backend" />'; |
|
| 431 |
echo '<form action="'.ADMIN_URL.'/index.php" method="post">';
|
|
| 432 |
echo ' <input name="backend_send" type="submit" value="kick me to the Backend" />';
|
|
| 419 | 433 |
echo '</form>'; |
| 420 | 434 |
} |
| 421 |
|
|
| 422 | 435 |
echo "<br /><br /></div> |
| 423 | 436 |
</div> |
| 424 | 437 |
</div> |
| 425 | 438 |
</body> |
| 426 |
</html> |
|
| 427 |
"; |
|
| 439 |
</html>"; |
|
| 428 | 440 |
|
| 429 | 441 |
exit(); |
| 430 | 442 |
} |
| ... | ... | |
| 444 | 456 |
echo implode(PHP_EOL,$aDebugMessage); |
| 445 | 457 |
} |
| 446 | 458 |
$aDebugMessage = array(); |
| 447 |
echo'<h3>Step '.(++$stepID).': Updating core tables</h3>';
|
|
| 459 |
echo'<h3>Step '.(++$stepID).': Updating tables included in package</h3>';
|
|
| 448 | 460 |
/********************************************************** |
| 449 | 461 |
* - Adding field sec_anchor to settings table |
| 450 | 462 |
*/ |
| ... | ... | |
| 580 | 592 |
|
| 581 | 593 |
if($bDebugModus) {
|
| 582 | 594 |
echo implode(PHP_EOL,$aDebugMessage); |
| 583 |
$aDebugMessage = array(); |
|
| 584 | 595 |
} |
| 585 | 596 |
|
| 597 |
$aDebugMessage = array(); |
|
| 586 | 598 |
echo "<h4>Adding/updating field on table pages</h4>"; |
| 587 | 599 |
/********************************************************** |
| 588 | 600 |
* - Add field "page_trail" to table "pages" |
| ... | ... | |
| 684 | 696 |
|
| 685 | 697 |
if($bDebugModus) {
|
| 686 | 698 |
echo implode(PHP_EOL,$aDebugMessage); |
| 687 |
$aDebugMessage = array(); |
|
| 688 | 699 |
} |
| 689 | 700 |
|
| 690 |
/********************************************************** |
|
| 701 |
$aDebugMessage = array(); |
|
| 702 |
/********************************************************** |
|
| 691 | 703 |
* modify wrong strucre on table sections |
| 692 | 704 |
* wrong structure let crash wb |
| 693 | 705 |
*/ |
| ... | ... | |
| 705 | 717 |
|
| 706 | 718 |
if($bDebugModus) {
|
| 707 | 719 |
echo implode(PHP_EOL,$aDebugMessage); |
| 708 |
$aDebugMessage = array(); |
|
| 709 | 720 |
} |
| 710 | 721 |
|
| 722 |
$aDebugMessage = array(); |
|
| 711 | 723 |
/********************************************************** |
| 712 | 724 |
* `confirm_code` VARCHAR(32) NOT NULL DEFAULT '', |
| 713 | 725 |
* `confirm_timeout` INT(11) NOT NULL DEFAULT '0', |
| ... | ... | |
| 725 | 737 |
|
| 726 | 738 |
if($bDebugModus) {
|
| 727 | 739 |
echo implode(PHP_EOL,$aDebugMessage); |
| 728 |
$aDebugMessage = array(); |
|
| 729 | 740 |
} |
| 730 | 741 |
|
| 742 |
$aDebugMessage = array(); |
|
| 731 | 743 |
/********************************************************** |
| 732 | 744 |
* Modify Administrator on groups table |
| 733 | 745 |
*/ |
| 734 | 746 |
echo "<h4>Update group Administrator on table groups</h4>"; |
| 735 | 747 |
$aDebugMessage[] = "<span>Modify Administrator on groups table</span>"; |
| 736 |
$sModulePermissions = '';
|
|
| 737 |
$sTemplatePermissions = '';
|
|
| 748 |
$sModulePermissions = '';
|
|
| 749 |
$sTemplatePermissions = '';
|
|
| 738 | 750 |
$sSystemPermissions = 'access,addons,admintools,admintools_view,groups,groups_add,groups_delete,groups_modify,groups_view,'; |
| 739 | 751 |
$sSystemPermissions .= 'languages,languages_install,languages_uninstall,languages_view,media,media_create,media_delete,media_rename,media_upload,media_view,'; |
| 740 | 752 |
$sSystemPermissions .= 'modules,modules_advanced,modules_install,modules_uninstall,modules_view,pages,pages_add,pages_add_l0,pages_delete,pages_intro,pages_modify,pages_settings,pages_view,'; |
| ... | ... | |
| 753 | 765 |
|
| 754 | 766 |
if($bDebugModus) {
|
| 755 | 767 |
echo implode(PHP_EOL,$aDebugMessage); |
| 756 |
$aDebugMessage = array(); |
|
| 757 | 768 |
} |
| 758 | 769 |
echo '</div>'; |
| 759 | 770 |
|
| ... | ... | |
| 790 | 801 |
} |
| 791 | 802 |
} |
| 792 | 803 |
|
| 793 |
if(version_compare(WB_REVISION, VERSION, '<'))
|
|
| 804 |
if(version_compare(WB_REVISION, REVISION, '<='))
|
|
| 794 | 805 |
{
|
| 795 | 806 |
$aDebugMessage = array(); |
| 796 | 807 |
echo '<h3>Step '.(++$stepID).': Updating group_id in table users</h3>'; |
| ... | ... | |
| 844 | 855 |
} |
| 845 | 856 |
|
| 846 | 857 |
$aDebugMessage = array(); |
| 847 |
echo '<h3>Step '.(++$stepID).': Updating acess and protected files in folders</h3>'; |
|
| 858 |
echo '<h3>Step '.(++$stepID).': Updating access and protected files in folders</h3>';
|
|
| 848 | 859 |
|
| 849 | 860 |
echo '<div style="margin-left:2em;">'; |
| 850 | 861 |
/********************************************************** |
| ... | ... | |
| 852 | 863 |
*/ |
| 853 | 864 |
$dir = (WB_PATH.MEDIA_DIRECTORY); |
| 854 | 865 |
echo '<h4>Upgrade media directory '.MEDIA_DIRECTORY.'/ index.php protect files</h4>'; |
| 855 |
$array = rebuildFolderProtectFile($dir);
|
|
| 856 |
if( sizeof( $array ) ){
|
|
| 857 |
echo '<span><strong>Upgrade '.sizeof( $array ).' directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $OK<br />";
|
|
| 866 |
$aDebugMessage = rebuildFolderProtectFile($dir);
|
|
| 867 |
if( sizeof( $aDebugMessage ) ){
|
|
| 868 |
echo '<span><strong>Upgrade '.sizeof( $aDebugMessage ).' directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $OK<br />";
|
|
| 858 | 869 |
} else {
|
| 859 | 870 |
echo '<span><strong>Upgrade directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $FAIL!<br />"; |
| 860 |
echo implode ('<br />',$array);
|
|
| 871 |
echo implode ('<br />',$aDebugMessage);
|
|
| 861 | 872 |
} |
| 862 | 873 |
|
| 874 |
$aDebugMessage = array(); |
|
| 863 | 875 |
/********************************************************** |
| 864 | 876 |
* upgrade pages directory index access files |
| 865 | 877 |
*/ |
| ... | ... | |
| 871 | 883 |
$sPagePath = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
|
| 872 | 884 |
$msg = rebuild_all_accessfiles(); |
| 873 | 885 |
|
| 874 |
echo implode ('<br />',$msg);
|
|
| 886 |
echo '<strong>'.implode ('<br />',$msg).'</strong>';
|
|
| 875 | 887 |
echo '</div>'; |
| 888 |
|
|
| 876 | 889 |
/* ***************************************************************************** |
| 877 | 890 |
* - check for deprecated / never needed files |
| 878 | 891 |
*/ |
| ... | ... | |
| 921 | 934 |
echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">'; |
| 922 | 935 |
echo ' <input name="send" type="submit" value="Restart upgrade script" />'; |
| 923 | 936 |
echo '</form>'; |
| 924 |
echo "<br /><br /></div> |
|
| 925 |
</div> |
|
| 926 |
</div> |
|
| 927 |
</body> |
|
| 928 |
</html> |
|
| 929 |
"; |
|
| 937 |
echo "<br /><br /></div> |
|
| 938 |
</div> |
|
| 939 |
</div> |
|
| 940 |
</body> |
|
| 941 |
</html>"; |
|
| 930 | 942 |
exit; |
| 931 | 943 |
} |
| 932 | 944 |
} |
| ... | ... | |
| 973 | 985 |
echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">'; |
| 974 | 986 |
echo ' <input name="send" type="submit" value="Restart upgrade script" />'; |
| 975 | 987 |
echo '</form>'; |
| 976 |
echo "<br /><br /></div> |
|
| 977 |
</div> |
|
| 978 |
</div> |
|
| 979 |
</body> |
|
| 980 |
</html> |
|
| 981 |
"; |
|
| 988 |
echo "<br /><br /></div> |
|
| 989 |
</div> |
|
| 990 |
</div> |
|
| 991 |
</body> |
|
| 992 |
</html>"; |
|
| 982 | 993 |
exit; |
| 983 | 994 |
} |
| 984 | 995 |
} |
| ... | ... | |
| 988 | 999 |
* $aModuleList list of proofed modules |
| 989 | 1000 |
*/ |
| 990 | 1001 |
$aModuleList = array('news','wysiwyg','form');
|
| 991 |
echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>'; |
|
| 992 |
foreach($aModuleList as $sModul) {
|
|
| 993 |
if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
|
|
| 994 |
$currModulVersion = get_modul_version ($sModul, false); |
|
| 995 |
$newModulVersion = get_modul_version ($sModul, true); |
|
| 996 |
if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
|
|
| 997 |
echo '<div style="margin-left:2em;">'; |
|
| 998 |
echo '<h4>'.'Upgrade module \''.$sModul.'\' version '.$newModulVersion.'</h4>'; |
|
| 999 |
require_once(WB_PATH.'/modules/'.$sModul.'/upgrade.php'); |
|
| 1000 |
echo '</div>'; |
|
| 1002 |
if(sizeof($aModuleList)) |
|
| 1003 |
{
|
|
| 1004 |
echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>'; |
|
| 1005 |
foreach($aModuleList as $sModul) {
|
|
| 1006 |
if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
|
|
| 1007 |
$currModulVersion = get_modul_version ($sModul, false); |
|
| 1008 |
$newModulVersion = get_modul_version ($sModul, true); |
|
| 1009 |
if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
|
|
| 1010 |
echo '<div style="margin-left:2em;">'; |
|
| 1011 |
echo '<h4>'.'Upgrade module \''.$sModul.'\' version '.$newModulVersion.'</h4>'; |
|
| 1012 |
require(WB_PATH.'/modules/'.$sModul.'/upgrade.php'); |
|
| 1013 |
echo '</div>'; |
|
| 1014 |
} |
|
| 1001 | 1015 |
} |
| 1002 | 1016 |
} |
| 1003 | 1017 |
} |
| 1004 | 1018 |
|
| 1019 |
/********************************************************** |
|
| 1020 |
* Reformat/rebuild all existing moules access files |
|
| 1021 |
* $aModuleList list of modules |
|
| 1022 |
*/ |
|
| 1023 |
$aModuleList = array('bakery','topics','news');
|
|
| 1024 |
if(sizeof($aModuleList)) |
|
| 1025 |
{
|
|
| 1026 |
echo '<h3>Step '.(++$stepID).': Create/Reorg Accessfiles from modules</h3>'; |
|
| 1027 |
foreach($aModuleList as $sModul) {
|
|
| 1028 |
$aReturnMsg = array(); |
|
| 1029 |
$sModulReorg = 'm_'.$sModul.'_Reorg'; |
|
| 1030 |
if(class_exists($sModulReorg)) {
|
|
| 1031 |
$sModulVersion = get_modul_version ($sModul, true); |
|
| 1032 |
echo '<div style="margin-left:2em;">'; |
|
| 1033 |
echo '<h4>'.'Create/Reorg Accesfiles for module \''.$sModul.'\' version '.$sModulVersion.'</h4>'; |
|
| 1034 |
$oReorg = new $sModulReorg(); |
|
| 1035 |
$aReturnMsg = $oReorg->execute(); // show details |
|
| 1036 |
if($bDebugModus && is_array($aReturnMsg)) {
|
|
| 1037 |
foreach($aReturnMsg as $title) {
|
|
| 1038 |
echo '<strong>'.$title.'</strong><br />'; |
|
| 1039 |
} |
|
| 1040 |
} |
|
| 1041 |
echo '</div>'; |
|
| 1042 |
} |
|
| 1043 |
} |
|
| 1044 |
} |
|
| 1005 | 1045 |
/********************************************************** |
| 1006 | 1046 |
* - Reload all addons |
| 1007 | 1047 |
*/ |
| ... | ... | |
| 1023 | 1063 |
} |
| 1024 | 1064 |
closedir($handle); |
| 1025 | 1065 |
} |
| 1026 |
echo '<span><strong>'.$iLoaded.' Modules reloaded,</span> found '.$iFound.' directories in folder /modules/</strong><br />';
|
|
| 1066 |
echo '<strong><span>'.$iLoaded.' Modules reloaded,</span> found '.$iFound.' directories in folder /modules/</strong><br />';
|
|
| 1027 | 1067 |
|
| 1028 | 1068 |
$iFound = 0; |
| 1029 | 1069 |
$iLoaded = 0; |
| ... | ... | |
| 1041 | 1081 |
} |
| 1042 | 1082 |
closedir($handle); |
| 1043 | 1083 |
} |
| 1044 |
echo '<span><strong>'.$iLoaded.' Templates reloaded,</span> found '.$iFound.' directories in folder /templates/</strong><br />';
|
|
| 1084 |
echo '<strong><span>'.$iLoaded.' Templates reloaded,</span> found '.$iFound.' directories in folder /templates/</strong><br />';
|
|
| 1045 | 1085 |
|
| 1046 | 1086 |
$iFound = 0; |
| 1047 | 1087 |
$iLoaded = 0; |
| ... | ... | |
| 1057 | 1097 |
} |
| 1058 | 1098 |
closedir($handle); |
| 1059 | 1099 |
} |
| 1060 |
echo '<span><strong>'.$iLoaded.' Languages reloaded,</span> found '.$iFound.' files in folder /languages/</strong><br />';
|
|
| 1100 |
echo '<strong><span>'.$iLoaded.' Languages reloaded,</span> found '.$iFound.' files in folder /languages/</strong><br />';
|
|
| 1061 | 1101 |
echo '</div>'; |
| 1062 | 1102 |
|
| 1063 | 1103 |
/********************************************************** |
| branches/2.8.x/wb/admin/skel/themes/htt/groups.htt | ||
|---|---|---|
| 1 |
<!-- BEGIN main_block --> |
|
| 2 |
|
|
| 3 |
<form class="access" action="groups.php" method="post"> |
|
| 4 |
{FTAN}
|
|
| 5 |
<table summary="" cellpadding="5" cellspacing="0" border="0" align="center" width="100%" style="margin-bottom:10px;"> |
|
| 6 |
<tr style="background:#f0f0f0;"> |
|
| 7 |
<td align="left"><h2>{HEADING_MODIFY_DELETE_GROUP}</h2></td>
|
|
| 8 |
<td align="right"> |
|
| 9 |
<!-- BEGIN manage_users_block --> |
|
| 10 |
<a href="{ADMIN_URL}/users/index.php">{TEXT_MANAGE_USERS}</a>
|
|
| 11 |
<!-- END manage_users_block --> |
|
| 12 |
</td> |
|
| 13 |
</tr> |
|
| 14 |
</table> |
|
| 15 |
|
|
| 16 |
<select name="group_id" style="width: 500px;"> |
|
| 17 |
<!-- BEGIN list_block --> |
|
| 18 |
<option value="{VALUE}">
|
|
| 19 |
{NAME}
|
|
| 20 |
</option> |
|
| 21 |
<!-- END list_block --> |
|
| 22 |
</select> |
|
| 23 |
<input type="submit" name="modify" style="width: 100px;" value="{TEXT_MODIFY}" class="{DISPLAY_MODIFY}" />
|
|
| 24 |
<input type="submit" name="delete" style="width: 100px;" value="{TEXT_DELETE}" onclick="return confirm('{CONFIRM_DELETE}');" class="{DISPLAY_DELETE}" />
|
|
| 25 |
</form> |
|
| 26 |
<br /> |
|
| 27 |
<h2 class="{DISPLAY_ADD}">
|
|
| 28 |
{HEADING_ADD_GROUP}
|
|
| 29 |
</h2> |
|
| 30 |
<!-- END main_block --> |
|
| 31 | 0 | |
| branches/2.8.x/wb/admin/interface/version.php | ||
|---|---|---|
| 51 | 51 |
|
| 52 | 52 |
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled) |
| 53 | 53 |
if(!defined('VERSION')) define('VERSION', '2.8.3');
|
| 54 |
if(!defined('REVISION')) define('REVISION', '1865');
|
|
| 54 |
if(!defined('REVISION')) define('REVISION', '1866');
|
|
| 55 | 55 |
if(!defined('SP')) define('SP', '');
|
| branches/2.8.x/wb/framework/WbDatabase.php | ||
|---|---|---|
| 1 | 1 |
<?php |
| 2 | 2 |
/** |
| 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
| 3 | 4 |
* |
| 4 |
* @category framework |
|
| 5 |
* @package database |
|
| 6 |
* @author WebsiteBaker Project |
|
| 7 |
* @copyright 2004-2009, Ryan Djurovich |
|
| 8 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
| 9 |
* @link http://www.websitebaker2.org/ |
|
| 10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
| 11 |
* @platform WebsiteBaker 2.8.x |
|
| 12 |
* @requirements PHP 5.2.2 and higher |
|
| 13 |
* @version $Id$ |
|
| 14 |
* @filesource $HeadURL$ |
|
| 15 |
* @lastmodified $Date$ |
|
| 5 |
* This program is free software: you can redistribute it and/or modify |
|
| 6 |
* it under the terms of the GNU General Public License as published by |
|
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
|
| 8 |
* (at your option) any later version. |
|
| 16 | 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
|
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 13 |
* GNU General Public License for more details. |
|
| 14 |
* |
|
| 15 |
* You should have received a copy of the GNU General Public License |
|
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 17 | 17 |
*/ |
| 18 |
/* |
|
| 19 |
Database class |
|
| 20 |
This class will be used to interface between the database |
|
| 21 |
and the Website Baker code |
|
| 22 |
*/ |
|
| 18 |
/** |
|
| 19 |
* WbDatabase.php |
|
| 20 |
* |
|
| 21 |
* @category Core |
|
| 22 |
* @package Core_database |
|
| 23 |
* @author Werner v.d.Decken <wkl@isteam.de> |
|
| 24 |
* @author Dietmar W. <dietmar.woellbrink@websitebaker.org> |
|
| 25 |
* @copyright Werner v.d.Decken <wkl@isteam.de> |
|
| 26 |
* @license http://www.gnu.org/licenses/gpl.html GPL License |
|
| 27 |
* @version 0.0.9 |
|
| 28 |
* @revision $Revision$ |
|
| 29 |
* @lastmodified $Date$ |
|
| 30 |
* @deprecated from WB version number 2.9 |
|
| 31 |
* @description Mysql database wrapper for use with websitebaker up to version 2.8.4 |
|
| 32 |
*/ |
|
| 33 |
|
|
| 23 | 34 |
/* -------------------------------------------------------- */ |
| 24 |
// Must include code to stop this file being accessed directly |
|
| 25 |
if(!defined('WB_PATH')) {
|
|
| 26 |
require_once(dirname(__FILE__).'/globalExceptionHandler.php'); |
|
| 27 |
throw new IllegalFileException(); |
|
| 28 |
} |
|
| 29 |
/* -------------------------------------------------------- */ |
|
| 30 | 35 |
define('DATABASE_CLASS_LOADED', true);
|
| 31 | 36 |
|
| 32 |
|
|
| 33 | 37 |
class WbDatabase {
|
| 34 | 38 |
|
| 35 | 39 |
private static $_oInstances = array(); |
| 36 | 40 |
|
| 37 | 41 |
private $_db_handle = null; // readonly from outside |
| 38 |
private $_scheme = 'mysql'; |
|
| 39 |
private $_hostname = 'localhost'; |
|
| 40 |
private $_username = ''; |
|
| 41 |
private $_password = ''; |
|
| 42 |
private $_hostport = '3306'; |
|
| 43 | 42 |
private $_db_name = ''; |
| 44 | 43 |
private $connected = false; |
| 45 | 44 |
private $error = ''; |
| ... | ... | |
| 84 | 83 |
public function doConnect($url = '') {
|
| 85 | 84 |
if($url != '') {
|
| 86 | 85 |
$aIni = parse_url($url); |
| 87 |
$this->_scheme = isset($aIni['scheme']) ? $aIni['scheme'] : 'mysql'; |
|
| 88 |
$this->_hostname = isset($aIni['host']) ? $aIni['host'] : ''; |
|
| 89 |
$this->_username = isset($aIni['user']) ? $aIni['user'] : ''; |
|
| 90 |
$this->_password = isset($aIni['pass']) ? $aIni['pass'] : ''; |
|
| 91 |
$this->_hostport = isset($aIni['port']) ? $aIni['port'] : '3306'; |
|
| 92 |
$this->_hostport = $this->_hostport == '3306' ? '' : ':'.$this->_hostport; |
|
| 93 |
$this->_db_name = ltrim(isset($aIni['path']) ? $aIni['path'] : '', '/\\'); |
|
| 86 |
|
|
| 87 |
$scheme = isset($aIni['scheme']) ? $aIni['scheme'] : 'mysql'; |
|
| 88 |
$hostname = isset($aIni['host']) ? $aIni['host'] : ''; |
|
| 89 |
$username = isset($aIni['user']) ? $aIni['user'] : ''; |
|
| 90 |
$password = isset($aIni['pass']) ? $aIni['pass'] : ''; |
|
| 91 |
$hostport = isset($aIni['port']) ? $aIni['port'] : '3306'; |
|
| 92 |
$hostport = $hostport == '3306' ? '' : ':'.$hostport; |
|
| 93 |
$db_name = ltrim(isset($aIni['path']) ? $aIni['path'] : '', '/\\'); |
|
| 94 |
$this->_db_name = $db_name; |
|
| 94 | 95 |
}else {
|
| 95 | 96 |
throw new RuntimeException('Missing parameter: unable to connect database');
|
| 96 | 97 |
} |
| 97 |
$this->_db_handle = mysql_connect($this->_hostname.$this->_hostport,
|
|
| 98 |
$this->_username,
|
|
| 99 |
$this->_password);
|
|
| 98 |
$this->_db_handle = mysql_connect($hostname.$hostport,
|
|
| 99 |
$username, |
|
| 100 |
$password); |
|
| 100 | 101 |
if(!$this->_db_handle) {
|
| 101 |
throw new RuntimeException('unable to connect \''.$this->_scheme.'://'.
|
|
| 102 |
$this->_hostname.$this->_hostport.'\'');
|
|
| 102 |
throw new RuntimeException('unable to connect \''.$scheme.'://'.
|
|
| 103 |
$hostname.$hostport.'\'');
|
|
| 103 | 104 |
} else {
|
| 104 |
if(!mysql_select_db($this->_db_name)) {
|
|
| 105 |
throw new RuntimeException('unable to select database \''.$this->_db_name.
|
|
| 106 |
'\' on \''.$this->_scheme.'://'.
|
|
| 107 |
$this->_hostname.$this->_hostport.'\'');
|
|
| 105 |
if(!mysql_select_db($db_name)) {
|
|
| 106 |
throw new RuntimeException('unable to select database \''.$db_name.
|
|
| 107 |
'\' on \''.$scheme.'://'. |
|
| 108 |
$hostname.$hostport.'\'');
|
|
| 108 | 109 |
} else {
|
| 109 | 110 |
$this->connected = true; |
| 110 | 111 |
} |
| ... | ... | |
| 170 | 171 |
return $this->error; |
| 171 | 172 |
} |
| 172 | 173 |
|
| 174 |
// Return escape_string |
|
| 173 | 175 |
/** |
| 176 |
* escape a string for use in DB |
|
| 177 |
* @param string |
|
| 178 |
* @return string |
|
| 179 |
*/ |
|
| 180 |
public function escapeString($string) {
|
|
| 181 |
return mysql_real_escape_string($string, $this->_db_handle); |
|
| 182 |
} |
|
| 183 |
|
|
| 184 |
/** |
|
| 174 | 185 |
* default Getter for some properties |
| 175 |
* @param string $sPropertyName
|
|
| 186 |
* @param string name of the Property
|
|
| 176 | 187 |
* @return mixed NULL on error or missing property |
| 177 | 188 |
*/ |
| 178 | 189 |
public function __get($sPropertyName) |
| ... | ... | |
| 183 | 194 |
case 'getDbHandle': |
| 184 | 195 |
$retval = $this->_db_handle; |
| 185 | 196 |
break; |
| 197 |
case 'LastInsertId': |
|
| 198 |
$retval = mysql_insert_id($this->_db_handle); |
|
| 199 |
break; |
|
| 186 | 200 |
case 'db_name': |
| 187 | 201 |
case 'DbName': |
| 188 | 202 |
case 'getDbName': |
| ... | ... | |
| 199 | 213 |
} // __get() |
| 200 | 214 |
|
| 201 | 215 |
/* |
| 202 |
* @param string $table_name: full name of the table (incl. TABLE_PREFIX)
|
|
| 203 |
* @param string $field_name: name of the field to seek for
|
|
| 204 |
* @return bool: true if field exists
|
|
| 216 |
* @param string full name of the table (incl. TABLE_PREFIX) |
|
| 217 |
* @param string name of the field to seek for |
|
| 218 |
* @return bool true if field exists |
|
| 205 | 219 |
*/ |
| 206 | 220 |
public function field_exists($table_name, $field_name) |
| 207 | 221 |
{
|
| ... | ... | |
| 211 | 225 |
} |
| 212 | 226 |
|
| 213 | 227 |
/* |
| 214 |
* @param string $table_name: full name of the table (incl. TABLE_PREFIX)
|
|
| 215 |
* @param string $index_name: name of the index to seek for
|
|
| 216 |
* @return bool: true if field exists
|
|
| 228 |
* @param string full name of the table (incl. TABLE_PREFIX) |
|
| 229 |
* @param string name of the index to seek for |
|
| 230 |
* @return bool true if field exists |
|
| 217 | 231 |
*/ |
| 218 | 232 |
public function index_exists($table_name, $index_name, $number_fields = 0) |
| 219 | 233 |
{
|
| ... | ... | |
| 241 | 255 |
} |
| 242 | 256 |
|
| 243 | 257 |
/* |
| 244 |
* @param string $table_name: full name of the table (incl. TABLE_PREFIX)
|
|
| 245 |
* @param string $field_name: name of the field to add
|
|
| 246 |
* @param string $description: describes the new field like ( INT NOT NULL DEFAULT '0')
|
|
| 247 |
* @return bool: true if successful, otherwise false and error will be set
|
|
| 258 |
* @param string full name of the table (incl. TABLE_PREFIX) |
|
| 259 |
* @param string name of the field to add |
|
| 260 |
* @param string describes the new field like ( INT NOT NULL DEFAULT '0') |
|
| 261 |
* @return bool true if successful, otherwise false and error will be set |
|
| 248 | 262 |
*/ |
| 249 | 263 |
public function field_add($table_name, $field_name, $description) |
| 250 | 264 |
{
|
| branches/2.8.x/wb/framework/TranslationTable.php | ||
|---|---|---|
| 83 | 83 |
}else {
|
| 84 | 84 |
$bLanguageFound = false; |
| 85 | 85 |
$oAdaptor= new $sAdaptor($this->sAddon); |
| 86 |
if(!$oAdaptor instanceof TranslatorAdaptorInterface) {
|
|
| 86 |
if(!$oAdaptor instanceof TranslateAdaptorInterface) {
|
|
| 87 | 87 |
$sMsg = 'Class ['.$sAdaptor.'] does not implement the ' |
| 88 | 88 |
. 'interface [TranslateAdaptorInterface]'; |
| 89 | 89 |
throw new TranslationException($sMsg); |
| branches/2.8.x/wb/framework/functions.php | ||
|---|---|---|
| 13 | 13 |
* @filesource $HeadURL$ |
| 14 | 14 |
* @lastmodified $Date$ |
| 15 | 15 |
* |
| 16 |
*/ |
|
| 16 |
*/
|
|
| 17 | 17 |
/* -------------------------------------------------------- */ |
| 18 | 18 |
// Must include code to stop this file being accessed directly |
| 19 | 19 |
if(!defined('WB_PATH')) {
|
| ... | ... | |
| 415 | 415 |
// Function to create directories |
| 416 | 416 |
function make_dir($dir_name, $dir_mode = OCTAL_DIR_MODE, $recursive=true) |
| 417 | 417 |
{
|
| 418 |
$retVal = is_dir($dir_name);
|
|
| 419 |
if(!is_dir($dir_name))
|
|
| 418 |
$bRetval = is_dir($dir_name);
|
|
| 419 |
if(!$bRetval)
|
|
| 420 | 420 |
{
|
| 421 | 421 |
// To create the folder with 0777 permissions, we need to set umask to zero. |
| 422 | 422 |
$oldumask = umask(0) ; |
| 423 |
$retVal = mkdir($dir_name, $dir_mode, $recursive);
|
|
| 423 |
$bRetval = mkdir($dir_name, $dir_mode|0711, $recursive);
|
|
| 424 | 424 |
umask( $oldumask ) ; |
| 425 | 425 |
} |
| 426 |
return $retVal;
|
|
| 426 |
return $bRetval;
|
|
| 427 | 427 |
} |
| 428 | 428 |
|
| 429 | 429 |
/** |
| ... | ... | |
| 433 | 433 |
* @param int rights in dec-value. 0= use wb-defaults |
| 434 | 434 |
* @return bool |
| 435 | 435 |
*/ |
| 436 |
function change_mode($sName, $iMode = 0) |
|
| 436 |
function change_mode($sName, $iMode = 0 )
|
|
| 437 | 437 |
{
|
| 438 | 438 |
$bRetval = true; |
| 439 | 439 |
$iErrorReporting = error_reporting(0); |
| ... | ... | |
| 653 | 653 |
} |
| 654 | 654 |
} |
| 655 | 655 |
|
| 656 |
|
|
| 656 | 657 |
// Create a new directory and/or protected file in the given directory |
| 657 | 658 |
function createFolderProtectFile($sAbsDir='',$make_dir=true) |
| 658 | 659 |
{
|
| ... | ... | |
| 663 | 664 |
|
| 664 | 665 |
if ( $make_dir==true ) {
|
| 665 | 666 |
// Check to see if the folder already exists |
| 666 |
if(file_exists($sAbsDir)) {
|
|
| 667 |
// $admin->print_error($MESSAGE['MEDIA_DIR_EXISTS']); |
|
| 667 |
if(is_readable($sAbsDir)) {
|
|
| 668 | 668 |
$retVal[] = basename($sAbsDir).'::'.$MESSAGE['MEDIA_DIR_EXISTS']; |
| 669 | 669 |
} |
| 670 | 670 |
if (!is_dir($sAbsDir) && !make_dir($sAbsDir) ) {
|
| 671 |
// $admin->print_error($MESSAGE['MEDIA_DIR_NOT_MADE']); |
|
| 672 | 671 |
$retVal[] = basename($sAbsDir).'::'.$MESSAGE['MEDIA_DIR_NOT_MADE']; |
| 673 | 672 |
} else {
|
| 674 | 673 |
change_mode($sAbsDir); |
| 675 | 674 |
} |
| 675 |
return $retVal; |
|
| 676 | 676 |
} |
| 677 | 677 |
|
| 678 | 678 |
if( is_writable($sAbsDir) ) |
| ... | ... | |
| 698 | 698 |
// write content into file |
| 699 | 699 |
if(is_writable($filename) || !file_exists($filename)) {
|
| 700 | 700 |
if(file_put_contents($filename, $content)) {
|
| 701 |
// print 'create => '.str_replace( $wb_path,'',$filename).'<br />'; |
|
| 702 |
change_mode($filename, 'file'); |
|
| 701 |
$retVal[] = change_mode($filename); |
|
| 703 | 702 |
} else {
|
| 704 | 703 |
$retVal[] = $MESSAGE['GENERIC_BAD_PERMISSIONS'].' :: '.$filename; |
| 705 | 704 |
} |
| ... | ... | |
| 714 | 713 |
{
|
| 715 | 714 |
global $MESSAGE; |
| 716 | 715 |
$retVal = array(); |
| 716 |
$tmpVal = array(); |
|
| 717 | 717 |
$dir = rtrim(str_replace('\/\\', '/', $dir), '/');
|
| 718 | 718 |
try {
|
| 719 | 719 |
$files = array(); |
| ... | ... | |
| 724 | 724 |
$files = array_unique($files); |
| 725 | 725 |
foreach( $files as $file) {
|
| 726 | 726 |
$protect_file = rtrim(str_replace('\/\\', '/', $file), '/');
|
| 727 |
$retVal[] = createFolderProtectFile($protect_file,false);
|
|
| 727 |
$tmpVal['file'][] = createFolderProtectFile($protect_file,false);
|
|
| 728 | 728 |
} |
| 729 |
$retVal = $tmpVal['file']; |
|
| 729 | 730 |
} catch ( Exception $e ) {
|
| 730 | 731 |
$retVal[] = $MESSAGE['MEDIA_DIR_ACCESS_DENIED']; |
| 731 | 732 |
} |
| ... | ... | |
| 733 | 734 |
} |
| 734 | 735 |
|
| 735 | 736 |
// Create a new file in the pages directory |
| 736 |
function create_access_file($filename,$page_id,$level) |
|
| 737 |
/** |
|
| 738 |
* createAccessFile() |
|
| 739 |
* |
|
| 740 |
* @param string The full path and filename to the new accessfile |
|
| 741 |
* @param int Id of the page for which the file should created |
|
| 742 |
* @param mixed an array with one or more additional statements to include in accessfile. |
|
| 743 |
* @return bool|string true or error message |
|
| 744 |
* @deprecated this function will be replaced by a core method in next version |
|
| 745 |
* @description: Create a new access file in the pages directory and subdirectory also if needed.<br /> |
|
| 746 |
* Example: $aOptionalCommands = array( |
|
| 747 |
* '$section_id = '.$section_id, |
|
| 748 |
* '$mod_var_int = '.$mod_var_int, |
|
| 749 |
* 'define(\'MOD_CONSTANT\'', '.$mod_var_int.')' |
|
| 750 |
* ); |
|
| 751 |
* forbidden commands: include|require[_once] |
|
| 752 |
* @deprecated 2013/02/19 |
|
| 753 |
*/ |
|
| 754 |
|
|
| 755 |
function create_access_file($sFileName, $iPageId, $iLevel = 0, array $aOptionalCommands = array() ) |
|
| 737 | 756 |
{
|
| 738 |
global $admin, $MESSAGE; |
|
| 739 |
$retVal = array(); |
|
| 740 |
// First make sure parent folder exists |
|
| 741 |
$parent_folders = explode('/',str_replace(WB_PATH.PAGES_DIRECTORY, '', dirname($filename)));
|
|
| 742 |
$parents = ''; |
|
| 743 |
foreach($parent_folders AS $parent_folder) |
|
| 744 |
{
|
|
| 745 |
if($parent_folder != '/' AND $parent_folder != '') |
|
| 757 |
global $MESSAGE; |
|
| 758 |
$sError = ''; |
|
| 759 |
// sanitize pathnames for the standard 'trailing slash' scheme |
|
| 760 |
$sAppPath = rtrim(str_replace('\\', '/', WB_PATH), '/').'/';
|
|
| 761 |
$sFileName = str_replace('\\', '/', $sFileName);
|
|
| 762 |
// try to create the whoole path to the accessfile |
|
| 763 |
$sAccessPath = dirname($sFileName).'/'; |
|
| 764 |
if(!($bRetval = is_dir($sAccessPath))) {
|
|
| 765 |
$iOldUmask = umask(0) ; |
|
| 766 |
// sanitize directory mode to 'o+rwx/g+x/u+x' and create path |
|
| 767 |
$bRetval = mkdir($sAccessPath, (OCTAL_DIR_MODE |0711), true); |
|
| 768 |
umask($iOldUmask); |
|
| 769 |
} |
|
| 770 |
if($bRetval) {
|
|
| 771 |
// check if accessfile is writeable |
|
| 772 |
if(is_writable($sAccessPath) || |
|
| 773 |
(file_exists($sFileName) && is_writable($sFileName)) ) |
|
| 746 | 774 |
{
|
| 747 |
$parents .= '/'.$parent_folder; |
|
| 748 |
$acces_file = WB_PATH.PAGES_DIRECTORY.$parents; |
|
| 749 |
// can only be dirs |
|
| 750 |
if(!is_readable($acces_file)) {
|
|
| 751 |
if(!make_dir($acces_file)) {
|
|
| 752 |
$retVal[] = $MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE_FOLDER']; |
|
| 753 |
$retVal[] = $MESSAGE['MEDIA_DIR_ACCESS_DENIED']; |
|
| 775 |
// build content for accessfile |
|
| 776 |
$sContent = '<?php'."\n" |
|
| 777 |
. '// *** This file is generated by WebsiteBaker Ver.'.VERSION."\n" |
|
| 778 |
. '// *** Creation date: '.date('c')."\n"
|
|
| 779 |
. '// *** Do not modify this file manually'."\n" |
|
| 780 |
. '// *** WB will rebuild this file from time to time!!'."\n" |
|
| 781 |
. '// *************************************************'."\n" |
|
| 782 |
. "\t".'$page_id = '.$iPageId.';'."\n"; |
|
| 783 |
// analyse OptionalCommands and add it to the accessfile |
|
| 784 |
foreach($aOptionalCommands as $sCommand) {
|
|
| 785 |
// loop through all available entries |
|
| 786 |
// remove all leading whitespaces and chars less then \x41(A) except \x24 ($) |
|
| 787 |
// also all trailing whitespaces and \x3B(;) too. |
|
| 788 |
$sNewCmd = rtrim(ltrim($sCommand, "\x00..\x23\x25..\x40"), ';'); |
|
| 789 |
if(preg_match('/^include|^require/i', $sNewCmd)) {
|
|
| 790 |
// insert forbidden include|require[_once] command and comment it out |
|
| 791 |
$sContent .= "\t".'// *not allowed command >> * '.$sNewCmd.';'."\n"; |
|
| 792 |
}elseif(preg_match('/^define/i', $sNewCmd)) {
|
|
| 793 |
// insert active define command and comment it as set deprecated |
|
| 794 |
$sContent .= "\t".$sNewCmd.'; // *deprecated command*'."\n"; |
|
| 795 |
}else {
|
|
| 796 |
// insert allowed active command |
|
| 797 |
$sContent .= "\t".$sNewCmd.';'."\n"; |
|
| 754 | 798 |
} |
| 755 | 799 |
} |
| 800 |
// calculate the needed backsteps and create the relative link to index.php |
|
| 801 |
$iBackSteps = substr_count(str_replace($sAppPath, '', $sFileName), '/'); |
|
| 802 |
$sIndexFile = str_repeat('../', $iBackSteps).'index.php';
|
|
| 803 |
// insert needed require command for index.php |
|
| 804 |
$sContent .= "\t".'require(\''.$sIndexFile.'\');'."\n" |
|
| 805 |
. '// *************************************************'."\n" |
|
| 806 |
. '// end of file'."\n"; |
|
| 807 |
// write new file out. If the file already exists overwrite its content. |
|
| 808 |
if(file_put_contents($sFileName, $sContent) !== false ) {
|
|
| 809 |
// if OS is not windows then chmod the new file |
|
| 810 |
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
|
|
| 811 |
// sanitize filemode to 'o-x/g-x/u-x/o+rw' and chmod the new file |
|
| 812 |
$bRetval = chmod($sName, ((OCTAL_FILE_MODE & ~0111)|0600)); |
|
| 813 |
} |
|
| 814 |
}else {
|
|
| 815 |
$sError = $MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']; |
|
| 816 |
} |
|
| 817 |
}else {
|
|
| 818 |
$sError = $MESSAGE['UPLOAD_ERR_CANT_WRITE']; |
|
| 756 | 819 |
} |
| 820 |
}else {
|
|
| 821 |
$sError = $MESSAGE['UPLOAD_ERR_CANT_WRITE']; |
|
| 757 | 822 |
} |
| 758 |
|
|
| 759 |
// The depth of the page directory in the directory hierarchy |
|
| 760 |
// '/pages' is at depth 2 |
|
| 761 |
$bPagesDirectorySet = (sizeof(explode('/',PAGES_DIRECTORY))==1);
|
|
| 762 |
// Work-out how many ../'s we need to get to the index page |
|
| 763 |
$pages_dir_depth = sizeof($parent_folders)-intval($bPagesDirectorySet); |
|
| 764 |
$index_location = str_repeat ( '../' , $pages_dir_depth ); |
|
| 765 |
$content = |
|
| 766 |
'<?php'."\n". |
|
| 767 |
'// *** This file is generated by WebsiteBaker Ver.'.VERSION."\n". |
|
| 768 |
'// *** Creation date: '.date('c')."\n".
|
|
| 769 |
'// *** Do not modify this file manually'."\n". |
|
| 770 |
'// *** WB will rebuild this file from time to time!!'."\n". |
|
| 771 |
'// *************************************************'."\n". |
|
| 772 |
"\t".'$page_id = '.$page_id.';'."\n". |
|
| 773 |
"\t".'require(\''.$index_location.'index.php\');'."\n". |
|
| 774 |
'// *************************************************'."\n"; |
|
| 775 |
|
|
| 776 |
if( ($handle = fopen($filename, 'w')) ) {
|
|
| 777 |
fwrite($handle, $content); |
|
| 778 |
fclose($handle); |
|
| 779 |
// Chmod the file |
|
| 780 |
change_mode($filename); |
|
| 781 |
} else {
|
|
| 782 |
// $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']); |
|
| 783 |
$retVal[] = $MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']; |
|
| 784 |
} |
|
| 785 |
return $retVal; |
|
| 823 |
// return boolean true if ok, on error return a message |
|
| 824 |
return ($sError == '' ? true : $sError); |
|
| 786 | 825 |
} |
| 787 | 826 |
|
| 788 | 827 |
// Function for working out a file mime type (if the in-built PHP one is not enabled) |
| ... | ... | |
| 1348 | 1387 |
* try to remove access files and build new folder protect files |
| 1349 | 1388 |
*/ |
| 1350 | 1389 |
$sTempDir = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
|
| 1351 |
if(($sTempDir!='') && is_writeable(WB_PATH.$sTempDir)==true) {
|
|
| 1352 |
if(rm_full_dir (WB_PATH.$sTempDir, true )==false) {
|
|
| 1353 |
$retVal[] = '<span><strong>Could not delete existing access files</strong></span>';
|
|
| 1354 |
} |
|
| 1355 |
} |
|
| 1356 |
$retVal[] = createFolderProtectFile(rtrim( WB_PATH.PAGES_DIRECTORY,'/') );
|
|
| 1390 |
// if(($sTempDir!='') && is_writeable(WB_PATH.$sTempDir)==true) {
|
|
| 1391 |
// if(rm_full_dir (WB_PATH.$sTempDir, true )==false) {
|
|
| 1392 |
// $retVal[] = 'Could not delete existing access files';
|
|
| 1393 |
// }
|
|
| 1394 |
// }
|
|
| 1395 |
$retVal = createFolderProtectFile(rtrim( WB_PATH.PAGES_DIRECTORY,'/') ); |
|
| 1357 | 1396 |
/** |
| 1358 | 1397 |
* Reformat/rebuild all existing access files |
| 1359 | 1398 |
*/ |
| 1360 |
$sql = 'SELECT `page_id`,`root_parent`,`link`, `level` FROM `'.TABLE_PREFIX.'pages` ORDER BY `link`'; |
|
| 1399 |
// $sql = 'SELECT `page_id`,`root_parent`,`link`, `level` FROM `'.TABLE_PREFIX.'pages` ORDER BY `link`'; |
|
| 1400 |
$sql = 'SELECT `page_id`,`root_parent`,`link`, `level` '; |
|
| 1401 |
$sql .= 'FROM `'.TABLE_PREFIX.'pages` '; |
|
| 1402 |
$sql .= 'WHERE `link` != \'\' ORDER BY `link` '; |
|
| 1361 | 1403 |
if (($oPage = $database->query($sql))) |
| 1362 | 1404 |
{
|
| 1363 | 1405 |
$x = 0; |
| ... | ... | |
| 1378 | 1420 |
|
| 1379 | 1421 |
if(!$database->query($sql)) {}
|
| 1380 | 1422 |
$filename = WB_PATH.PAGES_DIRECTORY.$page['link'].PAGE_EXTENSION; |
| 1381 |
$retVal = create_access_file($filename, $page['page_id'], $page['level']);
|
|
| 1423 |
create_access_file($filename, $page['page_id'], $page['level']); |
|
| 1382 | 1424 |
$x++; |
| 1383 | 1425 |
} |
| 1384 |
$retVal[] = '<span><strong>Number of new formated access files: '.$x.'</strong></span>';
|
|
| 1426 |
$retVal[] = 'Number of new formated access files: '.$x.'';
|
|
| 1385 | 1427 |
} |
| 1386 | 1428 |
return $retVal; |
| 1387 | 1429 |
} |
| ... | ... | |
| 1395 | 1437 |
$currModulVersion = get_modul_version ($sModul, false); |
| 1396 | 1438 |
$newModulVersion = get_modul_version ($sModul, true); |
| 1397 | 1439 |
if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
|
| 1398 |
require_once(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
|
|
| 1440 |
require(WB_PATH.'/modules/'.$sModul.'/upgrade.php'); |
|
| 1399 | 1441 |
} |
| 1400 | 1442 |
} |
| 1401 | 1443 |
} |
| branches/2.8.x/wb/framework/ModLanguage.php | ||
|---|---|---|
| 9 | 9 |
* @filesource $HeadURL$ |
| 10 | 10 |
* @since Datei vorhanden seit Release 2.8.4 |
| 11 | 11 |
* @lastmodified $Date$ |
| 12 |
* @deprecated 2013/02/19 |
|
| 12 | 13 |
*/ |
| 13 | 14 |
class ModLanguage {
|
| 14 | 15 |
|
| ... | ... | |
| 203 | 204 |
/** |
| 204 | 205 |
* Exception class for Translation |
| 205 | 206 |
*/ |
| 206 |
class TranslationException extends AppException {}
|
|
| 207 |
//class TranslationException extends AppException {}
|
|
| branches/2.8.x/wb/modules/news/Reorg.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
| 4 |
* |
|
| 5 |
* This program is free software: you can redistribute it and/or modify |
|
| 6 |
* it under the terms of the GNU General Public License as published by |
|
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
|
| 8 |
* (at your option) any later version. |
|
| 9 |
* |
|
| 10 |
* This program is distributed in the hope that it will be useful, |
|
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 13 |
* GNU General Public License for more details. |
|
| 14 |
* |
|
| 15 |
* You should have received a copy of the GNU General Public License |
|
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 17 |
*/ |
|
| 18 |
|
|
| 19 |
/** |
|
| 20 |
* Reorg.php |
|
| 21 |
* |
|
| 22 |
* @category Module |
|
| 23 |
* @package Module_news |
|
| 24 |
* @author Werner v.d.Decken <wkl@isteam.de> |
|
| 25 |
* @copyright Werner v.d.Decken <wkl@isteam.de> |
|
| 26 |
* @license http://www.gnu.org/licenses/gpl.html GPL License |
|
| 27 |
* @version 0.0.1 |
|
| 28 |
* @revision $Revision: $ |
|
| 29 |
* @link $HeadURL: $ |
|
| 30 |
* @lastmodified $Date: $ |
|
| 31 |
* @since File available since 17.01.2013 |
|
| 32 |
* @description Reorganisation jobs for the 'news' module |
|
| 33 |
*/ |
|
| 34 |
|
|
| 35 |
class m_news_Reorg {
|
|
| 36 |
|
|
| 37 |
private $_aSys = array(); |
|
| 38 |
/** |
|
| 39 |
* Execute reorganisation |
|
| 40 |
* @return string all occured messages |
|
| 41 |
*/ |
|
| 42 |
public function execute() |
|
| 43 |
{
|
|
| 44 |
$sOutput = null; |
|
| 45 |
if(class_exists('WbAdaptor')) {
|
|
| 46 |
$this->_aSys['TablePrefix'] = WbAdaptor::getInstance()->TablePrefix; |
|
| 47 |
$this->_aSys['AppPath'] = WbAdaptor::getInstance()->AppPath; |
|
| 48 |
$this->_aSys['PagesDir'] = WbAdaptor::getInstance()->PagesDir; |
|
| 49 |
$this->_aSys['PageExtension'] = WbAdaptor::getInstance()->PageExtension; |
|
| 50 |
$sOutput = $this->createAccessFiles(); |
|
| 51 |
} |
|
| 52 |
// add here the requests for additional reorg methods |
|
| 53 |
return $sOutput; |
|
| 54 |
} |
|
| 55 |
/** |
|
| 56 |
* Creates all Accessfiles from DB |
|
| 57 |
* @return string all occured messages |
|
| 58 |
*/ |
|
| 59 |
protected function createAccessFiles() |
|
| 60 |
{
|
|
| 61 |
$count = 0; |
|
| 62 |
$aReturnMsg = array(); |
|
| 63 |
$sql = 'SELECT `page_id`,`post_id`,`section_id`,`link` '; |
|
| 64 |
$sql .= 'FROM `'.$this->_aSys['TablePrefix'].'mod_news_posts`'; |
|
| 65 |
$sql .= 'WHERE `link` != \'\''; |
|
| 66 |
if(($oPosts = WbDatabase::getInstance()->query($sql))) {
|
|
| 67 |
while($aPost = $oPosts->fetchRow(MYSQL_ASSOC)) |
|
| 68 |
{
|
|
| 69 |
$sAccessFile = $this->_aSys['AppPath'].$this->_aSys['PagesDir'] |
|
| 70 |
. trim(str_replace('\\', '/', $aPost['link']), '/')
|
|
| 71 |
. $this->_aSys['PageExtension']; |
|
| 72 |
$aOptionalCommand = array( |
|
| 73 |
'$section_id = '.$aPost['section_id'].';', |
|
| 74 |
'$post_section = '.$aPost['section_id'].';', |
|
| 75 |
'$post_id = '.$aPost['post_id'].';' |
|
| 76 |
); |
|
| 77 |
if(create_access_file($sAccessFile, $aPost['page_id'], 0, $aOptionalCommand)){
|
|
| 78 |
$count++; |
|
| 79 |
} else {
|
|
| 80 |
$aReturnMsg[] = 'Can\'t create '.$sAccessFile; |
|
| 81 |
} |
|
| 82 |
} |
|
| 83 |
$aReturnMsg[] = 'Number of new created access files: '.$count; |
|
| 84 |
} |
|
| 85 |
return $aReturnMsg; |
|
| 86 |
} |
|
| 87 |
// add here some additional reorg methods **************************************** *// |
|
| 88 |
} // end of class Reorg |
|
| branches/2.8.x/wb/modules/news/upgrade.php | ||
|---|---|---|
| 1 | 1 |
<?php |
| 2 | 2 |
/** |
| 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
| 3 | 4 |
* |
| 4 |
* @category modules |
|
| 5 |
* @package news |
|
| 6 |
* @subpackage upgrade |
|
| 7 |
* @copyright 2009-2012, 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$ |
|
| 13 |
* @filesource $HeadURL$ |
|
| 14 |
* @lastmodified $Date$ |
|
| 5 |
* This program is free software: you can redistribute it and/or modify |
|
| 6 |
* it under the terms of the GNU General Public License as published by |
|
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
|
| 8 |
* (at your option) any later version. |
|
| 15 | 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
|
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 13 |
* GNU General Public License for more details. |
|
| 14 |
* |
|
| 15 |
* You should have received a copy of the GNU General Public License |
|
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 16 | 17 |
*/ |
| 17 | 18 |
|
| 19 |
/** |
|
| 20 |
* upgrade.php |
|
| 21 |
* |
|
| 22 |
* @category Module |
|
| 23 |
* @package Module_news |
|
| 24 |
* @subpackage upgrade |
|
| 25 |
* @author Dietmar Wöllbrink <dietmar.woellbrink@websitebaker.org> |
|
| 26 |
* @author Werner v.d.Decken <wkl@isteam.de> |
|
| 27 |
* @copyright Werner v.d.Decken <wkl@isteam.de> |
|
| 28 |
* @license http://www.gnu.org/licenses/gpl.html GPL License |
|
| 29 |
* @version 0.0.1 |
|
| 30 |
* @revision $Revision$ |
|
| 31 |
* @link $HeadURL$ |
|
| 32 |
* @lastmodified $Date$ |
|
| 33 |
* @since File available since 17.01.2013 |
|
| 34 |
* @description xyz |
|
| 35 |
* |
|
| 36 |
*/ |
|
| 37 |
|
|
| 18 | 38 |
/* -------------------------------------------------------- */ |
| 19 | 39 |
// Must include code to stop this file being accessed directly |
| 20 | 40 |
require_once( dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php'); |
| ... | ... | |
| 26 | 46 |
function mod_news_Upgrade() |
| 27 | 47 |
{
|
| 28 | 48 |
global $database, $admin, $MESSAGE,$bDebugModus; |
| 29 |
$msg = array();
|
|
| 49 |
$msg = array();
|
|
| 30 | 50 |
$callingScript = $_SERVER["SCRIPT_NAME"]; |
| 31 | 51 |
// check if upgrade startet by upgrade-script to echo a message |
| 32 | 52 |
$tmp = 'upgrade-script.php'; |
| 33 | 53 |
$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0; |
| 34 |
/**
|
|
| 35 |
* check database engine
|
|
| 36 |
*/
|
|
| 37 |
$aTable = array('mod_news_posts','mod_news_groups','mod_news_comments','mod_news_settings');
|
|
| 38 |
for($x=0; $x<sizeof($aTable);$x++) {
|
|
| 39 |
if(($sOldType = $database->getTableEngine(TABLE_PREFIX.$aTable[$x]))) {
|
|
| 40 |
if(('myisam' != strtolower($sOldType))) {
|
|
| 41 |
if(!$database->query('ALTER TABLE `'.TABLE_PREFIX.$aTable[$x].'` Engine = \'MyISAM\' ')) {
|
|
| 42 |
$msg[] = $database->get_error();
|
|
| 43 |
} else{
|
|
| 44 |
$msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` changed to Engine = \'MyISAM\'';
|
|
| 45 |
}
|
|
| 46 |
} else {
|
|
| 47 |
$msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` has Engine = \'MyISAM\'';
|
|
| 48 |
}
|
|
| 49 |
} else {
|
|
| 50 |
$msg[] = $database->get_error();
|
|
| 51 |
}
|
|
| 52 |
}
|
|
| 54 |
/**
|
|
| 55 |
* check database engine
|
|
| 56 |
*/
|
|
| 57 |
$aTable = array('mod_news_posts','mod_news_groups','mod_news_comments','mod_news_settings');
|
|
| 58 |
for($x=0; $x<sizeof($aTable);$x++) {
|
|
| 59 |
if(($sOldType = $database->getTableEngine(TABLE_PREFIX.$aTable[$x]))) {
|
|
| 60 |
if(('myisam' != strtolower($sOldType))) {
|
|
| 61 |
if(!$database->query('ALTER TABLE `'.TABLE_PREFIX.$aTable[$x].'` Engine = \'MyISAM\' ')) {
|
|
| 62 |
$msg[] = $database->get_error();
|
|
| 63 |
} else{
|
|
| 64 |
$msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` changed to Engine = \'MyISAM\'';
|
|
| 65 |
}
|
|
| 66 |
} else {
|
|
| 67 |
$msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` has Engine = \'MyISAM\'';
|
|
| 68 |
}
|
|
| 69 |
} else {
|
|
| 70 |
$msg[] = $database->get_error();
|
|
| 71 |
}
|
|
| 72 |
}
|
|
| 53 | 73 |
|
| 54 |
|
|
| 55 | 74 |
$sPagesPath = WB_PATH.PAGES_DIRECTORY; |
| 56 | 75 |
$sPostsPath = $sPagesPath.'/posts'; |
| 57 | 76 |
// create /posts/ - directory if not exists |
| 58 |
if(!file_exists($sPostsPath)) {
|
|
| 59 |
if(is_writable($sPagesPath)) {
|
|
| 60 |
make_dir(WB_PATH.PAGES_DIRECTORY.'/posts/'); |
|
| 61 |
} else {
|
|
| 62 |
if(!$globalStarted){
|
|
| 63 |
$msg[] = ($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']); |
|
| 64 |
// $admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']); |
|
| 65 |
return $msg; |
|
| 66 |
} else {
|
|
| 67 |
echo ''.$MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'].''; |
|
| 68 |
return $msg; |
|
| 69 |
} |
|
| 77 |
if(is_writable($sPagesPath)) {
|
|
| 78 |
if(!($bRetval = is_dir($sPostsPath))) {
|
|
| 79 |
$iOldUmask = umask(0) ; |
|
| 80 |
// sanitize directory mode to 'o+rwx/g+x/u+x' and create path |
|
| 81 |
$bRetval = mkdir($sPostsPath, (OCTAL_DIR_MODE |0711), true); |
|
| 82 |
umask($iOldUmask); |
|
| 70 | 83 |
} |
| 71 |
$msg[] = '<strong>Directory "'.PAGES_DIRECTORY.'/posts/" created</strong>'; |
|
| 72 |
} else {
|
|
| 73 |
$msg[] = '<strong>Directory "'.PAGES_DIRECTORY.'/posts/" already exists.</strong>'; |
|
| 84 |
if($bRetval) {
|
|
| 85 |
$msg[] = 'Directory "'.PAGES_DIRECTORY.'/posts/" already exists or created.'; |
|
| 86 |
}else {
|
|
| 87 |
$msg[] = ($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']); |
|
| 88 |
} |
|
| 89 |
}else {
|
|
| 90 |
$msg[] = ($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']); |
|
| 74 | 91 |
} |
| 75 | 92 |
// check if new fields must be added |
| 76 | 93 |
$doImportDate = true; |
| 77 | 94 |
if(!$database->field_exists(TABLE_PREFIX.'mod_news_posts', 'created_when')) {
|
| 78 | 95 |
if(!$database->field_add(TABLE_PREFIX.'mod_news_posts', 'created_when', |
| 79 | 96 |
'INT NOT NULL DEFAULT \'0\' AFTER `commenting`')) {
|
| 80 |
if($globalStarted){
|
|
| 81 |
echo ''.$MESSAGE['RECORD_MODIFIED_FAILED'].''; |
|
| 82 |
return $msg; |
|
| 83 |
} else {
|
|
| 84 |
// $admin->print_error($MESSAGE['RECORD_MODIFIED_FAILED']); |
|
| 85 | 97 |
$msg[] = $MESSAGE['RECORD_MODIFIED_FAILED']; |
| 86 |
return $msg;
|
|
| 87 |
}
|
|
| 98 |
} else {
|
|
| 99 |
$msg[] = 'TABLE `'.TABLE_PREFIX.'mod_news_posts` Datafield `created_when` added.';
|
|
| 88 | 100 |
} |
| 101 |
} else {
|
|
| 102 |
$msg[] = 'TABLE `'.TABLE_PREFIX.'mod_news_posts` Datafield `created_when` already exists.'; |
|
| 103 |
$doImportDate = false; |
|
| 104 |
} |
|
| 89 | 105 |
|
| 90 |
if($globalStarted) {
|
|
| 91 |
echo 'Datafield `'.TABLE_PREFIX.'mod_news_posts`.`created_when` added.<br />'; |
|
| 92 |
} |
|
| 93 |
} else { $doImportDate = false; }
|
|
| 94 |
|
|
| 95 | 106 |
if(!$database->field_exists(TABLE_PREFIX.'mod_news_posts', 'created_by')) {
|
| 96 | 107 |
if(!$database->field_add(TABLE_PREFIX.'mod_news_posts', 'created_by', |
| 97 | 108 |
'INT NOT NULL DEFAULT \'0\' AFTER `created_when`')) {
|
| 98 |
if($globalStarted){
|
|
| 99 |
echo ''.$MESSAGE['RECORD_MODIFIED_FAILED'].''; |
|
| 100 |
return $msg; |
|
| 101 |
}else {
|
|
| 102 |
// $admin->print_error($MESSAGE['RECORD_MODIFIED_FAILED']); |
|
| 103 |
$msg[] = $MESSAGE['RECORD_MODIFIED_FAILED']; |
|
| 104 |
return $msg; |
|
| 105 |
} |
|
| 109 |
$msg[] = $MESSAGE['RECORD_MODIFIED_FAILED']; |
|
| 106 | 110 |
} |
| 107 |
if($globalStarted) {
|
|
| 108 |
echo 'datafield `'.TABLE_PREFIX.'mod_news_posts`.`created_by` added.<br />';
|
|
| 109 |
}
|
|
| 111 |
} else {
|
|
| 112 |
$msg[] = 'TABLE `'.TABLE_PREFIX.'mod_news_posts` Datafield `created_by` already exists.';
|
|
| 113 |
$doImportDate = false;
|
|
| 110 | 114 |
} |
| 111 |
// preset new fields `created_by` and `created_when` from existing values
|
|
| 115 |
// preset new fields `created_by` and `created_by` from existing values
|
|
| 112 | 116 |
if($doImportDate) {
|
| 113 | 117 |
$sql = 'UPDATE `'.TABLE_PREFIX.'mod_news_posts` '; |
| 114 | 118 |
$sql .= 'SET `created_by`=`posted_by`, `created_when`=`posted_when`'; |
| 115 | 119 |
$database->query($sql); |
| 116 | 120 |
} |
| 117 | 121 |
|
| 118 |
/**
|
|
| 119 |
* rebuild news post folder
|
|
| 120 |
*/
|
|
| 121 |
$array = rebuildFolderProtectFile($sPostsPath); |
|
| 122 |
/**
|
|
| 123 |
* rebuild news post folder
|
|
| 124 |
*/
|
|
| 125 |
// $array = rebuildFolderProtectFile($sPostsPath);
|
|
| 122 | 126 |
// now iterate through all existing accessfiles, |
| 123 | 127 |
// write its creation date into database |
| 124 | 128 |
$oDir = new DirectoryIterator($sPostsPath); |
| ... | ... | |
| 137 | 141 |
$sql = 'UPDATE `'.TABLE_PREFIX.'mod_news_posts` '; |
| 138 | 142 |
$sql .= 'SET `created_when`='.$fileinfo->getMTime().' '; |
| 139 | 143 |
$sql .= 'WHERE `link`=\''.$link.'\''; |
| 140 |
$database->query($sql); |
|
| 144 |
if($database->query($sql)) {
|
|
| 145 |
// delete old access file |
|
| 146 |
unlink($fileinfo->getPathname()); |
|
| 147 |
$count++; |
|
| 148 |
} |
|
| 141 | 149 |
} |
| 142 |
// delete old access file |
|
| 143 |
unlink($fileinfo->getPathname()); |
|
| 144 |
$count++; |
|
| 145 | 150 |
} |
| 146 | 151 |
} |
| 147 | 152 |
unset($oDir); |
| 148 | 153 |
|
| 149 | 154 |
if($count > 0) {
|
| 150 |
$msg[] = 'save date of creation from '.$count.' old accessfiles and delete these files.';
|
|
| 155 |
$msg[] = 'Save date of creation from '.$count.' old accessfiles and delete these files.';
|
|
| 151 | 156 |
} |
| 152 | 157 |
// ************************************************ |
| 153 | 158 |
// Check the validity of 'create-file-timestamp' and balance against 'posted-timestamp' |
| ... | ... | |
| 161 | 166 |
$database->query($sql); |
| 162 | 167 |
// ************************************************ |
| 163 | 168 |
|
| 164 |
// rebuild all access-files |
|
| 165 |
$count = 0; |
|
| 166 |
$backSteps = preg_replace('@^'.preg_quote(WB_PATH).'@', '', $sPostsPath);
|
|
| 167 |
$backSteps = str_repeat( '../', substr_count($backSteps, '/')); |
|
| 168 |
$sql = 'SELECT `page_id`,`post_id`,`section_id`,`link` '; |
|
| 169 |
$sql .= 'FROM `'.TABLE_PREFIX.'mod_news_posts`'; |
|
| 170 |
$sql .= 'WHERE `link` != \'\''; |
|
| 171 |
if( ($resPosts = $database->query($sql)) ) |
|
| 172 |
{
|
|
| 173 |
while( $recPost = $resPosts->fetchRow() ) |
|
| 174 |
{
|
|
| 175 |
$file = $sPagesPath.$recPost['link'].PAGE_EXTENSION; |
|
| 176 |
$content = |
|
| 177 |
'<?php'."\n". |
|
| 178 |
'// *** This file is generated by WebsiteBaker Ver.'.VERSION."\n". |
|
| 179 |
'// *** Creation date: '.date('c')."\n".
|
|
| 180 |
'// *** Do not modify this file manually'."\n". |
|
| 181 |
'// *** WB will rebuild this file from time to time!!'."\n". |
|
| 182 |
'// *************************************************'."\n". |
|
| 183 |
"\t".'$page_id = '.$recPost['page_id'].';'."\n". |
|
| 184 |
"\t".'$section_id = '.$recPost['section_id'].';'."\n". |
|
| 185 |
"\t".'$post_id = '.$recPost['post_id'].';'."\n". |
|
| 186 |
"\t".'$post_section = '.$recPost['section_id'].';'."\n". |
|
| 187 |
"\t".'require(\''.$backSteps.'index.php\');'."\n". |
|
| 188 |
'// *************************************************'."\n"; |
|
| 189 |
if( file_put_contents($file, $content) !== false ) {
|
|
| 190 |
// Chmod the file |
|
| 191 |
change_mode($file); |
|
| 192 |
}else {
|
|
| 193 |
$msg[] = ($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']); |
|
| 194 |
} |
|
| 195 |
$count++; |
|
| 196 |
} |
|
| 197 |
$msg[] = '<strong>Number of new created access files: '.$count.'</strong>'; |
|
| 198 |
} |
|
| 199 | 169 |
// only for upgrade-script |
| 200 | 170 |
if($globalStarted) {
|
| 201 | 171 |
if($bDebugModus) {
|
| ... | ... | |
| 203 | 173 |
echo '<strong>'.$title.'</strong><br />'; |
| 204 | 174 |
} |
| 205 | 175 |
} |
| 206 |
} |
|
| 207 |
return $msg;
|
|
| 176 |
}
|
|
| 177 |
return ( ($globalStarted==true ) ? $globalStarted : $msg);
|
|
| 208 | 178 |
} |
| 209 | 179 |
} |
| 210 | 180 |
// end mod_news_Upgrade |
| 211 | 181 |
|
| 212 | 182 |
// ------------------------------------ |
| 213 |
|
|
| 214 |
$msg = mod_news_Upgrade(); |
|
| 215 |
|
|
| 216 |
|
|
| 217 |
/* **** END UPGRADE ********************************************************* */ |
|
| 183 |
// only show if manuell upgrade |
|
| 184 |
if( is_array($msg = mod_news_Upgrade()) ) {
|
|
| 185 |
$sModulReorg = 'm_news_Reorg'; |
|
| 186 |
if(class_exists($sModulReorg)) {
|
|
| 187 |
$oReorg = new $sModulReorg(); |
|
| 188 |
$msg = array_merge($msg, $oReorg->execute() ); // show details |
|
| 189 |
// $msg = array_merge($msg,(new $sModulReorg())->execute()); // show details |
|
| 190 |
} |
|
| 191 |
foreach($msg as $title) {
|
|
| 192 |
echo '<strong>'.$title.'</strong><br />'; |
|
| 193 |
} |
|
| 194 |
echo '<strong>News upgrade finished </strong><br /><br>'; |
|
| 195 |
} |
|
| 196 |
/* **** END UPGRADE ********************************************************* */ |
|
Also available in: Unified diff
! framework/functions.php set function create_access_file to deprecated
! set ModLanguage.php to deprecated
! add methode escapeString to class WbDatabase
! update upgrade-script.php
! add getter property LastInsertId to class WbDatabase