最近用織夢dedecms程序采集文章時(shí)候,發(fā)現(xiàn)每次采集都要去后臺更新一下文章、欄目、上下篇以及首頁,操作起來真心麻煩,后面在網(wǎng)上收集了一些代碼以及經(jīng)過自己調(diào)試,發(fā)現(xiàn)居然可以自動更新文章頁以及欄目、首頁。真心爽,這樣子就能穩(wěn)穩(wěn)的掛機(jī)采集了哈。這是免登陸接口帶自動更新,需要其他相關(guān)教程請移步《》《》
代碼附件下載地址:
代碼如下:
<?php /********密碼驗(yàn)證***********/ $password='密碼請自己修改'; //這個密碼是登陸驗(yàn)證用的.您需要在模塊里設(shè)置和這里一樣的密碼....注意一定需要修改. if($password!=$_GET['pw']) exit('驗(yàn)證密碼錯誤'); //安全檢測,密碼不符則退出 /****以下代碼非專業(yè)人員不建議修改***************/ if($_POST) $ispost=true; //require_once(dirname(__FILE__).'/config.php'); define('DEDEADMIN', ereg_replace("[/\\]{1,}", '/', dirname(__FILE__) ) ); require_once(DEDEADMIN.'/../include/common.inc.php'); require_once(DEDEINC.'/userlogin.class.php'); header('Cache-Control:private'); $dsql->safeCheck = false; $dsql->SetLongLink(); $cuserLogin = new userLogin(); $cuserLogin->userID = 1; //獲得當(dāng)前腳本名稱,如果你的系統(tǒng)被禁用了$_SERVER變量,請自行更改這個選項(xiàng) $dedeNowurl = $s_scriptName = ''; $isUrlOpen = @ini_get('allow_url_fopen'); $dedeNowurl = GetCurUrl(); $dedeNowurls = explode('?', $dedeNowurl); $s_scriptName = $dedeNowurls[0]; $cfg_remote_site = emptyempty($cfg_remote_site)? 'N' : $cfg_remote_site; //啟用遠(yuǎn)程站點(diǎn)則創(chuàng)建FTP類 if($cfg_remote_site=='Y') { require_once(DEDEINC.'/ftp.class.php'); if(file_exists(DEDEDATA."/cache/inc_remote_config.php")) { require_once DEDEDATA."/cache/inc_remote_config.php"; } if(emptyempty($remoteuploads)) $remoteuploads = 0; if(emptyempty($remoteupUrl)) $remoteupUrl = ''; $config = array( 'hostname' => $GLOBALS['cfg_ftp_host'], 'username' => $GLOBALS['cfg_ftp_user'], 'password' => $GLOBALS['cfg_ftp_pwd'], 'debug' => 'TRUE' ); $ftp = new FTP($config); //初始化FTP配置 if($remoteuploads==1){ $ftpconfig = array( 'hostname'=>$rmhost, 'port'=>$rmport, 'username'=>$rmname, 'password'=>$rmpwd ); } } function UpDateMemberModCache() { global $dsql; $cachefile = DEDEDATA.'/cache/member_model.inc'; $dsql->SetQuery("SELECT * FROM `dede_member_model` WHERE state='1'"); $dsql->Execute(); $fp1 = fopen($cachefile,'w'); $phph = '?'; $fp1Header = "<{$phph}php\r\nglobal \$_MemberMod;\r\n\$_MemberMod=array();\r\n"; fwrite($fp1,$fp1Header); while($row=$dsql->GetObject()) { fwrite($fp1,"\$_MemberMod[{$row->id}]=array('{$row->name}','{$row->table}');\r\n"); } fwrite($fp1,"{$phph}>"); fclose($fp1); } function DedeInclude($filename,$isabs=false) { return $isabs ? $filename : DEDEADMIN.'/'.$filename; } //config引用結(jié)束 //CheckPurview('a_New,a_AccNew'); require_once(DEDEINC.'/customfields.func.php'); require_once(DEDEADMIN.'/inc/inc_archives_functions.php'); if(file_exists(DEDEDATA.'/template.rand.php')) { require_once(DEDEDATA.'/template.rand.php'); } $dsql->SetSql("Select id as cid,reid as pid,typename as cname,ispart,topid from `dede_arctype` where channeltype =1 order by sortrank"); $dsql->Execute(); while($row=$dsql->GetObject()) { $cates[]=array('cid'=>$row->cid,'pid'=>$row->pid,'cname'=>$row->cname,'ispart'=>$row->ispart,'topid'=>$row->topid); } if(!$ispost) { echo "<select name='list'>"; echo maketree($cates,0,''); echo '</select>'; exit(); } /*-------------------------------- function __save(){ } -------------------------------*/ else { require_once(DEDEINC.'/image.func.php'); require_once(DEDEINC.'/oxwindow.class.php'); //檢驗(yàn)用戶登錄狀態(tài) $userinfo=$dsql->GetOne("Select * from `dede_member` where userid='$username'"); if(!$userinfo) exit("不存在用戶$username"); $uid = isset($userinfo['uid']) ? $userinfo['uid'] : $userinfo['mid']; //檢測欄目信息 foreach ($cates as $f=>$v) { if($v['cid']==$typeid) { $eid=$v; if($v['ispart']!=0) exit("該欄目不能發(fā)布內(nèi)容"); } } if(!$eid) exit("不存在的欄目id:$typeid"); require_once(DEDEINC.'/image.func.php'); //require_once(DEDEINC.'/oxwindow.class.php'); $flag = isset($flags) ? join(',',$flags) : ''; $notpost = isset($notpost) && $notpost == 1 ? 1: 0; if(emptyempty($typeid2)) $typeid2 = ''; if(!isset($autokey)) $autokey = 0; if(!isset($remote)) $remote = 0; if(!isset($dellink)) $dellink = 0; if(!isset($autolitpic)) $autolitpic = 0; if(emptyempty($click)) $click = ($cfg_arc_click=='-1' ? mt_rand(50, 200) : $cfg_arc_click); if(emptyempty($typeid)) { ShowMsg("請指定文檔的欄目!","-1"); exit(); } if(emptyempty($channelid)) { ShowMsg("文檔為非指定的類型,請檢查你發(fā)布內(nèi)容的表單是否合法!","-1"); exit(); } if(!CheckChannel($typeid,$channelid)) { ShowMsg("你所選擇的欄目與當(dāng)前模型不相符,請選擇白色的選項(xiàng)!","-1"); exit(); } //對保存的內(nèi)容進(jìn)行處理 if(emptyempty($writer))$writer=$username; if(emptyempty($source))$source='未知'; $pubdate = GetMkTime($pubdate); if(!$pubdate) $pubdate=time(); $senddate = time(); $sortrank = AddDay($pubdate,$sortup); $ismake = $ishtml==0 ? -1 : 0; $title = ereg_replace('"', '"', $title); $title = htmlspecialchars(cn_substrR($title,$cfg_title_maxlen)); $shorttitle = cn_substrR($shorttitle,36); $color = cn_substrR($color,7); $writer = cn_substrR($writer,20); $source = cn_substrR($source,30); $description = cn_substrR($description,$cfg_auot_description); $keywords = cn_substrR($keywords,60); $filename = trim(cn_substrR($filename,40)); $userip = GetIP(); $isremote = (empty($isremote)? 0 : $isremote); $serviterm=empty($serviterm)? "" : $serviterm; // if(!TestPurview('a_Check,a_AccCheck,a_MyCheck')) // { // $arcrank = -1; // } $adminid = $uid; //處理上傳的縮略圖 if(empty($ddisremote)) { $ddisremote = 0; } $litpic = GetDDImage('none', $picname, $ddisremote); //生成文檔ID $arcID = GetIndexKey($arcrank,$typeid,$sortrank,$channelid,$senddate,$adminid); if(empty($arcID)) { ShowMsg("無法獲得主鍵,因此無法進(jìn)行后續(xù)操作!","-1"); exit(); } if(trim($title) == '') { ShowMsg('標(biāo)題不能為空', '-1'); exit(); } //處理body字段自動摘要、自動提取縮略圖等 $body = AnalyseHtmlBody($body,$description,$litpic,$keywords,'htmltext'); //自動分頁 if($sptype=='auto') { $body = SpLongBody($body,$spsize*1024,"
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請注明: 織夢火車頭采集免登陸接口采集文章后自動更新欄目、首頁、文章頁