Skip to content

Commit

Permalink
Update & Fix Option,Node,Message,Mail,Cron
Browse files Browse the repository at this point in the history
  • Loading branch information
sendya committed Apr 11, 2016
1 parent 3e47271 commit 1fdce8b
Show file tree
Hide file tree
Showing 396 changed files with 1,700 additions and 155,111 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ Data/**/*


# Front-end Resources (compiled)
Public/**/*
!Public/**/*.php
#Public/**/*
#!Public/**/*.php

11 changes: 11 additions & 0 deletions Data/Config.simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
*/
define('THEME', 'Default');

/**
* Mailer config
*/
$MAIL = array(
'host' => 'smtp.exmail.qq.com',
'username' => '[email protected]',
'password' => 'password',
'from' => '某科学的h本 <[email protected]>',
'secure' => ''
);

/**
* Rewrite setting:
* remove "index.php" from url, needs to config apache/nginx manually
Expand Down
18 changes: 18 additions & 0 deletions Library/Contactable/ICron.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* shadowsocks-panel
* Add: 2016/3/27 9:39
* Author: Sendya <[email protected]>
*/
namespace Contactable;


interface ICron {

/** Cron 的运行方法 */
public function run();

/** 返回下次执行时间 */
public function getStep();

}
29 changes: 29 additions & 0 deletions Library/Contactable/IMailer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* Project: shadowsocks-panel
* Author: Sendya <[email protected]>
* Time: 2016/3/26 16:18
*/
namespace Contactable;

use Model\Mail as MailModel;

/**
* 邮件发送接口
* 怎么发送,使用什么方法自行继承并实现相应功能
*
* Interface Mailer
*/
interface Mailer {

/** 是否可以 */
public function isAvailable();

/** 发送方法 */
public function send(MailModel $mail);

/** 邮件发送测试 */
public function test();

}
21 changes: 21 additions & 0 deletions Library/Contactable/IPay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* shadowsocks-panel
* Add: 2016/4/6 10:40
* Author: Sendya <[email protected]>
*/

namespace Contactable;

/**
* Interface IPay
* 支付接口
*
* @package Contactable
*/
interface IPay {

public function pay();

public function status();
}
86 changes: 65 additions & 21 deletions Library/Controller/Admin/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,25 @@ public function index() {
Template::setView('admin/message');
}

