X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Images.php;h=54984b97edb54da70753c1d383f62d6f23fe5728;hb=b341a92085a9d4a5cfb1d2043e599420472aa6c8;hp=1e4a5bce29cddf66f71b436d7bbb20cad020347f;hpb=8e2e08d196dacb4aefc117c625c219ca06b30bc5;p=Pman.Core diff --git a/Images.php b/Images.php index 1e4a5bce..54984b97 100644 --- a/Images.php +++ b/Images.php @@ -2,6 +2,9 @@ /** * Deal with image delivery and HTML replacement of image links in body text. * + * + * NOTE THIS WAS NEVER INTENDED FOR PUBLIC IMAGE DISTRIBUTION - we need to create a seperate file for that... + * * $str = Pman_Core_Images::replaceImg($str); // < use with HTML * * or @@ -41,7 +44,18 @@ class Pman_Core_Images extends Pman // tables that do not need authentication checks before serving. var $public_image_tables = array(); - + var $sizes = array( + '100', + '100x100', + '150', + '150x150', + '200', + '200x0', + '200x200', + '400x0', + '300x100', + '500' + ); function getAuth() { parent::getAuth(); // load company! @@ -105,7 +119,7 @@ class Pman_Core_Images extends Pman $id = empty($bits[0]) ? 0 : $bits[0]; } - print_R($this);exit; + if (strpos($id,':') > 0) { // id format tablename:id:-imgtype if (!$this->authUser) { @@ -167,7 +181,7 @@ class Pman_Core_Images extends Pman $img = DB_DataObjecT::factory('Images'); if (!$id || !$img->get($id)) { - $this->imgErr("image has been removed or deleted.",$s); + $this->imgErr("image has been removed or deleted.",$s); } if (!$this->authUser && !in_array($img->ontable,$this->public_image_tables)) { @@ -271,7 +285,6 @@ class Pman_Core_Images extends Pman } // print_r($img);exit; $x = $img->toFileConvert(); - print_R($img);exit; if (empty($this->as_mimetype) || $img->mimetype == 'image/gif') { $this->as_mimetype = $img->mimetype; } @@ -326,18 +339,7 @@ class Pman_Core_Images extends Pman $ff = HTML_FlexyFramework::get(); - $sizes = array( - '100', - '100x100', - '150', - '150x150', - '200', - '200x0', - '200x200', - '400x0', - '300x100', - '500' - ); + $sizes= $this->sizes; $cfg = isset($ff->Pman_Images) ? $ff->Pman_Images : (isset($ff->Pman_Core_Images) ? $ff->Pman_Core_Images : array()); @@ -523,7 +525,6 @@ class Pman_Core_Images extends Pman function downloadEvent($bits) { - $popts = PEAR::getStaticProperty('Pman','options'); $ev = DB_DAtaObject::Factory('events'); if (!$ev->get($bits[1])) { die("could not find event id"); @@ -536,18 +537,23 @@ class Pman_Core_Images extends Pman $user = getenv('USERNAME'); // windows. } $ff = HTML_FlexyFramework::get(); - $file = $ff->Pman['event_log_dir']. '/'. $user. date('/Y/m/d/',strtotime($ev->event_when)). $ev->id . ".json"; + + $file = $ev->logDir() . date('/Y/m/d/',strtotime($ev->event_when)). $ev->id . ".json"; + + if(!$file || !file_exists($file)){ + die("file was not saved"); + } + $filesJ = json_decode(file_get_contents($file)); - //print_r($filesJ); - foreach($filesJ->FILES as $k=>$f){ if ($f->tmp_name != $bits[2]) { continue; } - $src = $ff->Pman['event_log_dir']. '/'. $user. date('/Y/m/d/', strtotime($ev->event_when)). $f->tmp_name ; - if (!file_exists($src)) { + $src = $file = $ev->logDir() . date('/Y/m/d/', strtotime($ev->event_when)). $f->tmp_name ; + + if (!$src || !file_exists($src)) { die("file was not saved"); } header ('Content-Type: ' . $f->type);