<?
include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compress.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/user.php';
$if_foto=intval($_GET['foto']);
$foto=mysql_fetch_assoc(mysql_query("SELECT * FROM `notes_image` WHERE `id` = '$if_foto' LIMIT 1"));
$notes=mysql_fetch_assoc(mysql_query("SELECT * FROM `notes` WHERE `id` = '$foto[id_notes]' LIMIT 1"));
$ank=get_user($notes['id_user']);
if (isset($_GET['rotate'])){
$filename = H.'sys/notes/'.$notes['id'].'/'.$foto['url'].'.jpg';
if (isset($_GET['left']))
{
$degrees = 90;
$mk='left';
}
if (isset($_GET['right']))
{
$degrees = -90;
$mk='right';
}
header('Content-type: image/jpeg');
$source = imagecreatefromjpeg($filename);
$rotate = imagerotate($source, $degrees, -1);
imagealphablending($rotate, true);
imagesavealpha($rotate, true);
imagejpeg($rotate);
$file = "http://$_SERVER[SERVER_NAME]/plugins/notes/rotate.php?foto=$foto[id]&rotate&$mk"; // обработанный файл для вывода
$newfile = H.'sys/notes/'.$notes['id'].'/'.$foto['url'].'.jpg.tmp'; // задаем новое имя файла
copy($file, $newfile); // копирование
$file = H.'sys/notes/'.$notes['id'].'/'.$foto['url'].'.jpg'; // определяем старый файл
unlink($file); // удаление
$file = H.'sys/notes/'.$notes['id'].'/'.$foto['url'].'.jpg.tmp';// определяем старый файл
$newfile = H.'sys/notes/'.$notes['id'].'/'.$foto['url'].'.jpg';// задаем новое имя файла
rename($file, $newfile); // переименование
@chmod($newfile,0777);
}
?>