Файл: modules/user/load_avatar.php
Строк: 64
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
import_lib('jimage.class');
if(file_exists(ROOT.'/files/avatars/'.$user['id'].'.jpg'))
{
unlink(ROOT.'/files/avatars/'. $user['id'] .'.jpg');
@unlink(ROOT.'/files/avatars/'. $user['id'] .'_mini.jpg');
}
$file_info = pathinfo($_FILES['avatar']['name']);
$file_info['extension'] = strtolower($file_info['extension']);
move_uploaded_file($_FILES['avatar']['tmp_name'], ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
$avatar = new jimage();
$avatar->thumb(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension'], ROOT.'/files/avatars/'.User::Id().'.jpg', 100, 120);
$avatar->thumb(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension'], ROOT.'/files/avatars/'.User::Id().'_mini.jpg', 36, 36);
unlink(ROOT.'/tmp/'.$file_info['filename'].'.'.$file_info['extension']);
redirect('/user/avatar');