$bits= explode('/', $s);
$id = 0;
-
+// var_dump($bits);die('in');
// without id as first part...
if (!empty($bits[0]) && $bits[0] == 'Thumb') {
$this->thumb = true;
$id = empty($bits[3]) ? 0 : $bits[3];
} else if (!empty($bits[0]) && $bits[0] == 'events') {
+
$popts = PEAR::getStaticProperty('Pman','options');
+ $ev = DB_DAtaObject::Factory('events');
+ if (!$ev->get($bits[1])) {
+ die("could not find event id");
+ }
+ // technically same user only.. -- normally www-data..
+ if (function_exists('posix_getpwuid')) {
+ $uinfo = posix_getpwuid( posix_getuid () );
+ $user = $uinfo['name'];
+ } else {
+ $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";
+ $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)) {
+ die("file was not saved");
+ }
+ header ('Content-Type: ' . $f->type);
- header ('Content-Type: image/jpeg');
- if(!empty($bits[2]) && $bits[2] == 'download'){
- $file = "{$popts['event_log_dir']}/{$bits[1]}";
- header("Content-Disposition: attachment; filename=\"".basename($file)."\";" );
- ob_clean();
+ header("Content-Disposition: attachment; filename=\"".basename($f->name)."\";" );
+ @ob_clean();
flush();
- readfile($file);
- }else{
- $file = "{$popts['event_log_dir']}/{$bits[1]}.jpg";
- $fh = fopen($file,'r');
- echo fread($fh,filesize($file));
+ readfile($src);
+ exit;
}
- exit;
+ die ("unknown file?");
} else {
$id = empty($bits[0]) ? 0 : $bits[0];
$img = DB_DataObjecT::factory('Images');
+
if (!$id || !$img->get($id)) {
header('Location: ' . $this->rootURL . '/Pman/templates/images/file-broken.png?reason=' .
urlencode("image has been removed or deleted."));
+
}
$this->serve($img);
exit;
function serve($img)
{
+ $this->sessionState(0); // turn off session... - locking...
+
require_once 'File/Convert.php';
if (!file_exists($img->getStoreName())) {
- //print_r($img);exit;
+// print_r($img);exit;
header('Location: ' . $this->rootURL . '/Pman/templates/images/file-broken.png?reason=' .
urlencode("Original file was missing : " . $img->getStoreName()));
}
-
+// print_r($img);exit;
$x = $img->toFileConvert();
if (empty($this->as_mimetype)) {
$this->as_mimetype = $img->mimetype;
if (!file_exists($fn)) {
$fn = $img->getStoreName() . '.'. $this->size . '.'. $img->fileExt();
- // if it's an image, convert into the same type for thumnail..
+ // if it's an image, convert into the same type for thumbnail..
if (preg_match('#^image/#', $img->mimetype)) {
$this->as_mimetype = $img->mimetype;
}
function validateSize()
{
+ if ($this->authUser && $this->authUser->company_id && $this->authUser->company()->comptype=='OWNER') {
+ return true;
+ }
+
// DEFAULT allowed - override with $cfg['sizes'];
$sizes = array(