Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "upconfig.php";
- $rootpath = '';
- $data = base64_decode($_POST['data']);
- $filename = $_POST['name'];
- $username = $_POST['username'];
- $pass = $_POST['password'];
- if (wbauth($username,$pass) == TRUE) {
- if (file_exists($rootpath.$filename)) { $exsist = 0; }
- while ($exsist) {
- $extension = "_{$exsist}";
- if (file_exists($rootpath.$filename.$extension)) { $exsist++; }
- else { $filename = $filename.$extension; $exsist = null; }
- }
- $fh = fopen($rootpath.$filename, 'w') or die("can't open file");
- fwrite($fh, $data);
- fclose($fh);
- //Do a check to see if it is really a picture. If it is not delete the file.
- if(exif_imagetype($filename) == IMAGETYPE_PNG) {
- if (filesize($filename) <= 20971520) {
- $con = mysql_connect("localhost",$mysql_user,$mysql_pass);
- mysql_select_db($mysql_db, $con);
- $date = date('D, d M Y, g:i:s');
- $timestamp = time();
- $submit = mysql_query("INSERT INTO ScreenGrabs (Screenshot, Username, Host, Date, Timestamp)
- VALUES('{$name}', '$username', '{$_SERVER['REMOTE_ADDR']}', '{$date}', '{$timestamp}')") ;
- if (!$submit) { die('A MySQL error occured when attempting to upload your grab' . mysql_error()); }
- die($filename);
- }
- else
- {
- unlink($rootpath.$filename);
- die("Filesize exceeded (20mb)");
- }
- }
- else {
- unlink($rootpath.$filename);
- die("Invalid Image file detected.");
- }
- }
- else { die('Authentication Failed'); }
- function wbauth($username,$password) {
- $link = mysql_connect('localhost','grabupi_wsb',mysql_wsb);
- mysql_select_db("grabupi_wsb", $link);
- $table = 'users';
- $result = mysql_query("SELECT * FROM ".$table." WHERE username = '".$username."' AND password = '".$password."' AND active = '1'");
- $authenticate = 0;
- while ($row = mysql_fetch_array($result)) {
- $authenticate++;
- }
- if ($authenticate == 1) { return TRUE; }
- if ($authenticate == 0) { return FALSE; }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement