Changeset 610

Show
Ignore:
Timestamp:
09/28/2007 07:39:20 PM (14 months ago)
Author:
Demio
Message:

Ported User-agent library. Fixed permissions in FTP library.

Location:
trunk
Files:
2 modified
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/application/controllers/welcome.php

    r605 r610  
    55        function index() 
    66        { 
    7                 print_r(date::hours(1, TRUE)); die; 
    8                  
     7                //print_r(date::hours(1, TRUE)); die 
    98                 
    109                foreach(get_class_methods(__CLASS__) as $method) 
    1110                { 
    1211                        if ( ! preg_match('/_example$/', $method)) continue; 
    13  
    14                         echo html::anchor('welcome/'.$method, $method)."<br/>\n"; 
     12                                echo html::anchor('welcome/'.$method, $method)."<br/>\n"; 
    1513                } 
    1614        } 
     
    105103                echo "done in {execution_time} seconds"; 
    106104        } 
     105        function user_agent_example() { 
     106                $this->load->library('user_agent'); 
     107                echo $this->user_agent;          
     108        } 
    107109 
    108110} 
  • trunk/system/libraries/Ftp.php

    r606 r610  
    3434class FTP_Core { 
    3535 
    36         protected $hostname     = ''; 
    37         protected $username     = ''; 
    38         protected $password     = ''; 
    39         protected $port         = 21; 
    40         protected $passive      = TRUE; 
    41         protected $debug                = FALSE; 
    42         protected $conn_id      = FALSE; 
     36        private $hostname       = ''; 
     37        private $username       = ''; 
     38        private $password       = ''; 
     39        private $port           = 21; 
     40        private $passive        = TRUE; 
     41        private $debug          = FALSE; 
     42        private $conn_id        = FALSE; 
    4343 
    4444        /** 
     
    128128         * FTP Login 
    129129         * 
    130          * @access      protected 
    131          * @return      bool 
    132          */ 
    133         protected function login() 
     130         * @access      private 
     131         * @return      bool 
     132         */ 
     133        private function login() 
    134134        { 
    135135                return @ftp_login($this->conn_id, $this->username, $this->password); 
     
    141141         * Validates the connection ID 
    142142         * 
    143          * @access      protected 
    144          * @return      bool 
    145          */ 
    146         protected function is_conn() 
     143         * @access      private 
     144         * @return      bool 
     145         */ 
     146        private function is_conn() 
    147147        { 
    148148                if ( ! is_resource($this->conn_id)) 
     
    540540         * Extract the file extension 
    541541         * 
    542          * @access      protected 
     542         * @access      private 
    543543         * @param       string 
    544544         * @return      string 
    545545         */ 
    546         protected function get_extension($filename) 
     546        private function get_extension($filename) 
    547547        { 
    548548                if (strpos($filename, '.') === FALSE) 
     
    561561         * Set the upload type 
    562562         * 
    563          * @access      protected 
     563         * @access      private 
    564564         * @param       string 
    565565         * @return      string 
    566566         */ 
    567         protected function set_type($ext) 
     567        private function set_type($ext) 
    568568        { 
    569569                $text_types = array( 
     
    613613         * Display error message 
    614614         * 
    615          * @access      protected 
    616          * @param       string 
    617          * @return      bool 
    618          */ 
    619         protected function error($msg) 
     615         * @access      private 
     616         * @param       string 
     617         * @return      bool 
     618         */ 
     619        private function error($msg) 
    620620        { 
    621621                throw new Kohana_Exception('ftp.'.$msg); 
     
    623623 
    624624 
    625 } 
    626 // END FTP Class 
    627 ?> 
     625} // End FTP Class 
  • trunk/system/libraries/User_agent.php

    r607 r610  
    3131 * @subpackage  Libraries 
    3232 * @category    User Agent 
    33  * @author              Rick Ellis 
     33 * @author              Rick Ellis, Kohana Team 
    3434 * @link                http://kohanaphp.com/user_guide/libraries/user_agent.html 
    3535 */ 
    3636class User_Agent_Core { 
    3737 
    38         var $agent              = NULL; 
    39  
    40         var $is_browser = FALSE; 
    41         var $is_robot   = FALSE; 
    42         var $is_mobile  = FALSE; 
    43  
    44         var $languages  = array(); 
    45         var $charsets   = array(); 
    46  
    47         var $platforms  = array(); 
    48         var $browsers   = array(); 
    49         var $mobiles    = array(); 
    50         var $robots             = array(); 
    51  
    52         var $platform   = ''; 
    53         var $browser    = ''; 
    54         var $version    = ''; 
    55         var $mobile             = ''; 
    56         var $robot              = ''; 
     38        private $agent          = NULL; 
     39 
     40        private $is_browser     = FALSE; 
     41        private $is_robot       = FALSE; 
     42        private $is_mobile      = FALSE; 
     43 
     44        private $languages      = array(); 
     45        private $charsets       = array(); 
     46 
     47        private $platforms      = array(); 
     48        private $browsers       = array(); 
     49        private $mobiles        = array(); 
     50        private $robots         = array(); 
     51 
     52        private $platform       = ''; 
     53        private $browser        = ''; 
     54        private $version        = ''; 
     55        private $mobile         = ''; 
     56        private $robot          = ''; 
     57 
    5758 
    5859        /** 
     
    7374                if ( ! is_null($this->agent)) 
    7475                { 
    75                         if ($this->_load_agent_file()) 
     76                        if ($this->load_agent_file()) 
    7677                        { 
    77                                 $this->_compile_data(); 
     78                                $this->compile_data(); 
    7879                        } 
    7980                } 
     
    9091         * @return      bool 
    9192         */ 
    92         private function _load_agent_file() 
     93        private function load_agent_file() 
    9394        { 
    9495                $config = Config::item('user_agents'); 
     
    139140         * @return      bool 
    140141         */ 
    141         private function _compile_data() 
    142         { 
    143                 $this->_set_platform(); 
    144  
    145                 foreach (array('_set_browser', '_set_robot', '_set_mobile') as $function) 
     142        private function compile_data() 
     143        { 
     144                $this->set_platform(); 
     145 
     146                foreach (array('set_browser', 'set_robot', 'set_mobile') as $function) 
    146147                { 
    147148                        if ($this->$function() === TRUE) 
     
    160161         * @return      mixed 
    161162         */ 
    162         private function _set_platform() 
     163        private function set_platform() 
    163164        { 
    164165                if (is_array($this->platforms) AND count($this->platforms) > 0) 
     
    184185         * @return      bool 
    185186         */ 
    186         private function _set_browser() 
     187        private function set_browser() 
    187188        { 
    188189                if (is_array($this->browsers) AND count($this->browsers) > 0) 
     
    195196                                        $this->version = $match[1]; 
    196197                                        $this->browser = $val; 
    197                                         $this->_set_mobile(); 
     198                                        $this->set_mobile(); 
    198199                                        return TRUE; 
    199200                                } 
     
    211212         * @return      bool 
    212213         */ 
    213         private function _set_robot() 
     214        private function set_robot() 
    214215        { 
    215216                if (is_array($this->robots) AND count($this->robots) > 0) 
     
    236237         * @return      bool 
    237238         */ 
    238         private function _set_mobile() 
     239        private function set_mobile() 
    239240        { 
    240241                if (is_array($this->mobiles) AND count($this->mobiles) > 0) 
     
    261262         * @return      void 
    262263         */ 
    263         private function _set_languages() 
     264        private function set_languages() 
    264265        { 
    265266                if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '') 
     
    284285         * @return      void 
    285286         */ 
    286         private function _set_charsets() 
     287        private function set_charsets() 
    287288        { 
    288289                if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '') 
     
    453454                if (count($this->languages) == 0) 
    454455                { 
    455                         $this->_set_languages(); 
     456                        $this->set_languages(); 
    456457                } 
    457458 
     
    471472                if (count($this->charsets) == 0) 
    472473                { 
    473                         $this->_set_charsets(); 
     474                        $this->set_charsets(); 
    474475                } 
    475476 
     
    502503                return (in_array(strtolower($charset), $this->charsets(), TRUE)) ? TRUE : FALSE; 
    503504        } 
    504  
    505  
    506 } 
    507  
    508 ?> 
     505         
     506        // -------------------------------------------------------------------- 
     507         
     508        /** 
     509         * Returns the full user agent string when the object is turned into a string. 
     510         * 
     511         * @access public 
     512         * @return string 
     513         */ 
     514        public function __toString() { 
     515                return $this->agent; 
     516        } 
     517         
     518} //End User_agent class