/** * 构造函数 * @param string $username 用户名 * @param string $password 密码 */ function __construct($pid, $username, $password) { $this->pid = $pid; $this->account = array('username' => $username, 'password' => $password); //parent::__construct(LOG_PATH . Passport::GetLoginUid() . '.cookie'); parent::__construct(LOG_PATH . "{$pid}.cookie"); }
function save_remote_img($content) { if (preg_match_all('#<img .*?src="(.+?)".*?>#i', $content, $matches)) { foreach ($matches[1] as $img) { $img_host = parse_url($img, PHP_URL_HOST); if (empty($img_host) || strtolower($img_host) == strtolower($_SERVER['HTTP_HOST'])) { continue; } $new_name = microtime(true) . '_' . basename($img); $mappath = UPLOAD_PATH . $new_name; $client = new WebClient(NULL, 10); $img_data = $client->get($img); @mkdir(UPLOAD_PATH, 0777, true); if (!empty($img_data) && file_put_contents($mappath, $img_data)) { $content = str_replace($img, get_absolute_url(UPLOAD_PATH_WWW . $new_name), $content); } } } return $content; }