Subversion Repositories Applications.papyrus

Rev

Rev 320 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 320 Rev 969
Line 17... Line 17...
17
 * @category   Networking
17
 * @category   Networking
18
 * @package    FTP
18
 * @package    FTP
19
 * @author     Tobias Schlitt <toby@php.net>
19
 * @author     Tobias Schlitt <toby@php.net>
20
 * @copyright  1997-2005 The PHP Group
20
 * @copyright  1997-2005 The PHP Group
21
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
21
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
22
 * @version    CVS: $Id: FTP.php,v 1.1 2005-03-30 08:50:33 jpm Exp $
22
 * @version    CVS: $Id: FTP.php,v 1.2 2006-10-05 08:55:35 florian Exp $
23
 * @link       http://pear.php.net/package/Net_FTP
23
 * @link       http://pear.php.net/package/Net_FTP
24
 * @since      File available since Release 0.0.1
24
 * @since      File available since Release 0.0.1
25
 */
25
 */
Line 26... Line 26...
26
 
26
 
Line 464... Line 464...
464
 * @license   http://www.php.net/license/3_0.txt  PHP License 3.0
464
 * @license   http://www.php.net/license/3_0.txt  PHP License 3.0
465
 * @category  Networking
465
 * @category  Networking
466
 * @package   FTP
466
 * @package   FTP
467
 * @author    Tobias Schlitt <toby@php.net>
467
 * @author    Tobias Schlitt <toby@php.net>
468
 * @copyright 1997-2005 The PHP Group
468
 * @copyright 1997-2005 The PHP Group
469
 * @version   Release: 1.3.0
469
 * @version   Release: @package_version@
470
 * @link      http://pear.php.net/package/Net_FTP
470
 * @link      http://pear.php.net/package/Net_FTP
471
 * @since     0.0.1
471
 * @since     0.0.1
472
 * @access    public
472
 * @access    public
473
 */
473
 */
474
class Net_FTP extends PEAR 
474
class Net_FTP extends PEAR 
Line 567... Line 567...
567
     * @since   1.3
567
     * @since   1.3
568
     */
568
     */
Line 569... Line 569...
569
    
569
    
570
    var $_ls_match = array(
570
    var $_ls_match = array(
571
        'unix'    => array(
571
        'unix'    => array(
572
            'pattern' => '/(?:(d)|.)([rwxt-]+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(\S+\s+\S+\s+\S+)\s+(.+)/',
572
            'pattern' => '/(?:(d)|.)([rwxt-]+)\s+(\w+)\s+([\w\d-]+)\s+([\w\d-]+)\s+(\w+)\s+(\S+\s+\S+\s+\S+)\s+(.+)/',
-
 
573
            'map'     => array(
-
 
574
                'is_dir'        => 1,
573
            'map'     => array('name'=>8,'size'=>6,'rights'=>2,'user'=>4,'group'=>5,
575
                'rights'        => 2,
-
 
576
                'files_inside'  => 3,
-
 
577
                'user'          => 4,
-
 
578
                'group'         => 5,
-
 
579
                'size'          => 6,
-
 
580
                'date'          => 7,
-
 
581
                'name'          => 8,
574
                              'files_inside'=>3,'date'=>7,'is_dir'=>1)
582
            )
575
        ),
583
        ),
576
        'windows' => array(
584
        'windows' => array(
577
            'pattern' => '/(.+)\s+(.+)\s+((<DIR>)|[0-9]+)\s+(.+)/',
585
            'pattern' => '/(.+)\s+(.+)\s+((<DIR>)|[0-9]+)\s+(.+)/',
-
 
586
            'map'     => array(
-
 
587
                'name'   => 5,
-
 
588
                'date'   => 1,
-
 
589
                'size'   => 3,
-
 
590
                'is_dir' => 4,
578
            'map'     => array('name'=>5,'date'=>1,'is_dir'=>3)
591
            )
579
        )
592
        )
Line 580... Line 593...
580
    );
593
    );
581
    
594
    
Line 925... Line 938...
925
 
938
 
926
            $dir_list = array();
939
            $dir_list = array();
927
            $mode = NET_FTP_DIRS_ONLY;
940
            $mode = NET_FTP_DIRS_ONLY;
928
            $dir_list = $this->ls($remote_path, $mode);
941
            $dir_list = $this->ls($remote_path, $mode);
-
 
