Project

General

Profile

1 4 ryan
<?php
2
3 286 stefan
// $Id$
4 4 ryan
5
/*
6
7
 Website Baker Project <http://www.websitebaker.org/>
8 519 Ruebenwurz
 Copyright (C) 2004-2008, Ryan Djurovich
9 4 ryan
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
// Get page & section id
27
if(!isset($_POST['page_id']) OR !is_numeric($_POST['page_id'])) {
28
	header("Location: index.php");
29 286 stefan
	exit(0);
30 4 ryan
} else {
31
	$page_id = $_POST['page_id'];
32
}
33
if(!isset($_POST['section_id']) OR !is_numeric($_POST['section_id'])) {
34
	header("Location: index.php");
35 286 stefan
	exit(0);
36 4 ryan
} else {
37
	$section_id = $_POST['section_id'];
38
}
39
40
// Create new admin object
41
require('../../config.php');
42
require_once(WB_PATH.'/framework/class.admin.php');
43
$admin = new admin('Pages', 'pages_modify');
44
45
// Get perms
46
$database = new database();
47
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
48
$results_array = $results->fetchRow();
49
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
50
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
51
if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
52
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
53
}
54
55
// Get page module
56
$database = new database();
57
$query = "SELECT module FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
58
$results = $database->query($query);
59
if($database->is_error()) {
60
	$admin->print_error($database->get_error());
61
}
62
if($results->numRows() == 0) {
63
	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
64
}
65
$results_array = $results->fetchRow();
66
$module = $results_array['module'];
67
68
// Update the pages table
69
$now = mktime();
70
$query = "UPDATE ".TABLE_PREFIX."pages SET modified_when = '$now', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'";
71
$database->query($query);
72
73
// Include the modules saving script if it exists
74
if(file_exists(WB_PATH.'/modules/'.$module.'/save.php')) {
75
	require(WB_PATH.'/modules/'.$module.'/save.php');
76
}
77
78
// Check if there is a db error, otherwise say successful
79
if($database->is_error()) {
80
	$admin->print_error($database->get_error(), $js_back);
81
} else {
82
	$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
83
}
84
85
// Print admin footer
86
$admin->print_footer();
87
88
?>