18 $this->_sHost = $sHost;
19 $this->_sLogin = $sLogin;
21 $this->_sPath = $sPath . (
'/' == substr($sPath, -1) ?
'' :
'/');
25 $this->_rStream = ftp_connect($this->_sHost);
26 if($this->_rStream ===
false)
29 return @ftp_login($this->_rStream, $this->_sLogin, $this->_sPassword);
33 return @ftp_size($this->_rStream, $this->_sPath .
'inc/header.inc.php') > 0;
35 function copy($sFilePathFrom, $sFilePathTo)
37 $sFilePathTo = $this->_sPath . $sFilePathTo;
38 return $this->
_copyFile($sFilePathFrom, $sFilePathTo);
40 function delete($sPath)
42 $sPath = $this->_sPath . $sPath;
47 $sPath = $this->_sPath . $sPath;
53 if(substr($sFilePathFrom, -1) ==
'*')
54 $sFilePathFrom = substr($sFilePathFrom, 0, -1);
56 if (is_file($sFilePathFrom)) {
57 if ($this->
_isFile($sFilePathTo)) {
59 if (isset($aFileParts[0])) {
62 $bResult = @ftp_put($this->_rStream, $sFilePathTo, $sFilePathFrom, FTP_BINARY);
65 $aFileParts = $this->
_parseFile($sFilePathFrom);
66 if (isset($aFileParts[1])) {
67 $bResult = @ftp_put($this->_rStream, $this->
_validatePath($sFilePathTo) . $aFileParts[1], $sFilePathFrom, FTP_BINARY);
70 }
else if(is_dir($sFilePathFrom) && $this->
_isDirectory($sFilePathTo)) {
83 if(!is_dir($sFilePath) || !($rSource = opendir($sFilePath)))
return false;
86 while((
$sFile = readdir($rSource)) !==
false) {
97 if (substr($sPath, -1) !=
'/')
100 if (($aFiles = @ftp_nlist($this->_rStream, $sPath)) !==
false)
105 if (!@ftp_rmdir($this->_rStream, $sPath))
108 }
else if (!@ftp_delete($this->_rStream, $sPath)) {
115 if($sPath && substr($sPath, -1) !=
'/' && $this->
_isDirectory($sPath))
123 preg_match(
"/^([a-zA-Z0-9@~_\.\\\\\/:-]+[\\\\\/])([a-zA-Z0-9~_-]+\.[a-zA-Z]{2,8})$/", $sFilePath, $aParts) ?
true :
false;
124 return count($aParts) > 1 ? array_slice($aParts, 1) :
false;
128 return preg_match(
"/^([a-zA-Z0-9@~_\.\\\\\/:-]+)\.([a-zA-Z]){2,8}$/", $sFilePath) ?
true :
false;
132 return preg_match(
"/^([a-zA-Z0-9@~_\.\\\\\/:-]+)[\\\\\/]([a-zA-Z0-9~_-]+)[\\\\\/]?$/", $sFilePath) ?
true :
false;
137 'writable' => $this->
_isDirectory($sPath) ? 0777 : 0666,
141 if(@ftp_chmod($this->_rStream, $aConvert[
$sMode], $sPath) ===
false)
148 $sPwd = ftp_pwd ($this->_rStream);
149 $aParts = explode(
"/", $sPath);
151 if (
'/' == $sPath[0]) {
153 ftp_chdir($this->_rStream,
'/');
155 foreach ($aParts
as $sPart) {
158 $sPathFull .= $sPart;
159 if (
'..' == $sPart) {
160 @ftp_cdup($this->_rStream);
161 } elseif (!@ftp_chdir($this->_rStream, $sPart)) {
162 if (!@ftp_mkdir($this->_rStream, $sPart)) {
163 ftp_chdir($this->_rStream,
$sPwd);
166 @ftp_chdir($this->_rStream, $sPart);
170 ftp_chdir($this->_rStream,
$sPwd);