作者 lyh

Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into master-server

... ... @@ -84,7 +84,7 @@ class DomainInfo extends Command
//除自建站项目外,记录已解析到别的ip的域名
if ($servers_ip_info['servers_id'] != ServerConfig::SELF_SITE_ID) {
//过滤已解析到别的ip的域名
if (!$this->check_cname($v['domain'], $servers_ip_info)) {
if (!check_domain_record($v['domain'], $servers_ip_info)) {
Log::channel('analyze_other')->error('域名 [' . $v['domain'] . '] 已解析到别的IP');
continue;
}
... ... @@ -111,7 +111,7 @@ class DomainInfo extends Command
if ($servers_ip_info['servers_id'] != ServerConfig::SELF_SITE_ID) {
//过滤已解析到别的ip的AMP域名
if (!$this->check_cname($amp_domain, $servers_ip_info)) {
if (!check_domain_record($amp_domain, $servers_ip_info)) {
Log::channel('analyze_other')->error('AMP域名 [' . $amp_domain . '] 已解析到别的IP');
continue;
}
... ... @@ -158,7 +158,7 @@ class DomainInfo extends Command
}
//过滤已解析到别的ip的域名
if (!$this->check_cname($v['domain'], $servers_ip_info)) {
if (!check_domain_record($v['domain'], $servers_ip_info)) {
continue;
}
... ... @@ -215,7 +215,7 @@ class DomainInfo extends Command
}
//过滤已解析到别的ip的域名
if (!$this->check_cname($amp_domain, $servers_ip_info)) {
if (!check_domain_record($amp_domain, $servers_ip_info)) {
continue;
}
... ... @@ -262,7 +262,7 @@ class DomainInfo extends Command
}
//过滤已解析到别的ip的域名
if (!$this->check_cname($v['custom_domain'], $servers_ip_info)) {
if (!check_domain_record($v['custom_domain'], $servers_ip_info)) {
Log::channel('analyze_other')->error('自定义跳转域名 [' . $v['custom_domain'] . '] 已解析到别的IP');
continue;
}
... ... @@ -315,41 +315,4 @@ class DomainInfo extends Command
}
return ['from' => $valid_from, 'to' => $valid_to];
}
/**
* 验证是否cname或者A记录解析到目标服务器
* @param $domain
* @param $server_info
* @return mixed
* @author zbj
* @date 2023/11/13
*/
public function check_cname($domain, $server_info)
{
$process = new Process(['nslookup', '-qt=a', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
if ($line) {
$checkA = strpos($line, $server_info['ip']) !== false;
if ($checkA) {
return $domain;
}
}
}
//是否cname
$process = new Process(['nslookup', '-qt=cname', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
if ($line) {
$checkCname = (strpos($line, $server_info['domain']) !== false);
if ($checkCname) {
return $domain;
}
}
}
return false;
}
}
... ...
... ... @@ -40,7 +40,7 @@ class EmergencyRelieve extends Command
//判断域名是否已经解析到目标服务器
$target_server = $server_ip_model->select(['id', 'ip', 'domain'])->where('id', $value->server_ip_id)->first()->toArray();
if (!$this->check_cname($domain_info['domain'], $target_server)) {
if (!check_domain_record($domain_info['domain'], $target_server)) {
$this->output($domain_info['domain'] . ' | 未解析到目标服务器');
continue;
}
... ... @@ -86,43 +86,6 @@ class EmergencyRelieve extends Command
}
/**
* 验证是否cname或者A记录解析到目标服务器
* @param $domain
* @param $server_info
* @return mixed
* @author zbj
* @date 2023/11/13
*/
public function check_cname($domain, $server_info)
{
$process = new Process(['nslookup', '-qt=a', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
if ($line) {
$checkA = strpos($line, $server_info['ip']) !== false;
if ($checkA) {
return $domain;
}
}
}
//是否cname
$process = new Process(['nslookup', '-qt=cname', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
if ($line) {
$checkCname = (strpos($line, $server_info['domain']) !== false);
if ($checkCname) {
return $domain;
}
}
}
return false;
}
/**
* 输出处理日志
* @param $message
*/
... ...
... ... @@ -42,7 +42,7 @@ class EmergencyRenewSite extends Command
}
//判断域名是否已经解析到目标服务器
if (!$this->check_cname($domain_info['domain'], $target_server)) {
if (!check_domain_record($domain_info['domain'], $target_server)) {
$this->output($domain_info['domain'] . ' | 未解析到目标服务器');
continue;
}
... ... @@ -93,43 +93,6 @@ class EmergencyRenewSite extends Command
}
/**
* 验证是否cname或者A记录解析到目标服务器
* @param $domain
* @param $server_info
* @return mixed
* @author zbj
* @date 2023/11/13
*/
public function check_cname($domain, $server_info)
{
$process = new Process(['nslookup', '-qt=a', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
if ($line) {
$checkA = strpos($line, $server_info['ip']) !== false;
if ($checkA) {
return $domain;
}
}
}
//是否cname
$process = new Process(['nslookup', '-qt=cname', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
if ($line) {
$checkCname = (strpos($line, $server_info['domain']) !== false);
if ($checkCname) {
return $domain;
}
}
}
return false;
}
/**
* 输出处理日志
* @param $message
*/
... ...
... ... @@ -30,7 +30,7 @@ class ProjectDomainCheck extends Command
$project_info = $project_model->read(['id' => $value->project_id], ['id', 'serve_id', 'company']);
$server_ip_info = $server_ip_model->read(['id' => $project_info['serve_id']], ['ip', 'domain']);
if ($this->check_cname($value->domain, $server_ip_info)) {
if (check_domain_record($value->domain, $server_ip_info)) {
continue;
} else {
$data[] = [
... ... @@ -58,43 +58,6 @@ class ProjectDomainCheck extends Command
}
/**
* 验证是否cname或者A记录解析到目标服务器
* @param $domain
* @param $server_info
* @return mixed
* @author zbj
* @date 2023/11/13
*/
public function check_cname($domain, $server_info)
{
$process = new Process(['nslookup', '-qt=a', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
if ($line) {
$checkA = strpos($line, $server_info['ip']) !== false;
if ($checkA) {
return $domain;
}
}
}
//是否cname
$process = new Process(['nslookup', '-qt=cname', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
if ($line) {
$checkCname = (strpos($line, $server_info['domain']) !== false);
if ($checkCname) {
return $domain;
}
}
}
return false;
}
/**
* 输出处理日志
* @param $message
*/
... ...
... ... @@ -100,13 +100,18 @@ class postInquiry extends Command
}else{
//v4 v5分离项目 往测试链接推
$website = $detail['re_website'];
$site_array = file_get_contents('https://www.quanqiusou.cn/extend_api/saas/split.php');
$client = new \GuzzleHttp\Client();
$site_array = $client->request('GET', "https://www.quanqiusou.cn/extend_api/saas/split.php", [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
$site_array = json_decode($site_array, true);
$mail_urls = array_column($site_array, 'main_url');
$key = array_search($detail['re_website'], $mail_urls);
$key = array_search('https://' . $detail['re_website'] . '/', $mail_urls);
if ($key !== false) {
// 分离项目 推送到测试链接
$website = $site_array[$key]['test_url'];
}else{
$website = 'https://' . $website . '/';
}
$data = [
... ... @@ -171,7 +176,7 @@ class postInquiry extends Command
];
$res = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data)->json();
if(empty($res['code']) || $res['code'] != 200){
if(empty($res['data'][0]['code']) || $res['data'][0]['code'] != 200){
$log->status = ReInquiryDetailLog::STATUS_FAIL;
$log->remark = $res['message'] ?? '';
$log->save();
... ...
... ... @@ -2,8 +2,10 @@
namespace App\Console\Commands\RankData;
use App\Helper\QuanqiusouApi;
use App\Http\Logic\Bside\RankData\RankDataLogic;
use App\Models\Project\DeployOptimize;
use App\Models\RankData\RankData;
use Illuminate\Support\Facades\Log;
/**
... ... @@ -34,6 +36,23 @@ class IndexedPages extends BaseCommands
* @date 2023/5/11
*/
public function do(){
$api = new QuanqiusouApi();
$site_res = $api->getSiteRes();
if (!$site_res) {
Log::channel('rank_data')->error('谷歌收录数据获取失败');
}else{
foreach ($site_res as $api_no => $num){
$project_ids = DeployOptimize::where('api_no', $api_no)->pluck('project_id');
foreach ($project_ids as $project_id){
$rank_data = RankData::where('project_id', $project_id)->where('lang', '')->first();
if($rank_data){
$rank_data->indexed_pages_num = $num;
$rank_data->save();
}
}
}
}
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray();
Log::channel('rank_data')->info('开始-页面收录数据-'.count($list));
... ...
... ... @@ -81,7 +81,7 @@ class Temp extends Command
*/
public function handle1()
{
$server_id = 14;
$server_id = 15;
$server_ip_model = new ServersIp();
... ... @@ -99,23 +99,17 @@ class Temp extends Command
}
$domain = $domain_info['domain'];
$check = $this->check_cname($domain);
foreach ($check as $item) {
if (strpos($item, 'Address:') !== false) {
$ip = trim(str_replace('Address:', '', $item));
if (strpos($ip, '#') === false) {
$ip_info = $server_ip_model->read(['ip' => $ip]);
if ($ip_info === false || $ip_info['servers_id'] != $server_id) {
$data[] = [
$value->id,
$value->title,
$domain,
$ip,
$ip_info ? $ip_info['servers_id'] : '',
];
}
}
}
$check = dns_get_record($domain, DNS_A);
$ip = $check[0]['ip'] ?? '';
$ip_info = $server_ip_model->read(['ip' => $ip]);
if ($ip_info === false || $ip_info['servers_id'] != $server_id) {
$data[] = [
$value->id,
$value->title,
$domain,
$ip,
$ip_info ? $ip_info['servers_id'] : '',
];
}
}
$map = ['项目id', '名称', '域名', 'IP', '服务器ID',];
... ... @@ -132,13 +126,6 @@ class Temp extends Command
}
}
public function check_cname($domain)
{
$process = new Process(['nslookup', '-qt=a', $domain]);
$process->run();
return explode(PHP_EOL, $process->getOutput());
}
/**
* 创建所有amp站页面生成任务
* @author Akun
... ...
... ... @@ -959,6 +959,31 @@ function generateRandomString($length) {
return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
}
if (!function_exists('check_domain_record')) {
/**
* 验证是否cname或者A记录解析到目标服务器
* @param $domain
* @param $server_info
* @return bool
* @author Akun
* @date 2024/10/14 11:02
*/
function check_domain_record($domain, $server_info)
{
$records = dns_get_record($domain,DNS_A);
if(count($records) != 1){
return false;
}
$record = $records[0];
if($record['host'] == $server_info['domain'] || $record['ip'] == $server_info['ip']){
return $domain;
}else{
return false;
}
}
}
... ...
... ... @@ -134,13 +134,13 @@ class NoticeController extends BaseController
return $this->error('target_domain参数不能为空');
}
if(!$this->check_a($origin_domain,DomainInfo::SERVER_IP_301)){
if(!check_domain_record($origin_domain,['domain'=>'','ip'=>DomainInfo::SERVER_IP_301])){
return $this->error($origin_domain . ' 未解析至 ' . DomainInfo::SERVER_IP_301);
}
if($other_domain){
foreach ($other_domain as $ov) {
if (!$this->check_a($ov, DomainInfo::SERVER_IP_301)) {
if (!check_domain_record($ov, ['domain'=>'','ip'=>DomainInfo::SERVER_IP_301])) {
return $this->error($ov . ' 未解析至 ' . DomainInfo::SERVER_IP_301);
}
}
... ... @@ -159,28 +159,4 @@ class NoticeController extends BaseController
return $this->success();
}
/**
* 验证是否A记录解析到目标服务器
* @param $domain
* @param $ip
* @return bool
* @author Akun
* @date 2024/09/19 11:14
*/
public function check_a($domain, $ip)
{
$process = new Process(['nslookup', '-qt=a', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line) {
if ($line) {
$checkA = strpos($line, $ip) !== false;
if ($checkA) {
return $domain;
}
}
}
return false;
}
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Aside\PackDir;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\Domain\DomainInfo;
... ... @@ -75,6 +76,9 @@ class PackDirController extends BaseController
if (!$server_ip_info) {
$this->fail('未查询到项目所属服务器信息');
}
if ($server_ip_info['servers_id'] == ServerConfig::SELF_SITE_ID) {
$this->fail('自建站项目不持支打包静态页面');
}
$data = [
'user_id' => $this->uid,
... ...
... ... @@ -156,9 +156,21 @@ class AdsController extends BaseController
public function fbInquiryList(Request $request)
{
$status = intval($request->input('status'));
$ad_name = $request->input('ad_name');
$ad_id = $request->input('ad_id');
$country = $request->input('country');
$result = ReInquiryForm::when($status, function ($query, $status) {
return $query->where('status', $status);
})
->when($ad_name, function ($query, $ad_name) {
return $query->where('ad_name', 'like', '%' . $ad_name . '%');
})
->when($ad_id, function ($query, $ad_id) {
return $query->where('ad_id', 'like', '%' . $ad_id . '%');
})
->when($country, function ($query, $country) {
return $query->where('country', 'like', '%' . $country . '%');
})
->orderBy('id', 'desc')
->paginate();
return $this->response('success', Code::SUCCESS, $result);
... ... @@ -171,8 +183,11 @@ class AdsController extends BaseController
*/
public function fbRelayDetail(Request $request)
{
//广告ID、询盘ID、国家、状态
$status = intval($request->input('status'));
$task_id = intval($request->input('task_id'));
$form_id = intval($request->input('form_id'));
$country = intval($request->input('country'));
$result = ReInquiryDetail::with('detailLog')
->when($status, function ($query, $status) {
return $query->where('status', $status);
... ... @@ -180,6 +195,12 @@ class AdsController extends BaseController
->when($form_id, function ($query, $form_id) {
return $query->where('form_id', $form_id);
})
->when($task_id, function ($query, $task_id) {
return $query->where('task_id', $task_id);
})
->when($country, function ($query, $country) {
return $query->where('country', 'like', '%'.$country.'%');
})
->orderBy('id', 'desc')
->paginate();
return $this->response('success', Code::SUCCESS, $result);
... ...
... ... @@ -175,16 +175,16 @@ class DomainInfoLogic extends BaseLogic
$this->fail('自建站服务器无法生成站点');
}
//域名是否都已经解析
if(!$this->check_cname($info['domain'], $serversIpInfo)){
if(!check_domain_record($info['domain'], $serversIpInfo)){
$this->fail('域名' . $info['domain'] . '未解析至目标服务器');
}
$domain_301 = '';
foreach ($this->param['other_domain']??[] as $other_domain){
if($other_domain && substr($other_domain,0,2) != '*.'){
if($this->check_a($other_domain,DomainInfo::SERVER_IP_301)){
if(check_domain_record($other_domain,['domain'=>'','ip'=>DomainInfo::SERVER_IP_301])){
$domain_301 = $other_domain;
}else{
if(!$this->check_cname($other_domain, $serversIpInfo)){
if(!check_domain_record($other_domain, $serversIpInfo)){
$this->fail('域名' . $other_domain . '未解析至目标服务器');
}
}
... ... @@ -202,7 +202,7 @@ class DomainInfoLogic extends BaseLogic
$host_array[0] = 'm';
}
$amp_domain = implode('.',$host_array);
if(!$this->check_cname($amp_domain, $serversIpInfo)){
if(!check_domain_record($amp_domain, $serversIpInfo)){
$this->fail('AMP站点域名' . $amp_domain . '未解析至目标服务器');
}
}
... ... @@ -286,64 +286,6 @@ class DomainInfoLogic extends BaseLogic
return $this->success();
}
/**
* 验证是否cname或者A记录解析到目标服务器
* @param $domain
* @param $server_info
* @return mixed
* @author zbj
* @date 2023/11/13
*/
public function check_cname($domain, $server_info){
$process = new Process(['nslookup', '-qt=a', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line){
if($line){
$checkA = strpos($line, $server_info['ip']) !== false;
if($checkA){
return $domain;
}
}
}
//是否cname
$process = new Process(['nslookup', '-qt=cname', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line){
if($line){
$checkCname = (strpos($line, $server_info['domain']) !== false);
if($checkCname){
return $domain;
}
}
}
return false;
}
/**
* 验证是否A记录解析到目标服务器
* @param $domain
* @param $ip
* @return mixed
*/
public function check_a($domain, $ip){
$process = new Process(['nslookup', '-qt=a', $domain]);
$process->run();
$output = explode(PHP_EOL, $process->getOutput());
foreach ($output as $line){
if($line){
$checkA = strpos($line, $ip) !== false;
if($checkA){
return $domain;
}
}
}
return false;
}
/**
* 设置语种自定义跳转链接
* @param $project_id
... ... @@ -386,7 +328,7 @@ class DomainInfoLogic extends BaseLogic
if($has_info && ($has_info['project_id'] != $project_id || $has_info['language_id'] != $this->param['language_id'])){
$this->fail('自定义域名已被使用');
}
if(!$this->check_cname($this->param['custom_domain'], $serversIpInfo)){
if(!check_domain_record($this->param['custom_domain'], $serversIpInfo)){
$this->fail('域名' . $this->param['custom_domain'] . '未解析至目标服务器');
}
}else{
... ...
... ... @@ -24,6 +24,7 @@ class AutoPullNotify extends Base
public static function processMap()
{
return [
'php artisan pack_site_dir' => '打包站点静态页面',
'php artisan handle_html' => '拉取页面zip文件并解压',
'php artisan create_update_page_route' => '创建主站路由',
'php artisan create_update_page_master' => '生成主站页面',
... ...