forked from lincanbin/Carbon-Forum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_crawler.php
43 lines (39 loc) · 1.2 KB
/
upload_crawler.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
<?php
set_time_limit(0);
include(dirname(__FILE__) . '/common.php');
include(dirname(__FILE__) . '/includes/Uploader.class.php');
SetStyle('api', 'API');
header("Content-Type: text/html; charset=utf-8");
Auth(1, 0, true);
/* 上传配置 */
$config = array(
"pathFormat" => $Config['WebsitePath'] . $UploadConfig['catcherPathFormat'],
"maxSize" => $UploadConfig['catcherMaxSize'],
"allowFiles" => $UploadConfig['catcherAllowFiles'],
"oriName" => "remote.png"
);
$fieldName = $UploadConfig['catcherFieldName'];
/* 抓取远程图片 */
$list = array();
if (isset($_POST[$fieldName])) {
$source = $_POST[$fieldName];
} else {
$source = $_GET[$fieldName];
}
foreach ($source as $imgUrl) {
$item = new Uploader($imgUrl, $config, "remote", $Prefix, $CurUserName, $DB);
$info = $item->getFileInfo();
array_push($list, array(
"state" => $info["state"],
"url" => $info["url"],
"size" => $info["size"],
"title" => htmlspecialchars($info["title"]),
"original" => htmlspecialchars($info["original"]),
"source" => htmlspecialchars($imgUrl)
));
}
/* 返回抓取数据 */
return json_encode(array(
'state' => count($list) ? 'SUCCESS' : 'ERROR',
'list' => $list
));