plugins/SpecialUserPrefs.php
changeset 329 0437a7cf1acc
parent 328 dc838fd61a06
child 334 c72b545f1304
equal deleted inserted replaced
328:dc838fd61a06 329:0437a7cf1acc
   706               unlink($tempfile);
   706               unlink($tempfile);
   707               echo '<div class="error-box">' . $lang->get('usercp_avatar_bad_filetype') . '</div>';
   707               echo '<div class="error-box">' . $lang->get('usercp_avatar_bad_filetype') . '</div>';
   708               break;
   708               break;
   709             }
   709             }
   710             
   710             
       
   711             $avi_path_new = ENANO_ROOT . '/' . getConfig('avatar_directory') . '/' . $session->user_id . '.' . $file_type;
       
   712             
   711             // The file type is good - validate dimensions and animation
   713             // The file type is good - validate dimensions and animation
   712             switch($file_type)
   714             switch($file_type)
   713             {
   715             {
   714               case 'png':
   716               case 'png':
   715                 $is_animated = is_png_animated($tempfile);
   717                 $is_animated = is_png_animated($tempfile);
   750               @unlink($tempfile);
   752               @unlink($tempfile);
   751               echo '<div class="error-box">' . $lang->get('usercp_avatar_too_large') . '</div>';
   753               echo '<div class="error-box">' . $lang->get('usercp_avatar_too_large') . '</div>';
   752               break;
   754               break;
   753             }
   755             }
   754             // All good!
   756             // All good!
   755             if ( rename($tempfile, $avi_path) )
   757             @unlink($avi_path);
       
   758             if ( rename($tempfile, $avi_path_new) )
   756             {
   759             {
   757               $q = $db->sql_query('UPDATE ' . table_prefix . "users SET user_has_avatar = 1, avatar_type = '$file_type' WHERE user_id = {$session->user_id};");
   760               $q = $db->sql_query('UPDATE ' . table_prefix . "users SET user_has_avatar = 1, avatar_type = '$file_type' WHERE user_id = {$session->user_id};");
   758               if ( !$q )
   761               if ( !$q )
   759                 $db->_die('Avatar CP updating users table after successful avatar upload');
   762                 $db->_die('Avatar CP updating users table after successful avatar upload');
   760               $has_avi = 1;
   763               $has_avi = 1;