<?
echo'<div class="app-block">';
if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `blog_files` WHERE `id_user` = '".$user['id']."' AND `time` = '0'") >= 5)
{
?>
<div class="list _gray _font-s _center">Вы прикрепили максимальное количество файлов!</div>
<?
} else {
if (isset($_GET['album']) && DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `photos_album` WHERE `id` = '".intval($_GET['album'])."'") > 0)
{
if (isset($_GET['photo']) && DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `photos` WHERE `id` = '".intval($_GET['photo'])."' AND `id_user` = '".$user['id']."' AND `id_album` = '".intval($_GET['album'])."'") > 0)
{
if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `blog_files` WHERE `id_user` = '".$user['id']."' AND `time` = '0'") >= 5)
{
?>
<div class="list _gray _font-s _center">Вы прикрепили максимальное количество фотографий!</div>
<?
} else {
$r = DB :: $pdo -> queryFetch("SELECT * FROM `photos` WHERE `id` = ? LIMIT 1;", array(intval($_GET['photo'])));
DB :: $pdo -> query("INSERT INTO `blog_files` (`id_user`) VALUES (?);", array($user['id']));
$last_id = DB :: $pdo -> lastInsertId();
if ((preg_match('#\.jpe?g$#i',"".FILES_SERVER.system :: photosGetView($r['hash'])."") && $imgc=@imagecreatefromjpeg("".FILES_SERVER.system :: photosGetView($r['hash'])."")) || (preg_match('#\.gif$#i',"".FILES_SERVER.system :: photosGetView($r['hash'])."") && $imgc=@imagecreatefromgif("".FILES_SERVER.system :: photosGetView($r['hash'])."")) || (preg_match('#\.png$#i',"".FILES_SERVER.system :: photosGetView($r['hash'])."") && $imgc=@imagecreatefrompng("".FILES_SERVER.system :: photosGetView($r['hash'])."")))
{
$screen = imagecreatetruecolor(150, 150);
imagecopyresampled($screen, $imgc, 0, 0, 0, 0, 150, 150, imagesx($imgc), imagesy($imgc));
imagejpeg($screen,"".FILES_PATH."/blog_files/".$last_id."_m.jpg",100);
chmod("".FILES_PATH."/blog_files/".$last_id."_m.jpg",0777);
}
copy("".FILES_SERVER.system :: photosGetView($r['hash'])."", "".FILES_PATH."/blog_files/".$last_id.".jpg");
chmod("".FILES_PATH."/blog_files/".$last_id.".jpg", 0777);
header("Location: /blog/?id=".$ank['id']."");
exit;
}
} else {
$total = DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `photos` WHERE `id_user` = '".$user['id']."' AND `id_album` = '".intval($_GET['album'])."'");
if ($total == 0)
{
?>
<div class="list _gray _font-s _center">Фотографии не найдены!</div>
<?
} else {
if ($total > 10)
{
$p = (($_GET['p']) ? intval($_GET['p']) : 1);
$pagination = new pagination(10, $total, $p);
$total_lin = $pagination -> limit;
} else {
$total_lin = '';
}
?>
<div class="_photos-main list">
<?
$query = DB :: $pdo -> query("SELECT * FROM `photos` WHERE `id_user` = '".$user['id']."' AND `id_album` = '".intval($_GET['album'])."' ORDER BY `id` DESC ".$total_lin."");
while($r = $query -> fetch())
{
?>
<a href="/blog/?id=<?echo $ank['id'];?>&add_photos&album=<?echo intval($_GET['album']);?>&photo=<?echo $r['id'];?>" class="_photos-item">
<div class="_photos-item-padd">
<div class="_photos-cont">
<div class="_photos-ph">
<div class="_photos-ph-t"><img src="<?=FILES_SERVER.system :: photosGetView($r['hash'],3)?>" class="_photos-prew">
</div>
</div>
</div>
</div>
</a>
<?
}
?>
</div>
<?
if ($total > 10)
{
echo $pagination -> printPages("/blog/?id=".$ank['id']."&add_photos&album=".intval($_GET['album'])."");
}
}
}
echo system :: touch("/blog/?id=".$ank['id']."&add_photos", system :: icon("arr-l")."К альбомам");
} else {
$total = DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `photos_album` WHERE `id_user` = '".$user['id']."'");
if ($total == 0)
{
?>
<div class="list _gray _font-s _center">Альбомы не найдены!</div>
<?
} else {
if ($total > 10)
{
$p = (($_GET['p']) ? intval($_GET['p']) : 1);
$pagination = new pagination(10, $total, $p);
$total_lin = $pagination -> limit;
} else {
$total_lin = '';
}
?>
<div class="_photos-main list">
<?
$query = DB :: $pdo -> query("SELECT * FROM `photos_album` WHERE `id_user` = '".$user['id']."' ORDER BY `id` DESC ".$total_lin."");
while($r = $query -> fetch())
{
$photos = DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `photos` WHERE `id_user` = '".$user['id']."' AND `id_album` = '".$r['id']."'");
?>
<a href="/blog/?id=<?echo $ank['id'];?>&add_photos&album=<?echo $r['id'];?>" class="_photos-item">
<div class="_photos-item-padd">
<div class="_photos-cont">
<div class="_photos-ph">
<div class="_photos-ph-t"><img src="<?=FILES_SERVER.system :: photosGetCover($r['id']); ?>" class="_photos-prew">
</div>
<div>
<div class="_font-s _photos-title"> <?echo stripcslashes(htmlspecialchars($r['name']));?></div>
<div class="_font-m"><?echo $photos;?> фотографий</div>
</div>
</div>
</div>
</div>
</a>
<?
}
?>
</div>
<?
if ($total > 10)
{
echo $pagination -> printPages("/blog/?id=".$ank['id']."&add_photos&");
}
}
}
}
echo system :: touch("/blog/?id=".$ank['id']."", system :: icon("arr-l")."Назад");
require (CORE."foot.php");
?>