liufumingren 7b18287328 fix: 全项目清理 PHP 7.4 升级遗留(open_basedir 临时目录、implode 反序、null 取下标、嵌套三元)
一、open_basedir 不能再写 /tmp(7.4 池子把白名单收紧,Monolog/EasyWeChat 会抛异常)
- addons/shopro/library/Wechat.php:easywechat 日志改到 runtime/easywechat/
- addons/epay/library/Yansongda/Supports/Logger.php:epay 日志默认路径改到 runtime/epay/
- application/admin/library/traits/Backend.php:CSV 导入临时文件改到 runtime/temp/

二、implode 参数反序(7.4 起 E_DEPRECATED,TP5 会抛异常)
- application/api/controller/Datas.php
- application/index/controller/wms/Pda.php
- 另修正 Wms.php 中 1 处(拆分面单提示)

三、null 取下标(7.4 起 "Trying to access array offset on value of type null")
- 覆盖 71 个文件 135 行:find()/value()/json_decode()/redis get 等结果未判空即取下标处,
  统一 (\['k'] ?? null) 兜底;foreach 目标用 ?? [];in_array/count 等数组参数用 ?? []
- 涉及 api/*、admin/shopro/*、addons/shopro/*、addons/epay/*、index/wms/* 等

四、嵌套三元未加括号(7.4 弃用)
- application/index/controller/wms/Wms.php getPackingprice 2 处,补括号后与旧版本解析顺序一致

验证:74 个文件、148 行改动,逐行括号/引号配平与 HEAD 一致,未改动 vendor/ 与 thinkphp/;
剩余扫描命中均为写目标、unset、或已被 if(!\){error()} 拦截的假阳性。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-25 09:47:48 +08:00

99 lines
3.1 KiB
PHP

<?php
namespace app\index\controller\wms;
use app\common\controller\Frontend;
use fast\Http;
use fast\Random;
class ExtBot extends Frontend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
protected $layout = '';
public function _initialize()
{
parent::_initialize();
$this->redis = new \Redis();
$this->redis->connect('127.0.0.1', 6379);
$this->redis->auth('qwe2019@');
$this->key = "8DE6CAD0E48D4DF84CF0593AD01DB62FE89D137B";
$this->wechatServer = "42.194.235.215";
$webhook_link = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=cd417ebc-4252-4583-9b07-107e954cd0cf";
$this->webhook_lib = new \app\index\library\Webhook($webhook_link);
}
public static function notic($msg){
$this->webhook_lib->sendText($msg);
}
public function init(){
$wxid = "wxid_29kk2tetnwho22";
$query_data = [
"method"=>"list"
];
$res = $this->query($query_data);
if(count(($res['data'] ?? []))==0){
$msg = "无登录的微信";
}
$pids = [];
$has = false;
foreach ($res['data'] as $value){
if($value['wxid']==$wxid){
$has = true;
if($value['isLogin']!=1){
//发送离线警告
$this->webhook_lib->sendText("定时检测已离线,请重新登录");
}
if($value['authMsg']!="已授权"){
$this->webhook_lib->sendText("授权已过期");
}
}
array_push($pids,$value['pid']);
}
if(!$has){
$this->webhook_lib->sendText("定时检测已离线,请重新登录");
}
$kill_pids = [];
$runing_pids = [];
$running_infos = [];
foreach ($res['pids'] as $value) {
if(!in_array($value['pid'],$pids)){
$this->kill($value['pid']);
array_push($kill_pids,$value['pid']);
}
}
return json([$res,$kill_pids,$runing_pids,$running_infos]);
}
private function kill($pid){
$query_data = [
"method"=>"kill",
"pid"=>$pid
];
$res = $this->query($query_data);
}
private function getInfo($pid){
$query_data = [
"method"=>"getInfo",
"pid"=>$pid
];
$res = $this->query($query_data);
}
private function run($is_new=0){
$query_data = [
"method"=>"run",
"pid"=>$is_new
];
$res = $this->query($query_data);
}
private function query($requsetData){
$header = [
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'
];
$options = [
CURLOPT_HTTPHEADER => $header
];
$urlEncodedString = http_build_query($requsetData);
$url = "http://{$this->wechatServer}:8203/api?json&key={$this->key}";
$res = Http::sendRequest($url,$urlEncodedString,'POST',$options);
return json_decode($res["msg"],true);
}
}