}
$res = phpAds_dbQuery("\n\tSELECT\n\t\t*\n\tFROM\n\t\t" . $phpAds_config['tbl_banners'] . "\n\tWHERE\n\t\tclientid = '{$campaignid}'\n\t" . phpAds_getBannerListOrder($navorder, $navdirection) . "\n") or phpAds_sqlDie();
while ($row = phpAds_dbFetchArray($res)) {
    phpAds_PageContext(phpAds_buildBannerName($row['bannerid'], $row['description'], $row['alt']), "stats-banner-affiliates.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&bannerid=" . $row['bannerid'], $bannerid == $row['bannerid']);
}
phpAds_PageShortcut($strClientProperties, 'client-edit.php?clientid=' . $clientid, 'images/icon-client.gif');
phpAds_PageShortcut($strCampaignProperties, 'campaign-edit.php?clientid=' . $clientid . '&campaignid=' . $campaignid, 'images/icon-campaign.gif');
phpAds_PageShortcut($strBannerProperties, 'banner-edit.php?clientid=' . $clientid . '&campaignid=' . $campaignid . '&bannerid=' . $bannerid, 'images/icon-banner-stored.gif');
phpAds_PageShortcut($strModifyBannerAcl, 'banner-acl.php?clientid=' . $clientid . '&campaignid=' . $campaignid . '&bannerid=' . $bannerid, 'images/icon-acl.gif');
phpAds_PageHeader("2.1.2.2.2");
echo "<img src='images/icon-client.gif' align='absmiddle'>&nbsp;" . phpAds_getParentName($campaignid);
echo "&nbsp;<img src='images/" . $phpAds_TextDirection . "/caret-rs.gif'>&nbsp;";
echo "<img src='images/icon-campaign.gif' align='absmiddle'>&nbsp;" . phpAds_getClientName($campaignid);
echo "&nbsp;<img src='images/" . $phpAds_TextDirection . "/caret-rs.gif'>&nbsp;";
echo "<img src='images/icon-banner-stored.gif' align='absmiddle'>&nbsp;<b>" . phpAds_getBannerName($bannerid) . "</b><br><br>";
echo phpAds_buildBannerCode($bannerid) . "<br><br><br><br>";
phpAds_ShowSections(array("2.1.2.2.1", "2.1.2.2.2"));
/*********************************************************/
/* Main code                                             */
/*********************************************************/
$manual['clicks'] = 0;
$manual['views'] = 0;
// Get affiliates and build the tree
$res_affiliates = phpAds_dbQuery("\n\tSELECT \n\t\taffiliateid, name\n\tFROM \n\t\t" . $phpAds_config['tbl_affiliates'] . "\n\t" . phpAds_getAffiliateListOrder($listorder, $orderdirection) . "\n\t") or phpAds_sqlDie();
while ($row_affiliates = phpAds_dbFetchArray($res_affiliates)) {
    $affiliates[$row_affiliates['affiliateid']] = $row_affiliates;
    $affiliates[$row_affiliates['affiliateid']]['expand'] = 0;
    $affiliates[$row_affiliates['affiliateid']]['count'] = 0;
}
// Get the zones for each affiliate
$res_zones = phpAds_dbQuery("\n\tSELECT \n\t\tzoneid, affiliateid, zonename, delivery, what\n\tFROM \n\t\t" . $phpAds_config['tbl_zones'] . "\n\t\t" . phpAds_getZoneListOrder($listorder, $orderdirection) . "\n\t") or phpAds_sqlDie();
                echo "<tr height='25'><td width='50%'>" . $strSize . ": -</td>";
            } else {
                echo "<tr height='25'><td width='50%'>" . $strSize . ": " . $banners[$bkey]['width'] . " x " . $banners[$bkey]['height'] . "</td>";
            }
            echo "<td width='50%'>" . $strWeight . ": " . $banners[$bkey]['weight'] . "</td></tr>";
            echo "</table><br></td></tr>";
        }
        // Banner preview
        if ($banners[$bkey]['expand'] == 1 || $phpAds_config['gui_show_campaign_preview']) {
            if (!$phpAds_config['gui_show_banner_info']) {
                echo "<tr " . ($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . "><td colspan='1'>&nbsp;</td><td colspan='4'>";
            }
            echo "<tr " . ($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . "><td colspan='5'>";
            echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'><tr>";
            echo "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
            echo "<td width='100%'>" . phpAds_buildBannerCode($banners[$bkey]['bannerid'], true) . "</td>";
            echo "</tr></table><br><br>";
            echo "</td></tr>";
        }
        $i++;
    }
}
echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
echo "<tr height='25'><td colspan='3' height='25' nowrap>";
if (isset($banners) && count($banners)) {
    echo "<img src='images/icon-recycle.gif' border='0' align='absmiddle'>&nbsp;<a href='banner-delete.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&returnurl=campaign-banners.php'" . phpAds_DelConfirm($strConfirmDeleteAllBanners) . ">{$strDeleteAllBanners}</a>&nbsp;&nbsp;&nbsp;&nbsp;";
}
if (isset($banners) && $count_active < count($banners)) {
    echo "<img src='images/icon-activate.gif' border='0' align='absmiddle'>&nbsp;<a href='banner-activate.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&value=f'>{$strActivateAllBanners}</a>&nbsp;&nbsp;&nbsp;&nbsp;";
}
if ($count_active > 0) {
    if ($row['contenttype'] == 'html') {
        $htmlcode = $row['htmlcache'];
        // Basic modifications
        $htmlcode = str_replace('{url_prefix}', $phpAds_config['url_prefix'], $htmlcode);
        $htmlcode = str_replace('{bannerid}', $bannerid, $htmlcode);
        $htmlcode = str_replace('{zoneid}', '', $htmlcode);
        $htmlcode = str_replace('{source}', '', $htmlcode);
        $htmlcode = str_replace('{target}', '_blank', $htmlcode);
        $htmlcode = str_replace('[bannertext]', '', $htmlcode);
        $htmlcode = str_replace('[/bannertext]', '', $htmlcode);
        $htmlcode = phpAds_replaceVariablesInBannerCode($htmlcode);
        // Remove appended HTML for the preview
        $htmlcode = str_replace($row['append'], '', $htmlcode);
        // Disable logging of adclicks
        $htmlcode = str_replace('adclick.php?', 'adclick.php?log=no&', $htmlcode);
    } else {
        $htmlcode = phpAds_buildBannerCode($row['bannerid'], true);
    }
    // Output banner
    echo $htmlcode;
    echo "</td><td width='32'>&nbsp;</td></tr>";
    echo "<tr height='32'><td width='32'><img src='images/cropmark-bl.gif' width='32' height='32'></td><td>";
    if ($row['contenttype'] == 'txt') {
        echo "&nbsp;";
    } else {
        echo "&nbsp;&nbsp;&nbsp;width: " . $row['width'] . "&nbsp;&nbsp;height: " . $row['height'] . "&nbsp" . ($row['bannertext'] ? '+ text&nbsp;' : '');
    }
    echo "</td><td width='32'><img src='images/cropmark-br.gif' width='32' height='32'></td></tr>";
    echo "</table>";
    echo "</body></html>";
}
// Include required files
require "config.php";
require "lib-statistics.inc.php";
// Initialize random generator
mt_srand((double) microtime() * 1000000);
/*********************************************************/
/* Main code                                             */
/*********************************************************/
$res = phpAds_dbQuery("\n\tSELECT\n\t\t*\n\tFROM\n\t\t" . $phpAds_config['tbl_banners'] . "\n\tWHERE\n\t\tbannerid = '{$bannerid}'\n\t") or phpAds_sqlDie();
if ($res) {
    $row = phpAds_dbFetchArray($res);
    echo "<html><head><title>" . strip_tags(phpAds_buildBannerName($bannerid, $row['description'], $row['alt'])) . "</title>";
    echo "<link rel='stylesheet' href='images/" . $phpAds_TextDirection . "/interface.css'></head>";
    echo "<body marginheight='0' marginwidth='0' leftmargin='0' topmargin='0' bgcolor='#EFEFEF'>";
    echo "<table cellpadding='0' cellspacing='0' border='0'>";
    echo "<tr height='32'><td width='32'><img src='images/cropmark-tl.gif' width='32' height='32'></td>";
    echo "<td background='images/ruler-top.gif'>&nbsp;</td><td width='32'><img src='images/cropmark-tr.gif' width='32' height='32'></td></tr>";
    echo "<tr height='" . $row['height'] . "'><td width='32' background='images/ruler-left.gif'>&nbsp;</td><td bgcolor='#FFFFFF' width='" . $row['width'] . "'>";
    // Output banner
    echo phpAds_buildBannerCode($row['bannerid'], true);
    echo "</td><td width='32'>&nbsp;</td></tr>";
    echo "<tr height='32'><td width='32'><img src='images/cropmark-bl.gif' width='32' height='32'></td><td>";
    if ($row['contenttype'] == 'txt') {
        echo "&nbsp;";
    } else {
        echo "&nbsp;&nbsp;&nbsp;" . $strWidth . ": " . $row['width'] . "&nbsp;&nbsp;" . $strHeight . ": " . $row['height'] . "&nbsp" . ($row['bannertext'] ? '+ text&nbsp;' : '');
    }
    echo "</td><td width='32'><img src='images/cropmark-br.gif' width='32' height='32'></td></tr>";
    echo "</table>";
    echo "</body></html>";
}