作者 赵彬吉
... ... @@ -128,7 +128,7 @@ class AiBlogAutoPublish extends Command
public function createTask($keywords, $project_id, $frequency){
$keyword = $keywords[array_rand($keywords)];
$aiBlogService = new AiBlogService($project_id);
$result = $aiBlogService->setRoute($keyword)->createTask($keyword);
$result = $aiBlogService->createTask($keyword);
if ($result['status'] == 200) {
$aiBlogTaskModel = new AiBlogTaskModel();
$next_auto_date = date('Y-m-d', strtotime('+' . mt_rand($frequency[0],$frequency[1]) . 'days')); //每3-6天自动发布
... ...
... ... @@ -147,7 +147,7 @@ class AiVideoTask extends Command
if($route != $result['data']['url']){
$aiVideoService->updateDetail(['url'=>$route,'task_id'=>$item['task_id']]);
}
$description = explode(",",$result['data']['content']);
$description = explode(".",$result['data']['content']);
$saveData = [
'title'=>$result['data']['title'],
'image'=>$result['data']['thumb'],
... ...
... ... @@ -10,13 +10,24 @@
namespace App\Console\Commands\LyhTest;
use App\Console\Commands\Domain\DomainInfo;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Models\Ai\AiBlog;
use App\Models\Ai\AiBlogAuthor;
use App\Models\Com\NoticeLog;
use App\Models\Com\V6WeeklyReport;
use App\Models\Project\AiBlogTask;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\OnlineCheck;
use App\Models\Project\Project;
use App\Models\Project\ProjectAiSetting;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Models\RouteMap\RouteMap;
use App\Models\Visit\Visit;
use App\Models\WebSetting\WebLanguage;
use App\Models\WebSetting\WebSetting;
use App\Models\Workchat\MessagePush;
use App\Services\AiBlogService;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
... ... @@ -40,19 +51,44 @@ class lyhDemo extends Command
public function handle(){
$projectModel = new Project();
$lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4]]], 'id', ['id']);
$lists = $projectModel->list(['delete_status' => 0,'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id']);
foreach ($lists as $val) {
echo date('Y-m-d H:i:s') . '开始--项目的id:'. $val['id'] . PHP_EOL;
ProjectServer::useProject($val['id']);
try {
$settingModel = new WebSetting();
$settingModel->edit(['anchor_num'=>10],['id'=>1,'anchor_num'=>3]);
}catch (\Exception $e){
DB::disconnect('custom_mysql');
$aiBlogModel = new AiBlog();
$aiLists = $aiBlogModel->list(['status'=>2],'id',['id','seo_description']);
if(!empty($aiLists)){
foreach ($aiLists as $item){
if(!empty($item['seo_description'])){
//查看当前是否包含句号。
$result = $this->hasAnyPeriod($item['seo_description']);
if($result === false){
$text = $this->trimToLastFullWord($item['seo_description']);
}else{
$arr = explode('.',$item['seo_description']);
$text = $arr[0].'.';
}
$aiBlogModel->edit(['seo_description'=>$text],['id'=>$item['id']]);
}
}
}
DB::disconnect('custom_mysql');
echo date('Y-m-d H:i:s') . '结束--项目的id:'. $val['id'] . PHP_EOL;
}
return true;
}
public function trimToLastFullWord($text) {
// 去掉结尾非字母数字字符
$text = rtrim($text);
// 如果最后一个单词被截断,就删除它
if (preg_match('/^(.*?\b)\w*$/', $text, $matches)) {
return $matches[1];
}
return trim($text); // fallback
}
public function hasAnyPeriod($text) {
return strpos($text, '.') !== false || mb_strpos($text, '。') !== false;
}
}
... ...
... ... @@ -41,22 +41,24 @@ class Temp extends Command
public function handle()
{
$this->create_all_amp_notify();
}
/**
* www.docareco.com批量设置301跳转
* 批量设置301跳转
* @author Akun
* @date 2025/04/21 16:12
*/
public function setDomain301()
{
$domain_extend_config = DomainInfo::where('domain', 'www.docareco.com')->value('extend_config');
$domain = 'www.lvtopsun.com';
$domain_extend_config = DomainInfo::where('domain', $domain)->value('extend_config');
$domain_origin_list = $domain_extend_config ? array_column($domain_extend_config, 'origin') : [];
//读取csv文件
$file = 'C:\Users\Akun\Desktop\有排名网页-还未做301-4.21.csv';
$file = 'C:\Users\Akun\Desktop\广东绿达新能源有限公司设置301页面.csv';
$line_of_text = [];
try {
$file_handle = fopen($file, 'r');
... ... @@ -71,8 +73,8 @@ class Temp extends Command
if (count($line_of_text) > 1) {
foreach ($line_of_text as $k => $v) {
if ($k > 0 && $v) {
$origin = str_replace('https://www.docareco.com', '', $v[0]);
$target = str_replace('https://www.docareco.com', '', $v[1]);
$origin = str_replace('https://'.$domain, '', $v[0]);
$target = str_replace('https://'.$domain, '', $v[1]);
if (!in_array($origin, $domain_origin_list)) {
$domain_extend_config[] = [
... ... @@ -84,7 +86,7 @@ class Temp extends Command
}
}
DomainInfo::where('domain', 'www.docareco.com')->update(['extend_config' => Arr::a2s($domain_extend_config)]);
DomainInfo::where('domain', $domain)->update(['extend_config' => Arr::a2s($domain_extend_config)]);
$this->output('success');
}
... ...
... ... @@ -159,13 +159,15 @@ class NoticeController extends BaseController
//新增重定向任务
$redirect_model = new DomainRedirectTask();
$task_redirect_info = $redirect_model->read(['origin_domain'=>$origin_domain]);
$task_redirect_info = $redirect_model->read(['origin_domain'=>$origin_domain],['id']);
if(!$task_redirect_info){
$redirect_model->add([
'origin_domain'=> $origin_domain,
'other_domain' => json_encode($other_domain),
'target_domain' => $target_domain
]);
}else{
$redirect_model->edit(['status'=>DomainRedirectTask::STATUS_UN],['id'=>$task_redirect_info['id']]);
}
return $this->success();
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Aside\Com;
use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Helper\Translate;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\MenuLogic;
use App\Http\Logic\Bside\User\UserLoginLogic;
... ... @@ -11,6 +12,7 @@ use App\Models\Inquiry\InquiryData;
use App\Models\Manage\Manage;
use App\Models\User\User;
use App\Models\WebSetting\WebLanguage;
use App\Services\HumanizeAiTextService;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
... ... @@ -160,5 +162,35 @@ class IndexController extends BaseController
$this->response('success',Code::SUCCESS,['dynamic_password'=>$dynamic_password]);
}
/**
* @remark :去ai痕迹
* @name :notAiHumanizer
* @author :lyh
* @method :post
* @time :2025/5/21 9:08
*/
public function notAiHumanizer(){
$this->request->validate([
'text'=>'required',
'lang'=>'required'
],[
'text.required' => '文本text不能为空',
'lang.required' => '语种不能为空',
]);
$service = new HumanizeAiTextService();
$data = $service->humanizer($this->param['text'],$this->param['lang']);
$this->response('success', Code::SUCCESS, $data);
}
/**
* @remark :翻译
* @name :stringTranslation
* @author :lyh
* @method :post
* @time :2025/5/21 9:31
*/
public function stringTranslation(){
$data = Translate::translateSl($this->param['text']);
$this->response('success', Code::SUCCESS, $data);
}
}
... ...
... ... @@ -1214,4 +1214,5 @@ class ProjectController extends BaseController
$lists = $model->list(['status' => 1], 'id', ['id', 'industry_name'], 'asc');
$this->response('success', Code::SUCCESS, $lists);
}
}
... ...
... ... @@ -68,12 +68,19 @@ class AggregationSettingController extends BaseController
if($number > 1){
$this->param['top_banner'] = array_slice($this->param['top_banner'], 1);
}
}else{
if(empty($info['image'])){
$settingImageModel->edit(['image'=>reset($this->param['top_banner'])],['type'=>4,'project_id'=>$this->user['project_id']]);
if($number > 1){
$this->param['top_banner'] = array_slice($this->param['top_banner'], 1);
}
}
}
if($number > 3){
$this->param['top_banner'] = array_slice($this->param['top_banner'], 0, 3);
}
$this->param['top_banner'] = Arr::a2s($this->param['top_banner']);
}
$this->param['top_banner'] = Arr::a2s($this->param['top_banner'] ?? []);
if(isset($this->param['foot_banner']) && !empty($this->param['foot_banner'])){
$this->param['foot_banner'] = Arr::a2s($this->param['foot_banner']);
}
... ...
... ... @@ -99,7 +99,6 @@ class AiBlogService
$param['title'] = $title;
}
$param['anchor'] = $anchor;
$param['url'] = $this->route;
$param['mch_id'] = $this->mch_id;
$param['template_id'] = 1;
$this->sign = $this->generateSign($param,$this->key);
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2025/5/20
* Time: 14:49
*/
namespace App\Services;
use Illuminate\Support\Facades\Http;
/**
* AI去痕迹
* Class HumanizeAiTextService
* @package App\Services
*/
class HumanizeAiTextService
{
/**
* 封装接口地址
*/
const CMER_API = 'https://api.cmer.com/';
const DRIVER_HUMANIZE = 'humanize'; //3.9号停用 https://rapidapi.com/firdavscoder1/api/humanize1/playground/apiendpoint_4bdba3d9-c66a-4e3d-b1e9-ff307da08e96
const DRIVER_HUMANIZE_AI_TEXT = 'humanize-ai-text';
#=======================================================================================================================
#== AI生成内容 去除AI痕迹 ==
#== https://rapidapi.com/bilgisamapi-bilgisamapi-default/api/ai-content-detection-ai-detector-humanize-ai-text ==
#== https://rapidapi.com/firdavscoder1/api/humanize1/playground/apiendpoint_4bdba3d9-c66a-4e3d-b1e9-ff307da08e96 ==
#=======================================================================================================================
/**
* 去AI痕迹 header
* @param $driver
* @return array
*/
public function humanizeHeader($driver)
{
return [
'apikey' => 'kWd7wQbEPUF0fr17dnt5NQLazfv44O9T',
'X-CmerApi-Host' => $driver . '.p.cmer.com',
'Content-Type' => 'application/json',
];
}
/**
* 去AI痕迹提交
* FIXME humanize:返回请求ID:request_id, 需要异步获取结果
* @param string $text
* @param string $lang
* @return array|mixed
*/
public function humanizer($text, $lang)
{
$driver = self::DRIVER_HUMANIZE_AI_TEXT;
switch ($driver){
case self::DRIVER_HUMANIZE:
$action = 'humainzer/';
$readilibty = 'Marketing';
$mode = 'ENHANCED';
$params = compact('text', 'readilibty', 'mode');
$result = Http::withoutVerifying()->withHeaders($this->humanizeHeader($driver))->asForm()->post(self::CMER_API . $action, $params)->json();
break;
case self::DRIVER_HUMANIZE_AI_TEXT:
$action = 'humanizeContent?noqueue=1&language=' . $lang;
$params = compact('text');
$result = Http::withoutVerifying()->withHeaders($this->humanizeHeader($driver))->post(self::CMER_API . $action, $params)->json();
break;
default:
$result = [];
break;
}
return $result;
}
/**
* 去AI痕迹结果
* FIXME humanize:异步获取结果
* @param $request_id
* @return \Illuminate\Http\Client\Response
*/
public function humanizerResult($request_id)
{
$action = 'result/';
$params = compact('request_id');
return Http::withoutVerifying()->withHeaders($this->humanizeHeader(self::DRIVER_HUMANIZE))->asForm()->post(self::CMER_API . $action, $params);
}
}
... ...
... ... @@ -17,6 +17,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify');
Route::any('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry');
Route::any('/getDynamicPassword', [Aside\Com\IndexController::class, 'getDynamicPassword'])->name('admin.getDynamicPassword');
Route::any('/notAiHumanizer', [Aside\Com\IndexController::class, 'notAiHumanizer'])->name('admin.notAiHumanizer');
//会员相关
Route::prefix('user')->group(function () {
//会员管理
... ... @@ -574,6 +575,7 @@ Route::middleware(['aloginauth'])->group(function () {
//无需登录验证的路由组
Route::group([], function () {
Route::any('/login', [Aside\LoginController::class, 'login'])->name('admin.login.white');
Route::any('/stringTranslation', [Aside\Com\IndexController::class, 'stringTranslation'])->name('admin.stringTranslation');
// Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class, 'index'])->name('admin.image_show');
Route::any('/file/{hash}', [\App\Http\Controllers\File\FileController::class, 'index'])->name('admin.file_show');
Route::any('/download_files', [\App\Http\Controllers\File\FileController::class, 'downLoad'])->name('admin.files_downLoad');//导出文件
... ...