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
19
// Get page & section id
20 1384 Luisehahne
if(!isset($_POST['page_id']) || !is_numeric($_POST['page_id'])) {
21 1358 Luisehahne
	header("Location: index.php");
22
	exit(0);
23
} else {
24
	$page_id = intval($_POST['page_id']);
25
}
26 1384 Luisehahne
if(!isset($_POST['section_id']) || !is_numeric($_POST['section_id'])) {
27 1358 Luisehahne
	header("Location: index.php");
28
	exit(0);
29
} else {
30
	$section_id = intval($_POST['section_id']);
31
}
32
33
// Create new admin object
34
require('../../config.php');
35
require_once(WB_PATH.'/framework/class.admin.php');
36
$admin = new admin('Pages', 'pages_modify');
37 1384 Luisehahne
38 1358 Luisehahne
if (!$admin->checkFTAN())
39
{
40 1384 Luisehahne
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],'index.php');
41 1358 Luisehahne
	exit();
42
}
43 1386 Luisehahne
$js_back = "javascript: history.go(-1);";
44 1358 Luisehahne
45
// Get perms
46
$sql  = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` ';
47
$sql .= 'WHERE `page_id` = '.$page_id;
48
$results = $database->query($sql);
49
$results_array = $results->fetchRow();
50
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
51
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
52
$in_old_group = FALSE;
53
foreach($admin->get_groups_id() as $cur_gid)
54
{
55
    if (in_array($cur_gid, $old_admin_groups))
56
    {
57
        $in_old_group = TRUE;
58
    }
59
}
60 1384 Luisehahne
if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
61 1358 Luisehahne
{
62
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
63
}
64
// Get page module
65
$sql  = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
66
$sql .= 'WHERE `page_id`='.$page_id.' AND `section_id`='.$section_id;
67
$module = $database->get_one($sql);
68
if(!$module)
69
{
70
	$admin->print_error( $database->is_error() ? $database->get_error() : $MESSAGE['PAGES']['NOT_FOUND']);
71
}
72
//$results = $database->query($sql);
73
//if($database->is_error()) {
74
//	$admin->print_error($database->get_error());
75
//}
76
//if($results->numRows() == 0) {
77
//	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
78
//}
79
//$results_array = $results->fetchRow();
80
//$module = $results_array['module'];
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(), $js_back);
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 4 ryan
?>