]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/class-ftp.php
WordPress 4.3
[autoinstalls/wordpress.git] / wp-admin / includes / class-ftp.php
index 0bf25e9c7853cc3e1cbc3a6d0c2be5501933afc9..c9d965649c3791d79323559cad2995b8df70264a 100644 (file)
@@ -9,7 +9,7 @@
  * @copyright Alexey Dotsenko
  * @author Alexey Dotsenko
  * @link http://www.phpclasses.org/browse/package/1743.html Site
  * @copyright Alexey Dotsenko
  * @author Alexey Dotsenko
  * @link http://www.phpclasses.org/browse/package/1743.html Site
- * @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
+ * @license LGPL http://www.opensource.org/licenses/lgpl-license.html
  */
 
 /**
  */
 
 /**
@@ -121,10 +121,6 @@ class ftp_base {
        var $AutoAsciiExt;
 
        /* Constructor */
        var $AutoAsciiExt;
 
        /* Constructor */
-       function ftp_base($port_mode=FALSE) {
-               $this->__construct($port_mode);
-       }
-
        function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) {
                $this->LocalEcho=$le;
                $this->Verbose=$verb;
        function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) {
                $this->LocalEcho=$le;
                $this->Verbose=$verb;
@@ -157,6 +153,10 @@ class ftp_base {
                elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac;
        }
 
                elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac;
        }
 
+       function ftp_base($port_mode=FALSE) {
+               $this->__construct($port_mode);
+       }
+
 // <!-- --------------------------------------------------------------------------------------- -->
 // <!--       Public functions                                                                  -->
 // <!-- --------------------------------------------------------------------------------------- -->
 // <!-- --------------------------------------------------------------------------------------- -->
 // <!--       Public functions                                                                  -->
 // <!-- --------------------------------------------------------------------------------------- -->
@@ -278,7 +278,10 @@ class ftp_base {
                $dns=@gethostbyaddr($host);
                if(!$ip) $ip=$host;
                if(!$dns) $dns=$host;
                $dns=@gethostbyaddr($host);
                if(!$ip) $ip=$host;
                if(!$dns) $dns=$host;
-                       if(ip2long($ip) === -1) {
+               // Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false
+               // -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid
+               $ipaslong = ip2long($ip);
+                       if ( ($ipaslong == false) || ($ipaslong === -1) ) {
                                $this->SendMSG("Wrong host name/address \"".$host."\"");
                                return FALSE;
                        }
                                $this->SendMSG("Wrong host name/address \"".$host."\"");
                                return FALSE;
                        }
@@ -492,7 +495,7 @@ class ftp_base {
                $this->_features=array();
                foreach($f as $k=>$v) {
                        $v=explode(" ", trim($v));
                $this->_features=array();
                foreach($f as $k=>$v) {
                        $v=explode(" ", trim($v));
-                       $this->_features[array_shift($v)]=$v;;
+                       $this->_features[array_shift($v)]=$v;
                }
                return true;
        }
                }
                return true;
        }
@@ -501,7 +504,7 @@ class ftp_base {
                return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist");
        }
 
                return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist");
        }
 
-       function nlist($pathname="") {
+       function nlist($pathname="", $arg="") {
                return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist");
        }
 
                return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist");
        }
 
@@ -893,11 +896,11 @@ class ftp_base {
        }
 }
 
        }
 }
 
-$mod_sockets=TRUE;
-if (!extension_loaded('sockets')) {
-       $prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : '';
-       if(!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE;
+$mod_sockets = extension_loaded( 'sockets' );
+if ( ! $mod_sockets && function_exists( 'dl' ) && is_callable( 'dl' ) ) {
+       $prefix = ( PHP_SHLIB_SUFFIX == 'dll' ) ? 'php_' : '';
+       @dl( $prefix . 'sockets.' . PHP_SHLIB_SUFFIX );
+       $mod_sockets = extension_loaded( 'sockets' );
 }
 
 }
 
-require_once "class-ftp-".($mod_sockets?"sockets":"pure").".php";
-?>
+require_once dirname( __FILE__ ) . "/class-ftp-" . ( $mod_sockets ? "sockets" : "pure" ) . ".php";