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
$admin = new admin('Pages', 'pages_modify');
24 1358 Luisehahne
25 1402 Luisehahne
if (!$admin->checkFTAN())
26
{
27
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],'index.php');
28
	exit();
29
}
30
31 1358 Luisehahne
// Get page & section id
32 1384 Luisehahne
if(!isset($_POST['page_id']) || !is_numeric($_POST['page_id'])) {
33 1358 Luisehahne
	header("Location: index.php");
34
	exit(0);
35
} else {
36
	$page_id = intval($_POST['page_id']);
37
}
38 1402 Luisehahne
39 1384 Luisehahne
if(!isset($_POST['section_id']) || !is_numeric($_POST['section_id'])) {
40 1358 Luisehahne
	header("Location: index.php");
41
	exit(0);
42
} else {
43
	$section_id = intval($_POST['section_id']);
44
}
45
46 1402 Luisehahne
/*
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 1384 Luisehahne
53 1402 Luisehahne
if( (!($section_id= $admin->checkIDKEY('section_id', 0, $_SERVER['REQUEST_METHOD']))) )
54 1358 Luisehahne
{
55 1402 Luisehahne
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
56 1358 Luisehahne
	exit();
57
}
58 1402 Luisehahne
*/
59
60 1386 Luisehahne
$js_back = "javascript: history.go(-1);";
61 1358 Luisehahne
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 1384 Luisehahne
if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
78 1358 Luisehahne
{
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 1402 Luisehahne
	$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id'] );
117 1358 Luisehahne
}
118
119
// Print admin footer
120
$admin->print_footer();
121
122 4 ryan
?>