PHP AD calling class code supports flash call

Source: Internet
Author: User
The call is as follows: where debugstr This function is like an echo.

Copy the Code code as follows:


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


Classes are as follows:

Copy the Code code as follows:


/**
* Description: Advertising class, easy to advertise the list, the content of the call.
* Required: Database class
* Support: Only support PHP5, single-piece mode
*
* @author Zerolone
* @version 2011-1-6 11:32:06
* Call method
* Adv::getcontentbyid ($ID); $id as the ad number, call only one and return the content as a string
* ADV::GETCONTENTBYIDJS ($ID); $id for the ad number, call only one, and return the content as a JS string
* Adv::getcontentbyorder ($order); $order for correspondence, call only the reverse ID, return the content as a string
* ADV::GETCONTENTBYORDERJS ($order); $order the corresponding order, only call the ID reverse one, the return content is the JS string
*/
Class Adv {
static $Id = 0; Number
static $Order = 0; Order
static $JS = 0; Whether to use JS, 0 is not used
/**
* Return ad content based on ID, call only one
*
* @param number $id
*
*/
public static function Getcontentbyid ($id) {
Self:: $Id = $id;
return Self::getcontent ();
}
/**
* According to the ID, return the ad content JS, call only one
*
* @param number $id
*
*/
public static function Getcontentbyidjs ($id) {
Self:: $Id = $id;
Self:: $JS = 1;
return Self::getcontent ();
}
/**
* Returns the ad content according to order, calling only one
*
* @param number $Order
*
*/
public static function Getcontentbyorder ($order) {
Self:: $Order = $order;
return Self::getcontent ();
}
/**
* According to order, return the ad content JS, call only one
*
* @param number $Order
*
*/
public static function Getcontentbyorderjs ($order) {
Self:: $Order = $order;
Self:: $JS = 1;
return Self::getcontent ();
}
/**
* Generate an ad content that calls only one
*
* @return Advertising Content
*/
Private Function getcontent () {
$ReturnC 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];
}
Judging type
$FileName _ext=strtoupper (PathInfo ($FileName, pathinfo_extension));
if ($FileName _ext== ' SWF ') {
Flash ads
$ReturnContent = '





';$ReturnContent. = ' ';$ReturnContent. = ' ';$ReturnContent. = ' ';$ReturnContent. = '
';
$ReturnContent. = '



';$ReturnContent. = ' ';$ReturnContent. = ' ';$ReturnContent. = ' ';$ReturnContent. = '
';
$ReturnContent. = ';
$ReturnContent. = ';
$ReturnContent. = '



'; $ReturnContent. = ' '; $ReturnContent. = ' '; $ReturnContent. = ' '; $ReturnContent. = '
';
$ReturnContent. = ';
$ReturnContent. = ';
$ReturnContent. = '';
$ReturnContent. = ';
$ReturnContent. = ';
$ReturnContent. = ';
$ReturnContent. = ' ';
$ReturnContent. = '
';
$ReturnContent. = '
';
}else{
Image ads
$ReturnContent = ";
}
If the JS method is called
if (self:: $JS) {
$ReturnContent = ' document.write ("'. Addslashes ($ReturnContent). '); ';
}
Resets the default value, which is still in single-piece mode
Self:: $Id = 0;
Self:: $Order = 0;
Self:: $JS = 0;
return $ReturnContent;
}
}
?>

The above describes the PHP ad calling class code to support Flash calls, including the content, I hope the PHP tutorial interested in a friend to help.

  • 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.