Файл: wall/post.php
Строк: 216
<?php
require_once '../incfiles/core.php';
require_once '../incfiles/func.php';
require_once '../incfiles/auth.php';
require_once '../incfiles/user.php';
if (!empty($_GET['id']) && is_numeric($_GET['id']))
{
$id = abs(intval($_GET['id']));
$result = mysql_query("SELECT * FROM `wall` WHERE `id` = '".$id."' LIMIT 1");
if (mysql_num_rows($result) == true)
{
$arr_post = mysql_fetch_array(mysql_query("SELECT * FROM `wall` WHERE `id` = '".$id."' LIMIT 1"));
$arr_user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$arr_post['wall_id']."' LIMIT 1"));
}
else go(URL.'/');
}
else go(URL.'/');
$title = $arr_user['name'].' '.$arr_user['surname'].' :: '.lang('Просмотр записи','Перегляд запису');
if ($window == false) require_once '../incfiles/head.php';
echo user_access_page($arr_user);
echo '<div class="title">'.($window==true?'<div class="right"><a href="" onclick="Window.Close(); return false"><img src="'.URL.'/design/img/del.png"/></a></div>'.lang('Просмотр записи','Перегляд запису'):'<a class="title_a_hover" href="'.URL.'/?id='.$arr_user['id'].'" onclick="Page.Go(this.href); return false">'.$arr_user['name'].' '.$arr_user['surname'].'</a>').'</div>
<div class="block">';
if ($arr_post['type'] == 'update_avatar') go(URL.'/avatars/preview.php?fname='.$arr_post['photos']);
else if ($arr_post['type'] == 'repost' || $arr_post['type'] == 'group_repost')
{
echo wall_post($arr_post,2);
}
else
{
echo user_name($arr_post['user_id']).'<br/>'.vtime($arr_post['time']).'<div class="clear"></div>';
if (!empty($arr_post['text'])) echo '<p>'.links(smiles(($_GET['text']=='full'?$arr_post['text']:cut($arr_post['text'],URL.'/wall/post.php?id='.$arr_post['id'].'&text=full')))).'</p>';
if (!empty($arr_post['photos']))
{
echo '<p>';
$q = explode("||", substr($arr_post['photos'], 1, -1));
$count = count($q);
$n = (isset($_GET['n']) and is_numeric($_GET['n']) and $_GET['n']>1 and $_GET['n']<=$count) ? $_GET['n'] : 1;
if ($count == 1)
{
if (file_exists(HOME .'/files/wall/'.$arr_post['user_id'].'/photos/'.$q[0])) echo '<center><img class="preview" src="'.URL.'/files/wall/'.$arr_post['user_id'].'/photos/preview/'.$q[0].'"/></center>'; else echo '<center><img class="preview_mini" src="'.URL.'/design/img/image_not_found.png"/></center>';
}
else if ($count > 1 && !empty($_GET['n']))
{
if (file_exists(HOME .'/files/wall/'.$arr_post['user_id'].'/photos/'.$q[($n-1)])) echo '<center><a href="'.URL.'/wall/post.php?id='.$id.'" onclick="Page.Go(this.href); return false"><img class="preview" src="'.URL.'/files/wall/'.$arr_post['user_id'].'/photos/preview/'.$q[($n-1)].'"/></a></center>'; else echo '<center><img class="preview_mini" src="'.URL.'/design/img/image_not_found.png"/></center>';
echo '<p><center>';
p($n,$count,URL.'/wall/post.php?id='.$id.'&');
echo ' | <b>'.$n.' '.lang('из','з').' '.$count.'</b> |';
n($n,$count,URL.'/wall/post.php?id='.$id.'&');
echo'</center></p>';
}
else
{
echo '<center>';
for ($i = 0; $i < $count; $i++)
{
if (file_exists(HOME .'/files/wall/'.$arr_post['user_id'].'/photos/'.$q[$i])) echo '<a href="'.URL.'/wall/post.php?id='.$id.'&n='.($i+1).'" onclick="Page.Go(this.href); return false"><img class="preview_mini" src="'.URL.'/files/wall/'.$arr_post['user_id'].'/photos/mini/'.$q[$i].'"/></a>'; else echo '<img class="preview_mini" src="'.URL.'/design/img/image_not_found.png"/>';
}
echo '</center>';
}
echo '</p>';
}
if (!empty($arr_post['video']))
{
echo '<p>';
$q = explode("||", substr($arr_post['video'], 1, -1));
$count = count($q);
for ($i = 0; $i < $count; $i++)
{
$arr_video = mysql_fetch_array(mysql_query("SELECT * FROM `video` WHERE `id` = '".($q[$i])."' LIMIT 1"));
if($arr_video['type']==0 || $arr_video['type']==2)
{
if(is_file(HOME .''.$arr_video['img'].''))$img =''.URL.''.$arr_video['img'].'';
else
$img =''.URL.'/design/img/video404.jpg';
}
elseif($arr_video['type']==1)
{
$img ='https://i.ytimg.com/vi/'.$arr_video['file'].'/mqdefault.jpg';
}
$url = ''.URL.'/video/'.$arr_video['id'].'';
//echo '<a href="'.URL.'/video/'.$arr['id'].'" onclick="Page.Go(this.href); return false;"><img class="preview_mini" src="'.$img.'"></a>';
if($count==1){
if (empty($_COOKIE['site_version']) || $_COOKIE['site_version'] == 'default')echo '<div class="video_one"><a href="'.$url.'" onclick="Page.Go(this.href); return false;"><div class="video_block_one"><img src="'.$img.'"/><div class="video_title_one">'.$arr_video['name'].'</div></div></a></div>';
else
echo '<a href="'.$url.'" onclick="Page.Go(this.href); return false;"><img class="preview_mini" src="'.$img.'"></a>';
}else{
if (empty($_COOKIE['site_version']) || $_COOKIE['site_version'] == 'default')echo '<div class="video"><a href="'.$url.'" onclick="Page.Go(this.href); return false;"><div class="video_block"><img src="'.$img.'"/><div class="video_title">'.$arr_video['name'].'</div></div></a></div>';
else
echo '<a href="'.$url.'" onclick="Page.Go(this.href); return false;"><img class="preview_mini" src="'.$img.'"></a>';
}
}
echo '</p><div class ="clear"></div>';
}
if (!empty($arr_post['audio']))
{
echo '<p>';
$q = explode("||", substr($arr_post['audio'], 1, -1));
$count = count($q);
for ($i = 0; $i < $count; $i++)
{
echo '<p>'.track($q[$i]).'</p>';
}
echo '</p>';
}
if ($window == false)
{
echo '<div class="post_panel">';
echo repost('wall',$id,$arr_post['urepost'],$arr_post['crepost'],$arr_post['user_id']);
echo like('wall',$id,$arr_post['ulike'],$arr_post['clike'],$arr_post['user_id']);
echo '</div>';
}
}
echo '</div>';
if ($window == true) exit;
if (!empty($user_id))
{
if ($device == 'Computer')
{
?>
<script type="text/javascript">
$(function(){
$('#form').on('submit', function(e){
e.preventDefault();
var $that = $(this),
formData = new FormData($that.get(0));
$.ajax({
url: $that.attr('action'),
type: $that.attr('method'),
contentType: false,
processData: false,
data: formData,
success: function(response){
if(response){
$('#content_comm').load($that.attr('action')+ '#content_comm .comm');
$('#textarea').val('');
}
}
});
});
});
$(function(){
$('#form_re_comm').on('submit', function(e){
e.preventDefault();
var $that = $(this),
formData = new FormData($that.get(0));
$.ajax({
url: $that.attr('action'),
type: $that.attr('method'),
contentType: false,
processData: false,
data: formData,
success: function(response){
if(response){
Page.Go('<?echo URL.'/wall/post.php?id='.$id;?>');
}
}
});
});
});
</script>
<?
}
require_once 'handler/del_comm.php';
require_once 'handler/comm.php';
if ($user_id == $arr_post['user_id'] || $user_id == $arr_post['wall_id'])
{
echo '<div class="title">';
if ($user_id == $arr_post['user_id'] && $arr_post['type'] != 'update_avatar') echo '<a href="'.URL.'/wall/edit_post.php?id='.$id.'" onclick="Page.Go(this.href); return false">'.lang('Редактировать запись','Редагувати запис').'</a> ';
echo '<a href="'.URL.'/?id='.$arr_post['wall_id'].'&del_post='.$id.'" onclick="Page.Go(this.href); return false">'.lang('Удалить запись','Видалити запис').'</a>
</div>';
}
echo '<div class="block2">
<form id="form" method="post" action="'.URL.'/wall/post.php?id='.$id.'">
<textarea id="textarea" class="input" name="comm" rows="4"></textarea>
<input class="button2" type="submit" value="'.lang('Написать','Написати').'"/>
<a class="button3" href="'.URL.'/ajax/smiles.php" onclick="FormContent.Smiles(this.href); return false"><img src="'.URL.'/design/img/smile.png"/></a>
</form>
</div>
<div id="form_content"></div>';
}
echo '<div id="content_comm"><div class="comm">
<div class="title">'.lang('Комментарии','Коментарі').' <div class="right">'.$arr_post['comm'].'</div></div>';
$all = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `wall_comm` WHERE `pid` = '".$id."' LIMIT 1"),0);
if ($all == true)
{
$cp = ceil($all/10);
$p = (isset($_GET['p']) and is_numeric($_GET['p']) and $_GET['p']>1 and $_GET['p']<=$cp) ? $_GET['p'] : 1;
$start = $p*10-10;
$arr_comm = mysql_query("SELECT * FROM `wall_comm` WHERE `pid` = '".$id."' ORDER by `time` DESC LIMIT $start,10");
while ($arr = mysql_fetch_array($arr_comm))
{
echo '<div class="block">';
if (!empty($user_id)) if ($user_id == $arr_post['wall_id'] || $user_id == $arr_post['user_id'] || $user_id == $arr['user_id']) echo '<div class="right"><a href="'.URL.'/wall/post.php?id='.$id.'&p='.$p.'&del_comm='.$arr['id'].'" onclick="Form.delPost(this.href); return false"><img src="'.URL.'/design/img/closed.png"/></a></div>';
echo user_name($arr['user_id']).'<br/>'.vtime($arr['time']).'<div class="clear"></div>';
if (!empty($arr['quote_id'])) echo '<ul><div class="quote">'.user_name($arr['quote_id']).'<br/>'.lang('пишет','пише').':<br/>'.smiles(text($arr['quote'])).'</div></ul>';
echo '<p>'.smiles(text($arr['text'])).'</p>';
if (!empty($user_id) && $user_id != $arr['user_id'])
{
echo '<p><a class="link_re_comm" id="link_re_comm_'.$arr['id'].'" href="" onclick="Form.reComm('.$arr['id'].'); return false">'.lang('Ответить','Відповісти').'</a></p>
<div class="re_comm" id="re_comm_'.$arr['id'].'">
<form id="form_re_comm" method="post" action="'.URL.'/wall/post.php?id='.$id.'">
<textarea class="input" name="re_comm" rows="4"></textarea>
<input type="hidden" name="re_id" value="'.$arr['id'].'"/>
<input class="button2" type="submit" value="'.lang('Написать','Написати').'"/>
</form>
</div>';
}
echo '</div>';
}
navi($p,$cp,''.URL.'/wall/post.php?id='.$id.'&');
}
echo '</div></div>';
require_once '../incfiles/foot.php';
?>