作者 赵彬吉
<?php
/**
* @remark :
* @name :AiDomainTask.php
* @author :lyh
* @method :post
* @time :2025/6/19 10:53
*/
namespace App\Console\Commands\Ai;
use App\Models\Domain\DomainInfo;
use Illuminate\Console\Command;
/**
* @remark :拉取项目Ai域名
* @name :AiDomainTask
* @author :lyh
* @method :post
* @time :2025/6/19 10:54
*/
class AiDomainTask extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ai_domain';
/**
* The console command description.
*
* @var string
*/
protected $description = '获取对应域名的ai复制站域名';
public $url = 'https://www.cmer.site/api/globalso_site';
/**
* @remark :执行方法
* @name :handle
* @author :lyh
* @method :post
* @time :2025/6/19 11:32
*/
public function handle(){
$pageSize = 300;
$page = 1;
$res = http_get($this->url.'?pagesize='.$pageSize.'&page='.$page);
if($res['status'] != 200){
echo date('Y-m-d H:i:s').'请求失败,状态码错误'.PHP_EOL;
return false;
}
if(empty($res['data']['data'])){
echo date('Y-m-d H:i:s').'请求失败,未拉取到数据'.PHP_EOL;
return false;
}
$data = $res['data']['data'];
while($page <= $res['data']['last_page']){
$res = http_get($this->url.'?pagesize='.$pageSize.'&page='.$page);
if($res['status'] != 200){
echo date('Y-m-d H:i:s').'第'.$page.'请求失败,未拉取到数据'.PHP_EOL;
return false;
}
$data = array_values(array_merge($data,$res['data']['data']));
$page++;
}
//处理数据
$this->handleData($data);
echo 'end'.PHP_EOL;
return true;
}
/**
* @remark :处理数据
* @name :handleData
* @author :lyh
* @method :post
* @time :2025/6/19 11:21
*/
public function handleData($data){
$domainInfoModel = new DomainInfo();
foreach ($data as $item){
$info = $domainInfoModel->read(['domain'=>$item['domain']],'id');
if($info === false){
$info = $domainInfoModel->read(['domain'=>$item['globalso_domain']],'id');
if($info !== false){
$domainInfoModel->edit(['ai_domain'=>$item['domain']],['id'=>$info['id']]);
}
}else{
$domainInfoModel->edit(['ai_domain'=>$item['globalso_domain']],['id'=>$info['id']]);
}
}
return true;
}
}
... ...
... ... @@ -58,28 +58,7 @@ class lyhDemo extends Command
protected $description = '更新路由';
public function handle(){
$projectModel = new Project();
$buildModel = new DeployBuild();
$lists = $projectModel->list(['delete_status' => 0,'project_type'=>0,'is_upgrade'=>0,'id'=>['<',1659],'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id','notice_order_id']);
foreach ($lists as $item){
echo date('Y-m-d H:i:s') . '开始--项目的id:'. $item['id'] . PHP_EOL;
try {
if(!empty($item['notice_order_id'])){
$api = new OaGlobalsoApi();
$data = $api->order_info($item['notice_order_id']);
if(!empty($data)){
if(isset($data['data']['ads_price'])){
echo '奖励金额:'.$data['data']['ads_price'].PHP_EOL;
$buildModel->edit(['ads_price'=>$data['data']['ads_price'] ?? 0],['project_id'=>$item['id']]);
}
}
}
}catch (\Exception $e){
continue;
}
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . '结束。。。' . PHP_EOL;
}
public function _actionTemplateMain(){
... ...
... ... @@ -183,6 +183,7 @@ class CountAllProject extends Command
}
}
$channel = Channel::getChannelText($v['channel']['user_id'] ?? 0);
$plan = Project::planMap();
$data[] = [
'project_id'=>$v['id'],
'version'=>1,//代表6.0
... ... @@ -196,7 +197,7 @@ class CountAllProject extends Command
'keywords_num'=>$v['key'],
'service_num'=>$v['day'],
'production_num'=>intval(abs((empty($v['uptime']) ? time() : strtotime($v['uptime'])) - strtotime($v['created_at'])) / 86400),
'plan'=>Project::planMap()[$v['plan']],
'plan'=>$plan[$v['plan']] ?? '无版本信息',
'status'=>$type,
'category'=>$category,
'is_admin5' => 6,
... ...
... ... @@ -51,11 +51,12 @@ class GeneratePage extends Command
{
$noticeModel = new NoticeLog();
while (true){
$noticeInfo = $noticeModel->read(['status'=>0,'type'=>$noticeModel::GENERATE_PAGE,'start_at'=>['<=',date('Y-m-d H:i:s')]]);
$task_id = $this->getTaskId();
if (empty($noticeInfo)) {
sleep(10);
continue;
}
$noticeInfo = $noticeModel->read(['id'=>$task_id]);
try {
$this->output(' taskID: ' . $noticeInfo['id'] . ' start');
$notice_data = json_decode($noticeInfo['data'],true);
... ... @@ -80,6 +81,28 @@ class GeneratePage extends Command
return true;
}
/**
* @remark :获取任务id
* @name :getTaskId
* @author :lyh
* @method :post
* @time :2025/6/19 10:02
*/
public function getTaskId()
{
$task_id = Redis::rpop('generate_page_id');
if (empty($task_id)) {
$noticeModel = new NoticeLog();
$ids = $noticeModel->selectField(['status'=>0],'id');
if(!empty($ids)){
foreach ($ids as $id) {
Redis::lpush('generate_page_id', $id);
}
}
$task_id = Redis::rpop('generate_page_id');
}
return $task_id;
}
/**
* 输出message
... ...
... ... @@ -43,7 +43,7 @@ class Temp extends Command
public function handle()
{
$this->specialImport();
$this->check_no_cname_projects();
}
/**
... ... @@ -1012,8 +1012,8 @@ class Temp extends Command
*/
public function check_no_cname_projects()
{
$server_id = 1;
$server_name = '硅谷云服务器';
$server_id = 20;
$server_name = '建站服务器01';
$server_ip_model = new ServersIp();
... ... @@ -1031,7 +1031,13 @@ class Temp extends Command
}
$domain = $domain_info['domain'];
$check = [];
try {
$check = dns_get_record($domain, DNS_A);
} catch (\Exception $e) {
$this->output($domain . ' | ' . $e->getMessage());
}
$ip = $check[0]['ip'] ?? '';
$host = $check[0]['host'] ?? '';
if (strpos($host, 'globalso.com') === false) {
... ...
... ... @@ -61,7 +61,7 @@ if (!function_exists('http_post')) {
* @param type $url
* @param type $post_data
*/
function http_post($url, $post_data, $header = [],$is_json = true)
function http_post($url, $post_data, $header = [],$is_json = true,$timeout = 60)
{
if (empty($header)) {
$header = array(
... ... @@ -73,6 +73,7 @@ if (!function_exists('http_post')) {
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
... ...
... ... @@ -234,6 +234,7 @@ class OptimizeController extends BaseController
'gl_project_deploy_optimize.first_compliance_time AS first_compliance_time',
'gl_domain_info.amp_status AS amp_status',
'gl_domain_info.domain AS domain',
'gl_domain_info.ai_domain AS ai_domain',
];
return $select;
}
... ... @@ -262,6 +263,9 @@ class OptimizeController extends BaseController
if(isset($this->map['ai_video']) && !empty($this->map['ai_video'])){
$query = $query->where('gl_project_deploy_optimize.ai_video',$this->map['ai_video']);
}
if(isset($this->map['ai_domain']) && !empty($this->map['ai_domain'])){
$query = $query->whereNotNull('gl_domain_info.ai_domain');
}
if(isset($this->map['amp_status'])){
$query = $query->where('gl_domain_info.amp_status',$this->map['amp_status']);
}
... ...
... ... @@ -123,7 +123,7 @@ class ProjectController extends BaseController
'gl_project_deploy_optimize.design_mid AS design_mid',
'gl_project_deploy_optimize.api_no AS api_no',
'gl_web_setting_template.template_id AS template_id',
'gl_project_association.friend_id as friend_id'
'gl_project_association.friend_id as friend_id',
];
return $select;
}
... ... @@ -174,7 +174,7 @@ class ProjectController extends BaseController
*/
public function searchType(&$query){
if(isset($this->map['type'])){
$query->where('gl_project.extend_type', '!=' ,5);
$query->where('gl_project.extend_type', '!=' ,5)->where('gl_project.extend_type', '!=' ,8);
if (in_array($this->map['type'], [Project::TYPE_ZERO, Project::TYPE_ONE, Project::TYPE_TWO, Project::TYPE_THREE])){
$query->where('gl_project.type', $this->map['type']);
} elseif ($this->map['type'] == 8){
... ...
... ... @@ -301,9 +301,12 @@ class CNoticeController extends BaseController
'language'=> $language,
'is_sitemap' => $is_sitemap
];
// http_post($c_url, json_encode($c_param));
try {
http_post($c_url, json_encode($c_param));
}catch (\Exception $e){
NoticeLog::createLog(NoticeLog::GENERATE_PAGE, json_encode(['c_url'=>$c_url,'c_params'=>$c_param]));
}
}
$this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!');
}
... ...
... ... @@ -70,7 +70,7 @@ class LoginLogic extends BaseLogic
// Cache::pull(Common::MANAGE_TOKEN . $manage['token']);
// }
//生成新token
$token = md5(uniqid().$manage['id']);
$token = $manage['id'].'_a'.md5(uniqid().$manage['id']);
unset($manage['password']);
//更新用户信息
$manage->token = $token;
... ...
... ... @@ -90,7 +90,7 @@ class UserLoginLogic
Cache::pull($info['token']);
}
//生成新token
$token = md5(uniqid().$info['id']);
$token = $info['id'].'_b'.md5(uniqid().$info['id']);
//存储缓存
$info['token'] = $token;
Cache::add($token,$info,3600 * 12);
... ...
... ... @@ -27,6 +27,7 @@ class AutoPullNotify extends Base
24 => '白帽专属服务器02',
23 => '西班牙服务器',
6 => '自建站服务器群',
27 => '硅谷建站服务器03',
];
}
... ...