php広告コールクラスコード(Flashコール対応)
9758 ワード
呼び出し方法は以下の通りです。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<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><IMG style="FLOAT: none; MARGIN: 1px; VERTICAL-ALIGN: middle; WIDTH: 18px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; HEIGHT: 18px; BORDER-BOTTOM-STYLE: none" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPkgAAD5IBBKh+oAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANFS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tKuaSKZ3nJtb7oh/fT7PX2nNv4BjlSkNxLrX2YAAAAASUVORK5CYII="></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><IMG style="FLOAT: none; MARGIN: 1px; VERTICAL-ALIGN: middle; WIDTH: 18px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; HEIGHT: 18px; BORDER-BOTTOM-STYLE: none" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPkgAAD5IBBKh+oAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANFSURBVDiNlZJLaNxVFIe/+3/OZJJMokMzxqTJOJ2kmkYbtBCxosSC0NiN0l11aUXcduNKKF0otBBcuXXhQlCkohUtSIvaSDBVqyEvjW3TxDwmk2Smmf/jPlwkMzXFLDxw+cHhnu+c+ztXGGMYGnrlmcf7jrydakp38T8iCqurt25OjXz8yQefOUtLS6nnnxv+sNBz6BEhBI7dAMDy8gz79hV2FQqh+XtxlrZsTz3XlesbmP3reLe9sLz25OCRl87M/fErm5tFWloewhjwPQfLSiAEgEFrEMT8cO0rcrkncBwbpTTJZNqfnBidc6Io8m3bvq+zYPznyxTyTzE1/SO+30CptM4LQyexLIvpqSs0pzNks30A2I7nWnu9P44ijAHHbuTw4WH8xHazUmkeIUQdUos6yLYt7sxP8tuNy9ytLOF6HkKAZdtMz1wnkfAByGS60EZw+9bYLpADUAo06439pHr7iYVg+i64+4eZi2Fm8SovHk0zsdCAvWRoefRlAgEBsLYc0pZy74FSrqA77dTpxtTMgo3mJMeODTH2y0c83OjU87V7nhCoWG+DPFvgO7sNr0WDb9Pa2kpUKaLKC7S1daK1IVYaKTWhVMRa4fxn9b9NFBaJRAIlV/lp/CLVqiTbfohstkCqKUMsQWm9N2hs7BJSlVlZWcN1XV597RSTk7P09uY5d+5d8gcO0pE7geM2E8Z7gKTStDzQSa4bLlwYoVwuMzg4yMDAAEEQcPbsO8zPz/PN1Tky2ceIJfdAShuk1EiliaWm9cEDjF//nPPn3yMIAlzXRSmF1ppstg1jNOul30mmC0i1M1E1UMTK1CE1LZZC8vkcxhjCMEQphZQSpRTpdJow2EDr7RVbIKlUYyrVmPLWtlZ2VDidjI6OEQQBYRgShiFxHCOlZGJikmRTd/2rWO0dHcurxWJc2ZLUTnlHUy09XPr6O4IgIAgCoigiiiKklHx7ZZzWzEG00kRBZUUUi8Xm02+NfJErDB2N1bbRUun6yHf+/JJnBzvxfQ/PdXE9G8e2+fTiNdrzJ1m8fWMuu/90rzDG8PqZLca/f+NNL9Hcf/8GtZJWGGwmtVaW1tKuaSKZ3nJtb7oh/fT7PX2nNv4BjlSkNxLrX2YAAAAASUVORK5CYII="></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{
//
$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;
}
}
?>