Skip to content

Commit

Permalink
update databaes
Browse files Browse the repository at this point in the history
  • Loading branch information
sendya committed Mar 23, 2016
1 parent 2b248aa commit dab2219
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Data/Shadowsocks-planel-DB.sql
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,7 @@ INSERT INTO `node` (`id`, `name`, `type`, `server`, `method`, `info`, `status`,
INSERT INTO `message` (`id`, `content`, `pushTime`, `addTime`, `pushUsers`, `type`, `pushEndTime`, `order`) VALUES ('1000', '公告:<br/>由于服务器遭到攻击,为补偿用户。本月不计费。(悲剧的事情莫过于挂SS主站的服务器居然被封了25端口)<br/>', '1457320205', '1457320205', '-1', '-2', '1488856205', '0');
INSERT INTO `message` (`id`, `content`, `pushTime`, `addTime`, `pushUsers`, `type`, `pushEndTime`, `order`) VALUES ('1001', '套餐等级如下:<br /><br />套餐A: 5GB(免费) (体验服务)<br />套餐B: 100GB(13RMB)<br />套餐C: 200GB(20RMB)<br />套餐D: 500GB(35RMB)<br /><br />套餐VIP: 无限制流量,优先端口转发(仅内部开放)', '1457320205', '1457320205', '-1', '-3', '1488856205', '0');
INSERT INTO `message` (`id`, `content`, `pushTime`, `addTime`, `pushUsers`, `type`, `pushEndTime`, `order`) VALUES ('1002', '首页浮动提示公告测试。。', '0', '0', '-1', '-4', '0', '0');

UPDATE `message` SET `pushUsers`='-2', `type`='-2', WHERE (`id`='1000');
UPDATE `message` SET `pushUsers`='-2', `type`='-3', WHERE (`id`='1001');
UPDATE `message` SET `pushUsers`='-2', `type`='-4', WHERE (`id`='1002');
2 changes: 1 addition & 1 deletion Library/Controller/Admin/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Message extends AdminListener {
public function index() {
global $user;

$lists = MessageModel::GetPushMsg();
$lists = MessageModel::GetPushMsg(-1);

include Template::load('/admin/message');
}
Expand Down
2 changes: 1 addition & 1 deletion Library/Controller/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function buyInvite() {
$user->transfer = $user->transfer - $tr;
$user->invite_num = $user->invite_num + 1;
$user->updateUser();
$result = array('error' => 0, 'message' => '购买成功,扣除手续费10GB流量');
$result = array('error' => 0, 'message' => '购买成功,扣除手续费10GB流量', 'invite_num' => $user->invite_num);
}
echo json_encode($result);
exit();
Expand Down
6 changes: 4 additions & 2 deletions Library/Model/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public static function GetMessageById($msgId) {
* @return message[]
*/
public static function GetPushMsg($pushEndTime = 0) {
if ($pushEndTime == 0) $pushEndTime = time();
if ($pushEndTime == 0)
$pushEndTime = time();

$statement = Database::prepare("SELECT * FROM message WHERE pushEndTime>?");
$statement->bindValue(1, $pushEndTime);
$statement->execute();
Expand All @@ -64,7 +66,7 @@ public static function GetPushMsgByUserId($userId = "-1") {
* @return message list
*/
public static function GetGlobalMessage() {
$statement = Database::prepare("SELECT * FROM message WHERE pushUsers=-1 AND type BETWEEN -5 AND -2 ORDER BY id ASC");
$statement = Database::prepare("SELECT * FROM message WHERE pushUsers=-2 AND type BETWEEN -5 AND -2 ORDER BY id ASC");
$statement->execute();
$list = $statement->fetchAll(\PDO::FETCH_CLASS, '\\Model\\Message');
return $list;
Expand Down
6 changes: 6 additions & 0 deletions Template/Default/admin/_header.htm
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ <h4>
</li>
</ul>
</li>
<li class="{(\Helper\Util::CheckAction('message'))}">
<a href="/admin/message" class="pjax">
<i class="linecons-comment "></i>
<span class="title">消息管理</span>
</a>
</li>
<li>
<a href="/Member">
<i class="fa-mail-reply"></i>
Expand Down
211 changes: 211 additions & 0 deletions Template/Default/admin/message.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
<import template="/admin/_header" />
<import template="/admin/_content" />

<div class="page-title">
<div class="title-env">
<h1 class="title" onclick="messageAdd();">消息管理
<a class="btn btn-success btn-sm" href="javascript:;" onclick="">添加</a></h1>
<p class="description">请注意消息的分类!</p>
</div>
<div class="breadcrumb-env">
<ol class="breadcrumb bc-1"><li><a href="/admin"><i class="fa-home"></i>管理端</a></li><li><a href="/admin/message">消息管理</a></li></ol>
</div>
</div>
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tbody>
<tr>
<th>ID</th>
<th>内容</th>
<th>结束推送时间</th>
<th>推送至</th>
<th>类型</th>
<th>操作</th>
</tr>
<if condition="count($lists) > 0">
<loop variable="$lists" key="$key" value="$msg">
<tr id="msg-{$msg->id}">
<td>#{$msg->id}</td>
<td> {(mb_substr(htmlspecialchars($msg->content),0,20,'utf-8'))}</td>
<td> {(date("Y-m-d H:i:s", $msg->pushEndTime))}</td>
<td><if condition="$msg->pushUsers == -1">系统消息<elseif condition="$msg->pushUsers == -2">系统固定消息<else>推送值特定用户</if></td>
<td><if condition="$msg->type == -1">重复推送<elseif condition="$msg->type == -2">系统公告<elseif condition="$msg->type == -3">套餐处说明<elseif condition="$msg->type == -4">首页浮动提示<else>普通消息</if></td>
<td>
<a class="btn btn-info btn-sm" href="javascript:;" onclick="messageModify({$msg->id});">编辑</a>
<if condition="$msg->pushUsers != -2">
<a class="btn btn-danger btn-sm" href="javascript:;" onclick="messageRemove({$msg->id});">删除</a>
</if>
</td>
</tr>
</loop>
<else>
<tr>
<td>#</td>
<td colspan="5">没有节点</td>
</tr>
</if>
</tbody>
</table>
</div><!-- /.box-body -->
</div><!-- /.box -->
</div>
</div>
</section>
</div>
</div>
<!-- Modal 6 (Long Modal)-->
<div class="modal fade" id="modal-6">
<div class="modal-dialog">
<div class="modal-content">

<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">新增节点</h4>
</div>
<form role="form" id="form1" method="post" action="/admin/node/add" class="validate" onsubmit="return postJSON(this.id, this.action);">
<input type="hidden" name="form_add" value="{(time())}"/>
<input type="hidden" name="node.id" id="node_id" value=""/>
<div class="modal-body">

<div class="row">
<div class="col-md-6">

<div class="form-group">
<label for="field-1" class="control-label">节点名称</label>

<input type="text" class="form-control" name="node.name" id="field-1" value="" data-validate="required" data-message-required="节点名称必须填写.">
</div>

</div>

<div class="col-md-6">

<div class="form-group">
<label for="field-2" class="control-label">节点地址</label>

<input type="text" class="form-control" name="node.server" id="field-2" placeholder="127.0.0.1" data-validate="required" data-message-required="服务器地址必须填写.">
</div>

</div>
</div>

<div class="row">
<div class="col-md-6">

<div class="form-group">
<label for="field-3" class="control-label">加密方式</label>

<input type="text" class="form-control" name="node.method" id="field-3" placeholder="aes-128-cfb" data-validate="required" data-message-required="加密方式必须填写.">
</div>

</div>

<div class="col-md-6">

<div class="form-group">
<label for="field-4" class="control-label">节点分类(0 普通 1 vip)</label>

<input type="text" class="form-control" name="node.type" id="field-4" value="0" placeholder="0" data-validate="required" data-message-required="This is custom message for required field.">
</div>

</div>
</div>

<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="field-5" class="control-label">节点状态</label>
<input type="text" class="form-control" name="node.status" id="field-5" placeholder="可用 / 不可用" data-validate="required" data-message-required="This is custom message for required field.">
</div>
</div>

<div class="col-md-6">
<div class="form-group">
<label for="field-6" class="control-label">排序</label>
<input type="text" class="form-control" name="node.order" id="field-6" value="0" placeholder="0" data-validate="required" data-message-required="This is custom message for required field.">
</div>
</div>
</div>

<div class="row">
<div class="col-md-12">
<div class="form-group no-margin">
<label for="field-7" class="control-label">备注信息</label>
<textarea class="form-control autogrow" name="node.info" id="field-7" placeholder="Write something about server info" ></textarea>
</div>
</div>
</div>

</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
<button type="submit" class="btn btn-success">立即保存</button>
</div>
</form>
</div>

</div>
</div>
<script type="text/javascript">
function nodeRemove(nodeId){
$.ajax({
url: "/admin/node/delete",
method: "POST",
dataType: "json",
data: {node_id: nodeId},
success: function(data){
if(data.error == 0){
showToastr(data.message, 0);
$("#node-" + nodeId).remove();
} else {
showToastr(data.message, 0);
}
},
error: function(Xhr){
showToastr("出现未知错误,请重试或联系管理员", 0);
}
});
}
function nodeModify(nodeId){
$.ajax({
url: "/admin/node/nodeInfo",
method: "GET",
dataType: "json",
data: {node_id: nodeId},
success: function(result){
if(result.error == 0){
if(result.data != false && result.data != null) {
var node = result.data;
$("input[name='node.id']").val(node.id);
$("input[name='node.name']").val(node.name);
$("input[name='node.type']").val(node.type);
$("input[name='node.server']").val(node.server);
$("input[name='node.method']").val(node.method);
$("textarea[name='node.info']").val(node.info);
$("input[name='node.status']").val(node.status);
$("input[name='node.order']").val(node.order);
$("#form1").attr("action", "/admin/node/modify");
jQuery('#modal-6 .modal-title').html('修改节点');
jQuery('#modal-6').modal('show', {backdrop: 'static'});
}
} else {
showToastr(result.message, 0);
}
},
error: function(Xhr){
showToastr("出现未知错误,请重试或联系管理员", 0);
}
});
jQuery('#modal-6').modal('show', {backdrop: 'static'});
}
function nodeAdd(){
$("#form1").attr("action", "/admin/node/add");
jQuery('#modal-6 .modal-title').html('新增节点');
jQuery('#modal-6').modal('show', {backdrop: 'static'});
}
</script>
<import template="/admin/_footer" />
6 changes: 4 additions & 2 deletions Template/Default/panel/invite.htm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="title-env">
<h1 class="title">邀请码</h1>
<p class="description"><if condition="$user->invite_num == 0">查看自己的邀请码<else>当前您可以生成<code>{$user->invite_num}</code>个邀请码。</if></p>
<p class="description"><if condition="$user->invite_num == 0">查看自己的邀请码<else>当前您可以生成<code id="invitec_num2">{$user->invite_num}</code>个邀请码。</if></p>
</div>

<div class="breadcrumb-env">
Expand All @@ -23,7 +23,7 @@ <h1 class="title">邀请码</h1>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<a class="btn btn-danger btn-sm invitec<if condition="$user->invite_num != 0"> hidden</if>" href="javascript:;" style="color:#FFF;">生成邀请码</a>&nbsp;<a class="btn btn-danger btn-sm inviteFlow" href="javascript:;" style="color:#FFF;">用流量购买邀请码</a>
<a class="btn btn-danger btn-sm invitec<if condition="$user->invite_num <= 0"> hidden</if>" href="javascript:;" style="color:#FFF;">生成邀请码(余 <span id="invitec_num">{$user->invite_num}</span> 次)</a>&nbsp;<a class="btn btn-danger btn-sm inviteFlow" href="javascript:;" style="color:#FFF;">用流量购买邀请码生成次数</a>
</h3>
</div>
<div class="panel-body">
Expand Down Expand Up @@ -107,6 +107,8 @@ <h4>注意!</h4>
if(data.error == 0){
showToastr(data.message, 0, 5000);
$(".invitec").removeClass("hidden");
$("#invitec_num").html(data.invite_num);
$("#invitec_num2").html(data.invite_num);
}else{
//$("#msg-error").show();
//$("#msg-error-p").html(data.msg);
Expand Down

0 comments on commit dab2219

Please sign in to comment.