| 
      1
     | 
    
      <?php
 
     | 
  
  
    | 
      2
     | 
    
      /****************************************************************************
 
     | 
  
  
    | 
      3
     | 
    
      * SVN Version information:
 
     | 
  
  
    | 
      4
     | 
    
      *
 
     | 
  
  
    | 
      5
     | 
    
      * $Id: admin.php 1224 2009-12-28 03:50:04Z Luisehahne $
 
     | 
  
  
    | 
      6
     | 
    
      *
 
     | 
  
  
    | 
      7
     | 
    
      *****************************************************************************
 
     | 
  
  
    | 
      8
     | 
    
      *                          WebsiteBaker
 
     | 
  
  
    | 
      9
     | 
    
      *
 
     | 
  
  
    | 
      10
     | 
    
      * WebsiteBaker Project <http://www.websitebaker2.org/>
 
     | 
  
  
    | 
      11
     | 
    
      * Copyright (C) 2009, Website Baker Org. e.V.
 
     | 
  
  
    | 
      12
     | 
    
      *         http://start.websitebaker2.org/impressum-datenschutz.php
 
     | 
  
  
    | 
      13
     | 
    
      * Copyright (C) 2004-2009, Ryan Djurovich
 
     | 
  
  
    | 
      14
     | 
    
      *
 
     | 
  
  
    | 
      15
     | 
    
      *                        About WebsiteBaker
 
     | 
  
  
    | 
      16
     | 
    
      *
 
     | 
  
  
    | 
      17
     | 
    
      * Website Baker is a PHP-based Content Management System (CMS)
 
     | 
  
  
    | 
      18
     | 
    
      * designed with one goal in mind: to enable its users to produce websites
 
     | 
  
  
    | 
      19
     | 
    
      * with ease.
 
     | 
  
  
    | 
      20
     | 
    
      *
 
     | 
  
  
    | 
      21
     | 
    
      *****************************************************************************
 
     | 
  
  
    | 
      22
     | 
    
      *
 
     | 
  
  
    | 
      23
     | 
    
      *****************************************************************************
 
     | 
  
  
    | 
      24
     | 
    
      *                        LICENSE INFORMATION
 
     | 
  
  
    | 
      25
     | 
    
      *
 
     | 
  
  
    | 
      26
     | 
    
      * WebsiteBaker is free software; you can redistribute it and/or
 
     | 
  
  
    | 
      27
     | 
    
      * modify it under the terms of the GNU General Public License
 
     | 
  
  
    | 
      28
     | 
    
      * as published by the Free Software Foundation; either version 2
 
     | 
  
  
    | 
      29
     | 
    
      * of the License, or (at your option) any later version.
 
     | 
  
  
    | 
      30
     | 
    
      *
 
     | 
  
  
    | 
      31
     | 
    
      * WebsiteBaker is distributed in the hope that it will be useful,
 
     | 
  
  
    | 
      32
     | 
    
      * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
     | 
  
  
    | 
      33
     | 
    
      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
     | 
  
  
    | 
      34
     | 
    
      * See the GNU General Public License for more details.
 
     | 
  
  
    | 
      35
     | 
    
      *
 
     | 
  
  
    | 
      36
     | 
    
      * You should have received a copy of the GNU General Public License
 
     | 
  
  
    | 
      37
     | 
    
      * along with this program; if not, write to the Free Software
 
     | 
  
  
    | 
      38
     | 
    
      * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
     | 
  
  
    | 
      39
     | 
    
      ****************************************************************************
 
     | 
  
  
    | 
      40
     | 
    
      *
 
     | 
  
  
    | 
      41
     | 
    
      *                   WebsiteBaker Extra Information
 
     | 
  
  
    | 
      42
     | 
    
      *
 
     | 
  
  
    | 
      43
     | 
    
      *
 
     | 
  
  
    | 
      44
     | 
    
      *
 
     | 
  
  
    | 
      45
     | 
    
      *
 
     | 
  
  
    | 
      46
     | 
    
      *****************************************************************************/
 
     | 
  
  
    | 
      47
     | 
    
      /**
 
     | 
  
  
    | 
      48
     | 
    
       *
 
     | 
  
  
    | 
      49
     | 
    
       * @category     backend
 
     | 
  
  
    | 
      50
     | 
    
       * @package      modules
 
     | 
  
  
    | 
      51
     | 
    
       * @author       Ryan Djurovich
 
     | 
  
  
    | 
      52
     | 
    
       * @copyright    2004-2009, Ryan Djurovich
 
     | 
  
  
    | 
      53
     | 
    
       * @copyright    2009, Website Baker Org. e.V.
 
     | 
  
  
    | 
      54
     | 
    
       * @version      $Id: admin.php 1224 2009-12-28 03:50:04Z Luisehahne $
 
     | 
  
  
    | 
      55
     | 
    
       * @platform     WebsiteBaker 2.8.x
 
     | 
  
  
    | 
      56
     | 
    
       * @requirements >= PHP 4.3.4
 
     | 
  
  
    | 
      57
     | 
    
       * @license      http://www.gnu.org/licenses/gpl.html
 
     | 
  
  
    | 
      58
     | 
    
       *
 
     | 
  
  
    | 
      59
     | 
    
       */
 
     | 
  
  
    | 
      60
     | 
    
      
 
     | 
  
  
    | 
      61
     | 
    
      // Stop this file being access directly
 
     | 
  
  
    | 
      62
     | 
    
      if(!defined('WB_URL')) {
     | 
  
  
    | 
      63
     | 
    
      	header('Location: ../index.php');
     | 
  
  
    | 
      64
     | 
    
      	exit(0);
 
     | 
  
  
    | 
      65
     | 
    
      }
 
     | 
  
  
    | 
      66
     | 
    
      
 
     | 
  
  
    | 
      67
     | 
    
      // Get page id
 
     | 
  
  
    | 
      68
     | 
    
      if(isset($_GET['page_id']) AND is_numeric($_GET['page_id'])) {
     | 
  
  
    | 
      69
     | 
    
      	$page_id = $_GET['page_id'];
 
     | 
  
  
    | 
      70
     | 
    
      } elseif(isset($_POST['page_id']) AND is_numeric($_POST['page_id'])) {
     | 
  
  
    | 
      71
     | 
    
      	$page_id = $_POST['page_id'];
 
     | 
  
  
    | 
      72
     | 
    
      } else {
     | 
  
  
    | 
      73
     | 
    
      	header("Location: index.php");
     | 
  
  
    | 
      74
     | 
    
      	exit(0);
 
     | 
  
  
    | 
      75
     | 
    
      }
 
     | 
  
  
    | 
      76
     | 
    
      
 
     | 
  
  
    | 
      77
     | 
    
      // Get section id if there is one
 
     | 
  
  
    | 
      78
     | 
    
      if(isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) {
     | 
  
  
    | 
      79
     | 
    
      	$section_id = $_GET['section_id'];
 
     | 
  
  
    | 
      80
     | 
    
      } elseif(isset($_POST['section_id']) AND is_numeric($_POST['section_id'])) {
     | 
  
  
    | 
      81
     | 
    
      	$section_id = $_POST['section_id'];
 
     | 
  
  
    | 
      82
     | 
    
      } else {
     | 
  
  
    | 
      83
     | 
    
      	// Check if we should redirect the user if there is no section id
 
     | 
  
  
    | 
      84
     | 
    
      	if(!isset($section_required)) {
     | 
  
  
    | 
      85
     | 
    
      		$section_id = 0;
 
     | 
  
  
    | 
      86
     | 
    
      	} else {
     | 
  
  
    | 
      87
     | 
    
      		header("Location: $section_required");
     | 
  
  
    | 
      88
     | 
    
      		exit(0);
 
     | 
  
  
    | 
      89
     | 
    
      	}
 
     | 
  
  
    | 
      90
     | 
    
      }
 
     | 
  
  
    | 
      91
     | 
    
      
 
     | 
  
  
    | 
      92
     | 
    
      // Create js back link
 
     | 
  
  
    | 
      93
     | 
    
      $js_back = 'javascript: history.go(-1);';
 
     | 
  
  
    | 
      94
     | 
    
      
 
     | 
  
  
    | 
      95
     | 
    
      // Create new admin object
 
     | 
  
  
    | 
      96
     | 
    
      require(WB_PATH.'/framework/class.admin.php');
 
     | 
  
  
    | 
      97
     | 
    
      $admin = new admin('Pages', 'pages_modify');
     | 
  
  
    | 
      98
     | 
    
      
 
     | 
  
  
    | 
      99
     | 
    
      // Get perms
 
     | 
  
  
    | 
      100
     | 
    
      $database = new database();
 
     | 
  
  
    | 
      101
     | 
    
      $results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
     | 
  
  
    | 
      102
     | 
    
      $results_array = $results->fetchRow();
 
     | 
  
  
    | 
      103
     | 
    
      $old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
     | 
  
  
    | 
      104
     | 
    
      $old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
     | 
  
  
    | 
      105
     | 
    
      
 
     | 
  
  
    | 
      106
     | 
    
      $in_group = FALSE;
 
     | 
  
  
    | 
      107
     | 
    
      foreach($admin->get_groups_id() as $cur_gid){
     | 
  
  
    | 
      108
     | 
    
          if (in_array($cur_gid, $old_admin_groups)) {
     | 
  
  
    | 
      109
     | 
    
              $in_group = TRUE;
 
     | 
  
  
    | 
      110
     | 
    
          }
 
     | 
  
  
    | 
      111
     | 
    
      }
 
     | 
  
  
    | 
      112
     | 
    
      if((!$in_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
     | 
  
  
    | 
      113
     | 
    
      	echo $admin->get_group_id().$admin->get_user_id();
 
     | 
  
  
    | 
      114
     | 
    
      	print_r ($old_admin_groups);
 
     | 
  
  
    | 
      115
     | 
    
      	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
 
     | 
  
  
    | 
      116
     | 
    
      }
 
     | 
  
  
    | 
      117
     | 
    
      
 
     | 
  
  
    | 
      118
     | 
    
      // Workout if the developer wants to show the info banner
 
     | 
  
  
    | 
      119
     | 
    
      if(isset($print_info_banner) AND $print_info_banner == true) {
     | 
  
  
    | 
      120
     | 
    
      	
 
     | 
  
  
    | 
      121
     | 
    
      // Get page details
 
     | 
  
  
    | 
      122
     | 
    
      $database = new database();
 
     | 
  
  
    | 
      123
     | 
    
      $query = "SELECT page_id,page_title,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
 
     | 
  
  
    | 
      124
     | 
    
      $results = $database->query($query);
 
     | 
  
  
    | 
      125
     | 
    
      if($database->is_error()) {
     | 
  
  
    | 
      126
     | 
    
      	$admin->print_header();
 
     | 
  
  
    | 
      127
     | 
    
      	$admin->print_error($database->get_error());
 
     | 
  
  
    | 
      128
     | 
    
      }
 
     | 
  
  
    | 
      129
     | 
    
      if($results->numRows() == 0) {
     | 
  
  
    | 
      130
     | 
    
      	$admin->print_header();
 
     | 
  
  
    | 
      131
     | 
    
      	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
 
     | 
  
  
    | 
      132
     | 
    
      }
 
     | 
  
  
    | 
      133
     | 
    
      $results_array = $results->fetchRow();
 
     | 
  
  
    | 
      134
     | 
    
      
 
     | 
  
  
    | 
      135
     | 
    
      // Get display name of person who last modified the page
 
     | 
  
  
    | 
      136
     | 
    
      $user=$admin->get_user_details($results_array['modified_by']);
 
     | 
  
  
    | 
      137
     | 
    
      
 
     | 
  
  
    | 
      138
     | 
    
      // Convert the unix ts for modified_when to human a readable form
 
     | 
  
  
    | 
      139
     | 
    
      if($results_array['modified_when'] != 0) {
     | 
  
  
    | 
      140
     | 
    
      	$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
 
     | 
  
  
    | 
      141
     | 
    
      } else {
     | 
  
  
    | 
      142
     | 
    
      	$modified_ts = 'Unknown';
 
     | 
  
  
    | 
      143
     | 
    
      }
 
     | 
  
  
    | 
      144
     | 
    
      
 
     | 
  
  
    | 
      145
     | 
    
      // Include page info script
 
     | 
  
  
    | 
      146
     | 
    
      $template = new Template(THEME_PATH.'/templates');
 
     | 
  
  
    | 
      147
     | 
    
      $template->set_file('page', 'pages_modify.htt');
     | 
  
  
    | 
      148
     | 
    
      $template->set_block('page', 'main_block', 'main');
     | 
  
  
    | 
      149
     | 
    
      $template->set_var(array(
 
     | 
  
  
    | 
      150
     | 
    
      								'PAGE_ID' => $results_array['page_id'],
 
     | 
  
  
    | 
      151
     | 
    
      								'PAGE_TITLE' => ($results_array['page_title']),
 
     | 
  
  
    | 
      152
     | 
    
      								'MODIFIED_BY' => $user['display_name'],
 
     | 
  
  
    | 
      153
     | 
    
      								'MODIFIED_BY_USERNAME' => $user['username'],
 
     | 
  
  
    | 
      154
     | 
    
      								'MODIFIED_WHEN' => $modified_ts,
 
     | 
  
  
    | 
      155
     | 
    
      								'ADMIN_URL' => ADMIN_URL
 
     | 
  
  
    | 
      156
     | 
    
      								)
 
     | 
  
  
    | 
      157
     | 
    
      						);
 
     | 
  
  
    | 
      158
     | 
    
      if($modified_ts == 'Unknown') {
     | 
  
  
    | 
      159
     | 
    
      	$template->set_var('DISPLAY_MODIFIED', 'hide');
     | 
  
  
    | 
      160
     | 
    
      } else {
     | 
  
  
    | 
      161
     | 
    
      	$template->set_var('DISPLAY_MODIFIED', '');
     | 
  
  
    | 
      162
     | 
    
      }
 
     | 
  
  
    | 
      163
     | 
    
      
 
     | 
  
  
    | 
      164
     | 
    
      // Work-out if we should show the "manage sections" link
 
     | 
  
  
    | 
      165
     | 
    
      $query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
     | 
  
  
    | 
      166
     | 
    
      if($query_sections->numRows() > 0) {
     | 
  
  
    | 
      167
     | 
    
      	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
     | 
  
  
    | 
      168
     | 
    
      } elseif(MANAGE_SECTIONS == 'enabled') {
     | 
  
  
    | 
      169
     | 
    
      	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
     | 
  
  
    | 
      170
     | 
    
      } else {
     | 
  
  
    | 
      171
     | 
    
      	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
     | 
  
  
    | 
      172
     | 
    
      }
 
     | 
  
  
    | 
      173
     | 
    
      
 
     | 
  
  
    | 
      174
     | 
    
      // Insert language TEXT
 
     | 
  
  
    | 
      175
     | 
    
      $template->set_var(array(
 
     | 
  
  
    | 
      176
     | 
    
      								'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
 
     | 
  
  
    | 
      177
     | 
    
      								'TEXT_CHANGE' => $TEXT['CHANGE'],
 
     | 
  
  
    | 
      178
     | 
    
      								'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
 
     | 
  
  
    | 
      179
     | 
    
      								'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
 
     | 
  
  
    | 
      180
     | 
    
      								'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
 
     | 
  
  
    | 
      181
     | 
    
      								)
 
     | 
  
  
    | 
      182
     | 
    
      						);
 
     | 
  
  
    | 
      183
     | 
    
      
 
     | 
  
  
    | 
      184
     | 
    
      // Parse and print header template
 
     | 
  
  
    | 
      185
     | 
    
      $template->parse('main', 'main_block', false);
     | 
  
  
    | 
      186
     | 
    
      $template->pparse('output', 'page');
     | 
  
  
    | 
      187
     | 
    
      
 
     | 
  
  
    | 
      188
     | 
    
      }
 
     | 
  
  
    | 
      189
     | 
    
      
 
     | 
  
  
    | 
      190
     | 
    
      // Work-out if the developer wants us to update the timestamp for when the page was last modified
 
     | 
  
  
    | 
      191
     | 
    
      if(isset($update_when_modified) AND $update_when_modified == true) {
     | 
  
  
    | 
      192
     | 
    
      	$database->query("UPDATE ".TABLE_PREFIX."pages SET modified_when = '".time()."', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'");
     | 
  
  
    | 
      193
     | 
    
      }
 
     | 
  
  
    | 
      194
     | 
    
      
 
     | 
  
  
    | 
      195
     | 
    
      ?>
 
     |