Skip to content

Commit

Permalink
remove __weekup() and __sleep()
Browse files Browse the repository at this point in the history
  • Loading branch information
ares333 committed Dec 5, 2018
1 parent 6a1042c commit 82fa719
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 171 deletions.
98 changes: 33 additions & 65 deletions demo/http_clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
if (! isset($argv[1])) {
$argv[1] = '1';
}
$dump = true;
if (isset($argv[2]) && '0' === $argv[2]) {
$dump = false;
}

class HttpCloneDemo extends HttpClone
{
Expand All @@ -25,8 +21,7 @@ function onProcess($r, $args)
'gif',
'png'
);
if ($this->blockedFileRemoveCache && in_array(
pathinfo($r['info']['url'], PATHINFO_EXTENSION), $checkExt)) {
if ($this->blockedFileRemoveCache && in_array(pathinfo($r['info']['url'], PATHINFO_EXTENSION), $checkExt)) {
if (false !== strpos($r['info']['content_type'], 'text')) {
$r['info']['http_code'] = 403;
if (isset($r['cacheFile']) && is_file($r['cacheFile'])) {
Expand All @@ -37,64 +32,37 @@ function onProcess($r, $args)
return parent::onProcess($r, $args);
}
}
$dumpFile = __DIR__ . '/output/clone/dump' . $argv[1];
if (is_file($dumpFile)) {
$clone = unserialize(file_get_contents($dumpFile));
} else {
$clone = new HttpCloneDemo($dir);
$clone->getCurl()->opt[CURLOPT_CONNECTTIMEOUT] = 3;
$clone->getCurl()->opt[CURLOPT_ENCODING] = 'gzip,deflate';
$clone->getCurl()->cache['enable'] = true;
$clone->getCurl()->cache['expire'] = 86400 * 30;
$clone->getCurl()->cache['enableDownload'] = true;
$clone->getCurl()->cache['dir'] = $cacheDir;
$clone->getCurl()->cache['compress'] = 6;
$clone->expire = 0;
switch ($argv[1]) {
case '1':
$clone->getCurl()->maxThread = 1;
$clone->getCurl()->opt[CURLOPT_TIMEOUT] = 5;
$clone->add('http://www.laruence.com/manual/');
$clone->blacklist = array(
'http://img.tongji.linezing.com/728491/tongji.gif',
'http://js.tongji.linezing.com/728491/tongji.js',
'http://www.laruence.com/manual/css/images/dialog-information.png',
'http://www.laruence.com/manual/css/images/dialog-warning.png'
);
break;
case '2':
$clone->getCurl()->maxThread = 2;
$clone->getCurl()->opt[CURLOPT_TIMEOUT] = 30;
$clone->download['video'] = true;
$clone->add('http://www.handubaby.com', 5);
break;
case '3':
$clone->getCurl()->maxThread = 2;
$clone->getCurl()->opt[CURLOPT_TIMEOUT] = 30;
$clone->add('http://www.bjszxx.cn/', 3);
break;
}
}
if ($dump) {
if (function_exists('pcntl_signal')) {
pcntl_signal(SIGINT,
function () use ($clone, $dumpFile) {
$clone->getCurl()->stop(
function () use ($clone, $dumpFile) {
$clone->getCurl()->onEvent = null;
file_put_contents($dumpFile, serialize($clone));
exit(0);
});
});

$clone->getCurl()->onEvent = function () {
pcntl_signal_dispatch();
};
} else {
echo "pcntl extension not found and auto dump is disabled.\n";
}
$clone = new HttpCloneDemo($dir);
$clone->getCurl()->opt[CURLOPT_CONNECTTIMEOUT] = 3;
$clone->getCurl()->opt[CURLOPT_ENCODING] = 'gzip,deflate';
$clone->getCurl()->cache['enable'] = true;
$clone->getCurl()->cache['expire'] = 86400 * 30;
$clone->getCurl()->cache['enableDownload'] = true;
$clone->getCurl()->cache['dir'] = $cacheDir;
$clone->getCurl()->cache['compress'] = 6;
$clone->expire = 0;
switch ($argv[1]) {
case '1':
$clone->getCurl()->maxThread = 1;
$clone->getCurl()->opt[CURLOPT_TIMEOUT] = 5;
$clone->add('http://www.laruence.com/manual/');
$clone->blacklist = array(
'http://img.tongji.linezing.com/728491/tongji.gif',
'http://js.tongji.linezing.com/728491/tongji.js',
'http://www.laruence.com/manual/css/images/dialog-information.png',
'http://www.laruence.com/manual/css/images/dialog-warning.png'
);
break;
case '2':
$clone->getCurl()->maxThread = 2;
$clone->getCurl()->opt[CURLOPT_TIMEOUT] = 30;
$clone->download['video'] = true;
$clone->add('http://www.handubaby.com', 5);
break;
case '3':
$clone->getCurl()->maxThread = 2;
$clone->getCurl()->opt[CURLOPT_TIMEOUT] = 30;
$clone->add('http://www.bjszxx.cn/', 3);
break;
}
$clone->start();
if (is_file($dumpFile)) {
unlink($dumpFile);
}
Loading

0 comments on commit 82fa719

Please sign in to comment.