Advertisement
arabtion

Untitled

Nov 13th, 2019
416
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. /**
  3. * Codychat
  4. *
  5. * @package Codychat
  6. * @author www.boomcoding.com
  7. * @copyright 2018
  8. * @terms any use of this script without a legal license is prohibited
  9. * all the content of Codychat is the propriety of BoomCoding and Cannot be
  10. * used for another project.
  11. */
  12. require_once('config_session.php');
  13.  
  14. if (isset($_FILES["file"])){
  15.  
  16. ini_set('memory_limit','128M');
  17.  
  18. $info = pathinfo($_FILES["file"]["name"]);
  19. $extension = $info['extension'];
  20.  
  21. if(!boomAllow($data['allow_avatar'])){
  22. die();
  23. }
  24. if(fileError(2)){
  25. echo 1;
  26. }
  27.  
  28. $count = rand(0,99999999);
  29. $count2 = rand(0,99999999);
  30. $file_tumb = "avatar_user" . $data["user_id"] . "_" . $count . $count2 . "." . $extension;
  31. $file_avatar = "temporary_avatar_user_" . $data["user_id"] . "." . $extension;
  32.  
  33. unlinkAvatar($file_avatar);
  34.  
  35. if (isImage($extension)){
  36. $info = getimagesize($_FILES["file"]["tmp_name"]);
  37. if ($info !== false) {
  38.  
  39. $width = $info[0];
  40. $height = $info[1];
  41. $type = $info['mime'];
  42.  
  43. $filepath = '../avatar/' . $file_tumb;
  44. $filesource = '../avatar/' . $file_avatar;
  45. move_uploaded_file($_FILES["file"]["tmp_name"], "../avatar/" . $file_avatar);
  46. if(strtolower(pathinfo($filepath,PATHINFO_EXTENSION)) == 'gif' && file_exists("../avatar/".$file_avatar)){
  47. copy("../avatar/".$file_avatar, "../avatar/gif/".$file_tumb);
  48. }
  49. $create = createTumbnail($filesource, $filepath, $type, $width, $height, 200, 200);
  50.  
  51. if(file_exists($filepath) && file_exists($filesource)){
  52. $new_av = getimagesize($filepath);
  53. if ($new_av !== false) {
  54. unlinkAvatar($data['user_tumb']);
  55. unlinkAvatar($file_avatar);
  56. $mysqli->query("UPDATE boom_users SET user_tumb = '$file_tumb' WHERE user_id = '{$data["user_id"]}'");
  57. echo 5;
  58. die();
  59. }
  60. else {
  61. unlinkAvatar($file_avatar);
  62. echo 7;
  63. die();
  64. }
  65. }
  66. else {
  67. unlinkAvatar($file_avatar);
  68. echo 7;
  69. }
  70. }
  71. else {
  72. echo 7;
  73. die();
  74. }
  75. }
  76. else {
  77. echo 1;
  78. }
  79. }
  80. else {
  81. echo 7;
  82. }
  83. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement