This page lists files in the current directory. You can view content, get download/execute commands for Wget, Curl, or PowerShell, or filter the list using wildcards (e.g., `*.sh`).
wget 'https://sme10.lists2.roe3.org/kodbox/plugins/storeImport/lib/Driver.class.php'
<?php
class impDriver {
protected $ioList = array(
'sg' => array('local','oss','qiniu','uss'), // ftp暂不考虑支持
's3' => array('s3','bos','cos','eds','eos','jos','minio','obs','oos','moss','nos')
);
public function __construct($store) {
if ($this->driver) return;
$type = strtolower($store['driver']);
$typeList = $GLOBALS['config']['settings']['ioClassList'];
$sfxType = (isset($typeList[$type]) ? $typeList[$type] : ucfirst($type));
// 基础类是否存在
$class = 'PathDriver'.$sfxType;
if( !class_exists($class) ){
throw new Exception(LNG('storeImport.main.ioNotSup').$class);
}
// 独立子类、S3系子类
if (in_array($type, $this->ioList['sg'])) {
include_once(__DIR__.'/Driver'.$sfxType.'.class.php'); // DriverOSS.class.php
$class = 'impDrv'.$sfxType;
} else if (in_array($type, $this->ioList['s3'])) {
include_once(__DIR__.'/DriverS3.class.php');
$class = 'impDrvS3';
}
if( !class_exists($class) ){
throw new Exception(LNG('storeImport.main.ioNotSup').$class);
}
// 自定义子类是否存在
$config = $store['config'];
$this->driver = new $class($config, $sfxType);
}
/**
* 获取内部地址;外部地址转内部地址
*/
public function getPathInner($path) {
return $this->driver->getPathInner($path);
}
/**
* 内部地址转外部地址
*/
public function getPathOuter($path) {
return $this->driver->getPathOuter($path);
}
/**
* 获取文件列表
* @param [type] $path
* @return void yield [[path,size],...]
*/
public function listAll($path){
$path = $this->getPathInner($path); // {io:xx}/abc/ => /xx/abc/
return $this->driver->listAll($path);
}
}
wget 'https://sme10.lists2.roe3.org/kodbox/plugins/storeImport/lib/DriverLocal.class.php'
<?php
/**
* 本地存储拓展方法
*/
class impDrvLocal extends PathDriverLocal {
public function __construct($config, $type='') {
parent::__construct($config);
}
/**
* 获取指定目录下所有列表,返回生成器
* @param [type] $path
* @return void
*/
public function listAll($path, &$result = array()) {
$path = $this->iconvSystem($path);
$path = rtrim($path,'/').'/';
// readdir依次读取,无法阶段性获取(当前目录下的)文件总数,故改用scandir
$entries = scandir($path);
$list = array_filter($entries, function($entry) use ($path) {
return $entry != "." && $entry != "..";
});
// (当前)文件总数
$GLOBALS['STORE_IMPORT_FILE_CNT'] += count($list);
foreach ($list as $file) {
$fullpath = $path.$file;
$isFolder = (is_dir($fullpath) && !is_link($fullpath)) ? 1:0;
$fullpath = $isFolder ? $fullpath.'/' : $fullpath;
$time = intval(@filemtime($fullpath));
$size = $isFolder ? 0 : intval($this->size($fullpath));
yield array(
'path' => $fullpath,
'folder' => $isFolder,
'modifyTime'=> $time,
'size' => $size,
);
if($isFolder){
// 递归返回的是一个子生成器对象,需要显式地迭代其结果并yeild给父生成器
foreach ($this->listAll($fullpath, $result) as $subItem) {
yield $subItem;
}
}
}
unset($list);
}
}
wget 'https://sme10.lists2.roe3.org/kodbox/plugins/storeImport/lib/DriverOSS.class.php'
<?php
// OSS
class impDrvOSS extends PathDriverOSS {
public function __construct($config, $type='') {
parent::__construct($config);
}
/**
* 获取指定目录下所有列表,返回生成器
* @param [type] $path
* @return void
*/
public function listAll($path){
$path = trim($path, '/');
$prefix = (empty($path) && $path !== '0') ? '' : $path . '/'; // 需要加上/,才能找到该目录,根目录为空
$nextMarker = '';
$maxkeys = 1000;
$folderList = $fileList = array();
while (true) {
// check_abort();
$options = array(
'delimiter' => '',
'prefix' => $prefix,
'max-keys' => $maxkeys,
'marker' => $nextMarker,
);
try {
$listObjectInfo = $this->client->listObjects($this->bucket, $options);
} catch (OSS\Core\OssException $e) {
$this->writeLog(__FUNCTION__.'|'.$e->getMessage());
break;
}
$nextMarker = $listObjectInfo->getNextMarker();
$listObject = $listObjectInfo->getObjectList(); // 文件列表
// (当前)文件总数
$GLOBALS['STORE_IMPORT_FILE_CNT'] += count($listObject);
foreach ($listObject as $objectInfo) {
if ($objectInfo->getKey() == $prefix) { continue;} // 包含一条文件夹自身的数据
$name = $objectInfo->getKey();
$size = $objectInfo->getSize();
$time = strtotime($objectInfo->getLastModified());
$isFolder = ($size == 0 && substr($name,strlen($name) - 1,1) == '/') ? 1 : 0;
yield array(
'path' => $name,
'folder' => $isFolder,
'modifyTime'=> $time,
'size' => $size,
);
}
if ($nextMarker === '') {break;}
}
}
}
wget 'https://sme10.lists2.roe3.org/kodbox/plugins/storeImport/lib/DriverQiniu.class.php'
<?php
// Qiniu
class impDrvQiniu extends PathDriverQiniu {
public function __construct($config, $type='') {
parent::__construct($config);
}
/**
* 获取指定目录下所有列表,返回生成器
* @param [type] $path
* @return void
*/
public function listAll($path){
$path = trim($path, '/');
$prefix = (empty($path) && $path !== '0') ? '' : $path . '/'; // 要列举文件的公共前缀(父目录);首位没有'/',否则获取为空
$marker = ''; // 上次列举返回的位置标记,作为本次列举的起点信息。
$limit = 1000; // 本次列举的条目数
$delimiter = '';
while (true) {
// check_abort();
// 列举文件,获取目录下的文件,末尾需加"/",不加则只获取目录本身
list($ret, $err) = $this->bucketManager->listFiles($this->bucket, $prefix, $marker, $limit, $delimiter);
if ($err) break;
$marker = array_key_exists('marker', $ret) ? $marker = $ret["marker"] : '';
$listObject = _get($ret, 'items', array()); // 文件列表
$listPrefix = _get($ret, 'commonPrefixes', array()); // 文件夹列表,$delimiter=/时存在该字段
// (当前)文件总数
$GLOBALS['STORE_IMPORT_FILE_CNT'] += count($listObject);
foreach ($listObject as $item) {
if ($item['key'] == $prefix) { continue;}
$name = $item['key'];
$size = $item['fsize'];
$time = !empty($item['putTime']) ? substr($item['putTime'].'',0,10) : 0;
$isFolder = ($size == 0 && substr($name,strlen($name) - 1,1) == '/') ? 1:0;
yield array(
'path' => $name,
'folder' => $isFolder,
'modifyTime'=> $time,
'size' => $size,
);
}
foreach ($listPrefix as $name) {
if ($name == $prefix) { continue;}
yield array(
'path' => $name,
'folder' => 1,
'modifyTime'=> 0,
'size' => 0,
);
}
if ($marker === '') {break;}
}
}
}
wget 'https://sme10.lists2.roe3.org/kodbox/plugins/storeImport/lib/DriverS3.class.php'
<?php
/**
* S3系存储拓展方法——有新增s3系存储时在Driver.ioList.s3数组中追加
*/
class impDrvS3 {
private $instance;
public function __construct($config, $type) {
$className = 'PathDriver'.$type; // PathDriverEOS
// 动态实例化传入的子类并传递参数
if (class_exists($className)) {
$this->instance = new $className($config);
} else {
throw new Exception("Class $className not found.");
}
}
// 动态调用子类的方法
public function __call($method, $arguments) {
if (method_exists($this->instance, $method)) {
return call_user_func_array([$this->instance, $method], $arguments);
} else {
throw new Exception("Method $method not found in " . get_class($this->instance));
}
}
/**
* 获取指定目录下所有列表,返回生成器
* @param [type] $path
* @return void
*/
public function listAll($path){
$client = $this->getProtMember('client');
$bucket = $this->getProtMember('bucket');
$path = trim($path, '/');
$prefix = (empty($path) && $path !== '0') ? '' : $path . '/'; // 要列举文件的公共前缀
$nextMarker = null; // 上次列举返回的位置标记(文件key),作为本次列举的起点信息。
$maxKey = 1000;
$delimiter = '';
$hasFile = $hasFolder = array();
while (true) {
$result = $client->getBucket($bucket, $prefix, $nextMarker, $maxKey, $delimiter, true);
if (!$result) break;
$nextMarker = $result['nextMarker'];
$listObject = $result['listObject'];
$listPrefix = $result['listPrefix'];
// (当前)文件总数
$GLOBALS['STORE_IMPORT_FILE_CNT'] += count($listObject);
foreach ($listObject as $objectInfo) {
$name = $objectInfo['name'];
if ($name == $prefix) { continue;} // 包含一条文件夹自身的数据
$time = _get($objectInfo, 'time', 0);
$size = _get($objectInfo, 'size', 0);
$isFolder = ($size == 0 && substr($name,strlen($name) - 1,1) == '/') ? 1:0;
yield array(
'path' => $name,
'folder' => $isFolder,
'modifyTime'=> $time,
'size' => $size,
);
}
foreach ($listPrefix as $objectInfo) {
yield array(
'path' => $objectInfo['name'],
'folder' => 1,
'modifyTime'=> 0,
'size' => 0,
);
}
if ($nextMarker === null) { break; }
}
}
// 使用反射获取protected属性/方法
private function getProtMember($name) {
$reflectionClass = new ReflectionClass($this->instance);
// 先尝试获取属性
if ($reflectionClass->hasProperty($name)) {
$property = $reflectionClass->getProperty($name);
$property->setAccessible(true);
return $property->getValue($this->instance);
}
// 如果属性不存在,尝试调用方法
if ($reflectionClass->hasMethod($name)) {
$args = func_get_args(); // 获取所有传入的参数
array_shift($args);
$method = $reflectionClass->getMethod($name);
$method->setAccessible(true);
// $method->invoke($this->instance, $param);
return call_user_func_array([$method, 'invoke'], array_merge([$this->instance], $args));
}
throw new Exception("Property or method $name not found in " . get_class($this->instance));
}
}
wget 'https://sme10.lists2.roe3.org/kodbox/plugins/storeImport/lib/DriverUSS.class.php'
<?php
// USS
class impDrvUSS extends PathDriverUSS {
public function __construct($config, $type='') {
parent::__construct($config);
}
/**
* 获取指定目录下所有列表,返回生成器
* @param [type] $path
* @return void
*/
public function listAll($path){
$path = rtrim($path,'/').'/';
$start = '';
$limit = 1000;
while (true) {
// check_abort();
$headers = array(
'Accept: application/json',
'x-list-limit: ' . $limit, // 默认100,最大10000
);
if($start) $headers[] = 'x-list-iter: ' . $start; // 为g2gCZAAEbmV4dGQAA2VvZg时,表示最后一个分页
$res = $this->ussRequest($path, 'GET', false, $headers);
if (!$res['code']) break;
$start = _get($res, 'data.iter', '');
$files = _get($res, 'data.files', array());
// (当前)文件总数
$GLOBALS['STORE_IMPORT_FILE_CNT'] += count($files);
foreach($files as $item) {
$fullpath = $path.$item['name'];
$isFolder = $item['type'] == 'folder' ? 1 : 0;
$fullpath = $isFolder ? $fullpath.'/' : $fullpath;
$time = intval($item['last_modified']);
$size = intval($item['length']);
yield array(
'path' => $fullpath,
'folder' => $isFolder,
'modifyTime'=> $time,
'size' => $size,
);
if ($isFolder) {
foreach ($this->listAll($fullpath) as $subItem) {
yield $subItem;
}
}
}
if(count($files) < $limit) break;
}
}
}