public function change() {
global $user;
/**
* 修改 or 新增
*
* @JSON
* @return array
*/
public function update() {

$result = array('error'=> 1, 'message'=> 'Request failed');

if($_POST['message_id'] != null) { // 修改

$msg = MessageModel::GetMessageById(trim($_POST['message_id']));
$msg = MessageModel::getMessageById(trim($_POST['message_id']));
if($msg) { // 修改
$msg->content = $_POST['message_content']==null ? "" : $_POST['message_content'];
$msg->pushTime = $_POST['message_pushTime']==null ? 0 : strtotime($_POST['message_pushTime']);
$msg->pushUsers = $_POST['message_pushUsers']==null ? -1 : $_POST['message_pushUsers'];
$msg->type = $_POST['message_type']==null ? 0 : $_POST['message_type'];
$msg->pushEndTime = $_POST['message_pushEndTime']==null ? 0 : strtotime($_POST['message_pushEndTime']);
$msg->update();
$msg->save();
$result = array('error'=> 0, 'message'=> '更新成功');
}
} else {
Expand All @@ -50,43 +55,82 @@ public function change() {
$msg->pushUsers = $_POST['message_pushUsers']==null ? 0 : $_POST['message_pushUsers'];
$msg->type = $_POST['message_type']==null ? 0 : $_POST['message_type'];
$msg->pushEndTime = $_POST['message_pushEndTime']==null ? 0 : strtotime($_POST['message_pushEndTime']);
$msg->insertToDB();
$msg->save();
$result = array('error'=> 0, 'message'=> '添加新消息成功');
}
// $msg = new MessageModel(); // 新增
$msg->content = mb_substr(htmlspecialchars($msg->content),0,20,'utf-8');
$msg->pushEndTime = date('Y-m-d H:i:s', $msg->pushEndTime);
$type = "";
switch($msg->type) {
case '-1':
$type = "重复消息";
break;
case '-2':
$type = "系统公告";
break;
case '-3':
$type = "套餐处说明";
break;
case '-4':
$type = "首页浮动提示";
break;
case '-5':
$type = "登录页公告";
break;
case '0':
default:
$type = "正常消息";
break;
}
$msg->type = $type;
$pushTo = "";
switch($msg->pushUsers){
case '-2':
$pushTo = "系统固定消息";
break;
case '-1':
$pushTo = "系统消息";
break;
default:
$pushTo = "用户:" . $msg->pushUsers;
break;
}
$msg->pushUsers = $pushTo;
$result['modal'] = $msg;

echo json_encode($result);
exit();
return $result;
}

/**
* 删除
* @JSON
*/
public function delete() {
global $user;
$result = array('error'=> 1, 'message'=> 'Request failed');

if($_POST['message_id'] != null) {

$rs = MessageModel::deleteMsgById(trim($_POST['message_id']));
if($rs)
$result = array('error'=> 0, 'message'=> '删除成功');
MessageModel::deleteMessageById(intval(trim($_POST['message_id'])));
$result = array('error'=> 0, 'message'=> '删除成功');
}
echo json_encode($result);
exit();
return $result;
}

/**
* 查询
* @JSON
*/
public function query() {
global $user;
$result = array('error'=> 1, 'message'=> 'Request failed');
$result['message_id'] = $_GET['message_id'];
if($_GET['message_id'] != null) {

$rs = MessageModel::GetMessageById(trim($_GET['message_id']));
$rs = MessageModel::getMessageById(trim($_GET['message_id']));
$rs->pushTime = date('Y-m-d H:i:s', $rs->pushTime);
$rs->pushEndTime = date('Y-m-d H:i:s', $rs->pushEndTime);
if($rs)
$result = array('error'=> 0, 'message'=> 'success', 'data'=> $rs);
$result = array('error'=> 0, 'message'=> 'success', 'modal'=> $rs);
}
echo json_encode($result);
exit();
return $result;
}

}
7 changes: 3 additions & 4 deletions Library/Controller/Admin/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ public function update() {
* @JSON
*/
public function query() {
$result = array('error' => 1, 'message' => '获取节点信息失败');
$result = array('error' => 1);
if($_GET['node_id']!=null) {
$result['data'] = NodeModel::getNodeById(trim($_GET['node_id']));
$result['node'] = NodeModel::getNodeById(trim($_GET['node_id']));
$result['error'] = 0;
}
echo json_encode($result);
exit();
return $result;
}

/**
Expand Down
59 changes: 59 additions & 0 deletions Library/Controller/Admin/Setting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* shadowsocks-panel
* Add: 2016/4/11 9:53
* Author: Sendya <[email protected]>
*/

namespace Controller\Admin;

use Core\Template;
use Helper\Option;
use Model\User;

/**
* Class Setting
* @Admin
* @Authorization
* @package Controller\Admin
*/
class Setting {

public function index() {
$data['user'] = User::getCurrent();
$data['options'] = Option::getOptions();

Template::setContext($data);
Template::setView("admin/setting");
}

/**
* 读取option详细配置
*
* @JSON
*/
public function query() {
$result['error'] = 0;
$result['message'] = 'success';

$result['modal'] = Option::get(trim($_GET['option']));
$result['isArray'] = false;
return $result;
}

/**
* 修改
* @JSON
*/
public function update() {

$result['error'] = 0;
$result['message'] = '保存完成';
if($_POST['option_v'] != null && $_POST['option_k'] != null) {
Option::set(trim($_POST['option_k']), trim($_POST['option_v']));
// 初始化一次系统设置
Option::init();
}
return $result;
}
}
Loading

0 comments on commit 1fdce8b

Please sign in to comment.