942
            foreach ($dir_list as $dir_entry) {
-
 
943
                if ($dir_entry == '.' || $dir_entry == '..') {;
-
 
944
                    continue;
929
            foreach ($dir_list as $dir_entry) {
945
                }
930
 
946
                
Line 931... Line 947...
931
                $remote_path_new = $remote_path.$dir_entry["name"]."/";
947
                $remote_path_new = $remote_path.$dir_entry["name"]."/";
932
 
948
 
Line 1814... Line 1830...
1814
     * @return  bool          True if $path is a directory, otherwise false
1830
     * @return  bool          True if $path is a directory, otherwise false
1815
     */
1831
     */
Line 1816... Line 1832...
1816
    
1832
    
1817
    function _check_dir($path)
1833
    function _check_dir($path)
1818
    {
1834
    {
1819
        if (substr($path, (strlen($path) - 1), 1) == "/") {
1835
        if (!empty($path) && substr($path, (strlen($path) - 1), 1) == "/") {
1820
            return true;
1836
            return true;
1821
        } else {
1837
        } else {
1822
            return false;
1838
            return false;
1823
        }
1839
        }
Line 1894... Line 1910...
1894
                return $res;
1910
                return $res;
1895
            }
1911
            }
1896
        }
1912
        }
1897
        $dir_list = $this->_ls_dirs($dir);
1913
        $dir_list = $this->_ls_dirs($dir);
1898
        foreach ($dir_list as $new_dir) {
1914
        foreach ($dir_list as $new_dir) {
-
 
1915
            if ($new_dir == '.' || $new_dir == '..') {
-
 
1916
                continue;
-
 
1917
            }
1899
            $new_dir = $dir.$new_dir["name"]."/";
1918
            $new_dir = $dir.$new_dir["name"]."/";
1900
            $res = $this->_rm_dir_recursive($new_dir);
1919
            $res = $this->_rm_dir_recursive($new_dir);
1901
            if ($this->isError($res)) {
1920
            if ($this->isError($res)) {
1902
                return $res;
1921
                return $res;
1903
            }
1922
            }
Line 1919... Line 1938...
1919
     */
1938
     */
Line 1920... Line 1939...
1920
    
1939
    
1921
    function _ls_both($dir)
1940
    function _ls_both($dir)
1922
    {
1941
    {
-
 
1942
        $list_splitted = $this->_list_and_parse($dir);
-
 
1943
        if (PEAR::isError($list_splitted)) {
-
 
1944
            return $list_splitted;
1923
        $list_splitted = $this->_list_and_parse($dir);
1945
        }
1924
        if (!is_array($list_splitted["files"])) {
1946
        if (!is_array($list_splitted["files"])) {
1925
            $list_splitted["files"] = array();
1947
            $list_splitted["files"] = array();
1926
        }
1948
        }
1927
        if (!is_array($list_splitted["dirs"])) {
1949
        if (!is_array($list_splitted["dirs"])) {
Line 1981... Line 2003...
1981
    function _list_and_parse($dir)
2003
    function _list_and_parse($dir)
1982
    {
2004
    {
1983
        $dirs_list = array();
2005
        $dirs_list = array();
1984
        $files_list = array();
2006
        $files_list = array();
1985
        $dir_list = @ftp_rawlist($this->_handle, $dir);
2007
        $dir_list = @ftp_rawlist($this->_handle, $dir);
1986
        if ($dir_list === false) {
2008
        if (!is_array($dir_list)) {
1987
            return PEAR::raiseError('Could not get raw directory listing.', NET_FTP_ERR_RAWDIRLIST_FAILED);
2009
            return PEAR::raiseError('Could not get raw directory listing.', NET_FTP_ERR_RAWDIRLIST_FAILED);
1988
        }
2010
        }
-
 
2011
        // Handle empty directories
-
 
2012
        if (count($dir_list) == 0) {
-
 
2013
            return array('dirs' => $dirs_list, 'files' => $files_list);
-
 
2014
        }
-
 
2015
 
-
 
2016
        // Exception for some FTP servers seem to return this wiered result instead of an empty list
-
 
2017
        if (count($dirs_list) == 1 && $dirs_list[0] == 'total 0') {
-
 
2018
            return array('dirs' => array(), 'files' => $files_list);
-
 
2019
        }
-
 
2020
        
1989
        if (!isset($this->_matcher) || PEAR::isError($this->_matcher)) {
2021
        if (!isset($this->_matcher) || PEAR::isError($this->_matcher)) {
1990
            $this->_matcher = $this->_determine_os_match($dir_list);
2022
            $this->_matcher = $this->_determine_os_match($dir_list);
1991
            if (PEAR::isError($this->_matcher)) {
2023
            if (PEAR::isError($this->_matcher)) {
1992
                return $this->_matcher;
2024
                return $this->_matcher;
1993
            }
2025
            }