Project

General

Profile

1
<?php
2
/*
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 *
18
 * cmdSave.php
19
 *
20
 * @category     Addons
21
 * @package      Addons_wrapper
22
 * @copyright    Manuela v.d.Decken <manuela@isteam.de>
23
 * @author       Manuela v.d.Decken <manuela@isteam.de>
24
 * @license      http://www.gnu.org/licenses/gpl.html   GPL License
25
 * @version      3.0.1
26
 * @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
27
 * @since        File available since 2015-12-17
28
 * @description  xyz
29
 */
30
/* -------------------------------------------------------- */
31
// Must include code to stop this file being accessed directly
32
if (!defined('WB_PATH')) { throw new Exception('Cannot access the addon \"'.basename(__DIR__).'\" directly'); }
33
/* -------------------------------------------------------- */
34
    $bBackLink = isset($_POST['pagetree']);
35

    
36
    // Update the mod_wrapper table with the contents
37
    if (isset($_POST['url'])) {
38
    // sanitize/validate url
39
        // first add the local URL if there is no one
40
        $sNewUrl = ltrim(str_replace('\\', '/', $_POST['url']), '/');
41
        if (!preg_match('/^https?:\/\/.*$/si', $sNewUrl)) {
42
            $sNewUrl = WB_URL.'/'.$sNewUrl;
43
        }
44
        // validate the URL
45
        include_once WB_PATH.'/include/idna_convert/idna_convert.class.php';
46
        $oIdn = new idna_convert();
47
        $url = $oIdn->encode($sNewUrl);
48
        $url = (filter_var($url, FILTER_VALIDATE_URL) === false ? '' : $url);
49
        $url = $oIdn->decode($url);
50
        unset($oIdn);
51
        // replace local host by SYSVAR-Tag
52
        $url = preg_replace(
53
            '/^'.preg_quote(str_replace('\\', '/', WB_URL).'/', '/').'/si',
54
            '{SYSVAR:AppUrl}',
55
            ltrim(str_replace('\\', '/', $url), '/')
56
        );
57
    } else { $url = ''; }
58
    // sanitize/validate height
59
    $height = (isset($_POST['height']) ? ((intval($_POST['height'])) ?: 400) : 400);
60
    // prepare SET part of the SQL-statement
61
    $sqlSet = '`'.TABLE_PREFIX.'mod_wrapper` SET '
62
            . '`section_id`='.$section_id.', '
63
            . '`page_id`='.$page_id.', '
64
            . '`url` = \''.$database->escapeString($url).'\', '
65
            . '`height` = \''.$database->escapeString($height).'\' ';
66
    // search for instance of this module in section
67
    $sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'mod_wrapper` '
68
         . 'WHERE `section_id`='.$section_id;
69
    if ($database->get_one($sql)) {
70
    // if matching record already exists run UPDATE
71
        $sql = 'UPDATE '.$sqlSet.'WHERE `section_id`='.$section_id;
72
    } else {
73
    // if no matching record exists INSERT new record
74
        $sql = 'INSERT INTO '.$sqlSet;
75
    }
76
    $database->query($sql);
77
    // Tells script to update when this page was last updated
78
    $update_when_modified = true;
79

    
80
// end of file
(4-4/7)