-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.php
executable file
·92 lines (83 loc) · 2.76 KB
/
get.php
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/php
<?php
/*
* 海賊王 = 2
* Bleach = 19
* 火影忍者 = 4
* 惡魔辯護 = 455
* Reborn = 256
* 結界師 = 74
*/
function getSkyfireComic($comic_id,$val,$t = null ){
// 建立資料夾.
if(!is_dir(dirname(__FILE__).DIRECTORY_SEPARATOR.$val)){
mkdir(dirname(__FILE__).DIRECTORY_SEPARATOR.$val);
}
$skyfire_hostnames = array('hotpic.sky-fire.com','coldpic.sky-fire.com','pic2.sky-fire.com');
foreach($skyfire_hostnames as $skyfire_hostname){
$url = "http://{$skyfire_hostname}/Utility/{$comic_id}/{$val}.js";
echo $url."\n";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url.$nowPic);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$str = curl_exec($curl)."\n";
$status = curl_getinfo($curl);
if($status['http_code'] == 200){
break;
}
curl_close($curl);
}
// 有時後會 comic.sky-fire.com 會把圖片放在不同的主機
preg_match_all('(http://'.$skyfire_hostname.'/Pic/OnlineComic[0-9]/[[:alnum:]\/._-]*)',$str,$data);
echo count($data[0]);
if(count($data[0]) <= 1){
preg_match_all('(http://v.sky-fire.com/Temp/[[:alnum:]\/._-]*)',$str,$data);
}
$i = 0;
foreach($data[0] as $img_src){
$i++;
$pid = pcntl_fork();
if($pid == -1){
die('could not fork');
}else if($pid){
echo 'Fork to '.$pid.' for get '.$img_src."\n";
}else{
$output_file_name = sprintf('%02d.jpg',$i);
if(file_exists($val."/".$output_file_name)){
echo $val."/".$output_file_name." File Exists!\n";
exit;
}
$curl = curl_init();
$header[] = 'Accept: image/png,*/*;q=0.5';
$header[] = 'Accept-Language: zh-tw,en-us;q=0.7,en;q=0.3';
$header[] = 'Accept-Encoding: gzip,deflate';
$header[] = 'Accept-Charset: Big5,utf-8;q=0.7,*;q=0.7';
$cookie = 'cnzz02=3; rtime=0; CommunityServer-UserCookie1=lv=1999-1-1 0:00:00&mra='.$mra.'; ltime=1174363041366; cnzz_eid=52991425-';
curl_setopt($curl, CURLOPT_URL, $img_src);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_COOKIE,$cookie);
curl_setopt($curl, CURLOPT_REFERER,$url.$nowPic.".html");
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT,10);
//curl_setopt($curl, CURLOPT_PROXY,'proxy.hinet.net');
//curl_setopt($curl, CURLOPT_PROXYPORT, 80);
$content = curl_exec($curl);
curl_close($curl);
if(strlen($content) > 100){
echo "Save: ".$val."/".$output_file_name." ".strlen($content)."\n";
$fp = fopen($val."/".$output_file_name,'w');
fputs($fp,$content);
fclose($fp);
exit;
}else{
echo "Connect Time Out.Retry \n";
exit;
}
}
}
}
$comic_id = trim($_SERVER['argv'][1]);
$set_id = $_SERVER['argv'][2];
getSkyfireComic($_SERVER['argv'][1],$_SERVER['argv'][2]);