summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/assets
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI/WebControls/assets')
-rw-r--r--framework/Web/UI/WebControls/assets/captcha.php35
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