23 |
23 |
/* ************************************************************************** */
|
24 |
24 |
/**
|
25 |
25 |
* execute the frontend output filter to modify email addresses
|
26 |
|
* @param string actual content
|
|
26 |
* @param string $sContent actual content
|
27 |
27 |
* @return string modified content
|
28 |
28 |
*/
|
29 |
|
function executeFrontendOutputFilter($content) {
|
|
29 |
function executeFrontendOutputFilter($sContent) {
|
30 |
30 |
// get output filter settings from database
|
31 |
31 |
$filter_settings = getOutputFilterSettings();
|
32 |
|
$sFilterDirectory = str_replace('\\', '/', dirname(__FILE__)).'/filters/';
|
|
32 |
$sFilterDirectory = str_replace('\\', '/', __DIR__).'/filters/';
|
33 |
33 |
$output_filter_mode = 0;
|
34 |
34 |
$output_filter_mode |= ($filter_settings['email_filter'] * pow(2, 0)); // n | 2^0
|
35 |
35 |
$output_filter_mode |= ($filter_settings['mailto_filter'] * pow(2, 1)); // n | 2^1
|
36 |
36 |
define('OUTPUT_FILTER_AT_REPLACEMENT', $filter_settings['at_replacement']);
|
37 |
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 ************** */
|
38 |
46 |
|
39 |
|
/* ### filter type: replace Sysvar placeholder ############################## */
|
40 |
|
if (file_exists($sFilterDirectory.'filterReplaceSysvar.php')) {
|
41 |
|
require_once($sFilterDirectory.'filterReplaceSysvar.php');
|
42 |
|
$content = doFilterReplaceSysvar($content);
|
43 |
|
}
|
44 |
|
/* ### filter type: change [wblinkxx] into real URLs ######################## */
|
45 |
|
if (file_exists($sFilterDirectory.'filterWbLink.php')) {
|
46 |
|
require_once($sFilterDirectory.'filterWbLink.php');
|
47 |
|
$content = doFilterWbLink($content);
|
48 |
|
}
|
49 |
47 |
/* ### filter type: execute droplets filter ################################# */
|
50 |
|
if (file_exists($sFilterDirectory.'filterDroplets.php')) {
|
51 |
|
require_once($sFilterDirectory.'filterDroplets.php');
|
52 |
|
$content = doFilterDroplets($content);
|
53 |
|
}
|
|
48 |
$sContent = OutputFilterApi('Droplets', $sContent);
|
54 |
49 |
/* ### filter type: protect email addresses ################################# */
|
55 |
50 |
if( ($output_filter_mode & pow(2, 0)) || ($output_filter_mode & pow(2, 1)) ) {
|
56 |
51 |
if (file_exists($sFilterDirectory.'filterEmail.php')) {
|
57 |
52 |
require_once($sFilterDirectory.'filterEmail.php');
|
58 |
|
$content = doFilterEmail($content, $output_filter_mode);
|
|
53 |
$sContent = doFilterEmail($sContent, $output_filter_mode);
|
59 |
54 |
}
|
60 |
55 |
}
|
61 |
|
/* ### filter type: replace Sysvar placeholder ############################## */
|
62 |
|
if (file_exists($sFilterDirectory.'filterReplaceSysvar.php')) {
|
63 |
|
require_once($sFilterDirectory.'filterReplaceSysvar.php');
|
64 |
|
$content = doFilterReplaceSysvar($content);
|
65 |
|
}
|
66 |
|
/* ### filter type: change [wblinkxx] into real URLs ######################## */
|
67 |
|
if (file_exists($sFilterDirectory.'filterWbLink.php')) {
|
68 |
|
require_once($sFilterDirectory.'filterWbLink.php');
|
69 |
|
$content = doFilterWbLink($content);
|
70 |
|
}
|
71 |
|
/* ### filter type: full qualified URLs to relative URLs##################### */
|
|
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);
|
72 |
66 |
if($filter_settings['sys_rel'] == 1){
|
73 |
|
if (file_exists($sFilterDirectory.'filterRelUrl.php')) {
|
74 |
|
require_once($sFilterDirectory.'filterRelUrl.php');
|
75 |
|
$content = doFilterRelUrl($content);
|
76 |
|
}
|
|
67 |
$sContent = OutputFilterApi('RelUrl', $sContent);
|
77 |
68 |
}
|
78 |
|
/* ### filter type: moves css definitions from <body> into <head> ########### */
|
79 |
|
if (file_exists($sFilterDirectory.'filterCssToHead.php')) {
|
80 |
|
require_once($sFilterDirectory.'filterCssToHead.php');
|
81 |
|
$content = doFilterCssToHead($content);
|
82 |
|
}
|
83 |
|
|
|
69 |
$sContent = OutputFilterApi('CssToHead', $sContent);
|
84 |
70 |
/* ### end of filters ####################################################### */
|
85 |
|
return $content;
|
|
71 |
return $sContent;
|
86 |
72 |
}
|
87 |
73 |
/* ************************************************************************** */
|
88 |
74 |
/**
|
... | ... | |
93 |
79 |
* @return array contains all settings
|
94 |
80 |
*/
|
95 |
81 |
function getOutputFilterSettings() {
|
96 |
|
global $database, $admin;
|
|
82 |
$oDb = WbDatabase::getInstance();
|
97 |
83 |
// set default values
|
98 |
84 |
$settings = array(
|
99 |
85 |
'sys_rel' => 0,
|
|
86 |
'opf' => 0,
|
100 |
87 |
'email_filter' => 0,
|
101 |
88 |
'mailto_filter' => 0,
|
102 |
89 |
'at_replacement' => '(at)',
|
103 |
90 |
'dot_replacement' => '(dot)'
|
104 |
91 |
);
|
105 |
92 |
// be sure field 'sys_rel' is in table
|
106 |
|
$database->field_add( TABLE_PREFIX.'mod_output_filter', 'sys_rel', 'INT NOT NULL DEFAULT \'0\' FIRST');
|
|
93 |
$oDb->field_add( $oDb->TablePrefix.'mod_output_filter', 'sys_rel', 'INT NOT NULL DEFAULT \'0\' FIRST');
|
107 |
94 |
// request settings from database
|
108 |
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_output_filter` ';
|
109 |
|
if(($res = $database->query($sql))) {
|
110 |
|
if(($rec = $res->fetchRow())) {
|
|
95 |
$sql = 'SELECT * FROM `'.$oDb->TablePrefix.'mod_output_filter` ';
|
|
96 |
if(($res = $oDb->doQuery($sql))) {
|
|
97 |
if(($rec = $res->fetchRow(MYSQL_ASSOC))) {
|
111 |
98 |
$settings = $rec;
|
112 |
|
$settings['at_replacement'] = $admin->strip_slashes($settings['at_replacement']);
|
113 |
|
$settings['dot_replacement'] = $admin->strip_slashes($settings['dot_replacement']);
|
114 |
99 |
}
|
115 |
100 |
}
|
116 |
101 |
// return array with filter settings
|
+ added new outputfilter to use OutputFilterDashboard