织梦全站进行推送/按时间推送功能插件

   因为业务需要,就花十多分钟做了这个插件,不能说插件,就是一个php执行文件,放在根目录运行即可,在此附上代码:

 

   

<?php
require_once ("include/common.inc.php");
require_once "include/arc.partview.class.php";
require_once('include/charset.func.php');
$year = date("Y");
$month = date("m");
$day = date("d");
$dayBegin = mktime(0,0,0,$month,$day,$year);//当天开始时间戳
$dayEnd = mktime(23,59,59,$month,$day,$year);//当天结束时间戳
$query = "SELECT arch.id,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate<".$dayEnd." AND pubdate>".$dayBegin.""; //这里dede换成你们自己的表前缀
$urls="";
$dsql->Execute('arch.id,types.typedir',$query);
while($row = $dsql->GetArray('arch.id,types.typedir'))
{
 $urls.="http://www.domain.com".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".","; 
}
$urls=substr($urls,0,-1);
$urls = explode(",",$urls);
$api = 'http://data.zz.baidu.com/urls?site=秘钥'; // 前边的site换成自己的site xxx换成自己的密钥
$ch = curl_init();
$options = array(
 CURLOPT_URL => $api,
 CURLOPT_POST => true,
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_POSTFIELDS => implode("\n", $urls),
 CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result.count($urls);
?>

  

posted @ 2019-07-18 11:33  圆柱模板  阅读(776)  评论(0编辑  收藏  举报