mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
Draft more ftp functions
This commit is contained in:
parent
0cc736b0ff
commit
2538587ecb
|
|
@ -19,6 +19,8 @@ use phpOMS\System\File\ContainerInterface;
|
|||
use phpOMS\System\File\DirectoryInterface;
|
||||
use phpOMS\System\File\Local\FileAbstract;
|
||||
use phpOMS\System\File\Local\Directory as DirectoryLocal;
|
||||
use phpOMS\System\File\Local\File as LocalFile;
|
||||
use phpOMS\Uri\Http;
|
||||
|
||||
/**
|
||||
* Filesystem class.
|
||||
|
|
@ -34,6 +36,37 @@ use phpOMS\System\File\Local\Directory as DirectoryLocal;
|
|||
*/
|
||||
class Directory extends FileAbstract implements DirectoryInterface
|
||||
{
|
||||
public static function ftpConnect(Http $http)
|
||||
{
|
||||
$con = ftp_connect($http->getBase() . $http->getPath(), $http->getPort());
|
||||
|
||||
ftp_login($con, $http->getUser(), $http->getPass());
|
||||
ftp_chdir($con, $http->getPath()); // todo: is this required ?
|
||||
|
||||
return $con;
|
||||
}
|
||||
|
||||
public static function ftpExists($con, string $path)
|
||||
{
|
||||
$list = ftp_nlist($con, LocalFile::parent($path));
|
||||
|
||||
return in_array(LocalFile::name($path), $list);
|
||||
}
|
||||
|
||||
public static function ftpCreate($con, string $path, int $permission, bool $recursive)
|
||||
{
|
||||
$parts = explode('/', $path);
|
||||
ftp_chdir($con, '/' . $parts[0]);
|
||||
|
||||
foreach ($parts as $part) {
|
||||
if (self::ftpExists($con, $part)) {
|
||||
ftp_mkdir($con, $part);
|
||||
ftp_chdir($con, $part);
|
||||
ftp_chmod($con, $permission, $part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Directory nodes (files and directories).
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ use phpOMS\System\File\ContainerInterface;
|
|||
use phpOMS\System\File\ContentPutMode;
|
||||
use phpOMS\System\File\FileInterface;
|
||||
use phpOMS\System\File\PathException;
|
||||
use phpOMS\System\File\Local\File as FileLocal;
|
||||
use phpOMS\System\File\Local\FileAbstract;
|
||||
use phpOMS\System\File\Local\Directory as LocalDirectory;
|
||||
use phpOMS\System\File\Local\File as LocalFile;
|
||||
|
|
@ -279,7 +278,7 @@ class File extends FileAbstract implements FileInterface
|
|||
*/
|
||||
public static function dirname(string $path) : string
|
||||
{
|
||||
return FileLocal::dirname($path);
|
||||
return LocalFile::dirname($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -293,7 +292,7 @@ class File extends FileAbstract implements FileInterface
|
|||
*/
|
||||
public static function dirpath(string $path) : string
|
||||
{
|
||||
return FileLocal::dirpath($path);
|
||||
return LocalFile::dirpath($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -370,7 +369,7 @@ class File extends FileAbstract implements FileInterface
|
|||
*/
|
||||
public static function name(string $path) : string
|
||||
{
|
||||
return FileLocal::name($path);
|
||||
return LocalFile::name($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -378,7 +377,7 @@ class File extends FileAbstract implements FileInterface
|
|||
*/
|
||||
public static function basename(string $path) : string
|
||||
{
|
||||
return FileLocal::basename($path);
|
||||
return LocalFile::basename($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -386,7 +385,7 @@ class File extends FileAbstract implements FileInterface
|
|||
*/
|
||||
public static function extension(string $path) : string
|
||||
{
|
||||
return FileLocal::extension($path);
|
||||
return LocalFile::extension($path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user