private function isUrl($link) { if (strpos($link, ' ') !== false) { return false; } $link = rtrim($link, '\\'); $link = ltrim($link, ':;/\\!@#$%^&*-_=+|\'"?<>[](){}.,'); $link = stripos($link, 'http') !== 0 ? 'http://' . $link : $link; foreach ($this->except as $page => $opt) { if (stristr($link, $page) !== false && $opt == 'pass') { return $link; } if (stristr($link, $page) !== false && $opt == 'block') { return false; } } $parse = parse_url($link); if (empty($parse['host'])) { return false; } if (filter_var($parse['host'], FILTER_VALIDATE_IP)) { return $link; } else { $dot = strrpos($parse['host'], '.') - strlen($parse['host']); $domain = strtoupper(substr($parse['host'], $dot + 1)); return array_intersect([$domain], UrlHelper::domainList()) ? $link : false; } }
protected function loadStreamUrl($url, $opts = false) { $ctx = $opts !== false ? stream_context_create($opts) : $this->ctx; $stream = @fopen($url, 'r', false, $ctx); if (empty($stream)) { return false; } if (empty($http_response_header)) { return false; } $this->httpHeader = UrlHelper::httpParseHeaders($http_response_header); $html = stream_get_contents($stream, 1024 * 1024 * 3); //max 3mb fclose($stream); return $html; }