OR comment_author_email LIKE ' . $DB->quote('%' . utf8_strtolower($keyword) . '%') . ' OR comment_author_url LIKE ' . $DB->quote('%' . $keyword . '%') . ' OR comment_content LIKE ' . $DB->quote('%' . $keyword . '%') . ')'; // asimo> we don't need transaction here $query = 'SELECT comment_ID FROM T_comments WHERE ' . $keyword_cond . $del_condition; $deleted_ids = $DB->get_col($query, 0, 'Get comment ids awaiting for delete'); $r = count($deleted_ids); $deleted_ids = implode(',', $deleted_ids); // Delete all comments data from DB Comment::db_delete_where('Comment', $keyword_cond . $del_condition); $Messages->add(sprintf(T_('Deleted %d comments matching «%s».'), $r, htmlspecialchars($keyword)), 'success'); } if ($blacklist_locally) { // Local blacklist: if (antispam_create($keyword)) { // Success $Messages->add(sprintf(T_('The keyword «%s» has been blacklisted locally.'), htmlspecialchars($keyword)), 'success'); } else { // Failed $Messages->add(sprintf(T_('Failed to add the keyword %s to black list locally.'), '<b>' . htmlspecialchars($keyword) . '</b>'), 'error'); } } if ($report) { // Report this keyword as abuse remotely: antispam_report_abuse($keyword); } if (!$blacklist_locally && !$report && !$delhits && !$delcomments) { // If no action has been selected $Messages->add(T_('Please select at least one action to ban the keyword.'), 'error'); }
/** * Request abuse list from central blacklist. * * @return boolean true = success, false = error */ function antispam_poll_abuse() { global $Messages, $Settings, $baseurl, $debug, $antispamsrv_host, $antispamsrv_port, $antispamsrv_uri; // Construct XML-RPC client: load_funcs('xmlrpc/model/_xmlrpc.funcs.php'); $client = new xmlrpc_client($antispamsrv_uri, $antispamsrv_host, $antispamsrv_port); $client->debug = $debug; // Get datetime from last update, because we only want newer stuff... $last_update = $Settings->get('antispam_last_update'); // Encode it in the XML-RPC format $Messages->add(T_('Latest update timestamp') . ': ' . $last_update, 'note'); $startat = mysql2date('Ymd\\TH:i:s', $last_update); //$startat = iso8601_encode( mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4)) ); // Construct XML-RPC message: $message = new xmlrpcmsg('b2evo.pollabuse', array(new xmlrpcval(0, 'int'), new xmlrpcval('annonymous', 'string'), new xmlrpcval('nopassrequired', 'string'), new xmlrpcval($startat, 'dateTime.iso8601'), new xmlrpcval(0, 'int'))); $Messages->add(sprintf(T_('Requesting abuse list from %s...'), $antispamsrv_host), 'note'); $result = $client->send($message); if ($ret = xmlrpc_logresult($result, $Messages)) { // Response is not an error, let's process it: $response = $result->value(); if ($response->kindOf() == 'struct') { // Decode struct: $response = xmlrpc_decode_recurse($response); if (!isset($response['strings']) || !isset($response['lasttimestamp'])) { $Messages->add(T_('Incomplete reponse.'), 'error'); $ret = false; } else { // Start registering strings: $value = $response['strings']; if (count($value) == 0) { $Messages->add(T_('No new blacklisted strings are available.'), 'note'); } else { // We got an array of strings: $Messages->add(T_('Adding strings to local blacklist:'), 'note'); foreach ($value as $banned_string) { if (antispam_create($banned_string, 'central')) { // Creation successed $Messages->add(T_('Adding:') . ' «' . $banned_string . '»: ' . T_('OK.'), 'note'); } else { // Was already handled $Messages->add(T_('Adding:') . ' «' . $banned_string . '»: ' . T_('Not necessary! (Already handled)'), 'note'); antispam_update_source($banned_string, 'central'); } } // Store latest timestamp: $endedat = date('Y-m-d H:i:s', iso8601_decode($response['lasttimestamp'])); $Messages->add(T_('New latest update timestamp') . ': ' . $endedat, 'note'); $Settings->set('antispam_last_update', $endedat); $Settings->dbupdate(); } $Messages->add(T_('Done.'), 'success'); } } else { $Messages->add(T_('Invalid reponse.'), 'error'); $ret = false; } } return $ret; }