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       Ryan Djurovich
9
 * @copyright       WebsiteBaker Org. e.V.
10
 * @link            http://websitebaker.org/
11
 * @license         http://www.gnu.org/licenses/gpl.html
12
 * @platform        WebsiteBaker 2.8.3
13
 * @requirements    PHP 5.3.6 and higher
14
 * @version         $Id: save_droplet.php 2 2017-07-02 15:14:29Z Manuela $
15
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/branches/main/modules/droplets/commands/save_droplet.php $
16
 * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
17
 *
18
 */
19
/* -------------------------------------------------------- */
20
// Must include code to stop this file being accessed directly
21
if(!defined('WB_PATH')) {
22
    require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
23
    throw new IllegalFileException();
24
} else {
25
        if ( !class_exists('admin', false) ) { require($oReg->AppPath.'/framework/class.admin.php'); }
26
        // Include WB admin wrapper script
27
        $oApp = new admin('admintools', 'admintools',false);
28
        /* later
29
        if (!$oApp->checkFTAN()) {
30
        //    $oApp->print_header();
31
            $oApp->print_error('FTAN_DROPLET::'. $MESSAGE['GENERIC_SECURITY_ACCESS'], $ToolUrl );
32
        }
33
        */
34
        if (($droplet_id === false)) {
35
         //   $oApp->print_header();
36
            $oApp->print_error('IDKEY_DROPLET::'. $oTrans->MESSAGE_GENERIC_SECURITY_ACCESS, $ToolUrl );
37
        }
38
        // Validate all fields
39
        if( ($oApp->get_post('title') == '') && ($droplet_id==0) ) {
40
            $oApp->print_error($MESSAGE['GENERIC_FILL_IN_ALL'].' ( Droplet Name )', $ToolUrl );
41
        } else {
42
            $title = $oApp->StripCodeFromText($oApp->get_post('title'));
43
            $active = (int) $oApp->get_post('active');
44
            $oApp_view = (int) $oApp->get_post('admin_view');
45
            $oApp_edit = (int) $oApp->get_post('admin_edit');
46
            $show_wysiwyg = (int) $oApp->get_post('show_wysiwyg');
47
            $description = $oApp->get_post('description');
48
            $aForbiddenTags = array('<?php', '?>' , '<?');
49
            $content = str_replace($aForbiddenTags, '', $_POST['savecontent']);
50
            $comments = trim(($oApp->get_post('comments')));
51
            $modified_when = time();
52
            $modified_by = (int) $oApp->get_user_id();
53
        }
54
        $sqlBody = ''
55
                . '`active` = '.(int)$active.', '
56
                . '`admin_view` = '.(int)$oApp_view.', '
57
                . '`admin_edit` = '.(int)$oApp_edit.', '
58
                . '`show_wysiwyg` = '.(int)$show_wysiwyg.', '
59
                . '`description` = \''.$oDb->escapeString($description).'\', '
60
                . '`code` = \''.$oDb->escapeString($content).'\', '
61
                . '`comments` = \''.$oDb->escapeString($comments).'\', '
62
                . '`modified_when` = '.(int)$modified_when.', '
63
                . '`modified_by` = '.(int)$modified_by.' ';
64

    
65
        if ($droplet_id == 0){
66
            $title = getUniqueName($oDb, $title);
67
            $sql  = 'INSERT INTO `'.TABLE_PREFIX.'mod_droplets` SET '
68
                  . '`name` = \''.$oDb->escapeString($title).'\', ';
69
            $sqlWhere  = '';
70
            if (!$oDb->query($sql.$sqlBody)) {
71

    
72
            }
73
        } else {
74
            $sql = 'UPDATE `'.TABLE_PREFIX.'mod_droplets` SET ';
75
            $sqlWhere  = 'WHERE `id` = '.(int)$droplet_id;
76
            $oDb->query($sql.$sqlBody.$sqlWhere);}
77

    
78
        // Check if there is a db error, otherwise say successful
79
        if($oDb->is_error()) {
80
            msgQueue::add($oDb->get_error());
81
        } else {
82
            msgQueue::add( $oTrans->TEXT_SUCCESS, true );
83
        }
84
}
85

    
(14-14/16)