<?php
/**********************************************/
/* Автор скрипта: Александр Есин */
/* E-Mail: [email protected] ([email protected]) */
/* ICQ: 6464729 */
/* Site: http://ticlove.ru */
/**********************************************/
?>
<?php define ('SECURED', true); ?>
<?php require (dirname(__FILE__).'/_inc/sql.php'); ?>
<?php require (dirname(__FILE__).'/_inc/config.php'); ?>
<?php require (dirname(__FILE__).'/_inc/function.php'); ?>
<?php
if (!isset($_SESSION['auth_id']))
{
header('Location: /');
exit;
}
$mode = isset($_GET['mode']) ? $_GET['mode'] : NULL;
if ($mode == 'comments') {
$title_page = 'Комментарии к фото';
$description_page = 'Комментарии к фото';
$keywords_page = 'Комментарии к фото';
}
else
{
$title_page = 'Фотоальбом пользователя';
$description_page = 'Фотоальбом пользователя';
$keywords_page = 'Фотоальбом пользователя';
}
$user_id = intval($_GET['user_id']);
$sql = mysql_query("SELECT * FROM `q_users` WHERE `id_user` = '".$user_id."' LIMIT 1;");
if (mysql_num_rows($sql) == 0)
{
header('Location: /');
exit;
}
if ($user_id == $_SESSION['auth_id'])
{
header("Location: /album.php");
exit;
}
$user_array = mysql_fetch_array($sql);
?>
<?php include (dirname(__FILE__).'/include/header.php'); ?>
<div id="block_left">
<?php include (dirname(__FILE__).'/include/lider.php'); ?>
</div>
<div id="block_center">
<h3><?php echo $title_page; ?></h3>
<?php
echo '<div style="padding: 0 0 20px 0;"><a href="user.php?id='.$user_id.'">Вернуться в анкету '.htmlspecialchars($user_array['name']).'</a></div>';
switch ($mode)
{
case 'comments':
$id_photo = intval($_GET['photo_id']);
$sql = mysql_query("SELECT * FROM `q_photo` WHERE `id_photo` = '".$id_photo."' AND `id_user` = '".$user_id."' LIMIT 1;");
if (mysql_num_rows($sql) == 0) {
?>
<script type="text/javascript">
location="/";
</script>
<?php
}
$array_foto = mysql_fetch_array($sql);
$name_photo = explode('.', $array_foto['name']);
$photo = str_replace($name_photo[0], $name_photo[0].'_p', $array_foto['name']);
?>
<div class="left">
<a href="/photos.php?user_id=<?php echo $user_id; ?>"><img class="photo_bor" src="<?php echo DIR_PHOTOS; ?>/<?php echo $array_foto['id_user']; ?>/<?php echo $photo; ?>" alt="" /></a>
</div>
<div class="left" style="margin-left: 10px; width: 330px;">
<?php if (!empty($array_foto['about'])) { ?>
<strong>Описание:</strong> <?php echo htmlspecialchars(function_bigword($array_foto['about'], 45), ENT_QUOTES); ?>
<?php } ?>
</div>
<div class="clear"></div>
<?php
$col = COMMENTS_PAGE;
if (isset($_GET['start'])) $start = abs(intval($_GET['start']));
else $start = 0;
$count_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `q_photo_comm` WHERE `id_foto` = '".$id_photo."';"), 0);
if ($count_p > 0) {
echo '<div style="padding-bottom: 10px; font-size: 16px; color: #ff6633; font-weight: bold;">Комментарии к фотографии:</div>';
if ($start >= $count_p) $start = 0;
$q = mysql_query("SELECT * FROM `q_photo_comm` INNER JOIN `q_users` ON `q_users`.`id_user` = `q_photo_comm`.`id_user` WHERE `q_photo_comm`.`id_foto` = '".$id_photo."' ORDER BY `q_photo_comm`.`id_comm` DESC LIMIT ".$start.", ".$col);
$i = 1;
while ($array = mysql_fetch_array($q)) { ?>
<table width="100%" cellspacing="5" cellpadding="0">
<tr>
<td width="60" valign="top">
<a href="http://<?php echo $_SERVER['HTTP_HOST']; ?>/id<?php echo $array['id_user']; ?>">
<?php if (!empty($array['avatar'])) { ?>
<img class="<?php echo ($array['vip_status'] == 1 ? 'photo_bor_vip' : 'photo_bor'); ?>" src="<?php echo DIR_PHOTOS; ?>/<?php echo $array['id_user']; ?>/<?php echo $array['avatar']; ?>" alt="" />
<?php } else { ?>
<img class="<?php echo ($array['vip_status'] == 1 ? 'photo_bor_vip' : 'photo_bor'); ?>" src="/images/no_photo_small.png" alt="" />
<?php } ?>
</a><br/>
<?php if (function_online($array['online']) == TRUE) { ?>
<img src="/images/on.gif" alt="Онлайн" title="Онлайн" />
<?php } ?>
</td>
<td valign="top">
<?php if ($array['vip_status'] == 1) { ?>
<img src="/images/vip.gif" alt="" width="16" height="16" title="VIP-пользователь" />
<?php } ?>
<a class="<?php echo ($array['pol'] == 1 ? 'm_color' : 'zh_color'); ?>" href="http://<?php echo $_SERVER['HTTP_HOST']; ?>/id<?php echo $array['id_user']; ?>"><?php echo htmlspecialchars($array['name'], ENT_QUOTES); ?></a>, <span class="vozrast"><?php echo function_vozrast_n($array['god'].'-'.$array['mes'].'-'.$array['day']); ?></span><br/>
<span class="city"><?php echo htmlspecialchars($array['city'], ENT_QUOTES); ?>, <?php echo htmlspecialchars($array['country'], ENT_QUOTES); ?></span><br/>
<span style="font-size: 11px; color: #069de5;">Написал<?php echo ($array['pol'] == 1 ? '' : 'а'); ?> <?php echo function_vizit($array['time']); ?></span><br/>
<?php echo function_smile(htmlspecialchars(function_bigword($array['msg'], 45), ENT_QUOTES)); ?>
</td>
</tr>
</table>
<?php
if ($i <> $col) {
?>
<div style="margin: 10px 0; border-top: 5px dotted #ccc; font-size: 16px; color: #ff6633; width: 100%;"></div>
<?php
}
$i++;
}
function_page($_SERVER['PHP_SELF'].'?mode=comments&user_id='.$user_id.'&photo_id='.$id_photo.'&', $col, $start, $count_p);
} else echo '<div style="font-size: 18px; text-align: center; padding: 0 0 30px 0;">Комментариев нет</div>';
?>
<div class="clear"></div>
<script type="text/javascript">
var ie=document.all?1:0;
var ns=document.getElementById&&!document.all?1:0;
function InsertSmile(SmileId)
{
if(ie)
{
document.all.message.focus();
document.all.message.value+=" "+SmileId+" ";
}
else if(ns)
{
document.forms['forma'].elements['message'].focus();
document.forms['forma'].elements['message'].value+=" "+SmileId+" ";
}
else alert("Ваш браузер не поддерживается!");
}
</script>
<script type="text/javascript">
$(document).ready(function() {
$('#add').click(function() {
$('#comm-status').hide();
$.ajax({
type: "POST",
url: "/moduls/photo_comm_add.php",
data: { user_id: <? echo $_SESSION['auth_id']; ?>, user_uid: <? echo $user_id; ?>, fid: <?php echo $id_photo; ?>, uname: $('#uname').val(), msg: $('#msg').val() },
beforeSend: function() {
$('#comm-status').fadeIn(900);
$("#comm-status").html('<span class="green">Ваш запрос обрабатывается...</span>');
},
success: function(data) {
$("#comm-status").html(data);
$('#comm-status').fadeOut(1200);
}
});
});
});
</script>
<script type="text/javascript">
function smiles() {
$(document).ready(function() {
$.arcticmodal({
type: 'ajax',
url: '/moduls/smiles.php',
ajax: {
type: 'POST',
data: { user_id: <?php echo $_SESSION['auth_id']; ?> },
dataType: 'html',
success: function(data, el, responce) {
var h = $(responce);
$('B', h).html(responce.title);
$('P:last', h).html(responce.text);
data.body.html(h);
}
}
});
});
};
</script>
<div style="background-color: #eee; padding: 20px 10px;">
<div id="comm-status" style="text-align: center;"></div>
<form action="javascript:void(0)" name="forma">
Добавление нового комментария:
<div style="padding: 5px 0;">
<script type="text/javascript">
jQuery.fn.maxlength = function(options) {
var settings = jQuery.extend({
maxChars: 1000, // максимальное колличество символов
leftChars: "символов" // текст в конце строки информера
}, options);
return this.each(function() {
var me = $(this);
var l = settings.maxChars;
me.bind('keydown keypress keyup',function(e) {
if(me.val().length>settings.maxChars) me.val(me.val().substr(0,settings.maxChars));
l = settings.maxChars - me.val().length;
me.next('span').html(l + ' ' + settings.leftChars);
});
me.after('Осталось <span class="maxlen">' + settings.maxChars + ' ' + settings.leftChars + '</span>');
});
};
</script>
<script type="text/javascript">
$(document).ready(function(){
$("#msg").maxlength();
});
</script>
<textarea style="width:95%; max-width:95%; min-width:95%; padding: 5px;" name="message" id="msg" rows="4" cols="20"></textarea>
</div>
<input type="hidden" id="uname" value="<?php echo htmlspecialchars($user_array['name']); ?>" />
<input type="submit" class="submit" id="add" value="Добавить комментарий" /> <input type="submit" class="submit_green" onclick="javascript:smiles()" value="Смайлики" />
</form>
</div>
<?php
break;
default:
$sql = mysql_query("SELECT * FROM `q_photo` WHERE `id_user` = '".$user_id."' ORDER BY `preor` DESC;");
$num_rows = mysql_num_rows($sql);
if ($num_rows > 0)
{
$_SESSION['allFoto'] = $num_rows;
?>
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<?php
$n = 0;
$i = 1;
while ($array = mysql_fetch_array($sql))
{
$name_photo = explode('.', $array['name']);
$photo = str_replace($name_photo[0], $name_photo[0].'_p', $array['name']);
?>
<td align="left" style="padding-bottom: 20px;">
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left">
<a href="javascript:void(0)" onclick="javascript:photo('<?php echo $array['id_photo']; ?>', '<?php echo $n; ?>')"><img class="photo_bor" src="<?php echo DIR_PHOTOS; ?>/<?php echo $array['id_user']; ?>/<?php echo $photo; ?>" alt="" /></a><br/>
</td>
</tr>
<tr>
<td align="left"><a href="/photos.php?mode=comments&user_id=<?php echo $user_id; ?>&photo_id=<?php echo $array['id_photo']; ?>"><?php echo ($array['all_comm'] > 0 ? 'Комментарии ('.$array['all_comm'].')' : 'Комментировать'); ?></a></td>
</tr>
</table>
<?php if ($i == 3) { ?>
</td></tr><tr>
<?php $i = 0; ?>
<?php } else { ?>
</td>
<?php } ?>
<?php
$i++;
$n++;
}
?>
</tr>
</table>
<script type="text/javascript">
function photo(str, n) {
$(document).ready(function()
{
$.arcticmodal({
type: 'ajax',
url: '/moduls/photo.php',
ajax: {
type: 'POST',
data: { user_id: <?php echo $_SESSION['auth_id']; ?>, user_uid: <?php echo $user_id; ?>, foto: str, n: n },
dataType: 'html',
success: function(data, el, responce) {
var h = $(responce);
$('B', h).html(responce.title);
$('P:last', h).html(responce.text);
data.body.html(h);
}
}
});
});
};
function photo_id(n) {
$(document).ready(function()
{
$.ajax({
type: "POST",
url: "/moduls/photo_id.php",
data: { user_id: <?php echo $_SESSION['auth_id']; ?>, user_uid: <?php echo $user_id; ?>, n: n },
beforeSend: function()
{
$("#load_content_foto").addClass('load_content_foto');
$("#content_fade").fadeTo(700, 0.4);
$("#load_content_foto").css({'margin-left':'20px'});
},
success: function(data)
{
$("#foto_id_status").html(data);
}
});
});
};
function photo_vote(user_id, user_uid, vote, foto_id)
{
$.ajax({
type: "POST",
url: "/moduls/photo_vote.php",
data: { user_id: user_id, user_uid: user_uid, vote: vote, foto_id: foto_id },
beforeSend: function()
{
$("#photo_vote_status").html('<img src="/images/ajax.gif" alt="" />');
},
success: function(data)
{
$("#photo_vote_status").html(data);
}
});
};
</script>
<?php
}
break;
}
?>
</div>
<div id="block_right">
<?php include (dirname(__FILE__).'/include/chat.php'); ?>
</div>
<div class="clear"></div>
<?php include (dirname(__FILE__).'/include/footer.php'); ?>