作者 刘锟

update

... ... @@ -31,14 +31,72 @@ class Temp extends Command
*
* @var string
*/
protected $description = '临时脚本';
protected $description = '临时脚本(akun)';
public function handle()
{
$this->relation_all_keywords();
}
/**
* 转移灾备服务器后,判断项目是否正常访问
* @author Akun
* @date 2024/12/11 10:15
*/
public function check_zb_complete_project_site()
{
$server_id = 15;
$server_name = '美服1';
$server_ip_model = new ServersIp();
$server_ip_ids = $server_ip_model->where('servers_id', $server_id)->get()->pluck('id')->toArray();
$project_list = Project::select(['id', 'serve_id', 'title'])->whereIn('serve_id', $server_ip_ids)->get();
$domain_model = new DomainInfo();
$data = [];
foreach ($project_list as $value) {
$domain_info = $domain_model->read(['project_id' => $value->id, 'status' => 1], ['id', 'domain']);
if (!$domain_info) {
//过滤未绑定正式域名的项目
continue;
}
$domain = $domain_info['domain'];
$check = dns_get_record($domain, DNS_A);
$ip = $check[0]['ip'] ?? '';
$host = $check[0]['host'] ?? '';
$code = check_curl_status($domain);
$data[] = [
$value->id,
$value->title,
$domain,
$host,
$ip,
$code
];
}
$map = ['项目id', '名称', '域名', 'CNAME', 'IP', '站点状态'];
if ($data) {
$table = new BatchExportService($server_name . '站点解析情况及访问状态');
$file = $table->head($map)->data($data)->save();
if (!$file) {
$this->output('文件生成失败,请重试');
} else {
$this->output('export success');
}
} else {
$this->output('no data');
}
}
/**
* 检查服务器上没有解析cname的项目
* @author Akun
* @date 2024/12/11 10:15
*/
public function handle7()
public function check_no_cname_projects()
{
$server_id = 15;
$server_name = '美服1';
... ... @@ -90,7 +148,7 @@ class Temp extends Command
* @author Akun
* @date 2024/12/10 10:43
*/
public function handle6()
public function wx_tg_projects()
{
//获取所有组内推广项目
$leader_mid = 16;
... ... @@ -178,9 +236,9 @@ class Temp extends Command
* @author Akun
* @date 2024/11/18 15:07
*/
public function handle()
public function relation_all_keywords()
{
$projects = Project::where('id', 874)->select(['id'])->orderBy('id', 'asc')->get();
$projects = Project::select(['id'])->orderBy('id', 'asc')->get();
foreach ($projects as $project) {
ProjectServer::useProject($project->id);
... ... @@ -204,7 +262,7 @@ class Temp extends Command
* @author Akun
* @date 2024/10/30 15:37
*/
public function handle4()
public function keywords_first_word()
{
$projects = Project::select(['id'])->orderBy('id', 'asc')->get();
foreach ($projects as $project) {
... ... @@ -279,7 +337,7 @@ class Temp extends Command
* @author Akun
* @date 2024/09/30 17:01
*/
public function handle3()
public function get_all_projects_by_server()
{
$server_id = 1;
... ... @@ -325,7 +383,7 @@ class Temp extends Command
* @author Akun
* @date 2024/09/26 10:48
*/
public function handle2()
public function check_no_server_projects()
{
$server_id = 15;
... ... @@ -377,7 +435,7 @@ class Temp extends Command
* @author Akun
* @date 2024/09/26 10:48
*/
public function handle1()
public function create_all_amp_notify()
{
$notify_model = new Notify();
$project_model = new Project();
... ...
... ... @@ -1001,6 +1001,40 @@ if (!function_exists('check_domain_record')) {
}
}
if (!function_exists('check_curl_status')) {
/**
* 获取域名访问状态码
* @param $url
* @return int
* @author Akun
* @date 2024/12/12 15:52
*/
function check_curl_status($url){
$header = array(
'Expect:',
'Content-Type: application/json; charset=utf-8'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246');
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 'all');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_exec($ch);
$http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
return $http_code;
}
}
/**
* 邮箱脱敏
* @author zbj
... ...