43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
include_once '../connect/cms-config.php' ;
|
|
include_once '../requires/function.php' ;
|
|
|
|
$folder = escapeString($_GET['folder']) ; // name
|
|
$file = base64_decode(escapeString($_GET['file'])) ; // password
|
|
$user = escapeString($_GET['user']) ; // user
|
|
|
|
// check login
|
|
$result = 'failed' ;
|
|
|
|
if ($_SESSION['system_id'] != '' && $_SESSION['system_name'] != '' && $user == $_SESSION['system_id']){
|
|
|
|
if ($folder != '' && $file != ''){
|
|
|
|
$degrees = -90 ; //change this to be whatever degree of rotation you want
|
|
header('Content-type: image/jpeg') ;
|
|
|
|
$array_folder = array('small' => '', 'medium' => 'm/', 'big' => 'b/') ;
|
|
|
|
foreach($array_folder as $key => $value){
|
|
|
|
$temp_file = 'uploads/'.$folder.'/'.$value.$file ;
|
|
$filename = $_SERVER['DOCUMENT_ROOT'].'/'.$temp_file ; //this is the original file
|
|
$source = imagecreatefromjpeg($filename) or notfound() ;
|
|
$rotate = imagerotate($source, $degrees, 0) ;
|
|
|
|
imagejpeg($rotate,$filename) ; //save the new image
|
|
imagedestroy($source) ; //free up the memory
|
|
imagedestroy($rotate) ; //free up the memory
|
|
|
|
$array[$key] = PATH.$temp_file.'?timestamp='.time() ;
|
|
$result = 'success' ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$array['result'] = $result ;
|
|
echo json_encode($array) ;
|
|
?>
|