Размер файла: 3.55Kb
<?php
/*
--------------------------------
Смена аватара на фото из альбома
--------------------------------
*/
$photo = DB::GET_COLUMN("SELECT COUNT(`ID`) FROM `PHOTOS` WHERE `ID` = '".INTVAL(GET('avatar_upgrade'))."' AND `USER_ID` = '".$user['ID']."' LIMIT 1");
IF (GET('avatar_upgrade') && $photo == 1){
CSRF::GET_CHECK_VALID(GET('avatar_upgrade'));
$photo_show = DB::GET_COLUMN("SELECT COUNT(*) FROM `PHOTOS_SHOW` WHERE `PHOTO_ID` = '".INTVAL(GET('avatar_upgrade'))."' AND `USER_ID` = '".$user['ID']."' AND `TYPE` = 'avatar' LIMIT 1");
IF ($photo_show == 1){
DB::GET_SET("DELETE FROM `PHOTOS_SHOW` WHERE `USER_ID` = '".$user['ID']."' AND `PHOTO_ID` = '".$settings['AVATAR']."' AND `TYPE` = 'avatar'");
}
IF ($photo_show == 0){
DB::GET_ADD("INSERT INTO `PHOTOS_SHOW` (`USER_ID`, `PHOTO_ID`, `TYPE`) VALUES ('".$user['ID']."', '".INTVAL(GET('avatar_upgrade'))."', 'avatar')");
}
DB::GET_SET("UPDATE `USERS_SETTINGS` SET `AVATAR` = '".INTVAL(GET('avatar_upgrade'))."' WHERE `USER_ID` = '".$user['ID']."' LIMIT 1");
REDIRECT('/id'.$user['ID'].'');
}ELSEIF (GET('avatar_upgrade') && $photo == 0){
CSRF::GET_CHECK_VALID(GET('avatar_upgrade'));
ERROR('Неизвестная ошибка', 'session');
REDIRECT('/id'.$user['ID'].'');
}
/*
-------------------------
Удаление текущего аватара
-------------------------
*/
$photo = DB::GET_COLUMN("SELECT COUNT(`ID`) FROM `PHOTOS` WHERE `ID` = '".INTVAL(GET('avatar_delete'))."' AND `USER_ID` = '".$user['ID']."' LIMIT 1");
IF (GET('avatar_delete') && $photo == 1){
CSRF::GET_CHECK_VALID(GET('avatar_delete'));
$photo_show = DB::GET_COLUMN("SELECT COUNT(*) FROM `PHOTOS_SHOW` WHERE `PHOTO_ID` = '".INTVAL(GET('avatar_delete'))."' AND `USER_ID` = '".$user['ID']."' AND `TYPE` = 'avatar' LIMIT 1");
IF ($photo_show == 1){
DB::GET_SET("DELETE FROM `PHOTOS_SHOW` WHERE `USER_ID` = '".$user['ID']."' AND `PHOTO_ID` = '".$settings['AVATAR']."' AND `TYPE` = 'avatar'");
}
DB::GET_SET("UPDATE `USERS_SETTINGS` SET `AVATAR` = '0' WHERE `USER_ID` = '".$user['ID']."' LIMIT 1");
REDIRECT('/id'.$user['ID'].'');
}ELSEIF (GET('avatar_delete') && $photo == 0){
CSRF::GET_CHECK_VALID(GET('avatar_delete'));
ERROR('Неизвестная ошибка', 'session');
REDIRECT('/id'.$user['ID'].'');
}
/*
------------
Вывод автара
------------
*/
ECHO "<div style='position: absolute; bottom: 5px; left: 25px;'>";
ECHO "<span style='position: relative;'>";
ECHO "<span id='avatar_upgrade'>";
USER::AVATAR($account['ID'], 85, 1);
ECHO "</span>";
//Вывод рейтинга
REQUIRE (ROOT.'/users/profile/account/plugins/rating.php');
IF ($account['ID'] == $user['ID']){
?><a id="upload" action="/system/AJAX/php/avatar.php" class="btn-avatar" onclick="modal_open('#avatar')" load="none"><?=ICONS('camera', 13, 'fa-fw')?></a><?
/*
-----------------------
Выгрузка новой аватарки
-----------------------
*/
ECHO "<div class='overlay'>";
ECHO "<div class='modal' id='avatar'>";
ECHO "<div class='modal-title'>";
ECHO "<b>".LG('Новый аватар')."</b>";
?><a onclick="modal_close('#avatar')" load="none" class="btn-modal-close"><?=ICONS('times', 20, 'fa-fw')?></a><?
ECHO "</div>";
ECHO "<div class='modal-optimize'>";
ECHO "<div class='list-menu'>";
ECHO "<div id='upload2'></div>";
ECHO "</div>";
ECHO "</div>";
ECHO "</div>";
ECHO "</div>";
}
ECHO "</span>";
ECHO "</div>";
?>