-
Notifications
You must be signed in to change notification settings - Fork 0
/
qu_or2.php
179 lines (166 loc) · 4.94 KB
/
qu_or2.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
require_once('config.inc.php');
require('functions.inc.php');
function shutdown() {
global $con, $con2;
echo '<br/><br/>Shutting down.<br/>';
var_dump($con, $con2);
}
register_shutdown_function('shutdown');
$res=file_get_contents('urlb2.data');
preg_match_all('#<p>([-a-zA-Z0-9 ?:\'’,!.]+)\s*(<strong>\((?:Completed|Suspend)\)</strong>)?\s*<small class="content is-small"><code><abbr class="timeago" title="([^"]+)">([^<]+)</abbr></code></small></p>\s*<ul>\s*<li>\s*(<a(?: target="_blank")? href="(?:[^"]+)">(?:[^<]+)</a>\s*(?:\|\s*)?|<strong>Missing (?:\d+(?:-\d+)?)</strong>\s*)+\s*</li>\s*</ul>#isU', $res, $matches);
$data2=$matches[0];
array_shift($matches);
array_pop($matches);
array_pop($matches);
var_dump(count($matches[0]));
/*echo '<table border="1">'."\r\n";
echo "\t".'<tr>'."\r\n";
echo "\t\t".'<th>Novel</th>'."\r\n";
echo "\t\t".'<th>Status</th>'."\r\n";
echo "\t\t".'<th>Last Modified</th>'."\r\n";
echo "\t".'</tr>'."\r\n";
for($i=0;$i<count($matches[0]);++$i) {
echo "\t".'<tr>'."\r\n";
echo "\t\t".'<td>'.$matches[0][$i].'</td>'."\r\n";
echo "\t\t".'<td>'.strip_tags($matches[1][$i]).'</td>'."\r\n";
echo "\t\t".'<td>'.$matches[2][$i].'</td>'."\r\n";
echo "\t".'</tr>'."\r\n";
}
echo '</table>'."\r\n";//*/
$links=$links2=array();
foreach($data2 as $k=>$d)
{
preg_match_all('#<a(?: target="_blank")? href="([^"]+)">([^<]+)</a>#isU',$d, $matches3);
array_shift($matches3);
$links[$matches[0][$k]]=array_combine($matches3[1],$matches3[0]);
$links2=array_merge($links2,$matches3[0]);
}
$novels=array_filter(array_map('trim',file('novels2.txt')));
var_dump($novels);
function skip($novel) {
global $novels;
return in_array($novel,$novels);
}
function skip2($novel) {
global $novels;
return !in_array($novel,$novels);
}
$links3=array_filter($links, 'skip', ARRAY_FILTER_USE_KEY);
$links4=array_filter($links, 'skip2', ARRAY_FILTER_USE_KEY);
flush();
$name2='';
$con=0;
$l='a';
foreach($links3 as $name => $links2) {
$name2=$name;
//$name2=str_replace(array('\''),'’', $name2);
$name2=str_replace(array('’'),'\'', $name2);
$name2=str_replace(array(':'),'-', $name2);
$name2=str_replace(array('?'),'', $name2);
$name2=preg_replace('#\.+$#','',$name2);
if(!file_exists($name2)) {
if(file_exists('__others/'.$name2)) {
rename('__others/'.$name2, $name2);
}
else {
mkdir($name2);
}
}
else if(file_exists('__others/'.$name2)) {
var_dump('__others/'.$name2);
}
if(substr($name2, 0, 1)!=$l) {
var_dump($l);flush();
$l=substr($name2, 0, 1);
}
foreach($links2 as $k => $v) {
$n = $name2.'/'.$k.'.htm';
$n2 = $n.'.gz';
if( (!SAVEHTM || file_exists($n)) && (!SAVEGZ || file_exists($n2)) ) continue;
++$con;
$data3 = get_paste2($v);
if($data3===false) {
var_dump($n, $v);
echo '<br/>';
continue;
}
$data4 = zlib_decode($data3);
$crc=hash('crc32b', $data4);
$crc=letobe($crc);
$crc=hex2bin($crc);
$size=strlen($data4);
$size=sprintf("%08x",$size);
$size=letobe($size);
$size=hex2bin($size);
//file_put_contents($n2, "\x1f\x8b\x08\x00\x00\x00\x00\x00".$data3.$crc.$size);//deflate
if(SAVEGZ) file_put_contents($n2, "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00".$data3.$crc.$size);//zlib
if(SAVEHTM) file_put_contents($n, $data4);
}
flush();
}
if(true) {
var_dump($l);flush();
$l=substr($name2, 0, 1);
}
flush();
echo 'Priority done<br/>';
var_dump($con);
$con2=0;
$l='a';
foreach($links4 as $name => $links2) {
$name2=$name;
//$name2=str_replace(array('\''),'’', $name2);
$name2=str_replace(array('’'),'\'', $name2);
$name2=str_replace(array(':'),'-', $name2);
$name2=str_replace(array('?'),'', $name2);
$name2=preg_replace('#\.+$#','',$name2);
if(!file_exists('__others/'.$name2)) {
if(file_exists($name2)) {
rename($name2, '__others/'.$name2);
}
else {
mkdir('__others/'.$name2);
}
}
else if(file_exists($name2)) {
var_dump($name2);
}
if(substr($name2, 0, 1)!=$l) {
var_dump($l);flush();
$l=substr($name2, 0, 1);
}
foreach($links2 as $k => $v) {
$n = '__others/'.$name2.'/'.$k.'.htm';
$n2 = $n.'.gz';
if( (!SAVEHTM || file_exists($n)) && (!SAVEGZ || file_exists($n2)) ) continue;
++$con2;
$data3 = get_paste2($v);
if($data3===false) {
var_dump($n, $v);
echo '<br/>';
continue;
}
$data4 = zlib_decode($data3);
$crc=hash('crc32b', $data4);
$crc=letobe($crc);
$crc=hex2bin($crc);
$size=strlen($data4);
$size=sprintf("%08x",$size);
$size=letobe($size);
$size=hex2bin($size);
//file_put_contents($n2, "\x1f\x8b\x08\x00\x00\x00\x00\x00".$data3.$crc.$size);//deflate
if(SAVEGZ) file_put_contents($n2, "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00".$data3.$crc.$size);//zlib
if(SAVEHTM) file_put_contents($n, $data4);
}
flush();
}
if(true) {
var_dump($l);flush();
$l=substr($name2, 0, 1);
}
flush();
echo 'Completely done<br/>';
var_dump($con2);
echo '<br/>'.date('Y-m-d H:i:s');
?>