Edit File by line
/home/barbar84/public_h.../wp-admin/includes
File: class-ftp.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* PemFTP - An Ftp implementation in pure PHP
[2] Fix | Delete
*
[3] Fix | Delete
* @package PemFTP
[4] Fix | Delete
* @since 2.5.0
[5] Fix | Delete
*
[6] Fix | Delete
* @version 1.0
[7] Fix | Delete
* @copyright Alexey Dotsenko
[8] Fix | Delete
* @author Alexey Dotsenko
[9] Fix | Delete
* @link https://www.phpclasses.org/package/1743-PHP-FTP-client-in-pure-PHP.html
[10] Fix | Delete
* @license LGPL https://opensource.org/licenses/lgpl-license.html
[11] Fix | Delete
*/
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Defines the newline characters, if not defined already.
[15] Fix | Delete
*
[16] Fix | Delete
* This can be redefined.
[17] Fix | Delete
*
[18] Fix | Delete
* @since 2.5.0
[19] Fix | Delete
* @var string
[20] Fix | Delete
*/
[21] Fix | Delete
if(!defined('CRLF')) define('CRLF',"\r\n");
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Sets whatever to autodetect ASCII mode.
[25] Fix | Delete
*
[26] Fix | Delete
* This can be redefined.
[27] Fix | Delete
*
[28] Fix | Delete
* @since 2.5.0
[29] Fix | Delete
* @var int
[30] Fix | Delete
*/
[31] Fix | Delete
if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1);
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
*
[35] Fix | Delete
* This can be redefined.
[36] Fix | Delete
* @since 2.5.0
[37] Fix | Delete
* @var int
[38] Fix | Delete
*/
[39] Fix | Delete
if(!defined("FTP_BINARY")) define("FTP_BINARY", 1);
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
*
[43] Fix | Delete
* This can be redefined.
[44] Fix | Delete
* @since 2.5.0
[45] Fix | Delete
* @var int
[46] Fix | Delete
*/
[47] Fix | Delete
if(!defined("FTP_ASCII")) define("FTP_ASCII", 0);
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Whether to force FTP.
[51] Fix | Delete
*
[52] Fix | Delete
* This can be redefined.
[53] Fix | Delete
*
[54] Fix | Delete
* @since 2.5.0
[55] Fix | Delete
* @var bool
[56] Fix | Delete
*/
[57] Fix | Delete
if(!defined('FTP_FORCE')) define('FTP_FORCE', true);
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* @since 2.5.0
[61] Fix | Delete
* @var string
[62] Fix | Delete
*/
[63] Fix | Delete
define('FTP_OS_Unix','u');
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* @since 2.5.0
[67] Fix | Delete
* @var string
[68] Fix | Delete
*/
[69] Fix | Delete
define('FTP_OS_Windows','w');
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* @since 2.5.0
[73] Fix | Delete
* @var string
[74] Fix | Delete
*/
[75] Fix | Delete
define('FTP_OS_Mac','m');
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* PemFTP base class
[79] Fix | Delete
*
[80] Fix | Delete
*/
[81] Fix | Delete
class ftp_base {
[82] Fix | Delete
/* Public variables */
[83] Fix | Delete
var $LocalEcho;
[84] Fix | Delete
var $Verbose;
[85] Fix | Delete
var $OS_local;
[86] Fix | Delete
var $OS_remote;
[87] Fix | Delete
[88] Fix | Delete
/* Private variables */
[89] Fix | Delete
var $_lastaction;
[90] Fix | Delete
var $_errors;
[91] Fix | Delete
var $_type;
[92] Fix | Delete
var $_umask;
[93] Fix | Delete
var $_timeout;
[94] Fix | Delete
var $_passive;
[95] Fix | Delete
var $_host;
[96] Fix | Delete
var $_fullhost;
[97] Fix | Delete
var $_port;
[98] Fix | Delete
var $_datahost;
[99] Fix | Delete
var $_dataport;
[100] Fix | Delete
var $_ftp_control_sock;
[101] Fix | Delete
var $_ftp_data_sock;
[102] Fix | Delete
var $_ftp_temp_sock;
[103] Fix | Delete
var $_ftp_buff_size;
[104] Fix | Delete
var $_login;
[105] Fix | Delete
var $_password;
[106] Fix | Delete
var $_connected;
[107] Fix | Delete
var $_ready;
[108] Fix | Delete
var $_code;
[109] Fix | Delete
var $_message;
[110] Fix | Delete
var $_can_restore;
[111] Fix | Delete
var $_port_available;
[112] Fix | Delete
var $_curtype;
[113] Fix | Delete
var $_features;
[114] Fix | Delete
[115] Fix | Delete
var $_error_array;
[116] Fix | Delete
var $AuthorizedTransferMode;
[117] Fix | Delete
var $OS_FullName;
[118] Fix | Delete
var $_eol_code;
[119] Fix | Delete
var $AutoAsciiExt;
[120] Fix | Delete
[121] Fix | Delete
/* Constructor */
[122] Fix | Delete
function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) {
[123] Fix | Delete
$this->LocalEcho=$le;
[124] Fix | Delete
$this->Verbose=$verb;
[125] Fix | Delete
$this->_lastaction=NULL;
[126] Fix | Delete
$this->_error_array=array();
[127] Fix | Delete
$this->_eol_code=array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n");
[128] Fix | Delete
$this->AuthorizedTransferMode=array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY);
[129] Fix | Delete
$this->OS_FullName=array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS');
[130] Fix | Delete
$this->AutoAsciiExt=array("ASP","BAT","C","CPP","CSS","CSV","JS","H","HTM","HTML","SHTML","INI","LOG","PHP3","PHTML","PL","PERL","SH","SQL","TXT");
[131] Fix | Delete
$this->_port_available=($port_mode==TRUE);
[132] Fix | Delete
$this->SendMSG("Staring FTP client class".($this->_port_available?"":" without PORT mode support"));
[133] Fix | Delete
$this->_connected=FALSE;
[134] Fix | Delete
$this->_ready=FALSE;
[135] Fix | Delete
$this->_can_restore=FALSE;
[136] Fix | Delete
$this->_code=0;
[137] Fix | Delete
$this->_message="";
[138] Fix | Delete
$this->_ftp_buff_size=4096;
[139] Fix | Delete
$this->_curtype=NULL;
[140] Fix | Delete
$this->SetUmask(0022);
[141] Fix | Delete
$this->SetType(FTP_AUTOASCII);
[142] Fix | Delete
$this->SetTimeout(30);
[143] Fix | Delete
$this->Passive(!$this->_port_available);
[144] Fix | Delete
$this->_login="anonymous";
[145] Fix | Delete
$this->_password="anon@ftp.com";
[146] Fix | Delete
$this->_features=array();
[147] Fix | Delete
$this->OS_local=FTP_OS_Unix;
[148] Fix | Delete
$this->OS_remote=FTP_OS_Unix;
[149] Fix | Delete
$this->features=array();
[150] Fix | Delete
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows;
[151] Fix | Delete
elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac;
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
function ftp_base($port_mode=FALSE) {
[155] Fix | Delete
$this->__construct($port_mode);
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
// <!-- --------------------------------------------------------------------------------------- -->
[159] Fix | Delete
// <!-- Public functions -->
[160] Fix | Delete
// <!-- --------------------------------------------------------------------------------------- -->
[161] Fix | Delete
[162] Fix | Delete
function parselisting($line) {
[163] Fix | Delete
$is_windows = ($this->OS_remote == FTP_OS_Windows);
[164] Fix | Delete
if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/",$line,$lucifer)) {
[165] Fix | Delete
$b = array();
[166] Fix | Delete
if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix
[167] Fix | Delete
$b['isdir'] = ($lucifer[7]=="<DIR>");
[168] Fix | Delete
if ( $b['isdir'] )
[169] Fix | Delete
$b['type'] = 'd';
[170] Fix | Delete
else
[171] Fix | Delete
$b['type'] = 'f';
[172] Fix | Delete
$b['size'] = $lucifer[7];
[173] Fix | Delete
$b['month'] = $lucifer[1];
[174] Fix | Delete
$b['day'] = $lucifer[2];
[175] Fix | Delete
$b['year'] = $lucifer[3];
[176] Fix | Delete
$b['hour'] = $lucifer[4];
[177] Fix | Delete
$b['minute'] = $lucifer[5];
[178] Fix | Delete
$b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]);
[179] Fix | Delete
$b['am/pm'] = $lucifer[6];
[180] Fix | Delete
$b['name'] = $lucifer[8];
[181] Fix | Delete
} else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) {
[182] Fix | Delete
//echo $line."\n";
[183] Fix | Delete
$lcount=count($lucifer);
[184] Fix | Delete
if ($lcount<8) return '';
[185] Fix | Delete
$b = array();
[186] Fix | Delete
$b['isdir'] = $lucifer[0][0] === "d";
[187] Fix | Delete
$b['islink'] = $lucifer[0][0] === "l";
[188] Fix | Delete
if ( $b['isdir'] )
[189] Fix | Delete
$b['type'] = 'd';
[190] Fix | Delete
elseif ( $b['islink'] )
[191] Fix | Delete
$b['type'] = 'l';
[192] Fix | Delete
else
[193] Fix | Delete
$b['type'] = 'f';
[194] Fix | Delete
$b['perms'] = $lucifer[0];
[195] Fix | Delete
$b['number'] = $lucifer[1];
[196] Fix | Delete
$b['owner'] = $lucifer[2];
[197] Fix | Delete
$b['group'] = $lucifer[3];
[198] Fix | Delete
$b['size'] = $lucifer[4];
[199] Fix | Delete
if ($lcount==8) {
[200] Fix | Delete
sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']);
[201] Fix | Delete
sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']);
[202] Fix | Delete
$b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']);
[203] Fix | Delete
$b['name'] = $lucifer[7];
[204] Fix | Delete
} else {
[205] Fix | Delete
$b['month'] = $lucifer[5];
[206] Fix | Delete
$b['day'] = $lucifer[6];
[207] Fix | Delete
if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) {
[208] Fix | Delete
$b['year'] = gmdate("Y");
[209] Fix | Delete
$b['hour'] = $l2[1];
[210] Fix | Delete
$b['minute'] = $l2[2];
[211] Fix | Delete
} else {
[212] Fix | Delete
$b['year'] = $lucifer[7];
[213] Fix | Delete
$b['hour'] = 0;
[214] Fix | Delete
$b['minute'] = 0;
[215] Fix | Delete
}
[216] Fix | Delete
$b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute']));
[217] Fix | Delete
$b['name'] = $lucifer[8];
[218] Fix | Delete
}
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
return $b;
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
function SendMSG($message = "", $crlf=true) {
[225] Fix | Delete
if ($this->Verbose) {
[226] Fix | Delete
echo $message.($crlf?CRLF:"");
[227] Fix | Delete
flush();
[228] Fix | Delete
}
[229] Fix | Delete
return TRUE;
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
function SetType($mode=FTP_AUTOASCII) {
[233] Fix | Delete
if(!in_array($mode, $this->AuthorizedTransferMode)) {
[234] Fix | Delete
$this->SendMSG("Wrong type");
[235] Fix | Delete
return FALSE;
[236] Fix | Delete
}
[237] Fix | Delete
$this->_type=$mode;
[238] Fix | Delete
$this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) );
[239] Fix | Delete
return TRUE;
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
function _settype($mode=FTP_ASCII) {
[243] Fix | Delete
if($this->_ready) {
[244] Fix | Delete
if($mode==FTP_BINARY) {
[245] Fix | Delete
if($this->_curtype!=FTP_BINARY) {
[246] Fix | Delete
if(!$this->_exec("TYPE I", "SetType")) return FALSE;
[247] Fix | Delete
$this->_curtype=FTP_BINARY;
[248] Fix | Delete
}
[249] Fix | Delete
} elseif($this->_curtype!=FTP_ASCII) {
[250] Fix | Delete
if(!$this->_exec("TYPE A", "SetType")) return FALSE;
[251] Fix | Delete
$this->_curtype=FTP_ASCII;
[252] Fix | Delete
}
[253] Fix | Delete
} else return FALSE;
[254] Fix | Delete
return TRUE;
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
function Passive($pasv=NULL) {
[258] Fix | Delete
if(is_null($pasv)) $this->_passive=!$this->_passive;
[259] Fix | Delete
else $this->_passive=$pasv;
[260] Fix | Delete
if(!$this->_port_available and !$this->_passive) {
[261] Fix | Delete
$this->SendMSG("Only passive connections available!");
[262] Fix | Delete
$this->_passive=TRUE;
[263] Fix | Delete
return FALSE;
[264] Fix | Delete
}
[265] Fix | Delete
$this->SendMSG("Passive mode ".($this->_passive?"on":"off"));
[266] Fix | Delete
return TRUE;
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
function SetServer($host, $port=21, $reconnect=true) {
[270] Fix | Delete
if(!is_long($port)) {
[271] Fix | Delete
$this->verbose=true;
[272] Fix | Delete
$this->SendMSG("Incorrect port syntax");
[273] Fix | Delete
return FALSE;
[274] Fix | Delete
} else {
[275] Fix | Delete
$ip=@gethostbyname($host);
[276] Fix | Delete
$dns=@gethostbyaddr($host);
[277] Fix | Delete
if(!$ip) $ip=$host;
[278] Fix | Delete
if(!$dns) $dns=$host;
[279] Fix | Delete
// Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false
[280] Fix | Delete
// -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid
[281] Fix | Delete
$ipaslong = ip2long($ip);
[282] Fix | Delete
if ( ($ipaslong == false) || ($ipaslong === -1) ) {
[283] Fix | Delete
$this->SendMSG("Wrong host name/address \"".$host."\"");
[284] Fix | Delete
return FALSE;
[285] Fix | Delete
}
[286] Fix | Delete
$this->_host=$ip;
[287] Fix | Delete
$this->_fullhost=$dns;
[288] Fix | Delete
$this->_port=$port;
[289] Fix | Delete
$this->_dataport=$port-1;
[290] Fix | Delete
}
[291] Fix | Delete
$this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\"");
[292] Fix | Delete
if($reconnect){
[293] Fix | Delete
if($this->_connected) {
[294] Fix | Delete
$this->SendMSG("Reconnecting");
[295] Fix | Delete
if(!$this->quit(FTP_FORCE)) return FALSE;
[296] Fix | Delete
if(!$this->connect()) return FALSE;
[297] Fix | Delete
}
[298] Fix | Delete
}
[299] Fix | Delete
return TRUE;
[300] Fix | Delete
}
[301] Fix | Delete
[302] Fix | Delete
function SetUmask($umask=0022) {
[303] Fix | Delete
$this->_umask=$umask;
[304] Fix | Delete
umask($this->_umask);
[305] Fix | Delete
$this->SendMSG("UMASK 0".decoct($this->_umask));
[306] Fix | Delete
return TRUE;
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
function SetTimeout($timeout=30) {
[310] Fix | Delete
$this->_timeout=$timeout;
[311] Fix | Delete
$this->SendMSG("Timeout ".$this->_timeout);
[312] Fix | Delete
if($this->_connected)
[313] Fix | Delete
if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE;
[314] Fix | Delete
return TRUE;
[315] Fix | Delete
}
[316] Fix | Delete
[317] Fix | Delete
function connect($server=NULL) {
[318] Fix | Delete
if(!empty($server)) {
[319] Fix | Delete
if(!$this->SetServer($server)) return false;
[320] Fix | Delete
}
[321] Fix | Delete
if($this->_ready) return true;
[322] Fix | Delete
$this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]);
[323] Fix | Delete
if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) {
[324] Fix | Delete
$this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\"");
[325] Fix | Delete
return FALSE;
[326] Fix | Delete
}
[327] Fix | Delete
$this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting.");
[328] Fix | Delete
do {
[329] Fix | Delete
if(!$this->_readmsg()) return FALSE;
[330] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[331] Fix | Delete
$this->_lastaction=time();
[332] Fix | Delete
} while($this->_code<200);
[333] Fix | Delete
$this->_ready=true;
[334] Fix | Delete
$syst=$this->systype();
[335] Fix | Delete
if(!$syst) $this->SendMSG("Can't detect remote OS");
[336] Fix | Delete
else {
[337] Fix | Delete
if(preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote=FTP_OS_Windows;
[338] Fix | Delete
elseif(preg_match("/os/i", $syst[0])) $this->OS_remote=FTP_OS_Mac;
[339] Fix | Delete
elseif(preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote=FTP_OS_Unix;
[340] Fix | Delete
else $this->OS_remote=FTP_OS_Mac;
[341] Fix | Delete
$this->SendMSG("Remote OS: ".$this->OS_FullName[$this->OS_remote]);
[342] Fix | Delete
}
[343] Fix | Delete
if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
[344] Fix | Delete
else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
[345] Fix | Delete
return TRUE;
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
function quit($force=false) {
[349] Fix | Delete
if($this->_ready) {
[350] Fix | Delete
if(!$this->_exec("QUIT") and !$force) return FALSE;
[351] Fix | Delete
if(!$this->_checkCode() and !$force) return FALSE;
[352] Fix | Delete
$this->_ready=false;
[353] Fix | Delete
$this->SendMSG("Session finished");
[354] Fix | Delete
}
[355] Fix | Delete
$this->_quit();
[356] Fix | Delete
return TRUE;
[357] Fix | Delete
}
[358] Fix | Delete
[359] Fix | Delete
function login($user=NULL, $pass=NULL) {
[360] Fix | Delete
if(!is_null($user)) $this->_login=$user;
[361] Fix | Delete
else $this->_login="anonymous";
[362] Fix | Delete
if(!is_null($pass)) $this->_password=$pass;
[363] Fix | Delete
else $this->_password="anon@anon.com";
[364] Fix | Delete
if(!$this->_exec("USER ".$this->_login, "login")) return FALSE;
[365] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[366] Fix | Delete
if($this->_code!=230) {
[367] Fix | Delete
if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE;
[368] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[369] Fix | Delete
}
[370] Fix | Delete
$this->SendMSG("Authentication succeeded");
[371] Fix | Delete
if(empty($this->_features)) {
[372] Fix | Delete
if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
[373] Fix | Delete
else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
[374] Fix | Delete
}
[375] Fix | Delete
return TRUE;
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
function pwd() {
[379] Fix | Delete
if(!$this->_exec("PWD", "pwd")) return FALSE;
[380] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[381] Fix | Delete
return preg_replace("/^[0-9]{3} \"(.+)\".*$/s", "\\1", $this->_message);
[382] Fix | Delete
}
[383] Fix | Delete
[384] Fix | Delete
function cdup() {
[385] Fix | Delete
if(!$this->_exec("CDUP", "cdup")) return FALSE;
[386] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[387] Fix | Delete
return true;
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
function chdir($pathname) {
[391] Fix | Delete
if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE;
[392] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[393] Fix | Delete
return TRUE;
[394] Fix | Delete
}
[395] Fix | Delete
[396] Fix | Delete
function rmdir($pathname) {
[397] Fix | Delete
if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE;
[398] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[399] Fix | Delete
return TRUE;
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
function mkdir($pathname) {
[403] Fix | Delete
if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE;
[404] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[405] Fix | Delete
return TRUE;
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
function rename($from, $to) {
[409] Fix | Delete
if(!$this->_exec("RNFR ".$from, "rename")) return FALSE;
[410] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[411] Fix | Delete
if($this->_code==350) {
[412] Fix | Delete
if(!$this->_exec("RNTO ".$to, "rename")) return FALSE;
[413] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[414] Fix | Delete
} else return FALSE;
[415] Fix | Delete
return TRUE;
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
function filesize($pathname) {
[419] Fix | Delete
if(!isset($this->_features["SIZE"])) {
[420] Fix | Delete
$this->PushError("filesize", "not supported by server");
[421] Fix | Delete
return FALSE;
[422] Fix | Delete
}
[423] Fix | Delete
if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE;
[424] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[425] Fix | Delete
return preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message);
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
function abort() {
[429] Fix | Delete
if(!$this->_exec("ABOR", "abort")) return FALSE;
[430] Fix | Delete
if(!$this->_checkCode()) {
[431] Fix | Delete
if($this->_code!=426) return FALSE;
[432] Fix | Delete
if(!$this->_readmsg("abort")) return FALSE;
[433] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[434] Fix | Delete
}
[435] Fix | Delete
return true;
[436] Fix | Delete
}
[437] Fix | Delete
[438] Fix | Delete
function mdtm($pathname) {
[439] Fix | Delete
if(!isset($this->_features["MDTM"])) {
[440] Fix | Delete
$this->PushError("mdtm", "not supported by server");
[441] Fix | Delete
return FALSE;
[442] Fix | Delete
}
[443] Fix | Delete
if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE;
[444] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[445] Fix | Delete
$mdtm = preg_replace("/^[0-9]{3} ([0-9]+).*$/s", "\\1", $this->_message);
[446] Fix | Delete
$date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d");
[447] Fix | Delete
$timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]);
[448] Fix | Delete
return $timestamp;
[449] Fix | Delete
}
[450] Fix | Delete
[451] Fix | Delete
function systype() {
[452] Fix | Delete
if(!$this->_exec("SYST", "systype")) return FALSE;
[453] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[454] Fix | Delete
$DATA = explode(" ", $this->_message);
[455] Fix | Delete
return array($DATA[1], $DATA[3]);
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
function delete($pathname) {
[459] Fix | Delete
if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE;
[460] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[461] Fix | Delete
return TRUE;
[462] Fix | Delete
}
[463] Fix | Delete
[464] Fix | Delete
function site($command, $fnction="site") {
[465] Fix | Delete
if(!$this->_exec("SITE ".$command, $fnction)) return FALSE;
[466] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[467] Fix | Delete
return TRUE;
[468] Fix | Delete
}
[469] Fix | Delete
[470] Fix | Delete
function chmod($pathname, $mode) {
[471] Fix | Delete
if(!$this->site( sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE;
[472] Fix | Delete
return TRUE;
[473] Fix | Delete
}
[474] Fix | Delete
[475] Fix | Delete
function restore($from) {
[476] Fix | Delete
if(!isset($this->_features["REST"])) {
[477] Fix | Delete
$this->PushError("restore", "not supported by server");
[478] Fix | Delete
return FALSE;
[479] Fix | Delete
}
[480] Fix | Delete
if($this->_curtype!=FTP_BINARY) {
[481] Fix | Delete
$this->PushError("restore", "can't restore in ASCII mode");
[482] Fix | Delete
return FALSE;
[483] Fix | Delete
}
[484] Fix | Delete
if(!$this->_exec("REST ".$from, "resore")) return FALSE;
[485] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[486] Fix | Delete
return TRUE;
[487] Fix | Delete
}
[488] Fix | Delete
[489] Fix | Delete
function features() {
[490] Fix | Delete
if(!$this->_exec("FEAT", "features")) return FALSE;
[491] Fix | Delete
if(!$this->_checkCode()) return FALSE;
[492] Fix | Delete
$f=preg_split("/[".CRLF."]+/", preg_replace("/[0-9]{3}[ -].*[".CRLF."]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY);
[493] Fix | Delete
$this->_features=array();
[494] Fix | Delete
foreach($f as $k=>$v) {
[495] Fix | Delete
$v=explode(" ", trim($v));
[496] Fix | Delete
$this->_features[array_shift($v)]=$v;
[497] Fix | Delete
}
[498] Fix | Delete
return true;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function