} else {
        $orderdirection = '';
    }
}
/*-------------------------------------------------------*/
/* Main code                                             */
/*-------------------------------------------------------*/
require_once MAX_PATH . '/lib/OA/Admin/Template.php';
$oTpl = new OA_Admin_Template('campaign-index.html');
// Get clients & campaign and build the tree
$dalCampaigns = OA_Dal::factoryDAL('campaigns');
$aCampaigns = $dalCampaigns->getClientCampaigns($clientid, $listorder, $orderdirection, array(DataObjects_Campaigns::CAMPAIGN_TYPE_MARKET_CONTRACT));
foreach ($aCampaigns as $campaignId => $aCampaign) {
    $aCampaign['impressions'] = phpAds_formatNumber($aCampaign['views']);
    $aCampaign['clicks'] = phpAds_formatNumber($aCampaign['clicks']);
    $aCampaign['conversions'] = phpAds_formatNumber($aCampaign['conversions']);
    if (!empty($aCampaign['activate_time'])) {
        $oActivateDate = new Date($aCampaign['activate_time']);
        $oTz = $oActivateDate->tz;
        $oActivateDate->setTZbyID('UTC');
        $oActivateDate->convertTZ($oTz);
        $aCampaign['activate'] = $oActivateDate->format($date_format);
    } else {
        $aCampaign['activate'] = '-';
    }
    if (!empty($aCampaign['expire_time'])) {
        $oExpireDate = new Date($aCampaign['expire_time']);
        $oTz = $oExpireDate->tz;
        $oExpireDate->setTZbyID('UTC');
        $oExpireDate->convertTZ($oTz);
        $aCampaign['expire'] = $oExpireDate->format($date_format);
 /**
  * A method to format a row of statistics according to the column's "format"
  * value in the {@link $this->_aFields} array, and according to user preferences
  * for how numbers/currency should be formatted.
  *
  * @param array   $aRow    An array containing a row of statistics to format.
  * @param boolean $isTotal Is the row a "total" row? When true, ensures that
  *                         all "id" formatted columns (from the
  *                         {@link $this->_aFields} array) are set to "-".
  */
 function _formatStats(&$aRow, $isTotal = false)
 {
     foreach ($this->_aFields as $k => $v) {
         if (array_key_exists($k, $aRow)) {
             if ($v['format'] == 'id') {
                 $aRow[$k] = $isTotal ? '-' : $aRow[$k];
             } elseif ($aRow[$k] == 0) {
                 $aRow[$k] = '-';
             } elseif ($v['format'] == 'percent') {
                 $aRow[$k] = phpAds_formatPercentage($aRow[$k]);
             } elseif ($v['format'] == 'currency') {
                 $aRow[$k] = phpAds_formatNumber($aRow[$k], 2);
             } else {
                 $aRow[$k] = phpAds_formatNumber($aRow[$k]);
             }
         }
     }
 }
    }
    if ($manual['views'] || $manual['clicks']) {
        echo "<tr height='25' " . ($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . ">";
        echo "<td height='25'>&nbsp;&nbsp;" . $strUnknown . "</td>";
        echo "<td height='25'>-</td>";
        echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($manual['views']) . "</td>";
        echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($manual['clicks']) . "</td>";
        echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($manual['views'], $manual['clicks']) . "&nbsp;&nbsp;</td>";
        echo "</tr>";
        echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
    }
    // 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) . "&nbsp;&nbsp;</td>";
    echo "</tr>";
    echo "</table>";
    echo "<br><br>";
} else {
    echo "<br><div class='errormessage'><img class='errormessage' src='images/info.gif' width='16' height='16' border='0' align='absmiddle'>";
    echo $strNoStats . '</div>';
}
/*********************************************************/
/* Store preferences                                     */
/*********************************************************/
$Session['prefs']['stats-banner-affiliates.php']['listorder'] = $listorder;
$Session['prefs']['stats-banner-affiliates.php']['orderdirection'] = $orderdirection;
$Session['prefs']['stats-banner-affiliates.php']['nodes'] = implode(",", $node_array);
phpAds_SessionDataStore();
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($totaltarget / $span_this) . "</td>";
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($totalviews / $span_this) . "</td>";
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>&nbsp;</td>";
        echo "</tr>";
        echo "<tr><td height='1' colspan='4' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
        echo "<tr>";
        echo "<td height='25'>&nbsp;<b>{$strTotal}</b></td>";
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($totals['target']) . "</td>";
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($totals['views']) . "</td>";
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_buildTargetRatio($totals['views'], $totals['target']) . "&nbsp;&nbsp;</td>";
        echo "</tr>";
        echo "<tr><td height='1' colspan='4' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
        echo "<tr>";
        echo "<td height='25'>&nbsp;{$strAverage} (" . $span_period . " " . $title . ")</td>";
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($span_period ? $totals['target'] / $span_period : 0) . "</td>";
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($span_period ? $totals['views'] / $span_period : 0) . "</td>";
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>&nbsp;</td>";
        echo "</tr>";
        echo "<tr><td height='1' colspan='4' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
        echo "</table>";
    }
    if (phpAds_GDImageFormat() != "none") {
        echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
        echo "<tr><td height='20' colspan='1'>&nbsp;</td></tr>";
        echo "<tr><td bgcolor='#FFFFFF' colspan='1'>";
        echo "<img src='graph-target.php" . $params . "period=" . $period . "&start=" . $start . "&limit=" . $limit . "' border='0'>";
        echo "</td></tr><tr><td height='10' colspan='1'>&nbsp;</td></tr>";
        echo "<tr><td height='1' colspan='1' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
        echo "</table>";
    }
} else {
    echo "<tr><td colspan='6'>&nbsp;</td></tr>";
    echo "<tr><td colspan='6'>&nbsp;</td></tr>";
    echo "<tr bgcolor='#FFFFFF' height='25'>";
    echo "<td></td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' width='15%' nowrap height='25'><b>" . $strViews . "</b></td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' width='15%' nowrap height='25'><b>" . $strClicks . "</b></td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' width='15%' nowrap height='25'><b>" . $strCTRShort . "</b>&nbsp;&nbsp;</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' width='15%' nowrap height='25'><b>" . $strConversions . "</b>&nbsp;&nbsp;</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' width='15%' nowrap height='25'><b>" . $strCNVR . "</b>&nbsp;&nbsp;</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td height='25'>&nbsp;<b>{$strTotal}</b></td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($totalviews) . "</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($totalclicks) . "</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_buildCTR($totalviews, $totalclicks) . "&nbsp;&nbsp;</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($totalconversions) . "&nbsp;&nbsp;</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . number_format($totalclicks > 0 ? phpAds_formatNumber($cr / $totalclicks) : 0, $phpAds_config['percentage_decimals'], $phpAds_DecimalPoint, $phpAds_ThousandsSeperator) . "%" . "&nbsp;&nbsp;</td>";
    echo "</tr>";
    echo "<tr><td height='1' colspan='6' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
    echo "<tr>";
    echo "<td height='25'>&nbsp;" . $strAverage . "</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($totalviews / 24) . "</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($totalclicks / 24) . "</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . "</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . phpAds_formatNumber($totalconversions / 24) . "&nbsp;&nbsp;</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25'>" . "&nbsp;&nbsp;</td>";
    echo "</tr>";
    echo "<tr><td height='1' colspan='6' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
}
echo "</table>";
echo "<br><br>";
示例#6
0
function MAX_displayZoneStats($aParams, $pageName, $anonymous, $aNodes, $expand, $listorder, $orderdirection, $hideinactive, $showPublisher, $entityIds)
{
    global $phpAds_TextAlignLeft, $phpAds_TextAlignRight, $phpAds_TextDirection;
    // Get the icons for all levels (publisher/zone)
    $entity = _getEntityString($entityIds);
    $publishersHidden = 0;
    $aZones = Admin_DA::fromCache('getZonesStats', $aParams);
    if (!empty($aZones)) {
        echo "\n        <br /><br />\n        <table border='0' width='100%' cellpadding='0' cellspacing='0'>";
        MAX_displayStatsHeader($pageName, $listorder, $orderdirection, $entityIds, $anonymous);
        // Variable to determine if the row should be grey or white...
        $i = 0;
        $totalRequests = 0;
        $totalViews = 0;
        $totalClicks = 0;
        $totalConversions = 0;
        // Loop through publishers
        MAX_sortArray($aZones, $listorder == 'id' ? 'zone_id' : $listorder, $orderdirection == 'up');
        foreach ($aZones as $zoneId => $zone) {
            $zoneRequests = phpAds_formatNumber($zone['sum_requests']);
            $zoneViews = phpAds_formatNumber($zone['sum_views']);
            $zoneClicks = phpAds_formatNumber($zone['sum_clicks']);
            $zoneConversions = phpAds_formatNumber($zone['sum_conversions']);
            $zoneCtr = phpAds_buildRatioPercentage($zone['sum_clicks'], $zone['sum_views']);
            $zoneSr = phpAds_buildRatioPercentage($zone['sum_conversions'], $zone['sum_clicks']);
            $zoneActive = true;
            $zoneIcon = MAX_getEntityIcon('zone', $zoneActive, $zone['type']);
            if (!$hideinactive || $zoneActive) {
                $bgcolor = $i++ % 2 == 0 ? " bgcolor='#F6F6F6'" : '';
                echo "\n        <tr height='25'{$bgcolor}>\n            <td>&nbsp;<img src='" . OX::assetPath() . "/images/spacer.gif' height='16' width='16'>&nbsp;\n                <img src='{$zoneIcon}' align='absmiddle'>&nbsp;";
                if ($anonymous) {
                    echo "\n                Hidden zone {$zone['id']}";
                } else {
                    echo "\n                <a href='stats.php?entity=zone&breakdown=history&affiliateid={$zone['publisher_id']}'>{$zone['name']}</a>";
                }
                echo "\n            </td>";
                if ($anonymous) {
                    echo "\n            <td align='{$phpAds_TextAlignRight}'>&nbsp;</td>";
                } else {
                    echo "\n            <td align='{$phpAds_TextAlignRight}'>{$zoneId}</td>";
                }
                echo "\n            <td align='{$phpAds_TextAlignRight}'>{$zoneRequests}</td>\n            <td align='{$phpAds_TextAlignRight}'>{$zoneViews}</td>\n            <td align='{$phpAds_TextAlignRight}'>{$zoneClicks}</td>\n            <td align='{$phpAds_TextAlignRight}'>{$zoneCtr}</td>\n            <td align='{$phpAds_TextAlignRight}'>{$zoneConversions}</td>\n            <td align='{$phpAds_TextAlignRight}'>{$zoneSr}</td>\n        </tr>\n        <tr height='1'><td colspan='8' bgcolor='#888888'><img src='" . OX::assetPath() . "/images/break.gif' height='1' width='100%'></td></tr>";
            } else {
                $publishersHidden++;
            }
            $totalRequests += $zone['sum_requests'];
            $totalViews += $zone['sum_views'];
            $totalClicks += $zone['sum_clicks'];
            $totalConversions += $zone['sum_conversions'];
        }
        // Total
        echo "\n        <tr height='25'{$bgcolor}>\n            <td>&nbsp;&nbsp;<b>{$GLOBALS['strTotal']}</b></td>\n            <td>&nbsp;</td>\n            <td align='{$phpAds_TextAlignRight}'>" . phpAds_formatNumber($totalRequests) . "</td>\n            <td align='{$phpAds_TextAlignRight}'>" . phpAds_formatNumber($totalViews) . "</td>\n            <td align='{$phpAds_TextAlignRight}'>" . phpAds_formatNumber($totalClicks) . "</td>\n            <td align='{$phpAds_TextAlignRight}'>" . phpAds_buildCTR($totalViews, $totalClicks) . "</td>\n            <td align='{$phpAds_TextAlignRight}'>" . phpAds_formatNumber($totalConversions) . "</td>\n            <td align='{$phpAds_TextAlignRight}'>" . phpAds_buildCTR($totalClicks, $totalConversions) . "</td>\n        </tr>\n        <tr height='1'>\n            <td colspan='8' bgcolor='#888888'><img src='" . OX::assetPath() . "/images/break.gif' height='1' width='100%'></td>\n        </tr>";
        if (!$anonymous) {
            echo "\n        <tr>\n            <td colspan='4' align='{$phpAds_TextAlignLeft}' nowrap>";
            if ($hideinactive == true) {
                echo "&nbsp;&nbsp;<img src='" . OX::assetPath() . "/images/icon-activate.gif' align='absmiddle' border='0'>&nbsp;<a href='{$pageName}?{$entity}hideinactive=0'>{$GLOBALS['strShowAll']}</a>&nbsp;&nbsp;|&nbsp;&nbsp;{$publishersHidden} {$GLOBALS['strInactivePublishersHidden']}";
            } else {
                echo "&nbsp;&nbsp;<img src='" . OX::assetPath() . "/images/icon-hideinactivate.gif' align='absmiddle' border='0'>&nbsp;<a href='{$pageName}?{$entity}hideinactive=1'>{$GLOBALS['strHideInactivePublishers']}</a>";
            }
            echo "\n            </td>\n            <td colspan='4' align='{$phpAds_TextAlignRight}' nowrap><img src='" . OX::assetPath() . "/images/triangle-d.gif' align='absmiddle' border='0'>&nbsp;<a href='{$pageName}?{$entity}expand=all'>{$GLOBALS['strExpandAll']}</a>&nbsp;&nbsp;|&nbsp;&nbsp;<img src='" . OX::assetPath() . "/images/{$phpAds_TextDirection}/triangle-l.gif' align='absmiddle' border='0'>&nbsp;<a href='{$pageName}?{$entity}expand=none'>{$GLOBALS['strCollapseAll']}</a>&nbsp;&nbsp;</td>\n        </tr>\n        <tr height='25'>";
            if ($showPublisher == 't') {
                echo "\n            <td colspan='7' align='{$phpAds_TextAlignLeft}' nowrap>&nbsp;&nbsp;<img src='" . OX::assetPath() . "/images/icon-affiliate.gif' align='absmiddle'><a href='{$pageName}?{$entity}showpublisher=f'> Hide parent publisher</a></td>";
            } else {
                echo "\n            <td colspan='7' align='{$phpAds_TextAlignLeft}' nowrap>&nbsp;&nbsp;<img src='" . OX::assetPath() . "/images/icon-affiliate.gif' align='absmiddle'><a href='{$pageName}?{$entity}showpublisher=t'> Show parent publisher</a></td>";
            }
            echo "\n        </tr>";
        }
        echo "\n        </table>\n        <br /><br />";
    } else {
        MAX_displayNoStatsMessage();
    }
}
require_once MAX_PATH . '/lib/OA/Admin/Template.php';
$oTpl = new OA_Admin_Template('campaign-index.html');
// Get clients & campaign and build the tree
$doCampaigns = OA_Dal::factoryDO('campaigns');
$doCampaigns->clientid = $clientid;
$doCampaigns->addListOrderBy($listorder, $orderdirection);
$doCampaigns->find();
while ($doCampaigns->fetch() && ($row_campaigns = $doCampaigns->toArray())) {
    $campaigns[$row_campaigns['campaignid']]['campaignid'] = $row_campaigns['campaignid'];
    // mask campaign name if anonymous campaign
    $campaign_details = Admin_DA::getPlacement($row_campaigns['campaignid']);
    $row_campaigns['campaignname'] = MAX_getPlacementName($campaign_details);
    $campaigns[$row_campaigns['campaignid']]['campaignname'] = $row_campaigns['campaignname'];
    $campaigns[$row_campaigns['campaignid']]['impressions'] = phpAds_formatNumber($row_campaigns['views']);
    $campaigns[$row_campaigns['campaignid']]['clicks'] = phpAds_formatNumber($row_campaigns['clicks']);
    $campaigns[$row_campaigns['campaignid']]['conversions'] = phpAds_formatNumber($row_campaigns['conversions']);
    if ($row_campaigns['activate'] && $row_campaigns['activate'] != '0000-00-00') {
        $oActivateDate =& new Date($row_campaigns['activate']);
        $campaigns[$row_campaigns['campaignid']]['activate'] = $oActivateDate->format($date_format);
    } else {
        $campaigns[$row_campaigns['campaignid']]['activate'] = '-';
    }
    if ($row_campaigns['activate'] && $row_campaigns['expire'] != '0000-00-00') {
        $oExpireDate =& new Date($row_campaigns['expire']);
        $campaigns[$row_campaigns['campaignid']]['expire'] = $oExpireDate->format($date_format);
    } else {
        $campaigns[$row_campaigns['campaignid']]['expire'] = '-';
    }
    if ($row_campaigns['priority'] == -1) {
        $campaigns[$row_campaigns['campaignid']]['priority'] = $strExclusive;
    } elseif ($row_campaigns['priority'] == -2) {
示例#8
0
 /**
  * A method to determine how long it will be until a campaign "expires".
  *
  * Returns the earliest possible date from the following values:
  *  - The campaign's expiration date, if set.
  *  - The eStimated expiration date based on lifetime impression delivery
  *    rate, if applicable.
  *  - The eStimated expiration date based on lifetime click delivery rate
  *    if applicable.
  *  - The eStimated expiration date based on lifetime conversion rate,
  *    if applicable.
  *
  * Usage:
  *   $desc = $dalCampaigns->getDaysLeftString($campaignid);
  *
  * Where:
  *   $desc is a string to display giving how the expiration was calculated
  *     eg. "Estimated expiration", or that there is no expiration date
  *
  * @param integer $campaignId The campaign ID.
  * @return string
  */
 function getDaysLeftString($campaignId)
 {
     global $date_format, $strNoExpiration, $strDaysLeft, $strEstimated, $strExpirationDate, $strNoExpirationEstimation, $strDaysAgo, $strCampaignStop;
     $prefix = $this->getTablePrefix();
     // Define array to store possible expiration date results
     $aExpiration = array();
     // Get the campaign target info
     $now = OA::getNow('Y-m-d');
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->selectAdd("views AS impressions");
     $doCampaigns->get($campaignId);
     $aCampaignData = $doCampaigns->toArray();
     if (!empty($aCampaignData['expire_time'])) {
         $oNow = new Date($now);
         $oNow->setHour(0);
         $oNow->setMinute(0);
         $oNow->setSecond(0);
         $oDate = new Date($aCampaignData['expire_time']);
         $oDate->setTZbyID('UTC');
         $oDate->convertTZ($oNow->tz);
         $oDate->setHour(0);
         $oDate->setMinute(0);
         $oDate->setSecond(0);
         $oSpan = new Date_Span();
         $oSpan->setFromDateDiff($oNow, $oDate);
         $aCampaignData['expire_f'] = $oDate->format($date_format);
         $aCampaignData['days_left'] = $oSpan->toDays() * ($oDate->before($oNow) ? -1 : 1);
     }
     $oDbh = OA_DB::singleton();
     $tableB = $oDbh->quoteIdentifier($prefix . 'banners', true);
     $tableD = $oDbh->quoteIdentifier($prefix . 'data_intermediate_ad', true);
     // Define array to return the expiration dates (if they exist)
     $aReturn = array('estimatedExpiration' => '', 'campaignExpiration' => '');
     // Does the campaign have lifetime impression targets?
     // If yes, try to get a stimated expiration date
     if ($aCampaignData['impressions'] > 0) {
         $query = "\n        \t    SELECT\n        \t        SUM(dia.impressions) AS delivered,\n        \t        DATE_FORMAT(MIN(dia.date_time), '%Y-%m-%d') AS day_of_first\n        \t    FROM\n        \t        {$tableD} AS dia,\n        \t        {$tableB} AS b\n        \t    WHERE\n        \t        dia.ad_id = b.bannerid\n        \t        AND\n        \t        b.campaignid = " . DBC::makeLiteral($campaignId);
         $rsImpressions = DBC::FindRecord($query);
         if ($rsImpressions) {
             $aImpressions = $rsImpressions->toArray();
             // Get the number of days until the campaign will end
             // based on the impression target delivery data
             $aExpiration = $this->_calculateRemainingDays($aImpressions, $aCampaignData['impressions']);
         }
     } elseif ($aCampaignData['clicks'] > 0) {
         $query = "\n        \t    SELECT\n        \t        SUM(dia.clicks) AS delivered,\n        \t        DATE_FORMAT(MIN(dia.date_time), '%Y-%m-%d') AS day_of_first\n        \t    FROM\n        \t        {$tableD} AS dia,\n        \t        {$tableB} AS b\n        \t    WHERE\n        \t        dia.ad_id = b.bannerid\n        \t        AND\n        \t        b.campaignid = " . DBC::makeLiteral($campaignId);
         $rsClicks = DBC::FindRecord($query);
         if ($rsClicks) {
             $aClicks = $rsClicks->toArray();
             // Get the number of days until the campaign will end
             // based on the click target delivery data
             $aExpiration = $this->_calculateRemainingDays($aClicks, $aCampaignData['clicks']);
         }
     } elseif ($aCampaignData['conversions'] > 0) {
         $query = "\n        \t    SELECT\n        \t        SUM(dia.conversions) AS delivered,\n        \t        DATE_FORMAT(MIN(dia.date_time), '%Y-%m-%d') AS day_of_first\n        \t    FROM\n        \t        {$tableD} AS dia,\n        \t        {$tableB} AS b\n        \t    WHERE\n        \t        dia.ad_id = b.bannerid\n        \t        AND\n        \t        b.campaignid = " . DBC::makeLiteral($campaignId);
         $rsConversions = DBC::FindRecord($query);
         if ($rsConversions) {
             $aConversions = $rsConversions->toArray();
             // Get the number of days until the campaign will end
             // based on the conversion target delivery data
             $aExpiration = $this->_calculateRemainingDays($aConversions, $aCampaignData['conversions']);
         }
     }
     // flags to control if the campaign expiration date and
     // the estimated expiration date are going to be showed
     $existExpirationDate = false;
     $showEtimatedDate = false;
     // is there a expiration date?
     if (!empty($aCampaignData['expire_time'])) {
         $existExpirationDate = true;
     }
     if ($existExpirationDate) {
         // has the expiration date been reached?
         if ((int) $aCampaignData['days_left'] < 0) {
             $aReturn['campaignExpiration'] = $strCampaignStop . ": " . $aCampaignData['expire_f'];
             $aReturn['campaignExpiration'] = $aReturn['campaignExpiration'] . " (" . abs((int) round($aCampaignData['days_left'])) . " {$strDaysAgo})";
         } else {
             $aReturn['campaignExpiration'] = $strExpirationDate . ": " . $aCampaignData['expire_f'];
             $aReturn['campaignExpiration'] = $aReturn['campaignExpiration'] . " (" . $strDaysLeft . ": " . round($aCampaignData['days_left']) . ")";
         }
     } else {
         $aReturn['campaignExpiration'] = $strNoExpiration;
     }
     // There is a estimated expiration date?
     // If yes, check if the campaign expiration date is set up and compare
     // both expiration dates to show only relevant estimated expiration dates
     if (!empty($aExpiration)) {
         if ($existExpirationDate == true) {
             if (round($aCampaignData['days_left']) >= 0) {
                 $campaignExpirationDate = new Date($aCampaignData['expire_time']);
                 $aExpiration['date']->hour = 0;
                 $aExpiration['date']->minute = 0;
                 $aExpiration['date']->second = 0;
                 $aExpiration['date']->partsecond = 0;
                 $compareDate = Date::compare($aExpiration['date'], $campaignExpirationDate);
                 // the estimated expiration date is previous or equal to the
                 // campaign expiration date and hasn't the expiration date been reached?
                 if ($compareDate <= 0 && (int) $aCampaignData['days_left'] >= 0) {
                     $showEtimatedDate = true;
                 }
             }
         } else {
             $showEtimatedDate = true;
         }
     } elseif ($existExpirationDate && round($aCampaignData['days_left']) >= 0 || !$existExpirationDate) {
         $aReturn['estimatedExpiration'] = $strEstimated . ": " . $strNoExpirationEstimation;
     }
     if ($showEtimatedDate) {
         $aExpiration['daysLeft'] = phpAds_formatNumber($aExpiration['daysLeft']);
         $aReturn['estimatedExpiration'] = $strEstimated . ": " . $aExpiration['date_f'] . " (" . $strDaysLeft . ": " . $aExpiration['daysLeft'] . ")";
     }
     return $aReturn;
 }
function phpAds_printSourceRow($source_row, $expand_arr, $begin_str)
{
    global $anonymous, $campaignid, $clientid, $cnt, $phpAds_TextDirection, $phpAds_TextAlignRight;
    $expand = $expand_arr == 'all' || isset($expand_arr[$source_row['path']]) && $expand_arr[$source_row['path']] == 1;
    $children_present = isset($source_row['children']) && is_array($source_row['children']) & sizeof($source_row['children']) > 0;
    echo "\t\t\t\t<tr height='25' " . ($cnt % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . ">\n";
    echo "\t\t\t\t\t<td>";
    echo $begin_str;
    if ($children_present && !$anonymous) {
        if ($expand) {
            echo "<a href='stats-banner-sources.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&collapse=" . $source_row['path'] . "'><img src='images/triangle-d.gif' align='absmiddle' border='0'></a>&nbsp;";
        } else {
            echo "<a href='stats-banner-sources.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&expand=" . $source_row['path'] . "'><img src='images/" . $phpAds_TextDirection . "/triangle-l.gif' align='absmiddle' border='0'></a>&nbsp;";
        }
    } else {
        echo "<img src='images/spacer.gif' align='absmiddle' width='16' height='16' border='0'>";
    }
    if ($anonymous) {
        echo "(hidden source #" . ($cnt + 1) . ")";
    } else {
        echo $source_row['name'];
    }
    echo "</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($source_row['views']) . "</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($source_row['clicks']) . "</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($source_row['views'], $source_row['clicks']) . "</td>";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($source_row['conversions']) . "</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($source_row['clicks'], $source_row['conversions']) . "&nbsp;&nbsp;</td>";
    echo "\t\t\t\t</tr>\n";
    if ($expand && $children_present && !$anonymous) {
        $child_source_row = $source_row['children'];
        for ($i = 0; $i < sizeof($child_source_row); $i++) {
            echo "\t\t\t\t<tr height='1'" . ($cnt % 2 == 0 ? " bgcolor='#F6F6F6'" : "") . "><td><img src='images/spacer.gif' width='100%' height='1' border='0'></td><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>\n";
            phpAds_printSourceRow($child_source_row[$i], $expand_arr, $begin_str . "&nbsp;&nbsp;&nbsp;&nbsp;");
        }
    }
}
        echo "<tr><td height='25' bgcolor='{$bgcolor}'>&nbsp;";
        echo $key != '' ? "<img src='images/flags/" . strtolower($key) . ".gif' width='19' height'11'>&nbsp;" . $phpAds_ISO3166[$key] : $strUnknown;
        echo "</td>";
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25' bgcolor='{$bgcolor}'>" . phpAds_formatNumber($value['views']) . "</td>";
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25' bgcolor='{$bgcolor}'>" . phpAds_formatNumber($value['clicks']) . "</td>";
        echo "<td align='" . $phpAds_TextAlignRight . "' height='25' bgcolor='{$bgcolor}'>" . phpAds_buildCTR($value['views'], $value['clicks']) . "&nbsp;&nbsp;</td>";
        echo "</tr>";
        echo "<tr><td height='1' colspan='4' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
        $totals['clicks'] += $value['clicks'];
        $totals['views'] += $value['views'];
        $i++;
    }
    $bgcolor = "#FFFFFF";
    $i % 2 ? 0 : ($bgcolor = "#F6F6F6");
    echo "<tr><td height='25' bgcolor='{$bgcolor}'>&nbsp;";
    echo "<b>" . $strTotal . "</b></td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25' bgcolor='{$bgcolor}'>" . phpAds_formatNumber($totals['views']) . "</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25' bgcolor='{$bgcolor}'>" . phpAds_formatNumber($totals['clicks']) . "</td>";
    echo "<td align='" . $phpAds_TextAlignRight . "' height='25' bgcolor='{$bgcolor}'>" . phpAds_buildCTR($totals['views'], $totals['clicks']) . "&nbsp;&nbsp;</td>";
    echo "</tr>";
    echo "<tr><td height='1' colspan='4' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
    echo "</table>";
}
if ($type == 't') {
    $lib_targetstats_where = "clientid > 0";
    unset($params);
    $lib_targetstats_params['type'] = 't';
    $lib_targetstats_misc_stats = true;
    include "lib-targetstats.inc.php";
}
echo "<br><br>";
示例#11
0
 /**
  * A private method to prepare the statistics part of the body of an
  * advertiser's "campaign delivery" report email.
  *
  * @access private
  * @param integer    $advertiserId The advertiser's ID.
  * @param Date $oStartDate   The start date of the report, inclusive.
  * @param Date $oEndDate     The end date of the report, inclusive.
  * @param string     $type         One of "impressions", "clicks" or "conversions".
  * @param string     $adTextPrint  An sprintf compatible formatting string for use
  *                                 with the $strTotalThisPeriod global string.
  * @return an array with
  *      'body'      => string The ad statistics part of the report.
  *      'adviews'   => int    Adviews in this period
  */
 function _prepareCampaignDeliveryEmailBodyStats($adId, $oStartDate, $oEndDate, $type, $adTextPrint)
 {
     $oDbh =& OA_DB::singleton();
     // Obtain the required date format
     global $date_format;
     // Obtain the impressions, clicks and conversions string, and prepare
     // these strings for use, including formatting strings
     global $strNoViewLoggedInInterval, $strNoClickLoggedInInterval, $strNoConversionLoggedInInterval, $strTotalThisPeriod;
     if ($type == 'impressions') {
         $nothingLogged = $strNoViewLoggedInInterval;
     } else {
         if ($type == 'clicks') {
             $nothingLogged = $strNoClickLoggedInInterval;
         } else {
             if ($type == 'conversions') {
                 $nothingLogged = $strNoConversionLoggedInInterval;
             } else {
                 return array('body' => '', 'adviews' => 0);
             }
         }
     }
     // Prepare the result
     $emailBodyStats = '';
     $total = 0;
     // Fetch the ad's stats for the report period, grouped by day
     $doDataSummaryAdHourly = OA_Dal::factoryDO('data_summary_ad_hourly');
     $doDataSummaryAdHourly->selectAdd();
     $doDataSummaryAdHourly->selectAdd("date_time");
     $doDataSummaryAdHourly->selectAdd("SUM({$type}) as quantity");
     $doDataSummaryAdHourly->ad_id = $adId;
     $doDataSummaryAdHourly->whereAdd("impressions > 0");
     if (!is_null($oStartDate)) {
         $oDate = new Date($oStartDate);
         $oDate->toUTC();
         $doDataSummaryAdHourly->whereAdd('date_time >= ' . $oDbh->quote($oDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp'));
     }
     $oDate = new Date($oEndDate);
     $oDate->toUTC();
     $doDataSummaryAdHourly->whereAdd('date_time <= ' . $oDbh->quote($oDate->format('%Y-%m-%d %H:%M:%S'), 'timestamp'));
     $doDataSummaryAdHourly->groupBy('date_time');
     $doDataSummaryAdHourly->orderBy('date_time DESC');
     $doDataSummaryAdHourly->find();
     if ($doDataSummaryAdHourly->getRowCount() > 0) {
         // The ad has statistics this period, perform time zone conversion and summarize
         $aAdQuantity = array();
         while ($doDataSummaryAdHourly->fetch()) {
             $v = $doDataSummaryAdHourly->toArray();
             $oDate = new Date($v['date_time']);
             $oDate->setTZbyID('UTC');
             $oDate->convertTZ($oEndDate->tz);
             $k = $oDate->format($date_format);
             if (!isset($aAdQuantity[$k])) {
                 $aAdQuantity[$k] = 0;
             }
             $aAdQuantity[$k] += $v['quantity'];
         }
         foreach ($aAdQuantity as $day => $quantity) {
             // Add this day
             $emailBodyStats .= sprintf($adTextPrint, $day) . ': ';
             $emailBodyStats .= sprintf('%15s', phpAds_formatNumber($quantity)) . "\n";
             $total += $quantity;
         }
         // Add the total statistics for the period
         $emailBodyStats .= sprintf($adTextPrint, $strTotalThisPeriod) . ': ';
         $emailBodyStats .= sprintf('%15s', phpAds_formatNumber($total)) . "\n";
     } else {
         // Simply note that there were no statistics this period
         $emailBodyStats .= '  ' . $nothingLogged . "\n";
     }
     // Return the result for the ad's stats
     return array('body' => $emailBodyStats, 'adviews' => $total);
 }
function phpAds_printSourceRow($source_row, $sources, $expand_arr, $listorder, $orderdirection, $begin_str)
{
    global $anonymous, $campaignid, $clientid, $cnt, $phpAds_TextDirection, $phpAds_TextAlignRight;
    $expand = $expand_arr == 'all' || isset($expand_arr['sources/' . $source_row['path']]) && $expand_arr['sources/' . $source_row['path']] == 1;
    $children_present = isset($source_row['children']) && is_array($source_row['children']) & sizeof($source_row['children']) > 0;
    $checked = '';
    for ($i = 0; $i < sizeof($sources); $i++) {
        if ($sources[$i] == $source_row['path']) {
            $checked = ' checked';
            break;
        }
    }
    echo "\t\t\t\t<tr height='25' " . ($cnt % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . ">\n";
    echo "\t\t\t\t\t<td><input type='checkbox' name='sources[]' value='" . $source_row['path'] . "'" . $checked . "></td>\n";
    echo "\t\t\t\t\t<td>";
    echo $begin_str;
    if ($children_present && !$anonymous) {
        if ($expand) {
            echo "<a href='stats-campaign-optimise.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&collapse=" . urlencode('sources/' . $source_row['path']) . "'><img src='images/triangle-d.gif' align='absmiddle' border='0'></a>&nbsp;";
        } else {
            echo "<a href='stats-campaign-optimise.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&expand=" . urlencode('sources/' . $source_row['path']) . "'><img src='images/" . $phpAds_TextDirection . "/triangle-l.gif' align='absmiddle' border='0'></a>&nbsp;";
        }
    } else {
        echo "<img src='images/spacer.gif' align='absmiddle' width='16' height='16' border='0'>";
    }
    if ($anonymous) {
        echo "(hidden source #" . ($cnt + 1) . ")";
    } else {
        echo $source_row['source'];
    }
    echo "</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($source_row['views']) . "</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($source_row['clicks']) . "</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($source_row['views'], $source_row['clicks']) . "</td>";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($source_row['conversions']) . "</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($source_row['clicks'], $source_row['conversions']) . "&nbsp;&nbsp;</td>";
    echo "\t\t\t\t</tr>\n";
    if ($expand && $children_present && !$anonymous) {
        $child_source_row = $source_row['children'];
        for ($i = 0; $i < sizeof($child_source_row); $i++) {
            phpAds_printTableBreak(7, 2, $cnt % 2 == 0 ? "#F6F6F6" : "");
            phpAds_printSourceRow($child_source_row[$i], $sources, $expand_arr, $listorder, $orderdirection, $begin_str . "&nbsp;&nbsp;&nbsp;&nbsp;");
        }
    }
}
                 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . ($sources['conversions'] > 0 ? "&pound;  " . $sources['total_cost'] / $sources['conversions'] : "&infin;") . "&nbsp;&nbsp;</td>";
             }
         }
         echo "<tr height='1'><td colspan='9' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
         $i++;
     }
 }
 // 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($totalclicks) . "</td>";
 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'></td>";
 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>&pound; " . phpAds_formatNumber($totalcost, 2) . "</td>";
 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($totalconversions) . "</td>";
 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($totalclicks, $totalconversions) . "</td>";
 echo "<td height='25' align='" . $phpAds_TextAlignRight . "'>&pound; " . phpAds_formatNumber($totalconversions == 0 ? 0 : $totalcost / $totalconversions, 2) . "&nbsp;&nbsp;</td>";
 echo "</tr>";
 echo "<tr height='1'><td colspan='8' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 echo "<tr><td height='25' colspan='5' align='" . $phpAds_TextAlignLeft . "' nowrap>";
 if ($hideinactive == true) {
     echo "&nbsp;&nbsp;<img src='images/icon-activate.gif' align='absmiddle' border='0'>";
     echo "&nbsp;<a href='" . $_SERVER['PHP_SELF'] . "?period=" . $period . "&amp;hideinactive=0&clientid=" . $clientid . "&campaignid=" . $campaignid . "'>" . $strShowAll . "</a>";
     echo "&nbsp;&nbsp;|&nbsp;&nbsp;" . $bannershidden . " " . $strInactiveBannersHidden;
 } else {
     echo "&nbsp;&nbsp;<img src='images/icon-hideinactivate.gif' align='absmiddle' border='0'>";
     echo "&nbsp;<a href='" . $_SERVER['PHP_SELF'] . "?period=" . $period . "&amp;hideinactive=1&clientid=" . $clientid . "&campaignid=" . $campaignid . "'>" . $strHideInactiveBanners . "</a>";
 }
 echo "</td><td height='25' colspan='4' align='" . $phpAds_TextAlignRight . "' nowrap>";
 echo "<img src='images/triangle-d.gif' align='absmiddle' border='0'>";
 echo "&nbsp;<a href='" . $_SERVER['PHP_SELF'] . "?period=" . $period . "&amp;expand=all&clientid=" . $clientid . "&campaignid=" . $campaignid . "' accesskey='" . $keyExpandAll . "'>" . $strExpandAll . "</a>";
 echo "&nbsp;&nbsp;|&nbsp;&nbsp;";
     echo "<td>-</td>";
     echo "<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($manual['views']) . "</td>";
     echo "<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($manual['clicks']) . "</td>";
     echo "<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($manual['views'], $manual['clicks']) . "</td>";
     echo "<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($manual['conversions']) . "</td>";
     echo "<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($manual['clicks'], $manual['conversions']) . "&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>";
 }
 // Total
 echo "<tr height='25'><td height='25'>&nbsp;&nbsp;<b>" . $strTotal . "</b></td>";
 echo "<td>&nbsp;</td>";
 echo "<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($totalviews) . "</td>";
 echo "<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($totalclicks) . "</td>";
 echo "<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($totalviews, $totalclicks) . "&nbsp;&nbsp;</td>";
 echo "<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($totalconversions) . "</td>";
 echo "<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_buildCTR($totalclicks, $totalconversions) . "&nbsp;&nbsp;</td>";
 echo "</tr>";
 // Break
 echo "\t\t\t\t<tr height='1'><td colspan='7' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>\n";
 // Expand / Collapse
 echo "\t\t\t\t<tr>\n";
 echo "\t\t\t\t\t<td colspan='7' align='" . $phpAds_TextAlignRight . "' nowrap>";
 echo "<img src='images/triangle-d.gif' align='absmiddle' border='0'>";
 echo "&nbsp;<a href='stats-campaign-affiliates.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&expand=all' accesskey='" . $keyExpandAll . "'>" . $strExpandAll . "</a>";
 echo "&nbsp;&nbsp;|&nbsp;&nbsp;";
 echo "<img src='images/" . $phpAds_TextDirection . "/triangle-l.gif' align='absmiddle' border='0'>";
 echo "&nbsp;<a href='stats-campaign-affiliates.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&expand=none' accesskey='" . $keyCollapseAll . "'>" . $strCollapseAll . "</a>";
 echo "</td>\n";
 echo "\t\t\t\t</tr>";
 echo "</table>";
