打造計(jì)數(shù)器DIY3步曲(中)
發(fā)表時(shí)間:2024-01-17 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]本篇將介紹在自己的鏡像站上也能放上自己的計(jì)數(shù)器。 我以假設(shè)您有多個(gè)鏡像站為例,首先在數(shù)據(jù)表中插入幾個(gè)新的數(shù)據(jù)num、visited,這在你的鏡像站上將用的著,只要將上篇中的count1.php改一下即可. 先建立一個(gè)文件夾count,里面放上您要用的文件count2.php,cou...
本篇將介紹在自己的鏡像站上也能放上自己的計(jì)數(shù)器。
我以假設(shè)您有多個(gè)鏡像站為例,首先在數(shù)據(jù)表中插入幾個(gè)新的數(shù)據(jù)num、visited,這在你的鏡像站上將用的著,只要將上篇中的count1.php改一下即可.
先建立一個(gè)文件夾count,里面放上您要用的文件count2.php,count3.php……,舉個(gè)例子,如count2的源碼,將count1.php改成:
<?
$linkptr=mysql_pconnect("localhost","yourname","password");
mysql_select_db("yourname",$linkptr);
mysql_query("update counter
set visited=visited+1 where num=2",$linkptr);
$result=mysql_query("select visited
from counter where num=2",$linkptr);
list($counter)=mysql_fetch_row($result);
$counter=sprintf("%05d",$counter);
for($i=0;$i<5;$i++){
$tmpstr="<img src=http://cnfree.oso.com.cn/img/".substr($counter,$i,1).".GIF border=0 >";
echo $tmpstr;
}
?>
注意:"<img src=……"中一定要放上完整的路徑,否則您的計(jì)數(shù)器將無(wú)法顯示出來(lái)!
做完這一步,我們?cè)俳⒁粋(gè)文件夾show,里面放上對(duì)應(yīng)的文件show2.php,
show3.php……,以show2.php為例,源碼寫為:
document.write("<a href=http://cnfree.oso.com.cn target=_blank title= 中國(guó)免費(fèi)資源信息聯(lián)盟 ><? include "../count/count2.php" ?></a>");
注意:<? include "../count/count2.php" ?>別忘了count前打上兩點(diǎn),這才是完整的路徑!
最后,在您的鏡像站上適當(dāng)?shù)奈恢梅胖么a:
<script language=javascript src=http://cnfree.oso.com.cn/show/show2.php></script>
http://cnfree.oso.com.cn 是我在OSO上的空間,您可以換成您自己的!
好了,一切OK!看看您的鏡像站主頁(yè)計(jì)數(shù)器是否也顯示出來(lái)了?下篇我只是介紹向您的站點(diǎn)會(huì)員提供免費(fèi)計(jì)數(shù)器的一些構(gòu)思,基本上就是本篇內(nèi)容的一些拓展.