aboutsummaryrefslogtreecommitdiff
path: root/mod/captcha/start.php
diff options
context:
space:
mode:
authordave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-08-06 14:17:37 +0000
committerdave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-08-06 14:17:37 +0000
commite9f261e51adcaa80429fe14b04ee277ab3124ce9 (patch)
tree6637cbf6a3917d29adcdffb4d1e8ab562050fd61 /mod/captcha/start.php
parent44c6025cc9a1536a772bf74af8cc9c07b0efc8b6 (diff)
downloadelgg-e9f261e51adcaa80429fe14b04ee277ab3124ce9.tar.gz
elgg-e9f261e51adcaa80429fe14b04ee277ab3124ce9.tar.bz2
removed all main plugins from core - they now live in the plugins svn
git-svn-id: https://code.elgg.org/elgg/trunk@3422 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/captcha/start.php')
-rw-r--r--mod/captcha/start.php141
1 files changed, 0 insertions, 141 deletions
diff --git a/mod/captcha/start.php b/mod/captcha/start.php
deleted file mode 100644
index 982a01c2c..000000000
--- a/mod/captcha/start.php
+++ /dev/null
@@ -1,141 +0,0 @@
-<?php
- /**
- * Elgg captcha plugin
- *
- * @package ElggCaptcha
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd
- * @copyright Curverider Ltd 2008-2009
- * @link http://elgg.com/
- */
-
- function captcha_init()
- {
- global $CONFIG;
-
- // Register page handler for captcha functionality
- register_page_handler('captcha','captcha_page_handler');
-
- // Extend CSS
- extend_view('css','captcha/css');
-
- // Number of background images
- $CONFIG->captcha_num_bg = 5;
-
- // Default length
- $CONFIG->captcha_length = 5;
-
- // Register a function that provides some default override actions
- register_plugin_hook('actionlist', 'captcha', 'captcha_actionlist_hook');
-
- // Register actions to intercept
- $actions = array();
- $actions = trigger_plugin_hook('actionlist', 'captcha', null, $actions);
-
- if (($actions) && (is_array($actions)))
- {
- foreach ($actions as $action)
- register_plugin_hook("action", $action, "captcha_verify_action_hook");
- }
- }
-
- function captcha_page_handler($page)
- {
- global $CONFIG;
-
- if (isset($page[0])) {
- set_input('captcha_token',$page[0]);
- }
-
- include($CONFIG->pluginspath . "captcha/captcha.php");
- }
-
- /**
- * Generate a token to act as a seed value for the captcha algorithm.
- */
- function captcha_generate_token()
- {
- return md5(generate_action_token(time()).rand()); // Use action token plus some random for uniqueness
- }
-
- /**
- * Generate a captcha based on the given seed value and length.
- *
- * @param string $seed_token
- * @return string
- */
- function captcha_generate_captcha($seed_token)
- {
- global $CONFIG;
-
- /*
- * We generate a token out of the random seed value + some session data,
- * this means that solving via pr0n site or indian cube farm becomes
- * significantly more tricky (we hope).
- *
- * We also add the site secret, which is unavailable to the client and so should
- * make it very very hard to guess values before hand.
- *
- */
-
- return strtolower(substr(md5(generate_action_token(0) . $seed_token), 0, $CONFIG->captcha_length));
- }
-
- /**
- * Verify a captcha based on the input value entered by the user and the seed token passed.
- *
- * @param string $input_value
- * @param string $seed_token
- * @return bool
- */
- function captcha_verify_captcha($input_value, $seed_token)
- {
- if (strcasecmp($input_value, captcha_generate_captcha($seed_token)) == 0)
- return true;
-
- return false;
- }
-
- /**
- * Listen to the action plugin hook and check the captcha.
- *
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
- */
- function captcha_verify_action_hook($hook, $entity_type, $returnvalue, $params)
- {
- $token = get_input('captcha_token');
- $input = get_input('captcha_input');
-
- if (($token) && (captcha_verify_captcha($input, $token)))
- return true;
-
- register_error(elgg_echo('captcha:captchafail'));
-
- return false;
- }
-
- /**
- * This function returns an array of actions the captcha will expect a captcha for, other plugins may
- * add their own to this list thereby extending the use.
- *
- * @param unknown_type $hook
- * @param unknown_type $entity_type
- * @param unknown_type $returnvalue
- * @param unknown_type $params
- */
- function captcha_actionlist_hook($hook, $entity_type, $returnvalue, $params)
- {
- if (!is_array($returnvalue))
- $returnvalue = array();
-
- $returnvalue[] = 'register';
- $returnvalue[] = 'user/requestnewpassword';
-
- return $returnvalue;
- }
-
- register_elgg_event_handler('init','system','captcha_init');
-?> \ No newline at end of file