From 559796b5129fa2849850e0bf89cd76187717320c Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Tue, 26 Apr 2022 08:35:06 +0800 Subject: [PATCH 1/2] * Fix unlink file error. --- module/extension/model.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/module/extension/model.php b/module/extension/model.php index 30dbc63ec7..88e184e6e1 100644 --- a/module/extension/model.php +++ b/module/extension/model.php @@ -599,11 +599,11 @@ class extensionModel extends model $file = $appRoot . $file; if(!file_exists($file)) continue; - if(md5_file($file) != $savedMD5) + if(!is_writable($file) or @md5_file($file) != $savedMD5) { $removeCommands[] = PHP_OS == 'Linux' ? "rm -fr $file #changed" : "del $file :changed"; } - elseif(!@unlink($file)) + elseif(!is_writable($file) or !@unlink($file)) { $removeCommands[] = PHP_OS == 'Linux' ? "rm -fr $file" : "del $file"; } @@ -617,7 +617,7 @@ class extensionModel extends model foreach($dirs as $dir) { if(!is_dir($appRoot . $dir)) continue; - if(!rmdir($appRoot . $dir)) $removeCommands[] = PHP_OS == 'Linux' ? "rm -fr $appRoot$dir" : "rmdir $appRoot$dir /s /q"; + if(!is_writable($appRoot . $dir) or !rmdir($appRoot . $dir)) $removeCommands[] = PHP_OS == 'Linux' ? "rm -fr $appRoot$dir" : "rmdir $appRoot$dir /s /q"; } } @@ -636,7 +636,10 @@ class extensionModel extends model public function cleanModelCache() { $modelCacheFiles = glob($this->app->getTmpRoot() . 'model/*'); - foreach($modelCacheFiles as $cacheFile) @unlink($cacheFile); + foreach($modelCacheFiles as $cacheFile) + { + if(is_writable($cacheFile) and !is_dir($cacheFile)) @unlink($cacheFile); + } } /** From 2df290f018232cb8887efc5d34af06d4bc5cf5e0 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Tue, 26 Apr 2022 09:04:11 +0800 Subject: [PATCH 2/2] * Fix bug #19311. --- module/common/model.php | 6 +++--- module/sso/control.php | 6 +++--- module/user/model.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/module/common/model.php b/module/common/model.php index 04d72c0aca..eb4c528ae5 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -2660,7 +2660,7 @@ EOD; if($isFreepasswd) return print(js::locate($this->config->webRoot)); $this->session->set('ENTRY_CODE', $this->get->code); - $this->session->set('VALID_ENTRY', md5(md5($this->get->code) . $this->server->remote_addr)); + $this->session->set('VALID_ENTRY', md5(md5($this->get->code) . helper::getRemoteIp())); $this->loadModel('entry')->saveLog($entry->id, $this->server->request_uri); /* Add for task #5384. */ @@ -2827,7 +2827,7 @@ EOD; commonModel::$requestErrors = array(); if(!is_array($headers)) $headers = (array)$headers; - $headers[] = "API-RemoteIP: " . zget($_SERVER, 'REMOTE_ADDR', ''); + $headers[] = "API-RemoteIP: " . helper::getRemoteIp(); $curl = curl_init(); curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); @@ -2914,7 +2914,7 @@ EOD; commonModel::$requestErrors = array(); if(!is_array($headers)) $headers = (array)$headers; - $headers[] = "API-RemoteIP: " . zget($_SERVER, 'REMOTE_ADDR', ''); + $headers[] = "API-RemoteIP: " . helper::getRemoteIp(); if($dataType == 'json') { $headers[] = 'Content-Type: application/json;charset=utf-8'; diff --git a/module/sso/control.php b/module/sso/control.php index 9b744832a6..e073bece90 100644 --- a/module/sso/control.php +++ b/module/sso/control.php @@ -26,7 +26,7 @@ class sso extends control $this->app->loadConfig('sso'); if(!$this->config->sso->turnon) return print($this->locate($locate)); - $userIP = $this->server->remote_addr; + $userIP = helper::getRemoteIp(); $code = $this->config->sso->code; $key = $this->config->sso->key; if($type != 'return') @@ -135,7 +135,7 @@ class sso extends control if($type != 'return') { $code = $this->config->sso->code; - $userIP = $this->server->remote_addr; + $userIP = helper::getRemoteIp(); $token = $this->get->token; $key = $this->config->sso->key; $auth = md5($code . $userIP . $token . $key); @@ -199,7 +199,7 @@ class sso extends control if(!$this->session->ssoData) return; $ssoData = $this->session->ssoData; - $userIP = $this->server->remote_addr; + $userIP = helper::getRemoteIp(); $code = $this->config->sso->code; $key = $this->config->sso->key; if($ssoData->auth != md5($code . $userIP . $ssoData->token . $key)) return; diff --git a/module/user/model.php b/module/user/model.php index ddca3fbfd3..48391ea0bd 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -888,7 +888,7 @@ class userModel extends model if($user) { - $ip = $this->server->remote_addr; + $ip = helper::getRemoteIp(); $last = $this->server->request_time; $user->lastTime = $user->last;