~quam-plures-core/quam-plures/file_manager_limits

« back to all changes in this revision

Viewing changes to qp_inc/antispam/settings.ctrl.php

  • Committer: EdB
  • Date: 2013-03-04 07:15:41 UTC
  • mfrom: (7655.1.3 qp5_antispam)
  • Revision ID: 1912webworks@gmail.com-20130304071541-x462crs4d531rh69
http://forums.quamplures.net/viewtopic.php?f=6&t=1887

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
/**
3
 
 * This file implements the UI controller for Antispam Features.
4
 
 *
5
 
 * This file is part of Quam Plures - {@link http://quamplures.net/}
6
 
 * See also {@link https://launchpad.net/quam-plures}.
7
 
 *
8
 
 * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
9
 
 * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
10
 
 * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
11
 
 *
12
 
 * {@internal License choice
13
 
 * - If you have received this file as part of a package, please find the license.txt file in
14
 
 *   the same folder or the closest folder above for complete license terms.
15
 
 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
16
 
 *   then you must choose one of the following licenses before using the file:
17
 
 *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
18
 
 *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
19
 
 * }}
20
 
 *
21
 
 * {@internal Open Source relicensing agreement:
22
 
 * Daniel HAHLER grants Francois PLANQUE the right to license
23
 
 * Daniel HAHLER's contributions to this file and the b2evolution project
24
 
 * under any OSI approved OSS license (http://www.opensource.org/licenses/).
25
 
 * }}
26
 
 *
27
 
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
28
 
 * @author blueyed: Daniel HAHLER.
29
 
 *
30
 
 * @package pond
 
3
 * $ctrl_mappings: 'aspm_settings' || Global settings -> Antispam
 
4
 *
 
5
 * @todo (1111): This should probably be turned into a plugin
 
6
 *
 
7
 * @author {@link http://wonderwinds.com/ Ed Bennett}
 
8
 * @author {@link http://daniel.hahler.de/ Daniel HAHLER}
 
9
 * @author {@link http://fplanque.net/ Francois PLANQUE}
 
10
 * @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
 
11
 * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
 
12
 * @package antispam
31
13
 */
32
 
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
33
 
 
34
 
 
35
 
// Check minimum permission:
 
14
if(!defined('QP_MAIN_INIT')) die('fail');
 
15
 
 
16
// Check minimum permission
36
17
$current_User->check_perm( 'options', 'view', true );
37
18
 
38
 
 
39
 
$AdminUI->set_path( 'options', 'antispam' );
 
19
$AdminUI->set_path( 'tools', 'antispam', 'saspm' );
40
20
 
41
21
param( 'action', 'string' );
42
22
 
