今天安装了openads2.0.11版本,想起之前的广告bug,也就是flash文件曾经碰到的错误,URL地址的问题,所以今天特意修复一下,本身首页也还有雀巢的广告。

问题阐述:

客户的网址是这样的:http://server1.adpolestar.net/ADPolestar/lgs/way/;er=&mv=710&pu=ctharmony&ad=0038108?http://www.nescafe.com.cn/promotion/index.asp

经过广告系统后就是:
http://server1.adpolestar.net/ADPolestar/lgs/way/;er=?mv=710&pu=ctharmony&ad=0038108?http://www.nescafe.com.cn/promotion/index.asp

;er=&mv 变成 ;er=?mv 导致传递到adpolestar方会少一个参数或者网址不同而出错了。

openads是会改变flash的链接的脚本的,把按钮地址变成:

on (release)
{
   getURL(_root.alink1, _root.atar1);
}


然后在代码里面传递变量 a.swf?alink1=****

一般的情况下,openads都会把urlencode一下,图片广告做这样的链接都没有问题,链接都是正常的,到了flash里就不同了,传递到flash的内容是通过参数传递的,虽然参数经过了urlencode,但是在flash里面的脚本却经过了unescape的,所以,网址变化如下:

1 要传递的参数是 a.swf?alink1=http://www.aslibra.com/blog/index.php
2 经过编码传递 a.swf?alink1=http%3A%2F%2Fwww.aslibra.com%2Fblog%2Findex.php
3 flash脚本处理后,其实获得的是  a.swf?alink1=http://www.aslibra.com/blog/index.php
4 也就是经过flash点击后,网址的参数没有编码

可以看到,碰到问题的url是变成了这样的:
adclick.php?dest=http://server1.adpolestar.net/ADPolestar/lgs/way/;er=&mv=710&pu=ctharmony&ad=0038108

阿权查看过adclick.php,里面是先检查自身系统用的变量,把所有变量都加在dest后面:


// Get vars
if (isset($_GET))
 foreach (array_keys($_GET) as $key)
 {
   if ($key != 'bannerid' &&
     $key != 'zoneid' &&
     $key != 'source' &&
     $key != 'dest' &&
     $key != 'ismap' &&
     $key != 'log' &&
     $key != 'trackonly' &&
     $key != 'n' &&
     $key != 'cb')
     $vars[] = $key.'='.$_GET[$key];
 }


以上是获取变量,非系统变量存在vars里面,POST的处理就不说了

if (isset($vars) && is_array($vars) && sizeof($vars) > 0)
{
 if (strpos ($url, '?') > 0)
   $url = $url.'&'.implode ('&', $vars);
 else
   $url = $url.'?'.implode ('&', $vars);
}


这个对于常理的链接是没有错误的,就算没有被编码过,那也是正常的,但是这里碰到的就是不正常的网址,不包含"?"字符,而直接就在后面有&字符,导致&后面的字符串被拆分为变量了。

那所以就会把网址变成了:
adclick.php?dest=http://server1.adpolestar.net/ADPolestar/lgs/way/;er=?mv=710&pu=ctharmony&ad=0038108
后面的字符串加在?字符后面了

问题就是上面阐述的了,阿权觉得有临时的方法是在adclick文件里面处理:

if (isset($vars) && is_array($vars) && sizeof($vars) > 0)
{
 //hqlulu 2007-12-6 方案一
 if(strstr($url,"/;er=")){
   $url = $url.'&'.implode ('&', $vars);
 }else{
   if (strpos ($url, '?') > 0)
     $url = $url.'&'.implode ('&', $vars);
   else
     $url = $url.'?'.implode ('&', $vars);
 }
}


这个是临时的了,那永久的处理就是把cache生成之前处理,找了找,找啊找也终于找到了,是编辑素材的时候生成和整理的 htmlcache 参数。




那就从显示开始查,从adframe.php 开始:

// Get the banner
$banner = view_raw ($what, $clientid, $target, $source, $withtext, $context);


查一下view_raw函数,是在 libraries/lib-view-main.inc.php 文件里定义的,是查找广告的过程,找到广告之后,调用 phpAds_getBannerDetails 函数来获取广告信息:

if ($found)
{
 // Prepare impression logging
 if ($phpAds_config['log_adviews'] && !$phpAds_config['log_beacon'])
   phpAds_logImpression ($row['bannerid'], $row['clientid'], $row['zoneid'], $source);

 $row = array_merge($row, phpAds_getBannerDetails($row['bannerid']));

 return phpAds_prepareOutput($row, $target, $source, $withtext);
}


查一下phpAds_getBannerDetails函数,也是在 libraries/lib-view-main.inc.php 文件里定义的
查找是否有cache,否则从数据库读出,之前以为数据是直接整理出来的,一直想着是否在cache到文件或者数据库的时候定义的。其实是保存在数据库里的 htmlcache  字段,所以就要查一下保存入库的代码了。

搜一下就知道是在 admin/lib-banner.inc.php 里面定义了cache的方法:phpAds_getBannerCache

大约在388行位置有关于flash文件的处理:

// Set flash variables
if ($banner['contenttype'] == 'swf')
{
 if ($banner['url'] != '')


里面有相应的代码,主要是把url两次urlencode就可以


$buffer = str_replace ('{swf_param}', 'clickTAG={url_prefix}/adclick.php%3Fbannerid={bannerid}%26zoneid={zoneid}%26source={source}%26dest='.urlencode(urlencode($banner['url'])), $buffer);


$buffer = str_replace ($matches[0],
'{url_prefix}/adclick.php%3Fbannerid={bannerid}%26zoneid={zoneid}%26source='.$source.'%26dest='.urlencode(urlencode($url)),
$buffer);


测试正常了。


原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
Tags: ,
流火王 Homepage Email
2011/01/15 23:06
winneyao
2008/01/04 10:25
你好 ,能请教个问题不? openads能不能发不 浮动的 对联广告啊?
愿能跟你交流:msn:sunygloves@hotmail.com
             QQ:45070972
hqlulu 回复于 2008/01/04 19:39
应该可以的吧,有比较多的形式,也许得自己看看
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemotemotemotemotemotemotemotemotemot
emotemotemotemotemotemotemotemotemotemotemotemot
打开HTML 打开UBB 打开表情 隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写
 

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