Exemplo n.º 1
0
 protected function checkProxyArray($arrayProxy, $chunk = 150)
 {
     if (is_array($arrayProxy)) {
         $goodProxy = [];
         $url = $this->getFunctionUrl() . '?ip=' . $this->getServerIp() . '&proxy=yandex';
         $this->loader->setCountStream(1);
         $this->loader->setMinSizeAnswer(5);
         $this->loader->setDefaultOption(CURLOPT_TIMEOUT, 30);
         $this->loader->setMaxRepeat(0);
         $this->loader->setDefaultOption(CURLOPT_REFERER, "proxy-check.net");
         $this->loader->setDefaultOption(CURLOPT_POST, true);
         $this->loader->setDefaultOption(CURLOPT_POSTFIELDS, "proxy=yandex");
         foreach (array_chunk($arrayProxy, $chunk) as $challenger) {
             $this->loader->setCountCurl(count($challenger));
             $urlList = [];
             $descriptorArray =& $this->loader->getDescriptorArray();
             foreach ($descriptorArray as $key => &$descriptor) {
                 $this->loader->setOption($descriptor, CURLOPT_PROXY, $challenger[$key]['proxy']);
                 $urlList[] = $url;
             }
             foreach ($this->loader->load($urlList) as $key => $answer) {
                 $infoProxy = $this->genInfo($challenger[$key], $answer, $descriptorArray[$key]['info']);
                 if ($infoProxy) {
                     $goodProxy[] = $infoProxy;
                 }
             }
             $this->loader->genNewKeyStream();
         }
         if (count($goodProxy)) {
             return $goodProxy;
         }
     }
     return array();
 }