WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-ftp.php

    r46828 r46828  
    11<?php
    22/**
    3  * PemFTP - A Ftp implementation in pure PHP
     3 * PemFTP - An Ftp implementation in pure PHP
    44 *
    55 * @package PemFTP
    6  * @since 2.5
     6 * @since 2.5.0
    77 *
    88 * @version 1.0
    99 * @copyright Alexey Dotsenko
    1010 * @author Alexey Dotsenko
    11  * @link http://www.phpclasses.org/browse/package/1743.html Site
    12  * @license LGPL http://www.opensource.org/licenses/lgpl-license.html
     11 * @link https://www.phpclasses.org/package/1743-PHP-FTP-client-in-pure-PHP.html
     12 * @license LGPL https://opensource.org/licenses/lgpl-license.html
    1313 */
    1414
     
    1818 * This can be redefined.
    1919 *
    20  * @since 2.5
     20 * @since 2.5.0
    2121 * @var string
    2222 */
     
    2828 * This can be redefined.
    2929 *
    30  * @since 2.5
     30 * @since 2.5.0
    3131 * @var int
    3232 */
     
    3636 *
    3737 * This can be redefined.
    38  * @since 2.5
     38 * @since 2.5.0
    3939 * @var int
    4040 */
     
    4444 *
    4545 * This can be redefined.
    46  * @since 2.5
     46 * @since 2.5.0
    4747 * @var int
    4848 */
     
    5454 * This can be redefined.
    5555 *
    56  * @since 2.5
     56 * @since 2.5.0
    5757 * @var bool
    5858 */
     
    6060
    6161/**
    62  * @since 2.5
     62 * @since 2.5.0
    6363 * @var string
    6464 */
     
    6666
    6767/**
    68  * @since 2.5
     68 * @since 2.5.0
    6969 * @var string
    7070 */
     
    7272
    7373/**
    74  * @since 2.5
     74 * @since 2.5.0
    7575 * @var string
    7676 */
     
    186186            if ($lcount<8) return '';
    187187            $b = array();
    188             $b['isdir'] = $lucifer[0]{0} === "d";
    189             $b['islink'] = $lucifer[0]{0} === "l";
     188            $b['isdir'] = $lucifer[0][0] === "d";
     189            $b['islink'] = $lucifer[0][0] === "l";
    190190            if ( $b['isdir'] )
    191191                $b['type'] = 'd';
     
    208208                $b['day'] = $lucifer[6];
    209209                if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) {
    210                     $b['year'] = date("Y");
     210                    $b['year'] = gmdate("Y");
    211211                    $b['hour'] = $l2[1];
    212212                    $b['minute'] = $l2[2];
     
    381381        if(!$this->_exec("PWD", "pwd")) return FALSE;
    382382        if(!$this->_checkCode()) return FALSE;
    383         return ereg_replace("^[0-9]{3} \"(.+)\".+", "\\1", $this->_message);
     383        return preg_replace("/^[0-9]{3} \"(.+)\".*$/s", "\\1", $this->_message);
    384384    }
    385385
     
    425425        if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE;
    426426        if(!$this->_checkCode()) return FALSE;
    427         return ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message);
     427        return preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message);
    428428    }
    429429
     
    445445        if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE;
    446446        if(!$this->_checkCode()) return FALSE;
    447         $mdtm = ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message);
     447        $mdtm = preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message);
    448448        $date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d");
    449449        $timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]);
     
    525525    }
    526526
    527     function fget($fp, $remotefile,$rest=0) {
     527    function fget($fp, $remotefile, $rest=0) {
    528528        if($this->_can_restore and $rest!=0) fseek($fp, $rest);
    529529        $pi=pathinfo($remotefile);
     
    584584    }
    585585
    586     function fput($remotefile, $fp) {
     586    function fput($remotefile, $fp, $rest=0) {
    587587        if($this->_can_restore and $rest!=0) fseek($fp, $rest);
    588588        $pi=pathinfo($remotefile);
     
    695695        foreach($list as $k=>$v) {
    696696            $list[$k]=$this->parselisting($v);
    697             if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
     697            if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
    698698        }
    699699        $ret=true;
     
    728728        foreach($list as $k=>$v) {
    729729            $list[$k]=$this->parselisting($v);
    730             if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
     730            if( ! $list[$k] or $list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
    731731        }
    732732        $ret=true;
     
    776776        } else $path=getcwd();
    777777        if(is_array($handle) and !empty($handle)) {
    778             while($dir=each($handle)) {
     778            foreach($handle as $dir) {
    779779                if($this->glob_pattern_match($pattern,$dir))
    780780                $output[]=$dir;
     
    819819        $sensitive=(PHP_OS!='WIN32');
    820820        return ($sensitive?
    821             ereg($pattern,$probe):
    822             eregi($pattern,$probe)
     821            preg_match( '/' . preg_quote( $pattern, '/' ) . '/', $probe ) :
     822            preg_match( '/' . preg_quote( $pattern, '/' ) . '/i', $probe )
    823823        );
    824824    }
     
    905905
    906906require_once dirname( __FILE__ ) . "/class-ftp-" . ( $mod_sockets ? "sockets" : "pure" ) . ".php";
     907
     908if ( $mod_sockets ) {
     909    class ftp extends ftp_sockets {}
     910} else {
     911    class ftp extends ftp_pure {}
     912}
Note: See TracChangeset for help on using the changeset viewer.