phpAds - Administrator's Guide

phpAds is a banner management and tracking system written in PHP.
Homepage: http://phpwizard.net/phpAds/

General Information

Please read the INSTALL file for installation instructions.

phpAds is split into three parts:

  1. An administration interface, accessible through http://<yourdomain>/<PathToPhpAds>/admin/
  2. A web interface for your clients, accessible through http://<yourdomain>/<PathToPhpAds>/client/
  3. A backend, which handles banner display and logging and sends statistics to your clients via email

The Admin Interface

Through this web based control center, you can manage your clients and their banners. It also allows to view statistics for individual clients.

Access Control Lists

In the banner administration section, you can access a page named Modify banner ACL. This allows you to set up Access Control Lists - filters defining the circumstances when the banner should be shown. Currently, the following filters are available:

Title Argument Description
Client IP IP net/mask: ip.ip.ip.ip/mask.mask.mask.mask, for example 127.0.0.1/255.255.255.0 Display banner only for a specific IP region.
User agent regexp Regular expression matching a user agent, for example ^Mozilla/4.? Display banner only for certain browsers.
Weekday (0-6) Day of the week, from 0 = Sunday to 6 = Saturday Display banner only on a specific day of the week.

For example, if you want to display this banner only on weekends, you would add two ACL entries:

  • Weekday (0-6), argument 6 (for Saturday)
  • Weekday (0-6), argument 0 (for Sunday)

The Client Interface

Usually, you'll give the URL of the client interface to your clients so that they can track the adviews/adclicks of their banners. As you can associate a username/password with each client, a client is only able to view information belonging to her banners.

The Backend

As an administrator you need to familiarize yourself with phpAds' backend structure. phpAds gives you two options to include a banner on your site: local mode and remote invocation. It is recommended to use the first method where possible.

Local Mode

This is the tradtional style of a including a banner within a PHP3-powered website. On every page you want to have a banner, you have to include config.inc.php3, view.inc.php3 and acl.inc.php3. These files are in your phpAds-installation-directory. Banner are displayed using the view()-function. This function has the following syntax:

int view (mixed what [, int clientID [, string target [, bool withText = 0[, array context]]]]);

  • The argument "what" is currently one of the following:
    • [int]: Display the banner with this bannerID. Example: view(1);
    • "[width]x[height]: Display a randomly selected banner with this width/height. Example: view("468x60");
    • "html": Display a randomly selected HTML-banner
    • "[keyword]": Display a randomly selected banner with this keyword associated to it. Example: view("maingroup");
      Note: Banners with the special keyword "global" associated to them, are also considered when using this syntax.
  • The optional argument clientID allows you to retrieve only banners by a specific client. Specify "" to view banners from all clients (in case you need the third or fourth argument, else don't specify it at all).
    Example: view("468x60", 1).
  • The optional argument "target" allows you to specify a frame target (may be one of "[framename]", "_blank", "_parent" and "_top").
    Example: view("maingroup", 0, "_blank");
  • The optional argument withText allows you to show a banner with its associated line of text below it (for example, "Suport our sponsor" is a common line of text).
    Example: view("maingroup", 0, "", 1);
  • The optional argument "context" is an array specifying banners to limit the search to or/and banners to be excluded from the search. It is an array containing as many associative arrays as you want. The key of the entries must either be "==" to denote a banner to which the search is limited to or "!=" to denote a banner to be excluded from the search. The value of an entry is a banner ID. For example, to show the same randomly selected banner on the top and bottom of a page, you could use the following:

    // Top of the page:
    $id = view("main", 5);

    // Bottom of the page
    $arr = array(
            array("==" => $id)
           );
    view("main", 0, "", 0, $arr);
    To make sure that the page does not the same banner two times, you could use this:
    // Top of the page:
    $id = view("main", 5);

  • // Bottom of the page
    $arr = array(
            array("!=" => $id)
           );
    view("main", 0, "", 0, $arr);

Some examples:

  • view(1); - Displays the banner with the bannerID of 1.
  • view("html"); - Displays a randomly selected HTML banner
  • view("468x60", 0, "_blank"); - Displays a randomly selected banner with a width of 468 pixels and a height of 60 pixels. If user clicks on it, the target destination will be opened in a new window.
  • view("Websites/Business/New_Media/"); - Displays a randomly selected banner from the group "Websites/Business/New_Media/" (in other words: with that keyword).

A sample HTML file could look like this:

<?
 require("/usr/local/etc/phpAds/config.inc.php3"); 
 require("/usr/local/etc/phpAds/view.inc.php3"); 
 require("/usr/local/etc/phpAds/acl.inc.php3"); 
?> 
  
<html>
    <head> 
      <title>phpAds demo</title>
    </head>
  <body>
    <?
      view("468x60");
    ?>
  </body>
</html> 
             

Remote Invocation

It is also possible to use phpAds on sites which lack PHP-support. Random or pre-defined banners can be shown using a standard <img>-construct. Just like in Local Mode, you can use the "what" argument to select the banner.

To use multiple banners on a single page, select a unique name for each banner and assign it to the "n" argument for both "click.php3" and "phpads.php3".

Examples:

  • <a href="click.php3"><img src="phpads.php3?what=468x60&n=ban1"></a> - Show a randomly selected banner of the size 468x60.
  • <a href="click.php3?n=top"><img src="phpads.php3?what=main&n=top"></a> - Show a randomly selected banner from the "main" group with the name "top".
  • <a href="click.php3?n=left"><img src="phpads.php3?what=468x60&n=left"></a> - Show a randomly selected banner of the size 468x60 with the name "left".

The mail.php3 File

This file is responsible for sending statistics to your clients (via email) and for disabling banners which have no adviews left. You should execute it daily, for example from Cron. For more instructions, please refer to INSTALL.

FAQ - Frequently Asked Questions

The login doesn't work, it keeps prompting for username/password all over again.
or I can't add banners.

Make sure you have enabled magic_quotes_gpc in your PHP configuration.

I get the following error: Fatal error: Call to unsupported or undefined function mysql_pconnect().

Your PHP is not configured for MySQL support. If you're on Unix, you need to recompile PHp --with-mysql. If you're on Windows, you have to enable the MySQL DLL in your PHP configuration. See the manual, installation section, for more details.

Can you help me to install phpAds? Can you please implement this feature I need?

No, sorry.