Project

General

Profile

« Previous | Next » 

Revision 1520

Added by darkviper over 12 years ago

/modules/output_filter completely recoded
+ new filter for relative-URL added
+ some small fixes
/admin/admintools/tool.php completely recoded
/wb/index.php output_filter request changed to adopt new output_filter

View differences:

tool.php
3 3
 *
4 4
 * @category        modules
5 5
 * @package         output_filter
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
6
 * @author          Christian Sommer, WB-Project, Werner v.d. Decken
7
 * @copyright       2011-, Website Baker Org. e.V.
9 8
 * @link			http://www.websitebaker2.org/
10 9
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
10
 * @platform        WebsiteBaker 2.8.2
12 11
 * @requirements    PHP 5.2.2 and higher
13 12
 * @version         $Id$
14 13
 * @filesource		$HeadURL$
15 14
 * @lastmodified    $Date$
16 15
 *
17 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
/* -------------------------------------------------------- */
18 22

  
19
// Must include code to stop this file being access directly
20
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
21

  
22
// check if module language file exists for the language set by the user (e.g. DE, EN)
23
$MOD_MAIL_FILTER['WARNING']	= '<p style="color: red; line-height:1.5em;"><strong>Warning: </strong>This function is now available as a Droplet. The next major release of website baker will not include this filter anymore. Please concider using the <a href="?tool=droplets">Droplet</a> [[EmailFilter]]</p>';
24
if(!file_exists(WB_PATH .'/modules/output_filter/languages/'.LANGUAGE .'.php')) {
25
	// no module language file exists for the language set by the user, include default module language file EN.php
26
	require_once(WB_PATH .'/modules/output_filter/languages/EN.php');
27
} else {
28
	// a module language file exists for the language defined by the user, load it
29
	require_once(WB_PATH .'/modules/output_filter/languages/'.LANGUAGE .'.php');
30
}
23
	$modPath = str_replace('\\', '/', dirname(__FILE__)).'/';
24
	$msgTxt = '';
25
	$msgCls = 'msg-box';
26
// include the modules language definitions
27
	if(!is_readable($modPath.'languages/'.LANGUAGE .'.php')) {
28
		require_once($modPath.'languages/EN.php');
29
	} else {
30
		require_once($modPath.'languages/'.LANGUAGE .'.php');
31
	}
