Exemple #1
0
 case 'rotate':
     // child = file id
     // child2 = rotate %
     $allowed = array(90, 270);
     if (!in_array($this->child2, $allowed)) {
         dp('HACK: odd rotate %: ' . $this->child2);
         return;
     }
     $session->requireLoggedIn();
     $f = File::get($this->child);
     if ($session->id != $f->uploader) {
         dp('HACK: tried to rotate photo ' . $this->child . ' which is not uploaded by user ' . $session->id);
         return;
     }
     $im = new ImageRotator($f);
     $im->rotate($this->child2);
     $im->render($im->mimetype, File::getUploadPath($f->id));
     File::sync($fileId);
     //updates tblFiles.size
     js_redirect('u/photo/show/' . $f->id);
     break;
 case 'delete':
     $session->requireLoggedIn();
     if ($this->child && confirmed('Are you sure you want to delete this photo?')) {
         // verify that the owner of the album is current session id
         $im = File::get($this->child);
         if ($im->uploader != $session->id) {
             dp('HACK: tried to delete photo ' . $this->child . ' which is not uploaded by user ' . $session->id);
             return;
         }
         File::delete($this->child);
<?php

namespace cd;

set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../core/');
require_once 'core.php';
require_once 'ImageRotator.php';
$file = '/home/ml/Skrivbord/DSC_1853.JPG';
$x = new ImageRotator($file);
$x->rotate(90);
$x->render('jpg', 'rotated90.jpg');
$x->rotate(90);
$x->render('jpg', 'rotated180.jpg');
$x->rotate(90);
$x->render('jpg', 'rotated270.jpg');