· 7 years ago · Nov 09, 2018, 10:16 PM
1<?php
2
3//Define Upload Secret Key
4$secret_key = "aCNwgcG9k!1SWdck5p$6LvzFzJVwM*iCFc^4JhL^s$crPsd5R5";
5//Define ShareX Directory
6$sharexdir = "i/"; //This will be where your images are uploaded to on the server.
7//Define the domain URL here
8$domain_url = "www.0x69.pw/";
9//Define the length of the string used for the file name (0,9)
10$lengthofstring = "5";
11//Define safe file types for upload
12$safe_types = ["jpg", "jpeg", "png", "gif", "mp4"];
13
14function RandomString($length) {
15 $keys = array_merge(range(0,9), range('a', 'z'));
16
17 for($i=0; $i < $length; $i++) {
18 $key .= $keys[mt_rand(0, count($keys) - 1)];
19
20 }
21 return $key;
22}
23
24if(isset($_POST['secret']))
25{
26 if($_POST['secret'] == $secret_key)
27 {
28 $filename = RandomString($lengthofstring);
29 $target_file = $_FILES["sharex"]["name"];
30 $fileType = pathinfo($target_file, PATHINFO_EXTENSION);
31 if (in_array($fileType, $safe_types))
32 {
33 if (move_uploaded_file($_FILES["sharex"]["tmp_name"], $sharexdir.$filename.'.'.$fileType))
34 {
35 echo $domain_url.$sharexdir.$filename.'.'.$fileType;
36 }
37 else
38 {
39 echo 'File Upload Has Failed';
40 //Add error code later, maybe make it so it tells you if the folder doesn't exist or perms are bad?
41 }
42 }
43 }
44 else
45 {
46 echo 'Invalid Key';
47 }
48}
49else
50{
51 echo 'No POST data received';
52}
53?>