ECSHOP 添加广告

本文介绍了两个PHP函数:get_adv用于获取指定类型的广告信息并展示;get_cat_advlist用于获取指定广告位的所有有效广告列表。这些函数通过SQL查询从数据库中获取广告数据,并将广告以HTML格式返回。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

17:19:21
 
function get_adv($type,$id) {  $sql = "select ap.ad_width,ap.ad_height,ad.ad_name,ad.ad_code,ad.ad_link from ".$GLOBALS['ecs']->table('ad_position')." as ap left join ".$GLOBALS['ecs']->table('ad')." as ad on ad.position_id = ap.position_id where ad.ad_name='".$type."_".$id."' and ad.media_type=0 and UNIX_TIMESTAMP()>ad.start_time and UNIX_TIMESTAMP()<ad.end_time and ad.enabled=1";      $res = $GLOBALS['db']->getRow($sql);        if($res)                              return  "<a href='".$res['ad_link']."' target='_blank'><img src='data/afficheimg/".$res['ad_code']."' width='".$res['ad_width']."' height='".$res['ad_height']."' /></a>";  else  { return "";   }   } /*  *获取某广告位名称的广告列表  */ function get_cat_advlist($position) {    $arr=array();    $sql = "select ap.ad_width,ap.ad_height,ad.ad_name,ad.ad_code,ad.ad_link,ad.ad_id from ".$GLOBALS['ecs']->table('ad_position')." as ap left join ".$GLOBALS['ecs']->table('ad')." as ad on ad.position_id = ap.position_id where ap.position_name='".$position."' and ad.media_type=0 and UNIX_TIMESTAMP()>ad.start_time and UNIX_TIMESTAMP()<ad.end_time and ad.enabled=1";      $res = $GLOBALS['db']->getAll($sql);  foreach($res as $idx => $row)  {     $arr[$row['ad_id']]['name'] = $row['ad_name']; $arr[$row['ad_id']]['content'] = "<a href='".$row['ad_link']."' target='_blank'><img src='data/afficheimg/".$row['ad_code']."' width='".$row['ad_width']."' height='".$row['ad_height']."' /></a>";  }  return $arr; }
   17:19:55
 
<?php echo  get_adv("ad","1");?></div>
   17:30:19
 
  function fetch_str($source)     {         if (!defined('ECS_ADMIN'))         {             $source = $this->smarty_prefilter_preCompile($source);         }
        return preg_replace("/{([^\}\{\n]*)}/e", "\$this->select('\\1');", $source);     }

 

转载于:https://www.cnblogs.com/shichangyi/archive/2013/01/12/2857383.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值