Compare commits
6 Commits
malio-A
...
merge_upst
| Author | SHA1 | Date |
|---|---|---|
|
|
5ddb11226f | 7 years ago |
|
|
5c7c9c59e6 | 7 years ago |
|
|
aea2272677 | 7 years ago |
|
|
62d3b91540 | 7 years ago |
|
|
8839d3c7a6 | 7 years ago |
|
|
50c55ea309 | 7 years ago |
@ -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,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,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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -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();
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
/**
|
||||
* SmsVerify Model
|
||||
*/
|
||||
class SmsVerify extends Model
|
||||
{
|
||||
protected $connection = 'default';
|
||||
protected $table = 'sms_verify';
|
||||
}
|
||||
@ -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,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);
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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,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> 充值</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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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,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,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -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> 管理面板</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> 系统概览</a></li>
|
||||
<li><a href="/admin/announcement"><i class="icon icon-lg">announcement</i> 公告管理</a></li>
|
||||
<li><a href="/admin/ticket"><i class="icon icon-lg">question_answer</i> 工单管理</a></li>
|
||||
<li><a href="/admin/auto"><i class="icon icon-lg">flash_auto</i> 下发命令</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> 节点列表</a></li>
|
||||
<li><a href="/admin/trafficlog"><i class="icon icon-lg">traffic</i> 流量记录</a></li>
|
||||
<li><a href="/admin/block"><i class="icon icon-lg">dialer_sip</i> 已封禁IP</a></li>
|
||||
<li><a href="/admin/unblock"><i class="icon icon-lg">dialer_sip</i> 已解封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> 用户列表</a></li>
|
||||
<li><a href="/admin/relay"><i class="icon icon-lg">compare_arrows</i> 中转规则</a></li>
|
||||
<li><a href="/admin/invite"><i class="icon icon-lg">loyalty</i> 邀请与返利</a></li>
|
||||
{if $config['subscribeLog']===true}
|
||||
<li><a href="/admin/subscribe"><i class="icon icon-lg">dialer_sip</i> 订阅记录</a></li>
|
||||
{/if}
|
||||
<li><a href="/admin/login"><i class="icon icon-lg">text_fields</i> 登录记录</a></li>
|
||||
<li><a href="/admin/alive"><i class="icon icon-lg">important_devices</i> 在线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> 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> 审计规则</a></li>
|
||||
<li><a href="/admin/detect/log"><i class="icon icon-lg">assignment_late</i> 审计记录</a></li>
|
||||
<li><a href="/admin/detect/ban"><i class="icon icon-lg">text_fields</i> 审计封禁</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>
|
||||
{if $config['enable_donate']===true}充值与捐赠记录{else}充值记录{/if}</a>
|
||||
</li>
|
||||
<li><a href="/admin/shop"><i class="icon icon-lg">shop</i> 商品</a></li>
|
||||
<li><a href="/admin/coupon"><i class="icon icon-lg">card_giftcard</i> 优惠码</a></li>
|
||||
<li><a href="/admin/bought"><i class="icon icon-lg">shopping_cart</i> 购买记录</a></li>
|
||||
{if $config['payment_system']=='chenAlipay'}
|
||||
<li><a href="/admin/editConfig"><i class="icon icon-lg">shopping_cart</i> 支付设置</a></li>
|
||||
{/if}
|
||||
</ul>
|
||||
<li><a href="/user"><i class="icon icon-lg">person</i> 用户中心</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…
Reference in New Issue