GetOne(" Select * From `#@__wx_mp_content` where id='$wx_content_id' "); $title = $wx_content['title'] ? $wx_content['title'] : ''; $description = $wx_content['description'] ? $wx_content['description'] : ''; $body = $wx_content['content'] ? $wx_content['content'] : ''; } //采集单个网页 if(preg_match("#^http:\/\/#", $geturl)) { require_once(DEDEADMIN."/inc/inc_coonepage.php"); $redatas = CoOnePage($geturl); extract($redatas); } //获得频道模型ID if($cid>0 && $channelid==0) { $row = $dsql->GetOne("Select channeltype From `#@__arctype` where id='$cid'; "); $channelid = $row['channeltype']; } else { if($channelid==0) { $channelid = 1; } } //获得频道模型信息 $cInfos = $dsql->GetOne(" Select * From `#@__channeltype` where id='$channelid' "); //获取文章最大id以确定当前权重 $maxWright = $dsql->GetOne("SELECT COUNT(*) AS cc FROM #@__archives"); //普通文章添加也显示公众号列表 $wx_user_list = array(); $wx_user_sql = "select name,uid,ch_name from `#@__wx_mp_list` where 1 and status=1 and uid != 0 ORDER BY id DESC"; $dsql->SetQuery($wx_user_sql); $dsql->Execute('wx_user_sql'); while ($row = $dsql->GetArray('wx_user_sql')) { $wx_user_list[] = $row; } //add sunjinliang 来自 AI合并或生成文章(hqjf@manage/templets/ai_question_list.htm) 2023.5.16 $ai_ids = isset($ai_ids) ? trim($ai_ids) : ''; $questionLogic = new QuestionLogic(); $aiArticleData = $questionLogic->getMakeArticleData($ai_ids); if (!empty($aiArticleData['title'])) { $title = $aiArticleData['title']; $cid = $aiArticleData['typeid']; $body = $aiArticleData['content']; } //end //add sjl 2024.02.21增加研究院 $ysLogic = new \hqjfmanage\logic\yingsheng\YsLogic(); $researchConf = $ysLogic->getCacheVideoTypeConf(); //end include DedeInclude("templets/article_add.htm"); exit(); } /*-------------------------------- function __save(){ } -------------------------------*/ else if($dopost=='save'){ DebugTime::setDebugTimeInfo("【新增文章】1开始"); require_once(DEDEINC.'/image.func.php'); require_once(DEDEINC.'/oxwindow.class.php'); $flag = isset($flags) ? join(',',$flags) : ''; //增加研究院必要字段验证 add sjl 2024.2.21 if (!empty($research)) { //验证类型, 和产业分类 if (empty($extra_type)) { ShowMsg("请选择类型!","-1"); exit(); } if (empty($industry_type)) { ShowMsg("请选择产业分类!","-1"); exit(); } } //end //需要推送异步的数据,将一些业务异步执行,优化速度慢 article_edit.php 也会用到 $pushAsync = array(); $thumb_needwatermark = isset($thumb_needwatermark) ? $thumb_needwatermark : 0; $notpost = isset($notpost) && $notpost == 1 ? 1: 0; if(empty($typeid2)) $typeid2 = ''; //3g新闻的 不要typeid2_2 不能选18 start $arr_3g = range(413,423); $arr_3g = array_merge($arr_3g,array(425,791)); //新科技的 也不要typeid2_2 $arr_new_tech = array_merge(range(1067,1072),array(1063,1074)); $arr_3g = array_merge($arr_3g,$arr_new_tech); if(in_array($typeid,$arr_3g)&&($typeid2_2==18)){ $typeid2_2 = ''; } //3g新闻的 不要typeid2_2 不能选18 end //// $typeid2 = implode(',',array_filter(explode(',',$typeid2.','.$typeid2_2))); if(!isset($autokey)) $autokey = 0; if(!isset($remote)) $remote = 0; if(!isset($dellink)) $dellink = 0; if(!isset($autolitpic)) $autolitpic = 0; if(!isset($weight)) $weight = 0; if(empty($click)) $click = ($cfg_arc_click=='-1' ? mt_rand(50, 200) : $cfg_arc_click); if(empty($typeid)) { ShowMsg("请指定文档的栏目!","-1"); exit(); } if(empty($channelid)) { ShowMsg("文档为非指定的类型,请检查你发布内容的表单是否合法!","-1"); exit(); } if(!CheckChannel($typeid,$channelid)) { ShowMsg("你所选择的栏目与当前模型不相符,请选择白色的选项!","-1"); exit(); } if(!TestPurview('a_New')) { CheckCatalog($typeid,"对不起,你没有操作栏目 {$typeid} 的权限!"); } //对保存的内容进行处理 if(empty($writer))$writer=$cuserLogin->getUserName(); if(empty($source))$source='未知'; $pubdate = GetMkTime($pubdate); $senddate = time(); $sortrank = AddDay($pubdate,$sortup); $ismake = $ishtml==0 ? -1 : 0; $title = preg_replace("#\"#", '"', $title); $title = htmlspecialchars(cn_substrR($title,$cfg_title_maxlen)); $shorttitle = cn_substrR($shorttitle,80); $color = cn_substrR($color,7); $writer = cn_substrR($writer,20); $source = cn_substrR($source,30); //$description = cn_substrR($description,$cfg_auot_description); $description = trim(cn_substrR($description,1000)); $keywords = cn_substrR($keywords,60); $filename = trim(cn_substrR($filename,40)); $userip = GetIP(); $isremote = (empty($isremote)? 0 : $isremote); $serviterm=empty($serviterm)? "" : $serviterm; $voteid = $voteid ? intval($voteid) : 0; $store_flag = $store_flag ? intval($store_flag) : 0; $wx_user_id = isset($wx_user_id) ? intval($wx_user_id) : 0; $is_md = 2;//是否是markdown 编辑器 1 md,2 普通 $isValid = empty($isValid) ? 0 : 1; $vip_limit = empty($vip_limit) ? 0 : $vip_limit; if(isset($weight_num)){ $weight_num = intval($weight_num); }else{ $weight_num = 0; } if(!is_numeric($weight_num) || ($weight_num < 0) ){ ShowMsg("排序权重请输入0-99999的数值", "-1"); exit(); } if(!TestPurview('a_Check,a_AccCheck,a_MyCheck')) { $arcrank = -1; } DebugTime::setDebugTimeInfo("【新增文章】3-1参数接收"); // modify by 刘平 2015年8月20日 添加定时发布功能 if (isset($_POST['timedrelease']) && $timedrelease == 1) { $arcrank = -1; } $dutyadmin = $cuserLogin->getUserID(); //后台发文时,如果有关联的前台用户,则mid去前台用户的uid (QiHaoyang 20220616) $adminid = getUidByAdminId($dutyadmin); //微信采集的 if($wx_content_id){ //$arcrank = -1; $info = $dsql->GetOne("SELECT target_wx_name FROM `#@__wx_mp_content` WHERE id='$wx_content_id' "); $wx_name = $info['target_wx_name']; $wx_uid_arr = $dsql->GetOne("SELECT uid, ch_name FROM `#@__wx_mp_list` WHERE name='$wx_name' "); if($wx_uid_arr && ($wx_uid_arr['uid'] > 0)){ $adminid = $wx_uid_arr['uid']; $flag = ($flag=='' ? 'z' : $flag.',z'); } $store_flag = 13; //爬取微信公众号文章,作者设置为空 $writer = ''; } //处理上传的缩略图 if(empty($ddisremote)) { $ddisremote = 0; } DebugTime::setDebugTimeInfo("【新增文章】3-1参数接收"); $litpic = GetDDImage('none', $picname, $ddisremote); DebugTime::setDebugTimeInfo("【新增文章】4GetDDImage"); //生成文档ID $arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$adminid); DebugTime::setDebugTimeInfo("【新增文章】5 GetIndexKey 生成文档ID"); if(empty($arcID)) { ShowMsg("无法获得主键,因此无法进行后续操作!","-1"); exit(); } if(trim($title) == '') { ShowMsg('标题不能为空', '-1'); exit(); } //处理body字段自动摘要、自动提取缩略图等 $is_need_water = 1; if($wx_content_id){ $is_need_water = 0; } $body = AnalyseHtmlBody($body,$description,$litpic,$keywords,'htmltext',$is_need_water,$thumb_needwatermark); DebugTime::setDebugTimeInfo("【新增文章】5AnalyseHtmlBody"); //自动分页 if($sptype=='auto') { $body = SpLongBody($body,$spsize*1024,"#p#分页标题#e#"); } // 去掉URL路径中包含的后台域名 $body = str_replace('http://'.$_SERVER['HTTP_HOST'].'/', '/', $body); //分析处理附加表数据 $dede_addonData = []; $set = explode(';',$dede_addonfields); foreach ($set as $k => $v){ $key = explode(',',$v)[0]; $dede_addonData[$key] = $$key; } $list = getInfoByBody($dede_addonfields,$dede_addonData); $check_video_url = $list['check_video_url']; $inadd_f_arr = $list['inadd_f']; $inadd_v_arr = $list['inadd_v']; foreach ($list['data'] as $k => $v){ $$k = $v; } // var_dump($video_url);exit; //2020-07-14 周思成 检查视频是否存在 if(!empty($check_video_url)){ $urlResult = get_headers($check_video_url,1); if(!preg_match('/200/',$urlResult[0])){ ShowMsg("视频地址不可用,请检查后重新填写", "-1"); exit(); } } //保存到主表 if(is_numeric($wx_user_id)&&($wx_user_id>0)){ //专栏标志 $flag = ($flag=='' ? 'z' : $flag.',z'); $insertMid = $wx_user_id; $unionId = (int)getUidByMid($wx_user_id,1); }else{ $insertMid = $adminid; $unionId = (int)getUidByMid($adminid,1); } //处理图片文档的自定义属性 //跳转网址的文档强制为动态 //加mysql中间件后 keywords太长会报错 $handleFlagInfo = handleFlagInfo($flag,$litpic,$redirecturl,$keywords,$ismake); $flag = $handleFlagInfo['flag']; $ismake = $handleFlagInfo['ismake']; $keywords = $handleFlagInfo['keywords']; //添加推荐时间 $archivesLogic = new \hqjfmanage\logic\article\ArchivesLogic(); $recommend_date = $archivesLogic->getRecommendTime($arcID,$isValid, $flag); if ($typeid != 1075 && strpos($flag,'z')!==false){ //不是电子说,却勾选了 z 专栏 需要去掉z $flag = explode(',',$flag); $flag = implode(',',array_diff($flag, ['z'])); } $query = "INSERT INTO `#@__archives`(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle, color,writer,source,litpic,pubdate,senddate,mid,unionid,voteid,notpost,description,keywords,filename,dutyadmin,weight,store_flag,vip_limit) VALUES ('$arcID','$typeid','$typeid2','$sortrank','$flag','$ismake','$channelid','$arcrank','$click','$money', '$title','$shorttitle','$color','$writer','$source','$litpic','$pubdate','$senddate', '$insertMid','$unionId','$voteid','$notpost','$description','$keywords','$filename','$dutyadmin','$weight','$store_flag','$vip_limit');"; if(!$dsql->ExecuteNoneQuery($query)) { $gerr = $dsql->GetError(); $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'"); ShowMsg("把数据保存到数据库主表 `#@__archives` 时出错,请把相关信息提交给DedeCms官方。".str_replace('"','',$gerr),"javascript:;"); exit(); } //保存到附加表 $cts = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$channelid' "); $addtable = trim($cts['addtable']); if(empty($addtable)) { $dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'"); $dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'"); ShowMsg("没找到当前模型[{$channelid}]的主表信息,无法完成操作!。","javascript:;"); exit(); } $useip = GetIP(); $templet = empty($templet) ? '' : $templet; //推荐权重 //代码块处理 前端自己处理了 $body = UtilHelper::doPreCodeOfBody($body); $weight_num = (strstr($flag,'c') !== false) ? $weight_num : 0; $inadd_f = $inadd_v = ''; foreach ($inadd_f_arr as $k => $v){ $inadd_f .= ','.$v; $inadd_v .= ',\''.$inadd_v_arr[$k] . '\''; } $bodyMd5 = \hqjfmanage\utils\UtilHelper::md5HtmlText($body); $query = "INSERT INTO `{$addtable}`(aid,typeid,redirecturl,templet,userip,body_md5,body{$inadd_f},is_md,weight_num) Values('$arcID','$typeid','$redirecturl','$templet','$useip','$bodyMd5','$body'{$inadd_v},$is_md,$weight_num)"; if(!$dsql->ExecuteNoneQuery($query)) { $gerr = $dsql->GetError(); $dsql->ExecuteNoneQuery("Delete From `#@__archives` where id='$arcID'"); $dsql->ExecuteNoneQuery("Delete From `#@__arctiny` where id='$arcID'"); ShowMsg("把数据保存到数据库附加表 `{$addtable}` 时出错,请把相关信息提交给DedeCms官方。".str_replace('"','',$gerr),"javascript:;"); exit(); } DebugTime::setDebugTimeInfo("【新增文章】6记录相关表 "); //记录焦点图来源地址 周思成 202-05-25 saveImageSource('', $litpic, $litpic_source); DebugTime::setDebugTimeInfo("【新增文章】6记录缩略图来源地址saveImageSource "); //// modify by 刘平 2015年8月20日 添加文章定时发布功能 $param = isset($_POST['timedrelease']) && $timedrelease == 1; handleTimedrelease($param,$arcID,$pubdate,$dsql); //维护文档主副栏目关系 modify sjl 2023.10.18 $arcTypeid2Logic = new \hqjfmanage\logic\article\ArchivesTypeid2Logic(); $arcTypeid2Logic->updateArcTypeid2($arcID, $typeid, $typeid2,$arcrank); //文档属性关系 $arcFlagLogic = new \hqjfmanage\logic\article\ArcFlagLogic(); $arcFlagLogic->updateArcFlag($arcID, $flag); DebugTime::setDebugTimeInfo("【新增文章】11 执行一些sqlredis "); //更新tag信息 InsertTags($tags,$arcID); DebugTime::setDebugTimeInfo("【新增文章】12 更新tag信息 "); //// 维护搜索引擎 $id = $arcID; //// 维护搜索引擎 //handleXunsou($id,$arcrank,$dsql); DebugTime::setDebugTimeInfo("【新增文章】13 生成文章html之前的sql处理 "); //微信采集的设置为已经审核和回填aid if($wx_content_id){ $dsql->ExecuteNoneQuery("UPDATE `#@__wx_mp_content` set status=1 , aid={$arcID} where id='{$wx_content_id}' limit 1"); } //add sunjinliang 2024.2.21 增加研究院 if (!empty($research)) { $arcResearchLogic = new \hqjfmanage\logic\article\ResearchLogic(); $researchData = ['extra_type' => $extra_type, 'industry_type' => $industry_type]; $arcResearchLogic->add($researchData, $arcID); } //end $pushAsync['keyMakeArt'] = array( 'arcID' => $arcID, 'isremote' => $isremote, ); $is_online = 0; if(DEDE_ENV == 'prod'){ $is_online = 1; } //如果是原创向百度提交 start $is_original = 0; if(strpos($flag,'y')!==false){ $is_original = 1; } //百度推送, if(DEDE_ENV == 'prod' && ($arcrank>-1)){ if ($ismake == 1) { //向百度提交实时资讯 $push_id_arr = array($id); $pushAsync['key_push_content_to_baidu_shishi'] = array( 'push_id_arr' => $push_id_arr, ); } //需要推送百度ping 或者 熊掌号 已改为异步 $pushAsync['key_push_content_to_baidu_ping_or_xiongzhang'] = array( 'id' => $id, 'is_y' => $is_original ); $to_baidu_msg = '推送百度,已改为异步执行';//$pushRes['msg']; } if(DEDE_ENV == 'prod' && ($arcrank>-1)){ //需要推送百度ping 或者 熊掌号 已改为异步 $pushAsync['key_push_content_to_baidu_ping_or_xiongzhang'] = array( 'id' => $id, 'is_y' => $is_original, ); $to_baidu_msg = '推送百度,已改为异步执行';//$pushRes['msg']; } //如果是原创向百度提交 end //向百度提交实时资讯 if(($ismake == 1 )&&($arcrank>-1)&&$is_online){ $push_id_arr = array($id); $pushAsync['key_push_content_to_baidu_shishi'] = array( 'push_id_arr' => $push_id_arr, ); //push_content_to_baidu_shishi($push_id_arr); //DebugTime::setDebugTimeInfo("【新增文章】18 推送 向百度提交实时资讯 "); } //维护es索引文档 start handleEs($arcID,$dsql); //维护es索引文档 end //添加文章添加记录 $ip = GetIP(); $visitor = $_COOKIE['visitor']; $dsql->ExecuteNoneQuery("insert into #@__arc_edit_log (aid,mid,visitor,ip,addtime) values ($arcID,$dutyadmin,'$visitor','$ip',$senddate) "); if($artUrl=='') { $artUrl = $cfg_phpurl."/view.php?aid=$arcID"; } ClearMyAddon($arcID, $title); DebugTime::setDebugTimeInfo("【新增文章】19 ClearMyAddon "); if ($arcrank>=0) { /** * 推送到BBS个人主页动态 */ $pushAsync['keyPushQueueAdd'] = array( 'typeid' => $typeid, 'typeid2' => $typeid2, 'channelid' => $channelid, 'adminid' => $adminid, 'wx_content_id' => $wx_content_id, 'wx_uid_arr' => $wx_uid_arr, 'arcID' => $arcID, 'title' => $title, 'litpic' => $litpic, 'mid' => $insertMid, 'unionid' => $unionId, ); } $unaudited_count = get_unaudited_count($adminid); DebugTime::setDebugTimeInfo("【新增文章】21 get_unaudited_count "); //写入置顶头图操作modify sjl 20230420 if($isValid == 1){ //审核通过 或定时发布的 if ($arcrank == 0 || !empty($timedrelease)) { require_once dirname(__DIR__) . '/hqjf@manage/inc/inc_article_func.php'; $bigicname = empty($bigpicname) ? '' : $bigpicname; $bigpicname_source = empty($bigpicname_source) ? '' : $bigpicname_source; editAritcleTop($arcID, $isValid, $bigicname, $bigpicname_source, 0); } } //end DebugTime::dumpDebugTime('新增文章'); if (!empty($pushAsync)){ sleep(2); //推送异步消息 elecfans_script项目会消费,并且异步调用 article_add_edit_async.php $pushQueue = new \hqjfmanage\logic\queue\Queue(); //新增文章事件 $push = []; $push['id'] = $id; $push['event'] = 'elecfans.article.add'; $push['eventTime'] = time(); $push['pushTime'] = time(); //这里需要是jsonobject 不能是 jsonarray $push['data'] = $pushAsync; $pushQueue->push_topic_queue($push,'elecfansScript',$push['event']); } $msg_notice = $unaudited_count > 0 ? '您有'.$unaudited_count.'篇待审' : ''; //返回成功信息 $msg = " 请选择你的后续操作: 继续发布文章 查看文章(已改为异步,当前按钮可能不准确) 更改文章 已发布文章管理 ".$msg_notice." $backurl "; if($is_original){ $msg.=" ".$to_baidu_msg; } $msg = "