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