| 1 | 
        
            238
         | 
        
            stefan
         | 
        <?php
  | 
      
      
        | 2 | 
        
         | 
        
         | 
        
  | 
      
      
        | 3 | 
        
         | 
        
         | 
        // $Id$
  | 
      
      
        | 4 | 
        
         | 
        
         | 
        
  | 
      
      
        | 5 | 
        
         | 
        
         | 
        /*
  | 
      
      
        | 6 | 
        
         | 
        
         | 
        
  | 
      
      
        | 7 | 
        
         | 
        
         | 
         Website Baker Project <http://www.websitebaker.org/>
  | 
      
      
        | 8 | 
        
            519
         | 
        
            Ruebenwurz
         | 
         Copyright (C) 2004-2008, Ryan Djurovich
  | 
      
      
        | 9 | 
        
            238
         | 
        
            stefan
         | 
        
  | 
      
      
        | 10 | 
        
         | 
        
         | 
         Website Baker is free software; you can redistribute it and/or modify
  | 
      
      
        | 11 | 
        
         | 
        
         | 
         it under the terms of the GNU General Public License as published by
  | 
      
      
        | 12 | 
        
         | 
        
         | 
         the Free Software Foundation; either version 2 of the License, or
  | 
      
      
        | 13 | 
        
         | 
        
         | 
         (at your option) any later version.
  | 
      
      
        | 14 | 
        
         | 
        
         | 
        
  | 
      
      
        | 15 | 
        
         | 
        
         | 
         Website Baker is distributed in the hope that it will be useful,
  | 
      
      
        | 16 | 
        
         | 
        
         | 
         but WITHOUT ANY WARRANTY; without even the implied warranty of
  | 
      
      
        | 17 | 
        
         | 
        
         | 
         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  | 
      
      
        | 18 | 
        
         | 
        
         | 
         GNU General Public License for more details.
  | 
      
      
        | 19 | 
        
         | 
        
         | 
        
  | 
      
      
        | 20 | 
        
         | 
        
         | 
         You should have received a copy of the GNU General Public License
  | 
      
      
        | 21 | 
        
         | 
        
         | 
         along with Website Baker; if not, write to the Free Software
  | 
      
      
        | 22 | 
        
         | 
        
         | 
         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  | 
      
      
        | 23 | 
        
         | 
        
         | 
        
  | 
      
      
        | 24 | 
        
         | 
        
         | 
        */
  | 
      
      
        | 25 | 
        
         | 
        
         | 
        
  | 
      
      
        | 26 | 
        
            4
         | 
        
            ryan
         | 
        // Include config file
  | 
      
      
        | 27 | 
        
            238
         | 
        
            stefan
         | 
        require('../../config.php');
 | 
      
      
        | 28 | 
        
         | 
        
         | 
        
  | 
      
      
        | 29 | 
        
            4
         | 
        
            ryan
         | 
        // Make sure people are allowed to access this page
  | 
      
      
        | 30 | 
        
            238
         | 
        
            stefan
         | 
        if(MANAGE_SECTIONS != 'enabled') {
 | 
      
      
        | 31 | 
        
         | 
        
         | 
        	header('Location: '.ADMIN_URL.'/pages/index.php');
 | 
      
      
        | 32 | 
        
            286
         | 
        
            stefan
         | 
        	exit(0);
  | 
      
      
        | 33 | 
        
            238
         | 
        
            stefan
         | 
        }
  | 
      
      
        | 34 | 
        
         | 
        
         | 
        
  | 
      
      
        | 35 | 
        
            643
         | 
        
            thorn
         | 
        require_once(WB_PATH."/include/jscalendar/jscalendar-functions.php");
  | 
      
      
        | 36 | 
        
         | 
        
         | 
        
  | 
      
      
        | 37 | 
        
            4
         | 
        
            ryan
         | 
        // Get page id
  | 
      
      
        | 38 | 
        
            238
         | 
        
            stefan
         | 
        if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
 | 
      
      
        | 39 | 
        
         | 
        
         | 
        	header("Location: index.php");
 | 
      
      
        | 40 | 
        
            286
         | 
        
            stefan
         | 
        	exit(0);
  | 
      
      
        | 41 | 
        
            238
         | 
        
            stefan
         | 
        } else {
 | 
      
      
        | 42 | 
        
         | 
        
         | 
        	$page_id = $_GET['page_id'];
  | 
      
      
        | 43 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 44 | 
        
         | 
        
         | 
        
  | 
      
      
        | 45 | 
        
            4
         | 
        
            ryan
         | 
        // Create new admin object
  | 
      
      
        | 46 | 
        
            238
         | 
        
            stefan
         | 
        require_once(WB_PATH.'/framework/class.admin.php');
  | 
      
      
        | 47 | 
        
         | 
        
         | 
        $admin = new admin('Pages', 'pages_modify');
 | 
      
      
        | 48 | 
        
         | 
        
         | 
        
  | 
      
      
        | 49 | 
        
            4
         | 
        
            ryan
         | 
        // Get perms
  | 
      
      
        | 50 | 
        
            238
         | 
        
            stefan
         | 
        $database = new database();
  | 
      
      
        | 51 | 
        
         | 
        
         | 
        $results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
 | 
      
      
        | 52 | 
        
         | 
        
         | 
        $results_array = $results->fetchRow();
  | 
      
      
        | 53 | 
        
         | 
        
         | 
        $old_admin_groups = explode(',', $results_array['admin_groups']);
 | 
      
      
        | 54 | 
        
         | 
        
         | 
        $old_admin_users = explode(',', $results_array['admin_users']);
 | 
      
      
        | 55 | 
        
            546
         | 
        
            doc
         | 
        $in_old_group = FALSE;
  | 
      
      
        | 56 | 
        
         | 
        
         | 
        foreach($admin->get_groups_id() as $cur_gid){
 | 
      
      
        | 57 | 
        
         | 
        
         | 
            if (in_array($cur_gid, $old_admin_groups)) {
 | 
      
      
        | 58 | 
        
         | 
        
         | 
                $in_old_group = TRUE;
  | 
      
      
        | 59 | 
        
         | 
        
         | 
            }
  | 
      
      
        | 60 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 61 | 
        
         | 
        
         | 
        if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
 | 
      
      
        | 62 | 
        
            238
         | 
        
            stefan
         | 
        	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
  | 
      
      
        | 63 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 64 | 
        
         | 
        
         | 
        
  | 
      
      
        | 65 | 
        
            4
         | 
        
            ryan
         | 
        // Get page details
  | 
      
      
        | 66 | 
        
            238
         | 
        
            stefan
         | 
        $database = new database();
  | 
      
      
        | 67 | 
        
         | 
        
         | 
        $query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
  | 
      
      
        | 68 | 
        
         | 
        
         | 
        $results = $database->query($query);
  | 
      
      
        | 69 | 
        
         | 
        
         | 
        if($database->is_error()) {
 | 
      
      
        | 70 | 
        
         | 
        
         | 
        	$admin->print_header();
  | 
      
      
        | 71 | 
        
         | 
        
         | 
        	$admin->print_error($database->get_error());
  | 
      
      
        | 72 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 73 | 
        
         | 
        
         | 
        if($results->numRows() == 0) {
 | 
      
      
        | 74 | 
        
         | 
        
         | 
        	$admin->print_header();
  | 
      
      
        | 75 | 
        
         | 
        
         | 
        	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
  | 
      
      
        | 76 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 77 | 
        
         | 
        
         | 
        $results_array = $results->fetchRow();
  | 
      
      
        | 78 | 
        
         | 
        
         | 
        
  | 
      
      
        | 79 | 
        
            4
         | 
        
            ryan
         | 
        // Set module permissions
  | 
      
      
        | 80 | 
        
            238
         | 
        
            stefan
         | 
        $module_permissions = $_SESSION['MODULE_PERMISSIONS'];
  | 
      
      
        | 81 | 
        
         | 
        
         | 
        
  | 
      
      
        | 82 | 
        
            4
         | 
        
            ryan
         | 
        // Loop through sections
  | 
      
      
        | 83 | 
        
            238
         | 
        
            stefan
         | 
        $query_sections = $database->query("SELECT section_id,module,position FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
 | 
      
      
        | 84 | 
        
         | 
        
         | 
        if($query_sections->numRows() > 0) {
 | 
      
      
        | 85 | 
        
         | 
        
         | 
        	$num_sections = $query_sections->numRows();
  | 
      
      
        | 86 | 
        
         | 
        
         | 
        	while($section = $query_sections->fetchRow()) {
 | 
      
      
        | 87 | 
        
            347
         | 
        
            stefan
         | 
        		if(!is_numeric(array_search($section['module'], $module_permissions))) {
 | 
      
      
        | 88 | 
        
         | 
        
         | 
        			// Update the section record with properties
  | 
      
      
        | 89 | 
        
         | 
        
         | 
        			$section_id = $section['section_id'];
  | 
      
      
        | 90 | 
        
            552
         | 
        
            thorn
         | 
        			$sql = ''; $publ_start = 0; $publ_end = 0;
  | 
      
      
        | 91 | 
        
         | 
        
         | 
        			$dst = date("I")?" DST":""; // daylight saving time?
 | 
      
      
        | 92 | 
        
            347
         | 
        
            stefan
         | 
        			if(isset($_POST['block'.$section_id]) AND $_POST['block'.$section_id] != '') {
 | 
      
      
        | 93 | 
        
         | 
        
         | 
        				$sql = "block = '".$admin->add_slashes($_POST['block'.$section_id])."'";
  | 
      
      
        | 94 | 
        
            552
         | 
        
            thorn
         | 
        			}
  | 
      
      
        | 95 | 
        
         | 
        
         | 
        			// update publ_start and publ_end, trying to make use of the strtotime()-features like "next week", "+1 month", ...
  | 
      
      
        | 96 | 
        
         | 
        
         | 
        			if(isset($_POST['start_date'.$section_id]) AND isset($_POST['end_date'.$section_id])) {
 | 
      
      
        | 97 | 
        
         | 
        
         | 
        				if(trim($_POST['start_date'.$section_id]) == '0' OR trim($_POST['start_date'.$section_id]) == '') {
 | 
      
      
        | 98 | 
        
         | 
        
         | 
        					$publ_start = 0;
  | 
      
      
        | 99 | 
        
         | 
        
         | 
        				} else {
 | 
      
      
        | 100 | 
        
            643
         | 
        
            thorn
         | 
        					$publ_start = jscalendar_to_timestamp($_POST['start_date'.$section_id]);
  | 
      
      
        | 101 | 
        
            238
         | 
        
            stefan
         | 
        				}
  | 
      
      
        | 102 | 
        
            552
         | 
        
            thorn
         | 
        				if(trim($_POST['end_date'.$section_id]) == '0' OR trim($_POST['end_date'.$section_id]) == '') {
 | 
      
      
        | 103 | 
        
         | 
        
         | 
        					$publ_end = 0;
  | 
      
      
        | 104 | 
        
         | 
        
         | 
        				} else {
 | 
      
      
        | 105 | 
        
            643
         | 
        
            thorn
         | 
        					$publ_end = jscalendar_to_timestamp($_POST['end_date'.$section_id], $publ_start);
  | 
      
      
        | 106 | 
        
            552
         | 
        
            thorn
         | 
        				}
  | 
      
      
        | 107 | 
        
         | 
        
         | 
        				if($sql != '')
  | 
      
      
        | 108 | 
        
         | 
        
         | 
        					$sql .= ",";
  | 
      
      
        | 109 | 
        
            656
         | 
        
            thorn
         | 
        				$sql .= " publ_start = '".$admin->add_slashes($publ_start)."'";
  | 
      
      
        | 110 | 
        
         | 
        
         | 
        				$sql .= ", publ_end = '".$admin->add_slashes($publ_end)."'";
  | 
      
      
        | 111 | 
        
            238
         | 
        
            stefan
         | 
        			}
  | 
      
      
        | 112 | 
        
            552
         | 
        
            thorn
         | 
        			$query = "UPDATE ".TABLE_PREFIX."sections SET $sql WHERE section_id = '$section_id' LIMIT 1";
  | 
      
      
        | 113 | 
        
         | 
        
         | 
        			if($sql != '') {
 | 
      
      
        | 114 | 
        
         | 
        
         | 
        				$database->query($query);
  | 
      
      
        | 115 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 116 | 
        
            238
         | 
        
            stefan
         | 
        		}
  | 
      
      
        | 117 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 118 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 119 | 
        
         | 
        
         | 
        // Check for error or print success message
  | 
      
      
        | 120 | 
        
            4
         | 
        
            ryan
         | 
        if($database->is_error()) {
 | 
      
      
        | 121 | 
        
         | 
        
         | 
        	$admin->print_error($database->get_error(), ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
  | 
      
      
        | 122 | 
        
         | 
        
         | 
        } else {
 | 
      
      
        | 123 | 
        
         | 
        
         | 
        	$admin->print_success($MESSAGE['PAGES']['SECTIONS_PROPERTIES_SAVED'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
  | 
      
      
        | 124 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 125 | 
        
            238
         | 
        
            stefan
         | 
        
  | 
      
      
        | 126 | 
        
            4
         | 
        
            ryan
         | 
        // Print admin footer
  | 
      
      
        | 127 | 
        
            238
         | 
        
            stefan
         | 
        $admin->print_footer();
  | 
      
      
        | 128 | 
        
         | 
        
         | 
        
  | 
      
      
        | 129 | 
        
            552
         | 
        
            thorn
         | 
        ?>
  |