1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category modules
|
5
|
* @package output_filter
|
6
|
* @author Christian Sommer, WB-Project, Werner v.d. Decken
|
7
|
* @copyright 2013, WebsiteBaker Org. e.V.
|
8
|
* @link http://www.websitebaker.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.4
|
11
|
* @requirements PHP 5.2.2 and higher
|
12
|
* @version $Id: index.php 2074 2014-01-06 22:46:12Z darkviper $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/output_filter/index.php $
|
14
|
* @lastmodified $Date: 2014-01-06 23:46:12 +0100 (Mon, 06 Jan 2014) $
|
15
|
*
|
16
|
*/
|
17
|
/* -------------------------------------------------------- */
|
18
|
// Must include code to stop this file being accessed directly
|
19
|
require_once( dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
|
20
|
if(!defined('WB_PATH')) { throw new IllegalFileException(); }
|
21
|
/* -------------------------------------------------------- */
|
22
|
|
23
|
/* ************************************************************************** */
|
24
|
/**
|
25
|
* execute the frontend output filter to modify email addresses
|
26
|
* @param string $sContent actual content
|
27
|
* @return string modified content
|
28
|
*/
|
29
|
function executeFrontendOutputFilter($sContent) {
|
30
|
// get output filter settings from database
|
31
|
$filter_settings = getOutputFilterSettings();
|
32
|
$sFilterDirectory = str_replace('\\', '/', __DIR__).'/filters/';
|
33
|
$output_filter_mode = 0;
|
34
|
$output_filter_mode |= ($filter_settings['email_filter'] * pow(2, 0)); // n | 2^0
|
35
|
$output_filter_mode |= ($filter_settings['mailto_filter'] * pow(2, 1)); // n | 2^1
|
36
|
define('OUTPUT_FILTER_AT_REPLACEMENT', $filter_settings['at_replacement']);
|
37
|
define('OUTPUT_FILTER_DOT_REPLACEMENT', $filter_settings['dot_replacement']);
|
38
|
if (!function_exists('OutputFilterApi')) {
|
39
|
require (__DIR__.'/OutputFilterApi.php');
|
40
|
}
|
41
|
/* ### fixed default filters ################################################ */
|
42
|
$sContent = OutputFilterApi('ReplaceSysvar', $sContent);
|
43
|
$sContent = OutputFilterApi('WbLink', $sContent);
|
44
|
/* ************************************************************************** */
|
45
|
/* *** from here insert requests of individual variable filter ************** */
|
46
|
|
47
|
/* ### filter type: execute droplets filter ################################# */
|
48
|
$sContent = OutputFilterApi('Droplets', $sContent);
|
49
|
/* ### filter type: protect email addresses ################################# */
|
50
|
if( ($output_filter_mode & pow(2, 0)) || ($output_filter_mode & pow(2, 1)) ) {
|
51
|
if (file_exists($sFilterDirectory.'filterEmail.php')) {
|
52
|
require_once($sFilterDirectory.'filterEmail.php');
|
53
|
$sContent = doFilterEmail($sContent, $output_filter_mode);
|
54
|
}
|
55
|
}
|
56
|
/* ### filter type: make use of Thorn's OutputFilterDashboard ############### */
|
57
|
if($filter_settings['opf'] == 1){
|
58
|
$sContent = OutputFilterApi('OpF', $sContent);
|
59
|
}
|
60
|
|
61
|
/* *** end of individual variable filter ************************************ */
|
62
|
/* ************************************************************************** */
|
63
|
/* ### fixed default filters ################################################ */
|
64
|
$sContent = OutputFilterApi('ReplaceSysvar', $sContent);
|
65
|
$sContent = OutputFilterApi('WbLink', $sContent);
|
66
|
if($filter_settings['sys_rel'] == 1){
|
67
|
$sContent = OutputFilterApi('RelUrl', $sContent);
|
68
|
}
|
69
|
$sContent = OutputFilterApi('CssToHead', $sContent);
|
70
|
/* ### end of filters ####################################################### */
|
71
|
return $sContent;
|
72
|
}
|
73
|
/* ************************************************************************** */
|
74
|
/**
|
75
|
* function to read the current filter settings
|
76
|
* @global object $database
|
77
|
* @global object $admin
|
78
|
* @param void
|
79
|
* @return array contains all settings
|
80
|
*/
|
81
|
function getOutputFilterSettings() {
|
82
|
$oDb = WbDatabase::getInstance();
|
83
|
// set default values
|
84
|
$settings = array(
|
85
|
'sys_rel' => 0,
|
86
|
'opf' => 0,
|
87
|
'email_filter' => 0,
|
88
|
'mailto_filter' => 0,
|
89
|
'at_replacement' => '(at)',
|
90
|
'dot_replacement' => '(dot)'
|
91
|
);
|
92
|
// be sure field 'sys_rel' is in table
|
93
|
$oDb->field_add( $oDb->TablePrefix.'mod_output_filter', 'sys_rel', 'INT NOT NULL DEFAULT \'0\' FIRST');
|
94
|
// request settings from database
|
95
|
$sql = 'SELECT * FROM `'.$oDb->TablePrefix.'mod_output_filter` ';
|
96
|
if(($res = $oDb->doQuery($sql))) {
|
97
|
if(($rec = $res->fetchRow(MYSQL_ASSOC))) {
|
98
|
$settings = $rec;
|
99
|
}
|
100
|
}
|
101
|
// return array with filter settings
|
102
|
return $settings;
|
103
|
}
|
104
|
/* ************************************************************************** */
|