function phpAds_unpackCookies()
{
    global $phpAds_cookieOldCache, $phpAds_config;
    // These are incremental cookies
    $incremental_cookies = array('phpAds_newCap' => array('var' => 'phpAds_capAd', 'type' => 'p', 'expiry' => time() + 31536000));
    if ($phpAds_config['pack_cookies']) {
        if (!isset($phpAds_cookieOldCache)) {
            $phpAds_cookieOldCache = array('s' => array(), 'p' => array());
        }
        if (isset($_COOKIE['pA_c']) && is_array($_COOKIE['pA_c'])) {
            ksort($_COOKIE['pA_c']);
            $now = time();
            $str = array();
            foreach ($_COOKIE['pA_c'] as $i => $c) {
                if (!preg_match('/^[sp](?:[a-f0-9]{15})?$/', $i)) {
                    continue;
                }
                $session = $i[0] == 's';
                if (extension_loaded('zlib')) {
                    // Decode and decompress if needed
                    $c = @gzinflate(@base64_decode($c));
                } else {
                    // Remove backslashes if needed
                    if (ini_get('magic_quotes_gpc')) {
                        $c = stripslashes($c);
                    }
                }
                if (($c = @unserialize($c)) && is_array($c)) {
                    // Cookies were stored in the correct way
                    // Create a query-string with cookies
                    foreach ($c as $k => $v) {
                        if (isset($v['v']) && ($session || isset($v['e']))) {
                            // Check for session cookies or not expired ones
                            if ($session || $v['e'] > $now) {
                                // Cookie not expired, append it
                                $str[] = urlencode($k) . '=' . urlencode($v['v']);
                                // Add cookie to the cache, so that it won't be lost
                                // in case we need to store other cookies
                                foreach (array_keys($incremental_cookies) as $ki) {
                                    // Skip incremental cookies
                                    if (!preg_match('#^' . $ki . '\\[.*\\]$#', $k)) {
                                        array_push($phpAds_cookieOldCache[$session ? 's' : 'p'], array($k, $v['v'], isset($v['e']) ? $v['e'] : 0));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (count($str)) {
                // Extract cookies into $c following magic_quotes configuration
                parse_str(join('&', $str), $c);
                // Merge them with the real cookie and make them available
                $c += $_COOKIE;
                $_COOKIE = $c;
            }
        }
    }
    // Handle incremental cookies
    foreach ($incremental_cookies as $src => $v) {
        $var = $v['var'];
        $expiry = $v['expiry'];
        $type = $v['type'];
        if (isset($_COOKIE[$src]) && is_array($_COOKIE[$src])) {
            foreach ($_COOKIE[$src] as $k => $v) {
                if (isset($_COOKIE[$var][$v])) {
                    $_COOKIE[$var][$v]++;
                } else {
                    $_COOKIE[$var][$v] = 1;
                }
                phpAds_setCookie($var . '[' . $v . ']', $_COOKIE[$var][$v], $expiry);
            }
            unset($_COOKIE[$src]);
        }
    }
}
    phpAds_SettingsWriteAdd('mult_key', isset($mult_key));
    phpAds_SettingsWriteAdd('p3p_policies', isset($p3p_policies));
    if (isset($p3p_compact_policy)) {
        phpAds_SettingsWriteAdd('p3p_compact_policy', $p3p_compact_policy);
    }
    if (isset($p3p_policy_location)) {
        phpAds_SettingsWriteAdd('p3p_policy_location', $p3p_policy_location);
    }
    phpAds_SettingsWriteAdd('pack_cookies', isset($pack_cookies));
    if ($phpAds_config['pack_cookies'] != isset($pack_cookies)) {
        // Recreate cookie cache
        unset($phpAds_cookieCache);
        unset($phpAds_cookieOldCache);
        // Send session ID using the selected method
        $phpAds_config['pack_cookies'] = isset($pack_cookies);
        phpAds_setCookie('sessionID', $_COOKIE['sessionID']);
        phpAds_flushCookie();
    }
    if (!count($errormessage)) {
        if (phpAds_SettingsWriteFlush()) {
            header("Location: settings-host.php");
            exit;
        }
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PrepareHelp();
phpAds_PageHeader("5.1");
phpAds_ShowSections(array("5.1", "5.3", "5.4", "5.2"));
Esempio n. 3
0
function phpAds_updateGeoTracking($phpAds_geo)
{
    global $phpAds_config, $HTTP_COOKIE_VARS;
    if ($phpAds_config['geotracking_type'] != '' && $phpAds_config['geotracking_cookie']) {
        if (!isset($HTTP_COOKIE_VARS['phpAds_geoInfo']) && $phpAds_geo) {
            phpAds_setCookie("phpAds_geoInfo", ($phpAds_geo['country'] ? $phpAds_geo['country'] : '') . '|' . ($phpAds_geo['continent'] ? $phpAds_geo['continent'] : '') . '|' . ($phpAds_geo['region'] ? $phpAds_geo['region'] : ''), 0);
        }
    }
}
Esempio n. 4
0
 // If zoneid is not set, log it as a regular banner
 if (!isset($zoneid)) {
     $zoneid = 0;
 }
 if (!isset($source)) {
     $source = '';
 }
 // Log clicks
 if (!isset($log) || $log != 'no') {
     if ($phpAds_config['block_adclicks'] == 0 || $phpAds_config['block_adclicks'] > 0 && (!isset($_COOKIE['phpAds_blockClick'][$bannerid]) || $_COOKIE['phpAds_blockClick'][$bannerid] <= time())) {
         if ($phpAds_config['log_adclicks']) {
             phpAds_logClick($bannerid, $clientid, $zoneid, $source);
         }
         // Send block cookies
         if ($phpAds_config['block_adclicks'] > 0) {
             phpAds_setCookie("phpAds_blockClick[" . $bannerid . "]", time() + $phpAds_config['block_adclicks'], time() + $phpAds_config['block_adclicks'] + 43200);
             phpAds_flushCookie();
         }
     }
 }
 // Get vars
 if (isset($_GET)) {
     foreach (array_keys($_GET) as $key) {
         if ($key != 'bannerid' && $key != 'zoneid' && $key != 'source' && $key != 'dest' && $key != 'ismap' && $key != 'log' && $key != 'trackonly' && $key != 'n' && $key != 'cb') {
             $vars[] = $key . '=' . $_GET[$key];
         }
     }
 }
 if (isset($_POST)) {
     foreach (array_keys($_POST) as $key) {
         if ($key != 'bannerid' && $key != 'zoneid' && $key != 'source' && $key != 'dest' && $key != 'ismap' && $key != 'log' && $key != 'trackonly' && $key != 'n' && $key != 'cb') {
Esempio n. 5
0
        // Send bannerid headers
        $cookie = array();
        $cookie['bannerid'] = $banner["bannerid"];
        // Send zoneid headers
        if ($banner['zoneid'] != 0) {
            $cookie['zoneid'] = $banner['zoneid'];
        }
        // Send source headers
        if (isset($source) && $source != '') {
            $cookie['source'] = $source;
        }
        phpAds_setCookie("phpAds_banner[" . $n . "]", serialize($cookie), 0);
        phpAds_flushCookie();
    } elseif (!empty($_COOKIE["phpAds_banner[" . $n . "]"])) {
        // Drop Google Adsense tracking
        phpAds_setCookie("phpAds_banner[" . $n . "]", '', 0);
        phpAds_flushCookie();
    }
}
// Build HTML
echo "<html>\n";
echo "<head>\n";
echo "<title>" . ($banner['alt'] ? $banner['alt'] : 'Advertisement') . "</title>\n";
// Add refresh meta tag if $refresh is set and numeric
if (isset($refresh) && !preg_match('/[^\\d]/', $refresh)) {
    echo "<meta http-equiv='refresh' content='" . $refresh . "'>\n";
}
if (isset($resize) && $resize == 1) {
    echo "<script language='JavaScript'>\n";
    echo "<!--\n";
    echo "\tfunction phpads_adjustframe(frame) {\n";
Esempio n. 6
0
                }
                header("Location: " . str_replace('{url_prefix}', $phpAds_config['url_prefix'], $row['imageurl']));
            } else {
                // Workaround for IE 4-5.5 problem
                // Load the banner from the database
                // and show the image directly to prevent
                // broken images when shown during a
                // form submit
                $res = phpAds_dbQuery("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tcontents\n\t\t\t\t\tFROM\n\t\t\t\t\t\t" . $phpAds_config['tbl_images'] . "\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tfilename = '" . $row['filename'] . "'\n\t\t\t\t");
                if ($image = phpAds_dbFetchArray($res)) {
                    phpAds_setCookie("phpAds_banner[" . $n . "]", serialize($cookie), 0);
                    phpAds_flushCookie();
                    header('Content-type: image/' . $row['contenttype'] . '; name=' . md5(microtime()) . '.' . $row['contenttype']);
                    echo $image['contents'];
                }
            }
            break;
    }
} else {
    phpAds_setCookie("phpAds_banner[" . $n . "]", 'DEFAULT', 0);
    phpAds_flushCookie();
    if ($phpAds_config['default_banner_url'] != '') {
        header("Location: " . $phpAds_config['default_banner_url']);
    } else {
        // Show 1x1 Gif, to ensure not broken image icon
        // is shown.
        header("Content-type: image/gif");
        echo chr(0x47) . chr(0x49) . chr(0x46) . chr(0x38) . chr(0x39) . chr(0x61) . chr(0x1) . chr(0x0) . chr(0x1) . chr(0x0) . chr(0x80) . chr(0x0) . chr(0x0) . chr(0x4) . chr(0x2) . chr(0x4) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x21) . chr(0xf9) . chr(0x4) . chr(0x1) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x2c) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x1) . chr(0x0) . chr(0x1) . chr(0x0) . chr(0x0) . chr(0x2) . chr(0x2) . chr(0x44) . chr(0x1) . chr(0x0) . chr(0x3b);
    }
}
phpAds_dbClose();
Esempio n. 7
0
require_once phpAds_path . "/libraries/lib-io.inc.php";
require phpAds_path . "/libraries/lib-db.inc.php";
require phpAds_path . "/libraries/lib-remotehost.inc.php";
require phpAds_path . "/libraries/lib-log.inc.php";
require phpAds_path . "/libraries/lib-cache.inc.php";
/*********************************************************/
/* Register input variables                              */
/*********************************************************/
phpAds_registerGlobal('bannerid', 'clientid', 'zoneid', 'source', 'block', 'capping', 'session_capping');
/*********************************************************/
/* Main code                                             */
/*********************************************************/
// Determine the user ID
$userid = phpAds_getUniqueUserID();
// Send the user ID
phpAds_setCookie("phpAds_id", $userid, time() + 365 * 24 * 60 * 60);
if (isset($bannerid) && isset($clientid) && isset($zoneid)) {
    $source = phpAds_deriveSource($source);
    if (!phpAds_isViewBlocked($bannerid)) {
        if ($phpAds_config['log_beacon'] && $phpAds_config['log_adviews']) {
            phpAds_dbConnect();
            phpAds_logImpression($userid, $bannerid, $zoneid, $source);
        }
        // Send block cookies
        phpAds_updateViewBlockTime($bannerid);
    }
    // Update the time which this ad can be seen again
    phpAds_updateAdBlockTime($bannerid, $block);
    // Update Capping information for this banner.
    phpAds_updateAdCapping($bannerid, $capping, $session_capping);
    // Update Geotracking information
function phpAds_setDeliveryCookies($row)
{
    global $phpAds_config, $phpAds_geo;
    // Block
    if ($row['block'] != '' && $row['block'] != '0') {
        phpAds_setCookie("phpAds_blockAd[" . $row['bannerid'] . "]", time() + $row['block'], time() + $row['block'] + 43200);
    }
    // Set capping
    if ($row['capping'] != '' && $row['capping'] != '0') {
        phpAds_setCookie("phpAds_newCap[" . md5(uniqid('', true)) . "]", $row['bannerid'], time() + 31536000);
    }
    // Cache geotargeting info
    if ($phpAds_config['geotracking_type'] != '') {
        if ($phpAds_config['geotracking_cookie'] && isset($phpAds_geo)) {
            phpAds_setCookie("phpAds_geoInfo", join('|', $phpAds_geo), time() + 900);
        } elseif (isset($_COOKIE['phpAds_geoInfo'])) {
            phpAds_setCookie("phpAds_geoInfo", '', time() - 900);
        }
    }
}
function phpAds_SessionDataDestroy()
{
    global $phpAds_config;
    global $Session;
    if (isset($_COOKIE['sessionID']) && preg_match('/^[0-9a-f]+$/D', $_COOKIE['sessionID'])) {
        // Remove the session data from the database
        phpAds_dbQuery("DELETE FROM " . $phpAds_config['tbl_session'] . " WHERE sessionid='" . addslashes($_COOKIE['sessionID']) . "'");
    }
    // Kill the cookie containing the session ID
    phpAds_setCookie('sessionID', '');
    phpAds_flushCookie();
    // Clear all local session data and the session ID
    $Session = "";
    unset($Session);
    $_COOKIE['sessionID'] = "";
    unset($_COOKIE['sessionID']);
}
function phpAds_SessionDataDestroy()
{
    global $phpAds_config;
    global $HTTP_COOKIE_VARS, $Session;
    // Remove the session data from the database
    phpAds_dbQuery("DELETE FROM " . $phpAds_config['tbl_session'] . " WHERE sessionid='" . $HTTP_COOKIE_VARS['sessionID'] . "'");
    // Kill the cookie containing the session ID
    phpAds_setCookie('sessionID', '');
    phpAds_flushCookie();
    // Clear all local session data and the session ID
    $Session = "";
    unset($Session);
    $HTTP_COOKIE_VARS['sessionID'] = "";
    unset($HTTP_COOKIE_VARS['sessionID']);
}
Esempio n. 11
0
phpAds_registerGlobal('bannerid', 'clientid', 'zoneid', 'source', 'block', 'capping');
/*********************************************************/
/* Main code                                             */
/*********************************************************/
if (isset($bannerid) && isset($clientid) && isset($zoneid)) {
    if (!isset($source)) {
        $source = '';
    }
    if ($phpAds_config['block_adviews'] == 0 || $phpAds_config['block_adviews'] > 0 && (!isset($_COOKIE['phpAds_blockView'][$bannerid]) || $_COOKIE['phpAds_blockView'][$bannerid] <= time())) {
        if ($phpAds_config['log_beacon'] && $phpAds_config['log_adviews']) {
            phpAds_dbConnect();
            phpAds_logImpression($bannerid, $clientid, $zoneid, $source);
        }
        // Send block cookies
        if ($phpAds_config['block_adviews'] > 0) {
            phpAds_setCookie("phpAds_blockView[" . $bannerid . "]", time() + $phpAds_config['block_adviews'], time() + $phpAds_config['block_adviews'] + 43200);
        }
    }
    // Set delivery cookies
    phpAds_setDeliveryCookies(array('bannerid' => $bannerid, 'block' => isset($block) ? $block : 0, 'capping' => isset($capping) ? $capping : 0));
    phpAds_flushCookie();
}
header("Content-Type: image/gif");
header("Content-Length: 43");
// 1 x 1 gif
echo chr(0x47) . chr(0x49) . chr(0x46) . chr(0x38) . chr(0x39) . chr(0x61) . chr(0x1) . chr(0x0) . chr(0x1) . chr(0x0) . chr(0x80) . chr(0x0) . chr(0x0) . chr(0x4) . chr(0x2) . chr(0x4) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x21) . chr(0xf9) . chr(0x4) . chr(0x1) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x2c) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x1) . chr(0x0) . chr(0x1) . chr(0x0) . chr(0x0) . chr(0x2) . chr(0x2) . chr(0x44) . chr(0x1) . chr(0x0) . chr(0x3b);
if ($phpAds_config['auto_maintenance']) {
    // Perform auto maintenance!
    require phpAds_path . '/libraries/lib-automaintenance.inc.php';
    phpAds_performAutoMaintenance();
}
function view_raw($what, $clientid = 0, $campaignid = 0, $target = '', $source = '', $withtext = 0, $context = 0, $richmedia = true)
{
    global $phpAds_config, $HTTP_SERVER_VARS;
    global $phpAds_followedChain;
    $userid = phpAds_getUniqueUserID();
    phpAds_setCookie("phpAds_id", $userid, time() + 365 * 24 * 60 * 60);
    $outputbuffer = '';
    // If $clientid consists of alpha-numeric chars it is
    // not the clientid, but the target parameter.
    if (!preg_match('#^[0-9]+$#', $clientid)) {
        $target = $clientid;
        $clientid = 0;
    }
    // Not sure what this does, but replicated to campaignid...
    // If $campaignid consists of alpha-numeric chars it is
    // not the campaignid, but the target parameter.
    if (!preg_match('#^[0-9]+$#', $campaignid)) {
        $target = $campaignid;
        $campaignid = 0;
    }
    $found = false;
    // Open database connection and get a banner
    if (phpAds_dbConnect()) {
        // Reset followed zone chain
        $phpAds_followedChain = array();
        $first = true;
        while (($first || $what != '') && $found == false) {
            $first = false;
            if (substr($what, 0, 5) == 'zone:') {
                if (!defined('LIBVIEWZONE_INCLUDED')) {
                    require phpAds_path . '/libraries/lib-view-zone.inc.php';
                }
                $row = phpAds_fetchBannerZone($what, $clientid, $campaignid, $context, $source, $richmedia);
            } else {
                if (!defined('LIBVIEWQUERY_INCLUDED')) {
                    require phpAds_path . '/libraries/lib-view-query.inc.php';
                }
                if (!defined('LIBVIEWDIRECT_INCLUDED')) {
                    require phpAds_path . '/libraries/lib-view-direct.inc.php';
                }
                $row = phpAds_fetchBannerDirect($what, $clientid, $campaignid, $context, $source, $richmedia);
            }
            if (is_array($row)) {
                $found = true;
            } else {
                $what = $row;
            }
        }
    }
    if ($found) {
        $outputbuffer = '';
        // Prepend
        if (isset($row['prepend'])) {
            $outputbuffer .= $row['prepend'];
        }
        // Get HTML cache
        $outputbuffer .= $row['htmlcache'];
        // Append
        if (isset($row['append'])) {
            $outputbuffer .= $row['append'];
        }
        // Determine target
        if ($row['target'] == '') {
            if ($target == '') {
                $target = '_blank';
            }
            // default
        } else {
            $target = $row['target'];
        }
        // Determine source
        $source = urlencode($source);
        // Set basic variables
        $outputbuffer = str_replace('{bannerid}', $row['bannerid'], $outputbuffer);
        $outputbuffer = str_replace('{zoneid}', $row['zoneid'], $outputbuffer);
        $outputbuffer = str_replace('{target}', $target, $outputbuffer);
        $outputbuffer = str_replace('{source}', $source, $outputbuffer);
        // Set path of phpAdsNew
        if ($HTTP_SERVER_VARS['SERVER_PORT'] == 443) {
            $phpAds_config['url_prefix'] = $phpAds_config['ssl_url_prefix'];
        }
        if (isset($HTTP_SERVER_VARS['HTTP_HOST'])) {
            $phpAds_config['url_prefix'] = preg_replace('#//[^/]+/#', '//' . $HTTP_SERVER_VARS['HTTP_HOST'] . '/', $phpAds_config['url_prefix']);
        }
        $outputbuffer = str_replace('{url_prefix}', $phpAds_config['url_prefix'], $outputbuffer);
        // Add text below banner
        if ($withtext) {
            $outputbuffer = str_replace('[bannertext]', '', $outputbuffer);
            $outputbuffer = str_replace('[/bannertext]', '', $outputbuffer);
        } else {
            $outputbuffer = preg_replace("#\\[bannertext\\](.*)\\[\\/bannertext\\]#", '', $outputbuffer);
        }
        // Web banner..
        if ($row['storagetype'] == 'web') {
            if ($HTTP_SERVER_VARS['SERVER_PORT'] == 443) {
                $phpAds_config['type_web_url'] = $phpAds_config['type_web_ssl_url'];
            }
            $outputbuffer = str_replace('{image_url_prefix}', $phpAds_config['type_web_url'], $outputbuffer);
        }
        // HTML/URL banner options
        if ($row['storagetype'] == 'html' || $row['storagetype'] == 'url' || $row['storagetype'] == 'network') {
            // Replace timestamp
            $outputbuffer = str_replace('{timestamp}', time(), $outputbuffer);
            $outputbuffer = str_replace('%7Btimestamp%7D', time(), $outputbuffer);
            // Replace random
            while (preg_match('#(%7B|\\{)random((%3A|:)([0-9]+)){0,1}(%7D|})#i', $outputbuffer, $matches)) {
                if ($matches[4]) {
                    $randomdigits = $matches[4];
                } else {
                    $randomdigits = 8;
                }
                if (isset($lastdigits) && $lastdigits == $randomdigits) {
                    $randomnumber = $lastrandom;
                } else {
                    $randomnumber = '';
                    for ($r = 0; $r < $randomdigits; $r = $r + 9) {
                        $randomnumber .= (string) mt_rand(111111111, 999999999);
                    }
                    $randomnumber = substr($randomnumber, 0 - $randomdigits);
                }
                $outputbuffer = str_replace($matches[0], $randomnumber, $outputbuffer);
                $lastdigits = $randomdigits;
                $lastrandom = $randomnumber;
            }
        }
        // Parse PHP code inside HTML banners
        if ($row['storagetype'] == 'html') {
            if ($phpAds_config['type_html_php']) {
                if (preg_match("#(\\<\\?php(.*)\\?\\>)#i", $outputbuffer, $parser_regs)) {
                    // Extract PHP script
                    $parser_php = $parser_regs[2];
                    $parser_result = '';
                    // Replace output function
                    $parser_php = preg_replace("#echo([^;]*);#i", '$parser_result .=\\1;', $parser_php);
                    $parser_php = preg_replace("#print([^;]*);#i", '$parser_result .=\\1;', $parser_php);
                    $parser_php = preg_replace("#printf([^;]*);#i", '$parser_result .= sprintf\\1;', $parser_php);
                    // Split the PHP script into lines
                    $parser_lines = explode(";", $parser_php);
                    for ($parser_i = 0; $parser_i < sizeof($parser_lines); $parser_i++) {
                        if (trim($parser_lines[$parser_i]) != '') {
                            eval(trim($parser_lines[$parser_i]) . ';');
                        }
                    }
                    // Replace the script with the result
                    $outputbuffer = str_replace($parser_regs[1], $parser_result, $outputbuffer);
                }
            }
        }
        // Add beacon image for logging
        if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) && preg_match("#Mozilla/(1|2|3|4)#", $HTTP_SERVER_VARS['HTTP_USER_AGENT']) && !preg_match("#compatible#", $HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
            $outputbuffer .= '<layer id="beacon_' . $row['bannerid'] . '" width="0" height="0" border="0" visibility="hide">';
            $outputbuffer .= '<img src=\'' . $phpAds_config['url_prefix'] . '/adlog.php?bannerid=' . $row['bannerid'] . '&amp;clientid=' . $row['clientid'] . '&amp;campaignid=' . $row['campaignid'] . '&amp;zoneid=' . $row['zoneid'] . '&amp;source=' . $source . '&amp;block=' . $row['block'] . '&amp;capping=' . $row['capping'] . '&amp;session_capping=' . $row['session_capping'] . '&amp;cb=' . md5(uniqid('', 1)) . '\' width=\'0\' height=\'0\' alt=\'\'>';
            $outputbuffer .= '</layer>';
        } else {
            //$outputbuffer .= '<div id="beacon_'.$row['bannerid'].'" style="width: 0px; height: 0px; overflow: hidden;">';
            $outputbuffer .= '<img src=\'' . $phpAds_config['url_prefix'] . '/adlog.php?bannerid=' . $row['bannerid'] . '&amp;clientid=' . $row['clientid'] . '&amp;campaignid=' . $row['campaignid'] . '&amp;zoneid=' . $row['zoneid'] . '&amp;source=' . $source . '&amp;block=' . $row['block'] . '&amp;capping=' . $row['capping'] . '&amp;session_capping=' . $row['session_capping'] . '&amp;cb=' . md5(uniqid('', 1)) . '\' width=\'0\' height=\'0\' alt=\'\' style=\'width: 0px; height: 0px;\'>';
            //$outputbuffer .= '</div>';
        }
        // Prepare impression logging
        if ($phpAds_config['log_adviews'] && !$phpAds_config['log_beacon']) {
            phpAds_logImpression($userid, $row['bannerid'], $row['zoneid'], $source);
        }
        // Return banner
        return array('html' => $outputbuffer, 'bannerid' => $row['bannerid'], 'alt' => $row['alt'], 'width' => $row['width'], 'height' => $row['height'], 'url' => $row['url'], 'clientid' => $row['clientid'], 'campaignid' => $row['campaignid']);
    } else {
        // An error occured, or there are no banners to display at all
        // Use the default banner if defined
        if ($phpAds_config['default_banner_target'] != '' && $phpAds_config['default_banner_url'] != '') {
            // Determine target
            if ($target == '') {
                $target = '_blank';
            }
            // default
            // Show default banner
            $outputbuffer = '<a href=\'' . $phpAds_config['default_banner_target'] . '\' target=\'' . $target . '\'><img src=\'' . $phpAds_config['default_banner_url'] . '\' border=\'0\' alt=\'\'></a>';
            // Return banner
            return array('html' => $outputbuffer, 'bannerid' => '');
        }
    }
}