Advertisement
Kraust

upload-v2.php

Jul 13th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. <?php
  2. require 'simple_html_dom.php';
  3. header("Access-Control-Allow-Origin: http://www.gamefaqs.com ");
  4. header("Access-Control-Allow-Origin: * ");
  5.  
  6. if ($_POST) {
  7.  
  8. try {
  9.  
  10. throw new Exception('No longer supported');
  11.  
  12. $user = str_replace(" ", "+", substr($_POST['user'], 0, -1));
  13.  
  14. if (!empty($_SERVER['HTTP_CLIENT_IP']))
  15. {
  16. $ip = $_SERVER['HTTP_CLIENT_IP'];
  17. }
  18. elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
  19. {
  20. $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  21. }
  22. else
  23. {
  24. $ip = $_SERVER['REMOTE_ADDR'];
  25. }
  26.  
  27. $html = file_get_html('http://www.gamefaqs.com/users/'.$user.'/boards');
  28.  
  29. foreach($html->find('td') as $element) {
  30.  
  31. if($element->innertext == 'avatarupload:true') {
  32.  
  33. // Rename uploaded file to reflect original name
  34. if ($_FILES['file']['error'] !== UPLOAD_ERR_OK)
  35. throw new Exception('File was not successfully uploaded from your computer.');
  36.  
  37. if ($_FILES['file']['name'] === "")
  38. throw new Exception('File name not supplied by the browser.');
  39.  
  40. $image_size = getimagesize( $_FILES['file']['tmp_name'] );
  41.  
  42. if( $image_size[0] > 100 || $image_size[1] > 100 )
  43. throw new Exception('Image is too large, Maximum Dimensions: 100x100px');
  44.  
  45. $file_name = substr($_POST['user'], 0, -1).'.png';
  46.  
  47. if(file_exists("avatars/$file_name")) {
  48. if(fileperms("avatars/$file_name") == 33216 ) {
  49. throw new Exception('Please Contact Judgmenl for details.');
  50. }
  51. }
  52.  
  53. if (!move_uploaded_file($_FILES['file']['tmp_name'], "avatars/$file_name"))
  54. throw new Exception('Cannot rename uploaded file!');
  55.  
  56.  
  57. echo 'Upload Successful! Refreshing to apply changes...';
  58.  
  59. return;
  60.  
  61. }
  62. }
  63.  
  64. echo "Please update to at least v2.1.0 of xfaqs or 2.6.0 of GameFAQs-Avatars";
  65.  
  66. } catch(Exception $e) {
  67. echo 'Error: ' . htmlspecialchars($e->getMessage()) ;
  68. }
  69.  
  70. } else {
  71. echo "Test\n" . `ls -la avatars`;
  72.  
  73. }
  74.  
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement