Advertisement
Guest User

Untitled

a guest
May 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1. <?php      
  2.     include "upconfig.php";
  3.     $rootpath = '';
  4.     $data = base64_decode($_POST['data']);
  5.     $filename = $_POST['name'];
  6.     $username = $_POST['username'];
  7.     $pass = $_POST['password'];
  8.     if (wbauth($username,$pass) == TRUE) {
  9.       if (file_exists($rootpath.$filename)) { $exsist = 0; }
  10.       while ($exsist) {
  11.           $extension = "_{$exsist}";
  12.           if (file_exists($rootpath.$filename.$extension)) { $exsist++; }
  13.           else { $filename = $filename.$extension; $exsist = null; }
  14.       }
  15.       $fh = fopen($rootpath.$filename, 'w') or die("can't open file");
  16.       fwrite($fh, $data);
  17.       fclose($fh);
  18.      
  19.       //Do a check to see if it is really a picture. If it is not delete the file.
  20.       if(exif_imagetype($filename) == IMAGETYPE_PNG) {
  21.         if (filesize($filename) <= 20971520) {
  22.           $con = mysql_connect("localhost",$mysql_user,$mysql_pass);
  23.           mysql_select_db($mysql_db, $con);
  24.           $date = date('D, d M Y, g:i:s');
  25.           $timestamp = time();
  26.           $submit = mysql_query("INSERT INTO ScreenGrabs (Screenshot, Username, Host, Date, Timestamp)
  27.          VALUES('{$name}', '$username', '{$_SERVER['REMOTE_ADDR']}', '{$date}', '{$timestamp}')") ;
  28.           if (!$submit) { die('A MySQL error occured when attempting to upload your grab' . mysql_error()); }
  29.           die($filename);
  30.         }
  31.         else
  32.         {
  33.            unlink($rootpath.$filename);
  34.            die("Filesize exceeded (20mb)");  
  35.         }
  36.       }
  37.       else {
  38.            unlink($rootpath.$filename);
  39.            die("Invalid Image file detected.");
  40.       }
  41.     }
  42.     else { die('Authentication Failed'); }
  43.     function wbauth($username,$password) {
  44.       $link = mysql_connect('localhost','grabupi_wsb',mysql_wsb);
  45.       mysql_select_db("grabupi_wsb", $link);
  46.       $table = 'users';
  47.       $result = mysql_query("SELECT * FROM ".$table." WHERE username = '".$username."' AND password = '".$password."' AND active = '1'");
  48.           $authenticate = 0;
  49.       while ($row = mysql_fetch_array($result)) {
  50.          $authenticate++;
  51.       }
  52.       if ($authenticate == 1) { return TRUE; }
  53.       if ($authenticate == 0) { return FALSE; }
  54.     }
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement