Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Codychat
- *
- * @package Codychat
- * @author www.boomcoding.com
- * @copyright 2018
- * @terms any use of this script without a legal license is prohibited
- * all the content of Codychat is the propriety of BoomCoding and Cannot be
- * used for another project.
- */
- require_once('config_session.php');
- if (isset($_FILES["file"])){
- ini_set('memory_limit','128M');
- $info = pathinfo($_FILES["file"]["name"]);
- $extension = $info['extension'];
- if(!boomAllow($data['allow_avatar'])){
- die();
- }
- if(fileError(2)){
- echo 1;
- }
- $count = rand(0,99999999);
- $count2 = rand(0,99999999);
- $file_tumb = "avatar_user" . $data["user_id"] . "_" . $count . $count2 . "." . $extension;
- $file_avatar = "temporary_avatar_user_" . $data["user_id"] . "." . $extension;
- unlinkAvatar($file_avatar);
- if (isImage($extension)){
- $info = getimagesize($_FILES["file"]["tmp_name"]);
- if ($info !== false) {
- $width = $info[0];
- $height = $info[1];
- $type = $info['mime'];
- $filepath = '../avatar/' . $file_tumb;
- $filesource = '../avatar/' . $file_avatar;
- move_uploaded_file($_FILES["file"]["tmp_name"], "../avatar/" . $file_avatar);
- if(strtolower(pathinfo($filepath,PATHINFO_EXTENSION)) == 'gif' && file_exists("../avatar/".$file_avatar)){
- copy("../avatar/".$file_avatar, "../avatar/gif/".$file_tumb);
- }
- $create = createTumbnail($filesource, $filepath, $type, $width, $height, 200, 200);
- if(file_exists($filepath) && file_exists($filesource)){
- $new_av = getimagesize($filepath);
- if ($new_av !== false) {
- unlinkAvatar($data['user_tumb']);
- unlinkAvatar($file_avatar);
- $mysqli->query("UPDATE boom_users SET user_tumb = '$file_tumb' WHERE user_id = '{$data["user_id"]}'");
- echo 5;
- die();
- }
- else {
- unlinkAvatar($file_avatar);
- echo 7;
- die();
- }
- }
- else {
- unlinkAvatar($file_avatar);
- echo 7;
- }
- }
- else {
- echo 7;
- die();
- }
- }
- else {
- echo 1;
- }
- }
- else {
- echo 7;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement