龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

防止采集的一個小程序 By 暖月

2015.09.10 | 17閱讀 | 0條評論 | 未命名

功能描述: 默認(rèn)設(shè)置完成24小時內(nèi)僅僅允許單用戶瀏覽5000個頁面。

引用:
<? //參數(shù)設(shè)置 $settime="86400"; //控制多久的采集數(shù)量,單位秒 $setsum="5000"; //在這個時間內(nèi)最多允許采集多少條 $setnotic="細(xì)水長流,采集因過量而被終止,建議24小時后重新嘗試。"; //如果條件吻合,給出的提示 $seturl="http://www.minblog.cn/"; //提示之后轉(zhuǎn)移的頁面 //參數(shù)設(shè)置 ob_start(); $utime=$HTTP_COOKIE_VARS["utime"]; $usee=$HTTP_COOKIE_VARS["usee"]; if(!$utime){ setcookie("utime", time(), time()+$settime); setcookie("usee", 1, time()+$settime); }elseif($utime>=(time()-$settime) and $usee>=$setsum){ echo "<script>alert('".$setnotic."');location.href='".$seturl."';</script>"; //說明:如果是html調(diào)用(使用方法 2),把本行刪除,下一行開頭的//刪除即可 // echo "alert('".$setnotic."');location.href='".$seturl."';"; }elseif($utime>=(time()-$settime) and $usee<$setsum){ setcookie("usee", $usee+1, time()+$settime); }else{ setcookie("utime", time(), time()+$settime); } ?> 使用方法: 1、php文件直接加入 保存文件為 ****.php 在你要套用的php程序頁面頂部加入
引用:
<? include "****.php"; ?> 即可 2、html頁面加入 保存文件為 ****.php ,在html模板中加入以下代碼。注意文件路徑
引用:
<script src="****.php" type="text/javascript"></script> 適用范圍: Discuz!,PHPWind...

贊 (

發(fā)表評論