as_mimetype = '' ; //DB_DataObject::debugLevel(1); $bits= explode('/', $s); $id = 0; // without id as first part... if (!empty($bits[0]) && $bits[0] == 'Thumb') { $this->thumb = true; $this->as_mimetype = 'image/jpeg'; $this->size = empty($bits[1]) ? '0x0' : $bits[1]; $id = empty($bits[2]) ? 0 : $bits[2]; } else if (!empty($bits[0]) && $bits[0] == 'Download') { $this->method = 'attachment'; $id = empty($bits[1]) ? 0 : $bits[1]; } else if (!empty($bits[1]) && $bits[1] == 'Thumb') { // with id as first part. $this->thumb = true; $this->as_mimetype = 'image/jpeg'; $this->size = empty($bits[2]) ? '0x0' : $bits[2]; $id = empty($bits[3]) ? 0 : $bits[3]; } else { $id = empty($bits[0]) ? 0 : $bits[0]; } $id = (int) $id; $img = DB_DataObjecT::factory('Images'); if (!$id || !$img->get($id)) { header('Location: ' . $this->rootURL . '/Pman/templates/images/file-broken.png?reason=' . urlencode("image with id does not exist, or is invalid")); exit; } //----------- Authentication... $obj = $img->object(); if ($obj->tableName() == 'Projects') { if ($this->currentProject() != $obj->id) { header('Location: ' . $this->rootURL . '/Pman/templates/images/file-broken.png?reason=' . urlencode("image is not the same project (1)")); exit; } } else { if (empty($obj->project_id) || $obj->project_id != $this->currentProject()) { header('Location: ' . $this->rootURL . '/Pman/templates/images/file-broken.png?reason=' . urlencode("image is not the same project (2)")); exit; } } // -- spamming us with resize.. $this->serve($img); exit; } var $thumb = false; var $asmimetype = false; var $method = 'inline'; function serve($img) { require_once 'File/Convert.php'; if (!file_exists($img->getStoreName())) { //print_r($img);exit; header('Location: ' . $this->rootURL . '/Pman/templates/images/file-broken.png?reason=' . urlencode("Original file was missing : " . $img->getStoreName())); } $x = new File_Convert($img->getStoreName(), $img->mimetype); if (empty($this->as_mimetype)) { $this->as_mimetype = $img->mimetype; } if (!$this->thumb) { $x->convert( $this->as_mimetype); $x->serve($this->method); exit; } $this->validateSize(); $x->convert( $this->as_mimetype, $this->size); $x->serve(); exit; } function validateSize() { if (!in_array($this->size, array( '100', '150', /*'100x100', '150', '150x150', '200', '200x0', '200x200', '400x0' */ ))) { header('Location: ' . $this->rootURL . '/Pman/templates/images/file-broken.png?reason=' . urlencode("invalid size")); exit; } } }