Compare commits
No commits in common. 'dev' and 'v2.2.0' have entirely different histories.
@ -1,2 +0,0 @@
|
||||
.git
|
||||
uim-index-dev/
|
||||
@ -1,22 +0,0 @@
|
||||
# https://editorconfig.org/
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
tab_width = 4
|
||||
|
||||
[*.php]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 80
|
||||
@ -0,0 +1,11 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Bug 反馈
|
||||
|
||||
---
|
||||
|
||||
1.此项目为前端,不解决任何后端对接相关问题
|
||||
2.提问前请先阅读 wiki,否则将会 close 并 block
|
||||
3.有问题先去 https://demo.nimaqu.com 测试,再写明如何复现这个问题,否则按上条处理
|
||||
4,issues 是反馈 bug / 提供建议的,不是问问题的,不会装自己去交流群花钱请人装
|
||||
5.发 issues 之前麻烦把这些东西删了再发
|
||||
@ -1,38 +1,9 @@
|
||||
.idea
|
||||
.vs/
|
||||
.htaccess
|
||||
*/.DS_Store
|
||||
.DS_Store
|
||||
composer.lock
|
||||
.php_cs.cache
|
||||
.env
|
||||
vendor
|
||||
|
||||
php_errors.log
|
||||
composer.phar
|
||||
|
||||
404.html
|
||||
index.html
|
||||
|
||||
config/.config.php
|
||||
config/.config.php.bak
|
||||
|
||||
public/ssr-download/
|
||||
public/images/*.*
|
||||
public/theme/material/css/images/bg
|
||||
|
||||
storage/framework/smarty/cache/*
|
||||
storage/framework/smarty/compile/*
|
||||
storage/framework/views/*
|
||||
storage/*.*
|
||||
/storage/traffic_notified/
|
||||
!storage/framework/smarty/cache/.gitkeep
|
||||
!storage/framework/smarty/compile/.gitkeep
|
||||
!storage/framework/views/.gitkeep
|
||||
|
||||
.user.ini
|
||||
public/.user.ini
|
||||
|
||||
resources/views/material/analytics.tpl
|
||||
|
||||
test/tpl_files.txt
|
||||
/vendor
|
||||
/config/.config.php
|
||||
/public/images/*.*
|
||||
/public/theme/material/css/images/bg
|
||||
/.idea
|
||||
storage/qqwry.md5
|
||||
.vs/
|
||||
|
||||
@ -1,98 +0,0 @@
|
||||
language: php
|
||||
services:
|
||||
- mysql
|
||||
php:
|
||||
- 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 "Install & upgrade linux packages"
|
||||
- echo "==========================================================="
|
||||
- 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:
|
||||
# Make composer download 10x faseter
|
||||
- composer global require hirak/prestissimo
|
||||
- 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 npm@latest && 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:
|
||||
- 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:
|
||||
- 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
|
||||
- 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
|
||||
- $HOME/.composer/cache/files
|
||||
@ -1,44 +0,0 @@
|
||||
# How to Contribute / 如何贡献代码
|
||||
|
||||
[English](#English)
|
||||
[简体中文](#简体中文)
|
||||
|
||||
## English
|
||||
|
||||
### Pull Requests
|
||||
|
||||
1. Fork the this repository
|
||||
2. Create a new branch for each feature or improvement
|
||||
3. Send a pull request from each feature branch against the dev branch.
|
||||
|
||||
It is very important to separate new features or improvements into separate feature branches, and to send a
|
||||
pull request for each branch. This allows each feature or improvement to be reviewed and merged individually.
|
||||
|
||||
### Coding Style
|
||||
|
||||
All pull requests and commits **must** adhere to the [PSR-2 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) at least.
|
||||
And we **recommend** adhering to the [PSR-12 standard](https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md).
|
||||
|
||||
### Commit message
|
||||
|
||||
The Commit message **must** containe all the changes you maked in sort.
|
||||
Please **do not** use words like "fix", "improve" only.
|
||||
|
||||
## 简体中文
|
||||
|
||||
### Pull Request
|
||||
|
||||
1. Fork 本项目
|
||||
2. 为每一项新特性或改进创建一个新的分支
|
||||
3. 为每一项新特性或改进创建一个独立的 Pull Request 至 dev 分支
|
||||
|
||||
我们建议你将不同的新特性置于不同的分支并以不同的 Pull Request 提交,这将有利于我们独立审查代码并独立合并。
|
||||
|
||||
### 代码风格
|
||||
|
||||
所有的 Pull request 和 commit 都至少**必须**遵守 [PSR-2 标准](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)。
|
||||
我们建议**最好**遵守 [PSR-12 标准](https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md)。
|
||||
|
||||
### Commit 消息
|
||||
|
||||
Commit 消息必须简洁地包含你所有的修改。请不要仅使用「修复」、「改进」等字样。
|
||||
@ -1,26 +0,0 @@
|
||||
FROM indexyz/php
|
||||
LABEL maintainer="Indexyz <indexyz@protonmail.com>"
|
||||
|
||||
COPY . /var/www
|
||||
WORKDIR /var/www
|
||||
|
||||
RUN cp config/.config.example.php config/.config.php && \
|
||||
chmod -R 755 storage && \
|
||||
chmod -R 777 /var/www/storage/framework/smarty/compile/ && \
|
||||
curl -SL https://getcomposer.org/installer -o composer-setup.php && \
|
||||
php composer-setup.php && \
|
||||
php composer.phar install && \
|
||||
php xcat initQQWry && \
|
||||
php xcat initdownload && \
|
||||
crontab -l | { cat; echo "30 22 * * * php /var/www/xcat sendDiaryMail"; } | crontab - && \
|
||||
crontab -l | { cat; echo "0 0 * * * php /var/www/xcat dailyjob"; } | crontab - && \
|
||||
crontab -l | { cat; echo "*/1 * * * * php /var/www/xcat checkjob"; } | crontab - && \
|
||||
crontab -l | { cat; echo "*/1 * * * * php /var/www/xcat syncnode"; } | crontab - && \
|
||||
{ \
|
||||
echo '[program:crond]'; \
|
||||
echo 'command=cron -f'; \
|
||||
echo 'autostart=true'; \
|
||||
echo 'autorestart=true'; \
|
||||
echo 'killasgroup=true'; \
|
||||
echo 'stopasgroup=true'; \
|
||||
} | tee /etc/supervisor/crond.conf
|
||||
@ -1,19 +0,0 @@
|
||||
根据时间从 2018 年 12 月始...
|
||||
|
||||
- 支持 Quantumult 格式的 V2Ray 订阅以及策略组配置导出
|
||||
- 支持 Surge 2 & 3 的托管配置以及 policy group
|
||||
- 支持 SurfBoard 的托管配置
|
||||
- 支持 Shadowrocket 支持的 Shadowsocks(R) & VMess 合并订阅
|
||||
- 提供用户使用文档
|
||||
- 完全合并普通端口和单端口的订阅及托管
|
||||
- ShadowsocksR 订阅中的账户及流量信息改为可选
|
||||
- ~~一键切换 SS/SSR 加密、协议、混淆~~ (已废弃)
|
||||
- 订阅链接兼容 Anankke
|
||||
- ~~支持 ss-v2ray-plugin 类型节点~~ (已合并到 Anankke)
|
||||
- V2Ray 订阅可选支持显示账户及流量信息
|
||||
- 可选使用预定义的加密、协议、混淆配置方案
|
||||
- 支持用户自定义 Surge 托管配置
|
||||
- 支持用户自定义 Clash 托管配置
|
||||
|
||||
……
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\AdminController;
|
||||
use Ozdemir\Datatables\Datatables;
|
||||
use App\Utils\DatatablesHelper;
|
||||
|
||||
class DetectBanLogController extends AdminController
|
||||
{
|
||||
public function index($request, $response, $args)
|
||||
{
|
||||
$table_config['total_column'] = array("id" => "ID", "user_id" => "用户ID",
|
||||
"user_name" => "用户名", "email" => "用户邮箱",
|
||||
"detect_number" => "违规次数", "ban_time" => "封禁时长(分钟)",
|
||||
"start_time" => "统计开始时间", "end_time" => "统计结束以及封禁开始时间",
|
||||
"ban_end_time" => "封禁结束时间", "all_detect_number" => "累计违规次数");
|
||||
$table_config['default_show_column'] = array();
|
||||
foreach ($table_config['total_column'] as $column => $value) {
|
||||
array_push($table_config['default_show_column'], $column);
|
||||
}
|
||||
$table_config['ajax_url'] = 'ban/ajax';
|
||||
return $this->view()->assign('table_config', $table_config)->display('admin/detect/ban.tpl');
|
||||
}
|
||||
|
||||
public function ajax_log($request, $response, $args)
|
||||
{
|
||||
$datatables = new Datatables(new DatatablesHelper());
|
||||
$datatables->query('Select detect_ban_log.id,detect_ban_log.user_id,detect_ban_log.user_name,detect_ban_log.email,detect_ban_log.detect_number,detect_ban_log.ban_time,detect_ban_log.start_time,detect_ban_log.end_time,detect_ban_log.all_detect_number,detect_ban_log.end_time as ban_end_time from detect_ban_log');
|
||||
$datatables->edit('start_time', function ($data) {
|
||||
return date('Y-m-d H:i:s', $data['start_time']);
|
||||
});
|
||||
$datatables->edit('end_time', function ($data) {
|
||||
return date('Y-m-d H:i:s', $data['end_time']);
|
||||
});
|
||||
$datatables->edit('ban_end_time', function ($data) {
|
||||
return date('Y-m-d H:i:s', $data['ban_end_time']+$data['ban_time']*60);
|
||||
});
|
||||
|
||||
$body = $response->getBody();
|
||||
$body->write($datatables->generate());
|
||||
}
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\AdminController;
|
||||
use App\Utils\QQWry;
|
||||
|
||||
use Ozdemir\Datatables\Datatables;
|
||||
use App\Utils\DatatablesHelper;
|
||||
|
||||
class SubscribeLogController extends AdminController
|
||||
{
|
||||
public function index($request, $response, $args)
|
||||
{
|
||||
$table_config['total_column'] = array('id' => 'ID', 'user_name' => '用户名',
|
||||
'user_id' => '用户ID', 'email' => '用户邮箱', 'subscribe_type' => '类型',
|
||||
'request_ip' => 'IP', 'location' => '归属地', 'request_time' => '时间',
|
||||
'request_user_agent' => 'User-Agent');
|
||||
$table_config['default_show_column'] = array();
|
||||
foreach ($table_config['total_column'] as $column => $value) {
|
||||
$table_config['default_show_column'][] = $column;
|
||||
}
|
||||
$table_config['ajax_url'] = 'subscribe/ajax';
|
||||
return $this->view()->assign('table_config', $table_config)->display('admin/subscribe.tpl');
|
||||
}
|
||||
|
||||
public function ajax_subscribe_log($request, $response, $args)
|
||||
{
|
||||
$datatables = new Datatables(new DatatablesHelper());
|
||||
$datatables->query('Select user_subscribe_log.id,user_subscribe_log.user_name,user_subscribe_log.user_id,user_subscribe_log.email,user_subscribe_log.subscribe_type,user_subscribe_log.request_ip,user_subscribe_log.request_ip as location,user_subscribe_log.request_time,user_subscribe_log.request_user_agent from user_subscribe_log');
|
||||
|
||||
$iplocation = new QQWry();
|
||||
$datatables->edit('location', static function ($data) use ($iplocation) {
|
||||
$location = $iplocation->getlocation($data['location']);
|
||||
return iconv('gbk', 'utf-8//IGNORE', $location['country'] . $location['area']);
|
||||
});
|
||||
|
||||
$body = $response->getBody();
|
||||
$body->write($datatables->generate());
|
||||
}
|
||||
}
|
||||
@ -1,575 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 部分应用自定义配置
|
||||
*
|
||||
* PHP version 7.2+
|
||||
*
|
||||
* @category GeekQu
|
||||
* @package App/Controllers/ConfController
|
||||
* @author GeekQu <iloves@live.com>
|
||||
* @license MIT https://github.com/GeekQu/ss-panel-v3-mod_Uim/blob/dev/LICENSE
|
||||
* @link https://github.com/GeekQu
|
||||
*/
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\Config;
|
||||
use App\Utils\ConfRender;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
|
||||
/**
|
||||
* ConfController
|
||||
*
|
||||
* @category GeekQu
|
||||
* @package App/Controllers/ConfController
|
||||
* @author GeekQu <iloves@live.com>
|
||||
* @license MIT https://github.com/GeekQu/ss-panel-v3-mod_Uim/blob/dev/LICENSE
|
||||
* @link https://github.com/GeekQu
|
||||
*/
|
||||
class ConfController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* YAML 转数组
|
||||
*
|
||||
* @param string $Content YAML 字符串
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function YAML2Array($Content)
|
||||
{
|
||||
try {
|
||||
return Yaml::parse($Content);
|
||||
} catch (ParseException $exception) {
|
||||
return printf('无法解析 YAML 字符串: %s', $exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从远端自定义配置文件生成 Surge 托管配置
|
||||
*
|
||||
* @param object $User 用户
|
||||
* @param string $AllProxys Surge 格式的全部节点
|
||||
* @param array $Nodes 全部节点数组
|
||||
* @param string $SourceContent 远程配置内容
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSurgeConfs($User, $AllProxys, $Nodes, $Configs, $local = false)
|
||||
{
|
||||
$General = self::getSurgeConfGeneral($Configs['General']);
|
||||
$Proxys = (isset($Configs['Proxy'])
|
||||
? self::getSurgeConfProxy($Configs['Proxy'])
|
||||
: '');
|
||||
|
||||
if (isset($Configs['Proxy Group'])) {
|
||||
$Configs['ProxyGroup'] = $Configs['Proxy Group'];
|
||||
}
|
||||
$ProxyGroups = self::getSurgeConfProxyGroup(
|
||||
$Nodes,
|
||||
$Configs['ProxyGroup']
|
||||
);
|
||||
$ProxyGroup = self::getSurgeProxyGroup2String($ProxyGroups);
|
||||
|
||||
$Rule = self::getSurgeConfRule($Configs['Rule'], $local);
|
||||
$Conf = '#!MANAGED-CONFIG '
|
||||
. Config::get('baseUrl') . $_SERVER['REQUEST_URI'] .
|
||||
"\n\n#---------------------------------------------------#" .
|
||||
"\n## 上次更新于:" . date("Y-m-d h:i:s") .
|
||||
"\n#---------------------------------------------------#" .
|
||||
"\n\n[General]"
|
||||
. $General .
|
||||
"\n\n[Proxy]\n"
|
||||
. $AllProxys . $Proxys .
|
||||
"\n\n[Proxy Group]"
|
||||
. $ProxyGroup .
|
||||
"\n\n[Rule]\n"
|
||||
. $Rule;
|
||||
|
||||
return $Conf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Surge 配置中的 General
|
||||
*
|
||||
* @param array $General Surge General 定义
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSurgeConfGeneral($General)
|
||||
{
|
||||
$return = '';
|
||||
if (count($General) != 0) {
|
||||
foreach ($General as $key => $value) {
|
||||
$return .= "\n$key = $value";
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Surge 配置中的 Proxy
|
||||
*
|
||||
* @param array $Proxys 自定义配置中的额外 Proxy
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSurgeConfProxy($Proxys)
|
||||
{
|
||||
$return = '';
|
||||
if (count($Proxys) != 0) {
|
||||
foreach ($Proxys as $value) {
|
||||
if (!preg_match('/(\[General|Replica|Proxy|Proxy\sGroup|Rule|Host|URL\sRewrite|Header\sRewrite|MITM|Script\])/', $value)) {
|
||||
$return .= "\n$value";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Surge 配置中的 ProxyGroup
|
||||
*
|
||||
* @param array $Nodes 全部节点数组
|
||||
* @param array $ProxyGroups Surge 策略组定义
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSurgeConfProxyGroup($Nodes, $ProxyGroups)
|
||||
{
|
||||
$return = [];
|
||||
foreach ($ProxyGroups as $ProxyGroup) {
|
||||
if (in_array($ProxyGroup['type'], ['select', 'url-test', 'fallback'])) {
|
||||
$proxies = [];
|
||||
if (
|
||||
isset($ProxyGroup['content']['left-proxies'])
|
||||
&& count($ProxyGroup['content']['left-proxies']) != 0
|
||||
) {
|
||||
$proxies = $ProxyGroup['content']['left-proxies'];
|
||||
}
|
||||
foreach ($Nodes as $item) {
|
||||
$item = self::getMatchProxy($item, $ProxyGroup);
|
||||
if ($item !== null && !in_array($item['remark'], $proxies)) {
|
||||
$proxies[] = $item['remark'];
|
||||
}
|
||||
}
|
||||
if (isset($ProxyGroup['content']['right-proxies'])) {
|
||||
$proxies = array_merge($proxies, $ProxyGroup['content']['right-proxies']);
|
||||
}
|
||||
$ProxyGroup['proxies'] = $proxies;
|
||||
}
|
||||
$return[] = $ProxyGroup;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取匹配的节点
|
||||
*
|
||||
* @param array $Proxy 节点
|
||||
* @param array $Rule 匹配规则
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getMatchProxy($Proxy, $Rule)
|
||||
{
|
||||
$return = null;
|
||||
switch (true) {
|
||||
case (isset($Rule['content']['class'])):
|
||||
if ($Proxy['class'] == $Rule['content']['class']) {
|
||||
if (isset($Rule['content']['regex'])) {
|
||||
if (preg_match('/' . $Rule['content']['regex'] . '/i', $Proxy['remark'])) {
|
||||
$return = $Proxy;
|
||||
}
|
||||
} else {
|
||||
$return = $Proxy;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (isset($Rule['content']['noclass'])):
|
||||
if ($Proxy['class'] != $Rule['content']['noclass']) {
|
||||
if (isset($Rule['content']['regex'])) {
|
||||
if (preg_match('/' . $Rule['content']['regex'] . '/i', $Proxy['remark'])) {
|
||||
$return = $Proxy;
|
||||
}
|
||||
} else {
|
||||
$return = $Proxy;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (!isset($Rule['content']['class'])
|
||||
&& !isset($Rule['content']['noclass'])
|
||||
&& isset($Rule['content']['regex'])
|
||||
&& preg_match('/' . $Rule['content']['regex'] . '/i', $Proxy['remark'])
|
||||
):
|
||||
$return = $Proxy;
|
||||
break;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Surge ProxyGroup 去除无用策略组
|
||||
*
|
||||
* @param array $ProxyGroups 策略组
|
||||
* @param array $checks 要检查的策略组名
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function fixSurgeProxyGroup($ProxyGroups, $checks)
|
||||
{
|
||||
if (count($checks) == 0) {
|
||||
return $ProxyGroups;
|
||||
}
|
||||
$clean_names = [];
|
||||
$newProxyGroups = [];
|
||||
foreach ($ProxyGroups as $ProxyGroup) {
|
||||
if (in_array($ProxyGroup['name'], $checks) && count($ProxyGroup['proxies']) == 0) {
|
||||
$clean_names[] = $ProxyGroup['name'];
|
||||
continue;
|
||||
}
|
||||
$newProxyGroups[] = $ProxyGroup;
|
||||
}
|
||||
if (count($clean_names) >= 1) {
|
||||
$ProxyGroups = $newProxyGroups;
|
||||
$newProxyGroups = [];
|
||||
foreach ($ProxyGroups as $ProxyGroup) {
|
||||
if (!in_array($ProxyGroup['name'], $checks) && $ProxyGroup['type'] != 'ssid') {
|
||||
$newProxies = [];
|
||||
foreach ($ProxyGroup['proxies'] as $proxie) {
|
||||
if (!in_array($proxie, $clean_names)) {
|
||||
$newProxies[] = $proxie;
|
||||
}
|
||||
}
|
||||
$ProxyGroup['proxies'] = $newProxies;
|
||||
}
|
||||
$newProxyGroups[] = $ProxyGroup;
|
||||
}
|
||||
}
|
||||
|
||||
return $newProxyGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Surge ProxyGroup 转字符串
|
||||
*
|
||||
* @param array $ProxyGroups Surge 策略组定义
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSurgeProxyGroup2String($ProxyGroups)
|
||||
{
|
||||
$return = '';
|
||||
foreach ($ProxyGroups as $ProxyGroup) {
|
||||
$str = '';
|
||||
if (in_array($ProxyGroup['type'], ['select', 'url-test', 'fallback'])) {
|
||||
$proxies = implode(', ', $ProxyGroup['proxies']);
|
||||
if (in_array($ProxyGroup['type'], ['url-test', 'fallback'])) {
|
||||
$str .= ($ProxyGroup['name']
|
||||
. ' = '
|
||||
. $ProxyGroup['type']
|
||||
. ', '
|
||||
. $proxies
|
||||
. ', url = ' . $ProxyGroup['url']
|
||||
. ', interval = ' . $ProxyGroup['interval']);
|
||||
} else {
|
||||
$str .= ($ProxyGroup['name']
|
||||
. ' = '
|
||||
. $ProxyGroup['type']
|
||||
. ', '
|
||||
. $proxies);
|
||||
}
|
||||
} elseif ($ProxyGroup['type'] == 'ssid') {
|
||||
$wifi = '';
|
||||
foreach ($ProxyGroup['content'] as $key => $value) {
|
||||
$wifi .= ', "' . $key . '" = ' . $value;
|
||||
}
|
||||
$cellular = (isset($ProxyGroup['cellular'])
|
||||
? ', cellular = ' . $ProxyGroup['cellular']
|
||||
: '');
|
||||
$str .= ($ProxyGroup['name']
|
||||
. ' = '
|
||||
. $ProxyGroup['type']
|
||||
. ', default = '
|
||||
. $ProxyGroup['default']
|
||||
. $cellular
|
||||
. $wifi);
|
||||
} else {
|
||||
$str .= '';
|
||||
}
|
||||
$return .= "\n$str";
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Surge 配置中的 Rule
|
||||
*
|
||||
* @param array $Rules Surge 规则加载地址
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getSurgeConfRule($Rules, $local)
|
||||
{
|
||||
// 加载本地规则文件
|
||||
if ($local) {
|
||||
$render = ConfRender::getTemplateRender();
|
||||
return $render->fetch(trim($Rules['source']));
|
||||
}
|
||||
|
||||
// 加载远程规则文件
|
||||
$return = '';
|
||||
if (isset($Rules['source']) && $Rules['source'] != '') {
|
||||
$sourceURL = trim($Rules['source']);
|
||||
// 远程规则仅支持 github 以及 gitlab
|
||||
if (preg_match('/^https:\/\/((gist\.)?github\.com|raw\.githubusercontent\.com|gitlab\.com)/i', $sourceURL)) {
|
||||
$return = @file_get_contents($sourceURL);
|
||||
if (!$return) {
|
||||
$return = ('// 远程规则加载失败'
|
||||
. PHP_EOL
|
||||
. 'GEOIP,CN,DIRECT'
|
||||
. PHP_EOL
|
||||
. 'FINAL,DIRECT,dns-failed');
|
||||
}
|
||||
} else {
|
||||
$return = ('// 远程规则仅支持 github 以及 gitlab'
|
||||
. PHP_EOL
|
||||
. 'GEOIP,CN,DIRECT'
|
||||
. PHP_EOL
|
||||
. 'FINAL,DIRECT,dns-failed');
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从远端自定义配置文件生成 Clash 配置
|
||||
*
|
||||
* @param object $User 用户
|
||||
* @param array $AllProxys 全部节点数组
|
||||
* @param string $SourceContent 远程配置内容
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getClashConfs($User, $AllProxys, $Configs, $local = false)
|
||||
{
|
||||
if (isset($Configs['Proxy']) || count($Configs['Proxy']) != 0) {
|
||||
$tmpProxys = array_merge($AllProxys, $Configs['Proxy']);
|
||||
} else {
|
||||
$tmpProxys = $AllProxys;
|
||||
}
|
||||
$Proxys = [];
|
||||
foreach ($tmpProxys as $Proxy) {
|
||||
unset($Proxy['class']);
|
||||
$Proxys[] = $Proxy;
|
||||
}
|
||||
$tmp = self::getClashConfGeneral($Configs['General']);
|
||||
$tmp['Proxy'] = $Proxys;
|
||||
if (isset($Configs['ProxyGroup'])) {
|
||||
$tmp['Proxy Group'] = self::getClashConfProxyGroup(
|
||||
$AllProxys,
|
||||
$Configs['ProxyGroup']
|
||||
);
|
||||
} else {
|
||||
$tmp['Proxy Group'] = self::getClashConfProxyGroup(
|
||||
$AllProxys,
|
||||
$Configs['Proxy Group']
|
||||
);
|
||||
}
|
||||
$Conf = '#!MANAGED-CONFIG '
|
||||
. Config::get('baseUrl') . $_SERVER['REQUEST_URI'] .
|
||||
"\n\n#---------------------------------------------------#" .
|
||||
"\n## 上次更新于:" . date("Y-m-d h:i:s") .
|
||||
"\n#---------------------------------------------------#" .
|
||||
"\n\n"
|
||||
. Yaml::dump($tmp, 4, 2) .
|
||||
"\n\n"
|
||||
. self::getClashConfRule($Configs['Rule'], $local);
|
||||
|
||||
return $Conf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clash 配置中的 General
|
||||
*
|
||||
* @param array $General Clash General 定义
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getClashConfGeneral($General)
|
||||
{
|
||||
if (count($General) != 0) {
|
||||
foreach ($General as $key) {
|
||||
if (in_array(
|
||||
$key,
|
||||
[
|
||||
'Proxy',
|
||||
'Proxy Group',
|
||||
'Rule'
|
||||
]
|
||||
)) {
|
||||
unset($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $General;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clash 配置中的 ProxyGroup
|
||||
*
|
||||
* @param array $Nodes 全部节点数组
|
||||
* @param array $ProxyGroups Clash 策略组定义
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getClashConfProxyGroup($Nodes, $ProxyGroups)
|
||||
{
|
||||
$return = [];
|
||||
foreach ($ProxyGroups as $ProxyGroup) {
|
||||
$tmp = [];
|
||||
if (in_array($ProxyGroup['type'], ['select', 'url-test', 'fallback', 'load-balance'])) {
|
||||
$proxies = [];
|
||||
if (
|
||||
isset($ProxyGroup['content']['left-proxies'])
|
||||
&& count($ProxyGroup['content']['left-proxies']) != 0
|
||||
) {
|
||||
$proxies = $ProxyGroup['content']['left-proxies'];
|
||||
}
|
||||
foreach ($Nodes as $item) {
|
||||
$item['remark'] = $item['name'];
|
||||
$item = self::getMatchProxy($item, $ProxyGroup);
|
||||
if ($item !== null && !in_array($item['name'], $proxies)) {
|
||||
$proxies[] = $item['name'];
|
||||
}
|
||||
}
|
||||
if (isset($ProxyGroup['content']['right-proxies'])) {
|
||||
$proxies = array_merge($proxies, $ProxyGroup['content']['right-proxies']);
|
||||
}
|
||||
$tmp = [
|
||||
'name' => $ProxyGroup['name'],
|
||||
'type' => $ProxyGroup['type'],
|
||||
'proxies' => $proxies
|
||||
];
|
||||
if ($ProxyGroup['type'] != 'select') {
|
||||
$tmp['url'] = $ProxyGroup['url'];
|
||||
$tmp['interval'] = $ProxyGroup['interval'];
|
||||
}
|
||||
$return[] = $tmp;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clash 配置中的 Rule
|
||||
*
|
||||
* @param array $Rules Clash 规则加载地址
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getClashConfRule($Rules, $local)
|
||||
{
|
||||
// 加载本地规则文件
|
||||
if ($local) {
|
||||
$render = ConfRender::getTemplateRender();
|
||||
return $render->fetch(trim($Rules['source']));
|
||||
}
|
||||
|
||||
// 加载远程规则文件
|
||||
$return = ('Rule:' . PHP_EOL);
|
||||
if (isset($Rules['source']) && $Rules['source'] != '') {
|
||||
$sourceURL = trim($Rules['source']);
|
||||
// 远程规则仅支持 github 以及 gitlab
|
||||
if (preg_match('/^https:\/\/((gist\.)?github\.com|raw\.githubusercontent\.com|gitlab\.com)/i', $sourceURL)) {
|
||||
$sourceContent = @file_get_contents($sourceURL);
|
||||
if (!$sourceContent) {
|
||||
$return .= ('// 远程规则加载失败'
|
||||
. PHP_EOL
|
||||
. 'GEOIP,CN,DIRECT'
|
||||
. PHP_EOL
|
||||
. 'MATCH,DIRECT');
|
||||
} else {
|
||||
try {
|
||||
$sourceRule = Yaml::parse($sourceContent);
|
||||
} catch (ParseException $exception) {
|
||||
$sourceRule['error'] = printf('无法解析 YAML 字符串: %s', $exception->getMessage());
|
||||
}
|
||||
if (isset($sourceRule['error']) || !isset($sourceRule['Rule'])) {
|
||||
$return .= $sourceContent;
|
||||
} else {
|
||||
$return .= Yaml::dump($sourceRule['Rule'], 4, 2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$return .= ('// 远程规则仅支持 github 以及 gitlab'
|
||||
. PHP_EOL
|
||||
. 'GEOIP,CN,DIRECT'
|
||||
. PHP_EOL
|
||||
. 'MATCH,DIRECT');
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clash ProxyGroup 去除无用策略组
|
||||
*
|
||||
* @param array $ProxyGroups 策略组
|
||||
* @param array $checks 要检查的策略组名
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function fixClashProxyGroup($ProxyGroups, $checks)
|
||||
{
|
||||
if (count($checks) == 0) {
|
||||
return $ProxyGroups;
|
||||
}
|
||||
$clean_names = [];
|
||||
$newProxyGroups = [];
|
||||
foreach ($ProxyGroups as $ProxyGroup) {
|
||||
if (in_array($ProxyGroup['name'], $checks) && count($ProxyGroup['proxies']) == 0) {
|
||||
$clean_names[] = $ProxyGroup['name'];
|
||||
continue;
|
||||
}
|
||||
$newProxyGroups[] = $ProxyGroup;
|
||||
}
|
||||
if (count($clean_names) >= 1) {
|
||||
$ProxyGroups = $newProxyGroups;
|
||||
$newProxyGroups = [];
|
||||
foreach ($ProxyGroups as $ProxyGroup) {
|
||||
if (!in_array($ProxyGroup['name'], $checks)) {
|
||||
$newProxies = [];
|
||||
foreach ($ProxyGroup['proxies'] as $proxie) {
|
||||
if (!in_array($proxie, $clean_names)) {
|
||||
$newProxies[] = $proxie;
|
||||
}
|
||||
}
|
||||
$ProxyGroup['proxies'] = $newProxies;
|
||||
}
|
||||
$newProxyGroups[] = $ProxyGroup;
|
||||
}
|
||||
}
|
||||
|
||||
return $newProxyGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clash ProxyGroup 转字符串
|
||||
*
|
||||
* @param array $ProxyGroups ProxyGroup
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getClashProxyGroup2String($ProxyGroups)
|
||||
{
|
||||
return Yaml::dump($ProxyGroups, 4, 2);
|
||||
}
|
||||
|
||||
// 待续 Quantumult...
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
class PayConfig{
|
||||
|
||||
public $pay_config;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->pay_config = [
|
||||
"notify_url" => "/yft/notify",
|
||||
"return_url" => "/user/code",
|
||||
"type" => "aliPay"
|
||||
];
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,440 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\InviteCode;
|
||||
use App\Models\User;
|
||||
use App\Models\Code;
|
||||
use App\Models\Payback;
|
||||
use App\Models\Ann;
|
||||
use App\Models\Shop;
|
||||
use App\Services\Auth;
|
||||
use App\Services\Config;
|
||||
use App\Utils\AliPay;
|
||||
use App\Utils\Tools;
|
||||
use App\Utils\TelegramSessionManager;
|
||||
use App\Utils\Spay_tool;
|
||||
use App\Utils\Geetest;
|
||||
|
||||
use App\Utils\URL;
|
||||
use App\Models\Node;
|
||||
use App\Models\Relay;
|
||||
|
||||
class VueController extends BaseController
|
||||
{
|
||||
public function getGlobalConfig($request, $response, $args)
|
||||
{
|
||||
$GtSdk = null;
|
||||
$recaptcha_sitekey = null;
|
||||
$user = $this->user;
|
||||
if (Config::get('captcha_provider') != '') {
|
||||
switch (Config::get('captcha_provider')) {
|
||||
case 'recaptcha':
|
||||
$recaptcha_sitekey = Config::get('recaptcha_sitekey');
|
||||
break;
|
||||
case 'geetest':
|
||||
$uid = time() . random_int(1, 10000);
|
||||
$GtSdk = Geetest::get($uid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Config::get('enable_telegram') == 'true') {
|
||||
$login_text = TelegramSessionManager::add_login_session();
|
||||
$login = explode('|', $login_text);
|
||||
$login_token = $login[0];
|
||||
$login_number = $login[1];
|
||||
} else {
|
||||
$login_token = '';
|
||||
$login_number = '';
|
||||
}
|
||||
|
||||
$res['globalConfig'] = array(
|
||||
'geetest_html' => $GtSdk,
|
||||
'login_token' => $login_token,
|
||||
'login_number' => $login_number,
|
||||
'telegram_bot' => Config::get('telegram_bot'),
|
||||
'enable_logincaptcha' => Config::get('enable_login_captcha'),
|
||||
'enable_regcaptcha' => Config::get('enable_reg_captcha'),
|
||||
'enable_checkin_captcha' => Config::get('enable_checkin_captcha'),
|
||||
'base_url' => Config::get('baseUrl'),
|
||||
'recaptcha_sitekey' => $recaptcha_sitekey,
|
||||
'captcha_provider' => Config::get('captcha_provider'),
|
||||
'jump_delay' => Config::get('jump_delay'),
|
||||
'register_mode' => Config::get('register_mode'),
|
||||
'enable_email_verify' => Config::get('enable_email_verify'),
|
||||
'appName' => Config::get('appName'),
|
||||
'dateY' => date('Y'),
|
||||
'isLogin' => $user->isLogin,
|
||||
'enable_telegram' => Config::get('enable_telegram'),
|
||||
'enable_mylivechat' => Config::get('enable_mylivechat'),
|
||||
'payment_type' => Config::get('payment_system'),
|
||||
);
|
||||
|
||||
$res['ret'] = 1;
|
||||
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
public function vuelogout($request, $response, $args)
|
||||
{
|
||||
Auth::logout();
|
||||
$res['ret'] = 1;
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
public function getUserInfo($request, $response, $args)
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
if (!$user->isLogin) {
|
||||
$res['ret'] = -1;
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
$pre_user = URL::cloneUser($user);
|
||||
$user->ssr_url_all = URL::getAllUrl($pre_user, 0, 0);
|
||||
$user->ssr_url_all_mu = URL::getAllUrl($pre_user, 1, 0);
|
||||
$user->ss_url_all = URL::getAllUrl($pre_user, 0, 2);
|
||||
$ssinfo = URL::getSSConnectInfo($pre_user);
|
||||
$user->ssd_url_all = URL::getAllSSDUrl($ssinfo);
|
||||
$user->isAbleToCheckin = $user->isAbleToCheckin();
|
||||
$ssr_sub_token = LinkController::GenerateSSRSubCode($this->user->id, 0);
|
||||
$GtSdk = null;
|
||||
$recaptcha_sitekey = null;
|
||||
if (Config::get('captcha_provider') != '') {
|
||||
switch (Config::get('captcha_provider')) {
|
||||
case 'recaptcha':
|
||||
$recaptcha_sitekey = Config::get('recaptcha_sitekey');
|
||||
break;
|
||||
case 'geetest':
|
||||
$uid = time() . random_int(1, 10000);
|
||||
$GtSdk = Geetest::get($uid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$Ann = Ann::orderBy('date', 'desc')->first();
|
||||
$display_ios_class = Config::get('display_ios_class');
|
||||
$ios_account = Config::get('ios_account');
|
||||
$ios_password = Config::get('ios_password');
|
||||
$mergeSub = Config::get('mergeSub');
|
||||
$subUrl = Config::get('subUrl');
|
||||
$baseUrl = Config::get('baseUrl');
|
||||
$user['online_ip_count'] = $user->online_ip_count();
|
||||
|
||||
$res['info'] = array(
|
||||
'user' => $user,
|
||||
'ssrSubToken' => $ssr_sub_token,
|
||||
'displayIosClass' => $display_ios_class,
|
||||
'iosAccount' => $ios_account,
|
||||
'iosPassword' => $ios_password,
|
||||
'mergeSub' => $mergeSub,
|
||||
'subUrl' => $subUrl,
|
||||
'baseUrl' => $baseUrl,
|
||||
'ann' => $Ann,
|
||||
'recaptchaSitekey' => $recaptcha_sitekey,
|
||||
'GtSdk' => $GtSdk,
|
||||
);
|
||||
|
||||
$res['ret'] = 1;
|
||||
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
public function getUserInviteInfo($request, $response, $args)
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
if (!$user->isLogin) {
|
||||
$res['ret'] = -1;
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
$code = InviteCode::where('user_id', $user->id)->first();
|
||||
if ($code == null) {
|
||||
$user->addInviteCode();
|
||||
$code = InviteCode::where('user_id', $user->id)->first();
|
||||
}
|
||||
|
||||
$pageNum = $request->getParam('current');
|
||||
|
||||
$paybacks = Payback::where('ref_by', $user->id)->orderBy('id', 'desc')->paginate(15, ['*'], 'page', $pageNum);
|
||||
if (!$paybacks_sum = Payback::where('ref_by', $user->id)->sum('ref_get')) {
|
||||
$paybacks_sum = 0;
|
||||
}
|
||||
$paybacks->setPath('/#/user/panel');
|
||||
|
||||
$res['inviteInfo'] = array(
|
||||
'code' => $code,
|
||||
'paybacks' => $paybacks,
|
||||
'paybacks_sum' => $paybacks_sum,
|
||||
'invite_num' => $user->invite_num,
|
||||
'invitePrice' => Config::get('invite_price'),
|
||||
'customPrice' => Config::get('custom_invite_price'),
|
||||
'invite_gift' => Config::get('invite_gift'),
|
||||
'invite_get_money' => Config::get('invite_get_money'),
|
||||
'code_payback' => Config::get('code_payback'),
|
||||
);
|
||||
|
||||
$res['ret'] = 1;
|
||||
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
public function getUserShops($request, $response, $args)
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
if (!$user->isLogin) {
|
||||
$res['ret'] = -1;
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
$shops = Shop::where('status', 1)->orderBy('name')->get();
|
||||
|
||||
$res['arr'] = array(
|
||||
'shops' => $shops,
|
||||
);
|
||||
$res['ret'] = 1;
|
||||
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
public function getAllResourse($request, $response, $args)
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
if (!$user->isLogin) {
|
||||
$res['ret'] = -1;
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
$res['resourse'] = array(
|
||||
'money' => $user->money,
|
||||
'class' => $user->class,
|
||||
'class_expire' => $user->class_expire,
|
||||
'expire_in' => $user->expire_in,
|
||||
'online_ip_count' => $user->online_ip_count(),
|
||||
'node_speedlimit' => $user->node_speedlimit,
|
||||
'node_connector' => $user->node_connector,
|
||||
);
|
||||
$res['ret'] = 1;
|
||||
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
public function getNewSubToken($request, $response, $args)
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
if (!$user->isLogin) {
|
||||
$res['ret'] = -1;
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
$user->clean_link();
|
||||
$ssr_sub_token = LinkController::GenerateSSRSubCode($this->user->id, 0);
|
||||
|
||||
$res['arr'] = array(
|
||||
'ssr_sub_token' => $ssr_sub_token,
|
||||
);
|
||||
|
||||
$res['ret'] = 1;
|
||||
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
public function getNewInviteCode($request, $response, $args)
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
if (!$user->isLogin) {
|
||||
$res['ret'] = -1;
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
$user->clear_inviteCodes();
|
||||
$code = InviteCode::where('user_id', $this->user->id)->first();
|
||||
if ($code == null) {
|
||||
$this->user->addInviteCode();
|
||||
$code = InviteCode::where('user_id', $this->user->id)->first();
|
||||
}
|
||||
|
||||
$res['arr'] = array(
|
||||
'code' => $code,
|
||||
);
|
||||
|
||||
$res['ret'] = 1;
|
||||
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
public function getTransfer($request, $response, $args)
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
if (!$user->isLogin) {
|
||||
$res['ret'] = -1;
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
$res['arr'] = array(
|
||||
'todayUsedTraffic' => $user->TodayusedTraffic(),
|
||||
'lastUsedTraffic' => $user->LastusedTraffic(),
|
||||
'unUsedTraffic' => $user->unusedTraffic(),
|
||||
);
|
||||
|
||||
$res['ret'] = 1;
|
||||
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
public function getCaptcha($request, $response, $args)
|
||||
{
|
||||
$GtSdk = null;
|
||||
$recaptcha_sitekey = null;
|
||||
if (Config::get('captcha_provider') != '') {
|
||||
switch (Config::get('captcha_provider')) {
|
||||
case 'recaptcha':
|
||||
$recaptcha_sitekey = Config::get('recaptcha_sitekey');
|
||||
$res['recaptchaKey'] = $recaptcha_sitekey;
|
||||
break;
|
||||
case 'geetest':
|
||||
$uid = time() . random_int(1, 10000);
|
||||
$GtSdk = Geetest::get($uid);
|
||||
$res['GtSdk'] = $GtSdk;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$res['respon'] = 1;
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
public function getChargeLog($request, $response, $args)
|
||||
{
|
||||
$user = $this->user;
|
||||
|
||||
if (!$user->isLogin) {
|
||||
$res['ret'] = -1;
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
$pageNum = $request->getParam('current');
|
||||
|
||||
$codes = Code::where('type', '<>', '-2')->where('userid', '=', $user->id)->orderBy('id', 'desc')->paginate(15, ['*'], 'page', $pageNum);
|
||||
$codes->setPath('/#/user/code');
|
||||
|
||||
$res['codes'] = $codes;
|
||||
$res['ret'] = 1;
|
||||
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
public function getNodeList($request, $response, $args)
|
||||
{
|
||||
$user = Auth::getUser();
|
||||
|
||||
if (!$this->user->isLogin) {
|
||||
$res['ret'] = -1;
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
|
||||
$nodes = Node::where('type', 1)->orderBy('node_class')->orderBy('name')->get();
|
||||
$relay_rules = Relay::where('user_id', $this->user->id)->orwhere('user_id', 0)->orderBy('id', 'asc')->get();
|
||||
if (!Tools::is_protocol_relay($user)) {
|
||||
$relay_rules = array();
|
||||
}
|
||||
|
||||
$array_nodes = array();
|
||||
$nodes_muport = array();
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if ($node->node_group != $user->node_group && $node->node_group != 0) {
|
||||
continue;
|
||||
}
|
||||
if ($node->sort == 9) {
|
||||
$mu_user = User::where('port', '=', $node->server)->first();
|
||||
$mu_user->obfs_param = $this->user->getMuMd5();
|
||||
$nodes_muport[] = array('server' => $node, 'user' => $mu_user);
|
||||
continue;
|
||||
}
|
||||
$array_node = array();
|
||||
|
||||
$array_node['id'] = $node->id;
|
||||
$array_node['class'] = $node->node_class;
|
||||
$array_node['name'] = $node->name;
|
||||
if ($this->user->class < $node->node_class) {
|
||||
$array_node['server'] = '***.***.***.***';
|
||||
} elseif ($node->sort == 13) {
|
||||
$server = Tools::ssv2Array($node->server);
|
||||
$array_node['server'] = $server['add'];
|
||||
} else {
|
||||
$array_node['server'] = $node->server;
|
||||
}
|
||||
|
||||
$array_node['sort'] = $node->sort;
|
||||
$array_node['info'] = $node->info;
|
||||
$array_node['mu_only'] = $node->mu_only;
|
||||
$array_node['group'] = $node->node_group;
|
||||
|
||||
$array_node['raw_node'] = $node;
|
||||
$regex = Config::get('flag_regex');
|
||||
$matches = array();
|
||||
preg_match($regex, $node->name, $matches);
|
||||
if (isset($matches[0])) {
|
||||
$array_node['flag'] = $matches[0] . '.png';
|
||||
} else {
|
||||
$array_node['flag'] = 'unknown.png';
|
||||
}
|
||||
|
||||
$node_online = $node->isNodeOnline();
|
||||
if ($node_online === null) {
|
||||
$array_node['online'] = 0;
|
||||
} elseif ($node_online === true) {
|
||||
$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['traffic_used'] = (int)Tools::flowToGB($node->node_bandwidth);
|
||||
$array_node['traffic_limit'] = (int)Tools::flowToGB($node->node_bandwidth_limit);
|
||||
if ($node->node_speedlimit == 0.0) {
|
||||
$array_node['bandwidth'] = 0;
|
||||
} elseif ($node->node_speedlimit >= 1024.00) {
|
||||
$array_node['bandwidth'] = round($node->node_speedlimit / 1024.00, 1) . 'Gbps';
|
||||
} else {
|
||||
$array_node['bandwidth'] = $node->node_speedlimit . 'Mbps';
|
||||
}
|
||||
|
||||
$array_node['traffic_rate'] = $node->traffic_rate;
|
||||
$array_node['status'] = $node->status;
|
||||
|
||||
$array_nodes[] = $array_node;
|
||||
}
|
||||
|
||||
$res['nodeinfo'] = array(
|
||||
'nodes' => $array_nodes,
|
||||
'nodes_muport' => $nodes_muport,
|
||||
'relay_rules' => $relay_rules,
|
||||
'user' => $user,
|
||||
'tools' => new Tools(),
|
||||
);
|
||||
$res['ret'] = 1;
|
||||
|
||||
return $response->getBody()->write(json_encode($res));
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class Config extends Model
|
||||
{
|
||||
protected $connection = 'default';
|
||||
protected $table = 'config';
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class DetectBanLog extends Model
|
||||
{
|
||||
protected $connection = "default";
|
||||
protected $table = "detect_ban_log";
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class UserSubscribeLog extends Model
|
||||
{
|
||||
protected $connection = 'default';
|
||||
protected $table = 'user_subscribe_log';
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue