-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
105 lines (71 loc) · 2.34 KB
/
Copy pathindex.php
File metadata and controls
105 lines (71 loc) · 2.34 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
98
99
100
101
102
103
104
105
<?php
//Get Keys: https://cloud.nabzclan.vip/account/edit
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
define("key1", "key here 1"); // add key 2
define("key2", "key here 2"); // add key 2
function apiToken() {
$url = "https://cloud.nabzclan.vip/api/v2/authorize"."?key1=".key1."&key2=".key2;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #:" . $err;
} else {
$data = json_decode($response, true);
$access_token = $data["data"]["access_token"];
$account_id = $data["data"]["account_id"];
return ["access_token" => $access_token, "account_id" => $account_id];
}
}
function uploadFile() {
$response = apiToken();
$access_token = $response["access_token"];
$account_id = $response["account_id"];
$filePath = $_FILES['file']['tmp_name'];
$type=$_FILES['file']['type'];
$fileName = $_FILES['file']['name'];
$data = array(
'access_token' => $response['access_token'],
'account_id' => $response['account_id'],
'upload_file' => curl_file_create($filePath, $type, $fileName),
'folder_id' => '632'
);
$url = "https://cloud.nabzclan.vip/api/v2/file/upload";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => array('Content-Type: multipart/form-data'),
CURLOPT_POST => 1,
CURLOPT_TIMEOUT => 3600,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $data
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$decoded = json_decode($response, true);
if (isset($decoded['data']['url'])) {
$decoded['data']['url'] = stripslashes($decoded['data']['url']);
}
echo "<pre>" . json_encode($decoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "</pre>";
}
if (isset($_POST['upload'])) {
uploadFile();
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="file">
<button name="upload">Upload</button>
</form>