php set_time_limit include libs curl pi_curl_exception php include lib

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
set_time_limit(0);
include 'libs/curl/pi_curl_exception.php';
include 'libs/curl/pi_curl.php';
include 'libs/multicurl/pi_multicurl_exception.php';
include 'libs/multicurl/pi_multicurl.php';
//$url_arr = file('url.txt');
//foreach($url_arr as $url)
$urls = file('url.txt');
$cURL = new Pi_MultiCurl();
// Количество потоков
$cURL->setThreadsCount(5);
// Таймаут потока
$cURL->setThreadTimeout(3);
// Перерыв между потоками в мс
$cURL->setUsleepTime(300);
$fwBad = fopen('bad.txt', 'w+');
$fwGood = fopen('good.txt', 'w+');
while(sizeof($urls)) {
$i = 5; // Будем ложить по пять адресов за раз
$_urls = array(); // Очищаем список адресов, которые мы будем ложить в поток
while($i--) {
$_urls[] = "http://". array_pop($urls) . "/engine/rss.php";
}
$cURL->setUrls($_urls);
$results = $cURL->getUrls();
foreach ($result as $thread) { // ругаеться на ету строку (Warning: Invalid argument supplied for foreach() in X:\home\dle_multicurl.cc\www\index.php on line 43)
if(strpos($thread['contents'], '<?xml version="1.0" encoding="windows-1251"?>') !== false) {
fwrite($fwGood, $thread['url'] . "\n");
} else {
fwrite($fwBad, $thread['url'] . "\n");
}
}
}
fclose($fwBad);
fclose($fwGood);