public function checkProxyList($file = NULL, $shuffle = FALSE) { $file = new \apf\core\File($file); $proxies = $file->getContentsAsArray(); if (!sizeof($proxies)) { throw new \Exception("Empty proxy file specified!"); } $this->log("Validating proxy list | (" . count($proxies) . ") proxies found", 0, "light_cyan"); if ($shuffle) { shuffle($proxies); } foreach ($proxies as $proxy) { $proxy = trim($proxy); if (empty($proxy)) { //blank line continue; } $proxy = explode(':', $proxy); $port = isset($proxy[1]) && is_int($proxy[1]) ? $proxy[1] : 80; //port $tunnel = isset($proxy[2]) && !empty($proxy[2]) ? $proxy[2] : NULL; //Proxy tunnel $user = isset($proxy[3]) && !empty($proxy[3]) ? $proxy[3] : NULL; //Proxy user $pass = isset($proxy[4]) && !empty($proxy[4]) ? $proxy[4] : NULL; //Proxy password $auth = isset($proxy[5]) && !empty($proxy[5]) ? $proxy[5] : NULL; //Proxy auth type $proxy = $proxy[0]; //Do host/ip validation etc,etc if (!empty($proxy)) { $isValid = $this->checkProxy($proxy, $port, $tunnel, $user, $pass, $auth); if ($isValid) { $this->log("Found valid proxy {$proxy}:{$port}!", 0, "light_green"); } else { $this->log("Invalid proxy {$proxy}:{$port}!", 1, "red"); } } else { $this->log("Syntax error on proxy list", 2, "yellow"); } } }
public function fetch() { if (is_null($this->getUri())) { throw new \Exception("Can't get RSS content, no URI specified"); } $file = tempnam(sys_get_temp_dir(), __CLASS__); $adapter = $this->getAdapter(); //If adapter is of type eCurl if (is_a($this->getAdapter(), "\\apf\\http\\adapter\\Ecurl")) { $adapter->setCurlOption("FILE", $file); $adapter->setCurlOption("RETURNTRANSFER", FALSE); $adapter->connect(); $file = new \apf\core\File($file); $content = $file->read(); } else { $content = $adapter->connect(); file_put_contents($content, $file); } $msg = "The given URI " . $this->getUri() . " has return no content!"; \apf\Validator::emptyString($content, $msg); return new \apf\parser\feed\Rss($file); }