Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

[疑难] ss7.0广告条怎么设置,请版主回答

[复制链接]
shuzefan 发表于 2009-6-22 11:59:58 | 显示全部楼层 |阅读模式
SupeSite模板
语言编码: GBK简体 
风格转换者: 原创
额~以前也有人问过类似的问题,但是始终没有得到解答,所以我也就特意去问了管理员,人家DZ的管理员说啦,发到疑难里面找专门的斑竹给我解答,然后还笑了一下((em:08))
OK,废话不说了,直奔主题。
我就是想把SS7.0的每个横幅广告条(页面中部广告 页面底部广告)变成多个,而且在后台很方便添加,需要怎么做,怕你看不懂我就通俗的说,吧首页聚合页面中部广告位变成三个横条小广告(多个更好),额,期待管理员特派版主解答下,谢谢!
回复

使用道具 举报

情动我心 发表于 2009-6-22 12:45:41 | 显示全部楼层
更换域名后图片不显示排版错落

www.jsbbw.cn
用replace.php工具没有用大家帮忙啊!
回复

使用道具 举报

lhc666168 发表于 2009-6-22 15:32:32 | 显示全部楼层
没人回答,想要答案
回复

使用道具 举报

lidq.jingwu 发表于 2009-6-22 16:08:13 | 显示全部楼层
进入function/common.func.php文件,找到函数getad,将它替换为以下函数:

  1. //$value为频道或者广告ID, style为广告投放位置, pagetype广告投放页面
  2. function getad($type, $value, $pagetype='') {
  3.         global $_SGLOBAL, $_SCONFIG;

  4.         $adarr = $paramarr = $advlist = $adresult = array();
  5.         $advhtml = $adpageout = '';
  6.         $advcount = 0;
  7.         if($type == 'system') {
  8.                 if($value == 'space') {
  9.                         @include_once S_ROOT .'./data/system/adspace.cache.php';
  10.                 }else{
  11.                         @include_once S_ROOT .'./data/system/adsystem.cache.php';
  12.                 }
  13.                 //判断此频道是否有广告
  14.                 if(!empty($_SGLOBAL['ad'][$value]) || !empty($_SGLOBAL['ad']['all'])){
  15.                         if(!empty($_SGLOBAL['ad']['all']) && !empty($_SGLOBAL['ad'][$value])) {
  16.                                 $adarr = array_merge($_SGLOBAL['ad']['all'],$_SGLOBAL['ad'][$value]);
  17.                         }elseif(!empty($_SGLOBAL['ad'][$value])){
  18.                                 $adarr = $_SGLOBAL['ad'][$value];
  19.                         }else{
  20.                                 $adarr = $_SGLOBAL['ad']['all'];
  21.                         }
  22.                         foreach($adarr as $key=>$advalue) {
  23.                                 $paramarr = $advalue['parameters'];
  24.                                 if(!empty($paramarr['endtime']) && (strtotime($paramarr['startime']) > ($_SGLOBAL['timestamp']+$_SCONFIG['timeoffset']*3600) || (strtotime($paramarr['endtime']) < $_SGLOBAL['timestamp']+$_SCONFIG['timeoffset']*3600)))  {
  25.                                         continue;
  26.                                 } else {
  27.                                         //获取广告代码
  28.                                         switch($advalue['adtype']) {
  29.                                                 case 'text':
  30.                                                         $advhtml = '<a href="'.$paramarr['texturl'].'" target="_blank" style="font-size: '.$paramarr['fontsize'].'px;">'.stripslashes($paramarr['textcontent']).'</a>';
  31.                                                         break;
  32.                                                 case 'code':
  33.                                                         $advhtml = stripslashes($paramarr['adcodecontent']);
  34.                                                         break;
  35.                                                 case 'image':
  36.                                                         $advhtml = '<a href="'.$paramarr['imageurl'].'" target="_blank"><img src="'.$paramarr['imagesrc'].'" width="'.$paramarr['imagewidth'].'px" height="'.$paramarr['imageheight'].'px" alt="'.$paramarr['imagetext'].'" /></a>';
  37.                                                         break;
  38.                                                 case 'flash':
  39.                                                         $advhtml  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" adcodebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0" width="'.$paramarr['flashwidth'].'px" height="'.$paramarr['flashheight'].'px">';
  40.                                                         $advhtml .= '<param name="movie" value="'.stripslashes($paramarr['flashsrc']).'" />';
  41.                                                         $advhtml .= '<param name="quality" value="high" />';
  42.                                                         $advhtml .= '<embed src="'.stripslashes($paramarr['flashsrc']).'" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'.$paramarr['flashwidth'].'px" height="'.$paramarr['flashheight'].'px"></embed>';
  43.                                                         $advhtml .= '</object>';
  44.                                         }
  45.                                         if(!empty($pagetype) && in_array($pagetype, explode("\t", $advalue['pagetype'])) || in_array('all', explode("\t", $advalue['pagetype']))) {
  46.                                                 if($advalue['style'] == 'pageoutindex' || $advalue['style'] == 'all') {
  47.                                                         $adpageout = addcslashes($advhtml , '/"\\');
  48.                                                         $adpageout = str_replace("\n",  '<br />',$adpageout);
  49.                                                         $adpageout = str_replace("\r",  '',$adpageout);
  50.                                                         $adpageout = <<<EOF
  51. <script type="text/javascript">
  52. function openwin() {
  53.         OpenWindow=window.open("", (window.name!="newwin")?"newwin":"", "height={$paramarr[outwidth]}px, width={$paramarr[outheight]}px,toolbar=no ,scrollbars=no,menubar=no");
  54.         OpenWindow.document.write("$adpageout");
  55.         OpenWindow.document.close();
  56. }
  57. openwin();
  58. </script>
  59. EOF;
  60.                                                 }
  61.                                         } else {
  62.                                                 continue;
  63.                                         }
  64.                                         switch($advalue['style']) {
  65.                                                 case 'pageoutindex' :
  66.                                                         $advlist['pageoutindex'][] = $adpageout;
  67.                                                         break;
  68.                                                 case 'all' :
  69.                                                         $advlist['pageheadad'][] = $advhtml;
  70.                                                         $advlist['pagecenterad'][] = $advhtml;
  71.                                                         $advlist['pagefootad'][] = $advhtml;
  72.                                                         $advlist['pagemovead'][] = $advhtml;
  73.                                                         $advlist['pageoutad'][] = $advhtml;
  74.                                                         $advlist['siderad'][] = $advhtml;
  75.                                                         $advlist['viewinad'][] = $advhtml;
  76.                                                         $advlist['pageoutindex'][] = $adpageout;
  77.                                                         break;
  78.                                                 default :
  79.                                                         $advlist[$advalue['style']][] = $advhtml;
  80.                                         }
  81.                                 }
  82.                         }
  83.                         foreach($advlist as $key=>$value) {
  84.                                 $advcount = count($value);
  85.                                 if($key=='pageheadad'){
  86.                                         $adresult['pageheadad'] = $value;
  87.                                 }elseif($key=='pagefootad'){
  88.                                         $adresult['pagefootad'] = $value;
  89.                                 }else{
  90.                                         if($advcount>0) {
  91.                                                 $adresult[$key] = $advcount > 1 ? $value[mt_rand(0, $advcount -1)] : $value[0];
  92.                                         }
  93.                                 }
  94.                         }
  95.                        
  96.                         if(!empty($adresult)) {
  97.                                 return $adresult;
  98.                         } elseif(empty($adresult)){
  99.                                 return '';
  100.                         }
  101.                 } else {
  102.                         return '';
  103.                 }
  104.         } elseif($type == 'user') {
  105.                 @include_once S_ROOT .'./data/system/aduser.cache.php';
  106.                 $adid = intval($value);
  107.                 $adarr = $_SGLOBAL['ad'][$adid];
  108.                 $paramarr = $adarr['parameters'];
  109.                 if(!empty($paramarr['endtime']) && (strtotime($paramarr['startime']) > ($_SGLOBAL['timestamp']+$_SCONFIG['timeoffset']*3600) || (strtotime($paramarr['endtime']) < $_SGLOBAL['timestamp']+$_SCONFIG['timeoffset']*3600))) {
  110.                         return '';
  111.                 } else {
  112.                         return $paramarr['adechocontent'];
  113.                 }
  114.         }
  115. }
