diff --git a/catch/monitor/command/ScheduleCommand.php b/catch/monitor/command/ScheduleCommand.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/catch/monitor/command/ScheduleCommand.php @@ -0,0 +1 @@ +user->updateBy($id, $request->param()); + $this->user->updateBy($id, $request->filterEmptyField()->param()); $user = $this->user->findBy($id); diff --git a/extend/catcher/Utils.php b/extend/catcher/Utils.php index d92d673..7eb3fc4 100644 --- a/extend/catcher/Utils.php +++ b/extend/catcher/Utils.php @@ -210,4 +210,23 @@ class Utils { return root_path($path ? 'public/'. $path : 'public'); } + + + /** + * 过滤空字符字段 + * + * @time 2021年01月16日 + * @param $data + * @return mixed + */ + public static function filterEmptyValue($data) + { + foreach ($data as $k => $v) { + if (!$v) { + unset($data[$k]); + } + } + + return $data; + } } diff --git a/extend/catcher/base/CatchRequest.php b/extend/catcher/base/CatchRequest.php index 558e2ac..29ce9f0 100644 --- a/extend/catcher/base/CatchRequest.php +++ b/extend/catcher/base/CatchRequest.php @@ -6,7 +6,7 @@ namespace catcher\base; use app\Request; use catcher\exceptions\FailedException; use catcher\exceptions\ValidateFailedException; -use think\App; +use catcher\Utils; class CatchRequest extends Request { @@ -89,4 +89,22 @@ class CatchRequest extends Request return parent::post($name, $default, $filter); // TODO: Change the autogenerated stub } + /** + * 过滤空字段 + * + * @time 2021年01月16日 + * @return $this + */ + public function filterEmptyField(): CatchRequest + { + if ($this->isGet()) { + $this->get = Utils::filterEmptyValue($this->get); + } elseif ($this->isPost()) { + $this->post = Utils::filterEmptyValue($this->post); + } else { + $this->put = Utils::filterEmptyValue($this->put); + } + + return $this; + } } diff --git a/extend/catcher/library/phpExecutable/ExecutableFinder.php b/extend/catcher/library/phpExecutable/ExecutableFinder.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/extend/catcher/library/phpExecutable/ExecutableFinder.php @@ -0,0 +1 @@ + + * @author Johannes M. Schmitt + */ +class ExecutableFinder +{ + private $suffixes = ['.exe', '.bat', '.cmd', '.com']; + + /** + * Replaces default suffixes of executable. + */ + public function setSuffixes(array $suffixes) + { + $this->suffixes = $suffixes; + } + + /** + * Adds new possible suffix to check for executable. + * + * @param string $suffix + */ + public function addSuffix($suffix) + { + $this->suffixes[] = $suffix; + } + + /** + * Finds an executable by name. + * + * @param string $name The executable name (without the extension) + * @param string|null $default The default to return if no executable is found + * @param array $extraDirs Additional dirs to check into + * + * @return string|null The executable path or default value + */ + public function find($name, $default = null, array $extraDirs = []) + { + if (ini_get('open_basedir')) { + $searchPath = array_merge(explode(PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs); + $dirs = []; + foreach ($searchPath as $path) { + // Silencing against https://bugs.php.net/69240 + if (@is_dir($path)) { + $dirs[] = $path; + } else { + if (basename($path) == $name && @is_executable($path)) { + return $path; + } + } + } + } else { + $dirs = array_merge( + explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')), + $extraDirs + ); + } + + $suffixes = ['']; + if ('\\' === \DIRECTORY_SEPARATOR) { + $pathExt = getenv('PATHEXT'); + $suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes); + } + foreach ($suffixes as $suffix) { + foreach ($dirs as $dir) { + if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) { + return $file; + } + } + } + + return $default; + } +} \ No newline at end of file diff --git a/extend/catcher/library/phpExecutable/PhpExecutableFinder.php b/extend/catcher/library/phpExecutable/PhpExecutableFinder.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/extend/catcher/library/phpExecutable/PhpExecutableFinder.php @@ -0,0 +1 @@ +