Project

General

Profile

1
<?php
2

    
3
// $Id: save.php 10 2005-09-04 08:59:31Z ryan $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, Ryan Djurovich
9

    
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
} else {
30
	$page_id = $_POST['page_id'];
31
}
32
if(!isset($_POST['section_id']) OR !is_numeric($_POST['section_id'])) {
33
	header("Location: index.php");
34
} else {
35
	$section_id = $_POST['section_id'];
36
}
37

    
38
// Create new admin object
39
require('../../config.php');
40
require_once(WB_PATH.'/framework/class.admin.php');
41
$admin = new admin('Pages', 'pages_modify');
42

    
43
// Get perms
44
$database = new database();
45
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
46
$results_array = $results->fetchRow();
47
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
48
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
49
if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
50
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
51
}
52

    
53
// Get page module
54
$database = new database();
55
$query = "SELECT module FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
56
$results = $database->query($query);
57
if($database->is_error()) {
58
	$admin->print_error($database->get_error());
59
}
60
if($results->numRows() == 0) {
61
	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
62
}
63
$results_array = $results->fetchRow();
64
$module = $results_array['module'];
65

    
66
// Update the pages table
67
$now = mktime();
68
$query = "UPDATE ".TABLE_PREFIX."pages SET modified_when = '$now', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'";
69
$database->query($query);
70

    
71
// Include the modules saving script if it exists
72
if(file_exists(WB_PATH.'/modules/'.$module.'/save.php')) {
73
	require(WB_PATH.'/modules/'.$module.'/save.php');
74
}
75

    
76
// Check if there is a db error, otherwise say successful
77
if($database->is_error()) {
78
	$admin->print_error($database->get_error(), $js_back);
79
} else {
80
	$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
81
}
82

    
83
// Print admin footer
84
$admin->print_footer();
85

    
86
?>
(13-13/20)