no_ymq_dev
laurieryayoi 8 years ago
commit d78523a64d

@ -8,10 +8,11 @@
- **商店**:商品增加同时连接设备数,用户限速属性
- 从肥羊那里**抄**来的:新用户注册现金奖励|高等级节点体验|设备数量限制
- **优化**:css和js等置入本地提升加载速度
- 增加**v2Ray** 功能,详情请看 [wiki](https://github.com/NimaQu/ss-panel-v3-mod_Uim/wiki/v2ray-%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B)
- 增加**v2Ray** 功能,详情请看 wiki: [Indexyz 版](https://github.com/Anankke/ss-panel-v3-mod_Uim/wiki/v2ray---indexyz-%E7%89%88%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B) | [Rico 版](https://github.com/Anankke/ss-panel-v3-mod_Uim/wiki/v2ray---Rico-%E7%89%88%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B)
Telegram 频道 :https://t.me/sspanel_Uim
Telegram 非官方水群 :https://t.me/SSUnion
演示站: [sspanel.host](https://sspanel.host) 账号和密码都是 admin 对接节点的 mukey=NimaQu

@ -62,7 +62,7 @@ class Job
}
else{
system('mysqldump --user='.Config::get('db_username').' --password='.Config::get('db_password').' --host='.$db_address_array[0].' '.(isset($db_address_array[1])?'-P '.$db_address_array[1]:'').' '.Config::get('db_database').' announcement auto blockip bought code coupon disconnect_ip link login_ip payback radius_ban shop speedtest ss_invite_code ss_node ss_password_reset ticket unblockip user user_token email_verify detect_list relay paylist> /tmp/ssmodbackup/mod.sql', $ret);
system('mysqldump --opt --user='.Config::get('db_username').' --password='.Config::get('db_password').' --host='.$db_address_array[0].' '.(isset($db_address_array[1])?'-P '.$db_address_array[1]:'').' -d '.Config::get('db_database').' alive_ip ss_node_info ss_node_online_log user_traffic_log detect_log telegram_session yft_order_info >> /tmp/ssmodbackup/mod.sql', $ret);
system('mysqldump --opt --user='.Config::get('db_username').' --password='.Config::get('db_password').' --host='.$db_address_array[0].' '.(isset($db_address_array[1])?'-P '.$db_address_array[1]:'').' -d '.Config::get('db_database').' alive_ip ss_node_info ss_node_online_log user_traffic_log detect_log telegram_session >> /tmp/ssmodbackup/mod.sql', $ret);
if (Config::get('enable_radius')=='true') {
$db_address_array = explode(':', Config::get('radius_db_host'));
system('mysqldump --user='.Config::get('radius_db_user').' --password='.Config::get('radius_db_password').' --host='.$db_address_array[0].' '.(isset($db_address_array[1])?'-P '.$db_address_array[1]:'').''.Config::get('radius_db_database').'> /tmp/ssmodbackup/radius.sql', $ret);

@ -6,16 +6,20 @@ use App\Models\User;
use App\Models\Code;
use App\Models\Ip;
use App\Models\RadiusBan;
use App\Models\Bought;
use App\Models\Relay;
use App\Controllers\AdminController;
use App\Services\Config;
use App\Services\Auth;
use App\Services\Mail;
use App\Utils;
use App\Utils\Hash;
use App\Utils\Radius;
use App\Utils\QQWry;
use App\Utils\Check;
use App\Utils\Tools;
class UserController extends AdminController
{
public function index($request, $response, $args)
@ -38,6 +42,136 @@ class UserController extends AdminController
$table_config['ajax_url'] = 'user/ajax';
return $this->view()->assign('table_config', $table_config)->display('admin/user/index.tpl');
}
public function createNewUser($request, $response, $args){
# 需要一个 userEmail
$email = $request->getParam('userEmail');
$email = trim($email);
$email = strtolower($email);
// check email format
if (!Check::isEmailLegal($email)) {
$res['ret'] = 0;
$res['msg'] = "邮箱无效";
return $response->getBody()->write(json_encode($res));
}
// check email
$user = User::where('email', $email)->first();
if ($user != null) {
$res['ret'] = 0;
$res['msg'] = "邮箱已经被注册了";
return $response->getBody()->write(json_encode($res));
}
// do reg user
$user = new User();
$pass = Tools::genRandomChar(8);
$user->user_name =$email;
$user->email = $email;
$user->pass = Hash::passwordHash($pass);
$user->passwd = Tools::genRandomChar(6);
$user->port = Tools::getAvPort();
$user->t = 0;
$user->u = 0;
$user->d = 0;
$user->method = Config::get('reg_method');
$user->protocol = Config::get('reg_protocol');
$user->protocol_param = Config::get('reg_protocol_param');
$user->obfs = Config::get('reg_obfs');
$user->obfs_param = Config::get('reg_obfs_param');
$user->forbidden_ip = Config::get('reg_forbidden_ip');
$user->forbidden_port = Config::get('reg_forbidden_port');
$user->im_type = 2;
$user->im_value = $email;
$user->transfer_enable = Tools::toGB(Config::get('defaultTraffic'));
$user->invite_num = Config::get('inviteNum');
$user->auto_reset_day = Config::get('reg_auto_reset_day');
$user->auto_reset_bandwidth = Config::get('reg_auto_reset_bandwidth');
$user->money = 0;
$user->class_expire = date("Y-m-d H:i:s", time() + Config::get('user_class_expire_default') * 3600);
$user->class = Config::get('user_class_default');
$user->node_connector = Config::get('user_conn');
$user->node_speedlimit = Config::get('user_speedlimit');
$user->expire_in = date("Y-m-d H:i:s", time() + Config::get('user_expire_in_default') * 86400);
$user->reg_date = date("Y-m-d H:i:s");
$user->reg_ip = $_SERVER["REMOTE_ADDR"];
$user->plan = 'A';
$user->theme = Config::get('theme');
$groups=explode(",", Config::get('ramdom_group'));
$user->node_group=$groups[array_rand($groups)];
$ga = new GA();
$secret = $ga->createSecret();
$user->ga_token = $secret;
$user->ga_enable = 0;
if ($user->save()) {
$res['ret'] = 1;
$res['msg'] = "新用户注册成功 用户名: ".$email." 随机初始密码: ".$pass;
$res['email_error']="success";
$subject = Config::get('appName')."-新用户注册通知";
$to = $user->email;
$text = "您好,管理员已经为您生成账户,用户名: ".$email.",登录密码为:". $pass.",感谢您的支持。 " ;
try {
Mail::send($to, $subject, 'newuser.tpl', [
"user" => $user,"text" => $text
], [
]);
} catch (\Exception $e) {
$res['email_error'] = $e->getMessage();
}
return $response->getBody()->write(json_encode($res));
}
$res['ret'] = 0;
$res['msg'] = "未知错误";
return $response->getBody()->write(json_encode($res));
}
public function buy($request, $response, $args){
#shop 信息可以通过 App\Controllers\UserController:shop 获得
# 需要shopId,disableothers,autorenew,userEmail
$shopId = $request->getParam('shopId');
$shop = Shop::where("id", $shopId)->where("status", 1)->first();
$disableothers = $request->getParam('disableothers');
$autorenew = $request->getParam('autorenew');
$email=$request->getParam("userEmail");
$user = User::where("email",'=', $email)->first();
if ($user==null){
$result['ret'] = 0;
$result['msg'] = "未找到该用户";
return $response->getBody()->write(json_encode($result));
}
if ($shop == null) {
$result['ret'] = 0;
$result['msg'] = "请选择套餐";
return $response->getBody()->write(json_encode($result));
}
if ($disableothers == 1) {
$boughts = Bought::where("userid", $user->id)->get();
foreach ($boughts as $disable_bought) {
$disable_bought->renew = 0;
$disable_bought->save();
}
}
$bought = new Bought();
$bought->userid = $user->id;
$bought->shopid = $shop->id;
$bought->datetime = time();
if ($autorenew == 0 || $shop->auto_renew == 0) {
$bought->renew = 0;
} else {
$bought->renew = time() + $shop->auto_renew * 86400;
}
$price = $shop->price;
$bought->price = $price;
$bought->save();
$shop->buy($user);
$result['ret'] = 1;
$result['msg'] = "套餐添加成功";
return $response->getBody()->write(json_encode($result));
}
public function search($request, $response, $args)
{

@ -60,12 +60,12 @@ class Mail
* @param $subject
* @param $template
* @param $ary
* @param $file
* @param $files
* @return bool|void
*/
public static function send($to, $subject, $template, $ary = [], $file = [])
public static function send($to, $subject, $template, $ary = [], $files = [])
{
$text = self::genHtml($template, $ary);
return self::getClient()->send($to, $subject, $text, $file);
return self::getClient()->send($to, $subject, $text, $files);
}
}

@ -29,16 +29,30 @@ class Mailgun extends Base
];
}
public function send($to, $subject, $text, $file)
public function send($to, $subject, $text, $files)
{
$this->mg->messages()->send($this->domain,[
$inline=array();
foreach($files as $file){
array_push($inline,array('filePath'=>$file, 'filename'=>basename($file)));
}
if(count($inline)==0){
$this->mg->messages()->send($this->domain,[
'from' => $this->sender,
'to' => $to,
'subject' => $subject,
'html' => $text
],[
'inline' => $file
]
);
]
);
}
else{
$this->mg->messages()->send($this->domain,[
'from' => $this->sender,
'to' => $to,
'subject' => $subject,
'html' => $text,
'inline' => $inline
]
);
}
}
}

@ -37,7 +37,7 @@ class SendGrid extends Base
$attachment = new \SendGrid\Attachment();
$attachment->setContent(base64_encode(file_get_contents($file)));
$attachment->setType("application/octet-stream");
$attachment->setFilename("backup.zip");
$attachment->setFilename(basename($file));
$attachment->setDisposition("attachment");
$attachment->setContentId("backup");
$mail->addAttachment($attachment);

@ -293,6 +293,8 @@ $app->group('/admin', function () {
$this->delete('/user', 'App\Controllers\Admin\UserController:delete');
$this->post('/user/changetouser', 'App\Controllers\Admin\UserController:changetouser');
$this->post('/user/ajax', 'App\Controllers\Admin\UserController:ajax');
$this->post('/user/create', 'App\Controllers\Admin\UserController:createNewUser');
$this->post('/user/buy', 'App\Controllers\Admin\UserController:buy');
$this->get('/coupon', 'App\Controllers\AdminController:coupon');

@ -0,0 +1,182 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<head>
<meta name="viewport" content="width=device-width"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Billing e.g. invoices and receipts</title>
<style type="text/css">
img {
max-width: 100%;
}
body {
-webkit-font-smoothing: antialiased;
-webkit-text-size-adjust: none;
width: 100% !important;
height: 100%;
line-height: 1.6em;
}
body {
background-color: #f6f6f6;
}
@media only screen and (max-width: 640px) {
body {
padding: 0 !important;
}
h1 {
font-weight: 800 !important;
margin: 20px 0 5px !important;
}
h2 {
font-weight: 800 !important;
margin: 20px 0 5px !important;
}
h3 {
font-weight: 800 !important;
margin: 20px 0 5px !important;
}
h4 {
font-weight: 800 !important;
margin: 20px 0 5px !important;
}
h1 {
font-size: 22px !important;
}
h2 {
font-size: 18px !important;
}
h3 {
font-size: 16px !important;
}
.container {
padding: 0 !important;
width: 100% !important;
}
.content {
padding: 0 !important;
}
.content-wrap {
padding: 10px !important;
}
.invoice {
width: 100% !important;
}
}
</style>
</head>
<body itemscope itemtype="http://schema.org/EmailMessage"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em; background-color: #f6f6f6; margin: 0;"
bgcolor="#f6f6f6">
<table class="body-wrap"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; background-color: #f6f6f6; margin: 0;"
bgcolor="#f6f6f6">
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;"
valign="top"></td>
<td class="container" width="600"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto;"
valign="top">
<div class="content"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; max-width: 600px; display: block; margin: 0 auto; padding: 20px;">
<table class="main" width="100%" cellpadding="0" cellspacing="0"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;"
bgcolor="#fff">
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-wrap aligncenter"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: center; margin: 0; padding: 20px;"
align="center" valign="top">
<table width="100%" cellpadding="0" cellspacing="0"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-block"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;"
valign="top">
<h1 class="aligncenter"
style="font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; box-sizing: border-box; font-size: 32px; color: #000; line-height: 1.2em; font-weight: 500; text-align: center; margin: 40px 0 0;"
align="center">{$config["appName"]}</h1>
</td>
</tr>
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-block"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;"
valign="top">
<h2 class="aligncenter"
style="font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; box-sizing: border-box; font-size: 24px; color: #000; line-height: 1.2em; font-weight: 400; text-align: center; margin: 40px 0 0;"
align="center">您的账户已经生成</h2>
</td>
</tr>
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-block aligncenter"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: center; margin: 0; padding: 0 0 20px;"
align="center" valign="top">
<table class="invoice"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; text-align: left; width: 80%; margin: 40px auto;">
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 5px 0;"
valign="top">Hi, {$user->user_name}<br
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"/>邮箱: {$user->email}
</td>
</tr>
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 5px 0;"
valign="top">{$text}
</td>
</tr>
</table>
</td>
</tr>
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-block aligncenter"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: center; margin: 0; padding: 0 0 20px;"
align="center" valign="top">
<a href="{$config["baseUrl"]}"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; color: #348eda; text-decoration: underline; margin: 0;">{$config["appName"]}</a>
</td>
</tr>
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-block aligncenter"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; text-align: center; margin: 0; padding: 0 0 20px;"
align="center" valign="top">
</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="footer"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; clear: both; color: #999; margin: 0; padding: 20px;">
<table width="100%"
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
</tr>
</table>
</div>
</div>
</td>
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;"
valign="top"></td>
</tr>
</table>
</body>
</html>

@ -391,7 +391,7 @@
{if $user->discord == 0}
<p>私聊发给 Discord 机器人 以绑定 Discord</p>
{/if}
{/if}
<div class="form-group form-group-label">
<div class="text-center">
<div id="telegram-qr" class="qr-center"></div>

Loading…
Cancel
Save