-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt.php
More file actions
93 lines (81 loc) · 2.38 KB
/
decrypt.php
File metadata and controls
93 lines (81 loc) · 2.38 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
<?php
class DeCrypt {
const APIURL = "https://api.decry.pt/";
const USERNAME = "0000";
const PASSWORD = "pass1234";
public static $CURL_OPTIONS = array(
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => 10,
CURLOPT_USERAGENT => 'DeCryptAPI/1.0',
);
public function sendAPI($endpoint, $data, $multipart = FALSE) {
$ch = curl_init();
if (!$multipart) {
$data = http_build_query($data);
}
$options = self::$CURL_OPTIONS + array(
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $data,
CURLOPT_URL => self::APIURL . $endpoint,
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
if (curl_errno($ch) == 60) {
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/ca_bundle.crt');
$result = curl_exec($ch);
}
if ($result === FALSE || curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200) {
curl_close($ch);
return FALSE;
}
curl_close($ch);
$data = json_decode($result);
return json_last_error() == JSON_ERROR_NONE ? $data : $result;
}
public function uploadFile($filename, $filecontent) {
$result = self::sendAPI(
'/SendFile.php',
array(
'username' => self::USERNAME,
'password' => self::PASSWORD,
'filename' => $filename,
'filecontent' => $filecontent
)
);
switch($result->code) {
case "ok":
//file ID for future download
return $result->info;
break;
case "login-failed":
//login failed
return "0";
break;
}
}
public function browseUploads($limit = 20, $only_success = 1, $min_ts = strtotime('-1 year',time()), $max_ts = time()) {
$result = self::sendAPI(
'/SearchList.php',
array(
'username' => self::USERNAME,
'password' => self::PASSWORD,
'limit' => $limit,
'only_success' => $only_success,
'min_ts' => $min_ts,
'max_ts' => $max_ts
)
);
switch($result->code) {
case "ok":
//all uploads inside array
return $result->info;
break;
case "login-failed":
//login failed
return "0";
break;
}
}
}
?>