3 * view permission should be required on the underlying object...
8 * args: ontable request
9 * ontable (req) tablename.
12 * as (serve as a type) = eg. mimetype.
15 * as :(serve as a type) = eg. mimetype.
17 * Images/{ID}/fullname.xxxx
19 * (valid thumbs 200, 400)...?
20 * Images/Thumb/200/{ID}/fullname.xxxx
21 * Images/Download/{ID}/fullname.xxxx
24 require_once 'Pman.php';
25 class Pman_Images extends Pman
29 parent::getAuth(); // load company!
31 $au = $this->getAuthUser();
33 // die("Access denied");
35 $this->authUser = $au;
40 function get($s) // determin what to serve!!!!
42 $this->as_mimetype = empty($_REQUEST['as']) ? '' : $_REQUEST['as'];
44 $bits= explode('/', $s);
46 // without id as first part...
47 if (!empty($bits[0]) && $bits[0] == 'Thumb') {
49 $this->as_mimetype = 'image/jpeg';
50 $this->size = empty($bits[1]) ? '0x0' : $bits[1];
51 $id = empty($bits[2]) ? 0 : $bits[2];
53 } else if (!empty($bits[0]) && $bits[0] == 'Download') {
54 $this->method = 'attachment';
55 $id = empty($bits[1]) ? 0 : $bits[1];
57 } else if (!empty($bits[1]) && $bits[1] == 'Thumb') { // with id as first part.
59 $this->as_mimetype = 'image/jpeg';
60 $this->size = empty($bits[2]) ? '0x0' : $bits[2];
61 $id = empty($bits[3]) ? 0 : $bits[3];
64 $id = empty($bits[0]) ? 0 : $bits[0];
67 if (strpos($id,':') > 0) { // id format tablename:id:-imgtype
68 $onbits = explode(':', $id);
69 if ((count($onbits) < 2) || empty($onbits[1]) || !is_numeric($onbits[1]) || !strlen($onbits[0])) {
72 $img = DB_DataObjecT::factory('Images');
73 $img->ontable = $onbits[0];
74 $img->onid = $onbits[1];
75 if (isset($onbits[2])) {
76 $img->imgtype = $onbits[2];
79 if (!$img->find(true)) {
89 // depreciated - should use ontable:onid:type here...
90 if (!empty($_REQUEST['ontable'])) {
92 //DB_DataObjecT::debugLevel(1);
93 $img = DB_DataObjecT::factory('Images');
94 $img->setFrom($_REQUEST);
96 // if (!empty($_REQUEST['query']['filename'])){
97 // $img->whereAdd("filename LIKE '". $img->escape($_REQUEST['query']['filename']).".%'");
102 if (!$img->find(true)) {
103 die("No file exists");
111 $img = DB_DataObjecT::factory('Images');
112 if (!$id || !$img->get($id)) {
113 die("image has been removed or deleted.");
119 var $asmimetype = false;
120 var $method = 'inline';
123 require_once 'File/Convert.php';
124 $x = new File_Convert($img->getStoreName(), $img->mimetype);
125 if (empty($this->as_mimetype)) {
126 $this->as_mimetype = $img->mimetype;
129 $x->convert( $this->as_mimetype);
130 $x->serve($this->method);
134 $this->validateSize();
135 $x->convert( $this->as_mimetype, $this->size);
143 function validateSize()
145 if (!in_array($this->size, array(
154 die("invalid scale");