Project

General

Profile

« Previous | Next » 

Revision 1782

Added by Dietmar almost 12 years ago

+ add maintance modus in backend

View differences:

class.wb.php
3 3
 *
4 4
 * @category        framework
5 5
 * @package         frontend
6
 * @author          Ryan Djurovich, WebsiteBaker Project
6
 * @author          Ryan Djurovich (2004-2009), WebsiteBaker Project
7 7
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8 8
 * @link			http://www.websitebaker2.org/
9 9
 * @license         http://www.gnu.org/licenses/gpl.html
......
31 31
{
32 32

  
33 33
 	public $password_chars = 'a-zA-Z0-9\_\-\!\#\*\+\@\$\&\:';	// General initialization function
34

  
34 35
	// performed when frontend or backend is loaded.
35

  
36 36
	public function  __construct($mode = SecureForm::FRONTEND) {
37 37
		parent::__construct($mode);
38 38
	}
39 39

  
40

  
41
	/**
42
	 *
43
	 *
44
	 * @param mixed $lang
45
	 * @param mixed $level
46
	 * @param mixed $parent
47
	 * @return
48
	 */
49
	public function GetLanguagesPages ( $lang, $level, $parent ) {
50
		global $database;
51
        $page = array();
52
        $sql =
53
        'SELECT `language`,`visibility`,`viewing_groups`,`viewing_users`,`language`,`position`, '.
54
        '`page_id`,`level`,`parent`,`root_parent`,`page_code`,`link` '.
55
        'FROM `'.TABLE_PREFIX.'pages` '.
56
        'WHERE `level`=\''.$level.'\' '.
57
          'AND `language`=\''.$lang['language'].'\' '.
58
          'AND `visibility`!=\'none\' '.
59
          'AND `visibility`!=\'hidden\' '.
60
          'AND `parent`=\''.$parent.'\' '.
61
          'AND `root_parent`=`page_id` '.
62
        'ORDER BY `position`';
63
        if($oPage = $database->query($sql))
64
        {
65
            $page = $oPage->fetchRow(MYSQL_ASSOC);
66
        }
67
        return $page;
68
	}
69

  
70
	/**
71
	 *
72
	 *
73
	 * @return
74
	 */
75
	public function GetLanguagesInUsed (  ) {
76
		global $database;
77
        $retVal = '';
78
        $page = array();
79
        $sql =
80
        'SELECT DISTINCT `language` '.
81
        'FROM `'.TABLE_PREFIX.'pages` '.
82
        'WHERE `level`= \'0\' '.
83
          'AND `visibility`!=\'none\' '.
84
          'AND `visibility`!=\'hidden\' '.
85
       'ORDER BY `position`';
86

  
87
        if($oRes = $database->query($sql))
88
        {
89
            while($lang = $oRes->fetchRow(MYSQL_ASSOC))
90
            {
91
                $page = $this->GetLanguagesPages ( $lang, 0, 0 );
92
                if(!$this->page_is_visible($page)) {continue;}
93
                $retVal .= $page['language'].',';
94
            }
95
        }
96
        return trim($retVal,',');
97
	}
98

  
99

  
40 100
/* ****************
41 101
 * check if one or more group_ids are in both group_lists
42 102
 *
......
429 489
		}
430 490
		return $retval;
431 491
	}
492
/*
493
 * @param string $type: 'locked'(default)  or 'new'
494
 * @return void: terminates application
495
 * @description: 'locked' >> Show maintenance screen and terminate, if system is locked
496
 *               'new' >> Show 'new site under construction'(former print_under_construction)
497
 */
498
	public function ShowMaintainScreen($type = 'locked')
499
	{
500
		global $database, $MESSAGE;
501
		$CHECK_BACK = $MESSAGE['GENERIC_PLEASE_CHECK_BACK_SOON'];
502
		$BE_PATIENT = '';
503
		$LANGUAGE   = strtolower((isset($_SESSION['LANGUAGE']) ? $_SESSION['LANGUAGE'] : LANGUAGE ));
432 504

  
505
		$show_screen = false;
506
		if($type == 'locked')
507
		{
508
			$curr_user = (intval(isset($_SESSION['USER_ID']) ? $_SESSION['USER_ID'] : 0) ) ;
509
			if( (defined('SYSTEM_LOCKED') && (int)SYSTEM_LOCKED == 1) && ($curr_user != 1))
510
			{
511
				header($_SERVER['SERVER_PROTOCOL'].' 503 Service Unavailable');
512
	// first kick logged users out of the system
513
		// delete all remember keys from table 'user' except user_id=1
514
				$sql  = 'UPDATE `'.TABLE_PREFIX.'users` SET `remember_key`=\'\' ';
515
				$sql .= 'WHERE `user_id`<>1';
516
				$database->query($sql);
517
		// delete remember key-cookie if set
518
				if (isset($_COOKIE['REMEMBER_KEY'])) {
519
					setcookie('REMEMBER_KEY', '', time() - 3600, '/');
520
				}
521
		// overwrite session array
522
				$_SESSION = array();
523
		// delete session cookie if set
524
				if (ini_get("session.use_cookies")) {
525
					$params = session_get_cookie_params();
526
					setcookie(session_name(), '', time() - 42000, $params["path"],
527
						$params["domain"], $params["secure"], $params["httponly"]
528
					);
529
				}
530
		// delete the session itself
531
				session_destroy();
532
				$PAGE_TITLE = $MESSAGE['GENERIC_WEBSITE_LOCKED'];
533
				$BE_PATIENT = $MESSAGE['GENERIC_BE_PATIENT'];
534
				$PAGE_ICON  = 'system';
535
				$show_screen = true;
536
			}
537
		} else {
538
			header($_SERVER['SERVER_PROTOCOL'].' 503 Service Unavailable');
539
			$PAGE_TITLE = $MESSAGE['GENERIC_WEBSITE_UNDER_CONSTRUCTION'];
540
			$PAGE_ICON  = 'negative';
541
			$show_screen = true;
542
		}
543
		if($show_screen)
544
		{
545
            $sMaintanceFile = $this->correct_theme_source('maintance.htt');
546
    		if(file_exists($sMaintanceFile))
547
    		{
548
                $tpl = new Template(dirname( $sMaintanceFile ));
549
    		    $tpl->set_file( 'page', 'maintance.htt' );
550
    		    $tpl->set_block( 'page', 'main_block', 'main' );
551

  
552
    			if(defined('DEFAULT_CHARSET'))
553
    			{
554
    				$charset=DEFAULT_CHARSET;
555
    			} else {
556
    				$charset='utf-8';
557
    			}
558
    		    $tpl->set_var( 'PAGE_TITLE', $MESSAGE['GENERIC_WEBSITE_UNDER_CONSTRUCTION'] );
559
    	 	    $tpl->set_var( 'CHECK_BACK', $MESSAGE['GENERIC_PLEASE_CHECK_BACK_SOON'] );
560
    	 	    $tpl->set_var( 'CHARSET', $charset );
561
    	 	    $tpl->set_var( 'WB_URL', WB_URL );
562
    	 	    $tpl->set_var( 'BE_PATIENT', $BE_PATIENT );
563
    	 	    $tpl->set_var( 'THEME_URL', THEME_URL );
564
    			$tpl->set_var( 'PAGE_ICON', $PAGE_ICON);
565
    			$tpl->set_var( 'LANGUAGE', strtolower(LANGUAGE));
566
    		    $tpl->parse( 'main', 'main_block', false );
567
    		    $tpl->pparse( 'output', 'page' );
568
                exit();
569
    		} else {
570
    		 require_once(WB_PATH.'/languages/'.DEFAULT_LANGUAGE.'.php');
571
    		echo '<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 TransitionalEN" "http:www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
572
    		<head><title>'.$MESSAGE['GENERIC_WEBSITE_UNDER_CONSTRUCTION'].'</title>
573
    		<style type="text/css"><!-- body{ font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 12px; background-image: url("'.WB_URL.'/templates/'.DEFAULT_THEME.'/images/background.png");background-repeat: repeat-x; background-color: #A8BCCB; text-align: center; }
574
    		h1 { margin: 0; padding: 0; font-size: 18px; color: #000; text-transform: uppercase;}--></style></head><body>
575
    		<br /><h1>'.$MESSAGE['GENERIC_WEBSITE_UNDER_CONSTRUCTION'].'</h1><br />
576
    		'.$MESSAGE['GENERIC_PLEASE_CHECK_BACK_SOON'].'</body></html>';
577
    		}
578
    		flush();
579
            exit();
580
		}
581
	}
582

  
433 583
	// Validate send email
434 584
	function mail($fromaddress, $toaddress, $subject, $message, $fromname='', $replyTo='') {
435 585
/*

Also available in: Unified diff