getIframeTemplateContent.php 2.71 KB
Newer Older
Giovannoni Laurent's avatar
Giovannoni Laurent committed
1
<?php
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

/*
*    Copyright 2008,2015 Maarch
*
*  This file is part of Maarch Framework.
*
*   Maarch Framework is free software: you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation, either version 3 of the License, or
*   (at your option) any later version.
*
*   Maarch Framework is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*    along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
*/
21
//Remove html tags to avoid empty space
22
$sessionTemplateContent = trim(str_replace(
23 24 25 26
    array('&nbsp;','<p>','</p>'),
    '',
    $_SESSION['template_content']
));
27 28
$sessionTemplateContent = strip_tags($sessionTemplateContent);
$sessionTemplateContent = trim(preg_replace(
29 30
    '/\s*/m',
    '',
31
    $sessionTemplateContent));
32

33
$sessionTemplateContent = utf8_encode(html_entity_decode($sessionTemplateContent));
34

35
$requestTemplateContent = utf8_encode(html_entity_decode(strip_tags($_REQUEST['template_content'])));
Pegane Nestor's avatar
Pegane Nestor committed
36 37 38 39 40
$sessionTemplateContent = trim(str_replace(
    "Â",
    "",
    $sessionTemplateContent
));
Giovannoni Laurent's avatar
Giovannoni Laurent committed
41

42
$sessionTemplateContent = trim(str_replace(
43
    "\n",
44 45 46
    "",
    $sessionTemplateContent
));
Pegane Nestor's avatar
Pegane Nestor committed
47
$sessionTemplateContent = trim(preg_replace(
48 49
    '/\s+/',
    '',
Pegane Nestor's avatar
Pegane Nestor committed
50
    $sessionTemplateContent));
51
$sessionTemplateContent = trim(str_replace(
52
    "\r",
53 54 55 56
    "",
    $sessionTemplateContent
));
$sessionTemplateContent = trim(str_replace(
57
    "\t",
58 59 60 61
    "",
    $sessionTemplateContent
));
$requestTemplateContent = trim(str_replace(
62 63
    "\n",
    "",
64 65 66
    $requestTemplateContent
));
$requestTemplateContent = trim(str_replace(
67 68
    " ",
    "",
69 70 71
    $requestTemplateContent
));
$requestTemplateContent = trim(str_replace(
72 73
    "\r",
    "",
74 75 76
    $requestTemplateContent
));
$requestTemplateContent = trim(str_replace(
77 78
    "\t",
    "",
79 80
    $requestTemplateContent
));
Giovannoni Laurent's avatar
Giovannoni Laurent committed
81

82 83
if ($sessionTemplateContent == $requestTemplateContent || empty($sessionTemplateContent)) {
    $_SESSION['template_content_same'] = true;
84 85
    echo "{status : '1, responseText : same content ! '}";
} else {
86 87 88
    $_SESSION['template_modified_content'] = $_REQUEST['template_content'];
    $_SESSION['template_modified_content'] = str_replace('[dates]', date('d-m-Y'), $_SESSION['template_modified_content']);
    $_SESSION['template_modified_content'] = str_replace('[time]', date('G:i:s'), $_SESSION['template_modified_content']);
89
    echo "{status : '0, responseText : " . addslashes(functions::xssafe($_REQUEST['template_content'])) . "'}";
90 91
}

Giovannoni Laurent's avatar
Giovannoni Laurent committed
92
exit;