/* HTML framework                                        */
/*********************************************************/
if (phpAds_isUser(phpAds_Admin)) {
    if (isset($Session['prefs']['stats-global-client.php']['listorder'])) {
        $navorder = $Session['prefs']['stats-global-client.php']['listorder'];
    } else {
        $navorder = '';
    }
    if (isset($Session['prefs']['stats-global-client.php']['orderdirection'])) {
        $navdirection = $Session['prefs']['stats-global-client.php']['orderdirection'];
    } else {
        $navdirection = '';
    }
    $res = phpAds_dbQuery("\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\tWHERE\n\t\t\tparent = 0\n\t\t" . phpAds_getListOrder($navorder, $navdirection) . "\n\t") or phpAds_sqlDie();
    while ($row = phpAds_dbFetchArray($res)) {
        phpAds_PageContext(phpAds_buildClientName($row['clientid'], $row['clientname']), "stats-client-history.php?clientid=" . $row['clientid'], $clientid == $row['clientid']);
    }
    phpAds_PageShortcut($strClientProperties, 'client-edit.php?clientid=' . $clientid, 'images/icon-client.gif');
    $extra = "<br><br><br>";
    $extra .= "<b>{$strMaintenance}</b><br>";
    $extra .= "<img src='images/break.gif' height='1' width='160' vspace='4'><br>";
    $extra .= "<a href='stats-reset.php?clientid={$clientid}'" . phpAds_DelConfirm($strConfirmResetClientStats) . ">";
    $extra .= "<img src='images/" . $phpAds_TextDirection . "/icon-undo.gif' align='absmiddle' border='0'>&nbsp;{$strResetStats}</a>";
    $extra .= "<br><br>";
    phpAds_PageHeader("2.1.1", $extra);
    echo "<img src='images/icon-client.gif' align='absmiddle'>&nbsp;<b>" . phpAds_getClientName($clientid) . "</b><br><br><br>";
    phpAds_ShowSections(array("2.1.1", "2.1.2"));
}
if (phpAds_isUser(phpAds_Client)) {
    phpAds_PageHeader("1.1");
    if ($phpAds_config['client_welcome']) {
    phpAds_PageShortcut($strClientProperties, 'client-edit.php?clientid=' . $clientid, 'images/icon-client.gif');
    phpAds_PageShortcut($strCampaignHistory, 'stats-campaign-history.php?clientid=' . $clientid . '&campaignid=' . $campaignid, 'images/icon-statistics.gif');
    $extra = "<form action='campaign-modify.php'>";
    $extra .= "<input type='hidden' name='campaignid' value='{$campaignid}'>";
    $extra .= "<input type='hidden' name='clientid' value='{$clientid}'>";
    $extra .= "<input type='hidden' name='returnurl' value='campaign-edit.php'>";
    $extra .= "<br><br>";
    $extra .= "<b>{$strModifyCampaign}</b><br>";
    $extra .= "<img src='images/break.gif' height='1' width='160' vspace='4'><br>";
    $extra .= "<img src='images/icon-move-campaign.gif' align='absmiddle'>&nbsp;{$strMoveTo}<br>";
    $extra .= "<img src='images/spacer.gif' height='1' width='160' vspace='2'><br>";
    $extra .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    $extra .= "<select name='moveto' style='width: 110px'>";
    $res = phpAds_dbQuery("SELECT * FROM " . $phpAds_config['tbl_clients'] . " WHERE parent = 0 AND clientid != " . phpAds_getParentID($campaignid)) or phpAds_sqlDie();
    while ($row = phpAds_dbFetchArray($res)) {
        $extra .= "<option value='" . $row['clientid'] . "'>" . phpAds_buildClientName($row['clientid'], $row['clientname']) . "</option>";
    }
    $extra .= "</select>&nbsp;<input type='image' src='images/" . $phpAds_TextDirection . "/go_blue.gif'><br>";
    $extra .= "<img src='images/break.gif' height='1' width='160' vspace='4'><br>";
    $extra .= "<img src='images/icon-recycle.gif' align='absmiddle'>&nbsp;<a href='campaign-delete.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&returnurl=client-index.php'" . phpAds_DelConfirm($strConfirmDeleteCampaign) . ">{$strDelete}</a><br>";
    $extra .= "</form>";
    phpAds_PageHeader("4.1.3.2", $extra);
    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;<b>" . phpAds_getClientName($campaignid) . "</b><br><br><br>";
    phpAds_ShowSections(array("4.1.3.2", "4.1.3.3", "4.1.3.4"));
} else {
    if (isset($move) && $move == 't') {
        // Convert client to campaign
        phpAds_PageHeader("4.1.3.2");
        echo "<img src='images/icon-client.gif' align='absmiddle'>&nbsp;" . phpAds_getClientName($clientid);
        $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\t\tWHERE\n\t\t\t\tparent = " . phpAds_getUserID() . "\n\t\t\t" . phpAds_getListOrder($navorder, $navdirection) . "\n\t\t") or phpAds_sqlDie();
        while ($row = phpAds_dbFetchArray($res)) {
            phpAds_PageContext(phpAds_buildClientName($row['clientid'], $row['clientname']), "stats-campaign-target.php?clientid=" . $clientid . "&campaignid=" . $row['clientid'], $campaignid == $row['clientid']);
        }
        phpAds_PageHeader("1.2.3");
        echo "<img src='images/icon-campaign.gif' align='absmiddle'>&nbsp;<b>" . phpAds_getClientName($campaignid) . "</b><br><br><br>";
        phpAds_ShowSections(array("1.2.1", "1.2.2", "1.2.3"));
    } else {
        phpAds_PageHeader("1");
        phpAds_Die($strAccessDenied, $strNotAdmin);
    }
}
if (phpAds_isUser(phpAds_Admin)) {
    $res = phpAds_dbQuery("\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\tWHERE\n\t\t\tparent = " . $clientid . "\n\t\t" . phpAds_getListOrder($navorder, $navdirection) . "\n\t") or phpAds_sqlDie();
    while ($row = phpAds_dbFetchArray($res)) {
        phpAds_PageContext(phpAds_buildClientName($row['clientid'], $row['clientname']), "stats-campaign-target.php?clientid=" . $clientid . "&campaignid=" . $row['clientid'], $campaignid == $row['clientid']);
    }
    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_PageHeader("2.1.2.3");
    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;<b>" . phpAds_getClientName($campaignid) . "</b><br><br><br>";
    phpAds_ShowSections(array("2.1.2.1", "2.1.2.2", "2.1.2.3"));
}
/*********************************************************/
/* Main code                                             */
/*********************************************************/
$lib_targetstats_params = array('clientid' => $clientid, 'campaignid' => $campaignid);
$lib_targetstats_where = "clientid = '" . $campaignid . "'";
include "lib-targetstats.inc.php";
if ($clientid != "") {
    if (phpAds_isUser(phpAds_Admin)) {
        if (isset($Session['prefs']['client-index.php']['listorder'])) {
            $navorder = $Session['prefs']['client-index.php']['listorder'];
        } else {
            $navorder = '';
        }
        if (isset($Session['prefs']['client-index.php']['orderdirection'])) {
            $navdirection = $Session['prefs']['client-index.php']['orderdirection'];
        } else {
            $navdirection = '';
        }
        // Get other clients
        $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\t\tWHERE\n\t\t\t\tparent = 0\n\t\t\t" . phpAds_getListOrder($navorder, $navdirection) . "\n\t\t") or phpAds_sqlDie();
        while ($row = phpAds_dbFetchArray($res)) {
            phpAds_PageContext(phpAds_buildClientName($row['clientid'], $row['clientname']), "client-edit.php?clientid=" . $row['clientid'], $clientid == $row['clientid']);
        }
        phpAds_PageShortcut($strClientHistory, 'stats-client-history.php?clientid=' . $clientid, 'images/icon-statistics.gif');
        phpAds_PageHeader("4.1.2");
        echo "<img src='images/icon-client.gif' align='absmiddle'>&nbsp;<b>" . phpAds_getClientName($clientid) . "</b><br><br><br>";
        phpAds_ShowSections(array("4.1.2", "4.1.3"));
    } else {
        phpAds_PageHeader("2");
    }
    // Do not get this information if the page
    // is the result of an error message
    if (!isset($client)) {
        $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\t\tWHERE\n\t\t\t\tclientid = '" . $clientid . "'\n\t\t\t") or phpAds_sqlDie();
        if (phpAds_dbNumRows($res)) {
            $client = phpAds_dbFetchArray($res);
        }
function phpAds_placeInvocationForm($extra = '', $zone_invocation = false)
{
    global $phpAds_config, $phpAds_TextDirection;
    global $submitbutton, $generate;
    global $codetype, $what, $acid, $source, $target;
    global $withText, $template, $refresh, $uniqueid;
    global $width, $height, $ilayer;
    global $popunder, $left, $top, $timeout, $delay, $delay_type;
    global $transparent, $resize, $block, $blockcampaign, $raw;
    global $hostlanguage, $toolbars, $location, $menubar, $status;
    global $layerstyle, $resizable, $scrollbars;
    global $hpostype, $hposleft, $hposright, $vpostype, $vpostop, $vposbottom;
    global $iframetracking;
    global $tabindex;
    // Check if affiliate is on the same server
    if ($extra != '' && isset($extra['website']) && $extra['website']) {
        $server_phpads = parse_url($phpAds_config['url_prefix']);
        $server_affilate = parse_url($extra['website']);
        $server_same = @gethostbyname($server_phpads['host']) == @gethostbyname($server_affilate['host']);
    } else {
        $server_same = true;
    }
    // Hide when integrated in zone-advanced.php
    if (!is_array($extra) || !isset($extra['zoneadvanced']) || !$extra['zoneadvanced']) {
        echo "<form name='generate' action='" . $_SERVER['PHP_SELF'] . "' method='POST'>\n";
    }
    // Invocation type selection
    if (!is_array($extra) || isset($extra['delivery']) && $extra['delivery'] != phpAds_ZoneInterstitial && $extra['delivery'] != phpAds_ZonePopup) {
        $allowed['adlayer'] = $phpAds_config['allow_invocation_interstitial'];
        $allowed['popup'] = $phpAds_config['allow_invocation_popup'];
        $allowed['xmlrpc'] = $phpAds_config['allow_invocation_xmlrpc'];
        $allowed['adframe'] = $phpAds_config['allow_invocation_frame'];
        $allowed['adjs'] = $phpAds_config['allow_invocation_js'];
        $allowed['adview'] = $phpAds_config['allow_invocation_plain'];
        $allowed['local'] = $phpAds_config['allow_invocation_local'];
        if (is_array($extra)) {
            $allowed['popup'] = false;
        }
        if (is_array($extra)) {
            $allowed['adlayer'] = false;
        }
        if (is_array($extra) && $server_same == false) {
            $allowed['local'] = false;
        }
        if (is_array($extra) && $server_same == false && ($extra['width'] == '-1' || $extra['height'] == '-1')) {
            $allowed['adframe'] = false;
        }
        if (is_array($extra) && $extra['delivery'] == phpAds_ZoneText) {
            // Only allow Javascript and Localmode
            // when using text ads
            $allowed['adlayer'] = $allowed['popup'] = $allowed['adframe'] = $allowed['adview'] = false;
        }
        if (!isset($codetype) || $allowed[$codetype] == false) {
            while (list($k, $v) = each($allowed)) {
                if ($v) {
                    $codetype = $k;
                }
            }
        }
        if (!isset($codetype)) {
            $codetype = '';
        }
        echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
        echo "<tr><td height='25' colspan='3'><b>" . $GLOBALS['strChooseInvocationType'] . "</b></td></tr>";
        echo "<tr><td height='35'>";
        echo "<select name='codetype' onChange=\"this.form.submit()\" accesskey=" . $GLOBALS['keyList'] . " tabindex='" . $tabindex++ . "'>";
        if ($allowed['adview']) {
            echo "<option value='adview'" . ($codetype == 'adview' ? ' selected' : '') . ">" . $GLOBALS['strInvocationRemote'] . "</option>";
        }
        if ($allowed['adjs']) {
            echo "<option value='adjs'" . ($codetype == 'adjs' ? ' selected' : '') . ">" . $GLOBALS['strInvocationJS'] . "</option>";
        }
        if ($allowed['adframe']) {
            echo "<option value='adframe'" . ($codetype == 'adframe' ? ' selected' : '') . ">" . $GLOBALS['strInvocationIframes'] . "</option>";
        }
        if ($allowed['xmlrpc']) {
            echo "<option value='xmlrpc'" . ($codetype == 'xmlrpc' ? ' selected' : '') . ">" . $GLOBALS['strInvocationXmlRpc'] . "</option>";
        }
        if ($allowed['popup']) {
            echo "<option value='popup'" . ($codetype == 'popup' ? ' selected' : '') . ">" . $GLOBALS['strInvocationPopUp'] . "</option>";
        }
        if ($allowed['adlayer']) {
            echo "<option value='adlayer'" . ($codetype == 'adlayer' ? ' selected' : '') . ">" . $GLOBALS['strInvocationAdLayer'] . "</option>";
        }
        if ($allowed['local']) {
            echo "<option value='local'" . ($codetype == 'local' ? ' selected' : '') . ">" . $GLOBALS['strInvocationLocal'] . "</option>";
        }
        echo "</select>";
        echo "&nbsp;<input type='image' src='images/" . $phpAds_TextDirection . "/go_blue.gif' border='0'>";
        echo "</td></tr></table>";
        phpAds_ShowBreak();
        echo "<br>";
    } else {
        if ($extra['delivery'] == phpAds_ZoneInterstitial) {
            $codetype = 'adlayer';
        }
        if ($extra['delivery'] == phpAds_ZonePopup) {
            $codetype = 'popup';
        }
        if (!isset($codetype)) {
            $codetype = '';
        }
    }
    if ($codetype == 'adlayer') {
        if (!isset($layerstyle)) {
            $layerstyle = 'geocities';
        }
        include '../libraries/layerstyles/' . $layerstyle . '/invocation.inc.php';
    }
    if ($codetype != '') {
        // Code
        if (isset($submitbutton) || isset($generate) && $generate) {
            echo "<table border='0' width='550' cellpadding='0' cellspacing='0'>";
            echo "<tr><td height='25'><img src='images/icon-generatecode.gif' align='absmiddle'>&nbsp;<b>" . $GLOBALS['strBannercode'] . "</b></td>";
            // Show clipboard button only on IE
            if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') > 0 && strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') < 1) {
                echo "<td height='25' align='right'><img src='images/icon-clipboard.gif' align='absmiddle'>&nbsp;";
                echo "<a href='javascript:phpAds_CopyClipboard(\"bannercode\");'>" . $GLOBALS['strCopyToClipboard'] . "</a></td></tr>";
            } else {
                echo "<td>&nbsp;</td>";
            }
            echo "<tr height='1'><td colspan='2' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
            echo "<tr><td colspan='2'><textarea name='bannercode' class='code-gray' rows='6' cols='55' style='width:550;' readonly>" . htmlspecialchars(phpAds_GenerateInvocationCode()) . "</textarea></td></tr>";
            echo "</table><br>";
            phpAds_ShowBreak();
            echo "<br>";
            $generated = true;
        } else {
            $generated = false;
        }
        // Hide when integrated in zone-advanced.php
        if (!(is_array($extra) && isset($extra['zoneadvanced']) && $extra['zoneadvanced'])) {
            // Header
            echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
            echo "<tr><td height='25' colspan='3'><img src='images/icon-overview.gif' align='absmiddle'>&nbsp;<b>" . $GLOBALS['strParameters'] . "</b></td></tr>";
            echo "<tr height='1'><td width='30'><img src='images/break.gif' height='1' width='30'></td>";
            echo "<td width='200'><img src='images/break.gif' height='1' width='200'></td>";
            echo "<td width='100%'><img src='images/break.gif' height='1' width='100%'></td></tr>";
            echo "<tr" . ($zone_invocation ? '' : " bgcolor='#F6F6F6'") . "><td height='10' colspan='3'>&nbsp;</td></tr>";
        }
        if ($codetype == 'adview') {
            $show = array('what' => true, 'acid' => true, 'target' => true, 'source' => true);
        }
        if ($codetype == 'adjs') {
            $show = array('what' => true, 'acid' => true, 'block' => true, 'target' => true, 'source' => true, 'withText' => true, 'blockcampaign' => true);
        }
        if ($codetype == 'adframe') {
            $show = array('what' => true, 'acid' => true, 'target' => true, 'source' => true, 'refresh' => true, 'size' => true, 'resize' => true, 'transparent' => true, 'ilayer' => true, 'iframetracking' => true);
        }
        if ($codetype == 'ad') {
            $show = array('what' => true, 'acid' => true, 'target' => true, 'source' => true, 'withText' => true, 'size' => true, 'resize' => true, 'transparent' => true);
        }
        if ($codetype == 'popup') {
            $show = array('what' => true, 'acid' => true, 'target' => true, 'source' => true, 'absolute' => true, 'popunder' => true, 'timeout' => true, 'delay' => true, 'windowoptions' => true);
        }
        if ($codetype == 'adlayer') {
            $show = phpAds_getLayerShowVar();
        }
        if ($codetype == 'xmlrpc') {
            $show = array('what' => true, 'acid' => true, 'target' => true, 'source' => true, 'withText' => true, 'template' => true, 'hostlanguage' => true);
        }
        if ($codetype == 'local') {
            $show = array('what' => true, 'acid' => true, 'target' => true, 'source' => true, 'withText' => true, 'block' => true, 'blockcampaign' => true, 'raw' => true);
        }
        // What
        if (!$zone_invocation && isset($show['what']) && $show['what'] == true) {
            echo "<tr bgcolor='#F6F6F6'><td width='30'>&nbsp;</td>";
            echo "<td width='200' valign='top'>" . $GLOBALS['strInvocationWhat'] . "</td><td width='370'>";
            echo "<textarea class='flat' name='what' rows='3' cols='50' style='width:350px;' tabindex='" . $tabindex++ . "'>" . (isset($what) ? stripslashes($what) : '') . "</textarea></td></tr>";
            echo "<tr bgcolor='#F6F6F6'><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
            echo "<td bgcolor='#F6F6F6' colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
        }
        // Acid
        if (!$zone_invocation && isset($show['acid']) && $show['acid'] == true) {
            echo "<tr bgcolor='#F6F6F6'><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strCampaign'] . "</td><td width='370'>";
            echo "<select name='acid' style='width:350px;' tabindex='" . $tabindex++ . "'>";
            echo "<option value='0'>-</option>";
            $res = phpAds_dbQuery("\n\t\t\t\tSELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\t\t\tWHERE\n\t\t\t\t\tparent > 0\n\t\t\t\t");
            while ($row = phpAds_dbFetchArray($res)) {
                echo "<option value='" . $row['clientid'] . "'" . ($acid == $row['clientid'] ? ' selected' : '') . ">";
                echo phpAds_buildClientName($row['clientid'], $row['clientname']);
                echo "</option>";
            }
            echo "</select>";
            echo "</td></tr>";
            echo "<tr bgcolor='#F6F6F6'><td height='10' colspan='3'>&nbsp;</td></tr>";
            echo "<tr height='1'><td colspan='3' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
            echo "<tr><td height='10' colspan='3'>&nbsp;</td></tr>";
        }
        // Target
        if (isset($show['target']) && $show['target'] == true) {
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strInvocationTarget'] . "</td><td width='370'>";
            echo "<input class='flat' type='text' name='target' size='' value='" . (isset($target) ? $target : '') . "' style='width:175px;' tabindex='" . $tabindex++ . "'></td></tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // Source
        if (isset($show['source']) && $show['source'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strInvocationSource'] . "</td><td width='370'>";
            echo "<input class='flat' type='text' name='source' size='' value='" . (isset($source) ? $source : '') . "' style='width:175px;' tabindex='" . $tabindex++ . "'></td></tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // WithText
        if (isset($show['withText']) && $show['withText'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strInvocationWithText'] . "</td>";
            echo "<td width='370'><input type='radio' name='withText' value='1'" . (isset($withText) && $withText != 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "<input type='radio' name='withText' value='0'" . (!isset($withText) || $withText == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "</td>";
            echo "</tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // refresh
        if (isset($show['refresh']) && $show['refresh'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strIFrameRefreshAfter'] . "</td><td width='370'>";
            echo "<input class='flat' type='text' name='refresh' size='' value='" . (isset($refresh) ? $refresh : '') . "' style='width:175px;' tabindex='" . $tabindex++ . "'> " . $GLOBALS['strAbbrSeconds'] . "</td></tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // size
        if (!$zone_invocation && isset($show['size']) && $show['size'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strFrameSize'] . "</td><td width='370'>";
            echo $GLOBALS['strWidth'] . ": <input class='flat' type='text' name='width' size='3' value='" . (isset($width) ? $width : '') . "' tabindex='" . $tabindex++ . "'>&nbsp;&nbsp;&nbsp;";
            echo $GLOBALS['strHeight'] . ": <input class='flat' type='text' name='height' size='3' value='" . (isset($height) ? $height : '') . "' tabindex='" . $tabindex++ . "'>";
            echo "</td></tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // Resize
        if (isset($show['resize']) && $show['resize'] == true) {
            // Only show this if affiliate is on the same server
            if ($server_same) {
                echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
                echo "<tr><td width='30'>&nbsp;</td>";
                echo "<td width='200'>" . $GLOBALS['strIframeResizeToBanner'] . "</td>";
                echo "<td width='370'><input type='radio' name='resize' value='1'" . (isset($resize) && $resize == 1 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
                echo "<input type='radio' name='resize' value='0'" . (!isset($resize) || $resize == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "</td>";
                echo "</tr>";
                echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
            } else {
                echo "<input type='hidden' name='resize' value='0'>";
            }
        }
        // Transparent
        if (isset($show['transparent']) && $show['transparent'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strIframeMakeTransparent'] . "</td>";
            echo "<td width='370'><input type='radio' name='transparent' value='1'" . (isset($transparent) && $transparent == 1 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "<input type='radio' name='transparent' value='0'" . (!isset($transparent) || $transparent == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "</td>";
            echo "</tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // Netscape 4 ilayer
        if (isset($show['ilayer']) && $show['ilayer'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strIframeIncludeNetscape4'] . "</td>";
            echo "<td width='370'><input type='radio' name='ilayer' value='1'" . (isset($ilayer) && $ilayer == 1 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "<input type='radio' name='ilayer' value='0'" . (!isset($ilayer) || $ilayer == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "</td>";
            echo "</tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // Google AdSense click tracking
        if (isset($show['iframetracking']) && $show['iframetracking'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . 'Include code to track Google AdSense clicks' . "</td>";
            echo "<td width='370'><input type='radio' name='iframetracking' value='1'" . (!isset($iframetracking) || $iframetracking == 1 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "<input type='radio' name='iframetracking' value='0'" . (isset($iframetracking) && $iframetracking == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "</td>";
            echo "</tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // Block
        if (isset($show['block']) && $show['block'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strInvocationDontShowAgain'] . "</td>";
            echo "<td width='370'><input type='radio' name='block' value='1'" . (isset($block) && $block != 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "<input type='radio' name='block' value='0'" . (!isset($block) || $block == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "</td>";
            echo "</tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // Blockcampaign
        if (isset($show['blockcampaign']) && $show['blockcampaign'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strInvocationDontShowAgainCampaign'] . "</td>";
            echo "<td width='370'><input type='radio' name='blockcampaign' value='1'" . (isset($blockcampaign) && $blockcampaign != 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "<input type='radio' name='blockcampaign' value='0'" . (!isset($blockcampaign) || $blockcampaign == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "</td>";
            echo "</tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // Raw
        if (isset($show['raw']) && $show['raw'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strInvocationTemplate'] . "</td>";
            echo "<td width='370'><input type='radio' name='raw' value='1'" . (isset($raw) && $raw != 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "<input type='radio' name='raw' value='0'" . (!isset($raw) || $raw == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "</td>";
            echo "</tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // AdLayer style
        if (isset($show['layerstyle']) && $show['layerstyle'] == true) {
            $layerstyles = array();
            $stylesdir = opendir('../libraries/layerstyles');
            while ($stylefile = readdir($stylesdir)) {
                if (is_dir('../libraries/layerstyles/' . $stylefile) && file_exists('../libraries/layerstyles/' . $stylefile . '/invocation.inc.php')) {
                    if (ereg('^[^.]', $stylefile)) {
                        $layerstyles[$stylefile] = isset($GLOBALS['strAdLayerStyleName'][$stylefile]) ? $GLOBALS['strAdLayerStyleName'][$stylefile] : str_replace("- ", "-", ucwords(str_replace("-", "- ", $stylefile)));
                    }
                }
            }
            closedir($stylesdir);
            asort($layerstyles, SORT_STRING);
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strAdLayerStyle'] . "</td><td width='370'>";
            echo "<select name='layerstyle' onChange='this.form.submit()' style='width:175px;' tabindex='" . $tabindex++ . "'>";
            while (list($k, $v) = each($layerstyles)) {
                echo "<option value='{$k}'" . ($layerstyle == $k ? ' selected' : '') . ">{$v}</option>";
            }
            echo "</select>";
            echo "</td></tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // popunder
        if (isset($show['popunder']) && $show['popunder'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strPopUpStyle'] . "</td>";
            echo "<td width='370'><input type='radio' name='popunder' value='0'" . (!isset($popunder) || $popunder != '1' ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . "<img src='images/icon-popup-over.gif' align='absmiddle'>&nbsp;" . $GLOBALS['strPopUpStylePopUp'] . "<br>";
            echo "<input type='radio' name='popunder' value='1'" . (isset($popunder) && $popunder == '1' ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . "<img src='images/icon-popup-under.gif' align='absmiddle'>&nbsp;" . $GLOBALS['strPopUpStylePopUnder'] . "</td>";
            echo "</tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // delay
        if (isset($show['delay']) && $show['delay'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strPopUpCreateInstance'] . "</td>";
            echo "<td width='370'><input type='radio' name='delay_type' value='none'" . (!isset($delay_type) || $delay_type != 'exit' && $delay_type != 'seconds' ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strPopUpImmediately'] . "<br>";
            echo "<input type='radio' name='delay_type' value='exit'" . (isset($delay_type) && $delay_type == 'exit' ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strPopUpOnClose'] . "<br>";
            echo "<input type='radio' name='delay_type' value='seconds'" . (isset($delay_type) && $delay_type == 'seconds' ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strPopUpAfterSec'] . "&nbsp;" . "<input class='flat' type='text' name='delay' size='' value='" . (isset($delay) ? $delay : '-') . "' style='width:50px;' tabindex='" . $tabindex++ . "'> " . $GLOBALS['strAbbrSeconds'] . "</td>";
            echo "</tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // absolute
        if (isset($show['absolute']) && $show['absolute'] == true) {
            if (isset($left) && $left != '') {
                if ($left == 'center') {
                    $hpostype = 'center';
                } elseif ($left < 0) {
                    $hpostype = 'right';
                    $hposright = 0 - (int) $left;
                } else {
                    $hpostype = 'left';
                    $hposleft = (int) $left;
                }
            }
            if (isset($top) && $top != '') {
                if ($top == 'center') {
                    $vpostype = 'center';
                } elseif ($top < 0) {
                    $vpostype = 'bottom';
                    $vposbottom = 0 - (int) $top;
                } else {
                    $vpostype = 'top';
                    $vpostop = (int) $top;
                }
            }
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strPopupInitialHPos'] . "</td>";
            echo "<td width='370'><input type='radio' name='hpostype' value='left'" . (!isset($hpostype) || $hpostype != 'right' && $hpostype != 'center' ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;";
            echo "<input class='flat' type='text' name='hposleft' size='' value='" . (isset($hposleft) ? $hposleft : '-') . "' style='width:50px;' tabindex='" . $tabindex++ . "'> " . $GLOBALS['strAbbrPixels'] . '&nbsp;' . $GLOBALS['strPopupFromLeft'] . '<br>';
            echo "<input type='radio' name='hpostype' value='right'" . (isset($hpostype) && $hpostype == 'right' ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;";
            echo "<input class='flat' type='text' name='hposright' size='' value='" . (isset($hposright) ? $hposright : '-') . "' style='width:50px;' tabindex='" . $tabindex++ . "'> " . $GLOBALS['strAbbrPixels'] . '&nbsp;' . $GLOBALS['strPopupFromRight'] . '<br>';
            echo "<input type='radio' name='hpostype' value='center'" . (isset($hpostype) && $hpostype == 'center' ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strPopupCentered'] . "</td>";
            echo "</tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strPopupInitialVPos'] . "</td>";
            echo "<td width='370'><input type='radio' name='vpostype' value='top'" . (!isset($vpostype) || $vpostype != 'bottom' && $vpostype != 'center' ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;";
            echo "<input class='flat' type='text' name='vpostop' size='' value='" . (isset($vpostop) ? $vpostop : '-') . "' style='width:50px;' tabindex='" . $tabindex++ . "'> " . $GLOBALS['strAbbrPixels'] . '&nbsp;' . $GLOBALS['strPopupFromTop'] . '<br>';
            echo "<input type='radio' name='vpostype' value='bottom'" . (isset($vpostype) && $vpostype == 'bottom' ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;";
            echo "<input class='flat' type='text' name='vposbottom' size='' value='" . (isset($vposbottom) ? $vposbottom : '-') . "' style='width:50px;' tabindex='" . $tabindex++ . "'> " . $GLOBALS['strAbbrPixels'] . '&nbsp;' . $GLOBALS['strPopupFromBottom'] . '<br>';
            echo "<input type='radio' name='vpostype' value='center'" . (isset($vpostype) && $vpostype == 'center' ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strPopupCentered'] . "</td>";
            echo "</tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // timeout
        if (isset($show['timeout']) && $show['timeout'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strAutoCloseAfter'] . "</td><td width='370'>";
            echo "<input class='flat' type='text' name='timeout' size='' value='" . (isset($timeout) ? $timeout : '-') . "' style='width:50px;' tabindex='" . $tabindex++ . "'> " . $GLOBALS['strAbbrSeconds'] . "</td></tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // Window options
        if (isset($show['windowoptions']) && $show['windowoptions'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td><td width='200' valign='top'>" . $GLOBALS['strWindowOptions'] . "</td><td width='370'>";
            echo "<table cellpadding='0' cellspacing='0' border='0'>";
            echo "<tr><td>" . $GLOBALS['strShowToolbars'] . "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='toolbars' value='1'" . (isset($toolbars) && $toolbars != 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='toolbars' value='0'" . (!isset($toolbars) || $toolbars == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "";
            echo "</td></tr><tr><td colspan='5'><img src='images/break-l.gif' height='1' width='200' vspace='2'></td></tr>";
            echo "<tr><td>" . $GLOBALS['strShowLocation'] . "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='location' value='1'" . (isset($location) && $location != 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='location' value='0'" . (!isset($location) || $location == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "";
            echo "</td></tr><tr><td colspan='5'><img src='images/break-l.gif' height='1' width='200' vspace='2'></td></tr>";
            echo "<tr><td>" . $GLOBALS['strShowMenubar'] . "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='menubar' value='1'" . (isset($menubar) && $menubar != 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='menubar' value='0'" . (!isset($menubar) || $menubar == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "";
            echo "</td></tr><tr><td colspan='5'><img src='images/break-l.gif' height='1' width='200' vspace='2'></td></tr>";
            echo "<tr><td>" . $GLOBALS['strShowStatus'] . "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='status' value='1'" . (isset($status) && $status != 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='status' value='0'" . (!isset($status) || $status == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "";
            echo "</td></tr><tr><td colspan='5'><img src='images/break-l.gif' height='1' width='200' vspace='2'></td></tr>";
            echo "<tr><td>" . $GLOBALS['strWindowResizable'] . "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='resizable' value='1'" . (isset($resizable) && $resizable != 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='resizable' value='0'" . (!isset($resizable) || $resizable == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "";
            echo "</td></tr><tr><td colspan='5'><img src='images/break-l.gif' height='1' width='200' vspace='2'></td></tr>";
            echo "<tr><td>" . $GLOBALS['strShowScrollbars'] . "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='scrollbars' value='1'" . (isset($scrollbars) && $scrollbars != 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strYes'] . "<br>";
            echo "</td><td>&nbsp;&nbsp;&nbsp;</td><td>";
            echo "<input type='radio' name='scrollbars' value='0'" . (!isset($scrollbars) || $scrollbars == 0 ? ' checked' : '') . " tabindex='" . $tabindex++ . "'>&nbsp;" . $GLOBALS['strNo'] . "";
            echo "</td></tr>";
            echo "</table>";
            echo "</td></tr><tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // AdLayer custom code
        if (isset($show['layercustom']) && $show['layercustom'] == true) {
            phpAds_placeLayerSettings();
        }
        // Host Language
        if (isset($show['hostlanguage']) && $show['hostlanguage'] == true) {
            echo "<td colspan='2'><img src='images/break-l.gif' height='1' width='200' vspace='6'></td></tr>";
            echo "<tr><td width='30'>&nbsp;</td>";
            echo "<td width='200'>" . $GLOBALS['strXmlRpcLanguage'] . "</td><td width='370'>";
            echo "<select name='hostlanguage' tabindex='" . $tabindex++ . "'>";
            echo "<option value='php'" . ($hostlanguage == 'php' ? ' selected' : '') . ">PHP</option>";
            //		echo "<option value='php-xmlrpc'".($hostlanguage == 'php-xmlrpc' ? ' selected' : '').">PHP with built in XML-RPC extension</option>";
            //		echo "<option value='asp'".($hostlanguage == 'asp' ? ' selected' : '').">ASP</option>";
            //		echo "<option value='jsp'".($hostlanguage == 'jsp' ? ' selected' : '').">JSP</option>";
            echo "</select>";
            echo "</td></tr>";
            echo "<tr><td width='30'><img src='images/spacer.gif' height='1' width='100%'></td>";
        }
        // Hide when integrated in zone-advanced.php
        if (!(is_array($extra) && isset($extra['zoneadvanced']) && $extra['zoneadvanced'])) {
            // Footer
            echo "<tr><td height='10' colspan='3'>&nbsp;</td></tr>";
            echo "<tr height='1'><td colspan='3' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
            echo "</table>";
            echo "<br><br>";
            echo "<input type='hidden' value='" . ($generated ? 1 : 0) . "' name='generate'>";
            if ($generated) {
                echo "<input type='submit' value='" . $GLOBALS['strRefresh'] . "' name='submitbutton' tabindex='" . $tabindex++ . "'>";
            } else {
                echo "<input type='submit' value='" . $GLOBALS['strGenerate'] . "' name='submitbutton' tabindex='" . $tabindex++ . "'>";
            }
        }
    }
    // Put extra hidden fields
    if (is_array($extra)) {
        while (list($k, $v) = each($extra)) {
            echo "<input type='hidden' value='{$v}' name='{$k}'>";
        }
    }
    // Hide when integrated in zone-advanced.php
    if (!is_array($extra) || !isset($extra['zoneadvanced']) || !$extra['zoneadvanced']) {
        echo "</form><br><br>";
    }
}
function phpAds_getZoneArray()
{
    global $phpAds_config;
    if (phpAds_isUser(phpAds_Affiliate)) {
        $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_zones'] . "\n\t\t\tWHERE\n\t\t\t\taffiliateid = " . phpAds_getUserID() . "\n\t\t");
    } else {
        $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_zones'] . "\n\t\t");
    }
    while ($row = phpAds_dbFetchArray($res)) {
        $zoneArray[$row['zoneid']] = phpAds_buildClientName($row['zoneid'], $row['zonename']);
    }
    return $zoneArray;
}
function phpAds_SendMaintenanceReport($clientid, $first_unixtimestamp, $last_unixtimestamp, $update = true)
{
    global $phpAds_config;
    global $date_format;
    global $strMailSubject, $strMailHeader, $strMailBannerStats, $strMailFooter, $strMailReportPeriod;
    global $strLogErrorClients, $strLogErrorBanners, $strLogErrorViews, $strNoStatsForCampaign;
    global $strLogErrorClicks, $strNoClickLoggedInInterval, $strNoViewLoggedInInterval;
    global $strTotal, $strTotalThisPeriod;
    global $strCampaign, $strBanner, $strLinkedTo, $strViews, $strClicks, $strMailReportPeriodAll;
    global $phpAds_CharSet;
    // Convert timestamps to SQL format
    $last_sqltimestamp = date("YmdHis", $last_unixtimestamp);
    $first_sqltimestamp = date("YmdHis", $first_unixtimestamp);
    // Get Client information
    $res_client = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tclientid,\n\t\t\tclientname,\n\t\t\tcontact,\n\t\t\temail,\n\t\t\tlanguage,\n\t\t\treport,\n\t\t\treportinterval,\n\t\t\treportlastdate,\n\t\t\tUNIX_TIMESTAMP(reportlastdate) AS reportlastdate_t\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\tWHERE\n\t\t\tclientid='" . $clientid . "'\n\t\t");
    if (phpAds_dbNumRows($res_client) > 0) {
        $client = phpAds_dbFetchArray($res_client);
        // Load client language strings
        @(include phpAds_path . '/language/english/default.lang.php');
        if ($client['language'] != '') {
            $phpAds_config['language'] = $client['language'];
        }
        if ($phpAds_config['language'] != 'english' && file_exists(phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php')) {
            @(include phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php');
        }
        $active_campaigns = false;
        $log = "";
        // Fetch all campaings belonging to client
        $res_campaigns = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\tclientid,\n\t\t\t\tclientname,\n\t\t\t\tviews,\n\t\t\t\tclicks,\n\t\t\t\texpire,\n\t\t\t\tUNIX_TIMESTAMP(expire) as expire_st,\n\t\t\t\tactivate,\n\t\t\t\tUNIX_TIMESTAMP(activate) as activate_st,\n\t\t\t\tactive\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\t\tWHERE\n\t\t\t\tparent = " . $client['clientid'] . "\n\t\t\n\t\t") or die($strLogErrorClients);
        while ($campaign = phpAds_dbFetchArray($res_campaigns)) {
            $current_log = '';
            // Fetch all banners belonging to campaign
            $res_banners = phpAds_dbQuery("\n\t\t\t\tSELECT\n\t\t\t\t\tbannerid,\n\t\t\t\t\tclientid,\n\t\t\t\t\turl,\n\t\t\t\t\tactive,\n\t\t\t\t\tdescription,\n\t\t\t\t\talt\n\t\t\t\tFROM\n\t\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\t\tWHERE\n\t\t\t\t\tclientid = " . $campaign['clientid'] . "\n\t\t\t\t") or die($strLogErrorBanners);
            $active_banners = false;
            $current_log .= "\n" . $strCampaign . "  " . phpAds_buildClientName($campaign['clientid'], $campaign['clientname'], false) . "\n";
            $current_log .= "=======================================================\n\n";
            while ($row_banners = phpAds_dbFetchArray($res_banners)) {
                $adviews = phpAds_totalViews($row_banners["bannerid"]);
                $client["views_used"] = $adviews;
                $adclicks = phpAds_totalClicks($row_banners["bannerid"]);
                $campaign["clicks_used"] = $adclicks;
                $current_log .= $strBanner . "  " . phpAds_buildBannerName($row_banners['bannerid'], $row_banners['description'], $row_banners['alt'], 0, false) . "\n";
                $current_log .= $strLinkedTo . ": " . $row_banners['url'] . "\n";
                $current_log .= "-------------------------------------------------------\n";
                $active_banner_stats = false;
                if ($adviews > 0) {
                    $current_log .= $strViews . " (" . $strTotal . "):    " . $adviews . "\n";
                    // Fetch all adviews belonging to banner belonging to client, grouped by day
                    if ($phpAds_config['compact_stats']) {
                        $res_adviews = phpAds_dbQuery("\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\tSUM(views) as qnt,\n\t\t\t\t\t\t\t\tDATE_FORMAT(day, '{$date_format}') as t_stamp_f,\n\t\t\t\t\t\t\t\tTO_DAYS(day) AS the_day\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t" . $phpAds_config['tbl_adstats'] . "\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tbannerid = " . $row_banners['bannerid'] . " AND\n\t\t\t\t\t\t\t\tviews > 0 AND\n\t\t\t\t\t\t\t\tUNIX_TIMESTAMP(day) >= {$first_unixtimestamp} AND\n\t\t\t\t\t\t\t\tUNIX_TIMESTAMP(day) < {$last_unixtimestamp}\n\t\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t\tday\n\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\tday DESC\n\t\t\t\t\t\t\t") or die("{$strLogErrorViews} " . phpAds_dbError());
                    } else {
                        $res_adviews = phpAds_dbQuery("\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t*,\n\t\t\t\t\t\t\t\tcount(*) as qnt,\n\t\t\t\t\t\t\t\tDATE_FORMAT(t_stamp, '{$date_format}') as t_stamp_f,\n\t\t\t\t\t\t\t\tTO_DAYS(t_stamp) AS the_day\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t" . $phpAds_config['tbl_adviews'] . "\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tbannerid = " . $row_banners['bannerid'] . " AND\n\t\t\t\t\t\t\t\tt_stamp >= {$first_sqltimestamp} AND\n\t\t\t\t\t\t\t\tt_stamp < {$last_sqltimestamp}\n\t\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t\tthe_day\n\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\tthe_day DESC\n\t\t\t\t\t\t\t") or die("{$strLogErrorViews} " . phpAds_dbError());
                    }
                    if (phpAds_dbNumRows($res_adviews)) {
                        $total = 0;
                        while ($row_adviews = phpAds_dbFetchArray($res_adviews)) {
                            $current_log .= "      " . $row_adviews['t_stamp_f'] . ":   " . $row_adviews['qnt'] . "\n";
                            $total += $row_adviews['qnt'];
                        }
                        $current_log .= $strTotalThisPeriod . ": " . $total . "\n";
                        $active_banner_stats = true;
                    } else {
                        $current_log .= "      " . $strNoViewLoggedInInterval . "\n";
                    }
                }
                if ($adclicks > 0) {
                    // Total adclicks
                    $current_log .= "\n" . $strClicks . " (" . $strTotal . "):   " . $adclicks . "\n";
                    // Fetch all adclicks belonging to banner belonging to client, grouped by day
                    if ($phpAds_config['compact_stats']) {
                        $res_adclicks = phpAds_dbQuery("\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\tSUM(clicks) as qnt,\n\t\t\t\t\t\t\t\tDATE_FORMAT(day, '{$date_format}') as t_stamp_f,\n\t\t\t\t\t\t\t\tTO_DAYS(day) AS the_day\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t" . $phpAds_config['tbl_adstats'] . "\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tbannerid = " . $row_banners['bannerid'] . " AND\n\t\t\t\t\t\t\t\tclicks > 0 AND\n\t\t\t\t\t\t\t\tUNIX_TIMESTAMP(day) >= {$first_unixtimestamp} AND\n\t\t\t\t\t\t\t\tUNIX_TIMESTAMP(day) < {$last_unixtimestamp}\n\t\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t\tday\n\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\tday DESC\n\t\t\t\t\t\t\t") or die("{$strLogErrorClicks} " . phpAds_dbError());
                    } else {
                        $res_adclicks = phpAds_dbQuery("\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\tcount(*) as qnt,\n\t\t\t\t\t\t\t\tDATE_FORMAT(t_stamp, '{$date_format}') as t_stamp_f,\n\t\t\t\t\t\t\t\tTO_DAYS(t_stamp) AS the_day\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t" . $phpAds_config['tbl_adclicks'] . "\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tbannerid = " . $row_banners['bannerid'] . " AND\n\t\t\t\t\t\t\t\tt_stamp >= {$first_sqltimestamp} AND\n\t\t\t\t\t\t\t\tt_stamp < {$last_sqltimestamp}\n\t\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t\tthe_day\n\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\tthe_day DESC\n\t\t\t\t\t\t\t") or die("{$strLogErrorClicks} " . phpAds_dbError());
                    }
                    if (phpAds_dbNumRows($res_adclicks)) {
                        $total = 0;
                        while ($row_adclicks = phpAds_dbFetchArray($res_adclicks)) {
                            $current_log .= "      " . $row_adclicks['t_stamp_f'] . ":   " . $row_adclicks['qnt'] . "\n";
                            $total += $row_adclicks['qnt'];
                        }
                        $current_log .= $strTotalThisPeriod . ": " . $total . "\n";
                        $active_banner_stats = true;
                    } else {
                        $current_log .= "      " . $strNoClickLoggedInInterval . "\n";
                    }
                }
                if ($adclicks == 0 && $adviews == 0) {
                    $current_log .= "      " . $strNoStatsForCampaign . "\n";
                }
                $current_log .= "\n\n";
                if ($campaign['active'] == 't' || $active_banner_stats == true) {
                    $active_banners = true;
                }
            }
            if ($active_banners == true) {
                $active_campaigns = true;
                $log .= $current_log;
            }
        }
        // E-mail Stats to active clients
        if ($client["email"] != '' && $active_campaigns == true) {
            $Subject = $strMailSubject . ": " . $client["clientname"];
            $Body = "{$strMailHeader}\n";
            $Body .= "{$strMailBannerStats}\n";
            if ($first_unixtimestamp == 0) {
                $Body .= "{$strMailReportPeriodAll}\n\n";
            } else {
                $Body .= "{$strMailReportPeriod}\n\n";
            }
            $Body .= "{$log}\n";
            $Body .= "{$strMailFooter}";
            $Body = str_replace("{clientname}", $client['clientname'], $Body);
            $Body = str_replace("{contact}", $client['contact'], $Body);
            $Body = str_replace("{adminfullname}", $phpAds_config['admin_fullname'], $Body);
            $Body = str_replace("{startdate}", date(str_replace('%', '', $date_format), $first_unixtimestamp), $Body);
            $Body = str_replace("{enddate}", date(str_replace('%', '', $date_format), $last_unixtimestamp), $Body);
            if ($phpAds_config['userlog_email']) {
                phpAds_userlogAdd(phpAds_actionAdvertiserReportMailed, $client['clientid'], $Subject . "\n\n" . $Body);
            }
            phpAds_sendMail($client['email'], $client['contact'], $Subject, $Body);
            // Update last run
            if ($update == true) {
                $res_update = phpAds_dbQuery("UPDATE " . $phpAds_config['tbl_clients'] . " SET reportlastdate=NOW() WHERE clientid=" . $client['clientid']);
            }
            return true;
        }
    }
    return false;
}