Skip to content

Commit

Permalink
August Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Anankke committed Aug 8, 2019
2 parents e827700 + 0d2d95d commit b309016
Show file tree
Hide file tree
Showing 104 changed files with 17,446 additions and 1,686 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ storage/*.*
.user.ini
public/.user.ini

resources/views/material/analytics.tpl
resources/views/material/analytics.tpl

test/tpl_files.txt
91 changes: 75 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,95 @@
language: php
services:
- mysql
php:
- 7.2
- 7.3
sudo: enabled
dist: xenial
addons:
hosts:
- sspanel.test
before_install:
- echo "$SHELL"
- echo "$TRAVIS_BUILD_DIR"
- echo $(whoami)
- sudo adduser www-data travis
- echo "==========================================================="
- echo "Upgrade linux packages"
- echo "==========================================================="
- sudo sed -i 's|http://us-east-1.ec2.archive.ubuntu.com|https://ubuntu.mirror.noc.one|g' /etc/apt/sources.list
- sudo sed -i 's|http://security.ubuntu.com|https://ubuntu.mirror.noc.one|g' /etc/apt/sources.list
- sudo sed -i 's|http://us-central1.gce.archive.ubuntu.com|https://ubuntu.mirror.noc.one|g' /etc/apt/sources.list
- sudo sed -i 's|http://ppa.launchpad.net|https://launchpad.proxy.noc.one|g' /etc/apt/sources.list.d/*.list
- curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
- sudo apt clean all && sudo apt -qq -y update
- sudo apt install -y nodejs
- sudo apt-get clean
- sudo add-apt-repository ppa:ondrej/php -y
- curl -sL https://noc.one/ubuntu | bash
- curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
# When setup Node, it has just helped me ran apt-get upadte.
- sudo apt-get -qq install -y nodejs php7.3-fpm php7.3-mysql php7.3-curl php7.3-gd php7.3-mbstring php7.3-xml php7.3-xmlrpc php7.3-opcache php7.3-zip php7.3-json php7.3-bz2 php7.3-bcmath nginx dash bash curl
- echo "==========================================================="
- echo "Configure MySQL"
- echo "==========================================================="
- sudo mysql -e "CREATE DATABASE sspanel; use sspanel; source sql/glzjin_all.sql;"
- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('sspanel') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;"
- sudo mysql_upgrade -u root -psspanel
- sudo service mysql restart
- echo "==========================================================="
- echo "Configure Nginx"
- echo "==========================================================="
#- sudo sed -e "s?user www-data;?user travis;?g" --in-place /etc/nginx/nginx.conf
- sudo cat /etc/nginx/nginx.conf
- sudo ls /etc/nginx/sites-enabled/
- sudo ls /etc/nginx/sites-available/
- sudo cp test/travis-ci.conf /etc/nginx/sites-available/sspanel.test.conf
- sudo rm -rf /etc/nginx/sites-available/default
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$TRAVIS_BUILD_DIR?g" --in-place /etc/nginx/sites-available/sspanel.test.conf
- sudo ln -s /etc/nginx/sites-available/sspanel.test.conf /etc/nginx/sites-enabled/
- sudo ls /etc/nginx/sites-enabled/
- sudo ls /etc/nginx/sites-available/
- sudo cat /etc/nginx/sites-enabled/sspanel.test.conf
install:
- sudo chmod -R 755 *
- composer install
- echo "==========================================================="
- echo $(git log -1 --pretty=%B | grep 'skip lint')
- echo "==========================================================="
# I don't need npm audit when npm i. I will do it myself.
- npm set audit false
- if [[ ! -n "$(git log -1 --pretty=%B | grep 'skip lint')" ]]; then
npm i -g phplint;
fi
- cd uim-index-dev
- npm i
- cd ..
- if [[ ! -n "$(git log -1 --pretty=%B | grep 'skip lint')" ]]; then
cd test && git clone https://github.com/biinari/smarty-lint && cd .. ;
fi
before_script:
- npm i -g phplint
- cd uim-index-dev
- npm audit > npm-audit.log || true
- if [[ ! -n "$(git log -1 --pretty=%B | grep 'skip lint')" ]]; then
npm run lint && npm run build;
fi
- cd ..
- if [[ ! -n "$(git log -1 --pretty=%B | grep 'skip lint')" ]]; then
phplint '**/*.php' '!vendor/**';
fi
- chmod +x ./test/listTpl.sh
- if [[ ! -n "$(git log -1 --pretty=%B | grep 'skip lint')" ]]; then
./test/listTpl.sh;
fi
script:
- cp config/.config.example.php config/.config.php
- phplint '**/*.php' '!vendor/**'
- chmod +x test/test.sh
- sudo chmod -R 755 *
- cp test/config.php config/.config.php
- php xcat createAdmin test@example.com test
- php xcat syncusers
- php xcat initdownload
- php xcat initQQWry
- php xcat update
- cd uim-index-dev
- npm run lint
- npm run build
- arrcookie=($(php xcat getCookie 1 | sed 's| |\n|g'))
- sudo service php7.3-fpm restart
- sudo nginx -c /etc/nginx/nginx.conf
- sudo chmod -R 777 $TRAVIS_BUILD_DIR
- sudo chown -R www-data:www-data $TRAVIS_BUILD_DIR
- ./test/test.sh ${arrcookie[0]} ${arrcookie[1]}
- sudo cat /var/log/nginx/access.log
- sudo cat /var/log/nginx/error.log
- cat uim-index-dev/npm-audit.log
cache:
directories:
- uim-index-dev/node_modules
Expand Down
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,28 @@ Telegram ~~可能是个官方~~水群 :https://t.me/SSUnion

记得点小星星!

演示站: [sspanel.host](https://sspanel.host) 账号和密码都是 admin 对接节点的 mukey=NimaQu
演示站: [sspanel.host](https://sspanel.host) 账号和密码都是 `admin` 对接节点的 `mukey=NimaQu`

**原作者** [galaxychuck](https://github.com/galaxychuck)

[支持开发者请点我](https://github.com/Anankke/SSPanel-Uim#%E5%85%B3%E4%BA%8E%E6%8D%90%E8%B5%A0)

## 搭建教程
## Wiki

GitHub Wiki : https://github.com/Anankke/SSPanel-Uim/wiki/%E5%89%8D%E7%AB%AF%E5%AE%89%E8%A3%85

Wiki 已经启用,欢迎为此面板维护 wiki
https://wiki.sspanel.host

#### 鸣谢

##### [Anankke](https://github.com/galaxychuck)

- 面板现**维护者**
- 面板现 **维护者**

##### [galaxychuck](https://github.com/galaxychuck)

- 面板**原作者**
- 面板 **原作者**

##### [hkserversolution](https://www.hkserversolution.com/cart.php)

- Demo 演示站服务器赞助

##### [dumplin](https://github.com/dumplin233)
Expand Down Expand Up @@ -87,9 +86,16 @@ Wiki 已经启用,欢迎为此面板维护 wiki
[**laurieryayoi**](https://github.com/laurieryayoi)

- 重做美化UI(~~援交~~圆角化)

- 新版 Vue(SPA) 版界面
- 重写节点列表,支持分级显示所有级别节点

[**sukka**](https://skk.moe)

- Travis CI 持续集成
- 单元测试
- 全站 JavaScript 的重写
- 新版 Wiki 的搭建和维护

#### 还有所有被引用过代码的同学,以及所有提交过 pr/issue 的同学。

#### 关于捐赠
Expand All @@ -112,8 +118,6 @@ Wiki 已经启用,欢迎为此面板维护 wiki

[laurieryayoi 的前端课程报名](https://t.me/kinokonominoco)



## 免责声明

本程序由 MIT License 授权。**不提供任何担保**。使用本程序即表明,您知情并同意:程序开发者不对此程序导致的任何服务中断、数据损失或任何少见未列出的事故负责。
4 changes: 2 additions & 2 deletions app/Command/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static function DailyJob()
// 定时任务开启的情况下,每天自动检测有没有最新版的后端,github源来自Miku
public static function updatedownload()
{
system('cd ' . BASE_PATH . '/public/ssr-download/ && git pull https://github.com/xcxnig/ssr-download.git');
system('cd ' . BASE_PATH . '/public/ssr-download/ && git pull https://github.com/xcxnig/ssr-download.git && git gc');
}


Expand Down Expand Up @@ -558,7 +558,7 @@ static function ($query) use ($node) {
$text = '管理员您好,系统发现节点 ' . $node->name . ' 恢复上线了。';
$postdata = http_build_query(
array(
'text' => Config::get('appName') . '-节点掉线了',
'text' => Config::get('appName') . '-节点恢复上线了',
'desp' => $text
)
);
Expand Down
2 changes: 1 addition & 1 deletion app/Command/XCat.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public function getCookie()
{
if (count($this->argv) === 3) {
$user = User::find($this->argv[2]);
$expire_in = 3600 + time();
$expire_in = 86400 + time();
echo Hash::cookieHash($user->pass, $expire_in) . ' ' . $expire_in;
}
}
Expand Down
49 changes: 33 additions & 16 deletions app/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
use App\Utils\Radius;
use App\Models\DetectLog;
use App\Models\DetectRule;
use App\Models\NodeOnlineLog;
use App\Models\NodeInfoLog;

use Exception;
use voku\helper\AntiXSS;
Expand All @@ -42,6 +44,7 @@
use App\Utils\TelegramSessionManager;
use App\Utils\Pay;
use App\Utils\URL;
use App\Utils\DatatablesHelper;
use App\Services\Mail;

/**
Expand Down Expand Up @@ -456,6 +459,9 @@ public function node($request, $response, $args)

$array_nodes = array();
$nodes_muport = array();
$db = new DatatablesHelper();
$infoLogs = $db->query('SELECT * FROM ( SELECT * FROM `ss_node_info` WHERE log_time > ' . (time() - 300) . ' ORDER BY id DESC LIMIT 999999999999 ) t GROUP BY node_id ORDER BY id DESC');
$onlineLogs = $db->query('SELECT * FROM ( SELECT * FROM `ss_node_online_log` WHERE log_time > ' . (time() - 300) . ' ORDER BY id DESC LIMIT 999999999999 ) t GROUP BY node_id ORDER BY id DESC');

foreach ($nodes as $node) {
if ($node->node_group != $user->node_group && $node->node_group != 0) {
Expand Down Expand Up @@ -493,26 +499,37 @@ public function node($request, $response, $args)
$array_node['flag'] = 'unknown.png';
}

$node_online = $node->isNodeOnline();
if ($node_online === null) {
$sort = $array_node['sort'];
$array_node['online_user'] = 0;

foreach ($onlineLogs as $log) {
if ($log['node_id'] != $node->id) {
continue;
}
if (in_array($sort, array(0, 7, 8, 10, 11, 12, 13))) {
$array_node['online_user'] = $log['online_user'];
} else {
$array_node['online_user'] = -1;
}
break;
}

// check node status
// 0: new node; -1: offline; 1: online
$node_heartbeat = $node->node_heartbeat + 300;
$array_node['online'] = -1;
if (!in_array($sort, array(0, 7, 8, 10, 11, 12, 13)) || $node_heartbeat == 300 ) {
$array_node['online'] = 0;
} elseif ($node_online === true) {
} elseif ($node_heartbeat > time()) {
$array_node['online'] = 1;
} elseif ($node_online === false) {
$array_node['online'] = -1;
}

if (in_array($node->sort, array(0, 7, 8, 10, 11, 12, 13))) {
$array_node['online_user'] = $node->getOnlineUserCount();
} else {
$array_node['online_user'] = -1;
}

$nodeLoad = $node->getNodeLoad();
if (isset($nodeLoad[0]['load'])) {
$array_node['latest_load'] = (explode(' ', $nodeLoad[0]['load']))[0] * 100;
} else {
$array_node['latest_load'] = -1;
$array_node['latest_load'] = -1;
foreach ($infoLogs as $log) {
if ($log['node_id'] == $node->id) {
$array_node['latest_load'] = (explode(' ', $log['load']))[0] * 100;
break;
}
}

$array_node['traffic_used'] = (int)Tools::flowToGB($node->node_bandwidth);
Expand Down
2 changes: 1 addition & 1 deletion app/Services/Gateway/Codepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function purchase($request, $response, $args)
$urls .= "$key=" . urlencode($val); //拼接为url参数形式并URL编码参数值
}
$query = $urls . '&sign=' . md5($sign . $codepay_key); //创建订单所需的参数
$url = 'https://codepay.fateqq.com:51888/creat_order/?' . $query; //支付页面
$url = 'https://codepay.fateqq.com/creat_order/?' . $query; //支付页面


header('Location:' . $url);
Expand Down
Loading

0 comments on commit b309016

Please sign in to comment.