Advertisement
Guest User

LVLup.pro/forum

a guest
Apr 23rd, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <!---
  2. Twórca: MTGmati/ReconV
  3. E-mail: reconv@my.ts3-avi.pl
  4.  
  5. API v2 do ShareX'a
  6. Dodano wykrywanie typu pliku.
  7. --->
  8.  
  9.  
  10. <?php
  11.  
  12. $secret_key = "KEY"; //Tajny kod
  13. $sharexdir = ""; //To jest twój katalog plików, także link... (jeżeli zostawisz puste będą przesyłane tam gdzie plik up.php)
  14. $domain_url = 'https://example.com';
  15. $lengthofstring = 8; //Długość randomowej nazwy zrzutu
  16. $allowedExts = array('png', 'jpg', 'jpeg', 'gif'); //Sprawdzanie typy pliku
  17. $allowedMime = array('image/png', 'image/jpeg', 'image/pjpeg', 'image/gif');  //Sprawdzanie typy pliku
  18.  
  19. function RandomString($length) {
  20.   $keys = array_merge(range(0,9), range('a', 'z'));
  21.  
  22.   for($i=0; $i < $length; $i++) {
  23.     $key .= $keys[mt_rand(0, count($keys) - 1)];
  24.   }
  25.   return $key;
  26. }
  27.  
  28. if(isset($_POST['secret']))
  29. {
  30.   if($_POST['secret'] == $secret_key)
  31.   {
  32.     $filename = RandomString($lengthofstring);
  33.     $target_file = $_FILES["sharex"]["name"];
  34.     $fileType = pathinfo($target_file, PATHINFO_EXTENSION);
  35.  
  36.     if ((in_array($_FILES['sharex']['type'], $allowedMime)) && (in_array(strtolower($fileType), $allowedExts))) {
  37.       if (move_uploaded_file($_FILES["sharex"]["tmp_name"], $sharexdir.$filename.'.'.$fileType))
  38.       {
  39.         echo $domain_url.$sharexdir.$filename.'.'.$fileType;
  40.       } else {
  41.         echo 'Nie udało się przesłać pliku';
  42.       }
  43.     } else {
  44.       echo "Nie obsługiwany typ pliku";
  45.     }
  46.   } else {
  47.     echo 'Nieprawidłowy tajny klucz';
  48.   }
  49. } else {
  50.   echo 'Nie otrzymano żadnych danych';
  51. }
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement