-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·97 lines (75 loc) · 3.32 KB
/
Copy pathindex.php
File metadata and controls
executable file
·97 lines (75 loc) · 3.32 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
if (!file_exists ('config.php')){
session_start();
if ($_POST['app_key'] && $_POST['app_secret']){
$url = 'https://api.dropbox.com/1/oauth/request_token';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,array(
'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="'.$_POST['app_key'].'", oauth_signature="'.$_POST['app_secret'].'&"',
'Content-Length: 0'
)
);
$response = curl_exec($ch);
parse_str($response,$response);
$oauth_token_secret = $response['oauth_token_secret'];
$oauth_token = $response['oauth_token'];
$_SESSION['app_key'] = $_POST['app_key'];
$_SESSION['app_secret'] = $_POST['app_secret'];
$_SESSION['request_token_secret'] = $oauth_token_secret;
$_SESSION['request_token'] = $oauth_token;
$_SESSION['root'] = $_POST['root'];
$_SESSION['base'] = $_SERVER['REQUEST_URI'];
curl_close($ch);
header('Location: https://www.dropbox.com/1/oauth/authorize?oauth_token='.$oauth_token.'&oauth_callback='.$_SERVER['HTTP_REFERER']);
} else if ($_GET['uid'] && $_GET['oauth_token']){
$url = 'https://api.dropbox.com/1/oauth/access_token';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,array(
'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="'.$_SESSION['app_key'].'", oauth_token="'.$_GET['oauth_token'].'", oauth_signature="'.$_SESSION['app_secret'].'&'.$_SESSION['request_token_secret'].'"',
'Content-Length: 0'
)
);
$response = curl_exec($ch);
parse_str($response,$response);
file_put_contents('config.php',"<?php\n \$app_key = \"".$_SESSION['app_key']."\";\n \$app_secret = \"".$_SESSION['app_secret']."\";\n \$access_token = \"".$response['oauth_token']."\";\n \$access_token_secret = \"".$response['oauth_token_secret']."\";\n \$root = \"".$_SESSION['root']."\";\n?>");
print_r($_SERVER);
header('Location: '.$_SESSION['base']);
} else {
include('setup.php');
}
} else {
include('config.php');
$uri = $_SERVER['PATH_INFO'];
if ( substr( $uri, -1 ) == '/' ){
$uri .= 'index.html';
}
$url = 'https://api-content.dropbox.com/1/files/'.$root.$uri;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER,true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,array(
'Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="'.$app_key.'", oauth_token="'.$access_token.'", oauth_signature="'.$app_secret.'&'.$access_token_secret.'"',
)
);
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($code == 404) {
header('HTTP/1.0 404 Not Found');
echo "404 - Not found";
} else {
list($header, $body) = explode("\r\n\r\n", $response, 2);
$headers = explode("\n",$header);
foreach($headers as $h){
header($h);
}
}
echo($body);
}
?>