Commit 97cf4399 authored by 蒋林's avatar 蒋林

tt

parent bd796fa2
...@@ -56,21 +56,85 @@ class Source ...@@ -56,21 +56,85 @@ class Source
return ['code' => $code, 'data' => $result]; return ['code' => $code, 'data' => $result];
} }
protected function GetUrlContents($url) protected function CurlPostHttps($url, $post, $headers)
{
$cacert = APPPATH.'config/cacert.pem';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_CAINFO, $cacert);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_COOKIEFILE, self::$cookieFilePath);
curl_setopt($curl, CURLOPT_COOKIEJAR, self::$cookieFilePath);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
$result = curl_exec($curl);
$info = curl_getinfo($curl);
curl_close($curl);
if ($info['http_code'] == 200) {
$this->ReturnError($result, $url);
}
return ['info' => $info, 'data' => $result];
}
protected function GetUrlContents($url, $isCheck = true)
{ {
$curl = curl_init(); $curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 15); curl_setopt($curl, CURLOPT_TIMEOUT, 15);
curl_setopt($curl, CURLOPT_COOKIEFILE, self::$cookieFilePath); //读取cookie curl_setopt($curl, CURLOPT_COOKIEFILE, self::$cookieFilePath);
$rs = curl_exec($curl); //执行cURL抓取页面内容 $rs = curl_exec($curl); //执行cURL抓取页面内容
curl_close($curl); curl_close($curl);
$this->ReturnError($rs, $url);
if ($isCheck) {
$this->ReturnError($rs, $url);
}
return $rs; return $rs;
} }
/**
* 获取手机验证码
* @return array
*/
public function GetMailPhoneCode()
{
$mbox = imap_open ("{pop.163.com:995/pop3/ssl}INBOX", "wxh__8888@163.com", "WXH888888");
$num = imap_num_msg($mbox);
$result = [];
if ($num) {
$body = imap_base64(imap_fetchbody($mbox, imap_num_msg($mbox), 1));
$body = iconv('utf8', 'gbk', $body);
preg_match('/\d{6}/', $body, $code);
preg_match('/2\d{3}-[\s\S]{14}/', $body, $date);
if (isset($code[0]) && isset($date[0])) {
$result['code'] = $code[0];
$result['date'] = $date[0];
$result['st'] = time() - strtotime($result['date']);
}
}
return $result;
}
protected function HandelHtmlScript($html)
{
return str_replace('script', 'scriptt', $html);
}
protected function ReturnError($html, $url) protected function ReturnError($html, $url)
{ {
if (!$html) { if (!$html) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment