From 3426112a55156003879eefe3f534b9f4a0d06513 Mon Sep 17 00:00:00 2001 From: mmmwhy Date: Mon, 13 Nov 2017 16:03:37 +0800 Subject: [PATCH] no message --- .gitignore | 1 + app/Controllers/AuthController.php | 12 +++---- app/Controllers/HomeController.php | 24 +++++++------- app/Controllers/LinkController.php | 3 +- app/Controllers/Mod_Mu/UserController.php | 20 ++++++------ app/Controllers/UserController.php | 38 ++++++----------------- app/Services/Config.php | 18 +++++------ app/Utils/TelegramProcess.php | 13 ++++---- app/Utils/Tools.php | 9 +----- app/Utils/URL.php | 11 ++----- 10 files changed, 58 insertions(+), 91 deletions(-) diff --git a/.gitignore b/.gitignore index 5b90ccf..f020a53 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ config/.config.php resources/views/material/analytics.tpl *.iml *.xml +*.bak diff --git a/app/Controllers/AuthController.php b/app/Controllers/AuthController.php index b7330a0..2f5f088 100644 --- a/app/Controllers/AuthController.php +++ b/app/Controllers/AuthController.php @@ -356,12 +356,12 @@ class AuthController extends BaseController $user->node_speedlimit=Config::get('user_speedlimit'); if (Config::get('enable_invite_code')=='true') { $user->ref_by = $c->user_id; - if ($user->ref_by !=0) { - $user->money=Config::get('invite_get_money'); - $gift_user=User::where("id", "=", $user->ref_by)->first(); - $gift_user->transfer_enable=($gift_user->transfer_enable+Config::get('invite_gift')*1024*1024*1024); - $gift_user->save(); - } + if ($user->ref_by !=0) { + $user->money=Config::get('invite_get_money'); + $gift_user=User::where("id", "=", $user->ref_by)->first(); + $gift_user->transfer_enable=($gift_user->transfer_enable+Config::get('invite_gift')*1024*1024*1024); + $gift_user->save(); + } } else { $user->ref_by = 0; } diff --git a/app/Controllers/HomeController.php b/app/Controllers/HomeController.php index b8c3e63..0584a41 100644 --- a/app/Controllers/HomeController.php +++ b/app/Controllers/HomeController.php @@ -42,41 +42,41 @@ class HomeController extends BaseController { return $this->view()->display('tos.tpl'); } - + public function staff() { return $this->view()->display('staff.tpl'); } - + public function telegram($request, $response, $args) { $token = ""; if (isset($request->getQueryParams()["token"])) { $token = $request->getQueryParams()["token"]; } - + if ($token == Config::get('telegram_request_token')) { TelegramProcess::process(); } else { echo("不正确请求!"); } } - + public function page404($request, $response, $args) { $pics=scandir(BASE_PATH."/public/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/404/"); - + if (count($pics)>2) { $pic=$pics[rand(2, count($pics)-1)]; } else { $pic="4041.png"; } - + $newResponse = $response->withStatus(404); $newResponse->getBody()->write($this->view()->assign("pic", "/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/404/".$pic)->display('404.tpl')); return $newResponse; } - + public function page405($request, $response, $args) { $pics=scandir(BASE_PATH."/public/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/405/"); @@ -85,12 +85,12 @@ class HomeController extends BaseController } else { $pic="5001.png"; } - + $newResponse = $response->withStatus(405); $newResponse->getBody()->write($this->view()->assign("pic", "/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/405/".$pic)->display('405.tpl')); return $newResponse; } - + public function page500($request, $response, $args) { $pics=scandir(BASE_PATH."/public/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/500/"); @@ -99,12 +99,12 @@ class HomeController extends BaseController } else { $pic="5001.png"; } - + $newResponse = $response->withStatus(500); $newResponse->getBody()->write($this->view()->assign("pic", "/theme/".(Auth::getUser()->isLogin==false?Config::get("theme"):Auth::getUser()->theme)."/images/error/500/".$pic)->display('500.tpl')); return $newResponse; } - + public function pay_callback($request, $response, $args) { Pay::callback($request); @@ -113,5 +113,5 @@ class HomeController extends BaseController public function notify($request, $response, $args) { Pay::pay91_notify($request); - } + } } diff --git a/app/Controllers/LinkController.php b/app/Controllers/LinkController.php index 793cb0f..966c51b 100644 --- a/app/Controllers/LinkController.php +++ b/app/Controllers/LinkController.php @@ -345,7 +345,7 @@ class LinkController extends BaseController "password"=>$item['passwd'], "tcp_over_udp"=>false, "udp_over_tcp"=>false, - "group"=>$item['group'], + "group"=>Config::get('appName'), "protocol"=>$item['protocol'], "protoparam"=>$item['protocol_param'], "obfs_udp"=>false, @@ -1740,7 +1740,6 @@ FINAL,Proxy'; $bash .= 'nvram set rt_ss_port_x'.$count.'='.$item['port']."\n"; $bash .= 'nvram set rt_ss_password_x'.$count.'="'.$item['passwd']."\"\n"; $bash .= 'nvram set rt_ss_server_x'.$count.'='.$item['address']."\n"; - $bash .= 'nvram set rt_ss_usage_x'.$count.'=""'."\n"; $bash .= 'nvram set rt_ss_method_x'.$count.'='.$item['method']."\n"; $count += 1; } diff --git a/app/Controllers/Mod_Mu/UserController.php b/app/Controllers/Mod_Mu/UserController.php index 2c9f628..d9e5c9a 100644 --- a/app/Controllers/Mod_Mu/UserController.php +++ b/app/Controllers/Mod_Mu/UserController.php @@ -34,21 +34,21 @@ class UserController extends BaseController $users_raw = User::where( function ($query) use ($node){ $query->where( - function ($query1) use ($node){ - $query1->where("class", ">=", $node->node_class) - ->where("node_group", "=", $node->node_group); - } + function ($query1) use ($node){ + $query1->where("class", ">=", $node->node_class) + ->where("node_group", "=", $node->node_group); + } )->orwhere('is_admin', 1); } ) - ->where("enable", 1)->where("expire_in", ">", date("Y-m-d H:i:s"))->get(); + ->where("enable", 1)->where("expire_in", ">", date("Y-m-d H:i:s"))->get(); } else { $users_raw = User::where( function ($query) use ($node){ $query->where( - function ($query1) use ($node){ - $query1->where("class", ">=", $node->node_class); - } + function ($query1) use ($node){ + $query1->where("class", ">=", $node->node_class); + } )->orwhere('is_admin', 1); } )->where("enable", 1)->where("expire_in", ">", date("Y-m-d H:i:s"))->get(); @@ -68,8 +68,8 @@ class UserController extends BaseController $users = array(); $key_list = array('method', 'obfs', 'obfs_param', 'protocol', 'protocol_param', - 'forbidden_ip', 'forbidden_port', 'node_speedlimit', 'disconnect_ip', - 'is_multi_user', 'id', 'port', 'passwd', 'u', 'd'); + 'forbidden_ip', 'forbidden_port', 'node_speedlimit', 'disconnect_ip', + 'is_multi_user', 'id', 'port', 'passwd', 'u', 'd'); foreach ($users_raw as $user_raw) { if ($user_raw->transfer_enable > $user_raw->u + $user_raw->d) { diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 270cebb..2fea543 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -86,6 +86,7 @@ class UserController extends BaseController } + public function lookingglass($request, $response, $args) { $Speedtest=Speedtest::where("datetime", ">", time()-Config::get('Speedtest_duration')*3600)->orderBy('datetime', 'desc')->get(); @@ -144,6 +145,8 @@ class UserController extends BaseController } } + + public function f2fpayget($request, $response, $args) { $time = $request->getQueryParams()["time"]; @@ -192,7 +195,8 @@ class UserController extends BaseController return $response->getBody()->write(json_encode($res)); } - + + public function alipay($request, $response, $args) { $amount = $request->getQueryParams()["amount"]; @@ -684,10 +688,6 @@ class UserController extends BaseController $iplocation = new QQWry(); - $userip=array(); - - $total = Ip::where("datetime",">=",time()-300)->where('userid', '=',$this->user->id)->get(); - $totallogin = LoginIp::where('userid', '=', $this->user->id)->where("type", "=", 0)->orderBy("datetime", "desc")->take(10)->get(); $userloginip=array(); @@ -703,29 +703,9 @@ class UserController extends BaseController } } - foreach($total as $single) - { - //if(isset($useripcount[$single->userid])) - { - $single->ip = Tools::getRealIp($single->ip); - $is_node = Node::where("node_ip", $single->ip)->first(); - if($is_node) { - continue; - } - - - if(!isset($userip[$single->ip])) - { - //$useripcount[$single->userid]=$useripcount[$single->userid]+1; - $location=$iplocation->getlocation($single->ip); - $userip[$single->ip]=iconv('gbk', 'utf-8//IGNORE', $location['country'].$location['area']); - } - } - } - - return $this->view()->assign("userip",$userip)->assign("userloginip", $userloginip)->assign("paybacks", $paybacks)->display('user/profile.tpl'); + return $this->view()->assign("userloginip", $userloginip)->assign("paybacks", $paybacks)->display('user/profile.tpl'); } @@ -970,10 +950,9 @@ class UserController extends BaseController $price=$shop->price*((100-$credit)/100); $user=$this->user; - - if ((float)$user->money<(float)$price) { + if ($user->money<$price) { $res['ret'] = 0; - $res['msg'] = "余额不足,总价为".$price."元。"; + $res['msg'] = "余额不足"; return $response->getBody()->write(json_encode($res)); } @@ -1568,4 +1547,5 @@ class UserController extends BaseController $newResponse = $response->withStatus(302)->withHeader('Location', '/user'); return $newResponse; } + } diff --git a/app/Services/Config.php b/app/Services/Config.php index 507b885..1a48afd 100644 --- a/app/Services/Config.php +++ b/app/Services/Config.php @@ -33,7 +33,7 @@ class Config "enable_analytics_code" => self::get("enable_analytics_code"), "enable_donate" => self::get("enable_donate"), "enable_telegram" => self::get("enable_telegram") - ]; + ]; } public static function getDbConfig() @@ -81,12 +81,12 @@ class Config switch ($type) { case 'obfs': $list = array('plain', 'http_simple', 'http_simple_compatible', 'http_post', 'http_post_compatible', - 'tls1.2_ticket_auth', 'tls1.2_ticket_auth_compatible', 'tls1.2_ticket_fastauth', 'tls1.2_ticket_fastauth_compatible', - 'simple_obfs_http', 'simple_obfs_http_compatible', 'simple_obfs_tls', 'simple_obfs_tls_compatible'); + 'tls1.2_ticket_auth', 'tls1.2_ticket_auth_compatible', 'tls1.2_ticket_fastauth', 'tls1.2_ticket_fastauth_compatible', + 'simple_obfs_http', 'simple_obfs_http_compatible', 'simple_obfs_tls', 'simple_obfs_tls_compatible'); return $list; case 'protocol': $list = array('origin', 'verify_deflate', - 'auth_sha1_v4', 'auth_sha1_v4_compatible', 'auth_aes128_sha1', 'auth_aes128_md5', 'auth_chain_a', 'auth_chain_b'); + 'auth_sha1_v4', 'auth_sha1_v4_compatible', 'auth_aes128_sha1', 'auth_aes128_md5', 'auth_chain_a', 'auth_chain_b'); return $list; case 'allow_none_protocol': $list = array('auth_chain_a', 'auth_chain_b'); @@ -96,17 +96,17 @@ class Config return $list; case 'ss_aead_method': $list = array('aes-128-gcm', 'aes-192-gcm', - 'aes-256-gcm', 'chacha20-ietf-poly1305', 'xchacha20-ietf-poly1305'); + 'aes-256-gcm', 'chacha20-ietf-poly1305', 'xchacha20-ietf-poly1305'); return $list; case 'ss_obfs': $list = array('simple_obfs_http', 'simple_obfs_http_compatible', 'simple_obfs_tls', 'simple_obfs_tls_compatible'); return $list; default: $list = array('rc4-md5', 'rc4-md5-6', 'aes-128-cfb', 'aes-192-cfb', 'aes-256-cfb', - 'aes-128-ctr', 'aes-192-ctr', 'aes-256-ctr', 'camellia-128-cfb', 'camellia-192-cfb', 'camellia-256-cfb', - 'bf-cfb', 'cast5-cfb', 'des-cfb', 'des-ede3-cfb', 'idea-cfb', - 'rc2-cfb', 'seed-cfb', 'salsa20', 'chacha20', 'chacha20-ietf', 'none', 'aes-128-gcm', 'aes-192-gcm', - 'aes-256-gcm', 'chacha20-ietf-poly1305', 'xchacha20-ietf-poly1305'); + 'aes-128-ctr', 'aes-192-ctr', 'aes-256-ctr', 'camellia-128-cfb', 'camellia-192-cfb', 'camellia-256-cfb', + 'bf-cfb', 'cast5-cfb', 'des-cfb', 'des-ede3-cfb', 'idea-cfb', + 'rc2-cfb', 'seed-cfb', 'salsa20', 'chacha20', 'chacha20-ietf', 'none', 'aes-128-gcm', 'aes-192-gcm', + 'aes-256-gcm', 'chacha20-ietf-poly1305', 'xchacha20-ietf-poly1305'); return $list; } } diff --git a/app/Utils/TelegramProcess.php b/app/Utils/TelegramProcess.php index 887ba6e..7daa1fa 100644 --- a/app/Utils/TelegramProcess.php +++ b/app/Utils/TelegramProcess.php @@ -16,7 +16,7 @@ class TelegramProcess 今日已使用 ".$user->TodayusedTraffic()." ".number_format(($user->u+$user->d-$user->last_day_t)/$user->transfer_enable*100, 2)."% 今日之前已使用 ".$user->LastusedTraffic()." ".number_format($user->last_day_t/$user->transfer_enable*100, 2)."% 未使用 ".$user->unusedTraffic()." ".number_format(($user->transfer_enable-($user->u+$user->d))/$user->transfer_enable*100, 2)."% - ", $parseMode = null, $disablePreview = false, $replyToMessageId = $reply_to); + ", $parseMode = null, $disablePreview = false, $replyToMessageId = $reply_to); break; case 'checkin': if (!$user->isAbleToCheckin()) { @@ -24,10 +24,10 @@ class TelegramProcess break; } $traffic = rand(Config::get('checkinMin'), Config::get('checkinMax')); - $user->transfer_enable = $user->transfer_enable + Tools::toMB($traffic); + $user->transfer_enable = $user->transfer_enable + Tools::toMB($traffic)*2; $user->last_check_in_time = time(); $user->save(); - $bot->sendMessage($message->getChat()->getId(), "天若有情天亦老,我为长者续一秒!获得了 ".$traffic." MB 流量!", $parseMode = null, $disablePreview = false, $replyToMessageId = $reply_to); + $bot->sendMessage($message->getChat()->getId(), "天若有情天亦老,我为长者续一秒!获得了 ".$traffic." MB 流量!因为我很喜欢你,所以多送你".$traffic." MB 流量!", $parseMode = null, $disablePreview = false, $replyToMessageId = $reply_to); break; default: $bot->sendMessage($message->getChat()->getId(), "???", $parseMode = null, $disablePreview = false, $replyToMessageId = $reply_to); @@ -40,11 +40,12 @@ class TelegramProcess public static function telegram_process($bot, $message, $command) { + $bot->sendChatAction($message->getChat()->getId(), 'typing'); + $user = User::where('telegram_id', $message->getFrom()->getId())->first(); if ($message->getChat()->getId() > 0) { //个人 - $bot->sendChatAction($message->getChat()->getId(), 'typing'); switch ($command) { case 'ping': @@ -68,7 +69,7 @@ class TelegramProcess /help 获取帮助信息 您可以在面板里点击 资料编辑 ,滑到页面最下方,就可以看到 Telegram 绑定指示了,绑定您的账号,更多精彩功能等着您去发掘。 - "; + "; $bot->sendMessage($message->getChat()->getId(), $help_list); break; default: @@ -167,8 +168,6 @@ class TelegramProcess return; } - $bot->sendChatAction($message->getChat()->getId(), 'typing'); - switch ($command) { case 'ping': $bot->sendMessage($message->getChat()->getId(), 'Pong!这个群组的 ID 是 '.$message->getChat()->getId().'!', $parseMode = null, $disablePreview = false, $replyToMessageId = $message->getMessageId()); diff --git a/app/Utils/Tools.php b/app/Utils/Tools.php index c25c6b2..dc1a207 100644 --- a/app/Utils/Tools.php +++ b/app/Utils/Tools.php @@ -73,7 +73,7 @@ class Tools public static function genRandomChar($length = 8) { // 密码字符集,可任意添加你需要的字符 - $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $chars = '123456789'; $char = ''; for ($i = 0; $i < $length; $i++) { $char .= $chars[mt_rand(0, strlen($chars) - 1)]; @@ -267,8 +267,6 @@ class Tools public static function is_protocol_relay($user) { - return true; - $relay_able_list = Config::getSupportParam('relay_able_protocol'); if (in_array($user->protocol, $relay_able_list) || Config::get('relay_insecure_mode') == 'true') { @@ -425,9 +423,4 @@ class Tools return true; } - - public static function getRealIp($rawIp) - { - return str_replace("::ffff:", "", $rawIp); - } } diff --git a/app/Utils/URL.php b/app/Utils/URL.php index bae5193..b557343 100644 --- a/app/Utils/URL.php +++ b/app/Utils/URL.php @@ -248,14 +248,14 @@ class URL $ss_obfs_list = Config::getSupportParam('ss_obfs'); if(!$is_ss) { - $ssurl = $item['address'].":".$item['port'].":".$item['protocol'].":".$item['method'].":".$item['obfs'].":".Tools::base64_url_encode($item['passwd'])."/?obfsparam=".Tools::base64_url_encode($item['obfs_param'])."&protoparam=".Tools::base64_url_encode($item['protocol_param'])."&remarks=".Tools::base64_url_encode($item['remark'])."&group=".Tools::base64_url_encode($item['group']); + $ssurl = $item['address'].":".$item['port'].":".$item['protocol'].":".$item['method'].":".$item['obfs'].":".Tools::base64_url_encode($item['passwd'])."/?obfsparam=".Tools::base64_url_encode($item['obfs_param'])."&protoparam=".Tools::base64_url_encode($item['protocol_param'])."&remarks=".Tools::base64_url_encode($item['remark'])."&group=".Tools::base64_url_encode(Config::get('appName')); return "ssr://".Tools::base64_url_encode($ssurl); } else { if($is_ss == 2) { $personal_info = $item['method'].':'.$item['passwd']."@".$item['address'].":".$item['port']; $ssurl = "ss://".Tools::base64_url_encode($personal_info); - $ssurl .= "#".rawurlencode($item['remark']); + $ssurl .= "#".rawurlencode(Config::get('appName')." - ".$item['remark']); }else{ $personal_info = $item['method'].':'.$item['passwd']; $ssurl = "ss://".Tools::base64_url_encode($personal_info)."@".$item['address'].":".$item['port']; @@ -275,7 +275,7 @@ class URL $ssurl .= "?plugin=".rawurlencode($plugin); } - $ssurl .= "#".rawurlencode($item['remark']); + $ssurl .= "#".rawurlencode(Config::get('appName')." - ".$item['remark']); } return $ssurl; } @@ -328,7 +328,6 @@ class URL * protocol_param * obfs * obfs_param - * group */ public static function getItem($user, $node, $mu_port = 0, $relay_rule_id = 0, $is_ss = 0) { @@ -381,10 +380,6 @@ class URL $return_array['protocol_param'] = $user->protocol_param; $return_array['obfs'] = $user->obfs; $return_array['obfs_param'] = $user->obfs_param; - $return_array['group'] = Config::get('appName'); - if($mu_port != 0) { - $return_array['group'] .= ' - 单端口多用户'; - } return $return_array; }