add:新增请求过滤空值方法
This commit is contained in:
1
catch/monitor/command/ScheduleCommand.php
Normal file
1
catch/monitor/command/ScheduleCommand.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php
|
1
catch/monitor/command/process/Parser.php
Normal file
1
catch/monitor/command/process/Parser.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php
|
@@ -110,7 +110,7 @@ class User extends CatchController
|
||||
*/
|
||||
public function update($id, UpdateRequest $request)
|
||||
{
|
||||
$this->user->updateBy($id, $request->param());
|
||||
$this->user->updateBy($id, $request->filterEmptyField()->param());
|
||||
|
||||
$user = $this->user->findBy($id);
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<?php
|
84
extend/catcher/library/phpExecutable/FindPhpExecutable.php
Normal file
84
extend/catcher/library/phpExecutable/FindPhpExecutable.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
namespace catcher\library;
|
||||
|
||||
class FindPhpExecutable
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generic executable finder.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
<?php
|
Reference in New Issue
Block a user