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 1402 2011-01-22 04:41:07Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/save.php $
15
 * @lastmodified    $Date: 2011-01-22 05:41:07 +0100 (Sat, 22 Jan 2011) $
16
 *
17
 */
18
/*
19
*/
20
// Create new admin object
21
require('../../config.php');
22
require_once(WB_PATH.'/framework/class.admin.php');
23
$admin = new admin('Pages', 'pages_modify');
24

    
25
if (!$admin->checkFTAN())
26
{
27
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],'index.php');
28
	exit();
29
}
30

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

    
39
if(!isset($_POST['section_id']) || !is_numeric($_POST['section_id'])) {
40
	header("Location: index.php");
41
	exit(0);
42
} else {
43
	$section_id = intval($_POST['section_id']);
44
}
45

    
46
/*
47
if( (!($page_id = $admin->checkIDKEY('page_id', 0, $_SERVER['REQUEST_METHOD']))) )
48
{
49
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
50
	exit();
51
}
52

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

    
60
$js_back = "javascript: history.go(-1);";
61

    
62
// Get perms
63
$sql  = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` ';
64
$sql .= 'WHERE `page_id` = '.$page_id;
65
$results = $database->query($sql);
66
$results_array = $results->fetchRow();
67
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
68
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
69
$in_old_group = FALSE;
70
foreach($admin->get_groups_id() as $cur_gid)
71
{
72
    if (in_array($cur_gid, $old_admin_groups))
73
    {
74
        $in_old_group = TRUE;
75
    }
76
}
77
if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
78
{
79
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
80
}
81
// Get page module
82
$sql  = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
83
$sql .= 'WHERE `page_id`='.$page_id.' AND `section_id`='.$section_id;
84
$module = $database->get_one($sql);
85
if(!$module)
86
{
87
	$admin->print_error( $database->is_error() ? $database->get_error() : $MESSAGE['PAGES']['NOT_FOUND']);
88
}
89
//$results = $database->query($sql);
90
//if($database->is_error()) {
91
//	$admin->print_error($database->get_error());
92
//}
93
//if($results->numRows() == 0) {
94
//	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
95
//}
96
//$results_array = $results->fetchRow();
97
//$module = $results_array['module'];
98

    
99
// Update the pages table
100
$now = time();
101
$sql  = 'UPDATE `'.TABLE_PREFIX.'pages` SET ';
102
$sql .= '`modified_when` = '.$now.', `modified_by` = '.$admin->get_user_id().' ';
103
$sql .= 'WHERE `page_id` = '.$page_id;
104
$database->query($sql);
105

    
106
// Include the modules saving script if it exists
107
if(file_exists(WB_PATH.'/modules/'.$module.'/save.php'))
108
{
109
	include_once(WB_PATH.'/modules/'.$module.'/save.php');
110
}
111
// Check if there is a db error, otherwise say successful
112
if($database->is_error())
113
{
114
	$admin->print_error($database->get_error(), $js_back);
115
} else {
116
	$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id'] );
117
}
118

    
119
// Print admin footer
120
$admin->print_footer();
121

    
122
?>
(16-16/21)