复制代码

这样在页面上接收到的返回值中头部和尾部广告就是一个数组,而不是单一的值,然后就可以在页面上循环显示了。
顶部显示代码:

  1. <!--{if !empty($ads['pageheadad']) }-->
  2. <!--{loop $ads['pageheadad'] $ad}-->
  3.         <div class="ad_header">$ad</div>
  4. <!--{/loop}-->
  5. <!--{/if}-->
复制代码

尾部显示代码:

  1. <!--{if !empty($ads['pagefootad']) }-->
  2. <!--{loop $ads['pagefootad'] $ad}-->
  3.         <div class="ad_pagebody">$ad</div>
  4. <!--{/loop}-->
  5. <!--{/if}-->
复制代码

至于怎么显示好看的问题就自己调吧。
回复

使用道具 举报

 楼主| shuzefan 发表于 2009-6-22 17:31:02 | 显示全部楼层
4# lidq.jingwu
管理员能检查下哪里出问题没有 按照你说的吧代码全部替换之后 全站都打不开了 我靠 我又换回来 又可以打开了!
回复

使用道具 举报

 楼主| shuzefan 发表于 2009-6-22 17:33:15 | 显示全部楼层
我的意思是一个中部广告位里面可以添加三个广告同时显示!哈哈!
回复

