1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
| <?php
require_once("include/common.php");
require_once("include/main.class.php");
require_once("data/config.cache.inc.php");
//设置每次推送的条数
$tnum = 30;
$remain = $_REQUEST['remain'];
$remain = isset($remain) ? intval($remain) : $tnum;
/*百度推送系统更新,不再限制推送条数,但remain参数保留,始终为1,为了防止官方把remain参数再次用上,这边也把remain保留,但不影响推送功能
百度推送好像限制了不能重复推送,否则将禁止该网站推送功能,现在只能每个地址推送一次。如果有的网友想重复推送,请往下看。
if($remain>30)
$pagesize=30;
else
$pagesize=$remain;
*/
$pagesize=$tnum;
$wheresql = "where v_push = 0 ";
$trow = $dsql->GetOne("Select count(*) as dd From `sea_data` $wheresql");
$totalnum = $trow['dd'];
//当总页数小于每页数目的时候,替换pagesize
if($totalnum<$pagesize)
$pagesize = $totalnum;
if(empty($totalpage)) $totalpage=ceil($totalnum/$pagesize);
if($totalnum==0 || $page>$totalpage || $remain==0){
/*---------------------------如果依然想重复推送的朋友,你可以把下面三行代码给注释掉。------------------------------*/
echo "恭喜,已推送所有内容页!";
echo "<br>暂停3秒后继续推送<script language=\"javascript\">setTimeout(\"baiduPush();\",3000);function baiduPush(){location.href='?remain=1';}</script></div>";
return;
/*---------------------------如果依然想重复推送的朋友,你可以把上面三行代码给注释掉。------------------------------*/
/*---------------------------如果依然想重复推送的朋友,你可以把下面三行代码注释给取消掉。-------------------------*/
//$query = "Update `sea_data` set v_push=0";
//$dsql->ExecuteNoneQuery($query);
//$pagesize = $tnum;
/*---------------------------如果依然想重复推送的朋友,你可以把上面三行代码注释给取消掉。-------------------------*/
}
$dsql->SetQuery("Select v_id From `sea_data` $wheresql order by v_id desc limit 0,$pagesize");
$dsql->Execute('video_list');
$plink ="";
$urls = array();
$ids = array();
$result ="{}";
while($row=$dsql->GetObject('video_list'))
{
$v_id = $row->v_id;
/*-----------------------------------------------------------------------------------------------------------*/
/*通过v_id来拼接内容页的地址,动态、伪静态、静态的内容页地址规律都不一样,请大家自行修改。$cfg_basehost代表你的域名*/
/*!!!!!!!!注意这里暂不支持已电影拼音做内容页地址的链接推送!!!!!!!!!!*/
/*-----------------------------------------------------------------------------------------------------------*/
$plink = $cfg_basehost."/detail/index".$v_id.".html"; //来源页面网址
array_push($urls ,$plink);
array_push($ids ,$v_id);
@ob_flush();
@flush();
}
//百度推送API地址,请各自去百度站长平台查看自己的token
$api = 'http://data.zz.baidu.com/urls?site=www.xxx.com&token=es8rdbhGjGjhUJBfNI';
$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);
$result_json = json_decode($result, true);
if(isset($result_json["remain"]))
{
//对ids数组循环,提示推送成功id,更新对应id的v_push=1
foreach ($ids as $vid){
$query = "Update `sea_data` set v_push=1 where v_id='$vid'";
$dsql->ExecuteNoneQuery($query);
echo $result ."已成功推送URL:".$cfg_basehost."/detail/index".$vid.".html";
echo '<br />';
}
$remaincount = $result_json["remain"];
echo "<br>暂停3秒后继续推送<script language=\"javascript\">setTimeout(\"baiduPush();\",3000);function baiduPush(){location.href='?remain=".$remaincount."';}</script></div>";
}
else
{
echo "今天百度推送次数已达上限!请明天再推送!";
echo "<br>暂停3秒后继续推送<script language=\"javascript\">setTimeout(\"baiduPush();\",3000);function baiduPush(){location.href='?remain=1';}</script></div>";
exit();
}
?>
|