<?
/******************************************************************************
始溴鼻 溫� 閱擇錨滓 � Anticaptcha 熱 Decaptcha.
� Anticaptcha 褕翰隨錳擘� 閱擇慮瘩�� system_pass. 仞鞅 獗� 詭閤璃� 蜻鋒靦�� �
撇錨準贖 蜻滓� 頜蝠擱錶 - 鋒曉鼻 � 彰粵錚繃蒙錙� 憐豢� 頑滓靦 頜�憐 � 蓊痘篦, 閱擇慮瘩��
$system_pass. 拖 骯髁� 擱琦痞� �� 鋒擋慮隧� 頜� 慚摟廓鞅頑甕� 蓊痘築
De-Captcha.com 泠綁閱鞣鈇綏 頡颱毚 頡溝綑詻� 滓瘩蝶� 憐溴��. 俏� 隆鳩慢瘟閑璃�
侑裂� 頜螂雒慾, 撲 蝌琛粳 鈇� 頡憐礦.
沅痘� 擋鼓琥褕痢 溫� 縝陽綁錚憐羲� � PHP4 � 殃痙羅
********************************************************************************/
class DeCaptcha {
/*- 青擇慮瘩灘 憐豢� 複擇滇鞅靦 � 頌綁� 綁鞅 獗� 詭閤璃� 蜻鋒靦�� � 餿貊� 蜻滇-*/
var $system_id = "突� �� 瘟慮� � 縊羲粳�"; // 拖慮� � 縊羲粳�
var $system_pass = "突� �� 鋒曉鼻 � De-Captcha.com"; // 阻曉鼻 � 縊羲粳�.
/*- 柳窟毚孃� 鋒擋慮隧� 隧蝶痞� 獗 皚豢�. 妾����� 縛擠菔� 頡溝綑詻� De-Captcha-*/
var $server = "http://de-captcha.com";
var $input_script = "/loadcapcha.php";
var $finger_script = "/finger.php";
var $captcha_step_time = 10; // 青撿蝠 複曉築 篦撼綑� 熱 蝌衝闐璃� 擋縉蝨熱璃�
var $captcha_timeout = 120; // 奉蜴慟畫贛蝦 陲粳� 蝸彰痢徹 蒙養鞣
var $img_hash = false; // 圭綁� 隄稞滓 鍊痢摘�� 闈� 頡縛窟獗廈 頑彙擠粵瘟廈 愿螂擋詭璃�
var $msg_current;
var $msg_array = array("[ok]"=>"疝廖蝌 獗�",
"[error_transfer]"=>"疝廖蒙 閱擇滓鞣 滓瘩贖",
"[error_load]"=>"疝廖蒙 頜� 頑彙擰蒸 愿螂擋詭璃� 熱 篦撼綑",
"[error_format]"=>"疝廖蒙 � 縴整痞� 閱擇滓鞣",
"[error_accessdenied]"=>"仁羲曙 頑蜥襯. 俏蝴綑靄� �� 斂慢畫贛癮 蜻� � 鋒曉鼻 熱 頑彙擰蝕, 甦錚隅褓靦 �羅廈 甦蒙斂錶.",
"[error_errorbalance]"=>"俠頡颱摘� 篛蝗 菴閤瘡.",
"[error_baseconnect]"=>"疝廖蒙 熱 篦撼綑�. 泠擋錚鋼艘 � 琴憂璃羲擋錙樽.",
"[error_timeout]"=>"看瘍痠�."
);
/*- 姥菔鞣� 閱擇慮瘩灘 蓊痘築. -*/
/*- 決瘡隧擱錙� 蓊痘築 -*/
function DeCaptcha($sys_id=false, $sys_pass=false)
{
if($sys_id !== false) $this->system_id = $sys_id;
if($sys_pass !== false) $this->system_pass = $sys_pass;
}
//------------------------ Private 縯璀甕� -------------------------------------
//------------------------------------------------------------------------------
function freadfile($file_path)
{
$result_content = "";
if(@file_exists($file_path))
{
@fclose(@fopen($file_path, "a+b"));
$fp = @fopen($file_path, "r+b");
if($fp)
{
flock($fp, LOCK_SH);
clearstatcache();
$fsize = filesize($file_path);
if($fsize>0) $result_content = fread($fp, $fsize);
}
@fclose($fp);
}
return $result_content;
}
function curl_get($url, $data=false, $multipart=false)
{
$ch=curl_init();
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "DwCapcha(Module for Remote download)");
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_URL, $url);
if($data === false)
{
curl_setopt ($ch, CURLOPT_POST, FALSE);
curl_setopt ($ch, CURLOPT_HTTPGET, TRUE);
}
else
{
curl_setopt ($ch, CURLOPT_POST, TRUE);
curl_setopt ($ch, CURLOPT_HTTPGET, FALSE);
if(!$multipart)
{
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
}
elseif(is_array($data))
{
$boundary = "DWCAPTCHADWCAPTCHADWCAPTCHA";
$datasend = "";
foreach($data as $k=>$v)
{$datasend .= "--{$boundary}\r\nContent-Disposition: form-data; name=\"{$k}\"\r\nContent-Transfer-Encoding: binary\r\n\r\n{$v}\r\n";};
$datasend .= "--{$boundary}--\r\n";
$header[] = "Content-type: multipart/form-data; boundary={$boundary}";
$header[] = "Content-length: ".strlen($datasend);
$header[] = "Cache-Control: no-cache\r\n";
$header[] = $datasend;
curl_setopt($ch, CURLOPT_POSTFIELDS, "");
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
unset($header);
}
}
$output = curl_exec($ch);
if(curl_errno($ch)) print curl_error($ch);
curl_close($ch);
return $output;
}
//--------------------------- Public 縯璀甕� -----------------------------------
//------------------------------------------------------------------------------
/*- 青擇滓闐 愿螂擋詭璃� 熱 螂擋菔錦�. -*/
function recognize($filename) {
$result = false;
if (file_exists($filename))
{
$capcha_for_send = base64_encode($this->freadfile($filename)); // 臭錶粳 糟瘧, � 閱擇隆溘� � base64 溫� 閱擇滓鞣
$this->img_hash = $this->curl_get($this->server.$this->input_script, array("account"=>@urlencode($this->system_id),
"password"=>@urlencode($this->system_pass),
"img"=>$capcha_for_send), true);//玩頜琵��粳 愿螂擋詭璃� 熱 篦撼綑
if(strlen($this->img_hash)>0 && $this->img_hash[0]=='[') {$this->msg_current = $this->img_hash;}
else
{
$start = time();
while (true)
{
sleep($this->captcha_step_time);
$response_array = @unserialize($this->curl_get($this->server.$this->finger_script."?hash=".$this->img_hash));
if(!is_array($response_array)) {$this->msg_current = "[error_transfer]"; break;}
elseif($response_array["status"] == "[HANDGET]") {$result = $response_array["answer"];}
unset($response_array);
if ((time() - $start) > $this->captcha_timeout)
{$this->msg_current = "[error_timeout]"; break;}
if($result !== false)
{$this->msg_current = "[ok]"; break;}
}
}
}
return $result;
}
/*- 降錶瘟階� 羲痞檀� 擋縉蝨熱鈇璃� 鋼蝕嚼廈 愿螂擋詭璃�, true/false.-*/
function report($result)
{
$command_query = "&erroranswer";
if($result) $command_query = "&goodanswer";
$this->curl_get($this->server.$this->finger_script."?hash=".$this->img_hash.$command_query); // 姻僮鼻錶� 獗 頜蝴綑�粳, 獗 皚豢� 熱� �蝶�
}
/*- 姻僮鼻錶靜 擋菔靜 縯璀甕� -*/
function echostatus($short=false)
{
$result = "";
if($short) $result = $this->msg_current;
else $result = $this->msg_array[$this->msg_current];
return $result;
}
}
?>
评论0