One of the great things about open source repositories such as SourceForge is that they provide access to a huge amount of quality software produced by talented developers from around the world.
SourceForge is a dream come true for Web developers looking for quality free Web apps and scripts for their open source-driven Websites. One of the most popular apps available on SourceForge is called phpAdsNew. phpAdsNew is a PHP/MySQL driven Web app that allows anyone to integrate ads into their Website.
phpAdsNew is one of the most popular open source ad projects on the Internet. I use it on my own site, and I’d honestly have to say that it’s the best ad management system I’ve ever used. In this article I’ll give you a guided tour of phpAdsNew. If you run your own site and attract a couple of thousand visitors each day, then you might want to consider using phpAdsNew to generate some revenue for all your hard work.
What is phpAdsNew?
In my opinion, it’s the best ad management system on the Internet. I’m a little biased however, because I love open source software. So here’s the "official" description, as seen on the SourceForge page:
"phpAdsNew is a banner management and tracking system written in PHP. Currently it can manage multiple banners (any size) per advertiser, view daily, overall and summary statistics and send statistics to advertisers via email."
I think that description pretty much says it all. At the time of writing this article, phpAdsNew was :
- in mature development stage,
- OS independent, and
- had a 99.8656% activity percentile on SourceForge
which means that it’s one of SourceForge’s most popular downloads… and with good reason! phpAdsNew is maintained by a team of 9 developers from around the world.
The current release of phpAdsNew is version 2 beta 6.1, which you can download here. Grab either the tar (262k) or zip (378k) version, and extract it into a folder on your Web server. By default, the folder will be called something like phpAdsNew_2.61, but rename it to phpAdsNew.
Next off we need to configure the details of our database. Open the config.inc.php file in your phpAdsNew directory and look for the following lines at the top of the file:
/* Database configuration */
// MySQL hostname
$phpAds_hostname = "localhost";
// MySQL username
$phpAds_mysqluser = "mysqlusername";
// MySQL password
$phpAds_mysqlpassword = "mysqlpassword";
// The database phpAdsNew lives in
$phpAds_db = "phpads";
You must change the variables shown above to match the details of the Web server where you have MySQL installed, in order for phpAdsNew to work. To make the
$phpAds_db variable function, a database with that name must exist on your MySQL server, so fire up the MySQL console application and enter the following:
create database phpads;
Next, find the administrator configuration section in config.inc.php and change the value of
$phpAds_admin, which is the username we will use shortly to login to phpAdsNew. You should also change
$phpAds_admin_pw to a suitable password.
Lastly, modify the variables under the phpAdsNew configuration section. Save config.inc.php and visit http://yourserver/phpadsnew in your Web browser. Obviously, you need to replace "yourserver" in the address above with either the name or IP address of the server onto which you installed phpAdsNew.
Now that we’ve created our phpAdsNew database, we need to import the table structures for it, which can be found in all.sql in phpAdsNew’s main directory. Jump onto your MySQL server and import the contents of all.sql, like this:
mysql -uadmin -ppassword phpads < c:phpadsnewall.sql
I’ve installed phpAdsNew on my Windows 2000 server running Apache, so obviously if you’re running Linux, then you’ll need to change the path to all.sql. MySQL should respond with a blank line. If you get any errors, double check your login credentials as well as the name of your database and where you’re telling MySQL to find all.sql.
Now, load phpAdsNew in your browser. I installed it locally on my Web server, so I loaded up http://localhost/phpadsnew. Here’s what it looked like:
Enter the values for the user and password that you specified in the config.inc.php file and click on the login button. The phpAdsNew stats screen will load:
phpAdsNew has zones, clients, and banners. First off, we want to add a client, so click on the administration tab and then the ‘add new client’ link. Complete the details of the client when the page loads. Before you click on the save changes button, you should think carefully about whether or not you would like to allow this client to login to your phpAdsNew system and modify his or her campaign.
If you’d like to give your clients the flexibility to change their banner whenever they like, then you should enter a username and password for them and select the appropriate checkboxes for them, which are shown below:
When you’re done, click on the save changes button. phpAdsNew will now let you create a new campaign for this client. The great thing about phpAdsNew is that you can either set how many impressions this clients ad will have, you can set both activation and expiry dates for the ad, or you can just let the ad run for as long as you like.
The weight field is the frequency at which the ad will be shown. The default is 1, but you can set it to a higher value if you’d like the ad to appear more frequently than others if it’s in a rotation.
Set the options for this client’s campaign, and click save changes. phpAdsNew will create the new campaign and redirect you back to the zones page. To create a banner for this client, click on the create link under their campaign:
Once the add new banner page loads, there are four possible types of banners that we can create:
Banner stored in SQL
This option allows you to upload an image directly into the phpAdsNew MySQL database. It’s stored as a blob, and you don’t have to worry about storing image files on your server.
Banner stored on the Web server
If you’d like to store your banner images on your Web server, then choose this option.
Banner references to through URL
This option allows you to reference a banner that’s available online (i.e. http://…). If you’re running banners as part of an ad network, then this is the option that you’re after.
HTML banners are ideal for rich media ads such as flash movies, or even plain text ads, which generally have a great click-thru rate (CTR).
For this article, we’ll create a banner stored in SQL, so select that option and choose/create a banner from your hard drive. I have created a simple 468×60 banner. Once you click on the submit ad button, phpAdsNew will show you how your banner will look. Here’s what mine looked like:
Now that our banner’s been created, it’s time to tell phpAdsNew to generate the banner code for it, which we can include in our Web pages to display the banner. Click on the administration tab and then the generate banner code link, just under the tab. Once again, there are several options to choose from. The way the banner is invocated can be one of five possible options:
- Remote Invocation: An image tag will be generated that points to the location of phpAdsNew’s adview.php script, passing in the ID of the client whose banner we want to display.
- Remote Invocation for iFrames: Generates an <iframe> tag that references adframe.php. Adframe.php returns the image so it’s displayed inside of the iFrame.
- Local Mode: PHP code that includes phpadsnew.inc.php and calls that scripts view function. This is the default mode, however if you’re using MySQL in other areas of your site to display data, then I would recommend staying away from this option.
Once you’ve chosen your banner display options, you’ll need to select the banner to be displayed from the ClientID drop down list. If you’d like the URL that the banner links to open in a new window, enter something like
_blank in the target field. In this example I’m using remote invocation, so here’s the code that phpAdsNew generated when I clicked on the generate button:
<a href='http://localhost/phpAdsNew/adclick.php' target='_blank'><img
Obviously at this point, it’s simply a matter of copying and pasting the generate code into your Web page, and then saving it.
At this point we haven’t really explored the capabilities of phpAdsNew, so let’s now take a look at its powerful reporting and banner rotation features.
One of the things I really like about phpAdsNew is its powerful statistic and graphing capabilities. By simply clicking on the statistics tab in phpAdsNew, you’re presented with detailed stats for each campaign you currently run:
For each campaign, phpAdsNew shows its ID, number of ad views, number of ad clicks, and its click through rate (CTR). Below the details of each campaign is a set of overall stats for all banners, including number of banners shown today, this week and this month, as well as number of clicks and CTR for each period.
On the statistics page, there’s also two links to history and weekly statistics. If you click on the history link, then you’ll be shown a tabulated list of days and the number of ad views, clicks, and CTR for those days. The weekly statistics link shows many of the same things, but in a weekly format.
Sometimes it’s handy to have our banner stats available offline, and, as you’ll see if you click on the reports tab, phpAdsNew supports this functionality. By simply choosing the campaign you’re after, phpAdsNew will generate a file called campaignhistory.csv, which is a set of values separated by commas. By choosing to open this CSV file, my Windows 2000 server launched Excel, and it looked like this:
Of course I’ve only added one campaign to demonstrate how phpAdsNew works, but if you had dozens of campaigns, then Excel’s chart wizard would allow you to create professional looking charts from your phpAdsNew campaign data, which can be used in your media kit to help persuade potential advertisers to advertise on your site.
One of the best ways to generate more revenue for your site is to set up banner rotations. As compared to normal banners, a rotation contains several (usually 5-20) banners in one ad space; a randomly selected ad from the set is displayed for each page view. Each advertiser gets a shared number of impressions, and rotations are great when you’re trying to advertise similar products/services to a niche audience.
To set up a banner rotation with phpAdsNew, simply create at least two banners and click on the administration -> generate bannercode link. The what field allows you to specify the criteria for the rotation. For example, if you wanted to set up a rotation with all your 468×60 banners, then you would enter 468×60 into the text box.
You can also display banners in rotation based on their name. If you created two banners that both have the word ‘test’ in their name, for example, then you can specify ‘test’ as the value of the what field. All banners with the word ‘test’ in their name would then be displayed in the rotation.
The what field can also accept some rather complex statements, allowing you to specify exactly which banners should be included in a rotation. If you want to match a banner by its ID, you can use the following statement:
On some occasions, it’s also handy to display only HTML banners, or only SQL-based banners, etc. We can do this by specifying the format statement in the what field, like this:
As mentioned earlier, you can specify the width of the banners you’d like in the rotation with width x height, just like this:
You can also specify just the width of the banner, like this:
There are dozens of other advanced values for the what field, including matching based on logical operators, the global keyword and more. If you’re interested in these other advanced values, then consult the phpAdsNew documentation, chapter 3.2.
In this article we’ve seen how to set up and use phpAdsNew, which is a great, free, open-source ad management system. If you run your own Website then you should consider using phpAdsNew to add some advertising to your site as a way to make some extra revenue for your hard work.
I think that the reason why phpAdsNew is so popular is because it’s always being updated and debugged, much like all of the other Web apps on SourceForge. I myself will use phpAdsNew both now and into the future, as I personally believe that there’s no other ad system like it.