raksmart活动促销

分享

写回答

发帖

悬赏求助GODADDY免费空间的广告功能

回答|共 13 个

bingu

发表于 2008-12-13 18:14:28 | 显示全部楼层

100银币没精神,100rmb可能会考虑。
回复

使用道具 举报

blog

发表于 2008-12-14 02:35:05 | 显示全部楼层

转载一个解决方案

我自己没这么试过:
------------------分割--------------------
服务器环境是centos 4.2 /apache 2.0.52

首先加载mod_ext_filter
在/etc/httpd/conf/httpd.conf
的Dynamic Shared Object (DSO) Support节
加入
Code:

LoadModule ext_filter_module modules/mod_ext_filter.so


然后定义filter的名字(advtext)和配置filter要调用程序的名字(gingeradv)。

Code:

ExtFilterDefine advtext mode=output intype=text/html cmd="/usr/bin/gingeradv"


在Directory标签里加入如下行。
Code:

SetOutputFilter advtext


加入后看起来如下
Code:

<Directory />
   Options FollowSymLinks
   AllowOverride None
   SetOutputFilter fixtext
</Directory>


用于加入广告的程序gingeradv是用perl写的,自己笨写的很垃圾。

Code:

#!/usr/bin/perl
my @lines = <STDIN>;
open ADVLINE, "/var/www/html/abc.txt" or die "cant't find the adv files";
my @advlines = <ADVLINE>;
print @lines,@advlines;


记得要给这个文件执行的权限。
Code:

chmod a+x gingeradv


要显示的广告保存在/var/www/html/abc.txt里。
我用于测试的这个是一个google的Google AdSense
abc.txt如下
Code:

<script type="text/j avascript"><!--
google_ad_client = "pub-5617089787488679";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
//--></script>
<script type="text/j avascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>


然后重新启动apache服务器

Code:

apachectl graceful


在浏览器里访问效果如下。

apachefilter


但是这样虽然解决了问题,但perl程序好像写的很笨拙,估计没有效率。
还有这种工作方式每个请求都会调用这个perl脚本,估计访问量大的时候会不怎么好。
自己猜想写个动态加载的so才是正路,可惜不会,慢慢学习中,但愿我能学习。
回复

使用道具 举报

kyxt

发表于 2008-12-14 13:27:21 | 显示全部楼层

静态页面可以用 SSI搞定
更普遍的,看看这个apache的模块: http://bbs.zzbaike.com/thread-4801-1-1.html

你的应该用SSI就可以了
回复

使用道具 举报

sevenstar

发表于 2009-7-9 14:54:27 | 显示全部楼层

帮你顶一下!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则