1 |
1306
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category admin
|
5 |
|
|
* @package pages
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
|
|
* @copyright 2004-2009, Ryan Djurovich
|
8 |
1349
|
Luisehahne
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9 |
1306
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
10 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
11 |
|
|
* @platform WebsiteBaker 2.8.x
|
12 |
1349
|
Luisehahne
|
* @requirements PHP 5.2.2 and higher
|
13 |
1306
|
Luisehahne
|
* @version $Id$
|
14 |
|
|
* @filesource $HeadURL$
|
15 |
|
|
* @lastmodified $Date$
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
// Get page & section id
|
20 |
|
|
if(!isset($_POST['page_id']) OR !is_numeric($_POST['page_id'])) {
|
21 |
|
|
header("Location: index.php");
|
22 |
|
|
exit(0);
|
23 |
|
|
} else {
|
24 |
|
|
$page_id = intval($_POST['page_id']);
|
25 |
|
|
}
|
26 |
|
|
if(!isset($_POST['section_id']) OR !is_numeric($_POST['section_id'])) {
|
27 |
|
|
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 |
|
|
|
38 |
1357
|
FrankH
|
if (!$admin->checkFTAN())
|
39 |
|
|
{
|
40 |
|
|
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
|
41 |
|
|
exit();
|
42 |
|
|
}
|
43 |
|
|
|
44 |
1306
|
Luisehahne
|
// Get perms
|
45 |
|
|
$sql = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` ';
|
46 |
|
|
$sql .= 'WHERE `page_id` = '.$page_id;
|
47 |
|
|
$results = $database->query($sql);
|
48 |
|
|
$results_array = $results->fetchRow();
|
49 |
|
|
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
|
50 |
|
|
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
|
51 |
|
|
$in_old_group = FALSE;
|
52 |
|
|
foreach($admin->get_groups_id() as $cur_gid)
|
53 |
|
|
{
|
54 |
|
|
if (in_array($cur_gid, $old_admin_groups))
|
55 |
|
|
{
|
56 |
|
|
$in_old_group = TRUE;
|
57 |
|
|
}
|
58 |
|
|
}
|
59 |
|
|
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
|
60 |
|
|
{
|
61 |
|
|
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
|
62 |
|
|
}
|
63 |
|
|
// Get page module
|
64 |
|
|
$sql = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
|
65 |
|
|
$sql .= 'WHERE `page_id`='.$page_id.' AND `section_id`='.$section_id;
|
66 |
|
|
$module = $database->get_one($sql);
|
67 |
|
|
if(!$module)
|
68 |
|
|
{
|
69 |
|
|
$admin->print_error( $database->is_error() ? $database->get_error() : $MESSAGE['PAGES']['NOT_FOUND']);
|
70 |
|
|
}
|
71 |
|
|
//$results = $database->query($sql);
|
72 |
|
|
//if($database->is_error()) {
|
73 |
|
|
// $admin->print_error($database->get_error());
|
74 |
|
|
//}
|
75 |
|
|
//if($results->numRows() == 0) {
|
76 |
|
|
// $admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
|
77 |
|
|
//}
|
78 |
|
|
//$results_array = $results->fetchRow();
|
79 |
|
|
//$module = $results_array['module'];
|
80 |
|
|
|
81 |
|
|
// Update the pages table
|
82 |
|
|
$now = time();
|
83 |
|
|
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` SET ';
|
84 |
|
|
$sql .= '`modified_when` = '.$now.', `modified_by` = '.$admin->get_user_id().' ';
|
85 |
|
|
$sql .= 'WHERE `page_id` = '.$page_id;
|
86 |
|
|
$database->query($sql);
|
87 |
|
|
|
88 |
|
|
// Include the modules saving script if it exists
|
89 |
|
|
if(file_exists(WB_PATH.'/modules/'.$module.'/save.php'))
|
90 |
|
|
{
|
91 |
|
|
include_once(WB_PATH.'/modules/'.$module.'/save.php');
|
92 |
|
|
}
|
93 |
|
|
// Check if there is a db error, otherwise say successful
|
94 |
|
|
if($database->is_error())
|
95 |
|
|
{
|
96 |
|
|
$admin->print_error($database->get_error(), $js_back);
|
97 |
|
|
} else {
|
98 |
1357
|
FrankH
|
$ftan2 = $admin->getFTAN(2);
|
99 |
|
|
$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL."/pages/modify.php?page_id=$page_id&$ftan2");
|
100 |
1306
|
Luisehahne
|
}
|
101 |
|
|
|
102 |
|
|
// Print admin footer
|
103 |
|
|
$admin->print_footer();
|
104 |
|
|
|
105 |
4
|
ryan
|
?>
|