This commit is contained in:
thinkphp
2017-11-19 13:55:08 +08:00
4 changed files with 10 additions and 10 deletions

View File

@@ -7,7 +7,7 @@
ThinkPHP 目前使用 Git 来控制程序版本,如果你想为 ThinkPHP 贡献源代码,请先大致了解 Git 的使用方法。我们目前把项目托管在 GitHub 上,任何 GitHub 用户都可以向我们贡献代码。 ThinkPHP 目前使用 Git 来控制程序版本,如果你想为 ThinkPHP 贡献源代码,请先大致了解 Git 的使用方法。我们目前把项目托管在 GitHub 上,任何 GitHub 用户都可以向我们贡献代码。
参与的方式很简单,`fork`一份 ThinkPHP 的代码到你的仓库中,修改后提交,并向我们发起`pull request`申请,我们会及时对代码进行审查并处理你的申请。审查通过后,你的代码将被`merge`进我们的仓库中,这样你就会自动出现在贡献者名单里了,非常方便。 参与的方式很简单,`fork`一份 ThinkPHP 的代码到你的仓库中,修改后提交,并向我们发起`pull request`申请,我们会及时对代码进行审查并处理你的申请。审查通过后,你的代码将被`merge`进我们的仓库中,这样你就会自动出现在贡献者名单里了,非常方便。
我们希望你贡献的代码符合: 我们希望你贡献的代码符合:

View File

@@ -1103,9 +1103,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
// 检测字段 // 检测字段
$allowFields = $this->checkAllowField(array_merge($this->auto, $this->insert)); $allowFields = $this->checkAllowField(array_merge($this->auto, $this->insert));
if (!empty($allowFields)) { if (!empty($allowFields)) {
$result = $this->getQuery()->strict(false)->field($allowFields)->insert($this->data); $result = $this->getQuery()->strict(false)->field($allowFields)->insert($this->data, false, false, $sequence);
} else { } else {
$result = $this->getQuery()->insert($this->data); $result = $this->getQuery()->insert($this->data, false, false, $sequence);
} }
// 获取自动增长主键 // 获取自动增长主键

View File

@@ -1265,7 +1265,7 @@ class Request
* @param boolean $adv 是否进行高级模式获取(有可能被伪装) * @param boolean $adv 是否进行高级模式获取(有可能被伪装)
* @return mixed * @return mixed
*/ */
public function ip($type = 0, $adv = false) public function ip($type = 0, $adv = true)
{ {
$type = $type ? 1 : 0; $type = $type ? 1 : 0;
static $ip = null; static $ip = null;

View File

@@ -12,6 +12,7 @@
namespace think\log\driver; namespace think\log\driver;
use think\App; use think\App;
use think\Request;
/** /**
* 本地化调试输出到文件 * 本地化调试输出到文件
@@ -20,10 +21,10 @@ class File
{ {
protected $config = [ protected $config = [
'time_format' => ' c ', 'time_format' => ' c ',
'single' => false,
'file_size' => 2097152, 'file_size' => 2097152,
'path' => LOG_PATH, 'path' => LOG_PATH,
'apart_level' => [], 'apart_level' => [],
'single' => false,
]; ];
protected $writed = []; protected $writed = [];
@@ -66,7 +67,7 @@ class File
if (in_array($type, $this->config['apart_level'])) { if (in_array($type, $this->config['apart_level'])) {
// 独立记录的日志级别 // 独立记录的日志级别
if ($this->config['single']) { if ($this->config['single']) {
$filename = $path . $type . '.log'; $filename = $path . DS . $type . '.log';
} else { } else {
$filename = $path . DS . date('d') . '_' . $type . $cli . '.log'; $filename = $path . DS . date('d') . '_' . $type . $cli . '.log';
} }
@@ -84,7 +85,7 @@ class File
protected function write($message, $destination, $apart = false) protected function write($message, $destination, $apart = false)
{ {
//检测日志文件大小,超过配置大小则备份日志文件重新生成 //检测日志文件大小,超过配置大小则备份日志文件重新生成
if (!$this->config['single'] && is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) { if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) {
rename($destination, dirname($destination) . DS . time() . '-' . basename($destination)); rename($destination, dirname($destination) . DS . time() . '-' . basename($destination));
$this->writed[$destination] = false; $this->writed[$destination] = false;
} }
@@ -108,11 +109,10 @@ class File
$message = '[ info ] ' . $current_uri . $time_str . $memory_str . $file_load . "\r\n" . $message; $message = '[ info ] ' . $current_uri . $time_str . $memory_str . $file_load . "\r\n" . $message;
} }
$now = date($this->config['time_format']); $now = date($this->config['time_format']);
$server = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '0.0.0.0'; $ip = Request::instance()->ip();
$remote = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0';
$method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'CLI'; $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'CLI';
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
$message = "---------------------------------------------------------------\r\n[{$now}] {$server} {$remote} {$method} {$uri}\r\n" . $message; $message = "---------------------------------------------------------------\r\n[{$now}] {$ip} {$method} {$uri}\r\n" . $message;
$this->writed[$destination] = true; $this->writed[$destination] = true;
} }