Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher and higher
13
 * @version         $Id: save.php 1692 2012-08-08 01:08:19Z darkviper $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/save.php $
15
 * @lastmodified    $Date: 2012-08-08 03:08:19 +0200 (Wed, 08 Aug 2012) $
16
 *
17
 */
18
/*
19
*/
20
// Create new admin object
21
require('../../config.php');
22
require_once(WB_PATH.'/framework/class.admin.php');
23

    
24
// suppress to print the header, so no new FTAN will be set
25
$admin = new admin('Pages', 'pages_modify', false);
26

    
27
// Get page & section id
28
if(!isset($_POST['page_id']) || !is_numeric($_POST['page_id'])) {
29
	header("Location: index.php");
30
	exit(0);
31
} else {
32
	$page_id = intval($_POST['page_id']);
33
}
34

    
35
if(!isset($_POST['section_id']) || !is_numeric($_POST['section_id'])) {
36
	header("Location: index.php");
37
	exit(0);
38
} else {
39
	$section_id = intval($_POST['section_id']);
40
}
41

    
42
// $js_back = "javascript: history.go(-1);";
43
$js_back = ADMIN_URL.'/pages/modify.php?page_id='.$page_id;
44

    
45
if (!$admin->checkFTAN())
46
{
47
	$admin->print_header();
48
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$js_back );
49
}
50
// After check print the header
51
$admin->print_header();
52

    
53
/*
54
if( (!($page_id = $admin->checkIDKEY('page_id', 0, $_SERVER['REQUEST_METHOD']))) )
55
{
56
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
57
}
58

    
59
if( (!($section_id= $admin->checkIDKEY('section_id', 0, $_SERVER['REQUEST_METHOD']))) )
60
{
61
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
62
}
63
*/
64

    
65
// 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
if(!$admin->ami_group_member($results_array['admin_users']) && 
71
   !$admin->is_group_match($admin->get_groups_id(), $results_array['admin_groups']))
72
{
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
if(!$module) {
80
	$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
	$admin->print_error($database->get_error(), ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
98
} else {
99
	$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
100
}
101

    
102
// Print admin footer
103
$admin->print_footer();
104

    
105
?>
(17-17/22)