PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Arturs Sosins   Pop under class   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Full customization with detailed description
Class: Pop under class
Display interstitial advertising
Author: By
Last change: credits changed
Date: 12 years ago
Size: 5,632 bytes


Class file image Download
 * This script is developed by Arturs Sosins aka ar2rsawseen,
 * Fee free to distribute and modify code, but keep reference to its creator
 * 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.
 * Language and template files included to provide full outlook customization
 * For more information, examples and online documentation visit:

//just for emulating site navigation from one link to another
$_GET['id'] = 0;

//declaring class instance
$popunder = new pop_under();

Setting timer how long should user view advertisment
in seconds.
Default value is 10 seconds

Setting probability for popunder to appear
in percents. 10 means there is a 10% chance
of advertisment to appear on every page view
(excluding sittuation when user is marked).
It means popunder should appear approximately
on every 10th page view, but thats random,
so don't count on consistency
Default value is 10.

set_exit method allows you to give visitor option
to skip advertisment and continue to requestet page
If set to false, then visitor will have to wait whole time
specified by set_timer method, if visitor will try to
refresh page, timer will be reset and start over again
(class uses session to maintain that)

There is an opton to mark visitors that already
viewed advertisment, to not bother them too often, using cookies.
The "not bothering" time depends on time set using
set_period() method in seconds,
by default it is 1 day, but you may change it if you wish.
If you choose not to use visitor marking
(by default it is on, but you can disable it using method below)
then popunder ads will appear based on specified probability
on every pageview, which could be pretty annoying
if probability is high

if visitor marking is true, then marked visitor
won't be bothered with pop under advertisments
for time period ins econds specified below

callback function is used to gather statistic
about which advertisment was shown and was it
skipped by user, or fully viewed
Callback function needs to be declared before
passing function name to class
and it must accept 2 parameters
1. parameter - ID of advertisment you provided
        when adding advertisment to rotation
2. parameter - bool whether advertisment was skipped
        by visitor. False means visitor didn't push
        skip advertising button/link
function call_back($id, $skip){
//update database record etc, based on advertisment ID if you need to
    //outputting text is just to show you how it works
echo "<p>Advertisment with ID ".$id." was shown and";
" was skipped";
" wasn't skipped";
" by visitor</p>";
//function declared, now we can pass it to class

add_url method ads avertisment to rotation
all advertisments appear in random order
and after user viewed advertisment
callback function will be called.
Method add_url accepts 3 parameters:
1. - url of advertisment
2.(optional) - title or deswcribing text
3.(optional) - unique identifier which will be
passed to callback function
$popunder->add_url("", "Code snippets", 1);
$popunder->add_url("", "Arturs Sosin's PHP classes", 2);

This is just for debugging purpose
if something isn't working as you expected
Shoouldn't be used in end version
if($errors = $popunder->get_errors())
$errors as $error)

And this method does all the magick
Use it before any other otuput to browser

Some random content
echo "<p>Content</p>";
"<p>There is a 50% probability of popunder advertisment to appear, just keep clicking link</p>";
"<p><a href='?id=".($_GET['id']+1)."'>Goto ".($_GET['id']+1)."</a></p>";


Class language

You may want to change language used in user interface
Do that by editing language.php file,
just keep aray structure and key names the same

Pop under template

You may customize popunder template in popunder_template.php
to match your site design. Just leave layout and constant,
you may change colors and sizes, etc