Fixes and improvements
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 10 Apr 2007 08:29:17 +0000 (08:29 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 10 Apr 2007 08:29:17 +0000 (08:29 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1676 839d8a87-29fc-0310-9880-83ba4fa771e5

classes/plbacktrace.php
classes/plupload.php
classes/session.php

index 89703aa..2f18f7a 100644 (file)
@@ -37,10 +37,15 @@ class PlBacktrace
         }
     }
 
+    private function fixCharset($action)
+    {
+        return is_utf8($action) ? $action : utf8_encode($action);
+    }
+
     private function add(array &$entry, $sizef = 'rows', $timef = 'exectime', $errorf = 'error')
     {
         $trace = array();
-        $trace['action'] = $entry['action'];
+        $trace['action'] = $this->fixCharset($entry['action']);
         unset($entry['action']);
         $trace['exectime'] = @$entry[$timef];
         $this->totaltime += $trace['exectime'];
@@ -58,14 +63,14 @@ class PlBacktrace
 
     public function newEvent($action, $rows = 0, $error = null, array $userdata = array())
     {
-        $trace = array('action' => $action, 'time' => 0);
+        $trace = array('action' => $this->fixCharset($action), 'time' => 0);
         $this->traces[] =& $trace;
         $this->update($rows, $error, $userdata);
     }
 
     public function start($action)
     {
-        $this->traces[] =  array('action' => $action, 'starttime' => microtime(true));;
+        $this->traces[] =  array('action' => $this->fixCharset($action), 'starttime' => microtime(true));;
     }
 
     public function stop($rows = 0, $error = null, array $userdata = array())
index ea84ca1..ce143a6 100644 (file)
@@ -199,7 +199,14 @@ class PlUpload
     {
         static $map;
         if (!isset($map)) {
-            $map = array (1 => 'gif', 2 => 'jpeg', 3 => 'png');
+            $tmpmap = array (IMG_GIF => 'gif', IMG_JPG => 'jpeg', IMG_PNG => 'png', IMG_WBMP => 'bmp', IMG_XPM => 'xpm');
+            $map = array();
+            $supported = imagetypes();
+            foreach ($tmpmap as $type=>$mime) {
+                if ($supported & $type) {
+                    $map[$type] = $mime;
+                }
+            }
         }
         $array = getimagesize($this->filename);
         $array[2] = @$map[$array[2]];
index c52e239..28a02d2 100644 (file)
@@ -27,7 +27,7 @@ class Session
         if (empty($_SESSION['challenge'])) {
             $_SESSION['challenge'] = sha1(uniqid(rand(), true));
         }
-        if (!isset($_SESSION['perms'])) {
+        if (!isset($_SESSION['perms']) || !($_SESSION['perms'] instanceof FlagSet)) {
             $_SESSION['perms'] = new FlagSet();
         }
     }