Revision 1626
Added by darkviper over 14 years ago
| index.php | ||
|---|---|---|
| 4 | 4 |
* @category modules |
| 5 | 5 |
* @package output_filter |
| 6 | 6 |
* @author Christian Sommer, WB-Project, Werner v.d. Decken |
| 7 |
* @copyright 2009-2011, Website Baker Org. e.V.
|
|
| 7 |
* @copyright 2011, Website Baker Org. e.V. |
|
| 8 | 8 |
* @link http://www.websitebaker2.org/ |
| 9 | 9 |
* @license http://www.gnu.org/licenses/gpl.html |
| 10 | 10 |
* @platform WebsiteBaker 2.8.2 |
| ... | ... | |
| 14 | 14 |
* @lastmodified $Date$ |
| 15 | 15 |
* |
| 16 | 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 |
/* -------------------------------------------------------- */ |
|
| 17 | 22 |
|
| 18 |
header('Location: ../index.php');
|
|
| 19 |
exit(); |
|
| 23 |
/* ************************************************************************** */ |
|
| 24 |
/** |
|
| 25 |
* execute the frontend output filter to modify email addresses |
|
| 26 |
* @param string actual content |
|
| 27 |
* @return string modified content |
|
| 28 |
*/ |
|
| 29 |
function executeFrontendOutputFilter($content) {
|
|
| 30 |
// get output filter settings from database |
|
| 31 |
$filter_settings = getOutputFilterSettings(); |
|
| 32 |
$sFilterDirectory = str_replace('\\', '/', dirname(__FILE__)).'/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 |
|
|
| 39 |
/* ### filter type: execute droplets filter ################################# */ |
|
| 40 |
if (file_exists($sFilterDirectory.'filterDroplets.php')) {
|
|
| 41 |
require($sFilterDirectory.'filterDroplets.php'); |
|
| 42 |
$content = doFilterDroplets($content); |
|
| 43 |
} |
|
| 44 |
/* ### filter type: protect email addresses ################################# */ |
|
| 45 |
if( ($output_filter_mode & pow(2, 0)) || ($output_filter_mode & pow(2, 1)) ) {
|
|
| 46 |
if (file_exists($sFilterDirectory.'filterEmail.php')) {
|
|
| 47 |
require($sFilterDirectory.'filterEmail.php'); |
|
| 48 |
$content = doFilterEmail($content, $output_filter_mode); |
|
| 49 |
} |
|
| 50 |
} |
|
| 51 |
/* ### filter type: change [wblinkxx] into real URLs ######################## */ |
|
| 52 |
if (file_exists($sFilterDirectory.'filterWbLink.php')) {
|
|
| 53 |
require($sFilterDirectory.'filterWbLink.php'); |
|
| 54 |
$content = doFilterWbLink($content); |
|
| 55 |
} |
|
| 56 |
/* ### filter type: full qualified URLs to relative URLs##################### */ |
|
| 57 |
if($filter_settings['sys_rel'] == 1){
|
|
| 58 |
if (file_exists($sFilterDirectory.'filterRelUrl.php')) {
|
|
| 59 |
require($sFilterDirectory.'filterRelUrl.php'); |
|
| 60 |
$content = doFilterRelUrl($content); |
|
| 61 |
} |
|
| 62 |
} |
|
| 63 |
/* ### filter type: moves css definitions from <body> into <head> ########### */ |
|
| 64 |
if (file_exists($sFilterDirectory.'filterCssToHead.php')) {
|
|
| 65 |
require($sFilterDirectory.'filterCssToHead.php'); |
|
| 66 |
$content = doFilterCssToHead($content); |
|
| 67 |
} |
|
| 68 |
|
|
| 69 |
/* ### end of filters ####################################################### */ |
|
| 70 |
return $content; |
|
| 71 |
} |
|
| 72 |
/* ************************************************************************** */ |
|
| 73 |
/** |
|
| 74 |
* function to read the current filter settings |
|
| 75 |
* @global object $database |
|
| 76 |
* @global object $admin |
|
| 77 |
* @param void |
|
| 78 |
* @return array contains all settings |
|
| 79 |
*/ |
|
| 80 |
function getOutputFilterSettings() {
|
|
| 81 |
global $database, $admin; |
|
| 82 |
// set default values |
|
| 83 |
$settings = array( |
|
| 84 |
'sys_rel' => 0, |
|
| 85 |
'email_filter' => 0, |
|
| 86 |
'mailto_filter' => 0, |
|
| 87 |
'at_replacement' => '(at)', |
|
| 88 |
'dot_replacement' => '(dot)' |
|
| 89 |
); |
|
| 90 |
// be sure field 'sys_rel' is in table |
|
| 91 |
$database->field_add( TABLE_PREFIX.'mod_output_filter', 'sys_rel', 'INT NOT NULL DEFAULT \'0\' FIRST'); |
|
| 92 |
// request settings from database |
|
| 93 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_output_filter'; |
|
| 94 |
if(($res = $database->query($sql))) {
|
|
| 95 |
if(($rec = $res->fetchRow())) {
|
|
| 96 |
$settings = $rec; |
|
| 97 |
$settings['at_replacement'] = $admin->strip_slashes($settings['at_replacement']); |
|
| 98 |
$settings['dot_replacement'] = $admin->strip_slashes($settings['dot_replacement']); |
|
| 99 |
} |
|
| 100 |
} |
|
| 101 |
// return array with filter settings |
|
| 102 |
return $settings; |
|
| 103 |
} |
|
| 104 |
/* ************************************************************************** */ |
|
Also available in: Unified diff
started rebuild and reorganize the OutputFilter-System