| Current Path : /proc/thread-self/root/proc/thread-self/root/proc/1908984/root/proc/2411249/cwd/ |
| Current File : //proc/thread-self/root/proc/thread-self/root/proc/1908984/root/proc/2411249/cwd/Filesystem.php.tar |
home/digilove/public_html/110/libraries/fof40/Platform/Base/Filesystem.php 0000644 00000004511 15241316447 0022276 0 ustar 00 <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace FOF40\Platform\Base;
defined('_JEXEC') || die;
use FOF40\Container\Container;
use FOF40\Platform\FilesystemInterface;
abstract class Filesystem implements FilesystemInterface
{
/**
* The list of paths where platform class files will be looked for
*
* @var array
*/
protected static $paths = [];
/** @var Container The component container */
protected $container;
/**
* Public constructor.
*
* @param \FOF40\Container\Container $c The component container
*/
public function __construct(Container $c)
{
$this->container = $c;
}
/**
* Recursive function that will scan every directory unless it's in the ignore list. Files that aren't in the
* ignore list are returned.
*
* @param string $path Folder where we should start looking
* @param array $ignoreFolders Folder ignore list
* @param array $ignoreFiles File ignore list
*
* @return array List of all the files
*/
protected static function scanDirectory(string $path, array $ignoreFolders = [], array $ignoreFiles = []): array
{
$return = [];
$handle = @opendir($path);
if (!$handle)
{
return $return;
}
while (($file = readdir($handle)) !== false)
{
if ($file == '.' || $file == '..')
{
continue;
}
$fullpath = $path . '/' . $file;
if ((is_dir($fullpath) && in_array($file, $ignoreFolders)) || (is_file($fullpath) && in_array($file, $ignoreFiles)))
{
continue;
}
if (is_dir($fullpath))
{
$return = array_merge(self::scanDirectory($fullpath, $ignoreFolders, $ignoreFiles), $return);
}
else
{
$return[] = $path . '/' . $file;
}
}
return $return;
}
/**
* Gets the extension of a file name
*
* @param string $file The file name
*
* @return string The file extension
*/
public function getExt(string $file): string
{
$dot = strrpos($file, '.') + 1;
return substr($file, $dot);
}
/**
* Strips the last extension off of a file name
*
* @param string $file The file name
*
* @return string The file name without the extension
*/
public function stripExt(string $file): string
{
return preg_replace('#\.[^.]*$#', '', $file);
}
}
home/digilove/public_html/libraries/fof30/Platform/Base/Filesystem.php 0000644 00000007152 15242265456 0022004 0 ustar 00 <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2019 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU GPL version 2 or later
*/
namespace FOF30\Platform\Base;
use FOF30\Container\Container;
use FOF30\Platform\FilesystemInterface;
defined('_JEXEC') or die;
abstract class Filesystem implements FilesystemInterface
{
/** @var Container The component container */
protected $container = null;
/**
* Public constructor.
*
* @param \FOF30\Container\Container $c The component container
*/
public function __construct(Container $c)
{
$this->container = $c;
}
/**
* The list of paths where platform class files will be looked for
*
* @var array
*/
protected static $paths = array();
/**
* This method will crawl a starting directory and get all the valid files that will be analyzed by getInstance.
* Then it organizes them into an associative array.
*
* @param string $path Folder where we should start looking
* @param array $ignoreFolders Folder ignore list
* @param array $ignoreFiles File ignore list
*
* @return array Associative array, where the `fullpath` key contains the path to the file,
* and the `classname` key contains the name of the class
*/
protected static function getFiles($path, array $ignoreFolders = array(), array $ignoreFiles = array())
{
$return = array();
$files = self::scanDirectory($path, $ignoreFolders, $ignoreFiles);
// Ok, I got the files, now I have to organize them
foreach($files as $file)
{
$clean = str_replace($path, '', $file);
$clean = trim(str_replace('\\', '/', $clean), '/');
$parts = explode('/', $clean);
// If I have less than 3 fragments, it means that the file was inside the generic folder
// (interface + abstract) so I have to skip it
if(count($parts) < 3)
{
continue;
}
$return[] = array(
'fullpath' => $file,
'classname' => 'F0FPlatform'.ucfirst($parts[0]).ucfirst(basename($parts[1], '.php'))
);
}
return $return;
}
/**
* Recursive function that will scan every directory unless it's in the ignore list. Files that aren't in the
* ignore list are returned.
*
* @param string $path Folder where we should start looking
* @param array $ignoreFolders Folder ignore list
* @param array $ignoreFiles File ignore list
*
* @return array List of all the files
*/
protected static function scanDirectory($path, array $ignoreFolders = array(), array $ignoreFiles = array())
{
$return = array();
$handle = @opendir($path);
if(!$handle)
{
return $return;
}
while (($file = readdir($handle)) !== false)
{
if($file == '.' || $file == '..')
{
continue;
}
$fullpath = $path . '/' . $file;
if((is_dir($fullpath) && in_array($file, $ignoreFolders)) || (is_file($fullpath) && in_array($file, $ignoreFiles)))
{
continue;
}
if(is_dir($fullpath))
{
$return = array_merge(self::scanDirectory($fullpath, $ignoreFolders, $ignoreFiles), $return);
}
else
{
$return[] = $path . '/' . $file;
}
}
return $return;
}
/**
* Gets the extension of a file name
*
* @param string $file The file name
*
* @return string The file extension
*/
public function getExt($file)
{
$dot = strrpos($file, '.') + 1;
return substr($file, $dot);
}
/**
* Strips the last extension off of a file name
*
* @param string $file The file name
*
* @return string The file name without the extension
*/
public function stripExt($file)
{
return preg_replace('#\.[^.]*$#', '', $file);
}
}
home/digilove/public_html/110/libraries/fof40/Platform/Joomla/Filesystem.php 0000644 00000015403 15242631204 0022637 0 ustar 00 <?php
/**
* @package FOF
* @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace FOF40\Platform\Joomla;
defined('_JEXEC') || die;
use FOF40\Platform\Base\Filesystem as BaseFilesystem;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\Path;
/**
* Abstraction for Joomla! filesystem API
*/
class Filesystem extends BaseFilesystem
{
/**
* Does the file exists?
*
* @param $path string Path to the file to test
*
* @return bool
*/
public function fileExists(string $path): bool
{
return File::exists($path);
}
/**
* Delete a file or array of files
*
* @param mixed $file The file name or an array of file names
*
* @return bool True on success
*
*/
public function fileDelete($file): bool
{
if (!is_string($file) && !is_array($file))
{
throw new \InvalidArgumentException(sprintf('%s::%s -- $file expects a string or an array', __CLASS__, __METHOD__));
}
return File::delete($file);
}
/**
* Copies a file
*
* @param string $src The path to the source file
* @param string $dest The path to the destination file
* @param string $path An optional base path to prefix to the file names
* @param bool $use_streams True to use streams
*
* @return bool True on success
*/
public function fileCopy(string $src, string $dest, ?string $path = null, bool $use_streams = false): bool
{
return File::copy($src, $dest, $path, $use_streams);
}
/**
* Write contents to a file
*
* @param string $file The full file path
* @param string &$buffer The buffer to write
* @param bool $use_streams Use streams
*
* @return bool True on success
*/
public function fileWrite(string $file, string &$buffer, bool $use_streams = false): bool
{
return File::write($file, $buffer, $use_streams);
}
/**
* Checks for snooping outside of the file system root.
*
* @param string $path A file system path to check.
*
* @return string A cleaned version of the path or exit on error.
*
* @throws \Exception
*/
public function pathCheck(string $path): string
{
return Path::check($path);
}
/**
* Function to strip additional / or \ in a path name.
*
* @param string $path The path to clean.
* @param string $ds Directory separator (optional).
*
* @return string The cleaned path.
*
* @throws \UnexpectedValueException
*/
public function pathClean(string $path, string $ds = DIRECTORY_SEPARATOR): string
{
return Path::clean($path, $ds);
}
/**
* Searches the directory paths for a given file.
*
* @param mixed $paths An path string or array of path strings to search in
* @param string $file The file name to look for.
*
* @return string|null The full path and file name for the target file, or bool false if the file is not found
* in any of the paths.
*/
public function pathFind($paths, string $file): ?string
{
if (!is_string($paths) && !is_array($paths))
{
throw new \InvalidArgumentException(sprintf('%s::%s -- $paths expects a string or an array', __CLASS__, __METHOD__));
}
$ret = Path::find($paths, $file);
if (($ret === false) || ($ret === ''))
{
return null;
}
return $ret;
}
/**
* Wrapper for the standard file_exists function
*
* @param string $path Folder name relative to installation dir
*
* @return bool True if path is a folder
*/
public function folderExists(string $path): bool
{
try
{
return Folder::exists($path);
}
catch (\Exception $e)
{
return false;
}
}
/**
* Utility function to read the files in a folder.
*
* @param string $path The path of the folder to read.
* @param string $filter A filter for file names.
* @param mixed $recurse True to recursively search into sub-folders, or an integer to specify the
* maximum depth.
* @param bool $full True to return the full path to the file.
* @param array $exclude Array with names of files which should not be shown in the result.
* @param array $excludefilter Array of filter to exclude
* @param bool $naturalSort False for asort, true for natsort
* @param bool $naturalSort False for asort, true for natsort
*
* @return array Files in the given folder.
*/
public function folderFiles(string $path, string $filter = '.', bool $recurse = false, bool $full = false,
array $exclude = [
'.svn', 'CVS', '.DS_Store', '__MACOSX',
], array $excludefilter = ['^\..*', '.*~'], bool $naturalSort = false): array
{
// JFolder throws nonsense errors if the path is not a folder
try
{
$path = Path::clean($path);
}
catch (\Exception $e)
{
return [];
}
if (!@is_dir($path))
{
return [];
}
// Now call JFolder
return Folder::files($path, $filter, $recurse, $full, $exclude, $excludefilter, $naturalSort);
}
/**
* Utility function to read the folders in a folder.
*
* @param string $path The path of the folder to read.
* @param string $filter A filter for folder names.
* @param mixed $recurse True to recursively search into sub-folders, or an integer to specify the
* maximum depth.
* @param bool $full True to return the full path to the folders.
* @param array $exclude Array with names of folders which should not be shown in the result.
* @param array $excludefilter Array with regular expressions matching folders which should not be shown in
* the result.
*
* @return array Folders in the given folder.
*/
public function folderFolders(string $path, string $filter = '.', bool $recurse = false, bool $full = false, array $exclude = [
'.svn', 'CVS', '.DS_Store', '__MACOSX',
], array $excludefilter = ['^\..*']): array
{
// JFolder throws idiotic errors if the path is not a folder
try
{
$path = Path::clean($path);
}
catch (\Exception $e)
{
return [];
}
if (!@is_dir($path))
{
return [];
}
// Now call JFolder
return Folder::folders($path, $filter, $recurse, $full, $exclude, $excludefilter);
}
/**
* Create a folder -- and all necessary parent folders.
*
* @param string $path A path to create from the base path.
* @param integer $mode Directory permissions to set for folders created. 0755 by default.
*
* @return bool True if successful.
*/
public function folderCreate(string $path = '', int $mode = 0755): bool
{
return Folder::create($path, $mode);
}
}