| 1 | 
        
            238
         | 
        
            stefan
         | 
        <?php
  | 
      
      
        | 2 | 
        
         | 
        
         | 
        
  | 
      
      
        | 3 | 
        
         | 
        
         | 
        // $Id$
  | 
      
      
        | 4 | 
        
         | 
        
         | 
        
  | 
      
      
        | 5 | 
        
         | 
        
         | 
        /*
  | 
      
      
        | 6 | 
        
         | 
        
         | 
        
  | 
      
      
        | 7 | 
        
         | 
        
         | 
         Website Baker Project <http://www.websitebaker.org/>
  | 
      
      
        | 8 | 
        
            310
         | 
        
            ryan
         | 
         Copyright (C) 2004-2006, 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 | 
        
            4
         | 
        
            ryan
         | 
        // Get page id
  | 
      
      
        | 36 | 
        
            238
         | 
        
            stefan
         | 
        if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
 | 
      
      
        | 37 | 
        
         | 
        
         | 
        	header("Location: index.php");
 | 
      
      
        | 38 | 
        
            286
         | 
        
            stefan
         | 
        	exit(0);
  | 
      
      
        | 39 | 
        
            238
         | 
        
            stefan
         | 
        } else {
 | 
      
      
        | 40 | 
        
         | 
        
         | 
        	$page_id = $_GET['page_id'];
  | 
      
      
        | 41 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 42 | 
        
         | 
        
         | 
        
  | 
      
      
        | 43 | 
        
            4
         | 
        
            ryan
         | 
        // Create new admin object
  | 
      
      
        | 44 | 
        
            238
         | 
        
            stefan
         | 
        require_once(WB_PATH.'/framework/class.admin.php');
  | 
      
      
        | 45 | 
        
         | 
        
         | 
        $admin = new admin('Pages', 'pages_modify');
 | 
      
      
        | 46 | 
        
         | 
        
         | 
        
  | 
      
      
        | 47 | 
        
            4
         | 
        
            ryan
         | 
        // Get perms
  | 
      
      
        | 48 | 
        
            238
         | 
        
            stefan
         | 
        $database = new database();
  | 
      
      
        | 49 | 
        
         | 
        
         | 
        $results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
 | 
      
      
        | 50 | 
        
         | 
        
         | 
        $results_array = $results->fetchRow();
  | 
      
      
        | 51 | 
        
         | 
        
         | 
        $old_admin_groups = explode(',', $results_array['admin_groups']);
 | 
      
      
        | 52 | 
        
         | 
        
         | 
        $old_admin_users = explode(',', $results_array['admin_users']);
 | 
      
      
        | 53 | 
        
         | 
        
         | 
        if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
 | 
      
      
        | 54 | 
        
         | 
        
         | 
        	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
  | 
      
      
        | 55 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 56 | 
        
         | 
        
         | 
        
  | 
      
      
        | 57 | 
        
            4
         | 
        
            ryan
         | 
        // Get page details
  | 
      
      
        | 58 | 
        
            238
         | 
        
            stefan
         | 
        $database = new database();
  | 
      
      
        | 59 | 
        
         | 
        
         | 
        $query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
  | 
      
      
        | 60 | 
        
         | 
        
         | 
        $results = $database->query($query);
  | 
      
      
        | 61 | 
        
         | 
        
         | 
        if($database->is_error()) {
 | 
      
      
        | 62 | 
        
         | 
        
         | 
        	$admin->print_header();
  | 
      
      
        | 63 | 
        
         | 
        
         | 
        	$admin->print_error($database->get_error());
  | 
      
      
        | 64 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 65 | 
        
         | 
        
         | 
        if($results->numRows() == 0) {
 | 
      
      
        | 66 | 
        
         | 
        
         | 
        	$admin->print_header();
  | 
      
      
        | 67 | 
        
         | 
        
         | 
        	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
  | 
      
      
        | 68 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 69 | 
        
         | 
        
         | 
        $results_array = $results->fetchRow();
  | 
      
      
        | 70 | 
        
         | 
        
         | 
        
  | 
      
      
        | 71 | 
        
            4
         | 
        
            ryan
         | 
        // Set module permissions
  | 
      
      
        | 72 | 
        
            238
         | 
        
            stefan
         | 
        $module_permissions = $_SESSION['MODULE_PERMISSIONS'];
  | 
      
      
        | 73 | 
        
         | 
        
         | 
        
  | 
      
      
        | 74 | 
        
            4
         | 
        
            ryan
         | 
        // Loop through sections
  | 
      
      
        | 75 | 
        
            238
         | 
        
            stefan
         | 
        $query_sections = $database->query("SELECT section_id,module,position FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
 | 
      
      
        | 76 | 
        
         | 
        
         | 
        if($query_sections->numRows() > 0) {
 | 
      
      
        | 77 | 
        
         | 
        
         | 
        	$num_sections = $query_sections->numRows();
  | 
      
      
        | 78 | 
        
         | 
        
         | 
        	while($section = $query_sections->fetchRow()) {
 | 
      
      
        | 79 | 
        
            4
         | 
        
            ryan
         | 
        		// Get the modules real name
  | 
      
      
        | 80 | 
        
            238
         | 
        
            stefan
         | 
        		$module_path = WB_PATH.'/modules/'.$section['module'].'/info.php';
  | 
      
      
        | 81 | 
        
         | 
        
         | 
        		if(file_exists($module_path)) {
 | 
      
      
        | 82 | 
        
         | 
        
         | 
        			require($module_path);
  | 
      
      
        | 83 | 
        
         | 
        
         | 
        			if(!isset($module_function)) { $module_function = 'unknown'; }
 | 
      
      
        | 84 | 
        
            169
         | 
        
            ryan
         | 
        			if(!is_numeric(array_search($section['module'], $module_permissions)) AND $module_function == 'page') {
 | 
      
      
        | 85 | 
        
            4
         | 
        
            ryan
         | 
        				// Update the section record with properties
  | 
      
      
        | 86 | 
        
         | 
        
         | 
        				$section_id = $section['section_id'];
  | 
      
      
        | 87 | 
        
         | 
        
         | 
        				$sql = '';
  | 
      
      
        | 88 | 
        
         | 
        
         | 
        				if(isset($_POST['block'.$section_id]) AND $_POST['block'.$section_id] != '') {
 | 
      
      
        | 89 | 
        
            40
         | 
        
            stefan
         | 
        					$sql = "block = '".$admin->add_slashes($_POST['block'.$section_id])."'";
  | 
      
      
        | 90 | 
        
            4
         | 
        
            ryan
         | 
        					$query = "UPDATE ".TABLE_PREFIX."sections SET $sql WHERE section_id = '$section_id' LIMIT 1";
  | 
      
      
        | 91 | 
        
         | 
        
         | 
        					if($sql != '') {
 | 
      
      
        | 92 | 
        
         | 
        
         | 
        						$database->query($query);
  | 
      
      
        | 93 | 
        
         | 
        
         | 
        					}
  | 
      
      
        | 94 | 
        
            238
         | 
        
            stefan
         | 
        				}
  | 
      
      
        | 95 | 
        
         | 
        
         | 
        			}
  | 
      
      
        | 96 | 
        
            169
         | 
        
            ryan
         | 
        			if(isset($module_function)) { unset($module_function); } // Unset module type
 | 
      
      
        | 97 | 
        
            238
         | 
        
            stefan
         | 
        		}
  | 
      
      
        | 98 | 
        
         | 
        
         | 
        	}
  | 
      
      
        | 99 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 100 | 
        
         | 
        
         | 
        // Check for error or print success message
  | 
      
      
        | 101 | 
        
            4
         | 
        
            ryan
         | 
        if($database->is_error()) {
 | 
      
      
        | 102 | 
        
         | 
        
         | 
        	$admin->print_error($database->get_error(), ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
  | 
      
      
        | 103 | 
        
         | 
        
         | 
        } else {
 | 
      
      
        | 104 | 
        
         | 
        
         | 
        	$admin->print_success($MESSAGE['PAGES']['SECTIONS_PROPERTIES_SAVED'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
  | 
      
      
        | 105 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 106 | 
        
            238
         | 
        
            stefan
         | 
        
  | 
      
      
        | 107 | 
        
            4
         | 
        
            ryan
         | 
        // Print admin footer
  | 
      
      
        | 108 | 
        
            238
         | 
        
            stefan
         | 
        $admin->print_footer();
  | 
      
      
        | 109 | 
        
         | 
        
         | 
        
  | 
      
      
        | 110 | 
        
            239
         | 
        
            stefan
         | 
        ?>
  |