diff options
author | xue <> | 2007-08-28 22:05:18 +0000 |
---|---|---|
committer | xue <> | 2007-08-28 22:05:18 +0000 |
commit | 669beed5392d22421d03b2a2d1bf12f5f0db9012 (patch) | |
tree | 948d01ac16e86c827ae803e90554c33bba832f85 /framework/Web/UI/WebControls/assets | |
parent | ff402bd8de1edd97bb06d30d7600212b5fc22f16 (diff) |
added TCaptcha, TCaptchaValidator.
Diffstat (limited to 'framework/Web/UI/WebControls/assets')
-rw-r--r-- | framework/Web/UI/WebControls/assets/captcha.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/framework/Web/UI/WebControls/assets/captcha.php b/framework/Web/UI/WebControls/assets/captcha.php new file mode 100644 index 00000000..aa3fdcc0 --- /dev/null +++ b/framework/Web/UI/WebControls/assets/captcha.php @@ -0,0 +1,35 @@ +<?php
+
+require_once(dirname(__FILE__).'/captcha_key.php');
+
+if(isset($_GET['pk']))
+ echo $_GET['pk'].$privateKey;
+else
+ echo $privateKey;
+
+function generateToken($publicKey,$privateKey,$tokenLength,$caseSensitive)
+{
+ $token=substr(hash2string(md5($publicKey.$privateKey)).hash2string(md5($privateKey.$publicKey)),0,$tokenLength);
+ return $caseSensitive?$token:strtoupper($token);
+}
+
+function hash2string($hex,$alphabet='')
+{
+ if(strlen($alphabet)<2)
+ $alphabet='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ $hexLength=strlen($hex);
+ $base=strlen($alphabet);
+ $result='';
+ for($i=0;$i<$hexLength;$i+=6)
+ {
+ $number=hexdec(substr($hex,$i,6));
+ while($number)
+ {
+ $result.=$alphabet[$number%$base];
+ $number=floor($number/$base);
+ }
+ }
+ return $result;
+}
+
+?>
\ No newline at end of file |