/** * Handle incoming requests for the introspection document */ public function act_introspection() { Utils::check_request_method(array('GET', 'HEAD', 'POST')); $cache_xml = null; if (Cache::has('atom:introspection:xml')) { $cache_xml = Cache::get('atom:introspection:xml'); $cache_xml = simplexml_load_string($cache_xml); } if ($cache_xml instanceof SimpleXMLElement) { $xml = $cache_xml; } else { $xml = new SimpleXMLElement('<service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom"></service>'); $service_workspace = $xml->addChild('workspace'); $workspace_title = $service_workspace->addChild('atom:title', Utils::htmlspecialchars(Options::get('title')), 'http://www.w3.org/2005/Atom'); $workspace_collection = $service_workspace->addChild('collection'); $workspace_collection->addAttribute('href', URL::get('atom_feed', 'index=1')); $collection_title = $workspace_collection->addChild('atom:title', 'Blog Entries', 'http://www.w3.org/2005/Atom'); $collection_accept = $workspace_collection->addChild('accept', 'application/atom+xml;type=entry'); Cache::set('atom:introspection:xml', $xml->asXML()); } Plugins::act('atom_introspection', $xml, $this->handler_vars); $xml = $xml->asXML(); ob_clean(); header('Content-Type: application/atomsvc+xml'); print $xml; }
public function action_admin_moderate_comments($action, Comments $comments, AdminHandler $handler) { $false_positives = array(); $false_negatives = array(); foreach ($comments as $comment) { switch ($action) { case 'spam': if (($comment->status == Comment::STATUS_APPROVED || $comment->status == Comment::STATUS_UNAPPROVED) && isset($comment->info->defensio_signature)) { $false_negatives[] = $comment->info->defensio_signature; } break; case 'approve': if ($comment->status == Comment::STATUS_SPAM && isset($comment->info->defensio_signature)) { $false_positives[] = $comment->info->defensio_signature; } break; } } try { if ($false_positives) { $this->defensio->report_false_positives(array('signatures' => $false_positives)); Cache::expire('defensio_stats'); $count = count($false_positives); Session::notice(sprintf(_n('Reported %d false positive to Defensio', 'Reported %d false positives to Defensio', $count, 'defensio'), $count)); } if ($false_negatives) { $this->defensio->report_false_negatives(array('signatures' => $false_negatives)); Cache::expire('defensio_stats'); $count = count($false_negatives); Session::notice(sprintf(_n('Reported %d false negative to Defensio', 'Reported %d false negatives to Defensio', $count, 'defensio'), $count)); } } catch (Exception $e) { EventLog::log($e->getMessage(), 'notice', 'comment', 'Defensio'); } }