Файл: modules/albums/photo.php
Строк: 95
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
if($db->query("SELECT * FROM `albums_photo` WHERE `id` = '".abs(intval($_GET['id']))."'")->rowCount() == 0 or !isset($_GET['id']))
{
redirect('/albums');
}
$locate = 'in_photo_albums';
$photo = $db->query("SELECT * FROM `albums_photo` WHERE `id` = '".abs(intval($_GET['id']))."'")->fetch();
$title = _t('photo_albums');
$id = num($_GET['id']);
if(isset($_GET['act']) && $_GET['act'] == 'set_avatar' && $photo['user_id'] == User::Id())
{
import_lib('jimage.class');
if(file_exists(ROOT.'/files/avatars/'.$user['id'].'.jpg'))
{
unlink(ROOT.'/files/avatars/'. $user['id'] .'.jpg');
@unlink(ROOT.'/files/avatars/'. $user['id'] .'_mini.jpg');
}
$avatar = new jimage();
$avatar->thumb(ROOT.'/files/albums/'.$photo['server_name'].'.'.$photo['ext'], ROOT.'/files/avatars/'.User::Id().'.jpg', 100, 120);
$avatar->thumb(ROOT.'/files/albums/'.$photo['server_name'].'.'.$photo['ext'], ROOT.'/files/avatars/'.User::Id().'_mini.jpg', 36, 36);
$avatar = _t('set_photo_avatar_yes');
}
$album = $db->query("SELECT * FROM `albums` WHERE `id` = '".$photo['album_id']."'")->fetch();
if(isset($_GET['send']) && $album['type'] == 3)
{
$pass = input($_POST['pass']);
if ($pass == $album['password'])
{
$_SESSION['alb_'.$album['id']] = $pass;
redirect('/albums/photo/'.abs(intval($_GET['id'])));
}
else
{
$err = _t('album_no_pass');
}
}
if(isset($_GET['_like_']))
{
$like = new Like('albums_photo', $id);
$like->change();
if($photo['user_id'] != User::Id() && $_GET['_like_'] == 'like')
{
$db->query("INSERT INTO `notify` SET `user_id` = '". $note['user_id'] ."', `from_id` = '". User::Id() ."', `request_id` = '/albums/photo/".$id."', `type` = 'liked your photo', `read` = '0', `time` = '". time() ."'");
}
else
{
$db->query("DELETE FROM `notify` SET `user_id` = '". $note['user_id'] ."' AND `from_id` = '". User::Id() ."' AND `request_id` = '/albums/photo/".$id."' AND `type` = 'liked your photo'");
}
redirect('/albums/photo/'.$id);
}
include_header($title);
Template::div('title', $title);
if (isset($err)) echo '<div class="error">'. $err .'</div>';
if (User::level() >= 6 or $album['user_id'] == User::Id() or $album['type'] == 0 or $album['type'] == 2 && $db->query("SELECT * FROM `friends` WHERE (`friend_id` = '". User::Id() ."' AND `user_id` = '". $album['user_id'] ."' OR `friend_id` = '". $album['user_id'] ."' AND `user_id` = '". User::Id() ."') AND `active` = '1'")->rowCount() > 0 or $album['type'] == 3 && $_SESSION['alb_'.$album['id']] == $album['password']) {
if (!empty($avatar)) Template::div('menu', _t('set_photo_avatar_yes'));
echo '<div class="post">
<img src="/cache/albums/thumbs/'.$photo['server_name'].'.jpg" alt="" /><br />
'.(!empty($photo['description']) ? $photo['description'].'<br />' : null).'
<hr>
<b>'._t('author').'</b>: '.nick($photo['user_id'], '', true).'<br />
<b>'._t('album').'</b>: <a href="/albums/album/'.$album['id'].'">'.$album['name'].'</a><br />
('.rtime($photo['time']).')<br/>';
$like = new Like('albums_photo', $id);
echo $like->show().'
<hr/>
'.img('info.png').' <b>'._t('dl_file_downloaded').'</b>: '.$photo['dl_times'].'<br/>';
$dl_image_info = getimagesize(ROOT.'/files/albums/'.$photo['server_name'].'.'.$photo['ext']);
$type = $dl_image_info['mime'];
$width = $dl_image_info[0];
$height = $dl_image_info[1];
echo''.img('downloads.png').' <a href="/albums/get_file/'.$photo['id'].'">'. _t('download_photo').'</a> ('.$width.'x'.$height.') <br/>
'.($photo['user_id'] == User::Id() ? img('avatar.png') .'<a href="?act=set_avatar">'. _t('set_photo_avatar') .'</a><br/>' : NULL).'
'.img('chat.png').'<a href="/albums/comments/'.$photo['id'].'">'._t('comments').'</a> ['.$db->query("SELECT * FROM `albums_comms` WHERE `albums_id` = '".$photo['id']."'")->rowCount().']
'.($photo['user_id'] == User::Id() || User::level() == 2 || User::level() >=6 ? '<div class="menu">'.
img('edit.png') .' <a href="/albums/edit_photo/'.$photo['id'].'">'. _t('dl_edit_file') .'</a><br/>'.
img('delete.png') .' <a href="/albums/delete_photo/'.$photo['id'].'">'. _t('dl_delete_file') .'</a><br/></div>' : NULL).'
</div>';
}
else
{
if ($album['type'] == 1) Template::div('menu', _t('album_stop1'));
if ($album['type'] == 2) Template::div('menu', _t('album_stop2'));
if ($album['type'] == 3)
{
echo '<div class="menu">
<form action="/albums/photo/'.abs(intval($_GET['id'])).'/?send" method="post">
'._t('album_stop3').':<br />
<input type="text" name="pass" maxlength="15" /><br/>
<input type="submit" name="send" value="'. _t('send') .'" />
</form></div>';
}
}
echo '<div class="block">
'. NAV.' <a href="/albums/album/'.$album['id'].'">'. _t('back').'</a><br/>
'. NAV.' <a href="/albums">'. _t('photo_albums').'</a><br/>'
.HICO.' <a href="/">'._t('home').'</a>
</div>';
include_footer();