Project

General

Profile

1 1358 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8 1373 Luisehahne
 * @copyright       2009-2011, Website Baker Org. e.V.
9 1358 Luisehahne
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12 1373 Luisehahne
 * @requirements    PHP 5.2.2 and higher and higher
13 1358 Luisehahne
 * @version         $Id$
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16
 *
17
 */
18 1402 Luisehahne
/*
19
*/
20
// Create new admin object
21
require('../../config.php');
22
require_once(WB_PATH.'/framework/class.admin.php');
23 1358 Luisehahne
24 1457 Luisehahne
// suppress to print the header, so no new FTAN will be set
25
$admin = new admin('Pages', 'pages_modify', false);
26
27 1358 Luisehahne
// Get page & section id
28 1384 Luisehahne
if(!isset($_POST['page_id']) || !is_numeric($_POST['page_id'])) {
29 1358 Luisehahne
	header("Location: index.php");
30
	exit(0);
31
} else {
32
	$page_id = intval($_POST['page_id']);
33
}
34 1402 Luisehahne
35 1384 Luisehahne
if(!isset($_POST['section_id']) || !is_numeric($_POST['section_id'])) {
36 1358 Luisehahne
	header("Location: index.php");
37
	exit(0);
38
} else {
39
	$section_id = intval($_POST['section_id']);
40
}
41
42 1425 Luisehahne
// $js_back = "javascript: history.go(-1);";
43 1457 Luisehahne
$js_back = ADMIN_URL.'/pages/modify.php?page_id='.$page_id;
44 1425 Luisehahne
45
if (!$admin->checkFTAN())
46
{
47 1457 Luisehahne
	$admin->print_header();
48 1425 Luisehahne
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$js_back );
49
}
50 1457 Luisehahne
// After check print the header
51
$admin->print_header();
52 1425 Luisehahne
53 1402 Luisehahne
/*
54
if( (!($page_id = $admin->checkIDKEY('page_id', 0, $_SERVER['REQUEST_METHOD']))) )
55
{
56
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
57
}
58 1384 Luisehahne
59 1402 Luisehahne
if( (!($section_id= $admin->checkIDKEY('section_id', 0, $_SERVER['REQUEST_METHOD']))) )
60 1358 Luisehahne
{
61 1402 Luisehahne
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
62 1358 Luisehahne
}
63 1402 Luisehahne
*/
64
65 1358 Luisehahne
// Get perms
66
$sql  = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` ';
67
$sql .= 'WHERE `page_id` = '.$page_id;
68
$results = $database->query($sql);
69
$results_array = $results->fetchRow();
70 1692 darkviper
if(!$admin->ami_group_member($results_array['admin_users']) &&
71
   !$admin->is_group_match($admin->get_groups_id(), $results_array['admin_groups']))
72 1358 Luisehahne
{
73
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
74
}
75
// Get page module
76
$sql  = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
77
$sql .= 'WHERE `page_id`='.$page_id.' AND `section_id`='.$section_id;
78
$module = $database->get_one($sql);
79 1692 darkviper
if(!$module) {
80 1358 Luisehahne
	$admin->print_error( $database->is_error() ? $database->get_error() : $MESSAGE['PAGES']['NOT_FOUND']);
81
}
82
// Update the pages table
83
$now = time();
84
$sql  = 'UPDATE `'.TABLE_PREFIX.'pages` SET ';
85
$sql .= '`modified_when` = '.$now.', `modified_by` = '.$admin->get_user_id().' ';
86
$sql .= 'WHERE `page_id` = '.$page_id;
87
$database->query($sql);
88
89
// Include the modules saving script if it exists
90
if(file_exists(WB_PATH.'/modules/'.$module.'/save.php'))
91
{
92
	include_once(WB_PATH.'/modules/'.$module.'/save.php');
93
}
94
// Check if there is a db error, otherwise say successful
95
if($database->is_error())
96
{
97 1692 darkviper
	$admin->print_error($database->get_error(), ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
98 1358 Luisehahne
} else {
99 1692 darkviper
	$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
100 1358 Luisehahne
}
101
102
// Print admin footer
103
$admin->print_footer();
104
105 4 ryan
?>