使用道具 举报

lidq.jingwu 发表于 2009-6-22 17:45:40 | 显示全部楼层
本帖最后由 lidq.jingwu 于 2009-6-22 17:48 编辑

这个效果是可以达到的,不过上给出的代码只限于顶部与底部,要底部的修改一下代码就可以了。
再问一下,你说的中部广告是指对联广告还是中央横幅广告
回复

使用道具 举报

lidq.jingwu 发表于 2009-6-22 17:59:12 | 显示全部楼层
针对中央横幅广告的代码修改getad函数如下:

  1. //$value为频道或者广告ID, style为广告投放位置, pagetype广告投放页面
  2. function getad($type, $value, $pagetype='') {
  3.         global $_SGLOBAL, $_SCONFIG;

  4.         $adarr = $paramarr = $advlist = $adresult = array();
  5.         $advhtml = $adpageout = '';
  6.         $advcount = 0;
  7.         if($type == 'system') {
  8.                 if($value == 'space') {
  9.                         @include_once S_ROOT .'./data/system/adspace.cache.php';
  10.                 }else{
  11.                         @include_once S_ROOT .'./data/system/adsystem.cache.php';
  12.                 }
  13.                 //判断此频道是否有广告
  14.                 if(!empty($_SGLOBAL['ad'][$value]) || !empty($_SGLOBAL['ad']['all'])){
  15.                         if(!empty($_SGLOBAL['ad']['all']) && !empty($_SGLOBAL['ad'][$value])) {
  16.                                 $adarr = array_merge($_SGLOBAL['ad']['all'],$_SGLOBAL['ad'][$value]);
  17.                         }elseif(!empty($_SGLOBAL['ad'][$value])){
  18.                                 $adarr = $_SGLOBAL['ad'][$value];
  19.                         }else{
  20.                                 $adarr = $_SGLOBAL['ad']['all'];
  21.                         }
  22.                         foreach($adarr as $key=>$advalue) {
  23.                                 $paramarr = $advalue['parameters'];
  24.                                 if(!empty($paramarr['endtime']) && (strtotime($paramarr['startime']) > ($_SGLOBAL['timestamp']+$_SCONFIG['timeoffset']*3600) || (strtotime($paramarr['endtime']) < $_SGLOBAL['timestamp']+$_SCONFIG['timeoffset']*3600)))  {
  25.                                         continue;
  26.                                 } else {
  27.                                         //获取广告代码
  28.                                         switch($advalue['adtype']) {
  29.                                                 case 'text':
  30.                                                         $advhtml = '<a href="'.$paramarr['texturl'].'" target="_blank" style="font-size: '.$paramarr['fontsize'].'px;">'.stripslashes($paramarr['textcontent']).'</a>';
  31.                                                         break;
  32.                                                 case 'code':
  33.                                                         $advhtml = stripslashes($paramarr['adcodecontent']);
  34.                                                         break;
  35.                                                 case 'image':
  36.                                                         $advhtml = '<a href="'.$paramarr['imageurl'].'" target="_blank"><img src="'.$paramarr['imagesrc'].'" width="'.$paramarr['imagewidth'].'px" height="'.$paramarr['imageheight'].'px" alt="'.$paramarr['imagetext'].'" /></a>';
  37.                                                         break;
  38.                                                 case 'flash':
  39.                                                         $advhtml  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" adcodebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0" width="'.$paramarr['flashwidth'].'px" height="'.$paramarr['flashheight'].'px">';
  40.                                                         $advhtml .= '<param name="movie" value="'.stripslashes($paramarr['flashsrc']).'" />';
  41.                                                         $advhtml .= '<param name="quality" value="high" />';
  42.                                                         $advhtml .= '<embed src="'.stripslashes($paramarr['flashsrc']).'" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'.$paramarr['flashwidth'].'px" height="'.$paramarr['flashheight'].'px"></embed>';
  43.                                                         $advhtml .= '</object>';
  44.                                         }
  45.                                         if(!empty($pagetype) && in_array($pagetype, explode("\t", $advalue['pagetype'])) || in_array('all', explode("\t", $advalue['pagetype']))) {
  46.                                                 if($advalue['style'] == 'pageoutindex' || $advalue['style'] == 'all') {
  47.                                                         $adpageout = addcslashes($advhtml , '/"\\');
  48.                                                         $adpageout = str_replace("\n",  '<br />',$adpageout);
  49.                                                         $adpageout = str_replace("\r",  '',$adpageout);
  50.                                                         $adpageout = <<<EOF
  51. <script type="text/javascript">
  52. function openwin() {
  53.         OpenWindow=window.open("", (window.name!="newwin")?"newwin":"", "height={$paramarr[outwidth]}px, width={$paramarr[outheight]}px,toolbar=no ,scrollbars=no,menubar=no");
  54.         OpenWindow.document.write("$adpageout");
  55.         OpenWindow.document.close();
  56. }
  57. openwin();
  58. </script>
  59. EOF;
  60.                                                 }
  61.                                         } else {
  62.                                                 continue;
  63.                                         }
  64.                                         switch($advalue['style']) {
  65.                                                 case 'pageoutindex' :
  66.                                                         $advlist['pageoutindex'][] = $adpageout;
  67.                                                         break;
  68.                                                 case 'all' :
  69.                                                         $advlist['pageheadad'][] = $advhtml;
  70.                                                         $advlist['pagecenterad'][] = $advhtml;
  71.                                                         $advlist['pagefootad'][] = $advhtml;
  72.                                                         $advlist['pagemovead'][] = $advhtml;
  73.                                                         $advlist['pageoutad'][] = $advhtml;
  74.                                                         $advlist['siderad'][] = $advhtml;
  75.                                                         $advlist['viewinad'][] = $advhtml;
  76.                                                         $advlist['pageoutindex'][] = $adpageout;
  77.                                                         break;
  78.                                                 default :
  79.                                                         $advlist[$advalue['style']][] = $advhtml;
  80.                                         }
  81.                                 }
  82.                         }
  83.                         foreach($advlist as $key=>$value) {
  84.                                 print_r($key);
  85.                                 $advcount = count($value);
  86.                                 if($key=='pageheadad'){
  87.                                         $adresult['pageheadad'] = $value;
  88.                                 }elseif($key=='pagefootad'){
  89.                                         $adresult['pagefootad'] = $value;
  90.                                 }elseif($key=='pagecenterad'){
  91.                                         $adresult['pagecenterad'] = $value;
  92.                                 }else{
  93.                                         if($advcount>0) {
  94.                                                 $adresult[$key] = $advcount > 1 ? $value[mt_rand(0, $advcount -1)] : $value[0];
  95.                                         }
  96.                                 }
  97.                         }
  98.                        
  99.                         if(!empty($adresult)) {
  100.                                 return $adresult;
  101.                         } elseif(empty($adresult)){
  102.                                 return '';
  103.                         }
  104.                 } else {
  105.                         return '';
  106.                 }
  107.         } elseif($type == 'user') {
  108.                 @include_once S_ROOT .'./data/system/aduser.cache.php';
  109.                 $adid = intval($value);
  110.                 $adarr = $_SGLOBAL['ad'][$adid];
  111.                 $paramarr = $adarr['parameters'];
  112.                 if(!empty($paramarr['endtime']) && (strtotime($paramarr['startime']) > ($_SGLOBAL['timestamp']+$_SCONFIG['timeoffset']*3600) || (strtotime($paramarr['endtime']) < $_SGLOBAL['timestamp']+$_SCONFIG['timeoffset']*3600))) {
  113.                         return '';
  114.                 } else {
  115.                         return $paramarr['adechocontent'];
  116.                 }
  117.         }
  118. }
复制代码

显示方式:

  1. <!--{if !empty($ads['pagecenterad']) }-->
  2. <!--{loop $ads['pagecenterad'] $ad}-->
  3.         <div class="ad_pagebody">$ad</div>
  4. <!--{/loop}-->
  5. <!--{/if}-->
复制代码
回复

使用道具 举报

mrsaner 发表于 2009-6-25 18:11:22 | 显示全部楼层
((em:12))强啊。。。。
回复

使用道具 举报

ldwlxs007 发表于 2009-6-25 19:23:59 | 显示全部楼层
这个效果是可以达到的,不过上给出的代码只限于顶部与底部,要底部的修改一下代码就可以了。
再问一下,你说的中部广告是指对联广告还是中央横幅广告
lidq.jingwu 发表于 2009-6-22 17:45




太喜欢你了!我可以爱你吗?
既然你都已经写了两个的修改的代码了
那就索性把其他几个广告位修改成各种样式
发给大家学习使用吧?
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-9-14 05:06 , Processed in 0.114800 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表