PHP AD Invoke Class code (support Flash call) _php tips

Source: Internet
Author: User
The invocation method is as follows: one of the DEBUGSTR functions is like an echo.
Copy Code code as follows:

Debugstr (' $Adv->getcontentbyid ($id); $id for the advertisement number, only one call, the return content is a string ');
Echo Adv::getcontentbyid (35);
Debugstr (' $Adv->getcontentbyidjs ($id); $id for the advertisement number, only one call, the return content is JS string ');
Echo Adv::getcontentbyidjs (35);
Debugstr (' $Adv->getcontentbyorder ($id); $id for ad number, only call ID reverse one, return content is String ');
Echo Adv::getcontentbyorder (4);
Debugstr (' $Adv->getcontentbyorderjs ($id); $id for advertisement number, only call ID reverse one, return content is JS string ');
Echo Adv::getcontentbyorderjs (4);
Echo '

The classes are as follows:
Copy Code code as follows:

<?php
/**
* Description: Advertising category, easy to advertise the list, the content of the call.
* Required: Database class
* Support: Support only PHP5, single piece mode
*
* @author Zerolone
* @version 2011-1-6 11:32:06
* Call method
* Adv::getcontentbyid ($ID); $id is the ad number, only one is invoked, and the returned content is a string
* ADV::GETCONTENTBYIDJS ($ID); $id for the ad number, only one call, the content is JS string
* Adv::getcontentbyorder ($order); $order for the corresponding, only call ID reverse one, the return of the content is a string
* ADV::GETCONTENTBYORDERJS ($order); $order corresponding order, only call ID reverse one, return content is JS string
*/
Class Adv {
static $Id = 0; Number
static $Order = 0; Order
static $JS = 0; Whether to use JS, 0 is not used
/**
* According to the ID, return the advertisement content, call only one
*
* @param number $id
*
*/
public static function Getcontentbyid ($id) {
Self:: $Id = $id;
return Self::getcontent ();
}
/**
* According to the ID, return ads content JS, only call one
*
* @param number $id
*
*/
public static function Getcontentbyidjs ($id) {
Self:: $Id = $id;
Self:: $JS = 1;
return Self::getcontent ();
}
/**
* According to the order, return the advertisement content, call only one
*
* @param number $Order
*
*/
public static function Getcontentbyorder ($order) {
Self:: $Order = $order;
return Self::getcontent ();
}
/**
* According to the order, return the content JS, only call one
*
* @param number $Order
*
*/
public static function Getcontentbyorderjs ($order) {
Self:: $Order = $order;
Self:: $JS = 1;
return Self::getcontent ();
}
/**
* Generate an advertisement content, call only one
*
* @return Advertising Content
*/
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];
}
Type of judgment
$FileName _ext=strtoupper (PathInfo ($FileName, pathinfo_extension));
if ($FileName _ext== ' SWF ') {
Flash ads
$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<span class= makelinks_urlspan>://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab<!--makelinks-->< A class=makelinks_url title=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab style= "margin:1px ; Vertical-align:middle "href=" Http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab "Target=_blank ></A></SPAN> #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<span class= makelinks_urlspan>://www.macromedia.com/go/getflashplayer<!--Makelinks--><a Class=makelinks_url Title=http://www.macromedia.com/go/getflashplayer style= "MARGIN:1PX; Vertical-align:middle "href=" http://www.macromedia.com/go/getflashplayer "target=_blank></A></SPAN>" type= "Application/x-shockwave-flash" width= "'. $Width. '" height= ". $HeighT. ' ></embed></object> ';
$ReturnContent. = ' </td> ';
$ReturnContent. = ' </tr> ';
$ReturnContent. = ' </table> ';
$ReturnContent. = ' </td> ';
$ReturnContent. = ' </tr> ';
$ReturnContent. = ' </table> ';
}else{
Photo Ads
$ReturnContent = ' <a target= ' _blank ' href= '. $Url. ' " ></a> ';
}
If you are calling the JS method
if (self:: $JS) {
$ReturnContent = ' document.write ($ReturnContent). '); ';
}
Reset defaults, here or in a single piece mode
Self:: $Id = 0;
Self:: $Order = 0;
Self:: $JS = 0;
return $ReturnContent;
}
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.