示例#15
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><td height='25' colspan='2'><b>" . $strCreditStats . "</b></td></tr>";
 echo "<tr><td height='1' colspan='2' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 if (phpAds_GDImageFormat() != "none" && $totaladviews > 0 && !$phpAds_config['compact_stats']) {
     $where = ereg_replace("OR\$", "", $where);
     echo "<tr><td height='20' colspan='2'>&nbsp;</td></tr>";
     echo "<tr><td bgcolor='#FFFFFF' colspan='2'><img src='graph-hourly.php?where=" . urlencode($where) . "' border='0' width='385' height='150'></td></tr>";
     echo "<tr><td height='10' colspan='2'>&nbsp;</td></tr>";
     echo "<tr><td height='1' colspan='2' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 }
 list($desc, $enddate, $daysleft) = days_left($campaignid);
 $adclicksleft = adclicks_left($campaignid);
 $adviewsleft = adviews_left($campaignid);
 echo "<tr><td height='25'>" . $strTotalViews . ": <b>" . phpAds_formatNumber($totaladviews) . "</b></td>";
 echo "<td height='25'>" . $strViewCredits . ": <b>" . $adviewsleft . "</b></td></tr>";
 echo "<tr><td height='1' colspan='2' bgcolor='#888888'><img src='images/break-el.gif' height='1' width='100%'></td></tr>";
 echo "<tr><td height='25'>" . $strTotalClicks . ": <b>" . phpAds_formatNumber($totaladclicks) . "</b></td>";
 echo "<td height='25'>" . $strClickCredits . ": <b>" . $adclicksleft . "</b></td></tr>";
 echo "<tr><td height='1' colspan='2' bgcolor='#888888'><img src='images/break-el.gif' height='1' width='100%'></td></tr>";
 echo "<tr><td height='25' colspan='2'>" . $desc . "</td></tr>";
 if ($adviewsleft != $strUnlimited || $adclicksleft != $strUnlimited) {
     echo "<tr><td height='1' colspan='2' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
     echo "<tr><td height='60' align='left'>";
     if ($adviewsleft == $strUnlimited) {
         echo "&nbsp;";
     } else {
         echo "<img src='graph-daily.php?width=200&data=Views^" . $totaladviews . "^^Credits^" . $adviewsleft . "^^'></td>";
     }
     echo "<td height='60'>";
     if ($adclicksleft == $strUnlimited) {
         echo "&nbsp;";
     } else {