编辑器图片上传问题

This commit is contained in:
2016-12-21 17:38:54 +08:00
parent 88c9a28681
commit 00b861e34f
2 changed files with 274 additions and 276 deletions

View File

@@ -9,7 +9,7 @@
"imageCompressBorder": 1600, /* */ "imageCompressBorder": 1600, /* */
"imageInsertAlign": "none", /* */ "imageInsertAlign": "none", /* */
"imageUrlPrefix": "", /* 访 */ "imageUrlPrefix": "", /* 访 */
"imagePathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* , */ "imagePathFormat": "./uploads/editor/image", /* , */
/* {filename} , */ /* {filename} , */
/* {rand:6} , */ /* {rand:6} , */
/* {time} */ /* {time} */
@@ -26,14 +26,14 @@
/* 涂鸦图片上传配置项 */ /* 涂鸦图片上传配置项 */
"scrawlActionName": "uploadscrawl", /* 执行上传涂鸦的action名称 */ "scrawlActionName": "uploadscrawl", /* 执行上传涂鸦的action名称 */
"scrawlFieldName": "upfile", /* 提交的图片表单名称 */ "scrawlFieldName": "upfile", /* 提交的图片表单名称 */
"scrawlPathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ "scrawlPathFormat": "./uploads/editor/image", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"scrawlMaxSize": 2048000, /* 上传大小限制单位B */ "scrawlMaxSize": 2048000, /* 上传大小限制单位B */
"scrawlUrlPrefix": "", /* 图片访问路径前缀 */ "scrawlUrlPrefix": "", /* 图片访问路径前缀 */
"scrawlInsertAlign": "none", "scrawlInsertAlign": "none",
/* 截图工具上传 */ /* 截图工具上传 */
"snapscreenActionName": "uploadimage", /* 执行上传截图的action名称 */ "snapscreenActionName": "uploadimage", /* 执行上传截图的action名称 */
"snapscreenPathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ "snapscreenPathFormat": "./uploads/editor/image", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"snapscreenUrlPrefix": "", /* 图片访问路径前缀 */ "snapscreenUrlPrefix": "", /* 图片访问路径前缀 */
"snapscreenInsertAlign": "none", /* 插入的图片浮动方式 */ "snapscreenInsertAlign": "none", /* 插入的图片浮动方式 */
@@ -41,7 +41,7 @@
"catcherLocalDomain": ["127.0.0.1", "localhost", "img.baidu.com"], "catcherLocalDomain": ["127.0.0.1", "localhost", "img.baidu.com"],
"catcherActionName": "catchimage", /* 执行抓取远程图片的action名称 */ "catcherActionName": "catchimage", /* 执行抓取远程图片的action名称 */
"catcherFieldName": "source", /* 提交的图片列表表单名称 */ "catcherFieldName": "source", /* 提交的图片列表表单名称 */
"catcherPathFormat": "/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ "catcherPathFormat": "./uploads/editor/image", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"catcherUrlPrefix": "", /* 图片访问路径前缀 */ "catcherUrlPrefix": "", /* 图片访问路径前缀 */
"catcherMaxSize": 2048000, /* 上传大小限制单位B */ "catcherMaxSize": 2048000, /* 上传大小限制单位B */
"catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 抓取图片格式显示 */ "catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 抓取图片格式显示 */
@@ -49,7 +49,7 @@
/* 上传视频配置 */ /* 上传视频配置 */
"videoActionName": "uploadvideo", /* 执行上传视频的action名称 */ "videoActionName": "uploadvideo", /* 执行上传视频的action名称 */
"videoFieldName": "upfile", /* 提交的视频表单名称 */ "videoFieldName": "upfile", /* 提交的视频表单名称 */
"videoPathFormat": "/ueditor/php/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ "videoPathFormat": "./uploads/editor/video", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"videoUrlPrefix": "", /* 视频访问路径前缀 */ "videoUrlPrefix": "", /* 视频访问路径前缀 */
"videoMaxSize": 102400000, /* 上传大小限制单位B默认100MB */ "videoMaxSize": 102400000, /* 上传大小限制单位B默认100MB */
"videoAllowFiles": [ "videoAllowFiles": [
@@ -59,7 +59,7 @@
/* 上传文件配置 */ /* 上传文件配置 */
"fileActionName": "uploadfile", /* controller里,执行上传视频的action名称 */ "fileActionName": "uploadfile", /* controller里,执行上传视频的action名称 */
"fileFieldName": "upfile", /* 提交的文件表单名称 */ "fileFieldName": "upfile", /* 提交的文件表单名称 */
"filePathFormat": "/ueditor/php/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */ "filePathFormat": "./uploads/editor/file", /* 上传保存路径,可以自定义保存路径和文件名格式 */
"fileUrlPrefix": "", /* 文件访问路径前缀 */ "fileUrlPrefix": "", /* 文件访问路径前缀 */
"fileMaxSize": 51200000, /* 上传大小限制单位B默认50MB */ "fileMaxSize": 51200000, /* 上传大小限制单位B默认50MB */
"fileAllowFiles": [ "fileAllowFiles": [
@@ -72,7 +72,7 @@
/* 列出指定目录下的图片 */ /* 列出指定目录下的图片 */
"imageManagerActionName": "listimage", /* 执行图片管理的action名称 */ "imageManagerActionName": "listimage", /* 执行图片管理的action名称 */
"imageManagerListPath": "/ueditor/php/upload/image/", /* 指定要列出图片的目录 */ "imageManagerListPath": "./uploads/editor/image/", /* 指定要列出图片的目录 */
"imageManagerListSize": 20, /* 每次列出文件数量 */ "imageManagerListSize": 20, /* 每次列出文件数量 */
"imageManagerUrlPrefix": "", /* 图片访问路径前缀 */ "imageManagerUrlPrefix": "", /* 图片访问路径前缀 */
"imageManagerInsertAlign": "none", /* 插入的图片浮动方式 */ "imageManagerInsertAlign": "none", /* 插入的图片浮动方式 */
@@ -80,7 +80,7 @@
/* 列出指定目录下的文件 */ /* 列出指定目录下的文件 */
"fileManagerActionName": "listfile", /* 执行文件管理的action名称 */ "fileManagerActionName": "listfile", /* 执行文件管理的action名称 */
"fileManagerListPath": "/ueditor/php/upload/file/", /* 指定要列出文件的目录 */ "fileManagerListPath": "./uploads/editor/file/", /* 指定要列出文件的目录 */
"fileManagerUrlPrefix": "", /* 文件访问路径前缀 */ "fileManagerUrlPrefix": "", /* 文件访问路径前缀 */
"fileManagerListSize": 20, /* 每次列出文件数量 */ "fileManagerListSize": 20, /* 每次列出文件数量 */
"fileManagerAllowFiles": [ "fileManagerAllowFiles": [

View File

@@ -6,351 +6,349 @@
namespace com; namespace com;
class Ueditor{ class Ueditor {
public $uid;//要操作的用户id 如有登录需要则去掉注释 public $uid; //要操作的用户id 如有登录需要则去掉注释
private $output;//要输出的数据 private $output; //要输出的数据
private $st; private $st;
private $rootpath = '/uploads'; private $rootpath = '/uploads';
private $config = ''; private $config = '';
public function __construct($uid = ''){ public function __construct($uid = '') {
//uid 为空则导入当前会话uid //uid 为空则导入当前会话uid
if(''===$uid) $this->uid = session('user_auth.uid'); if ('' === $uid) {
$this->uid = session('user_auth.uid');
}
//导入设置 //导入设置
$this->config = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents(APP_PATH."ueditor.json")), true); $this->config = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents(APP_PATH . "ueditor.json")), true);
$action = htmlspecialchars($_GET['action']); $action = htmlspecialchars($_GET['action']);
switch($action){ switch ($action) {
case 'config': case 'config':
$result = json_encode($this->config); $result = json_encode($this->config);
break; break;
case 'uploadimage': case 'uploadimage':
$config = array( $config = array(
"pathFormat" => $this->config['imagePathFormat'], "pathFormat" => $this->config['imagePathFormat'],
"maxSize" => $this->config['imageMaxSize'], "maxSize" => $this->config['imageMaxSize'],
"allowFiles" => $this->config['imageAllowFiles'] "allowFiles" => $this->config['imageAllowFiles'],
); );
$fieldName = $this->config['imageFieldName']; $fieldName = $this->config['imageFieldName'];
$result = $this->uploadFile($config, $fieldName); $result = $this->uploadFile($config, $fieldName);
break; break;
case 'uploadscrawl': case 'uploadscrawl':
$config = array( $config = array(
"pathFormat" => $this->config['scrawlPathFormat'], "pathFormat" => $this->config['scrawlPathFormat'],
"maxSize" => $this->config['scrawlMaxSize'], "maxSize" => $this->config['scrawlMaxSize'],
"allowFiles" => $this->config['scrawlAllowFiles'], "allowFiles" => $this->config['scrawlAllowFiles'],
"oriName" => "scrawl.png" "oriName" => "scrawl.png",
); );
$fieldName = $this->config['scrawlFieldName']; $fieldName = $this->config['scrawlFieldName'];
$result=$this->uploadBase64($config,$fieldName); $result = $this->uploadBase64($config, $fieldName);
break; break;
case 'uploadvideo': case 'uploadvideo':
$config = array( $config = array(
"pathFormat" => $this->config['videoPathFormat'], "pathFormat" => $this->config['videoPathFormat'],
"maxSize" => $this->config['videoMaxSize'], "maxSize" => $this->config['videoMaxSize'],
"allowFiles" => $this->config['videoAllowFiles'] "allowFiles" => $this->config['videoAllowFiles'],
); );
$fieldName = $this->config['videoFieldName']; $fieldName = $this->config['videoFieldName'];
$result=$this->uploadFile($config, $fieldName); $result = $this->uploadFile($config, $fieldName);
break; break;
case 'uploadfile': case 'uploadfile':
// default: // default:
$config = array( $config = array(
"pathFormat" => $this->config['filePathFormat'], "pathFormat" => $this->config['filePathFormat'],
"maxSize" => $this->config['fileMaxSize'], "maxSize" => $this->config['fileMaxSize'],
"allowFiles" => $this->config['fileAllowFiles'] "allowFiles" => $this->config['fileAllowFiles'],
); );
$fieldName = $this->config['fileFieldName']; $fieldName = $this->config['fileFieldName'];
$result=$this->uploadFile($config, $fieldName); $result = $this->uploadFile($config, $fieldName);
break; break;
case 'listfile': case 'listfile':
$config=array( $config = array(
'allowFiles' => $this->config['fileManagerAllowFiles'], 'allowFiles' => $this->config['fileManagerAllowFiles'],
'listSize' => $this->config['fileManagerListSize'], 'listSize' => $this->config['fileManagerListSize'],
'path' => $this->config['fileManagerListPath'], 'path' => $this->config['fileManagerListPath'],
); );
$result = $this->listFile($config); $result = $this->listFile($config);
break; break;
case 'listimage': case 'listimage':
$config=array( $config = array(
'allowFiles' => $this->config['imageManagerAllowFiles'], 'allowFiles' => $this->config['imageManagerAllowFiles'],
'listSize' => $this->config['imageManagerListSize'], 'listSize' => $this->config['imageManagerListSize'],
'path' => $this->config['imageManagerListPath'], 'path' => $this->config['imageManagerListPath'],
); );
$result = $this->listFile($config); $result = $this->listFile($config);
break; break;
case 'catchimage': case 'catchimage':
$config = array( $config = array(
"pathFormat" => $this->config['catcherPathFormat'], "pathFormat" => $this->config['catcherPathFormat'],
"maxSize" => $this->config['catcherMaxSize'], "maxSize" => $this->config['catcherMaxSize'],
"allowFiles" => $this->config['catcherAllowFiles'], "allowFiles" => $this->config['catcherAllowFiles'],
"oriName" => "remote.png" "oriName" => "remote.png",
); );
$fieldName = $this->config['catcherFieldName']; $fieldName = $this->config['catcherFieldName'];
$result = $this->saveRemote($config , $fieldName); $result = $this->saveRemote($config, $fieldName);
break; break;
default: default:
$result = json_encode(array( $result = json_encode(array(
'state'=> 'wrong require' 'state' => 'wrong require',
)); ));
break; break;
} }
if (isset($_GET["callback"])) { if (isset($_GET["callback"])) {
if (preg_match("/^[\w_]+$/", $_GET["callback"])) { if (preg_match("/^[\w_]+$/", $_GET["callback"])) {
$this->output = htmlspecialchars($_GET["callback"]) . '(' . $result . ')'; $this->output = htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
} else { } else {
$this->output = json_encode(array( $this->output = json_encode(array(
'state'=> 'callback参数不合法' 'state' => 'callback参数不合法',
)); ));
} }
} else { } else {
$this->output = $result; $this->output = $result;
} }
} }
/** /**
* *
* 输出结果 * 输出结果
* @param data 数组数据 * @param data 数组数据
* @return 组合后json格式的结果 * @return 组合后json格式的结果
*/ */
public function output(){ public function output() {
return $this->output; return $this->output;
} }
/** /**
* 上传文件方法 * 上传文件方法
* *
*/ */
private function uploadFile($config,$fieldName){ private function uploadFile($config, $fieldName) {
$file = request()->file('upfile');
if (is_array($config['allowFiles'])) {
$upload = new \org\Upload(); $config['allowFiles'] = str_replace('.', '', implode(',', $config['allowFiles']));
$upload->maxSize = $config['maxSize'] ;// 设置附件上传大小
$upload->exts = $this->format_exts($config['allowFiles']);// 设置附件上传类型
$upload->rootPath = '.'.$this->rootpath; // 设置附件上传根目录
$upload->autoSub = false;
$upload->savePath = $this->getFullPath($config['pathFormat']); // 设置附件上传(子)目录
$info=$upload->uploadOne($_FILES[$fieldName]);
$rootpath = $this->rootpath;
if(!$info){
$data = array(
"state"=>$upload -> getError(),
);
}else{ }else{
$config['allowFiles'] = '';
}
$info = $file->validate(array('size'=>$config['maxSize'], 'ext'=>$config['allowFiles']))->move($config['pathFormat'], true, false);
if ($info) {
$data = array( $data = array(
'state' => "SUCCESS", 'state' => "SUCCESS",
'url' => $rootpath . $info['savepath'] . $info['savename'], 'url' => str_replace("\\", '/', substr($info->getPathname(), 1)),
'title' => $info['name'], 'title' => $info->getSaveName(),
'original' => $info['name'], 'original' => $info->getFilename(),
'type' => '.' . $info['ext'], 'type' => '.' . $info->getExtension(),
'size' => $info['size'], 'size' => $info->getSize(),
);
} else {
$data = array(
"state" => $file->getError(),
); );
} }
return json_encode($data); return json_encode($data);
} }
/** /**
* *
* Enter description here ... * Enter description here ...
*/ */
private function uploadBase64($config,$fieldName){ private function uploadBase64($config, $fieldName) {
$data = array(); $data = array();
$base64Data = $_POST[$fieldName]; $base64Data = $_POST[$fieldName];
$img = base64_decode($base64Data); $img = base64_decode($base64Data);
$path = $this->getFullPath($config['pathFormat']); $path = $this->getFullPath($config['pathFormat']);
if(strlen($img)>$config['maxSize']){ if (strlen($img) > $config['maxSize']) {
$data['states'] = 'too large'; $data['states'] = 'too large';
return json_encode($data); return json_encode($data);
} }
$rootpath = $this->rootpath; $rootpath = $this->rootpath;
//替换随机字符串 //替换随机字符串
$imgname = uniqid().'.png'; $imgname = uniqid() . '.png';
$filename = $path.$imgname; $filename = $path . $imgname;
if(\Think\Storage::put($rootpath,$filename,$img)){ if (\Think\Storage::put($rootpath, $filename, $img)) {
$data=array( $data = array(
'state' =>'SUCCESS', 'state' => 'SUCCESS',
'url' => $rootpath . $filename, 'url' => $rootpath . $filename,
'title' =>$imgname, 'title' => $imgname,
'original' =>'scrawl.png', 'original' => 'scrawl.png',
'type' => '.png', 'type' => '.png',
'size' => strlen($img), 'size' => strlen($img),
); );
}else{ } else {
$data=array( $data = array(
'state'=>'cant write', 'state' => 'cant write',
); );
} }
return json_encode($data); return json_encode($data);
} }
/** /**
* 列出文件夹下所有文件,如果是目录则向下 * 列出文件夹下所有文件,如果是目录则向下
*/ */
private function listFile($config){ private function listFile($config) {
$allowFiles = substr(str_replace(".", "|", join("", $config['allowFiles'])), 1); $allowFiles = substr(str_replace(".", "|", join("", $config['allowFiles'])), 1);
$size = isset($_GET['size']) ? htmlspecialchars($_GET['size']) : $config['listSize']; $size = isset($_GET['size']) ? htmlspecialchars($_GET['size']) : $config['listSize'];
$start = isset($_GET['start']) ? htmlspecialchars($_GET['start']) : 0; $start = isset($_GET['start']) ? htmlspecialchars($_GET['start']) : 0;
$end = $start + $size; $end = $start + $size;
$rootpath = $this->rootpath; $rootpath = $this->rootpath;
$path = $config['path']; $path = $config['path'];
$files = \Think\Storage::listFile($rootpath,$path, $allowFiles); $files = \Think\Storage::listFile($rootpath, $path, $allowFiles);
//return $files; //return $files;
if (!count($files)) { if (!count($files)) {
return json_encode(array( return json_encode(array(
"state" => "no match file", "state" => "no match file",
"list" => array(), "list" => array(),
"start" => $start, "start" => $start,
"total" => count($files) "total" => count($files),
)); ));
} }
/* 获取指定范围的列表 */ /* 获取指定范围的列表 */
$len = count($files); $len = count($files);
for ($i = min($end, $len) - 1, $list = array(); $i < $len && $i >= 0 && $i >= $start; $i--){ for ($i = min($end, $len) - 1, $list = array(); $i < $len && $i >= 0 && $i >= $start; $i--) {
$list[] = $files[$i]; $list[] = $files[$i];
} }
//倒序 //倒序
//for ($i = $end, $list = array(); $i < $len && $i < $end; $i++){ //for ($i = $end, $list = array(); $i < $len && $i < $end; $i++){
// $list[] = $files[$i]; // $list[] = $files[$i];
//} //}
/* 返回数据 */ /* 返回数据 */
$result = json_encode(array( $result = json_encode(array(
"state" => "SUCCESS", "state" => "SUCCESS",
"list" => $list, "list" => $list,
"start" => $start, "start" => $start,
"total" => count($files) "total" => count($files),
)); ));
return $result; return $result;
} }
/** /**
* *
* Enter description here ... * Enter description here ...
*/ */
private function saveRemote($config , $fieldName){ private function saveRemote($config, $fieldName) {
$list = array(); $list = array();
if (isset($_POST[$fieldName])) { if (isset($_POST[$fieldName])) {
$source = $_POST[$fieldName]; $source = $_POST[$fieldName];
} else { } else {
$source = $_GET[$fieldName]; $source = $_GET[$fieldName];
} }
foreach ($source as $imgUrl) { foreach ($source as $imgUrl) {
$upload = new \org\Upload(); $upload = new \org\Upload();
$imgUrl = htmlspecialchars($imgUrl); $imgUrl = htmlspecialchars($imgUrl);
$imgUrl = str_replace("&amp;", "&", $imgUrl); $imgUrl = str_replace("&amp;", "&", $imgUrl);
//http开头验证 //http开头验证
if (strpos($imgUrl, "http") !== 0) { if (strpos($imgUrl, "http") !== 0) {
$data = array('state'=>'不是http链接'); $data = array('state' => '不是http链接');
return json_encode($data); return json_encode($data);
} }
//格式验证(扩展名验证和Content-Type验证) //格式验证(扩展名验证和Content-Type验证)
$fileType = strtolower(strrchr($imgUrl, '.')); $fileType = strtolower(strrchr($imgUrl, '.'));
if (!in_array($fileType, $config['allowFiles']) || stristr($heads['Content-Type'], "image")) { if (!in_array($fileType, $config['allowFiles']) || stristr($heads['Content-Type'], "image")) {
$data = array("state"=>"错误文件格式"); $data = array("state" => "错误文件格式");
return json_encode($data); return json_encode($data);
} }
//打开输出缓冲区并获取远程图片 //打开输出缓冲区并获取远程图片
ob_start(); ob_start();
$context = stream_context_create( $context = stream_context_create(
array('http' => array( array('http' => array(
'follow_location' => false // don't follow redirects 'follow_location' => false, // don't follow redirects
)) ))
); );
readfile($imgUrl, false, $context); readfile($imgUrl, false, $context);
$img = ob_get_contents(); $img = ob_get_contents();
ob_end_clean(); ob_end_clean();
preg_match("/[\/]([^\/]*)[\.]?[^\.\/]*$/", $imgUrl, $m); preg_match("/[\/]([^\/]*)[\.]?[^\.\/]*$/", $imgUrl, $m);
$path = $this->getFullPath($config['pathFormat']); $path = $this->getFullPath($config['pathFormat']);
if(strlen($img)>$config['maxSize']){ if (strlen($img) > $config['maxSize']) {
$data['states'] = 'too large'; $data['states'] = 'too large';
return json_encode($data); return json_encode($data);
} }
$rootpath = $this->rootpath; $rootpath = $this->rootpath;
$imgname = uniqid().'.png'; $imgname = uniqid() . '.png';
$filename = $path.$imgname; $filename = $path . $imgname;
$oriName = $m ? $m[1]:""; $oriName = $m ? $m[1] : "";
if(\Think\Storage::put($rootpath,$filename,$img)){ if (\Think\Storage::put($rootpath, $filename, $img)) {
array_push($list, array( array_push($list, array(
"state" => 'SUCCESS', "state" => 'SUCCESS',
"url" => \Think\Storage::getPath($rootpath,$filename), "url" => \Think\Storage::getPath($rootpath, $filename),
"size" => strlen($img), "size" => strlen($img),
"title" => $imgname, "title" => $imgname,
"original" => $oriName, "original" => $oriName,
"source" => htmlspecialchars($imgUrl) "source" => htmlspecialchars($imgUrl),
)); ));
}else{ } else {
array_push($list,array('state'=>'文件写入失败')); array_push($list, array('state' => '文件写入失败'));
} }
} }
/* 返回抓取数据 */ /* 返回抓取数据 */
return json_encode(array( return json_encode(array(
'state'=> count($list) ? 'SUCCESS':'ERROR', 'state' => count($list) ? 'SUCCESS' : 'ERROR',
'list'=> $list 'list' => $list,
)); ));
} }
/** /**
* 规则替换命名文件 * 规则替换命名文件
* @param $path * @param $path
* @return string * @return string
*/ */
private function getFullPath($path){ private function getFullPath($path) {
//替换日期事件 //替换日期事件
$t = time(); $t = time();
$d = explode('-', date("Y-y-m-d-H-i-s")); $d = explode('-', date("Y-y-m-d-H-i-s"));
$format = $path; $format = $path;
$format = str_replace("{yyyy}", $d[0], $format); $format = str_replace("{yyyy}", $d[0], $format);
$format = str_replace("{yy}", $d[1], $format); $format = str_replace("{yy}", $d[1], $format);
$format = str_replace("{mm}", $d[2], $format); $format = str_replace("{mm}", $d[2], $format);
$format = str_replace("{dd}", $d[3], $format); $format = str_replace("{dd}", $d[3], $format);
$format = str_replace("{hh}", $d[4], $format); $format = str_replace("{hh}", $d[4], $format);
$format = str_replace("{ii}", $d[5], $format); $format = str_replace("{ii}", $d[5], $format);
$format = str_replace("{ss}", $d[6], $format); $format = str_replace("{ss}", $d[6], $format);
$format = str_replace("{uid}", $this->uid, $format); $format = str_replace("{uid}", $this->uid, $format);
return $format; return $format;
} }
private function format_exts($exts){ private function format_exts($exts) {
$data=array(); $data = array();
foreach ($exts as $key => $value) { foreach ($exts as $key => $value) {
$data[]=ltrim($value,'.'); $data[] = ltrim($value, '.');
} }
return $data; return $data;
} }
} }