PHP
  Home arrow PHP arrow Page 5 - Commercial Break (A phpAds Primer)
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Commercial Break (A phpAds Primer)
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-07-30

    Table of Contents:
  • Commercial Break (A phpAds Primer)
  • Getting Started
  • The Toy Store
  • Different Strokes
  • Room With A View()
  • The Advanced Course
  • Access Denied
  • The Number Game
  • Endgame

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Commercial Break (A phpAds Primer) - Room With A View()


    (Page 5 of 9 )

    Remember how, a couple of pages back, you wondered what the AdViews, AdClicks and AdDays parameters were for in the client administration screen, and I rudely told you to shut up and sit down? Well, now that you know how banners work, it's safe to revisit those three mysterious parameters, and see where they fit in.

    The AdViews parameter lets you specify the number of times the client's banners should be displayed to site visitors, while the AdClicks parameter lets you specify the number of banner clicks purchased by the client. The AdDays parameter lets you specify a duration for which the client's banners are valid; this value is used to calculate the expiry date for the customer's banners.

    It should be noted, however, that the values above are largely toothless tigers, since phpAds does not automatically terminate display of the customer's banners once any of the values are exceeded. Rather, it merely uses them to warn the customer when his account is about to expire. This behaviour is somewhat strange - ideally, once the customer's account has expired, banner display should also stop - and you might want to correct it by modifying the source code of the application.

    Anyway, back to business. Adding phpAds to your Web site is a pretty painless process - it merely involves adding a couple of hooks to your Web pages. In order to better understand it, consider the following simple HTML page:

    <html> <head> <basefont face="Arial"> </head> <body> <table height="100%" width="100%" border="0" cellspacing="5" cellpadding="5"> <tr> <td align="center">Ad goes here</td> </tr> <tr> <td height="100%" width="100%" valign="top" bgcolor="silver" align="left"> <h2>Sample page</h2> <center> Content here <p> Content here <p> Content here <p> </center> </td> </tr> </table> </body> </html>
    Here's what it looks like:



    Now, let's suppose I want to add a banner to this page. I've got my phpAds all set up with client information and a bunch of banners. The first step, then, is to include some required files at the top of my HTML (now PHP) page.

    <? require("phpAds/config.inc.php3"); require("phpAds/view.inc.php3"); require("phpAds/acl.inc.php3"); ?>
    Next, I need to use the phpAds-supplied view() function to actually display a banner. This function takes five arguments, of which only the first one is compulsory. This first argument may be a banner ID, a keyword or image dimensions - phpAds will display a banner matching the argument specified.

    In order to illustrate this, consider the following updated HTML page:

    <? require("phpAds/config.inc.php3"); require("phpAds/view.inc.php3"); require("phpAds/acl.inc.php3"); ?> <html> <head> <basefont face="Arial"> </head> <body> <table height="100%" width="100%" border="0" cellspacing="5" cellpadding="5"> <tr> <td align="center"><? view(15); ?></td> </tr> <tr> <td height="100%" width="100%" valign="top" bgcolor="silver" align="left"> <h2>Sample page</h2> <center> Content here <p> Content here <p> Content here <p> </center> </td> </tr> </table> </body> </html>
    When this page is accessed through a Web browser, phpAds will wake up, read the argument passed to view() - a banner ID - and display the banner corresponding to that ID.

    If you look at the source of this page in your browser, you'll see that the call to

    <? view(15); ?>
    has been magically converted into a clickable hyperlink

    <a href="http://www.melonfire.com/phpAds/click.php3?bannerID=15"><img src="http://www.melonfire.com/phpAds/viewbanner.php3?bannerID=15" width=100 height=100 border=0></a>
    Downside? You don't want this, because it means you'll always be stuck with the same banner on your page. And while loyalty is a nice concept, you're interested in satisfying as many customers as possible so that you can buy your own island and retire. Which is why you might prefer this:

    <tr> <td align="center"><? view("kids"); ?></td> </tr>
    In this case, phpAds will display a random banner containing the keyword "kids".

    You can even display a banner on the basis of its dimensions. Consider the following example, which displays a random banner of size 600x60:

    <tr> <td align="center"><? view("600x60"); ?></td> </tr>
    If images aren't your thing, you can display an HTML banner by specifying the keyword "html" as an argument to view().

    <tr> <td align="center"><? view("html"); ?></td> </tr>
    There's a lot more that you can do with view() - and most of it is explained on the next page. Keep reading.

    More PHP Articles
    More By Harish Kamath, (c) Melonfire


     

       

    PHP ARTICLES

    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT