Online banner production using PHP to implement classes similar to ASP Banner components

WBOY
Release: 2016-07-29 08:34:25
Original
2388 people have browsed it

/***************************************************** ***
Author: Wu Zhenheng (Biz)--phpscript
E-mail: wuzhenheng@china.com
web: http://phpscript.osh.com.cn
File name: AdRotator.class.php3     
Copyright statement:
If you have used this document, please write an E-mail to the author
If you have any questions, please feel free to contact the author
Thank you for your attention!                                  **************************************/
/*
Advertisement management program
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
Return the link string of the advertisement
*/
function GetAdvertisement($adfile)
if (count( $this->BannerData)==0)
                                                                                                                 =count ($AdData);
// Randomly generate an ID
srand((double)microtime()*100000000000000000);
$id=@rand(1,$uplimited);
while($this->RandTemp==$ id)
                                                                                                                                                                                                               $id=@rand(1,$uplimited);
                                                  
             $this->RandTemp=$id;                                                                                                                                  $LinkString=" < ;a href="".$this->Redirect;
                                                                                                                 this->Target;
         $LinkString.="" Title="".$AdData[$id]["title"];
          $LinkString.="" >";               $LinkString.="" border="".$this->Border;
$LinkString.="" src="".$AdData[$id]["image"];
$LinkString.="" width="".$this ->Width;
           $LinkString.="" height="".$this->Height;                $LinkString.=""                                                               /echo $LinkString;
       return $LinkString;
    }
/*
private
读入文件的基本设置
*/
function ReadAdFile($adfile)
    {
    $FP=fopen($adfile,"r");
    while($buffer=@fgets($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 "
";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");
*/
?>  
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】    

以上就介绍了banner在线制作 利用PHP实现与ASP Banner组件相似的类,包括了banner在线制作方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template