作者 lyh

gx

@@ -48,337 +48,7 @@ class Demo extends Command @@ -48,337 +48,7 @@ class Demo extends Command
48 */ 48 */
49 protected $description = 'demo'; 49 protected $description = 'demo';
50 50
51 - /**  
52 - * Create a new command instance.  
53 - *  
54 - * @return void  
55 - */  
56 -// public function __construct()  
57 -// {  
58 -// parent::__construct();  
59 -// }  
60 -  
61 - public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)  
62 - {  
63 -  
64 - $ch = curl_init();  
65 - curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);  
66 - curl_setopt($ch, CURLOPT_URL, $url);  
67 - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
68 - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  
69 - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);  
70 - if ($data)  
71 - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));  
72 - curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([  
73 - 'Expect:',  
74 - 'Content-type: application/json',  
75 - 'Accept: application/json',  
76 - ], $header)  
77 - );  
78 - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);  
79 - $response = curl_exec($ch);  
80 - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);  
81 - curl_close($ch);  
82 - return [$code, $response];  
83 - }  
84 -  
85 - /**  
86 - * @return bool  
87 - */  
88 -// public function handle()  
89 -// {  
90 -// return $this->domain();  
91 -// $result = app(SyncService::class)->projectAcceptAddress(1);  
92 -// dd($result);  
93 -// $data = [  
94 -// 'key' => 'productkey_keyword',  
95 -// 'keywords' => 'apple watch'  
96 -// ];  
97 -// $result = Common::send_openai_msg('v2/openai_chat', $data);  
98 -// dd();  
99 -// $string = 'demo.globalso.site/';  
100 -// $domain_array = parse_url($string);  
101 -// $domain = $domain_array['host'] ?? $domain_array['path'];  
102 -// dd($domain);  
103 -// $data = [];  
104 -// dd(isset($data['a']['b']));  
105 -// $url = 'https://demo.globalso.site/';  
106 -// $action = 'api/updateHtmlNotify/';  
107 -// $data = [  
108 -// 'project_id' => 1,  
109 -// 'type' => 1,  
110 -// 'route' => 1  
111 -// ];;  
112 -// $method = 'GET';  
113 -// $result = $this->curlRequest($url . $action, $data, $method);  
114 -// dd($result);  
115 -//  
116 -// $context = stream_context_create([  
117 -// 'ssl' => [  
118 -// 'capture_peer_cert' => true,  
119 -// 'capture_peer_cert_chain' => false,  
120 -// ],  
121 -// ]);  
122 -//  
123 -// $stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);  
124 -//  
125 -// if(!$stream) {  
126 -// die("Failed to connect: $errno - $errstr");  
127 -// }  
128 -//  
129 -// $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];  
130 -//  
131 -// if(!$remote_cert) {  
132 -// die("Failed to retrieve certificate");  
133 -// }  
134 -//  
135 -// $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);  
136 -// $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);  
137 -//  
138 -// fclose($stream);  
139 -//  
140 -// echo "Certificate Valid From: $valid_from<br>";  
141 -// echo "Certificate Valid To: $valid_to<br>";  
142 -//  
143 -// dd('end');  
144 -// $dept_array = [  
145 -// '品牌部',  
146 -// '综合部',  
147 -// '渠道部',  
148 -// '广告推广部',  
149 -// 'AICC运营部',  
150 -// '黑格运营部',  
151 -// '直营运营部',  
152 -// '直营销售部',  
153 -// '深圳跨境部',  
154 -// '外贸部',  
155 -// '研发部',  
156 -// '技术部',  
157 -// '售后部',  
158 -// ];  
159 -// foreach ($dept_array as $v) {  
160 -// $dept = Dept::where(['title' => $v])->first();  
161 -// if (FALSE == empty($dept))  
162 -// continue;  
163 -// $dept = new Dept();  
164 -// $dept->title = $v;  
165 -// $dept->save();  
166 -// }  
167 -//// dd('dept end');  
168 -// $dept_map = Dept::pluck('title', 'id')->toArray();  
169 -// $belonging_map = BelongingGroup::pluck('name', 'id')->toArray();  
170 -//// dd($belonging_map);  
171 -//  
172 -// $filename = storage_path('logs/oa_hr.txt');  
173 -// $string = file_get_contents($filename);  
174 -// $data = explode("\r\n", $string);  
175 -// $data = array_filter($data);  
176 -// $dept = '';  
177 -// foreach ($data as $k=>$v) {  
178 -//// var_dump($v) . PHP_EOL;  
179 -// if ($k == 1)  
180 -// continue;  
181 -// $tmp = explode("\t", $v);  
182 -// if (count($tmp) == 3) {  
183 -// $dept = $tmp[0] ? : $dept;  
184 -// $position = $tmp[1];  
185 -// $name = $tmp[2];  
186 -// } else if (count($tmp) == 2) {  
187 -// $position = $tmp[0];  
188 -// $name = $tmp[1];  
189 -// } else {  
190 -// Log::info($v . PHP_EOL);  
191 -// continue;  
192 -// }  
193 -//  
194 -//  
195 -//// Log::info($dept . '---' . $position . '---' . $name . PHP_EOL);  
196 -//// continue;  
197 -//  
198 -// $dept_id = array_search($dept, $dept_map);  
199 -// $belonging_id = 17;  
200 -// if (FALSE !== strpos($dept,'技术部')) {  
201 -// $belonging_string = str_replace('技术部', '', $dept);  
202 -// if ($belonging_string) {  
203 -// $belonging_string = $belonging_string . '组';  
204 -// $belonging_id = array_search($belonging_string, $belonging_map);  
205 -// }  
206 -//  
207 -// $dept_tmp = '技术部';  
208 -// $dept_id = array_search($dept_tmp, $dept_map);  
209 -// }  
210 -// if (FALSE !== strpos($dept,'售后')) {  
211 -// $belonging_string = str_replace('售后', '', $dept);  
212 -// if ($belonging_string)  
213 -// $belonging_id = array_search($belonging_string, $belonging_map);  
214 -// $dept_tmp = '售后部';  
215 -// $dept_id = array_search($dept_tmp, $dept_map);  
216 -// }  
217 -//  
218 -// $position_log = EntryPosition::where(['name' => $position])->first();  
219 -// if (empty($position_log)) {  
220 -// $position_log = new EntryPosition();  
221 -// $position_log->name = $position;  
222 -// $position_log->save();  
223 -// }  
224 -// $position_id = $position_log->id;  
225 -//  
226 -// $hr = ManageHr::where(['name' => $name])->first();  
227 -// if (empty($hr)) {  
228 -// Log::info($k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id);  
229 -// continue;  
230 -// }  
231 -//  
232 -// $hr->belong_group = $belonging_id;  
233 -// $hr->dept_id = $dept_id;  
234 -// $hr->entry_position = $position_id;  
235 -// $hr->save();  
236 -// echo $k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id . '-' . '组' . '-' . $belonging_id . PHP_EOL;  
237 -//  
238 -// }  
239 -// dd('end');  
240 -// exit;  
241 -//  
242 -// if (($handle = fopen($filename, 'r')) !== false) {  
243 -// while (($data = fgetcsv($handle, 1000, ',')) !== false) {  
244 -// // 处理每行数据  
245 -// Log::info(var_export($data, true));  
246 -// }  
247 -// fclose($handle);  
248 -// }  
249 -// exit;  
250 -//  
251 -// $group = BelongingGroup::get();  
252 -// dd($group->toArray());  
253 -// $domain = parse_url('https//:dev.golbalso.site/');  
254 -// dd($domain);  
255 -// echo time() . PHP_EOL;  
256 -// $blogModel = new Image();  
257 -// $list = $blogModel->list();  
258 -// echo time() . PHP_EOL;  
259 -// dd(count($list));  
260 -//  
261 -// return;  
262 -// preg_match_all("/\@include\(\"([a-z0-9_]+)\"\)/i",'  
263 -//@include("asdf")@include("")@include("asdtrw2erf")  
264 -// ',$include);  
265 -//  
266 -// print_r($include);  
267 -// }  
268 public function handle(){ 51 public function handle(){
269 - $fileModel = new File();  
270 - $lists = $fileModel->list(['created_at'=>['>=','2024-04-12 00:00:00']]);  
271 - foreach ($lists as $k=> $v){  
272 - $str = './coscli cp cos://globalso-v6-1309677403'.$v['path'].' /home/cos/'.$v['path'];  
273 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($str, true) . PHP_EOL, FILE_APPEND);  
274 - }  
275 - return true;  
276 - }  
277 52
278 - /**  
279 - * @remark :处理子集排序  
280 - * @name :subSort  
281 - * @author :lyh  
282 - * @method :post  
283 - * @time :2024/2/29 15:30  
284 - */  
285 - public function subSort($subList,&$sort,$pid = 0){  
286 - $navModel = new BNav();  
287 - foreach ($subList as $k => $v){  
288 - $v = (array)$v;  
289 - $sort = $sort+1;  
290 - $navModel->edit(['sort'=>$sort],['id'=>$v['id']]);  
291 - if(!empty($v['sub'])){  
292 - $this->subSort($v['sub'],$sort,$v['id']);  
293 - }  
294 - }  
295 - return true;  
296 - }  
297 -// public function handle(){  
298 -// $projectModel = new DeployOptimize();  
299 -// $list = $projectModel->list(['project_id'=>['<',187]]);  
300 -// foreach ($list as $v){  
301 -// echo date('Y-m-d H:i:s') . 'end'.json_encode($v) . PHP_EOL;  
302 -// $data = [];  
303 -// if(!empty($v['minor_languages']) && is_array($v['minor_languages'])){  
304 -// foreach ($v['minor_languages'] as $k1=> $v1){  
305 -// if(!empty($v1['tl']) && !empty($v1['type'])){  
306 -// $data[] = [  
307 -// 'language'=>$v1['tl'],  
308 -// 'type'=>$v1['type'],  
309 -// 'keywords'=>$v1['keywords'],  
310 -// 'service_day'=>$v1['service_day'],  
311 -// 'project_id'=>$v['project_id'],  
312 -// 'created_at'=>date('Y-m-d H:i:s'),  
313 -// 'updated_at'=>date('Y-m-d H:i:s')  
314 -// ];  
315 -// }  
316 -// }  
317 -// }  
318 -// $languageModel = new MinorLanguages();  
319 -// $languageModel->insert($data);  
320 -// }  
321 -//  
322 -// }  
323 -  
324 - public function printMessage()  
325 - {  
326 - $client = new Client();  
327 - $headers = [  
328 - 'Accept-Language' => 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',  
329 - 'Cache-Control' => 'no-cache',  
330 - 'Content-Type' => 'application/json',  
331 - 'DNT' => '1',  
332 - 'Origin' => 'http://openai.waimaoq.com',  
333 - 'Pragma' => 'no-cache',  
334 - 'Proxy-Connection' => 'keep-alive',  
335 - 'Referer' => 'http://openai.waimaoq.com/docs',  
336 - 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',  
337 - 'accept' => 'application/json',  
338 - 'Access-Control-Allow-Origin' => '*'  
339 - ];  
340 - $body = '{  
341 - "prompt": "Human: 我需要一篇100字的英文原创博客并包含标题,内容结合:“cnc machine”。AI:"  
342 - }';  
343 - $response = $client->post('http://openai.waimaoq.com/v1/openai_chat_stream', [  
344 - 'stream' => true,  
345 - 'headers' => $headers,  
346 - 'body' => $body  
347 - ]);  
348 - // 获取响应流对象  
349 - $stream = $response->getBody();  
350 -  
351 - // 设置输出缓冲区  
352 - ob_start();  
353 -  
354 - // 读取流中的数据并输出到页面  
355 - while (!$stream->eof()) {  
356 - echo $stream->read(4);  
357 - ob_flush();  
358 - flush();  
359 - }  
360 - dd(1);  
361 - }  
362 -  
363 - /**  
364 - * @remark :获取域名  
365 - * @name :domain  
366 - * @author :lyh  
367 - * @method :post  
368 - * @time :2023/11/29 18:47  
369 - */  
370 - public function domain(){  
371 - $domainModel = new DomainInfo();  
372 - $lists = $domainModel->list();  
373 - foreach ($lists as $k => $v){  
374 - if($v['project_id'] != 0){  
375 - echo date('Y-m-d H:i:s') . ' start: ' . $v['project_id'] . PHP_EOL;  
376 - $domain = 'https://'.$v['domain'].'/';  
377 - $url = $domain.'/api/update_robots/?project_id='.$v['project_id'];  
378 - http_get($url);  
379 - echo date('Y-m-d H:i:s') . ' end: ' . $v['project_id'] . PHP_EOL;  
380 - }  
381 - }  
382 - return true;  
383 } 53 }
384 } 54 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :EditVideoMp4.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/4/16 9:44
  8 + */
  9 +
  10 +namespace App\Console\Commands\Test;
  11 +
  12 +use App\Models\Project\Project;
  13 +use App\Services\ProjectServer;
  14 +use Illuminate\Console\Command;
  15 +use Illuminate\Support\Facades\DB;
  16 +
  17 +class EditVideoMp4 extends Command
  18 +{
  19 + /**
  20 + * The name and signature of the console command.
  21 + *
  22 + * @var string
  23 + */
  24 + protected $signature = 'edit_video';
  25 +
  26 + /**
  27 + * The console command description.
  28 + *
  29 + * @var string
  30 + */
  31 + protected $description = 'edit_mp4';
  32 +
  33 +
  34 + public function handle(){
  35 + $projectModel = new Project();
  36 + $list = $projectModel->list(['id'=>1]);
  37 + $data = [];
  38 + foreach ($list as $v){
  39 + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  40 + ProjectServer::useProject($v['id']);
  41 + $this->copyTable();
  42 + DB::disconnect('custom_mysql');
  43 + }
  44 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  45 + }
  46 +
  47 + /**
  48 + * @remark :获取video的src
  49 + * @name :getVideoSrc
  50 + * @author :lyh
  51 + * @method :post
  52 + * @time :2024/4/16 9:46
  53 + */
  54 + public function getVideoSrc($html){
  55 + $videoArr = [];
  56 + $html = file_get_contents($html);
  57 + $pattern = '/<video.*?src=[\'"]([^\'"]+)[\'"].*?>/i';
  58 + preg_match_all($pattern, $html, $matches);
  59 + $srcLinks = $matches[1];
  60 + foreach ($srcLinks as $link) {
  61 + $videoArr[] = $link;
  62 + }
  63 + return $videoArr;
  64 + }
  65 +
  66 + /**
  67 + * @remark :复制表
  68 + * @name :copyTable
  69 + * @author :lyh
  70 + * @method :post
  71 + * @time :2024/4/16 9:51
  72 + */
  73 + public function copyTable(){
  74 + // 原始表名和新表名
  75 + $originalTableName = "gl_web_template";
  76 + $newTableName = "gl_web_template_copy";
  77 + // 检查原始表是否存在
  78 + $result = DB::connection('custom_mysql')->query("SHOW TABLES LIKE '{$originalTableName}'");
  79 + if ($result->num_rows == 1) {
  80 + // 复制原始表结构到新表
  81 + DB::connection('custom_mysql')->query("CREATE TABLE {$newTableName} LIKE {$originalTableName}");
  82 + // 复制原始表数据到新表
  83 + DB::connection('custom_mysql')->query("INSERT INTO {$newTableName} SELECT * FROM {$originalTableName}");
  84 + echo "表复制成功!";
  85 + } else {
  86 + echo "原始表不存在!";
  87 + }
  88 + DB::connection('custom_mysql')->close();
  89 + }
  90 +}
@@ -40,12 +40,10 @@ class ProjectServer @@ -40,12 +40,10 @@ class ProjectServer
40 config(['database.connections.custom_mysql.database' => $project->databaseName()]); 40 config(['database.connections.custom_mysql.database' => $project->databaseName()]);
41 config(['database.connections.custom_mysql.username' => $project->mysqlConfig->user]); 41 config(['database.connections.custom_mysql.username' => $project->mysqlConfig->user]);
42 config(['database.connections.custom_mysql.password' => $project->mysqlConfig->password]); 42 config(['database.connections.custom_mysql.password' => $project->mysqlConfig->password]);
43 -  
44 //清除现有的数据库连接配置 43 //清除现有的数据库连接配置
45 DB::purge('custom_mysql'); 44 DB::purge('custom_mysql');
46 //重连 45 //重连
47 DB::connection('custom_mysql')->reconnect(); 46 DB::connection('custom_mysql')->reconnect();
48 -  
49 // 设置 redis 配置 47 // 设置 redis 配置
50 return $project; 48 return $project;
51 } 49 }