Skip to content

Commit 4bdfcd6

Browse files
committed
version 4.38 release
1 parent ae89910 commit 4bdfcd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+196
-221
lines changed

ChangeLog.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
### ver4.38 `2019/2/25`
2+
-----
3+
#### update:
4+
- 针对移动端APP进行兼容适配优化
5+
- 部门列表过多时,排序效率优化。
6+
- https请求优化兼容
7+
- cad分享无法预览问题解决
8+
- 新增hook点
9+
- 其他细节优化
10+
111
### ver4.37 `2018/11/28`
212
-----
313
#### update:
@@ -28,7 +38,6 @@
2838
- 插件配置:文件选择组件支持配置参数;同文件选择组件参数;插件表单组件formMake增强
2939
- 断点续传分片重传加入延时;断网等类似情况下15s内自动上传
3040
- 通用前端worker调用支持
31-
- 分享的的失效时间可以设置当前时间前
3241
- 分享的的失效时间是否可以设置到分钟
3342
- 分享后设置禁止下载,禁用打开方式等相关操作
3443
- https的curl请求加入ssl版本声明;兼容性调整

app/controller/explorer.class.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ public function fileDownload(){
917917
file_put_out($this->path,true);
918918
}
919919
//文件下载后删除,用于文件夹下载
920-
public function fileDownloadRemove(){
920+
public function fileDownloadRemove(){
921921
$path = get_path_this(_DIR_CLEAR($this->in['path']));
922922
$path = iconv_system(USER_TEMP.$path);
923923
$fileName = substr(get_path_this($path),10);//前10个字符为随机前缀
@@ -1167,6 +1167,11 @@ public function fileThumb(){
11671167
//通用预览
11681168
public function fileView(){
11691169
Hook::trigger("explorer.fileViewStart",$this->path);
1170+
if(!isset($this->in['path'])){
1171+
show_tips('参数错误!');
1172+
}
1173+
$this->tpl = TEMPLATE.'api/';
1174+
$this->display('view.html');
11701175
}
11711176
//通用保存
11721177
public function fileSave(){

app/controller/pluginApp.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function to() {
3030
if(!$_SESSION['kodLogin']){
3131
show_tips("出错了!您尚未登录",APP_HOST,3);
3232
}
33-
show_tips("出错了!插件未开启,或您没有{$app}插件的权限");
33+
show_tips("出错了!插件未开启,或您没有{$app}插件的权限!");
3434
}
3535

3636
$appConfig = $model->getConfig($app);
@@ -63,7 +63,7 @@ private function checkAccessShare(){
6363
return false;
6464
}
6565
$share = KOD_USER_SHARE;
66-
if(substr($this->in['path'],0,strlen($share)) == $share){
66+
if(substr(urldecode($this->in['path']),0,strlen($share)) == $share){
6767
return true;
6868
}
6969
return false;
@@ -197,6 +197,7 @@ private function pluginInfo($app){
197197
"versionHash" => $this->config['settingSystem']['versionHash'],
198198
"systemOS" => $this->config['systemOS'],
199199
"phpVersion" => PHP_VERSION,
200+
"channel" => INSTALL_CHANNEL,
200201
"lang" => I18n::getType()
201202
);
202203
$info = url_request($api,'POST',$param);

app/controller/share.class.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ public function commonJs(){
249249
'ACT' => $this->in['act'],
250250
);
251251

252+
if(ST.''.ACT == 'explorer.fileView'){
253+
unset($theConfig['sharePage']);
254+
}
255+
252256
$userConfig = $GLOBALS['config']['settingDefault'];
253257
if(isset($this->in['user'])){
254258
$member = systemMember::loadData();

app/controller/user.class.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private function _loginSuccess($user){
139139
$GLOBALS['isRoot'] = 0;
140140
}
141141

142-
define('DESKTOP_FOLDER',$this->config['settingSystemDefault']['desktopFolder']);
142+
define('DESKTOP_FOLDER',$this->config['settingSystem']['desktopFolder']);
143143
$this->config['user'] = FileCache::load(USER.'data/config.php');
144144

145145
if(!is_array($this->config['user'])){
@@ -309,6 +309,22 @@ public function commonJs(){
309309
}
310310
echo 'LNG='.$lang.';G.useTime='.$useTime.';';
311311
}
312+
public function appConfig(){
313+
$theConfig = array(
314+
'lang' => I18n::getType(),
315+
'isRoot' => $GLOBALS['isRoot'],
316+
'userID' => $this->user['userID'],
317+
'myhome' => MYHOME,
318+
'settings' => array(
319+
'updloadChunkSize' => file_upload_size(),
320+
'updloadThreads' => $this->config['settings']['updloadThreads'],
321+
'uploadCheckChunk' => $this->config['settings']['uploadCheckChunk'],
322+
),
323+
'version' => KOD_VERSION,
324+
// 'userConfig' => $this->config['user'],
325+
);
326+
show_json($theConfig);
327+
}
312328

313329
/**
314330
* 登录view
@@ -425,7 +441,7 @@ public function loginSubmit(){
425441

426442
//首次登陆,初始化app 没有最后登录时间
427443
$this->_loginSuccess($user);//登陆成功
428-
if($user['lastLogin'] == ''){
444+
if(!$user['lastLogin']){
429445
$app = init_controller('app');
430446
$app->initApp($user);
431447
}

app/controller/utils.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

app/function/common.function.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,17 @@ function str_trim($str,$remove){
9393
return str_rtrim(str_ltrim($str,$remove),$remove);
9494
}
9595
function str_ltrim($str,$remove){
96-
if(!$str || !$remove) return false;
96+
if(!$str || !$remove) return $str;
9797
while(substr($str,0,strlen($remove)) == $remove){
9898
$str = substr($str,strlen($remove));
9999
}
100100
return $str;
101101
}
102102
function str_rtrim($str,$remove){
103-
if(!$str || !$remove) return false;
103+
if(!$str || !$remove) return $str;
104104
while(substr($str,-strlen($remove)) == $remove){
105105
$str = substr($str,0,-strlen($remove));
106+
echo $str;
106107
}
107108
return $str;
108109
}

app/function/file.function.php

Lines changed: 5 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -657,83 +657,14 @@ function dir_list($path){
657657
return array_merge($dirs,$files);
658658
}
659659

660-
/**
661-
* 借用临时文件方式对读写文件进行锁定标记
662-
*
663-
* fopen mode: http://www.w3school.com.cn/php/func_filesystem_fopen.asp
664-
* flock mode: http://www.w3school.com.cn/php/func_filesystem_flock.asp
665-
*/
666-
function file_lock($file,$open=true,$type='read',$timeout=5){
667-
clearstatcache();
668-
$lockFile = $file.'.'.$type.'.lock';
669-
$lockRead = $file.'.read.lock';
670-
$lockWrite = $file.'.write.lock';
671-
if(!$open){
672-
@unlink($lockFile);
673-
clearstatcache();
674-
return;
675-
}
676-
677-
$startTime = microtime(true);
678-
do{
679-
clearstatcache();
680-
$canLock = true;
681-
if( $type=='read' ){
682-
if( file_exists($lockWrite) ){
683-
$canLock = false;
684-
}
685-
}else if( $type=='write' ){
686-
if( file_exists($lockWrite) || file_exists($lockRead) ){
687-
$canLock = false;
688-
}
689-
}
690-
if(!$canLock){
691-
usleep(mt_rand(10, 50) * 1000);//10~50ms;
692-
}
693-
} while((!$canLock) && ((microtime(true) - $startTime) < $timeout ));
694-
$result = false;
695-
if($canLock){
696-
$result = file_put_contents($lockFile,time(),LOCK_EX);
697-
clearstatcache();
698-
$result = $result && file_exists($lockFile);
699-
//if(!$result){write_log($_GET['action'].';file not exists','test2');}
700-
}
701-
return $result;
702-
}
703-
704-
// 安全读取文件,避免并发下读取数据为空
705-
function file_read_safe1($file,$timeout = 5){
706-
if(file_lock($file,true,'read',$timeout)){
707-
$fp = @fopen($file, 'r');
708-
if(!$fp || !flock($fp, LOCK_EX)) return false;
709-
$result = fread($fp, filesize($file));
710-
flock($fp,LOCK_UN);fclose($fp);
711-
712-
file_lock($file,false,'read');
713-
return $result;
714-
}
715-
return false;
716-
}
717-
// 安全读取文件,避免并发下读取数据为空
718-
function file_wirte_safe1($file,$buffer,$timeout=5){
719-
if(file_lock($file,true,'write',$timeout)){
720-
$result = @file_put_contents($file,$buffer,LOCK_EX);
721-
file_lock($file,false,'write');
722-
return $result;
723-
}
724-
return false;
725-
}
726-
727-
728660
// 安全读取文件,避免并发下读取数据为空
729-
function file_read_safe($file,$timeout = 5){
730-
//return file_read_safe1($file,$timeout);
661+
function file_read_safe($file,$timeout = 3){
731662
if(!$file || !file_exists($file)) return false;
732663
$fp = @fopen($file, 'r');
733664
if(!$fp) return false;
734665
$startTime = microtime(true);
735666
do{
736-
$locked = flock($fp, LOCK_EX|LOCK_NB);//LOCK_EX|LOCK_NB
667+
$locked = flock($fp, LOCK_SH);//LOCK_EX|LOCK_NB
737668
if(!$locked){
738669
usleep(mt_rand(1, 50) * 1000);//1~50ms;
739670
}
@@ -753,8 +684,7 @@ function file_read_safe($file,$timeout = 5){
753684
}
754685

755686
// 安全读取文件,避免并发下读取数据为空
756-
function file_wirte_safe($file,$buffer,$timeout=5){
757-
//return file_wirte_safe1($file,$buffer,$timeout);
687+
function file_wirte_safe($file,$buffer,$timeout=3){
758688
clearstatcache();
759689
if(strlen($file) == 0 || !$file || !file_exists($file)) return false;
760690
$fp = fopen($file,'r+');
@@ -1069,21 +999,11 @@ function file_put_out($file,$download=-1,$downFilename=false){
1069999
}
10701000

10711001
$mime = get_file_mime(get_path_ext($filename));
1072-
$filenameOutput = rawurlencode(iconv_app($filename));
10731002
if ($download === -1 && !mime_support($mime)){
10741003
$download = true;
10751004
}
1076-
$headerName = $filenameOutput;
1077-
if(ua_has("Chrome") && !ua_has('Edge')){ //chrome下载
1078-
$filenameOutput = '"'.$filenameOutput.'"';
1079-
}
1080-
if(!is_wap()){
1081-
$headerName.=";filename*=utf-8''".$filenameOutput;
1082-
}
1083-
if( ua_has("Safari") && !ua_has('Edge')){//safari 中文下载问题
1084-
$headerName = rawurldecode($filenameOutput);
1085-
}
1086-
//var_dump($headerName,$filenameOutput,$_SERVER['HTTP_USER_AGENT']);exit;
1005+
$headerName = rawurlencode(iconv_app($filename));
1006+
$headerName = '"'.$headerName."\"; filename*=utf-8''".$headerName;
10871007
if ($download) {
10881008
header('Content-Type: application/octet-stream');
10891009
header('Content-Transfer-Encoding: binary');

app/function/helper.function.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function serverInfo(){
133133
"php" => floatval(PHP_VERSION),
134134
"server"=> $_SERVER['SERVER_SOFTWARE'],
135135
"lib" => $libStr,
136-
"info" => php_uname().';phpv='.PHP_VERSION,
136+
"info" => php_uname().';php='.PHP_VERSION,
137137
);
138138
$result = str_replace("\/","@",json_encode($env));
139139
return $result;

app/function/web.function.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ function url_request($url,$method='GET',$data=false,$headers=false,$options=fals
361361
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
362362
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
363363
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
364-
curl_setopt($ch, CURLOPT_SSLVERSION,1);//1|5|6; http://t.cn/RZy5nXF
364+
// curl_setopt($ch, CURLOPT_SSLVERSION,1);//1|5|6; http://t.cn/RZy5nXF
365365
curl_setopt($ch, CURLOPT_TIMEOUT,$timeout);
366366
curl_setopt($ch, CURLOPT_REFERER,get_url_link($url));
367367
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36');

app/kod/Downloader.class.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,18 @@ static function start($url,$saveFile,$timeout = 10) {
2222
if(!$url){
2323
return array('code'=>false,'data'=>'url error!');
2424
}
25-
2625
//默认下载方式if not support range
2726
if(!$fileHeader['supportRange'] ||
2827
$fileHeader['length'] == 0 ){
29-
@unlink($saveTemp);
30-
@unlink($saveFile);
28+
@unlink($saveTemp);@unlink($saveFile);
3129
$result = self::fileDownloadFopen($url,$saveFile,$fileHeader['length']);
3230
if($result['code']) {
3331
return $result;
3432
}else{
35-
@unlink($saveTemp);
36-
@unlink($saveFile);
37-
return self::fileDownloadCurl($url,$saveFile,false,0,$fileHeader['length']);
33+
@unlink($saveTemp);@unlink($saveFile);
34+
$result = self::fileDownloadCurl($url,$saveFile,false,0,$fileHeader['length']);
35+
@unlink($saveTemp);@unlink($saveFile);
36+
return $result;
3837
}
3938
}
4039

@@ -106,7 +105,7 @@ static function fileDownloadFopen($url, $fileName,$headerSize=0){
106105
if($headerSize != 0 && $filesize != $headerSize){
107106
return array('code'=>false,'data'=>'file size error');
108107
}
109-
108+
self::checkGzip($fileTemp);
110109
if(!@rename($fileTemp,$fileName)){
111110
usleep(round(rand(0,1000)*50));//0.01~10ms
112111
@unlink($fileName);
@@ -152,6 +151,7 @@ static function fileDownloadCurl($url, $fileName,$supportRange=false,$existsLeng
152151
}
153152

154153
if($res && filesize($fileTemp) != 0){
154+
self::checkGzip($fileTemp);
155155
if(!@rename($fileTemp,$fileName)){
156156
@unlink($fileName);
157157
$res = @rename($fileTemp,$fileName);
@@ -166,4 +166,15 @@ static function fileDownloadCurl($url, $fileName,$supportRange=false,$existsLeng
166166
return array('code'=>false,'data'=>'file create error');
167167
}
168168
}
169+
170+
static function checkGzip($file){
171+
$char = "\x1f\x8b";
172+
$str = file_sub_str($file,0,2);
173+
if($char != $str) return;
174+
175+
ob_start();
176+
readgzfile($file);
177+
$out = ob_get_clean();
178+
file_put_contents($file,$out);
179+
}
169180
}

app/kod/I18n.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static function defaultLang(){
2222
$lang = "en";
2323
$arr = $GLOBALS['config']['settingAll']['language'];
2424
$langs = array();
25+
if(!$arr) return 'zh-CN';
2526
foreach ($arr as $key => $value) {
2627
$langs[$key] = $key;
2728
}

app/kod/archiveLib/kodRarArchive.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,12 @@ static function listContent7z($file,$bin=false) {
243243

244244
// 不允许双引号
245245
function escapeShell($param){
246+
return escapeshellarg($param);
246247
//$param = escapeshellarg($param);
247248
$os = strtoupper(substr(PHP_OS, 0,3));
248249
if ( $os != 'WIN' && $os != 'DAR') {//linux
249250
$param = str_replace('!','\!',$param);
250251
}
251252
$param = rtrim($param,"\\");
252-
return '"'.str_replace(array('"',"\0"),'_',$param).'"';
253+
return '"'.str_replace(array('"',"\0",'`'),'_',$param).'"';
253254
}

app/model/PluginModel.class.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ public function viewList(){
177177
$list = $this->loadData();
178178
$result = array();
179179
foreach ($list as $key => $item) {
180+
if(!plugin_check_allow($key)){
181+
continue;
182+
}
180183
unset($item['regiest']);
181184
$package = Hook::apply($item['id'].'Plugin.appPackage');
182185
if(is_array($package)){

app/template/api/view.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@
7676
<script type="text/javascript">
7777
G.shareInfo = {
7878
path:"<?php echo $_GET['path'];?>",
79-
name:"<?php echo $name;?>",
79+
name:"<?php echo get_path_this($_GET['path']);?>",
8080
mtime:0,
8181
size:0
8282
}
83+
<?php if(ST.'.'.ACT == 'explorer.fileView'){echo "G.shareInfo.view = true;";}?>
8384
G['accessToken'] = "<?php echo access_token_get();?>";
8485
seajs.config({
8586
base: "<?php echo STATIC_PATH;?>js/",

app/template/common/footerCommon.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script type="text/javascript" src="<?php echo STATIC_PATH;?>js/lib/seajs/sea.js?ver=<?php echo KOD_VERSION;?>"></script>
22
<?php
33
//commonjs
4-
Hook::trigger('templateCommonFooter');
54
if(ST == 'share' || isset($GLOBALS['loadCommonJs'])){
65
if(isset($_GET['user'])){
76
$userInfo = '&user='.clear_html($_GET['user']).'&sid='.clear_html($_GET['sid']);
@@ -45,3 +44,4 @@
4544
]
4645
});
4746
</script>
47+
<?php Hook::trigger('templateCommonFooter');?>

app/template/common/header.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?php Hook::trigger('templateCommonHeaderStart'); ?>
12
<!DOCTYPE html>
23
<html>
34
<head>

0 commit comments

Comments
 (0)