summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/spam_filter/controllers/admin_spam_filter.php106
-rw-r--r--modules/spam_filter/helpers/spam_filter.php33
-rw-r--r--modules/spam_filter/helpers/spam_filter_installer.php33
-rw-r--r--modules/spam_filter/helpers/spam_filter_menu.php28
-rw-r--r--modules/spam_filter/libraries/SpamFilter.php100
-rw-r--r--modules/spam_filter/libraries/drivers/Akismet.php151
-rw-r--r--modules/spam_filter/libraries/drivers/Mollom.php83
-rw-r--r--modules/spam_filter/libraries/drivers/SpamFilter.php52
-rw-r--r--modules/spam_filter/module.info3
-rw-r--r--modules/spam_filter/tests/Akismet_Driver_Test.php112
-rw-r--r--modules/spam_filter/tests/SpamFilter_Helper_Test.php32
-rw-r--r--modules/spam_filter/views/admin_spam_filter.html.php48
-rw-r--r--modules/spam_filter/views/admin_spam_filter_akismet.html.php12
-rw-r--r--modules/spam_filter/views/admin_spam_filter_mollom.html.php19
14 files changed, 0 insertions, 812 deletions
diff --git a/modules/spam_filter/controllers/admin_spam_filter.php b/modules/spam_filter/controllers/admin_spam_filter.php
deleted file mode 100644
index 30492a12..00000000
--- a/modules/spam_filter/controllers/admin_spam_filter.php
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2008 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Admin_Spam_Filter_Controller extends Admin_Controller {
- public function index() {
- $view = new Admin_View("admin.html");
- $view->content = $this->get_edit_form();
-
- print $view;
- }
-
- public function get_edit_form($driver_name=null, $post=null) {
- $form = new View("admin_spam_filter.html");
-
- $drivers = spam_filter::get_driver_names();
- $current_driver = empty($driver_name) ? module::get_var("spam_filter", "driver") : $driver_name;
- $current_driver = !empty($current_driver) ? $current_driver : $drivers[0];
-
- $selected = 0;
- $driver_options = array();
- foreach ($drivers as $idx => $driver) {
- if ($driver == $current_driver) {
- $selected = $idx;
- }
- $driver_options[] = array("name" => $driver, "selected" => $driver == $current_driver);
- }
- $form->drivers = $driver_options;
-
- $form->filter_data = empty($selected) ? "" :
- SpamFilter::instance($current_driver)->get_admin_fields($post);
-
- return $form;
- }
-
- public function edit() {
- $selected = Input::instance()->post("drivers");
- $drivers = spam_filter::get_driver_names();
- $driver_name = $drivers[$selected];
-
- if (!empty($selected)) {
- $post = new Validation($_POST);
- SpamFilter::instance($driver_name)->get_validation_rules($post);
- if ($post->validate()) {
- module::set_var("spam_filter", "driver", $drivers[$selected]);
- SpamFilter::instance($driver_name)->set_api_data($post);
-
- log::success("spam_filter", _("Spam Filter configured"));
- message::success(_("Spam Filter configured"));
- print json_encode(
- array("result" => "success",
- "location" => url::site("admin/spam_filter")));
- } else {
- $form = $this->get_edit_form($driver_name, $post);
- print json_encode(
- array("result" => "error",
- "form" => $form->__toString()));
-
- }
- } else {
- $form = $this->get_edit_form();
- print json_encode(
- array("result" => "continue",
- "form" => $form->__toString()));
- }
- }
-
- public function callback() {
- $driver_name = Input::instance()->post("driver");
-
- $selected = $this->_get_selected_index($driver_name);
- if (!empty($selected)) {
- print SpamFilter::instance($driver_name)->get_admin_fields();
- } else {
- print "";
- }
- }
-
- public function _get_selected_index($driver_name) {
- $drivers = spam_filter::get_driver_names();
-
- $selected = 0;
- foreach ($drivers as $idx => $driver) {
- if ($driver == $driver_name) {
- $selected = $idx;
- }
- }
-
- return $selected;
- }
-} \ No newline at end of file
diff --git a/modules/spam_filter/helpers/spam_filter.php b/modules/spam_filter/helpers/spam_filter.php
deleted file mode 100644
index 2531392b..00000000
--- a/modules/spam_filter/helpers/spam_filter.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2008 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class spam_filter {
- public static function get_driver_names() {
- $drivers = array(_("Select Driver"));
- foreach (glob(MODPATH . "spam_filter/libraries/drivers/*.php") as $file) {
- if (preg_match("#spam_filter/libraries/drivers/(.*).php$#", $file, $matches)) {
- if ($matches[1] != "SpamFilter") {
- $drivers[] = $matches[1];
- }
- }
- }
-
- return $drivers;
- }
-} \ No newline at end of file
diff --git a/modules/spam_filter/helpers/spam_filter_installer.php b/modules/spam_filter/helpers/spam_filter_installer.php
deleted file mode 100644
index 4d0edde9..00000000
--- a/modules/spam_filter/helpers/spam_filter_installer.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2008 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class spam_filter_installer {
-
- public static function install() {
- $version = module::get_version("spam_filter");
-
- if ($version == 0) {
- module::set_version("spam_filter", 1);
- }
- }
-
- public static function uninstall() {
- module::delete("spam_filter");
- }
-}
diff --git a/modules/spam_filter/helpers/spam_filter_menu.php b/modules/spam_filter/helpers/spam_filter_menu.php
deleted file mode 100644
index 7788063c..00000000
--- a/modules/spam_filter/helpers/spam_filter_menu.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2008 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class spam_filter_menu_Core {
- public static function admin($menu, $theme) {
- $menu->get("settings_menu")
- ->append(Menu::factory("link")
- ->id("spam_filter")
- ->label(_("Spam Filtering"))
- ->url(url::site("admin/spam_filter")));
- }
-}
diff --git a/modules/spam_filter/libraries/SpamFilter.php b/modules/spam_filter/libraries/SpamFilter.php
deleted file mode 100644
index 3485bf75..00000000
--- a/modules/spam_filter/libraries/SpamFilter.php
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2008 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class SpamFilter_Core {
-
- private static $spam_filter;
-
- protected $driver;
-
- public static function instance($driver=null) {
- if (empty(self::$spam_filter)) {
- self::$spam_filter = new SpamFilter($driver);
- }
- return self::$spam_filter;
- }
-
- protected function __construct($driver=null) {
- if (empty($driver)) {
- $driver = module::get_var("spam_filter", "driver", null);
- }
-
- // Set driver name
- $driver = "{$driver}_Driver";
-
- // Load the driver
- if (!Kohana::auto_load($driver)) {
- throw new Exception("@todo SPAM FILTER DRIVER NO FOUND");
- }
-
- // Initialize the driver
- $this->driver = new $driver();
-
- // Validate the driver
- if (!($this->driver instanceof SpamFilter_Driver)) {
- throw new Exception("@todo SPAM FILTER DRIVER NOT IMPLEMENTED");
- }
- }
-
- public function check_comment($comment) {
- $this->_is_initialized();
-
- $is_valid = $this->driver->check_comment($comment);
- $comment->state = $is_valid ? "published" : "spam";
- return $is_valid;
- }
-
- public function submit_spam($comment) {
- $this->_is_initialized();
-
- return $this->driver->submit_spam($comment);
- }
-
- public function submit_ham($comment) {
- $this->_is_initialized();
-
- return $this->driver->submit_ham($comment);
- }
-
- public function get_statistics() {
- $this->_is_initialized();
- return $this->driver->get_statistics();
- }
-
- public function get_admin_fields($post=null) {
- return $this->driver->get_admin_fields($post);
- }
-
- public function get_validation_rules($post) {
- $this->driver->get_validation_rules($post);
- }
-
- public function set_api_data($post) {
- $this->driver->set_api_data($post);
- module::set_var("spam_filter", "key_verified", true);
- }
-
- private function _is_initialized() {
- $key_verified = module::get_var("spam_filter", "key_verified", null);
- if (empty($key_verified)) {
- throw new Exception("@todo SPAM FILTER NOT INITIALIZED");
- }
- }
-}
-
diff --git a/modules/spam_filter/libraries/drivers/Akismet.php b/modules/spam_filter/libraries/drivers/Akismet.php
deleted file mode 100644
index 67b4a88d..00000000
--- a/modules/spam_filter/libraries/drivers/Akismet.php
+++ /dev/null
@@ -1,151 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2008 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Akismet_Driver extends SpamFilter_Driver {
- // Lets not send everything to Akismet
- // @todo provide an admin option to send or not send this information
- private static $white_list = array("HTTP_USER_AGENT",
- "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
- "HTTP_ACCEPT_LANGUAGE", "HTTP_CONNECTION", "HTTP_HOST",
- "HTTP_KEEP_ALIVE", "HTTP_REFERER", "HTTP_USER_AGENT", "QUERY_STRING",
- "REMOTE_ADDR", "REMOTE_HOST", "REMOTE_PORT" );
-
- public function check_comment($comment) {
- $request = $this->_build_request("comment-check", $comment);
- $response = $this->_http_post($this->_get_host_url(), $request);
-
- Kohana::log("debug", print_r($response, 1));
- if ($response["body"][0] != "true" && $response["body"][0] != "false") {
- Kohana::log("alert", $response["body"][0]);
- }
- return $response["body"][0] == "true";
- }
-
- public function submit_spam($comment) {
- $request = $this->_build_request("submit-spam", $comment);
- $response = $this->_http_post($this->_get_host_url(), $request);
- if ($response["body"][0] != "true" && $response["body"][0] != "false") {
- Kohana::log("alert", $response["body"][0]);
- }
- return $response["body"][0] == "true";
- }
-
- public function submit_ham($comment) {
- $request = $this->_build_request("submit-ham", $comment);
- $response = $this->_http_post($this->_get_host_url(), $request);
- if ($response["body"][0] != "true" && $response["body"][0] != "false") {
- Kohana::log("alert", $response["body"][0]);
- }
- return $response["body"][0] == "true";
- }
-
- public function get_statistics() {
- throw new Exception("@todo GET_STATISTICS NOT SUPPORTED");
- }
-
- public function get_admin_fields($post) {
- $view = new View("admin_spam_filter_akismet.html");
- $view->api_key = empty($post) ? module::get_var("spam_filter", "api_key") :
- $post->api_key;
-
- $view->errors = $post ? $post->errors() : null;
- return $view;
- }
-
- public function get_validation_rules($post) {
- $post->add_rules("api_key", "required");
- $post->add_callbacks("api_key", array($this, "validate_key"));
- }
-
- public function validate_key(Validation $post, $field) {
- $request = $this->_build_verify_request($post->api_key);
- $response = $this->_http_post("rest.akismet.com", $request);
- Kohana::log("debug", print_r($response, 1));
- if ("valid" != $response["body"][0]) {
- $post->add_error("api_key", "invalid");
- Kohana::log("alert", "Failed to verify Akismet Key:\n" . print_r($response["headers"], 1));
- }
- }
-
- public function _build_verify_request($api_key) {
- $base_url = url::base(true, true);
- $query_string = "key={$api_key}&blog=$base_url";
-
- $http_request = "POST /1.1/verify-key HTTP/1.0\r\n";
- $http_request .= "Host: rest.akismet.com\r\n";
- $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n";
- $http_request .= "Content-Length: " . strlen($query_string) . "\r\n";
- $http_request .= "User-Agent: Gallery 3.0 | Akismet/1.11 \r\n";
- $http_request .= "\r\n";
- $http_request .= $query_string;
-
- return $http_request;
- }
-
- public function set_api_data($post) {
- module::set_var("spam_filter", "api_key", $post->api_key);
- }
-
- public function _build_request($function, $comment) {
- $comment_data = array();
- $comment_data["user_ip"] = $comment->ip_addr;
- $comment_data["permalink"] = url::site("comments/{$comment->id}");
- $comment_data["blog"] = url::base(true, true);
- $comment_data["user_agent"] = $comment->user_agent;
- $comment_data["referrer"] = $_SERVER["HTTP_REFERER"];
- $comment_data["comment_type"] = "comment";
- $comment_data["comment_author"] = $comment->author;
- $comment_data["comment_author_email"] = $comment->email;
- $comment_data["comment_author_url"] = str_replace(array("http://", "https://"), "", $comment->url);
- $comment_data["comment_content"] = $comment->text;
-
- foreach($_SERVER as $key => $value) {
- if(in_array($key, self::$white_list)) {
- $comment_data[$key] = $value;
- }
- }
-
- $query_string = array();
- foreach($comment_data as $key => $data) {
- if(!is_array($data)) {
-// $query_string .= $key . "=" . urlencode(stripslashes($data)) . "&";
- $query_string[] = "$key=" . urlencode($data);
- }
- }
- $query_string = join("&", $query_string);
-
- $host = $this->_get_host_url();
- $http_request = "POST /1.1/$function HTTP/1.0\r\n";
- $http_request .= "Host: $host\r\n";
- $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n";
- $http_request .= "Content-Length: " . strlen($query_string) . "\r\n";
- $http_request .= "User-Agent: Gallery 3.0 | Akismet/1.11 \r\n";
- $http_request .= "\r\n";
- $http_request .= $query_string;
-
- Kohana::log("debug", $http_request);
-
- return $http_request;
- }
-
- private function _get_host_url() {
- $api_key = module::get_var("spam_filter", "api_key");
- return "$api_key.rest.akismet.com";
- }
-}
diff --git a/modules/spam_filter/libraries/drivers/Mollom.php b/modules/spam_filter/libraries/drivers/Mollom.php
deleted file mode 100644
index 6887a1be..00000000
--- a/modules/spam_filter/libraries/drivers/Mollom.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2008 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Mollom_Driver extends SpamFilter_Driver {
- public function check_comment($comment_data) {
- return true;
- }
-
- public function submit_spam($comment_data) {
- return $response[1] == "true";
- }
-
- public function submit_ham($comment_data) {
- }
-
- public function get_statistics() {
- throw new Exception("@todo GET_STATISTICS NOT IMPLEMENTED");
- }
-
- public function get_admin_fields($post) {
- $view = new View("admin_spam_filter_mollom.html");
- $view->private_key = empty($post) ? module::get_var("spam_filter", "private_key") :
- $post->private_key;
- $view->public_key = empty($post) ? module::get_var("spam_filter", "public_key") :
- $post->private_key;
-
- $view->errors = $post ? $post->errors() : null;
- return $view;
- }
-
- public function get_validation_rules($post) {
- $post->add_rules("private_key", "required");
- $post->add_rules("public_key", "required");
- $post->add_callbacks("private_key", array($this, "validate_key"));
- }
-
- public function validate_key(Validation $array, $field) {
- // @todo verify key values
- Kohana::log("debug", "Mollom::validate_key");
- Kohana::log("debug", print_r($array, 1));
- Kohana::log("debug", "field: $field");
- }
-
- public function set_api_data($post) {
- module::set_var("spam_filter", "private_key", $post->private_key);
- module::set_var("spam_filter", "public_key", $post->public_key);
- }
-
- private function _build_request($function, $host, $comment_data) {
- return "";
- }
-
- public function _retrieve_serverList() {
- $server_list = module::get_var("spam_filter", "server_list");
- if (empty($server_list)) {
- $servers = array("http://xmlrpc1.mollom.com", "http://xmlrpc2.mollom.com", "http://xmlrpc1.mollom.com");
- foreach (array("http://xmlrpc1.mollom.com", "http://xmlrpc2.mollom.com", "http://xmlrpc1.mollom.com") as $server) {
- $result = xmlrpc($server . "/1.0");
- if (!xmplrpc_errno()) {
- module::set_var("spam_filter", "server_list", $result);
- $server_list = $result;
- }
- }
- }
- return $server_list;
- }
-}
diff --git a/modules/spam_filter/libraries/drivers/SpamFilter.php b/modules/spam_filter/libraries/drivers/SpamFilter.php
deleted file mode 100644
index 6ece0dd4..00000000
--- a/modules/spam_filter/libraries/drivers/SpamFilter.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2008 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-abstract class SpamFilter_Driver {
- public abstract function check_comment($comment);
-
- public abstract function submit_spam($comment);
-
- public abstract function submit_ham($comment);
-
- public abstract function get_statistics();
-
- public abstract function get_admin_fields($post);
-
- public abstract function get_validation_rules($post);
-
- public abstract function set_api_data($post);
-
- protected function _http_post($host, $http_request, $port=80, $timeout=5) {
- $response = "";
- if (false !== ($fs = @fsockopen($host, $port, $errno, $errstr, $timeout))) {
- fwrite($fs, $http_request);
- while ( !feof($fs) ) {
- $response .= fgets($fs, 1160); // One TCP-IP packet
- }
- fclose($fs);
- list($headers, $body) = explode("\r\n\r\n", $response);
- $headers = explode("\r\n", $headers);
- $body = explode("\r\n", $body);
- $response = array("headers" => $headers, "body" => $body);
- } else {
- throw new Exception("@todo CONNECTION TO SPAM SERVICE FAILED");
- }
- return $response;
- }
-} \ No newline at end of file
diff --git a/modules/spam_filter/module.info b/modules/spam_filter/module.info
deleted file mode 100644
index c31f794c..00000000
--- a/modules/spam_filter/module.info
+++ /dev/null
@@ -1,3 +0,0 @@
-name = Spam Filter
-description = Protect your gallery from unwanted and annoying comments
-version = 1
diff --git a/modules/spam_filter/tests/Akismet_Driver_Test.php b/modules/spam_filter/tests/Akismet_Driver_Test.php
deleted file mode 100644
index d5f5ee95..00000000
--- a/modules/spam_filter/tests/Akismet_Driver_Test.php
+++ /dev/null
@@ -1,112 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2008 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Akismet_Driver_Test extends Unit_Test_Case {
- private $_ip_address;
- private $_user_agent;
- private $_comment;
- private $_driver;
- private $_api_key;
-
- public function setup() {
- $this->_ip_address = Input::instance()->ip_address;
- $this->_user_agent = Kohana::$user_agent;
-
- Input::instance()->ip_address = "1.1.1.1";
- Kohana::$user_agent = "Gallery3 Unit Test";
-
- $this->_driver = new Akismet_Driver();
- $this->_comment = comment::create("John Doe", "John@gallery.com", "This is a comment", 0, "http://gallery.com");
- $this->_api_key = module::get_var("spam_filter", "api_key");
- if (empty($this->_api_key)) {
- $chars = "0123456789abcdefghijklmnopqrstuvwxyz";
- for ($i = 0; $i < 10; $i++) {
- $this->_api_key .= $chars[mt_rand(0, 36)];
- }
- module::set_var("spam_filter", "api_key", $this->_api_key);
- }
- }
-
- public function teardown() {
- Input::instance()->ip_address = $this->_ip_address;
- Kohana::$user_agent = $this->_user_agent;
- }
-
- public function build_verify_key_request_test() {
- $request = $this->_driver->_build_verify_request($this->_api_key);
- $data = "key={$this->_api_key}&blog=http://./";
- $data_length = strlen($data);
- $expected = "POST /1.1/verify-key HTTP/1.0\r\n" .
- "Host: rest.akismet.com\r\n" .
- "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n" .
- "Content-Length: {$data_length}\r\n" .
- "User-Agent: Gallery 3.0 | Akismet/1.11 \r\n" .
- "\r\n$data";
- $this->assert_equal($expected, $request);
- }
-
- public function build_check_comment_request_test() {
- $request = $this->_driver->_build_request("comment-check", $this->_comment);
- $data = "user_ip=1.1.1.1&permalink=http%3A%2F%2F.%2Findex.php%2Fcomments%2F2&blog=http%3A%2F%2F.%2F" .
- "&user_agent=Gallery3+Unit+Test&referrer=&comment_type=comment&comment_author=John+Doe" .
- "&comment_author_email=John%40gallery.com&comment_author_url=http%3A%2F%2Fgallery.com" .
- "&comment_content=This+is+a+comment&";
- $data_length = strlen($data);
- $expected = "POST /1.1/comment-check HTTP/1.0\r\n" .
- "Host: {$this->_api_key}.rest.akismet.com\r\n" .
- "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n" .
- "Content-Length: {$data_length}\r\n" .
- "User-Agent: Gallery 3.0 | Akismet/1.11 \r\n" .
- "\r\n$data";
- $this->assert_equal($expected, $request);
- }
-
- public function build_submit_spam_request_test() {
- $request = $this->_driver->_build_request("submit-spam", $this->_comment);
- $data = "user_ip=1.1.1.1&permalink=http%3A%2F%2F.%2Findex.php%2Fcomments%2F3&blog=http%3A%2F%2F.%2F" .
- "&user_agent=Gallery3+Unit+Test&referrer=&comment_type=comment&comment_author=John+Doe" .
- "&comment_author_email=John%40gallery.com&comment_author_url=http%3A%2F%2Fgallery.com" .
- "&comment_content=This+is+a+comment&";
- $data_length = strlen($data);
- $expected = "POST /1.1/submit-spam HTTP/1.0\r\n" .
- "Host: {$this->_api_key}.rest.akismet.com\r\n" .
- "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n" .
- "Content-Length: {$data_length}\r\n" .
- "User-Agent: Gallery 3.0 | Akismet/1.11 \r\n" .
- "\r\n$data";
- $this->assert_equal($expected, $request);
- }
-
- public function build_submit_ham_equest_test() {
- $request = $this->_driver->_build_request("submit-ham", $this->_comment);
- $data = "user_ip=1.1.1.1&permalink=http%3A%2F%2F.%2Findex.php%2Fcomments%2F4&blog=http%3A%2F%2F.%2F" .
- "&user_agent=Gallery3+Unit+Test&referrer=&comment_type=comment&comment_author=John+Doe" .
- "&comment_author_email=John%40gallery.com&comment_author_url=http%3A%2F%2Fgallery.com" .
- "&comment_content=This+is+a+comment&";
- $data_length = strlen($data);
- $expected = "POST /1.1/submit-ham HTTP/1.0\r\n" .
- "Host: {$this->_api_key}.rest.akismet.com\r\n" .
- "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n" .
- "Content-Length: {$data_length}\r\n" .
- "User-Agent: Gallery 3.0 | Akismet/1.11 \r\n" .
- "\r\n$data";
- $this->assert_equal($expected, $request);
- }
-}
-
diff --git a/modules/spam_filter/tests/SpamFilter_Helper_Test.php b/modules/spam_filter/tests/SpamFilter_Helper_Test.php
deleted file mode 100644
index 7f6bf5c0..00000000
--- a/modules/spam_filter/tests/SpamFilter_Helper_Test.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2008 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class SpamFilter_Helper_Test extends Unit_Test_Case {
- public function get_driver_names_test() {
- $expected[] = _("Select Driver");
- foreach (glob(MODPATH . "spam_filter/libraries/drivers/*.php") as $file) {
- if (preg_match("#spam_filter/libraries/drivers/(.*).php$#", $file, $matches)) {
- if ($matches[1] != "SpamFilter") {
- $expected[] = $matches[1];
- }
- }
- }
- $this->assert_equal($expected, spam_filter::get_driver_names());
- }
-} \ No newline at end of file
diff --git a/modules/spam_filter/views/admin_spam_filter.html.php b/modules/spam_filter/views/admin_spam_filter.html.php
deleted file mode 100644
index 80ea02b8..00000000
--- a/modules/spam_filter/views/admin_spam_filter.html.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.") ?>
-<script type="text/javascript">
- $("document").ready(function() {
- ajaxify_spam_filter_form();
- $("#gContent #drivers").change(function() {
- data = $("#gContent #drivers :selected").text();
- $("#gContent #filter_data").load("<?= url::site("admin/spam_filter/callback") ?>",
- {driver: $("#gContent #drivers :selected").text(),
- csrf: "<?= access::csrf_token() ?>"});
- });
- });
- function ajaxify_spam_filter_form() {
- $("#gContent form").ajaxForm({
- dataType: "json",
- success: function(data) {
- if (data.form) {
- $("#gContent form").replaceWith(data.form);
- ajaxify_spam_filter_form();
- }
- if (data.result == "success") {
- window.location.reload();
- }
- }
- });
- };
-</script>
-<form action="<?= url::site("admin/spam_filter/edit") ?>" method="post" class="form">
- <?= access::csrf_form_field() ?>
- <fieldset>
- <legend><?= _("Configure Spam Filter") ?></legend>
- <ul>
- <li>
- <label for="drivers" >Available Drivers</label>
- <select id="drivers" name="drivers" class="dropdown" >
- <? foreach ($drivers as $index => $driver): ?>
- <option value="<?= $index ?>"<? if (!empty($driver["selected"])): ?> selected="selected"<? endif?>><?= $driver["name"]?></option>
- <? endforeach ?>
- </select>
- </li>
- <div id="filter_data" >
- <?= $filter_data ?>
- </div>
- <li>
- <button type="submit" class="submit" ><?= _("Configure") ?></button>
- </li>
- </ul>
- </fieldset>
-</form>
diff --git a/modules/spam_filter/views/admin_spam_filter_akismet.html.php b/modules/spam_filter/views/admin_spam_filter_akismet.html.php
deleted file mode 100644
index 9d826b56..00000000
--- a/modules/spam_filter/views/admin_spam_filter_akismet.html.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.") ?>
-<li <? if (!empty($errors["api_key"])): ?> class="gError" <? endif ?>>
- <label for="api_key"><?= _("Api Key")?></label>
- <input name="api_key" id="gApiKey" class="textbox" type="text" value="<?= $api_key ?>" />
- <? if (!empty($errors["api_key"]) && $errors["api_key"] == "required"): ?>
- <p class="gError"><?= _("Api Key is required.") ?>
- <? endif ?>
- <? if (!empty($errors["api_key"]) && $errors["api_key"] == "invalid"): ?>
- <p class="gError"><?= _("Api Key is invalid.") ?>
- <? endif ?>
-</li>
-
diff --git a/modules/spam_filter/views/admin_spam_filter_mollom.html.php b/modules/spam_filter/views/admin_spam_filter_mollom.html.php
deleted file mode 100644
index 63f603fb..00000000
--- a/modules/spam_filter/views/admin_spam_filter_mollom.html.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.") ?>
-<li <? if (!empty($errors["public_key"])): ?> class="gError" <? endif ?>>
- <label for="public_key"><?= _("Public Key")?></label>
- <input name="public_key" id="gPublicKey" class="textbox" type="text" value="<?= $public_key ?>" size="72" />
- <? if (!empty($errors["public_key"]) && $errors["public_key"] == "required"): ?>
- <p class="gError"><?= _("Public Key is required.") ?>
- <? endif ?>
- <? if (!empty($errors["public_key"]) && $errors["public_key"] == "invalid"): ?>
- <p class="gError"><?= _("Private Key / Public Key combination is invalid.") ?>
- <? endif ?>
-</li>
-<li <? if (!empty($errors["private_key"])): ?> class="gError" <? endif ?>>
- <label for="private_key"><?= _("Private Key")?></label>
- <input name="private_key" id="gPrivateKey" class="textbox" type="text" value="<?= $private_key ?>" size="72" />
- <? if (!empty($errors["private_key"]) && $errors["private_key"] == "required"): ?>
- <p class="gError"><?= _("Private Key is required.") ?>
- <? endif ?>
-</li>
-