Skip to content

Commit

Permalink
Merge pull request #13 from NimaQu/dev
Browse files Browse the repository at this point in the history
pull
  • Loading branch information
willamblack authored Nov 29, 2018
2 parents 919b6e5 + dbe8427 commit b44ec86
Show file tree
Hide file tree
Showing 20 changed files with 112 additions and 117 deletions.
38 changes: 0 additions & 38 deletions app/Command/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,46 +425,8 @@ public static function CheckJob()
BlockIp::where("datetime", "<", time()-86400)->delete();
TelegramSession::where("datetime", "<", time()-900)->delete();


$adminUser = User::where("is_admin", "=", "1")->get();

$latest_content = file_get_contents("https://raw.githubusercontent.com/NimaQu/ss-panel-v3-mod_uim/master/bootstrap.php");
$newmd5 = md5($latest_content);
$oldmd5 = md5(file_get_contents(BASE_PATH."/bootstrap.php"));

if ($latest_content!="") {
if ($newmd5 == $oldmd5) {
if (file_exists(BASE_PATH."/storage/update.md5")) {
unlink(BASE_PATH."/storage/update.md5");
}
} else {
if (!file_exists(BASE_PATH."/storage/update.md5")) {
foreach ($adminUser as $user) {
echo "Send mail to user: ".$user->id;
$subject = Config::get('appName')."-系统提示";
$to = $user->email;
$text = "管理员您好,系统发现有了新版本,您可以到 <a href=\"https://github.com/NimaQu/ss-panel-v3-mod_Uim/wiki/%E5%8D%87%E7%B4%9A%E7%89%88%E6%9C%AC\">https://github.com/NimaQu/ss-panel-v3-mod_Uim/wiki/%E5%8D%87%E7%B4%9A%E7%89%88%E6%9C%AC</a> 按照步骤进行升级。" ;
try {
Mail::send($to, $subject, 'news/warn.tpl', [
"user" => $user,"text" => $text
], [
]);
} catch (\Exception $e) {
echo $e->getMessage();
}
}

Telegram::Send("姐姐姐姐,面板程序有更新了呢~看看你的邮箱吧~");

$myfile = fopen(BASE_PATH."/storage/update.md5", "w+") or die("Unable to open file!");
$txt = "1";
fwrite($myfile, $txt);
fclose($myfile);
}
}
}


//节点掉线检测
if (Config::get("enable_detect_offline")=="true") {
$nodes = Node::all();
Expand Down
4 changes: 2 additions & 2 deletions app/Command/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public static function migrateConfig()

echo(PHP_EOL);

echo('开始升级ssrdownload...');
echo('开始升级ssrdownload...'.PHP_EOL);
Job::updatedownload();
echo('升级ssrdownload结束');
echo('升级ssrdownload结束'.PHP_EOL);

echo(PHP_EOL);

Expand Down
1 change: 0 additions & 1 deletion app/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ public function sendVerify($request, $response, $next)
return $response->getBody()->write(json_encode($res));
}


