|
|
<?php
|
|
|
// 这个是提交脚本
|
|
|
\Co\run(function(){
|
|
|
while (1){
|
|
|
$body = db()->first("select * from `bodies` limit 1 ");
|
|
|
if(!$body || $body['lists_id']>300000000){
|
|
|
echo "执行完成\n";
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$d = 0;
|
|
|
$len = \Swlib\SaberGM::post('http://172.19.0.5:9527?id='.$body['lists_id'],['body'=>$body['text_html']])->getBody()->getContents();
|
|
|
if(is_numeric($len)&&$len){
|
|
|
$d = db()->delete('bodies',['lists_id'=>$body['lists_id']]);
|
|
|
}
|
|
|
_echo('成功 '.$body['lists_id'].' == '.$d.' == '.$len);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
// 这个是读取备份内容
|
|
|
\Co\run(function(){
|
|
|
|
|
|
$body = \Swlib\SaberGM::get('http://172.19.0.5:9527?id='.$body['lists_id'])->getBody()->getContents();
|
|
|
|
|
|
});
|
|
|
|
|
|
exit();
|
|
|
?>
|
|
|
|
|
|
这里是2个文件哦
|
|
|
------------------------------------------------------------------------------
|
|
|
|
|
|
<?php
|
|
|
|
|
|
/**
|
|
|
* 这个是一个http服务,邮件服务的body内容太大了,把body内容备份到其他服务器,
|
|
|
* 其他服务器放入这个代码 并运行
|
|
|
* 走内网 提交数据
|
|
|
* post 为提交
|
|
|
* get 为获取
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
ini_set("memory_limit", "512M");
|
|
|
|
|
|
// 关闭错误提示 其实这个可有可无 显示了错误也不会输出到前端
|
|
|
//ini_set("display_errors","off");
|
|
|
// 错误级别
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
|
// 时区设置
|
|
|
date_default_timezone_set('Asia/Shanghai');
|
|
|
|
|
|
// 定义 root 目录
|
|
|
define('root_path', __DIR__);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 服务
|
|
|
* @author:dc
|
|
|
* @time 2025/4/18 15:44
|
|
|
* Class mmd_serv
|
|
|
*/
|
|
|
class mmd_serv
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
* 这个是http服务,对外的
|
|
|
* @var Swoole\Http\Server
|
|
|
*/
|
|
|
private $server;
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
|
|
|
|
$this->init_http();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 前端请求处理
|
|
|
* @param \Swoole\Http\Request $request
|
|
|
* @param \Swoole\Http\Response $response
|
|
|
* @author:dc
|
|
|
* @time 2025/4/30 15:42
|
|
|
*/
|
|
|
public function request(\Swoole\Http\Request $request, \Swoole\Http\Response $response)
|
|
|
{
|
|
|
|
|
|
$len = 0;
|
|
|
if($request->server['request_uri']){
|
|
|
|
|
|
}
|
|
|
// print_r($request->get);
|
|
|
$id = intval($request->get['id']??0);
|
|
|
$path = root_path.'/mail/'.($id%10000).'/'.$id.'.log';
|
|
|
|
|
|
$m = strtoupper($request->getMethod());
|
|
|
// get 获取数据
|
|
|
if($m=='GET'){
|
|
|
$len = file_get_contents($path);
|
|
|
}
|
|
|
// 删除数据
|
|
|
elseif($m == 'DELETE'){
|
|
|
$len = unlink($path)?1:0;
|
|
|
}
|
|
|
elseif($m == 'POST'){
|
|
|
$body = $request->post['body']??'';
|
|
|
if($id && $body){
|
|
|
|
|
|
if(!is_dir(dirname($path))){
|
|
|
mkdir(dirname($path),0775,true);
|
|
|
}
|
|
|
$len = file_put_contents($path,$body);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$response->header("Content-Type", 'text/html; charset=UTF-8');
|
|
|
$response->end($len);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 初始
|
|
|
* @author:dc
|
|
|
* @time 2025/4/30 14:50
|
|
|
*/
|
|
|
private function init_http()
|
|
|
{
|
|
|
// 实例一个服务
|
|
|
$this->server = new Swoole\Http\Server("0.0.0.0", 9527);
|
|
|
// 服务设置
|
|
|
$this->server->set([
|
|
|
// 'open_http2_protocol' => true, // http2协议
|
|
|
// 'log_file' => __DIR__.'/error.log',
|
|
|
// 'log_level' => 0,
|
|
|
'package_max_length' => 20 * 1024 * 1024, // 可以post多大数据
|
|
|
// 'daemonize' => true
|
|
|
]);
|
|
|
|
|
|
// 前端请求时
|
|
|
$this->server->on('request', [$this, 'request']);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 启动http 服务
|
|
|
* @author:dc
|
|
|
* @time 2025/5/10 21:57
|
|
|
*/
|
|
|
public function start()
|
|
|
{
|
|
|
$this->server->start();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
(new mmd_serv())->start(); |
...
|
...
|
|