diff --git a/application/admin/controller/Common.php b/application/admin/controller/Common.php index e73b15a35..062170200 100755 --- a/application/admin/controller/Common.php +++ b/application/admin/controller/Common.php @@ -309,7 +309,6 @@ class Common extends Controller */ protected function IsPower() { - // 不需要校验权限的方法 $unwanted_power = ['getnodeson']; if(!AdminIsPower(null, null, $unwanted_power)) diff --git a/application/admin/controller/Payrequestlog.php b/application/admin/controller/Payrequestlog.php new file mode 100644 index 000000000..a6bdc7726 --- /dev/null +++ b/application/admin/controller/Payrequestlog.php @@ -0,0 +1,113 @@ +IsLogin(); + + // 权限校验 + $this->IsPower(); + } + + /** + * 列表 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-09-23 + * @desc description + */ + public function Index() + { + // 总数 + $total = PayRequestLogService::PayRequestLogTotal($this->form_where); + + // 分页 + $page_params = [ + 'number' => $this->page_size, + 'total' => $total, + 'where' => $this->data_request, + 'page' => $this->page, + 'url' => MyUrl('admin/payrequestlog/index'), + ]; + $page = new \base\Page($page_params); + + // 获取列表 + $data_params = [ + 'where' => $this->form_where, + 'm' => $page->GetPageStarNumber(), + 'n' => $this->page_size, + 'user_type' => 'admin', + ]; + $ret = PayRequestLogService::PayRequestLogList($data_params); + + // 基础参数赋值 + $this->assign('params', $this->data_request); + $this->assign('page_html', $page->GetPageHtml()); + $this->assign('data_list', $ret['data']); + return $this->fetch(); + } + + /** + * 详情 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-09-23 + * @desc description + */ + public function Detail() + { + if(!empty($this->data_request['id'])) + { + // 条件 + $where = [ + ['id', '=', intval($this->data_request['id'])], + ]; + + // 获取列表 + $data_params = [ + 'm' => 0, + 'n' => 1, + 'where' => $where, + 'user_type' => 'admin' + ]; + $ret = PayRequestLogService::PayRequestLogList($data_params); + $data = (empty($ret['data']) || empty($ret['data'][0])) ? [] : $ret['data'][0]; + $this->assign('data', $data); + } + return $this->fetch(); + } +} +?> \ No newline at end of file diff --git a/application/admin/form/Payrequestlog.php b/application/admin/form/Payrequestlog.php new file mode 100644 index 000000000..d03095d97 --- /dev/null +++ b/application/admin/form/Payrequestlog.php @@ -0,0 +1,256 @@ + [ + 'key_field' => 'id', + 'is_search' => 1, + 'search_url' => MyUrl('admin/payrequestlog/index'), + 'is_middle' => 0, + ], + // 表单配置 + 'form' => [ + [ + 'label' => '业务类型', + 'view_type' => 'field', + 'view_key' => 'business_type', + 'search_config' => [ + 'form_type' => 'select', + 'where_type' => 'in', + 'data' => $this->PayRequestLogFieldWhereList('business_type'), + 'data_key' => 'name', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => '请求参数', + 'view_type' => 'field', + 'view_type' => 'module', + 'view_key' => 'payrequestlog/module/request_params', + 'align' => 'left', + 'grid_size' => 'sm', + 'search_config' => [ + 'form_type' => 'input', + 'form_name' => 'request_params', + 'where_type' => 'like', + ], + ], + [ + 'label' => '响应数据', + 'view_type' => 'field', + 'view_type' => 'module', + 'view_key' => 'payrequestlog/module/response_data', + 'align' => 'left', + 'grid_size' => 'sm', + 'search_config' => [ + 'form_type' => 'input', + 'form_name' => 'response_data', + 'where_type' => 'like', + ], + ], + [ + 'label' => '业务处理结果', + 'view_type' => 'field', + 'view_type' => 'module', + 'view_key' => 'payrequestlog/module/business_handle', + 'align' => 'left', + 'grid_size' => 'sm', + 'search_config' => [ + 'form_type' => 'input', + 'where_type' => 'like', + ], + ], + [ + 'label' => '请求url地址', + 'view_type' => 'field', + 'view_key' => 'request_url', + 'search_config' => [ + 'form_type' => 'input', + 'form_name' => 'business_handle', + 'where_type' => 'like', + ], + ], + [ + 'label' => '端口号', + 'view_type' => 'field', + 'view_key' => 'server_port', + 'search_config' => [ + 'form_type' => 'select', + 'where_type' => 'in', + 'data' => $this->PayRequestLogFieldWhereList('server_port'), + 'data_key' => 'name', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => '服务器ip', + 'view_type' => 'field', + 'view_key' => 'server_ip', + 'search_config' => [ + 'form_type' => 'input', + 'where_type' => 'like', + ], + ], + [ + 'label' => '客户端ip', + 'view_type' => 'field', + 'view_key' => 'client_ip', + 'search_config' => [ + 'form_type' => 'input', + 'where_type' => 'like', + ], + ], + [ + 'label' => '操作系统', + 'view_type' => 'field', + 'view_key' => 'os', + 'search_config' => [ + 'form_type' => 'select', + 'where_type' => 'in', + 'data' => $this->PayRequestLogFieldWhereList('os'), + 'data_key' => 'name', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => '浏览器', + 'view_type' => 'field', + 'view_key' => 'browser', + 'search_config' => [ + 'form_type' => 'select', + 'where_type' => 'in', + 'data' => $this->PayRequestLogFieldWhereList('browser'), + 'data_key' => 'name', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => '请求类型', + 'view_type' => 'field', + 'view_key' => 'method', + 'search_config' => [ + 'form_type' => 'select', + 'where_type' => 'in', + 'data' => $this->PayRequestLogFieldWhereList('method'), + 'data_key' => 'name', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => 'http类型', + 'view_type' => 'field', + 'view_key' => 'scheme', + 'search_config' => [ + 'form_type' => 'select', + 'where_type' => 'in', + 'data' => $this->PayRequestLogFieldWhereList('scheme'), + 'data_key' => 'name', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => 'http版本', + 'view_type' => 'field', + 'view_key' => 'version', + 'search_config' => [ + 'form_type' => 'select', + 'where_type' => 'in', + 'data' => $this->PayRequestLogFieldWhereList('version'), + 'data_key' => 'name', + 'data_name' => 'name', + 'is_multiple' => 1, + ], + ], + [ + 'label' => '客户端详情', + 'view_type' => 'field', + 'view_key' => 'client', + 'search_config' => [ + 'form_type' => 'input', + 'where_type' => 'like', + ], + ], + [ + 'label' => '创建时间', + 'view_type' => 'field', + 'view_key' => 'add_time', + 'search_config' => [ + 'form_type' => 'datetime', + ], + ], + [ + 'label' => '更新时间', + 'view_type' => 'field', + 'view_key' => 'upd_time', + 'search_config' => [ + 'form_type' => 'datetime', + ], + ], + [ + 'label' => '操作', + 'view_type' => 'operate', + 'view_key' => 'payrequestlog/module/operate', + 'align' => 'center', + 'fixed' => 'right', + ], + ], + ]; + } + + /** + * 条件字段列表 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-09-23 + * @desc description + * @param [string] $field [字段名称] + */ + public function PayRequestLogFieldWhereList($field) + { + return Db::name('PayRequestLog')->field($field.' as name')->group($field)->select(); + } +} +?> \ No newline at end of file diff --git a/application/admin/view/default/paylog/index.html b/application/admin/view/default/paylog/index.html index 907d6eab9..b1ee8fe86 100755 --- a/application/admin/view/default/paylog/index.html +++ b/application/admin/view/default/paylog/index.html @@ -1,2 +1,13 @@ -{{extend name="public/module/form" /}} \ No newline at end of file +{{extend name="public/module/form" /}} + + +{{block name="form_operate_top"}} + + {{if AdminIsPower('payrequestlog', 'index')}} + 支付请求日志 + {{/if}} + + + {__block__} +{{/block}} \ No newline at end of file diff --git a/application/admin/view/default/payrequestlog/detail.html b/application/admin/view/default/payrequestlog/detail.html new file mode 100644 index 000000000..06eeee457 --- /dev/null +++ b/application/admin/view/default/payrequestlog/detail.html @@ -0,0 +1,2 @@ + +{{extend name="public/module/detail" /}} \ No newline at end of file diff --git a/application/admin/view/default/payrequestlog/index.html b/application/admin/view/default/payrequestlog/index.html new file mode 100755 index 000000000..5387e5154 --- /dev/null +++ b/application/admin/view/default/payrequestlog/index.html @@ -0,0 +1,13 @@ + +{{extend name="public/module/form" /}} + + +{{block name="form_operate_top"}} + + + + {__block__} +{{/block}} \ No newline at end of file diff --git a/application/admin/view/default/payrequestlog/module/business_handle.html b/application/admin/view/default/payrequestlog/module/business_handle.html new file mode 100644 index 000000000..00bf6422c --- /dev/null +++ b/application/admin/view/default/payrequestlog/module/business_handle.html @@ -0,0 +1,4 @@ + +{{if !empty($module_data) and !empty($module_data['business_handle'])}} +
{{$module_data.business_handle}}
+{{/if}}
\ No newline at end of file
diff --git a/application/admin/view/default/payrequestlog/module/operate.html b/application/admin/view/default/payrequestlog/module/operate.html
new file mode 100644
index 000000000..09f0f1470
--- /dev/null
+++ b/application/admin/view/default/payrequestlog/module/operate.html
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/application/admin/view/default/payrequestlog/module/request_params.html b/application/admin/view/default/payrequestlog/module/request_params.html
new file mode 100644
index 000000000..aaae93fed
--- /dev/null
+++ b/application/admin/view/default/payrequestlog/module/request_params.html
@@ -0,0 +1,4 @@
+
+{{if !empty($module_data) and !empty($module_data['request_params'])}}
+ {{$module_data.request_params}}
+{{/if}}
\ No newline at end of file
diff --git a/application/admin/view/default/payrequestlog/module/response_data.html b/application/admin/view/default/payrequestlog/module/response_data.html
new file mode 100644
index 000000000..bb743e92a
--- /dev/null
+++ b/application/admin/view/default/payrequestlog/module/response_data.html
@@ -0,0 +1,4 @@
+
+{{if !empty($module_data) and !empty($module_data['response_data'])}}
+ {{$module_data.response_data}}
+{{/if}}
\ No newline at end of file
diff --git a/application/api/controller/Common.php b/application/api/controller/Common.php
index e29e19d5f..192a9de67 100755
--- a/application/api/controller/Common.php
+++ b/application/api/controller/Common.php
@@ -50,7 +50,7 @@ class Common extends Controller
$this->data_request = input();
// 系统运行开始
- SystemService::SystemBegin();
+ SystemService::SystemBegin($this->data_request);
// 系统初始化
$this->SystemInit();
@@ -73,7 +73,7 @@ class Common extends Controller
public function __destruct()
{
// 系统运行结束
- SystemService::SystemEnd();
+ SystemService::SystemEnd($this->data_request);
}
/**
diff --git a/application/api/controller/Ordernotify.php b/application/api/controller/Ordernotify.php
index 292b859d2..55e929864 100755
--- a/application/api/controller/Ordernotify.php
+++ b/application/api/controller/Ordernotify.php
@@ -11,6 +11,7 @@
namespace app\api\controller;
use app\service\OrderService;
+use app\service\PayRequestLogService;
/**
* 订单支付异步通知
@@ -43,12 +44,20 @@ class OrderNotify extends Common
*/
public function Notify()
{
+ // 支付请求日志添加
+ $log_ret = PayRequestLogService::PayRequestLogInsert(OrderService::$business_type_name);
+
+ // 业务处理
$ret = OrderService::Notify($this->data_request);
- if($ret['code'] == 0)
- {
- $this->SuccessReturn();
- }
- $this->ErrorReturn();
+
+ // 响应内容
+ $res = ($ret['code'] == 0) ? $this->SuccessReturn() : $this->ErrorReturn();
+
+ // 支付响应日志
+ PayRequestLogService::PayRequestLogEnd($log_ret['data'], $ret, $res);
+
+ // 结束运行
+ die($res);
}
/**
@@ -62,10 +71,10 @@ class OrderNotify extends Common
private function SuccessReturn()
{
// 支付插件是否自定义返回内容
- $this->ContentReturn('SuccessReturn');
+ $res = $this->ContentReturn('SuccessReturn');
// 结束输出
- die('success');
+ return empty($res) ? 'success' : $res;
}
/**
@@ -79,10 +88,10 @@ class OrderNotify extends Common
private function ErrorReturn()
{
// 支付插件是否自定义返回内容
- $this->ContentReturn('ErrorReturn');
+ $res = $this->ContentReturn('ErrorReturn');
// 结束输出
- die('error');
+ return empty($res) ? 'error' : $res;
}
/**
@@ -102,9 +111,10 @@ class OrderNotify extends Common
$payment_obj = new $payment();
if(method_exists($payment_obj, $action))
{
- die($payment_obj->$action());
+ return $payment_obj->$action();
}
}
+ return '';
}
}
?>
\ No newline at end of file
diff --git a/application/common.php b/application/common.php
index e95ef4d34..3da3502dc 100755
--- a/application/common.php
+++ b/application/common.php
@@ -11,6 +11,49 @@
// 应用公共文件
+/**
+ * 获取参数数据
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2020-09-23
+ * @desc description
+ * @param [string] $key [参数key]
+ * @param [string] $default [默认值]
+ */
+function MyInput($key = null, $default = null)
+{
+ static $data = null;
+ if($data === null)
+ {
+ // raw
+ $raw_data = empty($HTTP_RAW_POST_DATA) ? [] : (!is_array($HTTP_RAW_POST_DATA) ? json_decode($HTTP_RAW_POST_DATA, true) : []);
+
+ // request
+ $request_data = empty($_REQUEST) ? [] : $_REQUEST;
+
+ // input
+ $input_data = file_get_contents("php://input");
+ $input_data = empty($input_data) ? [] : (!is_array($input_data) ? json_decode($input_data, true) : []);
+
+ // 数据合并
+ $data = array_merge($raw_data, $request_data, $input_data);
+ }
+
+ // 是否指定key
+ if(!empty($key))
+ {
+ if(array_key_exists($key, $data))
+ {
+ return is_array($data[$key]) ? $data[$key] : htmlspecialchars(trim($data[$key]));
+ }
+ return $default;
+ }
+
+ // 未指定key则返回所有数据
+ return $data;
+}
+
/**
* 当前应用平台
* @author Devil
@@ -1214,7 +1257,7 @@ function ScienceNumToString($num)
*/
function GetClientIP($long = false)
{
- $onlineip = '';
+ $onlineip = '';
if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown'))
{
$onlineip = getenv('HTTP_CLIENT_IP');
diff --git a/application/index/controller/Common.php b/application/index/controller/Common.php
index d9bfe4522..2073f3c74 100755
--- a/application/index/controller/Common.php
+++ b/application/index/controller/Common.php
@@ -87,7 +87,7 @@ class Common extends Controller
$this->SystemInit();
// 系统运行开始
- SystemService::SystemBegin();
+ SystemService::SystemBegin($this->data_request);
// 站点状态校验
$this->SiteStstusCheck();
@@ -119,7 +119,7 @@ class Common extends Controller
public function __destruct()
{
// 系统运行结束
- SystemService::SystemEnd();
+ SystemService::SystemEnd($this->data_request);
}
/**
diff --git a/application/install/controller/Index.php b/application/install/controller/Index.php
index c538476f7..2ef55f352 100755
--- a/application/install/controller/Index.php
+++ b/application/install/controller/Index.php
@@ -25,6 +25,9 @@ class Index extends Common
// 编码类型
private $charset_type_list;
+ // 安装日志上报
+ private $behavior_obj;
+
/**
* 构造方法
* @author Devil
@@ -50,6 +53,9 @@ class Index extends Common
'version' => 5.0,
],
];
+
+ // 安装日志上报类库
+ $this->behavior_obj = new \base\Behavior();
}
/**
@@ -80,7 +86,7 @@ class Index extends Common
public function Index()
{
$this->IsInstall();
- new \base\Behavior(['msg'=>'协议阅读']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'协议阅读']);
return $this->fetch();
}
@@ -95,7 +101,7 @@ class Index extends Common
public function Check()
{
$this->IsInstall();
- new \base\Behavior(['msg'=>'环境检测']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'环境检测']);
return $this->fetch();
}
@@ -110,7 +116,7 @@ class Index extends Common
public function Create()
{
$this->IsInstall();
- new \base\Behavior(['msg'=>'数据信息填写']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'数据信息填写']);
$this->assign('charset_type_list' , $this->charset_type_list);
return $this->fetch();
@@ -159,14 +165,14 @@ class Index extends Common
$ret = $this->ParamsCheck($params);
if($ret['code'] != 0)
{
- new \base\Behavior(['msg'=>'参数校验['.$ret['msg'].']']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'参数校验['.$ret['msg'].']']);
return $ret;
}
// 配置文件校验
if(file_exists(ROOT.'config/database.php'))
{
- new \base\Behavior(['msg'=>'你已经安装过该系统,重新安装需要先删除[./config/database.php 文件]']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'你已经安装过该系统,重新安装需要先删除[./config/database.php 文件]']);
return DataReturn('你已经安装过该系统,重新安装需要先删除[./config/database.php 文件]', -1);
}
@@ -174,7 +180,7 @@ class Index extends Common
$db = $this->DbObj($params);
if(!is_object($db))
{
- new \base\Behavior(['msg'=>'数据库连接失败']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'数据库连接失败']);
return DataReturn('数据库连接失败', -1);
}
@@ -192,7 +198,7 @@ class Index extends Common
{
$db = $this->DbObj($params, $params['DB_NAME']);
} else {
- new \base\Behavior(['msg'=>'数据库创建失败']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'数据库创建失败']);
return DataReturn('数据库创建失败', -1);
}
} else {
@@ -200,7 +206,7 @@ class Index extends Common
}
if(!is_object($db))
{
- new \base\Behavior(['msg'=>'数据库连接失败']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'数据库连接失败']);
return DataReturn('数据库连接失败', -1);
}
@@ -301,11 +307,11 @@ return [
php;
if(@file_put_contents(ROOT.'config/database.php', $db_str) === false)
{
- new \base\Behavior(['msg'=>'配置文件创建失败']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'配置文件创建失败']);
return DataReturn('配置文件创建失败', -1);
}
- new \base\Behavior(['msg'=>'安装成功']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'安装成功']);
return DataReturn('安装成功', 0);
}
@@ -322,7 +328,7 @@ php;
{
if(!file_exists(ROOT.'config/shopxo.sql'))
{
- new \base\Behavior(['msg'=>'数据库sql文件不存在']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'数据库sql文件不存在']);
return DataReturn('数据库sql文件不存在', -1);
}
@@ -363,7 +369,7 @@ php;
'success' => $success,
'failure' => $failure,
];
- new \base\Behavior(['msg'=>'sql运行 成功['.$success.']条, 失败['.$failure.']条']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'sql运行 成功['.$success.']条, 失败['.$failure.']条']);
if($failure > 0)
{
return DataReturn('sql运行失败['.$failure.']条', -1);
@@ -387,14 +393,14 @@ php;
$data = $db->query("select version() AS version");
if(empty($data[0]['version']))
{
- new \base\Behavior(['msg'=>'查询数据库版本失败']);
+ $this->behavior_obj->ReportInstallLog(['msg'=>'查询数据库版本失败']);
return DataReturn('查询数据库版本失败', -1);
} else {
$mysql_version = str_replace('-log', '', $data[0]['version']);
if($mysql_version < $this->charset_type_list[$db_charset]['version'])
{
$msg = '数据库版本过低、需要>='.$this->charset_type_list[$db_charset]['version'].'、当前'.$mysql_version;
- new \base\Behavior(['msg'=>$msg, 'mysql_version'=>$mysql_version]);
+ $this->behavior_obj->ReportInstallLog(['msg'=>$msg, 'mysql_version'=>$mysql_version]);
return DataReturn($msg, -1);
}
}
diff --git a/application/service/PayRequestLogService.php b/application/service/PayRequestLogService.php
new file mode 100644
index 000000000..9346da3f6
--- /dev/null
+++ b/application/service/PayRequestLogService.php
@@ -0,0 +1,145 @@
+ $business_type,
+ 'request_params' => empty($params) ? '' : (is_array($params) ? json_encode($params, JSON_UNESCAPED_UNICODE) : $params),
+ 'response_data' => '',
+ 'business_handle' => '',
+ 'request_url' => $behavior_obj->GetUrl('request'),
+ 'server_port' => $behavior_obj->GetServerPort(),
+ 'server_ip' => $behavior_obj->GetServerIP(),
+ 'client_ip' => $behavior_obj->GetClientIP(),
+ 'os' => $behavior_obj->GetOs(),
+ 'browser' => $behavior_obj->GetBrowser(),
+ 'method' => $behavior_obj->GetMethod(),
+ 'scheme' => $behavior_obj->GetScheme(),
+ 'version' => $behavior_obj->GetHttpVersion(),
+ 'client' => $behavior_obj->GetClinet(),
+ 'add_time' => time(),
+ ];
+ $log_id = Db::name('PayRequestLog')->insertGetId($data);
+ if($log_id > 0)
+ {
+ return DataReturn('支付请求日志添加成功', 0, $log_id);
+ }
+ return DataReturn('支付请求日志添加失败', -100);
+ }
+
+ /**
+ * 支付响应日志添加
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2020-09-23
+ * @desc description
+ * @param [int] $log_id [日志id]
+ * @param [array] $data [业务处理结果]
+ * @param [string] $res [响应数据]
+ */
+ public static function PayRequestLogEnd($log_id, $data, $res)
+ {
+ $data = [
+ 'business_handle' => empty($data) ? '' : (is_array($data) ? json_encode($data, JSON_UNESCAPED_UNICODE) : $data),
+ 'upd_time' => time(),
+ 'response_data' => empty($res) ? '' : (is_array($res) ? json_encode($res, JSON_UNESCAPED_UNICODE) : $res),
+ 'upd_time' => time(),
+ ];
+ if(Db::name('PayRequestLog')->where(['id'=>$log_id])->update($data))
+ {
+ return DataReturn('支付请求日志更新成功', 0, $log_id);
+ }
+ return DataReturn('支付请求日志更新失败', -100);
+ }
+
+ /**
+ * 列表
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2018-09-29
+ * @desc description
+ * @param [array] $params [输入参数]
+ */
+ public static function PayRequestLogList($params = [])
+ {
+ $where = empty($params['where']) ? [] : $params['where'];
+ $m = isset($params['m']) ? intval($params['m']) : 0;
+ $n = isset($params['n']) ? intval($params['n']) : 10;
+ $field = '*';
+ $order_by = empty($params['order_by']) ? 'id desc' : $params['order_by'];
+
+ // 获取数据列表
+ $data = Db::name('PayRequestLog')->where($where)->field($field)->limit($m, $n)->order($order_by)->select();
+ if(!empty($data))
+ {
+ // 循环处理数据
+ foreach($data as &$v)
+ {
+ // 时间
+ $v['add_time'] = empty($v['add_time']) ? '' : date('Y-m-d H:i:s', $v['add_time']);
+ $v['upd_time'] = empty($v['upd_time']) ? '' : date('Y-m-d H:i:s', $v['upd_time']);
+ }
+ }
+ return DataReturn('处理成功', 0, $data);
+ }
+
+ /**
+ * 总数
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2018-09-29
+ * @desc description
+ * @param [array] $where [条件]
+ */
+ public static function PayRequestLogTotal($where = [])
+ {
+ return (int) Db::name('PayRequestLog')->where($where)->count();
+ }
+}
+?>
\ No newline at end of file
diff --git a/extend/base/Behavior.php b/extend/base/Behavior.php
index fb000f338..2c42cdfae 100755
--- a/extend/base/Behavior.php
+++ b/extend/base/Behavior.php
@@ -11,7 +11,7 @@
namespace base;
/**
- * 行为记录
+ * 行为信息驱动
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
@@ -20,132 +20,62 @@ namespace base;
class Behavior
{
/**
- * [__construct 开始收集数据]
- * @author Devil
- * @blog http://gong.gg/
- * @version 0.0.1
- * @datetime 2017-04-11T16:51:02+0800
- * @param [array] $param [参数]
+ * 上报安装日志
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2020-09-23
+ * @desc description
+ * @param [array] $params [输入参数]
*/
- public function __construct($param = array())
+ public function ReportInstallLog($params = [])
{
// 数据列表
- $data = array(
- 'user' => $this->GetUserCookie(),
- 'host' => $this->GetUrl('host'),
- 'server_port' => $this->GetServerPort(),
- 'server_ip' => $this->GetServerIP(),
- 'url' => $this->GetUrl('url'),
- 'request_url' => $this->GetUrl('request'),
- 'source_url' => $this->GetSourceUrl(),
- 'client_ip' => $this->GetClientIP(),
- 'os' => $this->GetOs(),
- 'browser' => $this->GetBrowser(),
- 'method' => $this->GetMethod(),
- 'scheme' => $this->GetScheme(),
- 'version' => $this->GetHttpVersion(),
- 'client' => $this->GetClinet(),
- 'php_os' => PHP_OS,
- 'php_version' => PHP_VERSION,
- 'php_sapi_name' => php_sapi_name(),
- 'client_date' => date('Y-m-d H:i:s'),
- 'ymd' => date('Ymd'),
- 'ver' => str_replace('v', '', APPLICATION_VERSION),
- );
+ $data = [
+ 'user' => $this->GetUserCookie(),
+ 'host' => $this->GetUrl('host'),
+ 'server_port' => $this->GetServerPort(),
+ 'server_ip' => $this->GetServerIP(),
+ 'url' => $this->GetUrl('url'),
+ 'request_url' => $this->GetUrl('request'),
+ 'source_url' => $this->GetSourceUrl(),
+ 'client_ip' => $this->GetClientIP(),
+ 'os' => $this->GetOs(),
+ 'browser' => $this->GetBrowser(),
+ 'method' => $this->GetMethod(),
+ 'scheme' => $this->GetScheme(),
+ 'version' => $this->GetHttpVersion(),
+ 'client' => $this->GetClinet(),
+ 'php_os' => PHP_OS,
+ 'php_version' => PHP_VERSION,
+ 'php_sapi_name' => php_sapi_name(),
+ 'client_date' => date('Y-m-d H:i:s'),
+ 'ymd' => date('Ymd'),
+ 'ver' => str_replace('v', '', APPLICATION_VERSION),
+ ];
// 描述信息
- if(!empty($param['msg']))
+ if(!empty($params['msg']))
{
- $data['msg'] = $param['msg'];
+ $data['msg'] = $params['msg'];
}
// mysql版本
- if(!empty($param['mysql_version']))
+ if(!empty($params['mysql_version']))
{
- $data['mysql_version'] = $param['mysql_version'];
+ $data['mysql_version'] = $params['mysql_version'];
}
// 上报数据
$url = 'http://report.shopxo.net/install.php';
if(function_exists('curl_init'))
{
- $this->CurlPost($url, $data);
+ CurlPost($url, $data);
} else {
- $this->FsockopenPost($url, $data);
+ FsockopenPost($url, $data);
}
}
- /**
- * [CurlPost curl post]
- * @author Devil
- * @blog http://gong.gg/
- * @version 0.0.1
- * @datetime 2016-12-03T21:58:54+0800
- * @param [string] $url [请求地址]
- * @param [array] $post [发送的post数据]
- */
- private function CurlPost($url, $post)
- {
- $options = array(
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_HEADER => false,
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $post,
- );
-
- $ch = curl_init($url);
- curl_setopt_array($ch, $options);
-
- $result = curl_exec($ch);
- curl_close($ch);
-
- return $result;
- }
-
- /**
- * [FsockopenPost fsockopen方式]
- * @author Devil
- * @blog http://gong.gg/
- * @version 0.0.1
- * @datetime 2016-12-03T21:58:54+0800
- * @param [string] $url [url地址]
- * @param [string] $data [发送参数]
- */
- private function FsockopenPost($url, $data = '')
- {
- $row = parse_url($url);
- $host = $row['host'];
- $port = isset($row['port']) ? $row['port'] : 80;
- $file = $row['path'];
- $post = '';
- while (list($k,$v) = FunEach($data))
- {
- if(isset($k) && isset($v)) $post .= rawurlencode($k)."=".rawurlencode($v)."&"; //转URL标准码
- }
- $post = substr( $post , 0 , -1 );
- $len = strlen($post);
- $fp = @fsockopen( $host ,$port, $errno, $errstr, 10);
- if (!$fp) {
- return "$errstr ($errno)\n";
- } else {
- $receive = '';
- $out = "POST $file HTTP/1.0\r\n";
- $out .= "Host: $host\r\n";
- $out .= "Content-type: application/x-www-form-urlencoded\r\n";
- $out .= "Connection: Close\r\n";
- $out .= "Content-Length: $len\r\n\r\n";
- $out .= $post;
- fwrite($fp, $out);
- while (!feof($fp)) {
- $receive .= fgets($fp, 128);
- }
- fclose($fp);
- $receive = explode("\r\n\r\n",$receive);
- unset($receive[0]);
- return implode("",$receive);
- }
- }
-
/**
* [GetScheme http类型]
* @author Devil
@@ -153,9 +83,9 @@ class Behavior
* @version 0.0.1
* @datetime 2017-04-11T16:04:33+0800
*/
- private function GetScheme()
+ public function GetScheme()
{
- return empty($_SERVER['HTTPS']) ? 'HTTP' : 'HTTPS';
+ return strtoupper(__MY_HTTP__);
}
/**
@@ -165,7 +95,7 @@ class Behavior
* @version 0.0.1
* @datetime 2017-04-11T16:04:56+0800
*/
- private function GetClinet()
+ public function GetClinet()
{
return empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
}
@@ -177,7 +107,7 @@ class Behavior
* @version 0.0.1
* @datetime 2017-04-11T16:04:43+0800
*/
- private function GetHttpVersion()
+ public function GetHttpVersion()
{
return empty($_SERVER['SERVER_PROTOCOL']) ? '' : str_replace(array('HTTP/', 'HTTPS/'), '', $_SERVER['SERVER_PROTOCOL']);
}
@@ -189,7 +119,7 @@ class Behavior
* @version 0.0.1
* @datetime 2017-04-11T16:04:23+0800
*/
- private function GetMethod()
+ public function GetMethod()
{
return empty($_SERVER['REQUEST_METHOD']) ? '' : $_SERVER['REQUEST_METHOD'];
}
@@ -201,7 +131,7 @@ class Behavior
* @version 0.0.1
* @datetime 2017-04-11T16:02:06+0800
*/
- private function GetOs()
+ public function GetOs()
{
if(!empty($_SERVER['HTTP_USER_AGENT']))
{
@@ -242,7 +172,7 @@ class Behavior
* @version 0.0.1
* @datetime 2017-04-11T16:03:14+0800
*/
- private function GetBrowser()
+ public function GetBrowser()
{
if(!empty($_SERVER['HTTP_USER_AGENT']))
{
@@ -278,41 +208,23 @@ class Behavior
* @datetime 2017-04-11T16:29:03+0800
* @param [string] $type [host:host地址, url:url地址, request:完整url地址]
*/
- private function GetUrl($type = 'url')
+ public function GetUrl($type = 'url')
{
- // 当前host
- $host = empty($_SERVER['HTTP_HOST']) ? '' : $_SERVER['HTTP_HOST'];
-
- // 是否获取host
- if($type == 'host')
+ switch($type)
{
- return $host;
- }
+ // host
+ case 'host' :
+ return __MY_HOST__;
+ break;
- // http类型
- $http = empty($_SERVER['HTTPS']) ? 'http' : 'https';
+ // 当前url
+ case 'url' :
+ return __MY_URL__;
+ break;
- // 根目录
- $root = '';
- if(!empty($_SERVER['SCRIPT_NAME']))
- {
- $root = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')+1);
- } else {
- if(!empty($_SERVER['PHP_SELF']))
- {
- $root = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')+1);
- }
- }
-
- // url 或 request
- if($type == 'url')
- {
- return $http.'://'.$host.$root;
- } else {
- if(!empty($_SERVER['REQUEST_URI']))
- {
- return $http.'://'.$host.$_SERVER['REQUEST_URI'];
- }
+ // 当前url+参数
+ default :
+ return __MY_VIEW_URL__;
}
}
@@ -323,7 +235,7 @@ class Behavior
* @version 0.0.1
* @datetime 2017-04-11T16:34:24+0800
*/
- private function GetServerIP()
+ public function GetServerIP()
{
return empty($_SERVER['SERVER_ADDR']) ? '' : $_SERVER['SERVER_ADDR'];
}
@@ -335,7 +247,7 @@ class Behavior
* @version 0.0.1
* @datetime 2017-04-11T16:35:42+0800
*/
- private function GetServerPort()
+ public function GetServerPort()
{
return empty($_SERVER['SERVER_PORT']) ? 80 : $_SERVER['SERVER_PORT'];
}
@@ -350,25 +262,7 @@ class Behavior
*/
function GetClientIP($long = false)
{
- $onlineip = '';
- if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'),'unknown'))
- {
- $onlineip = getenv('HTTP_CLIENT_IP');
- } elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown'))
- {
- $onlineip = getenv('HTTP_X_FORWARDED_FOR');
- } elseif(getenv('REMOTE_ADDR' ) && strcasecmp(getenv('REMOTE_ADDR'),'unknown'))
- {
- $onlineip = getenv('REMOTE_ADDR');
- } elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'],'unknown'))
- {
- $onlineip = $_SERVER['REMOTE_ADDR'];
- }
- if($long)
- {
- $onlineip = sprintf("%u", ip2long($realip));
- }
- return $onlineip;
+ return GetClientIP($long);
}
/**
@@ -378,7 +272,7 @@ class Behavior
* @version 0.0.1
* @datetime 2017-04-11T15:57:00+0800
*/
- private function GetSourceUrl()
+ public function GetSourceUrl()
{
return empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
}
@@ -390,7 +284,7 @@ class Behavior
* @version 0.0.1
* @datetime 2017-04-11T15:55:12+0800
*/
- private function GetUserCookie()
+ public function GetUserCookie()
{
if(!empty($_COOKIE['behavior_user_cookie'])) return $_COOKIE['behavior_user_cookie'];
@@ -406,7 +300,7 @@ class Behavior
* @version 0.0.1
* @datetime 2017-04-11T15:56:14+0800
*/
- private function GetUserNumberRand()
+ public function GetUserNumberRand()
{
$str = date('YmdHis');
for($i=0; $i<6; $i++) $str .= rand(0, 9);
diff --git a/public/static/admin/default/css/payrequestlog.css b/public/static/admin/default/css/payrequestlog.css
new file mode 100644
index 000000000..2252a32bd
--- /dev/null
+++ b/public/static/admin/default/css/payrequestlog.css
@@ -0,0 +1,3 @@
+.pre-container {
+ height: 130px;
+}
\ No newline at end of file