Project

General

Profile

« Previous | Next » 

Revision 1588

Added by darkviper almost 13 years ago

all module depending code removed, some little fixes, better integration for module-upgrade

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12

  
13 13
=========================== add small Features 2.8.2 ==========================
14
25 Jan-2012 Build 1588 Werner v.d.Decken(DarkViper)
15
# all module depending code removed, some little fixes, better integration for module-upgrade
14 16
25 Jan-2012 Build 1587 Werner v.d.Decken(DarkViper)
15 17
+ module news: added sql-dump to create database tables
16 18
# module news: some little fixes in install/upgrade
branches/2.8.x/wb/upgrade-script.php
476 476
echo "<br />Adding field redirect_type to mod_menu_link table<br />";
477 477
db_add_field('redirect_type', 'mod_menu_link', "INT NOT NULL DEFAULT '302' AFTER `target_page_id`");
478 478

  
479
if (version_compare(WB_VERSION, '2.8') < 0)
479
/**********************************************************
480
 *  - Update search no results database filed to create
481
 *  valid XHTML if search is empty
482
 */
483
if (version_compare(WB_VERSION, '2.8', '<'))
480 484
{
481
    /**********************************************************
482
     *  - Update search no results database filed to create
483
     *  valid XHTML if search is empty
484
     */
485 485
    echo "<br />Updating database field `no_results` of search table: ";
486 486
    $search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
487
    $sql = "UPDATE `" . TABLE_PREFIX . "search` SET `value` = '$search_no_results' WHERE `name`= 'no_results'";
488
    $database->query($sql);
489
    echo ($database->query($sql)) ? " $OK<br />" : " $FAIL<br />";
490
    /**********************************************************
491
     *  - Update settings of News Modul
492
     */
493

  
494
    // These are the default setting
495
    $header = '<table cellpadding=\"0\" cellspacing=\"0\" class=\"loop-header\">'."\n";
496
    $post_loop = '<tr class=\"post_top\">
497
<td class=\"post_title\"><a href=\"[LINK]\">[TITLE]</a></td>
498
<td class=\"post_date\">[PUBLISHED_TIME], [PUBLISHED_DATE]</td>
499
</tr>
500
<tr>
501
<td class=\"post_short\" colspan=\"2\">
502
[SHORT]
503
<span style=\"visibility:[SHOW_READ_MORE];\"><a href=\"[LINK]\">[TEXT_READ_MORE]</a></span>
504
</td>
505
</tr>';
506
    $footer = '</table>
507
<table cellpadding="0" cellspacing="0" class="page-header" style="display: [DISPLAY_PREVIOUS_NEXT_LINKS]">
508
<tr>
509
<td class="page-left">[PREVIOUS_PAGE_LINK]</td>
510
<td class="page-center">[OF]</td>
511
<td class="page-right">[NEXT_PAGE_LINK]</td>
512
</tr>
513
</table>';
514
    $post_header = addslashes('<table cellpadding="0" cellspacing="0" class="post-header">
515
<tr>
516
<td><h1>[TITLE]</h1></td>
517
<td rowspan="3" style="display: [DISPLAY_IMAGE]">[GROUP_IMAGE]</td>
518
</tr>
519
<tr>
520
<td class="public-info"><b>[TEXT_POSTED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [PUBLISHED_DATE]</b></td>
521
</tr>
522
<tr style="display: [DISPLAY_GROUP]">
523
<td class="group-page"><a href="[BACK]">[PAGE_TITLE]</a> &gt;&gt; <a href="[BACK]?g=[GROUP_ID]">[GROUP_TITLE]</a></td>
524
</tr>
525
</table>');
526
    $post_footer = '<p>[TEXT_LAST_CHANGED]: [MODI_DATE] [TEXT_AT] [MODI_TIME]</p>
527
<a href=\"[BACK]\">[TEXT_BACK]</a>';
528
    $comments_header = addslashes('<br /><br />
529
<h2>[TEXT_COMMENTS]</h2>
530
<table cellpadding="2" cellspacing="0" class="comment-header">');
531
    $comments_loop = addslashes('<tr>
532
<td class="comment_title">[TITLE]</td>
533
<td class="comment_info">[TEXT_BY] [DISPLAY_NAME] [TEXT_ON] [DATE] [TEXT_AT] [TIME]</td>
534
</tr>
535
<tr>
536
<td colspan="2" class="comment_text">[COMMENT]</td>
537
</tr>');
538
    $comments_footer = '</table>
539
<br /><a href=\"[ADD_COMMENT_URL]\">[TEXT_ADD_COMMENT]</a>';
540
    $comments_page = '<h1>[TEXT_COMMENT]</h1>
541
<h2>[POST_TITLE]</h2>
542
<br />';
543

  
544
	if(in_array('mod_news_settings', $all_tables))
545
	{
546
	   // Insert default settings into database
547
	   $query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0");
548
	   if($query_dates->numRows() > 1)
549
	   {
550
	        while($result = $query_dates->fetchRow())
551
	        {
552

  
553
	        	echo "<br /><u>Add default settings to database for news section_id= ".$result['section_id']."</u><br />";
554
	        	$section_id = $result['section_id'];
555

  
556
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `header` = '$header' WHERE `section_id` = $section_id")) {
557
	        		echo 'Database data header added successfully';
558
	        	}
559
	        	echo mysql_error().'<br />';
560

  
561
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_loop` = '$post_loop' WHERE `section_id` = $section_id")) {
562
	        		echo 'Database data post_loop added successfully';
563
	        	}
564
	        	echo mysql_error().'<br />';
565

  
566
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `footer` = '$footer' WHERE `section_id` = $section_id")) {
567
	        		echo 'Database data footer added successfully';
568
	        	}
569
	        	echo mysql_error().'<br />';
570

  
571
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_header` = '$post_header' WHERE `section_id` = $section_id")) {
572
	        		echo 'Database data post_header added successfully';
573
	        	}
574
	        	echo mysql_error().'<br />';
575

  
576
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_footer` = '$post_footer' WHERE `section_id` = $section_id")) {
577
	        		echo 'Database data post_footer added successfully';
578
	        	}
579
	        	echo mysql_error().'<br />';
580

  
581
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_header` = '$comments_header' WHERE `section_id` = $section_id")) {
582
	        		echo 'Database data comments_header added successfully';
583
	        	}
584
	        	echo mysql_error().'<br />';
585

  
586
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_loop` = '$comments_loop' WHERE `section_id` = $section_id")) {
587
	        		echo 'Database data comments_loop added successfully';
588
	        	}
589
	        	echo mysql_error().'<br />';
590

  
591
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_footer` = '$comments_footer' WHERE `section_id` = $section_id")) {
592
	        		echo 'Database data comments_footer added successfully';
593
	        	}
594
	        	echo mysql_error().'<br />';
595

  
596
	        	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_page` = '$comments_page' WHERE `section_id` = $section_id")) {
597
	        		echo 'Database data comments_page added successfully';
598
	        	}
599
	        	echo mysql_error().'<br />';
600

  
601
	        }
602
	     }
603
	   }
487
    $sql  = 'UPDATE `'.TABLE_PREFIX.'search` ';
488
	$sql .= 'SET `value`=\''.$search_no_results.'\' ';
489
	$sql .= 'WHERE `name`=\'no_results\'';
490
    echo ($database->query($sql)) ? ' $OK<br />' : ' $FAIL<br />';
604 491
}
605 492
/**********************************************************
606 493
 * upgrade media folder index protect files
607 494
 */
608
$dir = (WB_PATH.MEDIA_DIRECTORY);
609
echo '<h4>Upgrade '.MEDIA_DIRECTORY.'/ index.php protect files</h4><br />';
610
$array = rebuildFolderProtectFile($dir);
611
if( sizeof( $array ) ){
612
	print '<br /><strong>Upgrade '.sizeof( $array ).' '.MEDIA_DIRECTORY.'/ protect files</strong>'." $OK<br />";
613
} else {
614
	print '<br /><strong>Upgrade '.MEDIA_DIRECTORY.'/ protect files</strong>'." $FAIL!<br />";
615
	print implode ('<br />',$array);
616
}
617

  
618
/**********************************************************
619
 * upgrade news if newer version is available
620
 */
621
	if(file_exists(WB_PATH.'/modules/news/upgrade.php'))
622
	{
623
		$currNewsVersion = get_modul_version ('news', false);
624
		$newNewsVersion =  get_modul_version ('news', true);
625
		if((version_compare($currNewsVersion, $newNewsVersion) <= 0)) {
626
			echo '<h4>Upgrade existings basically news module</h4><br />';
627
			// change old postfiles to new postfiles
628
			require_once(WB_PATH."/modules/news/upgrade.php");
629
		}
495
	$dir = (WB_PATH.MEDIA_DIRECTORY);
496
	echo '<h4>Upgrade '.MEDIA_DIRECTORY.'/ index.php protect files</h4><br />';
497
	$array = rebuildFolderProtectFile($dir);
498
	if( sizeof( $array ) ){
499
		print '<br /><strong>Upgrade '.sizeof( $array ).' '.MEDIA_DIRECTORY.'/ protect files</strong>'." $OK<br />";
500
	} else {
501
		print '<br /><strong>Upgrade '.MEDIA_DIRECTORY.'/ protect files</strong>'." $FAIL!<br />";
502
		print implode ('<br />',$array);
630 503
	}
631

  
632 504
/* *****************************************************************************
633 505
 * - check for deprecated / never needed files
634 506
 */
635
if(sizeof($filesRemove)) {
636
?>
637
<h2>Step <?php echo (++$stepID) ?>: Remove deprecated and old files</h2>
638
<?php
639
}
507
	if(sizeof($filesRemove)) {
508
		echo '<h2>Step '.(++$stepID).': Remove deprecated and old files</h2>';
509
	}
640 510
	$searches = array(
641 511
		'[ADMIN]',
642 512
		'[MEDIA]',
......
661 531
		{
662 532
			$file = str_replace($searches, $replacements, $file);
663 533
			$file = WB_PATH.'/'.$file;
664
			if( file_exists($file) )
665
			{ // try to unlink file
666
				if(!is_writable( $file ) || !unlink($file))
667
				{ // save in err-list, if failed
534
			if( file_exists($file) ) {
535
				// try to unlink file
536
				if(!is_writable( $file ) || !unlink($file)) {
537
					// save in err-list, if failed
668 538
					$msg .= $file.'<br />';
669 539
				}
670 540
			}
......
690 560
/**********************************************************
691 561
 * - check for deprecated / never needed files
692 562
 */
693
if(sizeof($dirRemove)) {
694
?>
695
<h2>Step  <?php echo (++$stepID) ?> : Remove deprecated and old folders</h2>
696
<?php
697

  
698
	$searches = array(
699
		'[ADMIN]',
700
		'[MEDIA]',
701
		'[PAGES]',
702
		'[TEMPLATE]'
703
	);
704
	$replacements = array(
705
		substr(ADMIN_PATH, strlen(WB_PATH)+1),
706
		MEDIA_DIRECTORY,
707
		PAGES_DIRECTORY,
708
		'/templates',
709
	);
710

  
711
	$msg = '';
712
	foreach( $dirRemove as $dir )
713
	{
714
		$dir = str_replace($searches, $replacements, $dir);
715
		$dir = WB_PATH.'/'.$dir;
716
		if( is_dir( $dir ))
717
		{ // try to delete dir
718
			if(!rm_full_dir($dir))
719
			{ // save in err-list, if failed
720
				$msg .= $dir.'<br />';
563
	if(sizeof($dirRemove)) {
564
		echo '<h2>Step  '.(++$stepID).': Remove deprecated and old folders</h2>';
565
		$searches = array(
566
			'[ADMIN]',
567
			'[MEDIA]',
568
			'[PAGES]',
569
			'[TEMPLATE]'
570
		);
571
		$replacements = array(
572
			substr(ADMIN_PATH, strlen(WB_PATH)+1),
573
			MEDIA_DIRECTORY,
574
			PAGES_DIRECTORY,
575
			'/templates',
576
		);
577
		$msg = '';
578
		foreach( $dirRemove as $dir ) {
579
			$dir = str_replace($searches, $replacements, $dir);
580
			$dir = WB_PATH.'/'.$dir;
581
			if( is_dir( $dir )) {
582
			// try to delete dir
583
				if(!rm_full_dir($dir)) {
584
				// save in err-list, if failed
585
					$msg .= $dir.'<br />';
586
				}
721 587
			}
722 588
		}
589
		if($msg != '') {
590
			$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
591
					can not be removed automatically.<br /><br />Please delete them
592
					using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
593
			status_msg($msg, 'error warning', 'div');
594
			echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
595
			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
596
			echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
597
			echo '</form>';
598
			echo '<br /><br /></div></body></html>';
599
			exit;
600
		}
723 601
	}
724
	if($msg != '')
725
	{
726
		$msg = '<br /><br />Following files are deprecated, outdated or a security risk and
727
			    can not be removed automatically.<br /><br />Please delete them
728
				using FTP and restart upgrade-script!<br /><br />'.$msg.'<br />';
729
        status_msg($msg, 'error warning', 'div');
730
		echo '<p style="font-size:120%;"><strong>WARNING: The upgrade script failed ...</strong></p>';
731 602

  
732
		echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
733
		echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
734
		echo '</form>';
735
		echo '<br /><br /></div></body></html>';
736
		exit;
603
/**********************************************************
604
 * upgrade modules if newer version is available
605
 */
606
	$aModuleList = array('news');
607
	foreach($aModuleList as $sModul) {
608
		if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
609
			$currModulVersion = get_modul_version ($sModul, false);
610
			$newModulVersion =  get_modul_version ($sModul, true);
611
			if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
612
				echo '<h2>Step '.(++$stepID).' : Upgrade module \''.$sModul.'\' to version '.$newModulVersion.'</h2>';
613
				require_once(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
614
			}
615
		}
737 616
	}
738

  
739
}
740

  
741
?>
742
<h2>Step <?php echo (++$stepID) ?> : Reload all addons database entry (no upgrade)</h2>
743
<?php
744 617
/**********************************************************
745 618
 *  - Reload all addons
746 619
 */
747 620

  
748
////delete modules
749
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
750
// Load all modules
751
if( ($handle = opendir(WB_PATH.'/modules/')) ) {
752
	while(false !== ($file = readdir($handle))) {
753
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
754
			load_module(WB_PATH.'/modules/'.$file );
755
		   // 	upgrade_module($file, true);
621
	echo '<h2>Step '.(++$stepID).' : Reload all addons database entry (no upgrade)</h2>';
622
	////delete modules
623
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'module'");
624
	// Load all modules
625
	if( ($handle = opendir(WB_PATH.'/modules/')) ) {
626
		while(false !== ($file = readdir($handle))) {
627
			if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
628
				load_module(WB_PATH.'/modules/'.$file );
629
			   // 	upgrade_module($file, true);
630
			}
756 631
		}
632
		closedir($handle);
757 633
	}
758
	closedir($handle);
759
}
760
echo '<br />Modules reloaded<br />';
634
	echo '<br />Modules reloaded<br />';
761 635

  
762
////delete templates
763
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
764
// Load all templates
765
if( ($handle = opendir(WB_PATH.'/templates/')) ) {
766
	while(false !== ($file = readdir($handle))) {
767
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
768
			load_template(WB_PATH.'/templates/'.$file);
636
	////delete templates
637
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'template'");
638
	// Load all templates
639
	if( ($handle = opendir(WB_PATH.'/templates/')) ) {
640
		while(false !== ($file = readdir($handle))) {
641
			if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
642
				load_template(WB_PATH.'/templates/'.$file);
643
			}
769 644
		}
645
		closedir($handle);
770 646
	}
771
	closedir($handle);
772
}
773
echo '<br />Templates reloaded<br />';
647
	echo '<br />Templates reloaded<br />';
774 648

  
775
////delete languages
776
//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
777
// Load all languages
778
if( ($handle = opendir(WB_PATH.'/languages/')) ) {
779
	while(false !== ($file = readdir($handle))) {
780
		if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
781
			load_language(WB_PATH.'/languages/'.$file);
649
	////delete languages
650
	//$database->query("DELETE FROM ".TABLE_PREFIX."addons WHERE type = 'language'");
651
	// Load all languages
652
	if( ($handle = opendir(WB_PATH.'/languages/')) ) {
653
		while(false !== ($file = readdir($handle))) {
654
			if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'index.php') {
655
				load_language(WB_PATH.'/languages/'.$file);
656
			}
782 657
		}
658
		closedir($handle);
783 659
	}
784
	closedir($handle);
785
}
786
echo '<br />Languages reloaded<br />';
660
	echo '<br />Languages reloaded<br />';
787 661

  
788 662
/**********************************************************
789 663
 *  - End of upgrade script
......
791 665

  
792 666
// require(WB_PATH.'/framework/initialize.php');
793 667

  
794
if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
795
if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
668
	if(!defined('DEFAULT_THEME')) { define('DEFAULT_THEME', $DEFAULT_THEME); }
669
	if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);}
796 670
/**********************************************************
797 671
 *  - Set Version to new Version
798 672
 */
799
echo '<br />Update database version number to '.VERSION.' '.SP.' '.' Revision ['.REVISION.'] : ';
800
// echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value`='".VERSION."' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />";
801
db_update_key_value('settings', 'wb_version', VERSION);
802
db_update_key_value('settings', 'wb_revision', REVISION);
803
db_update_key_value('settings', 'wb_sp', SP);
673
	echo '<br />Update database version number to '.VERSION.' '.SP.' '.' Revision ['.REVISION.'] : ';
674
	// echo ($database->query("UPDATE `".TABLE_PREFIX."settings` SET `value`='".VERSION."' WHERE `name` = 'wb_version'")) ? " $OK<br />" : " $FAIL<br />";
675
	db_update_key_value('settings', 'wb_version', VERSION);
676
	db_update_key_value('settings', 'wb_revision', REVISION);
677
	db_update_key_value('settings', 'wb_sp', SP);
804 678

  
805
echo '<p style="font-size:120%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
806
status_msg('<strong>Warning:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
807
// show buttons to go to the backend or frontend
808
echo '<br />';
679
	echo '<p style="font-size:120%;"><strong>Congratulations: The upgrade script is finished ...</strong></p>';
680
	status_msg('<strong>Warning:</strong><br />Please delete the file <strong>upgrade-script.php</strong> via FTP before proceeding.', 'warning', 'div');
681
	// show buttons to go to the backend or frontend
682
	echo '<br />';
809 683

  
810
if(defined('WB_URL')) {
811
	echo '<form action="'.WB_URL.'/">';
812
	echo '&nbsp;<input type="submit" value="kick me to the Frontend" />';
813
	echo '</form>';
814
}
815
if(defined('ADMIN_URL')) {
816
	echo '<form action="'.ADMIN_URL.'/">';
817
	echo '&nbsp;<input type="submit" value="kick me to the Backend" />';
818
	echo '</form>';
819
}
684
	if(defined('WB_URL')) {
685
		echo '<form action="'.WB_URL.'/">';
686
		echo '&nbsp;<input type="submit" value="kick me to the Frontend" />';
687
		echo '</form>';
688
	}
689
	if(defined('ADMIN_URL')) {
690
		echo '<form action="'.ADMIN_URL.'/">';
691
		echo '&nbsp;<input type="submit" value="kick me to the Backend" />';
692
		echo '</form>';
693
	}
820 694

  
821
?><br /><br />
822
</div>
823
</body>
824
</html>
695
	echo '<br /><br /></div></body></html>';
branches/2.8.x/wb/admin/interface/version.php
32 32
 * @category     	admin
33 33
 * @package      	interface
34 34
 * @author          WebsiteBaker Project
35
 * @copyright       2004-2009, Ryan Djurovich
36 35
 * @copyright       2009-2011, Website Baker Org. e.V.
37 36
 * @link			http://www.websitebaker2.org/
38 37
 * @license         http://www.gnu.org/licenses/gpl.html
......
52 51

  
53 52
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
54 53
if(!defined('VERSION')) define('VERSION', '2.8.2');
55
if(!defined('REVISION')) define('REVISION', '1587');
54
if(!defined('REVISION')) define('REVISION', '1588');
56 55
if(!defined('SP')) define('SP', 'SP2');

Also available in: Unified diff