Exemplo n.º 1
0
function rowPresenter($array, $i = 0, $level = 0, $parent = '', $isClient = false, $id = 0)
{
    global $HTTP_SERVER_VARS, $phpAds_TextAlignRight, $phpAds_TextDirection, $hideinactive, $i;
    if (is_array($array)) {
        foreach ($array as $array) {
            if ($array['kind'] == 'campaign' && $array['active'] == 'f' && $hideinactive == '1') {
                continue;
            }
            // Define kind of row and id
            $kind = $array['kind'];
            $thisID = $array['id'];
            // Inserts divider if NOT top level (level > 0)
            if ($level > 0) {
                echo "<tr " . ($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . "height='1'><td><img src='images/spacer.gif' width='1' height='1'></td><td colspan='6' bgcolor='#888888'><img src='images/break-l.gif' height='1' width='100%'></td></tr>";
            }
            // Sets background color of the row
            echo "<tr height='25' " . ($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . ">";
            // Indents as necesseary
            echo "<td height='25'>";
            echo "<img src='images/spacer.gif' height='16' width='" . 4 . "'>";
            echo "<img src='images/spacer.gif' height='16' width='" . $level * 20 . "'>";
            // expanding arrows
            if (isset($array['children']) && ($array['anonymous'] == 'f' || !phpAds_isUser(phpAds_Affiliate) && !phpAds_isUser(phpAds_Client))) {
                if (isset($array['expand']) && $array['expand'] == '1') {
                    echo "<a href='" . $HTTP_SERVER_VARS['PHP_SELF'] . "?_id_=" . ($parent != '' ? $parent . "-" : '') . $thisID . "&collapse=1&" . ($isClient ? 'clientid=' . $id : 'affiliateid=' . $id) . "'><img src='images/triangle-d.gif' align='absmiddle' align='absmiddle' border='0'></a>";
                } else {
                    echo "<a href='" . $HTTP_SERVER_VARS['PHP_SELF'] . "?_id_=" . ($parent != '' ? $parent . "-" : '') . $thisID . "&expand=1&" . ($isClient ? 'clientid=' . $id : 'affiliateid=' . $id) . "'><img src='images/" . $phpAds_TextDirection . "/triangle-l.gif' align='absmiddle' border='0'></a>";
                }
            } else {
                echo "<img src='images/spacer.gif' height='16' width='" . 16 . "' align='absmiddle'>";
            }
            echo "<img src='images/spacer.gif' height='16' width='" . 4 . "'>";
            // specific zone stuff
            if ($kind == 'zone') {
                // icon
                if ($array['delivery'] == phpAds_ZoneBanner) {
                    echo "<img src='images/icon-zone.gif' align='absmiddle'>";
                } elseif ($array['delivery'] == phpAds_ZoneInterstitial) {
                    echo "<img src='images/icon-interstitial.gif' align='absmiddle'>";
                } elseif ($array['delivery'] == phpAds_ZonePopup) {
                    echo "<img src='images/icon-popup.gif' align='absmiddle'>";
                } elseif ($array['delivery'] == phpAds_ZoneText) {
                    echo "<img src='images/icon-textzone.gif' align='absmiddle'>";
                }
                // spacer between icon and name
                echo "<img src='images/spacer.gif' height='16' width='" . 4 . "' align='absmiddle'>";
                // name and info
                echo "<a href='stats-zone-history.php?affiliateid=" . $array['affiliateid'] . "&zoneid=" . $array['id'] . "'>" . $array['name'] . "</a>";
                echo "</td>";
                echo "<td height='25'>" . $array['id'] . "</td>";
            } else {
                if ($kind == 'campaign') {
                    // check whether the campaign is active
                    if ($array['active'] == 't') {
                        echo "<img src='images/icon-campaign.gif' align='absmiddle'>";
                    } else {
                        echo "<img src='images/icon-campaign-d.gif' align='absmiddle'>";
                    }
                    // spacer between icon and name
                    echo "<img src='images/spacer.gif' height='16' width='" . 4 . "' align='absmiddle'>";
                    // get campaign name
                    $name = '';
                    if (isset($array['alt']) && $array['alt'] != '') {
                        $name = $array['alt'];
                    }
                    if (isset($array['name']) && $array['name'] != '') {
                        $name = $array['name'];
                    }
                    // check whether we should show the name and id of this banner
                    if ($array['anonymous'] == 't' && (phpAds_isUser(phpAds_Affiliate) || phpAds_isUser(phpAds_Client))) {
                        echo "<a href='#'>" . $GLOBALS['strHiddenCampaign'] . "</a></td>";
                        echo "<td height='25'></td>";
                    } else {
                        echo $isClient ? "<a href='stats-campaign-history.php?clientid=" . $id . "&campaignid=" . $array['id'] . "'>" . $name . "</a>" : "<a href='stats-campaign-affiliates.php?clientid=" . $id . "&campaignid=" . $array['id'] . "'>" . $name . "</a>";
                        echo "</td><td height='25'>" . $array['id'] . "</td>";
                    }
                } else {
                    if ($kind == 'banner') {
                        if (ereg('bannerid:' . $array['id'], $array['what'])) {
                            echo "<img src='images/icon-zone-linked.gif' align='absmiddle'>";
                        } else {
                            echo "<img src='images/icon-banner-stored.gif' align='absmiddle'>";
                        }
                        // spacer between icon and name
                        echo "<img src='images/spacer.gif' height='16' width='" . 4 . "' align='absmiddle'>";
                        if ($isClient) {
                            echo "<a href='stats-banner-history.php?clientid=" . $id . "&bannerid=" . $array['id'] . "&campaignid=" . phpAds_getBannerParentClientID($array['id']) . "'>" . ($array['anonymous'] == 't' ? "(Hidden Banner)" : phpAds_getBannerName($array['id'], 30, false)) . "</td>";
                        } else {
                            $thiszone = explode('-', $parent);
                            echo "<a href='stats-linkedbanner-history.php?affiliateid=" . $id . "&zoneid=" . $thiszone[0] . "&bannerid=" . $array['id'] . "'>" . ($array['anonymous'] == 't' ? "(Hidden Banner)" : phpAds_getBannerName($array['id'], 30, false)) . "</td>";
                        }
                        echo "</td>";
                        echo "<td height='25'>" . $array['id'] . "</td>";
                    }
                }
            }
            echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($array['views']) . "</td>";
            echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($array['clicks']) . "</td>";
            echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($array['views'], $array['clicks']) . "</td>";
            echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($array['conversions']) . "</td>";
            echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($array['clicks'], $array['conversions']) . "&nbsp;&nbsp;</td>";
            echo "</tr>";
            if ($array['expand'] == TRUE && ($array['anonymous'] != 't' || !phpAds_isUser(phpAds_Affiliate) && !phpAds_isUser(phpAds_Client)) && is_array($array['children'])) {
                rowPresenter($array['children'], $i, $level + 1, ($parent != '' ? $parent . "-" : '') . $thisID, $isClient, $id);
            }
            if ($level == 0) {
                echo "<tr height='1'><td colspan='7' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
            }
            if ($level == 0) {
                $i++;
            }
        }
    }
}
//-----------------------------------------------------------------------------------------------------------------------
echo "<tr height='1'><td colspan='7' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
if ($screen == 'zones') {
    $i = 0;
    if (!isset($array) || !is_array($array) || count($array) == 0) {
        echo "<tr height='25' bgcolor='#F6F6F6'><td height='25' colspan='7'>";
        echo "&nbsp;&nbsp;" . $strNoZones;
        echo "</td></tr>";
        echo "<td colspan='7' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td>";
    } else {
        rowPresenter($array, 0, '', 0, false, $affiliateid);
    }
} else {
    $i = 0;
    foreach ($array as $zone) {
        rowPresenter($zone['children'], $i, '', $zone['id'], false, $affiliateid);
    }
}
// Total
echo "<tr height='25'><td height='25'>&nbsp;&nbsp;<b>" . $strTotal . "</b></td>";
echo "<td height='25'>&nbsp;</td>";
echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($totalviews) . "</td>";
echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($totalclicks) . "</td>";
echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($totalviews, $totalclicks) . "</td>";
echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($totalconversions) . "</td>";
echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($totalclicks, $totalconversions) . "&nbsp;&nbsp;</td>";
echo "</tr>";
echo "<tr height='1'><td colspan='7' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
echo "<tr>";
echo "<td>";
// Hide/show inactive
     echo $orderdirection == "up" ? '<a href="' . $HTTP_SERVER_VARS['PHP_SELF'] . '?clientid=' . $clientid . '&orderdirection=down"><img src="images/caret-u.gif" border="0" alt="" title=""></a>' : '<a href="' . $HTTP_SERVER_VARS['PHP_SELF'] . '?clientid=' . $clientid . '&orderdirection=up"><img src="images/caret-ds.gif" border="0" alt="" title=""></a>';
 }
 echo '</b></td>';
 // Sales Ration colum
 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'><b><a href='" . $HTTP_SERVER_VARS['PHP_SELF'] . "?clientid=" . $clientid . "&listorder=CNVR'>" . $GLOBALS['strCNVRShort'] . '</a>&nbsp;&nbsp;';
 if ($listorder == "CNVR") {
     echo $orderdirection == "up" ? '<a href="' . $HTTP_SERVER_VARS['PHP_SELF'] . '?clientid=' . $clientid . '&orderdirection=down"><img src="images/caret-u.gif" border="0" alt="" title=""></a>' : '<a href="' . $HTTP_SERVER_VARS['PHP_SELF'] . '?clientid=' . $clientid . '&orderdirection=up"><img src="images/caret-ds.gif" border="0" alt="" title=""></a>';
 }
 echo '</b></td>';
 echo "</tr>";
 //-----------------------------------------------------------------------------------------------------------------------
 //Column headers END
 //-----------------------------------------------------------------------------------------------------------------------
 echo "<tr height='1'><td colspan='7' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 $i = 0;
 rowPresenter($array, $i++, 0, '', true, $clientid, '');
 // Total
 echo "<tr height='25' " . ($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . "><td height='25'>&nbsp;&nbsp;<b>" . $strTotal . "</b></td>";
 echo "<td height='25'>&nbsp;</td>";
 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($totalviews) . "</td>";
 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($totalclicks) . "</td>";
 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($totalviews, $totalclicks) . "</td>";
 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($totalconversions) . "</td>";
 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . number_format($totalclicks ? $totalconversions / $totalclicks * 100 : 0, $phpAds_config['percentage_decimals'], $phpAds_DecimalPoint, $phpAds_ThousandsSeperator) . "%&nbsp;&nbsp;</td>";
 echo "</tr>";
 echo "<tr height='1'><td colspan='7' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 echo "<tr height='25'><td colspan='2' height='25' align='" . $phpAds_TextAlignLeft . "' nowrap>";
 if ($hideinactive == true) {
     echo "&nbsp;&nbsp;<img src='images/icon-activate.gif' align='absmiddle' border='0'>";
     echo "&nbsp;<a href='stats-advertiser-campaigns.php?clientid=" . $clientid . "&hideinactive=0'>" . $strShowAll . "</a>";
     echo "&nbsp;&nbsp;|&nbsp;&nbsp;" . $campaignshidden . " " . $strInactiveCampaignsHidden;