-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathul.php
30 lines (29 loc) · 976 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
27
28
29
30
<?php
// Secret key. This must match the secret key in bookmarklet.js
$secret_key = "CHANGEME";
// Get values
$url = trim($_GET["img_url"]);
$sk = urldecode($_GET["secret_key"]);
$directory = urldecode($_GET["directory"]);
$resp_str = $_GET['resp_str'];
// Do we have all of the data?
if(!$url || !$directory || !$sk || !$resp_str) {
$return['status'] = 'failed';
$return['fail_reason'] = 'Insufficient Data';
$return['resp_str'] = $resp_str;
echo 'pResponse('.json_encode($return).');';
} elseif($secret_key != $sk) {
$return['status'] = 'failed';
$return['fail_reason'] = 'Unauthorized: Keys must match.';
$return['resp_str'] = $resp_str;
echo 'pResponse('.json_encode($return).');';
} else {
$new_img = rand(1,9999).basename($url);
file_put_contents($new_img, file_get_contents($url));
$return = array();
$return['status'] = 'success';
$return['url'] = $directory.$new_img;
$return['resp_str'] = $resp_str;
echo 'pResponse('.json_encode($return).');';
}
?>