function view_raw($what, $clientid = 0, $target = '', $source = '', $withtext = 0, $context = 0, $richmedia = true)
{
    global $phpAds_config;
    global $phpAds_followedChain;
    // 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;
    }
    $found = false;
    // 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, $context, $source, $richmedia);
        } else {
            if (!defined('LIBVIEWDIRECT_INCLUDED')) {
                require phpAds_path . '/libraries/lib-view-direct.inc.php';
            }
            $row = phpAds_fetchBannerDirect($what, $clientid, $context, $source, $richmedia);
        }
        if (is_array($row)) {
            $found = true;
        } else {
            $what = $row;
        }
    }
    if ($found) {
        // Prepare impression logging
        if ($phpAds_config['log_adviews'] && !$phpAds_config['log_beacon']) {
            phpAds_logImpression($row['bannerid'], $row['clientid'], $row['zoneid'], $source);
        }
        $row = array_merge($row, phpAds_getBannerDetails($row['bannerid']));
        return phpAds_prepareOutput($row, $target, $source, $withtext);
    } 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' => '');
        }
        return false;
    }
}
Exemplo n.º 2
0
    $row['bannerid'] = (int) $bannerid;
    $row['zoneid'] = $zoneid;
    $row['prepend'] = $prepend;
    $row['append'] = $append;
} else {
    $row['bannerid'] = (int) $bannerid;
    $row['zoneid'] = 0;
}
// Get the data we need to display the banner
$details = phpAds_getBannerDetails($row['bannerid']);
// Exit if no banner was found
if (!is_array($details)) {
    die;
}
$row = array_merge($row, $details);
$output = phpAds_prepareOutput($row, '_blank', $source, false);
echo "<html>\n";
echo "<head>\n";
echo "\t<title>" . ($row['alt'] ? $row['alt'] : 'Advertisement') . "</title>\n";
if (isset($timeout) && $timeout > 0) {
    echo "<script language='JavaScript'>\n";
    echo "<!--\n";
    echo "\twindow.setTimeout(\"window.close()\", " . $timeout * 1000 . ");\n";
    echo "// -->\n";
    echo "</script>\n";
}
echo "</head>\n";
echo "<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>\n";
echo $output['html'];
echo "\n</body>\n";
echo "</html>\n";