Implementing Ad Support Into Your Site With PHPAdsNew

PhpAdsNew is one of the most popular open source ad projects on the Internet. We use it right here on devArticles to manage ads for our advertisers, and I would honestly have to say that it’s the best ad management system I’ve ever used. In this article Mitchell’s going to give you a guided tour of PhpAdsNew, including how to install it, how to create your first banner, and also how to create your first banner rotation.

One of the great things about open source repositories such as SourceForge is the huge amount of quality software that talented developers from all around the world produce.

SourceForge is a dream come true for web developers looking for quality free web apps and scripts for their open source-driven web site. 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 web site.

PhpAdsNew is one of the most popular open source ad projects on the Internet. We use it right here on devArticles to manage ads for our advertisers, and I would honestly have to say that it’s the best ad management system I’ve ever used. In this article I’m going to give you a guided tour of PhpAdsNew. If you run your own web site and have a couple of thousand visitors coming to your site each day, then you might want to consider using PhpAdsNew to generate some revenue for all of your hard work.{mospagebreak title=What is PhpAdsNew?&toc=1} In my opinion, it is the best ad management system on the Internet. I am a little bias however, because I love open source software, so here’s the “official” description, as seen on the PhpAdsNew 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, was 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 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 should change the variables shown above to match the details of your web server where MySQL is installed. For the $phpAds_db variable, a database with that name must exist on your MySQL server before PhpAdsNew will work, so fire up the MySQL console application and enter the following:

create database phpads;

Next, find the administrator configuration section in 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 and visit http://yourserver/phpadsnew in your web browser. Obviously, you need to replace “yourserver” in the web address above with either the name or IP address of the web 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:

PhpAdsNew's login screen

Enter the values for the user and password that you specified in the file and click on the login button. The PhpAdsNew stats screen will load:

The PhpAdsNew stats screen{mospagebreak title=Using PhpAdsNew&toc=1} 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 campaign.

If you’d like to give your clients the flexibility of changing 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:

PhpAdsNew client options

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 that 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 any others if it’s in a rotation.

Set the options for this clients campaign then 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:

Adding a new banner for a client

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 Webserver: If you’d like to store your banner images on your webserver, 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 banner: 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:

Previewing my banner with PhpAdsNew

Now that our banner’s 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 with JavaScript: Generates a SCRIPT tag which references adjs.php, which uses JavaScript's document.write function to display the banner.
  • 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.
  • Combined Remote Invocation: Uses a combination of an iframe tag and script tag to generate a banner called from JavaScript based inside of an iFrame.
  • Local Mode: PHP code that includes 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 src=”'http://localhost/phpAdsNew/adview.php?clientID=2&target=_blank&#39″; border='0'>&lt/a>

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 power of PhpAdsNew, so let's now take a look at its powerful reporting and banner rotation features.{mospagebreak title=Stats and banner rotations&toc=1} 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 that you're currently running:

PhpAdsNew's powerful statistics features

For each campaign, PhpAdsNew shows its ID, number of ad views, number of ad clicks, and its click thru 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 of these periods.

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 much the same things, but in a weekly format.

Sometimes it's handy to have our banner stats available offline, and PhpAdsNew supports this, as you'll see if you click on the reports tab. 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:

The PhpAdsNew report in CSV format in Excel

Of course I've only added one campaign to demonstrate how PhpAdsNew works, but if you had dozens of campaigns, then Excels chart wizard would allow you to create professional looking charts from your PhpAdsNew campaign data, which can be used to form part of your media kit to convince potential advertisers to advertise on your web site.

Banner rotations
One of the best ways to generate more revenue for your site is to setup banner rotations. As compared to normal banners, a rotation contains several (usually 5-20) banners in one ad space, with only on ad being randomly selected to be shown each time. Each advertiser gets a shared amount of impressions, and rotations are great when you're trying to advertise similar products/services to a niche audience.

Setting up a banner rotation with PhpAdsNew is simply a matter of creating at least two banners and then clicking on the administration -> generate bannercode link. The what field is where you specify the criteria for the rotation. For example, if you wanted to setup a rotation with all of your 468×60 banners, then you would enter 468×60 into the text box.

You can also display banners in a rotation based on their name. If you created two banners both with the word test in their name for example, then you can specify test as the value of the what field and all banners with the word test in their name would 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:

[code] bannerId:40[/code]

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:

[code] 468×60 [/code]

You can also specify just the width of the banner, like this:

[code] Width:468 [/code]

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.{mospagebreak title=Conclusion&toc=1} In this article we've seen how to setup and use PhpAdsNew, which is a great free, open source ad management system. If you run your own web site 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, debugged, and having new version released, much like all of the other web apps on SourceForge. I myself will be using PhpAdsNew to run the ads on both now and into the future, as I personally believe that there's no other ad system like it.
[gp-comments width="770" linklove="off" ]

chat sex hikayeleri Ensest hikaye