$user = User::where('email', '=', $email)->first();
if ($user != null) {
$res['ret'] = 0;
Expand Down
1 change: 0 additions & 1 deletion app/Controllers/Mod_Mu/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use App\Models\DetectLog;
use App\Controllers\BaseController;
use App\Utils\Tools;
use Ramsey\Uuid\Uuid;

class UserController extends BaseController
{
Expand Down
2 changes: 2 additions & 0 deletions app/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,8 @@ public function doCheckIn($request, $response, $args)
$this->user->last_check_in_time = time();
$this->user->save();
$res['msg'] = sprintf("获得了 %d MB流量.", $traffic);
$res['unflowtraffic'] = $this->user->transfer_enable;
$res['traffic'] = Tools::flowAutoShow($this->user->transfer_enable);
$res['ret'] = 1;
return $this->echoJson($response, $res);
}
Expand Down
23 changes: 9 additions & 14 deletions app/Models/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,17 @@ public function getTrafficFromLogs()

public function isNodeOnline()
{
$node_heartbeat = $this->attributes['node_heartbeat'];
$result = false;
$id = $this->attributes['id'];
$sort = $this->attributes['sort'];

if (!($sort == 0 || $sort == 7 || $sort == 8 || $sort==10 || $sort==11)) {
return null;
}

if ($node_heartbeat == 0) {
return null;
}

if (time() - $node_heartbeat > 300) {
return false;
} else {
return true;
$node_heartbeat = $this->attributes['node_heartbeat'];
$log = NodeOnlineLog::where('node_id', $id)->where("log_time",">",time()-300)->orderBy('id', 'desc')->first();
if(!($sort == 0 || $sort == 7 || $sort == 8 || $sort==10 || $sort==11) || $node_heartbeat == 0){
$result = null;
}else if ($log != null && $log->log_time + 300 > time()) {
$result = true;
}
return $result;
}

public function isNodeTrafficOut()
Expand Down
8 changes: 3 additions & 5 deletions app/Services/Mail/Mailgun.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Mailgun extends Base
public function __construct()
{
$this->config = $this->getConfig();
$this->mg = new MailgunService($this->config["key"]);
$this->mg = MailgunService::create($this->config["key"]);
$this->domain = $this->config["domain"];
$this->sender = $this->config["sender"];
}
Expand All @@ -31,14 +31,12 @@ public function getConfig()

public function send($to, $subject, $text, $file)
{
$this->mg->sendMessage($this->domain,
[
$this->mg->messages()->send($this->domain,[
'from' => $this->sender,
'to' => $to,
'subject' => $subject,
'html' => $text
],
[
],[
'inline' => $file
]
);
Expand Down
2 changes: 1 addition & 1 deletion app/Utils/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Check
//
public static function isEmailLegal($email)
{
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
if (filter_var($email, FILTER_VALIDATE_EMAIL)&&strlen($email)<=32) {
return true;
} else {
return false;
Expand Down
31 changes: 16 additions & 15 deletions config/.config.php.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@ $System_Config['version']='0'; //仅当涉及【需要修改config以外的文


//基本设置--------------------------------------------------------------------------------------------
$System_Config['key'] = '1145141919810'; //!!! 瞎 jb 修改此key为随机字符串确保网站安全 !!!
$System_Config['debug'] = 'false'; //正式环境请确保为 false
$System_Config['appName'] = 'sspanel'; //站点名称
$System_Config['baseUrl'] = 'http://url.com'; //站点地址
$System_Config['subUrl'] = $System_Config['baseUrl'].'/link/'; //订阅地址
$System_Config['appStartTime'] = '2018'; //站点成立时间,显示在页脚 copyright 部分
$System_Config['muKey'] = 'NimaQu'; //用于校验ss-go mu的请求,可以随意修改,但请保持前后端一致
$System_Config['db_driver'] = 'mysql'; //数据库程序
$System_Config['db_host'] = 'localhost'; //数据库地址
$System_Config['db_database'] = 'sspanel'; //数据库名
$System_Config['db_username'] = 'root'; //数据库用户名
$System_Config['db_password'] = 'sspanel'; //用户名对应的密码
$System_Config['key'] = '1145141919810'; //!!! 瞎 jb 修改此key为随机字符串确保网站安全 !!!
$System_Config['debug'] = 'false'; //正式环境请确保为 false
$System_Config['appName'] = 'sspanel'; //站点名称
$System_Config['baseUrl'] = 'http://url.com'; //站点地址
$System_Config['subUrl'] = $System_Config['baseUrl'].'/link/'; //订阅地址
$System_Config['appStartTime'] = '2018'; //站点成立时间,显示在页脚 copyright 部分
$System_Config['muKey'] = 'NimaQu'; //用于校验ss-go mu的请求,可以随意修改,但请保持前后端一致
$System_Config['db_driver'] = 'mysql'; //数据库程序
$System_Config['db_host'] = 'localhost'; //数据库地址
$System_Config['db_database'] = 'sspanel'; //数据库名
$System_Config['db_username'] = 'root'; //数据库用户名
$System_Config['db_password'] = 'sspanel'; //用户名对应的密码


//邮件设置--------------------------------------------------------------------------------------------
$System_Config['mailDriver'] = 'mailgun'; // mailgun or smtp or sendgrid 选择发送邮件的方式
$System_Config['sendPageLimit']= 50; //发信分页 解决大站发公告超时问题
$System_Config['mailDriver'] = 'none'; //发送邮件方式:none / mailgun / smtp / sendgrid
$System_Config['sendPageLimit']= 50; //发信分页 解决大站发公告超时问题

# mailgun
$System_Config['mailgun_key'] = '';
$System_Config['mailgun_domain'] = '';
Expand Down Expand Up @@ -114,7 +115,7 @@ $System_Config['account_expire_delete_days']='-1'; //账户到期几天之后
$System_Config['enable_kill']='true'; //是否允许用户注销账户
$System_Config['notify_limit_mode'] = 'false'; //false为关闭,per为按照百分比提醒,mb为按照固定剩余流量提醒
$System_Config['notify_limit_value'] = '20'; //当上一项为per时,此处填写百分比;当上一项为mb时,此处填写流量
$System_Config['mergeSub'] = false; //合并订阅设置 可选项 false / true
$System_Config['mergeSub'] = false; //合并订阅设置 可选项 false / true


//Telegram bot设置------------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions public/theme/material/css/base.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -6453,6 +6453,9 @@ code.form-control {

i {
user-select: none;
-moz-user-select:none;
-webkit-user-select:none;
-ms-user-select:none;
}


Expand Down
5 changes: 5 additions & 0 deletions public/theme/material/css/project.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,11 @@ a.tag-gold,.tag-gold {
color: #faad14;
border-color: #ffe58f;
}
a.tag-red,.tag-red {
background: #fff1f0;
color: #f5222d;
border-color: #ffa39e;
}

.card-invite .form-group-label {
margin-bottom: 16px;
Expand Down
8 changes: 7 additions & 1 deletion public/theme/material/js/project.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ $(function(){
$(this).parent().addClass('control-highlight-custom');
});

$('button[data-toggle=dropdown]').blur(function(){
if ($(this)[0].innerText=='') {
$(this).parent().removeClass('control-highlight-custom');
}
});

$('.dropdown-option').click(function(){
var dropdownID = $(this).attr('data');
$('#' + dropdownID).text($(this).text());
Expand All @@ -28,7 +34,7 @@ $(function(){

});

// 传入两个对象,分别为点击的按钮和要弹出的部分
// 传入两个对象,分别为点击的按钮和要弹出的部分
// 传入两个数组循环调用即可实现多个按钮绑定对应模态框
function custModal(button,modal) {

Expand Down
2 changes: 1 addition & 1 deletion resources/views/material/auth/register.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
<div class="auth-row">
<div class="form-group-label auth-row">
<label class="floating-label" for="email">邮箱(唯一凭证请认真对待)</label>
<input class="form-control maxwidth-auth" id="email" type="text">
<input class="form-control maxwidth-auth" id="email" type="text" maxlength="32">
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/material/footer.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<!-- js -->
<script src="https://cdn.jsdelivr.net/npm/jquery@2.2.1"></script>
{if $geetest_html != null}
{if isset($geetest_html)}
<script src="//static.geetest.com/static/tools/gt.js"></script>
{/if}
<script src="/theme/material/js/base.min.js"></script>
Expand Down
15 changes: 5 additions & 10 deletions resources/views/material/user/edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<div class="form-group form-group-label control-highlight-custom dropdown">
<label class="floating-label" for="method">加密方式</label>
<button id="method" class="form-control maxwidth-edit" data-toggle="dropdown" value="{$user->method}">
[{if URL::CanMethodConnect($method) == 2}SS/SSD{else}SS/SSR{/if} 可连接]
[{if URL::CanMethodConnect($user->method) == 2}SS/SSD{else}SS/SSR{/if} 可连接]
</button>
<ul class="dropdown-menu" aria-labelledby="method">
{$method_list = $config_service->getSupportParam('method')}
Expand Down Expand Up @@ -124,11 +124,7 @@
<div class="form-group form-group-label control-highlight-custom dropdown">
<label class="floating-label" for="imtype">选择您的联络方式</label>
<button class="form-control maxwidth-edit" id="imtype" data-toggle="dropdown" value="{$user->im_type}">
{* <option></option>
<option value="1">微信</option>
<option value="2">QQ</option>
<option value="3">Google+</option>
<option value="4">Telegram</option> *}

</button>
<ul class="dropdown-menu" aria-labelledby="imtype">
<li><a href="#" class="dropdown-option" onclick="return false;" val="1" data="imtype">微信</a></li>
Expand Down Expand Up @@ -163,7 +159,7 @@
<div class="form-group form-group-label control-highlight-custom dropdown">
<label class="floating-label" for="protocol">协议</label>
<button id="protocol" class="form-control maxwidth-edit" data-toggle="dropdown" value="{$user->protocol}">
[{if URL::CanProtocolConnect($protocol) == 3}SS/SSD/SSR{else}SSR{/if} 可连接]
[{if URL::CanProtocolConnect($user->protocol) == 3}SS/SSD/SSR{else}SSR{/if} 可连接]
</button>
<ul class="dropdown-menu" aria-labelledby="protocol">
{$protocol_list = $config_service->getSupportParam('protocol')}
Expand All @@ -183,7 +179,7 @@
<div class="form-group form-group-label control-highlight-custom dropdown">
<label class="floating-label" for="obfs">混淆方式</label>
<button id="obfs" class="form-control maxwidth-edit" data-toggle="dropdown" value="{$user->obfs}">
[{if URL::CanObfsConnect($obfs) >= 3}SS/SSD/SSR{else}{if URL::CanObfsConnect($obfs) == 1}SSR{else}SS/SSD{/if}{/if} 可连接]
[{if URL::CanObfsConnect($user->obfs) >= 3}SS/SSD/SSR{elseif URL::CanObfsConnect($user->obfs) == 1}SSR{else}SS/SSD{/if} 可连接]
</button>
<ul class="dropdown-menu" aria-labelledby="obfs">
{$obfs_list = $config_service->getSupportParam('obfs')}
Expand Down Expand Up @@ -299,8 +295,7 @@
<div class="form-group form-group-label control-highlight-custom dropdown">
<label class="floating-label" for="ga-enable">验证设置</label>
<button type="button" id="ga-enable" class="form-control maxwidth-edit" data-toggle="dropdown" value="{$user->ga_enable}">
{* <option value="0">不要求</option>
<option value="1">要求验证</option> *}

</button>
<ul class="dropdown-menu" aria-labelledby="ga-enable">
<li><a href="#" class="dropdown-option" onclick="return false;" val="0" data="ga-enable">不要求</a> </li>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/material/user/footer.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<!-- js -->
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.17.0"></script>
{if $geetest_html != null}
{if isset($geetest_html)}
<script src="//static.geetest.com/static/tools/gt.js"></script>
{/if}
<script src="/theme/material/js/base.min.js"></script>
Expand Down
Loading

0 comments on commit b44ec86

Please sign in to comment.