Вход Регистрация
Файл: modules/profile/avatar.php
Строк: 97
<?php
if(!defined('SHCMS_ENGINE')) {
    die( 
"Неправильное действие" );
}
    if(isset(
$_POST['submit'])) {
            if (
$_FILES['avatar']['error'])
                   echo 
engine::error(Lang::__('Ошибка при загрузке'));
            elseif (!
$_FILES['avatar']['size'])
                echo 
engine::error(Lang::__('Содержимое файла пусто')); 
            else {
                
                
$info pathinfo($_FILES['avatar']['name']);
                
                switch (
strtolower($info['extension'])) {
                    
//JPG
                    
case 'jpg':
                        
$avatar = @imagecreatefromjpeg($_FILES['avatar']['tmp_name']);
                    break;
                    
//JPEG
                    
case 'jpeg':
                        
$avatar = @imagecreatefromjpeg($_FILES['avatar']['tmp_name']);
                    break;
                    
//GIF
                    
case 'gif':
                        
$avatar = @imagecreatefromgif($_FILES['avatar']['tmp_name']);
                    break;
                    
//PNG
                    
case 'png':
                        
$avatar = @imagecreatefrompng($_FILES['avatar']['tmp_name']);
                    break;
                    
//По умолчанию
                    
default:
                        echo 
engine::error(Lang::__('Расширение файла не опознано'));
                    break;
                }
                if (!empty(
$avatar)) {
                        
//Создаем $trans для объекта Totranslit
                        
$trans = new ToTranslit();
                            
//Категория куда попадет скриншот
                            
$uploaddir H.'upload/avatar/';
                            
//Название транслированное
                            
$end_name $users['id'];                
                            
//Выполняем добавление
                            
$handle = new upload($_FILES['avatar']);
                                
//если скрин доступен выполняем следующее ....
                                
if ($handle->uploaded) {
                                    
//даем название
                                    
$handle->file_new_name_body   $end_name;
                                    
$handle->file_overwrite true;
                                    
//размеры
                                    
$handle->image_resize         true;
                                    
$handle->image_x 500;
                                    
$handle->image_ratio_y        true;
                                    
//Конвертируем все изображение в jpg для качественности
                                    
$handle->image_convert 'jpg';                                    
                                    
//Водяной знак
                                    
$handle->image_text            'SHCMS Engine'//Временно не менять 
                                    
$handle->image_text_opacity    80;
                                    
//Установка цвета к водяному знаку
                                    
$handle->image_text_color      '#0000FF';
                                    
$handle->image_text_background '#FFFFFF';
                                    
//Установим значем в какой угол пойдет знак
                                    
$handle->image_text_x          = -5;
                                    
$handle->image_text_y          = -5;
                                    
$handle->image_text_padding    5;
                                    
//Если загрузилась то выводит 
                                    
$handle->process($uploaddir);
                                        if (
$handle->processed) {
                                            
//echo engine::success(Lang::__('Скриншот успешно загружен'));
                                            
$handle->clean();
                                        } else {
                                            
//При ошибке
                                            
echo 'error : ' $handle->error;
                                        }
                                }
                                
                                
//Добавляем путь к скриншоту в базу
                                
                                    
$db->query("UPDATE `users` SET `avatar` = '".$db->safesql($end_name).".jpg' WHERE `id` = '{$users['id']}'");

                                
//Если скриншот сохранился то выводит это
                                
engine::success(Lang::__('Скриншот успешно добавлен'));
                                echo 
engine::home(array(Lang::__('Назад'),'/modules/profile.php?act=avatar'));
                                exit;
                            }
                            
//Если нет то эта
                            
else {
                                
engine::error(Lang::__('Скриншот не добавлен'));
                                echo 
engine::home(array(Lang::__('Назад'),'/modules/profile.php?act=avatar'));
                                exit;
                            }
            }    
    }
    echo 
'<div class="mainname">'.Lang::__('Аватар пользователя').'&nbsp;'.$users['nick'].'</div>';
    echo 
'<div class="mainpost">';
        
        if(
$users['avatar'] == false or file_exists(H.'/upload/avatar/'.$users['avatar'].'') == false) {

            echo 
'<img style="width: 50px; height:50px;" src="/engine/template/avatar/no_avatar/default.png">';
        
        }else {
        
            echo 
'<img src="/upload/avatar/'.$users['avatar'].'">';
        
        }
        
    echo 
'</div>';
    
    echo 
'<div class="mainname">'.Lang::__('Загрузка аватара').'</div>';
    echo 
'<div class="mainpost">';
        
$form = new form('/modules/profile.php?act=avatar','','','enctype="multipart/form-data"');
        
$form->input(false,'avatar','file');
        
$form->text('<div style="font-size:11px;">Загружать желательно изображение больше 200px</div>');
        
$form->text('</div><div class="submit">');
        
$form->submit(Lang::__('Загрузить'),'submit');
        
$form->text('или <a class="cancel" href="/modules/profile.php?act=core">Отменить</a>');
        
$form->text('</div>');
        
$form->display();
Онлайн: 1
Реклама