· 8 years ago · Nov 30, 2017, 08:50 PM
1<?php
2$secret_key = "du.nerfst.men"; //Set this as your secret key, to prevent others uploading to your server.
3$sharexdir = ""; //This is your file dir, also the link..
4$domain_url = 'http://du.nerfst.men/';
5$safe_types = ["png", "gif"];
6
7function md5_arsch() {
8 $link = "";
9 $md5hash = false;
10 while (!$md5hash)
11 {
12 $link = substr(md5(rand()),0);
13 if (empty(glob(getcwd() . "/" . $link . ".*")))
14 {
15 $md5hash = true;
16 }
17 }
18 return $link;
19}
20
21if(isset($_POST['secret']))
22{
23 if($_POST['secret'] == $secret_key)
24 {
25 $filename = md5_arsch();
26 $target_file = $_FILES["sharex"]["name"];
27 $fileType = pathinfo($target_file, PATHINFO_EXTENSION);
28 //not sure how save that is, but you can use this instead:
29 //$fileType = strtolower(end(explode(".", $target_file)));
30 if (in_array($fileType, $safe_types))
31 {
32 if (move_uploaded_file($_FILES["sharex"]["tmp_name"], $sharexdir.$filename.'.'.$fileType))
33 {
34 echo $domain_url.$sharexdir.$filename.'.'.$fileType;
35 }
36 else
37 {
38 echo 'File upload failed - CHMOD/Folder doesn\'t exist?';
39 }
40 }
41 }
42 else
43 {
44 echo 'Invalid Secret Key';
45 }
46}
47else
48{
49 echo 'No post data recieved';