mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-11 23:19:05 +00:00
1. 修复节点信息获取错误的问题 2. 优化首页公告显示 3. 修复回复工单时按回车导致报错的问题 4. 修改用户编辑与添加排版 5. 修复潜在的IE兼容问题 6. 统一Table元素格式 7. 优化返利界面 8. 添加了封禁时间倒计时 9. 对非付费用户,首页添加提示购买宣传语
62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
||
|
||
namespace App\Components;
|
||
|
||
use App\Http\Models\EmailLog;
|
||
use Exception;
|
||
use Log;
|
||
|
||
class ServerChan
|
||
{
|
||
/**
|
||
* 推送消息
|
||
*
|
||
* @param string $title 消息标题
|
||
* @param string $content 消息内容
|
||
*
|
||
* @return mixed
|
||
*/
|
||
public static function send($title, $content)
|
||
{
|
||
if(Helpers::systemConfig()['is_server_chan'] && Helpers::systemConfig()['server_chan_key']){
|
||
try{
|
||
// TODO:一天仅可发送不超过500条
|
||
$url = 'https://sc.ftqq.com/'.Helpers::systemConfig()['server_chan_key'].'.send?text='.$title.'&desp='.urlencode($content);
|
||
$response = Curl::send($url);
|
||
$result = json_decode($response);
|
||
if(!$result->errno){
|
||
self::addLog($title, $content);
|
||
}else{
|
||
self::addLog($title, $content, 0, $result->errmsg);
|
||
}
|
||
} catch(Exception $e){
|
||
Log::error('ServerChan消息推送异常:'.$e);
|
||
}
|
||
}else{
|
||
Log::error('消息推送失败:未启用或未正确配置ServerChan');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 添加serverChan推送日志
|
||
*
|
||
* @param string $title 标题
|
||
* @param string $content 内容
|
||
* @param int $status 投递状态
|
||
* @param string $error 投递失败时记录的异常信息
|
||
*
|
||
* @return int
|
||
*/
|
||
private static function addLog($title, $content, $status = 1, $error = '')
|
||
{
|
||
$log = new EmailLog();
|
||
$log->type = 2;
|
||
$log->address = 'admin';
|
||
$log->title = $title;
|
||
$log->content = $content;
|
||
$log->status = $status;
|
||
$log->error = $error;
|
||
|
||
return $log->save();
|
||
}
|
||
} |