Changeset 2420

Show
Ignore:
Timestamp:
04/04/08 14:39:18 (3 months ago)
Author:
Geert
Message:

Cache->set() expects time to live in seconds, not a unix timestamp.
Also cleaning up url::redirect().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/modules/pdomo/models/pdo.php

    r2419 r2420  
    515515 
    516516                        // Set the cache 
    517                         Cache::instance()->set($key, $result, array('database', 'result'), strtotime('now +1 hour')); 
     517                        Cache::instance()->set($key, $result, array('database', 'result'), 3600); 
    518518                } 
    519519 
  • trunk/system/helpers/url.php

    r2400 r2420  
    142142        public static function redirect($uri = '', $method = '302') 
    143143        { 
    144                 if (!Event::has_run('system.send_headers')) 
    145                 { 
    146                         if(!is_array($uri)) 
    147                         { 
    148                                 $uri = array($uri); 
    149                         } 
    150                          
    151                         for($i=0; $i<count($uri); $i++) 
    152                         { 
    153                                 if (strpos($uri[$i], '://') === FALSE) 
     144                if (Event::has_run('system.send_headers')) 
     145                        return; 
     146 
     147                $uri = (array) $uri; 
     148 
     149                for ($i = 0, $count_uri = count($uri); $i < $count_uri; $i++) 
     150                { 
     151                        if (strpos($uri[$i], '://') === FALSE) 
     152                        { 
     153                                $uri[$i] = url::site($uri[$i]); 
     154                        } 
     155                } 
     156 
     157                if ($method == '300') 
     158                { 
     159                        if ($count_uri > 0) 
     160                        { 
     161                                header('HTTP/1.1 300 Multiple Choices'); 
     162                                header('Location: '.$uri[0]); 
     163 
     164                                $choices = ''; 
     165                                foreach($uri as $href) 
    154166                                { 
    155                                         $uri[$i] = url::site($uri[$i])
     167                                        $choices .= '<li><a href="'.$href.'">'.$href.'</a></li>'
    156168                                } 
    157                         } 
    158  
    159                         if ($method == '300') 
    160                         { 
    161                                 if(count($uri) > 0) 
    162                                 { 
    163                                         header('HTTP/1.1 300 Multiple Choices'); 
    164                                         header('Location: '.$uri[0]); 
    165  
    166                                         $choices = ''; 
    167                                         foreach($uri as $href) 
    168                                         { 
    169                                                 $choices .= '<li><a href="'.$href.'">'.$href.'</a></li>'; 
    170                                         } 
    171                                          
    172                                         exit('<h1>301 - Multiple Choices:</h1><ul>'.$choices.'</ul>'); 
    173                                 } 
     169                                 
     170                                exit('<h1>301 - Multiple Choices:</h1><ul>'.$choices.'</ul>'); 
     171                        } 
     172                } 
     173                else 
     174                { 
     175                        $uri = $uri[0]; 
     176 
     177                        if ($method == 'refresh') 
     178                        { 
     179                                header('Refresh: 0; url='.$uri); 
    174180                        } 
    175181                        else 
    176182                        { 
    177                                 $uri = $uri[0]; 
    178  
    179                                 if ($method == 'refresh') 
    180                                 { 
    181                                         header('Refresh: 0; url='.$uri); 
    182                                 } 
    183                                 else 
    184                                 { 
    185                                         $codes = array 
    186                                         ( 
    187                                                 '301' => 'Moved Permanently', 
    188                                                 '302' => 'Found', 
    189                                                 '303' => 'See Other', 
    190                                                 '304' => 'Not Modified', 
    191                                                 '305' => 'Use Proxy', 
    192                                                 '307' => 'Temporary Redirect' 
    193                                         ); 
    194  
    195                                         $method = isset($codes[$method]) ? $method : '302'; 
    196  
    197                                         header('HTTP/1.1 '.$method.' '.$codes[$method]); 
    198                                         header('Location: '.$uri); 
    199                                 } 
    200  
    201                                 exit('<h1>'.$method.' - '.$codes[$method].'</h1><p><a href="'.$uri.'">'.$uri.'</a></p>'); 
    202                         } 
    203                 } 
     183                                $codes = array 
     184                                ( 
     185                                        '301' => 'Moved Permanently', 
     186                                        '302' => 'Found', 
     187                                        '303' => 'See Other', 
     188                                        '304' => 'Not Modified', 
     189                                        '305' => 'Use Proxy', 
     190                                        '307' => 'Temporary Redirect' 
     191                                ); 
     192 
     193                                $method = isset($codes[$method]) ? $method : '302'; 
     194 
     195                                header('HTTP/1.1 '.$method.' '.$codes[$method]); 
     196                                header('Location: '.$uri); 
     197                        } 
     198 
     199                        exit('<h1>'.$method.' - '.$codes[$method].'</h1><p><a href="'.$uri.'">'.$uri.'</a></p>'); 
     200                } 
     201 
    204202                return; 
    205203        } 
  • trunk/system/libraries/Validation.php

    r2382 r2420  
    288288                { 
    289289                        // Multiple callback 
    290                         $callbacks = func_get_args(); 
    291                         $callbacks = array_slice($callbacks, 1); 
     290                        $callbacks = array_slice(func_get_args(), 1); 
    292291                } 
    293292                else