<?php
/*
- NTLCMS v 18.1 19.08.2017 г
- Автор скрипта Александр (NTL)
- Скрипт клик клуба v 18.1
- Оф.сайт http://clicks24.ru
- Контакты ntl-jt@mail.ru
- Все права принадлежат разработчику
- Вы не имеете право вносить изменения в код скрипта
- Данный скрипт запрещено распространять
*/
define('NTLCMS', 1);
$module = 'avatar';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
include ('../system/head.php');
include ('../system/upload.class.php');
################################################################################
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
################################################################################
$us = DB :: run() -> query("select (`avatar`) from `users` where `login` = ? limit 1", array($ulogin)) -> fetch(PDO::FETCH_OBJ);
if (isset($_POST['submit'])){
$handle = new upload($_FILES['imagefile']);
if ($handle -> uploaded){
// Обрабатываем фото
$handle -> file_new_name_body = $ilogin;
//$handle -> mime_check = false;
$handle -> allowed = array('image/jpeg', 'image/gif', 'image/png');
$handle -> file_max_size = 1024 * 1000 * 1;
$handle -> file_overwrite = true;
$handle -> image_resize = true;
$handle -> image_x = 160;
$handle -> image_ratio_y = true;
$handle -> image_convert = 'jpg';
$handle -> process(FOLDER.'/avatars/');
if ($handle -> processed){
$handle -> file_new_name_body = $ilogin;
$handle -> file_overwrite = true;
$handle -> image_resize = true;
$handle -> image_x = 40;
$handle -> image_ratio_y = true;
$handle -> image_convert = 'png';
$handle -> process(FOLDER.'/avatars/small');
DB :: run() -> query("update `users` set `avatar` = ? where `login` = ? limit 1", array(1, $ilogin));
} else {
header('Location: '.URL.'/cabinet');
$_SESSION['fail'] = $handle -> error;
}
$handle -> clean();
header('Location: '.URL.'/cabinet');
$_SESSION['success'] = 'Аватар успешно загружен!';
exit;
}
} else {
################################################################################
echo '<div class="title"><center>Загрузка аватара</center></div>';
################################################################################
if (isset($_GET['delete'])){
DB :: run() -> query("update `users` set `avatar` = ? where `login` = ? limit 1", array(0, $ilogin));
if (is_file(FOLDER.'/avatars/'.$ulogin.'.jpg')) unlink(FOLDER.'/avatars/'.$ulogin.'.jpg');
if (is_file(FOLDER.'/avatars/small/'.$ulogin.'.png')) unlink(FOLDER.'/avatars/small/'.$ulogin.'.png');
header('Location: '.URL.'/cabinet');
$_SESSION['success'] = 'Аватар успешно удален!';
}
################################################################################
echo '<div class="menu">';
if ($us -> avatar == '0'){
echo '<center><figure class="imgteaser"><img src="'.URL.'/style/icons/no-avatar.png" alt="*" style=" width: 110px; height: 110px; border-radius: 3%;"></figure></center>';
} else {
echo '<center><figure class="imgteaser"><img src="'.URL.'/avatars/'.$ulogin.'.jpg" alt="*" style=" width: 110px; height: 110px; border-radius: 3%;"></figure></center>';
}
if (is_file(FOLDER.'/avatars/'.$ulogin.'.jpg') || $us -> avatar != '0'){
echo '<center><a href="'.URL.'/ava_delete">Удалить аватар</a></center>';
}
echo '</div>';
################################################################################
echo '<div class="menu"><form enctype="multipart/form-data" method="post" action="'.URL.'/avatar">
Выберите изображение:<br/><input type="file" name="imagefile" value=""/>
<input type="hidden" name="MAX_FILE_SIZE" value="'.(1024 * 1000 * 1).'"/><br/>
<input type="submit" name="submit" value="Выгрузить файл"/></form>
<small>* Для выгрузки разрешены файлы JPG, JPEG, PNG, GIF<br/>* Размер файла не должен превышать 1 мб.</small></div>';
}
echo '<div class="block">'.image('home.png','18|18').' <a href="'.URL.'/cabinet">В кабинет</a></div>';
include ('../system/foot.php');
?>