[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Antispam, a plugin for Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
| 13 | dcPage::check('admin'); |
---|
| 14 | |
---|
| 15 | dcAntispam::initFilters(); |
---|
| 16 | $filters = dcAntispam::$filters->getFilters(); |
---|
| 17 | |
---|
| 18 | $page_name = __('Antispam'); |
---|
| 19 | $filter_gui = false; |
---|
| 20 | $default_tab = null; |
---|
| 21 | |
---|
| 22 | try |
---|
| 23 | { |
---|
| 24 | # Show filter configuration GUI |
---|
| 25 | if (!empty($_GET['f'])) |
---|
| 26 | { |
---|
| 27 | if (!isset($filters[$_GET['f']])) { |
---|
| 28 | throw new Exception(__('Filter does not exist.')); |
---|
| 29 | } |
---|
[223] | 30 | |
---|
[0] | 31 | if (!$filters[$_GET['f']]->hasGUI()) { |
---|
| 32 | throw new Exception(__('Filter has no user interface.')); |
---|
| 33 | } |
---|
[223] | 34 | |
---|
[0] | 35 | $filter = $filters[$_GET['f']]; |
---|
| 36 | $filter_gui = $filter->gui($filter->guiURL()); |
---|
| 37 | } |
---|
[223] | 38 | |
---|
[0] | 39 | # Remove all spam |
---|
[1052] | 40 | if (!empty($_POST['delete_all'])) |
---|
[0] | 41 | { |
---|
| 42 | $ts = dt::str('%Y-%m-%d %H:%M:%S',$_POST['ts'],$core->blog->settings->system->blog_timezone); |
---|
[223] | 43 | |
---|
[0] | 44 | dcAntispam::delAllSpam($core,$ts); |
---|
[2256] | 45 | |
---|
| 46 | dcPage::addSuccessNotice(__('Spam comments have been successfully deleted.')); |
---|
| 47 | http::redirect($p_url); |
---|
[0] | 48 | } |
---|
[223] | 49 | |
---|
[0] | 50 | # Update filters |
---|
| 51 | if (isset($_POST['filters_upd'])) |
---|
| 52 | { |
---|
| 53 | $filters_opt = array(); |
---|
| 54 | $i = 0; |
---|
| 55 | foreach ($filters as $fid => $f) { |
---|
| 56 | $filters_opt[$fid] = array(false,$i); |
---|
| 57 | $i++; |
---|
| 58 | } |
---|
[223] | 59 | |
---|
[0] | 60 | # Enable active filters |
---|
| 61 | if (isset($_POST['filters_active']) && is_array($_POST['filters_active'])) { |
---|
| 62 | foreach ($_POST['filters_active'] as $v) { |
---|
| 63 | $filters_opt[$v][0] = true; |
---|
| 64 | } |
---|
| 65 | } |
---|
[223] | 66 | |
---|
[0] | 67 | # Order filters |
---|
| 68 | if (!empty($_POST['f_order']) && empty($_POST['filters_order'])) |
---|
| 69 | { |
---|
| 70 | $order = $_POST['f_order']; |
---|
| 71 | asort($order); |
---|
| 72 | $order = array_keys($order); |
---|
| 73 | } |
---|
| 74 | elseif (!empty($_POST['filters_order'])) |
---|
| 75 | { |
---|
| 76 | $order = explode(',',trim($_POST['filters_order'],',')); |
---|
| 77 | } |
---|
[223] | 78 | |
---|
[0] | 79 | if (isset($order)) { |
---|
| 80 | foreach ($order as $i => $f) { |
---|
| 81 | $filters_opt[$f][1] = $i; |
---|
| 82 | } |
---|
| 83 | } |
---|
[223] | 84 | |
---|
[0] | 85 | # Set auto delete flag |
---|
| 86 | if (isset($_POST['filters_auto_del']) && is_array($_POST['filters_auto_del'])) { |
---|
| 87 | foreach ($_POST['filters_auto_del'] as $v) { |
---|
| 88 | $filters_opt[$v][2] = true; |
---|
| 89 | } |
---|
| 90 | } |
---|
[223] | 91 | |
---|
[0] | 92 | dcAntispam::$filters->saveFilterOpts($filters_opt); |
---|
[2256] | 93 | |
---|
| 94 | dcPage::addSuccessNotice(__('Filters configuration has been successfully saved.')); |
---|
| 95 | http::redirect($p_url); |
---|
[0] | 96 | } |
---|
| 97 | } |
---|
| 98 | catch (Exception $e) |
---|
| 99 | { |
---|
| 100 | $core->error->add($e->getMessage()); |
---|
| 101 | } |
---|
| 102 | ?> |
---|
| 103 | <html> |
---|
| 104 | <head> |
---|
[892] | 105 | <title><?php echo ($filter_gui !== false ? sprintf(__('%s configuration'),$filter->name).' - ' : '').$page_name; ?></title> |
---|
[1040] | 106 | <script type="text/javascript"> |
---|
| 107 | //<![CDATA[ |
---|
| 108 | <?php |
---|
| 109 | echo dcPage::jsVar('dotclear.msg.confirm_spam_delete',__('Are you sure you want to delete all spams?')); |
---|
| 110 | ?> |
---|
| 111 | //]]> |
---|
| 112 | </script> |
---|
[0] | 113 | <?php |
---|
[1130] | 114 | echo dcPage::jsPageTabs($default_tab); |
---|
| 115 | $core->auth->user_prefs->addWorkspace('accessibility'); |
---|
| 116 | if (!$core->auth->user_prefs->accessibility->nodragdrop) { |
---|
| 117 | echo |
---|
| 118 | dcPage::jsLoad('js/jquery/jquery-ui.custom.js'). |
---|
[2495] | 119 | dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js'). |
---|
[1130] | 120 | dcPage::jsLoad('index.php?pf=antispam/antispam.js'); |
---|
[1127] | 121 | } |
---|
[0] | 122 | ?> |
---|
| 123 | <link rel="stylesheet" type="text/css" href="index.php?pf=antispam/style.css" /> |
---|
| 124 | </head> |
---|
| 125 | <body> |
---|
| 126 | <?php |
---|
| 127 | |
---|
| 128 | if ($filter_gui !== false) |
---|
| 129 | { |
---|
[1358] | 130 | echo dcPage::breadcrumb( |
---|
[1339] | 131 | array( |
---|
| 132 | __('Plugins') => '', |
---|
| 133 | $page_name => $p_url, |
---|
[2166] | 134 | sprintf(__('%s filter configuration'),$filter->name) => '' |
---|
[2256] | 135 | )). |
---|
| 136 | dcPage::notices(); |
---|
[223] | 137 | |
---|
[2122] | 138 | echo '<p><a href="plugin.php?p=antispam" class="back">'.__('Back to filters list').'</a></p>'; |
---|
| 139 | |
---|
[0] | 140 | echo $filter_gui; |
---|
[2322] | 141 | |
---|
| 142 | if ($filter->help) { |
---|
| 143 | dcPage::helpBlock($filter->help); |
---|
| 144 | } |
---|
[0] | 145 | } |
---|
| 146 | else |
---|
| 147 | { |
---|
[1358] | 148 | echo dcPage::breadcrumb( |
---|
[1339] | 149 | array( |
---|
| 150 | __('Plugins') => '', |
---|
[2166] | 151 | $page_name => '' |
---|
[2256] | 152 | )). |
---|
| 153 | dcPage::notices(); |
---|
[505] | 154 | |
---|
[0] | 155 | # Information |
---|
| 156 | $spam_count = dcAntispam::countSpam($core); |
---|
| 157 | $published_count = dcAntispam::countPublishedComments($core); |
---|
| 158 | $moderationTTL = $core->blog->settings->antispam->antispam_moderation_ttl; |
---|
[223] | 159 | |
---|
[0] | 160 | echo |
---|
[536] | 161 | '<form action="'.$p_url.'" method="post" class="fieldset">'. |
---|
[1941] | 162 | '<h3>'.__('Information').'</h3>'; |
---|
[223] | 163 | |
---|
[0] | 164 | echo |
---|
| 165 | '<ul class="spaminfo">'. |
---|
| 166 | '<li class="spamcount"><a href="comments.php?status=-2">'.__('Junk comments:').'</a> '. |
---|
| 167 | '<strong>'.$spam_count.'</strong></li>'. |
---|
| 168 | '<li class="hamcount"><a href="comments.php?status=1">'.__('Published comments:').'</a> '. |
---|
| 169 | $published_count.'</li>'. |
---|
| 170 | '</ul>'; |
---|
[223] | 171 | |
---|
[0] | 172 | if ($spam_count > 0) |
---|
| 173 | { |
---|
| 174 | echo |
---|
| 175 | '<p>'.$core->formNonce(). |
---|
| 176 | form::hidden('ts',time()). |
---|
[1052] | 177 | '<input name="delete_all" class="delete" type="submit" value="'.__('Delete all spams').'" /></p>'; |
---|
[0] | 178 | } |
---|
| 179 | if ($moderationTTL != null && $moderationTTL >=0) { |
---|
[565] | 180 | echo '<p>'.sprintf(__('All spam comments older than %s day(s) will be automatically deleted.'), $moderationTTL).' '. |
---|
[1474] | 181 | sprintf(__('You can modify this duration in the %s'),'<a href="blog_pref.php#antispam_moderation_ttl"> '.__('Blog settings').'</a>'). |
---|
[1518] | 182 | '.</p>'; |
---|
[0] | 183 | } |
---|
[536] | 184 | echo '</form>'; |
---|
[223] | 185 | |
---|
| 186 | |
---|
[0] | 187 | # Filters |
---|
| 188 | echo |
---|
[1423] | 189 | '<form action="'.$p_url.'" method="post" id="filters-list-form">'; |
---|
[223] | 190 | |
---|
[0] | 191 | if (!empty($_GET['upd'])) { |
---|
[1553] | 192 | dcPage::success(__('Filters configuration has been successfully saved.')); |
---|
[0] | 193 | } |
---|
[223] | 194 | |
---|
[0] | 195 | echo |
---|
[2002] | 196 | '<div class="table-outer">'. |
---|
[0] | 197 | '<table class="dragable">'. |
---|
[1341] | 198 | '<caption class="as_h3">'.__('Available spam filters').'</caption>'. |
---|
[0] | 199 | '<thead><tr>'. |
---|
| 200 | '<th>'.__('Order').'</th>'. |
---|
| 201 | '<th>'.__('Active').'</th>'. |
---|
[223] | 202 | '<th>'.__('Auto Del.').'</th>'. |
---|
[0] | 203 | '<th class="nowrap">'.__('Filter name').'</th>'. |
---|
| 204 | '<th colspan="2">'.__('Description').'</th>'. |
---|
| 205 | '</tr></thead>'. |
---|
| 206 | '<tbody id="filters-list" >'; |
---|
[223] | 207 | |
---|
[0] | 208 | $i = 0; |
---|
| 209 | foreach ($filters as $fid => $f) |
---|
| 210 | { |
---|
| 211 | $gui_link = ' '; |
---|
| 212 | if ($f->hasGUI()) { |
---|
| 213 | $gui_link = |
---|
| 214 | '<a href="'.html::escapeHTML($f->guiURL()).'">'. |
---|
| 215 | '<img src="images/edit-mini.png" alt="'.__('Filter configuration').'" '. |
---|
| 216 | 'title="'.__('Filter configuration').'" /></a>'; |
---|
| 217 | } |
---|
[223] | 218 | |
---|
[0] | 219 | echo |
---|
| 220 | '<tr class="line'.($f->active ? '' : ' offline').'" id="f_'.$fid.'">'. |
---|
[1130] | 221 | '<td class="handle">'.form::field(array('f_order['.$fid.']'),2,5,(string) $i, 'position', '', false, 'title="'.__('position').'"').'</td>'. |
---|
[223] | 222 | '<td class="nowrap">'.form::checkbox(array('filters_active[]'),$fid,$f->active, '', '', false, 'title="'.__('Active').'"').'</td>'. |
---|
| 223 | '<td class="nowrap">'.form::checkbox(array('filters_auto_del[]'),$fid,$f->auto_delete, '', '', false, 'title="'.__('Auto Del.').'"').'</td>'. |
---|
[1474] | 224 | '<td class="nowrap" scope="row">'.$f->name.'</td>'. |
---|
[0] | 225 | '<td class="maximal">'.$f->description.'</td>'. |
---|
| 226 | '<td class="status">'.$gui_link.'</td>'. |
---|
| 227 | '</tr>'; |
---|
| 228 | $i++; |
---|
| 229 | } |
---|
| 230 | echo |
---|
[2002] | 231 | '</tbody></table></div>'. |
---|
[0] | 232 | '<p>'.form::hidden('filters_order',''). |
---|
| 233 | $core->formNonce(). |
---|
| 234 | '<input type="submit" name="filters_upd" value="'.__('Save').'" /></p>'. |
---|
[536] | 235 | '</form>'; |
---|
[223] | 236 | |
---|
| 237 | |
---|
[0] | 238 | # Syndication |
---|
| 239 | if (DC_ADMIN_URL) |
---|
| 240 | { |
---|
[776] | 241 | $ham_feed = $core->blog->url.$core->url->getURLFor( |
---|
| 242 | 'hamfeed', |
---|
| 243 | $code = dcAntispam::getUserCode($core) |
---|
| 244 | ); |
---|
| 245 | $spam_feed = $core->blog->url.$core->url->getURLFor( |
---|
| 246 | 'spamfeed', |
---|
| 247 | $code = dcAntispam::getUserCode($core) |
---|
| 248 | ); |
---|
[223] | 249 | |
---|
[0] | 250 | echo |
---|
[536] | 251 | '<h3>'.__('Syndication').'</h3>'. |
---|
[0] | 252 | '<ul class="spaminfo">'. |
---|
| 253 | '<li class="feed"><a href="'.$spam_feed.'">'.__('Junk comments RSS feed').'</a></li>'. |
---|
| 254 | '<li class="feed"><a href="'.$ham_feed.'">'.__('Published comments RSS feed').'</a></li>'. |
---|
[536] | 255 | '</ul>'; |
---|
[0] | 256 | } |
---|
[2322] | 257 | |
---|
| 258 | dcPage::helpBlock('antispam','antispam-filters'); |
---|
[0] | 259 | } |
---|
[2322] | 260 | |
---|
[0] | 261 | ?> |
---|
| 262 | |
---|
| 263 | </body> |
---|
[2495] | 264 | </html> |
---|