-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfo.php
36 lines (36 loc) · 927 Bytes
/
info.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
<?php
$file = $_GET['file'];
$uk = $_GET['uk'];
$shareid = $_GET['shareid'];
$jsonpcallback = $_GET['jsonpcallback'];
//get url
if ($file != '') {
$url = 'http://pan.baidu.com/s/' . $file;
} elseif ($shareid != '' && $uk != '') {
$url = 'http://pan.baidu.com/share/link?shareid=' . $shareid . '&uk=' . $uk;
} else {
echo 'Parameter Error';
return false;
}
//get html content
$src = file_get_contents($url);
//get filename
$pattern = '/server_filename="(.+?)"/is';
preg_match_all($pattern, $src, $result);
$filename = $result[1][0];
//get uk
$pattern = '/FileUtils.share_uk="(.+?)"/is';
preg_match_all($pattern, $src, $result);
$uk = $result[1][0];
//get shareid
$pattern = '/FileUtils.share_id="(.+?)"/is';
preg_match_all($pattern, $src, $result);
$shareid = $result[1][0];
//output json
$info = array(
'filename' => $filename,
'uk' => $uk,
'shareid' => $shareid,
);
echo $jsonpcallback, '(', json_encode($info), ')';
?>