-
Notifications
You must be signed in to change notification settings - Fork 1
/
archive.php
46 lines (33 loc) · 985 Bytes
/
archive.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
<?php
require dirname(__FILE__)."/app.php";
$urls = array();
$stdin = fopen("php://stdin", "r");
stream_set_blocking($stdin, false);
while($contentStdin = fgets($stdin)) {
$urls = array_merge($urls, PadClient::extractUrls($contentStdin));
}
fclose($stdin);
$bodyRequest = file_get_contents('php://input');
if($bodyRequest) {
$urls = array_merge($urls, PadClient::extractUrls($bodyRequest));
}
if(isset($argv)) {
$urls = array_merge($urls, PadClient::extractUrls(implode(" ", $argv)));
}
if(isset($_GET['url'])) {
$urls = array_merge($urls, PadClient::extractUrls($_GET['url']));
}
if(isset($_POST['url'])) {
$urls = array_merge($urls, PadClient::extractUrls($_GET['url']));
}
$urls = array_values(array_unique($urls));
foreach($urls as $url) {
Archive::add($url);
echo "$url in queue to be archived\n";
}
if(isset($_GET['run']) && $_GET['run']) {
Archive::run();
}
if(isset($_GET['url'])) {
header('Location: '.Config::getBaseUrl());
}