diff --git a/app/Components/CaptchaVerify.php b/app/Components/CaptchaVerify.php
index 32cdb8c9..b8f9e4c2 100644
--- a/app/Components/CaptchaVerify.php
+++ b/app/Components/CaptchaVerify.php
@@ -7,11 +7,9 @@ namespace App\Components;
*
* @package App\Components
*/
-class CaptchaVerify
-{
+class CaptchaVerify {
//从后台获取 hcaptcha_sitekey 和 hcaptcha_secret
- public static function hCaptchaGetConfig()
- {
+ public static function hCaptchaGetConfig() {
return [
"sitekey" => Helpers::systemConfig()["hcaptcha_sitekey"],
"secret" => Helpers::systemConfig()["hcaptcha_secret"],
@@ -20,8 +18,7 @@ class CaptchaVerify
}
//从后台获取 Geetest_id 和 Geetest_key
- public static function geetestCaptchaGetConfig()
- {
+ public static function geetestCaptchaGetConfig() {
return [
"geetest_id" => Helpers::systemConfig()["geetest_id"],
"geetest_key" => Helpers::systemConfig()["geetest_key"]
@@ -29,8 +26,7 @@ class CaptchaVerify
}
//从后台获取 google_captcha_sitekey 和 google_captcha_secret
- public static function googleCaptchaGetConfig()
- {
+ public static function googleCaptchaGetConfig() {
return [
"sitekey" => Helpers::systemConfig()["google_captcha_sitekey"],
"secret" => Helpers::systemConfig()["google_captcha_secret"],
@@ -39,4 +35,4 @@ class CaptchaVerify
}
}
-?>
\ No newline at end of file
+?>
diff --git a/app/Components/Curl.php b/app/Components/Curl.php
index 0ab79635..722203d6 100644
--- a/app/Components/Curl.php
+++ b/app/Components/Curl.php
@@ -2,21 +2,19 @@
namespace App\Components;
-class Curl
-{
+class Curl {
/**
- * @param string $url 请求地址
- * @param array $data 数据,如果有数据则用POST请求
+ * @param string $url 请求地址
+ * @param array $data 数据,如果有数据则用POST请求
*
* @return mixed
*/
- public static function send($url, $data = [])
- {
+ public static function send($url, $data = []) {
$ch = curl_init();
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL, $url);
if($data){
@@ -29,4 +27,4 @@ class Curl
return $result;
}
-}
\ No newline at end of file
+}
diff --git a/app/Components/Helpers.php b/app/Components/Helpers.php
index 42a6ac02..f1f573ad 100644
--- a/app/Components/Helpers.php
+++ b/app/Components/Helpers.php
@@ -12,8 +12,7 @@ use App\Http\Models\UserBalanceLog;
use App\Http\Models\UserSubscribe;
use App\Http\Models\UserTrafficModifyLog;
-class Helpers
-{
+class Helpers {
// 不生成的端口
private static $denyPorts = [
1068, 1109, 1434, 3127, 3128,
@@ -24,32 +23,27 @@ class Helpers
];
// 加密方式
- public static function methodList()
- {
+ public static function methodList() {
return SsConfig::type(1)->get();
}
// 协议
- public static function protocolList()
- {
+ public static function protocolList() {
return SsConfig::type(2)->get();
}
// 混淆
- public static function obfsList()
- {
+ public static function obfsList() {
return SsConfig::type(3)->get();
}
// 等级
- public static function levelList()
- {
+ public static function levelList() {
return Level::query()->get()->sortBy('level');
}
// 生成用户的订阅码
- public static function makeSubscribeCode()
- {
+ public static function makeSubscribeCode() {
$code = makeRandStr(5);
if(UserSubscribe::query()->whereCode($code)->exists()){
$code = self::makeSubscribeCode();
@@ -61,16 +55,15 @@ class Helpers
/**
* 添加用户
*
- * @param string $email 用户邮箱
- * @param string $password 用户密码
- * @param string $transfer_enable 可用流量
- * @param int $data 可使用天数
- * @param int $referral_uid 邀请人
+ * @param string $email 用户邮箱
+ * @param string $password 用户密码
+ * @param string $transfer_enable 可用流量
+ * @param int $data 可使用天数
+ * @param int $referral_uid 邀请人
*
* @return int
*/
- public static function addUser($email, $password, $transfer_enable, $data, $referral_uid = 0)
- {
+ public static function addUser($email, $password, $transfer_enable, $data, $referral_uid = 0) {
$user = new User();
$user->username = $email;
$user->email = $email;
@@ -91,7 +84,7 @@ class Helpers
$user->expire_time = date('Y-m-d', strtotime("+".$data." days"));
$user->reg_ip = getClientIp();
$user->referral_uid = $referral_uid;
- $user->reset_time = NULL;
+ $user->reset_time = null;
$user->status = 0;
$user->save();
@@ -99,22 +92,20 @@ class Helpers
}
// 获取系统配置
- public static function systemConfig()
- {
+ public static function systemConfig() {
$config = Config::query()->get();
$data = [];
foreach($config as $vo){
$data[$vo->name] = $vo->value;
}
- $data['is_onlinePay'] = ($data['is_AliPay'] || $data['is_QQPay'] || $data['is_WeChatPay'] || $data['is_otherPay'])? : 0;
+ $data['is_onlinePay'] = ($data['is_AliPay'] || $data['is_QQPay'] || $data['is_WeChatPay'] || $data['is_otherPay'])?: 0;
return $data;
}
// 获取一个随机端口
- public static function getRandPort()
- {
+ public static function getRandPort() {
$config = self::systemConfig();
$port = mt_rand($config['min_port'], $config['max_port']);
@@ -127,38 +118,34 @@ class Helpers
}
// 获取一个随机端口
- public static function getOnlyPort()
- {
+ public static function getOnlyPort() {
$config = self::systemConfig();
$port = $config['min_port'];
$exists_port = User::query()->where('port', '>=', $port)->pluck('port')->toArray();
while(in_array($port, $exists_port) || in_array($port, self::$denyPorts)){
- $port = $port+1;
+ $port = $port + 1;
}
return $port;
}
// 获取默认加密方式
- public static function getDefaultMethod()
- {
+ public static function getDefaultMethod() {
$config = SsConfig::default()->type(1)->first();
return $config? $config->name : 'aes-256-cfb';
}
// 获取默认协议
- public static function getDefaultProtocol()
- {
+ public static function getDefaultProtocol() {
$config = SsConfig::default()->type(2)->first();
return $config? $config->name : 'origin';
}
// 获取默认混淆
- public static function getDefaultObfs()
- {
+ public static function getDefaultObfs() {
$config = SsConfig::default()->type(3)->first();
return $config? $config->name : 'plain';
@@ -167,17 +154,16 @@ class Helpers
/**
* 添加通知推送日志
*
- * @param string $title 标题
- * @param string $content 内容
- * @param int $type 发送类型
- * @param string $address 收信方
- * @param int $status 投递状态
- * @param string $error 投递失败时记录的异常信息
+ * @param string $title 标题
+ * @param string $content 内容
+ * @param int $type 发送类型
+ * @param string $address 收信方
+ * @param int $status 投递状态
+ * @param string $error 投递失败时记录的异常信息
*
* @return int
*/
- public static function addNotificationLog($title, $content, $type, $address = 'admin', $status = 1, $error = '')
- {
+ public static function addNotificationLog($title, $content, $type, $address = 'admin', $status = 1, $error = '') {
$log = new NotificationLog();
$log->type = $type;
$log->address = $address;
@@ -193,15 +179,14 @@ class Helpers
/**
* 添加优惠券操作日志
*
- * @param int $couponId 优惠券ID
- * @param int $goodsId 商品ID
- * @param int $orderId 订单ID
- * @param string $desc 备注
+ * @param int $couponId 优惠券ID
+ * @param int $goodsId 商品ID
+ * @param int $orderId 订单ID
+ * @param string $desc 备注
*
* @return int
*/
- public static function addCouponLog($couponId, $goodsId, $orderId, $desc = '')
- {
+ public static function addCouponLog($couponId, $goodsId, $orderId, $desc = '') {
$log = new CouponLog();
$log->coupon_id = $couponId;
$log->goods_id = $goodsId;
@@ -214,17 +199,16 @@ class Helpers
/**
* 记录余额操作日志
*
- * @param int $userId 用户ID
- * @param string $oid 订单ID
- * @param int $before 记录前余额
- * @param int $after 记录后余额
- * @param int $amount 发生金额
- * @param string $desc 描述
+ * @param int $userId 用户ID
+ * @param string $oid 订单ID
+ * @param int $before 记录前余额
+ * @param int $after 记录后余额
+ * @param int $amount 发生金额
+ * @param string $desc 描述
*
* @return int
*/
- public static function addUserBalanceLog($userId, $oid, $before, $after, $amount, $desc = '')
- {
+ public static function addUserBalanceLog($userId, $oid, $before, $after, $amount, $desc = '') {
$log = new UserBalanceLog();
$log->user_id = $userId;
$log->order_id = $oid;
@@ -240,16 +224,15 @@ class Helpers
/**
* 记录流量变动日志
*
- * @param int $userId 用户ID
- * @param string $oid 订单ID
- * @param int $before 记录前的值
- * @param int $after 记录后的值
- * @param string $desc 描述
+ * @param int $userId 用户ID
+ * @param string $oid 订单ID
+ * @param int $before 记录前的值
+ * @param int $after 记录后的值
+ * @param string $desc 描述
*
* @return int
*/
- public static function addUserTrafficModifyLog($userId, $oid, $before, $after, $desc = '')
- {
+ public static function addUserTrafficModifyLog($userId, $oid, $before, $after, $desc = '') {
$log = new UserTrafficModifyLog();
$log->user_id = $userId;
$log->order_id = $oid;
@@ -259,4 +242,4 @@ class Helpers
return $log->save();
}
-}
\ No newline at end of file
+}
diff --git a/app/Components/IPIP.php b/app/Components/IPIP.php
index 49875f46..3e18dcf7 100644
--- a/app/Components/IPIP.php
+++ b/app/Components/IPIP.php
@@ -4,20 +4,18 @@ namespace App\Components;
use ipip\db\City;
-class IPIP
-{
+class IPIP {
/**
* 查询IP地址的详细信息
*
- * @param string $ip IPv4
+ * @param string $ip IPv4
*
* @return array|null
*/
- public static function ip($ip)
- {
+ public static function ip($ip) {
$filePath = public_path('ipip.ipdb');
$loc = new City($filePath);
return $loc->findMap($ip, 'CN');
}
-}
\ No newline at end of file
+}
diff --git a/app/Components/Namesilo.php b/app/Components/Namesilo.php
index 745f18e2..c8314b99 100644
--- a/app/Components/Namesilo.php
+++ b/app/Components/Namesilo.php
@@ -6,26 +6,22 @@ use Exception;
use Log;
use LSS\XML2Array;
-class Namesilo
-{
+class Namesilo {
protected static $host;
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$host = 'https://www.namesilo.com/api/';
self::$systemConfig = Helpers::systemConfig();
}
// 列出账号下所有域名
- public function listDomains()
- {
+ public function listDomains() {
return $this->send('listDomains');
}
// 发送请求
- private function send($operation, $data = [])
- {
+ private function send($operation, $data = []) {
$params = [
'version' => 1,
'type' => 'xml',
@@ -41,23 +37,27 @@ class Namesilo
// 出错
if(empty($result['namesilo']) || $result['namesilo']['reply']['code'] != 300 || $result['namesilo']['reply']['detail'] != 'success'){
- Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1, self::$systemConfig['webmaster_email'], 0, $result['namesilo']['reply']['detail']);
+ Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1,
+ self::$systemConfig['webmaster_email'], 0,
+ $result['namesilo']['reply']['detail']);
}else{
- Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1, self::$systemConfig['webmaster_email'], 1, $result['namesilo']['reply']['detail']);
+ Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1,
+ self::$systemConfig['webmaster_email'], 1,
+ $result['namesilo']['reply']['detail']);
}
return $result['namesilo']['reply'];
}catch(Exception $e){
Log::error('CURL请求失败:'.$e->getMessage().' --- '.$e->getLine());
- Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1, self::$systemConfig['webmaster_email'], 0, $e->getMessage());
+ Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1,
+ self::$systemConfig['webmaster_email'], 0, $e->getMessage());
- return FALSE;
+ return false;
}
}
// 列出指定域名的所有DNS记录
- public function dnsListRecords($domain)
- {
+ public function dnsListRecords($domain) {
$query = [
'domain' => $domain
];
@@ -66,8 +66,7 @@ class Namesilo
}
// 为指定域名添加DNS记录
- public function dnsAddRecord($domain, $host, $value, $type = 'A', $ttl = 7207)
- {
+ public function dnsAddRecord($domain, $host, $value, $type = 'A', $ttl = 7207) {
$query = [
'domain' => $domain,
'rrtype' => $type,
@@ -80,8 +79,7 @@ class Namesilo
}
// 更新DNS记录
- public function dnsUpdateRecord($domain, $id, $host, $value, $ttl = 7207)
- {
+ public function dnsUpdateRecord($domain, $id, $host, $value, $ttl = 7207) {
$query = [
'domain' => $domain,
'rrid' => $id,
@@ -94,8 +92,7 @@ class Namesilo
}
// 删除DNS记录
- public function dnsDeleteRecord($domain, $id)
- {
+ public function dnsDeleteRecord($domain, $id) {
$data = [
'domain' => $domain,
'rrid' => $id
@@ -103,4 +100,4 @@ class Namesilo
return $this->send('dnsDeleteRecord', $data);
}
-}
\ No newline at end of file
+}
diff --git a/app/Components/NetworkDetection.php b/app/Components/NetworkDetection.php
index e52ce91a..368d2ea3 100644
--- a/app/Components/NetworkDetection.php
+++ b/app/Components/NetworkDetection.php
@@ -5,45 +5,43 @@ namespace App\Components;
use Exception;
use Log;
-class NetworkDetection
-{
+class NetworkDetection {
/**
* 用api.50network.com进行节点阻断检测
*
- * @param string $ip 被检测的IP
- * @param boolean $type TRUE 为ICMP,FALSE 为tcp
- * @param int $port 检测端口,默认为空
+ * @param string $ip 被检测的IP
+ * @param boolean $type TRUE 为ICMP,FALSE 为tcp
+ * @param int $port 检测端口,默认为空
*
* @return bool|string
*/
- public static function networkCheck($ip, $type, $port = NULL)
- {
+ public static function networkCheck($ip, $type, $port = null) {
$url = 'https://api.50network.com/china-firewall/check/ip/'.($type? 'icmp/' : ($port? 'tcp_port/' : 'tcp_ack/')).$ip.($port? '/'.$port : '');
$checkName = $type? 'ICMP' : 'TCP';
try{
- $ret = json_decode(Curl::send($url), TRUE);
+ $ret = json_decode(Curl::send($url), true);
if(!$ret){
Log::warning("【".$checkName."阻断检测】检测".$ip."时,接口返回异常访问链接:".$url);
- return FALSE;
+ return false;
}elseif(!$ret['success']){
if($ret['error'] == "execute timeout (3s)"){
sleep(10);
return self::networkCheck($ip, $type, $port);
}else{
- Log::warning("【".$checkName."阻断检测】检测".$ip.($port? : '')."时,返回".json_encode($ret));
+ Log::warning("【".$checkName."阻断检测】检测".$ip.($port?: '')."时,返回".json_encode($ret));
}
- return FALSE;
+ return false;
}
}catch(Exception $e){
Log::warning("【".$checkName."阻断检测】检测".$ip."时,接口请求超时".$e);
- return FALSE;
+ return false;
}
if($ret['firewall-enable'] && $ret['firewall-disable']){
@@ -60,33 +58,32 @@ class NetworkDetection
/**
* 用api.iiwl.cc进行Ping检测
*
- * @param string $ip 被检测的IP或者域名
+ * @param string $ip 被检测的IP或者域名
*
* @return bool|array
*/
- public static function ping($ip)
- {
+ public static function ping($ip) {
$url = 'https://api.iiwl.cc/api/ping.php?url='.$ip;
try{
- $ret = json_decode(Curl::send($url), TRUE);
+ $ret = json_decode(Curl::send($url), true);
if(!$ret){
Log::warning("【PING】检测".$ip."时,接口返回异常访问链接:".$url);
- return FALSE;
+ return false;
}elseif($ret['code'] != 1 || $ret['msg'] != "检测成功!"){
Log::warning("【PING】检测".$ip."时,返回".json_encode($ret));
- return FALSE;
+ return false;
}
}catch(Exception $e){
Log::warning("【Ping】检测".$ip."时,接口请求超时".$e);
- return FALSE;
+ return false;
}
return $ret['data']; // 服务器宕机
}
}
-?>
\ No newline at end of file
+?>
diff --git a/app/Components/PushNotification.php b/app/Components/PushNotification.php
index 467db748..41434836 100644
--- a/app/Components/PushNotification.php
+++ b/app/Components/PushNotification.php
@@ -7,10 +7,8 @@ use Exception;
use Log;
use stdClass;
-class PushNotification
-{
- public static function send($title, $content)
- {
+class PushNotification {
+ public static function send($title, $content) {
switch(Helpers::systemConfig()['is_notification']){
case 'serverChan':
return self::ServerChan($title, $content);
@@ -19,33 +17,32 @@ class PushNotification
return self::Bark($title, $content);
break;
default:
- return FALSE;
+ return false;
}
}
/**
* ServerChan推送消息
*
- * @param string $title 消息标题
- * @param string $content 消息内容
+ * @param string $title 消息标题
+ * @param string $content 消息内容
*
* @return mixed
*/
- private static function ServerChan($title, $content)
- {
- $ret = FALSE;
+ private static function ServerChan($title, $content) {
+ $ret = false;
try{
// TODO:一天仅可发送不超过500条
$url = 'https://sc.ftqq.com/'.Helpers::systemConfig()['server_chan_key'].'.send?text='.$title.'&desp='.urlencode($content);
$result = json_decode(Curl::send($url));
if(empty(Helpers::systemConfig()['server_chan_key'])){
$result = new stdClass();
- $result->errno = TRUE;
+ $result->errno = true;
$result->errmsg = "未正确配置ServerChan";
}
- if($result != NULL && !$result->errno){
+ if($result != null && !$result->errno){
Helpers::addNotificationLog($title, $content, 2);
- $ret = TRUE;
+ $ret = true;
}else{
Helpers::addNotificationLog($title, $content, 2, 'admin', 1, $result? $result->errmsg : '未知');
}
@@ -60,21 +57,20 @@ class PushNotification
/**
* Bark推送消息
*
- * @param string $title 消息标题
- * @param string $content 消息内容
+ * @param string $title 消息标题
+ * @param string $content 消息内容
*
* @return mixed
*/
- private static function Bark($title, $content)
- {
- $ret = FALSE;
+ private static function Bark($title, $content) {
+ $ret = false;
try{
$url = 'https://api.day.app/'.Helpers::systemConfig()['bark_key'].'/'.$title.'/'.$content;
$result = json_decode(Curl::send($url));
if($result){
if($result->code == 200){
Helpers::addNotificationLog($title, $content, 3);
- $ret = TRUE;
+ $ret = true;
}else{
Helpers::addNotificationLog($title, $content, 3, 'admin', $result->message);
}
@@ -85,4 +81,4 @@ class PushNotification
return $ret;
}
-}
\ No newline at end of file
+}
diff --git a/app/Components/QQInfo.php b/app/Components/QQInfo.php
index a3c7eddc..6fcedde5 100644
--- a/app/Components/QQInfo.php
+++ b/app/Components/QQInfo.php
@@ -2,41 +2,38 @@
namespace App\Components;
-class QQInfo
-{
+class QQInfo {
/**
* 通过QQ号查询头像与昵称信息
*
- * @param string $qq QQ号
+ * @param string $qq QQ号
*
* @return string
*/
- public static function getName($qq)
- {
+ public static function getName($qq) {
//向接口发起请求获取json数据
$url = 'https://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?get_nick=1&uins='.$qq;
$ret = mb_convert_encoding(Curl::send($url), "UTF-8", "GBK");
// 接口是否异常
//echo $ret;
- if(strpos($ret, $qq) !== FALSE){
+ if(strpos($ret, $qq) !== false){
//对获取的json数据进行截取并解析成数组
- $ret = json_decode(substr($ret, 17, -1), TRUE);
+ $ret = json_decode(substr($ret, 17, -1), true);
return stripslashes($ret[$qq][6]);
}
echo $qq.PHP_EOL;
- return FALSE;
+ return false;
}
- public static function getName2($qq)
- {
+ public static function getName2($qq) {
//向接口发起请求获取json数据
$url = 'https://api.toubiec.cn/qq?qq='.$qq.'&size=100';
- $ret = json_decode(Curl::send($url), TRUE);
+ $ret = json_decode(Curl::send($url), true);
// 接口是否异常
if($ret){
if($ret['code'] == 200){
@@ -46,14 +43,13 @@ class QQInfo
echo $qq.PHP_EOL;
- return FALSE;
+ return false;
}
- public static function getName3($qq)
- {
+ public static function getName3($qq) {
//向接口发起请求获取json数据
$url = 'https://api.unipay.qq.com/v1/r/1450000186/wechat_query?cmd=1&pf=mds_storeopen_qb-__mds_qqclub_tab_-html5&pfkey=pfkey&from_h5=1&from_https=1&openid=openid&openkey=openkey&session_id=hy_gameid&session_type=st_dummy&qq_appid=&offerId=1450000186&sandbox=&provide_uin='.$qq;
- $ret = json_decode(Curl::send($url), TRUE);
+ $ret = json_decode(Curl::send($url), true);
// 接口是否异常
if($ret){
if($ret['ret'] == 0){
@@ -63,6 +59,6 @@ class QQInfo
echo $qq.PHP_EOL;
- return FALSE;
+ return false;
}
-}
\ No newline at end of file
+}
diff --git a/app/Components/QQWry.php b/app/Components/QQWry.php
index ce3e60e0..f20b3b6c 100644
--- a/app/Components/QQWry.php
+++ b/app/Components/QQWry.php
@@ -4,19 +4,17 @@ namespace App\Components;
use itbdw\Ip\IpLocation;
-class QQWry
-{
+class QQWry {
/**
* 查询IP地址的详细信息
*
- * @param string $ip IPv4
+ * @param string $ip IPv4
*
* @return array
*/
- public static function ip($ip)
- {
+ public static function ip($ip) {
$filePath = public_path('qqwry.dat');
return IpLocation::getLocation($ip, $filePath);
}
-}
\ No newline at end of file
+}
diff --git a/app/Console/Commands/AutoClearLog.php b/app/Console/Commands/AutoClearLog.php
index 7d6d052d..413a7419 100644
--- a/app/Console/Commands/AutoClearLog.php
+++ b/app/Console/Commands/AutoClearLog.php
@@ -18,34 +18,30 @@ use Exception;
use Illuminate\Console\Command;
use Log;
-class AutoClearLog extends Command
-{
+class AutoClearLog extends Command {
protected $signature = 'autoClearLog';
protected $description = '自动清除日志';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
// 清除日志
if(Helpers::systemConfig()['is_clear_log']){
$this->clearLog();
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
// 清除日志
- private function clearLog()
- {
+ private function clearLog() {
// 自动清除30分钟以前的节点负载信息日志
try{
SsNodeInfo::query()->where('log_time', '<=', strtotime("-30 minutes"))->delete();
@@ -60,13 +56,19 @@ class AutoClearLog extends Command
UserTrafficHourly::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-3 days')))->delete();
// 自动清除1个月以前的用户每天流量数据日志
- UserTrafficDaily::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-1 month 5 days')))->delete();
+ UserTrafficDaily::query()
+ ->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-1 month 5 days')))
+ ->delete();
// 自动清除2个月以前的节点每小时流量数据日志
- SsNodeTrafficHourly::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-2 month')))->delete();
+ SsNodeTrafficHourly::query()
+ ->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-2 month')))
+ ->delete();
// 自动清除3个月以前的节点每天流量数据日志
- SsNodeTrafficDaily::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-3 month')))->delete();
+ SsNodeTrafficDaily::query()
+ ->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-3 month')))
+ ->delete();
// 自动清除30天以前用户封禁日志
UserBanLog::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime("-1 month")))->delete();
@@ -78,7 +80,9 @@ class AutoClearLog extends Command
UserLoginLog::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime("-3 month")))->delete();
// 自动清除1个月前的用户订阅记录
- UserSubscribeLog::query()->where('request_time', '<=', date('Y-m-d H:i:s', strtotime("-1 month")))->delete();
+ UserSubscribeLog::query()
+ ->where('request_time', '<=', date('Y-m-d H:i:s', strtotime("-1 month")))
+ ->delete();
}catch(Exception $e){
Log::error('【清理日志】错误: '.$e->getMessage());
}
diff --git a/app/Console/Commands/AutoJob.php b/app/Console/Commands/AutoJob.php
index 7bf450f1..4eeffc1e 100644
--- a/app/Console/Commands/AutoJob.php
+++ b/app/Console/Commands/AutoJob.php
@@ -23,14 +23,12 @@ use Exception;
use Illuminate\Console\Command;
use Log;
-class AutoJob extends Command
-{
+class AutoJob extends Command {
protected static $systemConfig;
protected $signature = 'autoJob';
protected $description = '自动化任务';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
self::$systemConfig = Helpers::systemConfig();
}
@@ -38,9 +36,8 @@ class AutoJob extends Command
/*
* 警告:除非熟悉业务流程,否则不推荐更改以下执行顺序,随意变更以下顺序可能导致系统异常
*/
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
// 关闭超时未支付在线订单
$this->closePayments();
@@ -74,17 +71,19 @@ class AutoJob extends Command
}
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
// 关闭超时未在线支付订单
- private function closePayments()
- {
+ private function closePayments() {
// 关闭超时未支付的在线支付订单(在线支付收款二维码超过30分钟自动关闭,关闭后无法再支付,所以我们限制15分钟内必须付款)
- $paymentList = Payment::query()->whereStatus(0)->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-15 minutes")))->get();
+ $paymentList = Payment::query()
+ ->whereStatus(0)
+ ->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-15 minutes")))
+ ->get();
if($paymentList->isNotEmpty()){
DB::beginTransaction();
try{
@@ -99,7 +98,8 @@ class AutoJob extends Command
if($payment->order->coupon_id){
Coupon::query()->whereId($payment->order->coupon_id)->update(['status' => 0]);
- Helpers::addCouponLog($payment->order->coupon_id, $payment->order->goods_id, $payment->oid, '在线订单超时未支付,自动退回');
+ Helpers::addCouponLog($payment->order->coupon_id, $payment->order->goods_id, $payment->oid,
+ '在线订单超时未支付,自动退回');
}
}
@@ -113,10 +113,12 @@ class AutoJob extends Command
}
// 关闭超时未支付订单
- private function closeOrders()
- {
+ private function closeOrders() {
// 关闭超时未支付的在线支付订单(在线支付收款二维码超过30分钟自动关闭,关闭后无法再支付,所以我们限制15分钟内必须付款)
- $orderList = Order::query()->whereStatus(0)->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-30 minutes")))->get();
+ $orderList = Order::query()
+ ->whereStatus(0)
+ ->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-30 minutes")))
+ ->get();
if($orderList->isNotEmpty()){
DB::beginTransaction();
try{
@@ -142,10 +144,12 @@ class AutoJob extends Command
}
// 注册验证码自动置无效
- private function expireCode()
- {
+ private function expireCode() {
// 注册验证码自动置无效
- VerifyCode::query()->whereStatus(0)->where('created_at', '<=', date('Y-m-d H:i:s', strtotime("-10 minutes")))->update(['status' => 2]);
+ VerifyCode::query()
+ ->whereStatus(0)
+ ->where('created_at', '<=', date('Y-m-d H:i:s', strtotime("-10 minutes")))
+ ->update(['status' => 2]);
// 优惠券到期自动置无效
Coupon::query()->whereStatus(0)->where('available_end', '<=', time())->update(['status' => 2]);
@@ -155,17 +159,25 @@ class AutoJob extends Command
}
// 封禁访问异常的订阅链接
- private function blockSubscribe()
- {
+ private function blockSubscribe() {
if(self::$systemConfig['is_subscribe_ban']){
$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->get();
foreach($userList as $user){
$subscribe = UserSubscribe::query()->whereUserId($user->id)->first();
if($subscribe){
// 24小时内不同IP的请求次数
- $request_times = UserSubscribeLog::query()->whereSid($subscribe->id)->where('request_time', '>=', date("Y-m-d H:i:s", strtotime("-24 hours")))->distinct('request_ip')->count('request_ip');
+ $request_times = UserSubscribeLog::query()
+ ->whereSid($subscribe->id)
+ ->where('request_time', '>=',
+ date("Y-m-d H:i:s", strtotime("-24 hours")))
+ ->distinct('request_ip')
+ ->count('request_ip');
if($request_times >= self::$systemConfig['subscribe_ban_times']){
- UserSubscribe::query()->whereId($subscribe->id)->update(['status' => 0, 'ban_time' => time(), 'ban_desc' => '存在异常,自动封禁']);
+ UserSubscribe::query()->whereId($subscribe->id)->update([
+ 'status' => 0,
+ 'ban_time' => time(),
+ 'ban_desc' => '存在异常,自动封禁'
+ ]);
// 记录封禁日志
$this->addUserBanLog($subscribe->user_id, 0, '【完全封禁订阅】-订阅24小时内请求异常');
@@ -178,12 +190,11 @@ class AutoJob extends Command
/**
* 添加用户封禁日志
*
- * @param int $userId 用户ID
- * @param int $minutes 封禁时长,单位分钟
- * @param string $desc 封禁理由
+ * @param int $userId 用户ID
+ * @param int $minutes 封禁时长,单位分钟
+ * @param string $desc 封禁理由
*/
- private function addUserBanLog($userId, $minutes, $desc)
- {
+ private function addUserBanLog($userId, $minutes, $desc) {
$log = new UserBanLog();
$log->user_id = $userId;
$log->minutes = $minutes;
@@ -192,8 +203,7 @@ class AutoJob extends Command
}
// 封禁账号
- private function blockUsers()
- {
+ private function blockUsers() {
// 封禁1小时内流量异常账号
if(self::$systemConfig['is_traffic_ban']){
$userList = User::query()->whereEnable(1)->where('status', '>=', 0)->whereBanTime(0)->get();
@@ -204,9 +214,17 @@ class AutoJob extends Command
}
// 多往前取5分钟,防止数据统计任务执行时间过长导致没有数据
- $totalTraffic = UserTrafficHourly::query()->whereUserId($user->id)->whereNodeId(0)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->sum('total');
- if($totalTraffic >= (self::$systemConfig['traffic_ban_value']*1073741824)){
- User::query()->whereId($user->id)->update(['enable' => 0, 'ban_time' => strtotime(date('Y-m-d H:i:s', strtotime("+".self::$systemConfig['traffic_ban_time']." minutes")))]);
+ $totalTraffic = UserTrafficHourly::query()
+ ->whereUserId($user->id)
+ ->whereNodeId(0)
+ ->where('created_at', '>=', date('Y-m-d H:i:s', time() - 3900))
+ ->sum('total');
+ if($totalTraffic >= (self::$systemConfig['traffic_ban_value'] * 1073741824)){
+ User::query()->whereId($user->id)->update([
+ 'enable' => 0,
+ 'ban_time' => strtotime(date('Y-m-d H:i:s',
+ strtotime("+".self::$systemConfig['traffic_ban_time']." minutes")))
+ ]);
// 写入日志
$this->addUserBanLog($user->id, self::$systemConfig['traffic_ban_time'], '【临时封禁代理】-1小时内流量异常');
@@ -215,7 +233,12 @@ class AutoJob extends Command
}
// 禁用流量超限用户
- $userList = User::query()->whereEnable(1)->where('status', '>=', 0)->whereBanTime(0)->whereRaw("u + d >= transfer_enable")->get();
+ $userList = User::query()
+ ->whereEnable(1)
+ ->where('status', '>=', 0)
+ ->whereBanTime(0)
+ ->whereRaw("u + d >= transfer_enable")
+ ->get();
foreach($userList as $user){
User::query()->whereId($user->id)->update(['enable' => 0]);
@@ -225,8 +248,7 @@ class AutoJob extends Command
}
// 解封被临时封禁的账号
- private function unblockUsers()
- {
+ private function unblockUsers() {
// 解封被临时封禁的账号
$userList = User::query()->whereEnable(0)->where('status', '>=', 0)->where('ban_time', '>', 0)->get();
foreach($userList as $user){
@@ -239,7 +261,13 @@ class AutoJob extends Command
}
// 可用流量大于已用流量也解封(比如:邀请返利自动加了流量)
- $userList = User::query()->whereEnable(0)->where('status', '>=', 0)->whereBanTime(0)->where('expire_time', '>=', date('Y-m-d'))->whereRaw("u + d < transfer_enable")->get();
+ $userList = User::query()
+ ->whereEnable(0)
+ ->where('status', '>=', 0)
+ ->whereBanTime(0)
+ ->where('expire_time', '>=', date('Y-m-d'))
+ ->whereRaw("u + d < transfer_enable")
+ ->get();
foreach($userList as $user){
User::query()->whereId($user->id)->update(['enable' => 1]);
@@ -249,8 +277,7 @@ class AutoJob extends Command
}
// 端口回收与分配
- private function dispatchPort()
- {
+ private function dispatchPort() {
if(self::$systemConfig['auto_release_port']){
## 自动分配端口
$userList = User::query()->whereEnable(1)->where('status', '>=', 0)->wherePort(0)->get();
@@ -264,18 +291,25 @@ class AutoJob extends Command
User::query()->whereEnable(0)->whereStatus(-1)->where('port', '!=', 0)->update(['port' => 0]);
## 过期一个月的账户自动释放端口
- User::query()->whereEnable(0)->where('port', '!=', 0)->where('expire_time', '<=', date("Y-m-d", strtotime("-30 days")))->update(['port' => 0]);
+ User::query()
+ ->whereEnable(0)
+ ->where('port', '!=', 0)
+ ->where('expire_time', '<=', date("Y-m-d", strtotime("-30 days")))
+ ->update(['port' => 0]);
}
}
// 检测节点是否离线
- private function checkNodeStatus()
- {
+ private function checkNodeStatus() {
if(self::$systemConfig['is_node_offline']){
$nodeList = SsNode::query()->whereIsTransit(0)->whereStatus(1)->get();
foreach($nodeList as $node){
// 10分钟内无节点负载信息则认为是后端炸了
- $nodeTTL = SsNodeInfo::query()->whereNodeId($node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->doesntExist();
+ $nodeTTL = SsNodeInfo::query()
+ ->whereNodeId($node->id)
+ ->where('log_time', '>=', strtotime("-10 minutes"))
+ ->orderBy('id', 'desc')
+ ->doesntExist();
if($nodeTTL){
if(self::$systemConfig['offline_check_times']){
// 已通知次数
diff --git a/app/Console/Commands/AutoPingNode.php b/app/Console/Commands/AutoPingNode.php
index e15b180b..c2cfc16d 100644
--- a/app/Console/Commands/AutoPingNode.php
+++ b/app/Console/Commands/AutoPingNode.php
@@ -8,34 +8,30 @@ use App\Http\Models\SsNodePing;
use Illuminate\Console\Command;
use Log;
-class AutoPingNode extends Command
-{
+class AutoPingNode extends Command {
protected $signature = 'autoPingNode';
protected $description = '节点定时Ping测速';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
$nodeList = SsNode::query()->whereIsTransit(0)->whereStatus(1)->get();
foreach($nodeList as $node){
$this->pingNode($node->id, $node->is_ddns? $node->server : $node->ip);
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
// 节点Ping测速
- private function pingNode($nodeId, $ip)
- {
+ private function pingNode($nodeId, $ip) {
$result = NetworkDetection::ping($ip);
if($result){
diff --git a/app/Console/Commands/AutoReportNode.php b/app/Console/Commands/AutoReportNode.php
index b7c91be2..d32c8b08 100644
--- a/app/Console/Commands/AutoReportNode.php
+++ b/app/Console/Commands/AutoReportNode.php
@@ -9,19 +9,16 @@ use App\Http\Models\SsNodeTrafficDaily;
use Illuminate\Console\Command;
use Log;
-class AutoReportNode extends Command
-{
+class AutoReportNode extends Command {
protected $signature = 'autoReportNode';
protected $description = '自动报告节点昨日使用情况';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
if(Helpers::systemConfig()['node_daily_report']){
$nodeList = SsNode::query()->whereStatus(1)->get();
@@ -29,10 +26,10 @@ class AutoReportNode extends Command
$msg = "|节点|上行流量|下行流量|合计|\r\n| :------ | :------ | :------ |\r\n";
foreach($nodeList as $node){
$log = SsNodeTrafficDaily::query()
- ->whereNodeId($node->id)
- ->where('created_at', '>=', date('Y-m-d 00:00:00', strtotime("-1 day")))
- ->where('created_at', '<=', date('Y-m-d 23:59:59', strtotime("-1 day")))
- ->first();
+ ->whereNodeId($node->id)
+ ->where('created_at', '>=', date('Y-m-d 00:00:00', strtotime("-1 day")))
+ ->where('created_at', '<=', date('Y-m-d 23:59:59', strtotime("-1 day")))
+ ->first();
if($log){
$msg .= '|'.$node->name.'|'.flowAutoShow($log->u).'|'.flowAutoShow($log->d).'|'.$log->traffic."\r\n";
@@ -45,8 +42,8 @@ class AutoReportNode extends Command
}
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
diff --git a/app/Console/Commands/AutoStatisticsNodeDailyTraffic.php b/app/Console/Commands/AutoStatisticsNodeDailyTraffic.php
index cf0e4d07..eccd870a 100644
--- a/app/Console/Commands/AutoStatisticsNodeDailyTraffic.php
+++ b/app/Console/Commands/AutoStatisticsNodeDailyTraffic.php
@@ -8,33 +8,29 @@ use App\Http\Models\UserTrafficLog;
use Illuminate\Console\Command;
use Log;
-class AutoStatisticsNodeDailyTraffic extends Command
-{
+class AutoStatisticsNodeDailyTraffic extends Command {
protected $signature = 'autoStatisticsNodeDailyTraffic';
protected $description = '自动统计节点每日流量';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
$nodeList = SsNode::query()->whereStatus(1)->orderBy('id', 'asc')->get();
foreach($nodeList as $node){
$this->statisticsByNode($node->id);
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
- private function statisticsByNode($node_id)
- {
+ private function statisticsByNode($node_id) {
$start_time = strtotime(date('Y-m-d 00:00:00', strtotime("-1 day")));
$end_time = strtotime(date('Y-m-d 23:59:59', strtotime("-1 day")));
@@ -42,7 +38,7 @@ class AutoStatisticsNodeDailyTraffic extends Command
$u = $query->sum('u');
$d = $query->sum('d');
- $total = $u+$d;
+ $total = $u + $d;
$traffic = flowAutoShow($total);
if($total){ // 有数据才记录
diff --git a/app/Console/Commands/AutoStatisticsNodeHourlyTraffic.php b/app/Console/Commands/AutoStatisticsNodeHourlyTraffic.php
index bec85af7..17f876e6 100644
--- a/app/Console/Commands/AutoStatisticsNodeHourlyTraffic.php
+++ b/app/Console/Commands/AutoStatisticsNodeHourlyTraffic.php
@@ -8,33 +8,29 @@ use App\Http\Models\UserTrafficLog;
use Illuminate\Console\Command;
use Log;
-class AutoStatisticsNodeHourlyTraffic extends Command
-{
+class AutoStatisticsNodeHourlyTraffic extends Command {
protected $signature = 'autoStatisticsNodeHourlyTraffic';
protected $description = '自动统计节点每小时流量';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
$nodeList = SsNode::query()->whereStatus(1)->orderBy('id', 'asc')->get();
foreach($nodeList as $node){
$this->statisticsByNode($node->id);
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
- private function statisticsByNode($node_id)
- {
+ private function statisticsByNode($node_id) {
$start_time = strtotime(date('Y-m-d H:i:s', strtotime("-1 hour")));
$end_time = time();
@@ -42,7 +38,7 @@ class AutoStatisticsNodeHourlyTraffic extends Command
$u = $query->sum('u');
$d = $query->sum('d');
- $total = $u+$d;
+ $total = $u + $d;
$traffic = flowAutoShow($total);
if($total){ // 有数据才记录
diff --git a/app/Console/Commands/AutoStatisticsUserDailyTraffic.php b/app/Console/Commands/AutoStatisticsUserDailyTraffic.php
index df05803d..c5cbd25f 100644
--- a/app/Console/Commands/AutoStatisticsUserDailyTraffic.php
+++ b/app/Console/Commands/AutoStatisticsUserDailyTraffic.php
@@ -9,19 +9,16 @@ use App\Http\Models\UserTrafficLog;
use Illuminate\Console\Command;
use Log;
-class AutoStatisticsUserDailyTraffic extends Command
-{
+class AutoStatisticsUserDailyTraffic extends Command {
protected $signature = 'autoStatisticsUserDailyTraffic';
protected $description = '自动统计用户每日流量';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->get();
foreach($userList as $user){
@@ -35,14 +32,13 @@ class AutoStatisticsUserDailyTraffic extends Command
}
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
- private function statisticsByNode($user_id, $node_id = 0)
- {
+ private function statisticsByNode($user_id, $node_id = 0) {
$start_time = strtotime(date('Y-m-d 00:00:00', strtotime("-1 day")));
$end_time = strtotime(date('Y-m-d 23:59:59', strtotime("-1 day")));
@@ -54,7 +50,7 @@ class AutoStatisticsUserDailyTraffic extends Command
$u = $query->sum('u');
$d = $query->sum('d');
- $total = $u+$d;
+ $total = $u + $d;
$traffic = flowAutoShow($total);
if($total){ // 有数据才记录
diff --git a/app/Console/Commands/AutoStatisticsUserHourlyTraffic.php b/app/Console/Commands/AutoStatisticsUserHourlyTraffic.php
index dfe28490..7745d925 100644
--- a/app/Console/Commands/AutoStatisticsUserHourlyTraffic.php
+++ b/app/Console/Commands/AutoStatisticsUserHourlyTraffic.php
@@ -9,19 +9,16 @@ use App\Http\Models\UserTrafficLog;
use Illuminate\Console\Command;
use Log;
-class AutoStatisticsUserHourlyTraffic extends Command
-{
+class AutoStatisticsUserHourlyTraffic extends Command {
protected $signature = 'autoStatisticsUserHourlyTraffic';
protected $description = '自动统计用户每小时流量';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->get();
foreach($userList as $user){
@@ -35,14 +32,13 @@ class AutoStatisticsUserHourlyTraffic extends Command
}
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
- private function statisticsByNode($user_id, $node_id = 0)
- {
+ private function statisticsByNode($user_id, $node_id = 0) {
$start_time = strtotime(date('Y-m-d H:i:s', strtotime("-1 hour")));
$end_time = time();
@@ -54,7 +50,7 @@ class AutoStatisticsUserHourlyTraffic extends Command
$u = $query->sum('u');
$d = $query->sum('d');
- $total = $u+$d;
+ $total = $u + $d;
$traffic = flowAutoShow($total);
if($total){ // 有数据才记录
diff --git a/app/Console/Commands/DailyJob.php b/app/Console/Commands/DailyJob.php
index f7f50283..386fd6a5 100644
--- a/app/Console/Commands/DailyJob.php
+++ b/app/Console/Commands/DailyJob.php
@@ -13,21 +13,18 @@ use App\Http\Models\UserLabel;
use Illuminate\Console\Command;
use Log;
-class DailyJob extends Command
-{
+class DailyJob extends Command {
protected static $systemConfig;
protected $signature = 'dailyJob';
protected $description = '每日任务';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
self::$systemConfig = Helpers::systemConfig();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
// 过期用户处理
$this->expireUser();
@@ -40,27 +37,30 @@ class DailyJob extends Command
$this->resetUserTraffic();
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
- private function expireUser()
- {
+ private function expireUser() {
// 过期用户处理
- $userList = User::query()->where('status', '>=', 0)->whereEnable(1)->where('expire_time', '<', date('Y-m-d'))->get();
+ $userList = User::query()
+ ->where('status', '>=', 0)
+ ->whereEnable(1)
+ ->where('expire_time', '<', date('Y-m-d'))
+ ->get();
foreach($userList as $user){
if(self::$systemConfig['is_ban_status']){
User::query()->whereId($user->id)->update([
- 'u' => 0,
- 'd' => 0,
- 'transfer_enable' => 0,
- 'enable' => 0,
- 'reset_time' => NULL,
- 'ban_time' => 0,
- 'status' => -1
- ]);
+ 'u' => 0,
+ 'd' => 0,
+ 'transfer_enable' => 0,
+ 'enable' => 0,
+ 'reset_time' => null,
+ 'ban_time' => 0,
+ 'status' => -1
+ ]);
$this->addUserBanLog($user->id, 0, '【禁止登录,清空账户】-账号已过期');
@@ -71,13 +71,13 @@ class DailyJob extends Command
Helpers::addUserTrafficModifyLog($user->id, 0, $user->transfer_enable, 0, '[定时任务]账号已过期(禁止登录,清空账户)');
}else{
User::query()->whereId($user->id)->update([
- 'u' => 0,
- 'd' => 0,
- 'transfer_enable' => 0,
- 'enable' => 0,
- 'reset_time' => NULL,
- 'ban_time' => 0
- ]);
+ 'u' => 0,
+ 'd' => 0,
+ 'transfer_enable' => 0,
+ 'enable' => 0,
+ 'reset_time' => null,
+ 'ban_time' => 0
+ ]);
$this->addUserBanLog($user->id, 0, '【封禁代理,清空账户】-账号已过期');
@@ -93,12 +93,11 @@ class DailyJob extends Command
/**
* 添加用户封禁日志
*
- * @param int $userId 用户ID
- * @param int $minutes 封禁时长,单位分钟
- * @param string $desc 封禁理由
+ * @param int $userId 用户ID
+ * @param int $minutes 封禁时长,单位分钟
+ * @param string $desc 封禁理由
*/
- private function addUserBanLog($userId, $minutes, $desc)
- {
+ private function addUserBanLog($userId, $minutes, $desc) {
$log = new UserBanLog();
$log->user_id = $userId;
$log->minutes = $minutes;
@@ -107,9 +106,11 @@ class DailyJob extends Command
}
// 关闭超过72小时未处理的工单
- private function closeTickets()
- {
- $ticketList = Ticket::query()->where('updated_at', '<=', date('Y-m-d', strtotime("-3 days")))->whereStatus(1)->get();
+ private function closeTickets() {
+ $ticketList = Ticket::query()
+ ->where('updated_at', '<=', date('Y-m-d', strtotime("-3 days")))
+ ->whereStatus(1)
+ ->get();
foreach($ticketList as $ticket){
$ret = Ticket::query()->whereId($ticket->id)->update(['status' => 2]);
if($ret){
@@ -119,9 +120,12 @@ class DailyJob extends Command
}
// 重置用户流量
- private function resetUserTraffic()
- {
- $userList = User::query()->where('status', '>=', 0)->where('expire_time', '>', date('Y-m-d'))->where('reset_time', '<=', date('Y-m-d'))->get();
+ private function resetUserTraffic() {
+ $userList = User::query()
+ ->where('status', '>=', 0)
+ ->where('expire_time', '>', date('Y-m-d'))
+ ->where('reset_time', '<=', date('Y-m-d'))
+ ->get();
foreach($userList as $user){
// 跳过 没有重置日期的账号
if(!$user->reset_time){
@@ -130,14 +134,14 @@ class DailyJob extends Command
// 取出用户正在使用的套餐
$order = Order::query()
- ->with(['goods'])
- ->whereUserId($user->id)
- ->whereStatus(2)
- ->whereIsExpire(0)
- ->whereHas('goods', function($q){
- $q->whereType(2);
- })
- ->first();
+ ->with(['goods'])
+ ->whereUserId($user->id)
+ ->whereStatus(2)
+ ->whereIsExpire(0)
+ ->whereHas('goods', function($q) {
+ $q->whereType(2);
+ })
+ ->first();
// 无订单的免费/特殊用户跳过
if(!$order){
@@ -146,26 +150,33 @@ class DailyJob extends Command
// 过期生效中的加油包
Order::query()
- ->with(['goods'])
- ->whereUserId($user->id)
- ->whereStatus(2)
- ->whereIsExpire(0)
- ->whereHas('goods', function($q){
- $q->whereType(1);
- })->update(['is_expire' => 1]);
+ ->with(['goods'])
+ ->whereUserId($user->id)
+ ->whereStatus(2)
+ ->whereIsExpire(0)
+ ->whereHas('goods', function($q) {
+ $q->whereType(1);
+ })
+ ->update(['is_expire' => 1]);
//账号下一个重置时间
$nextResetTime = date('Y-m-d', strtotime("+".$order->goods->period." days"));
if($nextResetTime >= $user->expire_time){
- $nextResetTime = NULL;
+ $nextResetTime = null;
}
// 可用流量 变动日志
- if($user->transfer_enable != $order->goods->traffic*1048576){
- Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $order->goods->traffic*1048576, '【流量重置】重置可用流量');
+ if($user->transfer_enable != $order->goods->traffic * 1048576){
+ Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable,
+ $order->goods->traffic * 1048576, '【流量重置】重置可用流量');
}
// 重置流量
- User::query()->whereId($user->id)->update(['u' => 0, 'd' => 0, 'transfer_enable' => $order->goods->traffic*1048576, 'reset_time' => $nextResetTime]);
- Log::info('用户[ID:'.$user->id.' 昵称: '.$user->username.' 邮箱: '.$user->email.'] 流量重置为 '.($order->goods->traffic*1048576).'. 重置日期为 '.($nextResetTime? : '【无】'));
+ User::query()->whereId($user->id)->update([
+ 'u' => 0,
+ 'd' => 0,
+ 'transfer_enable' => $order->goods->traffic * 1048576,
+ 'reset_time' => $nextResetTime
+ ]);
+ Log::info('用户[ID:'.$user->id.' 昵称: '.$user->username.' 邮箱: '.$user->email.'] 流量重置为 '.($order->goods->traffic * 1048576).'. 重置日期为 '.($nextResetTime?: '【无】'));
}
}
-}
\ No newline at end of file
+}
diff --git a/app/Console/Commands/NodeBlockedDetection.php b/app/Console/Commands/NodeBlockedDetection.php
index df2c5efd..565b2672 100644
--- a/app/Console/Commands/NodeBlockedDetection.php
+++ b/app/Console/Commands/NodeBlockedDetection.php
@@ -12,21 +12,18 @@ use Illuminate\Console\Command;
use Log;
use Mail;
-class NodeBlockedDetection extends Command
-{
+class NodeBlockedDetection extends Command {
protected static $systemConfig;
protected $signature = 'nodeBlockedDetection';
protected $description = '节点阻断检测';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
self::$systemConfig = Helpers::systemConfig();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
if(self::$systemConfig['nodes_detection']){
if(!Cache::has('LastCheckTime')){
$this->checkNodes();
@@ -37,21 +34,20 @@ class NodeBlockedDetection extends Command
}
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info("---【{$this->description}】完成---,耗时 {$jobUsedTime} 秒");
}
// 监测节点状态
- private function checkNodes()
- {
+ private function checkNodes() {
$nodeList = SsNode::query()->whereIsTransit(0)->whereStatus(1)->where('detectionType', '>', 0)->get();
- $sendText = FALSE;
+ $sendText = false;
$message = "| 线路 | 协议 | 状态 |\r\n| ------ | ------ | ------ |\r\n";
$additionalMessage = '';
foreach($nodeList as $node){
- $info = FALSE;
+ $info = false;
if($node->detectionType == 0){
continue;
}
@@ -66,19 +62,19 @@ class NodeBlockedDetection extends Command
}
}
if($node->detectionType != 1){
- $icmpCheck = NetworkDetection::networkCheck($node->ip, TRUE);
- if($icmpCheck != FALSE && $icmpCheck != "通讯正常"){
+ $icmpCheck = NetworkDetection::networkCheck($node->ip, true);
+ if($icmpCheck != false && $icmpCheck != "通讯正常"){
$message .= "| ".$node->name." | ICMP | ".$icmpCheck." |\r\n";
- $sendText = TRUE;
- $info = TRUE;
+ $sendText = true;
+ $info = true;
}
}
if($node->detectionType != 2){
- $tcpCheck = NetworkDetection::networkCheck($node->ip, FALSE, $node->single? $node->port : NULL);
- if($tcpCheck != FALSE && $tcpCheck != "通讯正常"){
+ $tcpCheck = NetworkDetection::networkCheck($node->ip, false, $node->single? $node->port : null);
+ if($tcpCheck != false && $tcpCheck != "通讯正常"){
$message .= "| ".$node->name." | TCP | ".$tcpCheck." |\r\n";
- $sendText = TRUE;
- $info = TRUE;
+ $sendText = true;
+ $info = true;
}
}
@@ -113,18 +109,17 @@ class NodeBlockedDetection extends Command
}
// 随机生成下次检测时间
- Cache::put('LastCheckTime', time()+mt_rand(3000, 3600), 4000);
+ Cache::put('LastCheckTime', time() + mt_rand(3000, 3600), 4000);
}
/**
* 通知管理员
*
- * @param string $title 消息标题
- * @param string $content 消息内容
+ * @param string $title 消息标题
+ * @param string $content 消息内容
*
*/
- private function notifyMaster($title, $content)
- {
+ private function notifyMaster($title, $content) {
$result = PushNotification::send($title, $content);
if(!$result && self::$systemConfig['webmaster_email']){
$logId = Helpers::addNotificationLog($title, $content, 1, self::$systemConfig['webmaster_email']);
diff --git a/app/Console/Commands/ServiceTimer.php b/app/Console/Commands/ServiceTimer.php
index fc4d73f1..2f327d77 100644
--- a/app/Console/Commands/ServiceTimer.php
+++ b/app/Console/Commands/ServiceTimer.php
@@ -12,34 +12,32 @@ use Exception;
use Illuminate\Console\Command;
use Log;
-class ServiceTimer extends Command
-{
+class ServiceTimer extends Command {
protected $signature = 'serviceTimer';
protected $description = '服务计时器';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
// 扣减用户到期商品的流量
$this->decGoodsTraffic();
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
// 扣减用户到期商品的流量
- private function decGoodsTraffic()
- {
+ private function decGoodsTraffic() {
//获取失效的套餐
- $orderList = Order::query()->with(['goods'])->whereStatus(2)->whereIsExpire(0)->whereHas('goods', function($q){ $q->whereType(2); })->where('expire_at', '<=', date('Y-m-d H:i:s'))->get();
+ $orderList = Order::query()->with(['goods'])->whereStatus(2)->whereIsExpire(0)->whereHas('goods', function($q) {
+ $q->whereType(2);
+ })->where('expire_at', '<=', date('Y-m-d H:i:s'))->get();
if($orderList->isNotEmpty()){
try{
DB::beginTransaction();
@@ -49,27 +47,38 @@ class ServiceTimer extends Command
// 过期生效中的加油包
Order::query()
- ->with(['goods'])
- ->whereUserId($order->user_id)
- ->whereStatus(2)
- ->whereIsExpire(0)
- ->whereHas('goods', function($q){
- $q->whereType(1);
- })->update(['is_expire' => 1]);
+ ->with(['goods'])
+ ->whereUserId($order->user_id)
+ ->whereStatus(2)
+ ->whereIsExpire(0)
+ ->whereHas('goods', function($q) {
+ $q->whereType(1);
+ })
+ ->update(['is_expire' => 1]);
if(empty($order->user) || empty($order->goods)){
continue;
}
// 清理全部流量
- Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $order->user->transfer_enable, 0, '[定时任务]用户所购商品到期,扣减商品对应的流量');
- User::query()->whereId($order->user_id)->update(['u' => 0, 'd' => 0, 'transfer_enable' => 0, 'reset_time' => NULL]);
+ Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $order->user->transfer_enable, 0,
+ '[定时任务]用户所购商品到期,扣减商品对应的流量');
+ User::query()->whereId($order->user_id)->update([
+ 'u' => 0,
+ 'd' => 0,
+ 'transfer_enable' => 0,
+ 'reset_time' => null
+ ]);
// 删除对应用户的所有标签
UserLabel::query()->whereUserId($order->user_id)->delete();
// 检查该订单对应用户是否有预支付套餐
- $prepaidOrder = Order::query()->whereUserId($order->user_id)->whereStatus(3)->orderBy('oid', 'asc')->first();
+ $prepaidOrder = Order::query()
+ ->whereUserId($order->user_id)
+ ->whereStatus(3)
+ ->orderBy('oid', 'asc')
+ ->first();
if($prepaidOrder){
(new ServiceController)->activePrepaidOrder($prepaidOrder->oid);
diff --git a/app/Console/Commands/UserExpireAutoWarning.php b/app/Console/Commands/UserExpireAutoWarning.php
index 679020af..d92ba194 100644
--- a/app/Console/Commands/UserExpireAutoWarning.php
+++ b/app/Console/Commands/UserExpireAutoWarning.php
@@ -10,45 +10,41 @@ use Illuminate\Console\Command;
use Log;
use Mail;
-class UserExpireAutoWarning extends Command
-{
+class UserExpireAutoWarning extends Command {
protected static $systemConfig;
protected $signature = 'userExpireAutoWarning';
protected $description = '用户临近到期自动发邮件提醒';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
self::$systemConfig = Helpers::systemConfig();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
// 用户临近到期自动发邮件提醒
if(self::$systemConfig['expire_warning']){
$this->userExpireWarning();
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
- private function userExpireWarning()
- {
+ private function userExpireWarning() {
// 只取SSR没被禁用的用户,其他不用管
$userList = User::query()->whereEnable(1)->get();
foreach($userList as $user){
// 用户名不是邮箱的跳过
- if(FALSE === filter_var($user->email, FILTER_VALIDATE_EMAIL)){
+ if(false === filter_var($user->email, FILTER_VALIDATE_EMAIL)){
continue;
}
// 计算剩余可用时间
- $lastCanUseDays = ceil(round(strtotime($user->expire_time)-strtotime(date('Y-m-d H:i:s')))/3600/24);
+ $lastCanUseDays = ceil(round(strtotime($user->expire_time) - strtotime(date('Y-m-d H:i:s'))) / 3600 / 24);
if($lastCanUseDays == 0){
$title = '账号过期提醒';
$content = '您的账号将于今天晚上【24:00】过期。';
diff --git a/app/Console/Commands/UserTrafficAbnormalAutoWarning.php b/app/Console/Commands/UserTrafficAbnormalAutoWarning.php
index bee39b35..a12fad12 100644
--- a/app/Console/Commands/UserTrafficAbnormalAutoWarning.php
+++ b/app/Console/Commands/UserTrafficAbnormalAutoWarning.php
@@ -9,36 +9,38 @@ use App\Http\Models\UserTrafficHourly;
use Illuminate\Console\Command;
use Log;
-class UserTrafficAbnormalAutoWarning extends Command
-{
+class UserTrafficAbnormalAutoWarning extends Command {
protected static $systemConfig;
protected $signature = 'userTrafficAbnormalAutoWarning';
protected $description = '用户流量异常警告';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
self::$systemConfig = Helpers::systemConfig();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
// 用户流量异常警告
$this->userTrafficAbnormalWarning();
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
// 用户流量异常警告
- private function userTrafficAbnormalWarning()
- {
+ private function userTrafficAbnormalWarning() {
// 1小时内流量异常用户(多往前取5分钟,防止数据统计任务执行时间过长导致没有数据)
- $userTotalTrafficList = UserTrafficHourly::query()->whereNodeId(0)->where('total', '>', 104857600)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->groupBy('user_id')->selectRaw("user_id, sum(total) as totalTraffic")->get(); // 只统计100M以上的记录,加快查询速度
+ $userTotalTrafficList = UserTrafficHourly::query()
+ ->whereNodeId(0)
+ ->where('total', '>', 104857600)
+ ->where('created_at', '>=', date('Y-m-d H:i:s', time() - 3900))
+ ->groupBy('user_id')
+ ->selectRaw("user_id, sum(total) as totalTraffic")
+ ->get(); // 只统计100M以上的记录,加快查询速度
if(!$userTotalTrafficList->isEmpty()){
$title = "流量异常用户提醒";
@@ -46,8 +48,13 @@ class UserTrafficAbnormalAutoWarning extends Command
$user = User::query()->whereId($vo->user_id)->first();
// 推送通知管理员
- if($vo->totalTraffic > (self::$systemConfig['traffic_ban_value']*1073741824)){
- $traffic = UserTrafficHourly::query()->whereNodeId(0)->whereUserId($vo->user_id)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->selectRaw("user_id, sum(`u`) as totalU, sum(`d`) as totalD, sum(total) as totalTraffic")->first();
+ if($vo->totalTraffic > (self::$systemConfig['traffic_ban_value'] * 1073741824)){
+ $traffic = UserTrafficHourly::query()
+ ->whereNodeId(0)
+ ->whereUserId($vo->user_id)
+ ->where('created_at', '>=', date('Y-m-d H:i:s', time() - 3900))
+ ->selectRaw("user_id, sum(`u`) as totalU, sum(`d`) as totalD, sum(total) as totalTraffic")
+ ->first();
$content = "用户**{$user->email}(ID:{$user->id})**,最近1小时**上行流量:".flowAutoShow($traffic->totalU).",下行流量:".flowAutoShow($traffic->totalD).",共计:".flowAutoShow($traffic->totalTraffic)."**。";
diff --git a/app/Console/Commands/UserTrafficAutoWarning.php b/app/Console/Commands/UserTrafficAutoWarning.php
index 3ae4d3d8..687a8e5c 100644
--- a/app/Console/Commands/UserTrafficAutoWarning.php
+++ b/app/Console/Commands/UserTrafficAutoWarning.php
@@ -9,44 +9,40 @@ use Illuminate\Console\Command;
use Log;
use Mail;
-class UserTrafficAutoWarning extends Command
-{
+class UserTrafficAutoWarning extends Command {
protected static $systemConfig;
protected $signature = 'userTrafficAutoWarning';
protected $description = '用户流量超过警告阈值自动发邮件提醒';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
self::$systemConfig = Helpers::systemConfig();
}
- public function handle()
- {
- $jobStartTime = microtime(TRUE);
+ public function handle() {
+ $jobStartTime = microtime(true);
// 用户流量超过警告阈值自动发邮件提醒
if(self::$systemConfig['traffic_warning']){
$this->userTrafficWarning();
}
- $jobEndTime = microtime(TRUE);
- $jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+ $jobEndTime = microtime(true);
+ $jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
}
// 用户流量超过警告阈值自动发邮件提醒
- private function userTrafficWarning()
- {
+ private function userTrafficWarning() {
$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->where('transfer_enable', '>', 0)->get();
foreach($userList as $user){
// 用户名不是邮箱的跳过
- if(FALSE === filter_var($user->email, FILTER_VALIDATE_EMAIL)){
+ if(false === filter_var($user->email, FILTER_VALIDATE_EMAIL)){
continue;
}
- $usedPercent = round(($user->d+$user->u)/$user->transfer_enable, 2)*100; // 已使用流量百分比
+ $usedPercent = round(($user->d + $user->u) / $user->transfer_enable, 2) * 100; // 已使用流量百分比
if($usedPercent >= self::$systemConfig['traffic_warning_percent']){
$title = '流量提醒';
$content = '流量已使用:'.$usedPercent.'%,请保持关注。';
diff --git a/app/Console/Commands/updateUserName.php b/app/Console/Commands/updateUserName.php
index 1fd73f48..50e88662 100644
--- a/app/Console/Commands/updateUserName.php
+++ b/app/Console/Commands/updateUserName.php
@@ -7,18 +7,15 @@ use App\Http\Models\User;
use Illuminate\Console\Command;
use Log;
-class updateUserName extends Command
-{
+class updateUserName extends Command {
protected $signature = 'updateUserName';
protected $description = '升级用户昵称';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
}
- public function handle()
- {
+ public function handle() {
Log::info('----------------------------【升级用户昵称】开始----------------------------');
$userList = User::query()->get();
@@ -43,8 +40,7 @@ class updateUserName extends Command
}
}
-function process($id)
-{
+function process($id) {
$user = User::query()->whereId($id)->first();
// 先设个默认值
$name = $user->email;
@@ -52,14 +48,14 @@ function process($id)
if($user->qq){
$name = QQInfo::getName3($user->qq);
// 检测用户注册是否为QQ邮箱
- }elseif(strpos(strtolower($user->email), '@qq') != FALSE){
+ }elseif(strpos(strtolower($user->email), '@qq') != false){
// 分离QQ邮箱后缀
$email = explode('@', $user->email);
if(is_numeric($email[0])){
$name = QQInfo::getName3($email[0]);
}else{
// 分离www前缀
- if(strpos($email[0], '.') != FALSE){
+ if(strpos($email[0], '.') != false){
$temp = explode('.', $email[0]);
if(is_numeric($temp[1])){
$name = QQInfo::getName3($temp[1]);
@@ -69,7 +65,7 @@ function process($id)
}
}
}
- if($name == FALSE){
+ if($name == false){
$name = $user->email;
}
diff --git a/app/Console/Commands/upgradeUserResetTime.php b/app/Console/Commands/upgradeUserResetTime.php
index 7d50f81f..63874f06 100644
--- a/app/Console/Commands/upgradeUserResetTime.php
+++ b/app/Console/Commands/upgradeUserResetTime.php
@@ -6,23 +6,20 @@ use App\Http\Models\User;
use Illuminate\Console\Command;
use Log;
-class upgradeUserResetTime extends Command
-{
+class upgradeUserResetTime extends Command {
protected $signature = 'upgradeUserResetTime';
protected $description = '升级用户重置日期';
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
}
- public function handle()
- {
+ public function handle() {
Log::info('----------------------------【升级用户重置日期】开始----------------------------');
$userList = User::query()->get();
foreach($userList as $user){
- $reset_time = NULL;
+ $reset_time = null;
if($user->traffic_reset_day){
$today = date('d');// 今天 日期
$last_day = date('t'); //本月最后一天
@@ -31,7 +28,7 @@ class upgradeUserResetTime extends Command
// 案例:31 29,重置日 大于 本月最后一天
if($resetDay > $last_day){
//往后推一个月
- $resetDay = $resetDay-$last_day;
+ $resetDay = $resetDay - $last_day;
$reset_time = date('Y-m-'.$resetDay, strtotime("+1 month"));
//案例:20<30<31
}elseif($resetDay < $last_day && $resetDay > $today){
@@ -43,7 +40,7 @@ class upgradeUserResetTime extends Command
}elseif($resetDay < $today){
//类似第一种情况,向后推一月
if($resetDay > $next_last_day){
- $resetDay = $resetDay-$next_last_day;
+ $resetDay = $resetDay - $next_last_day;
$reset_time = date('Y-m-'.$resetDay, strtotime("+1 month"));
}else{
$reset_time = date('Y-m-'.$resetDay, strtotime("+1 month"));
@@ -51,12 +48,12 @@ class upgradeUserResetTime extends Command
}
// 用户账号有效期大于重置日期
if($reset_time > $user->expire_time){
- $reset_time = NULL;
+ $reset_time = null;
}
User::query()->whereId($user->id)->update(['reset_time' => $reset_time]);
}
- Log::info('---用户[ID:'.$user->id.' - '.$user->username.' ('.$user->email.')]的新重置日期为'.($reset_time != NULL? '【'.$reset_time.'】' : '【无】').'---');
+ Log::info('---用户[ID:'.$user->id.' - '.$user->username.' ('.$user->email.')]的新重置日期为'.($reset_time != null? '【'.$reset_time.'】' : '【无】').'---');
}
Log::info('----------------------------【升级用户重置日期】结束----------------------------');
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index b1461610..61fb44eb 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -20,8 +20,7 @@ use App\Console\Commands\UserTrafficAutoWarning;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
-class Kernel extends ConsoleKernel
-{
+class Kernel extends ConsoleKernel {
/**
* The Artisan commands provided by your application.
*
@@ -48,12 +47,11 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
- * @param Schedule $schedule
+ * @param Schedule $schedule
*
* @return void
*/
- protected function schedule(Schedule $schedule)
- {
+ protected function schedule(Schedule $schedule) {
$schedule->command('autoJob')->everyMinute();
$schedule->command('serviceTimer')->everyTenMinutes();
$schedule->command('autoClearLog')->everyThirtyMinutes();
@@ -75,8 +73,7 @@ class Kernel extends ConsoleKernel
*
* @return void
*/
- protected function commands()
- {
+ protected function commands() {
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
diff --git a/app/Events/Event.php b/app/Events/Event.php
index e3183026..009f0fe3 100644
--- a/app/Events/Event.php
+++ b/app/Events/Event.php
@@ -8,8 +8,7 @@ use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
-class Event
-{
+class Event {
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
@@ -17,8 +16,7 @@ class Event
*
* @return void
*/
- public function __construct()
- {
+ public function __construct() {
//
}
@@ -27,8 +25,7 @@ class Event
*
* @return Channel|array
*/
- public function broadcastOn()
- {
+ public function broadcastOn() {
return new PrivateChannel('channel-name');
}
}
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index 3e837d58..124cdebb 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -13,16 +13,13 @@ use Log;
use ReflectionException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-class Handler extends ExceptionHandler
-{
+class Handler extends ExceptionHandler {
/**
* A list of the exception types that are not reported.
*
* @var array
*/
- protected $dontReport = [
- //
- ];
+ protected $dontReport = [];
/**
* A list of the inputs that are never flashed for validation exceptions.
@@ -37,13 +34,12 @@ class Handler extends ExceptionHandler
/**
* Report or log an exception.
*
- * @param Exception $exception
+ * @param Exception $exception
*
* @return mixed|void
* @throws Exception
*/
- public function report(Exception $exception)
- {
+ public function report(Exception $exception) {
// 记录异常来源
Log::info('异常来源:'.get_class($exception));
@@ -58,13 +54,12 @@ class Handler extends ExceptionHandler
/**
* Render an exception into an HTTP response.
*
- * @param Request $request
- * @param Exception $exception
+ * @param Request $request
+ * @param Exception $exception
*
* @return Response
*/
- public function render($request, Exception $exception)
- {
+ public function render($request, Exception $exception) {
// 调试模式下直接返回错误信息
if(config('app.debug')){
return parent::render($request, $exception);
@@ -93,9 +88,15 @@ class Handler extends ExceptionHandler
// 捕获CSRF异常
if($exception instanceof TokenMismatchException){
if($request->ajax()){
- return response()->json(['status' => 'fail', 'data' => '', 'message' => trans('error.RefreshPage').''.trans('error.Refresh').'']);
+ return response()->json([
+ 'status' => 'fail',
+ 'data' => '',
+ 'message' => trans('error.RefreshPage').''.trans('error.Refresh').''
+ ]);
}else{
- return response()->view('auth.error', ['message' => trans('error.RefreshPage').''.trans('error.Refresh').'']);
+ return response()->view('auth.error', [
+ 'message' => trans('error.RefreshPage').''.trans('error.Refresh').''
+ ]);
}
}
@@ -111,9 +112,15 @@ class Handler extends ExceptionHandler
// 捕获系统错误异常
if($exception instanceof ErrorException){
if($request->ajax()){
- return response()->json(['status' => 'fail', 'data' => '', 'message' => trans('error.SystemError').', '.trans('error.Visit').''.trans('error.log').'']);
+ return response()->json([
+ 'status' => 'fail',
+ 'data' => '',
+ 'message' => trans('error.SystemError').', '.trans('error.Visit').''.trans('error.log').''
+ ]);
}else{
- return response()->view('auth.error', ['message' => trans('error.SystemError').', '.trans('error.Visit').''.trans('error.log').'']);
+ return response()->view('auth.error', [
+ 'message' => trans('error.SystemError').', '.trans('error.Visit').''.trans('error.log').''
+ ]);
}
}
diff --git a/app/Http/Controllers/Admin/AffiliateController.php b/app/Http/Controllers/Admin/AffiliateController.php
index a0d68057..38dcb4c6 100644
--- a/app/Http/Controllers/Admin/AffiliateController.php
+++ b/app/Http/Controllers/Admin/AffiliateController.php
@@ -16,24 +16,21 @@ use Response;
*
* @package App\Http\Controllers\Controller
*/
-class AffiliateController extends Controller
-{
+class AffiliateController extends Controller {
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$systemConfig = Helpers::systemConfig();
}
// 提现申请列表
- public function affiliateList(Request $request)
- {
+ public function affiliateList(Request $request) {
$email = $request->input('email');
$status = $request->input('status');
$query = ReferralApply::with('user');
if(isset($email)){
- $query->whereHas('user', function($q) use ($email){
+ $query->whereHas('user', function($q) use ($email) {
$q->where('email', 'like', '%'.$email.'%');
});
}
@@ -48,15 +45,18 @@ class AffiliateController extends Controller
}
// 提现申请详情
- public function affiliateDetail(Request $request)
- {
+ public function affiliateDetail(Request $request) {
$id = $request->input('id');
- $list = NULL;
+ $list = null;
$apply = ReferralApply::query()->with(['user'])->whereId($id)->first();
if($apply && $apply->link_logs){
$link_logs = explode(',', $apply->link_logs);
- $list = ReferralLog::query()->with(['user', 'order.goods'])->whereIn('id', $link_logs)->paginate(15)->appends($request->except('page'));
+ $list = ReferralLog::query()
+ ->with(['user', 'order.goods'])
+ ->whereIn('id', $link_logs)
+ ->paginate(15)
+ ->appends($request->except('page'));
}
$view['info'] = $apply;
@@ -66,8 +66,7 @@ class AffiliateController extends Controller
}
// 设置提现申请状态
- public function setAffiliateStatus(Request $request)
- {
+ public function setAffiliateStatus(Request $request) {
$id = $request->input('id');
$status = $request->input('status');
@@ -87,8 +86,7 @@ class AffiliateController extends Controller
}
// 用户返利流水记录
- public function userRebateList(Request $request)
- {
+ public function userRebateList(Request $request) {
$email = $request->input('email');
$ref_email = $request->input('ref_email');
$status = $request->input('status');
@@ -96,13 +94,13 @@ class AffiliateController extends Controller
$query = ReferralLog::query()->with(['user', 'order'])->orderBy('status', 'asc')->orderBy('id', 'desc');
if(isset($email)){
- $query->whereHas('user', function($q) use ($email){
+ $query->whereHas('user', function($q) use ($email) {
$q->where('email', 'like', '%'.$email.'%');
});
}
if(isset($ref_email)){
- $query->whereHas('ref_user', function($q) use ($ref_email){
+ $query->whereHas('ref_user', function($q) use ($ref_email) {
$q->where('email', 'like', '%'.$ref_email.'%');
});
}
diff --git a/app/Http/Controllers/Admin/CouponController.php b/app/Http/Controllers/Admin/CouponController.php
index ad4d40b7..747bcc3f 100644
--- a/app/Http/Controllers/Admin/CouponController.php
+++ b/app/Http/Controllers/Admin/CouponController.php
@@ -20,11 +20,9 @@ use Response;
*
* @package App\Http\Controllers\Controller
*/
-class CouponController extends Controller
-{
+class CouponController extends Controller {
// 优惠券列表
- public function couponList(Request $request)
- {
+ public function couponList(Request $request) {
$sn = $request->input('sn');
$type = $request->input('type');
$status = $request->input('status');
@@ -49,8 +47,7 @@ class CouponController extends Controller
}
// 添加商品
- public function addCoupon(Request $request)
- {
+ public function addCoupon(Request $request) {
if($request->isMethod('POST')){
$this->validate($request, [
'name' => 'required',
@@ -63,29 +60,29 @@ class CouponController extends Controller
'available_start' => 'required|date|before_or_equal:available_end',
'available_end' => 'required|date|after_or_equal:available_start',
], [
- 'name.required' => '请填入卡券名称',
- 'type.required' => '请选择卡券类型',
- 'type.integer' => '卡券类型不合法,请重选',
- 'type.between' => '卡券类型不合法,请重选',
- 'usage.required' => '请选择卡券用途',
- 'usage.integer' => '卡券用途不合法,请重选',
- 'usage.between' => '卡券用途不合法,请重选',
- 'num.required' => '请填写卡券数量',
- 'num.integer' => '卡券数量不合法',
- 'num.min' => '卡券数量不合法,最小1',
- 'amount.required_unless' => '请填入卡券面值',
- 'amount.numeric' => '卡券金额不合法',
- 'amount.min' => '卡券金额不合法,最小0.01',
- 'discount.required_if' => '请填入卡券折扣',
- 'discount.numeric' => '卡券折扣不合法',
- 'discount.between' => '卡券折扣不合法,有效范围:1 ~ 9.9',
- 'available_start.required' => '请填入有效期',
- 'available_start.date' => '有效期不合法',
- 'available_start.before_or_equal' => '有效期不合法',
- 'available_end.required' => '请填入有效期',
- 'available_end.date' => '有效期不合法',
- 'available_end.after_or_equal' => '有效期不合法'
- ]);
+ 'name.required' => '请填入卡券名称',
+ 'type.required' => '请选择卡券类型',
+ 'type.integer' => '卡券类型不合法,请重选',
+ 'type.between' => '卡券类型不合法,请重选',
+ 'usage.required' => '请选择卡券用途',
+ 'usage.integer' => '卡券用途不合法,请重选',
+ 'usage.between' => '卡券用途不合法,请重选',
+ 'num.required' => '请填写卡券数量',
+ 'num.integer' => '卡券数量不合法',
+ 'num.min' => '卡券数量不合法,最小1',
+ 'amount.required_unless' => '请填入卡券面值',
+ 'amount.numeric' => '卡券金额不合法',
+ 'amount.min' => '卡券金额不合法,最小0.01',
+ 'discount.required_if' => '请填入卡券折扣',
+ 'discount.numeric' => '卡券折扣不合法',
+ 'discount.between' => '卡券折扣不合法,有效范围:1 ~ 9.9',
+ 'available_start.required' => '请填入有效期',
+ 'available_start.date' => '有效期不合法',
+ 'available_start.before_or_equal' => '有效期不合法',
+ 'available_end.required' => '请填入有效期',
+ 'available_end.date' => '有效期不合法',
+ 'available_end.after_or_equal' => '有效期不合法'
+ ]);
$type = $request->input('type');
@@ -111,15 +108,17 @@ class CouponController extends Controller
for($i = 0; $i < $request->input('num'); $i++){
$obj = new Coupon();
$obj->name = $request->input('name');
- $obj->sn = $request->input('sn')? : strtoupper(makeRandStr(8));
+ $obj->sn = $request->input('sn')?: strtoupper(makeRandStr(8));
$obj->logo = $logo;
$obj->type = $type;
$obj->usage = $request->input('usage');
$obj->amount = $type == 2? 0 : $request->input('amount');
$obj->discount = $type != 2? 0 : $request->input('discount');
$obj->rule = $request->input('rule');
- $obj->available_start = strtotime(date('Y-m-d 00:00:00', strtotime($request->input('available_start'))));
- $obj->available_end = strtotime(date('Y-m-d 23:59:59', strtotime($request->input('available_end'))));
+ $obj->available_start = strtotime(date('Y-m-d 00:00:00',
+ strtotime($request->input('available_start'))));
+ $obj->available_end = strtotime(date('Y-m-d 23:59:59',
+ strtotime($request->input('available_end'))));
$obj->status = 0;
$obj->save();
}
@@ -140,33 +139,38 @@ class CouponController extends Controller
}
// 删除优惠券
- public function delCoupon(Request $request)
- {
+ public function delCoupon(Request $request) {
Coupon::query()->whereId($request->input('id'))->delete();
return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);
}
// 导出卡券
- public function exportCoupon()
- {
+ public function exportCoupon() {
$voucherList = Coupon::type(1)->whereStatus(0)->get();
$discountCouponList = Coupon::type(2)->whereStatus(0)->get();
$refillList = Coupon::type(3)->whereStatus(0)->get();
$filename = '卡券'.date('Ymd').'.xlsx';
$spreadsheet = new Spreadsheet();
- $spreadsheet->getProperties()->setCreator('SSRPanel')->setLastModifiedBy('SSRPanel')->setTitle('邀请码')->setSubject('邀请码')->setDescription('')->setKeywords('')->setCategory('');
+ $spreadsheet->getProperties()
+ ->setCreator('SSRPanel')
+ ->setLastModifiedBy('SSRPanel')
+ ->setTitle('邀请码')
+ ->setSubject('邀请码')
+ ->setDescription('')
+ ->setKeywords('')
+ ->setCategory('');
// 抵用券
$spreadsheet->setActiveSheetIndex(0);
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle('抵用券');
- $sheet->fromArray(['名称', '类型', '有效期', '券码', '金额(元)', '使用限制(元)'], NULL);
+ $sheet->fromArray(['名称', '类型', '有效期', '券码', '金额(元)', '使用限制(元)'], null);
foreach($voucherList as $k => $vo){
$usage = $vo->usage == 1? '一次性' : '重复使用';
$dateRange = date('Y-m-d', $vo->available_start).' ~ '.date('Y-m-d', $vo->available_end);
- $sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->amount, $vo->rule], NULL, 'A'.($k+2));
+ $sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->amount, $vo->rule], null, 'A'.($k + 2));
}
// 折扣券
@@ -174,11 +178,11 @@ class CouponController extends Controller
$spreadsheet->setActiveSheetIndex(1);
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle('折扣券');
- $sheet->fromArray(['名称', '类型', '有效期', '券码', '折扣(折)', '使用限制(元)'], NULL);
+ $sheet->fromArray(['名称', '类型', '有效期', '券码', '折扣(折)', '使用限制(元)'], null);
foreach($discountCouponList as $k => $vo){
$usage = $vo->usage == 1? '一次性' : '重复使用';
$dateRange = date('Y-m-d', $vo->available_start).' ~ '.date('Y-m-d', $vo->available_end);
- $sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->discount, $vo->rule], NULL, 'A'.($k+2));
+ $sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->discount, $vo->rule], null, 'A'.($k + 2));
}
// 充值券
@@ -186,11 +190,11 @@ class CouponController extends Controller
$spreadsheet->setActiveSheetIndex(2);
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle('充值券');
- $sheet->fromArray(['名称', '类型', '有效期', '券码', '金额(元)'], NULL);
+ $sheet->fromArray(['名称', '类型', '有效期', '券码', '金额(元)'], null);
foreach($refillList as $k => $vo){
$usage = '一次性';
$dateRange = date('Y-m-d', $vo->available_start).' ~ '.date('Y-m-d', $vo->available_end);
- $sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->amount], NULL, 'A'.($k+2));
+ $sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->amount], null, 'A'.($k + 2));
}
// 指针切换回第一个sheet
diff --git a/app/Http/Controllers/Admin/MarketingController.php b/app/Http/Controllers/Admin/MarketingController.php
index 0635dce9..8146fc08 100644
--- a/app/Http/Controllers/Admin/MarketingController.php
+++ b/app/Http/Controllers/Admin/MarketingController.php
@@ -19,18 +19,15 @@ use Response;
*
* @package App\Http\Controllers\Controller
*/
-class MarketingController extends Controller
-{
+class MarketingController extends Controller {
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$systemConfig = Helpers::systemConfig();
}
// 邮件群发消息列表
- public function emailList(Request $request)
- {
+ public function emailList(Request $request) {
$status = $request->input('status');
$query = Marketing::query()->whereType(1);
@@ -45,8 +42,7 @@ class MarketingController extends Controller
}
// 消息通道群发列表
- public function pushList(Request $request)
- {
+ public function pushList(Request $request) {
$status = $request->input('status');
$query = Marketing::query()->whereType(2);
@@ -61,8 +57,7 @@ class MarketingController extends Controller
}
// 添加推送消息
- public function addPushMarketing(Request $request)
- {
+ public function addPushMarketing(Request $request) {
$title = trim($request->input('title'));
$content = $request->input('content');
@@ -73,7 +68,13 @@ class MarketingController extends Controller
DB::beginTransaction();
try{
$client = new Client();
- $response = $client->request('GET', 'https://pushbear.ftqq.com/sub', ['query' => ['sendkey' => self::$systemConfig['push_bear_send_key'], 'text' => $title, 'desp' => $content]]);
+ $response = $client->request('GET', 'https://pushbear.ftqq.com/sub', [
+ 'query' => [
+ 'sendkey' => self::$systemConfig['push_bear_send_key'],
+ 'text' => $title,
+ 'desp' => $content
+ ]
+ ]);
$result = json_decode($response->getBody());
if($result->code){ // 失败
@@ -96,8 +97,7 @@ class MarketingController extends Controller
}
}
- private function addMarketing($type = 1, $title = '', $content = '', $status = 1, $error = '', $receiver = '')
- {
+ private function addMarketing($type = 1, $title = '', $content = '', $status = 1, $error = '', $receiver = '') {
$marketing = new Marketing();
$marketing->type = $type;
$marketing->receiver = $receiver;
@@ -108,4 +108,4 @@ class MarketingController extends Controller
return $marketing->save();
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/Admin/SensitiveWordsController.php b/app/Http/Controllers/Admin/SensitiveWordsController.php
index c3526901..84d6c135 100644
--- a/app/Http/Controllers/Admin/SensitiveWordsController.php
+++ b/app/Http/Controllers/Admin/SensitiveWordsController.php
@@ -15,28 +15,29 @@ use Validator;
*
* @package App\Http\Controllers\Controller
*/
-class SensitiveWordsController extends Controller
-{
+class SensitiveWordsController extends Controller {
// 敏感词列表
- public function sensitiveWordsList()
- {
+ public function sensitiveWordsList() {
$view['list'] = SensitiveWords::query()->orderBy('id', 'desc')->paginate(15);
return Response::view('admin.sensitiveWords.sensitiveWordsList', $view);
}
// 添加敏感词
- public function addSensitiveWords(Request $request)
- {
+ public function addSensitiveWords(Request $request) {
$validator = Validator::make($request->all(), [
'words' => 'required|unique:sensitive_words'
], [
- 'words.required' => '添加失败:请填写敏感词',
- 'words.unique' => '添加失败:敏感词已存在'
- ]);
+ 'words.required' => '添加失败:请填写敏感词',
+ 'words.unique' => '添加失败:敏感词已存在'
+ ]);
if($validator->fails()){
- return Response::json(['status' => 'fail', 'data' => '', 'message' => $validator->getMessageBag()->first()]);
+ return Response::json([
+ 'status' => 'fail',
+ 'data' => '',
+ 'message' => $validator->getMessageBag()->first()
+ ]);
}
$obj = new SensitiveWords();
@@ -51,8 +52,7 @@ class SensitiveWordsController extends Controller
}
// 删除敏感词
- public function delSensitiveWords(Request $request)
- {
+ public function delSensitiveWords(Request $request) {
$result = SensitiveWords::query()->whereId($request->input('id'))->delete();
if($result){
return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);
diff --git a/app/Http/Controllers/Admin/ShopController.php b/app/Http/Controllers/Admin/ShopController.php
index 96215a49..866a6fa8 100644
--- a/app/Http/Controllers/Admin/ShopController.php
+++ b/app/Http/Controllers/Admin/ShopController.php
@@ -21,11 +21,9 @@ use Session;
*
* @package App\Http\Controllers\Controller
*/
-class ShopController extends Controller
-{
+class ShopController extends Controller {
// 商品列表
- public function goodsList(Request $request)
- {
+ public function goodsList(Request $request) {
$type = $request->input('type');
$status = $request->input('status');
@@ -45,10 +43,27 @@ class ShopController extends Controller
}
// 添加商品
- public function addGoods(Request $request)
- {
+ public function addGoods(Request $request) {
if($request->isMethod('POST')){
- $this->validate($request, ['name' => 'required', 'traffic' => 'required_unless:type,3|integer|min:1024|max:10240000|nullable', 'price' => 'required|numeric|min:0', 'type' => 'required', 'days' => 'required|integer',], ['name.required' => '请填入名称', 'traffic.required_unless' => '请填入流量', 'traffic.integer' => '内含流量必须是整数值', 'traffic.min' => '内含流量不能低于1MB', 'traffic.max' => '内含流量不能超过10TB', 'price.required' => '请填入价格', 'price.numeric' => '价格不合法', 'price.min' => '价格最低0', 'type.required' => '请选择类型', 'days.required' => '请填入有效期', 'days.integer' => '有效期不合法',]);
+ $this->validate($request, [
+ 'name' => 'required',
+ 'traffic' => 'required_unless:type,3|integer|min:1024|max:10240000|nullable',
+ 'price' => 'required|numeric|min:0',
+ 'type' => 'required',
+ 'days' => 'required|integer',
+ ], [
+ 'name.required' => '请填入名称',
+ 'traffic.required_unless' => '请填入流量',
+ 'traffic.integer' => '内含流量必须是整数值',
+ 'traffic.min' => '内含流量不能低于1MB',
+ 'traffic.max' => '内含流量不能超过10TB',
+ 'price.required' => '请填入价格',
+ 'price.numeric' => '价格不合法',
+ 'price.min' => '价格最低0',
+ 'type.required' => '请选择类型',
+ 'days.required' => '请填入有效期',
+ 'days.integer' => '有效期不合法',
+ ]);
$type = $request->input('type');
$price = $request->input('price');
@@ -136,8 +151,7 @@ class ShopController extends Controller
}
// 编辑商品
- public function editGoods(Request $request, $id)
- {
+ public function editGoods(Request $request, $id) {
if($request->isMethod('POST')){
$name = $request->input('name');
$info = $request->input('info');
@@ -201,13 +215,14 @@ class ShopController extends Controller
'name' => $name,
'info' => $info,
'desc' => $desc,
- 'price' => $price*100,
- 'renew' => $renew*100,
+ 'price' => $price * 100,
+ 'renew' => $renew * 100,
'sort' => $sort,
'color' => $color,
'is_hot' => $is_hot,
'limit_num' => $limit_num,
- 'status' => $status];
+ 'status' => $status
+ ];
if($logo){
$data['logo'] = $logo;
@@ -256,8 +271,7 @@ class ShopController extends Controller
}
// 删除商品
- public function delGoods(Request $request)
- {
+ public function delGoods(Request $request) {
Goods::query()->whereId($request->input('id'))->delete();
return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);
diff --git a/app/Http/Controllers/Admin/SubscribeController.php b/app/Http/Controllers/Admin/SubscribeController.php
index 380e7c55..f2968603 100644
--- a/app/Http/Controllers/Admin/SubscribeController.php
+++ b/app/Http/Controllers/Admin/SubscribeController.php
@@ -17,18 +17,15 @@ use Response;
*
* @package App\Http\Controllers\Controller
*/
-class SubscribeController extends Controller
-{
+class SubscribeController extends Controller {
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$systemConfig = Helpers::systemConfig();
}
// 订阅码列表
- public function subscribeList(Request $request)
- {
+ public function subscribeList(Request $request) {
$user_id = $request->input('user_id');
$email = $request->input('email');
$status = $request->input('status');
@@ -40,7 +37,7 @@ class SubscribeController extends Controller
}
if(isset($email)){
- $query->whereHas('user', function($q) use ($email){
+ $query->whereHas('user', function($q) use ($email) {
$q->where('email', 'like', '%'.$email.'%');
});
}
@@ -55,8 +52,7 @@ class SubscribeController extends Controller
}
//订阅记录
- public function subscribeLog(Request $request)
- {
+ public function subscribeLog(Request $request) {
$id = $request->input('id');
$query = UserSubscribeLog::with('user:email');
@@ -70,8 +66,7 @@ class SubscribeController extends Controller
}
// 订阅设备列表
- public function deviceList(Request $request)
- {
+ public function deviceList(Request $request) {
$type = $request->input('type');
$platform = $request->input('platform');
$name = $request->input('name');
@@ -101,8 +96,7 @@ class SubscribeController extends Controller
}
// 设置用户的订阅的状态
- public function setSubscribeStatus(Request $request)
- {
+ public function setSubscribeStatus(Request $request) {
$id = $request->input('id');
$status = $request->input('status', 0);
@@ -120,8 +114,7 @@ class SubscribeController extends Controller
}
// 设置设备是否允许订阅的状态
- public function setDeviceStatus(Request $request)
- {
+ public function setDeviceStatus(Request $request) {
$id = $request->input('id');
$status = $request->input('status', 0);
diff --git a/app/Http/Controllers/Admin/TicketController.php b/app/Http/Controllers/Admin/TicketController.php
index 755bc317..01dc7a2a 100644
--- a/app/Http/Controllers/Admin/TicketController.php
+++ b/app/Http/Controllers/Admin/TicketController.php
@@ -21,24 +21,21 @@ use Response;
*
* @package App\Http\Controllers\Controller
*/
-class TicketController extends Controller
-{
+class TicketController extends Controller {
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$systemConfig = Helpers::systemConfig();
}
// 工单列表
- public function ticketList(Request $request)
- {
+ public function ticketList(Request $request) {
$email = $request->input('email');
$query = Ticket::query();
if(isset($email)){
- $query->whereHas('user', function($q) use ($email){
+ $query->whereHas('user', function($q) use ($email) {
$q->where('email', 'like', '%'.$email.'%');
});
}
@@ -49,8 +46,7 @@ class TicketController extends Controller
}
// 回复工单
- public function replyTicket(Request $request)
- {
+ public function replyTicket(Request $request) {
$id = $request->input('id');
if($request->isMethod('POST')){
@@ -77,8 +73,10 @@ class TicketController extends Controller
// 发通知邮件
if(!Auth::user()->is_admin){
if(self::$systemConfig['webmaster_email']){
- $logId = Helpers::addNotificationLog($title, $content, 1, self::$systemConfig['webmaster_email']);
- Mail::to(self::$systemConfig['webmaster_email'])->send(new replyTicket($logId, $title, $content));
+ $logId = Helpers::addNotificationLog($title, $content, 1,
+ self::$systemConfig['webmaster_email']);
+ Mail::to(self::$systemConfig['webmaster_email'])->send(new replyTicket($logId, $title,
+ $content));
}
}else{
$logId = Helpers::addNotificationLog($title, $content, 1, $ticket->user->email);
@@ -103,8 +101,7 @@ class TicketController extends Controller
}
// 关闭工单
- public function closeTicket(Request $request)
- {
+ public function closeTicket(Request $request) {
$id = $request->input('id');
$ticket = Ticket::query()->with(['user'])->whereId($id)->first();
diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php
index 8f2c6d4c..6503ce94 100644
--- a/app/Http/Controllers/AdminController.php
+++ b/app/Http/Controllers/AdminController.php
@@ -57,34 +57,48 @@ use Session;
*
* @package App\Http\Controllers
*/
-class AdminController extends Controller
-{
+class AdminController extends Controller {
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$systemConfig = Helpers::systemConfig();
}
- public function index()
- {
+ public function index() {
$past = strtotime(date('Y-m-d', strtotime("-".self::$systemConfig['expire_days']." days")));
$view['expireDays'] = self::$systemConfig['expire_days'];
$view['totalUserCount'] = User::query()->count(); // 总用户数
$view['enableUserCount'] = User::query()->whereEnable(1)->count(); // 有效用户数
$view['activeUserCount'] = User::query()->where('t', '>=', $past)->count(); // 活跃用户数
- $view['unActiveUserCount'] = User::query()->where('t', '<=', $past)->whereEnable(1)->where('t', '>', 0)->count(); // 不活跃用户数
- $view['onlineUserCount'] = User::query()->where('t', '>=', time()-600)->count(); // 10分钟内在线用户数
- $view['expireWarningUserCount'] = User::query()->where('expire_time', '>=', date('Y-m-d', strtotime("now")))->where('expire_time', '<=', date('Y-m-d', strtotime("+".self::$systemConfig['expire_days']." days")))->count(); // 临近过期用户数
- $view['largeTrafficUserCount'] = User::query()->whereRaw('(u + d) >= 107374182400')->whereIn('status', [0, 1])->count(); // 流量超过100G的用户
+ $view['unActiveUserCount'] = User::query()
+ ->where('t', '<=', $past)
+ ->whereEnable(1)
+ ->where('t', '>', 0)
+ ->count(); // 不活跃用户数
+ $view['onlineUserCount'] = User::query()->where('t', '>=', time() - 600)->count(); // 10分钟内在线用户数
+ $view['expireWarningUserCount'] = User::query()
+ ->where('expire_time', '>=', date('Y-m-d', strtotime("now")))
+ ->where('expire_time', '<=', date('Y-m-d',
+ strtotime("+".self::$systemConfig['expire_days']." days")))
+ ->count(); // 临近过期用户数
+ $view['largeTrafficUserCount'] = User::query()
+ ->whereRaw('(u + d) >= 107374182400')
+ ->whereIn('status', [0, 1])
+ ->count(); // 流量超过100G的用户
// 1小时内流量异常用户
$tempUsers = [];
- $userTotalTrafficList = UserTrafficHourly::query()->whereNodeId(0)->where('total', '>', 104857600)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->groupBy('user_id')->selectRaw("user_id, sum(total) as totalTraffic")->get(); // 只统计100M以上的记录,加快速度
+ $userTotalTrafficList = UserTrafficHourly::query()
+ ->whereNodeId(0)
+ ->where('total', '>', 104857600)
+ ->where('created_at', '>=', date('Y-m-d H:i:s', time() - 3900))
+ ->groupBy('user_id')
+ ->selectRaw("user_id, sum(total) as totalTraffic")
+ ->get(); // 只统计100M以上的记录,加快速度
if(!$userTotalTrafficList->isEmpty()){
foreach($userTotalTrafficList as $vo){
- if($vo->totalTraffic > (self::$systemConfig['traffic_ban_value']*1073741824)){
+ if($vo->totalTraffic > (self::$systemConfig['traffic_ban_value'] * 1073741824)){
$tempUsers[] = $vo->user_id;
}
}
@@ -92,24 +106,29 @@ class AdminController extends Controller
$view['flowAbnormalUserCount'] = User::query()->whereIn('id', $tempUsers)->count();
$view['nodeCount'] = SsNode::query()->count();
$view['unnormalNodeCount'] = SsNode::query()->whereStatus(0)->count();
- $flowCount = SsNodeTrafficDaily::query()->where('created_at', '>=', date('Y-m-d 00:00:00', strtotime("-30 days")))->sum('total');
+ $flowCount = SsNodeTrafficDaily::query()
+ ->where('created_at', '>=', date('Y-m-d 00:00:00', strtotime("-30 days")))
+ ->sum('total');
$view['flowCount'] = flowAutoShow($flowCount);
$totalFlowCount = SsNodeTrafficDaily::query()->sum('total');
$view['totalFlowCount'] = flowAutoShow($totalFlowCount);
- $view['totalBalance'] = User::query()->sum('balance')/100;
- $view['totalWaitRefAmount'] = ReferralLog::query()->whereIn('status', [0, 1])->sum('ref_amount')/100;
- $view['totalRefAmount'] = ReferralApply::query()->whereStatus(2)->sum('amount')/100;
+ $view['totalBalance'] = User::query()->sum('balance') / 100;
+ $view['totalWaitRefAmount'] = ReferralLog::query()->whereIn('status', [0, 1])->sum('ref_amount') / 100;
+ $view['totalRefAmount'] = ReferralApply::query()->whereStatus(2)->sum('amount') / 100;
$view['totalOrder'] = Order::query()->count();
$view['totalOnlinePayOrder'] = Order::query()->wherePayWay(2)->count();
$view['totalSuccessOrder'] = Order::query()->whereStatus(2)->count();
- $view['todaySuccessOrder'] = Order::query()->whereStatus(2)->where('created_at', '>=', date('Y-m-d 00:00:00'))->where('created_at', '<=', date('Y-m-d 23:59:59'))->count();
+ $view['todaySuccessOrder'] = Order::query()
+ ->whereStatus(2)
+ ->where('created_at', '>=', date('Y-m-d 00:00:00'))
+ ->where('created_at', '<=', date('Y-m-d 23:59:59'))
+ ->count();
return Response::view('admin.index', $view);
}
// 用户列表
- public function userList(Request $request)
- {
+ public function userList(Request $request) {
$id = $request->input('id');
$email = $request->input('email');
$wechat = $request->input('wechat');
@@ -164,26 +183,37 @@ class AdminController extends Controller
// 临近过期提醒
if($expireWarning){
- $query->where('expire_time', '>=', date('Y-m-d'))->where('expire_time', '<=', date('Y-m-d', strtotime("+".self::$systemConfig['expire_days']." days")));
+ $query->where('expire_time', '>=', date('Y-m-d'))
+ ->where('expire_time', '<=',
+ date('Y-m-d', strtotime("+".self::$systemConfig['expire_days']." days")));
}
// 当前在线
if($online){
- $query->where('t', '>=', time()-600);
+ $query->where('t', '>=', time() - 600);
}
// 不活跃用户
if($unActive){
- $query->where('t', '>', 0)->where('t', '<=', strtotime(date('Y-m-d', strtotime("-".self::$systemConfig['expire_days']." days"))))->whereEnable(1);
+ $query->where('t', '>', 0)
+ ->where('t', '<=',
+ strtotime(date('Y-m-d', strtotime("-".self::$systemConfig['expire_days']." days"))))
+ ->whereEnable(1);
}
// 1小时内流量异常用户
if($flowAbnormal){
$tempUsers = [];
- $userTotalTrafficList = UserTrafficHourly::query()->whereNodeId(0)->where('total', '>', 104857600)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->groupBy('user_id')->selectRaw("user_id, sum(total) as totalTraffic")->get(); // 只统计100M以上的记录,加快速度
+ $userTotalTrafficList = UserTrafficHourly::query()
+ ->whereNodeId(0)
+ ->where('total', '>', 104857600)
+ ->where('created_at', '>=', date('Y-m-d H:i:s', time() - 3900))
+ ->groupBy('user_id')
+ ->selectRaw("user_id, sum(total) as totalTraffic")
+ ->get(); // 只统计100M以上的记录,加快速度
if(!$userTotalTrafficList->isEmpty()){
foreach($userTotalTrafficList as $vo){
- if($vo->totalTraffic > (self::$systemConfig['traffic_ban_value']*1024*1024*1024)){
+ if($vo->totalTraffic > (self::$systemConfig['traffic_ban_value'] * 1024 * 1024 * 1024)){
$tempUsers[] = $vo->user_id;
}
}
@@ -194,7 +224,7 @@ class AdminController extends Controller
$userList = $query->orderBy('id', 'desc')->paginate(15)->appends($request->except('page'));
foreach($userList as $user){
$user->transfer_enable = flowAutoShow($user->transfer_enable);
- $user->used_flow = flowAutoShow($user->u+$user->d);
+ $user->used_flow = flowAutoShow($user->u + $user->d);
if($user->expire_time < date('Y-m-d')){
$user->expireWarning = -1; // 已过期
}elseif($user->expire_time == date('Y-m-d')){
@@ -206,9 +236,13 @@ class AdminController extends Controller
}
// 流量异常警告
- $time = date('Y-m-d H:i:s', time()-3900);
- $totalTraffic = UserTrafficHourly::query()->whereUserId($user->id)->whereNodeId(0)->where('created_at', '>=', $time)->sum('total');
- $user->trafficWarning = $totalTraffic > (self::$systemConfig['traffic_ban_value']*1024*1024*1024)? 1 : 0;
+ $time = date('Y-m-d H:i:s', time() - 3900);
+ $totalTraffic = UserTrafficHourly::query()
+ ->whereUserId($user->id)
+ ->whereNodeId(0)
+ ->where('created_at', '>=', $time)
+ ->sum('total');
+ $user->trafficWarning = $totalTraffic > (self::$systemConfig['traffic_ban_value'] * 1024 * 1024 * 1024)? 1 : 0;
// 订阅地址
$user->link = (self::$systemConfig['subscribe_domain']? self::$systemConfig['subscribe_domain'] : self::$systemConfig['website_url']).'/s/'.$user->subscribe->code;
@@ -220,8 +254,7 @@ class AdminController extends Controller
}
// 添加账号
- public function addUser(Request $request)
- {
+ public function addUser(Request $request) {
if($request->isMethod('POST')){
// 校验email是否已存在
$exists = User::query()->whereEmail($request->input('email'))->first();
@@ -235,33 +268,34 @@ class AdminController extends Controller
$user = new User();
$user->email = trim($request->input('email'));
- $user->password = Hash::make(trim($request->input('password'))? : makeRandStr());
+ $user->password = Hash::make(trim($request->input('password'))?: makeRandStr());
$user->port = $request->input('port');
$user->passwd = empty($request->input('passwd'))? makeRandStr() : $request->input('passwd');
- $user->vmess_id = $request->input('vmess_id')? : createGuid();
+ $user->vmess_id = $request->input('vmess_id')?: createGuid();
$user->transfer_enable = toGB($request->input('transfer_enable', 0));
$user->enable = $request->input('enable', 0);
$user->method = $request->input('method');
$user->protocol = $request->input('protocol');
- $user->protocol_param = $request->input('protocol_param')? : '';
+ $user->protocol_param = $request->input('protocol_param')?: '';
$user->obfs = $request->input('obfs');
- $user->obfs_param = $request->input('obfs_param')? : '';
+ $user->obfs_param = $request->input('obfs_param')?: '';
$user->speed_limit_per_con = $request->input('speed_limit_per_con');
$user->speed_limit_per_user = $request->input('speed_limit_per_user');
- $user->wechat = $request->input('wechat')? : '';
- $user->qq = $request->input('qq')? : '';
+ $user->wechat = $request->input('wechat')?: '';
+ $user->qq = $request->input('qq')?: '';
$user->usage = $request->input('usage');
$user->pay_way = $request->input('pay_way');
$user->balance = 0;
$user->enable_time = empty($request->input('enable_time'))? date('Y-m-d') : $request->input('enable_time');
- $user->expire_time = empty($request->input('expire_time'))? date('Y-m-d', strtotime("+365 days")) : $request->input('expire_time');
+ $user->expire_time = empty($request->input('expire_time'))? date('Y-m-d',
+ strtotime("+365 days")) : $request->input('expire_time');
$user->remark = str_replace("eval", "", str_replace("atob", "", $request->input('remark')));
- $user->level = $request->input('level')? : 1;
+ $user->level = $request->input('level')?: 1;
$user->is_admin = 0;
$user->reg_ip = getClientIp();
$user->referral_uid = 0;
- $user->reset_time = $request->input('reset_time') > date('Y-m-d')? $request->input('reset_time') : NULL;
- $user->status = $request->input('status')? : 1;
+ $user->reset_time = $request->input('reset_time') > date('Y-m-d')? $request->input('reset_time') : null;
+ $user->status = $request->input('status')?: 1;
$user->save();
if($user->id){
@@ -276,7 +310,8 @@ class AdminController extends Controller
$this->makeUserLabels($user->id, $request->input('labels'));
// 写入用户流量变动记录
- Helpers::addUserTrafficModifyLog($user->id, 0, 0, toGB($request->input('transfer_enable', 0)), '后台手动添加用户');
+ Helpers::addUserTrafficModifyLog($user->id, 0, 0, toGB($request->input('transfer_enable', 0)),
+ '后台手动添加用户');
return Response::json(['status' => 'success', 'data' => '', 'message' => '添加成功']);
}else{
@@ -297,8 +332,7 @@ class AdminController extends Controller
}
// 生成用户标签
- private function makeUserLabels($userId, $labels)
- {
+ private function makeUserLabels($userId, $labels) {
// 先删除该用户所有的标签
UserLabel::query()->whereUserId($userId)->delete();
@@ -313,8 +347,7 @@ class AdminController extends Controller
}
// 批量生成账号
- public function batchAddUsers(Request $request)
- {
+ public function batchAddUsers(Request $request) {
$amount = $request->input('amount');
DB::beginTransaction();
try{
@@ -352,8 +385,7 @@ class AdminController extends Controller
}
// 编辑账号
- public function editUser(Request $request, $id)
- {
+ public function editUser(Request $request, $id) {
if($request->isMethod('POST')){
$username = trim($request->input('username'));
$email = trim($request->input('email'));
@@ -429,7 +461,7 @@ class AdminController extends Controller
'usage' => $usage,
'pay_way' => $pay_way,
'status' => $status,
- 'reset_time' => empty($reset_time)? NULL : $reset_time,
+ 'reset_time' => empty($reset_time)? null : $reset_time,
'enable_time' => empty($enable_time)? date('Y-m-d') : $enable_time,
'expire_time' => empty($expire_time)? date('Y-m-d', strtotime("+365 days")) : $expire_time,
'remark' => $remark,
@@ -454,7 +486,8 @@ class AdminController extends Controller
// 写入用户流量变动记录
if($user->transfer_enable != toGB($transfer_enable)){
- Helpers::addUserTrafficModifyLog($id, 0, $user->transfer_enable, toGB($transfer_enable), '后台手动编辑用户');
+ Helpers::addUserTrafficModifyLog($id, 0, $user->transfer_enable, toGB($transfer_enable),
+ '后台手动编辑用户');
}
DB::commit();
@@ -494,8 +527,7 @@ class AdminController extends Controller
}
// 删除用户
- public function delUser(Request $request)
- {
+ public function delUser(Request $request) {
$id = $request->input('id');
if($id <= 1){
@@ -524,8 +556,7 @@ class AdminController extends Controller
}
// 节点列表
- public function nodeList(Request $request)
- {
+ public function nodeList(Request $request) {
if($request->isMethod('POST')){
$id = $request->input('id');
$node = SsNode::query()->whereId($id)->first();
@@ -538,8 +569,8 @@ class AdminController extends Controller
return Response::json(['status' => 'fail', 'title' => 'IP获取错误', 'message' => $node->name.'IP获取失败']);
}
}
- $data[0] = NetworkDetection::networkCheck($node->ip, TRUE); //ICMP
- $data[1] = NetworkDetection::networkCheck($node->ip, FALSE, $node->single? $node->port : NULL); //TCP
+ $data[0] = NetworkDetection::networkCheck($node->ip, true); //ICMP
+ $data[1] = NetworkDetection::networkCheck($node->ip, false, $node->single? $node->port : null); //TCP
return Response::json(['status' => 'success', 'title' => '['.$node->name.']阻断信息', 'message' => $data]);
}else{
@@ -551,10 +582,17 @@ class AdminController extends Controller
$query->whereStatus($status);
}
- $nodeList = $query->orderBy('status', 'desc')->orderBy('id', 'asc')->paginate(15)->appends($request->except('page'));
+ $nodeList = $query->orderBy('status', 'desc')
+ ->orderBy('id', 'asc')
+ ->paginate(15)
+ ->appends($request->except('page'));
foreach($nodeList as $node){
// 在线人数
- $online_log = SsNodeOnlineLog::query()->whereNodeId($node->id)->where('log_time', '>=', strtotime("-5 minutes"))->orderBy('id', 'desc')->first();
+ $online_log = SsNodeOnlineLog::query()
+ ->whereNodeId($node->id)
+ ->where('log_time', '>=', strtotime("-5 minutes"))
+ ->orderBy('id', 'desc')
+ ->first();
$node->online_users = empty($online_log)? 0 : $online_log->online_user;
// 已产生流量
@@ -562,7 +600,11 @@ class AdminController extends Controller
$node->transfer = flowAutoShow($totalTraffic);
// 负载(10分钟以内)
- $node_info = SsNodeInfo::query()->whereNodeId($node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->first();
+ $node_info = SsNodeInfo::query()
+ ->whereNodeId($node->id)
+ ->where('log_time', '>=', strtotime("-10 minutes"))
+ ->orderBy('id', 'desc')
+ ->first();
$node->isOnline = empty($node_info) || empty($node_info->load)? 0 : 1;
$node->load = $node->isOnline? $node_info->load : '离线';
$node->uptime = empty($node_info)? 0 : seconds2time($node_info->uptime);
@@ -575,18 +617,18 @@ class AdminController extends Controller
}
// 添加节点
- public function addNode(Request $request)
- {
+ public function addNode(Request $request) {
if($request->isMethod('POST')){
if($request->input('ssh_port') <= 0 || $request->input('ssh_port') >= 65535){
return Response::json(['status' => 'fail', 'data' => '', 'message' => '添加失败:SSH端口不合法']);
}
- if(FALSE === filter_var($request->input('ip'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
+ if(false === filter_var($request->input('ip'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
return Response::json(['status' => 'fail', 'data' => '', 'message' => '添加失败:IPv4地址不合法']);
}
- if($request->input('ipv6') && FALSE === filter_var($request->input('ipv6'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
+ if($request->input('ipv6')
+ && false === filter_var($request->input('ipv6'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
return Response::json(['status' => 'fail', 'data' => '', 'message' => '添加失败:IPv6地址不合法']);
}
@@ -607,42 +649,42 @@ class AdminController extends Controller
$ssNode = new SsNode();
$ssNode->type = $request->input('type');
$ssNode->name = $request->input('name');
- $ssNode->group_id = $request->input('group_id')? : 0;
- $ssNode->country_code = $request->input('country_code')? : 'un';
- $ssNode->server = $request->input('server')? : '';
+ $ssNode->group_id = $request->input('group_id')?: 0;
+ $ssNode->country_code = $request->input('country_code')?: 'un';
+ $ssNode->server = $request->input('server')?: '';
$ssNode->ip = $request->input('ip');
$ssNode->ipv6 = $request->input('ipv6');
- $ssNode->desc = $request->input('desc')? : '';
+ $ssNode->desc = $request->input('desc')?: '';
$ssNode->method = $request->input('method');
$ssNode->protocol = $request->input('protocol');
- $ssNode->protocol_param = $request->input('protocol_param')? : '';
- $ssNode->obfs = $request->input('obfs')? : '';
- $ssNode->obfs_param = $request->input('obfs_param')? : '';
- $ssNode->traffic_rate = $request->input('traffic_rate')? : 1;
- $ssNode->bandwidth = $request->input('bandwidth')? : 1000;
- $ssNode->traffic = $request->input('traffic')? : 1000;
- $ssNode->monitor_url = $request->input('monitor_url')? : '';
+ $ssNode->protocol_param = $request->input('protocol_param')?: '';
+ $ssNode->obfs = $request->input('obfs')?: '';
+ $ssNode->obfs_param = $request->input('obfs_param')?: '';
+ $ssNode->traffic_rate = $request->input('traffic_rate')?: 1;
+ $ssNode->bandwidth = $request->input('bandwidth')?: 1000;
+ $ssNode->traffic = $request->input('traffic')?: 1000;
+ $ssNode->monitor_url = $request->input('monitor_url')?: '';
$ssNode->is_subscribe = $request->input('is_subscribe');
$ssNode->is_ddns = $request->input('is_ddns');
$ssNode->is_transit = $request->input('is_transit');
- $ssNode->ssh_port = $request->input('ssh_port')? : 22;
+ $ssNode->ssh_port = $request->input('ssh_port')?: 22;
$ssNode->detectionType = $request->input('detectionType');
$ssNode->compatible = $request->input('type') == 2? 0 : ($request->input('is_ddns')? 0 : $request->input('compatible'));
$ssNode->single = $request->input('single');
- $ssNode->port = $request->input('single')? ($request->input('port')? : 443) : '';
- $ssNode->passwd = $request->input('single')? ($request->input('passwd')? : 'password') : '';
- $ssNode->sort = $request->input('sort')? : 0;
- $ssNode->status = $request->input('status')? : 1;
- $ssNode->v2_alter_id = $request->input('v2_alter_id')? : 16;
- $ssNode->v2_port = $request->input('v2_port')? : 10087;
- $ssNode->v2_method = $request->input('v2_method')? : 'aes-128-gcm';
- $ssNode->v2_net = $request->input('v2_net')? : 'tcp';
- $ssNode->v2_type = $request->input('v2_type')? : 'none';
- $ssNode->v2_host = $request->input('v2_host')? : '';
- $ssNode->v2_path = $request->input('v2_path')? : '';
- $ssNode->v2_tls = $request->input('v2_tls')? : 0;
- $ssNode->v2_insider_port = $request->input('v2_insider_port')? : 10550;
- $ssNode->v2_outsider_port = $request->input('v2_outsider_port')? : 443;
+ $ssNode->port = $request->input('single')? ($request->input('port')?: 443) : '';
+ $ssNode->passwd = $request->input('single')? ($request->input('passwd')?: 'password') : '';
+ $ssNode->sort = $request->input('sort')?: 0;
+ $ssNode->status = $request->input('status')?: 1;
+ $ssNode->v2_alter_id = $request->input('v2_alter_id')?: 16;
+ $ssNode->v2_port = $request->input('v2_port')?: 10087;
+ $ssNode->v2_method = $request->input('v2_method')?: 'aes-128-gcm';
+ $ssNode->v2_net = $request->input('v2_net')?: 'tcp';
+ $ssNode->v2_type = $request->input('v2_type')?: 'none';
+ $ssNode->v2_host = $request->input('v2_host')?: '';
+ $ssNode->v2_path = $request->input('v2_path')?: '';
+ $ssNode->v2_tls = $request->input('v2_tls')?: 0;
+ $ssNode->v2_insider_port = $request->input('v2_insider_port')?: 10550;
+ $ssNode->v2_outsider_port = $request->input('v2_outsider_port')?: 443;
$ssNode->save();
// 建立分组关联
@@ -687,8 +729,7 @@ class AdminController extends Controller
}
// 编辑节点
- public function editNode(Request $request)
- {
+ public function editNode(Request $request) {
$id = $request->input('id');
if($request->isMethod('POST')){
@@ -696,11 +737,12 @@ class AdminController extends Controller
return Response::json(['status' => 'fail', 'data' => '', 'message' => '编辑失败:SSH端口不合法']);
}
- if(FALSE === filter_var($request->input('ip'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
+ if(false === filter_var($request->input('ip'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
return Response::json(['status' => 'fail', 'data' => '', 'message' => '编辑失败:IPv4地址不合法']);
}
- if($request->input('ipv6') && FALSE === filter_var($request->input('ipv6'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
+ if($request->input('ipv6')
+ && false === filter_var($request->input('ipv6'), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
return Response::json(['status' => 'fail', 'data' => '', 'message' => '编辑失败:IPv6地址不合法']);
}
@@ -747,12 +789,15 @@ class AdminController extends Controller
'single' => $request->input('single'),
'port' => $request->input('single')? ($request->input('port')? $request->input('port') : 443) : '',
'passwd' => $request->input('single')? ($request->input('passwd')? $request->input('passwd') : 'password') : '',
- 'sort' => $request->input('sort'), 'status' => $request->input('status'),
+ 'sort' => $request->input('sort'),
+ 'status' => $request->input('status'),
'v2_alter_id' => $request->input('v2_alter_id')? $request->input('v2_alter_id') : 16,
'v2_port' => $request->input('v2_port')? $request->input('v2_port') : 10087,
'v2_method' => $request->input('v2_method')? $request->input('v2_method') : 'aes-128-gcm',
- 'v2_net' => $request->input('v2_net'), 'v2_type' => $request->input('v2_type'),
- 'v2_host' => $request->input('v2_host'), 'v2_path' => $request->input('v2_path'),
+ 'v2_net' => $request->input('v2_net'),
+ 'v2_type' => $request->input('v2_type'),
+ 'v2_host' => $request->input('v2_host'),
+ 'v2_path' => $request->input('v2_path'),
'v2_tls' => $request->input('v2_tls'),
'v2_insider_port' => $request->input('v2_insider_port', 10550),
'v2_outsider_port' => $request->input('v2_outsider_port', 443)
@@ -810,8 +855,7 @@ class AdminController extends Controller
}
// 生成节点标签
- private function makeNodeLabels($nodeId, $labels)
- {
+ private function makeNodeLabels($nodeId, $labels) {
// 先删除所有该节点的标签
SsNodeLabel::query()->whereNodeId($nodeId)->delete();
@@ -826,8 +870,7 @@ class AdminController extends Controller
}
// 删除节点
- public function delNode(Request $request)
- {
+ public function delNode(Request $request) {
$id = $request->input('id');
$node = SsNode::query()->whereId($id)->first();
@@ -862,8 +905,7 @@ class AdminController extends Controller
}
// 节点流量监控
- public function nodeMonitor($node_id)
- {
+ public function nodeMonitor($node_id) {
$node = SsNode::query()->whereId($node_id)->orderBy('sort', 'desc')->first();
if(!$node){
Session::flash('errorMsg', '节点不存在,请重试');
@@ -876,25 +918,37 @@ class AdminController extends Controller
$hourlyData = [];
// 节点一个月内的流量
- $nodeTrafficDaily = SsNodeTrafficDaily::query()->with(['info'])->whereNodeId($node->id)->where('created_at', '>=', date('Y-m', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
- $dailyTotal = date('d', time())-1;//今天不算,减一
+ $nodeTrafficDaily = SsNodeTrafficDaily::query()
+ ->with(['info'])
+ ->whereNodeId($node->id)
+ ->where('created_at', '>=', date('Y-m', time()))
+ ->orderBy('created_at', 'asc')
+ ->pluck('total')
+ ->toArray();
+ $dailyTotal = date('d', time()) - 1;//今天不算,减一
$dailyCount = count($nodeTrafficDaily);
- for($x = 0; $x < ($dailyTotal-$dailyCount); $x++){
+ for($x = 0; $x < ($dailyTotal - $dailyCount); $x++){
$dailyData[$x] = 0;
}
- for($x = ($dailyTotal-$dailyCount); $x < $dailyTotal; $x++){
- $dailyData[$x] = round($nodeTrafficDaily[$x-($dailyTotal-$dailyCount)]/(1024*1024*1024), 3);
+ for($x = ($dailyTotal - $dailyCount); $x < $dailyTotal; $x++){
+ $dailyData[$x] = round($nodeTrafficDaily[$x - ($dailyTotal - $dailyCount)] / (1024 * 1024 * 1024), 3);
}
// 节点一天内的流量
- $nodeTrafficHourly = SsNodeTrafficHourly::query()->with(['info'])->whereNodeId($node->id)->where('created_at', '>=', date('Y-m-d', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
+ $nodeTrafficHourly = SsNodeTrafficHourly::query()
+ ->with(['info'])
+ ->whereNodeId($node->id)
+ ->where('created_at', '>=', date('Y-m-d', time()))
+ ->orderBy('created_at', 'asc')
+ ->pluck('total')
+ ->toArray();
$hourlyTotal = date('H', time());
$hourlyCount = count($nodeTrafficHourly);
- for($x = 0; $x < ($hourlyTotal-$hourlyCount); $x++){
+ for($x = 0; $x < ($hourlyTotal - $hourlyCount); $x++){
$hourlyData[$x] = 0;
}
- for($x = ($hourlyTotal-$hourlyCount); $x < $hourlyTotal; $x++){
- $hourlyData[$x] = round($nodeTrafficHourly[$x-($hourlyTotal-$hourlyCount)]/(1024*1024*1024), 3);
+ for($x = ($hourlyTotal - $hourlyCount); $x < $hourlyTotal; $x++){
+ $hourlyData[$x] = round($nodeTrafficHourly[$x - ($hourlyTotal - $hourlyCount)] / (1024 * 1024 * 1024), 3);
}
$view['trafficDaily'] = ['nodeName' => $node->name, 'dailyData' => "'".implode("','", $dailyData)."'"];
@@ -922,8 +976,7 @@ class AdminController extends Controller
}
// Ping节点延迟
- public function pingNode(Request $request)
- {
+ public function pingNode(Request $request) {
$node = SsNode::query()->whereId($request->input('id'))->first();
if(!$node){
return Response::json(['status' => 'fail', 'message' => '节点不存在,请重试']);
@@ -932,10 +985,10 @@ class AdminController extends Controller
$result = NetworkDetection::ping($node->is_ddns? $node->server : $node->ip);
if($result){
- $data[0] = $result['China Telecom']['time']? : '无';
- $data[1] = $result['China Unicom']['time']? : '无';
- $data[2] = $result['China Mobile']['time']? : '无';
- $data[3] = $result['Hong Kong']['time']? : '无';
+ $data[0] = $result['China Telecom']['time']?: '无';
+ $data[1] = $result['China Unicom']['time']?: '无';
+ $data[2] = $result['China Mobile']['time']?: '无';
+ $data[3] = $result['Hong Kong']['time']?: '无';
return Response::json(['status' => 'success', 'message' => $data]);
}else{
@@ -943,8 +996,7 @@ class AdminController extends Controller
}
}
- public function nodePingLog(Request $request)
- {
+ public function nodePingLog(Request $request) {
$node_id = $request->input('nodeId');
$query = SsNodePing::query();
@@ -960,16 +1012,14 @@ class AdminController extends Controller
// 文章列表
- public function articleList(Request $request)
- {
+ public function articleList(Request $request) {
$view['list'] = Article::query()->orderBy('sort', 'desc')->paginate(15)->appends($request->except('page'));
return Response::view('admin.article.articleList', $view);
}
// 添加文章
- public function addArticle(Request $request)
- {
+ public function addArticle(Request $request) {
if($request->isMethod('POST')){
$article = new Article();
$article->title = $request->input('title');
@@ -1020,8 +1070,7 @@ class AdminController extends Controller
}
// 编辑文章
- public function editArticle(Request $request)
- {
+ public function editArticle(Request $request) {
$id = $request->input('id');
if($request->isMethod('POST')){
@@ -1075,8 +1124,7 @@ class AdminController extends Controller
}
// 删除文章
- public function delArticle(Request $request)
- {
+ public function delArticle(Request $request) {
$id = $request->input('id');
$ret = Article::query()->whereId($id)->delete();
@@ -1088,8 +1136,7 @@ class AdminController extends Controller
}
// 节点分组列表
- public function groupList(Request $request)
- {
+ public function groupList(Request $request) {
$view['groupList'] = SsGroup::query()->paginate(15)->appends($request->except('page'));
$levelList = Helpers::levelList();
@@ -1103,8 +1150,7 @@ class AdminController extends Controller
}
// 添加节点分组
- public function addGroup(Request $request)
- {
+ public function addGroup(Request $request) {
if($request->isMethod('POST')){
$ssGroup = new SsGroup();
$ssGroup->name = $request->input('name');
@@ -1120,8 +1166,7 @@ class AdminController extends Controller
}
// 编辑节点分组
- public function editGroup(Request $request, $id)
- {
+ public function editGroup(Request $request, $id) {
if($request->isMethod('POST')){
$name = $request->input('name');
$level = $request->input('level');
@@ -1143,8 +1188,7 @@ class AdminController extends Controller
}
// 删除节点分组
- public function delGroup(Request $request)
- {
+ public function delGroup(Request $request) {
$id = $request->input('id');
// 检查是否该分组下是否有节点
@@ -1162,8 +1206,7 @@ class AdminController extends Controller
}
// 流量日志
- public function trafficLog(Request $request)
- {
+ public function trafficLog(Request $request) {
$port = $request->input('port');
$user_id = $request->input('user_id');
$email = $request->input('email');
@@ -1174,7 +1217,7 @@ class AdminController extends Controller
$query = UserTrafficLog::query()->with(['user', 'node']);
if(isset($port)){
- $query->whereHas('user', function($q) use ($port){
+ $query->whereHas('user', function($q) use ($port) {
$q->wherePort($port);
});
}
@@ -1184,7 +1227,7 @@ class AdminController extends Controller
}
if(isset($email)){
- $query->whereHas('user', function($q) use ($email){
+ $query->whereHas('user', function($q) use ($email) {
$q->where('email', 'like', '%'.$email.'%');
});
}
@@ -1202,7 +1245,7 @@ class AdminController extends Controller
}
// 已使用流量
- $view['totalTraffic'] = flowAutoShow($query->sum('u')+$query->sum('d'));
+ $view['totalTraffic'] = flowAutoShow($query->sum('u') + $query->sum('d'));
$list = $query->orderBy('id', 'desc')->paginate(20)->appends($request->except('page'));
foreach($list as $vo){
@@ -1218,8 +1261,7 @@ class AdminController extends Controller
}
// SS(R)链接反解析
- public function decompile(Request $request)
- {
+ public function decompile(Request $request) {
if($request->isMethod('POST')){
$content = $request->input('content');
@@ -1234,9 +1276,9 @@ class AdminController extends Controller
foreach($content as $item){
// 判断是SS还是SSR链接
$str = '';
- if(FALSE !== strpos($item, 'ssr://')){
+ if(false !== strpos($item, 'ssr://')){
$str = mb_substr($item, 6);
- }elseif(FALSE !== strpos($item, 'ss://')){
+ }elseif(false !== strpos($item, 'ss://')){
$str = mb_substr($item, 5);
}
@@ -1253,8 +1295,7 @@ class AdminController extends Controller
}
// 格式转换(SS转SSR)
- public function convert(Request $request)
- {
+ public function convert(Request $request) {
if($request->isMethod('POST')){
$method = $request->input('method');
$transfer_enable = $request->input('transfer_enable');
@@ -1271,13 +1312,30 @@ class AdminController extends Controller
// 校验格式
$content = json_decode($content);
if(empty($content->port_password)){
- return Response::json(['status' => 'fail', 'data' => '', 'message' => '转换失败:配置信息里缺少【port_password】字段,或者该字段为空']);
+ return Response::json([
+ 'status' => 'fail',
+ 'data' => '',
+ 'message' => '转换失败:配置信息里缺少【port_password】字段,或者该字段为空'
+ ]);
}
// 转换成SSR格式JSON
$data = [];
foreach($content->port_password as $port => $passwd){
- $data[] = ['d' => 0, 'enable' => 1, 'method' => $method, 'obfs' => $obfs, 'obfs_param' => empty($obfs_param)? "" : $obfs_param, 'passwd' => $passwd, 'port' => $port, 'protocol' => $protocol, 'protocol_param' => empty($protocol_param)? "" : $protocol_param, 'transfer_enable' => toGB($transfer_enable), 'u' => 0, 'user' => date('Ymd').'_IMPORT_'.$port,];
+ $data[] = [
+ 'd' => 0,
+ 'enable' => 1,
+ 'method' => $method,
+ 'obfs' => $obfs,
+ 'obfs_param' => empty($obfs_param)? "" : $obfs_param,
+ 'passwd' => $passwd,
+ 'port' => $port,
+ 'protocol' => $protocol,
+ 'protocol_param' => empty($protocol_param)? "" : $protocol_param,
+ 'transfer_enable' => toGB($transfer_enable),
+ 'u' => 0,
+ 'user' => date('Ymd').'_IMPORT_'.$port,
+ ];
}
$json = json_encode($data);
@@ -1297,8 +1355,7 @@ class AdminController extends Controller
}
// 下载转换好的JSON文件
- public function download(Request $request)
- {
+ public function download(Request $request) {
$type = $request->input('type');
if(empty($type)){
exit('参数异常');
@@ -1318,8 +1375,7 @@ class AdminController extends Controller
}
// 数据导入
- public function import(Request $request)
- {
+ public function import(Request $request) {
if($request->isMethod('POST')){
if(!$request->hasFile('uploadFile')){
Session::flash('errorMsg', '请选择要上传的文件');
@@ -1409,8 +1465,7 @@ class AdminController extends Controller
}
// 导出配置信息
- public function export(Request $request, $id)
- {
+ public function export(Request $request, $id) {
if(empty($id)){
return Redirect::to('admin/userList');
}
@@ -1431,7 +1486,12 @@ class AdminController extends Controller
return Response::json(['status' => 'success', 'data' => $data, 'title' => $proxyType]);
}else{
- $view['nodeList'] = SsNode::query()->whereStatus(1)->orderBy('sort', 'desc')->orderBy('id', 'asc')->paginate(15)->appends($request->except('page'));
+ $view['nodeList'] = SsNode::query()
+ ->whereStatus(1)
+ ->orderBy('sort', 'desc')
+ ->orderBy('id', 'asc')
+ ->paginate(15)
+ ->appends($request->except('page'));
$view['user'] = $user;
}
@@ -1439,8 +1499,7 @@ class AdminController extends Controller
}
// 导出原版SS用户配置信息
- public function exportSSJson()
- {
+ public function exportSSJson() {
$userList = User::query()->where('port', '>', 0)->get();
$defaultMethod = Helpers::getDefaultMethod();
@@ -1480,8 +1539,7 @@ EOF;
}
// 修改个人资料
- public function profile(Request $request)
- {
+ public function profile(Request $request) {
if($request->isMethod('POST')){
$old_password = trim($request->input('old_password'));
$new_password = trim($request->input('new_password'));
@@ -1504,8 +1562,7 @@ EOF;
}
// 用户流量监控
- public function userMonitor($id)
- {
+ public function userMonitor($id) {
if(empty($id)){
return Redirect::to('admin/userList');
}
@@ -1519,26 +1576,38 @@ EOF;
$dailyData = [];
$hourlyData = [];
// 节点一个月内的流量
- $userTrafficDaily = UserTrafficDaily::query()->whereUserId($user->id)->whereNodeId(0)->where('created_at', '>=', date('Y-m', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
+ $userTrafficDaily = UserTrafficDaily::query()
+ ->whereUserId($user->id)
+ ->whereNodeId(0)
+ ->where('created_at', '>=', date('Y-m', time()))
+ ->orderBy('created_at', 'asc')
+ ->pluck('total')
+ ->toArray();
- $dailyTotal = date('d')-1; // 今天不算,减一
+ $dailyTotal = date('d') - 1; // 今天不算,减一
$dailyCount = count($userTrafficDaily);
- for($x = 0; $x < $dailyTotal-$dailyCount; $x++){
+ for($x = 0; $x < $dailyTotal - $dailyCount; $x++){
$dailyData[$x] = 0;
}
- for($x = $dailyTotal-$dailyCount; $x < $dailyTotal; $x++){
- $dailyData[$x] = round($userTrafficDaily[$x-($dailyTotal-$dailyCount)]/(1024*1024*1024), 3);
+ for($x = $dailyTotal - $dailyCount; $x < $dailyTotal; $x++){
+ $dailyData[$x] = round($userTrafficDaily[$x - ($dailyTotal - $dailyCount)] / (1024 * 1024 * 1024), 3);
}
// 节点一天内的流量
- $userTrafficHourly = UserTrafficHourly::query()->whereUserId($user->id)->whereNodeId(0)->where('created_at', '>=', date('Y-m-d', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
+ $userTrafficHourly = UserTrafficHourly::query()
+ ->whereUserId($user->id)
+ ->whereNodeId(0)
+ ->where('created_at', '>=', date('Y-m-d', time()))
+ ->orderBy('created_at', 'asc')
+ ->pluck('total')
+ ->toArray();
$hourlyTotal = date('H');
$hourlyCount = count($userTrafficHourly);
- for($x = 0; $x < $hourlyTotal-$hourlyCount; $x++){
+ for($x = 0; $x < $hourlyTotal - $hourlyCount; $x++){
$hourlyData[$x] = 0;
}
- for($x = ($hourlyTotal-$hourlyCount); $x < $hourlyTotal; $x++){
- $hourlyData[$x] = round($userTrafficHourly[$x-($hourlyTotal-$hourlyCount)]/(1024*1024*1024), 3);
+ for($x = ($hourlyTotal - $hourlyCount); $x < $hourlyTotal; $x++){
+ $hourlyData[$x] = round($userTrafficHourly[$x - ($hourlyTotal - $hourlyCount)] / (1024 * 1024 * 1024), 3);
}
// 本月天数数据
@@ -1562,14 +1631,12 @@ EOF;
}
// 生成端口
- public function makePort()
- {
+ public function makePort() {
return self::$systemConfig['is_rand_port']? Helpers::getRandPort() : Helpers::getOnlyPort();
}
// 加密方式、混淆、协议、等级、国家地区
- public function config(Request $request)
- {
+ public function config(Request $request) {
if($request->isMethod('POST')){
$name = $request->input('name');
$type = $request->input('type', 1); // 类型:1-加密方式(method)、2-协议(protocol)、3-混淆(obfs)
@@ -1606,8 +1673,7 @@ EOF;
}
// 删除配置
- public function delConfig(Request $request)
- {
+ public function delConfig(Request $request) {
$id = $request->input('id');
$ret = SsConfig::query()->whereId($id)->delete();
@@ -1619,8 +1685,7 @@ EOF;
}
// 设置默认配置
- public function setDefaultConfig(Request $request)
- {
+ public function setDefaultConfig(Request $request) {
$id = $request->input('id');
if(empty($id)){
@@ -1642,8 +1707,7 @@ EOF;
}
// 设置系统扩展信息,例如客服、统计代码
- public function setExtend(Request $request)
- {
+ public function setExtend(Request $request) {
$websiteAnalytics = $request->input('website_analytics');
$websiteCustomerService = $request->input('website_customer_service');
@@ -1705,8 +1769,7 @@ EOF;
}
// 日志分析
- public function analysis()
- {
+ public function analysis() {
$file = storage_path('app/ssserver.log');
if(!file_exists($file)){
Session::flash('analysisErrorMsg', $file.' 不存在,请先创建文件');
@@ -1715,7 +1778,7 @@ EOF;
}
$logs = $this->tail($file, 10000);
- if(FALSE === $logs){
+ if(false === $logs){
$view['urlList'] = [];
}else{
$url = [];
@@ -1728,7 +1791,8 @@ EOF;
if(!empty($tcp_matches)){
$url[] = str_replace('TCP request ', '[TCP] ', $tcp_matches[0]);
}else{
- preg_match('/UDP data to (25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)/', $log, $udp_matches);
+ preg_match('/UDP data to (25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)/',
+ $log, $udp_matches);
if(!empty($udp_matches)){
$url[] = str_replace('UDP data to ', '[UDP] ', $udp_matches[0]);
}
@@ -1742,8 +1806,7 @@ EOF;
}
// 添加等级
- public function addLevel(Request $request)
- {
+ public function addLevel(Request $request) {
$level = $request->input('level');
$level_name = trim($request->input('level_name'));
@@ -1773,8 +1836,7 @@ EOF;
}
// 编辑等级
- public function updateLevel(Request $request)
- {
+ public function updateLevel(Request $request) {
$id = $request->input('id');
$level = $request->input('level');
$level_name = $request->input('level_name');
@@ -1814,8 +1876,7 @@ EOF;
}
// 删除等级
- public function delLevel(Request $request)
- {
+ public function delLevel(Request $request) {
$id = $request->input('id');
if(empty($id)){
@@ -1838,7 +1899,7 @@ EOF;
if(!$existUsers->isEmpty()){
return Response::json(['status' => 'fail', 'data' => '', 'message' => '该等级下存在关联账号,请先取消关联']);
}
- $ret = FALSE;
+ $ret = false;
try{
$ret = Level::query()->whereId($id)->delete();
}catch(Exception $e){
@@ -1852,8 +1913,7 @@ EOF;
}
// 添加国家/地区
- public function addCountry(Request $request)
- {
+ public function addCountry(Request $request) {
$name = $request->input('country_name');
$code = $request->input('country_code');
@@ -1883,8 +1943,7 @@ EOF;
}
// 编辑国家/地区
- public function updateCountry(Request $request)
- {
+ public function updateCountry(Request $request) {
$id = $request->input('id');
$name = $request->input('country_name');
$code = $request->input('country_code');
@@ -1921,8 +1980,7 @@ EOF;
}
// 删除国家/地区
- public function delCountry(Request $request)
- {
+ public function delCountry(Request $request) {
$id = $request->input('id');
if(empty($id)){
@@ -1939,7 +1997,7 @@ EOF;
if(!$existNode->isEmpty()){
return Response::json(['status' => 'fail', 'data' => '', 'message' => '该国家/地区下存在关联节点,请先取消关联']);
}
- $ret = FALSE;
+ $ret = false;
try{
$ret = Country::query()->whereId($id)->delete();
}catch(Exception $e){
@@ -1953,8 +2011,7 @@ EOF;
}
// 系统设置
- public function system()
- {
+ public function system() {
$view = self::$systemConfig;
$view['label_list'] = Label::query()->orderBy('sort', 'desc')->orderBy('id', 'asc')->get();
@@ -1962,8 +2019,7 @@ EOF;
}
// 设置某个配置项
- public function setConfig(Request $request)
- {
+ public function setConfig(Request $request) {
$name = $request->input('name');
$value = trim($request->input('value'));
@@ -1977,7 +2033,8 @@ EOF;
}
// 如果开启用户邮件重置密码,则先设置网站名称和网址
- if(in_array($name, ['is_reset_password', 'is_activate_account', 'expire_warning', 'traffic_warning']) && $value != '0'){
+ if(in_array($name, ['is_reset_password', 'is_activate_account', 'expire_warning', 'traffic_warning'])
+ && $value != '0'){
$config = Config::query()->whereName('website_name')->first();
if($config->value == ''){
return Response::json(['status' => 'fail', 'message' => '设置失败:启用该配置需要先设置【网站名称】']);
@@ -1993,12 +2050,14 @@ EOF;
if(in_array($name, ['is_AliPay', 'is_QQPay', 'is_WeChatPay', 'is_otherPay']) && $value != ''){
switch($value){
case 'f2fpay':
- if(!self::$systemConfig['f2fpay_app_id'] || !self::$systemConfig['f2fpay_private_key'] || !self::$systemConfig['f2fpay_public_key']){
+ if(!self::$systemConfig['f2fpay_app_id'] || !self::$systemConfig['f2fpay_private_key']
+ || !self::$systemConfig['f2fpay_public_key']){
return Response::json(['status' => 'fail', 'message' => '请先设置【支付宝F2F】必要参数']);
}
break;
case 'codepay':
- if(!self::$systemConfig['codepay_url'] || !self::$systemConfig['codepay_id'] || !self::$systemConfig['codepay_key']){
+ if(!self::$systemConfig['codepay_url'] || !self::$systemConfig['codepay_id']
+ || !self::$systemConfig['codepay_key']){
return Response::json(['status' => 'fail', 'message' => '请先设置【码支付】必要参数']);
}
break;
@@ -2013,7 +2072,8 @@ EOF;
}
break;
case 'paypal':
- if(!self::$systemConfig['paypal_username'] || !self::$systemConfig['paypal_password'] || !self::$systemConfig['paypal_secret']){
+ if(!self::$systemConfig['paypal_username'] || !self::$systemConfig['paypal_password']
+ || !self::$systemConfig['paypal_secret']){
return Response::json(['status' => 'fail', 'message' => '请先设置【PayPal】必要参数']);
}
break;
@@ -2025,7 +2085,15 @@ EOF;
// 演示环境禁止修改特定配置项
if(env('APP_DEMO')){
- $denyConfig = ['website_url', 'min_rand_traffic', 'max_rand_traffic', 'push_bear_send_key', 'push_bear_qrcode', 'is_forbid_china', 'website_security_code'];
+ $denyConfig = [
+ 'website_url',
+ 'min_rand_traffic',
+ 'max_rand_traffic',
+ 'push_bear_send_key',
+ 'push_bear_qrcode',
+ 'is_forbid_china',
+ 'website_security_code'
+ ];
if(in_array($name, $denyConfig)){
return Response::json(['status' => 'fail', 'message' => '演示环境禁止修改该配置']);
@@ -2034,7 +2102,7 @@ EOF;
// 如果是返利比例,则需要除100
if(in_array($name, ['referral_percent'])){
- $value = intval($value)/100;
+ $value = intval($value) / 100;
}
// 更新配置
@@ -2044,11 +2112,10 @@ EOF;
}
//推送通知测试
- public function sendTestNotification()
- {
+ public function sendTestNotification() {
if(self::$systemConfig['is_notification']){
$result = PushNotification::send('这是测试的标题', 'SSRPanel_OM测试内容');
- if($result == FALSE){
+ if($result == false){
return Response::json(['status' => 'fail', 'message' => '发送失败,请重新尝试!']);
}
switch(self::$systemConfig['is_notification']){
@@ -2074,16 +2141,19 @@ EOF;
}
// 邀请码列表
- public function inviteList(Request $request)
- {
- $view['inviteList'] = Invite::query()->with(['generator', 'user'])->orderBy('status', 'asc')->orderBy('id', 'desc')->paginate(15)->appends($request->except('page'));
+ public function inviteList(Request $request) {
+ $view['inviteList'] = Invite::query()
+ ->with(['generator', 'user'])
+ ->orderBy('status', 'asc')
+ ->orderBy('id', 'desc')
+ ->paginate(15)
+ ->appends($request->except('page'));
return Response::view('admin.inviteList', $view);
}
// 生成邀请码
- public function makeInvite()
- {
+ public function makeInvite() {
for($i = 0; $i < 10; $i++){
$obj = new Invite();
$obj->uid = 0;
@@ -2098,23 +2168,29 @@ EOF;
}
// 导出邀请码
- public function exportInvite()
- {
+ public function exportInvite() {
$inviteList = Invite::query()->whereStatus(0)->orderBy('id', 'asc')->get();
$filename = '邀请码'.date('Ymd').'.xlsx';
$spreadsheet = new Spreadsheet();
- $spreadsheet->getProperties()->setCreator('SSRPanel')->setLastModifiedBy('SSRPanel')->setTitle('邀请码')->setSubject('邀请码')->setDescription('')->setKeywords('')->setCategory('');
+ $spreadsheet->getProperties()
+ ->setCreator('SSRPanel')
+ ->setLastModifiedBy('SSRPanel')
+ ->setTitle('邀请码')
+ ->setSubject('邀请码')
+ ->setDescription('')
+ ->setKeywords('')
+ ->setCategory('');
try{
$spreadsheet->setActiveSheetIndex(0);
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle('邀请码');
- $sheet->fromArray(['邀请码', '有效期'], NULL);
+ $sheet->fromArray(['邀请码', '有效期'], null);
foreach($inviteList as $k => $vo){
- $sheet->fromArray([$vo->code, $vo->dateline], NULL, 'A'.($k+2));
+ $sheet->fromArray([$vo->code, $vo->dateline], null, 'A'.($k + 2));
}
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); // 输出07Excel文件
@@ -2129,8 +2205,7 @@ EOF;
}
// 订单列表
- public function orderList(Request $request)
- {
+ public function orderList(Request $request) {
$email = $request->input('email');
$order_sn = $request->input('order_sn');
$is_coupon = $request->input('is_coupon');
@@ -2144,7 +2219,7 @@ EOF;
$query = Order::query()->with(['user', 'goods', 'coupon']);
if(isset($email)){
- $query->whereHas('user', function($q) use ($email){
+ $query->whereHas('user', function($q) use ($email) {
$q->where('email', 'like', '%'.$email.'%');
});
}
@@ -2193,8 +2268,7 @@ EOF;
}
// 重置用户流量
- public function resetUserTraffic(Request $request)
- {
+ public function resetUserTraffic(Request $request) {
$id = $request->input('id');
User::query()->whereId($id)->update(['u' => 0, 'd' => 0]);
@@ -2203,8 +2277,7 @@ EOF;
}
// 操作用户余额
- public function handleUserBalance(Request $request)
- {
+ public function handleUserBalance(Request $request) {
if($request->isMethod('POST')){
$userId = $request->input('user_id');
$amount = $request->input('amount');
@@ -2218,13 +2291,13 @@ EOF;
$user = User::query()->whereId($userId)->first();
// 写入余额变动日志
- Helpers::addUserBalanceLog($userId, 0, $user->balance, $user->balance+$amount, $amount, '后台手动充值');
+ Helpers::addUserBalanceLog($userId, 0, $user->balance, $user->balance + $amount, $amount, '后台手动充值');
// 加减余额
if($amount < 0){
- $user->decrement('balance', abs($amount)*100);
+ $user->decrement('balance', abs($amount) * 100);
}else{
- $user->increment('balance', abs($amount)*100);
+ $user->increment('balance', abs($amount) * 100);
}
DB::commit();
@@ -2241,14 +2314,13 @@ EOF;
}
// 用户余额变动记录
- public function userBalanceLogList(Request $request)
- {
+ public function userBalanceLogList(Request $request) {
$email = $request->input('email');
$query = UserBalanceLog::query()->with(['user'])->orderBy('id', 'desc');
if(isset($email)){
- $query->whereHas('user', function($q) use ($email){
+ $query->whereHas('user', function($q) use ($email) {
$q->where('email', 'like', '%'.$email.'%');
});
}
@@ -2259,14 +2331,13 @@ EOF;
}
// 用户封禁记录
- public function userBanLogList(Request $request)
- {
+ public function userBanLogList(Request $request) {
$email = $request->input('email');
$query = UserBanLog::query()->with(['user'])->orderBy('id', 'desc');
if(isset($email)){
- $query->whereHas('user', function($q) use ($email){
+ $query->whereHas('user', function($q) use ($email) {
$q->where('email', 'like', '%'.$email.'%');
});
}
@@ -2277,14 +2348,13 @@ EOF;
}
// 用户流量变动记录
- public function userTrafficLogList(Request $request)
- {
+ public function userTrafficLogList(Request $request) {
$email = $request->input('email');
$query = UserTrafficModifyLog::query()->with(['user', 'order', 'order.goods']);
if(isset($email)){
- $query->whereHas('user', function($q) use ($email){
+ $query->whereHas('user', function($q) use ($email) {
$q->where('email', 'like', '%'.$email.'%');
});
}
@@ -2295,8 +2365,7 @@ EOF;
}
// 用户在线IP记录
- public function userOnlineIPList(Request $request)
- {
+ public function userOnlineIPList(Request $request) {
$email = $request->input('email');
$port = $request->input('port');
$wechat = $request->input('wechat');
@@ -2324,7 +2393,14 @@ EOF;
if(!$userList->isEmpty()){
foreach($userList as $user){
// 最近5条在线IP记录,如果后端设置为60秒上报一次,则为10分钟内的在线IP
- $user->onlineIPList = SsNodeIp::query()->with(['node'])->whereType('tcp')->wherePort($user->port)->where('created_at', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->limit(5)->get();
+ $user->onlineIPList = SsNodeIp::query()
+ ->with(['node'])
+ ->whereType('tcp')
+ ->wherePort($user->port)
+ ->where('created_at', '>=', strtotime("-10 minutes"))
+ ->orderBy('id', 'desc')
+ ->limit(5)
+ ->get();
}
}
@@ -2334,8 +2410,7 @@ EOF;
}
// 转换成某个用户的身份
- public function switchToUser(Request $request)
- {
+ public function switchToUser(Request $request) {
$id = $request->input('user_id');
$user = User::query()->find($id);
@@ -2351,8 +2426,7 @@ EOF;
}
// 标签列表
- public function labelList(Request $request)
- {
+ public function labelList(Request $request) {
$labelList = Label::query()->paginate(15)->appends($request->except('page'));
foreach($labelList as $label){
$label->userCount = UserLabel::query()->whereLabelId($label->id)->groupBy('label_id')->count();
@@ -2365,8 +2439,7 @@ EOF;
}
// 添加标签
- public function addLabel(Request $request)
- {
+ public function addLabel(Request $request) {
if($request->isMethod('POST')){
$name = $request->input('name');
$sort = $request->input('sort');
@@ -2383,8 +2456,7 @@ EOF;
}
// 编辑标签
- public function editLabel(Request $request)
- {
+ public function editLabel(Request $request) {
if($request->isMethod('POST')){
$id = $request->input('id');
$name = $request->input('name');
@@ -2402,8 +2474,7 @@ EOF;
}
// 删除标签
- public function delLabel(Request $request)
- {
+ public function delLabel(Request $request) {
$id = $request->input('id');
DB::beginTransaction();
@@ -2423,8 +2494,7 @@ EOF;
}
// 邮件发送日志列表
- public function notificationLog(Request $request)
- {
+ public function notificationLog(Request $request) {
$email = $request->input('email');
$type = $request->input('type');
@@ -2444,40 +2514,42 @@ EOF;
}
// 在线IP监控(实时)
- public function onlineIPMonitor(Request $request)
- {
+ public function onlineIPMonitor(Request $request) {
$ip = $request->input('ip');
$email = $request->input('email');
$port = $request->input('port');
$nodeId = $request->input('nodeId');
$userId = $request->input('id');
- $query = SsNodeIp::query()->with(['node', 'user'])->whereType('tcp')->where('created_at', '>=', strtotime("-120 seconds"));
+ $query = SsNodeIp::query()
+ ->with(['node', 'user'])
+ ->whereType('tcp')
+ ->where('created_at', '>=', strtotime("-120 seconds"));
if(isset($ip)){
$query->whereIp($ip);
}
if(isset($email)){
- $query->whereHas('user', function($q) use ($email){
+ $query->whereHas('user', function($q) use ($email) {
$q->where('email', 'like', '%'.$email.'%');
});
}
if(isset($port)){
- $query->whereHas('user', function($q) use ($port){
+ $query->whereHas('user', function($q) use ($port) {
$q->wherePort($port);
});
}
if(isset($nodeId)){
- $query->whereHas('node', function($q) use ($nodeId){
+ $query->whereHas('node', function($q) use ($nodeId) {
$q->whereId($nodeId);
});
}
if(isset($userId)){
- $query->whereHas('user', function($q) use ($userId){
+ $query->whereHas('user', function($q) use ($userId) {
$q->whereId($userId);
});
}
@@ -2486,7 +2558,7 @@ EOF;
foreach($list as $vo){
// 跳过上报多IP的
- if(strpos($vo->ip, ',') == TRUE){
+ if(strpos($vo->ip, ',') == true){
continue;
}
@@ -2494,7 +2566,11 @@ EOF;
if(isset($ipInfo['error'])){
// 用IPIP的库再试一下
$ipip = IPIP::ip($vo->ip);
- $ipInfo = ['country' => $ipip['country_name'], 'province' => $ipip['region_name'], 'city' => $ipip['city_name']];
+ $ipInfo = [
+ 'country' => $ipip['country_name'],
+ 'province' => $ipip['region_name'],
+ 'city' => $ipip['city_name']
+ ];
}
$vo->ipInfo = $ipInfo['country'].' '.$ipInfo['province'].' '.$ipInfo['city'];
diff --git a/app/Http/Controllers/Api/LoginController.php b/app/Http/Controllers/Api/LoginController.php
index fa6459fc..91943a68 100644
--- a/app/Http/Controllers/Api/LoginController.php
+++ b/app/Http/Controllers/Api/LoginController.php
@@ -21,18 +21,15 @@ use Response;
*
* @package App\Http\Controllers
*/
-class LoginController extends Controller
-{
+class LoginController extends Controller {
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$systemConfig = Helpers::systemConfig();
}
// 登录返回订阅信息
- public function login(Request $request)
- {
+ public function login(Request $request) {
$email = trim($request->input('email'));
$password = trim($request->input('password'));
$cacheKey = 'request_times_'.md5(getClientIp());
@@ -82,14 +79,14 @@ class LoginController extends Controller
}
$nodeList = DB::table('ss_node')
- ->selectRaw('ss_node.*')
- ->leftJoin('ss_node_label', 'ss_node.id', '=', 'ss_node_label.node_id')
- ->whereIn('ss_node_label.label_id', $userLabelIds)
- ->where('ss_node.status', 1)
- ->groupBy('ss_node.id')
- ->orderBy('ss_node.sort', 'desc')
- ->orderBy('ss_node.id', 'asc')
- ->get();
+ ->selectRaw('ss_node.*')
+ ->leftJoin('ss_node_label', 'ss_node.id', '=', 'ss_node_label.node_id')
+ ->whereIn('ss_node_label.label_id', $userLabelIds)
+ ->where('ss_node.status', 1)
+ ->groupBy('ss_node.id')
+ ->orderBy('ss_node.sort', 'desc')
+ ->orderBy('ss_node.id', 'asc')
+ ->get();
$c_nodes = collect();
foreach($nodeList as $node){
@@ -119,7 +116,7 @@ class LoginController extends Controller
'buy_link' => '',
'money' => '0.00',
'sspannelName' => 'ssrpanel',
- 'usedTraffic' => flowAutoShow($user->u+$user->d),
+ 'usedTraffic' => flowAutoShow($user->u + $user->d),
'Traffic' => flowAutoShow($user->transfer_enable),
'all' => 1,
'residue' => '',
@@ -136,4 +133,4 @@ class LoginController extends Controller
return Response::json(['status' => 'success', 'data' => [], 'message' => '登录失败']);
}
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/Api/PingController.php b/app/Http/Controllers/Api/PingController.php
index c9f17932..e6db0e93 100644
--- a/app/Http/Controllers/Api/PingController.php
+++ b/app/Http/Controllers/Api/PingController.php
@@ -14,10 +14,8 @@ use Log;
*
* @package App\Http\Controllers\Api
*/
-class PingController extends Controller
-{
- public function ping(Request $request)
- {
+class PingController extends Controller {
+ public function ping(Request $request) {
$token = $request->input('token');
$host = $request->input('host');
$port = $request->input('port', 22);
@@ -51,7 +49,7 @@ class PingController extends Controller
}
// 如果不是IPv4
- if(FALSE === filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
+ if(false === filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
// 如果是IPv6
if(filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
$host = '['.$host.']';
diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php
index 5873bd2f..d5de22f7 100644
--- a/app/Http/Controllers/AuthController.php
+++ b/app/Http/Controllers/AuthController.php
@@ -36,26 +36,23 @@ use Validator;
*
* @package App\Http\Controllers
*/
-class AuthController extends Controller
-{
+class AuthController extends Controller {
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$systemConfig = Helpers::systemConfig();
}
// 登录
- public function login(Request $request)
- {
+ public function login(Request $request) {
if($request->isMethod('POST')){
$this->validate($request, [
'email' => 'required',
'password' => 'required'
], [
- 'email.required' => trans('auth.email_null'),
- 'password.required' => trans('auth.password_null')
- ]);
+ 'email.required' => trans('auth.email_null'),
+ 'password.required' => trans('auth.password_null')
+ ]);
$email = $request->input('email');
$password = $request->input('password');
@@ -63,7 +60,7 @@ class AuthController extends Controller
// 是否校验验证码
$captcha = $this->check_captcha($request);
- if($captcha != FALSE){
+ if($captcha != false){
return $captcha;
}
@@ -77,11 +74,14 @@ class AuthController extends Controller
if(Auth::user()->status < 0){
Auth::logout(); // 强制销毁会话,因为Auth::attempt的时候会产生会话
- return Redirect::back()->withInput()->withErrors(trans('auth.login_ban', ['email' => self::$systemConfig['webmaster_email']]));
+ return Redirect::back()->withInput()->withErrors(trans('auth.login_ban',
+ ['email' => self::$systemConfig['webmaster_email']]));
}elseif(Auth::user()->status == 0 && self::$systemConfig['is_activate_account']){
Auth::logout(); // 强制销毁会话,因为Auth::attempt的时候会产生会话
- return Redirect::back()->withInput()->withErrors(trans('auth.active_tip').'【'.trans('auth.active_account').'】');
+ return Redirect::back()
+ ->withInput()
+ ->withErrors(trans('auth.active_tip').'【'.trans('auth.active_account').'】');
}
}
@@ -111,8 +111,7 @@ class AuthController extends Controller
}
// 校验验证码
- private function check_captcha($request)
- {
+ private function check_captcha($request) {
switch(self::$systemConfig['is_captcha']){
case 1: // 默认图形验证码
if(!Captcha::check($request->input('captcha'))){
@@ -123,8 +122,8 @@ class AuthController extends Controller
$result = $this->validate($request, [
'geetest_challenge' => 'required|geetest'
], [
- 'geetest' => trans('auth.captcha_fail')
- ]);
+ 'geetest' => trans('auth.captcha_fail')
+ ]);
if(!$result){
return Redirect::back()->withInput()->withErrors(trans('auth.fail_captcha'));
@@ -158,11 +157,10 @@ class AuthController extends Controller
/**
* 添加用户登录日志
*
- * @param string $userId 用户ID
- * @param string $ip IP地址
+ * @param string $userId 用户ID
+ * @param string $ip IP地址
*/
- private function addUserLoginLog($userId, $ip)
- {
+ private function addUserLoginLog($userId, $ip) {
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
Log::info('识别到IPv6,尝试解析:'.$ip);
$ipInfo = getIPv6($ip);
@@ -206,16 +204,14 @@ class AuthController extends Controller
// 退出
- public function logout()
- {
+ public function logout() {
Auth::logout();
return Redirect::to('login');
}
// 注册
- public function register(Request $request)
- {
+ public function register(Request $request) {
$cacheKey = 'register_times_'.md5(getClientIp()); // 注册限制缓存key
if($request->isMethod('POST')){
@@ -226,16 +222,16 @@ class AuthController extends Controller
'confirmPassword' => 'required|same:password',
'term' => 'accepted'
], [
- 'username.required' => trans('auth.email_null'),
- 'email.required' => trans('auth.email_null'),
- 'email.email' => trans('auth.email_legitimate'),
- 'email.unique' => trans('auth.email_exist'),
- 'password.required' => trans('auth.password_null'),
- 'password.min' => trans('auth.password_limit'),
- 'confirmPassword.required' => trans('auth.confirm_password'),
- 'confirmPassword.same' => trans('auth.password_same'),
- 'term.accepted' => trans('auth.unaccepted')
- ]);
+ 'username.required' => trans('auth.email_null'),
+ 'email.required' => trans('auth.email_null'),
+ 'email.email' => trans('auth.email_legitimate'),
+ 'email.unique' => trans('auth.email_exist'),
+ 'password.required' => trans('auth.password_null'),
+ 'password.min' => trans('auth.password_limit'),
+ 'confirmPassword.required' => trans('auth.confirm_password'),
+ 'confirmPassword.same' => trans('auth.password_same'),
+ 'term.accepted' => trans('auth.unaccepted')
+ ]);
$username = $request->input('username');
$email = $request->input('email');
@@ -260,7 +256,7 @@ class AuthController extends Controller
// 校验域名邮箱黑白名单
if(self::$systemConfig['is_email_filtering']){
$result = $this->emailChecker($email);
- if($result != FALSE){
+ if($result != false){
return $result;
}
}
@@ -276,7 +272,9 @@ class AuthController extends Controller
if($code){
$codeEnable = Invite::query()->whereCode($code)->whereStatus(0)->doesntExist();
if($codeEnable){
- return Redirect::back()->withInput($request->except(['code']))->withErrors(trans('auth.code_error'));
+ return Redirect::back()
+ ->withInput($request->except(['code']))
+ ->withErrors(trans('auth.code_error'));
}
}
}
@@ -284,11 +282,19 @@ class AuthController extends Controller
// 注册前发送激活码
if(self::$systemConfig['is_activate_account'] == 1){
if(!$verify_code){
- return Redirect::back()->withInput($request->except(['verify_code']))->withErrors(trans('auth.captcha_null'));
+ return Redirect::back()
+ ->withInput($request->except(['verify_code']))
+ ->withErrors(trans('auth.captcha_null'));
}else{
- $verifyCode = VerifyCode::query()->whereAddress($email)->whereCode($verify_code)->whereStatus(0)->firstOrFail();
+ $verifyCode = VerifyCode::query()
+ ->whereAddress($email)
+ ->whereCode($verify_code)
+ ->whereStatus(0)
+ ->firstOrFail();
if(!$verifyCode){
- return Redirect::back()->withInput($request->except(['verify_code']))->withErrors(trans('auth.captcha_overtime'));
+ return Redirect::back()
+ ->withInput($request->except(['verify_code']))
+ ->withErrors(trans('auth.captcha_overtime'));
}
$verifyCode->status = 1;
@@ -298,7 +304,7 @@ class AuthController extends Controller
// 是否校验验证码
$captcha = $this->check_captcha($request);
- if($captcha != FALSE){
+ if($captcha != false){
return $captcha;
}
@@ -307,7 +313,9 @@ class AuthController extends Controller
if(Cache::has($cacheKey)){
$registerTimes = Cache::get($cacheKey);
if($registerTimes >= self::$systemConfig['register_ip_limit']){
- return Redirect::back()->withInput($request->except(['code']))->withErrors(trans('auth.register_anti'));
+ return Redirect::back()
+ ->withInput($request->except(['code']))
+ ->withErrors(trans('auth.register_anti'));
}
}
}
@@ -322,10 +330,11 @@ class AuthController extends Controller
$affArr = $this->getAff($code, $aff);
$referral_uid = $affArr['referral_uid'];
- $transfer_enable = 1048576*(self::$systemConfig['default_traffic']+($referral_uid? self::$systemConfig['referral_traffic'] : 0));
+ $transfer_enable = 1048576 * (self::$systemConfig['default_traffic'] + ($referral_uid? self::$systemConfig['referral_traffic'] : 0));
// 创建新用户
- $uid = Helpers::addUser($email, Hash::make($password), $transfer_enable, self::$systemConfig['default_days'], $referral_uid);
+ $uid = Helpers::addUser($email, Hash::make($password), $transfer_enable,
+ self::$systemConfig['default_days'], $referral_uid);
// 注册失败,抛出异常
if(!$uid){
@@ -383,7 +392,9 @@ class AuthController extends Controller
$referralUser = User::query()->whereId($referral_uid)->first();
if($referralUser){
if($referralUser->expire_time >= date('Y-m-d')){
- User::query()->whereId($referral_uid)->increment('transfer_enable', self::$systemConfig['referral_traffic']*1048576);
+ User::query()
+ ->whereId($referral_uid)
+ ->increment('transfer_enable', self::$systemConfig['referral_traffic'] * 1048576);
}
}
}
@@ -397,7 +408,9 @@ class AuthController extends Controller
return Redirect::to('login')->withInput();
}else{
- $view['emailList'] = self::$systemConfig['is_email_filtering'] != 2? FALSE : SensitiveWords::query()->whereType(2)->get();
+ $view['emailList'] = self::$systemConfig['is_email_filtering'] != 2? false : SensitiveWords::query()
+ ->whereType(2)
+ ->get();
Session::put('register_token', makeRandStr(16));
return Response::view('auth.register', $view);
@@ -405,8 +418,7 @@ class AuthController extends Controller
}
//邮箱检查
- private function emailChecker($email)
- {
+ private function emailChecker($email) {
$sensitiveWords = $this->sensitiveWords(self::$systemConfig['is_email_filtering']);
$emailSuffix = explode('@', $email); // 提取邮箱后缀
switch(self::$systemConfig['is_email_filtering']){
@@ -426,19 +438,18 @@ class AuthController extends Controller
return Response::json(['status' => 'fail', 'message' => trans('auth.email_invalid')]);
}
- return FALSE;
+ return false;
}
/**
* 获取AFF
*
- * @param string $code 邀请码
- * @param int $aff URL中的aff参数
+ * @param string $code 邀请码
+ * @param int $aff URL中的aff参数
*
* @return array
*/
- private function getAff($code = '', $aff = NULL)
- {
+ private function getAff($code = '', $aff = null) {
// 邀请人ID
$referral_uid = 0;
@@ -474,8 +485,7 @@ class AuthController extends Controller
}
// 生成申请的请求地址
- private function addVerifyUrl($uid, $email)
- {
+ private function addVerifyUrl($uid, $email) {
$token = md5(self::$systemConfig['website_name'].$email.microtime());
$verify = new Verify();
$verify->type = 1;
@@ -488,22 +498,22 @@ class AuthController extends Controller
}
// 重设密码页
- public function resetPassword(Request $request)
- {
+ public function resetPassword(Request $request) {
if($request->isMethod('POST')){
// 校验请求
$this->validate($request, [
'email' => 'required|email'
], [
- 'email.required' => trans('auth.email_null'),
- 'email.email' => trans('auth.email_legitimate')
- ]);
+ 'email.required' => trans('auth.email_null'),
+ 'email.email' => trans('auth.email_legitimate')
+ ]);
$email = $request->input('email');
// 是否开启重设密码
if(!self::$systemConfig['is_reset_password']){
- return Redirect::back()->withErrors(trans('auth.reset_password_close', ['email' => self::$systemConfig['webmaster_email']]));
+ return Redirect::back()->withErrors(trans('auth.reset_password_close',
+ ['email' => self::$systemConfig['webmaster_email']]));
}
// 查找账号
@@ -517,7 +527,8 @@ class AuthController extends Controller
if(Cache::has('resetPassword_'.md5($email))){
$resetTimes = Cache::get('resetPassword_'.md5($email));
if($resetTimes >= self::$systemConfig['reset_password_times']){
- return Redirect::back()->withErrors(trans('auth.reset_password_limit', ['time' => self::$systemConfig['reset_password_times']]));
+ return Redirect::back()->withErrors(trans('auth.reset_password_limit',
+ ['time' => self::$systemConfig['reset_password_times']]));
}
}
@@ -530,7 +541,7 @@ class AuthController extends Controller
$logId = Helpers::addNotificationLog('重置密码', '请求地址:'.$resetPasswordUrl, 1, $email);
Mail::to($email)->send(new resetPassword($logId, $resetPasswordUrl));
- Cache::put('resetPassword_'.md5($email), $resetTimes+1, 86400);
+ Cache::put('resetPassword_'.md5($email), $resetTimes + 1, 86400);
return Redirect::back()->with('successMsg', trans('auth.reset_password_success_tip'));
}else{
@@ -539,8 +550,7 @@ class AuthController extends Controller
}
// 重设密码
- public function reset(Request $request, $token)
- {
+ public function reset(Request $request, $token) {
if(!$token){
return Redirect::to('login');
}
@@ -550,12 +560,12 @@ class AuthController extends Controller
'password' => 'required|min:6',
'confirmPassword' => 'required|same:password'
], [
- 'password.required' => trans('auth.password_null'),
- 'password.min' => trans('auth.password_limit'),
- 'confirmPassword.required' => trans('auth.password_null'),
- 'confirmPassword.min' => trans('auth.password_limit'),
- 'confirmPassword.same' => trans('auth.password_same'),
- ]);
+ 'password.required' => trans('auth.password_null'),
+ 'password.min' => trans('auth.password_limit'),
+ 'confirmPassword.required' => trans('auth.password_null'),
+ 'confirmPassword.min' => trans('auth.password_limit'),
+ 'confirmPassword.same' => trans('auth.password_same'),
+ ]);
$password = $request->input('password');
// 校验账号
$verify = Verify::type(1)->with('user')->whereToken($token)->first();
@@ -584,7 +594,7 @@ class AuthController extends Controller
$verify = Verify::type(1)->whereToken($token)->first();
if(!$verify){
return Redirect::to('login');
- }elseif(time()-strtotime($verify->created_at) >= 1800){
+ }elseif(time() - strtotime($verify->created_at) >= 1800){
// 置为已失效
$verify->status = 2;
$verify->save();
@@ -598,27 +608,28 @@ class AuthController extends Controller
}
// 激活账号页
- public function activeUser(Request $request)
- {
+ public function activeUser(Request $request) {
if($request->isMethod('POST')){
$this->validate($request, [
'email' => 'required|email|exists:user,email'
], [
- 'email.required' => trans('auth.email_null'),
- 'email.email' => trans('auth.email_legitimate'),
- 'email.exists' => trans('auth.email_notExist')
- ]);
+ 'email.required' => trans('auth.email_null'),
+ 'email.email' => trans('auth.email_legitimate'),
+ 'email.exists' => trans('auth.email_notExist')
+ ]);
$email = $request->input('email');
// 是否开启账号激活
if(self::$systemConfig['is_activate_account'] != 2){
- return Redirect::back()->withInput()->withErrors(trans('auth.active_close', ['email' => self::$systemConfig['webmaster_email']]));
+ return Redirect::back()->withInput()->withErrors(trans('auth.active_close',
+ ['email' => self::$systemConfig['webmaster_email']]));
}
// 查找账号
$user = User::query()->whereEmail($email)->first();
if($user->status < 0){
- return Redirect::back()->withErrors(trans('auth.login_ban', ['email' => self::$systemConfig['webmaster_email']]));
+ return Redirect::back()->withErrors(trans('auth.login_ban',
+ ['email' => self::$systemConfig['webmaster_email']]));
}elseif($user->status > 0){
return Redirect::back()->withErrors(trans('auth.email_normal'));
}
@@ -628,7 +639,8 @@ class AuthController extends Controller
if(Cache::has('activeUser_'.md5($email))){
$activeTimes = Cache::get('activeUser_'.md5($email));
if($activeTimes >= self::$systemConfig['active_times']){
- return Redirect::back()->withErrors(trans('auth.active_limit', ['time' => self::$systemConfig['webmaster_email']]));
+ return Redirect::back()->withErrors(trans('auth.active_limit',
+ ['time' => self::$systemConfig['webmaster_email']]));
}
}
@@ -641,7 +653,7 @@ class AuthController extends Controller
$logId = Helpers::addNotificationLog('激活账号', '请求地址:'.$activeUserUrl, 1, $email);
Mail::to($email)->send(new activeUser($logId, $activeUserUrl));
- Cache::put('activeUser_'.md5($email), $activeTimes+1, 86400);
+ Cache::put('activeUser_'.md5($email), $activeTimes + 1, 86400);
return Redirect::back()->with('successMsg', trans('auth.register_active_tip'));
}else{
@@ -650,8 +662,7 @@ class AuthController extends Controller
}
// 激活账号
- public function active($token)
- {
+ public function active($token) {
if(!$token){
return Redirect::to('login');
}
@@ -671,7 +682,7 @@ class AuthController extends Controller
Session::flash('errorMsg', trans('auth.email_normal'));
return Response::view('auth.active');
- }elseif(time()-strtotime($verify->created_at) >= 1800){
+ }elseif(time() - strtotime($verify->created_at) >= 1800){
Session::flash('errorMsg', trans('auth.overtime'));
// 置为已失效
@@ -695,9 +706,11 @@ class AuthController extends Controller
// 账号激活后给邀请人送流量
if($verify->user->referral_uid){
- $transfer_enable = self::$systemConfig['referral_traffic']*1048576;
+ $transfer_enable = self::$systemConfig['referral_traffic'] * 1048576;
- User::query()->whereId($verify->user->referral_uid)->increment('transfer_enable', $transfer_enable, ['enable' => 1]);
+ User::query()
+ ->whereId($verify->user->referral_uid)
+ ->increment('transfer_enable', $transfer_enable, ['enable' => 1]);
}
Session::flash('successMsg', trans('auth.active_success'));
@@ -706,15 +719,14 @@ class AuthController extends Controller
}
// 发送注册验证码
- public function sendCode(Request $request)
- {
+ public function sendCode(Request $request) {
$validator = Validator::make($request->all(), [
'email' => 'required|email|unique:user'
], [
- 'email.required' => trans('auth.email_null'),
- 'email.email' => trans('auth.email_legitimate'),
- 'email.unique' => trans('auth.email_exist')
- ]);
+ 'email.required' => trans('auth.email_null'),
+ 'email.email' => trans('auth.email_legitimate'),
+ 'email.unique' => trans('auth.email_exist')
+ ]);
$email = $request->input('email');
@@ -725,7 +737,7 @@ class AuthController extends Controller
// 校验域名邮箱黑白名单
if(self::$systemConfig['is_email_filtering']){
$result = $this->emailChecker($email);
- if($result != FALSE){
+ if($result != false){
return $result;
}
}
@@ -741,7 +753,7 @@ class AuthController extends Controller
}
// 发送邮件
- $code = makeRandStr(6, TRUE);
+ $code = makeRandStr(6, true);
$logId = Helpers::addNotificationLog('发送注册验证码', '验证码:'.$code, 1, $email);
Mail::to($email)->send(new sendVerifyCode($logId, $code));
@@ -753,8 +765,7 @@ class AuthController extends Controller
}
// 生成注册验证码
- private function addVerifyCode($email, $code)
- {
+ private function addVerifyCode($email, $code) {
$verify = new VerifyCode();
$verify->address = $email;
$verify->code = $code;
@@ -763,18 +774,16 @@ class AuthController extends Controller
}
// 公开的邀请码列表
- public function free()
- {
+ public function free() {
$view['inviteList'] = Invite::query()->whereUid(0)->whereStatus(0)->paginate();
return Response::view('auth.free', $view);
}
// 切换语言
- public function switchLang($locale)
- {
+ public function switchLang($locale) {
Session::put("locale", $locale);
return Redirect::back();
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index dc1e2511..2c48a4f7 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -14,39 +14,34 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
-class Controller extends BaseController
-{
+class Controller extends BaseController {
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
// 生成随机密码
- public function makePasswd()
- {
+ public function makePasswd() {
return makeRandStr();
}
// 生成VmessId
- public function makeVmessId()
- {
+ public function makeVmessId() {
return createGuid();
}
// 生成网站安全码
- public function makeSecurityCode()
- {
+ public function makeSecurityCode() {
return strtolower(makeRandStr(8));
}
// 类似Linux中的tail命令
- public function tail($file, $n, $base = 5)
- {
+ public function tail($file, $n, $base = 5) {
$fileLines = $this->countLine($file);
if($fileLines < 15000){
- return FALSE;
+ return false;
}
$fp = fopen($file, "r+");
assert($n > 0);
- $pos = $n+1;
+ $pos = $n + 1;
$lines = [];
while(count($lines) <= $n){
try{
@@ -72,13 +67,12 @@ class Controller extends BaseController
*
* @return int
*/
- public function countLine($file)
- {
+ public function countLine($file) {
$fp = fopen($file, "r");
$i = 0;
while(!feof($fp)){
//每次读取2M
- if($data = fread($fp, 1024*1024*2)){
+ if($data = fread($fp, 1024 * 1024 * 2)){
//计算读取到的行数
$num = substr_count($data, "\n");
$i += $num;
@@ -91,14 +85,12 @@ class Controller extends BaseController
}
// 获取敏感词
- public function sensitiveWords($type)
- {
+ public function sensitiveWords($type) {
return SensitiveWords::query()->whereType($type)->get()->pluck('words')->toArray();
}
// 将Base64图片转换为本地图片并保存
- function base64ImageSaver($base64_image_content)
- {
+ function base64ImageSaver($base64_image_content) {
// 匹配出图片的格式
if(preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)){
$type = $result[2];
@@ -106,11 +98,12 @@ class Controller extends BaseController
$directory = date('Ymd');
$path = '/assets/images/qrcode/'.$directory.'/';
if(!file_exists(public_path($path))){ // 检查是否有该文件夹,如果没有就创建,并给予最高权限
- mkdir(public_path($path), 0755, TRUE);
+ mkdir(public_path($path), 0755, true);
}
- $fileName = makeRandStr(18, TRUE).".{$type}";
- if(file_put_contents(public_path($path.$fileName), base64_decode(str_replace($result[1], '', $base64_image_content)))){
+ $fileName = makeRandStr(18, true).".{$type}";
+ if(file_put_contents(public_path($path.$fileName),
+ base64_decode(str_replace($result[1], '', $base64_image_content)))){
chmod(public_path($path.$fileName), 0744);
return $path.$fileName;
@@ -125,24 +118,23 @@ class Controller extends BaseController
/**
* 节点信息
*
- * @param int $uid 用户ID
- * @param int $nodeId 节点ID
- * @param int $infoType 信息类型:0为链接,1为文字
+ * @param int $uid 用户ID
+ * @param int $nodeId 节点ID
+ * @param int $infoType 信息类型:0为链接,1为文字
*
* @return string
*/
- function getNodeInfo($uid, $nodeId, $infoType)
- {
+ function getNodeInfo($uid, $nodeId, $infoType) {
$user = User::whereId($uid)->first();
$node = SsNode::whereId($nodeId)->first();
- $scheme = NULL;
+ $scheme = null;
// 获取分组名称
$group = SsGroup::query()->whereId($node->group_id)->first();
- $host = $node->server? : $node->ip;
+ $host = $node->server?: $node->ip;
if($node->type == 1){
$group = $group? $group->name : Helpers::systemConfig()['website_name'];
- $obfs_param = $user->obfs_param? : $node->obfs_param;
+ $obfs_param = $user->obfs_param?: $node->obfs_param;
if($node->single){
$port = $node->port;
$protocol = $node->protocol;
@@ -167,35 +159,27 @@ class Controller extends BaseController
}
}else{
// 生成文本配置信息
- $data = "服务器:".$host.PHP_EOL.
- "IPv6:".($node->ipv6? : '').PHP_EOL.
- "远程端口:".$port.PHP_EOL.
- "密码:".$passwd.PHP_EOL.
- "加密方法:".$method.PHP_EOL.
- "路由:绕过局域网及中国大陆地址".PHP_EOL.
- "协议:".$protocol.PHP_EOL.
- "协议参数:".$protocol_param.PHP_EOL.
- "混淆方式:".$obfs.PHP_EOL.
- "混淆参数:".$obfs_param.PHP_EOL.
- "本地端口:1080".PHP_EOL;
+ $data = "服务器:".$host.PHP_EOL."IPv6:".($node->ipv6?: '').PHP_EOL."远程端口:".$port.PHP_EOL."密码:".$passwd.PHP_EOL."加密方法:".$method.PHP_EOL."路由:绕过局域网及中国大陆地址".PHP_EOL."协议:".$protocol.PHP_EOL."协议参数:".$protocol_param.PHP_EOL."混淆方式:".$obfs.PHP_EOL."混淆参数:".$obfs_param.PHP_EOL."本地端口:1080".PHP_EOL;
}
}else{
// 生成v2ray scheme
if($infoType != 1){
// 生成v2ray scheme
- $data = 'vmess://'.base64_encode(json_encode(["v" => "2", "ps" => $node->name, "add" => $host, "port" => $node->v2_port, "id" => $user->vmess_id, "aid" => $node->v2_alter_id, "net" => $node->v2_net, "type" => $node->v2_type, "host" => $node->v2_host, "path" => $node->v2_path, "tls" => $node->v2_tls? "tls" : ""], JSON_PRETTY_PRINT));
+ $data = 'vmess://'.base64_encode(json_encode([
+ "v" => "2",
+ "ps" => $node->name,
+ "add" => $host,
+ "port" => $node->v2_port,
+ "id" => $user->vmess_id,
+ "aid" => $node->v2_alter_id,
+ "net" => $node->v2_net,
+ "type" => $node->v2_type,
+ "host" => $node->v2_host,
+ "path" => $node->v2_path,
+ "tls" => $node->v2_tls? "tls" : ""
+ ], JSON_PRETTY_PRINT));
}else{
- $data = "服务器:".$host.PHP_EOL.
- "IPv6:".($node->ipv6? : "").PHP_EOL.
- "端口:".$node->v2_port.PHP_EOL.
- "加密方式:".$node->v2_method.PHP_EOL.
- "用户ID:".$user->vmess_id.PHP_EOL.
- "额外ID:".$node->v2_alter_id.PHP_EOL.
- "传输协议:".$node->v2_net.PHP_EOL.
- "伪装类型:".$node->v2_type.PHP_EOL.
- "伪装域名:".($node->v2_host? : "").PHP_EOL.
- "路径:".($node->v2_path? : "").PHP_EOL.
- "TLS:".($node->v2_tls? "tls" : "").PHP_EOL;
+ $data = "服务器:".$host.PHP_EOL."IPv6:".($node->ipv6?: "").PHP_EOL."端口:".$node->v2_port.PHP_EOL."加密方式:".$node->v2_method.PHP_EOL."用户ID:".$user->vmess_id.PHP_EOL."额外ID:".$node->v2_alter_id.PHP_EOL."传输协议:".$node->v2_net.PHP_EOL."伪装类型:".$node->v2_type.PHP_EOL."伪装域名:".($node->v2_host?: "").PHP_EOL."路径:".($node->v2_path?: "").PHP_EOL."TLS:".($node->v2_tls? "tls" : "").PHP_EOL;
}
}
@@ -203,8 +187,7 @@ class Controller extends BaseController
}
// 写入订阅访问日志
- public function log($subscribeId, $ip, $headers)
- {
+ public function log($subscribeId, $ip, $headers) {
$log = new UserSubscribeLog();
$log->sid = $subscribeId;
$log->request_ip = $ip;
diff --git a/app/Http/Controllers/Gateway/AbstractPayment.php b/app/Http/Controllers/Gateway/AbstractPayment.php
index f1d78d75..b7fcca26 100644
--- a/app/Http/Controllers/Gateway/AbstractPayment.php
+++ b/app/Http/Controllers/Gateway/AbstractPayment.php
@@ -13,27 +13,23 @@ use App\Http\Models\UserLabel;
use Illuminate\Http\Request;
use Log;
-abstract class AbstractPayment
-{
+abstract class AbstractPayment {
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$systemConfig = Helpers::systemConfig();
}
- public static function generateGuid()
- {
- mt_srand((double)microtime()*10000);
- $charid = strtoupper(md5(uniqid(mt_rand()+time(), TRUE)));
+ public static function generateGuid() {
+ mt_srand((double) microtime() * 10000);
+ $charid = strtoupper(md5(uniqid(mt_rand() + time(), true)));
$hyphen = chr(45);
- $uuid = chr(123)
- .substr($charid, 0, 8).$hyphen
- .substr($charid, 8, 4).$hyphen
- .substr($charid, 12, 4).$hyphen
- .substr($charid, 16, 4).$hyphen
- .substr($charid, 20, 12)
- .chr(125);
+ $uuid = chr(123).substr($charid, 0, 8).$hyphen.substr($charid, 8, 4).$hyphen.substr($charid, 12,
+ 4).$hyphen.substr($charid,
+ 16,
+ 4).$hyphen.substr($charid,
+ 20,
+ 12).chr(125);
$uuid = str_replace(['}', '{', '-'], '', $uuid);
$uuid = substr($uuid, 0, 8);
@@ -49,8 +45,7 @@ abstract class AbstractPayment
abstract public function getPurchaseHTML();
- public function postPayment($data, $method)
- {
+ public function postPayment($data, $method) {
// 获取需要的信息
$payment = Payment::whereSn($data)->first();
// 是否为余额购买套餐
@@ -65,9 +60,10 @@ abstract class AbstractPayment
//余额充值
if($order->goods_id == -1){
- User::query()->whereId($order->user_id)->increment('balance', $order->amount*100);
+ User::query()->whereId($order->user_id)->increment('balance', $order->amount * 100);
// 余额变动记录日志
- Helpers::addUserBalanceLog($order->user_id, $order->oid, $order->user->balance, $order->user->balance+$order->amount, $order->amount, '用户'.$method.'充值余额');
+ Helpers::addUserBalanceLog($order->user_id, $order->oid, $order->user->balance,
+ $order->user->balance + $order->amount, $order->amount, '用户'.$method.'充值余额');
return 0;
}
@@ -77,11 +73,21 @@ abstract class AbstractPayment
case 1:
$order->status = 2;
$order->save();
- User::query()->whereId($order->user_id)->increment('transfer_enable', $goods->traffic*1048576);
- Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $user->transfer_enable+$goods->traffic*1048576, '['.$method.']加上用户购买的套餐流量');
+ User::query()->whereId($order->user_id)->increment('transfer_enable', $goods->traffic * 1048576);
+ Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable,
+ $user->transfer_enable + $goods->traffic * 1048576,
+ '['.$method.']加上用户购买的套餐流量');
break;
case 2:
- $activePlan = Order::query()->whereUserId($user->id)->with(['goods'])->whereIsExpire(0)->whereStatus(2)->whereHas('goods', function($q){ $q->whereType(2); })->exists();
+ $activePlan = Order::query()
+ ->whereUserId($user->id)
+ ->with(['goods'])
+ ->whereIsExpire(0)
+ ->whereStatus(2)
+ ->whereHas('goods', function($q) {
+ $q->whereType(2);
+ })
+ ->exists();
// 2为开始生效,3为预支付
$order->status = $activePlan? 3 : 2;
@@ -89,30 +95,31 @@ abstract class AbstractPayment
if($activePlan){
// 预支付订单, 刷新账号有效时间用于流量重置判断
- User::query()->whereId($order->user_id)->update(['expire_time' => date('Y-m-d', strtotime("+".$goods->days." days", strtotime($user->expire_time)))]);
+ User::query()->whereId($order->user_id)->update([
+ 'expire_time' => date('Y-m-d',
+ strtotime("+".$goods->days." days",
+ strtotime($user->expire_time)))
+ ]);
}else{
// 如果买的是套餐,则先将之前购买的套餐都无效化,重置用户已用、可用流量为0
- Order::query()
- ->whereUserId($user->id)
- ->with(['goods'])
- ->whereHas('goods', function($q){
- $q->where('type', '<=', 2);
- })
- ->whereIsExpire(0)
- ->whereStatus(2)
- ->where('oid', '<>', $order->oid)
- ->update(['expire_at' => date('Y-m-d H:i:s'), 'is_expire' => 1]);
+ Order::query()->whereUserId($user->id)->with(['goods'])->whereHas('goods', function($q) {
+ $q->where('type', '<=', 2);
+ })->whereIsExpire(0)->whereStatus(2)->where('oid', '<>', $order->oid)->update([
+ 'expire_at' => date('Y-m-d H:i:s'),
+ 'is_expire' => 1
+ ]);
User::query()->whereId($order->user_id)->update(['u' => 0, 'd' => 0, 'transfer_enable' => 0]);
- Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, 0, '['.$method.']用户购买新套餐,先清空流量');
+ Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, 0,
+ '['.$method.']用户购买新套餐,先清空流量');
- $userTraffic = $goods->traffic*1048576;
+ $userTraffic = $goods->traffic * 1048576;
// 添加账号有效期
$expireTime = date('Y-m-d', strtotime("+".$goods->days." days"));
//账号下一个重置时间
$nextResetTime = date('Y-m-d', strtotime("+".$goods->period." days"));
if($nextResetTime >= $expireTime){
- $nextResetTime = NULL;
+ $nextResetTime = null;
}
// 写入用户标签
@@ -121,7 +128,12 @@ abstract class AbstractPayment
UserLabel::query()->whereUserId($order->user_id)->delete();
//取出 商品默认标签 & 系统默认标签 去重
- $newUserLabels = array_values(array_unique(array_merge(GoodsLabel::query()->whereGoodsId($order->goods_id)->pluck('label_id')->toArray(), self::$systemConfig['initial_labels_for_user']? explode(',', self::$systemConfig['initial_labels_for_user']) : [])));
+ $newUserLabels = array_values(array_unique(array_merge(GoodsLabel::query()
+ ->whereGoodsId($order->goods_id)
+ ->pluck('label_id')
+ ->toArray(),
+ self::$systemConfig['initial_labels_for_user']? explode(',',
+ self::$systemConfig['initial_labels_for_user']) : [])));
// 生成标签
foreach($newUserLabels as $Label){
@@ -132,8 +144,14 @@ abstract class AbstractPayment
}
}
- User::query()->whereId($order->user_id)->increment('invite_num', $goods->invite_num? : 0, ['transfer_enable' => $userTraffic, 'reset_time' => $nextResetTime, 'expire_time' => $expireTime, 'enable' => 1]);
- Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $userTraffic, '['.$method.']加上用户购买的套餐流量');
+ User::query()->whereId($order->user_id)->increment('invite_num', $goods->invite_num?: 0, [
+ 'transfer_enable' => $userTraffic,
+ 'reset_time' => $nextResetTime,
+ 'expire_time' => $expireTime,
+ 'enable' => 1
+ ]);
+ Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $userTraffic,
+ '['.$method.']加上用户购买的套餐流量');
}
// 是否返利
@@ -146,8 +164,11 @@ abstract class AbstractPayment
User::query()->whereId($order->user->referral_uid)->increment('invite_num', 1);
}
//按照返利模式进行返利判断
- if(self::$systemConfig['referral_type'] == 2 || (self::$systemConfig['referral_type'] == 1 && !$referral)){
- $this->addReferralLog($order->user_id, $order->user->referral_uid, $order->oid, $order->amount, $order->amount*self::$systemConfig['referral_percent']);
+ if(self::$systemConfig['referral_type'] == 2
+ || (self::$systemConfig['referral_type'] == 1
+ && !$referral)){
+ $this->addReferralLog($order->user_id, $order->user->referral_uid, $order->oid, $order->amount,
+ $order->amount * self::$systemConfig['referral_percent']);
}
}
@@ -162,16 +183,15 @@ abstract class AbstractPayment
/**
* 添加返利日志
*
- * @param int $userId 用户ID
- * @param int $refUserId 返利用户ID
- * @param int $oid 订单ID
- * @param int $amount 发生金额
- * @param int $refAmount 返利金额
+ * @param int $userId 用户ID
+ * @param int $refUserId 返利用户ID
+ * @param int $oid 订单ID
+ * @param int $amount 发生金额
+ * @param int $refAmount 返利金额
*
* @return int
*/
- private function addReferralLog($userId, $refUserId, $oid, $amount, $refAmount)
- {
+ private function addReferralLog($userId, $refUserId, $oid, $amount, $refAmount) {
$log = new ReferralLog();
$log->user_id = $userId;
$log->ref_user_id = $refUserId;
@@ -182,4 +202,4 @@ abstract class AbstractPayment
return $log->save();
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/Gateway/BitpayX.php b/app/Http/Controllers/Gateway/BitpayX.php
index 0ab2384e..fe8c475f 100644
--- a/app/Http/Controllers/Gateway/BitpayX.php
+++ b/app/Http/Controllers/Gateway/BitpayX.php
@@ -9,17 +9,15 @@ use Auth;
use Illuminate\Http\Request;
use Response;
-class BitpayX extends AbstractPayment
-{
+class BitpayX extends AbstractPayment {
private $bitpayGatewayUri = 'https://api.mugglepay.com/v1/';
/**
- * @param Request $request
+ * @param Request $request
*
* @return mixed
*/
- public function purchase(Request $request)
- {
+ public function purchase(Request $request) {
$payment = new Payment();
$payment->sn = self::generateGuid();
$payment->user_id = Auth::user()->id;
@@ -29,38 +27,40 @@ class BitpayX extends AbstractPayment
$data = [
'merchant_order_id' => $payment->sn,
- 'price_amount' => (float)$request->input('amount'),
+ 'price_amount' => (float) $request->input('amount'),
'price_currency' => 'CNY',
'pay_currency' => $request->input('type') == 1? 'ALIPAY' : 'WECHAT',
'title' => '支付单号:'.$payment->sn,
- 'description' => parent::$systemConfig['subject_name']? : parent::$systemConfig['website_name'],
- 'callback_url' => (parent::$systemConfig['website_callback_url']? : parent::$systemConfig['website_url']).'/callback/notify?method=bitpayx',
+ 'description' => parent::$systemConfig['subject_name']?: parent::$systemConfig['website_name'],
+ 'callback_url' => (parent::$systemConfig['website_callback_url']?: parent::$systemConfig['website_url']).'/callback/notify?method=bitpayx',
'success_url' => parent::$systemConfig['website_url'].'/invoices',
'cancel_url' => parent::$systemConfig['website_url'],
'token' => $this->sign($this->prepareSignId($payment->sn)),
];
- $result = json_decode($this->mprequest($data), TRUE);
+ $result = json_decode($this->mprequest($data), true);
if($result['status'] === 200 || $result['status'] === 201){
$result['payment_url'] .= '&lang=zh';
Payment::whereId($payment->id)->update(['url' => $result['payment_url']]);
- return Response::json(['status' => 'success', 'url' => $result['payment_url'] .= '&lang=zh', 'message' => '创建订单成功!']);
+ return Response::json([
+ 'status' => 'success',
+ 'url' => $result['payment_url'] .= '&lang=zh',
+ 'message' => '创建订单成功!'
+ ]);
}
return Response::json(['status' => 'fail', 'data' => $result, 'message' => '创建订单失败!']);
}
- public function sign($data)
- {
+ public function sign($data) {
return strtolower(md5(md5($data).parent::$systemConfig['bitpay_secret']));
}
- public function prepareSignId($tradeno)
- {
+ public function prepareSignId($tradeno) {
$data_sign = [
'merchant_order_id' => $tradeno,
'secret' => parent::$systemConfig['bitpay_secret'],
@@ -71,8 +71,7 @@ class BitpayX extends AbstractPayment
return http_build_query($data_sign);
}
- public function mprequest($data, $type = 'pay')
- {
+ public function mprequest($data, $type = 'pay') {
$headers = ['content-type: application/json', 'token: '.parent::$systemConfig['bitpay_secret']];
$curl = curl_init();
if($type === 'pay'){
@@ -88,21 +87,20 @@ class BitpayX extends AbstractPayment
}
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
- public function notify(Request $request)
- {
+ public function notify(Request $request) {
$inputString = file_get_contents('php://input', 'r');
$inputStripped = str_replace(["\r", "\n", "\t", "\v"], '', $inputString);
- $inputJSON = json_decode($inputStripped, TRUE); //convert JSON into array
+ $inputJSON = json_decode($inputStripped, true); //convert JSON into array
$data = [];
- if($inputJSON !== NULL){
+ if($inputJSON !== null){
$data = [
'status' => $inputJSON['status'],
'order_id' => $inputJSON['order_id'],
@@ -115,7 +113,7 @@ class BitpayX extends AbstractPayment
// 准备待签名数据
$str_to_sign = $this->prepareSignId($inputJSON['merchant_order_id']);
$resultVerify = $this->verify($str_to_sign, $inputJSON['token']);
- $isPaid = $data !== NULL && $data['status'] !== NULL && $data['status'] === 'PAID';
+ $isPaid = $data !== null && $data['status'] !== null && $data['status'] === 'PAID';
if($resultVerify && $isPaid){
$this->postPayment($inputJSON['merchant_order_id'], 'BitPayX');
@@ -130,20 +128,17 @@ class BitpayX extends AbstractPayment
exit();
}
- public function verify($data, $signature)
- {
+ public function verify($data, $signature) {
$mySign = $this->sign($data);
return $mySign === $signature;
}
- public function getReturnHTML(Request $request)
- {
+ public function getReturnHTML(Request $request) {
// TODO: Implement getReturnHTML() method.
}
- public function getPurchaseHTML()
- {
+ public function getPurchaseHTML() {
// TODO: Implement getPurchaseHTML() method.
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/Gateway/CodePay.php b/app/Http/Controllers/Gateway/CodePay.php
index 90f04904..2fbf9b96 100644
--- a/app/Http/Controllers/Gateway/CodePay.php
+++ b/app/Http/Controllers/Gateway/CodePay.php
@@ -6,10 +6,8 @@ use App\Http\Models\Payment;
use Auth;
use Response;
-class CodePay extends AbstractPayment
-{
- public function purchase($request)
- {
+class CodePay extends AbstractPayment {
+ public function purchase($request) {
$payment = new Payment();
$payment->sn = self::generateGuid();
$payment->user_id = Auth::user()->id;
@@ -20,12 +18,12 @@ class CodePay extends AbstractPayment
$data = [
'id' => parent::$systemConfig['codepay_id'],
'pay_id' => $payment->sn,
- 'type' => $request->input('type'),//1支付宝支付 2QQ钱包 3微信支付
+ 'type' => $request->input('type'), //1支付宝支付 2QQ钱包 3微信支付
'price' => $payment->amount,
'page' => 1,
'outTime' => 900,
'param' => '',
- 'notify_url' => (parent::$systemConfig['website_callback_url']? : parent::$systemConfig['website_url']).'/callback/notify?method=codepay',
+ 'notify_url' => (parent::$systemConfig['website_callback_url']?: parent::$systemConfig['website_url']).'/callback/notify?method=codepay',
'return_url' => parent::$systemConfig['website_url'].'/invoices',
];
@@ -53,8 +51,7 @@ class CodePay extends AbstractPayment
return Response::json(['status' => 'success', 'url' => $url, 'message' => '创建订单成功!']);
}
- public function notify($request)
- {
+ public function notify($request) {
ksort($_POST);
reset($_POST);
$sign = '';
@@ -81,13 +78,11 @@ class CodePay extends AbstractPayment
exit('fail');
}
- public function getReturnHTML($request)
- {
+ public function getReturnHTML($request) {
// TODO: Implement getReturnHTML() method.
}
- public function getPurchaseHTML()
- {
+ public function getPurchaseHTML() {
// TODO: Implement getReturnHTML() method.
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/Gateway/F2Fpay.php b/app/Http/Controllers/Gateway/F2Fpay.php
index 044d0372..164038c5 100644
--- a/app/Http/Controllers/Gateway/F2Fpay.php
+++ b/app/Http/Controllers/Gateway/F2Fpay.php
@@ -12,28 +12,25 @@ use Payment\Exceptions\ClassNotFoundException;
use Payment\Exceptions\GatewayException;
use Response;
-class F2Fpay extends AbstractPayment
-{
+class F2Fpay extends AbstractPayment {
private static $aliConfig;
- function __construct()
- {
+ function __construct() {
parent::__construct();
self::$aliConfig = [
- 'use_sandbox' => FALSE,
+ 'use_sandbox' => false,
'app_id' => self::$systemConfig['f2fpay_app_id'],
'sign_type' => 'RSA2',
'ali_public_key' => self::$systemConfig['f2fpay_public_key'],
'rsa_private_key' => self::$systemConfig['f2fpay_private_key'],
'limit_pay' => [],
- 'notify_url' => (self::$systemConfig['website_callback_url']? : self::$systemConfig['website_url']).'/callback/notify?method=f2fpay',
+ 'notify_url' => (self::$systemConfig['website_callback_url']?: self::$systemConfig['website_url']).'/callback/notify?method=f2fpay',
'return_url' => self::$systemConfig['website_url'].'/invoices',
'fee_type' => 'CNY',
];
}
- public function purchase($request)
- {
+ public function purchase($request) {
$payment = new Payment();
$payment->sn = self::generateGuid();
$payment->user_id = Auth::user()->id;
@@ -43,9 +40,9 @@ class F2Fpay extends AbstractPayment
$data = [
'body' => '',
- 'subject' => self::$systemConfig['subject_name']? : self::$systemConfig['website_name'],
+ 'subject' => self::$systemConfig['subject_name']?: self::$systemConfig['website_name'],
'trade_no' => $payment->sn,
- 'time_expire' => time()+900, // 必须 15分钟 内付款
+ 'time_expire' => time() + 900, // 必须 15分钟 内付款
'amount' => $payment->amount,
];
@@ -67,13 +64,14 @@ class F2Fpay extends AbstractPayment
exit;
}
- Payment::whereId($payment->id)->update(['qr_code' => 'http://qr.topscan.com/api.php?text='.$result['qr_code'].'&bg=ffffff&fg=000000&pt=1c73bd&m=10&w=400&el=1&inpt=1eabfc&logo=https://t.alipayobjects.com/tfscom/T1Z5XfXdxmXXXXXXXX.png']);//后备:https://cli.im/api/qrcode/code?text=".$result['qr_code']."&mhid=5EfGCwztyckhMHcmI9ZcOKs
+ Payment::whereId($payment->id)->update([
+ 'qr_code' => 'http://qr.topscan.com/api.php?text='.$result['qr_code'].'&bg=ffffff&fg=000000&pt=1c73bd&m=10&w=400&el=1&inpt=1eabfc&logo=https://t.alipayobjects.com/tfscom/T1Z5XfXdxmXXXXXXXX.png'
+ ]);//后备:https://cli.im/api/qrcode/code?text=".$result['qr_code']."&mhid=5EfGCwztyckhMHcmI9ZcOKs
return Response::json(['status' => 'success', 'data' => $payment->sn, 'message' => '创建订单成功!']);
}
- public function notify($request)
- {
+ public function notify($request) {
$data = [
'trade_no' => $request->input('out_trade_no'),
'transaction_id' => $request->input('trade_no'),
@@ -82,7 +80,7 @@ class F2Fpay extends AbstractPayment
try{
$client = new Client(Client::ALIPAY, self::$aliConfig);
$result = $client->tradeQuery($data);
- Log::info("【支付宝当面付】回调验证查询:".var_export($result, TRUE));
+ Log::info("【支付宝当面付】回调验证查询:".var_export($result, true));
}catch(InvalidArgumentException $e){
Log::error("【支付宝当面付】回调信息错误: ".$e->getMessage());
exit;
@@ -113,13 +111,11 @@ class F2Fpay extends AbstractPayment
exit($ret);
}
- public function getReturnHTML($request)
- {
+ public function getReturnHTML($request) {
// TODO: Implement getReturnHTML() method.
}
- public function getPurchaseHTML()
- {
+ public function getPurchaseHTML() {
// TODO: Implement getReturnHTML() method.
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/Gateway/Local.php b/app/Http/Controllers/Gateway/Local.php
index 8bae6922..7dd44ba6 100644
--- a/app/Http/Controllers/Gateway/Local.php
+++ b/app/Http/Controllers/Gateway/Local.php
@@ -11,18 +11,17 @@ use Auth;
use Illuminate\Http\Request;
use Response;
-class Local extends AbstractPayment
-{
- public function purchase(Request $request)
- {
+class Local extends AbstractPayment {
+ public function purchase(Request $request) {
$amount = $request->input('amount');
$order = Order::whereOid($request->input('oid'))->first();
$goods = Goods::query()->whereStatus(1)->whereId($request->input('goods_id'))->first();
if($goods){
- User::query()->whereId(Auth::user()->id)->decrement('balance', $amount*100);
+ User::query()->whereId(Auth::user()->id)->decrement('balance', $amount * 100);
// 记录余额操作日志
- Helpers::addUserBalanceLog(Auth::user()->id, $order->oid, Auth::user()->balance, Auth::user()->balance-$amount, -1*$amount, '购买商品:'.$goods->name);
+ Helpers::addUserBalanceLog(Auth::user()->id, $order->oid, Auth::user()->balance,
+ Auth::user()->balance - $amount, -1 * $amount, '购买商品:'.$goods->name);
}
self::postPayment($order->oid, '余额');
@@ -30,18 +29,15 @@ class Local extends AbstractPayment
return Response::json(['status' => 'success', 'message' => '购买完成!']);
}
- public function notify(Request $request)
- {
+ public function notify(Request $request) {
// TODO: Implement notify() method.
}
- public function getReturnHTML(Request $request)
- {
+ public function getReturnHTML(Request $request) {
// TODO: Implement getReturnHTML() method.
}
- public function getPurchaseHTML()
- {
+ public function getPurchaseHTML() {
// TODO: Implement getPurchaseHTML() method.
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/Gateway/PayJs.php b/app/Http/Controllers/Gateway/PayJs.php
index 2b371b44..24727deb 100644
--- a/app/Http/Controllers/Gateway/PayJs.php
+++ b/app/Http/Controllers/Gateway/PayJs.php
@@ -8,12 +8,10 @@ use Log;
use Response;
use Xhat\Payjs\Payjs as Pay;
-class PayJs extends AbstractPayment
-{
+class PayJs extends AbstractPayment {
private static $config;
- function __construct()
- {
+ function __construct() {
parent::__construct();
self::$config = [
'mchid' => self::$systemConfig['payjs_mch_id'], // 配置商户号
@@ -21,8 +19,7 @@ class PayJs extends AbstractPayment
];
}
- public function purchase($request)
- {
+ public function purchase($request) {
$payment = new Payment();
$payment->sn = self::generateGuid();
$payment->user_id = Auth::user()->id;
@@ -31,12 +28,12 @@ class PayJs extends AbstractPayment
$payment->save();
$result = (new Pay($this::$config))->native([
- 'body' => parent::$systemConfig['subject_name']? : parent::$systemConfig['website_name'],
- 'total_fee' => $payment->amount*100,
- 'out_trade_no' => $payment->sn,
- 'attach' => '',
- 'notify_url' => (parent::$systemConfig['website_callback_url']? : parent::$systemConfig['website_url']).'/callback/notify?method=payjs',
- ]);
+ 'body' => parent::$systemConfig['subject_name']?: parent::$systemConfig['website_name'],
+ 'total_fee' => $payment->amount * 100,
+ 'out_trade_no' => $payment->sn,
+ 'attach' => '',
+ 'notify_url' => (parent::$systemConfig['website_callback_url']?: parent::$systemConfig['website_url']).'/callback/notify?method=payjs',
+ ]);
if(!$result->return_code){
Log::error('PayJs '.$result->return_msg);
@@ -47,8 +44,7 @@ class PayJs extends AbstractPayment
return Response::json(['status' => 'success', 'data' => $payment->sn, 'message' => '创建订单成功!']);
}
- public function notify($request)
- {
+ public function notify($request) {
$data = (new Pay($this::$config))->notify();
if($data['return_code'] == 1){
@@ -58,13 +54,11 @@ class PayJs extends AbstractPayment
exit("fail");
}
- public function getReturnHTML($request)
- {
+ public function getReturnHTML($request) {
// TODO: Implement getReturnHTML() method.
}
- public function getPurchaseHTML()
- {
+ public function getPurchaseHTML() {
// TODO: Implement getReturnHTML() method.
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/Gateway/PayPal.php b/app/Http/Controllers/Gateway/PayPal.php
index 21bd2c82..9dcc35fa 100644
--- a/app/Http/Controllers/Gateway/PayPal.php
+++ b/app/Http/Controllers/Gateway/PayPal.php
@@ -13,13 +13,11 @@ use Log;
use Response;
use Srmklive\PayPal\Services\ExpressCheckout;
-class PayPal extends AbstractPayment
-{
+class PayPal extends AbstractPayment {
protected $provider;
protected $exChange;
- public function __construct()
- {
+ public function __construct() {
parent::__construct();
$this->provider = new ExpressCheckout();
$config = [
@@ -35,13 +33,14 @@ class PayPal extends AbstractPayment
'payment_action' => 'Sale',
'currency' => 'USD',
'billing_type' => 'MerchantInitiatedBilling',
- 'notify_url' => (self::$systemConfig['website_callback_url']? : self::$systemConfig['website_url']).'/callback/notify?method=paypal',
+ 'notify_url' => (self::$systemConfig['website_callback_url']?: self::$systemConfig['website_url']).'/callback/notify?method=paypal',
'locale' => 'zh_CN',
- 'validate_ssl' => TRUE,
+ 'validate_ssl' => true,
];
$this->provider->setApiCredentials($config);
$this->exChange = 7;
- $exChangeRate = json_decode(Curl::send('http://api.k780.com/?app=finance.rate&scur=USD&tcur=CNY&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4'), TRUE);
+ $exChangeRate = json_decode(Curl::send('http://api.k780.com/?app=finance.rate&scur=USD&tcur=CNY&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4'),
+ true);
if($exChangeRate){
if($exChangeRate['success']){
$this->exChange = $exChangeRate['result']['rate'];
@@ -49,8 +48,7 @@ class PayPal extends AbstractPayment
}
}
- public function purchase(Request $request)
- {
+ public function purchase(Request $request) {
$payment = new Payment();
$payment->sn = self::generateGuid();
$payment->user_id = Auth::user()->id;
@@ -63,7 +61,7 @@ class PayPal extends AbstractPayment
try{
$response = $this->provider->setExpressCheckout($data);
if(!$response['paypal_link']){
- Log::error(var_export($response, TRUE));
+ Log::error(var_export($response, true));
return Response::json(['status' => 'fail', 'message' => '创建订单失败,请使用其他方式或通知管理员!']);
}
@@ -76,17 +74,16 @@ class PayPal extends AbstractPayment
}
}
- protected function getCheckoutData($sn, $amount)
- {
- $amount = 0.3+ceil($amount/$this->exChange*100)/100;
+ protected function getCheckoutData($sn, $amount) {
+ $amount = 0.3 + ceil($amount / $this->exChange * 100) / 100;
return [
'invoice_id' => $sn,
'items' => [
[
- 'name' => self::$systemConfig['subject_name']? : self::$systemConfig['website_name'],
+ 'name' => self::$systemConfig['subject_name']?: self::$systemConfig['website_name'],
'price' => $amount,
- 'desc' => 'Description for'.(self::$systemConfig['subject_name']? : self::$systemConfig['website_name']),
+ 'desc' => 'Description for'.(self::$systemConfig['subject_name']?: self::$systemConfig['website_name']),
'qty' => 1
]
],
@@ -97,8 +94,7 @@ class PayPal extends AbstractPayment
];
}
- public function getCheckout(Request $request)
- {
+ public function getCheckout(Request $request) {
$token = $request->get('token');
$PayerID = $request->get('PayerID');
@@ -123,12 +119,11 @@ class PayPal extends AbstractPayment
return redirect('/invoices');
}
- public function notify(Request $request)
- {
+ public function notify(Request $request) {
$request->merge(['cmd' => '_notify-validate']);
$post = $request->all();
- $response = (string)$this->provider->verifyIPN($post);
+ $response = (string) $this->provider->verifyIPN($post);
if($response === 'VERIFIED' && $request['mp_desc']){
if(Payment::whereSn($request['mp_desc'])->first()->status == 0){
@@ -139,13 +134,11 @@ class PayPal extends AbstractPayment
exit("fail");
}
- public function getReturnHTML(Request $request)
- {
+ public function getReturnHTML(Request $request) {
// TODO: Implement getReturnHTML() method.
}
- public function getPurchaseHTML()
- {
+ public function getPurchaseHTML() {
// TODO: Implement getPurchaseHTML() method.
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php
index ebb368fc..87d2fc56 100644
--- a/app/Http/Controllers/PaymentController.php
+++ b/app/Http/Controllers/PaymentController.php
@@ -26,22 +26,19 @@ use Response;
*
* @package App\Http\Controllers
*/
-class PaymentController extends Controller
-{
+class PaymentController extends Controller {
private static $method;
- public static function notify(Request $request)
- {
+ public static function notify(Request $request) {
self::$method = $request->input('method');
- Log::info(self::$method."回调接口[POST]:".self::$method.var_export($request->all(), TRUE));
+ Log::info(self::$method."回调接口[POST]:".self::$method.var_export($request->all(), true));
self::getClient()->notify($request);
return 0;
}
- public static function getClient()
- {
+ public static function getClient() {
switch(self::$method){
case 'balance':
return new Local();
@@ -58,22 +55,19 @@ class PaymentController extends Controller
default:
Log::error("未知支付:".self::$method);
- return NULL;
+ return null;
}
}
- public static function returnHTML(Request $request)
- {
+ public static function returnHTML(Request $request) {
return self::getClient()->getReturnHTML($request);
}
- public static function purchaseHTML()
- {
+ public static function purchaseHTML() {
return Response::view('user.components.purchase');
}
- public static function getStatus(Request $request)
- {
+ public static function getStatus(Request $request) {
$payment = Payment::whereSn($request->input('sn'))->first();
if($payment){
if($payment->status == 1){
@@ -89,8 +83,7 @@ class PaymentController extends Controller
}
// 创建支付订单
- public function purchase(Request $request)
- {
+ public function purchase(Request $request) {
$goods_id = $request->input('goods_id');
$coupon_sn = $request->input('coupon_sn');
self::$method = $request->input('method');
@@ -110,7 +103,9 @@ class PaymentController extends Controller
}
// 是否有生效的套餐
- $activePlan = Order::uid()->with(['goods'])->whereHas('goods', function($q){ $q->whereType(2); })->whereStatus(2)->whereIsExpire(0)->doesntExist();
+ $activePlan = Order::uid()->with(['goods'])->whereHas('goods', function($q) {
+ $q->whereType(2);
+ })->whereStatus(2)->whereIsExpire(0)->doesntExist();
//无生效套餐,禁止购买加油包
if($goods->type == 1 && $activePlan){
@@ -135,7 +130,11 @@ class PaymentController extends Controller
if($goods->limit_num){
$count = Order::uid()->where('status', '>=', 0)->whereGoodsId($goods_id)->count();
if($count >= $goods->limit_num){
- return Response::json(['status' => 'fail', 'data' => '', 'message' => '此商品/服务限购'.$goods->limit_num.'次,您已购买'.$count.'次']);
+ return Response::json([
+ 'status' => 'fail',
+ 'data' => '',
+ 'message' => '此商品/服务限购'.$goods->limit_num.'次,您已购买'.$count.'次'
+ ]);
}
}
@@ -147,7 +146,7 @@ class PaymentController extends Controller
}
// 计算实际应支付总价
- $amount = $coupon->type == 2? $goods->price*$coupon->discount/10 : $goods->price-$coupon->amount;
+ $amount = $coupon->type == 2? $goods->price * $coupon->discount / 10 : $goods->price - $coupon->amount;
$amount = $amount > 0? round($amount, 2) : 0; // 四舍五入保留2位小数,避免无法正常创建订单
}else{
$amount = $goods->price;
@@ -174,9 +173,9 @@ class PaymentController extends Controller
$order->user_id = Auth::user()->id;
$order->goods_id = $balance? -1 : $goods_id;
$order->coupon_id = !empty($coupon)? $coupon->id : 0;
- $order->origin_amount = $balance? : $goods->price;
+ $order->origin_amount = $balance?: $goods->price;
$order->amount = $amount;
- $order->expire_at = $balance? NULL : date("Y-m-d H:i:s", strtotime("+".$goods->days." days"));
+ $order->expire_at = $balance? null : date("Y-m-d H:i:s", strtotime("+".$goods->days." days"));
$order->is_expire = 0;
$order->pay_way = self::$method;
$order->status = 0;
@@ -199,8 +198,7 @@ class PaymentController extends Controller
}
// 支付单详情
- public function detail($sn)
- {
+ public function detail($sn) {
$payment = Payment::uid()->with(['order', 'order.goods'])->whereSn($sn)->first();
$view['payment'] = $payment;
$view['name'] = $payment->order->goods? $payment->order->goods->name : '余额充值';
@@ -210,8 +208,7 @@ class PaymentController extends Controller
}
// 回调日志
- public function callbackList(Request $request)
- {
+ public function callbackList(Request $request) {
$status = $request->input('status', 0);
$query = PaymentCallback::query();
@@ -224,4 +221,4 @@ class PaymentController extends Controller
return Response::view('admin.logs.callbackList', $view);
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/ServiceController.php b/app/Http/Controllers/ServiceController.php
index 118b2520..c9bf4a8e 100644
--- a/app/Http/Controllers/ServiceController.php
+++ b/app/Http/Controllers/ServiceController.php
@@ -10,22 +10,27 @@ use App\Http\Models\Order;
use App\Http\Models\User;
use App\Http\Models\UserLabel;
-class ServiceController extends Controller
-{
- public function activePrepaidOrder($oid)
- {
+class ServiceController extends Controller {
+ public function activePrepaidOrder($oid) {
// 取出预支付订单
$prepaidOrder = Order::find($oid);
//去除使用中的套餐和 流量包
- Order::query()->whereUserId($prepaidOrder->user_id)->whereStatus(2)->whereIsExpire(0)->update(['expire_at' => date('Y-m-d H:i:s'), 'is_expire' => 1]);
+ Order::query()->whereUserId($prepaidOrder->user_id)->whereStatus(2)->whereIsExpire(0)->update([
+ 'expire_at' => date('Y-m-d H:i:s'),
+ 'is_expire' => 1
+ ]);
//取出对应套餐信息
$prepaidGood = Goods::query()->whereId($prepaidOrder->goods_id)->first();
//激活预支付套餐
- Order::query()->whereOid($prepaidOrder->oid)->update(['expire_at' => date("Y-m-d H:i:s", strtotime("+".$prepaidGood->days." days")), 'status' => 2]);
+ Order::query()->whereOid($prepaidOrder->oid)->update([
+ 'expire_at' => date("Y-m-d H:i:s",
+ strtotime("+".$prepaidGood->days." days")),
+ 'status' => 2
+ ]);
//取出用户信息
$user = User::query()->whereId($prepaidOrder->user_id)->first();
- $userTraffic = $prepaidGood->traffic*1048576;
+ $userTraffic = $prepaidGood->traffic * 1048576;
//拿出可能存在的其余套餐, 推算 最新的到期时间
$expire_time = date('Y-m-d', strtotime("+".$prepaidGood->days." days"));
$prepaidOrders = Order::query()->whereUserId($prepaidOrder->user_id)->whereStatus(3)->get();
@@ -37,13 +42,17 @@ class ServiceController extends Controller
//计算账号下一个重置时间
$nextResetTime = date('Y-m-d', strtotime("+".$prepaidGood->period." days"));
if($nextResetTime >= $expire_time){
- $nextResetTime = NULL;
+ $nextResetTime = null;
}
// 用户默认标签
- $defaultLabels = Helpers::systemConfig()['initial_labels_for_user']? explode(',', Helpers::systemConfig()['initial_labels_for_user']) : [];
+ $defaultLabels = Helpers::systemConfig()['initial_labels_for_user']? explode(',',
+ Helpers::systemConfig()['initial_labels_for_user']) : [];
//取出 商品默认标签 & 系统默认标签 去重
- $newUserLabels = array_values(array_unique(array_merge(GoodsLabel::query()->whereGoodsId($prepaidOrder->goods_id)->pluck('label_id')->toArray(), $defaultLabels)));
+ $newUserLabels = array_values(array_unique(array_merge(GoodsLabel::query()
+ ->whereGoodsId($prepaidOrder->goods_id)
+ ->pluck('label_id')
+ ->toArray(), $defaultLabels)));
// 生成标签
foreach($newUserLabels as $vo){
@@ -52,8 +61,15 @@ class ServiceController extends Controller
$obj->label_id = $vo;
$obj->save();
}
- Helpers::addUserTrafficModifyLog($prepaidOrder->user_id, $prepaidOrder->oid, $user->transfer_enable, $userTraffic, '[预支付订单激活]加上用户购买的套餐流量');
- User::query()->whereId($prepaidOrder->user_id)->increment('invite_num', $prepaidOrder->invite_num? : 0, ['u' => 0, 'd' => 0, 'transfer_enable' => $userTraffic, 'expire_time' => $expire_time, 'reset_time' => $nextResetTime]);
+ Helpers::addUserTrafficModifyLog($prepaidOrder->user_id, $prepaidOrder->oid, $user->transfer_enable,
+ $userTraffic, '[预支付订单激活]加上用户购买的套餐流量');
+ User::query()->whereId($prepaidOrder->user_id)->increment('invite_num', $prepaidOrder->invite_num?: 0, [
+ 'u' => 0,
+ 'd' => 0,
+ 'transfer_enable' => $userTraffic,
+ 'expire_time' => $expire_time,
+ 'reset_time' => $nextResetTime
+ ]);
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/User/AffiliateController.php b/app/Http/Controllers/User/AffiliateController.php
index d2d304a8..90c074c5 100644
--- a/app/Http/Controllers/User/AffiliateController.php
+++ b/app/Http/Controllers/User/AffiliateController.php
@@ -11,37 +11,44 @@ use App\Http\Models\User;
use Auth;
use Response;
-class AffiliateController extends Controller
-{
+class AffiliateController extends Controller {
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$systemConfig = Helpers::systemConfig();
}
// 推广返利
- public function referral()
- {
+ public function referral() {
if(Order::uid()->whereStatus(2)->doesntExist() && ReferralLog::uid()->doesntExist()){
- return Response::view('auth.error', ['message' => '本功能对非付费用户禁用!请 返 回']);
+ return Response::view('auth.error',
+ ['message' => '本功能对非付费用户禁用!请 返 回']);
}
- $view['referral_traffic'] = flowAutoShow(self::$systemConfig['referral_traffic']*1048576);
+ $view['referral_traffic'] = flowAutoShow(self::$systemConfig['referral_traffic'] * 1048576);
$view['referral_percent'] = self::$systemConfig['referral_percent'];
$view['referral_money'] = self::$systemConfig['referral_money'];
- $view['totalAmount'] = ReferralLog::uid()->sum('ref_amount')/100;
- $view['canAmount'] = ReferralLog::uid()->whereStatus(0)->sum('ref_amount')/100;
+ $view['totalAmount'] = ReferralLog::uid()->sum('ref_amount') / 100;
+ $view['canAmount'] = ReferralLog::uid()->whereStatus(0)->sum('ref_amount') / 100;
$view['link'] = self::$systemConfig['website_url'].'/register?aff='.Auth::user()->id;
- $view['referralLogList'] = ReferralLog::uid()->with('user')->orderBy('id', 'desc')->paginate(10, ['*'], 'log_page');
- $view['referralApplyList'] = ReferralApply::uid()->with('user')->orderBy('id', 'desc')->paginate(10, ['*'], 'apply_page');
- $view['referralUserList'] = User::query()->select(['email', 'created_at'])->whereReferralUid(Auth::user()->id)->orderBy('id', 'desc')->paginate(10, ['*'], 'user_page');
+ $view['referralLogList'] = ReferralLog::uid()
+ ->with('user')
+ ->orderBy('id', 'desc')
+ ->paginate(10, ['*'], 'log_page');
+ $view['referralApplyList'] = ReferralApply::uid()
+ ->with('user')
+ ->orderBy('id', 'desc')
+ ->paginate(10, ['*'], 'apply_page');
+ $view['referralUserList'] = User::query()
+ ->select(['email', 'created_at'])
+ ->whereReferralUid(Auth::user()->id)
+ ->orderBy('id', 'desc')
+ ->paginate(10, ['*'], 'user_page');
return Response::view('user.referral', $view);
}
// 申请提现
- public function extractMoney()
- {
+ public function extractMoney() {
// 判断账户是否过期
if(Auth::user()->expire_time < date('Y-m-d')){
return Response::json(['status' => 'fail', 'message' => '申请失败:账号已过期,请先购买服务吧']);
@@ -57,7 +64,10 @@ class AffiliateController extends Controller
$ref_amount = ReferralLog::uid()->whereStatus(0)->sum('ref_amount');
$ref_amount /= 100;
if($ref_amount < self::$systemConfig['referral_money']){
- return Response::json(['status' => 'fail', 'message' => '申请失败:满'.self::$systemConfig['referral_money'].'元才可以提现,继续努力吧']);
+ return Response::json([
+ 'status' => 'fail',
+ 'message' => '申请失败:满'.self::$systemConfig['referral_money'].'元才可以提现,继续努力吧'
+ ]);
}
// 取出本次申请关联返利日志ID
diff --git a/app/Http/Controllers/User/SubscribeController.php b/app/Http/Controllers/User/SubscribeController.php
index 8c997396..3d4764ca 100644
--- a/app/Http/Controllers/User/SubscribeController.php
+++ b/app/Http/Controllers/User/SubscribeController.php
@@ -12,18 +12,15 @@ use Illuminate\Http\Request;
use Redirect;
use Response;
-class SubscribeController extends Controller
-{
+class SubscribeController extends Controller {
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$systemConfig = Helpers::systemConfig();
}
// 通过订阅码获取订阅信息
- public function getSubscribeByCode(Request $request, $code)
- {
+ public function getSubscribeByCode(Request $request, $code) {
if(empty($code)){
return Redirect::to('login');
}
@@ -51,14 +48,23 @@ class SubscribeController extends Controller
exit($this->noneNode());
}
- $query = SsNode::query()->selectRaw('ss_node.*')->leftjoin("ss_node_label", "ss_node.id", "=", "ss_node_label.node_id");
+ $query = SsNode::query()
+ ->selectRaw('ss_node.*')
+ ->leftjoin("ss_node_label", "ss_node.id", "=", "ss_node_label.node_id");
// 启用混合订阅时,加入V2Ray节点,未启用时仅下发SSR节点信息
if(!self::$systemConfig['mix_subscribe']){
$query->where('ss_node.type', 1);
}
- $nodeList = $query->where('ss_node.status', 1)->where('ss_node.is_subscribe', 1)->whereIn('ss_node_label.label_id', $userLabelIds)->groupBy('ss_node.id')->orderBy('ss_node.sort', 'desc')->orderBy('ss_node.id', 'asc')->get()->toArray();
+ $nodeList = $query->where('ss_node.status', 1)
+ ->where('ss_node.is_subscribe', 1)
+ ->whereIn('ss_node_label.label_id', $userLabelIds)
+ ->groupBy('ss_node.id')
+ ->orderBy('ss_node.sort', 'desc')
+ ->orderBy('ss_node.id', 'asc')
+ ->get()
+ ->toArray();
if(empty($nodeList)){
exit($this->noneNode());
}
@@ -68,7 +74,7 @@ class SubscribeController extends Controller
shuffle($nodeList);
}
- $scheme = NULL;
+ $scheme = null;
// 展示到期时间和剩余流量
if(self::$systemConfig['is_custom_subscribe']){
@@ -99,20 +105,18 @@ class SubscribeController extends Controller
}
// 抛出无可用的节点信息,用于兼容防止客户端订阅失败
- private function noneNode()
- {
+ private function noneNode() {
return base64url_encode('ssr://'.base64url_encode('0.0.0.0:1:origin:none:plain:'.base64url_encode('0000').'/?obfsparam=&protoparam=&remarks='.base64url_encode('无可用节点或账号被封禁或订阅被封禁').'&group='.base64url_encode('错误').'&udpport=0&uot=0')."\n");
}
/**
* 过期时间
*
- * @param object $user
+ * @param object $user
*
* @return string
*/
- private function expireDate($user)
- {
+ private function expireDate($user) {
$text = '到期时间: '.$user->expire_time;
return 'ssr://'.base64url_encode('0.0.0.1:1:origin:none:plain:'.base64url_encode('0000').'/?obfsparam=&protoparam=&remarks='.base64url_encode($text).'&group='.base64url_encode(self::$systemConfig['website_name']).'&udpport=0&uot=0')."\n";
@@ -121,13 +125,12 @@ class SubscribeController extends Controller
/**
* 剩余流量
*
- * @param object $user
+ * @param object $user
*
* @return string
*/
- private function lastTraffic($user)
- {
- $text = '剩余流量: '.flowAutoShow($user->transfer_enable-$user->u-$user->d);
+ private function lastTraffic($user) {
+ $text = '剩余流量: '.flowAutoShow($user->transfer_enable - $user->u - $user->d);
return 'ssr://'.base64url_encode('0.0.0.2:1:origin:none:plain:'.base64url_encode('0000').'/?obfsparam=&protoparam=&remarks='.base64url_encode($text).'&group='.base64url_encode(self::$systemConfig['website_name']).'&udpport=0&uot=0')."\n";
}
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index 41bdf147..c82d1cf3 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -44,60 +44,80 @@ use Validator;
*
* @package App\Http\Controllers
*/
-class UserController extends Controller
-{
+class UserController extends Controller {
protected static $systemConfig;
- function __construct()
- {
+ function __construct() {
self::$systemConfig = Helpers::systemConfig();
}
- public function index()
- {
+ public function index() {
$totalTransfer = Auth::user()->transfer_enable;
- $usedTransfer = Auth::user()->u+Auth::user()->d;
- $unusedTransfer = $totalTransfer-$usedTransfer > 0? $totalTransfer-$usedTransfer : 0;
+ $usedTransfer = Auth::user()->u + Auth::user()->d;
+ $unusedTransfer = $totalTransfer - $usedTransfer > 0? $totalTransfer - $usedTransfer : 0;
$expireTime = Auth::user()->expire_time;
- $view['remainDays'] = $expireTime < date('Y-m-d')? -1 : (strtotime($expireTime)-strtotime(date('Y-m-d')))/86400;
- $view['resetDays'] = Auth::user()->reset_time? round((strtotime(Auth::user()->reset_time)-strtotime(date('Y-m-d')))/86400) : 0;
+ $view['remainDays'] = $expireTime < date('Y-m-d')? -1 : (strtotime($expireTime) - strtotime(date('Y-m-d'))) / 86400;
+ $view['resetDays'] = Auth::user()->reset_time? round((strtotime(Auth::user()->reset_time) - strtotime(date('Y-m-d'))) / 86400) : 0;
$view['unusedTransfer'] = $unusedTransfer;
$view['expireTime'] = $expireTime;
$view['banedTime'] = Auth::user()->ban_time? date('Y-m-d H:i:s', Auth::user()->ban_time) : 0;
- $view['unusedPercent'] = $totalTransfer > 0? round($unusedTransfer/$totalTransfer, 2) : 0;
+ $view['unusedPercent'] = $totalTransfer > 0? round($unusedTransfer / $totalTransfer, 2) : 0;
$view['noticeList'] = Article::type(2)->orderBy('id', 'desc')->Paginate(1); // 公告
//流量异常判断
- $hourlyTraffic = UserTrafficHourly::query()->whereUserId(Auth::user()->id)->whereNodeId(0)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->sum('total');
- $view['isTrafficWarning'] = $hourlyTraffic >= (self::$systemConfig['traffic_ban_value']*1073741824)? : 0;
+ $hourlyTraffic = UserTrafficHourly::query()
+ ->whereUserId(Auth::user()->id)
+ ->whereNodeId(0)
+ ->where('created_at', '>=', date('Y-m-d H:i:s', time() - 3900))
+ ->sum('total');
+ $view['isTrafficWarning'] = $hourlyTraffic >= (self::$systemConfig['traffic_ban_value'] * 1073741824)?: 0;
//付费用户判断
- $view['not_paying_user'] = Order::uid()->whereStatus(2)->whereIsExpire(0)->where('origin_amount', '>', 0)->doesntExist();
- $view['userLoginLog'] = UserLoginLog::query()->whereUserId(Auth::user()->id)->orderBy('id', 'desc')->first(); // 近期登录日志
+ $view['not_paying_user'] = Order::uid()
+ ->whereStatus(2)
+ ->whereIsExpire(0)
+ ->where('origin_amount', '>', 0)
+ ->doesntExist();
+ $view['userLoginLog'] = UserLoginLog::query()
+ ->whereUserId(Auth::user()->id)
+ ->orderBy('id', 'desc')
+ ->first(); // 近期登录日志
$dailyData = [];
$hourlyData = [];
// 节点一个月内的流量
// TODO:有bug
- $userTrafficDaily = UserTrafficDaily::query()->whereUserId(Auth::user()->id)->whereNodeId(0)->where('created_at', '<=', date('Y-m-d', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
+ $userTrafficDaily = UserTrafficDaily::query()
+ ->whereUserId(Auth::user()->id)
+ ->whereNodeId(0)
+ ->where('created_at', '<=', date('Y-m-d', time()))
+ ->orderBy('created_at', 'asc')
+ ->pluck('total')
+ ->toArray();
- $dailyTotal = date('d', time())-1; // 今天不算,减一
+ $dailyTotal = date('d', time()) - 1; // 今天不算,减一
$dailyCount = count($userTrafficDaily);
- for($x = 0; $x < $dailyTotal-$dailyCount; $x++){
+ for($x = 0; $x < $dailyTotal - $dailyCount; $x++){
$dailyData[$x] = 0;
}
- for($x = $dailyTotal-$dailyCount; $x < $dailyTotal; $x++){
- $dailyData[$x] = round($userTrafficDaily[$x-($dailyTotal-$dailyCount)]/(1024*1024*1024), 3);
+ for($x = $dailyTotal - $dailyCount; $x < $dailyTotal; $x++){
+ $dailyData[$x] = round($userTrafficDaily[$x - ($dailyTotal - $dailyCount)] / (1024 * 1024 * 1024), 3);
}
// 节点一天内的流量
- $userTrafficHourly = UserTrafficHourly::query()->whereUserId(Auth::user()->id)->whereNodeId(0)->where('created_at', '>=', date('Y-m-d', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
+ $userTrafficHourly = UserTrafficHourly::query()
+ ->whereUserId(Auth::user()->id)
+ ->whereNodeId(0)
+ ->where('created_at', '>=', date('Y-m-d', time()))
+ ->orderBy('created_at', 'asc')
+ ->pluck('total')
+ ->toArray();
$hourlyTotal = date('H');
$hourlyCount = count($userTrafficHourly);
- for($x = 0; $x < $hourlyTotal-$hourlyCount; $x++){
+ for($x = 0; $x < $hourlyTotal - $hourlyCount; $x++){
$hourlyData[$x] = 0;
}
- for($x = ($hourlyTotal-$hourlyCount); $x < $hourlyTotal; $x++){
- $hourlyData[$x] = round($userTrafficHourly[$x-($hourlyTotal-$hourlyCount)]/(1024*1024*1024), 3);
+ for($x = ($hourlyTotal - $hourlyCount); $x < $hourlyTotal; $x++){
+ $hourlyData[$x] = round($userTrafficHourly[$x - ($hourlyTotal - $hourlyCount)] / (1024 * 1024 * 1024), 3);
}
// 本月天数数据
@@ -120,8 +140,7 @@ class UserController extends Controller
}
// 签到
- public function checkIn()
- {
+ public function checkIn() {
// 系统开启登录加积分功能才可以签到
if(!self::$systemConfig['is_checkin']){
return Response::json(['status' => 'fail', 'message' => '系统未开启签到功能']);
@@ -132,25 +151,26 @@ class UserController extends Controller
return Response::json(['status' => 'fail', 'message' => '已经签到过了,明天再来吧']);
}
- $traffic = mt_rand((int)self::$systemConfig['min_rand_traffic'], (int)self::$systemConfig['max_rand_traffic'])*1048576;
+ $traffic = mt_rand((int) self::$systemConfig['min_rand_traffic'],
+ (int) self::$systemConfig['max_rand_traffic']) * 1048576;
$ret = User::uid()->increment('transfer_enable', $traffic);
if(!$ret){
return Response::json(['status' => 'fail', 'message' => '签到失败,系统异常']);
}
// 写入用户流量变动记录
- Helpers::addUserTrafficModifyLog(Auth::user()->id, 0, Auth::user()->transfer_enable, Auth::user()->transfer_enable+$traffic, '[签到]');
+ Helpers::addUserTrafficModifyLog(Auth::user()->id, 0, Auth::user()->transfer_enable,
+ Auth::user()->transfer_enable + $traffic, '[签到]');
// 多久后可以再签到
- $ttl = self::$systemConfig['traffic_limit_time']? self::$systemConfig['traffic_limit_time']*60 : 86400;
+ $ttl = self::$systemConfig['traffic_limit_time']? self::$systemConfig['traffic_limit_time'] * 60 : 86400;
Cache::put('userCheckIn_'.Auth::user()->id, '1', $ttl);
return Response::json(['status' => 'success', 'message' => '签到成功,系统送您 '.flowAutoShow($traffic).'流量']);
}
// 节点列表
- public function nodeList(Request $request)
- {
+ public function nodeList(Request $request) {
if($request->isMethod('POST')){
$node_id = $request->input('id');
$infoType = $request->input('type');
@@ -165,20 +185,36 @@ class UserController extends Controller
// 获取当前用户标签
$userLabelIds = UserLabel::uid()->pluck('label_id');
// 获取当前用户可用节点
- $nodeList = SsNode::query()->selectRaw('ss_node.*')->leftJoin('ss_node_label', 'ss_node.id', '=', 'ss_node_label.node_id')->whereIn('ss_node_label.label_id', $userLabelIds)->where('ss_node.status', 1)->groupBy('ss_node.id')->orderBy('ss_node.sort', 'desc')->orderBy('ss_node.id', 'asc')->get();
+ $nodeList = SsNode::query()
+ ->selectRaw('ss_node.*')
+ ->leftJoin('ss_node_label', 'ss_node.id', '=', 'ss_node_label.node_id')
+ ->whereIn('ss_node_label.label_id', $userLabelIds)
+ ->where('ss_node.status', 1)
+ ->groupBy('ss_node.id')
+ ->orderBy('ss_node.sort', 'desc')
+ ->orderBy('ss_node.id', 'asc')
+ ->get();
foreach($nodeList as $node){
- $node->ct = number_format(SsNodePing::query()->whereNodeId($node->id)->where('ct', '>', '0')->avg('ct'), 1, '.', '');
- $node->cu = number_format(SsNodePing::query()->whereNodeId($node->id)->where('cu', '>', '0')->avg('cu'), 1, '.', '');
- $node->cm = number_format(SsNodePing::query()->whereNodeId($node->id)->where('cm', '>', '0')->avg('cm'), 1, '.', '');
- $node->hk = number_format(SsNodePing::query()->whereNodeId($node->id)->where('hk', '>', '0')->avg('hk'), 1, '.', '');
+ $node->ct = number_format(SsNodePing::query()->whereNodeId($node->id)->where('ct', '>', '0')->avg('ct'),
+ 1, '.', '');
+ $node->cu = number_format(SsNodePing::query()->whereNodeId($node->id)->where('cu', '>', '0')->avg('cu'),
+ 1, '.', '');
+ $node->cm = number_format(SsNodePing::query()->whereNodeId($node->id)->where('cm', '>', '0')->avg('cm'),
+ 1, '.', '');
+ $node->hk = number_format(SsNodePing::query()->whereNodeId($node->id)->where('hk', '>', '0')->avg('hk'),
+ 1, '.', '');
// 节点在线状态
- $node->offline = SsNodeInfo::query()->whereNodeId($node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->doesntExist();
+ $node->offline = SsNodeInfo::query()
+ ->whereNodeId($node->id)
+ ->where('log_time', '>=', strtotime("-10 minutes"))
+ ->orderBy('id', 'desc')
+ ->doesntExist();
// 节点标签
$node->labels = SsNodeLabel::query()->whereNodeId($node->id)->first();
}
- $view['nodeList'] = $nodeList? : [];
+ $view['nodeList'] = $nodeList?: [];
}
@@ -186,16 +222,14 @@ class UserController extends Controller
}
// 公告详情
- public function article(Request $request)
- {
+ public function article(Request $request) {
$view['info'] = Article::query()->findOrFail($request->input('id'));
return Response::view('user.article', $view);
}
// 修改个人资料
- public function profile(Request $request)
- {
+ public function profile(Request $request) {
if($request->isMethod('POST')){
$old_password = trim($request->input('old_password'));
$new_password = trim($request->input('new_password'));
@@ -250,26 +284,45 @@ class UserController extends Controller
}
// 商品列表
- public function services(Request $request)
- {
+ public function services(Request $request) {
// 余额充值商品,只取10个
- $view['chargeGoodsList'] = Goods::type(3)->whereStatus(1)->orderBy('price', 'asc')->orderBy('price', 'asc')->limit(10)->get();
- $view['goodsList'] = Goods::query()->whereStatus(1)->where('type', '<=', '2')->orderBy('type', 'desc')->orderBy('sort', 'desc')->paginate(10)->appends($request->except('page'));
- $renewOrder = Order::query()->with(['goods'])->whereUserId(Auth::user()->id)->whereStatus(2)->whereIsExpire(0)->whereHas('goods', function($q){ $q->whereType(2); })->first();
+ $view['chargeGoodsList'] = Goods::type(3)
+ ->whereStatus(1)
+ ->orderBy('price', 'asc')
+ ->orderBy('price', 'asc')
+ ->limit(10)
+ ->get();
+ $view['goodsList'] = Goods::query()
+ ->whereStatus(1)
+ ->where('type', '<=', '2')
+ ->orderBy('type', 'desc')
+ ->orderBy('sort', 'desc')
+ ->paginate(10)
+ ->appends($request->except('page'));
+ $renewOrder = Order::query()
+ ->with(['goods'])
+ ->whereUserId(Auth::user()->id)
+ ->whereStatus(2)
+ ->whereIsExpire(0)
+ ->whereHas('goods', function($q) {
+ $q->whereType(2);
+ })
+ ->first();
$renewPrice = $renewOrder? Goods::query()->whereId($renewOrder->goods_id)->first() : 0;
$view['renewTraffic'] = $renewPrice? $renewPrice->renew : 0;
// 有重置日时按照重置日为标准,否者就以过期日为标准
$dataPlusDays = Auth::user()->reset_time? Auth::user()->reset_time : Auth::user()->expire_time;
- $view['dataPlusDays'] = $dataPlusDays > date('Y-m-d')? round((strtotime($dataPlusDays)-strtotime(date('Y-m-d')))/86400) : 0;
+ $view['dataPlusDays'] = $dataPlusDays > date('Y-m-d')? round((strtotime($dataPlusDays) - strtotime(date('Y-m-d'))) / 86400) : 0;
$view['purchaseHTML'] = PaymentController::purchaseHTML();
return Response::view('user.services', $view);
}
//重置流量
- public function resetUserTraffic()
- {
- $temp = Order::uid()->whereStatus(2)->whereIsExpire(0)->with(['goods'])->whereHas('goods', function($q){ $q->whereType(2); })->first();
+ public function resetUserTraffic() {
+ $temp = Order::uid()->whereStatus(2)->whereIsExpire(0)->with(['goods'])->whereHas('goods', function($q) {
+ $q->whereType(2);
+ })->first();
$renewCost = Goods::query()->whereId($temp->goods_id)->first()->renew;
if(Auth::user()->balance < $renewCost){
return Response::json(['status' => 'fail', 'data' => '', 'message' => '余额不足,请充值余额']);
@@ -277,33 +330,35 @@ class UserController extends Controller
User::uid()->update(['u' => 0, 'd' => 0]);
// 扣余额
- User::query()->whereId(Auth::user()->id)->decrement('balance', $renewCost*100);
+ User::query()->whereId(Auth::user()->id)->decrement('balance', $renewCost * 100);
// 记录余额操作日志
- Helpers::addUserBalanceLog(Auth::user()->id, '', Auth::user()->balance, Auth::user()->balance-$renewCost, -1*$renewCost, '用户自行重置流量');
+ Helpers::addUserBalanceLog(Auth::user()->id, '', Auth::user()->balance, Auth::user()->balance - $renewCost,
+ -1 * $renewCost, '用户自行重置流量');
return Response::json(['status' => 'success', 'data' => '', 'message' => '重置成功']);
}
}
// 工单
- public function ticketList(Request $request)
- {
+ public function ticketList(Request $request) {
$view['ticketList'] = Ticket::uid()->orderBy('id', 'desc')->paginate(10)->appends($request->except('page'));
return Response::view('user.ticketList', $view);
}
// 订单
- public function invoices(Request $request)
- {
- $view['orderList'] = Order::uid()->with(['user', 'goods', 'coupon', 'payment'])->orderBy('oid', 'desc')->paginate(10)->appends($request->except('page'));
+ public function invoices(Request $request) {
+ $view['orderList'] = Order::uid()
+ ->with(['user', 'goods', 'coupon', 'payment'])
+ ->orderBy('oid', 'desc')
+ ->paginate(10)
+ ->appends($request->except('page'));
return Response::view('user.invoices', $view);
}
- public function activeOrder(Request $request)
- {
+ public function activeOrder(Request $request) {
$oid = $request->input('oid');
$prepaidOrder = Order::query()->whereOid($oid)->first();
if(!$prepaidOrder){
@@ -318,16 +373,14 @@ class UserController extends Controller
}
// 订单明细
- public function invoiceDetail($sn)
- {
+ public function invoiceDetail($sn) {
$view['order'] = Order::uid()->with(['goods', 'coupon', 'payment'])->whereOrderSn($sn)->firstOrFail();
return Response::view('user.invoiceDetail', $view);
}
// 添加工单
- public function addTicket(Request $request)
- {
+ public function addTicket(Request $request) {
$title = $request->input('title');
$content = clean($request->input('content'));
$content = str_replace("eval", "", str_replace("atob", "", $content));
@@ -362,8 +415,7 @@ class UserController extends Controller
}
// 回复工单
- public function replyTicket(Request $request)
- {
+ public function replyTicket(Request $request) {
$id = $request->input('id');
$ticket = Ticket::uid()->with('user')->whereId($id)->firstOrFail();
@@ -416,8 +468,7 @@ class UserController extends Controller
}
// 关闭工单
- public function closeTicket(Request $request)
- {
+ public function closeTicket(Request $request) {
$id = $request->input('id');
$ret = Ticket::uid()->whereId($id)->update(['status' => 2]);
@@ -431,23 +482,22 @@ class UserController extends Controller
}
// 邀请码
- public function invite()
- {
+ public function invite() {
if(Order::uid()->whereStatus(2)->whereIsExpire(0)->where('origin_amount', '>', 0)->doesntExist()){
- return Response::view('auth.error', ['message' => '本功能对非付费用户禁用!请 返 回']);
+ return Response::view('auth.error',
+ ['message' => '本功能对非付费用户禁用!请 返 回']);
}
$view['num'] = Auth::user()->invite_num; // 还可以生成的邀请码数量
$view['inviteList'] = Invite::uid()->with(['generator', 'user'])->paginate(10); // 邀请码列表
- $view['referral_traffic'] = flowAutoShow(self::$systemConfig['referral_traffic']*1048576);
+ $view['referral_traffic'] = flowAutoShow(self::$systemConfig['referral_traffic'] * 1048576);
$view['referral_percent'] = self::$systemConfig['referral_percent'];
return Response::view('user.invite', $view);
}
// 生成邀请码
- public function makeInvite()
- {
+ public function makeInvite() {
if(Auth::user()->invite_num <= 0){
return Response::json(['status' => 'fail', 'data' => '', 'message' => '生成失败:已无邀请码生成名额']);
}
@@ -466,8 +516,7 @@ class UserController extends Controller
}
// 使用优惠券
- public function redeemCoupon(Request $request)
- {
+ public function redeemCoupon(Request $request) {
$coupon_sn = $request->input('coupon_sn');
$good_price = $request->input('price');
@@ -493,22 +542,33 @@ class UserController extends Controller
return Response::json(['status' => 'fail', 'title' => '使用条件未满足', 'message' => '请购买价格更高的套餐']);
}
- $data = ['name' => $coupon->name, 'type' => $coupon->type, 'amount' => $coupon->amount, 'discount' => $coupon->discount];
+ $data = [
+ 'name' => $coupon->name,
+ 'type' => $coupon->type,
+ 'amount' => $coupon->amount,
+ 'discount' => $coupon->discount
+ ];
return Response::json(['status' => 'success', 'data' => $data, 'message' => '优惠券有效']);
}
// 购买服务
- public function buy($goods_id)
- {
+ public function buy($goods_id) {
$goods = Goods::query()->whereId($goods_id)->whereStatus(1)->first();
if(empty($goods)){
return Redirect::to('services');
}
// 有重置日时按照重置日为标准,否者就以过期日为标准
$dataPlusDays = Auth::user()->reset_time? Auth::user()->reset_time : Auth::user()->expire_time;
- $view['dataPlusDays'] = $dataPlusDays > date('Y-m-d')? round((strtotime($dataPlusDays)-strtotime(date('Y-m-d')))/86400) : 0;
- $view['activePlan'] = Order::uid()->with(['goods'])->whereIsExpire(0)->whereStatus(2)->whereHas('goods', function($q){ $q->whereType(2); })->exists();
+ $view['dataPlusDays'] = $dataPlusDays > date('Y-m-d')? round((strtotime($dataPlusDays) - strtotime(date('Y-m-d'))) / 86400) : 0;
+ $view['activePlan'] = Order::uid()
+ ->with(['goods'])
+ ->whereIsExpire(0)
+ ->whereStatus(2)
+ ->whereHas('goods', function($q) {
+ $q->whereType(2);
+ })
+ ->exists();
$view['purchaseHTML'] = PaymentController::purchaseHTML();
$view['goods'] = $goods;
@@ -516,12 +576,15 @@ class UserController extends Controller
}
// 帮助中心
- public function help()
- {
+ public function help() {
$view['articleList'] = Article::type(1)->orderBy('sort', 'desc')->orderBy('id', 'desc')->limit(10)->paginate(5);
//付费用户判断
- $view['not_paying_user'] = Order::uid()->whereStatus(2)->whereIsExpire(0)->where('origin_amount', '>', 0)->doesntExist();
+ $view['not_paying_user'] = Order::uid()
+ ->whereStatus(2)
+ ->whereIsExpire(0)
+ ->where('origin_amount', '>', 0)
+ ->doesntExist();
//客户端安装
$view['Shadowrocket_install'] = 'itms-services://?action=download-manifest&url='.self::$systemConfig['website_url'].'/clients/Shadowrocket.plist';
$view['Quantumult_install'] = 'itms-services://?action=download-manifest&url='.self::$systemConfig['website_url'].'/clients/Quantumult.plist';
@@ -540,8 +603,7 @@ class UserController extends Controller
}
// 更换订阅地址
- public function exchangeSubscribe()
- {
+ public function exchangeSubscribe() {
DB::beginTransaction();
try{
// 更换订阅码
@@ -563,8 +625,7 @@ class UserController extends Controller
}
// 转换成管理员的身份
- public function switchToAdmin()
- {
+ public function switchToAdmin() {
if(!Session::has('admin')){
return Response::json(['status' => 'fail', 'data' => '', 'message' => '非法请求']);
}
@@ -577,14 +638,22 @@ class UserController extends Controller
}
// 卡券余额充值
- public function charge(Request $request)
- {
- $validator = Validator::make($request->all(), ['coupon_sn' => ['required', Rule::exists('coupon', 'sn')->where(function($query){
- $query->whereType(3)->whereStatus(0);
- }),]], ['coupon_sn.required' => '券码不能为空', 'coupon_sn.exists' => '该券不可用']);
+ public function charge(Request $request) {
+ $validator = Validator::make($request->all(), [
+ 'coupon_sn' => [
+ 'required',
+ Rule::exists('coupon', 'sn')->where(function($query) {
+ $query->whereType(3)->whereStatus(0);
+ }),
+ ]
+ ], ['coupon_sn.required' => '券码不能为空', 'coupon_sn.exists' => '该券不可用']);
if($validator->fails()){
- return Response::json(['status' => 'fail', 'data' => '', 'message' => $validator->getMessageBag()->first()]);
+ return Response::json([
+ 'status' => 'fail',
+ 'data' => '',
+ 'message' => $validator->getMessageBag()->first()
+ ]);
}
$coupon = Coupon::query()->whereSn($request->input('coupon_sn'))->first();
@@ -592,10 +661,12 @@ class UserController extends Controller
try{
DB::beginTransaction();
// 写入日志
- Helpers::addUserBalanceLog(Auth::user()->id, 0, Auth::user()->balance, Auth::user()->balance+$coupon->amount, $coupon->amount, '用户手动充值 - [充值券:'.$request->input('coupon_sn').']');
+ Helpers::addUserBalanceLog(Auth::user()->id, 0, Auth::user()->balance,
+ Auth::user()->balance + $coupon->amount, $coupon->amount,
+ '用户手动充值 - [充值券:'.$request->input('coupon_sn').']');
// 余额充值
- User::uid()->increment('balance', $coupon->amount*100);
+ User::uid()->increment('balance', $coupon->amount * 100);
// 更改卡券状态
$coupon->status = 1;
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index e33503c3..ff87d277 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -30,8 +30,7 @@ use Illuminate\Routing\Middleware\ValidateSignature;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;
-class Kernel extends HttpKernel
-{
+class Kernel extends HttpKernel {
/**
* The application's global HTTP middleware stack.
*
diff --git a/app/Http/Middleware/Affiliate.php b/app/Http/Middleware/Affiliate.php
index 07351062..d5262d72 100644
--- a/app/Http/Middleware/Affiliate.php
+++ b/app/Http/Middleware/Affiliate.php
@@ -6,18 +6,16 @@ use Closure;
use Cookie;
use Illuminate\Http\Request;
-class Affiliate
-{
+class Affiliate {
/**
* 返利识别
*
- * @param Request $request
- * @param Closure $next
+ * @param Request $request
+ * @param Closure $next
*
* @return mixed
*/
- public function handle($request, Closure $next)
- {
+ public function handle($request, Closure $next) {
$aff = trim($request->input('aff', 0));
if($aff){
Cookie::queue('register_aff', $aff, 129600);
diff --git a/app/Http/Middleware/CheckForMaintenanceMode.php b/app/Http/Middleware/CheckForMaintenanceMode.php
index 760104ee..c2923a27 100644
--- a/app/Http/Middleware/CheckForMaintenanceMode.php
+++ b/app/Http/Middleware/CheckForMaintenanceMode.php
@@ -4,14 +4,12 @@ namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
-class CheckForMaintenanceMode extends Middleware
-{
+class CheckForMaintenanceMode extends Middleware {
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
- protected $except = [
- //
+ protected $except = [//
];
}
diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php
index 98b44a53..ecf698f5 100644
--- a/app/Http/Middleware/EncryptCookies.php
+++ b/app/Http/Middleware/EncryptCookies.php
@@ -4,14 +4,12 @@ namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
-class EncryptCookies extends Middleware
-{
+class EncryptCookies extends Middleware {
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
- protected $except = [
- //
+ protected $except = [//
];
}
diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php
index a7ca44ed..cb5591b9 100644
--- a/app/Http/Middleware/RedirectIfAuthenticated.php
+++ b/app/Http/Middleware/RedirectIfAuthenticated.php
@@ -5,19 +5,17 @@ namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
-class RedirectIfAuthenticated
-{
+class RedirectIfAuthenticated {
/**
* Handle an incoming request.
*
- * @param Request $request
- * @param Closure $next
- * @param string|null $guard
+ * @param Request $request
+ * @param Closure $next
+ * @param string|null $guard
*
* @return mixed
*/
- public function handle($request, Closure $next, $guard = NULL)
- {
+ public function handle($request, Closure $next, $guard = null) {
if(auth()->guard($guard)->check()){
return redirect('/');
}
diff --git a/app/Http/Middleware/SetLocale.php b/app/Http/Middleware/SetLocale.php
index 873ecf06..97180661 100644
--- a/app/Http/Middleware/SetLocale.php
+++ b/app/Http/Middleware/SetLocale.php
@@ -6,18 +6,16 @@ use Closure;
use Illuminate\Http\Request;
use Session;
-class SetLocale
-{
+class SetLocale {
/**
* 变更语言
*
- * @param Request $request
- * @param Closure $next
+ * @param Request $request
+ * @param Closure $next
*
* @return mixed
*/
- public function handle($request, Closure $next)
- {
+ public function handle($request, Closure $next) {
if(Session::has('locale')){
app()->setLocale(Session::get('locale'));
}
@@ -30,4 +28,4 @@ class SetLocale
return $next($request);
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php
index e2393eb1..b57b8d85 100644
--- a/app/Http/Middleware/TrimStrings.php
+++ b/app/Http/Middleware/TrimStrings.php
@@ -4,8 +4,7 @@ namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
-class TrimStrings extends Middleware
-{
+class TrimStrings extends Middleware {
/**
* The names of the attributes that should not be trimmed.
*
diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php
index 15eaa6b2..879a20e2 100644
--- a/app/Http/Middleware/TrustProxies.php
+++ b/app/Http/Middleware/TrustProxies.php
@@ -5,8 +5,7 @@ namespace App\Http\Middleware;
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
-class TrustProxies extends Middleware
-{
+class TrustProxies extends Middleware {
/**
* The trusted proxies for this application.
*
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
index 38e7a7fa..7d54d17e 100644
--- a/app/Http/Middleware/VerifyCsrfToken.php
+++ b/app/Http/Middleware/VerifyCsrfToken.php
@@ -4,8 +4,7 @@ namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
-class VerifyCsrfToken extends Middleware
-{
+class VerifyCsrfToken extends Middleware {
/**
* The URIs that should be excluded from CSRF verification.
*
diff --git a/app/Http/Middleware/WebApi.php b/app/Http/Middleware/WebApi.php
new file mode 100644
index 00000000..3966a499
--- /dev/null
+++ b/app/Http/Middleware/WebApi.php
@@ -0,0 +1,47 @@
+input('key');
+ // 未提供 key
+ if($key === null){
+ return Response::json([
+ 'ret' => 0,
+ 'data' => 'Your key is null'
+ ]);
+ }
+
+ if(!in_array($key, env('WEB_API_KEY'))){
+ // key 不存在
+ return Response::json([
+ 'ret' => 0,
+ 'data' => 'Token is invalid'
+ ]);
+ }
+
+ if(env('WEB_API') == false){
+ // 主站不提供 Webapi
+ return Response::json([
+ 'ret' => 0,
+ 'data' => 'We regret this service is temporarily unavailable'
+ ]);
+ }
+
+ return $next($request);
+ }
+}
diff --git a/app/Http/Middleware/isAdmin.php b/app/Http/Middleware/isAdmin.php
index d3b1601a..e0b5c73e 100644
--- a/app/Http/Middleware/isAdmin.php
+++ b/app/Http/Middleware/isAdmin.php
@@ -7,18 +7,16 @@ use Closure;
use Illuminate\Http\Request;
use Redirect;
-class isAdmin
-{
+class isAdmin {
/**
* 校验是否为管理员身份
*
- * @param Request $request
- * @param Closure $next
+ * @param Request $request
+ * @param Closure $next
*
* @return mixed
*/
- public function handle($request, Closure $next)
- {
+ public function handle($request, Closure $next) {
if(!Auth::user()->is_admin){
return Redirect::to('/');
}
diff --git a/app/Http/Middleware/isAdminlogin.php b/app/Http/Middleware/isAdminlogin.php
index 716af5e5..75d3bfad 100644
--- a/app/Http/Middleware/isAdminlogin.php
+++ b/app/Http/Middleware/isAdminlogin.php
@@ -6,18 +6,16 @@ use Closure;
use Illuminate\Http\Request;
use Redirect;
-class isAdminlogin
-{
+class isAdminlogin {
/**
* Handle an incoming request.
*
- * @param Request $request
- * @param Closure $next
+ * @param Request $request
+ * @param Closure $next
*
* @return mixed
*/
- public function handle($request, Closure $next)
- {
+ public function handle($request, Closure $next) {
if(auth()->guest()){
return Redirect::to('admin/login');
}
diff --git a/app/Http/Middleware/isForbidden.php b/app/Http/Middleware/isForbidden.php
index 4b6fe7b1..705b027c 100644
--- a/app/Http/Middleware/isForbidden.php
+++ b/app/Http/Middleware/isForbidden.php
@@ -10,18 +10,16 @@ use Closure;
use Illuminate\Http\Request;
use Log;
-class isForbidden
-{
+class isForbidden {
/**
* 限制机器人、指定IP访问
*
- * @param Request $request
- * @param Closure $next
+ * @param Request $request
+ * @param Closure $next
*
* @return mixed
*/
- public function handle($request, Closure $next)
- {
+ public function handle($request, Closure $next) {
// 拒绝机器人访问
if(Helpers::systemConfig()['is_forbid_robot']){
if(Agent::isRobot()){
@@ -32,7 +30,8 @@ class isForbidden
}
// 拒绝通过订阅链接域名访问网站,防止网站被探测
- if(TRUE === strpos(Helpers::systemConfig()['subscribe_domain'], $request->getHost()) && FALSE === strpos(Helpers::systemConfig()['subscribe_domain'], Helpers::systemConfig()['website_url'])){
+ if(true === strpos(Helpers::systemConfig()['subscribe_domain'], $request->getHost())
+ && false === strpos(Helpers::systemConfig()['subscribe_domain'], Helpers::systemConfig()['website_url'])){
Log::info("识别到通过订阅链接访问,强制跳转至百度(".getClientIp().")");
return redirect('https://www.baidu.com');
@@ -41,10 +40,10 @@ class isForbidden
$ip = getClientIP();
if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
Log::info('识别到IPv6,尝试解析:'.$ip);
- $isIPv6 = TRUE;
+ $isIPv6 = true;
$ipInfo = getIPv6($ip);
}else{
- $isIPv6 = FALSE;
+ $isIPv6 = false;
$ipInfo = QQWry::ip($ip); // 通过纯真IP库解析IPv4信息
if(isset($ipInfo['error'])){
Log::info('无法识别IPv4,尝试使用IPIP的IP库解析:'.$ip);
@@ -73,7 +72,9 @@ class isForbidden
if(!in_array($ipInfo['country'], ['本机地址', '局域网'])){
// 拒绝大陆IP访问
if(Helpers::systemConfig()['is_forbid_china']){
- if(($ipInfo['country'] == '中国' && !in_array($ipInfo['province'], ['香港', '澳门', '台湾'])) || ($isIPv6 && $ipInfo['country'] == 'China')){
+ if(($ipInfo['country'] == '中国' && !in_array($ipInfo['province'], ['香港', '澳门', '台湾']))
+ || ($isIPv6
+ && $ipInfo['country'] == 'China')){
Log::info('识别到大陆IP,拒绝访问:'.$ip);
return response()->view('auth.error', ['message' => trans('error.ForbiddenChina')], 403);
@@ -82,7 +83,9 @@ class isForbidden
// 拒绝非大陆IP访问
if(Helpers::systemConfig()['is_forbid_oversea']){
- if($ipInfo['country'] != '中国' || in_array($ipInfo['province'], ['香港', '澳门', '台湾']) || ($isIPv6 && $ipInfo['country'] != 'China')){
+ if($ipInfo['country'] != '中国' || in_array($ipInfo['province'], ['香港', '澳门', '台湾'])
+ || ($isIPv6
+ && $ipInfo['country'] != 'China')){
Log::info('识别到海外IP,拒绝访问:'.$ip.' - '.$ipInfo['country']);
return response()->view('auth.error', ['message' => trans('error.ForbiddenOversea')], 403);
diff --git a/app/Http/Middleware/isLogin.php b/app/Http/Middleware/isLogin.php
index b13e93fa..df594bac 100644
--- a/app/Http/Middleware/isLogin.php
+++ b/app/Http/Middleware/isLogin.php
@@ -6,18 +6,16 @@ use Closure;
use Illuminate\Http\Request;
use Redirect;
-class isLogin
-{
+class isLogin {
/**
* 校验是否已登录
*
- * @param Request $request
- * @param Closure $next
+ * @param Request $request
+ * @param Closure $next
*
* @return mixed
*/
- public function handle($request, Closure $next)
- {
+ public function handle($request, Closure $next) {
if(auth()->guest()){
return Redirect::to('login');
}
diff --git a/app/Http/Middleware/isMaintenance.php b/app/Http/Middleware/isMaintenance.php
index b7d8339b..a37d98bc 100644
--- a/app/Http/Middleware/isMaintenance.php
+++ b/app/Http/Middleware/isMaintenance.php
@@ -6,22 +6,23 @@ use App\Components\Helpers;
use Closure;
use Illuminate\Http\Request;
-class isMaintenance
-{
+class isMaintenance {
/**
* 校验是否开启维护模式
*
- * @param Request $request
- * @param Closure $next
+ * @param Request $request
+ * @param Closure $next
*
* @return mixed
*/
- public function handle($request, Closure $next)
- {
+ public function handle($request, Closure $next) {
if(Helpers::systemConfig()['maintenance_mode']){
- return response()->view('auth.maintenance', ['message' => Helpers::systemConfig()['maintenance_content'], 'time' => Helpers::systemConfig()['maintenance_time']? : '0']);
+ return response()->view('auth.maintenance', [
+ 'message' => Helpers::systemConfig()['maintenance_content'],
+ 'time' => Helpers::systemConfig()['maintenance_time']?: '0'
+ ]);
}
return $next($request);
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Middleware/isSecurity.php b/app/Http/Middleware/isSecurity.php
index 8cd65dad..8edd07ed 100644
--- a/app/Http/Middleware/isSecurity.php
+++ b/app/Http/Middleware/isSecurity.php
@@ -7,18 +7,16 @@ use Cache;
use Closure;
use Log;
-class isSecurity
-{
+class isSecurity {
/**
* 是否需要安全码才访问(仅用于登录页)
*
- * @param $request
- * @param Closure $next
+ * @param $request
+ * @param Closure $next
*
* @return mixed
*/
- public function handle($request, Closure $next)
- {
+ public function handle($request, Closure $next) {
$ip = getClientIP();
$code = $request->securityCode;
$cacheKey = 'SecurityLogin_'.ip2long($ip);
@@ -28,7 +26,9 @@ class isSecurity
if($code != $websiteSecurityCode){
Log::info("拒绝非安全入口访问(".$ip.")");
- return response()->view('auth.error', ['message' => trans('error.SecurityError').', '.trans('error.Visit').''.trans('error.SecurityEnter').'']);
+ return response()->view('auth.error', [
+ 'message' => trans('error.SecurityError').', '.trans('error.Visit').''.trans('error.SecurityEnter').''
+ ]);
}else{
Cache::put($cacheKey, $ip, 7200); // 2小时之内无需再次输入安全码访问
}
diff --git a/app/Http/Models/Article.php b/app/Http/Models/Article.php
index 7dbc040d..efc79861 100644
--- a/app/Http/Models/Article.php
+++ b/app/Http/Models/Article.php
@@ -10,27 +10,22 @@ use Illuminate\Support\Carbon;
/**
* 文章
- * Class Article
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property string $title 标题
* @property string|null $author 作者
* @property string|null $summary 简介
* @property string|null $logo LOGO
* @property string|null $content 内容
- * @property int|null $type 类型:1-文章、2-公告、3-购买说明、4-使用教程
+ * @property int|null $type 类型:1-文章、2-站内公告、3-站外公告
* @property int $sort 排序
* @property Carbon|null $created_at 创建时间
* @property Carbon|null $updated_at 最后更新时间
* @property Carbon|null $deleted_at 删除时间
- * @method static bool|null forceDelete()
* @method static \Illuminate\Database\Eloquent\Builder|Article newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Article newQuery()
* @method static Builder|Article onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Article query()
- * @method static bool|null restore()
* @method static \Illuminate\Database\Eloquent\Builder|Article type($type)
* @method static \Illuminate\Database\Eloquent\Builder|Article whereAuthor($value)
* @method static \Illuminate\Database\Eloquent\Builder|Article whereContent($value)
@@ -45,9 +40,9 @@ use Illuminate\Support\Carbon;
* @method static \Illuminate\Database\Eloquent\Builder|Article whereUpdatedAt($value)
* @method static Builder|Article withTrashed()
* @method static Builder|Article withoutTrashed()
+ * @mixin Eloquent
*/
-class Article extends Model
-{
+class Article extends Model {
use SoftDeletes;
protected $table = 'article';
@@ -55,8 +50,7 @@ class Article extends Model
protected $dates = ['deleted_at'];
// 筛选类型
- function scopeType($query, $type)
- {
+ function scopeType($query, $type) {
return $query->whereType($type);
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Config.php b/app/Http/Models/Config.php
index db3b122b..fbde4122 100644
--- a/app/Http/Models/Config.php
+++ b/app/Http/Models/Config.php
@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* 系统配置
- * Class Config
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property string $name 配置名
* @property string|null $value 配置值
@@ -21,11 +18,11 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder|Config whereId($value)
* @method static Builder|Config whereName($value)
* @method static Builder|Config whereValue($value)
+ * @mixin Eloquent
*/
-class Config extends Model
-{
- public $timestamps = FALSE;
+class Config extends Model {
+ public $timestamps = false;
protected $table = 'config';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Country.php b/app/Http/Models/Country.php
index ac2a1e1b..8461efe5 100644
--- a/app/Http/Models/Country.php
+++ b/app/Http/Models/Country.php
@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* 国家/地区
- * Class Country
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property string $name 名称
* @property string $code 代码
@@ -21,10 +18,10 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder|Country whereCode($value)
* @method static Builder|Country whereId($value)
* @method static Builder|Country whereName($value)
+ * @mixin Eloquent
*/
-class Country extends Model
-{
- public $timestamps = FALSE;
+class Country extends Model {
+ public $timestamps = false;
protected $table = 'country';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Coupon.php b/app/Http/Models/Coupon.php
index 474fef75..1e344bd5 100644
--- a/app/Http/Models/Coupon.php
+++ b/app/Http/Models/Coupon.php
@@ -10,16 +10,13 @@ use Illuminate\Support\Carbon;
/**
* 优惠券
- * Class Goods
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property string $name 优惠券名称
* @property string $logo 优惠券LOGO
* @property string $sn 优惠券码
- * @property int $type 类型:1-现金券、2-折扣券、3-充值券
- * @property int $usage 用途:1-仅限一次性使用、2-可重复使用
+ * @property int $type 类型:1-抵用券、2-折扣券、3-充值券
+ * @property int $usage 用途:0-可重复使用、1-仅限一次性使用
* @property int $amount 金额,单位分
* @property float $discount 折扣
* @property int $rule 使用限制,单位分
@@ -29,12 +26,10 @@ use Illuminate\Support\Carbon;
* @property Carbon|null $created_at 创建时间
* @property Carbon|null $updated_at 最后更新时间
* @property Carbon|null $deleted_at 删除时间
- * @method static bool|null forceDelete()
* @method static \Illuminate\Database\Eloquent\Builder|Coupon newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Coupon newQuery()
* @method static Builder|Coupon onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Coupon query()
- * @method static bool|null restore()
* @method static \Illuminate\Database\Eloquent\Builder|Coupon type($type)
* @method static \Illuminate\Database\Eloquent\Builder|Coupon whereAmount($value)
* @method static \Illuminate\Database\Eloquent\Builder|Coupon whereAvailableEnd($value)
@@ -53,9 +48,9 @@ use Illuminate\Support\Carbon;
* @method static \Illuminate\Database\Eloquent\Builder|Coupon whereUsage($value)
* @method static Builder|Coupon withTrashed()
* @method static Builder|Coupon withoutTrashed()
+ * @mixin Eloquent
*/
-class Coupon extends Model
-{
+class Coupon extends Model {
use SoftDeletes;
protected $table = 'coupon';
@@ -63,38 +58,31 @@ class Coupon extends Model
protected $dates = ['deleted_at'];
// 筛选类型
- function scopeType($query, $type)
- {
+ function scopeType($query, $type) {
return $query->whereType($type);
}
- function getAmountAttribute($value)
- {
- return $value/100;
+ function getAmountAttribute($value) {
+ return $value / 100;
}
- function setAmountAttribute($value)
- {
- $this->attributes['amount'] = $value*100;
+ function setAmountAttribute($value) {
+ $this->attributes['amount'] = $value * 100;
}
- function getDiscountAttribute($value)
- {
- return $value*10;
+ function getDiscountAttribute($value) {
+ return $value * 10;
}
- function setDiscountAttribute($value)
- {
- $this->attributes['discount'] = $value/10;
+ function setDiscountAttribute($value) {
+ $this->attributes['discount'] = $value / 10;
}
- function getRuleAttribute($value)
- {
- return $value/100;
+ function getRuleAttribute($value) {
+ return $value / 100;
}
- function setRuleAttribute($value)
- {
- $this->attributes['rule'] = $value*100;
+ function setRuleAttribute($value) {
+ $this->attributes['rule'] = $value * 100;
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/CouponLog.php b/app/Http/Models/CouponLog.php
index 32a66074..2156effd 100644
--- a/app/Http/Models/CouponLog.php
+++ b/app/Http/Models/CouponLog.php
@@ -9,31 +9,28 @@ use Illuminate\Support\Carbon;
/**
* 优惠券使用日志
- * Class Goods
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
- * @property int $coupon_id 优惠券ID
- * @property int $goods_id 商品ID
- * @property int $order_id 订单ID
- * @property string $desc 备注
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
+ * @property int $coupon_id 优惠券ID
+ * @property int $goods_id 商品ID
+ * @property int $order_id 订单ID
+ * @property string $description 备注
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
* @method static Builder|CouponLog newModelQuery()
* @method static Builder|CouponLog newQuery()
* @method static Builder|CouponLog query()
* @method static Builder|CouponLog whereCouponId($value)
* @method static Builder|CouponLog whereCreatedAt($value)
- * @method static Builder|CouponLog whereDesc($value)
+ * @method static Builder|CouponLog whereDescription($value)
* @method static Builder|CouponLog whereGoodsId($value)
* @method static Builder|CouponLog whereId($value)
* @method static Builder|CouponLog whereOrderId($value)
* @method static Builder|CouponLog whereUpdatedAt($value)
+ * @mixin Eloquent
*/
-class CouponLog extends Model
-{
+class CouponLog extends Model {
protected $table = 'coupon_log';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Device.php b/app/Http/Models/Device.php
index d8c798c0..c38e3b47 100644
--- a/app/Http/Models/Device.php
+++ b/app/Http/Models/Device.php
@@ -8,36 +8,20 @@ use Illuminate\Database\Eloquent\Model;
/**
* 订阅设备列表
- * Class Device
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $type 类型:0-兼容、1-Shadowsocks(R)、2-V2Ray
- * @property int $platform 所属平台:0-其他、1-iOS、2-Android、3-Mac、4-Windows、5-Linux
- * @property string $name 设备名称
- * @property int $status 状态:0-禁止订阅、1-允许订阅
- * @property string $header 请求时头部的识别特征码
* @property-read mixed $platform_label
* @property-read mixed $type_label
* @method static Builder|Device newModelQuery()
* @method static Builder|Device newQuery()
* @method static Builder|Device query()
- * @method static Builder|Device whereHeader($value)
- * @method static Builder|Device whereId($value)
- * @method static Builder|Device whereName($value)
- * @method static Builder|Device wherePlatform($value)
- * @method static Builder|Device whereStatus($value)
- * @method static Builder|Device whereType($value)
+ * @mixin Eloquent
*/
-class Device extends Model
-{
- public $timestamps = FALSE;
+class Device extends Model {
+ public $timestamps = false;
protected $table = 'device';
protected $primaryKey = 'id';
- function getTypeLabelAttribute()
- {
+ function getTypeLabelAttribute() {
switch($this->attributes['type']){
case 1:
$type_label = ' Shadowsocks(R) ';
@@ -52,8 +36,7 @@ class Device extends Model
return $type_label;
}
- function getPlatformLabelAttribute()
- {
+ function getPlatformLabelAttribute() {
switch($this->attributes['platform']){
case 1:
$platform_label = ' iOS';
@@ -77,4 +60,4 @@ class Device extends Model
return $platform_label;
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Goods.php b/app/Http/Models/Goods.php
index c6012b1f..22f6fe7e 100644
--- a/app/Http/Models/Goods.php
+++ b/app/Http/Models/Goods.php
@@ -11,20 +11,17 @@ use Illuminate\Support\Carbon;
/**
* 商品
- * Class Goods
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property string $sku 商品服务SKU
* @property string $name 商品名称
* @property string $logo 商品图片地址
* @property int $traffic 商品内含多少流量,单位MiB
- * @property int $type 商品类型:1-流量包、2-套餐、3-余额充值
+ * @property int $type 商品类型:1-流量包、2-套餐
* @property int $price 售价,单位分
* @property int $renew 流量重置价格,单位分
* @property int $period 流量自动重置周期
- * @property string|null $info 商品
+ * @property string|null $info 商品信息
* @property string|null $desc 商品描述
* @property int $days 有效期
* @property int $invite_num 赠送邀请码数
@@ -39,12 +36,10 @@ use Illuminate\Support\Carbon;
* @property-read mixed $traffic_label
* @property-read Collection|GoodsLabel[] $label
* @property-read int|null $label_count
- * @method static bool|null forceDelete()
* @method static \Illuminate\Database\Eloquent\Builder|Goods newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Goods newQuery()
* @method static Builder|Goods onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Goods query()
- * @method static bool|null restore()
* @method static \Illuminate\Database\Eloquent\Builder|Goods type($type)
* @method static \Illuminate\Database\Eloquent\Builder|Goods whereColor($value)
* @method static \Illuminate\Database\Eloquent\Builder|Goods whereCreatedAt($value)
@@ -69,47 +64,40 @@ use Illuminate\Support\Carbon;
* @method static \Illuminate\Database\Eloquent\Builder|Goods whereUpdatedAt($value)
* @method static Builder|Goods withTrashed()
* @method static Builder|Goods withoutTrashed()
+ * @mixin Eloquent
*/
-class Goods extends Model
-{
+class Goods extends Model {
use SoftDeletes;
protected $table = 'goods';
protected $primaryKey = 'id';
protected $dates = ['deleted_at'];
- function scopeType($query, $type)
- {
+ function scopeType($query, $type) {
return $query->whereType($type)->whereStatus(1)->orderBy('sort', 'desc');
}
- function label()
- {
+ function label() {
return $this->hasMany(GoodsLabel::class, 'goods_id', 'id');
}
- function getPriceAttribute($value)
- {
- return $value/100;
+ function getPriceAttribute($value) {
+ return $value / 100;
}
- function setPriceAttribute($value)
- {
- $this->attributes['price'] = $value*100;
+ function setPriceAttribute($value) {
+ $this->attributes['price'] = $value * 100;
}
- function getRenewAttribute($value)
- {
- return $value/100;
+ function getRenewAttribute($value) {
+ return $value / 100;
}
- function setRenewAttribute($value)
- {
- return $this->attributes['renew'] = $value*100;
+ function setRenewAttribute($value) {
+ return $this->attributes['renew'] = $value * 100;
}
- function getTrafficLabelAttribute()
- {
- return flowAutoShow($this->attributes['traffic']*1048576);
+ function getTrafficLabelAttribute() {
+ return flowAutoShow($this->attributes['traffic'] * 1048576);
}
}
diff --git a/app/Http/Models/GoodsLabel.php b/app/Http/Models/GoodsLabel.php
index 8a0d0feb..03be1d67 100644
--- a/app/Http/Models/GoodsLabel.php
+++ b/app/Http/Models/GoodsLabel.php
@@ -8,29 +8,19 @@ use Illuminate\Database\Eloquent\Model;
/**
* 商品标签
- * Class GoodsLabel
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $goods_id 商品ID
- * @property int $label_id 标签ID
- * @property-read Goods $goods
+ * @property-read Goods|null $goods
* @method static Builder|GoodsLabel newModelQuery()
* @method static Builder|GoodsLabel newQuery()
* @method static Builder|GoodsLabel query()
- * @method static Builder|GoodsLabel whereGoodsId($value)
- * @method static Builder|GoodsLabel whereId($value)
- * @method static Builder|GoodsLabel whereLabelId($value)
+ * @mixin Eloquent
*/
-class GoodsLabel extends Model
-{
- public $timestamps = FALSE;
+class GoodsLabel extends Model {
+ public $timestamps = false;
protected $table = 'goods_label';
protected $primaryKey = 'id';
- function goods()
- {
+ function goods() {
return $this->hasOne(Goods::class, 'id', 'goods_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Invite.php b/app/Http/Models/Invite.php
index 05750179..493e4f29 100644
--- a/app/Http/Models/Invite.php
+++ b/app/Http/Models/Invite.php
@@ -11,28 +11,23 @@ use Illuminate\Support\Carbon;
/**
* 邀请码
- * Class Invite
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property-read mixed $status_label
- * @property int $id
- * @property int $uid 邀请人ID
- * @property int $fuid 受邀人ID
- * @property string $code 邀请码
- * @property int $status 邀请码状态:0-未使用、1-已使用、2-已过期
- * @property string|null $dateline 有效期至
- * @property Carbon|null $created_at
- * @property Carbon|null $updated_at
- * @property Carbon|null $deleted_at 删除时间
- * @property-read User $generator
- * @property-read User $user
- * @method static bool|null forceDelete()
+ * @property int $id
+ * @property int $uid 邀请人ID
+ * @property int $fuid 受邀人ID
+ * @property string $code 邀请码
+ * @property int $status 邀请码状态:0-未使用、1-已使用、2-已过期
+ * @property string|null $dateline 有效期至
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ * @property Carbon|null $deleted_at 删除时间
+ * @property-read User|null $generator
+ * @property-read mixed $status_label
+ * @property-read User|null $user
* @method static \Illuminate\Database\Eloquent\Builder|Invite newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Invite newQuery()
* @method static Builder|Invite onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|Invite query()
- * @method static bool|null restore()
* @method static \Illuminate\Database\Eloquent\Builder|Invite uid()
* @method static \Illuminate\Database\Eloquent\Builder|Invite whereCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|Invite whereCreatedAt($value)
@@ -45,32 +40,28 @@ use Illuminate\Support\Carbon;
* @method static \Illuminate\Database\Eloquent\Builder|Invite whereUpdatedAt($value)
* @method static Builder|Invite withTrashed()
* @method static Builder|Invite withoutTrashed()
+ * @mixin Eloquent
*/
-class Invite extends Model
-{
+class Invite extends Model {
use SoftDeletes;
protected $table = 'invite';
protected $primaryKey = 'id';
protected $dates = ['deleted_at'];
- function scopeUid($query)
- {
+ function scopeUid($query) {
return $query->whereUid(Auth::user()->id);
}
- function generator()
- {
+ function generator() {
return $this->hasOne(User::class, 'id', 'uid');
}
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'fuid');
}
- function getStatusLabelAttribute()
- {
+ function getStatusLabelAttribute() {
switch($this->attributes['status']){
case 0:
$status_label = ''.trans('home.invite_code_table_status_un').'';
@@ -88,4 +79,4 @@ class Invite extends Model
return $status_label;
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Label.php b/app/Http/Models/Label.php
index 1bf56fa1..f0e4f484 100644
--- a/app/Http/Models/Label.php
+++ b/app/Http/Models/Label.php
@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* 标签
- * Class Label
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property string $name 名称
* @property int $sort 排序值
@@ -21,10 +18,10 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder|Label whereId($value)
* @method static Builder|Label whereName($value)
* @method static Builder|Label whereSort($value)
+ * @mixin Eloquent
*/
-class Label extends Model
-{
- public $timestamps = FALSE;
+class Label extends Model {
+ public $timestamps = false;
protected $table = 'label';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Level.php b/app/Http/Models/Level.php
index 2feb47fe..ce6b57f2 100644
--- a/app/Http/Models/Level.php
+++ b/app/Http/Models/Level.php
@@ -8,23 +8,14 @@ use Illuminate\Database\Eloquent\Model;
/**
* 等级
- * Class Level
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $level 等级
- * @property string $level_name 等级名称
* @method static Builder|Level newModelQuery()
* @method static Builder|Level newQuery()
* @method static Builder|Level query()
- * @method static Builder|Level whereId($value)
- * @method static Builder|Level whereLevel($value)
- * @method static Builder|Level whereLevelName($value)
+ * @mixin Eloquent
*/
-class Level extends Model
-{
- public $timestamps = FALSE;
+class Level extends Model {
+ public $timestamps = false;
protected $table = 'level';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Marketing.php b/app/Http/Models/Marketing.php
index 553e77aa..62bf6b73 100644
--- a/app/Http/Models/Marketing.php
+++ b/app/Http/Models/Marketing.php
@@ -9,12 +9,9 @@ use Illuminate\Support\Carbon;
/**
* 营销
- * Class Marketing
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
- * @property int $type 类型:1-邮件群发、2-订阅渠道群发
+ * @property int $type 类型:1-邮件群发
* @property string $receiver 接收者
* @property string $title 标题
* @property string $content 内容
@@ -35,15 +32,14 @@ use Illuminate\Support\Carbon;
* @method static Builder|Marketing whereTitle($value)
* @method static Builder|Marketing whereType($value)
* @method static Builder|Marketing whereUpdatedAt($value)
+ * @mixin Eloquent
*/
-class Marketing extends Model
-{
+class Marketing extends Model {
protected $table = 'marketing';
protected $primaryKey = 'id';
protected $appends = ['status_label'];
- function getStatusLabelAttribute()
- {
+ function getStatusLabelAttribute() {
$status_label = '';
switch($this->attributes['status']){
case -1:
@@ -59,4 +55,4 @@ class Marketing extends Model
return $status_label;
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/NotificationLog.php b/app/Http/Models/NotificationLog.php
index 1d8ad0de..425e5d4d 100644
--- a/app/Http/Models/NotificationLog.php
+++ b/app/Http/Models/NotificationLog.php
@@ -9,13 +9,12 @@ use Illuminate\Support\Carbon;
/**
* 推送通知日志
- * Class NotificationLog
*
* @property int $id
- * @property int $type 类型:1-邮件、2-ServerChan、3-Bark
+ * @property int $type 类型:1-邮件、2-ServerChan、3-Bark、4-Telegram
* @property string $address 收信地址
- * @property string $title 标题
- * @property string $content 内容
+ * @property string|null $title 邮件标题
+ * @property string|null $content 邮件内容
* @property int $status 状态:-1发送失败、0-等待发送、1-发送成功
* @property string|null $error 发送失败抛出的异常信息
* @property Carbon|null $created_at 创建时间
@@ -34,9 +33,8 @@ use Illuminate\Support\Carbon;
* @method static Builder|NotificationLog whereUpdatedAt($value)
* @mixin Eloquent
*/
-class NotificationLog extends Model
-{
+class NotificationLog extends Model {
protected $table = 'notification_log';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Order.php b/app/Http/Models/Order.php
index e98ecc65..36de820c 100644
--- a/app/Http/Models/Order.php
+++ b/app/Http/Models/Order.php
@@ -10,30 +10,26 @@ use Illuminate\Support\Carbon;
/**
* 订单
- * Class Order
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property-read mixed $status_label
- * @property int $oid
- * @property string $order_sn 订单编号
- * @property int $user_id 操作人
- * @property int $goods_id 商品ID
- * @property int $coupon_id 优惠券ID
- * @property string|null $email 邮箱
- * @property int $origin_amount 订单原始总价,单位分
- * @property int $amount 订单总价,单位分
- * @property string|null $expire_at 过期时间
- * @property int $is_expire 是否已过期:0-未过期、1-已过期
- * @property int $pay_way 支付方式:1-余额支付、2-有赞云支付
- * @property int $status 订单状态:-1-已关闭、0-待支付、1-已支付待确认、2-已完成
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后一次更新时间
- * @property-read Coupon $coupon
- * @property-read Goods $goods
- * @property-read Payment $payment
- * @property-read User $user
- * @property-read mixed $pay_way_label
+ * @property int $oid
+ * @property string $order_sn 订单编号
+ * @property int $user_id 操作人
+ * @property int $goods_id 商品ID
+ * @property int $coupon_id 优惠券ID
+ * @property int $origin_amount 订单原始总价,单位分
+ * @property int $amount 订单总价,单位分
+ * @property string|null $expire_at 过期时间
+ * @property int $is_expire 是否已过期:0-未过期、1-已过期
+ * @property string $pay_way 支付方式:balance、f2fpay、codepay、payjs、bitpayx等
+ * @property int $status 订单状态:-1-已关闭、0-待支付、1-已支付待确认、2-已完成
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后一次更新时间
+ * @property-read Coupon|null $coupon
+ * @property-read mixed $pay_way_label
+ * @property-read mixed $status_label
+ * @property-read Goods|null $goods
+ * @property-read Payment|null $payment
+ * @property-read User|null $user
* @method static Builder|Order newModelQuery()
* @method static Builder|Order newQuery()
* @method static Builder|Order query()
@@ -41,7 +37,6 @@ use Illuminate\Support\Carbon;
* @method static Builder|Order whereAmount($value)
* @method static Builder|Order whereCouponId($value)
* @method static Builder|Order whereCreatedAt($value)
- * @method static Builder|Order whereEmail($value)
* @method static Builder|Order whereExpireAt($value)
* @method static Builder|Order whereGoodsId($value)
* @method static Builder|Order whereIsExpire($value)
@@ -52,41 +47,35 @@ use Illuminate\Support\Carbon;
* @method static Builder|Order whereStatus($value)
* @method static Builder|Order whereUpdatedAt($value)
* @method static Builder|Order whereUserId($value)
+ * @mixin Eloquent
*/
-class Order extends Model
-{
+class Order extends Model {
protected $table = 'order';
protected $primaryKey = 'oid';
protected $appends = ['status_label'];
- function scopeUid($query)
- {
+ function scopeUid($query) {
return $query->whereUserId(Auth::user()->id);
}
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'user_id');
}
- function goods()
- {
+ function goods() {
return $this->hasOne(Goods::class, 'id', 'goods_id')->withTrashed();
}
- function coupon()
- {
+ function coupon() {
return $this->hasOne(Coupon::class, 'id', 'coupon_id')->withTrashed();
}
- function payment()
- {
+ function payment() {
return $this->hasOne(Payment::class, 'oid', 'oid');
}
// 订单状态
- function getStatusLabelAttribute()
- {
+ function getStatusLabelAttribute() {
switch($this->attributes['status']){
case -1:
$status_label = trans('home.invoice_status_closed');
@@ -108,29 +97,24 @@ class Order extends Model
}
- function getOriginAmountAttribute($value)
- {
- return $value/100;
+ function getOriginAmountAttribute($value) {
+ return $value / 100;
}
- function setOriginAmountAttribute($value)
- {
- return $this->attributes['origin_amount'] = $value*100;
+ function setOriginAmountAttribute($value) {
+ return $this->attributes['origin_amount'] = $value * 100;
}
- function getAmountAttribute($value)
- {
- return $value/100;
+ function getAmountAttribute($value) {
+ return $value / 100;
}
- function setAmountAttribute($value)
- {
- return $this->attributes['amount'] = $value*100;
+ function setAmountAttribute($value) {
+ return $this->attributes['amount'] = $value * 100;
}
// 支付方式
- function getPayWayLabelAttribute()
- {
+ function getPayWayLabelAttribute() {
switch($this->attributes['pay_way']){
case 'balance':
$pay_way_label = '余额';
@@ -156,4 +140,4 @@ class Order extends Model
return $pay_way_label;
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Payment.php b/app/Http/Models/Payment.php
index 8e305595..f1ad6cee 100644
--- a/app/Http/Models/Payment.php
+++ b/app/Http/Models/Payment.php
@@ -10,16 +10,15 @@ use Illuminate\Support\Carbon;
/**
* 支付单
- * Class Payment
*
* @property int $id
- * @property string|null $sn
- * @property int $user_id 用户ID
- * @property int|null $oid 本地订单ID
- * @property int $amount 金额,单位分
- * @property string|null $qr_code 支付二维码
- * @property string|null $url 支付链接
- * @property int $status 状态:-1-支付失败、0-等待支付、1-支付成功
+ * @property string|null $trade_no 支付单号(本地订单号)
+ * @property int $user_id 用户ID
+ * @property int|null $oid 本地订单ID
+ * @property int $amount 金额,单位分
+ * @property string|null $qr_code 支付二维码
+ * @property string|null $url 支付链接
+ * @property int $status 支付状态:-1-支付失败、0-等待支付、1-支付成功
* @property Carbon $created_at
* @property Carbon $updated_at
* @property-read mixed $status_label
@@ -34,47 +33,40 @@ use Illuminate\Support\Carbon;
* @method static Builder|Payment whereId($value)
* @method static Builder|Payment whereOid($value)
* @method static Builder|Payment whereQrCode($value)
- * @method static Builder|Payment whereSn($value)
* @method static Builder|Payment whereStatus($value)
+ * @method static Builder|Payment whereTradeNo($value)
* @method static Builder|Payment whereUpdatedAt($value)
* @method static Builder|Payment whereUrl($value)
* @method static Builder|Payment whereUserId($value)
* @mixin Eloquent
*/
-class Payment extends Model
-{
+class Payment extends Model {
protected $table = 'payment';
protected $primaryKey = 'id';
protected $appends = ['status_label'];
- function scopeUid($query)
- {
+ function scopeUid($query) {
return $query->whereUserId(Auth::user()->id);
}
- function user()
- {
+ function user() {
return $this->belongsTo(User::class, 'user_id', 'id');
}
- function order()
- {
+ function order() {
return $this->belongsTo(Order::class, 'oid', 'oid');
}
- function getAmountAttribute($value)
- {
- return $value/100;
+ function getAmountAttribute($value) {
+ return $value / 100;
}
- function setAmountAttribute($value)
- {
- return $this->attributes['amount'] = $value*100;
+ function setAmountAttribute($value) {
+ return $this->attributes['amount'] = $value * 100;
}
// 订单状态
- function getStatusLabelAttribute()
- {
+ function getStatusLabelAttribute() {
switch($this->attributes['status']){
case -1:
$status_label = '支付失败';
diff --git a/app/Http/Models/PaymentCallback.php b/app/Http/Models/PaymentCallback.php
index 5973d259..35b57d3b 100644
--- a/app/Http/Models/PaymentCallback.php
+++ b/app/Http/Models/PaymentCallback.php
@@ -8,54 +8,34 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
/**
- * 支付回调(有赞云支付)
- * Class PaymentCallback
+ * 支付回调日志
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
- * @property string|null $client_id
- * @property string|null $yz_id
- * @property string|null $kdt_id
- * @property string|null $kdt_name
- * @property int|null $mode
- * @property string|null $msg
- * @property int|null $sendCount
- * @property string|null $sign
- * @property string|null $status
- * @property int|null $test
- * @property string|null $type
- * @property string|null $version
+ * @property string|null $trade_no 本地订单号
+ * @property string|null $out_trade_no 外部订单号(支付平台)
+ * @property int|null $amount 交易金额,单位分
+ * @property int|null $status 交易状态:0-失败、1-成功
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property-read mixed $status_label
* @method static Builder|PaymentCallback newModelQuery()
* @method static Builder|PaymentCallback newQuery()
* @method static Builder|PaymentCallback query()
- * @method static Builder|PaymentCallback whereClientId($value)
+ * @method static Builder|PaymentCallback whereAmount($value)
* @method static Builder|PaymentCallback whereCreatedAt($value)
* @method static Builder|PaymentCallback whereId($value)
- * @method static Builder|PaymentCallback whereKdtId($value)
- * @method static Builder|PaymentCallback whereKdtName($value)
- * @method static Builder|PaymentCallback whereMode($value)
- * @method static Builder|PaymentCallback whereMsg($value)
- * @method static Builder|PaymentCallback whereSendCount($value)
- * @method static Builder|PaymentCallback whereSign($value)
+ * @method static Builder|PaymentCallback whereOutTradeNo($value)
* @method static Builder|PaymentCallback whereStatus($value)
- * @method static Builder|PaymentCallback whereTest($value)
- * @method static Builder|PaymentCallback whereType($value)
+ * @method static Builder|PaymentCallback whereTradeNo($value)
* @method static Builder|PaymentCallback whereUpdatedAt($value)
- * @method static Builder|PaymentCallback whereVersion($value)
- * @method static Builder|PaymentCallback whereYzId($value)
+ * @mixin Eloquent
*/
-class PaymentCallback extends Model
-{
+class PaymentCallback extends Model {
protected $table = 'payment_callback';
protected $primaryKey = 'id';
protected $appends = ['status_label'];
- function getStatusLabelAttribute()
- {
+ function getStatusLabelAttribute() {
$status_label = '';
switch($this->attributes['status']){
case 'WAIT_BUYER_PAY':
@@ -74,4 +54,4 @@ class PaymentCallback extends Model
return $status_label;
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/ReferralApply.php b/app/Http/Models/ReferralApply.php
index 64e9d203..654e7559 100644
--- a/app/Http/Models/ReferralApply.php
+++ b/app/Http/Models/ReferralApply.php
@@ -10,20 +10,17 @@ use Illuminate\Support\Carbon;
/**
* 返利申请
- * Class ReferralApply
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $user_id 用户ID
- * @property int $before 操作前可提现金额,单位分
- * @property int $after 操作后可提现金额,单位分
- * @property int $amount 本次提现金额,单位分
- * @property string $link_logs 关联返利日志ID,例如:1,3,4
- * @property int $status 状态:-1-驳回、0-待审核、1-审核通过待打款、2-已打款
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read User $User
+ * @property int $id
+ * @property int $user_id 用户ID
+ * @property int $before 操作前可提现金额,单位分
+ * @property int $after 操作后可提现金额,单位分
+ * @property int $amount 本次提现金额,单位分
+ * @property string $link_logs 关联返利日志ID,例如:1,3,4
+ * @property int $status 状态:-1-驳回、0-待审核、1-审核通过待打款、2-已打款
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
+ * @property-read User|null $User
* @method static Builder|ReferralApply newModelQuery()
* @method static Builder|ReferralApply newQuery()
* @method static Builder|ReferralApply query()
@@ -37,49 +34,41 @@ use Illuminate\Support\Carbon;
* @method static Builder|ReferralApply whereStatus($value)
* @method static Builder|ReferralApply whereUpdatedAt($value)
* @method static Builder|ReferralApply whereUserId($value)
+ * @mixin Eloquent
*/
-class ReferralApply extends Model
-{
+class ReferralApply extends Model {
protected $table = 'referral_apply';
protected $primaryKey = 'id';
- function scopeUid($query)
- {
+ function scopeUid($query) {
return $query->whereUserId(Auth::user()->id);
}
- function User()
- {
+ function User() {
return $this->hasOne(User::class, 'id', 'user_id');
}
- function getBeforeAttribute($value)
- {
- return $value/100;
+ function getBeforeAttribute($value) {
+ return $value / 100;
}
- function setBeforeAttribute($value)
- {
- $this->attributes['before'] = $value*100;
+ function setBeforeAttribute($value) {
+ $this->attributes['before'] = $value * 100;
}
- function getAfterAttribute($value)
- {
- return $value/100;
+ function getAfterAttribute($value) {
+ return $value / 100;
}
- function setAfterAttribute($value)
- {
- $this->attributes['after'] = $value*100;
+ function setAfterAttribute($value) {
+ $this->attributes['after'] = $value * 100;
}
- function getAmountAttribute($value)
- {
- return $value/100;
+ function getAmountAttribute($value) {
+ return $value / 100;
}
- function setAmountAttribute($value)
- {
- $this->attributes['amount'] = $value*100;
+ function setAmountAttribute($value) {
+ $this->attributes['amount'] = $value * 100;
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/ReferralLog.php b/app/Http/Models/ReferralLog.php
index 8691cd6b..21bce283 100644
--- a/app/Http/Models/ReferralLog.php
+++ b/app/Http/Models/ReferralLog.php
@@ -10,22 +10,19 @@ use Illuminate\Support\Carbon;
/**
* 返利日志
- * Class ReferralLog
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $user_id 用户ID
- * @property int $ref_user_id 推广人ID
- * @property int $order_id 关联订单ID
- * @property int $amount 消费金额,单位分
- * @property int $ref_amount 返利金额
- * @property int $status 状态:0-未提现、1-审核中、2-已提现
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read Order $order
- * @property-read User $ref_user
- * @property-read User $user
+ * @property int $id
+ * @property int $user_id 用户ID
+ * @property int $ref_user_id 推广人ID
+ * @property int $order_id 关联订单ID
+ * @property int $amount 消费金额,单位分
+ * @property int $ref_amount 返利金额
+ * @property int $status 状态:0-未提现、1-审核中、2-已提现
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
+ * @property-read Order|null $order
+ * @property-read User|null $ref_user
+ * @property-read User|null $user
* @method static Builder|ReferralLog newModelQuery()
* @method static Builder|ReferralLog newQuery()
* @method static Builder|ReferralLog query()
@@ -39,49 +36,41 @@ use Illuminate\Support\Carbon;
* @method static Builder|ReferralLog whereStatus($value)
* @method static Builder|ReferralLog whereUpdatedAt($value)
* @method static Builder|ReferralLog whereUserId($value)
+ * @mixin Eloquent
*/
-class ReferralLog extends Model
-{
+class ReferralLog extends Model {
protected $table = 'referral_log';
protected $primaryKey = 'id';
- function scopeUid($query)
- {
+ function scopeUid($query) {
return $query->whereRefUserId(Auth::user()->id);
}
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'user_id');
}
- function ref_user()
- {
+ function ref_user() {
return $this->hasOne(User::class, 'id', 'ref_user_id');
}
- function order()
- {
+ function order() {
return $this->hasOne(Order::class, 'oid', 'order_id');
}
- function getAmountAttribute($value)
- {
- return $value/100;
+ function getAmountAttribute($value) {
+ return $value / 100;
}
- function setAmountAttribute($value)
- {
- $this->attributes['amount'] = $value*100;
+ function setAmountAttribute($value) {
+ $this->attributes['amount'] = $value * 100;
}
- function getRefAmountAttribute($value)
- {
- return $value/100;
+ function getRefAmountAttribute($value) {
+ return $value / 100;
}
- function setRefAmountAttribute($value)
- {
- $this->attributes['ref_amount'] = $value*100;
+ function setRefAmountAttribute($value) {
+ $this->attributes['ref_amount'] = $value * 100;
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/SensitiveWords.php b/app/Http/Models/SensitiveWords.php
index 76598ebe..9310ba9f 100644
--- a/app/Http/Models/SensitiveWords.php
+++ b/app/Http/Models/SensitiveWords.php
@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* 敏感词
- * Class SensitiveWords
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property int $type 类型:1-黑名单、2-白名单
* @property string $words 敏感词
@@ -21,10 +18,10 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder|SensitiveWords whereId($value)
* @method static Builder|SensitiveWords whereType($value)
* @method static Builder|SensitiveWords whereWords($value)
+ * @mixin Eloquent
*/
-class SensitiveWords extends Model
-{
- public $timestamps = FALSE;
+class SensitiveWords extends Model {
+ public $timestamps = false;
protected $table = 'sensitive_words';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/SsConfig.php b/app/Http/Models/SsConfig.php
index 4b1d06a9..528eec22 100644
--- a/app/Http/Models/SsConfig.php
+++ b/app/Http/Models/SsConfig.php
@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* 配置信息
- * Class SsConfig
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property string $name 配置名
* @property int $type 类型:1-加密方式、2-协议、3-混淆
@@ -27,23 +24,21 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder|SsConfig whereName($value)
* @method static Builder|SsConfig whereSort($value)
* @method static Builder|SsConfig whereType($value)
+ * @mixin Eloquent
*/
-class SsConfig extends Model
-{
- public $timestamps = FALSE;
+class SsConfig extends Model {
+ public $timestamps = false;
protected $table = 'ss_config';
protected $primaryKey = 'id';
// 筛选默认
- function scopeDefault($query)
- {
+ function scopeDefault($query) {
$query->whereIsDefault(1);
}
// 筛选类型
- function scopeType($query, $type)
- {
+ function scopeType($query, $type) {
$query->whereType($type);
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/SsGroup.php b/app/Http/Models/SsGroup.php
index 81c87877..e635ce70 100644
--- a/app/Http/Models/SsGroup.php
+++ b/app/Http/Models/SsGroup.php
@@ -9,13 +9,9 @@ use Illuminate\Support\Carbon;
/**
* SS节点分组
- * Class SsNodeGroup
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
- * @property string $name 分组名称
- * @property int $level 分组级别
+ * @property string $name 分组名称
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @method static Builder|SsGroup newModelQuery()
@@ -23,13 +19,12 @@ use Illuminate\Support\Carbon;
* @method static Builder|SsGroup query()
* @method static Builder|SsGroup whereCreatedAt($value)
* @method static Builder|SsGroup whereId($value)
- * @method static Builder|SsGroup whereLevel($value)
* @method static Builder|SsGroup whereName($value)
* @method static Builder|SsGroup whereUpdatedAt($value)
+ * @mixin Eloquent
*/
-class SsGroup extends Model
-{
+class SsGroup extends Model {
protected $table = 'ss_group';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/SsGroupNode.php b/app/Http/Models/SsGroupNode.php
index e433be03..3940f2fb 100644
--- a/app/Http/Models/SsGroupNode.php
+++ b/app/Http/Models/SsGroupNode.php
@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* SS分组和节点关联表
- * Class SsNodeGroup
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property int $group_id 分组ID
* @property int $node_id 节点ID
@@ -21,11 +18,11 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder|SsGroupNode whereGroupId($value)
* @method static Builder|SsGroupNode whereId($value)
* @method static Builder|SsGroupNode whereNodeId($value)
+ * @mixin Eloquent
*/
-class SsGroupNode extends Model
-{
- public $timestamps = FALSE;
+class SsGroupNode extends Model {
+ public $timestamps = false;
protected $table = 'ss_group_node';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/SsNode.php b/app/Http/Models/SsNode.php
index 8de569a2..8abc3486 100644
--- a/app/Http/Models/SsNode.php
+++ b/app/Http/Models/SsNode.php
@@ -10,49 +10,51 @@ use Illuminate\Support\Carbon;
/**
* SS节点信息
- * Class SsNode
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
- * @property int $type 服务类型:1-SS、2-V2ray
- * @property string $name 名称
- * @property int $group_id 所属分组
- * @property string $country_code 国家代码
- * @property string|null $server 服务器域名地址
- * @property string|null $ip 服务器IPV4地址
- * @property string|null $ipv6 服务器IPV6地址
- * @property string|null $desc 节点简单描述
- * @property string $method 加密方式
- * @property string $protocol 协议
- * @property string|null $protocol_param 协议参数
- * @property string $obfs 混淆
- * @property string|null $obfs_param 混淆参数
- * @property float $traffic_rate 流量比率
- * @property int $bandwidth 出口带宽,单位M
- * @property int $traffic 每月可用流量,单位G
- * @property string|null $monitor_url 监控地址
- * @property int|null $is_subscribe 是否允许用户订阅该节点:0-否、1-是
- * @property int $is_ddns 是否使用DDNS:0-否、1-是
- * @property int $is_transit 是否中转节点:0-否、1-是
- * @property int $ssh_port SSH端口
- * @property int $detectionType 节点检测: 0-关闭、1-只检测TCP、2-只检测ICMP、3-检测全部
- * @property int $compatible 兼容SS
- * @property int $single 启用单端口功能:0-否、1-是
- * @property string|null $port 单端口的端口号
- * @property string|null $passwd 单端口的连接密码
- * @property int $sort 排序值,值越大越靠前显示
- * @property int $status 状态:0-维护、1-正常
- * @property int $v2_alter_id V2ray额外ID
- * @property int $v2_port V2ray端口
- * @property string $v2_method V2ray加密方式
- * @property string $v2_net V2ray传输协议
- * @property string $v2_type V2ray伪装类型
- * @property string $v2_host V2ray伪装的域名
- * @property string $v2_path V2ray WS/H2路径
- * @property int $v2_tls V2ray底层传输安全 0 未开启 1 开启
- * @property int $v2_insider_port V2ray内部端口(内部监听),v2_port为0时有效
- * @property int $v2_outsider_port V2ray外部端口(外部覆盖),v2_port为0时有效
+ * @property int $type 服务类型:1-ShadowsocksR、2-V2ray
+ * @property string $name 名称
+ * @property int $group_id 所属分组
+ * @property string|null $country_code 国家代码
+ * @property string|null $server 服务器域名地址
+ * @property string|null $ip 服务器IPV4地址
+ * @property string|null $ipv6 服务器IPV6地址
+ * @property string|null $relay_server 中转地址
+ * @property int|null $relay_port 中转端口
+ * @property int $level 等级:0-无等级,全部可见
+ * @property int $speed_limit 节点限速,为0表示不限速,单位Byte
+ * @property int $client_limit 设备数限制
+ * @property string|null $description 节点简单描述
+ * @property string $method 加密方式
+ * @property string $protocol 协议
+ * @property string|null $protocol_param 协议参数
+ * @property string $obfs 混淆
+ * @property string|null $obfs_param 混淆参数
+ * @property float $traffic_rate 流量比率
+ * @property int $is_subscribe 是否允许用户订阅该节点:0-否、1-是
+ * @property int $is_ddns 是否使用DDNS:0-否、1-是
+ * @property int $is_relay 是否中转节点:0-否、1-是
+ * @property int $is_udp 是否启用UDP:0-不启用、1-启用
+ * @property int $ssh_port SSH端口
+ * @property int $detectiontype 节点检测: 0-关闭、1-只检测TCP、2-只检测ICMP、3-检测全部
+ * @property int $compatible 兼容SS
+ * @property int $single 启用单端口功能:0-否、1-是
+ * @property int|null $port 单端口的端口号
+ * @property string|null $passwd 单端口的连接密码
+ * @property int $sort 排序值,值越大越靠前显示
+ * @property int $status 状态:0-维护、1-正常
+ * @property int $v2_alter_id V2Ray额外ID
+ * @property int $v2_connect_port V2Ray连接端口
+ * @property int $v2_port V2Ray服务端口
+ * @property string $v2_method V2Ray加密方式
+ * @property string $v2_net V2Ray传输协议
+ * @property string $v2_type V2Ray伪装类型
+ * @property string $v2_host V2Ray伪装的域名
+ * @property string $v2_path V2Ray的WS/H2路径
+ * @property int $v2_connect_tls V2Ray连接TLS:0-未开启、1-开启
+ * @property int $v2_tls V2Ray后端TLS:0-未开启、1-开启
+ * @property string|null $tls_provider V2Ray节点的TLS提供商授权信息
+ * @property int $trojan_port Trojan连接端口
* @property Carbon $created_at
* @property Carbon $updated_at
* @property-read Collection|SsNodeLabel[] $label
@@ -60,21 +62,22 @@ use Illuminate\Support\Carbon;
* @method static Builder|SsNode newModelQuery()
* @method static Builder|SsNode newQuery()
* @method static Builder|SsNode query()
- * @method static Builder|SsNode whereBandwidth($value)
+ * @method static Builder|SsNode whereClientLimit($value)
* @method static Builder|SsNode whereCompatible($value)
* @method static Builder|SsNode whereCountryCode($value)
* @method static Builder|SsNode whereCreatedAt($value)
- * @method static Builder|SsNode whereDesc($value)
- * @method static Builder|SsNode whereDetectionType($value)
+ * @method static Builder|SsNode whereDescription($value)
+ * @method static Builder|SsNode whereDetectiontype($value)
* @method static Builder|SsNode whereGroupId($value)
* @method static Builder|SsNode whereId($value)
* @method static Builder|SsNode whereIp($value)
* @method static Builder|SsNode whereIpv6($value)
* @method static Builder|SsNode whereIsDdns($value)
+ * @method static Builder|SsNode whereIsRelay($value)
* @method static Builder|SsNode whereIsSubscribe($value)
- * @method static Builder|SsNode whereIsTransit($value)
+ * @method static Builder|SsNode whereIsUdp($value)
+ * @method static Builder|SsNode whereLevel($value)
* @method static Builder|SsNode whereMethod($value)
- * @method static Builder|SsNode whereMonitorUrl($value)
* @method static Builder|SsNode whereName($value)
* @method static Builder|SsNode whereObfs($value)
* @method static Builder|SsNode whereObfsParam($value)
@@ -82,33 +85,36 @@ use Illuminate\Support\Carbon;
* @method static Builder|SsNode wherePort($value)
* @method static Builder|SsNode whereProtocol($value)
* @method static Builder|SsNode whereProtocolParam($value)
+ * @method static Builder|SsNode whereRelayPort($value)
+ * @method static Builder|SsNode whereRelayServer($value)
* @method static Builder|SsNode whereServer($value)
* @method static Builder|SsNode whereSingle($value)
* @method static Builder|SsNode whereSort($value)
+ * @method static Builder|SsNode whereSpeedLimit($value)
* @method static Builder|SsNode whereSshPort($value)
* @method static Builder|SsNode whereStatus($value)
- * @method static Builder|SsNode whereTraffic($value)
+ * @method static Builder|SsNode whereTlsProvider($value)
* @method static Builder|SsNode whereTrafficRate($value)
+ * @method static Builder|SsNode whereTrojanPort($value)
* @method static Builder|SsNode whereType($value)
* @method static Builder|SsNode whereUpdatedAt($value)
* @method static Builder|SsNode whereV2AlterId($value)
+ * @method static Builder|SsNode whereV2ConnectPort($value)
+ * @method static Builder|SsNode whereV2ConnectTls($value)
* @method static Builder|SsNode whereV2Host($value)
- * @method static Builder|SsNode whereV2InsiderPort($value)
* @method static Builder|SsNode whereV2Method($value)
* @method static Builder|SsNode whereV2Net($value)
- * @method static Builder|SsNode whereV2OutsiderPort($value)
* @method static Builder|SsNode whereV2Path($value)
* @method static Builder|SsNode whereV2Port($value)
* @method static Builder|SsNode whereV2Tls($value)
* @method static Builder|SsNode whereV2Type($value)
+ * @mixin Eloquent
*/
-class SsNode extends Model
-{
+class SsNode extends Model {
protected $table = 'ss_node';
protected $primaryKey = 'id';
- function label()
- {
+ function label() {
return $this->hasMany(SsNodeLabel::class, 'node_id', 'id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/SsNodeInfo.php b/app/Http/Models/SsNodeInfo.php
index 8f0f8369..3660ca41 100644
--- a/app/Http/Models/SsNodeInfo.php
+++ b/app/Http/Models/SsNodeInfo.php
@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* SS节点负载情况
- * Class SsNodeInfo
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property int $node_id 节点ID
* @property int $uptime 后端存活时长,单位秒
@@ -25,11 +22,11 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder|SsNodeInfo whereLogTime($value)
* @method static Builder|SsNodeInfo whereNodeId($value)
* @method static Builder|SsNodeInfo whereUptime($value)
+ * @mixin Eloquent
*/
-class SsNodeInfo extends Model
-{
- public $timestamps = FALSE;
+class SsNodeInfo extends Model {
+ public $timestamps = false;
protected $table = 'ss_node_info';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/SsNodeIp.php b/app/Http/Models/SsNodeIp.php
index 1cc88f53..2d3e5982 100644
--- a/app/Http/Models/SsNodeIp.php
+++ b/app/Http/Models/SsNodeIp.php
@@ -9,10 +9,7 @@ use Illuminate\Support\Carbon;
/**
* SS节点在线IP信息
- * Class SsNodeIp
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property int $node_id 节点ID
* @property int $user_id 用户ID
@@ -32,19 +29,17 @@ use Illuminate\Support\Carbon;
* @method static Builder|SsNodeIp wherePort($value)
* @method static Builder|SsNodeIp whereType($value)
* @method static Builder|SsNodeIp whereUserId($value)
+ * @mixin Eloquent
*/
-class SsNodeIp extends Model
-{
+class SsNodeIp extends Model {
protected $table = 'ss_node_ip';
protected $primaryKey = 'id';
- function node()
- {
+ function node() {
return $this->belongsTo(SsNode::class, 'node_id', 'id');
}
- function user()
- {
+ function user() {
return $this->belongsTo(User::class, 'port', 'port');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/SsNodeLabel.php b/app/Http/Models/SsNodeLabel.php
index 12b642ee..925cefec 100644
--- a/app/Http/Models/SsNodeLabel.php
+++ b/app/Http/Models/SsNodeLabel.php
@@ -8,29 +8,25 @@ use Illuminate\Database\Eloquent\Model;
/**
* 节点标签
- * Class SsNodeLabel
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property-read Label $labelInfo
- * @property int $id
- * @property int $node_id 用户ID
- * @property int $label_id 标签ID
+ * @property int $id
+ * @property int $node_id 用户ID
+ * @property int $label_id 标签ID
+ * @property-read Label|null $labelInfo
* @method static Builder|SsNodeLabel newModelQuery()
* @method static Builder|SsNodeLabel newQuery()
* @method static Builder|SsNodeLabel query()
* @method static Builder|SsNodeLabel whereId($value)
* @method static Builder|SsNodeLabel whereLabelId($value)
* @method static Builder|SsNodeLabel whereNodeId($value)
+ * @mixin Eloquent
*/
-class SsNodeLabel extends Model
-{
- public $timestamps = FALSE;
+class SsNodeLabel extends Model {
+ public $timestamps = false;
protected $table = 'ss_node_label';
protected $primaryKey = 'id';
- function labelInfo()
- {
+ function labelInfo() {
return $this->hasOne(Label::class, 'id', 'label_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/SsNodeOnlineLog.php b/app/Http/Models/SsNodeOnlineLog.php
index 3b0d24e2..c76f12c4 100644
--- a/app/Http/Models/SsNodeOnlineLog.php
+++ b/app/Http/Models/SsNodeOnlineLog.php
@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* SS节点用户在线情况
- * Class SsNodeOnlineLog
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property int $node_id 节点ID
* @property int $online_user 在线用户数
@@ -23,11 +20,11 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder|SsNodeOnlineLog whereLogTime($value)
* @method static Builder|SsNodeOnlineLog whereNodeId($value)
* @method static Builder|SsNodeOnlineLog whereOnlineUser($value)
+ * @mixin Eloquent
*/
-class SsNodeOnlineLog extends Model
-{
- public $timestamps = FALSE;
+class SsNodeOnlineLog extends Model {
+ public $timestamps = false;
protected $table = 'ss_node_online_log';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/SsNodePing.php b/app/Http/Models/SsNodePing.php
index a9caba6e..8b248f2d 100644
--- a/app/Http/Models/SsNodePing.php
+++ b/app/Http/Models/SsNodePing.php
@@ -9,38 +9,34 @@ use Illuminate\Support\Carbon;
/**
* 节点定时Ping测速
- * App\Http\Models\SsNodePing
*
- * @mixin Eloquent
- * @property int $id
- * @property int $node_id 对应节点id
- * @property int $ct 电信
- * @property int $cu 联通
- * @property int $cm 移动
- * @property int $hk 香港
- * @property Carbon $created_at
- * @property Carbon $updated_at
+ * @property int $id
+ * @property int $node_id 对应节点id
+ * @property int $ct 电信
+ * @property int $cu 联通
+ * @property int $cm 移动
+ * @property int $hk 香港
+ * @property Carbon $created_at
+ * @property Carbon $updated_at
+ * @property-read SsNode|null $node
* @method static Builder|SsNodePing newModelQuery()
* @method static Builder|SsNodePing newQuery()
* @method static Builder|SsNodePing query()
* @method static Builder|SsNodePing whereCm($value)
* @method static Builder|SsNodePing whereCreatedAt($value)
+ * @method static Builder|SsNodePing whereCt($value)
* @method static Builder|SsNodePing whereCu($value)
* @method static Builder|SsNodePing whereHk($value)
* @method static Builder|SsNodePing whereId($value)
* @method static Builder|SsNodePing whereNodeId($value)
* @method static Builder|SsNodePing whereUpdatedAt($value)
- * @method static Builder|SsNodePing whereUt($value)
- * @method static Builder|SsNodePing whereCt($value)
- * @property-read SsNode $node
+ * @mixin Eloquent
*/
-class SsNodePing extends Model
-{
+class SsNodePing extends Model {
protected $table = 'ss_node_ping';
protected $primaryKey = 'id';
- public function node()
- {
+ public function node() {
return $this->hasOne(SsNode::class, 'id', 'node_id');
}
}
diff --git a/app/Http/Models/SsNodeTrafficDaily.php b/app/Http/Models/SsNodeTrafficDaily.php
index d7f3a037..6a21b032 100644
--- a/app/Http/Models/SsNodeTrafficDaily.php
+++ b/app/Http/Models/SsNodeTrafficDaily.php
@@ -9,19 +9,16 @@ use Illuminate\Support\Carbon;
/**
* 节点每日流量统计
- * Class SsUserTrafficDaily
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $node_id 节点ID
- * @property int $u 上传流量
- * @property int $d 下载流量
- * @property int $total 总流量
- * @property string|null $traffic 总流量(带单位)
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read SsNode $info
+ * @property int $id
+ * @property int $node_id 节点ID
+ * @property int $u 上传流量
+ * @property int $d 下载流量
+ * @property int $total 总流量
+ * @property string|null $traffic 总流量(带单位)
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
+ * @property-read SsNode|null $info
* @method static Builder|SsNodeTrafficDaily newModelQuery()
* @method static Builder|SsNodeTrafficDaily newQuery()
* @method static Builder|SsNodeTrafficDaily query()
@@ -33,15 +30,14 @@ use Illuminate\Support\Carbon;
* @method static Builder|SsNodeTrafficDaily whereTraffic($value)
* @method static Builder|SsNodeTrafficDaily whereU($value)
* @method static Builder|SsNodeTrafficDaily whereUpdatedAt($value)
+ * @mixin Eloquent
*/
-class SsNodeTrafficDaily extends Model
-{
+class SsNodeTrafficDaily extends Model {
protected $table = 'ss_node_traffic_daily';
protected $primaryKey = 'id';
- function info()
- {
+ function info() {
return $this->hasOne(SsNode::class, 'id', 'node_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/SsNodeTrafficHourly.php b/app/Http/Models/SsNodeTrafficHourly.php
index b3e07abd..8934b76f 100644
--- a/app/Http/Models/SsNodeTrafficHourly.php
+++ b/app/Http/Models/SsNodeTrafficHourly.php
@@ -9,19 +9,16 @@ use Illuminate\Support\Carbon;
/**
* 节点每日流量统计
- * Class SsUserTrafficHourly
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $node_id 节点ID
- * @property int $u 上传流量
- * @property int $d 下载流量
- * @property int $total 总流量
- * @property string|null $traffic 总流量(带单位)
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read SsNode $info
+ * @property int $id
+ * @property int $node_id 节点ID
+ * @property int $u 上传流量
+ * @property int $d 下载流量
+ * @property int $total 总流量
+ * @property string|null $traffic 总流量(带单位)
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
+ * @property-read SsNode|null $info
* @method static Builder|SsNodeTrafficHourly newModelQuery()
* @method static Builder|SsNodeTrafficHourly newQuery()
* @method static Builder|SsNodeTrafficHourly query()
@@ -33,14 +30,13 @@ use Illuminate\Support\Carbon;
* @method static Builder|SsNodeTrafficHourly whereTraffic($value)
* @method static Builder|SsNodeTrafficHourly whereU($value)
* @method static Builder|SsNodeTrafficHourly whereUpdatedAt($value)
+ * @mixin Eloquent
*/
-class SsNodeTrafficHourly extends Model
-{
+class SsNodeTrafficHourly extends Model {
protected $table = 'ss_node_traffic_hourly';
protected $primaryKey = 'id';
- function info()
- {
+ function info() {
return $this->hasOne(SsNode::class, 'id', 'node_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Ticket.php b/app/Http/Models/Ticket.php
index 38211d10..575b9c60 100644
--- a/app/Http/Models/Ticket.php
+++ b/app/Http/Models/Ticket.php
@@ -10,19 +10,16 @@ use Illuminate\Support\Carbon;
/**
* 工单
- * Class Ticket
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $user_id
- * @property string $title 标题
- * @property string $content 内容
- * @property int $status 状态:0-待处理、1-已处理未关闭、2-已关闭
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read mixed $status_label
- * @property-read User $user
+ * @property int $id
+ * @property int $user_id 用户ID
+ * @property string $title 标题
+ * @property string $content 内容
+ * @property int $status 状态:0-待处理、1-已处理未关闭、2-已关闭
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
+ * @property-read mixed $status_label
+ * @property-read User|null $user
* @method static Builder|Ticket newModelQuery()
* @method static Builder|Ticket newQuery()
* @method static Builder|Ticket query()
@@ -34,24 +31,21 @@ use Illuminate\Support\Carbon;
* @method static Builder|Ticket whereTitle($value)
* @method static Builder|Ticket whereUpdatedAt($value)
* @method static Builder|Ticket whereUserId($value)
+ * @mixin Eloquent
*/
-class Ticket extends Model
-{
+class Ticket extends Model {
protected $table = 'ticket';
protected $primaryKey = 'id';
- function scopeUid($query)
- {
+ function scopeUid($query) {
return $query->whereUserId(Auth::user()->id);
}
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'user_id');
}
- function getStatusLabelAttribute()
- {
+ function getStatusLabelAttribute() {
switch($this->attributes['status']){
case 0:
$status_label = ''.trans('home.ticket_table_status_wait').'';
@@ -69,4 +63,4 @@ class Ticket extends Model
return $status_label;
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/TicketReply.php b/app/Http/Models/TicketReply.php
index 7929d67a..46909e11 100644
--- a/app/Http/Models/TicketReply.php
+++ b/app/Http/Models/TicketReply.php
@@ -9,17 +9,14 @@ use Illuminate\Support\Carbon;
/**
* 工单回复
- * Class TicketReply
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $ticket_id 工单ID
- * @property int $user_id 回复人ID
- * @property string $content 回复内容
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read User $user
+ * @property int $id
+ * @property int $ticket_id 工单ID
+ * @property int $user_id 回复用户的ID
+ * @property string $content 回复内容
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
+ * @property-read User|null $user
* @method static Builder|TicketReply newModelQuery()
* @method static Builder|TicketReply newQuery()
* @method static Builder|TicketReply query()
@@ -29,14 +26,13 @@ use Illuminate\Support\Carbon;
* @method static Builder|TicketReply whereTicketId($value)
* @method static Builder|TicketReply whereUpdatedAt($value)
* @method static Builder|TicketReply whereUserId($value)
+ * @mixin Eloquent
*/
-class TicketReply extends Model
-{
+class TicketReply extends Model {
protected $table = 'ticket_reply';
protected $primaryKey = 'id';
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'user_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/User.php b/app/Http/Models/User.php
index f591ce46..985562ba 100644
--- a/app/Http/Models/User.php
+++ b/app/Http/Models/User.php
@@ -14,71 +14,69 @@ use Illuminate\Support\Carbon;
/**
* 用户信息
- * Class User
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
- * @property string $email 邮箱
- * @property string $username 用户名
- * @property string $password 密码
- * @property int $port 代理端口
- * @property string $passwd 代理密码
- * @property string $vmess_id V2Ray用户ID
- * @property int $transfer_enable 可用流量,单位字节,默认1TiB
- * @property int $u 已上传流量,单位字节
- * @property int $d 已下载流量,单位字节
- * @property int $t 最后使用时间
- * @property string|null $ip 最后连接IP
- * @property int $enable 代理状态
- * @property string $method 加密方式
- * @property string $protocol 协议
- * @property string|null $protocol_param 协议参数
- * @property string $obfs 混淆
- * @property string|null $obfs_param 混淆参数
- * @property int $speed_limit_per_con 单连接限速,默认10G,为0表示不限速,单位Byte
- * @property int $speed_limit_per_user 单用户限速,默认10G,为0表示不限速,单位Byte
- * @property string|null $wechat 微信
- * @property string|null $qq QQ
- * @property string $usage 用途:1-手机、2-电脑、3-路由器、4-其他
- * @property int $pay_way 付费方式:0-免费、1-季付、2-月付、3-半年付、4-年付
- * @property int $balance 余额,单位分
- * @property string|null $enable_time 开通日期
- * @property string $expire_time 过期时间
- * @property int $ban_time 封禁到期时间
- * @property string|null $remark 备注
- * @property int $level 等级:可定义名称
- * @property int $is_admin 是否管理员:0-否、1-是
- * @property string $reg_ip 注册IP
- * @property int $last_login 最后登录时间
- * @property int $referral_uid 邀请人
- * @property string|null $reset_time 流量重置日期,NULL表示不重置
- * @property int $invite_num 可生成邀请码数
- * @property int $status 状态:-1-禁用、0-未激活、1-正常
+ * @property string $username 昵称
+ * @property string $email 邮箱
+ * @property string $password 密码
+ * @property int $port 代理端口
+ * @property string $passwd SS密码
+ * @property string $uuid
+ * @property int $transfer_enable 可用流量,单位字节,默认1TiB
+ * @property int $u 已上传流量,单位字节
+ * @property int $d 已下载流量,单位字节
+ * @property int $t 最后使用时间
+ * @property string|null $ip 最后连接IP
+ * @property int $enable SS状态
+ * @property string $method 加密方式
+ * @property string $protocol 协议
+ * @property string $obfs 混淆
+ * @property string|null $obfs_param 混淆参数
+ * @property int $speed_limit 用户限速,为0表示不限速,单位Byte
+ * @property string|null $wechat 微信
+ * @property string|null $qq QQ
+ * @property int $usage 用途:1-手机、2-电脑、3-路由器、4-其他
+ * @property int $pay_way 付费方式:0-免费、1-季付、2-月付、3-半年付、4-年付
+ * @property int $credit 余额,单位分
+ * @property string|null $enable_time 开通日期
+ * @property string $expire_time 过期时间
+ * @property int $ban_time 封禁到期时间
+ * @property string|null $remark 备注
+ * @property int|null $group_id 所属分组ID
+ * @property int $level 等级,默认0级,最高9级
+ * @property int $is_admin 是否管理员:0-否、1-是
+ * @property string $reg_ip 注册IP
+ * @property int $last_login 最后登录时间
+ * @property int $referral_uid 邀请人
+ * @property string|null $reset_time 流量重置日期,NULL表示不重置
+ * @property int $invite_num 可生成邀请码数
+ * @property int $status 状态:-1-禁用、0-未激活、1-正常
* @property string|null $remember_token
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
+ * @property mixed $balance
* @property-read Collection|UserLabel[] $label
* @property-read int|null $label_count
- * @property-read Level $levelList
+ * @property-read Level|null $levelList
* @property-read DatabaseNotificationCollection|DatabaseNotification[] $notifications
* @property-read int|null $notifications_count
* @property-read Collection|Payment[] $payment
* @property-read int|null $payment_count
- * @property-read User $referral
- * @property-read UserSubscribe $subscribe
+ * @property-read User|null $referral
+ * @property-read UserSubscribe|null $subscribe
* @method static Builder|User newModelQuery()
* @method static Builder|User newQuery()
* @method static Builder|User query()
* @method static Builder|User uid()
- * @method static Builder|User whereEmail($value)
- * @method static Builder|User whereBalance($value)
* @method static Builder|User whereBanTime($value)
* @method static Builder|User whereCreatedAt($value)
+ * @method static Builder|User whereCredit($value)
* @method static Builder|User whereD($value)
+ * @method static Builder|User whereEmail($value)
* @method static Builder|User whereEnable($value)
* @method static Builder|User whereEnableTime($value)
* @method static Builder|User whereExpireTime($value)
+ * @method static Builder|User whereGroupId($value)
* @method static Builder|User whereId($value)
* @method static Builder|User whereInviteNum($value)
* @method static Builder|User whereIp($value)
@@ -93,15 +91,13 @@ use Illuminate\Support\Carbon;
* @method static Builder|User wherePayWay($value)
* @method static Builder|User wherePort($value)
* @method static Builder|User whereProtocol($value)
- * @method static Builder|User whereProtocolParam($value)
* @method static Builder|User whereQq($value)
* @method static Builder|User whereReferralUid($value)
* @method static Builder|User whereRegIp($value)
* @method static Builder|User whereRemark($value)
* @method static Builder|User whereRememberToken($value)
* @method static Builder|User whereResetTime($value)
- * @method static Builder|User whereSpeedLimitPerCon($value)
- * @method static Builder|User whereSpeedLimitPerUser($value)
+ * @method static Builder|User whereSpeedLimit($value)
* @method static Builder|User whereStatus($value)
* @method static Builder|User whereT($value)
* @method static Builder|User whereTransferEnable($value)
@@ -109,53 +105,45 @@ use Illuminate\Support\Carbon;
* @method static Builder|User whereUpdatedAt($value)
* @method static Builder|User whereUsage($value)
* @method static Builder|User whereUsername($value)
- * @method static Builder|User whereVmessId($value)
+ * @method static Builder|User whereUuid($value)
* @method static Builder|User whereWechat($value)
+ * @mixin Eloquent
*/
-class User extends Authenticatable
-{
+class User extends Authenticatable {
use Notifiable;
protected $table = 'user';
protected $primaryKey = 'id';
- function scopeUid($query)
- {
+ function scopeUid($query) {
return $query->whereId(Auth::user()->id);
}
- function levelList()
- {
+ function levelList() {
return $this->hasOne(Level::class, 'level', 'level');
}
- function payment()
- {
+ function payment() {
return $this->hasMany(Payment::class, 'user_id', 'id');
}
- function label()
- {
+ function label() {
return $this->hasMany(UserLabel::class, 'user_id', 'id');
}
- function subscribe()
- {
+ function subscribe() {
return $this->hasOne(UserSubscribe::class, 'user_id', 'id');
}
- function referral()
- {
+ function referral() {
return $this->hasOne(User::class, 'id', 'referral_uid');
}
- function getBalanceAttribute($value)
- {
- return $value/100;
+ function getBalanceAttribute($value) {
+ return $value / 100;
}
- function setBalanceAttribute($value)
- {
- return $this->attributes['balance'] = $value*100;
+ function setBalanceAttribute($value) {
+ return $this->attributes['balance'] = $value * 100;
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/UserBalanceLog.php b/app/Http/Models/UserBalanceLog.php
index 97bc1f46..f43b94b4 100644
--- a/app/Http/Models/UserBalanceLog.php
+++ b/app/Http/Models/UserBalanceLog.php
@@ -33,44 +33,36 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder|UserBalanceLog whereOrderId($value)
* @method static Builder|UserBalanceLog whereUserId($value)
*/
-class UserBalanceLog extends Model
-{
- public $timestamps = FALSE;
+class UserBalanceLog extends Model {
+ public $timestamps = false;
protected $table = 'user_balance_log';
protected $primaryKey = 'id';
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'user_id');
}
- function getBeforeAttribute($value)
- {
- return $value/100;
+ function getBeforeAttribute($value) {
+ return $value / 100;
}
- function setBeforeAttribute($value)
- {
- return $this->attributes['before'] = $value*100;
+ function setBeforeAttribute($value) {
+ return $this->attributes['before'] = $value * 100;
}
- function getAfterAttribute($value)
- {
- return $value/100;
+ function getAfterAttribute($value) {
+ return $value / 100;
}
- function setAfterAttribute($value)
- {
- return $this->attributes['after'] = $value*100;
+ function setAfterAttribute($value) {
+ return $this->attributes['after'] = $value * 100;
}
- function getAmountAttribute($value)
- {
- return $value/100;
+ function getAmountAttribute($value) {
+ return $value / 100;
}
- function setAmountAttribute($value)
- {
- return $this->attributes['amount'] = $value*100;
+ function setAmountAttribute($value) {
+ return $this->attributes['amount'] = $value * 100;
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/UserBanLog.php b/app/Http/Models/UserBanLog.php
index 46ad425e..d0e6480a 100644
--- a/app/Http/Models/UserBanLog.php
+++ b/app/Http/Models/UserBanLog.php
@@ -9,36 +9,32 @@ use Illuminate\Support\Carbon;
/**
* 用户封禁日志
- * Class UserBanLog
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $user_id 用户ID
- * @property int $minutes 封禁账号时长,单位分钟
- * @property string $desc 操作描述
- * @property int $status 状态:0-未处理、1-已处理
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read User $user
+ * @property int $id
+ * @property int $user_id 用户ID
+ * @property int $minutes 封禁账号时长,单位分钟
+ * @property string $description 操作描述
+ * @property int $status 状态:0-未处理、1-已处理
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
+ * @property-read User|null $user
* @method static Builder|UserBanLog newModelQuery()
* @method static Builder|UserBanLog newQuery()
* @method static Builder|UserBanLog query()
* @method static Builder|UserBanLog whereCreatedAt($value)
- * @method static Builder|UserBanLog whereDesc($value)
+ * @method static Builder|UserBanLog whereDescription($value)
* @method static Builder|UserBanLog whereId($value)
* @method static Builder|UserBanLog whereMinutes($value)
* @method static Builder|UserBanLog whereStatus($value)
* @method static Builder|UserBanLog whereUpdatedAt($value)
* @method static Builder|UserBanLog whereUserId($value)
+ * @mixin Eloquent
*/
-class UserBanLog extends Model
-{
+class UserBanLog extends Model {
protected $table = 'user_ban_log';
protected $primaryKey = 'id';
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'user_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/UserLabel.php b/app/Http/Models/UserLabel.php
index 4e93049b..38284307 100644
--- a/app/Http/Models/UserLabel.php
+++ b/app/Http/Models/UserLabel.php
@@ -9,35 +9,24 @@ use Illuminate\Database\Eloquent\Model;
/**
* 用户标签
- * Class UserLabel
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $user_id 用户ID
- * @property int $label_id 标签ID
- * @property-read User $user
+ * @property-read User|null $user
* @method static Builder|UserLabel newModelQuery()
* @method static Builder|UserLabel newQuery()
* @method static Builder|UserLabel query()
* @method static Builder|UserLabel uid()
- * @method static Builder|UserLabel whereId($value)
- * @method static Builder|UserLabel whereLabelId($value)
- * @method static Builder|UserLabel whereUserId($value)
+ * @mixin Eloquent
*/
-class UserLabel extends Model
-{
- public $timestamps = FALSE;
+class UserLabel extends Model {
+ public $timestamps = false;
protected $table = 'user_label';
protected $primaryKey = 'id';
- function scopeUid($query)
- {
+ function scopeUid($query) {
return $query->whereUserId(Auth::user()->id);
}
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'user_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/UserLoginLog.php b/app/Http/Models/UserLoginLog.php
index 408f81ea..bae8cb07 100644
--- a/app/Http/Models/UserLoginLog.php
+++ b/app/Http/Models/UserLoginLog.php
@@ -9,22 +9,19 @@ use Illuminate\Support\Carbon;
/**
* 用户登录日志
- * Class UserLoginLog
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $user_id
- * @property string $ip
- * @property string $country
- * @property string $province
- * @property string $city
- * @property string $county
- * @property string $isp
- * @property string $area
- * @property Carbon $created_at
- * @property Carbon $updated_at
- * @property-read User $user
+ * @property int $id
+ * @property int $user_id
+ * @property string $ip
+ * @property string $country
+ * @property string $province
+ * @property string $city
+ * @property string $county
+ * @property string $isp
+ * @property string $area
+ * @property Carbon $created_at
+ * @property Carbon $updated_at
+ * @property-read User|null $user
* @method static Builder|UserLoginLog newModelQuery()
* @method static Builder|UserLoginLog newQuery()
* @method static Builder|UserLoginLog query()
@@ -39,14 +36,13 @@ use Illuminate\Support\Carbon;
* @method static Builder|UserLoginLog whereProvince($value)
* @method static Builder|UserLoginLog whereUpdatedAt($value)
* @method static Builder|UserLoginLog whereUserId($value)
+ * @mixin Eloquent
*/
-class UserLoginLog extends Model
-{
+class UserLoginLog extends Model {
protected $table = 'user_login_log';
protected $primaryKey = 'id';
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'user_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/UserSubscribe.php b/app/Http/Models/UserSubscribe.php
index 767ff8e9..8cfe2e2a 100644
--- a/app/Http/Models/UserSubscribe.php
+++ b/app/Http/Models/UserSubscribe.php
@@ -10,20 +10,17 @@ use Illuminate\Support\Carbon;
/**
* 用户订阅地址
- * Class UserSubscribe
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $user_id 用户ID
- * @property string|null $code 订阅地址唯一识别码
- * @property int $times 地址请求次数
- * @property int $status 状态:0-禁用、1-启用
- * @property int $ban_time 封禁时间
- * @property string $ban_desc 封禁理由
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read User $user
+ * @property int $id
+ * @property int $user_id 用户ID
+ * @property string|null $code 订阅地址唯一识别码
+ * @property int $times 地址请求次数
+ * @property int $status 状态:0-禁用、1-启用
+ * @property int $ban_time 封禁时间
+ * @property string $ban_desc 封禁理由
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
+ * @property-read User|null $user
* @method static Builder|UserSubscribe newModelQuery()
* @method static Builder|UserSubscribe newQuery()
* @method static Builder|UserSubscribe query()
@@ -37,19 +34,17 @@ use Illuminate\Support\Carbon;
* @method static Builder|UserSubscribe whereTimes($value)
* @method static Builder|UserSubscribe whereUpdatedAt($value)
* @method static Builder|UserSubscribe whereUserId($value)
+ * @mixin Eloquent
*/
-class UserSubscribe extends Model
-{
+class UserSubscribe extends Model {
protected $table = 'user_subscribe';
protected $primaryKey = 'id';
- function scopeUid($query)
- {
+ function scopeUid($query) {
return $query->whereUserId(Auth::user()->id);
}
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'user_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/UserSubscribeLog.php b/app/Http/Models/UserSubscribeLog.php
index b6d6a909..bc2034e0 100644
--- a/app/Http/Models/UserSubscribeLog.php
+++ b/app/Http/Models/UserSubscribeLog.php
@@ -9,10 +9,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* 用户订阅地址请求日志
- * Class UserSubscribeLog
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property int|null $sid 对应user_subscribe的id
* @property string|null $request_ip 请求IP
@@ -28,15 +25,14 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder|UserSubscribeLog whereRequestIp($value)
* @method static Builder|UserSubscribeLog whereRequestTime($value)
* @method static Builder|UserSubscribeLog whereSid($value)
+ * @mixin Eloquent
*/
-class UserSubscribeLog extends Model
-{
- public $timestamps = FALSE;
+class UserSubscribeLog extends Model {
+ public $timestamps = false;
protected $table = 'user_subscribe_log';
protected $primaryKey = 'id';
- function user()
- {
+ function user() {
return $this->hasManyThrough(User::class, UserSubscribe::class, 'id', 'id', 'sid', 'user_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/UserTrafficDaily.php b/app/Http/Models/UserTrafficDaily.php
index dd6661d1..136e26e2 100644
--- a/app/Http/Models/UserTrafficDaily.php
+++ b/app/Http/Models/UserTrafficDaily.php
@@ -9,20 +9,17 @@ use Illuminate\Support\Carbon;
/**
* 用户每日流量统计
- * Class UserTrafficDaily
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $user_id 用户ID
- * @property int $node_id 节点ID,0表示统计全部节点
- * @property int $u 上传流量
- * @property int $d 下载流量
- * @property int $total 总流量
- * @property string|null $traffic 总流量(带单位)
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read SsNode $node
+ * @property int $id
+ * @property int $user_id 用户ID
+ * @property int $node_id 节点ID,0表示统计全部节点
+ * @property int $u 上传流量
+ * @property int $d 下载流量
+ * @property int $total 总流量
+ * @property string|null $traffic 总流量(带单位)
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
+ * @property-read SsNode|null $node
* @method static Builder|UserTrafficDaily newModelQuery()
* @method static Builder|UserTrafficDaily newQuery()
* @method static Builder|UserTrafficDaily query()
@@ -35,14 +32,13 @@ use Illuminate\Support\Carbon;
* @method static Builder|UserTrafficDaily whereU($value)
* @method static Builder|UserTrafficDaily whereUpdatedAt($value)
* @method static Builder|UserTrafficDaily whereUserId($value)
+ * @mixin Eloquent
*/
-class UserTrafficDaily extends Model
-{
+class UserTrafficDaily extends Model {
protected $table = 'user_traffic_daily';
protected $primaryKey = 'id';
- function node()
- {
+ function node() {
return $this->hasOne(SsNode::class, 'id', 'node_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/UserTrafficHourly.php b/app/Http/Models/UserTrafficHourly.php
index bf5a89f3..29081ad0 100644
--- a/app/Http/Models/UserTrafficHourly.php
+++ b/app/Http/Models/UserTrafficHourly.php
@@ -9,20 +9,17 @@ use Illuminate\Support\Carbon;
/**
* 用户流量每小时统计
- * Class Article
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $user_id 用户ID
- * @property int $node_id 节点ID,0表示统计全部节点
- * @property int $u 上传流量
- * @property int $d 下载流量
- * @property int $total 总流量
- * @property string|null $traffic 总流量(带单位)
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read SsNode $node
+ * @property int $id
+ * @property int $user_id 用户ID
+ * @property int $node_id 节点ID,0表示统计全部节点
+ * @property int $u 上传流量
+ * @property int $d 下载流量
+ * @property int $total 总流量
+ * @property string|null $traffic 总流量(带单位)
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
+ * @property-read SsNode|null $node
* @method static Builder|UserTrafficHourly newModelQuery()
* @method static Builder|UserTrafficHourly newQuery()
* @method static Builder|UserTrafficHourly query()
@@ -35,14 +32,13 @@ use Illuminate\Support\Carbon;
* @method static Builder|UserTrafficHourly whereU($value)
* @method static Builder|UserTrafficHourly whereUpdatedAt($value)
* @method static Builder|UserTrafficHourly whereUserId($value)
+ * @mixin Eloquent
*/
-class UserTrafficHourly extends Model
-{
+class UserTrafficHourly extends Model {
protected $table = 'user_traffic_hourly';
protected $primaryKey = 'id';
- function node()
- {
+ function node() {
return $this->hasOne(SsNode::class, 'id', 'node_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/UserTrafficLog.php b/app/Http/Models/UserTrafficLog.php
index 7995d949..284a91ff 100644
--- a/app/Http/Models/UserTrafficLog.php
+++ b/app/Http/Models/UserTrafficLog.php
@@ -8,16 +8,13 @@ use Illuminate\Database\Eloquent\Model;
/**
* 用户流量记录
- * Class UserTrafficLog
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property int $user_id 用户ID
* @property int $u 上传流量
* @property int $d 下载流量
* @property int $node_id 节点ID
- * @property float $rate 流量比例
+ * @property float $rate 倍率
* @property string $traffic 产生流量
* @property int $log_time 记录时间
* @property-read SsNode $node
@@ -33,24 +30,22 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder|UserTrafficLog whereTraffic($value)
* @method static Builder|UserTrafficLog whereU($value)
* @method static Builder|UserTrafficLog whereUserId($value)
+ * @mixin Eloquent
*/
-class UserTrafficLog extends Model
-{
- public $timestamps = FALSE;
+class UserTrafficLog extends Model {
+ public $timestamps = false;
protected $table = 'user_traffic_log';
protected $primaryKey = 'id';
// 关联账号
- function user()
- {
+ function user() {
return $this->belongsTo(User::class, 'user_id', 'id');
}
// 关联节点
- function node()
- {
+ function node() {
return $this->belongsTo(SsNode::class, 'node_id', 'id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/UserTrafficModifyLog.php b/app/Http/Models/UserTrafficModifyLog.php
index 19916238..3c755872 100644
--- a/app/Http/Models/UserTrafficModifyLog.php
+++ b/app/Http/Models/UserTrafficModifyLog.php
@@ -9,57 +9,50 @@ use Illuminate\Support\Carbon;
/**
* 用户流量变动记录
- * Class UserTrafficModifyLog
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $user_id 用户ID
- * @property int $order_id 发生的订单ID
- * @property int $before 操作前流量
- * @property int $after 操作后流量
- * @property string $desc 描述
- * @property Carbon $created_at
- * @property Carbon $updated_at
- * @property-read Order $order
- * @property-read User $user
+ * @property int $id
+ * @property int $user_id 用户ID
+ * @property int $order_id 发生的订单ID
+ * @property int $before 操作前流量
+ * @property int $after 操作后流量
+ * @property string $description 描述
+ * @property Carbon $created_at
+ * @property Carbon $updated_at
+ * @property-read Order|null $order
+ * @property-read User|null $user
* @method static Builder|UserTrafficModifyLog newModelQuery()
* @method static Builder|UserTrafficModifyLog newQuery()
* @method static Builder|UserTrafficModifyLog query()
* @method static Builder|UserTrafficModifyLog whereAfter($value)
* @method static Builder|UserTrafficModifyLog whereBefore($value)
* @method static Builder|UserTrafficModifyLog whereCreatedAt($value)
- * @method static Builder|UserTrafficModifyLog whereDesc($value)
+ * @method static Builder|UserTrafficModifyLog whereDescription($value)
* @method static Builder|UserTrafficModifyLog whereId($value)
* @method static Builder|UserTrafficModifyLog whereOrderId($value)
* @method static Builder|UserTrafficModifyLog whereUpdatedAt($value)
* @method static Builder|UserTrafficModifyLog whereUserId($value)
+ * @mixin Eloquent
*/
-class UserTrafficModifyLog extends Model
-{
+class UserTrafficModifyLog extends Model {
protected $table = 'user_traffic_modify_log';
protected $primaryKey = 'id';
// 关联账号
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'user_id');
}
// 关联订单
- function order()
- {
+ function order() {
return $this->hasOne(Order::class, 'oid', 'order_id');
}
- function getBeforeAttribute($value)
- {
+ function getBeforeAttribute($value) {
return $this->attributes['before'] = flowAutoShow($value);
}
- function getAfterAttribute($value)
- {
+ function getAfterAttribute($value) {
return $this->attributes['after'] = flowAutoShow($value);
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/Verify.php b/app/Http/Models/Verify.php
index 9f1e6c60..6a967ea2 100644
--- a/app/Http/Models/Verify.php
+++ b/app/Http/Models/Verify.php
@@ -9,18 +9,15 @@ use Illuminate\Support\Carbon;
/**
* 注册时的验证激活地址
- * Class Verify
*
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int $id
- * @property int $type 激活类型:1-自行激活、2-管理员激活
- * @property int $user_id 用户ID
- * @property string $token 校验token
- * @property int $status 状态:0-未使用、1-已使用、2-已失效
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read User $user
+ * @property int $id
+ * @property int $type 激活类型:1-自行激活、2-管理员激活
+ * @property int $user_id 用户ID
+ * @property string $token 校验token
+ * @property int $status 状态:0-未使用、1-已使用、2-已失效
+ * @property Carbon|null $created_at 创建时间
+ * @property Carbon|null $updated_at 最后更新时间
+ * @property-read User|null $user
* @method static Builder|Verify newModelQuery()
* @method static Builder|Verify newQuery()
* @method static Builder|Verify query()
@@ -32,21 +29,19 @@ use Illuminate\Support\Carbon;
* @method static Builder|Verify whereType($value)
* @method static Builder|Verify whereUpdatedAt($value)
* @method static Builder|Verify whereUserId($value)
+ * @mixin Eloquent
*/
-class Verify extends Model
-{
+class Verify extends Model {
protected $table = 'verify';
protected $primaryKey = 'id';
// 筛选类型
- function scopeType($query, $type)
- {
+ function scopeType($query, $type) {
return $query->whereType($type);
}
- function user()
- {
+ function user() {
return $this->hasOne(User::class, 'id', 'user_id');
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Models/VerifyCode.php b/app/Http/Models/VerifyCode.php
index 4edf5e23..0a354359 100644
--- a/app/Http/Models/VerifyCode.php
+++ b/app/Http/Models/VerifyCode.php
@@ -9,10 +9,7 @@ use Illuminate\Support\Carbon;
/**
* 注册时的激活验证码
- * Class VerifyCode
*
- * @package App\Http\Models
- * @mixin Eloquent
* @property int $id
* @property string $address 用户邮箱
* @property string $code 验证码
@@ -22,17 +19,16 @@ use Illuminate\Support\Carbon;
* @method static Builder|VerifyCode newModelQuery()
* @method static Builder|VerifyCode newQuery()
* @method static Builder|VerifyCode query()
+ * @method static Builder|VerifyCode whereAddress($value)
* @method static Builder|VerifyCode whereCode($value)
* @method static Builder|VerifyCode whereCreatedAt($value)
* @method static Builder|VerifyCode whereId($value)
* @method static Builder|VerifyCode whereStatus($value)
* @method static Builder|VerifyCode whereUpdatedAt($value)
- * @method static Builder|VerifyCode whereUsername($value)
- * @method static Builder|VerifyCode whereAddress($value)
+ * @mixin Eloquent
*/
-class VerifyCode extends Model
-{
+class VerifyCode extends Model {
protected $table = 'verify_code';
protected $primaryKey = 'id';
-}
\ No newline at end of file
+}
diff --git a/app/Listeners/EventListener.php b/app/Listeners/EventListener.php
index 6959c341..b2a3b861 100644
--- a/app/Listeners/EventListener.php
+++ b/app/Listeners/EventListener.php
@@ -4,27 +4,24 @@ namespace App\Listeners;
use App\Events\Event;
-class EventListener
-{
+class EventListener {
/**
* Create the event listener.
*
* @return void
*/
- public function __construct()
- {
+ public function __construct() {
//
}
/**
* Handle the event.
*
- * @param Event $event
+ * @param Event $event
*
* @return void
*/
- public function handle(Event $event)
- {
+ public function handle(Event $event) {
//
}
}
diff --git a/app/Listeners/LogSendingMessage.php b/app/Listeners/LogSendingMessage.php
index ca607194..228f9e11 100644
--- a/app/Listeners/LogSendingMessage.php
+++ b/app/Listeners/LogSendingMessage.php
@@ -4,27 +4,24 @@ namespace App\Listeners;
use Illuminate\Mail\Events\MessageSending;
-class LogSendingMessage
-{
+class LogSendingMessage {
/**
* Create the event listener.
*
* @return void
*/
- public function __construct()
- {
+ public function __construct() {
//
}
/**
* Handle the event.
*
- * @param MessageSending $event
+ * @param MessageSending $event
*
* @return void
*/
- public function handle(MessageSending $event)
- {
+ public function handle(MessageSending $event) {
//\Log::info('MessageSending:' . var_export($event->data, true));
}
}
diff --git a/app/Listeners/LogSentMessage.php b/app/Listeners/LogSentMessage.php
index 44d44e40..1a153d2a 100644
--- a/app/Listeners/LogSentMessage.php
+++ b/app/Listeners/LogSentMessage.php
@@ -4,27 +4,24 @@ namespace App\Listeners;
use Illuminate\Mail\Events\MessageSent;
-class LogSentMessage
-{
+class LogSentMessage {
/**
* Create the event listener.
*
* @return void
*/
- public function __construct()
- {
+ public function __construct() {
//
}
/**
* Handle the event.
*
- * @param MessageSent $event
+ * @param MessageSent $event
*
* @return void
*/
- public function handle(MessageSent $event)
- {
+ public function handle(MessageSent $event) {
//\Log::info('MessageSent:' . var_export($event, true));
}
}
diff --git a/app/Mail/activeUser.php b/app/Mail/activeUser.php
index b595c288..ca6bbef1 100644
--- a/app/Mail/activeUser.php
+++ b/app/Mail/activeUser.php
@@ -9,29 +9,25 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-class activeUser extends Mailable implements ShouldQueue
-{
+class activeUser extends Mailable implements ShouldQueue {
use Queueable, SerializesModels;
protected $id; // 邮件记录ID
protected $activeUserUrl; // 激活用户URL
- public function __construct($id, $activeUserUrl)
- {
+ public function __construct($id, $activeUserUrl) {
$this->id = $id;
$this->activeUserUrl = $activeUserUrl;
}
- public function build()
- {
+ public function build() {
return $this->view('emails.activeUser')->subject('激活账号')->with([
- 'activeUserUrl' => $this->activeUserUrl
- ]);
+ 'activeUserUrl' => $this->activeUserUrl
+ ]);
}
// 发件失败处理
- public function failed(Exception $e)
- {
+ public function failed(Exception $e) {
NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
}
}
diff --git a/app/Mail/closeTicket.php b/app/Mail/closeTicket.php
index 7df0988f..f725ffa4 100644
--- a/app/Mail/closeTicket.php
+++ b/app/Mail/closeTicket.php
@@ -9,32 +9,28 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-class closeTicket extends Mailable implements ShouldQueue
-{
+class closeTicket extends Mailable implements ShouldQueue {
use Queueable, SerializesModels;
protected $id; // 邮件记录ID
protected $title; // 工单标题
protected $content; // 工单内容
- public function __construct($id, $title, $content)
- {
+ public function __construct($id, $title, $content) {
$this->id = $id;
$this->title = $title;
$this->content = $content;
}
- public function build()
- {
+ public function build() {
return $this->view('emails.closeTicket')->subject('工单关闭提醒')->with([
- 'title' => $this->title,
- 'content' => $this->content
- ]);
+ 'title' => $this->title,
+ 'content' => $this->content
+ ]);
}
// 发件失败处理
- public function failed(Exception $e)
- {
+ public function failed(Exception $e) {
NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
}
}
diff --git a/app/Mail/newTicket.php b/app/Mail/newTicket.php
index 68c2c049..d35ba0df 100644
--- a/app/Mail/newTicket.php
+++ b/app/Mail/newTicket.php
@@ -9,32 +9,28 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-class newTicket extends Mailable implements ShouldQueue
-{
+class newTicket extends Mailable implements ShouldQueue {
use Queueable, SerializesModels;
protected $id; // 邮件记录ID
protected $title; // 工单标题
protected $content; // 工单内容
- public function __construct($id, $title, $content)
- {
+ public function __construct($id, $title, $content) {
$this->id = $id;
$this->title = $title;
$this->content = $content;
}
- public function build()
- {
+ public function build() {
return $this->view('emails.newTicket')->subject('新工单提醒')->with([
- 'title' => $this->title,
- 'content' => $this->content
- ]);
+ 'title' => $this->title,
+ 'content' => $this->content
+ ]);
}
// 发件失败处理
- public function failed(Exception $e)
- {
+ public function failed(Exception $e) {
NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
}
}
diff --git a/app/Mail/nodeCrashWarning.php b/app/Mail/nodeCrashWarning.php
index e099c1b6..723dcc94 100644
--- a/app/Mail/nodeCrashWarning.php
+++ b/app/Mail/nodeCrashWarning.php
@@ -9,26 +9,26 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-class nodeCrashWarning extends Mailable implements ShouldQueue
-{
+class nodeCrashWarning extends Mailable implements ShouldQueue {
use Queueable, SerializesModels;
protected $id; // 邮件记录ID
- public function __construct($id)
- {
+ public function __construct($id) {
$this->id = $id;
}
- public function build()
- {
+ public function build() {
- return $this->view('emails.nodeCrashWarning')->subject('节点阻断警告')->with(['content' => NotificationLog::query()->whereId($this->id)->first()->content]);
+ return $this->view('emails.nodeCrashWarning')->subject('节点阻断警告')->with([
+ 'content' => NotificationLog::query()
+ ->whereId($this->id)
+ ->first()->content
+ ]);
}
// 发件失败处理
- public function failed(Exception $e)
- {
+ public function failed(Exception $e) {
NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
}
}
diff --git a/app/Mail/replyTicket.php b/app/Mail/replyTicket.php
index 79dd60c5..68e6f7fe 100644
--- a/app/Mail/replyTicket.php
+++ b/app/Mail/replyTicket.php
@@ -9,32 +9,28 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-class replyTicket extends Mailable implements ShouldQueue
-{
+class replyTicket extends Mailable implements ShouldQueue {
use Queueable, SerializesModels;
protected $id; // 邮件记录ID
protected $title; // 工单标题
protected $content; // 工单内容
- public function __construct($id, $title, $content)
- {
+ public function __construct($id, $title, $content) {
$this->id = $id;
$this->title = $title;
$this->content = $content;
}
- public function build()
- {
+ public function build() {
return $this->view('emails.replyTicket')->subject('工单回复提醒')->with([
- 'title' => $this->title,
- 'content' => $this->content
- ]);
+ 'title' => $this->title,
+ 'content' => $this->content
+ ]);
}
// 发件失败处理
- public function failed(Exception $e)
- {
+ public function failed(Exception $e) {
NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
}
}
diff --git a/app/Mail/resetPassword.php b/app/Mail/resetPassword.php
index c31be0d7..8d54bb45 100644
--- a/app/Mail/resetPassword.php
+++ b/app/Mail/resetPassword.php
@@ -9,29 +9,25 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-class resetPassword extends Mailable implements ShouldQueue
-{
+class resetPassword extends Mailable implements ShouldQueue {
use Queueable, SerializesModels;
protected $id; // 邮件记录ID
protected $resetPasswordUrl; // 重置密码URL
- public function __construct($id, $resetPasswordUrl)
- {
+ public function __construct($id, $resetPasswordUrl) {
$this->id = $id;
$this->resetPasswordUrl = $resetPasswordUrl;
}
- public function build()
- {
+ public function build() {
return $this->view('emails.resetPassword')->subject('重置密码')->with([
- 'resetPasswordUrl' => $this->resetPasswordUrl
- ]);
+ 'resetPasswordUrl' => $this->resetPasswordUrl
+ ]);
}
// 发件失败处理
- public function failed(Exception $e)
- {
+ public function failed(Exception $e) {
NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
}
}
diff --git a/app/Mail/sendUserInfo.php b/app/Mail/sendUserInfo.php
index 46622652..0bc6eb28 100644
--- a/app/Mail/sendUserInfo.php
+++ b/app/Mail/sendUserInfo.php
@@ -9,29 +9,25 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-class sendUserInfo extends Mailable implements ShouldQueue
-{
+class sendUserInfo extends Mailable implements ShouldQueue {
use Queueable, SerializesModels;
protected $id; // 邮件记录ID
protected $content; // 账号信息
- public function __construct($id, $content)
- {
+ public function __construct($id, $content) {
$this->id = $id;
$this->content = $content;
}
- public function build()
- {
+ public function build() {
return $this->view('emails.sendUserInfo')->subject('发送账号信息')->with([
- 'content' => $this->content
- ]);
+ 'content' => $this->content
+ ]);
}
// 发件失败处理
- public function failed(Exception $e)
- {
+ public function failed(Exception $e) {
NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
}
}
diff --git a/app/Mail/sendVerifyCode.php b/app/Mail/sendVerifyCode.php
index 539a382f..5ac8c06d 100644
--- a/app/Mail/sendVerifyCode.php
+++ b/app/Mail/sendVerifyCode.php
@@ -9,29 +9,25 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-class sendVerifyCode extends Mailable implements ShouldQueue
-{
+class sendVerifyCode extends Mailable implements ShouldQueue {
use Queueable, SerializesModels;
protected $id; // 邮件记录ID
protected $code; // 要发送的验证码
- public function __construct($id, $code)
- {
+ public function __construct($id, $code) {
$this->id = $id;
$this->code = $code;
}
- public function build()
- {
+ public function build() {
return $this->view('emails.sendVerifyCode')->subject('发送注册验证码')->with([
- 'code' => $this->code
- ]);
+ 'code' => $this->code
+ ]);
}
// 发件失败处理
- public function failed(Exception $e)
- {
+ public function failed(Exception $e) {
NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
}
}
diff --git a/app/Mail/userExpireWarning.php b/app/Mail/userExpireWarning.php
index 0f71c703..b7be9131 100644
--- a/app/Mail/userExpireWarning.php
+++ b/app/Mail/userExpireWarning.php
@@ -9,29 +9,25 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-class userExpireWarning extends Mailable implements ShouldQueue
-{
+class userExpireWarning extends Mailable implements ShouldQueue {
use Queueable, SerializesModels;
protected $id; // 邮件记录ID
protected $lastCanUseDays; // 剩余可用天数
- public function __construct($id, $lastCanUseDays)
- {
+ public function __construct($id, $lastCanUseDays) {
$this->id = $id;
$this->lastCanUseDays = $lastCanUseDays;
}
- public function build()
- {
+ public function build() {
return $this->view('emails.userExpireWarning')->subject('账号过期提醒')->with([
- 'lastCanUseDays' => $this->lastCanUseDays
- ]);
+ 'lastCanUseDays' => $this->lastCanUseDays
+ ]);
}
// 发件失败处理
- public function failed(Exception $e)
- {
+ public function failed(Exception $e) {
NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
}
}
diff --git a/app/Mail/userExpireWarningToday.php b/app/Mail/userExpireWarningToday.php
index ae42a725..94ce1b01 100644
--- a/app/Mail/userExpireWarningToday.php
+++ b/app/Mail/userExpireWarningToday.php
@@ -9,25 +9,21 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-class userExpireWarningToday extends Mailable implements ShouldQueue
-{
+class userExpireWarningToday extends Mailable implements ShouldQueue {
use Queueable, SerializesModels;
protected $id; // 邮件记录ID
- public function __construct($id)
- {
+ public function __construct($id) {
$this->id = $id;
}
- public function build()
- {
+ public function build() {
return $this->view('emails.userExpireWarningToday')->subject('账号过期提醒');
}
// 发件失败处理
- public function failed(Exception $e)
- {
+ public function failed(Exception $e) {
NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
}
}
diff --git a/app/Mail/userTrafficWarning.php b/app/Mail/userTrafficWarning.php
index 3bfb870d..f10441ef 100644
--- a/app/Mail/userTrafficWarning.php
+++ b/app/Mail/userTrafficWarning.php
@@ -9,29 +9,25 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-class userTrafficWarning extends Mailable implements ShouldQueue
-{
+class userTrafficWarning extends Mailable implements ShouldQueue {
use Queueable, SerializesModels;
protected $id; // 邮件记录ID
protected $usedPercent; // 已使用百分比
- public function __construct($id, $usedPercent)
- {
+ public function __construct($id, $usedPercent) {
$this->id = $id;
$this->usedPercent = $usedPercent;
}
- public function build()
- {
+ public function build() {
return $this->view('emails.userTrafficWarning')->subject('流量警告')->with([
- 'usedPercent' => $this->usedPercent
- ]);
+ 'usedPercent' => $this->usedPercent
+ ]);
}
// 发件失败处理
- public function failed(Exception $e)
- {
+ public function failed(Exception $e) {
NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
}
}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index cb76a538..ecf758e7 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -6,17 +6,15 @@ use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
use Illuminate\Support\ServiceProvider;
use URL;
-class AppServiceProvider extends ServiceProvider
-{
+class AppServiceProvider extends ServiceProvider {
/**
* Bootstrap any application services.
*
* @return void
*/
- public function boot()
- {
+ public function boot() {
// 检测是否强制跳转https
- if(env('REDIRECT_HTTPS', FALSE)){
+ if(env('REDIRECT_HTTPS', false)){
URL::forceScheme('https');
}
@@ -28,8 +26,7 @@ class AppServiceProvider extends ServiceProvider
*
* @return void
*/
- public function register()
- {
+ public function register() {
if($this->app->environment() !== 'production'){
$this->app->register(IdeHelperServiceProvider::class);
}
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php
index 4649c6c7..e7a8cfc6 100644
--- a/app/Providers/AuthServiceProvider.php
+++ b/app/Providers/AuthServiceProvider.php
@@ -4,8 +4,7 @@ namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
-class AuthServiceProvider extends ServiceProvider
-{
+class AuthServiceProvider extends ServiceProvider {
/**
* The policy mappings for the application.
*
@@ -20,8 +19,7 @@ class AuthServiceProvider extends ServiceProvider
*
* @return void
*/
- public function boot()
- {
+ public function boot() {
$this->registerPolicies();
//
diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php
index 0546ead6..c6ab6eb2 100644
--- a/app/Providers/BroadcastServiceProvider.php
+++ b/app/Providers/BroadcastServiceProvider.php
@@ -5,15 +5,13 @@ namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
-class BroadcastServiceProvider extends ServiceProvider
-{
+class BroadcastServiceProvider extends ServiceProvider {
/**
* Bootstrap any application services.
*
* @return void
*/
- public function boot()
- {
+ public function boot() {
Broadcast::routes();
require base_path('routes/channels.php');
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index 82ba7e79..d485a5e1 100644
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -4,8 +4,7 @@ namespace App\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
-class EventServiceProvider extends ServiceProvider
-{
+class EventServiceProvider extends ServiceProvider {
/**
* The event listener mappings for the application.
*
@@ -28,8 +27,7 @@ class EventServiceProvider extends ServiceProvider
*
* @return void
*/
- public function boot()
- {
+ public function boot() {
parent::boot();
//
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
index 04e276b1..ca3ede43 100644
--- a/app/Providers/RouteServiceProvider.php
+++ b/app/Providers/RouteServiceProvider.php
@@ -5,8 +5,7 @@ namespace App\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
-class RouteServiceProvider extends ServiceProvider
-{
+class RouteServiceProvider extends ServiceProvider {
/**
* This namespace is applied to your controller routes.
*
@@ -21,8 +20,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
- public function boot()
- {
+ public function boot() {
//
parent::boot();
@@ -33,8 +31,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
- public function map()
- {
+ public function map() {
$this->mapApiRoutes();
$this->mapWebRoutes();
@@ -49,12 +46,8 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
- protected function mapApiRoutes()
- {
- Route::prefix('api')
- ->middleware('api')
- ->namespace($this->namespace)
- ->group(base_path('routes/api.php'));
+ protected function mapApiRoutes() {
+ Route::prefix('api')->middleware('api')->namespace($this->namespace)->group(base_path('routes/api.php'));
}
/**
@@ -64,10 +57,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
- protected function mapWebRoutes()
- {
- Route::middleware('web')
- ->namespace($this->namespace)
- ->group(base_path('routes/web.php'));
+ protected function mapWebRoutes() {
+ Route::middleware('web')->namespace($this->namespace)->group(base_path('routes/web.php'));
}
}
diff --git a/app/helpers.php b/app/helpers.php
index 59c05ff8..220d66ad 100644
--- a/app/helpers.php
+++ b/app/helpers.php
@@ -4,8 +4,7 @@ use App\Components\Curl;
// 生成SS密码
if(!function_exists('makeRandStr')){
- function makeRandStr($length = 6, $isNumbers = FALSE)
- {
+ function makeRandStr($length = 6, $isNumbers = false) {
// 密码字符集,可任意添加你需要的字符
if(!$isNumbers){
$chars = 'abcdefghijkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789';
@@ -15,7 +14,7 @@ if(!function_exists('makeRandStr')){
$char = '';
for($i = 0; $i < $length; $i++){
- $char .= $chars[mt_rand(0, strlen($chars)-1)];
+ $char .= $chars[mt_rand(0, strlen($chars) - 1)];
}
return $char;
@@ -24,39 +23,36 @@ if(!function_exists('makeRandStr')){
// base64加密(处理URL)
if(!function_exists('base64url_encode')){
- function base64url_encode($data)
- {
+ function base64url_encode($data) {
return strtr(base64_encode($data), ['+' => '-', '/' => '_', '=' => '']);
}
}
// base64解密(处理URL)
if(!function_exists('base64url_decode')){
- function base64url_decode($data)
- {
+ function base64url_decode($data) {
return base64_decode(strtr($data, '-_', '+/'));
}
}
// 根据流量值自动转换单位输出
if(!function_exists('flowAutoShow')){
- function flowAutoShow($value = 0)
- {
+ function flowAutoShow($value = 0) {
$kb = 1024;
$mb = 1048576;
$gb = 1073741824;
- $tb = $gb*1024;
- $pb = $tb*1024;
+ $tb = $gb * 1024;
+ $pb = $tb * 1024;
if(abs($value) >= $pb){
- return round($value/$pb, 2)."PB";
+ return round($value / $pb, 2)."PB";
}elseif(abs($value) >= $tb){
- return round($value/$tb, 2)."TB";
+ return round($value / $tb, 2)."TB";
}elseif(abs($value) >= $gb){
- return round($value/$gb, 2)."GB";
+ return round($value / $gb, 2)."GB";
}elseif(abs($value) >= $mb){
- return round($value/$mb, 2)."MB";
+ return round($value / $mb, 2)."MB";
}elseif(abs($value) >= $kb){
- return round($value/$kb, 2)."KB";
+ return round($value / $kb, 2)."KB";
}else{
return round($value, 2)."B";
}
@@ -64,40 +60,36 @@ if(!function_exists('flowAutoShow')){
}
if(!function_exists('toMB')){
- function toMB($traffic)
- {
+ function toMB($traffic) {
$mb = 1048576;
- return $traffic*$mb;
+ return $traffic * $mb;
}
}
if(!function_exists('toGB')){
- function toGB($traffic)
- {
- $gb = 1048576*1024;
+ function toGB($traffic) {
+ $gb = 1048576 * 1024;
- return $traffic*$gb;
+ return $traffic * $gb;
}
}
if(!function_exists('flowToGB')){
- function flowToGB($traffic)
- {
- $gb = 1048576*1024;
+ function flowToGB($traffic) {
+ $gb = 1048576 * 1024;
- return $traffic/$gb;
+ return $traffic / $gb;
}
}
// 文件大小转换
if(!function_exists('formatBytes')){
- function formatBytes($bytes, $precision = 2)
- {
+ function formatBytes($bytes, $precision = 2) {
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
$bytes = max($bytes, 0);
- $pow = floor(($bytes? log($bytes) : 0)/log(1024));
- $pow = min($pow, count($units)-1);
+ $pow = floor(($bytes? log($bytes) : 0) / log(1024));
+ $pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision).' '.$units[$pow];
@@ -106,11 +98,10 @@ if(!function_exists('formatBytes')){
// 秒转时间
if(!function_exists('seconds2time')){
- function seconds2time($seconds)
- {
- $day = floor($seconds/(3600*24));
- $hour = floor(($seconds%(3600*24))/3600);
- $minute = floor((($seconds%(3600*24))%3600)/60);
+ function seconds2time($seconds) {
+ $day = floor($seconds / (3600 * 24));
+ $hour = floor(($seconds % (3600 * 24)) / 3600);
+ $minute = floor((($seconds % (3600 * 24)) % 3600) / 60);
if($day > 0){
return $day.'天'.$hour.'小时'.$minute.'分';
}else{
@@ -125,8 +116,7 @@ if(!function_exists('seconds2time')){
// 获取访客真实IP
if(!function_exists('getClientIP')){
- function getClientIP()
- {
+ function getClientIP() {
/*
* 访问时用localhost访问的,读出来的是“::1”是正常情况
* ::1说明开启了IPv6支持,这是IPv6下的本地回环地址的表示
@@ -193,12 +183,11 @@ if(!function_exists('getIPv6')){
* "country_code": "CN"
* }
*/
- function getIPv6($ip)
- {
+ function getIPv6($ip) {
$url = 'https://api.ip.sb/geoip/'.$ip;
try{
- $result = json_decode(Curl::send($url), TRUE);
+ $result = json_decode(Curl::send($url), true);
if(!is_array($result) || isset($result['code'])){
throw new Exception('解析IPv6异常:'.$ip);
}
@@ -214,16 +203,15 @@ if(!function_exists('getIPv6')){
// 随机UUID
if(!function_exists('createGuid')){
- function createGuid()
- {
- mt_srand((double)microtime()*10000);
- $charid = strtoupper(md5(uniqid(rand(), TRUE)));
+ function createGuid() {
+ mt_srand((double) microtime() * 10000);
+ $charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45);
- $uuid = substr($charid, 0, 8).$hyphen
- .substr($charid, 8, 4).$hyphen
- .substr($charid, 12, 4).$hyphen
- .substr($charid, 16, 4).$hyphen
- .substr($charid, 20, 12);
+ $uuid = substr($charid, 0, 8).$hyphen.substr($charid, 8, 4).$hyphen.substr($charid, 12,
+ 4).$hyphen.substr($charid, 16,
+ 4).$hyphen.substr($charid,
+ 20,
+ 12);
return strtolower($uuid);
}
@@ -231,13 +219,10 @@ if(!function_exists('createGuid')){
// 过滤emoji表情
if(!function_exists('filterEmoji')){
- function filterEmoji($str)
- {
- $str = preg_replace_callback('/./u',
- function(array $match){
- return strlen($match[0]) >= 4? '' : $match[0];
- },
- $str);
+ function filterEmoji($str) {
+ $str = preg_replace_callback('/./u', function(array $match) {
+ return strlen($match[0]) >= 4? '' : $match[0];
+ }, $str);
return $str;
}
@@ -245,12 +230,12 @@ if(!function_exists('filterEmoji')){
// 验证手机号是否正确
if(!function_exists('isMobile')){
- function isMobile($mobile)
- {
+ function isMobile($mobile) {
if(!is_numeric($mobile)){
- return FALSE;
+ return false;
}
- return preg_match('#^13[\d]{9}$|^14[5,7]{1}\d{8}$|^15[^4]{1}\d{8}$|^17[0,6,7,8]{1}\d{8}$|^18[\d]{9}$#', $mobile)? TRUE : FALSE;
+ return preg_match('#^13[\d]{9}$|^14[5,7]{1}\d{8}$|^15[^4]{1}\d{8}$|^17[0,6,7,8]{1}\d{8}$|^18[\d]{9}$#',
+ $mobile)? true : false;
}
}
diff --git a/bootstrap/app.php b/bootstrap/app.php
index f2801adf..9c879ffe 100644
--- a/bootstrap/app.php
+++ b/bootstrap/app.php
@@ -12,7 +12,7 @@
*/
$app = new Illuminate\Foundation\Application(
- realpath(__DIR__.'/../')
+ realpath(__DIR__ . '/../')
);
/*
diff --git a/config/HCaptcha.php b/config/HCaptcha.php
index 0abb5a2a..30ccd3c4 100644
--- a/config/HCaptcha.php
+++ b/config/HCaptcha.php
@@ -1,10 +1,10 @@
env('HCAPTCHA_SECRET'),
- 'sitekey' => env('HCAPTCHA_SITEKEY'),
- 'server-get-config' => TRUE,
- 'options' => [
- 'timeout' => 30,
- ],
+ 'secret' => env('HCAPTCHA_SECRET'),
+ 'sitekey' => env('HCAPTCHA_SITEKEY'),
+ 'server-get-config' => TRUE,
+ 'options' => [
+ 'timeout' => 30,
+ ],
];
diff --git a/config/NoCaptcha.php b/config/NoCaptcha.php
index 9fa4d566..e87d496b 100644
--- a/config/NoCaptcha.php
+++ b/config/NoCaptcha.php
@@ -1,10 +1,10 @@
env('NOCAPTCHA_SECRET'),
- 'sitekey' => env('NOCAPTCHA_SITEKEY'),
- 'server-get-config' => TRUE,
- 'options' => [
- 'timeout' => 30,
- ],
+ 'secret' => env('NOCAPTCHA_SECRET'),
+ 'sitekey' => env('NOCAPTCHA_SITEKEY'),
+ 'server-get-config' => TRUE,
+ 'options' => [
+ 'timeout' => 30,
+ ],
];
diff --git a/config/app.php b/config/app.php
index ba57811f..7407db2e 100644
--- a/config/app.php
+++ b/config/app.php
@@ -2,228 +2,228 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Application Name
- |--------------------------------------------------------------------------
- |
- | This value is the name of your application. This value is used when the
- | framework needs to place the application's name in a notification or
- | any other location as required by the application or its packages.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Application Name
+ |--------------------------------------------------------------------------
+ |
+ | This value is the name of your application. This value is used when the
+ | framework needs to place the application's name in a notification or
+ | any other location as required by the application or its packages.
+ |
+ */
- 'name' => env('APP_NAME', 'Laravel'),
+ 'name' => env('APP_NAME', 'Laravel'),
- /*
- |--------------------------------------------------------------------------
- | Application Environment
- |--------------------------------------------------------------------------
- |
- | This value determines the "environment" your application is currently
- | running in. This may determine how you prefer to configure various
- | services your application utilizes. Set this in your ".env" file.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Application Environment
+ |--------------------------------------------------------------------------
+ |
+ | This value determines the "environment" your application is currently
+ | running in. This may determine how you prefer to configure various
+ | services your application utilizes. Set this in your ".env" file.
+ |
+ */
- 'env' => env('APP_ENV', 'production'),
+ 'env' => env('APP_ENV', 'production'),
- /*
- |--------------------------------------------------------------------------
- | Application Debug Mode
- |--------------------------------------------------------------------------
- |
- | When your application is in debug mode, detailed error messages with
- | stack traces will be shown on every error that occurs within your
- | application. If disabled, a simple generic error page is shown.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Application Debug Mode
+ |--------------------------------------------------------------------------
+ |
+ | When your application is in debug mode, detailed error messages with
+ | stack traces will be shown on every error that occurs within your
+ | application. If disabled, a simple generic error page is shown.
+ |
+ */
- 'debug' => env('APP_DEBUG', FALSE),
+ 'debug' => env('APP_DEBUG', FALSE),
- /*
- |--------------------------------------------------------------------------
- | Application URL
- |--------------------------------------------------------------------------
- |
- | This URL is used by the console to properly generate URLs when using
- | the Artisan command line tool. You should set this to the root of
- | your application so that it is used when running Artisan tasks.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Application URL
+ |--------------------------------------------------------------------------
+ |
+ | This URL is used by the console to properly generate URLs when using
+ | the Artisan command line tool. You should set this to the root of
+ | your application so that it is used when running Artisan tasks.
+ |
+ */
- 'url' => env('APP_URL', 'http://localhost'),
+ 'url' => env('APP_URL', 'http://localhost'),
- /*
- |--------------------------------------------------------------------------
- | Application Timezone
- |--------------------------------------------------------------------------
- |
- | Here you may specify the default timezone for your application, which
- | will be used by the PHP date and date-time functions. We have gone
- | ahead and set this to a sensible default for you out of the box.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Application Timezone
+ |--------------------------------------------------------------------------
+ |
+ | Here you may specify the default timezone for your application, which
+ | will be used by the PHP date and date-time functions. We have gone
+ | ahead and set this to a sensible default for you out of the box.
+ |
+ */
- 'timezone' => env('APP_TIMEZONE', 'UTC'),
+ 'timezone' => env('APP_TIMEZONE', 'UTC'),
- /*
- |--------------------------------------------------------------------------
- | Application Locale Configuration
- |--------------------------------------------------------------------------
- |
- | The application locale determines the default locale that will be used
- | by the translation service provider. You are free to set this value
- | to any of the locales which will be supported by the application.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Application Locale Configuration
+ |--------------------------------------------------------------------------
+ |
+ | The application locale determines the default locale that will be used
+ | by the translation service provider. You are free to set this value
+ | to any of the locales which will be supported by the application.
+ |
+ */
- 'locale' => env('APP_LOCALE', 'en'),
+ 'locale' => env('APP_LOCALE', 'en'),
- /*
- |--------------------------------------------------------------------------
- | Application Fallback Locale
- |--------------------------------------------------------------------------
- |
- | The fallback locale determines the locale to use when the current one
- | is not available. You may change the value to correspond to any of
- | the language folders that are provided through your application.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Application Fallback Locale
+ |--------------------------------------------------------------------------
+ |
+ | The fallback locale determines the locale to use when the current one
+ | is not available. You may change the value to correspond to any of
+ | the language folders that are provided through your application.
+ |
+ */
- 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'zh-CN'),
+ 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'zh-CN'),
- /*
- |--------------------------------------------------------------------------
- | Encryption Key
- |--------------------------------------------------------------------------
- |
- | This key is used by the Illuminate encrypter service and should be set
- | to a random, 32 character string, otherwise these encrypted strings
- | will not be safe. Please do this before deploying an application!
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Encryption Key
+ |--------------------------------------------------------------------------
+ |
+ | This key is used by the Illuminate encrypter service and should be set
+ | to a random, 32 character string, otherwise these encrypted strings
+ | will not be safe. Please do this before deploying an application!
+ |
+ */
- 'key' => env('APP_KEY'),
+ 'key' => env('APP_KEY'),
- 'cipher' => 'AES-256-CBC',
+ 'cipher' => 'AES-256-CBC',
- /*
- |--------------------------------------------------------------------------
- | Autoloaded Service Providers
- |--------------------------------------------------------------------------
- |
- | The service providers listed here will be automatically loaded on the
- | request to your application. Feel free to add your own services to
- | this array to grant expanded functionality to your applications.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Autoloaded Service Providers
+ |--------------------------------------------------------------------------
+ |
+ | The service providers listed here will be automatically loaded on the
+ | request to your application. Feel free to add your own services to
+ | this array to grant expanded functionality to your applications.
+ |
+ */
- 'providers' => [
+ 'providers' => [
- /*
- * Laravel Framework Service Providers...
- */
- Illuminate\Auth\AuthServiceProvider::class,
- Illuminate\Broadcasting\BroadcastServiceProvider::class,
- Illuminate\Bus\BusServiceProvider::class,
- Illuminate\Cache\CacheServiceProvider::class,
- Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
- Illuminate\Cookie\CookieServiceProvider::class,
- Illuminate\Database\DatabaseServiceProvider::class,
- Illuminate\Encryption\EncryptionServiceProvider::class,
- Illuminate\Filesystem\FilesystemServiceProvider::class,
- Illuminate\Foundation\Providers\FoundationServiceProvider::class,
- Illuminate\Hashing\HashServiceProvider::class,
- Illuminate\Mail\MailServiceProvider::class,
- Illuminate\Notifications\NotificationServiceProvider::class,
- Illuminate\Pagination\PaginationServiceProvider::class,
- Illuminate\Pipeline\PipelineServiceProvider::class,
- Illuminate\Queue\QueueServiceProvider::class,
- Illuminate\Redis\RedisServiceProvider::class,
- Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
- Illuminate\Session\SessionServiceProvider::class,
- // Illuminate\Translation\TranslationServiceProvider::class, // 弃用自带多国语言包功能
- Illuminate\Validation\ValidationServiceProvider::class,
- Illuminate\View\ViewServiceProvider::class,
+ /*
+ * Laravel Framework Service Providers...
+ */
+ Illuminate\Auth\AuthServiceProvider::class,
+ Illuminate\Broadcasting\BroadcastServiceProvider::class,
+ Illuminate\Bus\BusServiceProvider::class,
+ Illuminate\Cache\CacheServiceProvider::class,
+ Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
+ Illuminate\Cookie\CookieServiceProvider::class,
+ Illuminate\Database\DatabaseServiceProvider::class,
+ Illuminate\Encryption\EncryptionServiceProvider::class,
+ Illuminate\Filesystem\FilesystemServiceProvider::class,
+ Illuminate\Foundation\Providers\FoundationServiceProvider::class,
+ Illuminate\Hashing\HashServiceProvider::class,
+ Illuminate\Mail\MailServiceProvider::class,
+ Illuminate\Notifications\NotificationServiceProvider::class,
+ Illuminate\Pagination\PaginationServiceProvider::class,
+ Illuminate\Pipeline\PipelineServiceProvider::class,
+ Illuminate\Queue\QueueServiceProvider::class,
+ Illuminate\Redis\RedisServiceProvider::class,
+ Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
+ Illuminate\Session\SessionServiceProvider::class,
+ // Illuminate\Translation\TranslationServiceProvider::class, // 弃用自带多国语言包功能
+ Illuminate\Validation\ValidationServiceProvider::class,
+ Illuminate\View\ViewServiceProvider::class,
- /*
- * Package Service Providers...
- */
- Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class, //IDE帮助
- Barryvdh\Debugbar\ServiceProvider::class,//Debug工具
- Jenssegers\Agent\AgentServiceProvider::class, //用户浏览器检测
- Misechow\Geetest\GeetestServiceProvider::class, // Geetest极验
- Misechow\NoCaptcha\NoCaptchaServiceProvider::class, // Google reCAPTCHA
- Overtrue\LaravelLang\TranslationServiceProvider::class, // 多国语言包功能
- Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider::class,//日志查看
- Scyllaly\HCaptcha\HCaptchaServiceProvider::class, //HCaptcha
- Srmklive\PayPal\Providers\PayPalServiceProvider::class, // PayPal
+ /*
+ * Package Service Providers...
+ */
+ Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class, //IDE帮助
+ Barryvdh\Debugbar\ServiceProvider::class,//Debug工具
+ Jenssegers\Agent\AgentServiceProvider::class, //用户浏览器检测
+ Misechow\Geetest\GeetestServiceProvider::class, // Geetest极验
+ Misechow\NoCaptcha\NoCaptchaServiceProvider::class, // Google reCAPTCHA
+ Overtrue\LaravelLang\TranslationServiceProvider::class, // 多国语言包功能
+ Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider::class,//日志查看
+ Scyllaly\HCaptcha\HCaptchaServiceProvider::class, //HCaptcha
+ Srmklive\PayPal\Providers\PayPalServiceProvider::class, // PayPal
- /*
- * Application Service Providers...
- */
- App\Providers\AppServiceProvider::class,
- App\Providers\AuthServiceProvider::class,
- // App\Providers\BroadcastServiceProvider::class,
- App\Providers\EventServiceProvider::class,
- App\Providers\RouteServiceProvider::class,
+ /*
+ * Application Service Providers...
+ */
+ App\Providers\AppServiceProvider::class,
+ App\Providers\AuthServiceProvider::class,
+ // App\Providers\BroadcastServiceProvider::class,
+ App\Providers\EventServiceProvider::class,
+ App\Providers\RouteServiceProvider::class,
- ],
+ ],
- /*
- |--------------------------------------------------------------------------
- | Class Aliases
- |--------------------------------------------------------------------------
- |
- | This array of class aliases will be registered when this application
- | is started. However, feel free to register as many as you wish as
- | the aliases are "lazy" loaded so they don't hinder performance.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Class Aliases
+ |--------------------------------------------------------------------------
+ |
+ | This array of class aliases will be registered when this application
+ | is started. However, feel free to register as many as you wish as
+ | the aliases are "lazy" loaded so they don't hinder performance.
+ |
+ */
- 'aliases' => [
- 'Agent' => Jenssegers\Agent\Facades\Agent::class,
- 'App' => Illuminate\Support\Facades\App::class,
- 'Artisan' => Illuminate\Support\Facades\Artisan::class,
- 'Auth' => Illuminate\Support\Facades\Auth::class,
- 'Blade' => Illuminate\Support\Facades\Blade::class,
- 'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
- 'Bus' => Illuminate\Support\Facades\Bus::class,
- 'Cache' => Illuminate\Support\Facades\Cache::class,
- 'Captcha' => Mews\Captcha\Facades\Captcha::class,
- 'Config' => Illuminate\Support\Facades\Config::class,
- 'Cookie' => Illuminate\Support\Facades\Cookie::class,
- 'Crypt' => Illuminate\Support\Facades\Crypt::class,
- 'DB' => Illuminate\Support\Facades\DB::class,
- 'Debugbar' => Barryvdh\Debugbar\Facade::class,
- 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
- 'Event' => Illuminate\Support\Facades\Event::class,
- 'File' => Illuminate\Support\Facades\File::class,
- 'Gate' => Illuminate\Support\Facades\Gate::class,
- 'Geetest' => Misechow\Geetest\Geetest::class,
- 'Hash' => Illuminate\Support\Facades\Hash::class,
- 'HCaptcha' => Scyllaly\HCaptcha\Facades\HCaptcha::class,
- 'Lang' => Illuminate\Support\Facades\Lang::class,
- 'Log' => Illuminate\Support\Facades\Log::class,
- 'Mail' => Illuminate\Support\Facades\Mail::class,
- 'NoCaptcha' => Misechow\NoCaptcha\Facades\NoCaptcha::class,
- 'Notification' => Illuminate\Support\Facades\Notification::class,
- 'Password' => Illuminate\Support\Facades\Password::class,
- 'PayPal' => Srmklive\PayPal\Facades\PayPal::class,
- 'Purifier' => Mews\Purifier\Facades\Purifier::class,
- 'Queue' => Illuminate\Support\Facades\Queue::class,
- 'Redirect' => Illuminate\Support\Facades\Redirect::class,
- 'Redis' => Illuminate\Support\Facades\Redis::class,
- 'Request' => Illuminate\Support\Facades\Request::class,
- 'Response' => Illuminate\Support\Facades\Response::class,
- 'Route' => Illuminate\Support\Facades\Route::class,
- 'Schema' => Illuminate\Support\Facades\Schema::class,
- 'Session' => Illuminate\Support\Facades\Session::class,
- 'Storage' => Illuminate\Support\Facades\Storage::class,
- 'URL' => Illuminate\Support\Facades\URL::class,
- 'Validator' => Illuminate\Support\Facades\Validator::class,
- 'View' => Illuminate\Support\Facades\View::class,
- ],
+ 'aliases' => [
+ 'Agent' => Jenssegers\Agent\Facades\Agent::class,
+ 'App' => Illuminate\Support\Facades\App::class,
+ 'Artisan' => Illuminate\Support\Facades\Artisan::class,
+ 'Auth' => Illuminate\Support\Facades\Auth::class,
+ 'Blade' => Illuminate\Support\Facades\Blade::class,
+ 'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
+ 'Bus' => Illuminate\Support\Facades\Bus::class,
+ 'Cache' => Illuminate\Support\Facades\Cache::class,
+ 'Captcha' => Mews\Captcha\Facades\Captcha::class,
+ 'Config' => Illuminate\Support\Facades\Config::class,
+ 'Cookie' => Illuminate\Support\Facades\Cookie::class,
+ 'Crypt' => Illuminate\Support\Facades\Crypt::class,
+ 'DB' => Illuminate\Support\Facades\DB::class,
+ 'Debugbar' => Barryvdh\Debugbar\Facade::class,
+ 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
+ 'Event' => Illuminate\Support\Facades\Event::class,
+ 'File' => Illuminate\Support\Facades\File::class,
+ 'Gate' => Illuminate\Support\Facades\Gate::class,
+ 'Geetest' => Misechow\Geetest\Geetest::class,
+ 'Hash' => Illuminate\Support\Facades\Hash::class,
+ 'HCaptcha' => Scyllaly\HCaptcha\Facades\HCaptcha::class,
+ 'Lang' => Illuminate\Support\Facades\Lang::class,
+ 'Log' => Illuminate\Support\Facades\Log::class,
+ 'Mail' => Illuminate\Support\Facades\Mail::class,
+ 'NoCaptcha' => Misechow\NoCaptcha\Facades\NoCaptcha::class,
+ 'Notification' => Illuminate\Support\Facades\Notification::class,
+ 'Password' => Illuminate\Support\Facades\Password::class,
+ 'PayPal' => Srmklive\PayPal\Facades\PayPal::class,
+ 'Purifier' => Mews\Purifier\Facades\Purifier::class,
+ 'Queue' => Illuminate\Support\Facades\Queue::class,
+ 'Redirect' => Illuminate\Support\Facades\Redirect::class,
+ 'Redis' => Illuminate\Support\Facades\Redis::class,
+ 'Request' => Illuminate\Support\Facades\Request::class,
+ 'Response' => Illuminate\Support\Facades\Response::class,
+ 'Route' => Illuminate\Support\Facades\Route::class,
+ 'Schema' => Illuminate\Support\Facades\Schema::class,
+ 'Session' => Illuminate\Support\Facades\Session::class,
+ 'Storage' => Illuminate\Support\Facades\Storage::class,
+ 'URL' => Illuminate\Support\Facades\URL::class,
+ 'Validator' => Illuminate\Support\Facades\Validator::class,
+ 'View' => Illuminate\Support\Facades\View::class,
+ ],
];
diff --git a/config/auth.php b/config/auth.php
index 92d50006..3e60ab0e 100644
--- a/config/auth.php
+++ b/config/auth.php
@@ -2,101 +2,101 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Authentication Defaults
- |--------------------------------------------------------------------------
- |
- | This option controls the default authentication "guard" and password
- | reset options for your application. You may change these defaults
- | as required, but they're a perfect start for most applications.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Authentication Defaults
+ |--------------------------------------------------------------------------
+ |
+ | This option controls the default authentication "guard" and password
+ | reset options for your application. You may change these defaults
+ | as required, but they're a perfect start for most applications.
+ |
+ */
- 'defaults' => [
- 'guard' => 'web',
- 'passwords' => 'users',
- ],
+ 'defaults' => [
+ 'guard' => 'web',
+ 'passwords' => 'users',
+ ],
- /*
- |--------------------------------------------------------------------------
- | Authentication Guards
- |--------------------------------------------------------------------------
- |
- | Next, you may define every authentication guard for your application.
- | Of course, a great default configuration has been defined for you
- | here which uses session storage and the Eloquent user provider.
- |
- | All authentication drivers have a user provider. This defines how the
- | users are actually retrieved out of your database or other storage
- | mechanisms used by this application to persist your user's data.
- |
- | Supported: "session", "token"
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Authentication Guards
+ |--------------------------------------------------------------------------
+ |
+ | Next, you may define every authentication guard for your application.
+ | Of course, a great default configuration has been defined for you
+ | here which uses session storage and the Eloquent user provider.
+ |
+ | All authentication drivers have a user provider. This defines how the
+ | users are actually retrieved out of your database or other storage
+ | mechanisms used by this application to persist your user's data.
+ |
+ | Supported: "session", "token"
+ |
+ */
- 'guards' => [
- 'web' => [
- 'driver' => 'session',
- 'provider' => 'users',
- ],
+ 'guards' => [
+ 'web' => [
+ 'driver' => 'session',
+ 'provider' => 'users',
+ ],
- 'api' => [
- 'driver' => 'token',
- 'provider' => 'users',
- ],
- ],
+ 'api' => [
+ 'driver' => 'token',
+ 'provider' => 'users',
+ ],
+ ],
- /*
- |--------------------------------------------------------------------------
- | User Providers
- |--------------------------------------------------------------------------
- |
- | All authentication drivers have a user provider. This defines how the
- | users are actually retrieved out of your database or other storage
- | mechanisms used by this application to persist your user's data.
- |
- | If you have multiple user tables or models you may configure multiple
- | sources which represent each model / table. These sources may then
- | be assigned to any extra authentication guards you have defined.
- |
- | Supported: "database", "eloquent"
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | User Providers
+ |--------------------------------------------------------------------------
+ |
+ | All authentication drivers have a user provider. This defines how the
+ | users are actually retrieved out of your database or other storage
+ | mechanisms used by this application to persist your user's data.
+ |
+ | If you have multiple user tables or models you may configure multiple
+ | sources which represent each model / table. These sources may then
+ | be assigned to any extra authentication guards you have defined.
+ |
+ | Supported: "database", "eloquent"
+ |
+ */
- 'providers' => [
- 'users' => [
- 'driver' => 'eloquent',
- 'model' => App\Http\Models\User::class,
- ],
+ 'providers' => [
+ 'users' => [
+ 'driver' => 'eloquent',
+ 'model' => App\Http\Models\User::class,
+ ],
- // 'users' => [
- // 'driver' => 'database',
- // 'table' => 'users',
- // ],
- ],
+ // 'users' => [
+ // 'driver' => 'database',
+ // 'table' => 'users',
+ // ],
+ ],
- /*
- |--------------------------------------------------------------------------
- | Resetting Passwords
- |--------------------------------------------------------------------------
- |
- | You may specify multiple password reset configurations if you have more
- | than one user table or model in the application and you want to have
- | separate password reset settings based on the specific user types.
- |
- | The expire time is the number of minutes that the reset token should be
- | considered valid. This security feature keeps tokens short-lived so
- | they have less time to be guessed. You may change this as needed.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Resetting Passwords
+ |--------------------------------------------------------------------------
+ |
+ | You may specify multiple password reset configurations if you have more
+ | than one user table or model in the application and you want to have
+ | separate password reset settings based on the specific user types.
+ |
+ | The expire time is the number of minutes that the reset token should be
+ | considered valid. This security feature keeps tokens short-lived so
+ | they have less time to be guessed. You may change this as needed.
+ |
+ */
- 'passwords' => [
- 'users' => [
- 'provider' => 'users',
- 'table' => 'password_resets',
- 'expire' => 60,
- ],
- ],
+ 'passwords' => [
+ 'users' => [
+ 'provider' => 'users',
+ 'table' => 'password_resets',
+ 'expire' => 60,
+ ],
+ ],
];
diff --git a/config/broadcasting.php b/config/broadcasting.php
index 5740d11d..5b0ae815 100644
--- a/config/broadcasting.php
+++ b/config/broadcasting.php
@@ -2,58 +2,58 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Default Broadcaster
- |--------------------------------------------------------------------------
- |
- | This option controls the default broadcaster that will be used by the
- | framework when an event needs to be broadcast. You may set this to
- | any of the connections defined in the "connections" array below.
- |
- | Supported: "pusher", "redis", "log", "null"
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Default Broadcaster
+ |--------------------------------------------------------------------------
+ |
+ | This option controls the default broadcaster that will be used by the
+ | framework when an event needs to be broadcast. You may set this to
+ | any of the connections defined in the "connections" array below.
+ |
+ | Supported: "pusher", "redis", "log", "null"
+ |
+ */
- 'default' => env('BROADCAST_DRIVER', 'null'),
+ 'default' => env('BROADCAST_DRIVER', 'null'),
- /*
- |--------------------------------------------------------------------------
- | Broadcast Connections
- |--------------------------------------------------------------------------
- |
- | Here you may define all of the broadcast connections that will be used
- | to broadcast events to other systems or over websockets. Samples of
- | each available type of connection are provided inside this array.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Broadcast Connections
+ |--------------------------------------------------------------------------
+ |
+ | Here you may define all of the broadcast connections that will be used
+ | to broadcast events to other systems or over websockets. Samples of
+ | each available type of connection are provided inside this array.
+ |
+ */
- 'connections' => [
+ 'connections' => [
- 'pusher' => [
- 'driver' => 'pusher',
- 'key' => env('PUSHER_APP_KEY'),
- 'secret' => env('PUSHER_APP_SECRET'),
- 'app_id' => env('PUSHER_APP_ID'),
- 'options' => [
- 'cluster' => env('PUSHER_APP_CLUSTER'),
- 'encrypted' => TRUE,
- ],
- ],
+ 'pusher' => [
+ 'driver' => 'pusher',
+ 'key' => env('PUSHER_APP_KEY'),
+ 'secret' => env('PUSHER_APP_SECRET'),
+ 'app_id' => env('PUSHER_APP_ID'),
+ 'options' => [
+ 'cluster' => env('PUSHER_APP_CLUSTER'),
+ 'encrypted' => TRUE,
+ ],
+ ],
- 'redis' => [
- 'driver' => 'redis',
- 'connection' => 'default',
- ],
+ 'redis' => [
+ 'driver' => 'redis',
+ 'connection' => 'default',
+ ],
- 'log' => [
- 'driver' => 'log',
- ],
+ 'log' => [
+ 'driver' => 'log',
+ ],
- 'null' => [
- 'driver' => 'null',
- ],
+ 'null' => [
+ 'driver' => 'null',
+ ],
- ],
+ ],
];
diff --git a/config/cache.php b/config/cache.php
index e1809ce0..7285bf19 100644
--- a/config/cache.php
+++ b/config/cache.php
@@ -2,93 +2,93 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Default Cache Store
- |--------------------------------------------------------------------------
- |
- | This option controls the default cache connection that gets used while
- | using this caching library. This connection is used when another is
- | not explicitly specified when executing a given caching function.
- |
- | Supported: "apc", "array", "database", "file", "memcached", "redis"
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Default Cache Store
+ |--------------------------------------------------------------------------
+ |
+ | This option controls the default cache connection that gets used while
+ | using this caching library. This connection is used when another is
+ | not explicitly specified when executing a given caching function.
+ |
+ | Supported: "apc", "array", "database", "file", "memcached", "redis"
+ |
+ */
- 'default' => env('CACHE_DRIVER', 'file'),
+ 'default' => env('CACHE_DRIVER', 'file'),
- /*
- |--------------------------------------------------------------------------
- | Cache Stores
- |--------------------------------------------------------------------------
- |
- | Here you may define all of the cache "stores" for your application as
- | well as their drivers. You may even define multiple stores for the
- | same cache driver to group types of items stored in your caches.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Cache Stores
+ |--------------------------------------------------------------------------
+ |
+ | Here you may define all of the cache "stores" for your application as
+ | well as their drivers. You may even define multiple stores for the
+ | same cache driver to group types of items stored in your caches.
+ |
+ */
- 'stores' => [
+ 'stores' => [
- 'apc' => [
- 'driver' => 'apc',
- ],
+ 'apc' => [
+ 'driver' => 'apc',
+ ],
- 'array' => [
- 'driver' => 'array',
- ],
+ 'array' => [
+ 'driver' => 'array',
+ ],
- 'database' => [
- 'driver' => 'database',
- 'table' => 'cache',
- 'connection' => NULL,
- ],
+ 'database' => [
+ 'driver' => 'database',
+ 'table' => 'cache',
+ 'connection' => NULL,
+ ],
- 'file' => [
- 'driver' => 'file',
- 'path' => storage_path('framework/cache/data'),
- ],
+ 'file' => [
+ 'driver' => 'file',
+ 'path' => storage_path('framework/cache/data'),
+ ],
- 'memcached' => [
- 'driver' => 'memcached',
- 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
- 'sasl' => [
- env('MEMCACHED_USERNAME'),
- env('MEMCACHED_PASSWORD'),
- ],
- 'options' => [
- // Memcached::OPT_CONNECT_TIMEOUT => 2000,
- ],
- 'servers' => [
- [
- 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
- 'port' => env('MEMCACHED_PORT', 11211),
- 'weight' => 100,
- ],
- ],
- ],
+ 'memcached' => [
+ 'driver' => 'memcached',
+ 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
+ 'sasl' => [
+ env('MEMCACHED_USERNAME'),
+ env('MEMCACHED_PASSWORD'),
+ ],
+ 'options' => [
+ // Memcached::OPT_CONNECT_TIMEOUT => 2000,
+ ],
+ 'servers' => [
+ [
+ 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
+ 'port' => env('MEMCACHED_PORT', 11211),
+ 'weight' => 100,
+ ],
+ ],
+ ],
- 'redis' => [
- 'driver' => 'redis',
- 'connection' => 'default',
- ],
+ 'redis' => [
+ 'driver' => 'redis',
+ 'connection' => 'default',
+ ],
- ],
+ ],
- /*
- |--------------------------------------------------------------------------
- | Cache Key Prefix
- |--------------------------------------------------------------------------
- |
- | When utilizing a RAM based store such as APC or Memcached, there might
- | be other applications utilizing the same cache. So, we'll specify a
- | value to get prefixed to all our keys so we can avoid collisions.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Cache Key Prefix
+ |--------------------------------------------------------------------------
+ |
+ | When utilizing a RAM based store such as APC or Memcached, there might
+ | be other applications utilizing the same cache. So, we'll specify a
+ | value to get prefixed to all our keys so we can avoid collisions.
+ |
+ */
- 'prefix' => env(
- 'CACHE_PREFIX',
- str_slug(env('APP_NAME', 'laravel'), '_').'_cache'
- ),
+ 'prefix' => env(
+ 'CACHE_PREFIX',
+ str_slug(env('APP_NAME', 'laravel'), '_') . '_cache'
+ ),
];
diff --git a/config/captcha.php b/config/captcha.php
index 73ec8205..a782a8b1 100644
--- a/config/captcha.php
+++ b/config/captcha.php
@@ -2,46 +2,46 @@
return [
- 'characters' => '123467890',
- //'characters' => '2346789abcdefghjmnpqrtuxyzABCDEFGHJMNPQRTUXYZ',
+ 'characters' => '123467890',
+ //'characters' => '2346789abcdefghjmnpqrtuxyzABCDEFGHJMNPQRTUXYZ',
- 'default' => [
- 'length' => 4, // ���ÿ�ѧ�����Ҫ��Ϊ 9
- 'width' => 90,
- 'height' => 43,
- 'quality' => 90,
- 'math' => FALSE, // ��Ϊtrue�����ÿ�ѧ����
- ],
+ 'default' => [
+ 'length' => 4, // ���ÿ�ѧ�����Ҫ��Ϊ 9
+ 'width' => 90,
+ 'height' => 43,
+ 'quality' => 90,
+ 'math' => FALSE, // ��Ϊtrue�����ÿ�ѧ����
+ ],
- 'flat' => [
- 'length' => 6,
- 'width' => 160,
- 'height' => 46,
- 'quality' => 90,
- 'lines' => 6,
- 'bgImage' => FALSE,
- 'bgColor' => '#ecf2f4',
- 'fontColors' => ['#2c3e50', '#c0392b', '#16a085', '#c0392b', '#8e44ad', '#303f9f', '#f57c00', '#795548'],
- 'contrast' => -5,
- ],
+ 'flat' => [
+ 'length' => 6,
+ 'width' => 160,
+ 'height' => 46,
+ 'quality' => 90,
+ 'lines' => 6,
+ 'bgImage' => FALSE,
+ 'bgColor' => '#ecf2f4',
+ 'fontColors' => ['#2c3e50', '#c0392b', '#16a085', '#c0392b', '#8e44ad', '#303f9f', '#f57c00', '#795548'],
+ 'contrast' => -5,
+ ],
- 'mini' => [
- 'length' => 3,
- 'width' => 60,
- 'height' => 32,
- ],
+ 'mini' => [
+ 'length' => 3,
+ 'width' => 60,
+ 'height' => 32,
+ ],
- 'inverse' => [
- 'length' => 5,
- 'width' => 120,
- 'height' => 36,
- 'quality' => 90,
- 'sensitive' => TRUE,
- 'angle' => 12,
- 'sharpen' => 10,
- 'blur' => 2,
- 'invert' => TRUE,
- 'contrast' => -5,
- ]
+ 'inverse' => [
+ 'length' => 5,
+ 'width' => 120,
+ 'height' => 36,
+ 'quality' => 90,
+ 'sensitive' => TRUE,
+ 'angle' => 12,
+ 'sharpen' => 10,
+ 'blur' => 2,
+ 'invert' => TRUE,
+ 'contrast' => -5,
+ ]
];
diff --git a/config/database.php b/config/database.php
index 3a252717..ba0ff7d8 100644
--- a/config/database.php
+++ b/config/database.php
@@ -2,119 +2,119 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Default Database Connection Name
- |--------------------------------------------------------------------------
- |
- | Here you may specify which of the database connections below you wish
- | to use as your default connection for all database work. Of course
- | you may use many connections at once using the Database library.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Default Database Connection Name
+ |--------------------------------------------------------------------------
+ |
+ | Here you may specify which of the database connections below you wish
+ | to use as your default connection for all database work. Of course
+ | you may use many connections at once using the Database library.
+ |
+ */
- 'default' => env('DB_CONNECTION', 'mysql'),
+ 'default' => env('DB_CONNECTION', 'mysql'),
- /*
- |--------------------------------------------------------------------------
- | Database Connections
- |--------------------------------------------------------------------------
- |
- | Here are each of the database connections setup for your application.
- | Of course, examples of configuring each database platform that is
- | supported by Laravel is shown below to make development simple.
- |
- |
- | All database work in Laravel is done through the PHP PDO facilities
- | so make sure you have the driver for your particular database of
- | choice installed on your machine before you begin development.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Database Connections
+ |--------------------------------------------------------------------------
+ |
+ | Here are each of the database connections setup for your application.
+ | Of course, examples of configuring each database platform that is
+ | supported by Laravel is shown below to make development simple.
+ |
+ |
+ | All database work in Laravel is done through the PHP PDO facilities
+ | so make sure you have the driver for your particular database of
+ | choice installed on your machine before you begin development.
+ |
+ */
- 'connections' => [
+ 'connections' => [
- 'sqlite' => [
- 'driver' => 'sqlite',
- 'database' => env('DB_DATABASE', database_path('database.sqlite')),
- 'prefix' => '',
- ],
+ 'sqlite' => [
+ 'driver' => 'sqlite',
+ 'database' => env('DB_DATABASE', database_path('database.sqlite')),
+ 'prefix' => '',
+ ],
- 'mysql' => [
- 'driver' => 'mysql',
- 'host' => env('DB_HOST', '127.0.0.1'),
- 'port' => env('DB_PORT', '3306'),
- 'database' => env('DB_DATABASE', 'forge'),
- 'username' => env('DB_USERNAME', 'forge'),
- 'password' => env('DB_PASSWORD', ''),
- 'unix_socket' => env('DB_SOCKET', ''),
- 'charset' => 'utf8mb4',
- 'collation' => 'utf8mb4_unicode_ci',
- 'prefix' => '',
- 'strict' => env('DB_STRICT', TRUE),
- 'engine' => NULL,
- ],
+ 'mysql' => [
+ 'driver' => 'mysql',
+ 'host' => env('DB_HOST', '127.0.0.1'),
+ 'port' => env('DB_PORT', '3306'),
+ 'database' => env('DB_DATABASE', 'forge'),
+ 'username' => env('DB_USERNAME', 'forge'),
+ 'password' => env('DB_PASSWORD', ''),
+ 'unix_socket' => env('DB_SOCKET', ''),
+ 'charset' => 'utf8mb4',
+ 'collation' => 'utf8mb4_unicode_ci',
+ 'prefix' => '',
+ 'strict' => env('DB_STRICT', TRUE),
+ 'engine' => NULL,
+ ],
- 'pgsql' => [
- 'driver' => 'pgsql',
- 'host' => env('DB_HOST', '127.0.0.1'),
- 'port' => env('DB_PORT', '5432'),
- 'database' => env('DB_DATABASE', 'forge'),
- 'username' => env('DB_USERNAME', 'forge'),
- 'password' => env('DB_PASSWORD', ''),
- 'charset' => 'utf8',
- 'prefix' => '',
- 'schema' => 'public',
- 'sslmode' => 'prefer',
- ],
+ 'pgsql' => [
+ 'driver' => 'pgsql',
+ 'host' => env('DB_HOST', '127.0.0.1'),
+ 'port' => env('DB_PORT', '5432'),
+ 'database' => env('DB_DATABASE', 'forge'),
+ 'username' => env('DB_USERNAME', 'forge'),
+ 'password' => env('DB_PASSWORD', ''),
+ 'charset' => 'utf8',
+ 'prefix' => '',
+ 'schema' => 'public',
+ 'sslmode' => 'prefer',
+ ],
- 'sqlsrv' => [
- 'driver' => 'sqlsrv',
- 'host' => env('DB_HOST', 'localhost'),
- 'port' => env('DB_PORT', '1433'),
- 'database' => env('DB_DATABASE', 'forge'),
- 'username' => env('DB_USERNAME', 'forge'),
- 'password' => env('DB_PASSWORD', ''),
- 'charset' => 'utf8',
- 'prefix' => '',
- ],
+ 'sqlsrv' => [
+ 'driver' => 'sqlsrv',
+ 'host' => env('DB_HOST', 'localhost'),
+ 'port' => env('DB_PORT', '1433'),
+ 'database' => env('DB_DATABASE', 'forge'),
+ 'username' => env('DB_USERNAME', 'forge'),
+ 'password' => env('DB_PASSWORD', ''),
+ 'charset' => 'utf8',
+ 'prefix' => '',
+ ],
- ],
+ ],
- /*
- |--------------------------------------------------------------------------
- | Migration Repository Table
- |--------------------------------------------------------------------------
- |
- | This table keeps track of all the migrations that have already run for
- | your application. Using this information, we can determine which of
- | the migrations on disk haven't actually been run in the database.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Migration Repository Table
+ |--------------------------------------------------------------------------
+ |
+ | This table keeps track of all the migrations that have already run for
+ | your application. Using this information, we can determine which of
+ | the migrations on disk haven't actually been run in the database.
+ |
+ */
- 'migrations' => 'migrations',
+ 'migrations' => 'migrations',
- /*
- |--------------------------------------------------------------------------
- | Redis Databases
- |--------------------------------------------------------------------------
- |
- | Redis is an open source, fast, and advanced key-value store that also
- | provides a richer set of commands than a typical key-value systems
- | such as APC or Memcached. Laravel makes it easy to dig right in.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Redis Databases
+ |--------------------------------------------------------------------------
+ |
+ | Redis is an open source, fast, and advanced key-value store that also
+ | provides a richer set of commands than a typical key-value systems
+ | such as APC or Memcached. Laravel makes it easy to dig right in.
+ |
+ */
- 'redis' => [
+ 'redis' => [
- 'client' => 'predis',
+ 'client' => 'predis',
- 'default' => [
- 'host' => env('REDIS_HOST', '127.0.0.1'),
- 'password' => env('REDIS_PASSWORD', NULL),
- 'port' => env('REDIS_PORT', 6379),
- 'database' => 0,
- ],
+ 'default' => [
+ 'host' => env('REDIS_HOST', '127.0.0.1'),
+ 'password' => env('REDIS_PASSWORD', NULL),
+ 'port' => env('REDIS_PORT', 6379),
+ 'database' => 0,
+ ],
- ],
+ ],
];
diff --git a/config/debugbar.php b/config/debugbar.php
index f7f116bc..419e82a1 100644
--- a/config/debugbar.php
+++ b/config/debugbar.php
@@ -2,201 +2,201 @@
return [
- /*
- |--------------------------------------------------------------------------
- | Debugbar Settings
- |--------------------------------------------------------------------------
- |
- | Debugbar is enabled by default, when debug is set to true in app.php.
- | You can override the value by setting enable to true or false instead of null.
- |
- | You can provide an array of URI's that must be ignored (eg. 'api/*')
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Debugbar Settings
+ |--------------------------------------------------------------------------
+ |
+ | Debugbar is enabled by default, when debug is set to true in app.php.
+ | You can override the value by setting enable to true or false instead of null.
+ |
+ | You can provide an array of URI's that must be ignored (eg. 'api/*')
+ |
+ */
- 'enabled' => env('DEBUGBAR_ENABLED', NULL),
- 'except' => [
- 'telescope*'
- ],
+ 'enabled' => env('DEBUGBAR_ENABLED', NULL),
+ 'except' => [
+ 'telescope*'
+ ],
- /*
- |--------------------------------------------------------------------------
- | Storage settings
- |--------------------------------------------------------------------------
- |
- | DebugBar stores data for session/ajax requests.
- | You can disable this, so the debugbar stores data in headers/session,
- | but this can cause problems with large data collectors.
- | By default, file storage (in the storage folder) is used. Redis and PDO
- | can also be used. For PDO, run the package migrations first.
- |
- */
- 'storage' => [
- 'enabled' => TRUE,
- 'driver' => 'file', // redis, file, pdo, custom
- 'path' => storage_path('debugbar'), // For file driver
- 'connection' => NULL, // Leave null for default connection (Redis/PDO)
- 'provider' => '' // Instance of StorageInterface for custom driver
- ],
+ /*
+ |--------------------------------------------------------------------------
+ | Storage settings
+ |--------------------------------------------------------------------------
+ |
+ | DebugBar stores data for session/ajax requests.
+ | You can disable this, so the debugbar stores data in headers/session,
+ | but this can cause problems with large data collectors.
+ | By default, file storage (in the storage folder) is used. Redis and PDO
+ | can also be used. For PDO, run the package migrations first.
+ |
+ */
+ 'storage' => [
+ 'enabled' => TRUE,
+ 'driver' => 'file', // redis, file, pdo, custom
+ 'path' => storage_path('debugbar'), // For file driver
+ 'connection' => NULL, // Leave null for default connection (Redis/PDO)
+ 'provider' => '' // Instance of StorageInterface for custom driver
+ ],
- /*
- |--------------------------------------------------------------------------
- | Vendors
- |--------------------------------------------------------------------------
- |
- | Vendor files are included by default, but can be set to false.
- | This can also be set to 'js' or 'css', to only include javascript or css vendor files.
- | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
- | and for js: jquery and and highlight.js
- | So if you want syntax highlighting, set it to true.
- | jQuery is set to not conflict with existing jQuery scripts.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Vendors
+ |--------------------------------------------------------------------------
+ |
+ | Vendor files are included by default, but can be set to false.
+ | This can also be set to 'js' or 'css', to only include javascript or css vendor files.
+ | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
+ | and for js: jquery and and highlight.js
+ | So if you want syntax highlighting, set it to true.
+ | jQuery is set to not conflict with existing jQuery scripts.
+ |
+ */
- 'include_vendors' => TRUE,
+ 'include_vendors' => TRUE,
- /*
- |--------------------------------------------------------------------------
- | Capture Ajax Requests
- |--------------------------------------------------------------------------
- |
- | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
- | you can use this option to disable sending the data through the headers.
- |
- | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools.
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Capture Ajax Requests
+ |--------------------------------------------------------------------------
+ |
+ | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
+ | you can use this option to disable sending the data through the headers.
+ |
+ | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools.
+ */
- 'capture_ajax' => TRUE,
- 'add_ajax_timing' => FALSE,
+ 'capture_ajax' => TRUE,
+ 'add_ajax_timing' => FALSE,
- /*
- |--------------------------------------------------------------------------
- | Custom Error Handler for Deprecated warnings
- |--------------------------------------------------------------------------
- |
- | When enabled, the Debugbar shows deprecated warnings for Symfony components
- | in the Messages tab.
- |
- */
- 'error_handler' => FALSE,
+ /*
+ |--------------------------------------------------------------------------
+ | Custom Error Handler for Deprecated warnings
+ |--------------------------------------------------------------------------
+ |
+ | When enabled, the Debugbar shows deprecated warnings for Symfony components
+ | in the Messages tab.
+ |
+ */
+ 'error_handler' => FALSE,
- /*
- |--------------------------------------------------------------------------
- | Clockwork integration
- |--------------------------------------------------------------------------
- |
- | The Debugbar can emulate the Clockwork headers, so you can use the Chrome
- | Extension, without the server-side code. It uses Debugbar collectors instead.
- |
- */
- 'clockwork' => FALSE,
+ /*
+ |--------------------------------------------------------------------------
+ | Clockwork integration
+ |--------------------------------------------------------------------------
+ |
+ | The Debugbar can emulate the Clockwork headers, so you can use the Chrome
+ | Extension, without the server-side code. It uses Debugbar collectors instead.
+ |
+ */
+ 'clockwork' => FALSE,
- /*
- |--------------------------------------------------------------------------
- | DataCollectors
- |--------------------------------------------------------------------------
- |
- | Enable/disable DataCollectors
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | DataCollectors
+ |--------------------------------------------------------------------------
+ |
+ | Enable/disable DataCollectors
+ |
+ */
- 'collectors' => [
- 'phpinfo' => TRUE, // Php version
- 'messages' => TRUE, // Messages
- 'time' => TRUE, // Time Datalogger
- 'memory' => TRUE, // Memory usage
- 'exceptions' => TRUE, // Exception displayer
- 'log' => TRUE, // Logs from Monolog (merged in messages if enabled)
- 'db' => TRUE, // Show database (PDO) queries and bindings
- 'views' => TRUE, // Views with their data
- 'route' => TRUE, // Current route information
- 'auth' => FALSE, // Display Laravel authentication status
- 'gate' => TRUE, // Display Laravel Gate checks
- 'session' => TRUE, // Display session data
- 'symfony_request' => TRUE, // Only one can be enabled..
- 'mail' => TRUE, // Catch mail messages
- 'laravel' => FALSE, // Laravel version and environment
- 'events' => FALSE, // All events fired
- 'default_request' => FALSE, // Regular or special Symfony request logger
- 'logs' => FALSE, // Add the latest log messages
- 'files' => FALSE, // Show the included files
- 'config' => FALSE, // Display config settings
- 'cache' => FALSE, // Display cache events
- 'models' => FALSE, // Display models
- ],
+ 'collectors' => [
+ 'phpinfo' => TRUE, // Php version
+ 'messages' => TRUE, // Messages
+ 'time' => TRUE, // Time Datalogger
+ 'memory' => TRUE, // Memory usage
+ 'exceptions' => TRUE, // Exception displayer
+ 'log' => TRUE, // Logs from Monolog (merged in messages if enabled)
+ 'db' => TRUE, // Show database (PDO) queries and bindings
+ 'views' => TRUE, // Views with their data
+ 'route' => TRUE, // Current route information
+ 'auth' => FALSE, // Display Laravel authentication status
+ 'gate' => TRUE, // Display Laravel Gate checks
+ 'session' => TRUE, // Display session data
+ 'symfony_request' => TRUE, // Only one can be enabled..
+ 'mail' => TRUE, // Catch mail messages
+ 'laravel' => FALSE, // Laravel version and environment
+ 'events' => FALSE, // All events fired
+ 'default_request' => FALSE, // Regular or special Symfony request logger
+ 'logs' => FALSE, // Add the latest log messages
+ 'files' => FALSE, // Show the included files
+ 'config' => FALSE, // Display config settings
+ 'cache' => FALSE, // Display cache events
+ 'models' => FALSE, // Display models
+ ],
- /*
- |--------------------------------------------------------------------------
- | Extra options
- |--------------------------------------------------------------------------
- |
- | Configure some DataCollectors
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Extra options
+ |--------------------------------------------------------------------------
+ |
+ | Configure some DataCollectors
+ |
+ */
- 'options' => [
- 'auth' => [
- 'show_name' => TRUE, // Also show the users name/email in the debugbar
- ],
- 'db' => [
- 'with_params' => TRUE, // Render SQL with the parameters substituted
- 'backtrace' => TRUE, // Use a backtrace to find the origin of the query in your files.
- 'timeline' => FALSE, // Add the queries to the timeline
- 'explain' => [ // Show EXPLAIN output on queries
- 'enabled' => FALSE,
- 'types' => ['SELECT'], // // workaround ['SELECT'] only. https://github.com/barryvdh/laravel-debugbar/issues/888 ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
- ],
- 'hints' => TRUE, // Show hints for common mistakes
- ],
- 'mail' => [
- 'full_log' => FALSE
- ],
- 'views' => [
- 'data' => FALSE, //Note: Can slow down the application, because the data can be quite large..
- ],
- 'route' => [
- 'label' => TRUE // show complete route on bar
- ],
- 'logs' => [
- 'file' => NULL
- ],
- 'cache' => [
- 'values' => TRUE // collect cache values
- ],
- ],
+ 'options' => [
+ 'auth' => [
+ 'show_name' => TRUE, // Also show the users name/email in the debugbar
+ ],
+ 'db' => [
+ 'with_params' => TRUE, // Render SQL with the parameters substituted
+ 'backtrace' => TRUE, // Use a backtrace to find the origin of the query in your files.
+ 'timeline' => FALSE, // Add the queries to the timeline
+ 'explain' => [ // Show EXPLAIN output on queries
+ 'enabled' => FALSE,
+ 'types' => ['SELECT'], // // workaround ['SELECT'] only. https://github.com/barryvdh/laravel-debugbar/issues/888 ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
+ ],
+ 'hints' => TRUE, // Show hints for common mistakes
+ ],
+ 'mail' => [
+ 'full_log' => FALSE
+ ],
+ 'views' => [
+ 'data' => FALSE, //Note: Can slow down the application, because the data can be quite large..
+ ],
+ 'route' => [
+ 'label' => TRUE // show complete route on bar
+ ],
+ 'logs' => [
+ 'file' => NULL
+ ],
+ 'cache' => [
+ 'values' => TRUE // collect cache values
+ ],
+ ],
- /*
- |--------------------------------------------------------------------------
- | Inject Debugbar in Response
- |--------------------------------------------------------------------------
- |
- | Usually, the debugbar is added just before