commit | author | age
|
8bd4d9
|
1 |
<?php |
JK |
2 |
$file = file('./channels.list'); |
|
3 |
foreach($file as $chan) { |
|
4 |
$chan = trim($chan); |
|
5 |
if(empty($chan) || substr($chan, 0, 1)=='#') { |
|
6 |
continue; |
|
7 |
} |
|
8 |
|
|
9 |
$parts = preg_split('/\t[\40\t]*/', $chan, 4); |
|
10 |
|
|
11 |
echo STAR.'Pobieranie kanału '.$parts[3]; |
|
12 |
|
|
13 |
$curl = curl_init($parts[0]); |
|
14 |
curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE); |
|
15 |
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE); |
|
16 |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); |
|
17 |
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); |
|
18 |
curl_setopt($curl, CURLOPT_MAXREDIRS, 5); |
|
19 |
curl_setopt($curl, CURLOPT_FILETIME, TRUE); |
|
20 |
curl_setopt($curl, CURLOPT_USERAGENT, 'BotGaduGadu/1.0 mod_rss/1.0 (http://jacekk.info/botgg)'); |
|
21 |
if(is_file($parts[1].'.rss')) { |
|
22 |
curl_setopt($curl, CURLOPT_HTTPHEADER, array( |
|
23 |
'If-Modified-Since: '.date('r', filemtime($parts[1].'.rss')), |
|
24 |
)); |
|
25 |
} |
|
26 |
|
|
27 |
$return = curl_exec($curl); |
|
28 |
$info = curl_getinfo($curl); |
|
29 |
|
|
30 |
if($info['http_code'] == 304) { |
|
31 |
echo NOT; |
|
32 |
} |
|
33 |
else if($info['http_code'] == 200) { |
|
34 |
file_put_contents($parts[1].'.rss', $return); |
|
35 |
if($info['filetime']>0) { |
|
36 |
touch($parts[1].'.rss', $info['filetime']); |
|
37 |
} |
|
38 |
echo OK; |
|
39 |
} |
|
40 |
else |
|
41 |
{ |
|
42 |
echo '('.$info['http_code'].') '.FAIL; |
|
43 |
} |
|
44 |
|
|
45 |
curl_close($curl); |
|
46 |
|
|
47 |
unset($return); |
|
48 |
} |
|
49 |
?> |