Test.php
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
namespace App\Console\Commands;
use App\Http\Logic\Aside\Project\DomainInfoLogic;
use App\Models\Com\UpdateNotify;
use App\Models\Devops\DevopsTask as DevopsTaskModel;
use App\Models\Devops\DevopsTaskLog;
use App\Models\Domain\DomainInfo;
use App\Models\File\File;
use App\Models\File\Image;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\DB;
/**
* 测试
* Class Traffic
* @package App\Console\Commands
* @author zbj
* @date 2023/5/18
*/
class Test extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test';
/**
* The console command description.
*
* @var string
*/
protected $description = '测试';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
$projects = Project::all();
foreach ($projects as $project){
echo "project " . $project->id;
if(!ProjectServer::useProject($project->id)){
echo '-->' . '未配置数据库' . PHP_EOL;
continue;
}
try {
$page = BCustomTemplate::where('url', '404')->first();
if(!$page){
$page = new BCustomTemplate();
}
$page->project_id = $project->id;
$page->name = '404';
$page->status = 1;
$page->url = '404';
$page->html = '<main>
<section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404"
id="sectionIdyxqu938">
<div class="layout" data-unable="demo01-error404">
<img src="https://ecdn6.globalso.com/upload/m/image_other/2023-10/6528a87e594db30162.png" />
</div>
<p style="text-align: center">SORRY. THE PAGE HAS EITHER MOVED OR CANNOT BE FOUND.</p>
<style>
.section-block-error404 .layout {
height: 700px;
display: flex;
align-items: center;
justify-content: center;
}
.section-block-error404 img {
width: 400px;
}
@media only screen and (max-width:500) {
.section-block-error404 img {
max-width: 100%;
}
}
</style>
<script>
</script>
</section>
</main>';
$page->html_style = '<style id="globalsojs-styles"></style>';
$page->description = 'Sorry. The page has either moved or cannot be found.';
$page->title = '404-Page not found';
$page->save();
$domain = (new DomainInfo())->getDomain($project['deploy_optimize']['domain']);
$url = $domain.'api/delHtml/?project_id='.$project->id.'&route=404';
curlGet($url);
}catch (QueryException | \Exception $e){
echo '-->' . $e->getMessage() . PHP_EOL;
continue;
}
echo '-->成功:' . PHP_EOL;
}
}
}