国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

利用PHP實現與ASP Banner組件相似的類

2024-05-04 23:00:49
字體:
來源:轉載
供稿:網友
<?php
/*******************************************************
作者: 吳振亨 (biz)--phpscript
e-mail:[email protected]
web: http://phpscript.osh.com.cn
文件名:adrotator.class.php3                 
版權聲明:                      

如果您使用了本文件,請給作者寫一封e-mail   
如有問題歡迎與作者聯系
謝謝您的關注!                     
********************************************************/

/*
廣告條管理程序
public method
    getadvertisement($adfile)
     
parameters
    target=
    width=
    height=
    border=
    redirect=
     
*/
class adrotator {
    var $target="_blank";
    var $width="460";
    var $height="60";
    var $border=0;
    var $redirect="";
    var $bannerdata=array ();
    var $randtemp=1;
     
function adrotator()
    {
    }
/*
public  
返回廣告的鏈接字串
*/
function getadvertisement($adfile)
    {
    if(count($this->bannerdata)==0)
        {
        $this->bannerdata=$this->readadfile($adfile);
        }
    $addata=$this->bannerdata;
     
    $uplimited=count($addata);
     
    //隨機產生一個id
    srand((double)microtime()*1000000000000000000);
    $[email protected](1,$uplimited);
                
        while($this->randtemp==$id)
               {
            srand((double)microtime()*1000000000000000000);
               //$[email protected](1,count($addata));
               $[email protected](1,$uplimited);
               }
           $this->randtemp=$id;
         
       //echo $id;
       //echo count($addata);
       //echo $addata[5]["image"];
         
         
        $linkstring=" <a href="".$this->redirect;
        $linkstring.="?url=".$addata[$id]["url"];
        $linkstring.="" target="".$this->target;
        $linkstring.="" title="".$addata[$id]["title"];
        $linkstring.="" >";
        $linkstring.=" <img border="".$this->border;
        $linkstring.="" src="".$addata[$id]["image"];
        $linkstring.="" width="".$this->width;
        $linkstring.="" height="".$this->height;
        $linkstring.="" >";
        $linkstring.="</a>";
         
        //echo $linkstring;
        return $linkstring;
    }
/*
private
讀入文件的基本設置
*/
function readadfile($adfile)
    {
    $fp=fopen($adfile,"r");
    while($[email protected]($fp,1024))
        {
        if(!eregi("#",$buffer))
            {
            if(eregi("^*",$buffer))
                {
                $switchto="off";
                }

            $settemp=split("=",$buffer);

            if($switchto=="")
                {
                switch     ($settemp[0])
                    {
                    case "redirect":
                    $this->redirect=$settemp[1];
                    break;
                     
                    case "width":
                    $this->width=$settemp[1];
                    break;
                     
                    case "height":
                    $this->height=$settemp[1];
                    break;
                     
                    case "border":
                    $this->border=$settemp[1];
                    break;
                    case "target":
                    $this->target=$settemp[1];
                    break;
                    }
                }
            else
                {
                switch     ($settemp[0])
                    {
                    case "image":
                    $i++;
                    $bannerdata[$i]["image"]=$settemp[1];
                    //echo "<br>";echo $buffer;echo $settemp[1];
                    //echo $bannerdata[$i]["image"];
                    break;
                     
                    case "url":
                    $bannerdata[$i]["url"]=$settemp[1];
                    break;
                     
                    case "title":
                    $bannerdata[$i]["title"]=$settemp[1];
                    break;
                     
                    case "rate":
                    $bannerdata[$i]["rate"]=$settemp[1];
                    break;
                    }//end of switch
                }//end of if($switch)
            }//end of if(#)
         
        }//end of while

    return $bannerdata;
     
    }//end of function

}//end of class

/*
使用方法
廣告設置文件書寫格式banner.txt
------開始---
redirect=./adredir.asp
width=468
height=60
border=0
*

#注釋

#某某公司廣告1
image=../banner/1.gif
url=http://www.asps0ite.com1
title=one
rate=30
----結束-----
說明:
與asp的廣告組件相仿
*表示設置,其他為圖片的設置 #:表示注釋

----使用-----
$banner=new adrotator();
echo $banner->getadvertisement("./banner.txt");
echo $banner->getadvertisement("./banner.txt");
echo $banner->getadvertisement("./banner.txt");
*/
?>  

【本文版權歸作者與奧索網共同擁有,如需轉載,請注明作者及出處】    
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 五台县| 亳州市| 静乐县| 象山县| 昭觉县| 鄂尔多斯市| 濮阳县| 扎兰屯市| 金塔县| 云龙县| 晋城| 屯昌县| 崇左市| 临澧县| 当阳市| 巴林右旗| 大冶市| 十堰市| 正宁县| 安丘市| 阳高县| 五华县| 论坛| 兰西县| 永顺县| 永靖县| 鲜城| 海兴县| 淅川县| 黑龙江省| 当阳市| 蛟河市| 定襄县| 毕节市| 福泉市| 嘉义市| 汪清县| 丰镇市| 赣州市| 商丘市| 东光县|