Implement pop under advertising to your site using pop under class
Pop under class allows you to implement pop under advertising to your website.
You can customize probability of ads to appear, time for how long to show advertisement and much more.
There is also an option to mark users who saw advertisement for specified period of time, so they won't be bothered with pop under advertisements during that specified period.
You can also specify advertisement URL and unique ID (optional to track showed advertisements and whether they were skipped by users or watched fully using callback function).
Easiest implementation you'll ever have, just check out example file codes at phpclasses.org
Contents
- Download
- Example codes
- Examples in action
- Method list
- Possible error messages
- Template
- Change language
- Latest changes
- Rate us
- Support
- Awards
Download
Example codes
Simple example:
<?php //declaring class instance include("./pop_under.class.php"); $popunder = new pop_under(); //putting in link to show with optional title text $popunder->add_url("http://code-snippets.co.cc/", "Code snippets"); $popunder->add_url("http://www.phpclasses.org/browse/author/838850.html", "Arturs Sosin's PHP classes"); //for testing purpose visitors won't be marked $popunder->use_mark(false); //and of course showing ads //put this before any other output $popunder->show_ads(); //and some content goes here echo "<p>Content</p>"; echo "<p>Default probability of popunder to appear is 10% "; echo "on every pageview, so just keep refreshing till you get it ;)</p>"; echo "<p><a href='?id=".($_GET['id']+1)."'>Goto ".($_GET['id']+1)."</a></p>"; ?>
Examples in action
Example scripts provided with package in action:
Method list
- Get errors
- Set advertisment timer
- Set probability of pop under to appear
- Allow or disallow visitor to skip advertisment
- Mark visitors who already saw advertisment
- Set period of time not to show advertisment
- Add advertisment to show
- Set callback for displaying advertisment
- Show random advertisments
Get errors
| Method name | get_errors() |
| Description | Returns array with errors or empty array if there was no errors |
| Example output |
Array
(
[0] => Timer can not be negative. Previous or default value will be used
)
|
Set advertisment timer
| Method name | set_timer($sec) |
| Description | Sets the timer for how long to display advertisment in seconds. Default value 10 seconds |
| Input parameters | int $sec - time in seconds how long to display advertisment |
| Example input | set_timer(10) |
Set probability of pop under to appear
| Method name | set_probability($percent) |
| Description | Sets the probability in percent for advertisment to appear, while browsing website. Default value 10% |
| Input parameters | int $percent - value bigger than 1 and lesser or eqaul then 100. 100% - every page refresh advertisment will be showed |
| Example input | set_probability(50) |
Allow or disallow visitor to skip advertisment
| Method name | set_exit($bool) |
| Description | Allows or dissallows visitors to skip advertisment by clicking specific link. Refresh page won't skip advertisment, it will be loaded from the start. Default value: allow to skip advertisments |
| Input parameters | boolean $bool - true: show skip option, false: don't allow to skip advertisment |
| Example input | set_exit(false) |
Mark visitors who already saw advertisment
| Method name | use_mark($bool) |
| Description | Allows to mark visitors, using cookies, to whom advertisment already appear, so they won't be bothered with it for a specified period of time using set_period method. After specified period of time, visitor will be shown advertisment with specified probability. Default value: mark visitors |
| Input parameters | boolean $bool - true: mark visitors and don't show advertisment for specified period of time, false: don't mark visitors and show advertisment with probability to appear |
| Example input | use_mark(false) |
Set period of time not to show advertisment
| Method name | set_period($sec) |
| Description | Sets the period of time not to show advertisments to marked visitors (who already saw one advertisment). Default value 1 day |
| Input parameters | int $sec - specifies period of time in seconds |
| Example input | set_period(6400) |
Add advertisment to show
| Method name | add_url($src, $title = "", $id = "") |
| Description | Add advertisment to show randomly to website visitors |
| Input parameters | string $src - url of advertisment string $title - Title of advertisment to appear on top int $id - unique identifier of advertisment, to notify you via callback function which advertisment was show to visitor |
| Example input | add_url("http://code-snippets.co.cc/PHP-classes/Implement-pop-under-advertising-to-your-site-using-pop-under-class", "Pop under class documentation") |
Set callback for displaying advertisment
| Method name | set_callback($func_name) |
| Description | Sets the callback function to call everytime advertisment is displayed, which provides information on which advertisment was shown and was it skipped by user or not. Callback function must take to parameters, unique identifier of advertisment provided with add_url method, and second boolean specifying whether visitor skipped advertisment using exit link. If true - visitor skipped, if false - didn't skip |
| Input parameters | string $func_name - name of callback function string $title - Title of advertisment to appear on top int $id - unique identifier of advertisment, to notify you via callback function which advertisment was show to visitor |
| Example input | add_url("http://code-snippets.co.cc/PHP-classes/Implement-pop-under-advertising-to-your-site-using-pop-under-class", "Pop under class documentation") |
Show random advertisments
| Method name | show_ads() |
| Description | Combines all settings provided and starts the probability of random advertisments. Without calling this method, advertisments won't appear. You must call this methid before any output to browser. You can use output buffer to ensure this |
Possible error messages
List of all errors and meanings
| Error text | Meaning | Solution |
| Incorrect language array. Default language array will be used | Format of language array you specified is incorrect | Don't modify keys in array provided in language.php, change only text. Example format of language array:
Array
{
'add_to_title' => 'Advertisment',
'seconds_left' => 'seconds left',
'redirecting' => 'Redirecting',
'waiting' => 'Waiting for page to load',
'skip' => 'Continue to page'
}
|
| No language array provided. Default language array will be used | No language array in language.php or language.php doesn't exists | Create language.php in same directory and create and array in it: $lang = array ( "add_to_title" => "Advertisment", "seconds_left" => "seconds left", "redirecting" => "Redirecting", "waiting" => "Waiting for page to load", "skip" => "Continue to page" ); |
| Timer can not be negative. Previous or default value will be used | You provided negative value for timer | Provide value that is bigger than 0 |
| Porbability can be between 1 and 100 percents. Previous or default value will be used | You provided percents that are out of 1-100 ranges | Provide value that is bigger than 1 and lesser or equal then 100 |
| Period of time can not be negative. Previous or default value will be used | You provided negative value for period | Provide value that is bigger than 0 |
| Function with specified name: $func_name does not exist | Callback function your provided, doesn't exist | Provide valid callback function |
| No urls to show provided | You didn't provide any advertisment urls to show | Provide adverstisment urls |
Template
File popunder_template.php contains a template for iframe where advertisments appear. Do not delete or change specified constants: [@constant_name]. You can change only html code. If popunder_template.php is missing, default template will be used form within the cass
Default template:
<html> <head> [@title] [@script] </head> <body> <table style='height:80px; width:100%; text-align: center; border: 0;'> <tr> <td style='width: 70%'> <h3>[@popunder_text]</h3> </td> <td style='width: 30%'> <p id='seconds'>[@waiting]</p> <p>[@exit]</p> </td> </tr> </table> <iframe name='content' src='[@popunder_src]' width='100%' height='100%'/> <noframes> <p><a href='[@request_uri]'>[@skip]</a></p> </noframes> </body> </html>
Change language
File language.php contains default texts. You can modify values of array $lang to display your own default texts, but DO NOT modify the keys of array, or else default language array will be used from within the class
Default language file:
<?php $lang = array ( "add_to_title" => "Advertisment", "seconds_left" => "seconds left", "redirecting" => "Redirecting", "waiting" => "Waiting for page to load", "skip" => "Continue to page" ); ?>
Latest changes
None for now
Rate us
Try it out and Rate on PHPclasses.org
Support
PHP classes support forum or comments below
Awards
Pop under class was nominated to Innovation Award and achieved 7th place, thank you for support
You may also be interested in:
Powered by BlogAlike.com










