Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        backend
5
 * @package         wysiwyg
6
 * @author          WebsiteBaker Project
7
 * @copyright       WebsiteBaker Org. e.V.
8
 * @link            http://websitebaker.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.3
11
 * @requirements    PHP 5.3.6 and higher
12
 * @version         $Id: save.php 2 2017-07-02 15:14:29Z Manuela $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/branches/main/modules/wysiwyg/save.php $
14
 * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
15
 *
16
*/
17

    
18
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
19

    
20
// suppress to print the header, so no new FTAN will be set
21
$admin_header = false;
22
// Tells script to update when this page was last updated
23
$update_when_modified = true;
24
// Include WB admin wrapper script
25
require(WB_PATH.'/modules/admin.php');
26

    
27
if (!$admin->checkFTAN()) {
28
    $admin->print_header();
29
    $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
30
}
31
// After check print the header
32
$admin->print_header();
33

    
34
// Include the WB functions file
35
require_once(WB_PATH.'/framework/functions.php');
36

    
37
$bBackLink = isset($_POST['pagetree']);
38
// Update the mod_wysiwygs table with the contents
39
if(isset($_POST['content'.$section_id])) {
40
    $content = $_POST['content'.$section_id];
41
    if(ini_get('magic_quotes_gpc')==true)
42
    {
43
        $content = $admin->strip_slashes($_POST['content'.$section_id]);
44
    }
45
/*
46
    $sMediaUrl = WB_URL.MEDIA_DIRECTORY;
47
    $searchfor = '@(<[^>]*=\s*")('.preg_quote($sMediaUrl).')([^">]*".*>)@siU';
48
    $content = preg_replace($searchfor, '$1{SYSVAR:MEDIA_REL}$3', $content);
49
*/
50
    $sRelUrl = preg_replace('/^https?:\/\/[^\/]+(.*)/is', '\1', WB_URL);
51
    $sDocumentRootUrl = str_replace($sRelUrl, '', WB_URL);
52
    $sMediaUrl = WB_URL.MEDIA_DIRECTORY;
53
    $aPatterns = array(
54
        '/(<[^>]*?=\s*\")(\/+)([^\"]*?\"[^>]*?)/is',
55
        '/(<[^>]*=\s*")('.preg_quote($sMediaUrl, '/').')([^">]*".*>)/siU'
56
    );
57
    $aReplacements = array(
58
        '\1'.$sDocumentRootUrl.'/\3',
59
        '$1{SYSVAR:MEDIA_REL}$3'
60
    );
61
    $content = preg_replace($aPatterns, $aReplacements, $content);
62

    
63
    $text = strip_tags($content);
64
    $sql = 'UPDATE `'.TABLE_PREFIX.'mod_wysiwyg` SET '
65
         . '`content`=\''.$database->escapeString($content).'\', '
66
         . '`text`=\''.$database->escapeString($text).'\' '
67
         . 'WHERE `section_id`='.(int)$section_id;
68
    $database->query($sql);
69
}
70
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? '#'.SEC_ANCHOR.$section['section_id'] : '' );
71
if(defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION){
72
    $edit_page = ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'&wysiwyg='.$section_id;
73
} elseif ( $bBackLink ) {
74
  $edit_page = ADMIN_URL.'/pages/index.php';
75
} else {
76
    $edit_page = ADMIN_URL.'/pages/modify.php?page_id='.$page_id.$sec_anchor;
77
}
78

    
79
// Check if there is a database error, otherwise say successful
80
if($database->is_error()) {
81
    $admin->print_error($database->get_error(), $js_back);
82
} else {
83
    $admin->print_success($MESSAGE['PAGES_SAVED'], $edit_page );
84
}
85

    
86
// Print admin footer
87
$admin->print_footer();
(8-8/11)