43
23
switch( $action )
44
24
{
45
25
        case 'update':
46
 
                // Check permission:
47
 
                $current_User->check_perm( 'options', 'edit', true );
48
 
 
49
 
                param( 'submit', 'array', array() );
50
 
                if( isset($submit['restore_defaults']) )
51
 
                { // RESTORE DEFAULTS:
52
 
                        $Settings->delete_array( array(
53
 
                                'antispam_threshold_publish', 'antispam_threshold_delete', 'antispam_block_spam_referers' ) );
54
 
 
55
 
                        // Set "spam detection relevance weight" back to 1 for all plugins:
56
 
                        $changed = $DB->query( 'UPDATE T_plugins SET plug_spam_weight = 1' );
57
 
 
58
 
                        if( $Settings->dbupdate() || $changed )
59
 
                        {
60
 
                                $Messages->add( T_('Restored default values.'), 'success' );
 
26
        // Check permission
 
27
        $current_User->check_perm( 'options', 'edit', true );
 
28
        param( 'submit', 'array', array() );
 
29
        if( isset( $submit['restore_defaults'] ) )
 
30
        {
 
31
                // restore defaults
 
32
                $Settings->delete_array( array(
 
33
                        'antispam_threshold_publish', 'antispam_threshold_delete', 'antispam_block_spam_referers' )
 
34
                );
 
35
                // Set "spam detection relevance weight" back to 1 for all plugins
 
36
                $changed = $DB->query( 'UPDATE T_plugins SET plug_spam_weight = 1' );
 
37
 
 
38
                if( $Settings->dbupdate() || $changed )
 
39
                {
 
40
                        $Messages->add( T_('Restored default values.'), 'success' );
 
41
                }
 
42
                else
 
43
                {
 
44
                        $Messages->add( T_('Settings have not changed.'), 'note' );
 
45
                }
 
46
        }
 
47
        else
 
48
        {
 
49
                // update
 
50
                param_integer_range( 'antispam_threshold_publish', -100, 100, T_('The threshold must be between -100 and 100.') );
 
51
                $Settings->set( 'antispam_threshold_publish', $antispam_threshold_publish );
 
52
                param_integer_range( 'antispam_threshold_delete', -100, 100, T_('The threshold must be between -100 and 100.') );
 
53
                $Settings->set( 'antispam_threshold_delete', $antispam_threshold_delete );
 
54
                param( 'antispam_block_spam_referers', 'integer', 0 );
 
55
                $Settings->set( 'antispam_block_spam_referers', $antispam_block_spam_referers );
 
56
                param( 'antispam_report_to_central', 'integer', 0 );
 
57
                $Settings->set( 'antispam_report_to_central', $antispam_report_to_central );
 
58
                $changed_weight = false;
 
59
                param( 'antispam_plugin_spam_weight', 'array', array() );
 
60
                foreach( $antispam_plugin_spam_weight as $l_plugin_ID => $l_weight )
 
61
                {
 
62
                        if( ! is_numeric( $l_weight ) )
 
63
                        {
 
64
                                continue;
 
65
                        }
 
66
                        if( $l_weight < 0 || $l_weight > 100 )
 
67
                        {
 
68
                                param_error( 'antispam_plugin_spam_weight['.$l_plugin_ID.']', T_('Spam weight has to be in the range of 0-100.') );
 
69
                                continue;
 
70
                        }
 
71
                        if( $DB->query( 'UPDATE T_plugins SET plug_spam_weight = '.$DB->quote( $l_weight ).' WHERE plug_ID = '.(int)$l_plugin_ID ) )
 
72
                        {
 
73
                                $changed_weight = true;
 
74
                        }
 
75
                }
 
76
                if( $changed_weight )
 
77
                {
 
78
                        // Reload plugins table (for display)
 
79
                        $Plugins->loaded_plugins_table = false;
 
80
                        $Plugins->load_plugins_table();
 
81
                }
 
82
 
 
83
                if( ! $Messages->count('error') )
 
84
                {
 
85
                        if( $Settings->dbupdate() || $changed_weight )
 
86
                        {
 
87
                                $Messages->add( T_('Settings updated.'), 'success' );
61
88
                        }
62
89
                        else
63
90
                        {
64
91
                                $Messages->add( T_('Settings have not changed.'), 'note' );
65
92
                        }
66
93
                }
67
 
                else
68
 
                { // UPDATE:
69
 
                        param_integer_range( 'antispam_threshold_publish', -100, 100, T_('The threshold must be between -100 and 100.') );
70
 
                        $Settings->set( 'antispam_threshold_publish', $antispam_threshold_publish );
71
 
 
72
 
                        param_integer_range( 'antispam_threshold_delete', -100, 100, T_('The threshold must be between -100 and 100.') );
73
 
                        $Settings->set( 'antispam_threshold_delete', $antispam_threshold_delete );
74
 
 
75
 
                        param( 'antispam_block_spam_referers', 'integer', 0 );
76
 
                        $Settings->set( 'antispam_block_spam_referers', $antispam_block_spam_referers );
77
 
 
78
 
                        param( 'antispam_report_to_central', 'integer', 0 );
79
 
                        $Settings->set( 'antispam_report_to_central', $antispam_report_to_central );
80
 
 
81
 
                        $changed_weight = false;
82
 
                        param( 'antispam_plugin_spam_weight', 'array', array() );
83
 
                        foreach( $antispam_plugin_spam_weight as $l_plugin_ID => $l_weight )
84
 
                        {
85
 
                                if( ! is_numeric($l_weight) )
86
 
                                {
87
 
                                        continue;
88
 
                                }
89
 
                                if( $l_weight < 0 || $l_weight > 100 )
90
 
                                {
91
 
                                        param_error( 'antispam_plugin_spam_weight['.$l_plugin_ID.']', T_('Spam weight has to be in the range of 0-100.') );
92
 
                                        continue;
93
 
                                }
94
 
                                if( $DB->query( '
95
 
                                                UPDATE T_plugins
96
 
                                                   SET plug_spam_weight = '.$DB->quote($l_weight).'
97
 
                                                 WHERE plug_ID = '.(int)$l_plugin_ID ) )
98
 
                                {
99
 
                                        $changed_weight = true;
100
 
                                }
101
 
                        }
102
 
                        if( $changed_weight )
103
 
                        { // Reload plugins table (for display):
104
 
                                $Plugins->loaded_plugins_table = false;
105
 
                                $Plugins->load_plugins_table();
106
 
                        }
107
 
 
108
 
 
109
 
                        if( ! $Messages->count('error') )
110
 
                        {
111
 
                                if( $Settings->dbupdate() || $changed_weight )
112
 
                                {
113
 
                                        $Messages->add( T_('Settings updated.'), 'success' );
114
 
                                }
115
 
                                else
116
 
                                {
117
 
                                        $Messages->add( T_('Settings have not changed.'), 'note' );
118
 
                                }
119
 
                        }
120
 
                }
121
 
                break;
 
94
        }
 
95
        break;
122
96
}
123
97
 
124
 
 
125
 
// Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
 
98
// Display <html><head>...</head> section (should be done early if actions do not redirect)
126
99
$AdminUI->disp_html_head();
127
 
 
128
 
// Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
 
100
// Display title, menu, messages, etc... (messages MUST be displayed AFTER the actions)
129
101
$AdminUI->disp_body_top();
130
 
 
131
 
// Begin payload block:
 
102
// Begin payload block
132
103
$AdminUI->disp_payload_begin();
133
 
 
134
 
// Display VIEW:
135
 
$AdminUI->disp_view( 'antispam/views/_antispam_settings.form.php' );
136
 
 
137
 
// End payload block:
 
104
// Display final (unbound) menu depth
 
105
echo $AdminUI->get_html_menu( array( 'tools', 'antispam' ), 'menu3' );
 
106
 
 
107
// Display VIEW
 
108
$AdminUI->disp_view( 'antispam/views/_settings.form.php' );
 
109
 
 
110
// End payload block
138
111
$AdminUI->disp_payload_end();
139
 
 
140
 
// Display body bottom, debug info and close </html>:
 
112
// Display body bottom, debug info, close </html>
141
113
$AdminUI->disp_global_footer();
142
114
 
143
 
?>
 
 
b'\\ No newline at end of file'
 
115
?>