为了突破图片防盗链采集图片,找了一个类,应该可以处理一部分突破的防盗链。
比如说 UserAgent ,Referrer,Header,Cookie啥的。
https://github.com/php-curl-class/php-curl-class
进入e目录 composer require php-curl-class/php-curl-class
修改connect.php加入
define('STR_IREPLACE', function_exists('str_ireplace')); require ECMS_PATH . './e/vendor/autoload.php'; use \Curl\Curl;
修改 取得文件内容 的这个 function。
//取得文件内容
function ReadFiletext($filepath) { $filepath = trim($filepath); //远程 if (strstr($filepath, "http://www.aaa.cn")) { $curl = new Curl(); $curl->setCookie('cookie',''); $curl->get($filepath); $string = $curl->response; } else if (strstr($filepath, "://")) { $htmlfp = @fopen($filepath, "r"); while ($data = @fread($htmlfp, 500000)) { $string .= $data; } @fclose($htmlfp); } //本地 else { $htmlfp = @fopen($filepath, "r"); $string = @fread($htmlfp, @filesize($filepath)); @fclose($htmlfp); } return $string; }
|