Файл: users/attachments/plugins/inc_news_edit.php
Строк: 56
<?php
/*
------
Музыка
------
*/
IF (GET('add_atcom_music') && DB::GET_COLUMN("SELECT COUNT(*) FROM `MUSIC` WHERE `USER_ID` = '".$user['ID']."' AND `ID` = '".INTVAL(GET('add_atcom_music'))."' LIMIT 1") > 0){
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `ATTACHMENTS` WHERE `NEWS` = '1' AND `USER_ID` = '".$user['ID']."' AND (`ID_POST` = '".$news['ID']."' OR `ID_POST` = '0') LIMIT 1") >= 3){
ERROR('Нельзя прикреплять более 3 файлов к 1 записи', 'success');
REDIRECT(''.BASE64_DECODE(GET('url')).'');
}
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `ATTACHMENTS` WHERE `NEWS` = '1' AND (`ID_POST` = '".$news['ID']."' OR `ID_POST` = '0') AND `USER_ID` = '".$user['ID']."' AND `OBJECT_ID` = '".INTVAL(GET('add_atcom_music'))."' AND `TYPE` = 'music' LIMIT 1") == 0){
DB::GET_ADD("INSERT INTO `ATTACHMENTS` (`USER_ID`, `OBJECT_ID`, `TYPE`, `TIME`, `NEWS`, `ID_POST`) VALUES ('".$user['ID']."', '".INTVAL(GET('add_atcom_music'))."', 'music', '".TIME()."', '1', '".$news['ID']."')");
}
REDIRECT(''.BASE64_DECODE(GET('url')).'');
}
/*
-----
Видео
-----
*/
IF (GET('add_atcom_videos') && DB::GET_COLUMN("SELECT COUNT(*) FROM `VIDEOS` WHERE `USER_ID` = '".$user['ID']."' AND `ID` = '".INTVAL(GET('add_atcom_videos'))."' LIMIT 1") > 0){
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `ATTACHMENTS` WHERE `NEWS` = '1' AND (`ID_POST` = '".$news['ID']."' OR `ID_POST` = '0') AND `USER_ID` = '".$user['ID']."' LIMIT 1") >= 3){
ERROR('Нельзя прикреплять более 3 файлов к 1 записи', 'success');
REDIRECT(''.BASE64_DECODE(GET('url')).'');
}
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `ATTACHMENTS` WHERE `NEWS` = '1' AND (`ID_POST` = '".$news['ID']."' OR `ID_POST` = '0') AND `USER_ID` = '".$user['ID']."' AND `OBJECT_ID` = '".INTVAL(GET('add_atcom_videos'))."' AND `TYPE` = 'videos' LIMIT 1") == 0){
DB::GET_ADD("INSERT INTO `ATTACHMENTS` (`USER_ID`, `OBJECT_ID`, `TYPE`, `TIME`, `NEWS`, `ID_POST`) VALUES ('".$user['ID']."', '".INTVAL(GET('add_atcom_videos'))."', 'videos', '".TIME()."', '1', '".$news['ID']."')");
}
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `VIDEOS_SHOW` WHERE `VIDEO_ID` = '".INTVAL(GET('add_atcom_videos'))."' AND `USER_ID` = '".$user['ID']."' AND `TYPE` = 'atcom' LIMIT 1") == 1){
DB::GET_SET("DELETE FROM `VIDEOS_SHOW` WHERE `USER_ID` = '".$user['ID']."' AND `VIDEO_ID` = '".INTVAL(GET('add_atcom_videos'))."' AND `TYPE` = 'atcom'");
}
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `VIDEOS_SHOW` WHERE `VIDEO_ID` = '".INTVAL(GET('add_atcom_videos'))."' AND `USER_ID` = '".$user['ID']."' AND `TYPE` = 'atcom' LIMIT 1") == 0){
DB::GET_ADD("INSERT INTO `VIDEOS_SHOW` (`USER_ID`, `VIDEO_ID`, `TYPE`) VALUES ('".$user['ID']."', '".INTVAL(GET('add_atcom_videos'))."', 'atcom')");
}
REDIRECT(''.BASE64_DECODE(GET('url')).'');
}
/*
----
Фото
----
*/
IF (GET('add_atcom_photos') && DB::GET_COLUMN("SELECT COUNT(*) FROM `PHOTOS` WHERE `USER_ID` = '".$user['ID']."' AND `ID` = '".INTVAL(GET('add_atcom_photos'))."' LIMIT 1") > 0){
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `ATTACHMENTS` WHERE `NEWS` = '1' AND (`ID_POST` = '".$news['ID']."' OR `ID_POST` = '0') AND `USER_ID` = '".$user['ID']."' LIMIT 1") >= 3){
ERROR('Нельзя прикреплять более 3 файлов к 1 записи', 'success');
REDIRECT(''.BASE64_DECODE(GET('url')).'');
}
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `ATTACHMENTS` WHERE `NEWS` = '1' AND (`ID_POST` = '".$news['ID']."' OR `ID_POST` = '0') AND `USER_ID` = '".$user['ID']."' AND `OBJECT_ID` = '".INTVAL(GET('add_atcom_photos'))."' AND `TYPE` = 'photos' LIMIT 1") == 0){
DB::GET_ADD("INSERT INTO `ATTACHMENTS` (`USER_ID`, `OBJECT_ID`, `TYPE`, `TIME`, `NEWS`, `ID_POST`) VALUES ('".$user['ID']."', '".INTVAL(GET('add_atcom_photos'))."', 'photos', '".TIME()."', '1', '".$news['ID']."')");
}
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `PHOTOS_SHOW` WHERE `PHOTO_ID` = '".INTVAL(GET('add_atcom_photos'))."' AND `USER_ID` = '".$user['ID']."' AND `TYPE` = 'atcom' LIMIT 1") == 1){
DB::GET_SET("DELETE FROM `PHOTOS_SHOW` WHERE `USER_ID` = '".$user['ID']."' AND `PHOTO_ID` = '".INTVAL(GET('add_atcom_photos'))."' AND `TYPE` = 'atcom'");
}
IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `PHOTOS_SHOW` WHERE `PHOTO_ID` = '".INTVAL(GET('add_atcom_photos'))."' AND `USER_ID` = '".$user['ID']."' AND `TYPE` = 'atcom' LIMIT 1") == 0){
DB::GET_ADD("INSERT INTO `PHOTOS_SHOW` (`USER_ID`, `PHOTO_ID`, `TYPE`) VALUES ('".$user['ID']."', '".INTVAL(GET('add_atcom_photos'))."', 'atcom')");
}
REDIRECT(''.BASE64_DECODE(GET('url')).'');
}
/*----------------------------------------*/
IF (GET('delete_atcom') && DB::GET_COLUMN("SELECT COUNT(*) FROM `ATTACHMENTS` WHERE `NEWS` = '1' AND (`ID_POST` = '".$news['ID']."' OR `ID_POST` = '0') AND `ID` = '".INTVAL(GET('delete_atcom'))."' LIMIT 1") > 0){
DB::GET_SET("DELETE FROM `ATTACHMENTS` WHERE `ID` = '".INTVAL(GET('delete_atcom'))."' LIMIT 1");
REDIRECT(''.REQUEST_URI.'');
}
ECHO "<div id='atcom-upgrade'>";
$count = DB::GET_COLUMN("SELECT COUNT(*) FROM `ATTACHMENTS` WHERE `NEWS` = '1' AND (`ID_POST` = '".$news['ID']."' OR `ID_POST` = '0') LIMIT 1");
IF ($count > 0){
ECHO "<div style='position: relative; padding: 4px;'>";
$data = DB::GET_STRING_ALL("SELECT * FROM `ATTACHMENTS` WHERE `NEWS` = '1' AND (`ID_POST` = '".$news['ID']."' OR `ID_POST` = '0') ORDER BY `TIME` DESC LIMIT 3");
WHILE ($list = $data->FETCH()){
IF ($list['TYPE'] == 'photos'){
$photos = DB::GET_STRING("SELECT * FROM `PHOTOS` WHERE `ID` = '".$list['OBJECT_ID']."' LIMIT 1");
ECHO "<div style='display: inline-block; width: 110px; text-align: center; vertical-align: top; position: relative;'>";
ECHO "<a href='".REQUEST_URI."&delete_atcom=".$list['ID']."' class='btn-o' style='position: absolute; top: -2px; right: 8px; z-index: 1; padding: 1px 0.5em;'>".ICONS('trash', 15, 'fa-fw')."</a>";
ECHO FILE::ICONS($photos['EXT']);
ECHO "<br />";
ECHO "<a href='/modules/?path=photos§ion=show&photo_id=".$photos['ID']."'>";
ECHO CROP_TEXT($photos['NAME'], 0, 8);
ECHO "</a>";
ECHO "</div>";
}
IF ($list['TYPE'] == 'videos'){
$videos = DB::GET_STRING("SELECT * FROM `VIDEOS` WHERE `ID` = '".$list['OBJECT_ID']."' LIMIT 1");
ECHO "<div style='display: inline-block; width: 110px; text-align: center; vertical-align: top; position: relative;'>";
ECHO "<a href='".REQUEST_URI."&delete_atcom=".$list['ID']."' class='btn-o' style='position: absolute; top: -2px; right: 8px; z-index: 1; padding: 1px 0.5em;'>".ICONS('trash', 15, 'fa-fw')."</a>";
ECHO FILE::ICONS($videos['EXT']);
ECHO "<br />";
ECHO "<a href='/modules/?path=videos§ion=show&video_id=".$videos['ID']."'>";
ECHO CROP_TEXT($videos['NAME'], 0, 8);
ECHO "</a>";
ECHO "</div>";
}
IF ($list['TYPE'] == 'music'){
$music = DB::GET_STRING("SELECT * FROM `MUSIC` WHERE `ID` = '".$list['OBJECT_ID']."' LIMIT 1");
ECHO "<div style='display: inline-block; width: 110px; text-align: center; vertical-align: top; position: relative;'>";
ECHO "<a href='".REQUEST_URI."&delete_atcom=".$list['ID']."' class='btn-o' style='position: absolute; top: -2px; right: 8px; z-index: 1; padding: 1px 0.5em;'>".ICONS('trash', 15, 'fa-fw')."</a>";
ECHO FILE::ICONS($music['EXT']);
ECHO "<br />";
ECHO "<a href='/modules/?path=music§ion=users&id=".$user['ID']."'>";
ECHO CROP_TEXT($music['NAME'], 0, 8);
ECHO "</a>";
ECHO "</div>";
}
}
ECHO "</div>";
}
ECHO "</div>";
ECHO "<div class='overlay'>";
ECHO "<div class='modal' id='at_comment'>";
ECHO "<div class='modal-title'>";
ECHO "<b>".LG('Прикрепить файл')."</b>";
?><a onclick="modal_close('#at_comment')" load="none" class="btn-modal-close"><?=ICONS('times', 20, 'fa-fw')?></a><?
ECHO "</div>";
ECHO "<div class='modal-optimize'>";
ECHO "<div id='upload-atcom-show'></div>";
ECHO "</div>";
ECHO "</div>";
ECHO "</div>";
?>