All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
如何让你的SQL运行得更快(2)_[SQL,Server教程]
轻松掌握Ajax.net系列教程七:使用ModalPopupExtender_[Asp.Net教程]
C#网络应用编程基础练习题与答案(六)_.net资料_编程技术
在SQL Server中使用NewID()产生随机集_[SQL Server教程]
同步两个Sql,server(1)_[SQL,Server教程]
C#教程:拖放技术的典型应用实例
Web2.0催生的蝴蝶效应,业务敏捷与SOA_.net资料_编程技术
六步使用ICallbackEventHandler实现无刷新回调_[Asp.Net教程]
不用GD库生成当前时间的PNG格式图象的程序_[PHP教程]
GDI+中的元文件
Reading number is top 10 pictures
黑社会大哥相亲
美女挤公交
China railway shunting skills competition
The household of rural style is designed
Cesarean section, bloody, silently into it!2
A resort photographed beautiful young woman change clothes process vomiting blood1
Thrilling English baby
大年初五接财神
China's family planning commission forced abortions 270 million newborns for 30 years
青春清纯美女大集合4
Download software ranking
尖东毒玫瑰B
WebService在.NET中的实战应用教学视频 → 第5集
The cock of the Grosvenor LTD handsome
美女写真2
SP4 for SQL2000
The Bermuda triangle3
Unix video tutorial10
The Bermuda triangle2
WebService在.NET中的实战应用教学视频 → 第1集
Boxer vs Yellow5
归海一刀 published in(发表于) 2014/2/17 7:33:35 Edit(编辑)
PHP实例:用PHP程序实现随机广告图片显示_[PHP教程]

PHP实例:用PHP程序实现随机广告图片显示_[PHP教程]

PHP实例:用PHP程序实现随机广告图片显示_[PHP教程]

#########随机广告显示##########
function myads(){
dir="ads"; #设置存放记录的目录
//dir="ads"; #设置存放记录的目录
ads="dir/ads.txt"; #设置广告代码文件
log ="dir/ads.log"; #设置ip记录文件

ads_lines=file(ads);
lines=count(ads_lines);#文件总行数

####读出广告总数ads_count和显示次数到数组display_array########
ads_count=0;
display_count=0;
for (i=0;i if((!strcmp(substr(ads_lines[i],0,7),"display"))){
ads_count+=1;
display_array[ads_count]=substr(ads_lines[i],8);
display_count+=display_array[ads_count];
}
}
####决定随机显示序号display_rand#####
srand((double)microtime()*1000000);
display_rand = rand(1,display_count);

###决定广告序号ads_num######
pricount=0;
ads_num=1;
for(i=1; i<=ads_count; i++) {
pricount += display_array[i];
if (display_rand<=pricount) {ads_num=i;break;}
}

#####播放广告########
num=0;
flag=0;

for(i=0;i if((!strcmp(substr(ads_lines[i],0,7),"display"))){num++;}
if((num==ads_num)and(flag==0)){flag=1;continue;}
if((flag==1)and strcmp(ads_lines[i][0],"#")){echo ads_lines[i];continue;}
if((flag==1)and(!(strcmp(ads_lines[i][0],"#")))){break;}
}
####纪录广告显示次数#########
fp=fopen(log,"a");
fputs(fp,date( "Y-m-d H:i:s " ).getenv("REMOTE_ADDR")."==>".ads_num."\n");
fclose(fp);
}
?>


广告代码文件ads.txt


########每个广告代码之间用'#'隔开,display为显示加权数,越大显示次数越多######
display=10


################################
display=10


调用即可







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.