/** * Display ban icon, which goes to the antispam screen with keyword=author_url * * @param boolean true if create ajax button * @param boolean true if need permission check, because it wasn't check before * @param glue between url params * @return link on success, false otherwise */ function banurl_link($redirect_to, $ajax_button = false, $check_perm = true, $glue = '&', $save_context = true) { global $current_User, $admin_url; if (!is_logged_in(false)) { return false; } //$Item = & $this->get_Item(); if ($check_perm && !$current_User->check_perm('spamblacklist', 'edit')) { // if current user has no permission to edit spams return false; } if ($save_context) { if ($redirect_to == NULL) { $redirect_to = rawurlencode(regenerate_url('', 'filter=restore', '', '&')); } $redirect_to = $glue . 'redirect_to=' . $redirect_to; } else { $redirect_to = ''; } // TODO: really ban the base domain! - not by keyword $authorurl = rawurlencode(get_ban_domain($this->get_author_url())); $ban_url = $admin_url . '?ctrl=antispam&action=ban&keyword=' . $authorurl . $redirect_to . '&' . url_crumb('antispam'); if ($ajax_button) { echo ' <a id="ban_url" href="' . $ban_url . '" onclick="ban_url(\'' . $authorurl . '\'); return false;">' . get_icon('ban') . '</a>'; } else { echo ' <a href="' . $ban_url . '">' . get_icon('ban') . '</a> '; } }
// Display a pingback: echo T_('Pingback from'); break; } echo ' <strong>'; $Comment->author(); echo '</strong>'; $comment_Item =& $Comment->get_Item(); echo ' ' . T_('in response to') . ' <a href="?ctrl=items&blog=' . $comment_Item->blog_ID . '&p=' . $comment_Item->ID . '"><strong>' . $comment_Item->dget('title') . '</strong></a>'; echo '</h3>'; echo '<div class="notes">'; if ($Comment->author_url('', 'Url: <span class="bUrl">', '</span>')) { if ($current_User->check_perm('spamblacklist', 'edit')) { // There is an URL and we have permission to ban... // TODO: really ban the base domain! - not by keyword echo ' <a href="' . $dispatcher . '?ctrl=antispam&action=ban&keyword=' . rawurlencode(get_ban_domain($Comment->author_url)) . '">' . get_icon('ban') . '</a> '; } echo ' • '; } $Comment->author_email('', 'Email: <span class="bEmail">', '</span> • '); $Comment->author_ip('IP: <span class="bIP">', '</span> • '); $Comment->spam_karma(T_('Spam Karma') . ': %s%', T_('No Spam Karma')); echo '</div>'; ?> <div class="small"> <?php $Comment->content(); ?> </div>
/** * Add a javascript ban action icon after the given url * * @param string url * @return string the url with ban icon */ function add_jsban($url) { global $admin_url; $url = rawurlencode(get_ban_domain($url)); $ban_url = $admin_url . '?ctrl=antispam&action=ban&keyword=' . $url . '&' . url_crumb('antispam'); return '<a id="ban_url" href="' . $ban_url . '" onclick="ban_url(\'' . $url . '\'); return false;">' . get_icon('ban') . '</a>'; }
/** * Test {@link get_ban_domain()} */ function test_get_ban_domain() { $this->assertEqual(get_ban_domain('www.example.com'), '.example.com'); $this->assertEqual(get_ban_domain('www2.example.com'), '.example.com'); $this->assertEqual(get_ban_domain('http://hostname'), '//hostname'); $this->assertEqual(get_ban_domain('http://hostname.tld'), '//hostname.tld'); $this->assertEqual(get_ban_domain('http://www.example.com'), '.example.com'); $this->assertEqual(get_ban_domain('http://www2.example.com'), '.example.com'); $this->assertEqual(get_ban_domain('http://www2.example.com/'), '.example.com'); $this->assertEqual(get_ban_domain('http://www.example.com/path/'), '.example.com/path/'); $this->assertEqual(get_ban_domain('http://www.example.com/path/page.html'), '.example.com/path/'); $this->assertEqual(get_ban_domain('http://www2.example.com/path/?query=1'), '.example.com/path/'); $this->assertEqual(get_ban_domain('http://www2.example.com/path/page.html?query=1'), '.example.com/path/'); $this->assertEqual(get_ban_domain('http://example.com/path/'), '//example.com/path/'); $this->assertEqual(get_ban_domain('http://example.com/path/sub/?query=1'), '//example.com/path/sub/'); $this->assertEqual(get_ban_domain('http://example.com/path/sub/page.html'), '//example.com/path/sub/'); $this->assertEqual(get_ban_domain('http://example.com/path/sub/page.html?query=1'), '//example.com/path/sub/'); $this->assertEqual(get_ban_domain('http://example.com:8080/path/sub/page.html?query=1'), '//example.com:8080/path/sub/'); $this->assertEqual(get_ban_domain('https://www.example.com'), '.example.com'); $this->assertEqual(get_ban_domain('https://www2.example.com'), '.example.com'); $this->assertEqual(get_ban_domain('http://sub2.sub1.example.com'), '//sub2.sub1.example.com'); $this->assertEqual(get_ban_domain('http://sub3.sub2.sub1.example.com'), '//sub3.sub2.sub1.example.com'); $this->assertEqual(get_ban_domain('http://sub3.sub2.sub1.example.com'), '//sub3.sub2.sub1.example.com'); $this->assertIdentical(get_ban_domain(''), false); // Anchor after domain name, used by spammers: $this->assertEqual(get_ban_domain('http://example.com#anchor'), '//example.com'); $this->assertEqual(get_ban_domain('http://example.com/#anchor'), '//example.com'); }
/** * @uses get_ban_domain() * @param string URL * @return string Link to ban the URL */ function referer_ban_link($uri) { return '<a href="?ctrl=antispam&action=ban&keyword=' . rawurlencode(get_ban_domain($uri)) . '" title="' . T_('Ban this domain!') . '">' . get_icon('ban') . '</a>'; }
$Messages->add(T_('Quick moderation not available.')); } // Check the secret parameter (This doubles as a CRUMB) if ($secret != $posted_Comment->get('secret') || empty($secret)) { // Invalid secret, no moderation allowed here, go to regular form with regular login requirements: $Messages->add(T_('Invalid secret key. Quick moderation not available.')); } if ($posted_Comment->status == 'trash') { // Comment is already in trash $Messages->add(T_('The comment was already deleted. Quick moderation not available.')); } if ($Messages->has_errors()) { // quick moderation is not available, redirect to normal edit form header_redirect($to_comment_edit); } $antispam_url = $admin_url . '?ctrl=antispam&action=ban&keyword=' . rawurlencode(get_ban_domain($posted_Comment->author_url)) . '&' . url_crumb('antispam'); // perform action if action is not null switch ($action) { case 'publish': $posted_Comment->set('status', 'published'); // Comment moderation is done, handle moderation "secret" $posted_Comment->handle_qm_secret(); $posted_Comment->dbupdate(); // Commit update to the DB $posted_Comment->handle_notifications(); $Messages->add(T_('Comment has been published.'), 'success'); header_redirect($to_dashboard); /* exited */ break; case 'deprecate': $posted_Comment->set('status', 'deprecated');