Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        module
5
 * @package         droplet
6
 * @author          Ruud Eisinga (Ruud) John (PCWacht)
7
 * @author          WebsiteBaker Project
8
 * @copyright       2004-2009, Ryan Djurovich
9
 * @copyright       2009-2011, Website Baker Org. e.V.
10
 * @link			http://www.websitebaker2.org/
11
 * @license         http://www.gnu.org/licenses/gpl.html
12
 * @platform        WebsiteBaker 2.8.x
13
 * @requirements    PHP 5.2.2 and higher
14
 * @version         $Id: save_droplet.php 1948 2013-08-04 11:39:49Z darkviper $
15
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/droplets/save_droplet.php $
16
 * @lastmodified    $Date: 2013-08-04 13:39:49 +0200 (Sun, 04 Aug 2013) $
17
 *
18
 */
19

    
20
require('../../config.php');
21
// Get id
22
/*
23
if(!isset($_POST['droplet_id']) OR !is_numeric($_POST['droplet_id'])) {
24
	header("Location: ".ADMIN_URL."/pages/index.php");
25
} else {
26
	$droplet_id = (int) $_POST['droplet_id'];
27
}
28
*/
29

    
30
// Include WB admin wrapper script
31
require_once(WB_PATH.'/framework/class.admin.php');
32
require_once(WB_PATH.'/framework/functions.php');
33

    
34
$admintool_link = ADMIN_URL .'/admintools/index.php';
35
$module_edit_link = ADMIN_URL .'/admintools/tool.php?tool=droplets';
36

    
37
$admin = new admin('admintools', 'admintools',false);
38

    
39
$droplet_id = intval($admin->checkIDKEY('droplet_id', false, 'POST'));
40

    
41
if(!$admin->checkFTAN() || !$droplet_id ) {
42
	$admin->print_header();
43
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $module_edit_link );
44
}
45
$admin->print_header();
46
$oDb = WbDatabase::getInstance();
47
// Validate all fields
48
if($admin->get_post('title') == '') {
49
	$admin->print_error($MESSAGE['GENERIC']['FILL_IN_ALL'], WB_URL.'/modules/droplets/modify_droplet.php?droplet_id='. $admin->getIDKEY($droplet_id));
50
} else {
51
	$title = $admin->get_post('title');
52
	$active = (int) $admin->get_post('active');
53
	$admin_view = (int) $admin->get_post('admin_view');
54
	$admin_edit = (int) $admin->get_post('admin_edit');
55
	$show_wysiwyg = (int) $admin->get_post('show_wysiwyg');
56
	$description = $admin->get_post('description');
57
	$tags = array('<?php', '?>' , '<?');
58
	$content = str_replace($tags, '', $_POST['savecontent']);
59
	$comments = $admin->get_post('comments');
60
	$modified_when = time();
61
	$modified_by = (int) $admin->get_user_id();
62
}
63

    
64
// Update row
65
$sql = 'UPDATE `'.$oDb->TablePrefix.'mod_droplets` SET ';
66
$sql .= '`name` = \''.$oDb->escapeString($title).'\', ';
67
$sql .= '`active` = '.$active.', ';
68
$sql .= '`admin_view` = '.$admin_view.', ';
69
$sql .= '`admin_edit` = '.$admin_edit.', ';
70
$sql .= '`show_wysiwyg` = '.$show_wysiwyg.', ';
71
$sql .= '`description` = \''.$oDb->escapeString($description).'\', ';
72
$sql .= '`code` = \''.$oDb->escapeString($content).'\', ';
73
$sql .= '`comments` = \''.$oDb->escapeString($comments).'\', ';
74
$sql .= '`modified_when` = '.$modified_when.', ';
75
$sql .= '`modified_by` = '.$modified_by.' ';
76
$sql .= 'WHERE `id` = '.$droplet_id;
77
$oDb->query($sql);
78

    
79
// Check if there is a db error, otherwise say successful
80
if($oDb->is_error()) {
81
	$admin->print_error($oDb->get_error(), WB_URL.'/modules/droplets/modify_droplet.php?droplet_id='. $admin->getIDKEY($droplet_id));
82
} else {
83
    $admin->print_success($TEXT['SUCCESS'], $module_edit_link);
84
}
85

    
86
// Print admin footer
87
$admin->print_footer();
(12-12/16)