Compare commits

..

6 Commits

Author SHA1 Message Date
Rico 5ddb11226f Merge branch 'A-dev' into merge_upstream
# Conflicts:
#	app/Command/Job.php
#	app/Controllers/Admin/UserController.php
#	app/Controllers/Client/ClientApiController.php
#	app/Controllers/HomeController.php
#	app/Controllers/LinkController.php
#	app/Controllers/UserController.php
#	app/Middleware/Mod_Mu.php
#	app/Models/User.php
#	app/Services/Config.php
#	app/Services/Gateway/TomatoPay.php
#	app/Services/Gateway/TrimePay.php
#	app/Services/Payment.php
#	app/Utils/TelegramProcess.php
#	app/Utils/Tools.php
#	app/Utils/URL.php
#	composer.json
#	config/.config.example.php
#	resources/clients/ss-win/使用注意.txt
#	resources/clients/ssd-win/使用注意.txt
#	resources/clients/ssr-win/使用注意.txt
#	resources/views/material/user/index.tpl
#	sql/glzjin_all.sql
7 years ago
Rico 5c7c9c59e6 add tomatoPay.php 7 years ago
Rico aea2272677 merge Merge branch 'dev' of https://github.com/Anankke/SSPanel-Uim into A-dev 7 years ago
Rico 62d3b91540 mergeMerge branch 'dev' of https://github.com/Anankke/SSPanel-Uim into A-dev 7 years ago
Rico 8839d3c7a6 merge upstream Merge branch 'dev' of https://github.com/Anankke/SSPanel-Uim into A-dev 7 years ago
Rico 50c55ea309 排除已经中止的套餐 7 years ago

10
.gitignore vendored

@ -6,7 +6,6 @@
composer.lock
.php_cs.cache
.env
.editorconfig
vendor
php_errors.log
@ -36,11 +35,4 @@ public/.user.ini
resources/views/material/analytics.tpl
.vscode
config/.malio_config.php
malio-noobfs.js
malio-dev.js
malio-release.js
malio.js
resources/email/template
.i18n.php
test/tpl_files.txt

@ -0,0 +1,19 @@
根据时间从 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 托管配置
……

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2017 Javi Aguilar
Copyright (c) 2019 Anankke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

@ -1,121 +0,0 @@
# 欢迎使用 SSPanel V3 魔改再次修改版
**ss-panel-v3-mod**是一款专为 Shadowsocks/ShadowsocksR 设计的管理面板,再次感谢 ss-panel-v3-mod 的制作者,修改后的功能简介:
此仓库由 GeekQu 维护,修改记录 **[在此查看](https://github.com/GeekQu/ss-panel-v3-mod_Uim/blob/dev/GeekQu.md)**。
- **支付系统集成**:集成 支付宝当面付 易付通 码支付 TrimePay 等多种支付系统,使用方法见项目[wiki](https://github.com/Anankke/SSPanel-Uim/wiki/)
- **UI** :修改为 ~~援交~~ 圆角、并自定义了几个图标的显示,节点列表等級 0 可见等級 1 节点但无法看见节点详情,增加了国家图标显示
- **商店**:商品增加同时连接设备数,用户限速属性
- 从肥羊那里**抄**来的:新用户注册现金奖励|高等级节点体验|设备数量限制
- **优化**:css 和 js 等置入本地提升加载速度
- 增加 **v2Ray** 功能,详情请看 wiki: [Indexyz 版](https://github.com/Anankke/SSPanel-Uim/wiki/v2ray---indexyz-%E7%89%88%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B) | [Rico 版](https://github.com/Anankke/SSPanel-Uim/wiki/v2ray---Rico-%E7%89%88%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B)
- 巨量性能优化
- 更多新功能写不下了。(确信)
Telegram 频道 :https://t.me/sspanel_Uim
Telegram ~~可能是个官方~~水群 :https://t.me/SSUnion
记得点小星星!
演示站: [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)
## 搭建教程
GitHub Wiki : https://github.com/Anankke/SSPanel-Uim/wiki/%E5%89%8D%E7%AB%AF%E5%AE%89%E8%A3%85
Wiki 已经启用,欢迎为此面板维护 wiki
#### 鸣谢
##### [Anankke](https://github.com/galaxychuck)
- 面板现**维护者**
##### [galaxychuck](https://github.com/galaxychuck)
- 面板**原作者**
##### [hkserversolution](https://www.hkserversolution.com/cart.php)
- Demo 演示站服务器赞助
##### [dumplin](https://github.com/dumplin233)
- 码支付对接 + 码支付当面付二合一
- 为面板加入 AFF 链接功能
- 商品增加限速和限制 ip 属性
- 多端口订阅
- 解决用户列表加载缓慢历史遗留问题
##### [RinSAMA](https://github.com/mxihan)
- 整理分类 config.php
- 美观性调整
- 客服系统优化
##### [miku](https://github.com/xcxnig)
- 美观和性能优化
##### [Tony Zou](https://github.com/ZJY2003)
- 为公告增加群发邮件功能
- 节点负载情况显示&用户账户过期在首页弹窗提醒
- 增加返利列表
[**Indexyz**](https://github.com/Indexyz)
- 为面板增加 v2Ray 功能
[**NeverBehave**](https://github.com/NeverBehave)
- 添加 Telegram OAuth
[**CGDF**](https://github.com/CGDF-GitHub)
- xcat一键update
- 适配SSD
- 用户列表分页加载
[**CHEN**](https://github.com/ChenSee)
- 免签约支付宝与微信,自带监听,不需第三方软件,直接到个人账户
[**laurieryayoi**](https://github.com/laurieryayoi)
- 重做美化UI(~~援交~~圆角化)
- 重写节点列表,支持分级显示所有级别节点
#### 还有所有被引用过代码的同学,以及所有提交过 pr/issue 的同学。
#### 关于捐赠
您对我们的帮助将是支持我们做下去的动力,只需您在购买部分产品或向他人推荐产品时从我们的返利链接购买,这就是对我们很大的支持了。~~没有钱了,肯定要做啊,不做没有钱用啊,打工是不可能打工的,这辈子不可能打工的~~
##### Anankke
- [Anankke 很可爱请给 Anankke 钱](https://t.me/anankke/5)
##### dumplin
- [码支付-微信收款功能开通](https://codepay.fateqq.com/i/39756)
##### galaxychuck
- [黛米付-支付接入](https://www.daimiyun.cn/register.php?aff=624)
- [冲上云霄云主机](http://console.soar-clouds.com/aff.php?aff=94)
- [Vultr](https://www.vultr.com/?ref=7205737)
[laurieryayoi 的前端课程报名](https://t.me/kinokonominoco)
## 免责声明
本程序由 MIT License 授权。**不提供任何担保**。使用本程序即表明,您知情并同意:程序开发者不对此程序导致的任何服务中断、数据损失或任何少见未列出的事故负责。

@ -1,187 +1,175 @@
# 不能删改页面底部的 Powered by SSPANEL,不能删改staff页面的任何信息。
## 删除Powered by SSPANEL可能会导致你的网站被D,现在 Theme by editXY 可以随意去掉
<img src="https://cdn.jsdelivr.net/npm/skx@0.1.3/img/uim-logo-round.png" alt="logo" width="130" height="130" align="left" />
本主题包含了SSPANEL的完整代码,需要删除原来的面板,然后全新安装(数据库通用),操作前请备份面板
<h1>SSPanel UIM</h1>
## 安装步骤
> Across the Great Wall we can reach every corner in the world
<br/>
[![License](https://img.shields.io/github/license/Anankke/SSPanel-Uim?style=flat-square)](https://github.com/Anankke/SSPanel-Uim/blob/dev/LICENSE)
[![Travis Build Status](https://img.shields.io/travis/Anankke/SSPanel-UIM/master.svg?style=flat-square)](https://travis-ci.org/Anankke/SSPanel-Uim)
![GitHub repo size](https://img.shields.io/github/repo-size/anankke/sspanel-uim?style=flat-square&color=328657)
[![Telegram Channel](https://img.shields.io/badge/news-t.me%2Fsspanel_uim-0d86d7?style=flat-square)](https://t.me/sspanel_uim)
[![Telegram Chat](https://img.shields.io/badge/chat-t.me%2Fssunion-0d86d7?style=flat-square)](https://t.me/ssunion)
# 安装宝塔面板
[演示站点](https://sspanel.host) | [使用文档](https://wiki.sspanel.host) | [更新日志](https://github.com/Anankke/SSPanel-Uim/releases) | [Telegram 频道](https://t.me/sspanel_uim) | [Telegram 水群](https://t.me/ssunion)
使用SSH登录你的VPS,根据你VPS的系统选择下面的安装命令
## 简介
宝塔面板 Centos 一键安装脚本👇
SSPanel UIM 是一款专为 Shadowsocks / ShadowsocksR / V2Ray 设计的多用户管理面板,基于 ss-panel-v3-mod 开发。
```
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
```
宝塔面板 Ubuntu/Debian 一键安装脚本👇
```
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh
```
输入 `y` 回车安装
## AD
执行完毕后,会显示类似下面的宝塔面板的登录信息,请保存好此信息
**特别优惠 Malio SSPANEL 主题 + Rico V2Ray 后端,原价 1000 CNY,现在只需 899 CNY,👉[查看详情](https://malio.fxxkmy.life/)**
```
Bt-Panel: http://xxx.xxx.xx.xx:8888/xxxxxxx
username: xxxxxxx
password: xxxxxxxx
```
# 安装LNMP
登录宝塔面板后,宝塔面板会提示你安装 PHP, MySQL, Nginx 等环境。
## 特性
推荐使用 PHP 7.1、MySQL 5.6、Nginx任意版本。
- 集成超过 8 种支付系统
- 重构面板首页、节点列表、商品列表;新增 SPA(Single Page Apps)版 UI
- 商品增加同时连接设备数,用户限速属性
- 新用户注册现金奖励、用户常规端口切换与指定
- 公共库文件加载使用 jsDelivr
- 支持 V2Ray
- 巨量性能优化
- 更多新功能写不下了
需要一段时间才能安装完成,请等待完成。
## 安装
# 配置PHP
SSPanel UIM 的需要以下程序才能正常的安装和运行:
打开 `宝塔面版 > 软件商店 > 你安装的PHP > 设置`,在禁用函数一栏删除 `system`、`proc_open`、`proc_get_status`、`putenv`、`pcntl_signal`。
- Git
- MySQL
- PHP 7.2+
- Composer
# 安装Malio主题
SSPanel UIM 支持安装在 LNMP、宝塔面板、Plesk 面板、oneinstack 等集成环境中。安装教程请参阅 [文档](https://wiki.sspanel.host)。
打开 `宝塔面版 > 网站 > 添加站点`,输入你的域名,点击提交
## 演示
------
在SSH里执行下面命令👇👇👇
下载SSPANEL+Malio的代码。如果你的这个网站文件夹包含原版的SSPANEL代码,请删除原版SSPANEL代码或者换个目录
[演示站](https://sspanel.host) 每天更新 `dev` 分支最新源码。
```
cd /www/wwwroot/你的网站文件夹名
git clone -b malio https://gitlab.com/maxitio/malio-theme-for-sspanel.git tmp && mv tmp/.git . && rm -rf tmp && git reset --hard
账号:admin
密码:admin
mukey ShirakamiFubuki
```
然后Git会要求你输入Gitlab的账号密码
使用composer安装依赖
## 文档
```
wget https://getcomposer.org/installer -O composer.phar
php composer.phar
php composer.phar install
```
> 我们安装,我们更新,我们开发
用composer安装依赖时如果内存不够的话,可以使用 `宝塔面版 > 首页 > Linux工具箱 > Swap/虚拟内存` 增加虚拟内存
[SSPanel UIM 的文档](https://wiki.sspanel.host),在这里你可以找到大部分问题的解答。
复制配置文件
## 贡献
```
cp config/.malio_config.example.php config/.malio_config.php
cp config/.config.example.php config/.config.php
cp config/.i18n.example.php config/.i18n.php
```
[提出新想法 & 提交 Bug](https://github.com/Anankke/SSPanel-Uim/issues/new) | [改善文档 & 投稿](https://github.com/sspanel-uim/Wiki) | [Fork & Pull Request](https://github.com/Anankke/SSPanel-Uim/fork)
------
SSPanel UIM 欢迎各种贡献,包括但不限于改进,新功能,文档和代码改进,问题和错误报告。
打开 `宝塔面版 > 网站 > 你的网站`
## 协议
在 `网站目录` 里取消勾选 `防跨站攻击`,运行目录里面选择 `/public`,点击保存。
SSPanel UIM 使用 MIT License 开源、不提供任何担保。使用 SSPanel UIM 即表明,您知情并同意:
在 `伪静态` 中填入下面内容,然后保存
- 您在使用 SSPanel UIM 时,必须保留 Staff 页面(该页面包含了 MIT License)和页脚的 Staff 入口
- SSPanel UIM 不会对您的任何损失负责,包括但不限于服务中断、Kernel Panic、机器无法开机或正常使用、数据丢失或硬件损坏、原子弹爆炸、第三次世界大战、SCP 基金会无法阻止 SCP-3125 引发的全球 MK 级现实重构等
```
location / {
try_files $uri /index.php$is_args$args;
}
```
------
## 鸣谢
在SSH里的网站目录下执行,给网站文件755权限
### [HKServerSolution](https://www.hkserversolution.com/cart.php)
```
cd ../
chmod -R 755 你的文件夹名/
chown -R www:www 你的文件夹名/
```
Demo 演示站服务器赞助。
# 数据库操作
### [贡献者](https://github.com/Anankke/SSPanel-Uim/graphs/contributors)
打开 `宝塔面版 > 数据库`,选择添加数据库,数据库名字和用户名任意写,密码建议使用随机生成的密码,点击提交即可添加数据库
SSPanel UIM 离不开所有 [贡献代码](https://github.com/Anankke/SSPanel-Uim/graphs/contributors) 和提交 Issue 的人。
点击数据库名字旁边的 `导入 > 本地上传`,即可上传并导入sql文件到数据库
<details>
<summary>查看贡献者</summary>
如果你是全新安装面板,请上传并导入网站目录下的 `/sql/glzjin_all.sql`、`/sql/malio_all.sql`
#### [Anankke](https://github.com/Anankke)
如果你是从其他主题迁移到Malio主题,请上传并导入网站目录下的 `/sql/malio_all.sql`、`/sql/user_subscribe_log.sql`、`/sql/detect_ban_log.sql`
- 面板现 **维护者**
如果没有导入 `/sql/malio_all.sql` 的话会导致无法注册新用户
#### [galaxychuck](https://github.com/galaxychuck)
将数据库user表里的全部用户的theme列改为malio,使用phpmyadmin执行这条sql语句👉 `UPDATE user SET theme='malio'`
- 面板 **原作者**
# 编辑 config.php
##### [dumplin](https://github.com/dumplin233)
将你的数据库名字,用户名和密码填入.config.php里,类似下面这样
- 码支付对接 + 码支付当面付二合一
- 为面板加入 AFF 链接功能
- 商品增加限速和限制 ip 属性
- 多端口订阅
- 解决用户列表加载缓慢历史遗留问题
```
$_ENV['db_database'] = 'sspanel'; //数据库名
$_ENV['db_username'] = 'sspanel'; //数据库用户名
$_ENV['db_password'] = 'sspanel_password'; //用户名对应的密码
```
##### [RinSAMA](https://github.com/mxihan)
# 其他操作
- 整理分类 config.php
- 美观性调整
- 客服系统优化
在SSH里的网站目录下执行 `php xcat createAdmin`,即可创建管理员用户。(如果你已经有了管理员用户就不用创建了)
##### [miku](https://github.com/xcxnig)
在SSH里的网站目录下执行 `php xcat initQQWry `,即可下载IP数据库(必须要执行这个)
- 美观和性能优化
下载通知频道里的 `GeoLite2-City.mmdb` 文件放入网站目录下的 `/storage/` 目录下
##### [Tony Zou](https://github.com/ZJY2003)
为Crisp和Chatra的跨设备恢复会话功能生成UUID,在SSH里网站目录下执行👉 `php xcat GenerateUUIDforAllUsers`
- 为公告增加群发邮件功能
- 节点负载情况显示&用户账户过期在首页弹窗提醒
- 增加返利列表
# 配置定时任务
[**Indexyz**](https://github.com/Indexyz)
执行 `crontab -e` 命令,添加以下:
- 为面板增加 v2Ray 功能
```
0 0 * * * php -n /www/wwwroot/你的文件夹名/xcat dailyjob
*/1 * * * * php /www/wwwroot/你的文件夹名/xcat checkjob
*/1 * * * * php /www/wwwroot/你的文件夹名/xcat syncnode
```
[**NeverBehave**](https://github.com/NeverBehave)
# 客户端下载
- 添加 Telegram OAuth
客户端的安装包需要自行下载到 `/public/client-download/` 目录,安装包名字参考同目录下的 apps.txt 文件
[**CGDF**](https://github.com/CGDF-GitHub)
另外在此目录下还提供了 [download.sh](https://github.com/sspanel-uim/ssr-download-updater) 脚本,可自动下载部分客户端。
- xcat 一键 update
- 适配 SSD
- 用户列表分页加载
# 请仔细阅读 .malio_config.php 和 .config.php 的全部注释,进一步了解SSPANEL
[**CHEN**](https://github.com/ChenSee)
- 免签约支付宝与微信,自带监听,不需第三方软件,直接到个人账户
[**laurieryayoi**](https://github.com/laurieryayoi)
- 重做美化UI(~~援交~~圆角化)
- 新版 Vue(SPA) 版界面
- 重写节点列表,支持分级显示所有级别节点
[**Sukka**](https://github.com/SukkaW)
- Travis CI 持续集成
- 单元测试
- 全站 JavaScript 重写
- 新版 Wiki 的搭建和维护
## 贡献
</details>
[提出新想法 & 提交 Bug](https://github.com/Cadwalader307/Malio-Theme-for-SSPANEL/issues/new) | [改善文档 & 投稿](https://github.com/Cadwalader307/Malio-Theme-for-SSPANEL/Wiki) | [Fork & Pull Request](https://github.com/Cadwalader307/Malio-Theme-for-SSPANEL/pulls)
## 捐赠
由于原开发团队已经放弃Malio主题,因此此项目欢迎各种贡献,包括但不限于改进,新功能,文档和代码改进,问题和错误报告。
您对我们的帮助将是支持我们做下去的动力。您可以直接进行捐赠,也可以在购买部分产品或向他人推荐产品时从我们的返利链接购买。
## 注意事项
.malio_config.php 文件里的商品id必须设置好,不然在商店plans模式下没办法购买。
#### Anankke
在.config.php里设置新用户注册等级为-1,如果不设置为-1的话,就没有新手引导教程,同时需要在.config.php里设置用户等级过期时间,建议设置为超过一个月的时间(720小时)。
- [Anankke 很可爱请给 Anankke 钱](https://t.me/anankke/5)
安装完成后如果旧用户无法登录的话,检查下 .config.php 里面的 salt 和 pwdMethod 的值是否跟原来的 .config.php 一致。
#### dumplin
端口偏移的说明查看 [端口偏移的食用方法](https://678765.xyz/2019/2.html),根据群友说支持普通端口和单端口,格式跟uim原版的偏移不一样
- [码支付-微信收款功能开通](https://codepay.fateqq.com/i/39756)
如果需要配置Stripe支付接口的话,请看本仓库的wiki
#### galaxychuck
需要去.config.php打开订阅记录的开关才会记录订阅
- [hkserversolution-推荐UIM面板服务器放置](https://www.hkserversolution.com/aff.php?aff=60)
- [moecloud-美國VPS](https://moecloud.asia/aff.php?aff=56)
https://t.me/woaizyg)
#### laurieryayoi
## CREDIT
基于 [Anankke](https://github.com/Anankke),[galaxyq](https://github.com/galaxychuck),[dumplin](https://github.com/dumplin233),[Rin SAMA](https://github.com/mxihan),[Miku](https://github.com/xcxnig),[Tony Zou](https://github.com/ZJY2003),[Nymph](https://github.com/laurieryayoi) 维护的 [SSPanel-Uim](https://github.com/Anankke/SSPanel-Uim) 修改
[laurieryayoi 的前端课程报名](https://t.me/kinokonominoco)

@ -52,7 +52,7 @@ class DailyMail
$sts = new Analytics();
if (Config::getdb('Telegram.enable.Diary') !== '0') {
if (Config::get('sendDiary_Telegram') == 'true') {
Telegram::Send(
str_replace(
array(
@ -63,7 +63,7 @@ class DailyMail
$sts->getTodayCheckinUser(),
Tools::flowAutoShow($lastday_total)
),
Config::getdb('Telegram.msg.Diary')
Config::get('sendDiary_Msg')
)
);
}

@ -19,7 +19,6 @@ use App\Models\TelegramSession;
use App\Models\EmailVerify;
use App\Models\UserSubscribeLog;
use App\Models\DetectBanLog;
use App\Models\TelegramTasks;
use App\Services\Config;
use App\Services\Password;
use App\Utils\DNSoverHTTPS;
@ -31,12 +30,9 @@ use App\Utils\GA;
use App\Utils\Telegram;
use ArrayObject;
use App\Models\Disconnect;
use App\Models\GConfig;
use App\Models\Token;
use App\Models\UnblockIp;
use Exception;
use RuntimeException;
use Ramsey\Uuid\Uuid;
class Job
{
@ -156,8 +152,6 @@ class Job
// 清理订阅记录
UserSubscribeLog::where('request_time', '<', date('Y-m-d H:i:s', time() - 86400 * (int) Config::get('subscribeLog_keep_days')))->delete();
Token::where('expire_time', '<', time())->delete();
NodeInfoLog::where('log_time', '<', time() - 86400 * 3)->delete();
NodeOnlineLog::where('log_time', '<', time() - 86400 * 3)->delete();
TrafficLog::where('log_time', '<', time() - 86400 * 3)->delete();
@ -166,12 +160,12 @@ class Job
EmailVerify::where('expire_in', '<', time() - 86400 * 3)->delete();
system('rm ' . BASE_PATH . '/storage/*.png', $ret);
if (Config::getdb('Telegram.enable.DailyJob') !== '0') {
Telegram::Send(Config::getdb('Telegram.msg.DailyJob'));
if (Config::get('sendDailyJob_Telegram') == 'true') {
Telegram::Send(Config::get('sendDailyJob_Msg'));
}
//auto reset
$boughts = Bought::all();
$boughts = Bought::where('renew', '<>', 0)->get();
$boughted_users = array();
foreach ($boughts as $bought) {
$user = User::where('id', $bought->userid)->first();
@ -308,7 +302,7 @@ class Job
$ips[$alive_ip->ip] = 1;
if ($user->node_connector < count($ips)) {
//暂时封禁
$isDisconnect = Disconnect::where('ip', '=', $alive_ip->ip)->where(
$isDisconnect = Disconnect::where('id', '=', $alive_ip->ip)->where(
'userid',
'=',
$user->id
@ -490,14 +484,11 @@ class Job
} catch (Exception $e) {
echo $e->getMessage();
}
$notice_text = str_replace(
'%node_name%',
$node->name,
Config::getdb('Telegram.msg.NodeOffline')
);
$notice_text = '喵喵喵~ ' . $node->name . ' 节点掉线了喵~';
}
if (Config::getdb('Telegram.enable.NodeOffline') !== '0') {
if (Config::get('sendNodeOffline_Telegram') == true) {
Telegram::Send($notice_text);
}
@ -543,14 +534,11 @@ class Job
} catch (Exception $e) {
echo $e->getMessage();
}
$notice_text = str_replace(
'%node_name%',
$node->name,
Config::getdb('Telegram.msg.NodeOnline')
);
$notice_text = '喵喵喵~ ' . $node->name . ' 节点恢复了喵~';
}
if (Config::getdb('Telegram.enable.NodeOnline') !== '0') {
if (Config::get('sendNodeOnline_Telegram') == true) {
Telegram::Send($notice_text);
}
@ -611,11 +599,6 @@ class Job
$users = User::all();
foreach ($users as $user) {
$user->uuid = Uuid::uuid3(
Uuid::NAMESPACE_DNS,
strval($user->id) . '|' . $user->passwd
)->toString();
$user->save();
if (($user->transfer_enable <= $user->u + $user->d || $user->enable == 0 || (strtotime($user->expire_in) < time() && strtotime($user->expire_in) > 644447105)) && RadiusBan::where(
'userid',
$user->id
@ -798,12 +781,10 @@ class Job
}
// 审计封禁解封
if ($user->enable == 0) {
$logs = DetectBanLog::where('user_id', $user->id)->orderBy('id', 'desc')->first();
if ($logs != null) {
if (($logs->end_time + $logs->ban_time * 60) <= time()) {
$user->enable = 1;
}
if ($user->detect_ban == 1) {
$logs = DetectBanLog::where('user_id', $user->id)->orderBy("id", "desc")->first();
if (($logs->end_time + $logs->ban_time * 60) <= time() || $logs == null) {
$user->detect_ban = 0;
}
}
@ -824,21 +805,6 @@ class Job
Radius::Add($user, $user->passwd);
}
}
if (Config::get('enable_telegram') === true) {
# 删除 tg 消息
$TelegramTasks = TelegramTasks::where('type', 1)->where('executetime', '<', time())->get();
foreach ($TelegramTasks as $Task) {
\App\Utils\Telegram\TelegramTools::SendPost('deleteMessage', ['chat_id' => $Task->chatid, 'message_id' => $Task->messageid]);
TelegramTasks::where('chatid', $Task->chatid)->where('type', '<>', 1)->where('messageid', $Task->messageid)->delete();
$Task->delete();
}
}
if ($_ENV['enable_auto_detect_ban'] === true) {
self::DetectBan();
}
}
public static function detectGFW()
@ -895,13 +861,9 @@ class Job
} catch (Exception $e) {
echo $e->getMessage();
}
$notice_text = str_replace(
'%node_name%',
$node->name,
Config::getdb('Telegram.msg.NodeGFW')
);
$notice_text = '喵喵喵~ ' . $node->name . ' 节点被墙了喵~';
}
if (Config::getdb('Telegram.enable.NodeGFW') !== '0') {
if (Config::get('sendNodeGFW_Telegram') == true) {
Telegram::Send($notice_text);
}
$file_node = fopen(BASE_PATH . '/storage/' . $node->id . '.gfw', 'wb+');
@ -926,13 +888,9 @@ class Job
} catch (Exception $e) {
echo $e->getMessage();
}
$notice_text = str_replace(
'%node_name%',
$node->name,
Config::getdb('Telegram.msg.NodeGFW_recover')
);
$notice_text = '喵喵喵~ ' . $node->name . ' 节点恢复了喵~';
}
if (Config::getdb('Telegram.enable.NodeGFW_recover') !== '0') {
if (Config::get('sendNodeGFW_recover_Telegram') == true) {
Telegram::Send($notice_text);
}
unlink(BASE_PATH . '/storage/' . $node->id . '.gfw');
@ -945,88 +903,4 @@ class Job
sleep(3);
}
}
public static function DetectBan()
{
echo '审计封禁检查开始.';
$last_id = (int) Config::getdb('get.Detect.Log');
$new_logs = DetectLog::where('id', '>', $last_id)->orderBy('id', 'desc')->get();
if (count($new_logs) != 0) {
$Config = GConfig::find('get.Detect.Log');
$Config->value = $new_logs[0]->id;
$Config->save();
$user_logs = [];
foreach ($new_logs as $log) {
if (!in_array($log->user_id, array_keys($user_logs))) {
$user_logs[$log->user_id] = 0;
}
$user_logs[$log->user_id]++;
}
foreach ($user_logs as $userid => $value) {
$user = User::find($userid);
if ($user == null) {
continue;
}
$user->all_detect_number += $value;
$user->save();
if ($user->enable == 0 || ($user->is_admin && Config::get('auto_detect_ban_allow_admin') === true) || in_array($user->id, Config::get('auto_detect_ban_allow_users'))) {
continue;
}
if (Config::get('auto_detect_ban_type') == 1) {
$last_DetectBanLog = DetectBanLog::where('user_id', $userid)->orderBy('id', 'desc')->first();
$last_all_detect_number = ($last_DetectBanLog == null ? 0 : (int) $last_DetectBanLog->all_detect_number);
$detect_number = ($user->all_detect_number - $last_all_detect_number);
if ($detect_number >= Config::get('auto_detect_ban_number')) {
$last_detect_ban_time = $user->last_detect_ban_time;
$end_time = date('Y-m-d H:i:s');
$user->enable = 0;
$user->last_detect_ban_time = $end_time;
$user->save();
$DetectBanLog = new DetectBanLog();
$DetectBanLog->user_name = $user->user_name;
$DetectBanLog->user_id = $user->id;
$DetectBanLog->email = $user->email;
$DetectBanLog->detect_number = $detect_number;
$DetectBanLog->ban_time = Config::get('auto_detect_ban_time');
$DetectBanLog->start_time = strtotime($last_detect_ban_time);
$DetectBanLog->end_time = strtotime($end_time);
$DetectBanLog->all_detect_number = $user->all_detect_number;
$DetectBanLog->save();
}
} else {
$number = $user->all_detect_number;
$tmp = 0;
foreach (Config::get('auto_detect_ban') as $key => $value) {
if ($number >= $key) {
if ($key >= $tmp) {
$tmp = $key;
}
}
}
if ($tmp != 0) {
if (Config::get('auto_detect_ban')[$tmp]['type'] == 'kill') {
$user->kill_user();
} else {
$last_detect_ban_time = $user->last_detect_ban_time;
$end_time = date('Y-m-d H:i:s');
$user->enable = 0;
$user->last_detect_ban_time = $end_time;
$user->save();
$DetectBanLog = new DetectBanLog();
$DetectBanLog->user_name = $user->user_name;
$DetectBanLog->user_id = $user->id;
$DetectBanLog->email = $user->email;
$DetectBanLog->detect_number = $number;
$DetectBanLog->ban_time = Config::get('auto_detect_ban')[$tmp]['time'];
$DetectBanLog->start_time = strtotime('1989-06-04 00:05:00');
$DetectBanLog->end_time = strtotime($end_time);
$DetectBanLog->all_detect_number = $number;
$DetectBanLog->save();
}
}
}
}
}
echo '审计封禁检查结束.';
}
}

@ -1,25 +0,0 @@
<?php
namespace App\Command;
use App\Models\User;
use App\Services\Config;
use Ramsey\Uuid\Uuid;
class Malio
{
public static function GenerateUUIDforAllUsers()
{
$users = User::all();
foreach ($users as $user) {
if ($user->uuid == null) {
$user->uuid = Uuid::uuid3(Uuid::NAMESPACE_DNS, ($user->passwd) . Config::get('key') . $user->id)->toString();
if ($user->save()) {
echo ($user->id . " 生成UUID成功 " . $user->uuid . PHP_EOL);
} else {
echo ($user->id . " 失败 " . $user->uuid . PHP_EOL);
};
}
}
}
}

@ -1,239 +0,0 @@
<?php
/**
* [实验性] 检测到端口被墙则自动更换端口
*
* // 实验性,可能会有惊喜,请确保拥有承受能力
* // 请通过 Crontab 启动,间隔建议 60 分钟以上
*
* PHP version 7.2+
*
* @category GeekQu
* @package App\Command
* @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\Command;
use App\Models\Node;
use App\Models\User;
use App\Services\Config;
use App\Utils\URL;
class PortAutoChange
{
/**
* 配置
*/
private const Config = [
// 取端口范围最小值,新的端口将是之间的随机数
'port_min' => 23333,
// 取端口范围最大值,新的端口将是之间的随机数
'port_max' => 65535,
// 当某个使用的端口的被墙节点数量超过该端口使用总数量的百分比
// 超过该百分比时,直接更换单端口多用户节点(sort=9)和承载用户的端口
// 未超过时,对已被墙该端口的节点进行端口偏移
'mu_node_port_change_percent' => 60,
// 例外的节点,填写节点 ID,英文逗号分隔
// 此处提供的节点将不会进行端口更换
// 即使当原先的承载端口被更换时,也会将例外节点的端口偏移回去
'exception_node_id' => array(),
];
public static function index()
{
$gfw_port_nodes = [];
$nodes = Node::where(
static function ($query) {
$query->where('sort', 0)
->orwhere('sort', 10);
}
)
->where('mu_only', '>=', '0')
->where('type', '1')
->get();
foreach ($nodes as $node) {
$mu_nodes = Node::where('sort', 9)->where('type', '1')
->where(
static function ($query) use ($node) {
$query->Where('node_group', '=', $node->node_group)
->orWhere('node_group', '=', 0);
}
)
->where('node_class', '<=', $node->node_class)
->get();
foreach ($mu_nodes as $mu_node) {
$mu_user = User::where('enable', 1)->where('is_multi_user', '<>', 0)->where('port', '=', $mu_node->server)->first();
if ($mu_user == null) continue;
$port = self::OutPort($node->server, $mu_node->server);
$api_url = Config::get('detect_gfw_url');
$api_url = str_replace(
array('{ip}', '{port}'),
array($node->node_ip, $port),
$api_url
);
$result_tcping = self::DetectPort($api_url);
if ($result_tcping) continue;
$gfw_port_nodes[$mu_node->server][] = $node->id;
echo ('#' . $node->id . ' --- ' . $node->name . ' --- ' . $port . ' 端口不通' . PHP_EOL);
}
}
foreach ($gfw_port_nodes as $port => $array) {
$mu_node = Node::where('sort', 9)->where('server', '=', $port)->where('type', '1')->first();
$mu_user = User::where('enable', 1)->where('is_multi_user', '<>', 0)->where('port', '=', $port)->first();
if ($mu_node == null || $mu_user == null) continue;
$mu_port_nodes = Node::where(
static function ($query) {
$query->where('sort', 0)
->orwhere('sort', 10);
}
)
->where(
static function ($query) use ($mu_node) {
if ($mu_node->node_group == 0) {
$query->where('node_group', '>=', 0);
} else {
$query->where('node_group', '=', $mu_node->node_group);
}
}
)
->where('node_class', '>=', $mu_node->node_class)
->where('mu_only', '>=', '0')
->where('type', '1')
->get();
for ($i = 0; $i <= 10; $i++) {
$new_port = rand((int) self::Config['port_min'], (int) self::Config['port_max']);
if (Node::where('sort', 9)->where('server', '=', $new_port)->first() == null && User::where('port', '=', $new_port)->first() == null) {
break;
}
}
$number = (count($array) / count($mu_port_nodes)) * 100;
if ($number >= self::Config['mu_node_port_change_percent']) {
echo ('超过百分比:' . $number . '%'. PHP_EOL);
echo ('#' . $mu_node->id . ' - 单端口承载节点 - ' . $mu_node->name . ' - 更换了新的端口 ' . $new_port . PHP_EOL);
$mu_node->server = $new_port;
$mu_node->save();
echo ('#' . $mu_user->id . ' - 单端口承载用户 - ' . $mu_user->user_name . ' - 更换了新的端口 ' . $new_port . PHP_EOL);
$mu_user->port = $new_port;
$mu_user->save();
foreach ($mu_port_nodes as $mu_port_node) {
$node_port = self::OutPort($mu_port_node->server, $port);
if (in_array($mu_port_node->id, $array) && !in_array($mu_port_node->id, self::Config['exception_node_id'])) {
if ($node_port != $port) {
if ($node_port == $new_port) {
if (strpos($mu_port_node->server, ($port . '#')) !== false) {
for ($i = 0; $i <= 10; $i++) {
$new_mu_node_port = rand((int) self::Config['port_min'], (int) self::Config['port_max']);
if ($new_mu_node_port != $new_port && Node::where('port', '=', $new_mu_node_port)->first() == null && User::where('port', '=', $new_mu_node_port)->first() == null) {
break;
}
}
$mu_port_node->server = str_replace(($port . '#' . $node_port), ($new_port . '#' . $new_mu_node_port), $mu_port_node->server);
echo ('#' . $mu_port_node->id . ' - 节点 - ' . $mu_port_node->name . ' - 端口从 ' . $node_port . ' 偏移到了新的端口 ' . $new_mu_node_port . PHP_EOL);
}
} else {
if (strpos($mu_port_node->server, ($port . '#')) !== false) {
$mu_port_node->server = str_replace(('+' . $port . '#' . $node_port), '', $mu_port_node->server);
$mu_port_node->server = str_replace(($port . '#' . $node_port . '+'), '', $mu_port_node->server);
$mu_port_node->server = str_replace(($port . '#' . $node_port), '', $mu_port_node->server);
echo ('#' . $mu_port_node->id . ' - 节点 - ' . $mu_port_node->name . ' - 端口从 ' . $node_port . ' 偏移到了新的端口 ' . $new_port . PHP_EOL);
}
}
}
} else {
if ($node_port == $port) {
if (strpos($mu_port_node->server, ';') !== false) {
if (strpos($mu_port_node->server, 'port=') !== false) {
$mu_port_node->server = str_replace('port=', ('port=' . $new_port . '#' . $port . '+'), $mu_port_node->server);
} else {
$mu_port_node->server = ($mu_port_node->server . ';port=' . $new_port . '#' . $port);
}
} else {
$mu_port_node->server = ($mu_port_node->server . ';port=' . $new_port . '#' . $port);
}
} else {
if (strpos($mu_port_node->server, ($port . '#')) !== false) {
$mu_port_node->server = str_replace(($port . '#'), ($new_port . '#'), $mu_port_node->server);
}
}
echo ('#' . $mu_port_node->id . ' - 节点 - ' . $mu_port_node->name . ' - 由于端口未被墙或例外设置,已将端口偏移回原端口 ' . $node_port . PHP_EOL);
}
$mu_port_node->save();
}
} else {
foreach ($array as $node_id) {
if (in_array($node_id, self::Config['exception_node_id'])) continue;
$node = Node::find($node_id);
$node_port = self::OutPort($node->server, $port);
if ($node_port != $port) {
if (strpos($node->server, ('#' . $node_port)) !== false) {
echo ('#' . $node->id . ' - 节点 - ' . $node->name . ' - 端口从' . $node_port . '偏移到了新的端口 ' . $new_port . PHP_EOL);
$node->server = str_replace(('#' . $node_port), ('#' . $new_port), $node->server);
}
} else {
if (strpos($node->server, ';') !== false) {
if (strpos($node->server, 'port=') !== false) {
$node->server = str_replace('port=', ('port=' . $port . '#' . $new_port . '+'), $node->server);
} else {
$node->server = ($node->server . ';port=' . $port . '#' . $new_port);
}
} else {
$node->server = ($node->server . ';port=' . $port . '#' . $new_port);
}
echo ('#' . $node->id . ' - 节点 - ' . $node->name . ' - 端口从' . $node_port . '偏移到了新的端口 ' . $new_port . PHP_EOL);
}
$node->save();
}
}
}
}
public static function OutPort($server, $mu_port)
{
$node_port = $mu_port;
if (strpos($server, ';') !== false) {
$node_server = explode(';', $server);
if (strpos($node_server[1], 'port') !== false) {
$item = URL::parse_args($node_server[1]);
if (strpos($item['port'], '#') !== false) {
if (strpos($item['port'], '+') !== false) {
$args_explode = explode('+', $item['port']);
foreach ($args_explode as $arg) {
if ((int) substr($arg, 0, strpos($arg, '#')) == $mu_port) {
$node_port = (int) substr($arg, strpos($arg, '#') + 1);
}
}
} else {
if ((int) substr($item['port'], 0, strpos($item['port'], '#')) == $mu_port) {
$node_port = (int) substr($item['port'], strpos($item['port'], '#') + 1);
}
}
} else {
$node_port = ($mu_port + (int) $item['port']);
}
}
}
return $node_port;
}
public static function DetectPort($api_url)
{
$result_tcping = false;
$detect_time = Config::get('detect_gfw_count');
for ($i = 1; $i <= $detect_time; $i++) {
$json_tcping = json_decode(file_get_contents($api_url), true);
if (eval('return ' . Config::get('detect_gfw_judge') . ';')) {
$result_tcping = true;
break;
}
}
return $result_tcping;
}
}

@ -3,7 +3,6 @@
namespace App\Command;
use App\Services\Config;
use App\Services\DefaultConfig;
class Update
{
@ -12,16 +11,12 @@ class Update
global $_ENV;
$copy_result = copy(BASE_PATH . '/config/.config.php', BASE_PATH . '/config/.config.php.bak');
if ($copy_result == true) {
echo ('备份成功' . PHP_EOL);
echo('备份成功' . PHP_EOL);
} else {
echo ('备份失败,迁移终止' . PHP_EOL);
echo('备份失败,迁移终止' . PHP_EOL);
return false;
}
echo(PHP_EOL);
// 检查并创建新增的配置项
echo DefaultConfig::detectConfigs();
echo(PHP_EOL);
echo('开始升级客户端...' . PHP_EOL);
@ -32,7 +27,7 @@ class Update
$xcat->initQQWry();
echo('升级 QQWry结束' . PHP_EOL);
echo (PHP_EOL);
echo(PHP_EOL);
$config_old = file_get_contents(BASE_PATH . '/config/.config.php');
$config_new = file_get_contents(BASE_PATH . '/config/.config.example.php');
@ -52,7 +47,7 @@ class Update
$matches_new = array();
preg_match($regex, $config_new, $matches_new);
if (isset($matches_new[0]) == false) {
echo ('未找到配置项:' . $key . ' 未能在新config文件中找到,可能已被更名或废弃' . PHP_EOL);
echo('未找到配置项:' . $key . ' 未能在新config文件中找到,可能已被更名或废弃' . PHP_EOL);
continue;
}
@ -62,7 +57,7 @@ class Update
$config_new = str_replace($matches_new[0], $matches_old[0], $config_new);
$migrated[] = '_ENV[\'' . $key . '\']';
}
echo (PHP_EOL);
echo(PHP_EOL);
//检查新增了哪些config
$regex_new = '/_ENV\[\'.*?\'\]/s';
@ -95,9 +90,9 @@ class Update
$difference = substr($difference, 15);
$difference = substr($difference, 0, -2);
echo ('新增配置项:' . $difference . ':' . $comment . PHP_EOL);
echo('新增配置项:' . $difference . ':' . $comment . PHP_EOL);
}
echo ('新增配置项通常带有默认值,因此通常即使不作任何改动网站也可以正常运行' . PHP_EOL);
echo('新增配置项通常带有默认值,因此通常即使不作任何改动网站也可以正常运行' . PHP_EOL);
//输出notice
$regex_notice = '/_ENV\[\'config_migrate_notice\'\].*?(?=\';)/s';
@ -118,21 +113,19 @@ class Update
echo($notice_new);
}
} else {
echo ($notice_new);
echo($notice_new);
}
echo (PHP_EOL);
echo(PHP_EOL);
file_put_contents(BASE_PATH . '/config/.config.php', $config_new);
echo (PHP_EOL . '迁移完成' . PHP_EOL);
echo(PHP_EOL . '迁移完成' . PHP_EOL);
echo (PHP_EOL);
self::update_malio_config($xcat);
echo(PHP_EOL);
echo ('开始升级composer依赖...' . PHP_EOL);
echo('开始升级composer依赖...' . PHP_EOL);
system('php ' . BASE_PATH . '/composer.phar selfupdate');
system('php ' . BASE_PATH . '/composer.phar install -d ' . BASE_PATH);
echo ('升级composer依赖结束,请自行根据上方输出确认是否升级成功' . PHP_EOL);
echo('升级composer依赖结束,请自行根据上方输出确认是否升级成功' . PHP_EOL);
system('rm -rf ' . BASE_PATH . '/storage/framework/smarty/compile/*');
system('chown -R www:www ' . BASE_PATH . '/storage');
}
@ -140,106 +133,4 @@ class Update
public static function old_to_new($version_old)
{
}
public static function update_malio_config($xcat)
{
echo ('----------开始.malio_config.php迁移工作-----------');
global $Malio_Config;
$copy_result = copy(BASE_PATH . '/config/.malio_config.php', BASE_PATH . '/config/.malio_config.php.bak');
if ($copy_result == true) {
echo ('备份成功' . PHP_EOL);
} else {
echo ('备份失败,迁移终止' . PHP_EOL);
return false;
}
$config_old = file_get_contents(BASE_PATH . '/config/.malio_config.php');
$config_new = file_get_contents(BASE_PATH . '/config/.malio_config.example.php');
$migrated = array();
foreach ($Malio_Config as $key => $value_reserve) {
if ($key == 'config_migrate_notice' || $key == 'version') {
continue;
}
$regex = '/Malio_Config\[\'' . $key . '\'\].*?;/s';
$matches_new = array();
preg_match($regex, $config_new, $matches_new);
if (isset($matches_new[0]) == false) {
echo ('未找到配置项:' . $key . ' 未能在新malio_config文件中找到,可能已被更名或废弃' . PHP_EOL);
continue;
}
$matches_old = array();
preg_match($regex, $config_old, $matches_old);
$config_new = str_replace($matches_new[0], $matches_old[0], $config_new);
$migrated[] = 'Malio_Config[\'' . $key . '\']';
}
echo (PHP_EOL);
//检查新增了哪些config
$regex_new = '/Malio_Config\[\'.*?\'\]/s';
$matches_new_all = array();
preg_match_all($regex_new, $config_new, $matches_new_all);
$differences = array_diff($matches_new_all[0], $migrated);
foreach ($differences as $difference) {
if (
$difference == 'Malio_Config[\'config_migrate_notice\']' ||
$difference == 'Malio_Config[\'version\']'
) {
continue;
}
//匹配注释
$regex_comment = '/' . $difference . '.*?;.*?(?=\n)/s';
$regex_comment = str_replace(array('[', ']'), array('\[', '\]'), $regex_comment);
$matches_comment = array();
preg_match($regex_comment, $config_new, $matches_comment);
$comment = '';
if (isset($matches_comment[0])) {
$comment = $matches_comment[0];
$comment = substr(
$comment,
strpos(
$comment,
'//',
strpos($comment, ';') //查找';'之后的第一个'//',然后substr其后面的comment
) + 2
);
}
//裁去首尾
$difference = substr($difference, 15);
$difference = substr($difference, 0, -2);
echo ('新增配置项:' . $difference . ':' . $comment . PHP_EOL);
}
echo ('新增配置项通常带有默认值,因此通常即使不作任何改动网站也可以正常运行' . PHP_EOL);
//输出notice
$regex_notice = '/System_Config\[\'config_migrate_notice\'\].*?(?=\';)/s';
$matches_notice = array();
preg_match($regex_notice, $config_new, $matches_notice);
$notice_new = $matches_notice[0];
$notice_new = substr(
$notice_new,
strpos(
$notice_new,
'\'',
strpos($notice_new, '=') //查找'='之后的第一个'\'',然后substr其后面的notice
) + 1
);
echo ('以下是迁移附注:');
if (isset($Malio_Config['config_migrate_notice'])) {
if ($Malio_Config['config_migrate_notice'] != $notice_new) {
echo ($notice_new);
}
} else {
echo ($notice_new);
}
echo (PHP_EOL);
file_put_contents(BASE_PATH . '/config/.malio_config.php', $config_new);
echo (PHP_EOL . '.malio_config.php迁移完成' . PHP_EOL);
echo (PHP_EOL);
}
}

@ -13,7 +13,7 @@ use App\Services\Gateway\ChenPay;
use App\Utils\Hash;
use App\Utils\Tools;
use App\Services\Config;
use App\Services\DefaultConfig;
use App\Utils\GA;
use App\Models\Node;
use App\Utils\DNSoverHTTPS;
@ -32,10 +32,6 @@ class XCat
public function boot()
{
switch ($this->argv[1]) {
case ('detectConfigs'):
return $this->detectConfigs();
case ('portAutoChange'):
return PortAutoChange::index();
case ('alipay'):
return (new ChenPay())->AliPayListen();
case ('wxpay'):
@ -98,39 +94,35 @@ class XCat
return $this->resetPort();
case ('resetAllPort'):
return $this->resetAllPort();
case ('update'):
return Update::update($this);
case ('update'):
return Update::update($this);
case ('sendDailyUsageByTG'):
return $this->sendDailyUsageByTG();
case ('npmbuild'):
case ('npmbuild'):
return $this->npmbuild();
case ('getCookie'):
return $this->getCookie();
case ('iptest'):
return $this->iptest();
case ('GenerateUUIDforAllUsers'):
return Malio::GenerateUUIDforAllUsers();
case ('delSubCache'):
return $this->delSubCache();
default:
default:
return $this->defaultAction();
}
}
public function defaultAction()
{
echo (PHP_EOL . '用法: php xcat [选项]' . PHP_EOL);
echo ('常用选项:' . PHP_EOL);
echo (' createAdmin - 创建管理员帐号' . PHP_EOL);
echo (' setTelegram - 设置 Telegram 机器人' . PHP_EOL);
echo (' cleanRelayRule - 清除所有中转规则' . PHP_EOL);
echo (' resetPort - 重置单个用户端口' . PHP_EOL);
echo (' resetAllPort - 重置所有用户端口' . PHP_EOL);
echo (' initdownload - 下载 SSR 程序至服务器' . PHP_EOL);
echo (' initdocuments - 下载用户使用文档至服务器' . PHP_EOL);
echo (' initQQWry - 下载 IP 解析库' . PHP_EOL);
echo (' resetTraffic - 重置所有用户流量' . PHP_EOL);
echo (' update - 更新并迁移配置' . PHP_EOL);
echo(PHP_EOL . '用法: php xcat [选项]' . PHP_EOL);
echo('常用选项:' . PHP_EOL);
echo(' createAdmin - 创建管理员帐号' . PHP_EOL);
echo(' setTelegram - 设置 Telegram 机器人' . PHP_EOL);
echo(' cleanRelayRule - 清除所有中转规则' . PHP_EOL);
echo(' resetPort - 重置单个用户端口' . PHP_EOL);
echo(' resetAllPort - 重置所有用户端口' . PHP_EOL);
echo(' initdownload - 下载 SSR 程序至服务器' . PHP_EOL);
echo(' initdocuments - 下载用户使用文档至服务器' . PHP_EOL);
echo(' initQQWry - 下载 IP 解析库' . PHP_EOL);
echo(' resetTraffic - 重置所有用户流量' . PHP_EOL);
echo(' update - 更新并迁移配置' . PHP_EOL);
}
public function resetPort()
@ -167,9 +159,9 @@ class XCat
{
$rules = Relay::all();
foreach ($rules as $rule) {
echo ($rule->id . "\n");
echo($rule->id . "\n");
if ($rule->source_node_id == 0) {
echo ($rule->id . "被删除!\n");
echo($rule->id . "被删除!\n");
$rule->delete();
continue;
}
@ -177,7 +169,7 @@ class XCat
$ruleset = Relay::where('user_id', $rule->user_id)->orwhere('user_id', 0)->get();
$maybe_rule_id = Tools::has_conflict_rule($rule, $ruleset, $rule->id);
if ($maybe_rule_id != 0) {
echo ($rule->id . "被删除!\n");
echo($rule->id . "被删除!\n");
$rule->delete();
}
}
@ -210,7 +202,7 @@ class XCat
fwrite(STDOUT, "Press [y] to create admin..... 按下[Y]确认来确认创建管理员账户..... \n");
$y = trim(fgets(STDIN));
} elseif (count($this->argv) === 4) {
[,, $email, $passwd] = $this->argv;
[, , $email, $passwd] = $this->argv;
$y = 'y';
}
@ -274,42 +266,33 @@ class XCat
public function setTelegram()
{
if (Config::get('use_new_telegram_bot') === true) {
$WebhookUrl = (Config::get('baseUrl') . '/TelegramCallback?token=' . Config::get('telegram_request_token'));
$telegram = new \Telegram\Bot\Api(Config::get('telegram_token'));
$telegram->removeWebhook();
if ($telegram->setWebhook(['url' => $WebhookUrl])) {
echo('New Bot @' . $telegram->getMe()->getUsername() . ' 设置成功!');
}
} else {
$bot = new BotApi(Config::get('telegram_token'));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, sprintf('https://api.telegram.org/bot%s/deleteWebhook', Config::get('telegram_token')));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$deleteWebhookReturn = json_decode(curl_exec($ch));
curl_close($ch);
if ($deleteWebhookReturn->ok && $deleteWebhookReturn->result && $bot->setWebhook(Config::get('baseUrl') . '/telegram_callback?token=' . Config::get('telegram_request_token')) == 1) {
echo ('Old Bot 设置成功!' . PHP_EOL);
}
$bot = new BotApi(Config::get('telegram_token'));
$ch= curl_init();
curl_setopt ($ch, CURLOPT_URL, sprintf('https://api.telegram.org/bot%s/deleteWebhook', Config::get('telegram_token')));
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
$deleteWebhookReturn = json_decode(curl_exec($ch));
curl_close($ch);
if ($deleteWebhookReturn->ok && $deleteWebhookReturn->result && $bot->setWebhook(Config::get('baseUrl') . '/telegram_callback?token=' . Config::get('telegram_request_token')) == 1) {
echo('设置成功!' . PHP_EOL);
}
}
public function initQQWry()
{
echo ('开始下载纯真 IP 数据库....');
echo('开始下载纯真 IP 数据库....');
$qqwry = file_get_contents('https://qqwry.mirror.noc.one/QQWry.Dat?from=sspanel_uim');
if ($qqwry != '') {
$fp = fopen(BASE_PATH . '/storage/qqwry.dat', 'wb');
if ($fp) {
fwrite($fp, $qqwry);
fclose($fp);
echo ('纯真 IP 数据库下载成功!');
echo('纯真 IP 数据库下载成功!');
} else {
echo ('纯真 IP 数据库保存失败!');
echo('纯真 IP 数据库保存失败!');
}
} else {
echo ('下载失败!请重试,或在 https://github.com/SukkaW/qqwry-mirror/issues/new 反馈!');
echo('下载失败!请重试,或在 https://github.com/SukkaW/qqwry-mirror/issues/new 反馈!');
}
}
@ -348,12 +331,11 @@ class XCat
}
}
public function npmbuild()
{
chdir(BASE_PATH . '/uim-index-dev');
system('npm install');
system('npm run build');
system('cp -u ../public/vuedist/index.html ../resources/views/material/index.tpl');
public function npmbuild(){
chdir(BASE_PATH . '/uim-index-dev');
system('npm install');
system('npm run build');
system('cp -u ../public/vuedist/index.html ../resources/views/material/index.tpl');
}
public function iptest()
@ -369,8 +351,8 @@ class XCat
$ip = DNSoverHTTPS::gethostbyName($server); // returns a collection of DNS A Records
}
}
if ($server != "" and $ip != "") {
echo "Server: " . $server . " ip address: " . $ip . "\n";
if ($server!="" and $ip !="") {
echo "Server: ".$server." ip address: ".$ip."\n";
}
}
}
@ -383,22 +365,4 @@ class XCat
echo Hash::cookieHash($user->pass, $expire_in) . ' ' . $expire_in;
}
}
public function detectConfigs()
{
echo DefaultConfig::detectConfigs();
}
public function delSubCache()
{
if (Config::get('enable_sub_cache') === true) {
if (Tools::delSubCache() === true) {
echo (PHP_EOL . '订阅缓存清理成功.' . PHP_EOL);
} else {
echo (PHP_EOL . '订阅缓存清理失败.' . PHP_EOL);
}
} else {
echo (PHP_EOL . '订阅缓存未开启.' . PHP_EOL);
}
}
}

@ -1,108 +0,0 @@
<?php
namespace App\Controllers\Admin;
use App\Controllers\AdminController;
use App\Services\Auth;
use App\Models\GConfig;
class GConfigController extends AdminController
{
public function update($request, $response, $args)
{
$key = trim($args['key']);
$user = Auth::getUser();
$config = GConfig::find($key);
$config->oldvalue = $config->value;
$config->value = $request->getParam('value');
$config->operator_id = $user->id;
$config->operator_name = $user->user_name;
$config->operator_email = $user->email;
$config->last_update = time();
if (!$config->save()) {
$rs['ret'] = 0;
$rs['msg'] = '修改失败';
return $response->write(json_encode($rs));
}
$rs['ret'] = 1;
$rs['msg'] = '修改成功';
return $response->write(json_encode($rs));
}
public function telegram($request, $response, $args)
{
$table_config['total_column'] = array(
'op' => '操作',
'name' => '配置名称',
'key' => '配置名',
'value' => '配置值',
'operator_id' => '操作员 ID',
'operator_name' => '操作员名称',
'operator_email' => '操作员邮箱',
'last_update' => '修改时间'
);
$table_config['default_show_column'] = array();
foreach ($table_config['total_column'] as $column => $value) {
$table_config['default_show_column'][] = $column;
}
$table_config['ajax_url'] = 'telegram/ajax';
return $this->view()->assign('table_config', $table_config)->fetch('admin/config/telegram/index.tpl');
}
public function telegram_edit($request, $response, $args)
{
$key = trim($args['key']);
$config = GConfig::find($key);
return $this->view()->assign('edit_config', $config)->fetch('admin/config/telegram/edit.tpl');
}
public function telegram_update($request, $response, $args)
{
return self::update($request, $response, $args);
}
public function telegram_ajax($request, $response, $args)
{
$start = $request->getParam("start");
$limit_length = $request->getParam('length');
$configs = GConfig::skip($start)->where('key', 'LIKE', "%Telegram%")->limit($limit_length)->get();
$total_conut = GConfig::where('key', 'LIKE', "%Telegram%")->count();
$data = [];
foreach ($configs as $config) {
$tempdata = [];
$tempdata['op'] = '<a class="btn btn-brand" href="/admin/config/telegram/' . $config->key . '/edit">编辑</a>';
$tempdata['name'] = $config->name;
$tempdata['key'] = $config->key;
$tempdata['value'] = $config->value;
$tempdata['operator_id'] = $config->operator_id;
$tempdata['operator_name'] = $config->operator_name;
$tempdata['operator_email'] = $config->operator_email;
$tempdata['last_update'] = date('Y-m-d H:i:s', $config->last_update);
if (strpos($config->key, '.enable.')) {
switch ((int) $config->value) {
case 0:
$tempdata['value'] = '关闭';
break;
case 1:
$tempdata['value'] = '开启';
break;
default:
$tempdata['value'] = '未知';
break;
}
} else {
$tempdata['value'] = '(请在编辑页面查看)';
}
$data[] = $tempdata;
}
$info = [
'draw' => $request->getParam('draw'),
'recordsTotal' => $total_conut,
'recordsFiltered' => $total_conut,
'data' => $data
];
return json_encode($info, true);
}
}

@ -19,7 +19,7 @@ class NodeController extends AdminController
{
$table_config['total_column'] = array('op' => '操作', 'id' => 'ID', 'name' => '节点名称',
'type' => '显示与隐藏', 'sort' => '类型',
'server' => '节点地址', 'outaddress' => '出口地址', 'node_ip' => '节点IP',
'server' => '节点地址', 'node_ip' => '节点IP',
'info' => '节点信息',
'status' => '状态', 'traffic_rate' => '流量比率', 'node_group' => '节点群组',
'node_class' => '节点等级', 'node_speedlimit' => '节点限速/Mbps',
@ -97,18 +97,16 @@ class NodeController extends AdminController
CloudflareDriver::updateRecord($domain_name[0], $node->node_ip);
}
if (Config::getdb('Telegram.enable.AddNode') !== '0') {
if (Config::get('sendAddNode_Telegram') == 'true') {
Telegram::Send(
str_replace(
'%node_name%',
$request->getParam('name'),
Config::getdb('Telegram.msg.AddNode')
Config::get('sendAddNode_Msg')
)
);
}
Tools::delSubCache();
$rs['ret'] = 1;
$rs['msg'] = '节点添加成功';
return $response->getBody()->write(json_encode($rs));
@ -196,18 +194,16 @@ class NodeController extends AdminController
$node->save();
if (Config::getdb('Telegram.enable.UpdateNode') !== '0') {
if (Config::get('sendUpdateNode_Telegram') == 'true') {
Telegram::Send(
str_replace(
'%node_name%',
$request->getParam('name'),
Config::getdb('Telegram.msg.UpdateNode')
Config::get('sendUpdateNode_Msg')
)
);
}
Tools::delSubCache();
$rs['ret'] = 1;
$rs['msg'] = '修改成功';
return $response->getBody()->write(json_encode($rs));
@ -228,18 +224,16 @@ class NodeController extends AdminController
return $response->getBody()->write(json_encode($rs));
}
if (Config::getdb('Telegram.enable.DeleteNode') !== '0') {
if (Config::get('sendDeleteNode_Telegram') == 'true') {
Telegram::Send(
str_replace(
'%node_name%',
$node->name,
Config::getdb('Telegram.msg.DeleteNode')
Config::get('sendDeleteNode_Msg')
)
);
}
Tools::delSubCache();
$rs['ret'] = 1;
$rs['msg'] = '删除成功';
return $response->getBody()->write(json_encode($rs));
@ -252,7 +246,7 @@ class NodeController extends AdminController
$total_column = array('op' => '操作', 'id' => 'ID', 'name' => '节点名称',
'type' => '显示与隐藏', 'sort' => '类型',
'server' => '节点地址', 'outaddress' => '出口地址', 'node_ip' => '节点IP',
'server' => '节点地址', 'node_ip' => '节点IP',
'info' => '节点信息',
'status' => '状态', 'traffic_rate' => '流量比率', 'node_group' => '节点群组',
'node_class' => '节点等级', 'node_speedlimit' => '节点限速/Mbps',
@ -266,10 +260,6 @@ class NodeController extends AdminController
$key_str .= 'id as op';
continue;
}
if ($single_key == 'outaddress') {
$key_str .= ',server as ' . $single_key;
continue;
}
$key_str .= ',' . $single_key;
}
@ -280,10 +270,6 @@ class NodeController extends AdminController
<a class="btn btn-brand-accent" ' . ($data['sort'] == 999 ? 'disabled' : 'id="delete" value="' . $data['id'] . '" href="javascript:void(0);" onClick="delete_modal_show(\'' . $data['id'] . '\')"') . '>删除</a>';
});
$datatables->edit('outaddress', static function ($data) {
return (in_array($data['sort'], [0, 10, 11, 12, 13, 14]) ? explode(';', $data['server'])[0] : '');
});
$datatables->edit('node_bandwidth', static function ($data) {
return Tools::flowToGB($data['node_bandwidth']);
});
@ -322,9 +308,6 @@ class NodeController extends AdminController
case 13:
$sort = 'Shadowsocks - V2Ray-Plugin';
break;
case 14:
$sort = 'Trojan';
break;
default:
$sort = '系统保留';
}

@ -124,8 +124,6 @@ class RelayController extends AdminController
return $response->getBody()->write(json_encode($rs));
}
Tools::delSubCache();
$rs['ret'] = 1;
$rs['msg'] = '添加成功';
return $response->getBody()->write(json_encode($rs));
@ -236,8 +234,6 @@ class RelayController extends AdminController
return $response->getBody()->write(json_encode($rs));
}
Tools::delSubCache();
$rs['ret'] = 1;
$rs['msg'] = '修改成功';
return $response->getBody()->write(json_encode($rs));
@ -259,9 +255,6 @@ class RelayController extends AdminController
$rs['msg'] = '删除失败';
return $response->getBody()->write(json_encode($rs));
}
Tools::delSubCache();
$rs['ret'] = 1;
$rs['msg'] = '删除成功';
return $response->getBody()->write(json_encode($rs));

@ -17,10 +17,6 @@ use App\Utils\DatatablesHelper;
use App\Controllers\AdminController;
use App\Utils\Telegram;
use TelegramBot\Api\BotApi;
class TicketController extends AdminController
{
public function index($request, $response, $args)
@ -56,36 +52,24 @@ class TicketController extends AdminController
$ticket_main = Ticket::where('id', '=', $id)->where('rootid', '=', 0)->first();
$user = User::where('id','=', $ticket_main->userid)->first();
$ticket_url = Config::get('baseUrl') . '/user/ticket/' . $ticket_main->id . '/view';
$subject = '您提出的工单已被回复';
$to = $user->email;
$text = '管理员已回复您提出的工单';
try {
Mail::send($to, $subject, 'ticket/ticket_reply.tpl', [
'user' => $user, 'text' => $text, 'content' => $content, 'title' => $ticket_main->title, 'ticket_url' => $ticket_url
], [
]);
} catch (Exception $e) {
}
if (Config::get('enable_telegram') == 'true' && $user->telegram_id != null) {
$messageText = 'Hi,'.$user->user_name.PHP_EOL.'管理员已回复您提出的工单'.PHP_EOL.PHP_EOL.'工单标题: '.$ticket_main->title.PHP_EOL.'回复内容: '.$content;
$keyboard = new \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup(
[
[
['text' => '回复工单', 'url' => $ticket_url]
]
]
);
$bot = new BotApi(Config::get('telegram_token'));
//if($status==1&&$ticket_main->status!=$status)
{
$adminUser = User::where('id', '=', $ticket_main->userid)->get();
foreach ($adminUser as $user) {
$subject = Config::get('appName') . '-工单被回复';
$to = $user->email;
$text = '您好,有人回复了<a href="' . Config::get('baseUrl') . '/user/ticket/' . $ticket_main->id . '/view">工单</a>,请您查看。';
try {
$bot->sendMessage($user->telegram_id, $messageText, null, null, null, $keyboard);
Mail::send($to, $subject, 'news/warn.tpl', [
'user' => $user, 'text' => $text
], [
]);
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
$antiXss = new AntiXSS();

@ -7,8 +7,6 @@ use App\Models\Bought;
use App\Models\Ip;
use App\Models\Relay;
use App\Models\User;
use App\Models\DetectBanLog;
use App\Models\Shop;
use App\Services\Auth;
use App\Services\Config;
use App\Services\Mail;
@ -20,7 +18,6 @@ use App\Utils\Radius;
use App\Utils\Tools;
use Exception;
class UserController extends AdminController
{
public function index($request, $response, $args)
@ -335,24 +332,6 @@ class UserController extends AdminController
$user->forbidden_ip = str_replace(PHP_EOL, ',', $request->getParam('forbidden_ip'));
$user->forbidden_port = str_replace(PHP_EOL, ',', $request->getParam('forbidden_port'));
// 手动封禁
$ban_time = (int) $request->getParam('ban_time');
if ($ban_time > 0) {
$user->enable = 0;
$end_time = date('Y-m-d H:i:s');
$user->last_detect_ban_time = $end_time;
$DetectBanLog = new DetectBanLog();
$DetectBanLog->user_name = $user->user_name;
$DetectBanLog->user_id = $user->id;
$DetectBanLog->email = $user->email;
$DetectBanLog->detect_number = '0';
$DetectBanLog->ban_time = $ban_time;
$DetectBanLog->start_time = strtotime('1989-06-04 00:05:00');
$DetectBanLog->end_time = strtotime($end_time);
$DetectBanLog->all_detect_number = $user->all_detect_number;
$DetectBanLog->save();
}
if (!$user->save()) {
$rs['ret'] = 0;
$rs['msg'] = '修改失败';
@ -508,7 +487,6 @@ class UserController extends AdminController
//model里是casts所以没法直接 $tempdata=(array)$user
$tempdata['op'] = '<a class="btn btn-brand" href="/admin/user/' . $user->id . '/edit">编辑</a>
<a class="btn btn-brand-accent" id="delete" href="javascript:void(0);" onClick="delete_modal_show(\'' . $user->id . '\')">删除</a>
<a class="btn btn-brand" href="/admin/user/' . $user->id . '/bought">查套餐</a>
<a class="btn btn-brand" id="changetouser" href="javascript:void(0);" onClick="changetouser_modal_show(\'' . $user->id . '\')">切换为该用户</a>';
$tempdata['id'] = $user->id;
$tempdata['user_name'] = $user->user_name;
@ -575,136 +553,4 @@ class UserController extends AdminController
];
return json_encode($info, true);
}
public function cleanSubCache($request, $response, $args)
{
$id = $args['id'];
$user_path = (BASE_PATH . '/storage/SubscribeCache/' . $id . '/');
Tools::delDirAndFile($user_path);
$res['ret'] = 1;
$res['msg'] = '清理成功';
return $this->echoJson($response, $res);
}
public function bought($request, $response, $args)
{
$id = $args['id'];
$user = User::find($id);
$table_config['total_column'] = array(
'op' => '操作',
'id' => 'ID',
'name' => '商品名称',
'valid' => '是否有效期内',
'auto_renew' => '自动续费时间',
'reset_time' => '流量重置时间',
'buy_time' => '套餐购买时间',
'exp_time' => '套餐过期时间',
'content' => '商品详细内容',
);
$table_config['default_show_column'] = array('op', 'name', 'valid', 'reset_time');
$table_config['ajax_url'] = 'bought/ajax';
$shops = Shop::where('status', 1)->orderBy('name')->get();
return $this->view()->assign('table_config', $table_config)->assign('shops', $shops)->assign('user', $user)->display('admin/user/bought.tpl');
}
public function bought_ajax($request, $response, $args)
{
$start = $request->getParam("start");
$limit_length = $request->getParam('length');
$id = $args['id'];
$user = User::find($id);
$boughts = Bought::where('userid', $user->id)->skip($start)->limit($limit_length)->orderBy('id', 'desc')->get();
$total_conut = Bought::where('userid', $user->id)->count();
$data = [];
foreach ($boughts as $bought) {
$shop = $bought->shop();
if ($shop == null) {
$bought->delete();
continue;
}
$tempdata = [];
$tempdata['op'] = '<a class="btn btn-brand-accent" id="delete" href="javascript:void(0);" onClick="delete_modal_show(\'' . $bought->id . '\')">删除</a>';
$tempdata['id'] = $bought->id;
$tempdata['name'] = $shop->name;
$tempdata['content'] = $shop->content();
$tempdata['auto_renew'] = ($bought->renew == 0 ? '不自动续费' : $bought->renew_date());
$tempdata['buy_time'] = $bought->datetime();
if ($bought->use_loop()) {
$tempdata['valid'] = ($bought->valid() ? '有效' : '已过期');
} else {
$tempdata['valid'] = '-';
}
$tempdata['reset_time'] = $bought->reset_time();
$tempdata['exp_time'] = $bought->exp_time();
$data[] = $tempdata;
}
$info = [
'draw' => $request->getParam('draw'),
'recordsTotal' => $total_conut,
'recordsFiltered' => $total_conut,
'data' => $data
];
return json_encode($info, true);
}
public function bought_delete($request, $response, $args)
{
$id = $request->getParam('id');
$Bought = Bought::find($id);
if (!$Bought->delete()) {
$rs['ret'] = 0;
$rs['msg'] = '删除失败';
return $response->getBody()->write(json_encode($rs));
}
$rs['ret'] = 1;
$rs['msg'] = '删除成功';
return $response->getBody()->write(json_encode($rs));
}
public function bought_add($request, $response, $args)
{
$id = $args['id'];
$user = User::find($id);
$shop_id = (int) $request->getParam('buy_shop');
$buy_type = (int) $request->getParam('buy_type');
if ($shop_id == '') {
$rs['ret'] = 0;
$rs['msg'] = '请选择套餐';
return $response->getBody()->write(json_encode($rs));
}
$shop = Shop::find($shop_id);
if ($shop == null) {
$rs['ret'] = 0;
$rs['msg'] = '套餐不存在';
return $response->getBody()->write(json_encode($rs));
}
if ($buy_type != 0) {
if (bccomp($user->money, $shop->price, 2) == -1) {
$res['ret'] = 0;
$res['msg'] = '喵喵喵~ 该用户余额不足。';
return $response->getBody()->write(json_encode($res));
}
$user->money = bcsub($user->money, $shop->price, 2);
$user->save();
}
$boughts = Bought::where('userid', $user->id)->get();
foreach ($boughts as $disable_bought) {
$disable_bought->renew = 0;
$disable_bought->save();
}
$bought = new Bought();
$bought->userid = $user->id;
$bought->shopid = $shop->id;
$bought->datetime = time();
$bought->renew = 0;
$bought->coupon = '';
$bought->price = $shop->price;
$bought->save();
$shop->buy($user);
$rs['msg'] = ($buy_type != 0 ? '套餐购买成功' : '套餐添加成功');
$rs['ret'] = 1;
return $response->getBody()->write(json_encode($rs));
}
}

@ -21,16 +21,7 @@ class AdminController extends UserController
public function index($request, $response, $args)
{
$sts = new Analytics();
$days = [];
for ($i = 1; $i <= 7; $i++) {
$date_expression = '-'.$i.' days';
$day = strtotime($date_expression);
$days[] = date("Y-m-d", $day);
}
return $this->view()->assign('sts', $sts)->assign('days', $days)->display('admin/index.tpl');
return $this->view()->assign('sts', $sts)->display('admin/index.tpl');
}
public function node($request, $response, $args)
@ -247,79 +238,4 @@ class AdminController extends UserController
$body = $response->getBody();
$body->write($datatables->generate());
}
public function getIncome($request, $response, $args)
{
$date = $request->getParam('date');
$date_in_timestamp = strtotime($date);
//$date_in_timestamp = strtotime('2019-12-12');
$stats = new Analytics();
$today_income = $stats->getIncome($date_in_timestamp, $date_in_timestamp+86400);
$yesterday_income = $stats->getIncome($date_in_timestamp-86400, $date_in_timestamp);
$first_day_of_this_week_timestamp = strtotime("last monday midnight",$date_in_timestamp);
$first_day_of_next_week_timestamp = strtotime("next monday midnight",$date_in_timestamp);
$this_week_income = $stats->getIncome($first_day_of_this_week_timestamp, $first_day_of_next_week_timestamp);
$first_day_of_last_week_timestamp = strtotime("last monday midnight",$date_in_timestamp-604800);
$last_week_income = $stats->getIncome($first_day_of_last_week_timestamp, $first_day_of_this_week_timestamp);
$first_day_of_this_month_timestamp = strtotime("first day of this month",$date_in_timestamp);
$first_day_of_next_month_timestamp = strtotime("first day of next month",$date_in_timestamp);
$this_month_income = $stats->getIncome($first_day_of_this_month_timestamp, $first_day_of_next_month_timestamp);
$first_day_of_last_month_timestamp = strtotime("first day of last month",$date_in_timestamp);
$last_moneth_income = $stats->getIncome($first_day_of_last_month_timestamp, $first_day_of_this_month_timestamp);
$res['success'] = true;
$res['error'] = '';
$res['message'] = '';
$res['data'] = array(
"date" => $date,
"todayIncome" => $today_income,
"yesterdayIncome" => $yesterday_income,
"thisWeekIncome" => $this_week_income,
"lastWeekIncome" => $last_week_income,
"thisMonthIncome" => $this_month_income,
"lastMonthIncome" => $last_moneth_income
);
return $response->getBody()->write(json_encode($res));
}
public function newUsers($request, $response, $args)
{
$date = $request->getParam('date');
$date_in_timestamp = strtotime($date);
$stats = new Analytics();
$today_users = $stats->getNewUsers($date_in_timestamp, $date_in_timestamp+86400);
$yesterday_users = $stats->getNewUsers($date_in_timestamp-86400, $date_in_timestamp);
$first_day_of_this_week_timestamp = strtotime("last monday midnight",$date_in_timestamp);
$first_day_of_next_week_timestamp = strtotime("next monday midnight",$date_in_timestamp);
$this_week_users = $stats->getNewUsers($first_day_of_this_week_timestamp, $first_day_of_next_week_timestamp);
$first_day_of_last_week_timestamp = strtotime("last monday midnight",$date_in_timestamp-604800);
$last_week_users = $stats->getNewUsers($first_day_of_last_week_timestamp, $first_day_of_this_week_timestamp);
$first_day_of_this_month_timestamp = strtotime("first day of this month",$date_in_timestamp);
$first_day_of_next_month_timestamp = strtotime("first day of next month",$date_in_timestamp);
$this_month_users = $stats->getNewUsers($first_day_of_this_month_timestamp, $first_day_of_next_month_timestamp);
$first_day_of_last_month_timestamp = strtotime("first day of last month",$date_in_timestamp);
$last_moneth_users = $stats->getNewUsers($first_day_of_last_month_timestamp, $first_day_of_this_month_timestamp);
$res['success'] = true;
$res['error'] = '';
$res['message'] = '';
$res['data'] = array(
"date" => $date,
"today" => $today_users,
"yesterday" => $yesterday_users,
"thisWeek" => $this_week_users,
"lastWeek" => $last_week_users,
"thisMonth" => $this_month_users,
"lastMonth" => $last_moneth_users
);
return $response->getBody()->write(json_encode($res));
}
}

@ -4,7 +4,6 @@ namespace App\Controllers;
use App\Models\InviteCode;
use App\Services\Config;
use App\Services\MalioConfig;
use App\Utils\Check;
use App\Utils\Tools;
use App\Utils\Radius;
@ -17,21 +16,16 @@ use App\Services\Mail;
use App\Models\User;
use App\Models\LoginIp;
use App\Models\EmailVerify;
use App\Models\SmsVerify;
use App\Utils\GA;
use App\Utils\Geetest;
use App\Utils\TelegramSessionManager;
use Ramsey\Uuid\Uuid;
use App\Services\Internationalization;
/**
* AuthController
*/
class AuthController extends BaseController
{
public function login($request, $response, $args)
public function login()
{
$GtSdk = null;
$recaptcha_sitekey = null;
@ -57,34 +51,13 @@ class AuthController extends BaseController
$login_number = '';
}
$welcome = '';
$time = date('G');
if ($time <= 4) {
$welcome = 'Good Night';
} else if ($time <= 12) {
$welcome = 'Good Morning';
} else if ($time <=18) {
$welcome = 'Good Afternoon';
} else {
$welcome = 'Good Evening';
}
$i18n = new Internationalization();
if (MalioConfig::get('only_one_lang') != 'none') {
$i18n->lang = MalioConfig::get('only_one_lang');
} else {
$i18n->detectLang($request, $response, $args);
}
return $this->view()
->assign('geetest_html', $GtSdk)
->assign('login_token', $login_token)
->assign('login_number', $login_number)
->assign('welcome', $welcome)
->assign('telegram_bot', Config::get('telegram_bot'))
->assign('base_url', Config::get('baseUrl'))
->assign('recaptcha_sitekey', $recaptcha_sitekey)
->assign('i18n', $i18n)
->display('auth/login.tpl');
}
@ -176,7 +149,7 @@ class AuthController extends BaseController
$rcode = $ga->verifyCode($user->ga_token, $code);
if (!$rcode) {
$res['ret'] = 2;
$res['ret'] = 0;
$res['msg'] = '两步验证码错误,如果您是丢失了生成器或者错误地设置了这个选项,您可以尝试重置密码,即可取消这个选项。';
return $response->getBody()->write(json_encode($res));
}
@ -257,15 +230,8 @@ class AuthController extends BaseController
}
}
$i18n = new Internationalization();
if (MalioConfig::get('only_one_lang') != 'none') {
$i18n->lang = MalioConfig::get('only_one_lang');
} else {
$i18n->detectLang($request, $response, $args);
}
return $this->view()
->assign('i18n', $i18n)
->assign('geetest_html', $GtSdk)
->assign('enable_email_verify', Config::get('enable_email_verify'))
->assign('code', $code)
@ -346,84 +312,6 @@ class AuthController extends BaseController
return $response->getBody()->write(json_encode($res));
}
public function sendSMS($request, $response, $next)
{
if (MalioConfig::get('enable_sms_verify') == true) {
$phone = $request->getParam('phone');
$phone = trim($phone);
$area_code = $request->getParam('area_code');
$full_phone = $area_code.$phone;
if ($phone == '' || $area_code == '') {
$res['ret'] = 0;
$res['msg'] = '请填写完整的手机号';
return $response->getBody()->write(json_encode($res));
}
$ipcount = SmsVerify::where('ip', '=', $_SERVER['REMOTE_ADDR'])->where('expire_in', '>', time())->count();
if ($ipcount >= (int)MalioConfig::get('sms_verify_iplimit')) {
$res['ret'] = 0;
$res['msg'] = '此IP请求次数过多';
return $response->getBody()->write(json_encode($res));
}
$code = Tools::genRandomNum(6);
$pamas = array(
'access_key' => MalioConfig::get('globalsent_access_key'),
'mobile' => $full_phone,
'content' => '您的注册验证码是 '.$code
);
$url = 'https://api.globalsent.com/send?'.http_build_query($pamas);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$return = curl_exec($ch);
curl_close($ch);
$return = json_decode($return);
if ($return->code != '0000') {
$res['ret'] = 0;
$res['msg'] = '发送短信验证码失败';
return $return->code;
return $response->getBody()->write(json_encode($res));
} else {
$sv = new SmsVerify();
$sv->expire_in = time() + Config::get('email_verify_ttl');
$sv->ip = $_SERVER['REMOTE_ADDR'];
$sv->phone = $full_phone;
$sv->code = $code;
$sv->save();
$res['ret'] = 1;
$res['msg'] = '验证码发送成功,请查收短信。';
return $response->getBody()->write(json_encode($res));
}
/*
{
"code": "0000",
"data": {
"send_id": "312312312",
"mobile": "861212131212",
"messages": "\u3010Malio\u4e91\u3011test",
"count": 1,
"per_price": 0.06,
"count_price": 0.06
},
"message": ""
}
*/
}
$res['ret'] = 0;
return $response->getBody()->write(json_encode($res));
}
public function registerHandle($request, $response)
{
if (Config::get('register_mode') === 'close') {
@ -446,15 +334,6 @@ class AuthController extends BaseController
$wechat = trim($wechat);
// check code
$sms_code = $request->getParam('sms_code');
$sms_code = trim($sms_code);
$phone = $request->getParam('phone');
$phone = trim($phone);
$area_code = $request->getParam('area_code');
$full_phone = $area_code.$phone;
if (Config::get('enable_reg_captcha') === true) {
switch (Config::get('captcha_provider')) {
@ -481,7 +360,7 @@ class AuthController extends BaseController
//dumplin:1、邀请人等级为0则邀请码不可用;2、邀请人invite_num为可邀请次数,填负数则为无限
$c = InviteCode::where('code', $code)->first();
if ($c == null && MalioConfig::get('code_required') == true) {
if ($c == null) {
if (Config::get('register_mode') === 'invite') {
$res['ret'] = 0;
$res['msg'] = '邀请码无效';
@ -495,13 +374,13 @@ class AuthController extends BaseController
return $response->getBody()->write(json_encode($res));
}
if ($gift_user->class == 0 && MalioConfig::get('code_required') == true) {
if ($gift_user->class == 0) {
$res['ret'] = 0;
$res['msg'] = '邀请人不是VIP';
return $response->getBody()->write(json_encode($res));
}
if ($gift_user->invite_num == 0 && MalioConfig::get('code_required') == true) {
if ($gift_user->invite_num == 0) {
$res['ret'] = 0;
$res['msg'] = '邀请人可用邀请次数为0';
return $response->getBody()->write(json_encode($res));
@ -515,19 +394,6 @@ class AuthController extends BaseController
$res['msg'] = '邮箱无效';
return $response->getBody()->write(json_encode($res));
}
$email_postfix = '@'.(explode("@",$email)[1]);
if (in_array($email_postfix, MalioConfig::get('register_email_black_list')) == true) {
$res['ret'] = 0;
$res['msg'] = '邮箱后缀已被拉黑';
return $response->getBody()->write(json_encode($res));
}
if (MalioConfig::get('enable_register_email_restrict') == true) {
if (in_array($email_postfix, MalioConfig::get('register_email_white_list')) == false) {
$res['ret'] = 0;
$res['msg'] = '小老弟还会发送post请求啊';
return $response->getBody()->write(json_encode($res));
}
}
// check email
$user = User::where('email', $email)->first();
if ($user != null) {
@ -545,15 +411,6 @@ class AuthController extends BaseController
}
}
if (MalioConfig::get('enable_sms_verify') == true) {
$smscount = SmsVerify::where('phone', '=', $full_phone)->where('code', '=', $sms_code)->where('expire_in', '>', time())->first();
if ($smscount == null) {
$res['ret'] = 0;
$res['msg'] = '您的短信验证码不正确';
return $response->getBody()->write(json_encode($res));
}
}
// check pwd length
if (strlen($passwd) < 8) {
$res['ret'] = 0;
@ -568,7 +425,6 @@ class AuthController extends BaseController
return $response->getBody()->write(json_encode($res));
}
/*
if ($imtype == '' || $wechat == '') {
$res['ret'] = 0;
$res['msg'] = '请填上你的联络方式';
@ -581,15 +437,9 @@ class AuthController extends BaseController
$res['msg'] = '此联络方式已注册';
return $response->getBody()->write(json_encode($res));
}
*/
if (Config::get('enable_email_verify') == true) {
EmailVerify::where('email', '=', $email)->delete();
}
if (MalioConfig::get('enable_sms_verify') == true) {
SmsVerify::where('phone', '=', $full_phone)->delete();
}
// do reg user
$user = new User();
@ -618,23 +468,16 @@ class AuthController extends BaseController
$user->auto_reset_day = Config::get('reg_auto_reset_day');
$user->auto_reset_bandwidth = Config::get('reg_auto_reset_bandwidth');
$user->money = 0;
if ($full_phone == '') {
$user->phone = null;
} else {
$user->phone = $full_phone;
}
//dumplin:填写邀请人,写入邀请奖励
$user->ref_by = 0;
if (($c != null) && $c->user_id != 0) {
$gift_user = User::where('id', '=', $c->user_id)->first();
if ($gift_user->invite_num != 0) {
$user->ref_by = $c->user_id;
$user->money = Config::get('invite_get_money');
$gift_user->transfer_enable += Config::get('invite_gift') * 1024 * 1024 * 1024;
--$gift_user->invite_num;
$gift_user->save();
};
$user->ref_by = $c->user_id;
$user->money = Config::get('invite_get_money');
$gift_user->transfer_enable += Config::get('invite_gift') * 1024 * 1024 * 1024;
--$gift_user->invite_num;
$gift_user->save();
}
@ -659,11 +502,6 @@ class AuthController extends BaseController
$user->ga_enable = 0;
/* malio 增加UUID */
$user->uuid = Uuid::uuid3(Uuid::NAMESPACE_DNS, ($user->passwd) . Config::get('key') . $user->id)->toString();
/* malio end */
if ($user->save()) {
$res['ret'] = 1;
$res['msg'] = '注册成功!正在进入登录界面';

@ -8,7 +8,6 @@ use App\Services\Auth;
use Slim\Http\Response;
use Psr\Http\Message\ResponseInterface;
use Smarty;
use App\Services\Internationalization;
/**
* BaseController
@ -32,7 +31,6 @@ class BaseController
{
$this->view = View::getSmarty();
$this->user = Auth::getUser();
$this->i18n = new Internationalization();
}
/**

@ -0,0 +1,71 @@
<?php
/**
* Created by PhpStorm.
* User: kaguya
* Date: 2018/06/30
* Time: 21:40
*/
namespace App\Controllers\Client;
use App\Controllers\BaseController;
use App\Controllers\LinkController;
use App\Models\Ann;
use App\Models\User;
use App\Services\Auth;
use App\Services\Config;
use App\Services\Factory;
use App\Utils\Helper;
class ClientApiController extends BaseController
{
public function GetAnnouncement($request, $response, $args)
{
$accessToken = Helper::getParam($request, 'access_token');
$storage = Factory::createTokenStorage();
$token = $storage->get($accessToken);
$user = User::find($token->userId);
$Anns = Ann::orderBy('date', 'desc')->first();
$res['ret'] = 1;
$res['msg'] = 'ok';
$res['data'] = $Anns;
return $this->echoJson($response, $res);
}
public function Redirect($request, $response, $args)
{
$user = Auth::getUser();
$url = $request->getQueryParams()['target'];
if (!$user->isLogin) {
$accessToken = Helper::getParam($request, 'access_token');
$storage = Factory::createTokenStorage();
$token = $storage->get($accessToken);
if ($token == null) {
$res['ret'] = 0;
$res['msg'] = 'token is null';
return $this->echoJson($response, $res);
}
$user = User::find($token->userId);
$time = 3600 * 24;
Auth::login($user->id, $time);
}
return $response->withRedirect($url);
}
public function GetSubLink($request, $response, $args)
{
$accessToken = Helper::getParam($request, 'access_token');
$sub = (Helper::getParam($request, 'sub') != ''
? Helper::getParam($request, 'sub')
: 1);
$storage = Factory::createTokenStorage();
$token = $storage->get($accessToken);
$user = User::find($token->userId);
$ssr_sub_token = LinkController::GenerateSSRSubCode($user->id, 0);
$res['ret'] = 1;
$res['msg'] = 'ok';
$res['data'] = Config::get('subUrl') . $ssr_sub_token . '?sub=' . $sub;
return $this->echoJson($response, $res);
}
}

@ -180,7 +180,7 @@ class ConfController extends BaseController
$return = null;
switch (true) {
case (isset($Rule['content']['class'])):
if (in_array($Proxy['class'], $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;
@ -191,7 +191,7 @@ class ConfController extends BaseController
}
break;
case (isset($Rule['content']['noclass'])):
if (!in_array($Proxy['class'], $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;
@ -358,17 +358,6 @@ class ConfController extends BaseController
*/
public static function getClashConfs($User, $AllProxys, $Configs, $local = false)
{
$confStr = [
'Proxy' => 'proxies',
'ProxyGroup' => 'proxy-groups',
];
if (isset($_GET['newconf']) && (int) $_GET['newconf'] == 0) {
$confStr = [
'Proxy' => 'Proxy',
'ProxyGroup' => 'Proxy Group',
];
}
if (isset($Configs['Proxy']) || count($Configs['Proxy']) != 0) {
$tmpProxys = array_merge($AllProxys, $Configs['Proxy']);
} else {
@ -380,14 +369,14 @@ class ConfController extends BaseController
$Proxys[] = $Proxy;
}
$tmp = self::getClashConfGeneral($Configs['General']);
$tmp[$confStr['Proxy']] = $Proxys;
$tmp['Proxy'] = $Proxys;
if (isset($Configs['ProxyGroup'])) {
$tmp[$confStr['ProxyGroup']] = self::getClashConfProxyGroup(
$tmp['Proxy Group'] = self::getClashConfProxyGroup(
$AllProxys,
$Configs['ProxyGroup']
);
} else {
$tmp[$confStr['ProxyGroup']] = self::getClashConfProxyGroup(
$tmp['Proxy Group'] = self::getClashConfProxyGroup(
$AllProxys,
$Configs['Proxy Group']
);
@ -486,19 +475,14 @@ class ConfController extends BaseController
*/
public static function getClashConfRule($Rules, $local)
{
$confStr = 'rules';
if (isset($_GET['newconf']) && (int) $_GET['newconf'] == 0) {
$confStr = 'Rule';
}
$return = ($confStr . ':' . PHP_EOL);
// 加载本地规则文件
if ($local) {
$render = ConfRender::getTemplateRender();
return $return . $render->fetch(trim($Rules['source']));
return $render->fetch(trim($Rules['source']));
}
// 加载远程规则文件
$return = ('Rule:' . PHP_EOL);
if (isset($Rules['source']) && $Rules['source'] != '') {
$sourceURL = trim($Rules['source']);
// 远程规则仅支持 github 以及 gitlab
@ -516,10 +500,10 @@ class ConfController extends BaseController
} catch (ParseException $exception) {
$sourceRule['error'] = printf('无法解析 YAML 字符串: %s', $exception->getMessage());
}
if (isset($sourceRule['error']) || !isset($sourceRule[$confStr])) {
if (isset($sourceRule['error']) || !isset($sourceRule['Rule'])) {
$return .= $sourceContent;
} else {
$return .= Yaml::dump($sourceRule[$confStr], 4, 2);
$return .= Yaml::dump($sourceRule['Rule'], 4, 2);
}
}
} else {

@ -5,14 +5,11 @@ namespace App\Controllers;
use App\Models\InviteCode;
use App\Services\Auth;
use App\Services\Config;
use App\Services\MalioConfig;
use App\Utils\AliPay;
use App\Utils\TelegramSessionManager;
use App\Utils\TelegramProcess;
use App\Utils\Geetest;
use App\Utils\Tools;
use App\Services\Internationalization;
use App\Utils\Telegram\Process;
use Slim\Http\{Request, Response};
use Psr\Http\Message\ResponseInterface;
@ -42,7 +39,7 @@ class HomeController extends BaseController
}
}
if (Config::get('enable_telegram') == true) {
if (Config::get('enable_telegram')) {
$login_text = TelegramSessionManager::add_login_session();
$login = explode('|', $login_text);
$login_token = $login[0];
@ -52,40 +49,20 @@ class HomeController extends BaseController
$login_number = '';
}
if (Config::get('newIndex') === false && Config::get('theme') == 'material') {
return $response->write($this->view()->fetch('indexold.tpl'));
if ( !Config::get('newIndex') && Config::get('theme') == 'material') {
return $response->write($this->view()->display('indexold.tpl'));
} else {
if (!Auth::getUser()->isLogin) {
$i18n = new Internationalization();
if (MalioConfig::get('only_one_lang') != 'none') {
$i18n->lang = MalioConfig::get('only_one_lang');
} else {
$i18n->detectLang($request, $response, $args);
}
return $response->write($this->view()
->assign('i18n', $i18n)
->assign('geetest_html', $GtSdk)
->assign('login_token', $login_token)
->assign('login_number', $login_number)
->assign('telegram_bot', Config::get('telegram_bot'))
->assign('enable_logincaptcha', Config::get('enable_login_captcha'))
->assign('enable_regcaptcha', Config::get('enable_reg_captcha'))
->assign('base_url', Config::get('baseUrl'))
->assign('recaptcha_sitekey', $recaptcha_sitekey)
->display('index.tpl'));
} else {
return $response->write($this->view()
->assign('geetest_html', $GtSdk)
->assign('login_token', $login_token)
->assign('login_number', $login_number)
->assign('telegram_bot', Config::get('telegram_bot'))
->assign('enable_logincaptcha', Config::get('enable_login_captcha'))
->assign('enable_regcaptcha', Config::get('enable_reg_captcha'))
->assign('base_url', Config::get('baseUrl'))
->assign('recaptcha_sitekey', $recaptcha_sitekey)
->display('index.tpl')
);
}
return $response->write($this->view()
->assign('geetest_html', $GtSdk)
->assign('login_token', $login_token)
->assign('login_number', $login_number)
->assign('telegram_bot', Config::get('telegram_bot'))
->assign('enable_logincaptcha', Config::get('enable_login_captcha'))
->assign('enable_regcaptcha', Config::get('enable_reg_captcha'))
->assign('base_url', Config::get('baseUrl'))
->assign('recaptcha_sitekey', $recaptcha_sitekey)
->fetch('index.tpl'));
}
}
@ -110,6 +87,9 @@ class HomeController extends BaseController
return $response->write($this->view()->assign('codes', $codes)->fetch('code.tpl'));
}
public function down()
{ }
/**
* @param Request $request
* @param Response $response
@ -147,23 +127,6 @@ class HomeController extends BaseController
return $response->write($result);
}
/**
* @param Request $request
* @param Response $response
* @param array $args
*/
public function NewTelegram($request, $response, $args): ResponseInterface
{
$token = $request->getQueryParam('token');
if ($token == Config::get('telegram_request_token')) {
Process::index();
$result = '1';
} else {
$result = '0';
}
return $response->write($result);
}
/**
* @param Request $request
* @param Response $response
@ -231,31 +194,30 @@ class HomeController extends BaseController
public function getDocCenter($request, $response, $args)
{
$user = Auth::getUser();
if (!$user->isLogin && Config::get('enable_documents') === false) {
if (!$user->isLogin && !Config::get('enable_documents')) {
$newResponse = $response->withStatus(302)->withHeader('Location', '/');
return $newResponse;
return $response->write($newResponse);
}
$basePath = Config::get('remote_documents') === true ? Config::get('documents_source') : '/docs/GeekQu';
return $this->view()
$basePath = Config::get('remote_documents') == 'true' ? Config::get('documents_source') : '/docs/GeekQu';
return $response->write($this->view()
->assign('appName', Config::get('documents_name'))
->assign('basePath', $basePath)
->fetch('doc/index.tpl');
->display('doc/index.tpl'));
}
public function getSubLink($request, $response, $args)
{
$type = trim($request->getParam('type'));
$user = Auth::getUser();
if (!$user->isLogin) {
return $msg = '!> ₍₍ ◝(・ω・)◟ ⁾⁾ 您没有登录噢,[点击此处登录](/auth/login \':ignore target=_blank\') 之后再刷新就阔以了啦';
} else {
$subInfo = LinkController::getSubinfo($user, 0);
switch ($type) {
switch ($request->getParam('type')) {
case 'ssr':
$msg = [
'**订阅链接:**',
'```',
$subInfo['ssr'],
$subInfo['ssr'] . '&extend=1',
'```'
];
break;
@ -263,7 +225,7 @@ class HomeController extends BaseController
$msg = [
'**订阅链接:**',
'```',
$subInfo['v2ray'],
$subInfo['v2ray'] . '&extend=1',
'```'
];
break;
@ -299,7 +261,7 @@ class HomeController extends BaseController
$msg = [
'**包含 ss、v2ray 的合并订阅链接:**',
'```',
$subInfo['kitsunebi'],
$subInfo['kitsunebi'] . '&extend=1',
'```'
];
break;
@ -344,20 +306,12 @@ class HomeController extends BaseController
];
break;
default:
if (in_array($type, $subInfo)) {
$msg = [
'```',
$subInfo[$type],
'```'
];
} else {
$msg = [
'获取失败了呢...,请联系管理员。'
];
}
$msg = [
'获取失败了呢...,请联系管理员。'
];
break;
}
}
return implode(PHP_EOL, $msg);
return $response(implode(PHP_EOL, $msg));
}
}

File diff suppressed because it is too large Load Diff

@ -62,16 +62,53 @@ class FuncController extends BaseController
$server = null;
}
foreach ($rules as $rule) {
$dis = $this->get_dis_node_info($rule['dist_node_id']);
if ($dis != null) {
$rule['source_node_sort'] = $node->sort;
$rule['dist_node_sort'] = $dis->sort;
$rule['dist_node_server'] = $dis->server;
} else {
$rule['source_node_sort'] = $node->sort;
$rule['dist_node_sort'] = null;
$rule['dist_node_server'] = null;
if (Config::get('relay_port_migration') == 'true') {
foreach ($rules as $rule) {
$dis = $this->get_dis_node_info($rule['dist_node_id']);
if ($dis != null) {
$rule['source_node_sort'] = $node->sort;
$rule['dist_node_sort'] = $dis->sort;
if (in_array($dis->sort, [0, 10])) {
$dis_server = explode(';', $dis->server);
$rule['dist_node_server'] = $dis_server[0];
} else {
$rule['dist_node_server'] = $dis->server;
}
if (in_array($dis->sort, [0, 10]) && strpos($dis->server, ';') !== false && $dis->mu_only != -1) {
$muPort = Tools::get_MuOutPortArray($dis->server);
$user = User::where('port', '=', $rule['port'])->first();
if ($user != null) {
if ($user->is_multi_user != 0) {
if ($muPort['type'] == 0) {
if (in_array($rule['port'], array_keys($muPort['port']))) {
$rule['port'] = $muPort['port'][$rule['port']];
}
} else {
$rule['port'] = ($rule['port'] + $muPort['type']);
}
}
}
}
} else {
$rule['source_node_sort'] = $node->sort;
$rule['dist_node_sort'] = null;
$rule['dist_node_server'] = null;
}
}
} else {
foreach ($rules as $rule) {
$dis = $this->get_dis_node_info($rule['dist_node_id']);
if ($dis != null) {
$rule['source_node_sort'] = $node->sort;
$rule['dist_node_sort'] = $dis->sort;
$rule['dist_node_server'] = $dis->server;
} else {
$rule['source_node_sort'] = $node->sort;
$rule['dist_node_sort'] = null;
$rule['dist_node_server'] = null;
}
}
}

@ -58,16 +58,6 @@ class NodeController extends BaseController
} else {
$node_server = $node->server;
}
// 0: new node; -1: offline; 1: online
$node_heartbeat = $node->node_heartbeat + 300;
$node_online = -1;
if ($node_heartbeat == 300) {
$node_online = 0;
} elseif ($node_heartbeat > time()) {
$node_online = 1;
}
$res = [
'ret' => 1,
'data' => [
@ -78,8 +68,7 @@ class NodeController extends BaseController
'mu_only' => $node->mu_only,
'sort' => $node->sort,
'server' => $node_server,
'type' => 'ss-panel-v3-mod_Uim',
'online' => $node_online
'type' => 'ss-panel-v3-mod_Uim'
],
];
return $this->echoJson($response, $res);

@ -13,7 +13,6 @@ use App\Controllers\BaseController;
use App\Services\Config;
use App\Utils\Tools;
use App\Utils\URL;
use App\Services\MalioConfig;
class UserController extends BaseController
{
@ -53,7 +52,7 @@ class UserController extends BaseController
if (in_array($node->sort, [0, 10]) && $node->mu_only != -1) {
$mu_port_migration = Config::get('mu_port_migration');
} else {
$mu_port_migration = false;
$mu_port_migration = 'false';
}
/*
@ -62,7 +61,7 @@ class UserController extends BaseController
*/
$users_raw = User::where(
static function ($query) use ($node, $mu_port_migration) {
if ($mu_port_migration === true) {
if ($mu_port_migration == 'true') {
$query->where(
static function ($query1) use ($node) {
if ($node->node_group != 0) {
@ -90,10 +89,10 @@ class UserController extends BaseController
)->orwhere('is_admin', 1);
}
}
)->where('enable', 1)->where('expire_in', '>', date('Y-m-d H:i:s'))->get();
)->where('enable', 1)->where("detect_ban", 0)->where('expire_in', '>', date('Y-m-d H:i:s'))->get();
// 单端口承载用户
if ($mu_port_migration === true) {
if ($mu_port_migration == 'true') {
$mu_users_raw = User::where(
static function ($query) use ($node) {
$query->where(
@ -109,7 +108,7 @@ class UserController extends BaseController
}
)->orwhere('is_admin', 1);
}
)->where('enable', 1)->where('expire_in', '>', date('Y-m-d H:i:s'))->get();
)->where('enable', 1)->where("detect_ban", 0)->where('expire_in', '>', date('Y-m-d H:i:s'))->get();
$muPort = Tools::get_MuOutPortArray($node->server);
if ($muPort['type'] == 0) {
@ -131,26 +130,33 @@ class UserController extends BaseController
$key_list = array('email', 'method', 'obfs', 'obfs_param', 'protocol', 'protocol_param',
'forbidden_ip', 'forbidden_port', 'node_speedlimit', 'disconnect_ip',
'is_multi_user', 'id', 'port', 'passwd', 'u', 'd', 'node_connector',
'sort', 'uuid', 'sha224uuid');
'is_multi_user', 'id', 'port', 'passwd', 'u', 'd');
$users = array();
foreach ($users_raw as $user_raw) {
if ($node->sort == 14) {
$user_raw->sha224uuid = hash('sha224', $user_raw->uuid);
if (Config::get('keep_connect') == 'true') {
foreach ($users_raw as $user_raw) {
if ($user_raw->transfer_enable > $user_raw->u + $user_raw->d) {
$user_raw = Tools::keyFilter($user_raw, $key_list);
$user_raw->uuid = $user_raw->getUuid();
$users[] = $user_raw;
} else {
// 流量耗尽用户限速至 1Mbps
$user_raw = Tools::keyFilter($user_raw, $key_list);
$user_raw->uuid = $user_raw->getUuid();
$user_raw->node_speedlimit = 1;
$users[] = $user_raw;
}
}
if ($user_raw->transfer_enable > $user_raw->u + $user_raw->d) {
$user_raw = Tools::keyFilter($user_raw, $key_list);
$users[] = $user_raw;
} else if (Config::get('keep_connect') === true) {
$user_raw = Tools::keyFilter($user_raw, $key_list);
// 流量耗尽用户限速至 1Mbps
$user_raw->node_speedlimit = 1;
$users[] = $user_raw;
} else {
foreach ($users_raw as $user_raw) {
if ($user_raw->transfer_enable > $user_raw->u + $user_raw->d) {
$user_raw = Tools::keyFilter($user_raw, $key_list);
$user_raw->uuid = $user_raw->getUuid();
$users[] = $user_raw;
}
}
}
$res = [
'ret' => 1,
@ -292,18 +298,49 @@ class UserController extends BaseController
return $this->echoJson($response, $res);
}
if (count($data) > 0) {
foreach ($data as $log) {
$list_id = $log['list_id'];
$user_id = $log['user_id'];
// log
$detect_log = new DetectLog();
$detect_log->user_id = $user_id;
$detect_log->list_id = $list_id;
$detect_log->node_id = $node_id;
$detect_log->datetime = time();
$detect_log->save();
if (Config::get('enable_auto_detect_ban') == 'true') {
$detect_Users = array();
if (count($data) > 0) {
foreach ($data as $log) {
$list_id = $log['list_id'];
$user_id = $log['user_id'];
// log
$detect_log = new DetectLog();
$detect_log->user_id = $user_id;
$detect_log->list_id = $list_id;
$detect_log->node_id = $node_id;
$detect_log->datetime = time();
$detect_log->save();
$User = User::find($user_id);
if ($User == null) {
continue;
}
if (!in_array($user_id, $detect_Users)) {
$detect_Users[] = $user_id;
}
$User->all_detect_number++;
$User->save();
}
}
if (count($detect_Users) > 0) {
self::DetectBan($detect_Users);
}
} else {
if (count($data) > 0) {
foreach ($data as $log) {
$list_id = $log['list_id'];
$user_id = $log['user_id'];
// log
$detect_log = new DetectLog();
$detect_log->user_id = $user_id;
$detect_log->list_id = $list_id;
$detect_log->node_id = $node_id;
$detect_log->datetime = time();
$detect_log->save();
}
}
}
@ -313,4 +350,74 @@ class UserController extends BaseController
];
return $this->echoJson($response, $res);
}
public function DetectBan($detect_Users)
{
foreach ($detect_Users as $user_id) {
$User = User::find($user_id);
if ($User == null) {
continue;
}
if ($User->detect_ban == 1 || ($User->is_admin && Config::get('auto_detect_ban_allow_admin') == 'true') || in_array($User->id, Config::get('auto_detect_ban_allow_users'))) {
continue;
}
if (Config::get('auto_detect_ban_type') == '1') {
$last_DetectBanLog = DetectBanLog::where('user_id', $user_id)->orderBy("id", "desc")->first();
$last_all_detect_number = (
$last_DetectBanLog == null
? 0
: (int) $last_DetectBanLog->all_detect_number
);
$detect_number = ($User->all_detect_number - $last_all_detect_number);
if ($detect_number >= Config::get('auto_detect_ban_number')) {
$last_detect_ban_time = $User->last_detect_ban_time;
$end_time = date('Y-m-d H:i:s');
$User->detect_ban = 1;
$User->last_detect_ban_time = $end_time;
$User->save();
$DetectBanLog = new DetectBanLog();
$DetectBanLog->user_name = $User->user_name;
$DetectBanLog->user_id = $User->id;
$DetectBanLog->email = $User->email;
$DetectBanLog->detect_number = $detect_number;
$DetectBanLog->ban_time = Config::get('auto_detect_ban_time');
$DetectBanLog->start_time = strtotime($last_detect_ban_time);
$DetectBanLog->end_time = strtotime($end_time);
$DetectBanLog->all_detect_number = $User->all_detect_number;
$DetectBanLog->save();
}
} else {
$number = $User->all_detect_number;
$tmp = 0;
foreach (Config::get('auto_detect_ban') as $key => $value) {
if ($number >= $key) {
if ($key >= $tmp) {
$tmp = $key;
}
}
}
if ($tmp != 0) {
if (Config::get('auto_detect_ban')[$tmp]['type'] == 'kill') {
$User->kill_user();
} else {
$last_detect_ban_time = $User->last_detect_ban_time;
$end_time = date('Y-m-d H:i:s');
$User->detect_ban = 1;
$User->last_detect_ban_time = $end_time;
$User->save();
$DetectBanLog = new DetectBanLog();
$DetectBanLog->user_name = $User->user_name;
$DetectBanLog->user_id = $User->id;
$DetectBanLog->email = $User->email;
$DetectBanLog->detect_number = $number;
$DetectBanLog->ban_time = Config::get('auto_detect_ban')[$tmp]['time'];
$DetectBanLog->start_time = strtotime('1989-06-04 00:05:00');
$DetectBanLog->end_time = strtotime($end_time);
$DetectBanLog->all_detect_number = $number;
$DetectBanLog->save();
}
}
}
}
}
}

@ -86,10 +86,10 @@ class RelayController extends UserController
if ($single_path->end_node->id == $path->begin_node->id) {
$path->begin_node = $single_path->begin_node;
if ($path->begin_node->isNodeAccessable() == false) {
$path->path = '' . $single_path->begin_node->name . '' . ' <i class="fas fa-long-arrow-alt-right"></i> ' . $path->path;
$path->path = '<font color="#FF0000">' . $single_path->begin_node->name . '</font>' . ' → ' . $path->path;
$path->status = '阻断';
} else {
$path->path = $single_path->begin_node->name . ' <i class="fas fa-long-arrow-alt-right"></i> ' . $path->path;
$path->path = $single_path->begin_node->name . ' → ' . $path->path;
$path->status = '通畅';
}
@ -100,10 +100,10 @@ class RelayController extends UserController
if ($path->end_node->id == $single_path->begin_node->id) {
$path->end_node = $single_path->end_node;
if ($single_path->end_node->isNodeAccessable() == false) {
$path->path = $path->path . ' <i class="fas fa-long-arrow-alt-right"></i> ' . '' . $single_path->end_node->name . '';
$path->path = $path->path . ' → ' . '<font color="#FF0000">' . $single_path->end_node->name . '</font>';
$path->status = '阻断';
} else {
$path->path = $path->path . ' <i class="fas fa-long-arrow-alt-right"></i> ' . $single_path->end_node->name;
$path->path = $path->path . ' → ' . $single_path->end_node->name;
}
$pathset->offsetUnset($index);
@ -268,8 +268,6 @@ class RelayController extends UserController
return $response->getBody()->write(json_encode($rs));
}
Tools::delSubCache();
$rs['ret'] = 1;
$rs['msg'] = '添加成功';
return $response->getBody()->write(json_encode($rs));
@ -434,8 +432,6 @@ class RelayController extends UserController
return $response->getBody()->write(json_encode($rs));
}
Tools::delSubCache();
$rs['ret'] = 1;
$rs['msg'] = '修改成功';
return $response->getBody()->write(json_encode($rs));
@ -457,9 +453,6 @@ class RelayController extends UserController
$rs['msg'] = '删除失败';
return $response->getBody()->write(json_encode($rs));
}
Tools::delSubCache();
$rs['ret'] = 1;
$rs['msg'] = '删除成功';
return $response->getBody()->write(json_encode($rs));

@ -13,7 +13,6 @@ use App\Models\Coupon;
use App\Models\Bought;
use App\Models\Ticket;
use App\Services\Config;
use App\Services\MalioConfig;
use App\Services\Gateway\ChenPay;
use App\Services\BitPayment;
use App\Services\Payment;
@ -38,10 +37,8 @@ use App\Models\BlockIp;
use App\Models\UnblockIp;
use App\Models\Payback;
use App\Models\Relay;
use App\Models\Token;
use App\Models\UserSubscribeLog;
use App\Utils\QQWry;
use App\Utils\GeoIP2;
use App\Utils\GA;
use App\Utils\Geetest;
use App\Utils\Telegram;
@ -51,8 +48,6 @@ use App\Utils\URL;
use App\Utils\DatatablesHelper;
use App\Services\Mail;
use TelegramBot\Api\BotApi;
/**
* HomeController
*/
@ -78,36 +73,10 @@ class UserController extends BaseController
$Ann = Ann::orderBy('date', 'desc')->first();
if (!$paybacks_sum = Payback::where("ref_by", $this->user->id)->sum('ref_get')) {
$paybacks_sum = 0;
}
$class_left_days = floor((strtotime($this->user->class_expire)-time())/86400)+1;
if ($_ENV['subscribe_client_url'] != '') {
$getClient = new Token();
for ($i = 0; $i < 10; $i++) {
$token = $this->user->id . Tools::genRandomChar(16);
$Elink = Token::where('token', '=', $token)->first();
if ($Elink == null) {
$getClient->token = $token;
break;
}
}
$getClient->user_id = $this->user->id;
$getClient->create_time = time();
$getClient->expire_time = time() + 10 * 60;
$getClient->save();
} else {
$token = '';
}
return $this->view()
->assign('class_left_days', $class_left_days)
->assign('paybacks_sum', $paybacks_sum)
->assign('subInfo', LinkController::getSubinfo($this->user, 0))
->assign('ssr_sub_token', $ssr_sub_token)
->assign('getClient', $token)
->assign('display_ios_class', Config::get('display_ios_class'))
->assign('display_ios_topup', Config::get('display_ios_topup'))
->assign('ios_account', Config::get('ios_account'))
@ -135,15 +104,7 @@ class UserController extends BaseController
$pageNum = $request->getQueryParams()['page'] ?? 1;
$codes = Code::where('type', '<>', '-2')->where('userid', '=', $this->user->id)->orderBy('id', 'desc')->paginate(15, ['*'], 'page', $pageNum);
$codes->setPath('/user/code');
$bought_pageNum = 1;
if (isset($request->getQueryParams()["bought"])) {
$bought_pageNum = $request->getQueryParams()["bought"];
}
$shops = Bought::where("userid", $this->user->id)->orderBy("id", "desc")->paginate(5, ['*'], 'bought', $bought_pageNum);
$shops->setPath('/user/code');
return $this->view()->assign('shops', $shops)->assign('codes', $codes)->assign('pmw', Payment::purchaseHTML())->assign('bitpay', BitPayment::purchaseHTML())->display('user/code.tpl');
return $this->view()->assign('codes', $codes)->assign('pmw', Payment::purchaseHTML())->assign('bitpay', BitPayment::purchaseHTML())->display('user/code.tpl');
}
public function orderDelete($request, $response, $args)
@ -354,7 +315,7 @@ class UserController extends BaseController
if ($code == '') {
$res['ret'] = 0;
$res['msg'] = '6位验证码不能为空';
$res['msg'] = '二维码不能为空';
return $response->getBody()->write(json_encode($res));
}
@ -362,15 +323,13 @@ class UserController extends BaseController
$rcode = $ga->verifyCode($user->ga_token, $code);
if (!$rcode) {
$res['ret'] = 0;
$res['msg'] = '未成功开启';
$res['msg'] = '测试错误';
return $response->getBody()->write(json_encode($res));
}
$user->ga_enable = 1;
$user->save();
$res['ret'] = 1;
$res['msg'] = '成功开启二步验证';
$res['msg'] = '测试成功';
return $response->getBody()->write(json_encode($res));
}
@ -397,20 +356,77 @@ class UserController extends BaseController
public function ResetPort($request, $response, $args)
{
$price = Config::get('port_price');
$user = $this->user;
$temp = $user->ResetPort();
$res['msg'] = $temp['msg'];
$res['ret'] = ($temp['ok'] === true ? 1 : 0);
if ($user->money < $price) {
$res['ret'] = 0;
$res['msg'] = '余额不足';
return $response->getBody()->write(json_encode($res));
}
$origin_port = $user->port;
$user->port = Tools::getAvPort();
$relay_rules = Relay::where('user_id', $user->id)->where('port', $origin_port)->get();
foreach ($relay_rules as $rule) {
$rule->port = $user->port;
$rule->save();
}
$user->money -= $price;
$user->save();
$res['ret'] = 1;
$res['msg'] = $user->port;
return $response->getBody()->write(json_encode($res));
}
public function SpecifyPort($request, $response, $args)
{
$price = Config::get('port_price_specify');
$user = $this->user;
if ($user->money < $price) {
$res['ret'] = 0;
$res['msg'] = '余额不足';
return $response->getBody()->write(json_encode($res));
}
$port = $request->getParam('port');
$temp = $user->SpecifyPort($port);
$res['msg'] = $temp['msg'];
$res['ret'] = ($temp['ok'] === true ? 1 : 0);
if ($port < Config::get('min_port') || $port > Config::get('max_port') || Tools::isInt($port) == false) {
$res['ret'] = 0;
$res['msg'] = '端口不在要求范围内';
return $response->getBody()->write(json_encode($res));
}
$port_occupied = User::pluck('port')->toArray();
if (in_array($port, $port_occupied) == true) {
$res['ret'] = 0;
$res['msg'] = '端口已被占用';
return $response->getBody()->write(json_encode($res));
}
$origin_port = $user->port;
$user->port = $port;
$relay_rules = Relay::where('user_id', $user->id)->where('port', $origin_port)->get();
foreach ($relay_rules as $rule) {
$rule->port = $user->port;
$rule->save();
}
$user->money -= $price;
$user->save();
$res['ret'] = 1;
$res['msg'] = '钦定成功';
return $response->getBody()->write(json_encode($res));
}
@ -422,7 +438,7 @@ class UserController extends BaseController
$user->ga_token = $secret;
$user->save();
return $response->withStatus(302)->withHeader('Location', '/user/profile');
return $response->withStatus(302)->withHeader('Location', '/user/edit');
}
@ -453,6 +469,9 @@ class UserController extends BaseController
if ($user->is_admin == 0 && $node->node_group != $user->node_group && $node->node_group != 0) {
continue;
}
if ($user->is_admin==0 && $user->class<$node->node_class){
continue;
}
if ($node->sort == 9) {
$mu_user = User::where('port', '=', $node->server)->first();
$mu_user->obfs_param = $this->user->getMuMd5();
@ -468,7 +487,7 @@ class UserController extends BaseController
$server = Tools::ssv2Array($node->server);
$array_node['server'] = $server['add'];
} else {
$array_node['server'] = $node->getServer();
$array_node['server'] = $node->server;
}
$array_node['sort'] = $node->sort;
$array_node['info'] = $node->info;
@ -492,7 +511,7 @@ class UserController extends BaseController
if ($log['node_id'] != $node->id) {
continue;
}
if (in_array($sort, array(0, 7, 8, 10, 11, 12, 13, 14))) {
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;
@ -504,7 +523,7 @@ class UserController extends BaseController
// 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, 14)) || $node_heartbeat == 300) {
if (!in_array($sort, array(0, 7, 8, 10, 11, 12, 13)) || $node_heartbeat == 300) {
$array_node['online'] = 0;
} elseif ($node_heartbeat > time()) {
$array_node['online'] = 1;
@ -672,25 +691,7 @@ class UserController extends BaseController
switch ($node->sort) {
case 0:
if ((($user->class >= $node->node_class && ($user->node_group == $node->node_group || $node->node_group == 0)) || $user->is_admin) && ($node->node_bandwidth_limit == 0 || $node->node_bandwidth < $node->node_bandwidth_limit)) {
$nodes_muport = array();
if($node->mu_only != -1) {
$nodes = Node::where('type', 1)->orderBy('node_class')->orderBy('name')->get();
foreach($nodes as $node_mu){
if ($node_mu->sort == 9) {
$mu_user = User::where('port', '=', $node_mu->server)->first();
$mu_user->obfs_param = $this->user->getMuMd5();
$nodes_muport[] = array('server' => $node_mu, 'user' => $mu_user);
}
}
}
return $this->view()
->assign('nodes_muport', $nodes_muport)
->assign('node', $node)
->assign('user', $user)
->assign('mu', $mu)
->assign('relay_rule_id', $relay_rule_id)
->registerClass('URL', URL::class)
->display('user/nodeinfo.tpl');
return $this->view()->assign('node', $node)->assign('user', $user)->assign('mu', $mu)->assign('relay_rule_id', $relay_rule_id)->registerClass('URL', URL::class)->display('user/nodeinfo.tpl');
}
break;
case 1:
@ -731,11 +732,6 @@ class UserController extends BaseController
return $this->view()->assign('node', $node)->assign('user', $user)->assign('mu', $mu)->assign('relay_rule_id', $relay_rule_id)->registerClass('URL', URL::class)->display('user/nodeinfo.tpl');
}
break;
case 14:
if ((($user->class >= $node->node_class && ($user->node_group == $node->node_group || $node->node_group == 0)) || $user->is_admin) && ($node->node_bandwidth_limit == 0 || $node->node_bandwidth < $node->node_bandwidth_limit)) {
return $this->view()->assign('node', $node)->assign('user', $user)->registerClass('URL', URL::class)->display('user/nodeinfo.tpl');
}
break;
default:
echo '微笑';
}
@ -743,11 +739,12 @@ class UserController extends BaseController
public function profile($request, $response, $args)
{
$user = Auth::getUser();
$pageNum = $request->getQueryParams()['page'] ?? 1;
$paybacks = Payback::where('ref_by', $this->user->id)->orderBy('datetime', 'desc')->paginate(15, ['*'], 'page', $pageNum);
$paybacks->setPath('/user/profile');
$iplocation = new QQWry();
$userip = array();
$total = Ip::where('datetime', '>=', time() - 300)->where('userid', '=', $this->user->id)->get();
@ -756,72 +753,37 @@ class UserController extends BaseController
$userloginip = array();
if (MalioConfig::get('ip_database') == 'QQWry') {
$iplocation = new QQWry();
foreach ($totallogin as $single) {
//if(isset($useripcount[$single->userid]))
{
if (!isset($userloginip[$single->ip])) {
//$useripcount[$single->userid]=$useripcount[$single->userid]+1;
$location = $iplocation->getlocation($single->ip);
$userloginip[$single->ip] = iconv('gbk', 'utf-8//IGNORE', $location['country'] . $location['area']);
}
}
}
foreach ($total as $single) {
//if(isset($useripcount[$single->userid]))
{
$single->ip = Tools::getRealIp($single->ip);
$is_node = Node::where('node_ip', $single->ip)->first();
if ($is_node) {
continue;
}
if (!isset($userip[$single->ip])) {
//$useripcount[$single->userid]=$useripcount[$single->userid]+1;
$location = $iplocation->getlocation($single->ip);
$userip[$single->ip] = iconv('gbk', 'utf-8//IGNORE', $location['country'] . $location['area']);
}
foreach ($totallogin as $single) {
//if(isset($useripcount[$single->userid]))
{
if (!isset($userloginip[$single->ip])) {
//$useripcount[$single->userid]=$useripcount[$single->userid]+1;
$location = $iplocation->getlocation($single->ip);
$userloginip[$single->ip] = iconv('gbk', 'utf-8//IGNORE', $location['country'] . $location['area']);
}
}
}
if (MalioConfig::get('ip_database') == 'GeoIP2') {
$ip_location_geoip2 = new GeoIP2();
foreach ($totallogin as $single) {
{
if (!isset($userloginip[$single->ip])) {
$userloginip[$single->ip] = $ip_location_geoip2->getLocation($single->ip, $user->lang);
}
foreach ($total as $single) {
//if(isset($useripcount[$single->userid]))
{
$single->ip = Tools::getRealIp($single->ip);
$is_node = Node::where('node_ip', $single->ip)->first();
if ($is_node) {
continue;
}
}
foreach ($total as $single) {
{
$single->ip = Tools::getRealIp($single->ip);
$is_node = Node::where('node_ip', $single->ip)->first();
if ($is_node) {
continue;
}
if (!isset($userip[$single->ip])) {
$userip[$single->ip] = $ip_location_geoip2->getLocation($single->ip, $user->lang);
}
if (!isset($userip[$single->ip])) {
//$useripcount[$single->userid]=$useripcount[$single->userid]+1;
$location = $iplocation->getlocation($single->ip);
$userip[$single->ip] = iconv('gbk', 'utf-8//IGNORE', $location['country'] . $location['area']);
}
}
}
$bind_token = TelegramSessionManager::add_bind_session($this->user);
return $this->view()
->assign('telegram_bot', Config::get('telegram_bot'))
->assign('bind_token', $bind_token)
->assign('userip', $userip)
->assign('userloginip', $userloginip)
->assign('paybacks', $paybacks)->display('user/profile.tpl');
return $this->view()->assign('userip', $userip)->assign('userloginip', $userloginip)->assign('paybacks', $paybacks)->display('user/profile.tpl');
}
@ -835,25 +797,7 @@ class UserController extends BaseController
public function tutorial($request, $response, $args)
{
$ssr_sub_token = LinkController::GenerateSSRSubCode($this->user->id, 0);
$opts = $request->getQueryParams();
if ($opts['os'] == 'faq') {
return $this->view()->display('user/tutorial/faq.tpl');
}
if ($opts['os'] != '' && $opts['client'] != '') {
$url = 'user/tutorial/'.$opts['os'].'-'.$opts['client'].'.tpl';
return $this->view()
->assign('subInfo', LinkController::getSubinfo($this->user, 0))
->assign('ssr_sub_token', $ssr_sub_token)
->assign('mergeSub', Config::get('mergeSub'))
->assign('subUrl', Config::get('subUrl'))
->assign('user', $this->user)
->registerClass('URL', URL::class)
->assign('baseUrl', Config::get('baseUrl'))
->display($url);
} else {
return $this->view()->display('user/tutorial.tpl');
}
return $this->view()->display('user/tutorial.tpl');
}
@ -874,10 +818,7 @@ class UserController extends BaseController
$config_service = new Config();
$ssr_sub_token = LinkController::GenerateSSRSubCode($this->user->id, 0);
return $this->view()
->assign('ssr_sub_token', $ssr_sub_token)
->assign('user', $this->user)
->assign('schemes', Config::get('user_agreement_scheme'))
->assign('themes', $themes)
@ -1094,14 +1035,10 @@ class UserController extends BaseController
if ($coupon == null) {
$res['ret'] = 0;
$res['msg'] = '此优惠码无效';
return $response->getBody()->write(json_encode($res));
}
if ($coupon->expire < time()) {
$res['ret'] = 0;
$res['msg'] = '优惠码已过期';
$res['msg'] = '优惠码无效';
return $response->getBody()->write(json_encode($res));
}
if ($coupon->order($shop->id) == false) {
$res['ret'] = 0;
$res['msg'] = '此优惠码不可用于此商品';
@ -1120,9 +1057,7 @@ class UserController extends BaseController
$res['ret'] = 1;
$res['name'] = $shop->name;
$res['credit'] = $coupon->credit;
$res['onetime'] = $coupon->onetime;
$res['shop'] = $coupon->shop;
$res['credit'] = $coupon->credit . ' %';
$res['total'] = $shop->price * ((100 - $coupon->credit) / 100) . '元';
return $response->getBody()->write(json_encode($res));
@ -1137,10 +1072,6 @@ class UserController extends BaseController
$disableothers = $request->getParam('disableothers');
$autorenew = $request->getParam('autorenew');
if (MalioConfig::get('shop_enable_trail_plan') == true && MalioConfig::get('shop_trail_plan_shopid') == $shop && $this->user->class >= 0) {
return 0;
};
$shop = Shop::where('id', $shop)->where('status', 1)->first();
if ($shop == null) {
@ -1211,10 +1142,13 @@ class UserController extends BaseController
} else {
$bought->renew = time() + $shop->auto_renew * 86400;
}
$bought->coupon = $code;
if (isset($onetime)) {
$bought->renew = 0;
$price = $shop->price;
}
$bought->coupon = $code;
$bought->price = $price;
$bought->save();
@ -1306,44 +1240,18 @@ class UserController extends BaseController
$ticket->datetime = time();
$ticket->save();
$new_ticket = Ticket::where('userid', $this->user->id)->where('title', $ticket->title)->orderBy('id','desc')->first();
$ticket_url = Config::get('baseUrl').'/admin/ticket/'.$new_ticket->id.'/view';
if (Config::get('mail_ticket') == true && $markdown != '') {
$adminUser = User::where('is_admin', '=', '1')->get();
foreach ($adminUser as $user) {
$subject = '新工单被开启';
$subject = Config::get('appName') . '-新工单被开启';
$to = $user->email;
$text = '有新工单需要您处理';
$text = '管理员,有人开启了新的工单,请您及时处理。';
try {
Mail::send($to, $subject, 'ticket/new_ticket.tpl', [
'user' => $this->user, 'admin' =>$user, 'text' => $text, 'title' => $title, 'content' => $content, 'ticket_url' =>$ticket_url
], [
]);
Mail::send($to, $subject, 'news/warn.tpl', [
'user' => $user, 'text' => $text
], []);
} catch (Exception $e) {
}
}
}
/* notify admins on telegram */
if (Config::get('enable_telegram') == true) {
$messageText = 'Hi,管理员'.PHP_EOL.'有新工单需要您处理'.PHP_EOL.PHP_EOL.$this->user->user_name.': '.$title.PHP_EOL.$content;
$keyboard = new \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup(
[
[
['text' => '回复工单', 'url' => $ticket_url]
]
]
);
$bot = new BotApi(Config::get('telegram_token'));
$adminUser = User::where('is_admin', '=', '1')->get();
foreach ($adminUser as $user) {
if ($user->telegram_id != null) {
try {
$bot->sendMessage($user->telegram_id, $messageText, null, null, null, $keyboard);
} catch (Exception $e) {
}
echo $e->getMessage();
}
}
}
@ -1447,27 +1355,6 @@ class UserController extends BaseController
}
}
}
if (Config::get('enable_telegram') == 'true') {
$messageText = 'Hi,管理员'.PHP_EOL.'有人回复了工单,请您及时处理'.PHP_EOL.PHP_EOL.$this->user->user_name.': '.$ticket_main->title.PHP_EOL.$content;
$ticket_url = Config::get('baseUrl') . '/admin/ticket/' . $ticket_main->id . '/view';
$keyboard = new \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup(
[
[
['text' => '回复工单', 'url' => $ticket_url]
]
]
);
$bot = new BotApi(Config::get('telegram_token'));
$adminUser = User::where('is_admin', '=', '1')->get();
foreach ($adminUser as $user) {
if ($user->telegram_id != null) {
try {
$bot->sendMessage($user->telegram_id, $messageText, null, null, null, $keyboard);
} catch (Exception $e) {
}
}
}
}
if (Config::get('useScFtqq') == true && $markdown != '') {
$ScFtqq_SCKEY = Config::get('ScFtqq_SCKEY');
$postdata = http_build_query(
@ -1486,7 +1373,6 @@ class UserController extends BaseController
file_get_contents('https://sc.ftqq.com/' . $ScFtqq_SCKEY . '.send', false, $context);
}
}
$antiXss = new AntiXSS();
@ -1523,7 +1409,7 @@ class UserController extends BaseController
$ticketset->setPath('/user/ticket/' . $id . '/view');
return $this->view()->assign('ticketset', $ticketset)->assign('ticket_status', $ticket_main->status)->assign('id', $id)->display('user/ticket_view.tpl');
return $this->view()->assign('ticketset', $ticketset)->assign('id', $id)->display('user/ticket_view.tpl');
}
@ -1611,8 +1497,6 @@ class UserController extends BaseController
$user->save();
$user->cleanSubCache();
if (!URL::SSCanConnect($user)) {
$res['ret'] = 1;
$res['msg'] = '设置成功,但您目前的协议,混淆,加密方式设置会导致 Shadowsocks原版客户端无法连接,请您自行更换到 ShadowsocksR 客户端。';
@ -1719,7 +1603,6 @@ class UserController extends BaseController
Radius::Add($user, $pwd);
$user->cleanSubCache();
return $this->echoJson($response, $res);
}
@ -1759,7 +1642,7 @@ class UserController extends BaseController
$user->updateMethod($method);
if (!URL::SSCanConnect($user)) {
$res['ret'] = 1;
$res['ret'] = 0;
$res['msg'] = '设置成功,但您目前的协议,混淆,加密方式设置会导致 Shadowsocks原版客户端无法连接,请您自行更换到 ShadowsocksR 客户端。';
return $this->echoJson($response, $res);
}
@ -1811,21 +1694,23 @@ class UserController extends BaseController
return $response->getBody()->write(json_encode($res));
}
$checkin = $this->user->checkin();
if ($checkin['ok'] === false) {
if (!$this->user->isAbleToCheckin()) {
$res['ret'] = 0;
$res['msg'] = $checkin['msg'];
return $this->echoJson($response, $res);
}
if (MalioConfig::get('daily_bonus_mode') == 'malio') {
$traffic = random_int(MalioConfig::get('daily_bonus_settings')[$this->user->class]['min'], MalioConfig::get('daily_bonus_settings')[$this->user->class]['max']);
} else {
$traffic = random_int(Config::get('checkinMin'), Config::get('checkinMax'));
$res['msg'] = '您似乎已经签到过了...';
return $response->getBody()->write(json_encode($res));
}
$traffic = random_int(Config::get('checkinMin'), Config::get('checkinMax'));
$this->user->transfer_enable += Tools::toMB($traffic);
$this->user->last_check_in_time = time();
$this->user->save();
$res['msg'] = $this->i18n->get('got-daily-bonus',[$traffic]);
$res['msg'] = sprintf('获得了 %d MB流量.', $traffic);
$res['unflowtraffic'] = $this->user->transfer_enable;
$res['traffic'] = Tools::flowAutoShow($this->user->transfer_enable);
$res['trafficInfo'] = array(
'todayUsedTraffic' => $this->user->TodayusedTraffic(),
'lastUsedTraffic' => $this->user->LastusedTraffic(),
'unUsedTraffic' => $this->user->unusedTraffic(),
);
$res['ret'] = 1;
return $this->echoJson($response, $res);
}
@ -1852,7 +1737,6 @@ class UserController extends BaseController
if (Config::get('enable_kill') == true) {
Auth::logout();
$user->cleanSubCache();
$user->kill_user();
$res['ret'] = 1;
$res['msg'] = '您的帐号已经从我们的系统中删除。欢迎下次光临!';
@ -1894,7 +1778,8 @@ class UserController extends BaseController
public function telegram_reset($request, $response, $args)
{
$user = $this->user;
$user->TelegramReset();
$user->telegram_id = 0;
$user->save();
return $response->withStatus(302)->withHeader('Location', '/user/edit');
}
@ -1902,7 +1787,6 @@ class UserController extends BaseController
{
$user = $this->user;
$user->clean_link();
$user->cleanSubCache();
return $response->withStatus(302)->withHeader('Location', '/user');
}
@ -1978,11 +1862,8 @@ class UserController extends BaseController
$user->obfs = $scheme['obfs'];
$user->save();
$user->cleanSubCache();
$res['ret'] = 1;
$res['msg'] = '切换' . $scheme['name'] . '成功';
return $this->echoJson($response, $res);
}
@ -1999,7 +1880,7 @@ class UserController extends BaseController
$return .= URL::getAllUrl($user, 0, 0) . PHP_EOL;
break;
case 'ssd':
$return .= LinkController::getSSD($user, 1, [], ['type' => 'ss', 'is_mu' => 1], false) . PHP_EOL;
$return .= URL::getAllSSDUrl($user) . PHP_EOL;
break;
case 'v2ray':
$return .= URL::getAllVMessUrl($user) . PHP_EOL;
@ -2009,8 +1890,7 @@ class UserController extends BaseController
break;
}
$newResponse = $response->withHeader('Content-type', ' application/octet-stream; charset=utf-8')->withHeader('Cache-Control', 'no-store, no-cache, must-revalidate')->withHeader('Content-Disposition', ' attachment; filename=node.txt');
$newResponse->write($return);
$newResponse->getBody()->write($return);
return $newResponse;
}
@ -2025,127 +1905,6 @@ class UserController extends BaseController
return $this->view()->assign('logs', $logs)->assign('iplocation', $iplocation)->display('user/subscribe_log.tpl');
}
public function getmoney($request, $response, $args)
{
$user = $this->user;
$res['money'] = $user->money;
$res['ret'] = 1;
return $this->echoJson($response, $res);
}
public function getPlanInfo($request, $response, $args)
{
$plan_time = $request->getQueryParams()['time'];
$plan_num = $request->getQueryParams()['num'];
if (empty($plan_num) || empty($plan_time)) {
$res['ret'] = 0;
return $this->echoJson($response, $res);
}
$shop_id = (MalioConfig::get('plan_shop_id'))[$plan_num][$plan_time];
$shop = Shop::where('id', $shop_id)->first();
$res['id'] = $shop_id;
$res['name'] = $shop->name;
$res['price'] = $shop->price;
$res['ret'] = 1;
return $this->echoJson($response, $res);
}
public function getPlanTime($request, $response, $args)
{
$plan_num = $request->getQueryParams()['num'];
if (empty($plan_num)) {
$res['ret'] = 0;
return $this->echoJson($response, $res);
}
$plan_time = [];
foreach ((MalioConfig::get('plan_shop_id'))[$plan_num] as $key => $value) {
if ($value != 0) {
$plan_time[] = $key;
}
}
$res['plan_time'] = $plan_time;
$res['ret'] = 1;
return $this->echoJson($response, $res);
}
public function buyTrafficPackage($request, $response, $args)
{
$shopId = $request->getParam('shopid');
$shop = Shop::where('id', $shopId)->where('status', 1)->first();
if ($shop == null) {
$res['ret'] = 0;
$res['msg'] = '非法请求';
return $response->getBody()->write(json_encode($res));
}
$price = $shop->price;
$user = $this->user;
if (!$user->isLogin) {
$res['ret'] = -1;
return $response->getBody()->write(json_encode($res));
}
if (bccomp($user->money, $price, 2) == -1) {
$res['ret'] = 0;
$res['msg'] = '喵喵喵~ 当前余额不足,总价为' . $price . '元。</br><a href="/user/code">点击进入充值界面</a>';
return $response->getBody()->write(json_encode($res));
}
$user->money = bcsub($user->money, $price, 2);
$traffic = $shop->bandwidth();
$user->transfer_enable += $traffic * 1024 * 1024 * 1024;
$user->save();
$bought = new Bought();
$bought->userid = $user->id;
$bought->shopid = $shop->id;
$bought->datetime = time();
$bought->coupon = '';
$bought->renew = 0;
$bought->price = $price;
$bought->save();
$res['ret'] = 1;
$res['msg'] = '购买成功';
return $response->getBody()->write(json_encode($res));
}
public function share_account($request, $response, $args)
{
return $this->view()->display('user/share_account.tpl');
}
public function qrcode($request, $response, $args)
{
return $this->view()->display('user/qrcode.tpl');
}
public function changeLang($request, $response, $args)
{
$lang = $request->getParam('lang');
$supported_lang = ['zh-cn','en'];
if (!in_array($lang, $supported_lang)) {
$res['ret'] = 0;
$res['msg'] = 'unsupport lang';
}
$this->user->lang = $lang;
$this->user->save();
$res['msg'] = 'yes';
$res['ret'] = 1;
return $this->echoJson($response, $res);
}
/**
* 获取包含订阅信息的客户端压缩档
*
* @param Request $request
* @param Response $response
* @param array $args
*/
public function getPcClient($request, $response, $args)
{
$zipArc = new \ZipArchive();
@ -2174,12 +1933,6 @@ class UserController extends BaseController
$content = LinkController::getSSRPcConf($this->user);
$client_path .= $type . '/';
break;
case 'v2rayn-win':
$temp_file_path .= $type . '_' . $user_token . '.zip';
$user_config_file_name = 'guiNConfig.json';
$content = LinkController::getV2RayPcNConf($this->user);
$client_path .= $type . '/';
break;
default:
return 'gg';
}
@ -2197,41 +1950,9 @@ class UserController extends BaseController
$zipArc->close();
$newResponse = $response->withHeader('Content-type', ' application/octet-stream')->withHeader('Content-Disposition', ' attachment; filename=' . $type . '.zip');
$newResponse->write(file_get_contents($temp_file_path));
$newResponse->getBody()->write(file_get_contents($temp_file_path));
unlink($temp_file_path);
return $newResponse;
}
public function getClientfromToken($request, $response, $args)
{
$token = $args['token'];
$Etoken = Token::where('token', '=', $token)->where('create_time', '>', time() - 60 * 10)->first();
if ($Etoken == null) {
return '下载链接已失效,请刷新页面后重新点击.';
}
$user = User::find($Etoken->user_id);
if ($user == null) {
return null;
}
$this->user = $user;
return self::getPcClient($request, $response, $args);
}
/**
* 清理订阅缓存
*
* @param Request $request
* @param Response $response
* @param array $args
*/
public function cleanSubCache($request, $response, $args)
{
$this->user->cleanSubCache();
$res['ret'] = 1;
$res['msg'] = '清理成功';
return $this->echoJson($response, $res);
}
}

@ -4,7 +4,6 @@ namespace App\Middleware;
use App\Services\Config;
use App\Models\Node;
use App\Services\MalioConfig;
class Mod_Mu
{
@ -27,17 +26,11 @@ class Mod_Mu
$keys = Config::getMuKey();
$auth = in_array($key, $keys);
if ($auth == false) {
$res['ret'] = 0;
$res['data'] = 'token is invalid';
$response->getBody()->write(json_encode($res));
return $response;
}
if (Config::get('checkNodeIp') === true){
if (Config::get('checkNodeIp')){
$node = Node::where('node_ip', 'LIKE', $_SERVER['REMOTE_ADDR'] . '%')->first();
if ($auth === false || ($node === null && $_SERVER['REMOTE_ADDR'] != '127.0.0.1')) {
if ($auth === false
|| ($node === null && $_SERVER['REMOTE_ADDR'] != '127.0.0.1')
) {
return $response->withJson([
'ret' => 0,
'data' => 'Token or IP is invalid. Now, your IP address is ' . $_SERVER['REMOTE_ADDR']
@ -45,6 +38,7 @@ class Mod_Mu
}
}
return $next($request, $response);
}
}

@ -32,65 +32,4 @@ class Bought extends Model
{
return Shop::where('id', $this->attributes['shopid'])->first();
}
/*
* 套餐已使用的天数
*
*/
public function used_days()
{
return (int) ((strtotime(date('Y-m-d')) - $this->datetime) / 86400);
}
/*
* 是否有效期内
*
*/
public function valid()
{
$shop = $this->shop();
if ($this->use_loop()) {
return (time() - $shop->reset_exp() * 86400 < $this->datetime);
}
return false;
}
/*
* 是否周期性商品
*
*/
public function use_loop()
{
$shop = $this->shop();
return ($shop->reset() != 0 && $shop->reset_value() != 0 && $shop->reset_exp() != 0);
}
/*
* 下一次流量重置时间
*
*/
public function reset_time($unix = false)
{
$shop = $this->shop();
if ($this->use_loop()) {
$day = $shop->reset() - ($this->used_days() % $shop->reset());
$time = time() + ($day * 86400);
return ($unix == false ? date('Y-m-d', $time) : $time);
}
return ($unix == false ? '-' : 0);
}
/*
* 过期时间
*
*/
public function exp_time($unix = false)
{
$shop = $this->shop();
if ($this->use_loop()) {
$time = $this->datetime + ($shop->reset_exp() * 86400);
return ($unix == false ? date('Y-m-d H:i:s', $time) : $time);
}
return ($unix == false ? '-' : 0);
}
}

@ -1,55 +0,0 @@
<?php
namespace App\Models;
use App\Services\DefaultConfig;
class GConfig extends Model
{
/**
* The connection name for the model.
*
* @var string
*/
protected $connection = 'default';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'gconfig';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'key';
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
/**
* The "type" of the auto-incrementing ID.
*
* @var string
*/
protected $keyType = 'string';
public static function recover($user)
{
$this->oldvalue = $this->value;
$this->value = DefaultConfig::default_value($this->key)['value'];
$this->operator_id = $user->id;
$this->operator_name = ('[恢复默认] - ' . $user->user_name);
$this->operator_email = $user->email;
$this->last_update = time();
$this->save();
}
}

@ -6,9 +6,8 @@ namespace App\Models;
* Node Model
*/
use App\Utils\{Tools, URL};
use App\Utils\Tools;
use App\Utils\DNSoverHTTPS;
class Node extends Model
{
protected $connection = 'default';
@ -173,21 +172,4 @@ class Node extends Model
$node_ip_array = explode(',', $node_ip_str);
return $node_ip_array[0];
}
public function getServer()
{
$out = '';
$explode = explode(';', $this->attributes['server']);
if (in_array($this->attributes['sort'], [0, 10])) {
if (isset($explode[1]) && stripos($explode[1], 'server=') !== false) {
$out = URL::parse_args($explode[1])['server'];
}
}
return ($out != '' ? $out : $explode[0]);
}
public function getOffsetPort($port)
{
return Tools::OutPort($this->attributes['server'], $this->attributes['name'], $port)['port'];
}
}

@ -3,7 +3,6 @@
namespace App\Models;
use App\Services\Config;
use App\Services\MalioConfig;
class Shop extends Model
{
@ -141,11 +140,6 @@ class Shop extends Model
$user->u = 0;
$user->d = 0;
$user->last_day_t = 0;
} elseif (MalioConfig::get('reset_bandwidth_and_expire_date_when_change_class') == true && $user->class != $content['class']) {
$user->transfer_enable = $value * 1024 * 1024 * 1024;
$user->u = 0;
$user->d = 0;
$user->last_day_t = 0;
} else {
$user->transfer_enable += $value * 1024 * 1024 * 1024;
}

@ -1,12 +0,0 @@
<?php
namespace App\Models;
/**
* SmsVerify Model
*/
class SmsVerify extends Model
{
protected $connection = 'default';
protected $table = 'sms_verify';
}

@ -1,36 +0,0 @@
<?php
namespace App\Models;
/**
* TelegramTasks Model
*
* 请勿重复使用 type
*
* type:
* = 1 删除消息
* = 2 储存 /setuser 操作产生的 messageid
*
*/
class TelegramTasks extends Model
{
protected $connection = 'default';
protected $table = 'telegram_tasks';
protected $casts = [
'type' => 'int',
'status' => 'int',
'chatid' => 'int',
'messageid' => 'int',
'userid' => 'int',
'tguserid' => 'int',
'executetime' => 'int',
'datetime' => 'int',
];
public function datetime()
{
return date('Y-m-d H:i:s', $this->attributes['datetime']);
}
}

@ -12,7 +12,7 @@ use App\Services\Config;
use App\Utils\GA;
use App\Utils\QQWry;
use App\Utils\Radius;
use App\Utils\URL;
use Ramsey\Uuid\Uuid;
use App\Models\DetectLog;
use App\Models\DetectBanLog;
@ -39,13 +39,8 @@ class User extends Model
public function getGravatarAttribute()
{
$email_su=substr($this->attributes['email'],-6);
$email_pre=substr($this->attributes['email'],0,-7);
if($email_su=="qq.com" and is_numeric($email_pre)) {
return "https://q4.qlogo.cn/g?b=qq&nk=".$this->attributes['email']."&s=3";
}
$hash = md5(strtolower(trim($this->attributes['email'])));
return "https://secure.gravatar.com/avatar/".$hash;
return 'https://gravatar.loli.net/avatar/' . $hash."?&d=identicon";
}
public function isAdmin()
@ -139,59 +134,43 @@ class User extends Model
public function getUuid()
{
// return Uuid::uuid3(
// Uuid::NAMESPACE_DNS,
// $this->attributes['id'] . '|' . $this->attributes['passwd']
// )->toString();
return $this->attributes['uuid'];
return Uuid::uuid3(
Uuid::NAMESPACE_DNS,
$this->attributes['id'] . '|' . $this->attributes['passwd']
)->toString();
}
public function trafficUsagePercent()
{
$total = $this->attributes['u'] + $this->attributes['d'];
$transferEnable = $this->attributes['transfer_enable'];
if ($transferEnable == 0) {
return 0;
}
$percent = $total / $transferEnable;
$percent = round($percent, 2);
$percent *= 100;
return $percent;
}
/*
* 总流量
*/
public function enableTraffic()
{
$transfer_enable = $this->attributes['transfer_enable'];
return Tools::flowAutoShow($transfer_enable);
}
/*
* 总流量[GB]
*/
public function enableTrafficInGB()
{
$transfer_enable = $this->attributes['transfer_enable'];
return Tools::flowToGB($transfer_enable);
}
/*
* 已用流量
*/
public function usedTraffic()
{
$total = $this->attributes['u'] + $this->attributes['d'];
return Tools::flowAutoShow($total);
}
/*
* 已用流量占总流量的百分比
*/
public function trafficUsagePercent()
{
$total = $this->attributes['u'] + $this->attributes['d'];
$transferEnable = $this->attributes['transfer_enable'];
if ($transferEnable == 0) {
return 0;
}
$percent = $total / $transferEnable;
$percent = round($percent, 2);
$percent *= 100;
return $percent;
}
/*
* 剩余流量
*/
public function unusedTraffic()
{
$total = $this->attributes['u'] + $this->attributes['d'];
@ -199,75 +178,18 @@ class User extends Model
return Tools::flowAutoShow($transfer_enable - $total);
}
/*
* 剩余流量占总流量的百分比
*/
public function unusedTrafficPercent()
{
$transferEnable = $this->attributes['transfer_enable'];
if ($transferEnable == 0) {
return 0;
}
$unusedTraffic = $transferEnable - ($this->attributes['u'] + $this->attributes['d']);
$percent = $unusedTraffic / $transferEnable;
$percent = round($percent, 2);
$percent *= 100;
return $percent;
}
/*
* 今天使用的流量
*/
public function TodayusedTraffic()
{
$total = $this->attributes['u'] + $this->attributes['d'] - $this->attributes['last_day_t'];
return Tools::flowAutoShow($total);
}
/*
* 今天使用的流量占总流量的百分比
*/
public function TodayusedTrafficPercent()
{
$transferEnable = $this->attributes['transfer_enable'];
if ($transferEnable == 0) {
return 0;
}
$TodayusedTraffic = $this->attributes['u'] + $this->attributes['d'] - $this->attributes['last_day_t'];
$percent = $TodayusedTraffic / $transferEnable;
$percent = round($percent, 2);
$percent *= 100;
return $percent;
}
/*
* 今天之前已使用的流量
*/
public function LastusedTraffic()
{
$total = $this->attributes['last_day_t'];
return Tools::flowAutoShow($total);
}
/*
* 今天之前已使用的流量占总流量的百分比
*/
public function LastusedTrafficPercent()
{
$transferEnable = $this->attributes['transfer_enable'];
if ($transferEnable == 0) {
return 0;
}
$LastusedTraffic = $this->attributes['last_day_t'];
$percent = $LastusedTraffic / $transferEnable;
$percent = round($percent, 2);
$percent *= 100;
return $percent;
}
/*
* 是否可以签到
*/
public function isAbleToCheckin()
{
$last = $this->attributes['last_check_in_time'];
@ -429,7 +351,6 @@ class User extends Model
$this->attributes['method'],
$this->attributes['protocol'],
$this->attributes['obfs'],
$this->attributes['obfs_param'],
$this->online_ip_count(),
$this->lastSsTime(),
$used_traffic,
@ -474,8 +395,8 @@ class User extends Model
// 当前解封时间
public function relieve_time()
{
$logs = DetectBanLog::where('user_id', $this->attributes['id'])->orderBy('id', 'desc')->first();
if ($this->attributes['enable'] == 0 && $logs != null) {
if ($this->attributes['detect_ban'] == 1) {
$logs = DetectBanLog::where('user_id', $this->attributes['id'])->orderBy("id", "desc")->first();
$time = ($logs->end_time + $logs->ban_time * 60);
return date('Y-m-d H:i:s', $time);
} else {
@ -531,301 +452,4 @@ class User extends Model
$reason = DetectRule::where('id', '=', $reason_id->list_id)->get();
return $reason[0]->text;
}
/**
* 清理订阅缓存
*/
public function cleanSubCache()
{
$id = $this->attributes['id'];
$user_path = (BASE_PATH . '/storage/SubscribeCache/' . $id . '/');
if (is_dir($user_path)) {
Tools::delDirAndFile($user_path);
}
}
/**
* 签到
*/
public function checkin()
{
$return = [
'ok' => true,
'msg' => ''
];
if (!$this->isAbleToCheckin()) {
$return['ok'] = false;
$return['msg'] = '您似乎已经签到过了...';
} else {
$traffic = random_int((int) Config::get('checkinMin'), (int) Config::get('checkinMax'));
$this->transfer_enable += Tools::toMB($traffic);
$this->last_check_in_time = time();
$this->save();
$return['msg'] = '获得了 ' . $traffic . 'MB 流量.';
}
return $return;
}
/**
* 更新加密方式
*/
public function setMethod($method)
{
$return = [
'ok' => true,
'msg' => '设置成功,您可自由选用两种客户端来进行连接。'
];
if ($method == '') {
$return['ok'] = false;
$return['msg'] = '非法输入';
return $return;
}
if (!Tools::is_param_validate('method', $method)) {
$return['ok'] = false;
$return['msg'] = '加密无效';
return $return;
}
$this->method = $method;
if (!Tools::checkNoneProtocol($this)) {
$return['ok'] = false;
$return['msg'] = '系统检测到您将要设置的加密方式为 none ,但您的协议并不在以下协议【' . implode(',', Config::getSupportParam('allow_none_protocol')) . '】之内,请您先修改您的协议,再来修改此处设置。';
return $return;
}
if (!URL::SSCanConnect($this) && !URL::SSRCanConnect($this)) {
$return['ok'] = false;
$return['msg'] = '您这样设置之后,就没有客户端能连接上了,所以系统拒绝了您的设置,请您检查您的设置之后再进行操作。';
return $return;
}
$this->updateMethod($method);
if (!URL::SSCanConnect($this)) {
$return['ok'] = true;
$return['msg'] = '设置成功,但您目前的协议,混淆,加密方式设置会导致 Shadowsocks 原版客户端无法连接,请您自行更换到 ShadowsocksR 客户端。';
}
if (!URL::SSRCanConnect($this)) {
$return['ok'] = true;
$return['msg'] = '设置成功,但您目前的协议,混淆,加密方式设置会导致 ShadowsocksR 客户端无法连接,请您自行更换到 Shadowsocks 客户端。';
}
return $return;
}
/**
* 更新协议
*/
public function setProtocol($Protocol)
{
$return = [
'ok' => true,
'msg' => '设置成功,您可自由选用客户端来连接。'
];
if ($Protocol == '') {
$return['ok'] = false;
$return['msg'] = '非法输入';
return $return;
}
if (!Tools::is_param_validate('protocol', $Protocol)) {
$return['ok'] = false;
$return['msg'] = '协议无效';
return $return;
}
$this->protocol = $Protocol;
if (!Tools::checkNoneProtocol($this)) {
$return['ok'] = false;
$return['msg'] = '系统检测到您目前的加密方式为 none ,但您将要设置为的协议并不在以下协议【' . implode(',', Config::getSupportParam('allow_none_protocol')) . '】之内,请您先修改您的加密方式,再来修改此处设置。';
return $return;
}
if (!URL::SSCanConnect($this) && !URL::SSRCanConnect($this)) {
$return['ok'] = false;
$return['msg'] = '您这样设置之后,就没有客户端能连接上了,所以系统拒绝了您的设置,请您检查您的设置之后再进行操作。';
return $return;
}
$this->save();
$this->cleanSubCache();
if (!URL::SSCanConnect($this)) {
$return['ok'] = true;
$return['msg'] = '设置成功,但您目前的协议,混淆,加密方式设置会导致 Shadowsocks 原版客户端无法连接,请您自行更换到 ShadowsocksR 客户端。';
}
if (!URL::SSRCanConnect($this)) {
$return['ok'] = true;
$return['msg'] = '设置成功,但您目前的协议,混淆,加密方式设置会导致 ShadowsocksR 客户端无法连接,请您自行更换到 Shadowsocks 客户端。';
}
return $return;
}
/**
* 更新混淆
*/
public function setObfs($Obfs)
{
$return = [
'ok' => true,
'msg' => '设置成功,您可自由选用客户端来连接。'
];
if ($Obfs == '') {
$return['ok'] = false;
$return['msg'] = '非法输入';
return $return;
}
if (!Tools::is_param_validate('obfs', $Obfs)) {
$return['ok'] = false;
$return['msg'] = '混淆无效';
return $return;
}
$this->obfs = $Obfs;
if (!URL::SSCanConnect($this) && !URL::SSRCanConnect($this)) {
$return['ok'] = false;
$return['msg'] = '您这样设置之后,就没有客户端能连接上了,所以系统拒绝了您的设置,请您检查您的设置之后再进行操作。';
return $return;
}
$this->save();
$this->cleanSubCache();
if (!URL::SSCanConnect($this)) {
$return['ok'] = true;
$return['msg'] = '设置成功,但您目前的协议,混淆,加密方式设置会导致 Shadowsocks 原版客户端无法连接,请您自行更换到 ShadowsocksR 客户端。';
}
if (!URL::SSRCanConnect($this)) {
$return['ok'] = true;
$return['msg'] = '设置成功,但您目前的协议,混淆,加密方式设置会导致 ShadowsocksR 客户端无法连接,请您自行更换到 Shadowsocks 客户端。';
}
return $return;
}
/**
* 解绑 Telegram
*/
public function TelegramReset()
{
$return = [
'ok' => true,
'msg' => '解绑成功.'
];
$telegram_id = $this->telegram_id;
$this->telegram_id = 0;
if ($this->save()) {
if (
Config::get('enable_telegram') === true
&&
Config::get('group_bound_user') === true
&&
Config::get('unbind_kick_member') === true
) {
\App\Utils\Telegram\TelegramTools::SendPost(
'kickChatMember',
[
'chat_id' => Config::get('telegram_chatid'),
'user_id' => $telegram_id,
]
);
}
} else {
$return = [
'ok' => false,
'msg' => '解绑失败.'
];
}
return $return;
}
/**
* 更新端口
*/
public function setPort($Port)
{
$PortOccupied = User::pluck('port')->toArray();
if (in_array($Port, $PortOccupied) == true) {
return [
'ok' => false,
'msg' => '端口已被占用'
];
}
$origin_port = $this->port;
$this->port = $Port;
$relay_rules = Relay::where('user_id', $this->id)->where('port', $origin_port)->get();
foreach ($relay_rules as $rule) {
$rule->port = $this->port;
$rule->save();
}
$this->save();
$this->cleanSubCache();
return [
'ok' => true,
'msg' => $this->port
];
}
/**
* 重置端口
*/
public function ResetPort()
{
$price = Config::get('port_price');
if ($this->money < $price) {
return [
'ok' => false,
'msg' => '余额不足'
];
}
$this->money -= $price;
$Port = Tools::getAvPort();
$this->setPort($Port);
$this->save();
return [
'ok' => true,
'msg' => $this->port
];
}
/**
* 指定端口
*/
public function SpecifyPort($Port)
{
$price = Config::get('port_price_specify');
if ($this->money < $price) {
return [
'ok' => false,
'msg' => '余额不足'
];
}
if ($Port < Config::get('min_port') || $Port > Config::get('max_port') || Tools::isInt($Port) == false) {
return [
'ok' => false,
'msg' => '端口不在要求范围内'
];
}
$PortOccupied = User::pluck('port')->toArray();
if (in_array($Port, $PortOccupied) == true) {
return [
'ok' => false,
'msg' => '端口已被占用'
];
}
$this->money -= $price;
$this->setPort($Port);
$this->save();
return [
'ok' => true,
'msg' => '钦定成功'
];
}
public function valid_use_loop()
{
$boughts = Bought::where('userid', $this->id)->orderBy('id', 'desc')->get();
$data = [];
foreach ($boughts as $bought) {
$shop = $bought->shop();
if ($shop != null && $bought->valid()) {
$data[] = $bought->reset_time();
}
}
if (count($data) == 0) {
return '未购买套餐.';
}
if (count($data) == 1) {
return $data[0];
}
return '多个有效套餐无法显示.';
}
}

@ -5,7 +5,6 @@ namespace App\Services;
use App\Models\User;
use App\Models\Node;
use App\Utils\Tools;
use App\Models\Code;
class Analytics
{
@ -118,26 +117,4 @@ class Analytics
}
)->where('node_heartbeat', '>', time() - 90)->count();
}
public function getIncome($start, $end)
{
$sum = Code::where('usedatetime', '>=', date("Y-m-d H:i:s", $start))
->where('usedatetime', '<', date("Y-m-d H:i:s", $end))
->sum('number');
if ($sum == null) {
$sum = 0;
}
return $sum;
}
public function getNewUsers($start, $end)
{
$users = User::where('reg_date', '>=', date("Y-m-d H:i:s", $start))
->where('reg_date', '<', date("Y-m-d H:i:s", $end))
->count();
if ($users == null) {
$users = 0;
}
return $users;
}
}

@ -2,8 +2,6 @@
namespace App\Services;
use App\Models\GConfig;
class Config
{
// TODO: remove
@ -12,22 +10,12 @@ class Config
return $_ENV[$key];
}
public static function getdb($key)
{
$value = GConfig::find($key);
if ($value === null) {
$value = DefaultConfig::firstOrCreate($key);
}
return $value->value;
}
public static function getPublicConfig()
{
return [
'appName' => self::get('appName'),
'version' => VERSION,
'baseUrl' => self::get('baseUrl'),
'subUrl' => self::get('subUrl'),
'min_port' => self::get('min_port'),
'max_port' => self::get('max_port'),
'checkinMin' => self::get('checkinMin'),
@ -57,6 +45,8 @@ class Config
'custom_invite_price' => self::get('custom_invite_price'),
'captcha_provider' => self::get('captcha_provider'),
'enable_email_verify' => self::get('enable_email_verify'),
'subscribe_client' => self::get('subscribe_client')
'enable_email_verify' => self::get('enable_email_verify'),
'protocol_specify' => self::get('protocol_specify'),
'subscribeLog' => self::get('subscribeLog'),
'subscribeLog_keep_days' => self::get('subscribeLog_keep_days'),
@ -65,11 +55,7 @@ class Config
'auto_detect_ban_number' => self::get('auto_detect_ban_number'),
'auto_detect_ban_time' => self::get('auto_detect_ban_time'),
'auto_detect_ban' => self::get('auto_detect_ban'),
'subscribe_client' => self::get('subscribe_client'),
'enable_sub_cache' => self::get('enable_sub_cache'),
'use_new_telegram_bot' => self::get('use_new_telegram_bot'),
'subscribe_client_url' => self::get('subscribe_client_url'),
];
];
}
public static function getDbConfig()

@ -1,236 +0,0 @@
<?php
namespace App\Services;
use App\Models\GConfig;
class DefaultConfig
{
public static function create($key)
{
$value = self::default_value($key);
if ($value != null) {
$new = new GConfig();
$new->key = $value['key'];
$new->value = $value['value'];
$new->name = $value['name'];
$new->comment = $value['comment'];
$new->operator_id = $value['operator_id'];
$new->operator_name = $value['operator_name'];
$new->oldvalue = '';
$new->operator_email = '';
$new->last_update = time();
if ($new->save()) {
return true;
}
}
return false;
}
public static function firstOrCreate($key)
{
return (self::create($key)
? GConfig::find($key)
: null
);
}
public static function detectConfigs()
{
$return = '开始检查新增的配置项...' . PHP_EOL;
$configs = self::configs();
foreach ($configs as $key => $value) {
$config = GConfig::find($key);
if ($config == null) {
if (self::create($key)) {
$return .= '新增的配置项:' . $key . ':' . $value['name'] . PHP_EOL;
} else {
$return .= $key . ':配置项创建失败,请检查错误' . PHP_EOL;
}
}
}
$return .= '以上是新增的配置项...' . PHP_EOL;
return $return;
}
public static function configs($key = null)
{
$configs = [
'Telegram.enable.Diary' => [
'key' => $key,
'value' => 1,
'name' => '开启 Telegram 群组推送系统今天的运行状况',
'comment' => '',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.msg.Diary' => [
'key' => $key,
'value' => ('各位老爷少奶奶,我来为大家报告一下系统今天的运行状况哈~' . PHP_EOL . '今日签到人数:%getTodayCheckinUser%' . PHP_EOL . '今日使用总流量:%lastday_total%' . PHP_EOL . '晚安~'),
'name' => '自定义向 Telegram 群组推送系统今天的运行状况的信息',
'comment' => '可用变量:' . PHP_EOL . '[今日签到人数] %getTodayCheckinUser%' . PHP_EOL . '[今日使用总流量] %lastday_total%',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.enable.DailyJob' => [
'key' => $key,
'value' => 1,
'name' => '开启 Telegram 群组推送数据库清理的通知',
'comment' => '',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.msg.DailyJob' => [
'key' => $key,
'value' => '姐姐姐姐,数据库被清理了,感觉身体被掏空了呢~',
'name' => '自定义向 Telegram 群组推送数据库清理通知的信息',
'comment' => '',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.enable.NodeOffline' => [
'key' => $key,
'value' => 1,
'name' => '开启 Telegram 群组推送节点掉线的通知',
'comment' => '',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.msg.NodeOffline' => [
'key' => $key,
'value' => '喵喵喵~ %node_name% 节点掉线了喵~',
'name' => '自定义向 Telegram 群组推送节点掉线通知的信息',
'comment' => '可用变量:' . PHP_EOL . '[节点名称] %node_name%',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.enable.NodeOnline' => [
'key' => $key,
'value' => 1,
'name' => '开启 Telegram 群组推送节点上线的通知',
'comment' => '',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.msg.NodeOnline' => [
'key' => $key,
'value' => '喵喵喵~ %node_name% 节点恢复了喵~',
'name' => '自定义向 Telegram 群组推送节点上线通知的信息',
'comment' => '可用变量:' . PHP_EOL . '[节点名称] %node_name%',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.enable.NodeGFW' => [
'key' => $key,
'value' => 1,
'name' => '开启 Telegram 群组推送节点被墙的通知',
'comment' => '',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.msg.NodeGFW' => [
'key' => $key,
'value' => '喵喵喵~ %node_name% 节点被墙了喵~',
'name' => '自定义向 Telegram 群组推送节点被墙通知的信息',
'comment' => '可用变量:' . PHP_EOL . '[节点名称] %node_name%',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.enable.NodeGFW_recover' => [
'key' => $key,
'value' => 1,
'name' => '开启 Telegram 群组推送节点被墙恢复的通知',
'comment' => '',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.msg.NodeGFW_recover' => [
'key' => $key,
'value' => '喵喵喵~ %node_name% 节点恢复了喵~',
'name' => '自定义向 Telegram 群组推送节点被墙恢复通知的信息',
'comment' => '可用变量:' . PHP_EOL . '[节点名称] %node_name%',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.enable.AddNode' => [
'key' => $key,
'value' => 1,
'name' => '开启 Telegram 群组推送节点新增的通知',
'comment' => '',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.msg.AddNode' => [
'key' => $key,
'value' => '新节点添加~ %node_name%',
'name' => '自定义向 Telegram 群组推送节点新增通知的信息',
'comment' => '可用变量:' . PHP_EOL . '[节点名称] %node_name%',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.enable.UpdateNode' => [
'key' => $key,
'value' => 1,
'name' => '开启 Telegram 群组推送节点修改的通知',
'comment' => '',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.msg.UpdateNode' => [
'key' => $key,
'value' => '节点信息被修改~ %node_name%',
'name' => '自定义向 Telegram 群组推送节点修改通知的信息',
'comment' => '可用变量:' . PHP_EOL . '[节点名称] %node_name%',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.enable.DeleteNode' => [
'key' => $key,
'value' => 1,
'name' => '开启 Telegram 群组推送节点删除的通知',
'comment' => '',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'Telegram.msg.DeleteNode' => [
'key' => $key,
'value' => '节点被删除~ %node_name%',
'name' => '自定义向 Telegram 群组推送节点删除通知的信息',
'comment' => '可用变量:' . PHP_EOL . '[节点名称] %node_name%',
'operator_id' => 0,
'operator_name' => '系统默认',
],
'get.Detect.Log' => [
'key' => $key,
'value' => '0',
'name' => '审计记录的处理记录',
'comment' => '',
'operator_id' => 0,
'operator_name' => '系统默认',
],
];
return ($key === null
? $configs
: $configs[$key]
);
}
public static function default_value($key)
{
return (in_array($key, array_keys(self::configs()))
? self::configs($key)
: null
);
}
}

@ -93,58 +93,6 @@ abstract class AbstractPayment
return 0;
}
public function postPaymentMaliopay($pid, $method)
{
$p = Paylist::where('tradeno', $pid)->first();
if ($p->status == 1) {
return json_encode(['errcode' => 0]);
}
$p->status = 1;
$p->save();
$user = User::find($p->userid);
// 先保存code,防止用户账号余额重复到账
$codeq = new Code();
$codeq->code = $method;
$codeq->isused = 1;
$codeq->type = -1;
$codeq->number = $p->total;
$codeq->usedatetime = date('Y-m-d H:i:s');
$codeq->userid = $user->id;
$codeq->tradeno = $pid;
$user->money += $p->total;
$user->save();
if (!$codeq->save()) {
return 0; // failed
}
if ($user->ref_by >= 1) {
$gift_user = User::where('id', '=', $user->ref_by)->first();
$gift_user->money += ($codeq->number * (Config::get('code_payback') / 100));
$gift_user->save();
$Payback = new Payback();
$Payback->total = $codeq->number;
$Payback->userid = $user->id;
$Payback->ref_by = $user->ref_by;
$Payback->ref_get = $codeq->number * (Config::get('code_payback') / 100);
$Payback->datetime = time();
$Payback->save();
}
if (Config::get('enable_donate') == 'true') {
if ($user->is_hide == 1) {
Telegram::Send('一位不愿透露姓名的大老爷给我们捐了 ' . $codeq->number . ' 元!');
} else {
Telegram::Send($user->user_name . ' 大老爷给我们捐了 ' . $codeq->number . ' 元!');
}
}
return 0;
}
public static function generateGuid()
{
mt_srand((double)microtime() * 10000);

@ -69,46 +69,6 @@ class AopF2F extends AbstractPayment
return json_encode($return);
}
public function purchase_maliopay($type, $price)
{
$amount = $price;
$user = Auth::getUser();
$pl = new Paylist();
$pl->userid = $user->id;
$pl->tradeno = self::generateGuid();
$pl->total = $amount;
$pl->save();
$gateway = Omnipay::create('Alipay_AopF2F');
$gateway->setSignType('RSA2'); //RSA/RSA2
$gateway->setAppId(Config::get('f2fpay_app_id'));
$gateway->setPrivateKey(Config::get('merchant_private_key')); // 可以是路径,也可以是密钥内容
$gateway->setAlipayPublicKey(Config::get('alipay_public_key')); // 可以是路径,也可以是密钥内容
$notifyUrl = Config::get('f2fNotifyUrl') ?? (Config::get('baseUrl') . '/payment/notify/f2fpay');
$gateway->setNotifyUrl($notifyUrl);
$request = $gateway->purchase();
$request->setBizContent([
'subject' => $pl->tradeno,
'out_trade_no' => $pl->tradeno,
'total_amount' => $pl->total
]);
/** @var \Omnipay\Alipay\Responses\AopTradePreCreateResponse $response */
$aliResponse = $request->send();
// 获取收款二维码内容
$qrCodeContent = $aliResponse->getQrCode();
$return['errcode'] = 0;
$return['url'] = $qrCodeContent;
$return['amount'] = $pl->total;
$return['tradeno'] = $pl->tradeno;
return $return;
}
public function notify($request, $response, $args)
{
$gateway = $this->createGateway();

@ -165,7 +165,7 @@ class BitPay extends AbstractPayment
public function getPurchaseHTML()
{
return 0;
return View::getSmarty()->fetch('user/bitpay.tpl');
}
public function getReturnHTML($request, $response, $args)

@ -12,7 +12,6 @@ namespace App\Services\Gateway;
use App\Models\Paylist;
use App\Services\Auth;
use App\Services\Config;
use App\Services\MalioConfig;
use App\Services\View;
class BitPayX extends AbstractPayment
@ -87,38 +86,29 @@ class BitPayX extends AbstractPayment
{
$price = $request->getParam('price');
$type = $request->getParam('type');
$mobile = $request->getParam('mobile');
// file_put_contents(BASE_PATH.'/bitpay_purchase.log', $price . " " . $type . "\r\n", FILE_APPEND);
if ($price <= 0) {
return json_encode(['errcode' => -1, 'errmsg' => '请输入合理的金额。']);
}
if (MalioConfig::get('bitpyax_alipay_type') == 'ALIGLOBAL' && $type == 'ALIPAY') {
$type = 'ALIGLOBAL';
}
$user = Auth::getUser();
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->datetime = time(); // date("Y-m-d H:i:s");
$pl->save();
$data['merchant_order_id'] = $pl->tradeno;
$data['price_amount'] = (float)$price;
$data['price_currency'] = 'CNY';
if ($type === 'WECHAT') {
$data['pay_currency'] = $type;
}
if ($type === 'ALIGLOBAL' || $type === 'ALIPAY') {
if ($type === 'WECHAT' || $type === 'ALIPAY') {
$data['pay_currency'] = $type;
}
$data['mobile'] = $mobile;
$data['title'] = '支付单号:' . $pl->tradeno;
$data['description'] = '充值:' . $price . ' 元';
$data['callback_url'] = Config::get('baseUrl') . '/payment/notify';
$data['success_url'] = Config::get('baseUrl') . '/user/payment/return?merchantTradeNo=';
$data['success_url'] .= $pl->tradeno;
$data['cancel_url'] = Config::get('baseUrl') . '/user/code';
$data['cancel_url'] = $data['success_url'];
$str_to_sign = $this->prepareSignId($pl->tradeno);
$data['token'] = $this->sign($str_to_sign);
@ -126,89 +116,13 @@ class BitPayX extends AbstractPayment
$result['pid'] = $pl->tradeno;
// file_put_contents(BASE_PATH.'/bitpay_purchase.log', json_encode($data)."\r\n", FILE_APPEND);
// file_put_contents(BASE_PATH.'/bitpay_purchase.log', json_encode($result)."\r\n", FILE_APPEND);
$qrcode_url = '';
$click_url = '';
if ($result['status'] === 200 || $result['status'] === 201) {
$result['payment_url'] .= '&lang=zh';
if ($result['invoice'] && $result['invoice']['pay_currency']) {
$pay_currency = $result['invoice']['pay_currency'];
$order_id = $result['invoice']['order_id'];
$base_url = 'https://www.zhihu.com/qrcode?url=';
if ($pay_currency === 'ALIPAY') {
$click_url = 'https://qrcode.icedropper.com/invoices/?id=' . $order_id . '&type=ALIPAY';
$qrcode_url = $base_url . $click_url;
} else if ($pay_currency === 'ALIGLOBAL') {
$click_url = 'https://qrcode.oceanlunettes.com/invoices/?id=' . $order_id . '&type=ALIGLOBAL';
$qrcode_url = $base_url . $click_url;
} else if ($pay_currency === 'WECHAT') {
$qrcode_url = $base_url . $result['invoice']['qrcode'];
$click_url = "#";
}
}
// file_put_contents(BASE_PATH.'/bitpay_purchase.log', json_encode($result) . "\r\n" . $qrcode_url . "\r\n", FILE_APPEND);
return json_encode(array('url' => $result['payment_url'], 'qrcode_url' => $qrcode_url, 'click_url' => $click_url, 'errcode' => 0, 'pid' => $pl->tradeno));
return json_encode(array('url' => $result['payment_url'], 'errcode' => 0, 'pid' => $pl->id));
}
return json_encode(['errcode' => -1, 'errmsg' => $result . error]);
}
public function purchase_maliopay($type, $price)
{
$user = Auth::getUser();
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->datetime = time(); // date("Y-m-d H:i:s");
$pl->save();
$data['merchant_order_id'] = $pl->tradeno;
$data['price_amount'] = (float)$price;
$data['price_currency'] = 'CNY';
$type = strtoupper($type);
if ($type === 'WECHAT') {
$data['pay_currency'] = $type;
}
if ($type === 'ALIGLOBAL' || $type === 'ALIPAY') {
$data['pay_currency'] = $type;
}
$data['mobile'] = false;
$data['title'] = '支付单号:' . $pl->tradeno;
$data['description'] = '充值:' . $price . ' 元';
$data['callback_url'] = Config::get('baseUrl') . '/payment/notify/bitpayx';
$data['success_url'] = Config::get('baseUrl') . '/user/payment/return?merchantTradeNo='.$pl->tradeno.'&tradeno='.$pl->tradeno;
$data['cancel_url'] = Config::get('baseUrl') . '/user/code';
$str_to_sign = $this->prepareSignId($pl->tradeno);
$data['token'] = $this->sign($str_to_sign);
$result = json_decode($this->mprequest($data), true);
$result['pid'] = $pl->tradeno;
$qrcode_url = '';
$click_url = '';
if ($result['status'] === 200 || $result['status'] === 201) {
$result['payment_url'] .= '&lang=zh';
if ($result['invoice'] && $result['invoice']['pay_currency']) {
$pay_currency = $result['invoice']['pay_currency'];
$order_id = $result['invoice']['order_id'];
$base_url = 'https://www.zhihu.com/qrcode?url=';
if ($pay_currency === 'ALIPAY') {
$click_url = 'https://qrcode.icedropper.com/invoices/?id=' . $order_id . '&type=ALIPAY';
$qrcode_url = $base_url . $click_url;
} else if ($pay_currency === 'ALIGLOBAL') {
$click_url = 'https://qrcode.oceanlunettes.com/invoices/?id=' . $order_id . '&type=ALIGLOBAL';
$qrcode_url = $base_url . $click_url;
} else if ($pay_currency === 'WECHAT') {
$qrcode_url = $result['invoice']['qrcode'];
$click_url = "#";
}
}
return array('url' => $result['payment_url'], 'qrcode_url' => $qrcode_url, 'click_url' => $click_url, 'errcode' => 0, 'tradeno' => $pl->tradeno);
}
return ['errcode' => -1, 'errmsg' => $result];
}
public function notify($request, $response, $args)
{
if (!$this->bitpayAppSecret || $this->bitpayAppSecret === '') {
@ -236,7 +150,7 @@ class BitPayX extends AbstractPayment
$isPaid = $data !== null && $data['status'] !== null && $data['status'] === 'PAID';
// file_put_contents(BASE_PATH.'/bitpay_notify.log', $resultVerify."\r\n".$isPaid."\r\n", FILE_APPEND);
if ($resultVerify && $isPaid) {
$this->postPayment($data['merchant_order_id'], 'BitPayX ' . $data['merchant_order_id']);
$this->postPayment($data['merchant_order_id'], 'BitPayX');
// echo 'SUCCESS';
$return = [];
$return['status'] = 200;
@ -251,7 +165,7 @@ class BitPayX extends AbstractPayment
public function getPurchaseHTML()
{
return 1;
return View::getSmarty()->fetch('user/bitpayx.tpl');
}
public function getReturnHTML($request, $response, $args)
@ -284,5 +198,4 @@ class BitPayX extends AbstractPayment
// file_put_contents(BASE_PATH.'/bitpay_status_success.log', json_encode($return)."\r\n", FILE_APPEND);
return json_encode($return);
}
}
}

@ -89,7 +89,8 @@ class Codepay extends AbstractPayment
$query = $urls . '&sign=' . md5($sign . $codepay_key); //创建订单所需的参数
$url = 'https://codepay.fateqq.com/creat_order/?' . $query; //支付页面
return json_encode(['code' => 0, 'url' => $url]);
header('Location:' . $url);
}
public function notify($request, $response, $args)

@ -1,236 +0,0 @@
<?php
/**
* Created by PhpStorm.
* User: tonyzou
* Date: 2018/9/24
* Time: 下午9:24
*/
namespace App\Services\Gateway;
use App\Services\Auth;
use App\Services\Config;
use App\Models\Paylist;
use App\Services\View;
use Exception;
use Omnipay\Omnipay;
class F2Fpay_PAYJS extends AbstractPayment
{
// f2fpay
private function createGateway()
{
$gateway = Omnipay::create('Alipay_AopF2F');
$gateway->setSignType('RSA2'); //RSA/RSA2
$gateway->setAppId(Config::get('f2fpay_app_id'));
$gateway->setPrivateKey(Config::get('merchant_private_key')); // 可以是路径,也可以是密钥内容
$gateway->setAlipayPublicKey(Config::get('alipay_public_key')); // 可以是路径,也可以是密钥内容
$notifyUrl = Config::get('f2fNotifyUrl') ?? (Config::get('baseUrl') . '/payment/notify');
$gateway->setNotifyUrl($notifyUrl);
return $gateway;
}
// f2fpay end
// payjs
public function __construct()
{
$this->appSecret = Config::get('payjs_key');
$this->gatewayUri = 'https://payjs.cn/api/';
}
public function prepareSign($data)
{
$data['mchid'] = Config::get('payjs_mchid');
$data = array_filter($data);
ksort($data);
return http_build_query($data);
}
public function sign($data)
{
return strtoupper(md5(urldecode($data) . '&key=' . $this->appSecret));
}
public function verify($data, $signature)
{
$mySign = $this->sign($data);
return $mySign === $signature;
}
public function post($data, $type = 'pay')
{
if ($type == 'pay') {
$this->gatewayUri .= 'cashier';
} elseif ($type == 'refund') {
$this->gatewayUri .= 'refund';
} else {
$this->gatewayUri .= 'check';
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->gatewayUri);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
public function query($tradeNo)
{
$data['payjs_order_id'] = $tradeNo;
$params = $this->prepareSign($data);
$data['sign'] = $this->sign($params);
return json_decode($this->post($data, $type = 'query'), true);
}
public function refund($merchantTradeNo)
{
$data['payjs_order_id'] = $merchantTradeNo;
$params = $this->prepareSign($data);
$data['sign'] = $this->sign($params);
return $this->post($data, 'refund');
}
// payjs end
public function purchase($request, $response, $args)
{
$payment = $request->getParam('payment');
if ($payment == 'alipay') {
$amount = $request->getParam('amount');
$user = Auth::getUser();
if ($amount == '') {
$res['ret'] = 0;
$res['msg'] = '订单金额错误:' . $amount;
return $response->getBody()->write(json_encode($res));
}
$pl = new Paylist();
$pl->userid = $user->id;
$pl->tradeno = self::generateGuid();
$pl->total = $amount;
$pl->save();
$gateway = $this->createGateway();
$request = $gateway->purchase();
$request->setBizContent([
'subject' => $pl->tradeno,
'out_trade_no' => $pl->tradeno,
'total_amount' => $pl->total
]);
/** @var \Omnipay\Alipay\Responses\AopTradePreCreateResponse $response */
$aliResponse = $request->send();
// 获取收款二维码内容
$qrCodeContent = $aliResponse->getQrCode();
$return['ret'] = 1;
$return['qrcode'] = $qrCodeContent;
$return['amount'] = $pl->total;
$return['pid'] = $pl->tradeno;
return json_encode($return);
} else if ($payment == 'wechat') {
$price = $request->getParam('amount');
if ($price <= 0) {
return json_encode(['ret' => -1, 'errmsg' => '非法的金额.']);
}
$user = Auth::getUser();
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->save();
$data['mchid'] = Config::get('payjs_mchid');
$data['out_trade_no'] = $pl->tradeno;
$data['total_fee'] = (float) $price * 100;
$data['notify_url'] = Config::get('baseUrl') . '/payment/notify?way=payjs';
$params = $this->prepareSign($data);
$data['sign'] = $this->sign($params);
$url = 'https://payjs.cn/api/cashier?' . http_build_query($data);
return json_encode(['ret' => 1, 'qrcode' => $url, 'pid' => $data['out_trade_no']]);
} else {
$res['ret'] = 0;
$res['msg'] = 'payment参数缺失';
return $response->getBody()->write(json_encode($res));
}
}
public function notify($request, $response, $args)
{
$way = $_GET['way'];
if ($way == 'payjs') {
$data = $_POST;
if($data['return_code'] == 1){
// 验证签名
$in_sign = $data['sign'];
unset($data['sign']);
$data = array_filter($data);
ksort($data);
$sign = strtoupper(md5(urldecode(http_build_query($data) . '&key=' . $this->appSecret)));
$resultVerify = $sign ? true : false;
//$str_to_sign = $this->prepareSign($data);
//$resultVerify = $this->verify($str_to_sign, $request->getParam('sign'));
if ($resultVerify) {
// 验重
$p = Paylist::where('tradeno', '=', $data['out_trade_no'])->first();
$money = $p->total;
if ($p->status != 1) {
$this->postPayment($data['out_trade_no'], '微信支付');
echo 'SUCCESS';
} else {
echo 'ERROR';
}
} else {
echo 'FAIL2';
}
} else {
echo 'FAIL1';
}
} else {
$gateway = $this->createGateway();
$aliRequest = $gateway->completePurchase();
$aliRequest->setParams($_POST);
try {
/** @var \Omnipay\Alipay\Responses\AopCompletePurchaseResponse $response */
$aliResponse = $aliRequest->send();
$pid = $aliResponse->data('out_trade_no');
if ($aliResponse->isPaid()) {
$this->postPayment($pid, '支付宝当面付 ' . $pid);
die('success'); //The response should be 'success' only
}
} catch (Exception $e) {
die('fail');
}
}
}
public function getPurchaseHTML()
{
return 1;
}
public function getStatus($request, $response, $args)
{
$p = Paylist::where('tradeno', $_POST['pid'])->first();
$return['ret'] = 1;
$return['result'] = $p->status;
return json_encode($return);
}
public function getReturnHTML($request, $response, $args)
{
return 0;
}
}

@ -1,176 +0,0 @@
<?php
/* *
* 支付宝接口公用函数
* 详细:该类是请求、通知返回两个文件所调用的公用函数核心处理文件
* 版本:3.3
* 日期:2012-07-19
* 说明:
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
*/
/**
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
* @param $para 需要拼接的数组
* return 拼接完成以后的字符串
*/
function createLinkstring($para) {
$arg = "";
foreach ($para as $key=>$val){
$arg.=$key."=".$val."&";
}
//去掉最后一个&字符
$arg = rtrim($arg,'&');
//如果存在转义字符,那么去掉转义
if(get_magic_quotes_gpc()){$arg = stripslashes($arg);}
return $arg;
}
/**
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码
* @param $para 需要拼接的数组
* return 拼接完成以后的字符串
*/
function createLinkstringUrlencode($para) {
$arg = "";
foreach ($para as $key=>$val){
$arg.=$key."=".$val."&";
}
//去掉最后一个&字符
$arg = rtrim($arg,'&');
//如果存在转义字符,那么去掉转义
if(get_magic_quotes_gpc()){$arg = stripslashes($arg);}
return $arg;
}
/**
* 除去数组中的空值和签名参数
* @param $para 签名参数组
* return 去掉空值与签名参数后的新签名参数组
*/
function paraFilter($para) {
$para_filter = array();
foreach ($para as $key=>$val){
if($key == "sign" || $key == "sign_type" || $val == "")continue;
else $para_filter[$key] = $para[$key];
}
return $para_filter;
}
/**
* 对数组排序
* @param $para 排序前的数组
* return 排序后的数组
*/
function argSort($para) {
ksort($para);
reset($para);
return $para;
}
/**
* 写日志,方便测试(看网站需求,也可以改成把记录存入数据库)
* 注意:服务器需要开通fopen配置
* @param $word 要写入日志里的文本内容 默认值:空值
*/
function logResult($word='') {
$fp = fopen("log.txt","a");
flock($fp, LOCK_EX) ;
fwrite($fp,"执行日期:".strftime("%Y%m%d%H%M%S",time())."\n".$word."\n");
flock($fp, LOCK_UN);
fclose($fp);
}
/**
* 远程获取数据,POST模式
* 注意:
* 1.使用Crul需要修改服务器中php.ini文件的设置,找到php_curl.dll去掉前面的";"就行了
* 2.文件夹中cacert.pem是SSL证书请保证其路径有效,目前默认路径是:getcwd().'\\cacert.pem'
* @param $url 指定URL完整路径地址
* @param $cacert_url 指定当前工作目录绝对路径
* @param $para 请求的数据
* @param $input_charset 编码格式。默认值:空值
* return 远程输出的数据
*/
function getHttpResponsePOST($url, $cacert_url, $para, $input_charset = '') {
if (trim($input_charset) != '') {
$url = $url."_input_charset=".$input_charset;
}
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);//SSL证书认证
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);//严格认证
curl_setopt($curl, CURLOPT_CAINFO,$cacert_url);//证书地址
curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果
curl_setopt($curl,CURLOPT_POST,true); // post传输数据
curl_setopt($curl,CURLOPT_POSTFIELDS,$para);// post传输数据
$responseText = curl_exec($curl);
//var_dump( curl_error($curl) );//如果执行curl过程中出现异常,可打开此开关,以便查看异常内容
curl_close($curl);
return $responseText;
}
/**
* 远程获取数据,GET模式
* 注意:
* 1.使用Crul需要修改服务器中php.ini文件的设置,找到php_curl.dll去掉前面的";"就行了
* 2.文件夹中cacert.pem是SSL证书请保证其路径有效,目前默认路径是:getcwd().'\\cacert.pem'
* @param $url 指定URL完整路径地址
* @param $cacert_url 指定当前工作目录绝对路径
* return 远程输出的数据
*/
function getHttpResponseGET($url,$cacert_url) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, 0 ); // 过滤HTTP头
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);// 显示输出结果
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);//SSL证书认证
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);//严格认证
curl_setopt($curl, CURLOPT_CAINFO,$cacert_url);//证书地址
$responseText = curl_exec($curl);
//var_dump( curl_error($curl) );//如果执行curl过程中出现异常,可打开此开关,以便查看异常内容
curl_close($curl);
return $responseText;
}
/**
* 实现多种字符编码方式
* @param $input 需要编码的字符串
* @param $_output_charset 输出的编码格式
* @param $_input_charset 输入的编码格式
* return 编码后的字符串
*/
function charsetEncode($input,$_output_charset ,$_input_charset) {
$output = "";
if(!isset($_output_charset) )$_output_charset = $_input_charset;
if($_input_charset == $_output_charset || $input ==null ) {
$output = $input;
} elseif (function_exists("mb_convert_encoding")) {
$output = mb_convert_encoding($input,$_output_charset,$_input_charset);
} elseif(function_exists("iconv")) {
$output = iconv($_input_charset,$_output_charset,$input);
} else die("sorry, you have no libs support for charset change.");
return $output;
}
/**
* 实现多种字符解码方式
* @param $input 需要解码的字符串
* @param $_output_charset 输出的解码格式
* @param $_input_charset 输入的解码格式
* return 解码后的字符串
*/
function charsetDecode($input,$_input_charset ,$_output_charset) {
$output = "";
if(!isset($_input_charset) )$_input_charset = $_input_charset ;
if($_input_charset == $_output_charset || $input ==null ) {
$output = $input;
} elseif (function_exists("mb_convert_encoding")) {
$output = mb_convert_encoding($input,$_output_charset,$_input_charset);
} elseif(function_exists("iconv")) {
$output = iconv($_input_charset,$_output_charset,$input);
} else die("sorry, you have no libs support for charset changes.");
return $output;
}
?>

@ -1,41 +0,0 @@
<?php
/* *
* MD5
* 详细:MD5加密
* 版本:3.3
* 日期:2012-07-19
* 说明:
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
* 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
*/
/**
* 签名字符串
* @param $prestr 需要签名的字符串
* @param $key 私钥
* return 签名结果
*/
function md5Sign($prestr, $key) {
$prestr = $prestr . $key;
return md5($prestr);
}
/**
* 验证签名
* @param $prestr 需要签名的字符串
* @param $sign 签名结果
* @param $key 私钥
* return 签名结果
*/
function md5Verify($prestr, $sign, $key) {
$prestr = $prestr . $key;
$mysgin = md5($prestr);
if($mysgin == $sign) {
return true;
}
else {
return false;
}
}
?>

@ -1,121 +0,0 @@
<?php
/* *
* 类名:EpayNotify
* 功能:SAF易支付通知处理类
* 详细:处理易支付接口通知返回
*/
namespace App\Services\Gateway;
require_once("epay_core.function.php");
require_once("epay_md5.function.php");
class AlipayNotify {
var $alipay_config;
function __construct($alipay_config){
$this->alipay_config = $alipay_config;
$this->http_verify_url = $this->alipay_config['apiurl'].'api.php?';
}
function AlipayNotify($alipay_config) {
$this->__construct($alipay_config);
}
/**
* 针对notify_url验证消息是否是支付宝发出的合法消息
* @return 验证结果
*/
function verifyNotify(){
if(empty($_GET)) {//判断POST来的数组是否为空
return false;
}
else {
//生成签名结果
$isSign = $this->getSignVeryfy($_GET, $_GET["sign"]);
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
$responseTxt = 'true';
//if (! empty($_POST["notify_id"])) {$responseTxt = $this->getResponse($_POST["notify_id"]);}
//验证
//$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
//isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
if (preg_match("/true$/i",$responseTxt) && $isSign) {
return true;
} else {
return false;
}
}
}
/**
* 针对return_url验证消息是否是支付宝发出的合法消息
* @return 验证结果
*/
function verifyReturn(){
if(empty($_GET)) {//判断POST来的数组是否为空
return false;
}
else {
//生成签名结果
$isSign = $this->getSignVeryfy($_GET, $_GET["sign"]);
//获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息)
$responseTxt = 'true';
//if (! empty($_GET["notify_id"])) {$responseTxt = $this->getResponse($_GET["notify_id"]);}
//验证
//$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
//isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
if (preg_match("/true$/i",$responseTxt) && $isSign) {
return true;
} else {
return false;
}
}
}
/**
* 获取返回时的签名验证结果
* @param $para_temp 通知返回来的参数数组
* @param $sign 返回的签名结果
* @return 签名验证结果
*/
function getSignVeryfy($para_temp, $sign) {
//除去待签名参数数组中的空值和签名参数
$para_filter = paraFilter($para_temp);
//对待签名参数数组排序
$para_sort = argSort($para_filter);
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
$prestr = createLinkstring($para_sort);
$isSgin = false;
$isSgin = md5Verify($prestr, $sign, $this->alipay_config['key']);
return $isSgin;
}
/**
* 获取远程服务器ATN结果,验证返回URL
* @param $notify_id 通知校验ID
* @return 服务器ATN结果
* 验证结果集:
* invalid命令参数不对 出现这个错误,请检测返回处理中partner和key是否为空
* true 返回正确信息
* false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟
*/
function getResponse($notify_id) {
$transport = strtolower(trim($this->alipay_config['transport']));
$partner = trim($this->alipay_config['partner']);
$veryfy_url = '';
if($transport == 'https') {
$veryfy_url = $this->https_verify_url;
}
else {
$veryfy_url = $this->http_verify_url;
}
$veryfy_url = $veryfy_url."partner=" . $partner . "&notify_id=" . $notify_id;
$responseTxt = getHttpResponseGET($veryfy_url, $this->alipay_config['cacert']);
return $responseTxt;
}
}
?>

@ -1,98 +0,0 @@
<?php
/* *
* 类名:EpaySubmit
* 功能:SAF易支付接口请求提交类
* 详细:构造易支付接口表单HTML文本,获取远程HTTP数据
*/
namespace App\Services\Gateway;
require_once("epay_core.function.php");
require_once("epay_md5.function.php");
class AlipaySubmit {
var $alipay_config;
function __construct($alipay_config){
$this->alipay_config = $alipay_config;
$this->alipay_gateway_new = $this->alipay_config['apiurl'].'submit.php?';
}
function AlipaySubmit($alipay_config) {
$this->__construct($alipay_config);
}
/**
* 生成签名结果
* @param $para_sort 已排序要签名的数组
* return 签名结果字符串
*/
function buildRequestMysign($para_sort) {
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
$prestr = createLinkstring($para_sort);
$mysign = md5Sign($prestr, $this->alipay_config['key']);
return $mysign;
}
/**
* 生成要请求给支付宝的参数数组
* @param $para_temp 请求前的参数数组
* @return 要请求的参数数组
*/
function buildRequestPara($para_temp) {
//除去待签名参数数组中的空值和签名参数
$para_filter = paraFilter($para_temp);
//对待签名参数数组排序
$para_sort = argSort($para_filter);
//生成签名结果
$mysign = $this->buildRequestMysign($para_sort);
//签名结果与签名方式加入请求提交参数组中
$para_sort['sign'] = $mysign;
$para_sort['sign_type'] = strtoupper(trim($this->alipay_config['sign_type']));
return $para_sort;
}
/**
* 生成要请求给支付宝的参数数组
* @param $para_temp 请求前的参数数组
* @return 要请求的参数数组字符串
*/
function buildRequestParaToString($para_temp) {
//待请求参数数组
$para = $this->buildRequestPara($para_temp);
//把参数组中所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码
$request_data = createLinkstringUrlencode($para);
return $request_data;
}
/**
* 建立请求,以表单HTML形式构造(默认)
* @param $para_temp 请求参数数组
* @param $method 提交方式。两个值可选:post、get
* @param $button_name 确认按钮显示文字
* @return 提交表单HTML文本
*/
function buildRequestForm($para_temp, $method='POST', $button_name='正在跳转') {
//待请求参数数组
$para = $this->buildRequestPara($para_temp);
$sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='".$this->alipay_gateway_new."_input_charset=".trim(strtolower($this->alipay_config['input_charset']))."' method='".$method."'>";
foreach ($para as $key=>$val){
$sHtml.= "<input type='hidden' name='".$key."' value='".$val."'/>";
}
//submit按钮控件请不要含有name属性
$sHtml = $sHtml."<input type='submit' value='".$button_name."'></form>";
$sHtml = $sHtml."<script>document.forms['alipaysubmit'].submit();</script>";
return $sHtml;
}
}
?>

@ -1,253 +0,0 @@
<?php
namespace App\Services\Gateway;
use App\Services\Auth;
use App\Models\Paylist;
use App\Services\Config;
use App\Services\View;
require_once("IDt/epay_submit.class.php");
require_once("IDt/epay_notify.class.php");
class IDtPay extends AbstractPayment
{
public function purchase($request, $response, $args)
{
$type = $request->getParsedBodyParam('type');
$price = $request->getParsedBodyParam('price');
if ($price <= 0) {
return $response->write(json_encode(['errcode' => -1, 'errmsg' => "非法的金额."]));
}
$user = Auth::getUser();
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->save();
$settings = Config::get("idtpay");
$alipay_config = array(
'partner' => $settings['partner'],
'key' => $settings['key'],
'sign_type' => $settings['sign_type'],
'input_charset' => $settings['input_charset'],
'transport' => $settings['transport'],
'apiurl' => $settings['apiurl']
);
/**************************请求参数**************************/
$notify_url = Config::get("baseUrl")."/payment/notify";
//需http://格式的完整路径,不能加?id=123这类自定义参数
//页面跳转同步通知页面路径
$return_url = Config::get("baseUrl")."/user/payment/return";
//需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/
//商户订单号
$out_trade_no = $pl->tradeno;
//商户网站订单系统中唯一订单号,必填
//商品名称
$name =$settings["subjects"][array_rand($settings["subjects"])];
//付款金额
$money =$price;
//站点名称
$sitename = $settings['appname'];
//必填
//订单描述
/************************************************************/
//构造要请求的参数数组,无需改动
$parameter = array(
"pid" => trim($alipay_config['partner']),
"type" => $type,
"notify_url" => $notify_url,
"return_url" => $return_url,
"out_trade_no" => $out_trade_no,
"name" => $name,
"money" => $money,
"sitename" => $sitename
);
//建立请求
$alipaySubmit = new AlipaySubmit($alipay_config);
$html_text = $alipaySubmit->buildRequestForm($parameter);
return $response->write(json_encode(['code' => $html_text, 'errcode' => 0, 'pid' => $pl->id]));
}
public function notify($request, $response, $args)
{
$pid = $_GET['out_trade_no'];
$p = Paylist::where('tradeno', '=', $pid)->first();
if ($p->status == 1) {
$success = 1;
} else {
$settings = Config::get("idtpay");
$alipay_config = array(
'partner' => $settings['partner'],
'key' => $settings['key'],
'sign_type' => $settings['sign_type'],
'input_charset' => $settings['input_charset'],
'transport' => $settings['transport'],
'apiurl' => $settings['apiurl']
);
//计算得出通知验证结果
$alipayNotify = new AlipayNotify($alipay_config);
$verify_result = $alipayNotify->verifyNotify();
if($verify_result) {
if ($_GET['trade_status'] == 'TRADE_SUCCESS') {
$this->postPayment($_GET['out_trade_no'], "IDtPay");
$success = 1;
}
else {
$success = 0;
}
}
else {
$success = 0;
}
}
if ($success==1){
echo "success";
}else{
echo "fail";
}
}
public function getReturnHTML($request, $response, $args)
{
$pid = $_GET['out_trade_no'];
$p = Paylist::where('tradeno', '=', $pid)->first();
$money = $p->total;
if ($p->status == 1) {
$success = 1;
} else {
$settings = Config::get("idtpay");
$alipay_config = array(
'partner' => $settings['partner'],
'key' => $settings['key'],
'sign_type' => $settings['sign_type'],
'input_charset' => $settings['input_charset'],
'transport' => $settings['transport'],
'apiurl' => $settings['apiurl']
);
//计算得出通知验证结果
$alipayNotify = new AlipayNotify($alipay_config);
$verify_result = $alipayNotify->verifyNotify();
if($verify_result) {
if ($_GET['trade_status'] == 'TRADE_SUCCESS') {
$this->postPayment($_GET['out_trade_no'], "IDtPay");
$success = 1;
}
else {
$success = 0;
}
}
else {
$success = 0;
}
}
return View::getSmarty()->assign('money', $money)->assign('success', $success)->fetch('user/pay_success.tpl');
}
public function getPurchaseHTML()
{
return '
<div class="card-inner">
<p class="card-heading">充值</p>
<h5>支付方式:</h5>
<h5 style="color:red">推荐使用支付宝支付,更快到账!</h5>
<br/>
<nav class="tab-nav margin-top-no">
<ul class="nav nav-list">
<li>
<a class="waves-attach waves-effect type active" data-toggle="tab" data-pay="alipay"><img src="/images/alipay.jpg" height="50px"></img></a>
</li>
<li>
<a class="waves-attach waves-effect type" data-toggle="tab" data-pay="wxpay"><img src="/images/weixin.jpg" height="50px"></img></a>
</li>
</ul>
<div class="tab-nav-indicator"></div>
</nav>
<div class="form-group form-group-label">
<label class="floating-label" for="amount">金额</label>
<input class="form-control" id="amount" type="text">
</div>
</div>
<div class="card-action">
<div class="card-action-btn pull-left">
<button class="btn btn-flat waves-attach" id="idt_pay" ><span class="icon">check</span>&nbsp;充值</NOtton>
</div>
</div>
<script>
var type = "wxpay";
var type = "alipay";
var pid = 0;
$(".type").click(function(){
type = $(this).data("pay");
});
$("#idt_pay").click(function(){
var price = parseFloat($("#amount").val());
console.log("将要使用"+type+"方法充值"+price+"元")
if(isNaN(price)){
$("#result").modal();
$("#msg").html("非法的金额!");
}
$.ajax({
\'url\':"/user/payment/purchase",
\'data\':{
\'price\':price,
\'type\':type,
},
\'dataType\':\'json\',
\'type\':"POST",
success:function(data){
console.log(data);
if(data.errcode==-1){
$("#result").modal();
$("#msg").html(data.errmsg);
}
if(data.errcode==0){
pid = data.pid;
if(type=="wxpay"){
$("#result").modal();
$("#msg").html("正在跳转到微信..."+data.code);
}else if(type=="alipay"){
$("#result").modal();
$("#msg").html("正在跳转到支付宝..."+data.code);
}
}
}
});
});
</script>
';
}
public function getStatus($request, $response, $args)
{
$return = [];
$p = Paylist::where('tradeno', $_POST['pid'])->first();
$return['ret'] = 1;
$return['result'] = $p->status;
// file_put_contents(BASE_PATH.'/bitpay_status_success.log', json_encode($return)."\r\n", FILE_APPEND);
return json_encode($return);
}
}

@ -1,458 +0,0 @@
<?php
namespace App\Services\Gateway;
use App\Services\View;
use App\Services\Auth;
use App\Services\Config;
use App\Models\Paylist;
use App\Services\MalioConfig;
use Omnipay\Omnipay;
use Stripe\Stripe;
use Stripe\Charge;
class MalioPay extends AbstractPayment
{
public function purchase($request, $response, $args)
{
$price = $request->getParam('price');
$type = $request->getParam('type');
$user = Auth::getUser();
if ($type != 'alipay' and $type != 'wechat') {
return json_encode(['ret' => 0, 'msg' => 'wrong type']);
}
if ($price < MalioConfig::get('mups_minimum_amount')) {
return json_encode(['ret' => 0, 'errmsg' => '充值最低金额为' . MalioConfig::get('mups_minimum_amount') . '元']);
}
if ($price <= 0) {
return json_encode(['ret' => 0, 'msg' => "金额必须大于0元"]);
}
if ($type == 'alipay') {
$payment_system = MalioConfig::get('mups_alipay');
switch ($payment_system) {
case ('bitpayx'):
$bitpayx = new BitPayX(Config::get('bitpay_secret'));
$result = $bitpayx->purchase_maliopay($type, $price);
if ($result['errcode'] == 0) {
$return = array(
'ret' => 1,
'type' => 'url',
'tradeno' => $result['tradeno'],
'url' => $result['url']
);
} else {
$return = array(
'ret' => 0,
'msg' => $result['errmsg']
);
}
return json_encode($return);
case ('tomatopay'):
$tomatopay = new TomatoPay();
$result = $tomatopay->purchase_maliopay($type, $price);
if ($result['errcode'] == 0) {
$return = array(
'ret' => 1,
'type' => 'url',
'tradeno' => $result['tradeno'],
'url' => $result['code']
);
} else {
$return = array(
'ret' => 0,
'msg' => $result['errmsg']
);
}
return json_encode($return);
case ('f2fpay'):
$f2fpay = new AopF2F();
$result = $f2fpay->purchase_maliopay($type, $price);
if ($result['errcode'] == 0) {
$return = array(
'ret' => 1,
'type' => 'qrcode',
'tradeno' => $result['tradeno'],
'url' => $result['url']
);
} else {
$return = array(
'ret' => 0,
'msg' => $result['errmsg']
);
}
return json_encode($return);
case ('stripe'):
$stripe = new StripePay();
$result = $stripe->purchase_maliopay($type, $price);
if ($result['errcode'] == 0) {
$return = array(
'ret' => 1,
'type' => 'url',
'tradeno' => $result['tradeno'],
'url' => $result['url']
);
} else {
$return = array(
'ret' => 0,
'msg' => $result['errmsg']
);
}
return json_encode($return);
case ('wolfpay'):
$wolfpay = new Wolfpay();
$result = $wolfpay->purchase_maliopay($type, $price);
if ($result['errcode'] == 0) {
$return = array(
'ret' => 1,
'type' => 'url',
'tradeno' => $result['tradeno'],
'url' => $result['url']
);
} else {
$return = array(
'ret' => 0,
'msg' => $result['errmsg']
);
}
return json_encode($return);
case ('materialpay'):
$materialpay = new MaterialPay(Config::get('materialpay_secret'));
$result = $materialpay->purchase_maliopay($type, $price);
if ($result['errcode'] == 0) {
$return = array(
'ret' => 1,
'type' => 'url',
'tradeno' => $result['tradeno'],
'url' => $result['url']
);
} else {
$return = array(
'ret' => 0,
'msg' => $result['errmsg']
);
}
return json_encode($return);
}
} else if ($type == 'wechat') {
$payment_system = MalioConfig::get('mups_wechat');
switch ($payment_system) {
case ('bitpayx'):
$bitpayx = new BitPayX(Config::get('bitpay_secret'));
$result = $bitpayx->purchase_maliopay($type, $price);
if ($result['errcode'] == 0) {
$return = array(
'ret' => 1,
'type' => 'qrcode',
'tradeno' => $result['tradeno'],
'url' => $result['qrcode_url']
);
} else {
$return = array(
'ret' => 0,
'msg' => $result['errmsg']
);
}
return json_encode($return);
case ('tomatopay'):
$tomatopay = new TomatoPay();
$result = $tomatopay->purchase_maliopay($type, $price);
if ($result['errcode'] == 0) {
$return = array(
'ret' => 1,
'type' => 'url',
'tradeno' => $result['tradeno'],
'url' => $result['code']
);
} else {
$return = array(
'ret' => 0,
'msg' => $result['errmsg']
);
}
return json_encode($return);
case ('stripe'):
$stripe = new StripePay();
$result = $stripe->purchase_maliopay($type, $price);
if ($result['errcode'] == 0) {
$return = array(
'ret' => 1,
'type' => 'qrcode',
'tradeno' => $result['tradeno'],
'url' => $result['url']
);
} else {
$return = array(
'ret' => 0,
'msg' => $result['errmsg']
);
}
return json_encode($return);
case ('materialpay'):
$materialpay = new MaterialPay(Config::get('materialpay_secret'));
$result = $materialpay->purchase_maliopay($type, $price);
if ($result['errcode'] == 0) {
$return = array(
'ret' => 1,
'type' => 'qrcode',
'tradeno' => $result['tradeno'],
'url' => $result['url']
);
} else {
$return = array(
'ret' => 0,
'msg' => $result['errmsg']
);
}
return json_encode($return);
}
}
}
public function notify($request, $response, $args)
{
$path = $request->getUri()->getPath();
$path_exploded = explode('/', $path);
$payment_system = $path_exploded[3];
switch ($payment_system) {
case ('bitpayx'):
$bitpayx = new BitPayX(Config::get('bitpay_secret'));
if (!Config::get('bitpay_secret') || Config::get('bitpay_secret') === '') {
$return = [];
$return['status'] = 400;
echo json_encode($return);
return $return;
}
$inputString = file_get_contents('php://input', 'r');
$inputStripped = str_replace(array("\r", "\n", "\t", "\v"), '', $inputString);
$inputJSON = json_decode($inputStripped, true); //convert JSON into array
$data = array();
if ($inputJSON !== null) {
$data['status'] = $inputJSON['status'];
$data['order_id'] = $inputJSON['order_id'];
$data['merchant_order_id'] = $inputJSON['merchant_order_id'];
$data['price_amount'] = $inputJSON['price_amount'];
$data['price_currency'] = $inputJSON['price_currency'];
$data['created_at_t'] = $inputJSON['created_at_t'];
}
$str_to_sign = $bitpayx->prepareSignId($inputJSON['merchant_order_id']);
$resultVerify = $bitpayx->verify($str_to_sign, $inputJSON['token']);
$isPaid = $data !== null && $data['status'] !== null && $data['status'] === 'PAID';
if ($resultVerify && $isPaid) {
$bitpayx->postPaymentMaliopay($data['merchant_order_id'], '在线支付 ' . $data['merchant_order_id']);
// echo 'SUCCESS';
$return = [];
$return['status'] = 200;
echo json_encode($return);
} else {
// echo 'FAIL';
$return = [];
$return['status'] = 400;
echo json_encode($return);
}
return $return;
case ('tomatopay'):
$type = 'alipay';
$settings = Config::get("tomatopay")[$type];
$order_data = $_REQUEST;
$transid = $order_data['trade_no']; //转账交易号
$invoiceid = $order_data['out_trade_no']; //订单号
$amount = $order_data['total_fee']; //获取递过来的总价格
$status = $order_data['trade_status']; //获取传递过来的交易状态
$signs = $order_data['sign'];
if ($request->isGet()) {
header("Location: /user/payment/return?tradeno=".$order_data['out_trade_no']);
return 0;
}
$security = array();
$security['out_trade_no'] = $invoiceid;
$security['total_fee'] = $amount;
$security['trade_no'] = $transid;
$security['trade_status'] = $status;
foreach ($security as $k => $v) {
$o .= "$k=" . urlencode($v) . "&";
}
$sign = md5(substr($o, 0, -1) . $settings['token']);
if ($sign == $signs) {
//验重
$p = Paylist::where('tradeno', '=', $order_data['out_trade_no'])->first();
$money = $p->total;
if ($p->status != 1) {
$this->postPaymentMaliopay($order_data['out_trade_no'], "在线支付");
echo 'SUCCESS';
} else {
echo 'ERROR';
}
echo 'success';
} else {
echo '验证失败';
}
return 'tomatopay';
case ('f2fpay'):
$f2fpay = new AopF2F();
$gateway = Omnipay::create('Alipay_AopF2F');
$gateway->setSignType('RSA2'); //RSA/RSA2
$gateway->setAppId(Config::get('f2fpay_app_id'));
$gateway->setPrivateKey(Config::get('merchant_private_key')); // 可以是路径,也可以是密钥内容
$gateway->setAlipayPublicKey(Config::get('alipay_public_key')); // 可以是路径,也可以是密钥内容
$aliRequest = $gateway->completePurchase();
$aliRequest->setParams($_POST);
$aliResponse = $aliRequest->send();
$pid = $aliResponse->data('out_trade_no');
if ($aliResponse->isPaid()) {
$this->postPaymentMaliopay($pid, '支付宝');
die('success'); //The response should be 'success' only
}
return 'f2fpay';
case ('stripe'):
Stripe::setApiKey(Config::get('stripe_key'));
$endpoint_secret = Config::get('stripe_webhook_endpoint_secret');
$payload = @file_get_contents('php://input');
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
$event = null;
try {
$event = \Stripe\Webhook::constructEvent(
$payload,
$sig_header,
$endpoint_secret
);
} catch (\UnexpectedValueException $e) {
http_response_code(400);
exit();
} catch (\Stripe\Error\SignatureVerification $e) {
http_response_code(400);
exit();
}
switch ($event->type) {
case 'source.chargeable':
$source = $event->data->object;
$charge = Charge::create([
'amount' => $source['amount'],
'currency' => $source['currency'],
'source' => $source['id'],
]);
if ($charge['status'] == 'succeeded') {
$type = null;
if ($source['type'] == 'alipay') {
$type = '支付宝支付';
} else if ($source['type'] == 'wechat') {
$type = '微信支付';
}
$order = Paylist::where('tradeno', '=', $source['id'])->first();
if ($order->status != 1) {
$this->postPaymentMaliopay($source['id'], 'Stripe '.$type);
echo 'SUCCESS';
} else {
echo 'ERROR';
}
}
break;
default:
http_response_code(400);
exit();
}
http_response_code(200);
case ('wolfpay'):
$type = $args['method'];
$settings = Config::get("wolfpay") ['config'];
$security['orderid'] = $_REQUEST['out_trade_no'];
if ($security['orderid'] == '' OR $security['orderid'] == null) {
header("Location: /user/code");
} else {
//实例化支付类
//$pay = new Pays($settings['hid'], $settings['key']);
$wolfpay = new Wolfpay();
//接收异步通知数据
$data = $_GET;
//商户订单号
$out_trade_no = $data['out_trade_no'];
//验证签名
if ($wolfpay->verify($data)) {
//验证支付状态
if ($data['trade_status'] == 'TRADE_SUCCESS') {
$wolfpay->postPaymentMaliopay($data['out_trade_no'], "在线支付");
echo "success";
header("Location: /user/code");
}
} else {
echo '錯誤';
}
}
case ('materialpay'):
$data = array();
$data['tradeStatus'] = $request->getParam('tradeStatus');
$data['payAmount'] = number_format($request->getParam('payAmount'),2);
$data['tradeNo'] = $request->getParam('tradeNo');
$data['payType'] = $request->getParam('payType');
$data['outTradeNo'] = $request->getParam('outTradeNo');
$pl = Paylist::where('tradeno',$data['outTradeNo'])->first();
if ($pl->status == 1) {
echo 'success';
return;
}
$materialpay = new MaterialPay(Config::get('materialpay_secret'));
// 准备待签名数据
$str_to_sign = $materialpay->prepareSign($data);
// 验证签名
$resultVerify = $materialpay->verify($str_to_sign, $request->getParam('sign'));
if ($resultVerify) {
$materialpay->postPaymentMaliopay($data['outTradeNo'], 'MaterialPay - ' . $data['outTradeNo']);
echo 'success';
return;
} else {
echo 'fail';
return;
}
default:
return 'failed';
}
}
public function getPurchaseHTML()
{
return 1;
}
public function getReturnHTML($request, $response, $args)
{
$tradeno = $_GET['tradeno'];
if ($tradeno == '' || $tradeno == null) {
$tradeno = $_GET['source'];
}
if ($tradeno == '' || $tradeno == null) {
$tradeno = $_GET['out_trade_no'];
}
$p = Paylist::where('tradeno', '=', $tradeno)->first();
$money = $p->total;
if ($p->status === 1) {
$success = 1;
} else {
$success = 0;
}
return View::getSmarty()->assign('money', $money)->assign('success', $success)->fetch('user/pay_success.tpl');
}
public function getStatus($request, $response, $args)
{
$p = Paylist::where('tradeno', $_POST['tradeno'])->first();
$return['ret'] = 1;
$return['result'] = $p->status;
return json_encode($return);
}
}

@ -1,202 +0,0 @@
<?php
namespace App\Services\Gateway;
use App\Services\View;
use App\Services\Auth;
use App\Services\Config;
use App\Models\Paylist;
class MaterialPay extends AbstractPayment
{
private $appSecret;
private $gatewayUri;
public function __construct($appSecret)
{
$this->appSecret = $appSecret;
$this->gatewayUri = 'https://www.materialpay.com/api/payment/';
}
public function prepareSign($data)
{
ksort($data);
return http_build_query($data);
}
public function sign($data)
{
return strtolower(md5(md5($data) . $this->appSecret));
}
public function verify($data, $signature)
{
$mySign = $this->sign($data);
return $mySign === $signature;
}
public function post($data, $type = 'create')
{
if ($type == 'create') {
$this->gatewayUri .= 'create';
} else {
$this->gatewayUri .= 'query';
}
$headerArray = array("Content-type:application/json;charset='utf-8'","Accept:application/json");
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->gatewayUri);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headerArray);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
public function purchase($request, $response, $args)
{
$price = $request->getParam('price');
$type = $request->getParam('type');
if ($price <= 0) {
return json_encode(['code' => -1, 'errmsg' => '非法的金额.']);
}
$user = Auth::getUser();
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->save();
$data['appId'] = Config::get('materialpay_appid');
$data['outTradeNo'] = $pl->tradeno;
$data['payAmount'] = (float)$price;
$data['payType'] = $type;
$params = $this->prepareSign($data);
$data['sign'] = $this->sign($params);
$data['returnUrl'] = Config::get('baseUrl') . '/user/code';
switch ($type) {
case ('WXPAY'):
$result = json_decode($this->post($data), true);
break;
default:
$result = json_decode($this->post($data), true);
}
$result['pid'] = $pl->tradeno;
return json_encode($result);
}
public function purchase_maliopay($type, $price)
{
if ($price <= 0) {
return json_encode(['code' => -1, 'errmsg' => '非法的金额.']);
}
if ($type == 'wechat') {
$type = 'WXPAY';
}
if ($type == 'alipay') {
$type = 'ALIPAY_WEB';
}
$user = Auth::getUser();
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->save();
$data['appId'] = Config::get('materialpay_appid');
$data['outTradeNo'] = $pl->tradeno;
$data['payAmount'] = (float)$price;
$data['payType'] = $type;
$params = $this->prepareSign($data);
$data['sign'] = $this->sign($params);
$data['returnUrl'] = Config::get('baseUrl') . '/user/code';
switch ($type) {
case ('WXPAY'):
$result = json_decode($this->post($data), true);
break;
default:
$result = json_decode($this->post($data), true);
}
$result['pid'] = $pl->tradeno;
return array('url' => $result['result']['url'], 'errcode' => 0, 'tradeno' => $pl->tradeno);
}
public function query($tradeNo)
{
$data['appId'] = Config::get('materialpay_appid');
$data['outTradeNo'] = $tradeNo;
$params = $this->prepareSign($data);
$data['sign'] = $this->sign($params);
return json_decode($this->post($data, $type = 'query'), true);
}
public function notify($request, $response, $args)
{
$data = array();
$data['tradeStatus'] = $request->getParam('tradeStatus');
$data['payAmount'] = number_format($request->getParam('payAmount'),2);
$data['tradeNo'] = $request->getParam('tradeNo');
$data['payType'] = $request->getParam('payType');
$data['outTradeNo'] = $request->getParam('outTradeNo');
// 准备待签名数据
$str_to_sign = $this->prepareSign($data);
// 验证签名
$resultVerify = $this->verify($str_to_sign, $request->getParam('sign'));
if ($resultVerify) {
$this->postPayment($data['outTradeNo'], 'MaterialPay - ' . $data['outTradeNo']);
echo 'success';
} else {
echo 'fail';
}
}
public function getPurchaseHTML()
{
return View::getSmarty()->fetch('user/materialpay.tpl');
}
public function getReturnHTML($request, $response, $args)
{
$pid = $_GET['outTradeNo'];
$p = Paylist::where('tradeno', '=', $pid)->first();
$money = $p->total/1000;
if ($p->status == 1) {
$success = 1;
} else {
$data = array();
$data['tradeStatus'] = $request->getParam('tradeStatus');
$data['payAmount'] = number_format($request->getParam('payAmount'),2);
$data['tradeNo'] = $request->getParam('tradeNo');
$data['payType'] = $request->getParam('payType');
$data['outTradeNo'] = $request->getParam('outTradeNo');
// 准备待签名数据
$str_to_sign = $this->prepareSign($data);
// 验证签名
$resultVerify = $this->verify($str_to_sign, $request->getParam('sign'));
if ($resultVerify) {
$this->postPayment($data['outTradeNo'], 'MaterialPay');
$success = 1;
} else {
$success = 0;
}
}
return View::getSmarty()->assign('money', $money)->assign('success', $success)->fetch('user/pay_success.tpl');
}
public function getStatus($request, $response, $args)
{
$return = [];
$p = Paylist::where('tradeno', $_POST['pid'])->first();
$return['ret'] = 1;
$return['result'] = $p->status;
return json_encode($return);
}
}

@ -150,7 +150,7 @@ class PAYJS extends AbstractPayment
}
public function getPurchaseHTML()
{
return 1;
return View::getSmarty()->fetch('user/payjs.tpl');
}
public function getReturnHTML($request, $response, $args)
{

@ -13,7 +13,6 @@ use App\Models\Code;
use App\Services\Auth;
use App\Models\Payback;
use App\Services\Config;
use App\Utils\Telegram;
use Paymentwall_Config;
use Paymentwall_Pingback;
use Paymentwall_Widget;

@ -1,174 +0,0 @@
<?php
namespace App\Services\Gateway;
use App\Services\Auth;
use App\Services\Config;
use App\Models\Paylist;
use App\Services\View;
use App\Services\MalioConfig;
use Exception;
use App\Services\Gateway\PayssionClient;
class Payssion extends AbstractPayment
{
public function purchase($request, $response, $args)
{
$price = $request->getParam('price');
$type = $request->getParam('type');
$user = Auth::getUser();
if ($type != 'alipay' and $type != 'unionpay') {
return json_encode(['errcode' => -1, 'errmsg' => 'wrong payment.']);
}
if ($type == 'alipay') {
$type = 'alipay_cn';
} else if ($type == 'unionpay') {
$type = 'unionpay_cn';
}
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->save();
$payssion = new PayssionClient(Config::get('payssion_api_key'), Config::get('payssion_secret_key'));
$payssion_response = null;
try {
//$type = 'dotpay_pl'; // for test
$payssion_response = $payssion->create(array(
'amount' => $price,
'currency' => 'CNY',
'pm_id' => $type,
'description' => 'Shadowsocks Product',
'order_id' => $pl->tradeno,
'return_url' => Config::get('baseUrl').'/user/payment/return' //optional, the return url after payments (for both of paid and non-paid)
));
} catch (\Exception $e) {
$res['ret'] = 0;
$res['msg'] = "创建订单失败。".$e->getMessage();
return $response->getBody()->write(json_encode($res));
}
if ($payssion->isSuccess()) {
$todo = $payssion_response['todo'];
if ($todo) {
$todo_list = explode('|', $todo);
if (in_array("redirect", $todo_list)) {
$res['ret'] = 1;
$res['url'] = $payssion_response['redirect_url'];
$res['pid'] = $pl->id;
return $response->getBody()->write(json_encode($res));
}
} else {
//just in case, should not be here
}
} else {
return json_encode($payssion_response);
}
$res['ret'] = 0;
$res['msg'] = "购买失败";
return $response->getBody()->write(json_encode($res));
}
public function notify($request, $response, $args)
{
$api_key=Config::get('payssion_api_key');
$pm_id=$request->getParam('pm_id');
$amount=$request->getParam('amount');
$currency=$request->getParam('currency');
$order_id=$request->getParam('order_id');
$secret_key=Config::get('payssion_secret_key');
$state=$request->getParam('state');
$msg = implode('|', array($api_key, $pm_id, $amount, $currency,$order_id,$state, $secret_key));
if($request->getParam('notify_sig')!= md5($msg)){
return;
}
$state_code=3;
switch ($state) {
case 'error':
$state_code=2;
break;
case 'pending':
$state_code=3;
break;
case 'completed':
$state_code=4;
break;
case 'paid_partial':
$state_code=5;
break;
case 'failed':
$state_code=6;
break;
case 'cancelled':
$state_code=7;
break;
case 'expired':
$state_code=8;
break;
case 'refunded':
$state_code=9;
break;
case 'refund_pending':
$state_code=10;
break;
case 'refund_failed':
$state_code=11;
break;
case 'refund_cancelled':
$state_code=12;
break;
case 'chargeback':
$state_code=13;
break;
default:
$state_code=14;
break;
}
if ($state_code != 4) {
return;
}
$type = null;
if ($pm_id == 'alipay_cn') {
$type = '支付宝支付';
} else if ($pm_id == 'unionpay_cn') {
$type = '银联支付';
}
$order = Paylist::where('tradeno', '=', $order_id)->first();
if ($order->status != 1) {
$this->postPayment($order_id, 'Payssion '.$type);
echo 'SUCCESS';
} else {
echo 'ERROR';
}
}
public function getPurchaseHTML()
{
return 1;
}
public function getReturnHTML($request, $response, $args)
{
$pid = $_GET['order_id'];
$p = Paylist::where('tradeno', '=', $pid)->first();
$money = $p->total;
if ($p->status === 1) {
$success = 1;
} else {
$success = 0;
}
return View::getSmarty()->assign('money', $money)->assign('success', $success)->fetch('user/pay_success.tpl');
}
public function getStatus($request, $response, $args)
{
return;
}
}

@ -1,313 +0,0 @@
<?php
namespace App\Services\Gateway;
/**
* Client library for Payssion API.
*/
class PayssionClient
{
/**
* @const string
*/
const VERSION = '1.3.0.160612';
/**
* @var string
*/
protected $api_url;
protected $api_key = ''; //your api key
protected $secret_key = ''; //your secret key
protected static $sig_keys = array(
'create' => array(
'api_key', 'pm_id', 'amount', 'currency', 'order_id', 'secret_key'
),
'details' => array(
'api_key', 'transaction_id', 'order_id', 'secret_key'
)
);
/**
* @var array
*/
protected $http_errors = array
(
400 => '400 Bad Request',
401 => '401 Unauthorized',
500 => '500 Internal Server Error',
501 => '501 Not Implemented',
502 => '502 Bad Gateway',
503 => '503 Service Unavailable',
504 => '504 Gateway Timeout',
);
/**
* @var bool
*/
protected $is_success = false;
/**
* @var array
*/
protected $allowed_request_methods = array(
'get',
'put',
'post',
'delete',
);
/**
* @var boolean
*/
protected $ssl_verify = true;
/**
* Constructor
*
* @param string $api_key Payssion App api_key
* @param string $secret_key Payssion App secret_key
* @param bool $is_livemode false if you use sandbox api_key and true for live mode
*/
public function __construct($api_key, $secret_key, $is_livemode = true)
{
$this->api_key = $api_key;
$this->secret_key = $secret_key;
$validate_params = array
(
false === extension_loaded('curl') => 'The curl extension must be loaded for using this class!',
false === extension_loaded('json') => 'The json extension must be loaded for using this class!',
empty($this->api_key) => 'api_key is not set!',
empty($this->secret_key) => 'secret_key is not set!',
);
$this->checkForErrors($validate_params);
$this->setLiveMode($is_livemode);
}
/**
* Set LiveMode
*
* @param bool $is_livemode
*/
public function setLiveMode($is_livemode)
{
if ($is_livemode) {
$this->api_url = 'https://www.payssion.com/api/v1/payment/';
} else {
$this->api_url = 'http://sandbox.payssion.com/api/v1/payment/';
}
}
/**
* Set Api URL
*
* @param string $url Api URL
*/
public function setUrl($url)
{
$this->api_url = $url;
}
/**
* Sets SSL verify
*
* @param bool $ssl_verify SSL verify
*/
public function setSSLverify($ssl_verify)
{
$this->ssl_verify = $ssl_verify;
}
/**
* Request state getter
*
* @return bool
*/
public function isSuccess()
{
return $this->is_success;
}
/**
* create payment order
*
* @param $params create Params
* @return array
*/
public function create(array $params)
{
return $this->call(
'create',
'post',
$params
);
}
/**
* get payment details
*
* @param $params query Params
* @return array
*/
public function getDetails(array $params)
{
return $this->call(
'details',
'post',
$params
);
}
/**
* Method responsible for preparing, setting state and returning answer from rest server
*
* @param string $method
* @param string $request
* @param array $params
* @return array
*/
protected function call($method, $request, $params)
{
$this->is_success = false;
$validate_params = array
(
false === is_string($method) => 'Method name must be string',
false === $this->checkRequestMethod($request) => 'Not allowed request method type',
true === empty($params) => 'params is null',
);
$this->checkForErrors($validate_params);
$params['api_key'] = $this->api_key;
$params['api_sig'] = $this->getSig($params, self::$sig_keys[$method]);
$response = $this->pushData($method, $request, $params);
$response = json_decode($response, true);
if (isset($response['result_code']) && 200 == $response['result_code'])
{
$this->is_success = true;
}
return $response;
}
/**
* Checking error mechanism
*
* @param array $validateArray
* @throws Exception
*/
protected function getSig(array &$params, array $sig_keys)
{
$msg_array = array();
foreach ($sig_keys as $key) {
$msg_array[$key] = isset($params[$key]) ? $params[$key] : '';
}
$msg_array['secret_key'] = $this->secret_key;
$msg = implode('|', $msg_array);
$sig = md5($msg);
return $sig;
}
/**
* Checking error mechanism
*
* @param array $validateArray
* @throws Exception
*/
protected function checkForErrors(&$validate_params)
{
foreach ($validate_params as $key => $error)
{
if ($key)
{
throw new Exception($error, -1);
}
}
}
/**
* Check if method is allowed
*
* @param string $method_type
* @return bool
*/
protected function checkRequestMethod($method_type)
{
$request_method = strtolower($method_type);
if(in_array($request_method, $this->allowed_request_methods))
{
return true;
}
return false;
}
/**
* Method responsible for pushing data to server
*
* @param string $method
* @param string $method_type
* @param array|string $vars
* @return array
* @throws Exception
*/
protected function pushData($method, $method_type, $vars)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->api_url. $method);
curl_setopt($ch, CURLOPT_POST, true);
if (is_array($vars)) $vars = http_build_query($vars, '', '&');
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getHeaders());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->ssl_verify);
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (isset($this->http_errors[$code]))
{
throw new Exception('Response Http Error - ' . $this->http_errors[$code], $code);
}
$code = curl_errno($ch);
if (0 < $code)
{
throw new Exception('Unable to connect to ' . $this->api_url . ' Error: ' . "$code :". curl_error($ch), $code);
}
curl_close($ch);
return $response;
}
protected function &getHeaders() {
$langVersion = phpversion();
$uname = php_uname();
$ua = array(
'version' => self::VERSION,
'lang' => 'php',
'lang_version' => $langVersion,
'publisher' => 'payssion',
'uname' => $uname,
);
$headers = array(
'X-Payssion-Client-User-Agent: ' . json_encode($ua),
"User-Agent: Payssion/php/$langVersion/" . self::VERSION,
'Content-Type: application/x-www-form-urlencoded',
);
return $headers;
}
}

@ -62,7 +62,7 @@ class SPay extends AbstractPayment
//header("Location: http://www.dayyun.com/pay/pay/alipay.php?".http_build_query($data));
return json_encode(['code' => 0, 'url' => 'http://h.8889838.com/pay/pay/alipay.php?' . http_build_query($data)]);
return json_encode(['code' => 0, 'url' => 'http://www.dayyun.com/pay/pay/alipay.php?' . http_build_query($data)]);
}
public function notify($request, $response, $args)

@ -1,196 +0,0 @@
<?php
namespace App\Services\Gateway;
use App\Services\Auth;
use App\Services\Config;
use App\Models\Paylist;
use App\Services\View;
use App\Services\MalioConfig;
use Exception;
use Stripe\Stripe;
use Stripe\Charge;
use Stripe\Source;
class StripePay extends AbstractPayment
{
public function __construct()
{
Stripe::setApiKey(Config::get('stripe_key'));
}
public function purchase($request, $response, $args)
{
$price = $request->getParam('price');
$type = $request->getParam('type');
$user = Auth::getUser();
if ($type != 'alipay' and $type != 'wechat') {
return json_encode(['errcode' => -1, 'errmsg' => 'wrong payment.']);
}
$stripe_minimum_amount = MalioConfig::get('stripe_minimum_amount');
if ($price < $stripe_minimum_amount) {
return json_encode(['errcode' => -1, 'errmsg' => '充值最低金额为'.$stripe_minimum_amount.'元']);
}
$ch = curl_init();
$url = 'https://api.exchangeratesapi.io/latest?symbols=CNY&base='.strtoupper(MalioConfig::get('stripe_currency'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$currency = json_decode(curl_exec($ch));
curl_close($ch);
$price_exchanged = ((double)$price) / ($currency->rates->CNY);
$source = Source::create([
'amount' => floor($price_exchanged * 100),
'currency' => MalioConfig::get('stripe_currency'),
'type' => $type,
'redirect' => [
'return_url' => Config::get('baseUrl') . '/user/payment/return',
],
]);
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = $source['id'];
$pl->save();
if ($type == 'alipay') {
return json_encode(array('url' => $source['redirect']['url'], 'errcode' => 0, 'pid' => $pl->id));
} else {
return json_encode(array('url' => $source['wechat']['qr_code_url'], 'errcode' => 0, 'pid' => $pl->id));
}
}
public function purchase_maliopay($type, $price)
{
$user = Auth::getUser();
if ($type != 'alipay' and $type != 'wechat') {
return json_encode(['errcode' => -1, 'errmsg' => 'wrong payment.']);
}
$stripe_minimum_amount = MalioConfig::get('stripe_minimum_amount');
if ($price < $stripe_minimum_amount) {
return json_encode(['errcode' => -1, 'errmsg' => '充值最低金额为'.$stripe_minimum_amount.'元']);
}
$ch = curl_init();
$url = 'https://api.exchangeratesapi.io/latest?symbols=CNY&base='.strtoupper(MalioConfig::get('stripe_currency'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$currency = json_decode(curl_exec($ch));
curl_close($ch);
$price_exchanged = ((double)$price) / ($currency->rates->CNY);
$source = Source::create([
'amount' => floor($price_exchanged * 100),
'currency' => MalioConfig::get('stripe_currency'),
'type' => $type,
'redirect' => [
'return_url' => Config::get('baseUrl') . '/user/payment/return',
],
]);
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = $source['id'];
$pl->save();
if ($type == 'alipay') {
return array(
'url' => $source['redirect']['url'],
'errcode' => 0,
'tradeno' => $pl->tradeno
);
} else {
return array(
'url' => $source['wechat']['qr_code_url'],
'errcode' => 0,
'tradeno' => $pl->tradeno
);
}
}
public function notify($request, $response, $args)
{
$endpoint_secret = Config::get('stripe_webhook_endpoint_secret');
$payload = @file_get_contents('php://input');
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
$event = null;
try {
$event = \Stripe\Webhook::constructEvent(
$payload,
$sig_header,
$endpoint_secret
);
} catch (\UnexpectedValueException $e) {
http_response_code(400);
exit();
} catch (\Stripe\Error\SignatureVerification $e) {
http_response_code(400);
exit();
}
switch ($event->type) {
case 'source.chargeable':
$source = $event->data->object;
$charge = Charge::create([
'amount' => $source['amount'],
'currency' => $source['currency'],
'source' => $source['id'],
]);
if ($charge['status'] == 'succeeded') {
$type = null;
if ($source['type'] == 'alipay') {
$type = '支付宝支付';
} else if ($source['type'] == 'wechat') {
$type = '微信支付';
}
$order = Paylist::where('tradeno', '=', $source['id'])->first();
if ($order->status != 1) {
$this->postPayment($source['id'], 'Stripe '.$type);
echo 'SUCCESS';
} else {
echo 'ERROR';
}
}
break;
default:
http_response_code(400);
exit();
}
http_response_code(200);
}
public function getPurchaseHTML()
{
return 1;
}
public function getReturnHTML($request, $response, $args)
{
$pid = $_GET['source'];
$p = Paylist::where('tradeno', '=', $pid)->first();
$money = $p->total;
if ($p->status === 1) {
$success = 1;
} else {
$success = 0;
}
return View::getSmarty()->assign('money', $money)->assign('success', $success)->fetch('user/pay_success.tpl');
}
public function getStatus($request, $response, $args)
{
$p = Paylist::where('id', $_POST['pid'])->first();
$return['ret'] = 1;
$return['result'] = $p->status;
return json_encode($return);
}
}

@ -1,200 +1,146 @@
<?php
namespace App\Services\Gateway;
use App\Services\View;
use App\Services\Auth;
use App\Services\Config;
use App\Models\Paylist;
class TomatoPay extends AbstractPayment
{
public function purchase($request, $response, $args)
{
$type = $request->getParam('type');
$price = $request->getParam('price');
if($price <= 0){
return json_encode(['errcode'=>-1,'errmsg'=>"非法的金额."]);
$type = $request->getParsedBodyParam('type');
$price = $request->getParsedBodyParam('price');
if ($price <= 0) {
return $response->write(json_encode(['errcode' => -1, 'errmsg' => "非法的金额."]));
}
$user = Auth::getUser();
$settings = Config::get("tomatopay")[$type];
$settings = $_ENV['tomatopay'][$type];
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->save();
$fqaccount=$settings['account'];
$fqkey=$settings['token'];
$pl->save();
$fqaccount = $settings['account'];
$fqkey = $settings['token'];
$fqmchid = $settings['mchid'];
$fqtype = 1;
$fqtrade = $pl->tradeno;
$fqcny = $price;
$data = [
'account' => $settings['account'],
'mchid' => $settings['mchid'],
'type' => 1,
'trade' => $pl->tradeno,
'cny' => $price,
];
$signs = md5("mchid=".$fqmchid."&account=".$fqaccount."&cny=".$fqcny."&type=1&trade=".$fqtrade.$fqkey);
$url="https://b.fanqieui.com/gateways/".$type.".php?account=".$fqaccount."&mchid=".$fqmchid."&type=".$fqtype."&trade=".$fqtrade."&cny=".$fqcny."&signs=".$signs;
$result = "<script language='javascript' type='text/javascript'>window.location.href='".$url."';</script>";
$result = json_encode(array('code'=>$url,'errcode'=>0,'pid' =>$pl->id));
return $result;
}
public function purchase_maliopay($type, $price)
{
if($price <= 0){
return json_encode(['errcode'=>-1,'errmsg'=>"非法的金额."]);
}
$user = Auth::getUser();
$settings = Config::get("tomatopay")[$type];
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->save();
$fqaccount=$settings['account'];
$fqkey=$settings['token'];
$fqmchid = $settings['mchid'];
$fqtype = 1;
$fqtrade = $pl->tradeno;
$fqcny = $price;
$data = [
'account' => $settings['account'],
'mchid' => $settings['mchid'],
'type' => 1,
'trade' => $pl->tradeno,
'cny' => $price,
];
$signs = md5("mchid=".$fqmchid."&account=".$fqaccount."&cny=".$fqcny."&type=1&trade=".$fqtrade.$fqkey);
$url="https://b.fanqieui.com/gateways/".$type.".php?account=".$fqaccount."&mchid=".$fqmchid."&type=".$fqtype."&trade=".$fqtrade."&cny=".$fqcny."&signs=".$signs;
$result = array('code'=>$url,'errcode'=>0,'tradeno' => $pl->tradeno );
return $result;
}
public function notify($request, $response, $args)
{
$type = $args['type'];
$settings = Config::get("tomatopay")[$type];
$order_data = $_REQUEST;
$transid = $order_data['trade_no']; //转账交易号
$invoiceid = $order_data['out_trade_no']; //订单号
$amount = $order_data['total_fee']; //获取递过来的总价格
$status = $order_data['trade_status']; //获取传递过来的交易状态
$signs = $order_data['sign'];
$security = array();
$security['out_trade_no'] = $invoiceid;
$security['total_fee'] = $amount;
$security['trade_no'] = $transid;
$security['trade_status'] = $status;
foreach ($security as $k=>$v)
{
$o.= "$k=".urlencode($v)."&";
}
$sign = md5(substr($o,0,-1).$settings['token']);
$fqtrade = $pl->tradeno;
$fqcny = $price;
$signs = md5(
'mchid=' . $fqmchid . '&account=' . $fqaccount . '&cny=' . $fqcny . '&type=1&trade=' . $fqtrade . $fqkey
);
$url = 'https://b.fanqieui.com/gateways/' . $type . '.php?account='
. $fqaccount . '&mchid=' . $fqmchid . '&type=1'
. '&trade=' . $fqtrade . '&cny=' . $fqcny . '&signs=' . $signs;
$result = "<script language='javascript' type='text/javascript'>window.location.href='" . $url . "';</script>";
return $response->write(json_encode(['code' => $result, 'errcode' => 0, 'pid' => $pl->id]));
}
if ($sign == $signs) {
//验重
$p = Paylist::where('tradeno', '=', $order_data['out_trade_no'])->first();
$money = $p->total;
if ($p->status != 1) {
$this->postPayment($order_data['out_trade_no'], "在线支付");
echo 'SUCCESS';
} else {
echo 'ERROR';
}
echo 'success';
if($ispost==0) header("Location: /user/code");
}else{
echo '验证失败';
public function notify($request, $response, $args)
{
$type = $args['type'];
$settings = $_ENV['tomatopay'][$type];
$order_data = $request->getParsedBody();
$signs = $order_data['sign'];
unset($order_data['sign']);
$security = $order_data;
$o = '';
foreach ($security as $k => $v) {
$o .= "$k=" . urlencode($v) . "&";
}
$sign = md5(substr($o, 0, -1) . $settings['token']);
if ($sign == $signs) {
$this->postPayment($order_data['out_trade_no'], "在线支付");
return $response->write('success');
} else {
return $response->write('failed');
}
}
public function getPurchaseHTML()
{
return '
<div class="card-inner">
<p class="card-heading">充值</p>
<h5>支付方式:</h5>
<nav class="tab-nav margin-top-no">
<ul class="nav nav-list">
<li>
<a class="waves-attach waves-effect type active" data-toggle="tab" data-pay="wxpay">微信支付</a>
</li>
<li>
<a class="waves-attach waves-effect type" data-toggle="tab" data-pay="alipay">支付宝</a>
</li>
</ul>
<div class="tab-nav-indicator"></div>
</nav>
<div class="form-group form-group-label">
<label class="floating-label" for="amount">金额</label>
<input class="form-control" id="amount" type="text">
</div>
</div>
<p class="card-heading">充值</p>
<h5>支付方式:</h5>
<h5 style="color:red">推荐使用支付宝支付,更快到账!</h5>
<br/>
<nav class="tab-nav margin-top-no">
<ul class="nav nav-list">
<li>
<a class="waves-attach waves-effect type active" data-toggle="tab" data-pay="alipay"><img src="/images/alipay.jpg" height="50px"></img></a>
</li>
<li>
<a class="waves-attach waves-effect type" data-toggle="tab" data-pay="wxpay"><img src="/images/weixin.jpg" height="50px"></img></a>
</li>
</ul>
<div class="tab-nav-indicator"></div>
</nav>
<div class="form-group form-group-label">
<label class="floating-label" for="amount">金额</label>
<input class="form-control" id="amount" type="text">
</div>
</div>
<div class="card-action">
<div class="card-action-btn pull-left">
<button class="btn btn-flat waves-attach" id="code-update" ><span class="icon">check</span>&nbsp;充值</NOtton>
</div>
</div>
<div class="card-action-btn pull-left">
<button class="btn btn-flat waves-attach" id="tomato_pay" ><span class="icon">check</span>&nbsp;充值</NOtton>
</div>
</div>
<script>
var type = "wxpay";
var type = "alipay";
var pid = 0;
$(".type").click(function(){
type = $(this).data("pay");
});
$("#code-update").click(function(){
var price = parseFloat($("#amount").val());
console.log("将要使用"+type+"方法充值"+price+"元")
if(isNaN(price)){
$("#result").modal();
$("#msg").html("非法的金额!");
}
$.ajax({
\'url\':"/user/payment/purchase",
\'data\':{
\'price\':price,
\'type\':type,
},
\'dataType\':\'json\',
\'type\':"POST",
success:function(data){
console.log(data);
if(data.errcode==-1){
$("#result").modal();
$("#msg").html(data.errmsg);
}
if(data.errcode==0){
pid = data.pid;
if(type=="wxpay"){
$("#result").modal();
$("#msg").html("正在跳转到微信..."+data.code);
}else if(type=="alipay"){
$("#result").modal();
$("#msg").html("正在跳转到支付宝..."+data.code);
}
}
}
});
});
var type = "wxpay";
var type = "alipay";
var pid = 0;
$(".type").click(function(){
type = $(this).data("pay");
});
$("#tomato_pay").click(function(){
var price = parseFloat($("#amount").val());
console.log("将要使用"+type+"方法充值"+price+"元")
if(isNaN(price)){
$("#result").modal();
$("#msg").html("非法的金额!");
}
$.ajax({
\'url\':"/user/payment/purchase",
\'data\':{
\'price\':price,
\'type\':type,
},
\'dataType\':\'json\',
\'type\':"POST",
success:function(data){
console.log(data);
if(data.errcode==-1){
$("#result").modal();
$("#msg").html(data.errmsg);
}
if(data.errcode==0){
pid = data.pid;
if(type=="wxpay"){
$("#result").modal();
$("#msg").html("正在跳转到微信..."+data.code);
}else if(type=="alipay"){
$("#result").modal();
$("#msg").html("正在跳转到支付宝..."+data.code);
}
}
}
});
setTimeout(f, 1000);
});
</script>
';
}
public function getReturnHTML($request, $response, $args)
{
// TODO: Implement getReturnHTML() method.
}
public function getStatus($request, $response, $args)
{
// TODO: Implement getStatus() method.

@ -1,131 +0,0 @@
<?php
namespace App\Services\Gateway;
use App\Services\View;
use App\Services\Auth;
use App\Services\Config;
use App\Models\Paylist;
class Wolfpay extends AbstractPayment {
private $pid;
private $key;
private $url;
public function __construct() {
$config = Config::get("wolfpay") ['config'];
$this->pid = $config['hid'];
$this->key = $config['key'];
$this->url = $config['url'];
}
public function purchase($request, $response, $args) {
return '';
}
public function purchase_maliopay($type, $price) {
$user = Auth::getUser();
$settings = Config::get("wolfpay")['config'];
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->save();
//支付方式
$type = 'all'; //$type;
//订单号
$out_trade_no = $pl->tradeno;
//异步通知地址
$notify_url = 'https://' . $_SERVER['HTTP_HOST'] . '/payment/notify/wolfpay/' . $type;
//回调通知地址
$return_url = 'https://' . $_SERVER['HTTP_HOST'] . '/user/payment/return';
//商品名称
$name = 'SS商品-' . $_SERVER['HTTP_HOST'];
//支付金额(保留小数点后两位)
$money = round($price, 2);
//站点名称
$sitename = $_SERVER['HTTP_HOST'];
//发起支付
$url = $this->submit($type, $out_trade_no, $notify_url, $return_url, $name, $money, $sitename);
return array(
'url' => $url,
'errcode' => 0,
'tradeno' => $pl->tradeno
);
}
public function notify($request, $response, $args) {
return '';
}
public function getPurchaseHTML() {
return '';
}
public function getReturnHTML($request, $response, $args) {
}
public function getStatus($request, $response, $args) {
// TODO: Implement getStatus() method.
}
public function verify($data) {
if (!isset($data['sign']) || !$data['sign']) {
return false;
}
$sign = $data['sign'];
unset($data['sign']);
unset($data['sign_type']);
$sign2 = $this->getSign($data, $this->key);
if ($sign != $sign2) {
return false;
}
return true;
}
public function submit($type, $out_trade_no, $notify_url, $return_url, $name, $money, $sitename) {
$data = ['pid' => $this->pid, 'type' => $type, 'out_trade_no' => $out_trade_no, 'notify_url' => $notify_url, 'return_url' => $return_url, 'name' => $name, 'money' => $money, 'sitename' => $sitename];
$string = http_build_query($data);
$keys = $this->ensy($string, $this->pid);
$keyss = $this->base64url_encode($this->pid . '-' . $keys);
$sign = substr($this->ensy($keyss, $this->key) , 0, 15);
return 'https://' . $this->url . '/submit?skey=' . $keyss . '&sign=' . $sign . '&sign_type=MD5';
}
private function getSign($data) {
$data = array_filter($data);
ksort($data);
$str1 = '';
foreach ($data as $k => $v) {
$str1.= '&' . $k . "=" . $v;
}
$str = $str1 . $this->key;
$str = trim($str, '&');
$sign = md5($str);
return $sign;
}
public function ensy($data, $key) {
$key = md5($key);
$len = strlen($data);
$code = '';
for ($i = 0; $i < ceil($len / 32); $i++) {
for ($j = 0; $j < 32; $j++) {
$p = $i * 32 + $j;
if ($p < $len) {
$code.= $data{$p} ^ $key{$j};
}
}
}
$code = str_replace(array(
'+',
'/',
'='
) , array(
'_',
'$',
''
) , base64_encode($code));
return $code;
}
public function base64url_encode($data) {
return rtrim(strtr(base64_encode($data) , '+/', '-_') , '=');
}
}

@ -1,239 +0,0 @@
<?php
namespace App\Services\Gateway;
use App\Services\View;
use App\Services\Auth;
use App\Services\Config;
use App\Models\Paylist;
class Pays
{
private $pid;
private $key;
public function __construct($pid, $key)
{
$this->pid = $pid;
$this->key = $key;
}
/**
* @Note 支付发起
* @param $type 支付方式
* @param $out_trade_no 订单号
* @param $notify_url 异步通知地址
* @param $return_url 回调通知地址
* @param $name 商品名称
* @param $money 金额
* @param $sitename 站点名称
* @return string
*/
public function submit($type, $out_trade_no, $notify_url, $return_url, $name, $money, $sitename)
{
$data = [
'pid' => $this->pid,
'type' => $type,
'out_trade_no' => $out_trade_no,
'notify_url' => $notify_url,
'return_url' => $return_url,
'name' => $name,
'money' => $money,
'sitename' => $sitename
];
$string = http_build_query($data);
$sign = $this->getsign($data);
return 'https://api.jxspay.cn/submit/?' . $string . '&sign=' . $sign . '&sign_type=MD5';
}
/**
* @Note 验证签名
* @param $data 待验证参数
* @return bool
*/
public function verify($data)
{
if (!isset($data['sign']) || !$data['sign']) {
return false;
}
$sign = $data['sign'];
unset($data['sign']);
unset($data['sign_type']);
$sign2 = $this->getSign($data, $this->key);
if ($sign != $sign2) {
return false;
}
return true;
}
/**
* @Note 生成签名
* @param $data 参与签名的参数
* @return string
*/
private function getSign($data)
{
$data = array_filter($data);
ksort($data);
$str1 = '';
foreach ($data as $k => $v) {
$str1 .= '&' . $k . "=" . $v;
}
$str = $str1 . $this->key;
$str = trim($str, '&');
$sign = md5($str);
return $sign;
}
}
class flyfoxpay extends AbstractPayment
{
public function purchase($request, $response, $args)
{
$type = $request->getParam('type');
$price = $request->getParam('price');
if($price <= 0){
return json_encode(['errcode'=>-1,'errmsg'=>"非法的金额."]);
}
$user = Auth::getUser();
$settings = Config::get("flyfoxpay")['config'];
$pl = new Paylist();
$pl->userid = $user->id;
$pl->total = $price;
$pl->tradeno = self::generateGuid();
$pl->save();
$return='https://'.$_SERVER['HTTP_HOST'].'/flyfoxpay_back/'.$type;
$pay = new Pays($settings['hid'], $settings['key']);
//支付方式
$type = 'all';
//订单号
$out_trade_no = $pl->tradeno;
//异步通知地址
$notify_url = $return;
//回调通知地址
$return_url = $return;
//商品名称
$name = 'SS商品-'.$_SERVER['HTTP_HOST'];
//支付金额(保留小数点后两位)
$money = $price;
//站点名称
$sitename = $_SERVER['HTTP_HOST'];
//发起支付
$url = $pay->submit($type, $out_trade_no, $notify_url, $return_url, $name, $money, $sitename);
$result = "<script language='javascript' type='text/javascript'>window.location.href='".$url."';</script>";
$result = json_encode(array('code'=>$url,'errcode'=>0,'pid' =>$pl->id));
return $result;
}
public function notify($request, $response, $args)
{
$type = $args['type'];
$settings = Config::get("flyfoxpay")['config'];
$security['orderid'] = $_REQUEST['out_trade_no'];
if($security['orderid']=='' OR $security['orderid']==null){header("Location: /user/code");}else{
//实例化支付类
$pay = new Pays($settings['hid'], $settings['key']);
//接收异步通知数据
$data = $_GET;
//商户订单号
$out_trade_no = $data['out_trade_no'];
//验证签名
if ($pay->verify($data)) {
//验证支付状态
if ($data['trade_status'] == 'TRADE_SUCCESS') {
$this->postPayment($data['out_trade_no'], "在线支付");
header("Location: /user/code");
//这里就可以放心的处理您的业务流程了
//您可以通过上面的商户订单号进行业务流程处理
}
} else {
echo '錯誤';
}
}}
public function getPurchaseHTML()
{
return '
<div class="card-inner">
<p class="card-heading">充值</p>
<h5>支付方式:</h5>
<nav class="tab-nav margin-top-no">
<ul class="nav nav-list">
<li>
<a class="waves-attach waves-effect type active" data-toggle="tab" data-pay="wxpay">聚合支付</a>
</li>
</ul>
<div class="tab-nav-indicator"></div>
</nav>
<div class="form-group form-group-label">
<label class="floating-label" for="amount">金额</label>
<input class="form-control" id="amount" type="text">
</div>
</div>
<div class="card-action">
<div class="card-action-btn pull-left">
<button class="btn btn-flat waves-attach" id="code-updates" ><span class="icon">check</span>&nbsp;充值</button>
</div>
</div>
<script>
var type = "wxpay";
var pid = 0;
$(".type").click(function(){
type = $(this).data("pay");
});
$("#code-updates").click(function(){
var price = parseFloat($("#amount").val());
console.log("将要使用"+type+"方法充值"+price+"元")
if(isNaN(price)){
$("#result").modal();
$("#msg").html("非法的金额!");
}
$.ajax({
\'url\':"/user/payment/purchase",
\'data\':{
\'price\':price,
\'type\':type,
},
\'dataType\':\'json\',
\'type\':"POST",
success:function(data){
console.log(data);
if(data.errcode==-1){
$("#result").modal();
$("#msg").html(data.errmsg);
}
if(data.errcode==0){
pid = data.pid;
if(type=="wxpay"){
$("#result").modal();
$("#msg").html("正在跳转到支付系統..."+data.code);
}
}
}
});
});
</script>
';
}
public function getReturnHTML($request, $response, $args)
{
}
public function getStatus($request, $response, $args)
{
// TODO: Implement getStatus() method.
}
}

@ -1,74 +0,0 @@
<?php
namespace App\Services;
use App\Utils\Cookie;
class Internationalization
{
public function __construct()
{
$this->lang = MalioConfig::get('default_lang');
}
public function detectLang($request, $response, $args)
{
$user = Auth::getUser();
if ($user->isLogin == true && $user->lang != null) {
$lang = $user->lang;
} else {
$cookie = Cookie::get('lang');
if ($cookie != null || $cookie != '') {
$lang = $cookie;
} else {
$accept_language = $request->getHeader('Accept-Language');
$accept_language = strtolower($accept_language[0]);
$accept_language = explode(";",$accept_language)[0];
$accept_language = explode(",",$accept_language)[0];
if (strpos($accept_language, 'zh') !== false) {
if (strpos($accept_language, 'cn') !== false || strpos($accept_language, 'sg') !== false) {
$lang = 'zh-cn';
} elseif (strpos($accept_language, 'tw') !== false || strpos($accept_language, 'hk') !== false) {
$lang = 'zh-cn';
} else {
$lang = 'zh-cn';
}
} else if (strpos($accept_language, 'en') !== false) {
$lang = 'en';
}
if ($lang == null) {
$lang = MalioConfig::get('default_lang');
}
Cookie::set([
'lang' => $lang
],'1775445251');
}
}
$this->lang = $lang;
return $lang;
}
public function get($name, $args=null) {
global $I18N;
if ($args == null){
return $I18N[$name][$this->lang];
} else {
$counter = 1;
$text = $I18N[$name][$this->lang];
foreach ($args as $arg) {
$text = str_replace("$".$counter, $arg, $text);
$counter += 1;
}
return $text;
}
}
public static function getPublicConfig()
{
global $I18N;
return $I18N;
}
}

@ -31,7 +31,7 @@ class SendGrid extends Base
public function send($to_address, $subject_raw, $text, $files)
{
$from = new Email(Config::get('appName'), $this->sender);
$from = new Email(null, $this->sender);
$subject = $subject_raw;
$to = new Email(null, $to_address);
$content = new Content('text/html', $text);

@ -1,18 +0,0 @@
<?php
namespace App\Services;
class MalioConfig
{
public static function get($key)
{
global $Malio_Config;
return $Malio_Config[$key];
}
public static function getPublicConfig()
{
global $Malio_Config;
return $Malio_Config;
}
}

@ -9,7 +9,7 @@
namespace App\Services;
use App\Services\Gateway\{
AopF2F, Codepay, DoiAMPay, PaymentWall, ChenPay, SPay, TrimePay, BitPayX, TomatoPay, flyfoxpay, PAYJS, F2Fpay_PAYJS, StripePay, Payssion, YftPay, MalioPay, IDtPay
AopF2F, Codepay, PaymentWall, ChenPay, SPay, PAYJS, YftPay,BitPayX
};
class Payment
@ -30,24 +30,10 @@ class Payment
return new ChenPay();
case ('bitpayx'):
return new BitPayX(Config::get('bitpay_secret'));
case("tomatopay"):
return new TomatoPay();
case("flyfoxpay"):
return new flyfoxpay();
case ('payjs'):
return new PAYJS(Config::get('payjs_key'));
case ('f2fpay_payjs'):
return new F2Fpay_PAYJS();
case ('stripe'):
return new StripePay();
case ('payssion'):
return new Payssion();
case ('yftpay'):
return new YftPay();
case ('malio'):
return new MalioPay();
case ("idtpay"):
return new IDtPay();
default:
return null;
}

@ -4,7 +4,6 @@ namespace App\Services;
use Smarty;
use App\Utils;
use App\Services\Internationalization;
class View
{
@ -19,15 +18,6 @@ class View
if ($user->isLogin) {
$theme = $user->theme;
$theme = $user->theme;
$i18n = new Internationalization();
if (MalioConfig::get('only_one_lang') != 'none') {
$i18n->lang = MalioConfig::get('only_one_lang');
} else {
$i18n->lang = $user->lang;
}
$smarty->assign('i18n', $i18n);
} else {
$theme = Config::get('theme');
}
@ -41,8 +31,6 @@ class View
$smarty->setcachedir(BASE_PATH . '/storage/framework/smarty/cache/'); //设置缓存文件存放目录
// add config
$smarty->assign('config', Config::getPublicConfig());
$smarty->assign('malio_config', MalioConfig::getPublicConfig());
$smarty->assign('I18N', Internationalization::getPublicConfig());
$smarty->assign('user', $user);
$smarty->assign('can_backtoadmin', $can_backtoadmin);

@ -1,519 +0,0 @@
<?php
namespace App\Utils;
use App\Services\Config;
class AppURI
{
public static function getSurgeURI($item, $version)
{
$return = null;
switch ($version) {
case 2:
if ($item['obfs'] == 'v2ray') {
break;
}
if ($item['type'] == 'ss') {
$return = ($item['remark'] . ' = custom, ' . $item['address'] . ', ' . $item['port'] . ', ' . $item['method'] . ', ' . $item['passwd'] . ', https://raw.githubusercontent.com/lhie1/Rules/master/SSEncrypt.module' . URL::getSurgeObfs($item));
}
break;
default:
switch ($item['type']) {
case 'ss':
if ($item['obfs'] == 'v2ray') {
break;
}
$return = ($item['remark'] . ' = ss, ' . $item['address'] . ', ' . $item['port'] . ', encrypt-method=' . $item['method'] . ', password=' . $item['passwd'] . URL::getSurgeObfs($item) . ', udp-relay=true');
break;
case 'vmess':
if (!in_array($item['net'], ['ws', 'tcp'])) {
break;
}
$tls = ($item['tls'] == 'tls'
? ', tls=true'
: '');
$ws = ($item['net'] == 'ws'
? ', ws=true, ws-path=' . $item['path'] . ', ws-headers=host:' . $item['host']
: '');
$return = $item['remark'] . ' = vmess, ' . $item['add'] . ', ' . $item['port'] . ', username = ' . $item['id'] . $ws . $tls;
break;
case 'trojan':
$return = ($item['remark'] . ' = trojan, ' . $item['address'] . ', ' . $item['port'] . ', password=' . $item['passwd']) . ", sni=" . $item['host'];
break;
}
break;
}
return $return;
}
public static function getQuantumultURI($item, $base64_encode = false)
{
$return = null;
switch ($item['type']) {
case 'ss':
if ($item['obfs'] == 'v2ray') {
break;
}
$return = ($item['remark'] . ' = shadowsocks, ' . $item['address'] . ', ' . $item['port'] . ', ' . $item['method'] . ', "' . $item['passwd'] . '", upstream-proxy=false, upstream-proxy-auth=false' . URL::getSurgeObfs($item) . ', group=' . Config::get('appName') . '_ss');
break;
case 'ssr':
$return = ($item['remark'] . ' = shadowsocksr, ' . $item['address'] . ', ' . $item['port'] . ', ' . $item['method'] . ', "' . $item['passwd'] . '", protocol=' . $item['protocol'] . ', protocol_param=' . $item['protocol_param'] . ', obfs=' . $item['obfs'] . ', obfs_param="' . $item['obfs_param'] . '", group=' . Config::get('appName'));
break;
case 'vmess':
if (!in_array($item['net'], ['ws', 'tcp', 'http'])) {
break;
}
$tls = ', over-tls=false, certificate=1';
if ($item['tls'] == 'tls') {
$tls = ', over-tls=true';
if ($item['verify_cert']) {
$tls .=', tls-host=' . $item['host'];
$tls .= ', certificate=1';
} else {
$tls .=', tls-host=' . $item['host'];
$tls .= ', certificate=0';
}
}
$obfs = '';
if (in_array($item['net'], ['ws', 'http'])) {
$obfs = ', obfs=' . $item['net'] . ', obfs-path="' . $item['path'] . '", obfs-header="Host: ' . $item['host'] . '[Rr][Nn]User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 18_0_0 like Mac OS X) AppleWebKit/888.8.88 (KHTML, like Gecko) Mobile/6666666"';
}
$return = ($item['remark'] . ' = vmess, ' . $item['add'] . ', ' . $item['port'] . ', chacha20-ietf-poly1305, "' . $item['id'] . '", group=' . Config::get('appName') . '_VMess' . $tls . $obfs);
if ($base64_encode === true) {
$return = 'vmess://' . base64_encode($return);
}
break;
}
return $return;
}
public static function getQuantumultXURI($item)
{
$return = null;
switch ($item['type']) {
case 'ss':
// ;shadowsocks=example.com:80, method=chacha20, password=pwd, obfs=http, obfs-host=bing.com, obfs-uri=/resource/file, fast-open=false, udp-relay=false, server_check_url=http://www.apple.com/generate_204, tag=ss-01
// ;shadowsocks=example.com:80, method=chacha20, password=pwd, obfs=http, obfs-host=bing.com, obfs-uri=/resource/file, fast-open=false, udp-relay=false, tag=ss-02
// ;shadowsocks=example.com:443, method=chacha20, password=pwd, obfs=tls, obfs-host=bing.com, fast-open=false, udp-relay=false, tag=ss-03
// ;shadowsocks=example.com:80, method=aes-128-gcm, password=pwd, obfs=ws, fast-open=false, udp-relay=false, tag=ss-ws-01
// ;shadowsocks=example.com:80, method=aes-128-gcm, password=pwd, obfs=ws, obfs-uri=/ws, fast-open=false, udp-relay=false, tag=ss-ws-02
// ;shadowsocks=example.com:443, method=aes-128-gcm, password=pwd, obfs=wss, obfs-uri=/ws, fast-open=false, udp-relay=false, tag=ss-ws-tls
$return = ('shadowsocks=' . $item['address'] . ':' . $item['port'] . ', method=' . $item['method'] . ', password=' . $item['passwd']);
switch ($item['obfs']) {
case 'simple_obfs_http':
$return .= ', obfs=http';
$return .= ($item['obfs_param'] != '' ? ', obfs-host=' . $item['obfs_param'] : ', obfs-host=wns.windows.com');
$return .= ', obfs-uri=/';
break;
case 'simple_obfs_tls':
$return .= ', obfs=tls';
$return .= ($item['obfs_param'] != '' ? ', obfs-host=' . $item['obfs_param'] : ', obfs-host=wns.windows.com');
$return .= ', obfs-uri=/';
break;
case 'v2ray';
$return .= ($item['tls'] == 'tls' ? ', obfs=wss' : ', obfs=ws');
$return .= ', obfs-uri=' . $item['path'];
break;
}
$return .= (', tag=' . $item['remark']);
break;
case 'ssr':
// ;shadowsocks=example.com:443, method=chacha20, password=pwd, ssr-protocol=auth_chain_b, ssr-protocol-param=def, obfs=tls1.2_ticket_fastauth, obfs-host=bing.com, tag=ssr
$return = ('shadowsocks=' . $item['address'] . ':' . $item['port'] . ', method=' . $item['method'] . ', password=' . $item['passwd']);
$return .= (', ssr-protocol=' . $item['protocol']);
$return .= (', ssr-protocol-param=' . $item['protocol_param']);
$return .= (', obfs=' . $item['obfs']);
$return .= (', obfs-host="' . $item['obfs_param']);
$return .= (', tag=' . $item['remark']);
break;
case 'vmess':
// ;vmess=example.com:80, method=none, password=23ad6b10-8d1a-40f7-8ad0-e3e35cd32291, fast-open=false, udp-relay=false, tag=vmess-01
// ;vmess=example.com:80, method=aes-128-gcm, password=23ad6b10-8d1a-40f7-8ad0-e3e35cd32291, fast-open=false, udp-relay=false, tag=vmess-02
// ;vmess=example.com:443, method=none, password=23ad6b10-8d1a-40f7-8ad0-e3e35cd32291, obfs=over-tls, fast-open=false, udp-relay=false, tag=vmess-tls
// ;vmess=example.com:80, method=chacha20-poly1305, password=23ad6b10-8d1a-40f7-8ad0-e3e35cd32291, obfs=ws, obfs-uri=/ws, fast-open=false, udp-relay=false, tag=vmess-ws
// ;vmess=example.com:443, method=chacha20-poly1305, password=23ad6b10-8d1a-40f7-8ad0-e3e35cd32291, obfs=wss, obfs-uri=/ws, fast-open=false, udp-relay=false, tag=vmess-ws-tls
if (!in_array($item['net'], ['ws', 'tcp'])) {
break;
}
$return = ('vmess=' . $item['add'] . ':' . $item['port'] . ', method=chacha20-poly1305' . ', password=' . $item['id']);
switch ($item['net']) {
case 'ws':
$return .= ($item['tls'] == 'tls' ? ', obfs=wss' : ', obfs=ws');
$return .= ', obfs-uri=' . $item['path'];
break;
case 'tcp':
$return .= ($item['tls'] == 'tls' ? ', obfs=over-tls' : '');
break;
}
$return .= (', tag=' . $item['remark']);
break;
case 'trojan':
// ;trojan=example.com:443, password=pwd, over-tls=true, tls-verification=true, fast-open=false, udp-relay=false, tag=trojan-tls-01
$return = ('trojan=' . $item['address'] . ':' . $item['port'] . ', password=' . $item['passwd'] . ', tls-host=' . $item['host']);
$return .= ', over-tls=true, tls-verification=true';
$return .= (', tag=' . $item['remark']);
break;
}
return $return;
}
public static function getSurfboardURI($item)
{
$return = null;
switch ($item['type']) {
case 'ss':
if ($item['obfs'] == 'v2ray') {
break;
}
$return = ($item['remark'] . ' = custom, ' . $item['address'] . ', ' . $item['port'] . ', ' . $item['method'] . ', ' . $item['passwd'] . ', https://raw.githubusercontent.com/lhie1/Rules/master/SSEncrypt.module' . URL::getSurgeObfs($item));
break;
}
return $return;
}
public static function getClashURI($item, $ssr_support = false)
{
$return = null;
if ($item['type'] == 'ssr' && $ssr_support === false) {
return $return;
}
switch ($item['type']) {
case 'ss':
$method = ['rc4-md5-6', 'camellia-128-cfb', 'camellia-192-cfb', 'camellia-256-cfb', 'bf-cfb', 'cast5-cfb', 'des-cfb', 'des-ede3-cfb', 'idea-cfb', 'rc2-cfb', 'seed-cfb', 'salsa20', 'chacha20', 'xsalsa20', 'none'];
if (in_array($item['method'], $method)) {
// 不支持的
break;
}
$return = [
'name' => $item['remark'],
'type' => 'ss',
'server' => $item['address'],
'port' => $item['port'],
'cipher' => $item['method'],
'password' => $item['passwd'],
'udp' => true
];
if ($item['obfs'] != 'plain') {
switch ($item['obfs']) {
case 'simple_obfs_http':
$return['plugin'] = 'obfs';
$return['plugin-opts']['mode'] = 'http';
break;
case 'simple_obfs_tls':
$return['plugin'] = 'obfs';
$return['plugin-opts']['mode'] = 'tls';
break;
case 'v2ray':
$return['plugin'] = 'v2ray-plugin';
$return['plugin-opts']['mode'] = 'websocket';
if ($item['tls'] == 'tls') {
$return['plugin-opts']['tls'] = true;
if ($item['verify_cert'] == false) {
$return['plugin-opts']['skip-cert-verify'] = true;
}
}
$return['plugin-opts']['host'] = $item['host'];
$return['plugin-opts']['path'] = $item['path'];
break;
}
if ($item['obfs'] != 'v2ray') {
if ($item['obfs_param'] != '') {
$return['plugin-opts']['host'] = $item['obfs_param'];
} else {
$return['plugin-opts']['host'] = 'windowsupdate.windows.com';
}
}
}
break;
case 'ssr':
if (
in_array($item['method'], ['rc4-md5-6', 'des-ede3-cfb', 'xsalsa20', 'none'])
||
in_array($item['protocol'], array_merge(Config::getSupportParam('allow_none_protocol'), ['verify_deflate']))
||
in_array($item['obfs'], ['tls1.2_ticket_fastauth'])
) {
// 不支持的
break;
}
$return = [
'name' => $item['remark'],
'type' => 'ssr',
'server' => $item['address'],
'port' => $item['port'],
'cipher' => $item['method'],
'password' => $item['passwd'],
'protocol' => $item['protocol'],
'protocolparam' => $item['protocol_param'],
'obfs' => $item['obfs'],
'obfsparam' => $item['obfs_param']
];
break;
case 'vmess':
if (!in_array($item['net'], array('ws', 'tcp'))) {
break;
}
$return = [
'name' => $item['remark'],
'type' => 'vmess',
'server' => $item['add'],
'port' => $item['port'],
'uuid' => $item['id'],
'alterId' => $item['aid'],
'cipher' => 'auto',
'udp' => true
];
if ($item['net'] == 'ws') {
$return['network'] = 'ws';
$return['ws-path'] = $item['path'];
$return['ws-headers']['Host'] = ($item['host'] != '' ? $item['host'] : $item['add']);
}
if ($item['tls'] == 'tls') {
$return['tls'] = true;
if ($item['verify_cert'] == false) {
$return['skip-cert-verify'] = true;
}
}
break;
case 'trojan':
$return = [
'name' => $item['remark'],
'type' => 'trojan',
'server' => $item['address'],
'port' => $item['port'],
'password' => $item['passwd'],
'sni' => $item['host']
];
break;
}
return $return;
}
public static function getShadowrocketURI($item)
{
$return = null;
switch ($item['type']) {
case 'ss':
if (in_array($item['obfs'], Config::getSupportParam('ss_obfs'))) {
$return = (URL::getItemUrl($item, 1));
} else {
if ($item['obfs'] == 'v2ray') {
$v2rayplugin = [
'address' => $item['address'],
'port' => (string) $item['port'],
'path' => $item['path'],
'host' => $item['host'],
'mode' => 'websocket',
];
$v2rayplugin['tls'] = $item['tls'] == 'tls' ? true : false;
if ($v2rayplugin['tls']) {
if ($v2rayplugin['host'] != '' && $v2rayplugin['host'] != 'microsoft.com'){
$v2rayplugin['peer'] = $v2rayplugin['host'];
}else {
$v2rayplugin['peer'] = $v2rayplugin['address'];
}
}else {
$v2rayplugin['peer'] = '';
}
$return = ('ss://' . Tools::base64_url_encode($item['method'] . ':' . $item['passwd'] . '@' . $item['address'] . ':' . $item['port']) . '?v2ray-plugin=' . base64_encode(json_encode($v2rayplugin)) . '#' . rawurlencode($item['remark']));
}
if ($item['obfs'] == 'plain') {
$return = (URL::getItemUrl($item, 2));
}
}
break;
case 'ssr':
$return = (URL::getItemUrl($item, 0));
break;
case 'vmess':
if (!in_array($item['net'], ['tcp', 'ws', 'http', 'h2'])) {
break;
}
$obfs = '';
switch ($item['net']) {
case 'ws':
$obfs .= ($item['host'] != ''
? ('&obfsParam=' . $item['host'] . '&path=' . $item['path'] . '&obfs=websocket')
: ('&obfsParam=' . $item['add'] . '&path=' . $item['path'] . '&obfs=websocket'));
break;
case 'kcp':
$obfs .= 'obfsParam={"header":' . '"' . ($item['headerType'] == '' || $item['headerType'] == 'noop' ? 'none' : $item['headerType']) . '"' . '}&obfs=mkcp';
break;
case 'mkcp':
$obfs .= 'obfsParam={"header":' . '"' . ($item['headerType'] == '' || $item['headerType'] == 'noop' ? 'none' : $item['headerType']) . '"' . '}&obfs=mkcp';
break;
case 'h2':
$obfs .= ($item['host'] != ''
? ('&obfsParam=' . $item['host'] . '&path=' . $item['path'] . '&obfs=h2')
: ('&obfsParam=' . $item['add'] . '&path=' . $item['path'] . '&obfs=h2'));
break;
default:
$obfs .= '&obfs=none';
break;
}
$tls = '';
if ($item['tls'] == 'tls') {
$tls = '&tls=1';
if ($item['verify_cert'] == false){
$tls .= '&allowInsecure=1';
}
$tls .= '&peer=' . $item['host'];
}
$return = ('vmess://' . Tools::base64_url_encode('chacha20-poly1305:' . $item['id'] . '@' . $item['add'] . ':' . $item['port']) . '?remarks=' . rawurlencode($item['remark']) . $obfs . $tls);
break;
case 'trojan':
$return = ('trojan://' . $item['passwd'] . '@' . $item['address'] . ':' . $item['port']);
$return .= ('?peer=' . $item['host'] . '#' . rawurlencode($item['remark']));
break;
}
return $return;
}
public static function getKitsunebiURI($item)
{
$return = null;
switch ($item['type']) {
case 'ss':
if (in_array($item['obfs'], ['v2ray', 'simple_obfs_http', 'simple_obfs_tls'])) {
break;
}
$return = (URL::getItemUrl($item, 2));
break;
case 'vmess':
$network = ($item['net'] == 'tls'
? '&network=tcp'
: ('&network=' . $item['net']));
$protocol = '';
switch ($item['net']) {
case 'kcp':
$protocol .= ('&kcpheader=' . $item['headerType']);
break;
case 'ws':
$protocol .= ('&wspath=' . $item['path'] . '&wsHost=' . $item['host']);
break;
case 'h2':
$protocol .= ('&h2Path=' . $item['path'] . '&h2Host=' . $item['host']);
break;
}
$tls = '';
if ($item['tls'] == 'tls') {
$tls = '&tls=1';
if ($item['verify_cert'] == false) {
$tls .= '&allowInsecure=1';
}
}
$return .= ('vmess://' . base64_encode('auto:' . $item['id'] . '@' . $item['add'] . ':' . $item['port']) . '?remark=' . rawurlencode($item['remark']) . $network . $protocol . '&aid=' . $item['aid'] . $tls);
break;
}
return $return;
}
public static function getSSDURI($item)
{
$return = null;
switch ($item['type']) {
case 'ss':
# 666
$return['remarks'] = $item['remark'];
$return['server'] = $item['address'];
$return['port'] = $item['port'];
$return['encryption'] = $item['method'];
$return['password'] = $item['passwd'];
$plugin_options = '';
if ($item['obfs'] != 'plain') {
switch ($item['obfs']) {
case 'simple_obfs_http':
$return['plugin'] = 'simple-obfs';
$plugin_options .= 'obfs=http;obfs-host=' . $item['obfs_param'];
break;
case 'simple_obfs_tls':
$return['plugin'] = 'simple-obfs';
$plugin_options .= 'obfs=tls;obfs-host=' . $item['obfs_param'];
break;
case 'v2ray':
$return['plugin'] = 'v2ray';
if ($item['net'] == 'ws') {
$plugin_options .= 'mode=ws';
}
if ($item['tls'] == 'tls') {
$plugin_options .= ';security=tls';
} else {
$plugin_options .= ';security=none';
}
$plugin_options .= ';path=' . $item['path'];
if ($item['host'] != '') {
$plugin_options .= ';host=' . $item['host'];
} else {
$plugin_options .= ';host=' . $item['address'];
}
break;
}
}
$return['plugin_options'] = $plugin_options;
$return['ratio'] = $item['ratio'];
break;
}
return $return;
}
public static function getSSJSON($item)
{
$return = null;
switch ($item['type']) {
case 'ss':
# 666
$return['remarks'] = $item['remark'];
$return['server'] = $item['address'];
$return['server_port'] = $item['port'];
$return['method'] = $item['method'];
$return['password'] = $item['passwd'];
if ($item['obfs'] != 'plain') {
$plugin_options = '';
switch ($item['obfs']) {
case 'simple_obfs_http':
$return['plugin'] = 'simple-obfs';
$plugin_options .= 'obfs=http;obfs-host=' . $item['obfs_param'];
break;
case 'simple_obfs_tls':
$return['plugin'] = 'simple-obfs';
$plugin_options .= 'obfs=tls;obfs-host=' . $item['obfs_param'];
break;
case 'v2ray':
$return['plugin'] = 'v2ray';
if ($item['net'] == 'ws') {
$plugin_options .= 'mode=ws';
}
if ($item['tls'] == 'tls') {
$plugin_options .= ';security=tls';
} else {
$plugin_options .= ';security=none';
}
$plugin_options .= ';path=' . $item['path'];
if ($item['host'] != '') {
$plugin_options .= ';host=' . $item['host'];
} else {
$plugin_options .= ';host=' . $item['address'];
}
break;
}
$return['plugin_opts'] = $plugin_options;
}
break;
}
return $return;
}
public static function getTrojanURI(array $item)
{
$return = null;
switch ($item['type']) {
case 'trojan':
$return = ('trojan://' . $item['passwd'] . '@' . $item['address'] . ':' . $item['port']);
$return .= ('?peer=' . $item['host'] . '#' . rawurlencode($item['remark']));
break;
}
return $return;
}
}

@ -1,38 +0,0 @@
<?php
namespace App\Utils;
use GeoIp2\Database\Reader;
use GeoIp2\Exception\AddressNotFoundException;
class GeoIP2
{
public function __construct()
{
$this->reader = new Reader(BASE_PATH . '/storage/GeoLite2-City.mmdb');
}
public function getLocation($ip, $lang)
{
try {
$record = $this->reader->city($ip);
} catch (AddressNotFoundException $e) {
if ($lang == 'zh-cn') {
return "未知";
} else {
return "Unknow";
}
}
if ($lang == 'zh-cn') {
$lang = 'zh-CN';
}
if ($lang == 'en') {
return $record->city->name. ', '.$record->country->name;
} else if ($lang == 'zh-CN') {
return $record->country->names[$lang]. ' '.$record->city->names[$lang];
}
}
}

@ -5,62 +5,32 @@ namespace App\Utils;
use App\Services\Config;
use Exception;
use TelegramBot\Api\BotApi;
use Telegram\Bot\Api;
class Telegram
{
/**
* 发送消息
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
*/
public static function Send($messageText)
{
if (Config::get('enable_telegram') == true) {
// $bot = new BotApi(Config::get('telegram_token'));
// try {
// $bot->sendMessage(Config::get('telegram_chatid'), $messageText);
// } catch (Exception $e) {
// echo $e->getMessage();
// }
$bot = new Api(Config::get('telegram_token'));
$sendMessage = [
'chat_id' => Config::get('telegram_chatid'),
'text' => $messageText,
'parse_mode' => '',
'disable_web_page_preview' => false,
'reply_to_message_id' => null,
'reply_markup' => null
];
$bot = new BotApi(Config::get('telegram_token'));
try {
$bot->sendMessage($sendMessage);
$bot->sendMessage(Config::get('telegram_chatid'), $messageText);
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
public static function SendMarkdown($messageText)
{
if (Config::get('enable_telegram') == true) {
// $bot = new BotApi(Config::get('telegram_token'));
// try {
// $bot->sendMessage(Config::get('telegram_chatid'), $messageText, 'Markdown');
// } catch (Exception $e) {
// echo $e->getMessage();
// }
$bot = new Api(Config::get('telegram_token'));
$sendMessage = [
'chat_id' => Config::get('telegram_chatid'),
'text' => $messageText,
'parse_mode' => 'Markdown',
'disable_web_page_preview' => false,
'reply_to_message_id' => null,
'reply_markup' => null
];
$bot = new BotApi(Config::get('telegram_token'));
try {
$bot->sendMessage($sendMessage);
$bot->sendMessage(Config::get('telegram_chatid'), $messageText, 'Markdown');
} catch (Exception $e) {
echo $e->getMessage();
}

@ -1,136 +0,0 @@
<?php
namespace App\Utils\Telegram\Callbacks;
use App\Utils\Telegram\TelegramTools;
class Callback
{
public static function CallbackQueryMethod($bot, $Callback)
{
// 触发用户
$SendUser = [
'id' => $Callback->getFrom()->getId(),
'name' => $Callback->getFrom()->getFirstName() . ' ' . $Callback->getFrom()->getLastName(),
'username' => $Callback->getFrom()->getUsername(),
];
// 触发源消息发送时间
$MessageSendTime = $Callback->getMessage()->getDate();
// 消息是否可编辑
$AllowEditMessage = (time() < $MessageSendTime + 172800
? true
: false);
$Data = [
'CallbackData' => $Callback->getData(), // 回调数据
'ChatID' => $Callback->getMessage()->getChat()->getId(), // 消息会话 ID
'MessageID' => $Callback->getMessage()->getMessageId(), // 触发源信息 ID
'AllowEditMessage' => $AllowEditMessage, // 消息是否可编辑
];
if ($Data['ChatID'] < 0 && $_ENV['telegram_group_quiet'] === true) {
// 群组中不回应
return;
}
switch (true) {
case (strpos($Data['CallbackData'], 'user.') === 0):
// 用户相关
UserCallback::handler($bot, $Callback, $Data, $SendUser);
break;
// case (strpos($Data['CallbackData'], 'admin.') === 0):
// // 管理员
// break;
default:
// 回调数据处理
self::CallbackDataHandler($bot, $Callback, $Data, $SendUser);
break;
}
}
public static function getGuestIndexKeyboard()
{
$Keyboard = [
[
[
'text' => '产品介绍',
'callback_data' => 'general.pricing'
],
[
'text' => '服务条款',
'callback_data' => 'general.terms'
]
]
];
$text = '游客您好,以下是 BOT 菜单:' . PHP_EOL . PHP_EOL . '本站用户请前往用户中心进行 Telegram 绑定操作.';
return [
'text' => $text,
'keyboard' => $Keyboard,
];
}
/**
*
* 回调数据处理
*
*/
public static function CallbackDataHandler($bot, $Callback, $Data, $SendUser)
{
$CallbackDataExplode = explode('|', $Data['CallbackData']);
switch ($CallbackDataExplode[0]) {
case 'general.pricing':
// 产品介绍
$sendMessage = [
'text' => $_ENV['telegram_general_pricing'],
'disable_web_page_preview' => false,
'reply_to_message_id' => null,
'reply_markup' => json_encode(
[
'inline_keyboard' => self::getGuestIndexKeyboard()['keyboard']
]
),
];
break;
case 'general.terms':
// 服务条款
$sendMessage = [
'text' => $_ENV['telegram_general_terms'],
'disable_web_page_preview' => false,
'reply_to_message_id' => null,
'reply_markup' => json_encode(
[
'inline_keyboard' => self::getGuestIndexKeyboard()['keyboard']
]
),
];
break;
default:
// 主菜单
$temp = self::getGuestIndexKeyboard();
$sendMessage = [
'text' => $temp['text'],
'disable_web_page_preview' => false,
'reply_to_message_id' => null,
'reply_markup' => json_encode(
[
'inline_keyboard' => $temp['keyboard']
]
),
];
break;
}
$sendMessage = array_merge(
$sendMessage,
[
'chat_id' => $Data['ChatID'],
'message_id' => $Data['MessageID'],
'parse_mode' => 'HTML',
]
);
return ($Data['AllowEditMessage']
? TelegramTools::SendPost('editMessageText', $sendMessage)
: $bot->sendMessage($sendMessage));
}
}

File diff suppressed because it is too large Load Diff

@ -1,93 +0,0 @@
<?php
namespace App\Utils\Telegram\Commands;
use App\Models\User;
use App\Utils\Telegram\TelegramTools;
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
/**
* Class CheckinCommand.
*/
class CheckinCommand extends Command
{
/**
* @var string Command Name
*/
protected $name = 'checkin';
/**
* @var string Command Description
*/
protected $description = '[群组/私聊] 每日签到.';
/**
* {@inheritdoc}
*/
public function handle($arguments)
{
$Update = $this->getUpdate();
$Message = $Update->getMessage();
// 消息会话 ID
$ChatID = $Message->getChat()->getId();
if ($ChatID < 0) {
// 群组
if ($_ENV['enable_delete_user_cmd'] === true) {
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $Message->getMessageId(),
]);
}
if ($_ENV['telegram_group_quiet'] === true) {
// 群组中不回应
return;
}
if ($ChatID != $_ENV['telegram_chatid']) {
// 非我方群组
return;
}
}
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
// 触发用户
$SendUser = [
'id' => $Message->getFrom()->getId(),
'name' => $Message->getFrom()->getFirstName() . ' ' . $Message->getFrom()->getLastName(),
'username' => $Message->getFrom()->getUsername(),
];
$User = User::where('telegram_id', $SendUser['id'])->first();
if ($User == null) {
// 回送信息
$response = $this->replyWithMessage(
[
'text' => $_ENV['user_not_bind_reply'],
'parse_mode' => 'Markdown',
]
);
} else {
$checkin = $User->checkin();
// 回送信息
$response = $this->replyWithMessage(
[
'text' => $checkin['msg'],
'reply_to_message_id' => $Message->getMessageId(),
'parse_mode' => 'Markdown',
]
);
}
if ($ChatID < 0) {
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
]);
}
return $response;
}
}

@ -1,71 +0,0 @@
<?php
namespace App\Utils\Telegram\Commands;
use App\Services\Config;
use App\Utils\Telegram\TelegramTools;
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
/**
* Class HelpCommand.
*/
class HelpCommand extends Command
{
/**
* @var string Command Name
*/
protected $name = 'help';
/**
* @var string Command Description
*/
protected $description = '[群组/私聊] 系统中可用的所有命令.';
/**
* {@inheritdoc}
*/
public function handle($arguments)
{
$Update = $this->getUpdate();
$Message = $Update->getMessage();
if ($Message->getChat()->getId() < 0) {
if ($_ENV['enable_delete_user_cmd'] === true) {
TelegramTools::DeleteMessage([
'chatid' => $Message->getChat()->getId(),
'messageid' => $Message->getMessageId(),
]);
}
if ($_ENV['telegram_group_quiet'] === true) {
return;
}
}
if (!preg_match('/^\/help\s?(@' . $_ENV['telegram_bot'] . ')?.*/i', $Message->getText())) {
if ($_ENV['help_any_command'] === false) {
return;
}
}
$this->replyWithChatAction(['action' => Actions::TYPING]);
$commands = $this->telegram->getCommands();
$text = '系统中可用的所有命令.';
$text .= PHP_EOL . PHP_EOL;
foreach ($commands as $name => $handler) {
$text .= '/' . $name . PHP_EOL . '` - ' . $handler->getDescription() . '`' . PHP_EOL;
}
$response = $this->replyWithMessage(
[
'text' => $text,
'parse_mode' => 'Markdown',
'disable_web_page_preview' => false,
'reply_to_message_id' => $Message->getMessageId(),
'reply_markup' => null,
]
);
if ($Message->getChat()->getId() < 0) {
TelegramTools::DeleteMessage([
'chatid' => $Message->getChat()->getId(),
'messageid' => $response->getMessageId(),
]);
}
}
}

@ -1,116 +0,0 @@
<?php
namespace App\Utils\Telegram\Commands;
use App\Services\Config;
use App\Models\User;
use App\Utils\Telegram\{Reply, TelegramTools};
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
/**
* Class InfoCommand.
*/
class InfoCommand extends Command
{
/**
* @var string Command Name
*/
protected $name = 'info';
/**
* @var string Command Description
*/
protected $description = '[群组] 获取被回复消息的用户信息,管理员命令.';
/**
* {@inheritdoc}
*/
public function handle($arguments)
{
$Update = $this->getUpdate();
$Message = $Update->getMessage();
// 消息会话 ID
$ChatID = $Message->getChat()->getId();
// 消息 ID
$MessageID = $Message->getMessageId();
if ($ChatID < 0) {
// 群组
if ($_ENV['enable_delete_user_cmd'] === true) {
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $MessageID,
]);
}
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
// 触发用户
$SendUser = [
'id' => $Message->getFrom()->getId(),
'name' => $Message->getFrom()->getFirstName() . ' ' . $Message->getFrom()->getLastName(),
'username' => $Message->getFrom()->getUsername(),
];
if (!in_array($SendUser['id'], $_ENV['telegram_admins'])) {
$AdminUser = User::where('is_admin', 1)->where('telegram_id', $SendUser['id'])->first();
if ($AdminUser == null) {
// 非管理员回复消息
if ($_ENV['enable_not_admin_reply'] === true && $_ENV['not_admin_reply_msg'] != '') {
$response = $this->replyWithMessage(
[
'text' => $_ENV['not_admin_reply_msg'],
'parse_mode' => 'HTML',
'reply_to_message_id' => $MessageID,
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
]);
return;
}
}
}
if ($Message->getReplyToMessage() != null) {
// 回复源消息用户
$FindUser = [
'id' => $Message->getReplyToMessage()->getFrom()->getId(),
'name' => $Message->getReplyToMessage()->getFrom()->getFirstName() . ' ' . $Message->getReplyToMessage()->getFrom()->getLastName(),
'username' => $Message->getReplyToMessage()->getFrom()->getUsername(),
];
$User = TelegramTools::getUser($FindUser['id']);
if ($User == null) {
$response = $this->replyWithMessage(
[
'text' => $_ENV['no_user_found'],
'reply_to_message_id' => $MessageID,
]
);
} else {
$response = $this->replyWithMessage(
[
'text' => Reply::getUserInfoFromAdmin($User, $ChatID),
'reply_to_message_id' => $MessageID,
]
);
}
} else {
$response = $this->replyWithMessage(
[
'text' => '请回复消息使用.',
'reply_to_message_id' => $MessageID,
]
);
}
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
'executetime' => $_ENV['delete_admin_message_time']
]);
}
}
}

@ -1,88 +0,0 @@
<?php
namespace App\Utils\Telegram\Commands;
use App\Utils\Telegram\{TelegramTools};
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
/**
* Class MenuCommand.
*/
class MenuCommand extends Command
{
/**
* @var string Command Name
*/
protected $name = 'menu';
/**
* @var string Command Description
*/
protected $description = '[私聊] 用户主菜单、个人中心.';
/**
* {@inheritdoc}
*/
public function handle($arguments)
{
$Update = $this->getUpdate();
$Message = $Update->getMessage();
// 消息 ID
$MessageID = $Message->getMessageId();
// 消息会话 ID
$ChatID = $Message->getChat()->getId();
if ($ChatID > 0) {
// 私人会话
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
// 触发用户
$SendUser = [
'id' => $Message->getFrom()->getId(),
'name' => $Message->getFrom()->getFirstName() . ' ' . $Message->getFrom()->getLastName(),
'username' => $Message->getFrom()->getUsername(),
];
$user = TelegramTools::getUser($SendUser['id']);
if ($user == null) {
// 回送信息
$this->replyWithMessage(
[
'text' => $_ENV['user_not_bind_reply'],
'parse_mode' => 'Markdown',
]
);
return;
}
$reply = \App\Utils\Telegram\Callbacks\UserCallback::getUserIndexKeyboard($user);
// 回送信息
return $this->replyWithMessage(
[
'text' => $reply['text'],
'parse_mode' => 'Markdown',
'disable_web_page_preview' => false,
'reply_to_message_id' => null,
'reply_markup' => json_encode(
[
'inline_keyboard' => $reply['keyboard']
]
),
]
);
} else {
if ($_ENV['enable_delete_user_cmd'] === true) {
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $MessageID,
]);
}
}
}
}

@ -1,125 +0,0 @@
<?php
namespace App\Utils\Telegram\Commands;
use App\Models\User;
use App\Services\Config;
use App\Utils\Telegram\Reply;
use App\Utils\Telegram\TelegramTools;
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
/**
* Class MyCommand.
*/
class MyCommand extends Command
{
/**
* @var string Command Name
*/
protected $name = 'my';
/**
* @var string Command Description
*/
protected $description = '[群组/私聊] 我的个人信息.';
/**
* {@inheritdoc}
*/
public function handle($arguments)
{
$Update = $this->getUpdate();
$Message = $Update->getMessage();
// 消息 ID
$MessageID = $Message->getMessageId();
// 消息会话 ID
$ChatID = $Message->getChat()->getId();
if ($ChatID < 0) {
// 群组
if ($_ENV['enable_delete_user_cmd'] === true) {
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $MessageID,
]);
}
if ($_ENV['telegram_group_quiet'] === true) {
// 群组中不回应
return;
}
if ($ChatID != $_ENV['telegram_chatid']) {
// 非我方群组
return;
}
}
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
// 触发用户
$SendUser = [
'id' => $Message->getFrom()->getId(),
'name' => $Message->getFrom()->getFirstName() . ' ' . $Message->getFrom()->getLastName(),
'username' => $Message->getFrom()->getUsername(),
];
$User = User::where('telegram_id', $SendUser['id'])->first();
if ($User == null) {
// 回送信息
$response = $this->replyWithMessage(
[
'text' => $_ENV['user_not_bind_reply'],
'reply_to_message_id' => $MessageID,
'parse_mode' => 'Markdown',
]
);
} else {
if ($ChatID > 0) {
// 私人
$response = $this->triggerCommand('menu');
} else {
// 群组
$response = self::Group($User, $SendUser, $ChatID, $Message, $MessageID);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
]);
}
}
return $response;
}
public function Group($User, $SendUser, $ChatID, $Message, $MessageID)
{
$text = Reply::getUserTitle($User);
$text .= PHP_EOL . PHP_EOL;
$text .= Reply::getUserTrafficInfo($User);
$text .= PHP_EOL;
$text .= '流量重置时间:' . $User->valid_use_loop();
// 回送信息
return $this->replyWithMessage(
[
'text' => $text,
'parse_mode' => 'Markdown',
'reply_to_message_id' => $MessageID,
'reply_markup' => json_encode(
[
'inline_keyboard' => [
[
[
'text' => (!$User->isAbleToCheckin() ? '已签到' : '签到'),
'callback_data' => 'user.checkin.' . $SendUser['id']
]
],
]
]
),
]
);
}
}

@ -1,90 +0,0 @@
<?php
namespace App\Utils\Telegram\Commands;
use App\Utils\Telegram\TelegramTools;
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
/**
* Class PingCommand.
*/
class PingCommand extends Command
{
/**
* @var string Command Name
*/
protected $name = 'ping';
/**
* @var string Command Description
*/
protected $description = '[群组/私聊] 获取我或者群组的唯一 ID.';
/**
* {@inheritdoc}
*/
public function handle($arguments)
{
$Update = $this->getUpdate();
$Message = $Update->getMessage();
// 消息会话 ID
$ChatID = $Message->getChat()->getId();
if ($ChatID > 0) {
// 私人会话
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
$text = [
'Pong!',
'这个群组的 ID 是 ' . $ChatID . '.',
];
// 回送信息
$this->replyWithMessage(
[
'text' => implode(PHP_EOL, $text),
'parse_mode' => 'Markdown',
]
);
} else {
// 群组
if ($_ENV['enable_delete_user_cmd'] === true) {
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $Message->getMessageId(),
]);
}
if ($_ENV['telegram_group_quiet'] === true) {
// 群组中不回应
return;
}
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
$text = [
'Pong!',
'您的 ID 是 ' . $Message->getFrom()->getId() . '.',
'这个群组的 ID 是 ' . $ChatID . '.',
];
// 回送信息
$response = $this->replyWithMessage(
[
'text' => implode(PHP_EOL, $text),
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
]);
}
}
}

@ -1,295 +0,0 @@
<?php
namespace App\Utils\Telegram\Commands;
use App\Models\User;
use App\Services\Config;
use App\Utils\Telegram\{Reply, TelegramTools};
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
/**
* Class SetuserCommand.
*/
class SetuserCommand extends Command
{
/**
* @var string Command Name
*/
protected $name = 'setuser';
/**
* @var string Command Description
*/
protected $description = '[群组/私聊] 修改用户数据,管理员命令.';
/**
* {@inheritdoc}
*/
public function handle($arguments)
{
$Update = $this->getUpdate();
$Message = $Update->getMessage();
// 消息 ID
$MessageID = $Message->getMessageId();
// 消息会话 ID
$ChatID = $Message->getChat()->getId();
// 触发用户
$SendUser = [
'id' => $Message->getFrom()->getId(),
'name' => $Message->getFrom()->getFirstName() . ' ' . $Message->getFrom()->getLastName(),
'username' => $Message->getFrom()->getUsername(),
];
if ($_ENV['enable_delete_user_cmd'] === true) {
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $Message->getMessageId(),
]);
}
if (!in_array($SendUser['id'], $_ENV['telegram_admins'])) {
$AdminUser = User::where('is_admin', 1)->where('telegram_id', $SendUser['id'])->first();
if ($AdminUser == null) {
// 非管理员回复消息
if ($_ENV['enable_not_admin_reply'] === true && $_ENV['not_admin_reply_msg'] != '') {
$response = $this->replyWithMessage(
[
'text' => $_ENV['not_admin_reply_msg'],
'parse_mode' => 'HTML',
'reply_to_message_id' => $MessageID,
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
]);
return;
}
}
}
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
return self::Reply($arguments, $SendUser, $Message, $MessageID, $ChatID);
}
public function Reply($arguments, $SendUser, $Message, $MessageID, $ChatID)
{
$User = null;
$FindUser = null;
$arguments = trim($arguments);
if ($Message->getReplyToMessage() != null) {
// 回复源消息用户
$FindUser = [
'id' => $Message->getReplyToMessage()->getFrom()->getId(),
'name' => $Message->getReplyToMessage()->getFrom()->getFirstName() . ' ' . $Message->getReplyToMessage()->getFrom()->getLastName(),
'username' => $Message->getReplyToMessage()->getFrom()->getUsername(),
];
$User = TelegramTools::getUser($FindUser['id']);
if ($User == null) {
$response = $this->replyWithMessage(
[
'text' => $_ENV['no_user_found'],
'parse_mode' => 'HTML',
'reply_to_message_id' => $MessageID,
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
'executetime' => $_ENV['delete_admin_message_time']
]);
return;
}
if ($arguments == '') {
// 无参数时回复用户信息
$response = $this->replyWithMessage(
[
'text' => Reply::getUserInfoFromAdmin($User, $ChatID),
'reply_to_message_id' => $MessageID,
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
'executetime' => $_ENV['delete_admin_message_time']
]);
// 储存 Bot 所发的 Message ID
TelegramTools::FindUserSave([
'userid' => $User->id,
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
]);
return;
}
}
if ($arguments == '') {
$strArray = [
'/setuser [用户识别] [操作字段] [操作参数]',
'',
'用户识别:[使用回复消息方式则无需填写]',
'- [' . implode(' | ', array_keys(TelegramTools::getUserSearchMethods())) . '],可省略,默认:email',
'- 例 1:/setuser admin@admin 操作字段 操作参数',
'- 例 2:/setuser port:10086 操作字段 操作参数',
'',
'操作字段:',
'[' . implode(' | ', array_keys(TelegramTools::getUserActionOption())) . ']',
'',
'操作参数:',
'- 请查看对应选项支持的写法.',
];
$response = $this->replyWithMessage(
[
'text' => TelegramTools::StrArrayToCode($strArray),
'parse_mode' => 'HTML',
'reply_to_message_id' => $MessageID,
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
'executetime' => $_ENV['delete_admin_message_time']
]);
return;
}
// 命令格式:
// - /setuser [用户识别码] 选项 操作值
// ############## 命令解析 ##############
$UserCode = '';
if ($User == null) {
$Options = TelegramTools::StrExplode($arguments, ' ', 3);
if (count($Options) < 3) {
$response = $this->replyWithMessage(
[
'text' => '没有提供选项或操作值.',
'parse_mode' => 'HTML',
'reply_to_message_id' => $MessageID,
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
'executetime' => $_ENV['delete_admin_message_time']
]);
return;
}
// 用户识别码
$UserCode = $Options[0];
// 选项
$Option = $Options[1];
// 操作值
$value = $Options[2];
} else {
$Options = TelegramTools::StrExplode($arguments, ' ', 2);
if (count($Options) < 2) {
$response = $this->replyWithMessage(
[
'text' => '没有提供选项或操作值.',
'parse_mode' => 'HTML',
'reply_to_message_id' => $MessageID,
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
'executetime' => $_ENV['delete_admin_message_time']
]);
return;
}
// 选项
$Option = $Options[0];
// 操作值
$value = $Options[1];
}
// ############## 命令解析 ##############
// ############## 用户识别码处理 ##############
if ($User == null) {
// 默认搜寻字段
$useMethod = 'email';
if (strpos($UserCode, ':') !== false) {
// 如果指定了字段
$UserCodeExplode = explode(':', $UserCode);
$Search = $UserCodeExplode[0];
$UserCode = $UserCodeExplode[1];
$SearchMethods = TelegramTools::getUserSearchMethods();
$useTempMethod = TelegramTools::getOptionMethod($SearchMethods, $Search);
if ($useTempMethod != '') {
$useMethod = $useTempMethod;
}
}
$User = TelegramTools::getUser($UserCode, $useMethod);
if ($User == null) {
$response = $this->replyWithMessage(
[
'text' => $_ENV['no_user_found'],
'parse_mode' => 'HTML',
'reply_to_message_id' => $MessageID,
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
'executetime' => $_ENV['delete_admin_message_time']
]);
return;
}
}
// ############## 用户识别码处理 ##############
// ############## 字段选项处理 ##############
$OptionMethods = TelegramTools::getUserActionOption();
$useOptionMethod = TelegramTools::getOptionMethod($OptionMethods, $Option);
if ($useOptionMethod == '') {
$response = $this->replyWithMessage(
[
'text' => $_ENV['data_method_not_found'],
'parse_mode' => 'HTML',
'reply_to_message_id' => $MessageID,
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
'executetime' => $_ENV['delete_admin_message_time']
]);
return;
}
// ############## 字段选项处理 ##############
$reply = TelegramTools::OperationUser($User, $useOptionMethod, $value, $ChatID);
$response = $this->replyWithMessage(
[
'text' => $reply['msg'],
'parse_mode' => 'HTML',
'reply_to_message_id' => $MessageID,
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
'executetime' => $_ENV['delete_admin_message_time']
]);
return;
}
}

@ -1,114 +0,0 @@
<?php
namespace App\Utils\Telegram\Commands;
use App\Models\User;
use App\Utils\Telegram\TelegramTools;
use App\Utils\TelegramSessionManager;
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
/**
* Class StratCommand.
*/
class StartCommand extends Command
{
/**
* @var string Command Name
*/
protected $name = 'start';
/**
* @var string Command Description
*/
protected $description = '[群组/私聊] Bot 初始命令.';
/**
* {@inheritdoc}
*/
public function handle($arguments)
{
$Update = $this->getUpdate();
$Message = $Update->getMessage();
// 消息会话 ID
$ChatID = $Message->getChat()->getId();
if ($ChatID > 0) {
// 私人会话
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
// 触发用户
$SendUser = [
'id' => $Message->getFrom()->getId(),
'name' => $Message->getFrom()->getFirstName() . ' ' . $Message->getFrom()->getLastName(),
'username' => $Message->getFrom()->getUsername(),
];
// 消息内容
$MessageText = trim($arguments);
if ($MessageText != '') {
$BindCode = $MessageText;
if (strlen($BindCode) == 16) {
$Uid = TelegramSessionManager::verify_bind_session($BindCode);
if ($Uid == 0) {
$text = '绑定失败了呢,经检查发现:【' . $BindCode . '】的有效期为 10 分钟,您可以在我们网站上的 **资料编辑** 页面刷新后重试.';
} else {
$BinsUser = User::where('id', $Uid)->first();
$BinsUser->telegram_id = $SendUser['id'];
$BinsUser->im_type = 4;
$BinsUser->im_value = $SendUser['username'];
$BinsUser->save();
if ($BinsUser->is_admin >= 1) {
$text = '尊敬的**管理员**您好,恭喜绑定成功。' . PHP_EOL . '当前绑定邮箱为:' . $BinsUser->email;
} else {
if ($BinsUser->class >= 1) {
$text = '尊敬的 **VIP ' . $BinsUser->class . '** 用户您好.' . PHP_EOL . '恭喜您绑定成功,当前绑定邮箱为:' . $BinsUser->email;
} else {
$text = '绑定成功了,您的邮箱为:' . $BinsUser->email;
}
}
}
}
// 回送信息
$this->replyWithMessage(
[
'text' => $text,
'parse_mode' => 'Markdown',
]
);
}
// 触发 /help
$this->triggerCommand('help');
} else {
// 群组
if ($_ENV['enable_delete_user_cmd'] === true) {
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $Message->getMessageId(),
]);
}
if ($_ENV['telegram_group_quiet'] === true) {
// 群组中不回应
return;
}
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
// 回送信息
$response = $this->replyWithMessage(
[
'text' => '喵喵喵.',
]
);
// 消息删除任务
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $response->getMessageId(),
]);
}
}
}

@ -1,111 +0,0 @@
<?php
namespace App\Utils\Telegram\Commands;
use App\Models\User;
use App\Utils\Telegram\TelegramTools;
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
/**
* Class UnbindCommand.
*/
class UnbindCommand extends Command
{
/**
* @var string Command Name
*/
protected $name = 'unbind';
/**
* @var string Command Description
*/
protected $description = '[私聊] 解除账户绑定.';
/**
* {@inheritdoc}
*/
public function handle($arguments)
{
$Update = $this->getUpdate();
$Message = $Update->getMessage();
// 消息 ID
$MessageID = $Message->getMessageId();
// 消息会话 ID
$ChatID = $Message->getChat()->getId();
// 触发用户
$SendUser = [
'id' => $Message->getFrom()->getId(),
'name' => $Message->getFrom()->getFirstName() . ' ' . $Message->getFrom()->getLastName(),
'username' => $Message->getFrom()->getUsername(),
];
$User = User::where('telegram_id', $SendUser['id'])->first();
if ($ChatID > 0) {
// 私人
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
if ($User == null) {
// 回送信息
$this->replyWithMessage(
[
'text' => $_ENV['user_not_bind_reply'],
'parse_mode' => 'Markdown',
]
);
return;
}
// 消息内容
$MessageText = trim($arguments);
if ($MessageText == $User->email) {
$temp = $User->TelegramReset();
$text = $temp['msg'];
// 回送信息
$this->replyWithMessage(
[
'text' => $text,
'parse_mode' => 'Markdown',
]
);
return;
}
$text = self::sendtext();
if ($MessageText != '') {
$text = '键入的 Email 地址与您的账户不匹配.';
}
// 回送信息
$this->replyWithMessage(
[
'text' => $text,
'parse_mode' => 'Markdown',
]
);
} else {
if ($_ENV['enable_delete_user_cmd'] === true) {
TelegramTools::DeleteMessage([
'chatid' => $ChatID,
'messageid' => $MessageID,
]);
}
}
}
public function sendtext()
{
$text = '发送 **/unbind 账户邮箱** 进行解绑.';
if ($_ENV['unbind_kick_member'] === true) {
$text .= PHP_EOL . PHP_EOL . '根据管理员的设定,您解绑账户将会被自动移出用户群.';
}
return $text;
}
}

@ -1,168 +0,0 @@
<?php
namespace App\Utils\Telegram;
use App\Utils\TelegramSessionManager;
use App\Services\Config;
class Message
{
public static function MessageMethod($bot, $Message)
{
// 触发用户
$SendUser = [
'id' => $Message->getFrom()->getId(),
'name' => $Message->getFrom()->getFirstName() . ' ' . $Message->getFrom()->getLastName(),
'username' => $Message->getFrom()->getUsername(),
];
$user = TelegramTools::getUser($SendUser['id']);
// 消息会话 ID
$ChatID = $Message->getChat()->getId();
// 消息内容
$MessageData = $Message->getText();
if ($MessageData != null) {
$MessageData = trim($MessageData);
if ($user != null) {
if (is_numeric($MessageData) && strlen($MessageData) == 6) {
$uid = TelegramSessionManager::verify_login_number($MessageData, $user->id);
if ($uid != 0) {
$text = '登录验证成功,邮箱:' . $user->email;
} else {
$text = '登录验证失败,数字无效';
}
$bot->sendMessage(
[
'chat_id' => $ChatID,
'text' => $text,
'parse_mode' => 'Markdown',
]
);
}
} else {
if (strlen($MessageData) == 16) {
$Uid = TelegramSessionManager::verify_bind_session($MessageData);
if ($Uid == 0) {
$text = '绑定失败了呢,经检查发现:【' . $MessageData . '】的有效期为 10 分钟,您可以在我们网站上的 **资料编辑** 页面刷新后重试.';
} else {
$BinsUser = TelegramTools::getUser($Uid, 'id');
$BinsUser->telegram_id = $SendUser['id'];
$BinsUser->im_type = 4;
$BinsUser->im_value = $SendUser['username'];
$BinsUser->save();
if ($BinsUser->is_admin >= 1) {
$text = '尊敬的**管理员**您好,恭喜绑定成功。' . PHP_EOL . '当前绑定邮箱为:' . $BinsUser->email;
} else {
if ($BinsUser->class >= 1) {
$text = '尊敬的 **VIP ' . $BinsUser->class . '** 用户您好.' . PHP_EOL . '恭喜您绑定成功,当前绑定邮箱为:' . $BinsUser->email;
} else {
$text = '绑定成功了,您的邮箱为:' . $BinsUser->email;
}
}
}
$bot->sendMessage(
[
'chat_id' => $ChatID,
'text' => $text,
'parse_mode' => 'Markdown',
]
);
}
}
return;
}
$NewChatMember = $Message->getNewChatParticipant();
if ($NewChatMember != null) {
self::NewChatParticipant($user, $bot, $Message, $ChatID, $NewChatMember);
}
}
public static function NewChatParticipant($user, $bot, $Message, $ChatID, $NewChatMember)
{
$Member = [
'id' => $NewChatMember->getId(),
'name' => $NewChatMember->getFirstName() . ' ' . $NewChatMember->getLastName(),
'username' => $NewChatMember->getUsername(),
];
if ($NewChatMember->getUsername() == $_ENV['telegram_bot']) {
// 机器人加入新群组
if ($_ENV['allow_to_join_new_groups'] !== true && !in_array($ChatID, $_ENV['group_id_allowed_to_join'])) {
// 退群
$bot->sendMessage(
[
'text' => '不约,叔叔我们不约.',
'chat_id' => $ChatID,
'reply_to_message_id' => $Message->getMessageId(),
]
);
TelegramTools::SendPost(
'kickChatMember',
[
'chat_id' => $ChatID,
'user_id' => $Member['id'],
]
);
if (count($_ENV['telegram_admins']) >= 1) {
foreach ($_ENV['telegram_admins'] as $id) {
$bot->sendMessage(
[
'text' => '由于您的设定,Bot 退出了一个群组.' . PHP_EOL . PHP_EOL . '群组名称:' . $Message->getChat()->getTitle(),
'chat_id' => $id
]
);
}
}
} else {
$bot->sendMessage(
[
'text' => '同志们好,同志们辛苦了.',
'chat_id' => $ChatID,
'reply_to_message_id' => $Message->getMessageId(),
]
);
}
} else {
// 新成员加入群组
$NewUser = TelegramTools::getUser($Member['id']);
$deNewChatMember = json_decode($NewChatMember, true);
if (
$_ENV['group_bound_user'] === true
&&
$ChatID == $_ENV['telegram_chatid']
&&
$NewUser == null
&&
$deNewChatMember['is_bot'] == false
) {
$bot->sendMessage(
[
'text' => '由于 ' . $Member['name'] . ' 未绑定账户,将被移除.',
'chat_id' => $ChatID,
'reply_to_message_id' => $Message->getMessageId(),
]
);
TelegramTools::SendPost(
'kickChatMember',
[
'chat_id' => $ChatID,
'user_id' => $Member['id'],
]
);
return;
}
if ($_ENV['enable_welcome_message'] === true) {
$text = ($NewUser->class >= 1 ? '欢迎 VIP' . $NewUser->class . ' 用户 ' . $Member['name'] . '回到组织.' : '欢迎 ' . $Member['name']);
$bot->sendMessage(
[
'text' => $text,
'chat_id' => $ChatID,
'reply_to_message_id' => $Message->getMessageId(),
]
);
}
}
}
}

@ -1,40 +0,0 @@
<?php
namespace App\Utils\Telegram;
use App\Models\User;
use App\Services\Config;
use Telegram\Bot\Api;
use Exception;
class Process
{
public static function index()
{
try {
$bot = new Api($_ENV['telegram_token']);
$bot->addCommands(
[
Commands\MyCommand::class,
Commands\HelpCommand::class,
Commands\InfoCommand::class,
Commands\MenuCommand::class,
Commands\PingCommand::class,
Commands\StartCommand::class,
Commands\UnbindCommand::class,
Commands\CheckinCommand::class,
Commands\SetuserCommand::class,
]
);
$update = $bot->commandsHandler(true);
if ($update->getCallbackQuery() !== null) {
Callbacks\Callback::CallbackQueryMethod($bot, $update->getCallbackQuery());
}
if ($update->getMessage() !== null) {
Message::MessageMethod($bot, $update->getMessage());
}
} catch (Exception $e) {
$e->getMessage();
}
}
}

@ -1,90 +0,0 @@
<?php
namespace App\Utils\Telegram;
use App\Services\Config;
use App\Models\Bought;
class Reply
{
public static function getUserTrafficInfo($user)
{
$text = [
'您当前的流量状况:',
'',
'今日已使用 ' . $user->TodayusedTrafficPercent() . '% :' . $user->TodayusedTraffic(),
'之前已使用 ' . $user->LastusedTrafficPercent() . '% :' . $user->LastusedTraffic(),
'流量约剩余 ' . $user->unusedTrafficPercent() . '% :' . $user->unusedTraffic(),
];
return implode(PHP_EOL, $text);
}
public static function getUserInfo($user)
{
$text = [
'当前余额:' . $user->money,
'在线设备:' . ($user->node_connector != 0 ? $user->online_ip_count() . ' / ' . $user->node_connector : $user->online_ip_count() . ' / 不限制'),
'端口速率:' . ($user->node_speedlimit != 0 ? $user->node_speedlimit . 'Mbps' : '无限制'),
'上次使用:' . $user->lastSsTime(),
'过期时间:' . $user->class_expire,
];
return implode(PHP_EOL, $text);
}
public static function getUserTitle($user)
{
if ($user->class > 0) {
$text = '尊敬的 VIP ' . $user->class . ' 您好:';
} else {
$text = '尊敬的用户您好:';
}
return $text;
}
public static function getUserBoughts($user)
{
$boughts = Bought::where('userid', $user->id)->orderBy('id', 'desc')->get();
$data = [];
foreach ($boughts as $bought) {
$shop = $bought->shop();
if ($shop == null) {
$bought->delete();
continue;
}
if ($bought->valid()) {
$strArray = [];
$strArray[] = ' - 商品套餐名称:' . $shop->name;
$strArray[] = ' - 套餐购买时间:' . $bought->datetime();
$strArray[] = ' - 套餐自动续费:' . ($bought->renew == 0 ? '不自动续费' : $bought->renew_date());
$strArray[] = ' - 下次流量重置:' . $bought->reset_time();
$strArray[] = ' - 套餐过期时间:' . $bought->exp_time();
$strArray[] = '';
$data[] = implode(PHP_EOL, $strArray);
}
}
return $data;
}
public static function getUserInfoFromAdmin($user, $ChatID)
{
$strArray = [
'#' . $user->id . ' ' . $user->user_name . ' 的用户信息',
'',
'用户邮箱:' . TelegramTools::getUserEmail($user->email, $ChatID),
'账户余额:' . $user->money,
'是否启用:' . ((int) $user->enable == 1 ? '启用' : '禁用'),
'用户等级:' . $user->class,
'剩余流量:' . $user->unusedTraffic(),
'等级到期:' . $user->class_expire,
'账户到期:' . $user->expire_in,
'套餐详情:'
];
$boughts = self::getUserBoughts($user);
if (count($boughts) != 0) {
$strArray = array_merge($strArray, $boughts);
} else {
$strArray[] = ' - 该用户无生效套餐.';
}
return implode(PHP_EOL, $strArray);
}
}

@ -1,587 +0,0 @@
<?php
namespace App\Utils\Telegram;
use App\Models\{TelegramTasks, User};
use App\Services\Config;
use App\Utils\Tools;
class TelegramTools
{
/**
* 搜索用户
*
* @param string $value 搜索值
* @param string $method 查找列
*
* @return \App\Models\User
*/
public static function getUser($value, $method = 'telegram_id')
{
return User::where($method, $value)->first();
}
/**
* Sends a POST request to Telegram Bot API.
* 伪异步,无结果返回.
*
* @param array $params
*
* @return string
*/
public static function SendPost($Method, $Params)
{
$URL = 'https://api.telegram.org/bot' . $_ENV['telegram_token'] . '/' . $Method;
$POSTData = json_encode($Params);
$C = curl_init();
curl_setopt($C, CURLOPT_URL, $URL);
curl_setopt($C, CURLOPT_POST, 1);
curl_setopt($C, CURLOPT_HTTPHEADER, ['Content-Type:application/json; charset=utf-8']);
curl_setopt($C, CURLOPT_POSTFIELDS, $POSTData);
curl_setopt($C, CURLOPT_TIMEOUT, 1);
curl_exec($C);
curl_close($C);
}
/**
* 用户识别搜索字段
*
* @return array
*/
public static function getUserSearchMethods()
{
return [
'id' => [],
'email' => $_ENV['remark_user_search_email'],
'port' => $_ENV['remark_user_search_port'],
];
}
/**
* 操作字段
*
* @return array
*/
public static function getUserActionOption()
{
return [
'is_admin' => $_ENV['remark_user_option_is_admin'],
'enable' => $_ENV['remark_user_option_enable'],
'money' => $_ENV['remark_user_option_money'],
'port' => $_ENV['remark_user_option_port'],
'transfer_enable' => $_ENV['remark_user_option_transfer_enable'],
'passwd' => $_ENV['remark_user_option_passwd'],
'method' => $_ENV['remark_user_option_method'],
'protocol' => $_ENV['remark_user_option_protocol'],
'protocol_param' => $_ENV['remark_user_option_protocol_param'],
'obfs' => $_ENV['remark_user_option_obfs'],
'obfs_param' => $_ENV['remark_user_option_obfs_param'],
'invite_num' => $_ENV['remark_user_option_invite_num'],
'node_group' => $_ENV['remark_user_option_node_group'],
'class' => $_ENV['remark_user_option_class'],
'class_expire' => $_ENV['remark_user_option_class_expire'],
'expire_in' => $_ENV['remark_user_option_expire_in'],
'node_speedlimit' => $_ENV['remark_user_option_node_speedlimit'],
'node_connector' => $_ENV['remark_user_option_node_connector'],
];
}
/**
* 待定
*
* @return mixed
*/
public static function OperationUser($User, $useOptionMethod, $value, $ChatID)
{
$Email = self::getUserEmail($User->email, $ChatID);
$old = $User->$useOptionMethod;
$useOptionMethodName = self::getUserActionOption()[$useOptionMethod][0];
switch ($useOptionMethod) {
// ##############
case 'enable':
case 'is_admin':
$strArray = [
'// 支持的写法',
'// [启用|是] —— 字面意思',
'// [禁用|否] —— 字面意思',
];
if (strpos($value, ' ') !== false) {
return [
'ok' => false,
'msg' => '处理出错,不支持的写法.' . PHP_EOL . PHP_EOL . self::StrArrayToCode($strArray),
];
}
if (in_array($value, ['启用', '是'])) {
$User->$useOptionMethod = 1;
$new = '启用';
} elseif (in_array($value, ['禁用', '否'])) {
$User->$useOptionMethod = 0;
$new = '禁用';
} else {
return [
'ok' => false,
'msg' => '处理出错,不支持的写法.' . PHP_EOL . PHP_EOL . self::StrArrayToCode($strArray),
];
}
$old = ($old ? '启用' : '禁用');
break;
// ##############
case 'port':
// 支持正整数或 0 随机选择
if (!is_numeric($value) || strpos($value, '-') === 0) {
return [
'ok' => false,
'msg' => '提供的端口非数值,如要随机重置请指定为 0.',
];
}
if ((int) $value === 0) {
$value = Tools::getAvPort();
}
$temp = $User->setPort($value);
if ($temp['ok'] === false) {
$strArray = [
'目标用户:' . $Email,
'欲修改项:' . $useOptionMethodName . '[' . $useOptionMethod . ']',
'当前值为:' . $old,
'欲修改为:' . $value,
'错误详情:' . $temp['msg'],
];
return [
'ok' => false,
'msg' => self::StrArrayToCode($strArray),
];
}
$new = $User->$useOptionMethod;
$User->$useOptionMethod = $new;
break;
// ##############
case 'transfer_enable':
$strArray = [
'// 支持的写法,不支持单位 b,不区分大小写',
'// 支持的单位:kb | mb | gb | tb | pb',
'// 2kb —— 指定为该值得流量',
'// +2kb —— 增加流量',
'// -2kb —— 减少流量',
'// *2 —— 以当前流量做乘法,不支持填写单位',
'// /2 —— 以当前流量做除法,不支持填写单位',
];
if (strpos($value, ' ') !== false) {
return [
'ok' => false,
'msg' => '处理出错,不支持的写法.' . PHP_EOL . PHP_EOL . self::StrArrayToCode($strArray),
];
}
$new = self::TrafficMethod($User->$useOptionMethod, $value);
if ($new === null) {
return [
'ok' => false,
'msg' => '处理出错,不支持的写法.' . PHP_EOL . PHP_EOL . self::StrArrayToCode($strArray),
];
}
$User->$useOptionMethod = $new;
$old = Tools::flowAutoShow($old);
$new = Tools::flowAutoShow($new);
break;
// ##############
case 'expire_in':
case 'class_expire':
$strArray = [
'// 支持的写法,单位:天',
'// 使用天数设置不能包含空格',
'// 2 —— 以当前时间为基准的天数设置',
'// +2 —— 增加天数',
'// -2 —— 减少天数',
'// 指定日期,在日期与时间中含有一个空格',
'// 2020-02-30 —— 指定日期',
'// 2020-02-30 08:00:00 —— 指定日期精确到秒',
];
if (
strpos($value, '+') === 0
||
strpos($value, '-') === 0
) {
$operator = substr($value, 0, 1);
$number = substr($value, 1);
if (is_numeric($number)) {
$number *= 86400;
$old_time = strtotime($old);
$new = ($operator == '+' ? $old_time + $number : $old_time - $number);
$new = date('Y-m-d H:i:s', $new);
} else {
if (strtotime($value) === false) {
return [
'ok' => false,
'msg' => '处理出错,不支持的写法.' . PHP_EOL . PHP_EOL . self::StrArrayToCode($strArray),
];
}
$new = strtotime($value);
$new = date('Y-m-d H:i:s', $new);
}
} else {
$number = $value;
if (is_numeric($value)) {
$number *= 86400;
$new = time() + $number;
$new = date('Y-m-d H:i:s', $new);
} else {
if (strtotime($value) === false) {
return [
'ok' => false,
'msg' => '处理出错,不支持的写法.' . PHP_EOL . PHP_EOL . self::StrArrayToCode($strArray),
];
}
$new = strtotime($value);
$new = date('Y-m-d H:i:s', $new);
}
}
$User->$useOptionMethod = $new;
break;
// ##############
case 'obfs':
case 'method':
case 'protocol':
// 支持系统中存在的协议、混淆、加密,且受可行性限制
$MethodClass = 'set' . ucfirst($useOptionMethod);
$temp = $User->$MethodClass($value);
if ($temp['ok'] === true) {
$strArray = [
'目标用户:' . $Email,
'被修改项:' . $useOptionMethodName . '[' . $useOptionMethod . ']',
'修改前值:' . $old,
'修改后值:' . $User->$useOptionMethod,
'修改备注:' . $temp['msg'],
];
} else {
$strArray = [
'目标用户:' . $Email,
'欲修改项:' . $useOptionMethodName . '[' . $useOptionMethod . ']',
'当前值为:' . $old,
'欲修改为:' . $value,
'错误详情:' . $temp['msg'],
];
}
return [
'ok' => $temp['ok'],
'msg' => self::StrArrayToCode($strArray),
];
break;
// ##############
case 'passwd':
case 'obfs_param':
case 'protocol_param':
// 参数值中不允许有空格
if (strpos($value, ' ') !== false) {
return [
'ok' => false,
'msg' => '处理出错,协议中含有空格等字符.',
];
}
$new = $value;
$User->$useOptionMethod = $new;
break;
// ##############
case 'money':
$strArray = [
'// 参数值中不允许有空格,结果会含小数 2 位',
'// +2 —— 增加余额',
'// -2 —— 减少余额',
'// *2 —— 以当前余额做乘法',
'// /2 —— 以当前余额做除法',
];
$value = explode(' ', $value)[0];
$new = self::ComputingMethod($User->$useOptionMethod, $value, true);
if ($new === null) {
return [
'ok' => false,
'msg' => '处理出错,不支持的写法.' . PHP_EOL . PHP_EOL . self::StrArrayToCode($strArray),
];
}
$User->$useOptionMethod = $new;
break;
// ##############
case 'class':
case 'invite_num':
case 'node_group':
case 'node_connector':
case 'node_speedlimit':
$strArray = [
'// 参数值中不允许有空格',
'// +2 —— 增加值',
'// -2 —— 减少值',
'// *2 —— 以当前值做乘法',
'// /2 —— 以当前值做除法',
];
$value = explode(' ', $value)[0];
$new = self::ComputingMethod($User->$useOptionMethod, $value, false);
if ($new === null) {
return [
'ok' => false,
'msg' => '处理出错,不支持的写法.' . PHP_EOL . PHP_EOL . self::StrArrayToCode($strArray),
];
}
$User->$useOptionMethod = $new;
break;
// ##############
default:
return [
'ok' => false,
'msg' => '尚不支持.',
];
break;
}
if ($User->save()) {
$strArray = [
'目标用户:' . $Email,
'被修改项:' . $useOptionMethodName . '[' . $useOptionMethod . ']',
'修改前为:' . $old,
'修改后为:' . $new,
];
return [
'ok' => true,
'msg' => self::StrArrayToCode($strArray),
];
} else {
return [
'ok' => false,
'msg' => '保存出错',
];
}
}
/**
* 获取用户邮箱
*
* @param string $email 邮箱
* @param int $ChatID 会话 ID
*
* @return string
*/
public static function getUserEmail($email, $ChatID)
{
if ($_ENV['enable_user_email_group_show'] === true || $ChatID > 0) {
return $email;
}
$a = strpos($email, '@');
if ($a === false) {
return $email;
}
$string = substr($email, $a);
return ($a === 1 ? '*' . $string : substr($email, 0, 1) . str_pad('', $a - 1, '*') . $string);
}
/**
* 分割字符串
*
* @param string $Str 源字符串
* @param string $Delimiter 分割定界符
* @param int $Quantity 最大返回数量
*
* @return array
*/
public static function StrExplode($Str, $Delimiter, $Quantity = 10)
{
$return = [];
$Str = trim($Str);
for ($x = 0; $x <= 10; $x++) {
if (strpos($Str, $Delimiter) !== false && count($return) < $Quantity - 1) {
$temp = substr($Str, 0, strpos($Str, $Delimiter));
$return[] = $temp;
$Str = trim(substr($Str, strlen($temp)));
} else {
$return[] = $Str;
break;
}
}
return $return;
}
/**
* 查找字符串是否是某个方法的别名
*
* @param array $MethodGroup 方法别名的数组
* @param string $Search 被搜索的字符串
*
* @return string
*/
public static function getOptionMethod($MethodGroup, $Search)
{
$useMethod = '';
foreach ($MethodGroup as $MethodName => $Remarks) {
if (strlen($MethodName) === strlen($Search)) {
if (stripos($MethodName, $Search) === 0) {
$useMethod = $MethodName;
break;
}
}
if (count($Remarks) >= 1) {
foreach ($Remarks as $Remark) {
if (strlen($Remark) === strlen($Search) && stripos($Remark, $Search) === 0) {
$useMethod = $MethodName;
break 2;
}
}
}
}
return $useMethod;
}
/**
* 使用 $Value 给定的运算式与 $Source 计算结果
*
* @param string $Source 源数值
* @param string $Value 运算式含增改数值
* @param bool $FloatingNumber 是否格式化为浮点数
*
* @return string|null
*/
public static function ComputingMethod($Source, $Value, $FloatingNumber = false)
{
if (
(strpos($Value, '+') === 0
||
strpos($Value, '-') === 0
||
strpos($Value, '*') === 0
||
strpos($Value, '/') === 0)
&&
is_numeric(substr($Value, 1))
) {
$Source = eval('return $Source ' . substr($Value, 0, 1) . '= ' . substr($Value, 1) . ';');
} else {
if (is_numeric($Value)) {
$Source = $Value;
} else {
$Source = null;
}
}
if ($Source !== null) {
$Source = ($FloatingNumber === false
? number_format($Source, 0, '.', '')
: number_format($Source, 2, '.', ''));
}
return $Source;
}
/**
* 使用 $Value 给定的运算式及流量单位与 $Source 计算结果
*
* @param string $Source 源数值
* @param string $Value 运算式含增改数值
*
* @return int|null
*/
public static function TrafficMethod($Source, $Value)
{
if (
strpos($Value, '+') === 0
||
strpos($Value, '-') === 0
||
strpos($Value, '*') === 0
||
strpos($Value, '/') === 0
) {
$operator = substr($Value, 0, 1);
if (!in_array($operator, ['*', '/'])) {
$number = Tools::flowAutoShowZ(substr($Value, 1));
} else {
$number = substr($Value, 1, strlen($Value) - 1);
if (!is_numeric($number)) return null;
}
if ($number === null) {
return null;
}
$Source = eval('return $Source ' . $operator . '= ' . $number . ';');
} else {
if (is_numeric($Value)) {
if ((int) $Value === 0) {
$Source = 0;
} else {
$Source = Tools::flowAutoShowZ($Value . 'KB');
}
} else {
$Source = Tools::flowAutoShowZ($Value);
}
}
return $Source;
}
/**
* 字符串数组转 TG HTML 等宽字符串
*
* @param array $strArray 字符串数组
*
* @return string
*/
public static function StrArrayToCode($strArray)
{
return implode(
PHP_EOL,
array_map(
function ($item) {
return ('<code>' . $item . '</code>');
},
$strArray
)
);
}
/**
* 删除消息
*
* <code>
* $Params = [
* 'chatid' => '',
* 'messageid' => '',
* 'executetime' => '',
* ];
* </code>
*
* @return void
*/
public static function DeleteMessage($Params)
{
if (isset($Params['executetime']) && is_numeric($Params['executetime'])) {
$executetime = $Params['executetime'];
} else {
$executetime = $_ENV['delete_message_time'];
}
if ($executetime != 0) {
$executetime += time();
$task = new TelegramTasks();
$task->type = 1;
$task->chatid = $Params['chatid'];
$task->messageid = $Params['messageid'];
$task->executetime = $executetime;
$task->datetime = time();
$task->save();
}
}
/**
* 储存 /setuser 操作产生的 messageid
*
* <code>
* $Params = [
* 'chatid' => '',
* 'messageid' => '',
* 'userid' => '',
* ];
* </code>
*
* @return void
*/
public static function FindUserSave($Params)
{
$task = new TelegramTasks();
$task->type = 2;
$task->chatid = $Params['chatid'];
$task->messageid = $Params['messageid'];
$task->executetime = 0;
$task->userid = $Params['userid'];
$task->datetime = time();
$task->save();
}
}

@ -8,7 +8,6 @@
use TelegramBot\Api\Client;
use TelegramBot\Api\Exception;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use App\Services\MalioConfig;
class TelegramProcess
{
@ -290,12 +289,6 @@
} else {
$reply['message'] = null;
}
if ($user == null && $message->getNewChatMember() != null && MalioConfig::get('force_user_to_bind_tg_when_join_group') == true) {
$remove_message = $bot->sendMessage($message->getChat()->getId(), '您未绑定本站账号,无法加入此群组。您可以进入网站的 “我的账号” 页面绑定您的账号。', $parseMode = null, $disablePreview = false, $replyToMessageId = $reply_to, $replyMarkup = $reply['mark']);
$bot->kickChatMember($message->getChat()->getId(), $message->getFrom()->getId(), time()+60);
$bot->deleteMessage($message->getChat()->getId(), $remove_message->getMessageId());
}
}
}
@ -334,4 +327,4 @@
$e->getMessage();
}
}
}
}

@ -44,45 +44,6 @@ class Tools
return round($value, 2) . 'B';
}
/**
* 根据流量值转换 B 输出
*/
public static function flowAutoShowZ($Value)
{
$number = substr($Value, 0, strlen($Value) - 2);
if (!is_numeric($number)) return null;
$unit = strtoupper(substr($Value, -2));
$kb = 1024;
$mb = 1048576;
$gb = 1073741824;
$tb = $gb * 1024;
$pb = $tb * 1024;
switch ($unit) {
case 'B':
$number = round($number, 2);
break;
case 'KB':
$number = round($number * $kb, 2);
break;
case 'MB':
$number = round($number * $mb, 2);
break;
case 'GB':
$number = round($number * $gb, 2);
break;
case 'TB':
$number = round($number * $tb, 2);
break;
case 'PB':
$number = round($number * $pb, 2);
break;
default:
return null;
break;
}
return $number;
}
//虽然名字是toMB,但是实际上功能是from MB to B
public static function toMB($traffic)
{
@ -370,10 +331,10 @@ class Tools
if ($single_rule->dist_node_id == $path->begin_node->id) {
$path->begin_node = $single_rule->Source_Node();
if ($path->begin_node->isNodeAccessable() == false) {
$path->path = '' . $single_rule->Source_Node()->name . '' . ' <i class="fas fa-long-arrow-alt-right"></i> ' . $path->path;
$path->path = '<font color="#FF0000">' . $single_rule->Source_Node()->name . '</font>' . ' → ' . $path->path;
$path->status = '阻断';
} else {
$path->path = $single_rule->Source_Node()->name . ' <i class="fas fa-long-arrow-alt-right"></i> ' . $path->path;
$path->path = $single_rule->Source_Node()->name . ' → ' . $path->path;
$path->status = '通畅';
}
return $pathset;
@ -382,10 +343,10 @@ class Tools
if ($path->end_node->id == $single_rule->source_node_id) {
$path->end_node = $single_rule->Dist_Node();
if ($path->end_node->isNodeAccessable() == false) {
$path->path = $path->path . ' <i class="fas fa-long-arrow-alt-right"></i> ' . '' . $single_rule->Dist_Node()->name . '';
$path->path = $path->path . ' → ' . '<font color="#FF0000">' . $single_rule->Dist_Node()->name . '</font>';
$path->status = '阻断';
} else {
$path->path = $path->path . ' <i class="fas fa-long-arrow-alt-right"></i> ' . $single_rule->Dist_Node()->name;
$path->path = $path->path . ' → ' . $single_rule->Dist_Node()->name;
}
return $pathset;
}
@ -395,7 +356,7 @@ class Tools
$new_path = new \stdClass();
$new_path->begin_node = $single_rule->Source_Node();
if ($new_path->begin_node->isNodeAccessable() == false) {
$new_path->path = '' . $single_rule->Source_Node()->name . '';
$new_path->path = '<font color="#FF0000">' . $single_rule->Source_Node()->name . '</font>';
$new_path->status = '阻断';
} else {
$new_path->path = $single_rule->Source_Node()->name;
@ -404,10 +365,10 @@ class Tools
$new_path->end_node = $single_rule->Dist_Node();
if ($new_path->end_node->isNodeAccessable() == false) {
$new_path->path .= ' <i class="fas fa-long-arrow-alt-right"></i> ' . '' . $single_rule->Dist_Node()->name . '';
$new_path->path .= ' -> ' . '<font color="#FF0000">' . $single_rule->Dist_Node()->name . '</font>';
$new_path->status = '阻断';
} else {
$new_path->path .= ' <i class="fas fa-long-arrow-alt-right"></i> ' . $single_rule->Dist_Node()->name;
$new_path->path .= ' -> ' . $single_rule->Dist_Node()->name;
}
$new_path->port = $port;
@ -425,13 +386,12 @@ class Tools
}
return $object;
}
public static function relayRulePortCheck($rules)
{
public static function relayRulePortCheck($rules){
$res = array();
foreach ($rules as $value) {
foreach($rules as $value) {
$res[$value->port][] = $value->port;
}
return count($res) == count($rules);
return count($res)==count($rules);
}
public static function getRelayNodeIp($source_node, $dist_node)
@ -502,7 +462,7 @@ class Tools
}
$item['aid'] = (int) $server[2];
$item['net'] = 'tcp';
$item['headerType'] = 'none';
$item['type'] = 'none';
if (count($server) >= 4) {
$item['net'] = $server[3];
if ($item['net'] == 'ws') {
@ -512,8 +472,8 @@ class Tools
}
}
if (count($server) >= 5) {
if (in_array($item['net'], array('kcp', 'http', 'mkcp'))) {
$item['headerType'] = $server[4];
if (in_array($item['net'], array('kcp', 'http','mkcp'))) {
$item['type'] = $server[4];
} elseif ($server[4] == 'ws') {
$item['net'] = 'ws';
} elseif ($server[4] == 'tls') {
@ -529,8 +489,8 @@ class Tools
if (array_key_exists('relayserver', $item)) {
$item['add'] = $item['relayserver'];
unset($item['relayserver']);
if ($item['tls'] == 'tls') {
$item['verify_cert'] = false;
if ($item['tls']=='tls'){
$item['verify_cert']=false;
}
}
if (array_key_exists('outside_port', $item)) {
@ -554,7 +514,7 @@ class Tools
{
$server = explode(';', $node);
$item = [
'host' => 'microsoft.com',
'host' => 'windowsupdate.microsoft.com',
'path' => '',
'net' => 'ws',
'tls' => ''
@ -593,14 +553,6 @@ class Tools
unset($item['outside_port']);
}
}
if ($item['net'] == 'obfs') {
if (stripos($server[4], 'http') !== false) {
$item['obfs'] = 'simple_obfs_http';
}
if (stripos($server[4], 'tls') !== false) {
$item['obfs'] = 'simple_obfs_tls';
}
}
return $item;
}
@ -629,7 +581,7 @@ class Tools
}
return [
'name' => (Config::get('disable_sub_mu_port') ? $node_name : $node_name . ' - ' . $node_port . ' 单端口'),
'name' => ($node_name . ' - ' . $node_port . ' 单端口'),
'address' => $node_server[0],
'port' => $node_port
];
@ -652,7 +604,7 @@ class Tools
$port[substr($item['port'], 0, strpos($item['port'], '#'))] = (int) substr($item['port'], strpos($item['port'], '#') + 1);
}
} else {
$type = (int) $item['port'];
$$type = (int) $item['port'];
}
}
@ -836,10 +788,9 @@ class Tools
/**
* Add files and sub-directories in a folder to zip file.
*
* @param string $folder
* @param string $folder
* @param ZipArchive $zipFile
* @param int $exclusiveLength Number of text to be exclusived from the file path.
* @param int $exclusiveLength Number of text to be exclusived from the file path.
*/
public static function folderToZip($folder, &$zipFile, $exclusiveLength)
{
@ -860,39 +811,4 @@ class Tools
}
closedir($handle);
}
/**
* 清空文件夹
*
* @param string $dirName
*/
public static function delDirAndFile($dirPath)
{
if ($handle = opendir($dirPath)) {
while (false !== ($item = readdir($handle))) {
if ($item != '.' && $item != '..') {
if (is_dir($dirPath . '/' . $item)) {
self::delDirAndFile($dirPath . '/' . $item);
} else {
unlink($dirPath . '/' . $item);
}
}
}
closedir($handle);
}
}
/**
* 清空订阅缓存
*/
public static function delSubCache()
{
if (Config::get('enable_sub_cache') === true) {
$path = (BASE_PATH . '/storage/SubscribeCache/');
//rm -rf /home/happy/baidu/*
$a = system('rm -rf ' . $path . '*');
return ($a === false ?: true);
}
return true;
}
}

@ -139,7 +139,7 @@ class URL
return $new_user;
}
public static function getAllItems($user, $is_mu = 0, $is_ss = 0, $emoji = false)
public static function getAllItems($user, $is_mu = 0, $is_ss = 0, $emoji = 0)
{
$return_array = array();
if ($user->is_admin) {
@ -239,276 +239,6 @@ class URL
return $return_array;
}
public static function getNew_AllItems($user, $Rule)
{
// $Rule = [
// 'type' => 'ss | ssr | vmess',
// 'emoji' => false,
// 'is_mu' => 1
// 'content' => [
// 'noclass' => [0, 1, 2],
// 'class' => [0, 1, 2],
// 'regex' => '.*香港.*HKBN.*',
// ]
// ];
$is_mu = $Rule['is_mu'];
$is_ss = 0;
$emoji = (isset($Rule['emoji']) ? $Rule['emoji'] : false);
switch ($Rule['type']) {
case 'ss':
$sort = [0, 10, 13];
$is_ss = 1;
break;
case 'ssr':
$sort = [0, 10];
break;
case 'vmess':
$sort = [11, 12];
break;
case 'trojan':
$sort = [14];
break;
default:
$Rule['type'] = 'all';
$sort = [0, 10, 11, 12, 13, 14];
break;
}
if ($user->is_admin) {
$nodes = Node::whereIn('sort', $sort)->where('type', '1')->orderBy('name')->get();
} else {
$node_query = Node::query();
$node_query->whereIn('sort', $sort)->where('type', '1')->where(
static function ($query) use ($user) {
$query->where('node_group', '=', $user->node_group)
->orWhere('node_group', '=', 0);
}
);
$class = [];
if (isset($Rule['content']['class']) && count($Rule['content']['class']) > 0) {
foreach ($Rule['content']['class'] as $x) {
if ($x <= $user->class && $x >= 0 && !in_array($x, $class)) {
$class[] = $x;
}
}
}
if (count($class) > 0) {
$node_query->whereIn('node_class', $class);
} else {
$node_query->where('node_class', '<=', $user->class);
}
$nodes = $node_query->orderBy('name')->get();
}
$return_array = array();
if ($is_mu != 0 && $Rule['type'] != 'vmess' && $Rule['type'] != 'trojan') {
$mu_node_query = Node::query();
$mu_node_query->where('sort', 9)->where('type', '1');
if ($user->is_admin) {
if ($is_mu != 1) {
$mu_node_query->where('server', $is_mu);
}
} elseif ($is_mu != 1) {
$mu_node_query->where('server', $is_mu)
->where('node_class', '<=', $user->class)
->where(
static function ($query) use ($user) {
$query->where('node_group', '=', $user->node_group)
->orWhere('node_group', '=', 0);
}
);
} else {
$mu_node_query->where('node_class', '<=', $user->class)
->where(
static function ($query) use ($user) {
$query->where('node_group', '=', $user->node_group)
->orWhere('node_group', '=', 0);
}
);
}
$mu_nodes = $mu_node_query->get();
}
if (!Tools::is_protocol_relay($user)) {
$relay_rules = array();
} else {
$relay_rules = Relay::where('user_id', $user->id)->orwhere('user_id', 0)->orderBy('id', 'asc')->get();
}
$foreachss = [];
if ($Rule['type'] == 'all') {
$foreachss = [0, 1];
} else {
$foreachss[] = $is_ss;
}
foreach ($foreachss as $x) {
// all is_ss *2
foreach ($nodes as $node) {
if (in_array($node->sort, [13]) && (($Rule['type'] == 'all' && $x == 0) || ($Rule['type'] != 'all'))) {
// Rico SS (V2RayPlugin && obfs)
$item = self::getV2RayPluginItem($user, $node, $emoji);
if ($item != null) {
$find = (isset($Rule['content']['regex']) && $Rule['content']['regex'] != '' ? ConfController::getMatchProxy($item, ['content' => ['regex' => $Rule['content']['regex']]]) : true);
if ($find) {
$return_array[] = $item;
}
}
continue;
}
if (in_array($node->sort, [11, 12]) && (($Rule['type'] == 'all' && $x == 0) || ($Rule['type'] != 'all'))) {
// V2Ray
$item = self::getV2Url($user, $node, 1, $emoji);
if ($item != null) {
$find = (isset($Rule['content']['regex']) && $Rule['content']['regex'] != '' ? ConfController::getMatchProxy($item, ['content' => ['regex' => $Rule['content']['regex']]]) : true);
if ($find) {
$return_array[] = $item;
}
}
continue;
}
if (in_array($node->sort, [14]) && (($Rule['type'] == 'all' && $x == 0) || ($Rule['type'] == 'trojan'))) {
// Trojan
$item = self::getTrojanItem($user, $node, $emoji);
if ($item != null) {
$find = (isset($Rule['content']['regex']) && $Rule['content']['regex'] != '' ? ConfController::getMatchProxy($item, ['content' => ['regex' => $Rule['content']['regex']]]) : true);
if ($find) {
$return_array[] = $item;
}
}
continue;
}
if (in_array($node->sort, [0, 10]) && $node->mu_only != 1 && ($is_mu == 0 || ($is_mu != 0 && Config::get('mergeSub') === true))) {
// 节点非只启用单端口 && 只获取普通端口
if ($node->sort == 10) {
// SS 中转
$relay_rule_id = 0;
$relay_rule = Tools::pick_out_relay_rule($node->id, $user->port, $relay_rules);
if ($relay_rule != null && $relay_rule->dist_node() != null) {
$relay_rule_id = $relay_rule->id;
}
$item = self::getItem($user, $node, 0, $relay_rule_id, $x, $emoji);
if ($item != null) {
$find = (isset($Rule['content']['regex']) && $Rule['content']['regex'] != '' ? ConfController::getMatchProxy($item, ['content' => ['regex' => $Rule['content']['regex']]]) : true);
if ($find) {
$return_array[] = $item;
}
}
} else {
// SS 非中转
$item = self::getItem($user, $node, 0, 0, $x, $emoji);
if ($item != null) {
$find = (isset($Rule['content']['regex']) && $Rule['content']['regex'] != '' ? ConfController::getMatchProxy($item, ['content' => ['regex' => $Rule['content']['regex']]]) : true);
if ($find) {
$return_array[] = $item;
}
}
}
}
if (in_array($node->sort, [0, 10]) && $node->custom_rss == 1 && $node->mu_only != -1 && $is_mu != 0) {
// 非只启用普通端口 && 获取单端口
foreach ($mu_nodes as $mu_node) {
if ($node->sort == 10) {
// SS 中转
$relay_rule_id = 0;
$relay_rule = Tools::pick_out_relay_rule($node->id, $mu_node->server, $relay_rules);
if ($relay_rule != null && $relay_rule->dist_node() != null) {
$relay_rule_id = $relay_rule->id;
}
$item = self::getItem($user, $node, $mu_node->server, $relay_rule_id, $x, $emoji);
if ($item != null) {
$find = (isset($Rule['content']['regex']) && $Rule['content']['regex'] != '' ? ConfController::getMatchProxy($item, ['content' => ['regex' => $Rule['content']['regex']]]) : true);
if ($find) {
$return_array[] = $item;
}
}
} else {
// SS 非中转
$item = self::getItem($user, $node, $mu_node->server, 0, $x, $emoji);
if ($item != null) {
$find = (isset($Rule['content']['regex']) && $Rule['content']['regex'] != '' ? ConfController::getMatchProxy($item, ['content' => ['regex' => $Rule['content']['regex']]]) : true);
if ($find) {
$return_array[] = $item;
}
}
}
}
}
}
}
if (!isset($Rule['content']['class']) && isset($Rule['content']['noclass']) && count($Rule['content']['noclass']) > 0) {
// 如果设置不需要的等级的节点
$tmp = [];
foreach ($return_array as $outnode) {
if (!in_array($outnode['class'], $Rule['content']['noclass'])) {
// 放行节点等级不存在数组内的
$tmp[] = $outnode;
}
}
$return_array = $tmp;
}
if ($Rule['type'] != 'all') {
// 如果获取节点的类型不是 all
$tmp = [];
foreach ($return_array as $outnode) {
if ($outnode['type'] == $Rule['type']) {
// 放行类型相同
$tmp[] = $outnode;
}
}
$return_array = $tmp;
}
return $return_array;
}
/**
* 获取 Trojan 全部节点
*
* @param User $user 用户
* @param bool $emoji
*
* @return array
*/
public static function getAllTrojan($user, $emoji = false)
{
$return_array = array();
$nodes = Node::where('sort', 14)
->where('type', '1')
->orderBy('name')
->get();
foreach ($nodes as $node) {
$item = self::getTrojanItem($user, $node, $emoji);
if ($item != null) {
$return_array[] = $item;
}
}
return $return_array;
}
/**
* Trojan 节点
*
* @param User $user 用户
* @param Node $node
* @param bool $emoji
*
* @return array
*/
public static function getTrojanItem($user, $node, $emoji = false)
{
$server = explode(';', $node->server);
$opt = [];
if (isset($server[1])) {
$opt = self::parse_args($server[1]);
}
$item['remark'] = ($emoji == true ? Tools::addEmoji($node->name) : $node->name);
$item['type'] = 'trojan';
$item['address'] = $server[0];
$item['port'] = (isset($opt['port']) ? (int) $opt['port'] : 443);
$item['passwd'] = $user->uuid;
$item['host'] = $item['address'];
if (isset($opt['host'])) {
$item['host'] = $opt['host'];
}
return $item;
}
public static function getAllUrl($user, $is_mu, $is_ss = 0, $getV2rayPlugin = 1)
{
$return_url = '';
@ -532,27 +262,44 @@ class URL
* 获取全部节点 Url
*
* @param object $user 用户
* @param int $is_ss 是否 ss
* @param int $getV2rayPlugin 是否获取 V2rayPlugin 节点
* @param array $Rule 节点筛选规则
* @param bool $find 是否筛选节点
*
* @return string
*/
public static function get_NewAllUrl($user, $Rule)
public static function get_NewAllUrl($user, $is_ss, $getV2rayPlugin, $Rule, $find, $emoji = 0)
{
$return_url = '';
if (strtotime($user->expire_in) < time()) {
return $return_url;
}
$items = URL::getNew_AllItems($user, $Rule);
foreach ($items as $item) {
if ($item['type'] == 'vmess') {
$out = LinkController::getListItem($item, 'v2rayn');
} else {
$out = LinkController::getListItem($item, $Rule['type']);
if ($getV2rayPlugin === 0) {
$items = array_merge(
self::getAllItems($user, 0, $is_ss, $emoji),
self::getAllItems($user, 1, $is_ss, $emoji)
);
} else {
$items = array_merge(
self::getAllItems($user, 0, $is_ss, $emoji),
self::getAllItems($user, 1, $is_ss, $emoji),
self::getAllV2RayPluginItems($user, $emoji)
);
}
if ($find) {
foreach ($items as $item) {
$item = ConfController::getMatchProxy($item, $Rule);
if ($item !== null) {
$return_url .= self::getItemUrl($item, $is_ss) . PHP_EOL;
}
}
if ($out !== null) {
$return_url .= $out . PHP_EOL;
} else {
foreach ($items as $item) {
$return_url .= self::getItemUrl($item, $is_ss) . PHP_EOL;
}
}
return $return_url;
}
@ -579,7 +326,7 @@ class URL
if ($is_ss == 2) {
$personal_info = $item['method'] . ':' . $item['passwd'] . '@' . $item['address'] . ':' . $item['port'];
$ssurl = 'ss://' . Tools::base64_url_encode($personal_info);
$ssurl .= (Config::get('add_appName_to_ss_uri') === true
$ssurl .= (Config::get('add_appName_to_ss_uri') == 'true'
? '#' . rawurlencode(Config::get('appName') . ' - ' . $item['remark'])
: '#' . rawurlencode($item['remark']));
} else {
@ -601,7 +348,7 @@ class URL
} else {
$ssurl .= '/?group=' . Tools::base64_url_encode(Config::get('appName'));
}
$ssurl .= (Config::get('add_appName_to_ss_uri') === true
$ssurl .= (Config::get('add_appName_to_ss_uri') == 'true'
? '#' . rawurlencode(Config::get('appName') . ' - ' . $item['remark'])
: '#' . rawurlencode($item['remark']));
}
@ -615,7 +362,7 @@ class URL
*
* @return array
*/
public static function getAllV2RayPluginItems($user, $emoji = false)
public static function getAllV2RayPluginItems($user, $emoji = 0)
{
$return_array = array();
if ($user->is_admin) {
@ -654,14 +401,14 @@ class URL
*
* @return array
*/
public static function getV2RayPluginItem($user, $node, $emoji = false)
public static function getV2RayPluginItem($user, $node, $emoji = 0)
{
$return_array = Tools::ssv2Array($node->server);
// 非 AEAD 加密无法使用
if ($return_array['net'] != 'obfs' && !in_array($user->method, Config::getSupportParam('ss_aead_method'))) {
if (!in_array($user->method, Config::getSupportParam('ss_aead_method'))) {
return null;
}
$return_array['remark'] = ($emoji == true
$return_array = Tools::ssv2Array($node->server);
$return_array['remark'] = ($emoji == 1
? Tools::addEmoji($node->name)
: $node->name);
$return_array['address'] = $return_array['add'];
@ -669,35 +416,28 @@ class URL
$return_array['passwd'] = $user->passwd;
$return_array['protocol'] = 'origin';
$return_array['protocol_param'] = '';
if ($return_array['net'] == 'obfs') {
$return_array['obfs_param'] = $user->getMuMd5();
$return_array['obfs'] = 'v2ray';
if ($return_array['tls'] == 'tls' && $return_array['net'] == 'ws') {
$return_array['obfs_param'] = ('mode=ws;security=tls;path=' . $return_array['path'] .
';host=' . $return_array['host']);
} else {
$return_array['obfs'] = 'v2ray';
if ($return_array['tls'] == 'tls' && $return_array['net'] == 'ws') {
$return_array['obfs_param'] = ('mode=ws;security=tls;path=' . $return_array['path'] .
';host=' . $return_array['host']);
} else {
$return_array['obfs_param'] = ('mode=ws;security=none;path=' . $return_array['path'] .
';host=' . $return_array['host']);
}
$return_array['path'] = ($return_array['path'] . '?redirect=' . $user->getMuMd5());
$return_array['obfs_param'] = ('mode=ws;security=none;path=' . $return_array['path'] .
';host=' . $return_array['host']);
}
$return_array['path'] = ($return_array['path'] . '?redirect=' . $user->getMuMd5());
$return_array['class'] = $node->node_class;
$return_array['group'] = Config::get('appName');
$return_array['type'] = 'ss';
$return_array['ratio'] = $node->traffic_rate;
return $return_array;
}
public static function getV2Url($user, $node, $arrout = 0, $emoji = false)
public static function getV2Url($user, $node, $arrout = 0, $emoji = 0)
{
$item = Tools::v2Array($node->server);
$item['v'] = '2';
$item['type'] = 'vmess';
$item['ps'] = ($emoji == true
$item['ps'] = ($emoji == 1
? Tools::addEmoji($node->name)
: $node->name);
$item['remark'] = $item['ps'];
$item['id'] = $user->getUuid();
$item['class'] = $node->node_class;
if ($arrout == 0) {
@ -709,7 +449,7 @@ class URL
return $item;
}
public static function getAllVMessUrl($user, $arrout = 0, $emoji = false)
public static function getAllVMessUrl($user, $arrout = 0, $emoji = 0)
{
if ($user->is_admin) {
$nodes = Node::where(
@ -738,32 +478,6 @@ class URL
->orderBy('name')
->get();
}
# 增加中转配置,后台目前配置user=0的话是自由门直接中转
$tmp_nodes = array();
foreach($nodes as $node){
$tmp_nodes[]=$node;
if ($node->sort==12){
$relay_rule = Relay::where('source_node_id', $node->id)->where(
static function ($query) use ($user) {
$query->Where('user_id', '=',0);
}
)->orderBy('priority', 'DESC')->orderBy('id')->first();
if ($relay_rule != null) {
//是中转起源节点
$tmp_node = $relay_rule->dist_node();
$server = explode(';', $tmp_node->server);
$source_server = Tools::v2Array($node->server);
if (count($server)<6){
$tmp_node->server.=str_repeat(";",6-count($server));
}
$tmp_node->server.="relayserver=".$source_server['add']."|"."outside_port=".$source_server['port'];
$tmp_node->name = $node->name."=>".$tmp_node->name;
$tmp_nodes[]=$tmp_node;
}
}
}
$nodes=$tmp_nodes;
if ($arrout == 0) {
$result = '';
foreach ($nodes as $node) {
@ -842,34 +556,21 @@ class URL
$server['remarks'] = $node->name . ' - 单多' . $server['port'] . '端口';
$server['encryption'] = $user->method;
$server['password'] = $user->passwd;
$server['path'] = '';
$plugin_options = '';
if ($server['net'] == 'obfs') {
$array_all['plugin'] = 'simple-obfs'; //目前只支持这个
if (strpos($server['obfs'], 'http') != false) {
$plugin_options .= 'obfs=http';
}
if (strpos($server['obfs'], 'tls') != false) {
$plugin_options .= 'obfs=tls';
}
$plugin_options .= ';obfs-host=' . $user->getMuMd5();
$server['plugin'] = 'v2ray';
$server['path'] = ($server['path'] . '?redirect=' . $user->getMuMd5());
if ($server['tls'] == 'tls' && $server['net'] == 'ws') {
$server['obfs_param'] = ('mode=ws;security=tls;path=' . $server['path'] .
';host=' . $server['host']);
} else {
$server['plugin'] = 'v2ray';
$server['path'] = ($server['path'] . '?redirect=' . $user->getMuMd5());
if ($server['tls'] == 'tls' && $server['net'] == 'ws') {
$plugin_options .= ('mode=ws;security=tls;path=' . $server['path'] .
';host=' . $server['host']);
} else {
$plugin_options .= ('mode=ws;security=none;path=' . $server['path'] .
';host=' . $server['host']);
}
$server['obfs_param'] = ('mode=ws;security=none;path=' . $server['path'] .
';host=' . $server['host']);
}
$server['plugin_options'] = $plugin_options;
$array_server[] = $server;
$server_index++;
continue;
} else {
$server['server'] = $node->getServer();
$node_server = explode(';', $node->server);
$server['server'] = $node_server[0];
}
$server['id'] = $server_index;
//判断是否是中转起源节点
@ -991,7 +692,7 @@ class URL
* obfs
* obfs_param
*/
public static function getItem($user, $node, $mu_port = 0, $relay_rule_id = 0, $is_ss = 0, $emoji = false)
public static function getItem($user, $node, $mu_port = 0, $relay_rule_id = 0, $is_ss = 0, $emoji = 0)
{
$relay_rule = Relay::where('id', $relay_rule_id)->where(
static function ($query) use ($user) {
@ -1011,35 +712,36 @@ class URL
$mu_user->obfs_param = $user->getMuMd5();
$mu_user->protocol_param = $user->id . ':' . $user->passwd;
$user = $mu_user;
$node_name .= (Config::get('disable_sub_mu_port') ? '' : ' - ' . $mu_port . ' 单端口');
$node_name .= ' - ' . $mu_port . ' 单端口';
}
if ($is_ss) {
if (!self::SSCanConnect($user)) {
return;
}
$user = self::getSSConnectInfo($user);
$return_array['type'] = 'ss';
} else {
if (!self::SSRCanConnect($user)) {
return;
}
$user = self::getSSRConnectInfo($user);
$return_array['type'] = 'ssr';
}
$return_array['address'] = $node->getServer();
$return_array['address'] = $node->server;
$return_array['port'] = $user->port;
$return_array['protocol'] = $user->protocol;
$return_array['protocol_param'] = $user->protocol_param;
$return_array['obfs'] = $user->obfs;
$return_array['obfs_param'] = $user->obfs_param;
if ($mu_port != 0 && strpos($node->server, ';') !== false) {
if (strpos($node->server, ';') !== false) {
$node_tmp = Tools::OutPort($node->server, $node->name, $mu_port);
$return_array['port'] = $node_tmp['port'];
$node_name = $node_tmp['name'];
if ($mu_port != 0) {
$return_array['port'] = $node_tmp['port'];
$node_name = $node_tmp['name'];
}
$return_array['address'] = $node_tmp['address'];
}
$return_array['passwd'] = $user->passwd;
$return_array['method'] = $user->method;
$return_array['remark'] = ($emoji == true
$return_array['remark'] = ($emoji == 1
? Tools::addEmoji($node_name)
: $node_name);
$return_array['class'] = $node->node_class;
@ -1055,4 +757,50 @@ class URL
{
return clone $user;
}
public static function getUserInfo($user, $type, $traffic_class_expire)
{
$return = '';
// 订阅信息
$info_array = (count(Config::get('sub_message')) != 0
? (array) Config::get('sub_message')
: []);
if ($traffic_class_expire !== 0) {
// 用户账户及流量信息
if (strtotime($user->expire_in) > time()) {
if ($user->transfer_enable == 0) {
$info_array[] = '剩余流量:0.00%';
} else {
$info_array[] = '剩余流量:' . number_format(($user->transfer_enable - $user->u - $user->d) / $user->transfer_enable * 100, 2) . '% ' . $user->unusedTraffic();
}
$info_array[] = '过期时间:' . $user->class_expire;
} else {
$info_array[] = '账户已过期,请续费后使用';
}
}
$group_name = Config::get('appName');
foreach ($info_array as $item) {
switch ($type) {
case 'ss':
$return .= 'ss://' . Tools::base64_url_encode('chacha20:breakwall') . '@www.google.com:10086' . '/?group=' . Tools::base64_url_encode($group_name) . '#' . rawurlencode($item) . PHP_EOL;
break;
case 'ssr':
$return .= 'ssr://' . Tools::base64_url_encode('www.google.com:10086:auth_chain_a:chacha20:tls1.2_ticket_auth:YnJlYWt3YWxs/?obfsparam=&protoparam=&remarks=' . Tools::base64_url_encode($item) . '&group=' . Tools::base64_url_encode($group_name)) . PHP_EOL;
break;
case 'v2ray':
$v2ray = ['v' => '2', 'ps' => $item, 'add' => 'www.google.com', 'port' => '10086', 'id' => '2661b5f8-8062-34a5-9371-a44313a75b6b', 'aid' => '2', 'net' => 'tcp', 'type' => 'none', 'host' => '', 'tls' => ''];
$return .= 'vmess://' . base64_encode(json_encode($v2ray, JSON_UNESCAPED_UNICODE)) . PHP_EOL;
break;
case 'quantumult_v2':
$quantumult_v2 = base64_encode($item . ' = vmess, ' . 'www.google.com' . ', ' . '10086' . ', chacha20-ietf-poly1305, "2661b5f8-8062-34a5-9371-a44313a75b6b", group=' . $group_name . '_v2') . PHP_EOL;
$return .= 'vmess://' . base64_encode($quantumult_v2) . PHP_EOL;
break;
}
}
return $return;
}
}

@ -18,9 +18,6 @@ require BASE_PATH.'/vendor/autoload.php';
require BASE_PATH."/config/.config.php";
require BASE_PATH."/config/.malio_config.php";
require BASE_PATH."/config/.i18n.php";
Boot::setDebug();

@ -21,12 +21,11 @@
"chen-see/chen-pay": "^1.0@dev",
"league/omnipay": "^3",
"lokielse/omnipay-alipay": "*",
"khanamiryan/qrcode-detector-decoder": "*"
"charlottedunois/yasmin": "*",
"khanamiryan/qrcode-detector-decoder": "*",
"remotelyliving/php-dns": "3.0.6",
"symfony/yaml": "^4.4@dev",
"irazasyed/telegram-bot-sdk": "^2.0",
"stripe/stripe-php": "7.0.0",
"geoip2/geoip2": "~2.0"
"symfony/yaml": "^4.4@dev"
},
"autoload": {
"psr-4": {

@ -17,7 +17,7 @@ $_ENV['version'] = '1'; //仅当涉及【需要修改config以外的文件】时
//基本设置--------------------------------------------------------------------------------------------
$_ENV['key'] = '1145141919810'; //!!! 瞎 jb 修改此key为随机字符串确保网站安全 !!!
$_ENV['debug'] = false; //正式环境请确保为 false
$_ENV['appName'] = 'Malio'; //站点名称
$_ENV['appName'] = 'sspanel'; //站点名称
$_ENV['baseUrl'] = 'http://url.com'; //站点地址
$_ENV['subUrl'] = $_ENV['baseUrl'] . '/link/'; //订阅地址,如需和站点名称相同,请不要修改
$_ENV['muKey'] = 'default_mu_key'; //用于校验魔改后端请求,可以随意修改,但请保持前后端一致,否则节点不能工作!
@ -31,13 +31,10 @@ $_ENV['db_password'] = 'sspanel'; //用户名对应的密码
$_ENV['newIndex'] = true; //使用新的 Node.js 开发的首页请填写 true,其他值为使用先前的首页,如您使用其他主题请保持 true
$_ENV['checkNodeIp'] = true; //是否webapi验证节点ip
// 订阅中的公告信息
// 使用数组形式,将会添加在订阅列表的顶端
// 可用于为用户推送最新地址等信息,尽可能简短且数量不宜太多
$_ENV['sub_message'] = [];
$_ENV['enable_sub_extend'] = true; // 是否开启订阅中默认显示流量剩余以及账户到期时间以及 sub_message 中的信息
$_ENV['disable_sub_mu_port'] = false; // 将订阅中单端口的信息去除
$_ENV['sub_message'] = [];
//邮件设置--------------------------------------------------------------------------------------------
$_ENV['mailDriver'] = 'none'; //发送邮件方式:none / mailgun / smtp / sendgrid
@ -65,7 +62,7 @@ $_ENV['sendgrid_sender'] = '';
//备份设置--------------------------------------------------------------------------------------------
$_ENV['auto_backup_email'] = ''; //接收备份的邮箱
$_ENV['auto_backup_passwd'] = ''; //备份的压缩密码
$_ENV['backup_notify'] = false; //备份通知到TG群中
$_ENV['backup_notify'] = true; //备份通知到TG群中
//用户注册设置-----------------------------------------------------------------------------------------
@ -121,10 +118,15 @@ $_ENV['port_price_specify'] = -1; //用户指明钦定端口所需要的价格
$_ENV['class_expire_reset_traffic'] = 0; //等级到期时重置为的流量值,单位GB,小于0时不重置
$_ENV['account_expire_delete_days'] = -1; //账户到期几天之后会删除账户,小于0时不删除
$_ENV['enable_kill'] = true; //是否允许用户注销账户
$_ENV['notify_limit_mode'] = false; //false为关闭,per为按照百分比提醒,mb为按照固定剩余流量提醒
$_ENV['notify_limit_mode'] = true; //false为关闭,per为按照百分比提醒,mb为按照固定剩余流量提醒
$_ENV['notify_limit_value'] = 20; //当上一项为per时,此处填写百分比;当上一项为mb时,此处填写流量
$_ENV['mergeSub'] = true; //合并订阅设置 可选项 false / true
$_ENV['class_expire_reset_traffic']=0; //等级到期时重置为的流量值,单位GB,小于0时不重置
$_ENV['account_expire_delete_days']=-1; //账户到期几天之后会删除账户,小于0时不删除
$_ENV['enable_kill']=true; //是否允许用户注销账户
$_ENV['notify_limit_mode'] = false; //false为关闭,per为按照百分比提醒,mb为按照固定剩余流量提醒
$_ENV['notify_limit_value'] = 20; //当上一项为per时,此处填写百分比;当上一项为mb时,此处填写流量
$_ENV['mergeSub'] = false; //合并订阅设置 可选项 false / true,此项在 Rico && GeekQu 仓库已废弃
$_ENV['protocol_specify'] = true; //允许用户自行切换加密、协议、混淆,允许请填写 true,禁止用户自行修改将使用下方配置的方案
$_ENV['keep_connect'] = false; //是否开启用户流量耗尽后降低速率至 1Mbps 而不断网
@ -140,75 +142,28 @@ $_ENV['subscribeLog_keep_days'] = 7; //订阅记录保留天数
//Bot 设置--------------------------------------------------------------------------------------------
#通用
$_ENV['finance_public'] = false; //财务报告是否向群公开
$_ENV['finance_public'] = true; //财务报告是否向群公开
$_ENV['enable_welcome_message'] = true; //机器人发送欢迎消息
# Telegram BOT
$_ENV['use_new_telegram_bot'] = true; //是否使用新的 Telegram Bot
$_ENV['enable_telegram'] = false; //是否开启Telegram Bot
$_ENV['telegram_token'] = ''; //Telegram Bot 的 Token,跟 Father Bot 申请
$_ENV['telegram_bot'] = ''; //Telegram Bot 用户名
$_ENV['telegram_group_quiet'] = false; //Telegram Bot 在群组中不回应
$_ENV['telegram_chatid'] = ''; //Telegram 群组会话 ID,把 Bot 拉进群里之后跟他 /ping 一下即可得到。
$_ENV['telegram_request_token'] = ''; //Telegram 机器人请求验证 Key,随意设置,由大小写英文和数字组成,更新这个参数之后请 php xcat setTelegram
$_ENV['enable_tuling'] = false; //是否开启图灵机器人
$_ENV['tuling_apikey'] = ''; //图灵机器人 API Key
$_ENV['tuling_apisecert'] = ''; //图灵机器人密钥
# Telegram BOT 其他选项
$_ENV['show_group_link'] = false; //在 Bot 菜单中显示加入用户群
$_ENV['telegram_group_link'] = ''; //用户群的链接
$_ENV['group_bound_user'] = false; //仅允许已绑定 Telegram 账户的用户加入 telegram_chatid 设定的群组
$_ENV['allow_to_join_new_groups'] = true; //允许 Bot 加入下方配置之外的群组
$_ENV['group_id_allowed_to_join'] = []; //允许加入的群组 ID,格式为 PHP 数组
$_ENV['telegram_admins'] = []; //Telegram 管理员 ID,格式为 PHP 数组
$_ENV['unbind_kick_member'] = false; //用户解绑 Telegram 账户后自动踢出群组
$_ENV['enable_not_admin_reply'] = true; //非管理员操作管理员功能是否回复
$_ENV['not_admin_reply_msg'] = '!'; //非管理员操作管理员功能的回复内容
$_ENV['no_user_found'] = '!'; //管理员操作时,找不到用户的回复
$_ENV['no_search_value_provided'] = '!'; //管理员操作时,没有提供用户搜索值的回复
$_ENV['data_method_not_found'] = '!'; //管理员操作时,修改数据的字段没有找到的回复
$_ENV['delete_message_time'] = 180; //在以下时间后删除用户命令触发的 bot 回复,单位:秒,删除时间可能会因为定时任务而有差异,为 0 代表不开启此功能
$_ENV['delete_admin_message_time'] = 86400; //在以下时间后删除管理命令触发的 bot 回复,单位:秒,删除时间可能会因为定时任务而有差异,为 0 代表不开启此功能
$_ENV['enable_delete_user_cmd'] = false; //自动删除群组中用户发送的命令,使用 delete_message_time 配置的时间,删除时间可能会因为定时任务而有差异
$_ENV['help_any_command'] = false; //允许任意未知的命令触发 /help 的回复
$_ENV['remark_user_search_email'] = ['邮箱']; //用户搜索字段 email 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_search_port'] = ['端口']; //用户搜索字段 port 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_is_admin'] = ['管理员']; //用户搜索字段 is_admin 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_enable'] = ['用户启用']; //用户搜索字段 enable 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_money'] = ['金钱', '余额']; //用户搜索字段 money 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_port'] = ['端口']; //用户搜索字段 port 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_transfer_enable'] = ['流量']; //用户搜索字段 transfer_enable 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_passwd'] = ['连接密码']; //用户搜索字段 passwd 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_method'] = ['加密']; //用户搜索字段 method 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_protocol'] = ['协议']; //用户搜索字段 protocol 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_protocol_param'] = ['协参', '协议参数']; //用户搜索字段 protocol_param 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_obfs'] = ['混淆']; //用户搜索字段 obfs 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_obfs_param'] = ['混参', '混淆参数']; //用户搜索字段 obfs_param 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_invite_num'] = ['邀请数量']; //用户搜索字段 invite_num 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_node_group'] = ['用户组', '用户分组']; //用户搜索字段 node_group 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_class'] = ['等级']; //用户搜索字段 class 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_class_expire'] = ['等级过期时间']; //用户搜索字段 class_expire 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_expire_in'] = ['账号过期时间']; //用户搜索字段 expire_in 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_node_speedlimit'] = ['限速']; //用户搜索字段 node_speedlimit 的别名,可多个,格式为 PHP 数组
$_ENV['remark_user_option_node_connector'] = ['连接数', '客户端']; //用户搜索字段 node_connector 的别名,可多个,格式为 PHP 数组
$_ENV['enable_user_email_group_show'] = false; //开启在群组搜寻用户信息时显示用户完整邮箱,关闭则会对邮箱中间内容打码,如 g****@gmail.com
$_ENV['user_not_bind_reply'] = '您未绑定本站账号,您可以进入网站的 **资料编辑**,在右下方绑定您的账号.'; //未绑定账户的回复
$_ENV['telegram_general_pricing'] = '产品介绍.'; //面向游客的产品介绍
$_ENV['telegram_general_terms'] = '服务条款.'; //面向游客的服务条款
#Telegram
$_ENV['enable_telegram'] = true; //是否开启Telegram bot
$_ENV['telegram_token'] = ''; //Telegram bot,bot 的 token ,跟 father bot 申请
$_ENV['telegram_chatid'] = ''; //Telegram bot,群组会话 ID,把机器人拉进群里之后跟他 /ping 一下即可得到。
$_ENV['enable_tuling'] = true; //是否开启图灵机器人
$_ENV['tuling_apikey'] = ''; //图灵机器人API Key
$_ENV['tuling_apisecert'] = ''; //图灵机器人密钥
$_ENV['telegram_bot'] = '_bot'; //Telegram 机器人账号
$_ENV['telegram_group_quiet'] = true; //Telegram 机器人在群组中不回应
$_ENV['telegram_request_token'] = ''; //Telegram 机器人请求Key,随意设置,由大小写英文和数字组成,更新这个参数之后请 php xcat setTelegram
//沟通设置--------------------------------------------------------------------------------------------
#客服系统设置,注册地址 https://www.mylivechat.com
#此项在 malio 主题中已被废弃
$_ENV['enable_mylivechat'] = false; //是否开启客服系统
$_ENV['enable_mylivechat'] = true; //是否开启客服系统
$_ENV['mylivechat_id'] = ''; //客服系统ID
# PushBear 基于微信模板的向关注了二维码的用户以微信方式推送消息 https://pushbear.ftqq.com/
$_ENV['usePushBear'] = false; // true 启用 false 禁用
$_ENV['usePushBear'] = true; // true 启用 false 禁用
$_ENV['PushBear_sendkey'] = ''; //请填写您在PushBear获取的sendkey 请仔细检查勿粘贴错
#工单系统设置
@ -216,12 +171,11 @@ $_ENV['enable_ticket'] = true; //是否开启工单系统
$_ENV['mail_ticket'] = true; //是否开启工单邮件提醒
# Server酱 用户提交新工单或者回复工单时用微信提醒机场主 http://sc.ftqq.com/
$_ENV['useScFtqq'] = false; //是否开启工单Server酱提醒
$_ENV['useScFtqq'] = true; //是否开启工单Server酱提醒
$_ENV['ScFtqq_SCKEY'] = ''; //请填写您在Server酱获取的SCKEY 请仔细检查勿粘贴错
#管理员联系方式设置
#此项在 malio 主题中已被废弃,即时通讯请用客服系统
$_ENV['enable_admin_contact']=false; //是否开启管理员联系方式
$_ENV['enable_admin_contact'] = true; //是否开启管理员联系方式
$_ENV['admin_contact1'] = 'QQ:1233456'; //QQ、邮箱、微信仅用于举例
$_ENV['admin_contact2'] = '邮箱123456@qq.com'; //也可以写电话、tg等其他联系方式
$_ENV['admin_contact3'] = '微信~123456'; //没有格式要求,想怎么写就怎么写,可留空
@ -237,34 +191,18 @@ $_ENV['recaptcha_secret'] = '';
$_ENV['geetest_id'] = '';
$_ENV['geetest_key'] = '';
$_ENV['enable_reg_captcha'] = false; //启用注册验证码
$_ENV['enable_login_captcha'] = false; //启用登录验证码
$_ENV['enable_checkin_captcha'] = false; //启用签到验证码
$_ENV['enable_reg_captcha'] = true; //启用注册验证码
$_ENV['enable_login_captcha'] = true; //启用登录验证码
$_ENV['enable_checkin_captcha'] = true; //启用签到验证码
//支付系统设置----------------------------------------------------------------------------------------
#取值 none | codepay | trimepay | f2fpay | chenAlipay | paymentwall | spay | tomatopay | bitpayx | flyfoxpay | payjs | f2fpay_payjs | stripe | payssion | yftpay
# 当此项设置为 malio 时即可使用malio聚合支付系统
$_ENV['payment_system']='none';
# Stripe
$_ENV['stripe_key'] = '';
$_ENV['stripe_webhook_endpoint_secret'] = '';
# wolfpay 以下内容可以在用户中心首页下方取得 (仅在malio聚合支付系统下生效)
$_ENV['wolfpay']=['config'=>[
'hid'=>'商户ID',
'key'=>'商户KEY',
'url'=>'商户API网址'
]];
# payssion
$_ENV['payssion_api_key'] = '';
$_ENV['payssion_secret_key'] = '';
#取值 none | codepay | f2fpay | chenAlipay | paymentwall | spay |tomatopay | payjs | yftpay
$_ENV['payment_system'] = 'none';
#yft支付设置
$_ENV['yft_secret']='';
$_ENV['yft_accesskey']='';
$_ENV['yft_secret'] = '';
$_ENV['yft_accesskey'] = '';
#codepay码支付
#wiki地址:https://goo.gl/dRwRDi http://t.cn/RnsWjtB
@ -279,11 +217,10 @@ $_ENV['merchant_private_key'] = '';
$_ENV['f2fNotifyUrl'] = null; //自定义当面付回调地址
#PaymentWall
#此项在 malio 主题中暂未支持
$_ENV['pmw_publickey']='';
$_ENV['pmw_privatekey']='';
$_ENV['pmw_widget']='m2_1';
$_ENV['pmw_height']='350px';
$_ENV['pmw_publickey'] = '';
$_ENV['pmw_privatekey'] = '';
$_ENV['pmw_widget'] = 'm2_1';
$_ENV['pmw_height'] = '350px';
#alipay,spay
$_ENV['alipay_id'] = '';
@ -291,36 +228,18 @@ $_ENV['alipay_key'] = '';
$_ENV['amount'] = [2, 23, 233, 2333, 23333]; //充值金额选项设定
#alipay,zfbjk.com
#此项在 malio 主题中暂未支持
$_ENV['zfbjk_pid']='';
$_ENV['zfbjk_key']='';
$_ENV['zfbjk_qrcodeurl']='';
$_ENV['zfbjk_pid'] = '';
$_ENV['zfbjk_key'] = '';
$_ENV['zfbjk_qrcodeurl'] = '';
# BitPay 数字货币支付(比特币、以太坊、EOS等) 商户后台获取授权码 https://merchants.mugglepay.com/
# 客服和技术 24x7 在线支持: https://t.me/joinchat/GLKSKhUnE4GvEAPgqtChAQ
$_ENV['bitpay_secret'] = '';
# materialpay
$_ENV['materialpay_appid']=''; //AppID
$_ENV['materialpay_secret']=''; //AppSecret
#PayJs
$_ENV['payjs_mchid'] = '';
$_ENV['payjs_key'] = '';
$_ENV['idtpay']=[
'partner'=>"", //商户号
'key' =>"", //商户key
'sign_type'=>strtoupper('MD5'),
'input_charset'=>strtolower('utf-8'),
'subjects'=>["内存",'手抓饼'], //商品名称
'transport'=>'https' ,//访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
'apiurl'=>'https://pay.idt.xyz/', //http开头
'appname'=>$_ENV['appName'],
];
#tomatopay番茄云支付
#使用教程:https://swapidc.fanqieui.com/?t/329.html tg群 https://t.me/fanqiepay
$_ENV['tomatopay'] = [
@ -337,21 +256,10 @@ $_ENV['tomatopay'] = [
];
# flyfox
$_ENV['flyfoxpay'] = [
'config' => [
'hid'=>'******',
'key'=>'********',
'mail'=>'*******@****.***'
]
];
//其他面板显示设置------------------------------------------------------------------------------------------
#用户文档
#此项在 malio 主题中未被支持
$_ENV['enable_documents'] = false; //是否允许未登陆用户查看文档中心
#用户文
$_ENV['enable_documents'] = true; //是否允许未登陆用户查看文档中心
$_ENV['documents_name'] = $_ENV['appName'] . ' 文档中心'; //文档中心名称
$_ENV['remote_documents'] = true; //是否从远程加载文档中心,否的话请执行 php xcat initdocuments
$_ENV['documents_source'] = 'https://raw.githubusercontent.com/GeekQu/PANEL_DOC/master/GeekQu'; //远程文档加载地址
@ -360,16 +268,13 @@ $_ENV['documents_source'] = 'https://raw.githubusercontent.com/GeekQu/PANEL_DOC/
$_ENV['sales_period'] = 30; //统计指定周期内的销量,值为【expire/任意大于0的整数】
#国旗
#此项在 malio 主题中已被废弃
$_ENV['enable_flag'] = true; //启用该项之前务必先仔细阅读教程
$_ENV['flag_regex'] = '/.*?(?=\s)/'; //从站点全名中匹配【国家/地区】的正则表达式(php版)
#捐赠
#此项在 malio 主题中已被废弃
$_ENV['enable_donate'] = true; //是否显示用户捐赠(所有收入将被公开)
#iOS账户显示
#此项在 malio 主题中已被废弃
$_ENV['display_ios_class'] = -1; //至少等级为多少的用户可以看见,小于0时关闭此功能
$_ENV['display_ios_topup'] = 0; //满足等级要求后,累计充值高于多少的用户可以看见
$_ENV['ios_account'] = ''; //iOS账户
@ -387,7 +292,7 @@ $_ENV['detect_gfw_count'] = '3'; //尝试次数
#离线检测
$_ENV['enable_detect_offline'] = true;
#离线检测是否推送到Server酱 请配置好上文的Server配置
$_ENV['enable_detect_offline_useScFtqq'] = false;
$_ENV['enable_detect_offline_useScFtqq'] = true;
//V2Ray相关设置------------------------------------------------------------------------------------------
@ -407,7 +312,7 @@ $_ENV['sessionDriver'] = 'cookie'; //可选: cookie,redis
$_ENV['cacheDriver'] = 'cookie'; //可选: cookie,redis
$_ENV['tokenDriver'] = 'db'; //可选: db,redis
$_ENV['jump_delay'] = 1200; //跳转延时,单位ms,不建议太长
$_ENV['theme'] = 'malio'; //主题
$_ENV['theme'] = 'material'; //主题
$_ENV['pacp_offset'] = -20000; //VPN 端口偏移
$_ENV['pacpp_offset'] = -20000;
$_ENV['Speedtest_duration'] = 6; //显示多长时间的测速记录
@ -417,15 +322,13 @@ $_ENV['db_charset'] = 'utf8';
$_ENV['db_collation'] = 'utf8_general_ci';
$_ENV['db_prefix'] = '';
$_ENV['muKeyList'] = []; //多 key 列表
$_ENV['subscribe_client'] = false; //下载协议客户端时附带节点和订阅信息
$_ENV['subscribe_client_url'] = ''; //使用独立的服务器提供附带节点和订阅信息的协议客户端下载,为空表示不使用
$_ENV['subscribe_client'] = true; //下载协议客户端时附带节点和订阅信息
$_ENV['muKeyList'] = [' ']; //多 key 列表
$_ENV['mu_port_migration'] = false; //为后端直接下发偏移后的端口
$_ENV['relay_port_migration'] = false; //为中转规则下发偏移后的端口,此项未经测试
$_ENV['add_emoji_to_node_name'] = false; //为部分订阅中默认添加 emoji
$_ENV['add_appName_to_ss_uri'] = true; //为 SS 节点名称中添加站点名
$_ENV['enable_sub_cache'] = false; //订阅信息缓存
$_ENV['sub_cache_time'] = 360; //订阅信息缓存有效时间 (分钟)
$_ENV['sub_cache_max_quantity'] = 15; //每个用户订阅缓存最大数量,请基于磁盘空间考虑
// 审计自动封禁开关
$_ENV['enable_auto_detect_ban'] = false;
@ -454,19 +357,19 @@ $_ENV['auto_detect_ban_time'] = 60;
$_ENV['auto_detect_ban'] = [
100 => [
'type' => 'time',
'time' => 120
'time' => '120'
],
300 => [
'type' => 'time',
'time' => 720
'time' => '720'
],
600 => [
'type' => 'time',
'time' => 4320
'time' => '4320'
],
1000 => [
'type' => 'kill',
'time' => 0
'time' => '0'
]
];
@ -482,7 +385,7 @@ $_ENV['redis_database'] = '';
$_ENV['redis_password']= '';
#Radius设置
$_ENV['enable_radius'] = false; //是否开启Radius
$_ENV['enable_radius'] = true; //是否开启Radius
$_ENV['radius_db_host'] = ''; //以下4项为Radius数据库设置
$_ENV['radius_db_database'] = '';
$_ENV['radius_db_user'] = '';
@ -490,18 +393,96 @@ $_ENV['radius_db_password'] = '';
$_ENV['radius_secret'] = ''; //Radius连接密钥
#Cloudflare
$_ENV['cloudflare_enable'] = false; //是否开启 Cloudflare 解析
$_ENV['cloudflare_enable'] = true; //是否开启 Cloudflare 解析
$_ENV['cloudflare_email'] = 'user@example.com'; //Cloudflare 邮箱地址
$_ENV['cloudflare_key'] = 'c2547eb745079dac9320b638f5e225cf483cc5cfdda41'; //Cloudflare API Key
$_ENV['cloudflare_name'] = 'example.com'; //域名
#不安全中转模式,这个开启之后使用除了 auth_aes128_md5 或者 auth_aes128_sha1 以外的协议地用户也可以设置和使用中转
$_ENV['relay_insecure_mode'] = false; //强烈推荐不开启
$_ENV['relay_insecure_mode'] = true; //强烈推荐不开启
#是否夹带统计代码,自己在 resources/views/{主题名} 下创建一个 analytics.tpl ,如果有必要就用 literal 界定符
$_ENV['enable_analytics_code'] = false;
$_ENV['enable_analytics_code'] = true;
$_ENV['sspanelAnalysis'] = true;
//自定义设置---------------------------------------------------------------------
//是否向 Telegram 群组推送系统今天的运行状况
$_ENV['sendDiary_Telegram'] = true;
//自定义向 Telegram 群组推送系统今天的运行状况的信息
$_ENV['sendDiary_Msg'] = ('各位老爷少奶奶,我来为大家报告一下系统今天的运行状况哈~' . PHP_EOL
. '今日签到人数:%getTodayCheckinUser%' . PHP_EOL
. '今日使用总流量:%lastday_total%' . PHP_EOL
. '晚安~');
//是否向 Telegram 群组推送数据库清理通知
$_ENV['sendDailyJob_Telegram'] = true;
//自定义向 Telegram 群组推送数据库清理通知的信息
$_ENV['sendDailyJob_Msg'] = '姐姐姐姐,数据库被清理了,感觉身体被掏空了呢~';
//是否向 Telegram 群组推送节点掉线通知
$_ENV['sendNodeOffline_Telegram'] = true;
//自定义向 Telegram 群组推送节点掉线已切换通知的信息
$_ENV['sendNodeOffline_Update_Msg'] = '喵喵喵~ %node_name% 节点掉线了喵~域名解析被切换到了 %Temp_node_name% 上了喵~';
//自定义向 Telegram 群组推送节点掉线通知的信息
$_ENV['sendNodeOffline_Msg'] = '喵喵喵~ %node_name% 节点掉线了喵~';
//是否向 Telegram 群组推送节点上线通知
$_ENV['sendNodeOnline_Telegram'] = true;
//自定义向 Telegram 群组推送节点上线已切换通知的信息
$_ENV['sendNodeOnline_Update_Msg'] = '喵喵喵~ %node_name% 节点恢复了喵~域名解析被切换回来了喵~';
//自定义向 Telegram 群组推送节点上线通知的信息
$_ENV['sendNodeOnline_Msg'] = '喵喵喵~ %node_name% 节点恢复了喵~';
//是否向 Telegram 群组推送节点被墙通知
$_ENV['sendNodeGFW_Telegram'] = true;
//自定义向 Telegram 群组推送节点被墙已切换通知的信息
$_ENV['sendNodeGFW_Update_Msg'] = '喵喵喵~ %node_name% 节点被墙了喵~域名解析被切换到了 %Temp_node_name% 上了喵~';
//自定义向 Telegram 群组推送节点被墙通知的信息
$_ENV['sendNodeGFW_Msg'] = '喵喵喵~ %node_name% 节点被墙了喵~';
//是否向 Telegram 群组推送节点被墙恢复通知
$_ENV['sendNodeGFW_recover_Telegram'] = true;
//自定义向 Telegram 群组推送节点被墙恢复已切换通知的信息
$_ENV['sendNodeGFW_recover_Update_Msg'] = '喵喵喵~ %node_name% 节点恢复了喵~域名解析被切换回来了喵~';
//自定义向 Telegram 群组推送节点被墙恢复通知的信息
$_ENV['sendNodeGFW_recover_Msg'] = '喵喵喵~ %node_name% 节点恢复了喵~';
//是否向 Telegram 群组推送节点新增通知
$_ENV['sendAddNode_Telegram'] = true;
//自定义向 Telegram 群组推送节点新增通知的信息
$_ENV['sendAddNode_Msg'] = '新节点添加~ %node_name%';
//是否向 Telegram 群组推送节点修改通知
$_ENV['sendUpdateNode_Telegram'] = true;
//自定义向 Telegram 群组推送节点修改通知的信息
$_ENV['sendUpdateNode_Msg'] = '节点信息被修改~ %node_name%';
//是否向 Telegram 群组推送节点删除通知
$_ENV['sendDeleteNode_Telegram'] = true;
//自定义向 Telegram 群组推送节点删除通知的信息
$_ENV['sendDeleteNode_Msg'] = '节点被删除~ %node_name%';
#在套了CDN之后获取用户真实ip,如果您不知道这是什么,请不要乱动
if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) ) {

File diff suppressed because it is too large Load Diff

@ -1,269 +0,0 @@
<?php
/*
__ __ ______ __ __ ______
/\ '-./ \ /\ __ \ /\ \ /\ \ /\ __ \
\ \ \-./\ \ \ \ __ \ \ \ \____ \ \ \ \ \ \/\ \
\ \_\ \ \_\ \ \_\ \_\ \ \_____\ \ \_\ \ \_____\
\/_/ \/_/ \/_/\/_/ \/_____/ \/_/ \/_____/
made by @editXY
*/
####### 版本信息说明(请勿更改) #######
$Malio_Config['config_migrate_notice'] = '';
$Malio_Config['version'] = '1';
####### 通用设置 #######
$Malio_Config['theme_color'] = 'purple'; // 主题颜色,可选值为 purple, blue, darkblue, orange, pink TODO:(此功能尚在开发中)
$Malio_Config['google_analytics_code'] = 'UA-123456789-1'; // Google 统计代码,留空为不开启,code格式为 'UA-123456789-1'
$Malio_Config['login_style'] = 'wallpaper'; // 登录页面的样式,可选 simple 和 wallpaper
$Malio_Config['enable_landing_page'] = true; // 是否启用着陆页用于介绍本站
$Malio_Config['malio_js_version'] = 'v1'; // 可以随便写,每次更新 malio.js 文件就要改变这个值,用户浏览器就会请求最新的js授权文件,就不会出现缓存的问题
$Malio_Config['small_brand'] = 'ML'; // 侧边栏在缩小状态下显示的 logo 名称,建议写两个英文字母或一个中文汉字
####### 面板设置 #######
$Malio_Config['enable_webapi_ip_verification'] = false; // (此项已废弃,可使用.config.php里面的checkNodeIp) 当节点通过 webapi 连接时,不验证节点IP是否与数据库中的IP相同。关闭此选项会降低安全性。设置为 true 为开启 IP 验证
$Malio_Config['enable_webapi_email_hash'] = true; // 启用后,当节点通过 webapi 连接时,传出去的邮件地址会经过md5加密。
$Malio_Config['reset_bandwidth_and_expire_date_when_change_class'] = false; // 设置为true时,当用户购买与用户当前等级不同的套餐时,重置流量和过期时间。(定制功能)
$Malio_Config['force_user_to_bind_tg_when_join_group'] = true; // 设置为true时,限制只有绑定了tg的用户才能加入群组,如未绑定将会被踢出群组。.config.php 需要设置群组id,机器人在群组中不回应设为false才能用。机器人需要在群里组设定为管理员才能踢人。(定制功能)
$Malio_Config['ip_database'] = 'QQWry'; // IP归属地数据库,可选 QQWry | GeoIP2
$Malio_Config['enable_i18n'] = true; // 是否显示切换语言的按钮
$Malio_Config['default_lang'] = 'zh-cn'; // 面板默认的语言,支持 en | zh-cn
$Malio_Config['only_one_lang'] = 'none'; // 强制使用某种语言,支持 en | zh-cn | none
####### 支付系统 #######
// 支付系统写 none 意味着不启用此收款方式
// 支付宝目前支持 bitpayx | stripe | tomatopay | f2fpay | wolfpay | materialpay
$Malio_Config['mups_alipay'] = 'bitpayx'; // Malio 聚合支付系统里面的 支付宝 要用的支付平台
// 微信支付目前支持 bitpayx | stripe | materialpay
$Malio_Config['mups_wechat'] = 'bitpayx'; // Malio 聚合支付系统里面的 微信支付 要用的支付平台
$Malio_Config['mups_minimum_amount'] = 0; // Malio 聚合支付系统限制最低的充值金额
// 下面的选项在 Malio 聚合支付系统无效
$Malio_Config['stripe_minimum_amount'] = 4; // Stripe 支付接口可充值的最低金额
$Malio_Config['stripe_currency'] = 'usd'; // Stripe 支付接口的默认货币,可以写 hkd usd等,stripe限制了收款货币只能是账号注册地区的货币
$Malio_Config['bitpyax_alipay_type'] = 'ALIPAY'; // bitpayx 支付宝充值的类似,ALIPAY是国内支付宝,ALIGLOBAL是国际支付宝
####### 注册 #######
$Malio_Config['code_required'] = false; // 设置为true时,注册时邀请码是必须的。设置为false时,有无邀请码都可以注册,但是可以填邀请码(aff专用)
$Malio_Config['enable_register_email_restrict'] = true; // 设置为true时,会限制注册时使用的邮箱后缀
$Malio_Config['register_email_white_list'] = ['@gmail.com','@qq.com','@outlook.com','@163.com','@126.com','@yeah.net','@foxmail.com']; // 注册时的邮箱后缀白白白白白白名单,仅在上面的设置为true时生效
$Malio_Config['register_email_black_list'] = ['@bcaoo.com','@chacuo.net','@tmpmail.net','@tmail.ws','@tmpmail.org','@moimoi.re','@bccto.me','@027168.com','@disbox.org','@linshiyouxiang.net','@t.odmail.cn','@tmails.net','@moakt.co','@moakt.ws','@disbox.net','@bareed.ws']; // 注册时的邮箱后缀黑黑黑黑黑黑名单
$Malio_Config['enable_sms_verify'] = false; // 是否启用注册时的短信验证码
$Malio_Config['sms_verify_iplimit'] = '5'; // 单IP限制发送短信验证码的次数
$Malio_Config['globalsent_access_key'] = ''; // GlobalSent 的 api key, https://globalsent.com
$Malio_Config['phone_area_code'] = [ // 发送短信支持的手机区号
'86' => '中国 +86',
'1' => '美国 +1',
'852' => '香港 +852',
'81' => '日本 +81',
'44' => '英国 +44',
'61' => '澳大利亚 +61'
];
####### 订阅设置 #######
$Malio_Config['support_sub_type'] = ['ss','ssr','v2ray']; // 选择网站支持的代理协议,会影响复制订阅链接和一键导入按钮的显示。比如删除这个参数里的ss,则 Surge 订阅按钮不会显示再首页上,教程里也不会显示Surge教程
$Malio_Config['quantumult_mode'] = 'single'; // quantumult 一键导入按钮的模式,可选 "single"或"all"。选择single的话只能导入一种订阅(比如只能导入SSR订阅)。选择all的话可以一次性导入全部订阅类型(SS+SSR+V2RAY),但是导入后需要用户手动更新订阅才会出现节点。
$Malio_Config['quantumult_sub_type'] = 'v2ray'; // quanmutult 的一键导入的订阅类型,可选 ss、ssr、v2ray (仅在quantumult_mode设置为single时生效)
$Malio_Config['enable_copy_urls_to_clipboard'] = true; // 设置为 true 时,首页会显示 批量复制XX链接到剪贴板 的按钮,不建议启用。
$Malio_Config['enable_sub_extend'] = false; // 设置为true时,订阅将包含等级过期时间和流量信息
####### 在线客服系统 #######
// Crisp 设置
$Malio_Config['enable_crisp'] = false; // 是否启用 Crisp 在线客服系统 https://crisp.chat
$Malio_Config['enable_crisp_outside'] = true; // 是否对未登录的用户也启用 Crisp,设置为 false 的话,着陆页和登录/注册等页面不会显示 Crisp,同时对 Chatra 也是生效的
$Malio_Config['crisp_wesite_id'] = '18b46e92-eb21-76d3-bfb7-8f2ae9adba64'; // Crisp 的网站ID,格式为 '18b46e92-eb21-76d3-bfb7-8f2ae9adba64'
// Chatra 设置
$Malio_Config['enable_chatra'] = true; // 是否启用 Chatra 在线客服系统 https://chatra.io
$Malio_Config['chatra_id'] = ''; // Chatra 的 ChatraID,可以在 Chatra 提供的网站代码里找到
####### 侧边栏 #######
$Malio_Config['enable_relay'] = true; // 是否显示中转规则
$Malio_Config['enable_ticket'] = true; // 是否显示工单系统
$Malio_Config['enable_detect'] = true; // 是否显示审计系统
$Malio_Config['enable_invite'] = true; // 是否显示邀请注册
$Malio_Config['enable_wallet'] = true; // 是否显示我的钱包
$Malio_Config['enable_user_sub_log'] = true; // 是否显示用户订阅记录页面
$Malio_Config['enable_share_account_page'] = true; // 是否在侧边栏显示共享账号页面 (定制功能)
$Malio_Config['enable_sidebar_button'] = true; // 是否显示底部 Telegram 按钮
$Malio_Config['telegram_group'] = 'https://t.me/SSUnion'; // Telegram 按钮的链接
$Malio_Config['telegram_group_class'] = 0; // 显示底部 Telegram 按钮的用户最低等级,用户等级小于这个数字的将不会显示 Telegram 按钮
####### 首页 #######
$Malio_Config['enable_index_subinfo'] = true; // 是否在首页显示订阅链接复制或一键导入等按钮
$Malio_Config['index_subinfo_buttons_align'] = false; // 是否开启首页订阅链接按钮的对齐
$Malio_Config['index_show_alert_to_tutorial'] = false; // 首页是否一直显示进入教程的横幅 (此项设置为false后,新用户的首页依旧会显示引导进入教程的横幅)
$Malio_Config['enable_index_popup_ann'] = false; // 是否在用户登录后弹出重要公告
$Malio_Config['enable_index_popup_ann_time'] = false; // 重要公告弹窗是否24小时只弹一次
$Malio_Config['index_popup_ann_content'] = '仅在有重大通知时使用,否则会降低用户体验,可以使用HTML标签'; // 重要公告的内容
// 不在首页显示的一键导入按钮,clash | kitsunebi | quantumult | shadowrocket | v2ray | ss | ssr | ssd | surge | surfboard | copy-ss | copy-ssr | copy-vmess
$Malio_Config['index_hidden_import_buttons'] = ['copy-ss','copy-ssr','ssd','copy-vmess'];
$Malio_Config['enable_share'] = true; // 是否显示共享账号
$Malio_Config['share_account'] = [ // 一个array为一个共享账号
'Netflix' => [ // 这个是账号分类
array(
'name' => 'Netflix 1', // 账号的名字
'account' => 'malio@nintendo.jp', // 账号的登录邮箱啥的
'passwd' => 'yahaha~', // 账号的密码
'class' => 2 // 大于等于此等级的用户才能看到此共享账号
),
array(
'name' => 'Netflix 2',
'account' => 'malio22222@nintendo.jp',
'passwd' => 'yahaha~',
'class' => 2
)
],
'HBO' => [
array(
'name' => 'HBO 1',
'account' => 'malio@nintendo.jp',
'passwd' => 'yahaha~',
'class' => 2
)
],
'Hulu' => [
array(
'name' => 'Hulu 1',
'account' => 'malio@nintendo.jp',
'passwd' => 'yahaha~',
'class' => 1,
)
],
];
$Malio_Config['daily_bonus_mode'] = 'sspanel'; // 签到的模式,填写 sspanel 为原版模式,填写 malio 为不同等级给不同的签到流量
$Malio_Config['daily_bonus_settings'] = array( // 为不同等级给不同的签到流量,仅在 daily_bonus_mode 为 malio 时生效
1 => array( // 用户等级
'min' => 100, // 最低流量,单位为MB
'max' => 200 // 最高流量,单位为MB
),
2 => array(
'min' => 1000,
'max' => 2000
),
3 => array(
'min' => 10000,
'max' => 20000
),
);
####### 商店 #######
$Malio_Config['shop_style'] = 'plans'; // 商店的显示风格, legacy为SSPANEL原版,plans为新版
$Malio_Config['shop_enable_autorenew'] = true; // 商店是否显示自动续费的选项
$Malio_Config['shop_enable_coupon'] = true; // 商店是否显示试用优惠券选项
$Malio_Config['shop_enable_trail_plan'] = true; // 商店是否显示新用户试用选项
$Malio_Config['shop_trail_plan_shopid'] = '12'; // 新用户试用的商品ID
$Malio_Config['index_one_row_plans'] = '3'; // 首页里每行显示多少个会员计划,可以写 3 或 4
$Malio_Config['shop_one_row_plans'] = '3'; // 商店里每行显示多少个会员计划,可以写 3 或 4
// 每个会员计划不同时长所对应的商品ID(商品ID可以在管理面板的商品列表里找到),此项必须设置,不然商店购买功能无法正常工作
// 可以复制 array 增加会员计划,比如增加第四个会员计划,使用 'plan_4' => array(...) 这样的格式
$Malio_Config['plan_shop_id'] = array(
'plan_1' => array(
'1month' => 1,
'3month' => 2,
'6month' => 3,
'12month' => 4,
),
'plan_2' => array(
'1month' => 5,
'3month' => 6,
'6month' => 7,
'12month' => 8,
),
'plan_3' => array(
'1month' => 9,
'3month' => 10,
'6month' => 11,
'12month' => 12,
),
);
$Malio_Config['shop_enable_traffic_package'] = true; // 商店是否显示流量叠加包的选项(仅在用户购买会员计划后才会显示)
$Malio_Config['shop_traffic_packages'] = [ // 商店流量叠加包的详细信息,一个array为一个流量叠加包。在商品列表添加流量包时只需要填写名称、价格、流量,其他参数默认即可
array(
'shopid' => 13, // 流量叠加包的商品ID
'traffic' => 10, // 单位为GB
'price' => 5
),
array(
'shopid' => 14,
'traffic' => 20,
'price' => 9
),
array(
'shopid' => 15,
'traffic' => 30,
'price' => 15
),
];
####### 我的钱包 #######
$Malio_Config['enable_topup_code'] = true; // 是否在我的钱包页面显示充值码充值按钮
$Malio_Config['topup_amount_input_mode'] = 'input'; // 充值金额的输入方式,input 是用户手动输入, select 是用户选择站长设定的固定值进行充值
$Malio_Config['topup_select_list'] = [9.9, 19.9, 29.9]; // 用户只能在这个列表里选择充值金额,只有在 topup_amount_input_mode 设置为 select 的时候有效
####### 我的账号 #######
$Malio_Config['enable_2fa'] = true; // 是否显示二步验证的选项
$Malio_Config['enable_delete'] = true; // 是否显示删除账号的选项
$Malio_Config['enable_telegram'] = true; // 是否显示绑定 Telegram 账号的选项,禁用后登录页面的 “使用 Telegram 登录” 按钮会隐藏
####### 节点列表 #######
$Malio_Config['enable_node_load'] = true; // 是否显示节点的负载
$Malio_Config['enable_online_user'] = true; // 是否显示节点的在线人数
$Malio_Config['enable_node_traffic_rate'] = true; // 是否显示节点的流量倍率
$Malio_Config['enable_node_speedlimit'] = true; // 是否显示节点的限速
$Malio_Config['flag_mode'] = 'node-name'; // 节点列表的国旗取值方式。node-name 为从节点名字前两个字取值(比如美国Vultr取值为美国)。node-info 为从节点状态取值,在节点列表里编辑节点,填写节点状态为 us 则显示美国国旗。us这个是国家ISO 3166码,不懂就谷歌。
$Malio_Config['taiwan_flag'] = 'cn'; // 台湾的旗显示方式,cn为中国国旗,tw为台湾区旗
####### 节点设置 -> 连接设置 #######
$Malio_Config['enable_protocol'] = true; // 是否显示自定义混淆和协议设置
$Malio_Config['enable_method'] = true; // 是否显示自定义加密方式设置
$Malio_Config['enable_reset_port'] = true; // 是否显示重置端口设置,.config.php 里的 port_price (重置端口价格) 为负数的话是不会显示的。
####### 下载和使用 #######
$Malio_Config['display_more_app_button'] = true; // 教程页面是否显示”其他客户端按钮“
$Malio_Config['windows_client'] = 'cfw'; // Windows 教程的首选客户端,可选 cfw, ssr
$Malio_Config['ios_client'] = 'quantumult'; // iOS 教程的首选客户端,可选 quantumult, shadowrocket, kitsunebi
$Malio_Config['ios_sub_type'] = 'v2ray'; // iOS 客户端的一键导入的订阅类型,可选ssr、v2ray
$Malio_Config['enable_ios_apple_id'] = true; // 是否在 iOS 教程页面显示 Apple ID
$Malio_Config['ios_apple_id'] = 'malio@icloud.com'; // iOS 教程页面的 Apple ID 账号
$Malio_Config['ios_apple_id_password'] = '1UPBOY~~'; // iOS 教程页面的 Apple ID 密码
$Malio_Config['android_client'] = 'clash'; // Android 教程的首选客户端,可选 ssr, kitsunebi, v2rayng, surfboard, clash
$Malio_Config['mac_client'] = 'clashx'; // Mac 教程的首选客户端,可选 clashx, shadowsocksx-ng-r
$Malio_Config['linux_client'] = 'clash'; // Linux 教程的首选客户端,可选 clash, electron-ssr
$Malio_Config['enable_faq'] = true; // 是否显示 FAQ 常见问题页面
$Malio_Config['enable_windows_gaming_tutorial'] = true; // 是否启用 Windows 游戏教程 (netch教程)
####### 着陆页设置 #######
// 着陆页文本可以在 .i18n.php 更改
$Malio_Config['index_enable_promotion'] = true; // 着陆页是否显示促销活动提示
$Malio_Config['index_statistics_1_data'] = '100+'; // 着陆页的第1个统计数据(国际节点)
$Malio_Config['index_statistics_2_data'] = '25+'; // 着陆页的第2个统计数据(国家地区)
$Malio_Config['index_statistics_3_data'] = '6500+'; // 着陆页的第3个统计数据(满意用户)

@ -59,11 +59,9 @@ $app->get('/500', App\Controllers\HomeController::class . ':page500');
$app->post('/notify', App\Controllers\HomeController::class . ':notify');
$app->get('/tos', App\Controllers\HomeController::class . ':tos');
$app->get('/staff', App\Controllers\HomeController::class . ':staff');
// New Telegram
$app->post('/TelegramCallback', App\Controllers\HomeController::class . ':NewTelegram');
// Old Telegram
$app->post('/telegram_callback', App\Controllers\HomeController::class . ':telegram');
$app->post('/tomato_back/{type}', 'App\Services\Payment:notify');
$app->get('/tomato_back/{type}', 'App\Services\Payment:notify');
// User Center
$app->group('/user', function () {
@ -150,6 +148,9 @@ $app->group('/user', function () {
// getUserAllURL
$this->get('/getUserAllURL', App\Controllers\UserController::class . ':getUserAllURL');
// getPcClient
$this->get('/getPcClient', App\Controllers\UserController::class . ':getPcClient');
//Reconstructed Payment System
$this->post('/payment/purchase', App\Services\Payment::class . ':purchase');
$this->get('/payment/return', App\Services\Payment::class . ':returnHTML');
@ -158,28 +159,14 @@ $app->group('/user', function () {
$this->post('/payment/bitpay/purchase', App\Services\BitPayment::class . ':purchase');
$this->get('/payment/bitpay/return', App\Services\BitPayment::class . ':returnHTML');
// Malio
$this->get('/money', App\Controllers\UserController::class . ':getmoney');
$this->get('/shop/getplaninfo', App\Controllers\UserController::class . ':getPlanInfo');
$this->get('/shop/getplantime', App\Controllers\UserController::class . ':getPlanTime');
$this->post('/shop/buytrafficpackage', App\Controllers\UserController::class . ':buyTrafficPackage');
$this->get('/share-account', App\Controllers\UserController::class . ':share_account');
$this->post('/api/change-lang', App\Controllers\UserController::class . ':changeLang');
$this->get('/qrcode', App\Controllers\UserController::class . ':qrcode');
// getPcClient
$this->get('/getPcClient', App\Controllers\UserController::class . ':getPcClient');
// CleanSubCache
$this->get('/cleanSubCache', App\Controllers\UserController::class . ':cleanSubCache');
})->add(new Auth());
$app->group('/payment', function () {
$this->get('/notify', App\Services\Payment::class . ':notify');
$this->post('/notify', App\Services\Payment::class . ':notify');
$this->get('/notify/{type}', App\Services\Payment::class . ':notify');
$this->post('/notify/{type}', App\Services\Payment::class . ':notify');
$this->get('/notify/{type}/{method}', App\Services\Payment::class . ':notify');
$this->post('/notify/{type}/{method}', App\Services\Payment::class . ':notify');
$this->post('/status', App\Services\Payment::class . ':getStatus');
$this->post('/bitpay/notify', App\Services\BitPayment::class . ':notify');
@ -195,7 +182,6 @@ $app->group('/auth', function () {
$this->get('/register', App\Controllers\AuthController::class . ':register');
$this->post('/register', App\Controllers\AuthController::class . ':registerHandle');
$this->post('/send', App\Controllers\AuthController::class . ':sendVerify');
$this->post('/sendsms', App\Controllers\AuthController::class . ':sendSMS');
$this->get('/logout', App\Controllers\AuthController::class . ':logout');
$this->get('/telegram_oauth', App\Controllers\AuthController::class . ':telegram_oauth');
$this->get('/login_getCaptcha', App\Controllers\AuthController::class . ':getCaptcha');
@ -319,11 +305,6 @@ $app->group('/admin', function () {
$this->post('/user/create', App\Controllers\Admin\UserController::class . ':createNewUser');
$this->post('/user/buy', App\Controllers\Admin\UserController::class . ':buy');
$this->get('/user/{id}/bought', App\Controllers\Admin\UserController::class . ':bought');
$this->post('/user/{id}/bought/ajax', App\Controllers\Admin\UserController::class . ':bought_ajax');
$this->delete('/user/bought', App\Controllers\Admin\UserController::class . ':bought_delete');
$this->post('/user/{id}/bought/buy', App\Controllers\Admin\UserController::class . ':bought_add');
$this->get('/coupon', App\Controllers\AdminController::class . ':coupon');
$this->post('/coupon', App\Controllers\AdminController::class . ':addCoupon');
@ -336,21 +317,6 @@ $app->group('/admin', function () {
$this->get('/sys', App\Controllers\AdminController::class . ':sys');
$this->get('/logout', App\Controllers\AdminController::class . ':logout');
$this->post('/payback/ajax', App\Controllers\AdminController::class . ':ajax_payback');
// stats
$this->get('/api/analytics/income', App\Controllers\AdminController::class . ':getIncome');
$this->get('/api/analytics/new-users', App\Controllers\AdminController::class . ':newUsers');
// CleanSubCache
$this->get('/user/{id}/cleanSubCache', App\Controllers\Admin\UserController::class . ':cleanSubCache');
// Config Mange
$this->group('/config', function () {
$this->get('/telegram', App\Controllers\Admin\GConfigController::class . ':telegram');
$this->post('/telegram/ajax', App\Controllers\Admin\GConfigController::class . ':telegram_ajax');
$this->get('/telegram/{key}/edit', App\Controllers\Admin\GConfigController::class . ':telegram_edit');
$this->put('/telegram/{key}', App\Controllers\Admin\GConfigController::class . ':telegram_update');
});
})->add(new Admin());
// mu
@ -383,9 +349,6 @@ $app->group('/res', function () {
$this->get('/captcha/{id}', App\Controllers\ResController::class . ':captcha');
});
$app->group('/getClient', function () {
$this->get('/{token}', App\Controllers\UserController::class . ':getClientfromToken');
});
$app->group('/link', function () {
$this->get('/{token}', App\Controllers\LinkController::class . ':GetContent');
@ -440,19 +403,5 @@ $app->group('/doc', function () {
$app->get('/sublink', App\Controllers\HomeController::class . ':getSubLink');
//doc end
// tmtpay
$app->post('/tomato_back/{type}', 'App\Services\Payment:notify');
$app->get('/tomato_back/{type}', 'App\Services\Payment:notify');
// end of tmtpay
// flyfoxpay
$app->post('/flyfoxpay_back/{type}', 'App\Services\Payment:notify');
$app->get('/flyfoxpay_back/{type}', 'App\Services\Payment:notify');
// end of flyfox
// wolfpay
$app->post('/wolfpay_back/{type}', 'App\Services\Payment:notify');
$app->get('/wolfpay_back/{type}', 'App\Services\Payment:notify');
// Run Slim Routes for App
$app->run();

@ -1,152 +0,0 @@
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
<meta name="theme-color" content="#4285f4">
<title>{$config["appName"]}</title>
<!-- css -->
<link href="/theme/material/css/base.min.css" rel="stylesheet">
<link href="/theme/material/css/project.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/material-design-lite@1.1.0/dist/material.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/gh/DataTables/DataTables@1.10.19/media/css/dataTables.material.min.css"
rel="stylesheet">
<!-- js -->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1"></script>
<!-- favicon -->
<!-- ... -->
<style>
body {
position: relative;
}
.table-responsive {
background: white;
}
.dropdown-menu.dropdown-menu-right a {
color: #212121;
}
a[href='#ui_menu'] {
color: #212121;
}
</style>
</head>
<body class="page-brand">
<header class="header header-red header-transparent header-waterfall ui-header">
<ul class="nav nav-list pull-left">
<div>
<a data-toggle="menu" href="#ui_menu">
<span class="icon icon-lg">menu</span>
</a>
</div>
</ul>
<ul class="nav nav-list pull-right">
<div class="dropdown margin-right">
<a class="dropdown-toggle padding-left-no padding-right-no" data-toggle="dropdown">
{if $user->isLogin}
<span class="access-hide">{$user->user_name}</span>
<span class="avatar avatar-sm"><img src="/theme/material/images/users/avatar-001.jpg"></span>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li>
<a class="waves-attach" href="/user/"><span class="icon icon-lg margin-right">account_box</span>用户中心</a>
</li>
<li>
<a class="waves-attach" href="/user/logout"><span
class="icon icon-lg margin-right">exit_to_app</span>登出</a>
</li>
</ul>
{else}
<span class="access-hide">未登录</span>
<span class="avatar avatar-sm"><img src="/theme/material/images/users/avatar-001.jpg"></span>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li>
<a class="waves-attach" href="/auth/login"><span
class="icon icon-lg margin-right">account_box</span>登录</a>
</li>
<li>
<a class="waves-attach" href="/auth/register"><span
class="icon icon-lg margin-right">pregnant_woman</span>注册</a>
</li>
</ul>
{/if}
</div>
</ul>
</header>
<nav aria-hidden="true" class="menu menu-left nav-drawer nav-drawer-md" id="ui_menu" tabindex="-1">
<div class="menu-scroll">
<div class="menu-content">
<a class="menu-logo" href="/"><i class="icon icon-lg">person_pin</i>&nbsp;管理面板</a>
<ul class="nav">
<li>
<a class="waves-attach" data-toggle="collapse" href="#ui_menu_me">我的</a>
<ul class="menu-collapse collapse in" id="ui_menu_me">
<li><a href="/admin"><i class="icon icon-lg">business_center</i>&nbsp;系统概览</a></li>
<li><a href="/admin/announcement"><i class="icon icon-lg">announcement</i>&nbsp;公告管理</a></li>
<li><a href="/admin/ticket"><i class="icon icon-lg">question_answer</i>&nbsp;工单管理</a></li>
<li><a href="/admin/auto"><i class="icon icon-lg">flash_auto</i>&nbsp;下发命令</a></li>
</ul>
<a class="waves-attach" data-toggle="collapse" href="#ui_menu_node">节点</a>
<ul class="menu-collapse collapse in" id="ui_menu_node">
<li><a href="/admin/node"><i class="icon icon-lg">router</i>&nbsp;节点列表</a></li>
<li><a href="/admin/trafficlog"><i class="icon icon-lg">traffic</i>&nbsp;流量记录</a></li>
<li><a href="/admin/block"><i class="icon icon-lg">dialer_sip</i>&nbsp;已封禁IP</a></li>
<li><a href="/admin/unblock"><i class="icon icon-lg">dialer_sip</i>&nbsp;已解封IP</a></li>
</ul>
<a class="waves-attach" data-toggle="collapse" href="#ui_menu_user">用户</a>
<ul class="menu-collapse collapse in" id="ui_menu_user">
<li><a href="/admin/user"><i class="icon icon-lg">supervisor_account</i>&nbsp;用户列表</a></li>
<li><a href="/admin/relay"><i class="icon icon-lg">compare_arrows</i>&nbsp;中转规则</a></li>
<li><a href="/admin/invite"><i class="icon icon-lg">loyalty</i>&nbsp;邀请与返利</a></li>
{if $config['subscribeLog']===true}
<li><a href="/admin/subscribe"><i class="icon icon-lg">dialer_sip</i>&nbsp;订阅记录</a></li>
{/if}
<li><a href="/admin/login"><i class="icon icon-lg">text_fields</i>&nbsp;登录记录</a></li>
<li><a href="/admin/alive"><i class="icon icon-lg">important_devices</i>&nbsp;在线IP</a></li>
</ul>
<a class="waves-attach" data-toggle="collapse" href="#ui_menu_config">配置</a>
<ul class="menu-collapse collapse in" id="ui_menu_config">
<li><a href="/admin/config/telegram"><i class="icon icon-lg">supervisor_account</i>&nbsp;Telegram</a></li>
</ul>
<a class="waves-attach" data-toggle="collapse" href="#ui_menu_detect">审计</a>
<ul class="menu-collapse collapse in" id="ui_menu_detect">
<li><a href="/admin/detect"><i class="icon icon-lg">account_balance</i>&nbsp;审计规则</a></li>
<li><a href="/admin/detect/log"><i class="icon icon-lg">assignment_late</i>&nbsp;审计记录</a></li>
<li><a href="/admin/detect/ban"><i class="icon icon-lg">text_fields</i>&nbsp;审计封禁</a></li>
</ul>
<a class="waves-attach" data-toggle="collapse" href="#ui_menu_trade">交易</a>
<ul class="menu-collapse collapse in" id="ui_menu_trade">
<li><a href="/admin/code">
<i class="icon icon-lg">code</i>
&nbsp;{if $config['enable_donate']===true}充值与捐赠记录{else}充值记录{/if}</a>
</li>
<li><a href="/admin/shop"><i class="icon icon-lg">shop</i>&nbsp;商品</a></li>
<li><a href="/admin/coupon"><i class="icon icon-lg">card_giftcard</i>&nbsp;优惠码</a></li>
<li><a href="/admin/bought"><i class="icon icon-lg">shopping_cart</i>&nbsp;购买记录</a></li>
{if $config['payment_system']=='chenAlipay'}
<li><a href="/admin/editConfig"><i class="icon icon-lg">shopping_cart</i>&nbsp;支付设置</a></li>
{/if}
</ul>
<li><a href="/user"><i class="icon icon-lg">person</i>&nbsp;用户中心</a></li>
</ul>
</div>
</div>
</nav>

@ -1,18 +0,0 @@
可以使用download.sh脚本自动下载的客户端:
Clash-Windows.7z
Clash-Windows.exe
ClashX.dmg
ss-android.apk
ss-win.zip
ss-mac.zip
ssd-android.apk
ssd-win.7z
ssrr-android.apk
v2rayng.apk
需要手动下载的客户端:
kitsunebi.apk
surfboard.apk
ssr.7z
netch.7z
clash-for-android.apk

@ -1,166 +0,0 @@
#!/bin/bash
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
git clone https://github.com/xcxnig/ssr-download.git deploy
# Clash for Windows
echo "==========================================================================="
echo "* Clash for Windows"
echo "https://github.com/Fndroid/clash_for_windows_pkg"
clash_for_windows_pkg_version=$(get_latest_release "Fndroid/clash_for_windows_pkg")
echo "Latest Verison: $clash_for_windows_pkg_version"
mkdir -p Clash-Windows
wget -o /dev/null -O Clash-Windows/Clash.for.Windows.Setup.$clash_for_windows_pkg_version.exe "https://github.com/Fndroid/clash_for_windows_pkg/releases/download/$clash_for_windows_pkg_version/Clash.for.Windows.Setup.$clash_for_windows_pkg_version.exe"
7za a Clash-Windows.7z ./Clash-Windows/*
[ -d "Clash-Windows.7z" ] && mv -f Clash-Windows.7z ./deploy/Clash-Windows.7z
rm -rf Clash-Windows
sleep 35
# clashX(macOS)
echo "==========================================================================="
echo "* ClashX (for macOS)"
echo "https://github.com/yichengchen/clashX"
clashx_version=$(get_latest_release "yichengchen/clashX")
echo "Latest Verison: $clashx_version"
wget -o /dev/null -O ClashX.dmg "https://github.com/yichengchen/clashX/releases/download/$clashx_version/ClashX.dmg"
[ -d "ClashX.dmg" ] && mv -f ClashX.dmg ./deploy/ClashX.dmg
sleep 35
# Shadowsocks Android
echo "==========================================================================="
echo "* Shadowsocks Android"
echo "https://github.com/shadowsocks/shadowsocks-android"
ss_android_version=$(get_latest_release "shadowsocks/shadowsocks-android" | sed 's|v||g')
echo "Latest Verison: $ss_android_version"
wget -o /dev/null -O ss-android.apk "https://github.com/shadowsocks/shadowsocks-android/releases/download/v$ss_android_version/shadowsocks--universal-$ss_android_version.apk"
[ -d "ss-android.apk" ] && mv -f ss-android.apk ./deploy/ss-android.apk
sleep 35
# Shadowsocks Windows
echo "==========================================================================="
echo "* Shadowsocks Windows"
echo "https://github.com/shadowsocks/shadowsocks-windows"
ss_windows_version=$(get_latest_release "shadowsocks/shadowsocks-windows")
echo "Latest Verison: $ss_windows_version"
wget -o /dev/null -O ss-win.zip "https://github.com/shadowsocks/shadowsocks-windows/releases/download/$ss_windows_version/Shadowsocks-$ss_windows_version.zip"
[ -d "ss-win.zip" ] && mv -f ss-win.zip ./deploy/ss-win.zip
sleep 35
# ShadowsocksX-NG
echo "==========================================================================="
echo "* ShadowsocksX-NG (macOS)"
echo "https://github.com/shadowsocks/ShadowsocksX-NG"
ss_mac_version=$(get_latest_release "shadowsocks/ShadowsocksX-NG" | sed 's|v||g')
echo "Latest Verison: $ss_mac_version"
wget -o /dev/null -O ss-mac.zip "https://github.com/shadowsocks/ShadowsocksX-NG/releases/download/v$ss_mac_version/ShadowsocksX-NG.app.$ss_mac_version.zip"
[ -d "ss-mac.zip" ] && mv -f ss-mac.zip ./deploy/ss-mac.zip
sleep 35
# ShadowsocksD Android
echo "==========================================================================="
echo "* ShadowsocksD Android"
echo "https://github.com/TheCGDF/SSD-Android"
ssd_android_version=$(get_latest_release "TheCGDF/SSD-Android")
echo "Latest Verison: $ssd_android_version"
wget -o /dev/null -O ssd-android.apk "https://github.com/TheCGDF/SSD-Android/releases/download/$ssd_android_version/shadowsocksd_$ssd_android_version.apk"
[ -d "ssd-android.apk" ] && mv -f ssd-android.apk ./deploy/ssd-android.apk
sleep 35
# ShadowsocksD Windows
echo "==========================================================================="
echo "* ShadowsocksD Windows"
echo "https://github.com/TheCGDF/SSD-Windows"
ssd_windows_version=$(get_latest_release "TheCGDF/SSD-Windows")
echo "Latest Verison: $ssd_windows_version"
mkdir -p SSD-Windows
wget -o /dev/null -O ssd-win.zip "https://github.com/TheCGDF/SSD-Windows/releases/download/$ssd_windows_version/Shadowsocks-$ssd_windows_version.zip"
unzip ssd-win.zip
rm -rf ssd-win.zip
7za a ssd-win.7z ShadowsocksD.exe
[ -d "ssd-win.7z" ] && mv -f ssd-win.7z ./deploy/ssd-win.7z
sleep 35
# ShadowsocksRR Android
echo "==========================================================================="
echo "* ShadowsocksRR Android"
echo "https://github.com/shadowsocksrr/shadowsocksr-android"
ssrr_android_version=$(get_latest_release "shadowsocksrr/shadowsocksr-android")
echo "Latest Verison: $ssrr_android_version"
wget -o /dev/null -O ssrr-android.apk "https://github.com/shadowsocksrr/shadowsocksr-android/releases/download/$ssrr_android_version/shadowsocksr-android-$ssrr_android_version.apk"
[ -d "ssrr-android.apk" ] && mv -f ssrr-android.apk ./deploy/ssrr-android.apk
sleep 35
# V2RayNG
echo "==========================================================================="
echo "* V2RayNG (Android)"
echo "https://github.com/2dust/v2rayNG"
v2rayng_android_version=$(get_latest_release "2dust/v2rayNG")
echo "Latest Verison: $v2rayng_android_version"
wget -o /dev/null -O v2rayng.apk "https://github.com/2dust/v2rayNG/releases/download/$v2rayng_android_version/app-universal-release.apk"
[ -d "v2rayng.apk" ] && mv -f v2rayng.apk ./deploy/v2rayng.apk

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,63 +0,0 @@
body.skin-reverse.sidebar-mini .main-sidebar:after {
background-color: color(primary); }
body.skin-reverse.sidebar-mini .main-sidebar .sidebar-menu li.active > a {
background-color: #fff;
box-shadow: none;
color: color(primary); }
body.skin-reverse.sidebar-mini .main-sidebar .sidebar-menu li.active ul.dropdown-menu li a,
body.skin-reverse.sidebar-mini .main-sidebar .sidebar-menu li ul.dropdown-menu li a {
background-color: transparent;
color: color_lighten(font, 10%); }
body.skin-reverse.sidebar-mini .main-sidebar .sidebar-menu li.active ul.dropdown-menu li a:hover,
body.skin-reverse.sidebar-mini .main-sidebar .sidebar-menu li ul.dropdown-menu li a:hover {
background-color: color_lighten(light, 7.6%);
color: color(dark); }
body.skin-reverse.sidebar-mini .main-sidebar .sidebar-menu li.active ul.dropdown-menu li.active a,
body.skin-reverse.sidebar-mini .main-sidebar .sidebar-menu li ul.dropdown-menu li.active a {
background-color: transparent !important;
color: color(primary); }
body.skin-reverse .main-sidebar {
background-color: color(primary); }
body.skin-reverse .main-sidebar .sidebar-brand a {
color: #fff; }
body.skin-reverse .main-sidebar .sidebar-menu li a {
color: color_lighten(primary, 25%); }
body.skin-reverse .main-sidebar .sidebar-menu li a:hover {
background-color: #6070e5; }
body.skin-reverse .main-sidebar .sidebar-menu li.active a,
body.skin-reverse .main-sidebar .sidebar-menu li.active a:hover,
body.skin-reverse .main-sidebar .sidebar-menu li.active ul.dropdown-menu li a:hover,
body.skin-reverse .main-sidebar .sidebar-menu li.active ul.dropdown-menu li a {
background-color: #6070e5; }
body.skin-reverse .main-sidebar .sidebar-menu li.menu-header {
color: #afb7ff; }
body.skin-reverse .main-sidebar .sidebar-menu li ul.dropdown-menu li a {
color: color_lighten(primary, 25%); }
body.skin-reverse .main-sidebar .sidebar-menu li ul.dropdown-menu li a:hover {
background-color: color(primary);
color: #fff; }
body.skin-reverse .main-sidebar .sidebar-menu li ul.dropdown-menu li.active a {
color: #fff; }
body.skin-reverse .navbar-bg,
body.skin-reverse .navbar {
background-color: #fff; }
body.skin-reverse .navbar-bg .nav-link.nav-link-user,
body.skin-reverse .navbar-bg .nav-link,
body.skin-reverse .navbar .nav-link.nav-link-user,
body.skin-reverse .navbar .nav-link {
color: #000; }
body.skin-reverse .navbar-bg .nav-link.nav-link-user:hover,
body.skin-reverse .navbar-bg .nav-link:hover,
body.skin-reverse .navbar .nav-link.nav-link-user:hover,
body.skin-reverse .navbar .nav-link:hover {
color: #1a1a1a; }
body.skin-reverse .navbar-bg .form-inline .btn,
body.skin-reverse .navbar-bg .form-inline .form-control,
body.skin-reverse .navbar .form-inline .btn,
body.skin-reverse .navbar .form-inline .form-control {
background-color: color_lighten(primary, 31.5%); }

@ -1,399 +0,0 @@
@charset "UTF-8";
/**
* Stisla
*
* Stisla is a clean & modern HTML5 admin template based on Bootstrap 4.
* Stisla will make it easier for you to create your own admin interface.
*
* @package Stisla
* @version 2.3.0
* @author Muhamad Nauval Azhar & Team
* @url https://getstisla.com
*
*/
@font-face {
font-family: Vazir;
src: url("../fonts/vazir/Vazir.eot");
src: url("../fonts/vazir/Vazir.eot?#iefix") format("embedded-opentype"), url("../fonts/vazir/Vazir.woff2") format("woff2"), url("../fonts/vazir/Vazir.woff") format("woff"), url("../fonts/vazir/Vazir.ttf") format("truetype");
font-weight: normal;
font-style: normal; }
@font-face {
font-family: Vazir;
src: url("../fonts/vazir/Vazir-Bold.eot");
src: url("../fonts/vazir/Vazir-Bold.eot?#iefix") format("embedded-opentype"), url("../fonts/vazir/Vazir-Bold.woff2") format("woff2"), url("../fonts/vazir/Vazir-Bold.woff") format("woff"), url("../fonts/vazir/Vazir-Bold.ttf") format("truetype");
font-weight: bold;
font-style: normal; }
@font-face {
font-family: Vazir;
src: url("../fonts/vazir/Vazir-Black.eot");
src: url("../fonts/vazir/Vazir-Black.eot?#iefix") format("embedded-opentype"), url("../fonts/vazir/Vazir-Black.woff2") format("woff2"), url("../fonts/vazir/Vazir-Black.woff") format("woff"), url("../fonts/vazir/Vazir-Black.ttf") format("truetype");
font-weight: 900;
font-style: normal; }
@font-face {
font-family: Vazir;
src: url("../fonts/vazir/Vazir-Medium.eot");
src: url("../fonts/vazir/Vazir-Medium.eot?#iefix") format("embedded-opentype"), url("../fonts/vazir/Vazir-Medium.woff2") format("woff2"), url("../fonts/vazir/Vazir-Medium.woff") format("woff"), url("../fonts/vazir/Vazir-Medium.ttf") format("truetype");
font-weight: 500;
font-style: normal; }
@font-face {
font-family: Vazir;
src: url("../fonts/vazir/Vazir-Light.eot");
src: url("../fonts/vazir/Vazir-Light.eot?#iefix") format("embedded-opentype"), url("../fonts/vazir/Vazir-Light.woff2") format("woff2"), url("../fonts/vazir/Vazir-Light.woff") format("woff"), url("../fonts/vazir/Vazir-Light.ttf") format("truetype");
font-weight: 300;
font-style: normal; }
@font-face {
font-family: Vazir;
src: url("../fonts/vazir/Vazir-Thin.eot");
src: url("../fonts/vazir/Vazir-Thin.eot?#iefix") format("embedded-opentype"), url("../fonts/vazir/Vazir-Thin.woff2") format("woff2"), url("../fonts/vazir/Vazir-Thin.woff") format("woff"), url("../fonts/vazir/Vazir-Thin.ttf") format("truetype");
font-weight: 100;
font-style: normal; }
body, html {
direction: rtl;
font-family: Vazir, Tahoma, Arial; }
.ltr {
direction: ltr; }
.rtl {
direction: rtl; }
h1, h2, h3, h4, h5, h6, p, a, span, input, textarea, select, option, label {
font-family: Vazir, Tahoma, Arial; }
.main-sidebar {
right: 0;
left: auto; }
.main-content {
padding-right: 280px;
padding-left: 30px; }
.section .section-header {
font: normal normal 24px "IRANSans Bold"; }
.section .section-header div {
float: right; }
.navbar-expand-lg .navbar-nav {
padding-right: 0px; }
body.sidebar-mini .main-sidebar:after {
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.03);
content: " ";
position: fixed;
width: 65px;
height: 100%;
left: auto;
right: 0;
top: 0;
z-index: -1;
opacity: 0;
-webkit-animation-name: mini-sidebar;
animation-name: mini-sidebar;
-webkit-animation-duration: 1.5s;
animation-duration: 1.5s;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards; }
.dropdown-toggle::after {
display: inline-block;
width: 0;
height: 0;
margin-left: .255em;
vertical-align: .255em;
content: "";
border-top: .3em solid;
border-left: .4em solid transparent;
border-bottom: 0;
border-right: .4em solid transparent;
padding: 0px;
margin-right: 3px; }
.main-sidebar .sidebar-menu li ul.dropdown-menu li a {
padding-left: auto !important;
padding-right: 65px; }
body:not(.sidebar-mini) .sidebar-style-2 .sidebar-menu li.active ul.dropdown-menu li a {
padding-left: 0; }
body.sidebar-mini .main-sidebar .sidebar-menu > li ul.dropdown-menu {
left: auto;
right: 65px; }
body.layout-2 .main-sidebar .sidebar-menu li a.has-dropdown::after {
left: 0;
right: auto; }
body:not(.sidebar-mini) .sidebar-style-2 .sidebar-menu > li.active > a::before {
right: 0; }
body.layout-2 .main-content {
padding-top: 107px;
padding-right: 30px;
padding-left: 0;
width: calc(100% - 200px); }
body.layout-2 .main-sidebar .sidebar-menu li ul.dropdown-menu li a {
padding-right: 34px;
padding-left: 0; }
.main-sidebar .sidebar-menu li a.has-dropdown::after {
left: 20px;
right: auto; }
body.sidebar-mini .navbar {
right: 65px;
left: 0px; }
body.sidebar-mini .main-content, body.sidebar-mini .main-footer {
padding-right: 90px;
padding-left: 30px; }
body.layout-2 .main-footer {
margin-right: 230px;
width: calc(100% - 230px);
padding-right: 20px; }
.main-sidebar .sidebar-menu li {
text-align: right; }
.navbar {
right: 250px;
left: 0px; }
.progress {
direction: ltr; }
.btn.btn-icon-split i, .dropdown-item.has-icon i, .btn.btn-icon-split i, .dropdown-item.has-icon i {
text-align: center;
width: 15px;
font-size: 15px;
float: right;
margin-right: 10px; }
.dropdown-list .dropdown-list-icons .dropdown-item .dropdown-item-desc {
margin-right: 15px;
margin-left: 0; }
body.layout-2 .navbar {
right: 0; }
.main-sidebar .sidebar-menu li a i {
float: right;
margin-left: 15px !important;
text-align: center; }
a:not(.btn-social-icon):not(.btn-social):not(.page-link) .ion, a:not(.btn-social-icon):not(.btn-social):not(.page-link) .fas, a:not(.btn-social-icon):not(.btn-social):not(.page-link) .far, a:not(.btn-social-icon):not(.btn-social):not(.page-link) .fal, a:not(.btn-social-icon):not(.btn-social):not(.page-link) .fab {
margin: 4px; }
.dropdown-list .dropdown-item .dropdown-item-avatar {
float: right; }
.dropdown-list .dropdown-item .dropdown-item-desc {
margin-right: 60px;
margin-left: 0; }
.main-sidebar .sidebar-menu li a.has-dropdown::after {
float: left; }
body.sidebar-gone .main-sidebar {
right: -250px; }
body.sidebar-gone .main-content {
padding-right: 30px; }
body.sidebar-gone .navbar {
right: 0; }
.card.card-sm-3 .card-icon, .card.card-sm-4 .card-icon {
float: right;
margin-left: 15px;
margin-right: 10px; }
.card.card-sm .card-icon {
float: right;
text-align: left;
padding-left: 15px; }
.card.card-sm .card-options {
float: left;
margin-left: 20px; }
.card.card-sm .card-wrap {
margin-right: 30px;
margin-left: 15px; }
.card.card-sm-2 .card-icon {
left: 20px;
right: auto; }
.main-sidebar .sidebar-menu li a .badge {
float: left; }
.card .card-header h4 + .card-header-action, .card .card-header h4 + .card-header-form {
margin-right: auto;
margin-left: 0px; }
.card .card-header h4 + .card-header-action .btn-group .btn:first-child, .card .card-header h4 + .card-header-form .btn-group .btn:first-child {
border-radius: 0 30px 30px 0 !important; }
.list-unstyled-border li .custom-checkbox {
margin-left: 15px;
margin-right: 0; }
.card.card-statistic-1 .card-icon, .card.card-statistic-2 .card-icon {
float: right; }
.form-group label {
font-weight: normal;
font-family: Vazir, Tahoma, Arial;
letter-spacing: 0; }
.dropdown-list .dropdown-header {
letter-spacing: 0;
overflow: hidden; }
.media .media-left {
float: left;
font-weight: 600;
font-size: 16px; }
.card.card-sm-3 .card-header h4, .card.card-sm-4 .card-header h4 {
letter-spacing: 0;
font-family: Vazir, Tahoma, Arial; }
.main-sidebar .sidebar-user .sidebar-user-picture {
float: right;
margin-left: 10px; }
.main-footer {
font-family: Vazir, Tahoma, Arial;
padding: 20px 280px 20px 30px;
font-size: 90%;
border-top: solid 1px #EEE;
background-color: #FFF;
box-shadow: -3px 0px 7px 1px #EEE;
margin-bottom: -5px; }
body.layout-2 .main-footer, body.layout-3 .main-footer {
background-color: transparent;
box-shadow: none;
margin-bottom: -5px; }
.btn.btn-icon-split i, .dropdown-item.has-icon i {
font-size: 15px !important;
float: right !important;
margin: 0px !important;
margin-left: 15px !important; }
.navbar .form-inline .search-result::before {
right: 34px; }
.navbar .form-inline .form-control {
padding-right: 20px;
padding-left: 0;
margin-left: -6px;
margin-right: inherit;
border-radius: 0 3px 3px 0px; }
.navbar .form-inline .btn {
border-radius: 3px 0 0 3px;
padding: 9px 15px; }
.dropdown-menu-right {
left: 0px;
right: auto; }
.budget-price .budget-price-label {
margin-right: 5px; }
.section .section-header .section-header-breadcrumb {
margin-left: 0px;
margin-right: auto; }
.breadcrumb-item + .breadcrumb-item {
padding-right: .5rem;
padding-left: 0; }
.breadcrumb-item + .breadcrumb-item::before {
padding-left: .5rem;
padding-right: 0;
display: inline-block;
color: #6c757d;
content: "»"; }
.section .section-title::before {
float: right;
margin-left: 15px;
margin-right: 0; }
body.layout-3 .navbar.navbar-secondary .navbar-nav > .nav-item > .nav-link.has-dropdown {
margin-left: 35px;
margin-right: 0; }
body.layout-3 .navbar.navbar-secondary .navbar-nav > .nav-item > .nav-link.has-dropdown::after {
position: absolute;
top: 50%;
-webkit-transform: translate(0, -50%);
transform: translate(0, -50%);
font-size: 12px;
right: unset;
left: -20px; }
body.layout-3 .navbar.navbar-secondary .navbar-nav > .nav-item.active > .nav-link::before {
right: 35px;
left: 0; }
.dropdown-menu-left {
right: 0; }
.dropdown-menu-left .dropdown-menu-left {
right: 100%; }
body.layout-3 .navbar.navbar-secondary .navbar-nav > .nav-item .dropdown-menu .nav-item .nav-link.has-dropdown::after {
position: absolute;
top: 50%;
-webkit-transform: translate(0, -50%);
transform: translate(0, -50%);
font-size: 12px;
right: unset;
left: 15px; }
.alert-dismissible .close {
position: absolute;
top: 0;
right: unset;
left: 0; }
.card .card-header h4 + .card-header-action .btn-group .btn:last-child, .card .card-header h4 + .card-header-form .btn-group .btn:last-child {
border-radius: 30px 0 0 30px !important; }
.input-group > .input-group-append:last-child > .btn:not(:last-child):not(.dropdown-toggle), .input-group > .input-group-append:last-child > .input-group-text:not(:last-child) {
border-radius: 0 5px 5px 0; }
.input-group > .input-group-append:not(:last-child) > .btn, .input-group > .input-group-append:not(:last-child) > .input-group-text {
border-radius: 0 5px 5px 0; }
.input-group > .input-group-prepend > .btn, .input-group > .input-group-prepend > .input-group-text {
border-radius: 0 5px 5px 0; }
.input-group > .custom-select:not(:first-child), .input-group > .form-control:not(:first-child) {
border-radius: 5px 0 0 5px; }
.card .card-header h4 + .card-header-action .input-group .form-control, .card .card-header h4 + .card-header-form .input-group .form-control {
border-radius: 0 30px 30px 0 !important; }
.card .card-header h4 + .card-header-action .input-group .form-control + .input-group-btn .btn, .card .card-header h4 + .card-header-form .input-group .form-control + .input-group-btn .btn {
border-radius: 30px 0 0 30px !important; }
.btn-group > .btn-group:not(:first-child) > .btn, .btn-group > .btn:not(:first-child) {
border-radius: 5px 0px 0px 5px; }
.btn-group > .btn-group:not(:last-child) > .btn, .btn-group > .btn:not(:last-child):not(.dropdown-toggle) {
border-radius: 0px 5px 5px 0px; }
.dropleft .dropdown-toggle::before {
margin-left: .255em;
margin-right: unset; }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save