mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-12-02 03:48:47 +08:00
兼容iis服务器document root
This commit is contained in:
parent
94a9b2ba68
commit
784c9b93fa
@ -275,7 +275,7 @@ class Ueditor extends Common
|
|||||||
$end = $start + $size;
|
$end = $start + $size;
|
||||||
|
|
||||||
/* 获取文件列表 */
|
/* 获取文件列表 */
|
||||||
$path = $_SERVER['DOCUMENT_ROOT'] . (substr($path, 0, 1) == "/" ? "":"/") . $path;
|
$path = GetDocumentRoot() . (substr($path, 0, 1) == "/" ? "":"/") . $path;
|
||||||
$files = $this->GetFilesList($path, $allow_files);
|
$files = $this->GetFilesList($path, $allow_files);
|
||||||
|
|
||||||
// 倒序
|
// 倒序
|
||||||
@ -359,6 +359,7 @@ class Ueditor extends Common
|
|||||||
if(!is_dir($path)) return null;
|
if(!is_dir($path)) return null;
|
||||||
if(substr($path, strlen($path) - 1) != '/') $path .= '/';
|
if(substr($path, strlen($path) - 1) != '/') $path .= '/';
|
||||||
$handle = opendir($path);
|
$handle = opendir($path);
|
||||||
|
$document_root = GetDocumentRoot();
|
||||||
while(false !== ($file = readdir($handle)))
|
while(false !== ($file = readdir($handle)))
|
||||||
{
|
{
|
||||||
if($file != '.' && $file != '..')
|
if($file != '.' && $file != '..')
|
||||||
@ -371,7 +372,7 @@ class Ueditor extends Common
|
|||||||
if(preg_match("/\.(".$allow_files.")$/i", $file))
|
if(preg_match("/\.(".$allow_files.")$/i", $file))
|
||||||
{
|
{
|
||||||
$files[] = array(
|
$files[] = array(
|
||||||
'url'=> substr($path2, strlen($_SERVER['DOCUMENT_ROOT'])),
|
'url'=> substr($path2, strlen($document_root)),
|
||||||
'mtime'=> filemtime($path2)
|
'mtime'=> filemtime($path2)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,40 @@
|
|||||||
|
|
||||||
// 应用公共文件
|
// 应用公共文件
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前系统所在根路径
|
||||||
|
* @author Devil
|
||||||
|
* @blog http://gong.gg/
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2019-04-09
|
||||||
|
* @desc description
|
||||||
|
*/
|
||||||
|
function GetDocumentRoot()
|
||||||
|
{
|
||||||
|
// 当前所在的文档根目录
|
||||||
|
if(!empty($_SERVER['DOCUMENT_ROOT']))
|
||||||
|
{
|
||||||
|
return $_SERVER['DOCUMENT_ROOT'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理iis服务器DOCUMENT_ROOT路径为空
|
||||||
|
if(!empty($_SERVER['PHP_SELF']))
|
||||||
|
{
|
||||||
|
// 当前执行程序的绝对路径及文件名
|
||||||
|
if(!empty($_SERVER['SCRIPT_FILENAME']))
|
||||||
|
{
|
||||||
|
return str_replace('\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0 -strlen($_SERVER['PHP_SELF'])));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 当前所在绝对路径
|
||||||
|
if(!empty($_SERVER['PATH_TRANSLATED']))
|
||||||
|
{
|
||||||
|
return str_replace('\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0 -strlen($_SERVER['PHP_SELF'])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成随机字符串
|
* 生成随机字符串
|
||||||
* @author Devil
|
* @author Devil
|
||||||
|
@ -453,7 +453,7 @@ class Uploader
|
|||||||
private function getFilePath()
|
private function getFilePath()
|
||||||
{
|
{
|
||||||
$fullname = $this->fullName;
|
$fullname = $this->fullName;
|
||||||
$rootPath = $_SERVER['DOCUMENT_ROOT'];
|
$rootPath = GetDocumentRoot();
|
||||||
|
|
||||||
if (substr($fullname, 0, 1) != '/') {
|
if (substr($fullname, 0, 1) != '/') {
|
||||||
$fullname = '/' . $fullname;
|
$fullname = '/' . $fullname;
|
||||||
|
Loading…
Reference in New Issue
Block a user