From aaa5d4901aed57897e17b329902b488cbce0eeaa Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Wed, 3 Aug 2022 09:24:27 +0800 Subject: [PATCH] * Code for delete sheet2. --- module/port/control.php | 1 - module/port/model.php | 30 +++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/module/port/control.php b/module/port/control.php index 09aec9f8c0..a383c1ddf4 100644 --- a/module/port/control.php +++ b/module/port/control.php @@ -113,7 +113,6 @@ class port extends control move_uploaded_file($file['tmpname'], $fileName); if($extension == 'xlsx' or $extension == 'xls') $this->port->cutFile($fileName); - die; $phpExcel = $this->app->loadClass('phpexcel'); $phpReader = new PHPExcel_Reader_Excel2007(); diff --git a/module/port/model.php b/module/port/model.php index 42894206dc..44fed60837 100644 --- a/module/port/model.php +++ b/module/port/model.php @@ -80,8 +80,11 @@ class portModel extends model */ public function checkSuhosinInfo($datas = array()) { + if(empty($datas)) return; + $current = (array)current($datas); + /* Judge whether the editedTasks is too large and set session. */ - $countInputVars = count($datas) * 11; // Count all post datas + $countInputVars = count($datas) * count($current); // Count all post datas $showSuhosinInfo = common::judgeSuhosinSetting($countInputVars); if($showSuhosinInfo) return extension_loaded('suhosin') ? sprintf($this->lang->suhosinInfo, $countInputVars) : sprintf($this->lang->maxVarsInfo, $countInputVars); return ''; @@ -164,13 +167,34 @@ class portModel extends model file_put_contents($sheet2xmlPath, $xml); file_put_contents($sheet2reslPath, $resl); file_put_contents($sheet2wookbookPath, $wookbook); - unlink($sheet2Path); + @unlink($sheet2Path); } $result = $zip->create($tmpPath,PCLZIP_OPT_REMOVE_PATH,$tmpPath); + $this->deleteDir($tmpPath); } } + /** + * Delete directory. + * + * @param string $dir + */ + public function deleteDir($dir) + { + foreach (scandir($dir) as $file) { + if ($file === '.' || $file === '..') { + continue; + } elseif (is_file($dir . '/' . $file)) { + unlink($dir . '/' . $file); + } elseif (is_dir($dir . '/' . $file)) { + $this->deleteDir($dir . '/' . $file); + } + } + + rmdir($dir); + } + /** * export * @@ -354,7 +378,7 @@ class portModel extends model if(empty($values)) { if(strpos($this->modelConfig->sysLangFields, $field) and !empty($this->modelLang->{$field.'List'})) return $this->modelLang->{$field.'List'}; - if(strpos($this->modelConfig->sysDataFields, $field) and !empty($this->portConfig->sysDataList[$values])) return $this->portConfig->sysDataList[$values]; + if(strpos($this->modelConfig->sysDataFields, $field) and !empty($this->portConfig->sysDataList[$field])) return $this->portConfig->sysDataList[$field]; } if(is_array($values) and $withKey)