Pman.Gnumeric.js
[Pman.Core] / Images.php
index 54984b9..4d2fd14 100644 (file)
@@ -75,6 +75,7 @@ class Pman_Core_Images extends Pman
     var $as_mimetype = false;
     var $method = 'inline';
     var $page = false;
+    var $is_local = false;
     
     function get($s, $opts=array()) // determin what to serve!!!!
     {
@@ -83,6 +84,8 @@ class Pman_Core_Images extends Pman
         //   return $this->post();
         //}
         
+        $this->is_local = (!empty($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] == 'localhost') ? true : false;
+        
         $this->as_mimetype = empty($_REQUEST['as']) ? '' : $_REQUEST['as'];
         
         $this->page = empty($_REQUEST['page']) ? false : (int) $_REQUEST['page'];
@@ -176,16 +179,18 @@ 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);
         }
         
+        if($this->is_local) {
+            return $this->serve($img);
+        }
+        
         if (!$this->authUser && !in_array($img->ontable,$this->public_image_tables)) {
-           
+            
             if ($img->ontable != 'core_company') {
                 $this->imgErr("not-authenticated {$img->ontable}",$s);
             }
@@ -196,15 +201,13 @@ class Pman_Core_Images extends Pman
             if ($comp->comptype != 'OWNER') {
                 $this->imgErr("not-owner-company",$s);
             }
+            
             return $this->serve($img);
-        
             
         }
         
-        
         if(!$this->hasPermission($img)){
             $this->imgErr("access to this image/file has been denied.",$s);
-            
         }
         
         $this->serve($img);
@@ -331,6 +334,10 @@ class Pman_Core_Images extends Pman
     }
     function validateSize()
     {
+        if($this->is_local) {
+            return true;
+        }
+        
         if (($this->authUser && !empty($this->authUser->company_id) && $this->authUser->company()->comptype=='OWNER')
             || $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR']) {
             return true;
@@ -465,7 +472,8 @@ class Pman_Core_Images extends Pman
         $id = $umatch[2];
         $hash = '';
         if (!empty($umatch[3]) && strpos($umatch[3],'#')) {
-            $hash = '#'. array_pop(explode('#',$umatch[3]));
+            $hh = explode('#',$umatch[3]);
+            $hash = '#'. array_pop($hh);
         }