【原创】广告调用类,支持Flash调用
2011-11-09 08:21
381 查看
简介:这是【原创】广告调用类,支持Flash调用的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。
class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=343823' scrolling='no'>调用方式如下:其中DebugStr这个函数就是类似一个echo。
类如下:
爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具
http://biancheng.dnbcw.info/php/343823.html pageNo:5
class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=343823' scrolling='no'>调用方式如下:其中DebugStr这个函数就是类似一个echo。
DebugStr('$Adv->getContentById($id); $id为广告编号, 仅调用一条,返回内容为字符串'); echo Adv::getContentById(35); DebugStr('$Adv->getContentByIdJS($id); $id为广告编号, 仅调用一条,返回内容为JS字符串'); echo Adv::getContentByIdJS(35); DebugStr('$Adv->getContentByOrder($id); $id为广告编号, 仅调用ID倒序一条,返回内容为字符串'); echo Adv::getContentByOrder(4); DebugStr('$Adv->getContentByOrderJS($id); $id为广告编号, 仅调用ID倒序一条,返回内容为JS字符串'); echo Adv::getContentByOrderJS(4); echo '<hr>';
类如下:
<?php /** * 说明:广告类,方便广告列表、内容的调用。 * 需要:数据库类 * 支持:仅支持PHP5,单件模式 * * @author Zerolone * @version 2011-1-6 11:32:06 * 调用方法 * Adv::getContentById($id); $id为广告编号, 仅调用一条,返回内容为字符串 * Adv::getContentByIdJs($id); $id为广告编号, 仅调用一条,返回内容为JS字符串 * Adv::getContentByOrder($order); $order为对应, 仅调用ID倒序一条,返回内容为字符串 * Adv::getContentByOrderJs($order); $order对应顺序, 仅调用ID倒序一条,返回内容为JS字符串 */ class Adv { static $Id = 0; //编号 static $Order = 0; //顺序 static $JS = 0; //是否使用JS, 0为不使用 /** * 根据Id, 返回广告内容,仅调用一条 * * @param 编号 $id * */ public static function getContentById($id){ self::$Id = $id; return self::getContent(); } /** * 根据Id, 返回广告内容Js,仅调用一条 * * @param 编号 $id * */ public static function getContentByIdJS($id){ self::$Id = $id; self::$JS = 1; return self::getContent(); } /** * 根据Order, 返回广告内容,仅调用一条 * * @param 编号 $Order * */ public static function getContentByOrder($order){ self::$Order = $order; return self::getContent(); } /** * 根据Order, 返回广告内容Js,仅调用一条 * * @param 编号 $Order * */ public static function getContentByOrderJS($order){ self::$Order = $order; self::$JS = 1; return self::getContent(); } /** * 生成一个广告内容,只调用一条 * * @return 广告内容 */ private function getContent(){ $ReturnContent=''; //------------------0-------1--------2--------3 $SqlStr = 'SELECT `pic`, `width`, `height`, `url` FROM '.TABLE_ADV; if(self::$Id){ $SqlStr.= ' WHERE `id`=' . self::$Id; }else{ $SqlStr.= ' WHERE `order`=' . self::$Order; $SqlStr.= ' ORDER BY `id` DESC '; } $SqlStr.= ' LIMIT 1'; $MyDatabase=Database::Get(); $MyDatabase->SqlStr = $SqlStr; if ($MyDatabase->Query ()) { $DB_Record = $MyDatabase->ResultArr [0]; $FileName = $DB_Record[0]; $Width = $DB_Record[1]; $Height = $DB_Record[2]; $Url = $DB_Record[3]; } //判断类型 $FileName_Ext=strtoupper(pathinfo($FileName, PATHINFO_EXTENSION)); if ($FileName_Ext=='SWF'){ //Flash广告 $ReturnContent = '<table width="' . $Width .'" border="0" cellspacing="0" cellpadding="0">'; $ReturnContent.= '<tr>'; $ReturnContent.= '<td height="' . $Height . '">'; $ReturnContent.= '<table width="100%" border="0" cellpadding="0" cellspacing="0">'; $ReturnContent.= '<tr>'; $ReturnContent.= '<td>'; $ReturnContent.= '<div style="position:absolute; width:0px; height:0px; z-index:1">'; $ReturnContent.= '<div style="position:absolute; left:0px; top:0px; width:' . $Width . 'px; height:' . $Height . 'px; z-index:2; filter:alpha(opacity=0)">'; $ReturnContent.= '<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">'; $ReturnContent.= '<tr>'; $ReturnContent.= '<td style="cursor:hand" onClick=window.open("'. $Url . '");> </td>'; $ReturnContent.= '</tr>'; $ReturnContent.= '</table>'; $ReturnContent.= '</div>'; $ReturnContent.= '</div>'; $ReturnContent.= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab #version=7,0,19,0" width="'.$Width.'" height="'.$Height.'">'; $ReturnContent.= '<param name="movie" value="'.$FileName.'">'; $ReturnContent.= '<param name="quality" value="high">'; $ReturnContent.= '<param name="wmode" value="transparent">'; $ReturnContent.= '<embed src="'.$FileName.'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer " type="application/x-shockwave-flash" width="'.$Width.'" height="'.$Height.'"></embed></object>'; $ReturnContent.= '</td>'; $ReturnContent.= '</tr>'; $ReturnContent.= '</table>'; $ReturnContent.= '</td>'; $ReturnContent.= '</tr>'; $ReturnContent.= '</table>'; }else{ //图片广告 $ReturnContent = '<a target="_blank" href="'.$Url.'"><img src="'.$FileName.'" width="'.$Width.'" height="'.$Height.'" border="0" /></a>'; } //如果为调用JS方式 if(self::$JS){ $ReturnContent = 'document.write("'.addslashes($ReturnContent).'");'; } //重置默认值,这里还是采用单件模式 self::$Id = 0; self::$Order = 0; self::$JS = 0; return $ReturnContent; } } ?>
爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具
http://biancheng.dnbcw.info/php/343823.html pageNo:5
相关文章推荐
- php 广告调用类代码(支持Flash调用)
- php 广告调用类代码(支持Flash调用)
- FLASH广告完全揭密 搜狐体育频道FLASH广告JS调用代码
- 一个能支持Flash的广告控件
- [原创] 全站快速变灰(只支持IE浏览器,可变flash)
- [原创]JEECMS 自定义标签调用广告版位下的所有广告(利用广告管理管理首页幻灯片)
- 关于Flash广告的调用
- [原创] 支持异步的Soap简单调用模块,SoapPro.DLL
- [原创]一个类似Ajax的咚咚,支持IE4,支持98
- JSON传数据,JSONP跨域(外域JS调用本地回调函数):需外域服务端支持
- 方便调用27种flash图片切换特效
- 诺基亚C7提供全HTML网页浏览器使用JavaScript和Flash支持
- 如何在PB中调用F1控件如何插入图片(原创)
- 汇编调用flash文件.实现界面的初探
- Unity宣布支持Flash 网页游戏迎来3D元年
- (原创)Silverlight远程调用WCF
- FLASH轮换广告
- 【原创】PHP调用PHP页面并且get传值
- 在u-boot中增加nor flash的支持
- 不在抄袭,支持原创