-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathul.php
26 lines (25 loc) · 955 Bytes
/
ul.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
<?php
// Secret key. This must match the secret key in bookmarklet.js
$secret_key = "CHANGEME";
// Get/Set values
$url = urldecode($_GET["img_url"]);
$sk = urldecode($_GET["secret_key"]);
$file_path = rand(1,9999).basename($url);
$return = array("resp_str" => urldecode($_GET["resp_str"]), "full_path" => urldecode($_GET["directory"]).$file_path);
if(!$url || !$file_path || !$sk) { // Ensure we have all of the required data
$return["status"] = "failed";
$return["fail_reason"] = "Missing Data";
} elseif($secret_key != $sk) { // Make sure we're authorized
$return["status"] = "failed";
$return["fail_reason"] = "Unauthorized: Keys must match.";
} else {
if(file_put_contents($file_path, file_get_contents($url))) {
$return["status"] = "success";
$return["url"] = urldecode($_GET["directory"]).$file_path;
} else {
$return["status"] = "failed";
$return["fail_reason"] = "Unknown Error";
}
}
echo 'pResponse('.json_encode($return).')';
?>