31 32
// check if data was submitted
32
if(isset($_POST['save_settings'])) {
33
	
34
	if (!$admin->checkFTAN())
35
	{
36
		if(!$admin_header) { $admin->print_header(); }
37
		$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$_SERVER['REQUEST_URI'],false);
33
	if($doSave) {
34
	// take over post - arguments
35
		$data = array();
36
		$data['sys_rel']       = (int)(intval(isset($_POST['sys_rel']) ? $_POST['sys_rel'] : 0) != 0);
37
		$data['email_filter']  = (int)(intval(isset($_POST['email_filter']) ? $_POST['email_filter'] : 0) != 0);
38
		$data['mailto_filter'] = (int)(intval(isset($_POST['mailto_filter']) ? $_POST['mailto_filter'] : 0) != 0);
39
		$data['at_replacement']  = isset($_POST['at_replacement']) ? trim(strip_tags($_POST['at_replacement'])) : '';
40
		$data['dot_replacement'] = isset($_POST['dot_replacement']) ? trim(strip_tags($_POST['dot_replacement'])) : '';
41
		if ($admin->checkFTAN()) {
42
		// update database settings
43
			$sql = 'UPDATE `'.TABLE_PREFIX.'mod_output_filter` SET '.
44
					  '`email_filter`='.$data['email_filter'].', '.
45
					  '`sys_rel`='.$data['sys_rel'].', '.
46
					  '`mailto_filter`='.$data['mailto_filter'].', '.
47
					  '`at_replacement`=\''.mysql_real_escape_string($data['at_replacement']).'\', '.
48
					  '`dot_replacement`=\''.mysql_real_escape_string($data['dot_replacement']).'\'';
49
			if($database->query($sql)) {
50
			//anything ok
51
				$msgTxt = $MESSAGE['RECORD_MODIFIED_SAVED'];
52
				$msgCls = 'msg-box';
53
			}else {
54
			// database error
55
				$msgTxt = $MESSAGE['RECORD_MODIFIED_FAILED'];
56
				$msgCls = 'error-box';
57
			}
58
		}else {
59
		// FTAN error
60
			$msgTxt = $MESSAGE['GENERIC_SECURITY_ACCESS'];
61
			$msgCls = 'error-box';
62
		}
63
	}else {
64
	// read settings from the database to show
65
		require_once($modPath.'filter-routines.php');
66
		$data = getOutputFilterSettings();
38 67
	}
39
	// get overall output filter settings
40
	$sys_rel = (isset($_POST['sys_rel']) && $_POST['sys_rel'] == '1') ? '1' : '0';
41
	$email_filter = (isset($_POST['email_filter']) && $_POST['email_filter'] == '1') ? '1' : '0';
42
	$mailto_filter = (isset($_POST['mailto_filter']) && $_POST['mailto_filter'] == '1') ? '1' : '0';
43
	
44
	// get email replacement settings
45
	$at_replacement = isset($_POST['at_replacement']) ?strip_tags($_POST['at_replacement']) : '';
46
	$at_replacement = (strlen(trim($at_replacement)) > 0) ? $admin->add_slashes($at_replacement) : '(at)';
47
	$dot_replacement = isset($_POST['dot_replacement']) ?strip_tags($_POST['dot_replacement']) : '';
48
	$dot_replacement = (strlen(trim($dot_replacement)) > 0) ? $admin->add_slashes($dot_replacement) : '(dot)';
49
	
50
	// update database settings
51
	$database->query("UPDATE " .TABLE_PREFIX ."mod_output_filter SET email_filter = '$email_filter',
52
		sys_rel = '$sys_rel', mailto_filter = '$mailto_filter', at_replacement = '$at_replacement', dot_replacement = '$dot_replacement'");
53

  
54
	// check if there is a database error, otherwise say successful
68
	// write out header if needed
55 69
	if(!$admin_header) { $admin->print_header(); }
56
	if($database->is_error()) {
57
		$admin->print_error($database->get_error(), $js_back);
58
	} else {
59
		$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/admintools/tool.php?tool=output_filter');
70
	if( $msgTxt != '') {
71
	// write message box if needed
72
		echo '<div class="'.$msgCls.'">'.$msgTxt.'</div>';
60 73
	}
61

  
62
} else {
63
}
64
	// write out heading
65
	echo '<h2>' .$MOD_MAIL_FILTER['HEADING'] .'</h2>';
66

  
67
	// include filter functions
68
	require_once(WB_PATH .'/modules/output_filter/filter-routines.php');
69
	
70
	// read the mail filter settings from the database
71
	$data = get_output_filter_settings();
72
	
73
	// output the form with values from the database
74
	echo '<p>' .$MOD_MAIL_FILTER['HOWTO'] .'</p>';
75
	echo $MOD_MAIL_FILTER['WARNING'];
76 74
?>
75
<h2><?php echo $MOD_MAIL_FILTER['HEADING']; ?></h2>
76
<p><?php echo $MOD_MAIL_FILTER['HOWTO']; ?></p>
77 77
<form name="store_settings" action="<?php echo $_SERVER['REQUEST_URI'];?>" method="post">
78
<?php echo $admin->getFTAN(); ?>
78
	<?php echo $admin->getFTAN(); ?>
79
	<input type="hidden" name="action" value="save" />
79 80
	<table width="98%" cellspacing="0" cellpadding="5px" class="row_a">
80 81
	<tr><td colspan="2"><strong><?php echo $MOD_MAIL_FILTER['BASIC_CONF'];?>:</strong></td></tr>
81 82
	<tr>
......
117 118
			name="dot_replacement"/></td>
118 119
	</tr>
119 120
	</table>
120
	<input type="submit" name="save_settings" style="margin-top:10px; width:140px;" value="<?php echo $TEXT['SAVE']; ?>" />
121
</form>
121
	<input type="submit" style="margin-top:10px; width:140px;" value="<?php echo $TEXT['SAVE']; ?>" />
122
</form>

Also available in: Unified diff