forked from sxyazi/qiniu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandle.inc.php
executable file
·67 lines (53 loc) · 1.76 KB
/
handle.inc.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
<?php
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
// require_once libfile('function/post');
// print_r(getattach(0, 0, 31));die;
// require_once libfile('function/attachment');
// echo getattachexif(0, DISCUZ_ROOT . 'data/attachment/forum/2.png');die;
(empty($_GET['upload_ret']) || empty($_SERVER['HTTP_REFERER'])) && exit();
// 载入类库
require_once DISCUZ_ROOT . 'source/plugin/qiniu/lib/qiniu.php';
require_once DISCUZ_ROOT . 'source/plugin/qiniu/lib/attachXML.php';
$result = json_decode(Qiniu\base64_urlSafeDecode($_GET['upload_ret']), true);
// {"name":"test.png", "size":1418, "hash":"FkRsIOKizjRdSb9lqUs9ri7AbDjv", "type":"image/png", "key":"FkRsIOKizjRdSb9lqUs9ri7AbDjv", "ext":".png", "imageInfo":{"colorModel":"nrgba","format":"png","height":52,"width":56}}
// 获取fid
$url = parse_url($_SERVER['HTTP_REFERER']);
parse_str($url['query'], $url);
empty($url['fid']) && exit();
// 伪造值
$_GET['fid'] = $url['fid'];
$_FILES['Filedata'] = array(
'name' => $result['name'],
'type' => $result['ext'],
'sha1' => $result['hash'],
'tmp_name' => $result['key'],
'error' => 0,
'size' => $result['size'],
'imageInfo' => $result['imageInfo']
);
$_GET['type'] = 'image';
$_GET['operation'] = 'upload';
if($_GET['maile'] == 1){
unset($_GET['type']);
}elseif($_GET['maile'] == 2){
$_GET['simple'] = 2;
}
// 组织JSON
ob_start();
require DISCUZ_ROOT . 'source/plugin/qiniu/extend/upload_handle.php';
$id = ob_get_clean();
if($_GET['maile'] == 2){
$str = explode('|', $id);
if(!is_numeric($str[3]) || $str[3]<1)
maile\qiniu::unlink($result['key']);
echo $id;
return;
}
if(!is_numeric($id) || $id<1)
maile\qiniu::unlink($result['key']);
echo json_encode(array(
'id' => $id,
'name' => $result['name'],
));