function Plugin_TrackerHistoryExecute($clientid, $start, $end, $delimiter = ",")
{
    global $phpAds_config, $date_format;
    global $strCampaign, $strTotal, $strDay, $strViews, $strClicks, $strCTRShort;
    header("Content-type: application/csv\nContent-Disposition: inline; filename=trackerhistory.csv");
    // get all trackers and group them by advertiser and campaign
    $res_trackers = phpAds_dbQuery("SELECT\n\t\t\t\t\t\t\t\t\t\ttrackers.trackerid,\n\t\t\t\t\t\t\t\t\t\ttrackers.trackername\n\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t\t" . $phpAds_config['tbl_trackers'] . " as trackers\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\ttrackers.clientid = " . $clientid . "\n\t\t\t\t\t\t\t\t\t");
    $trackers = array();
    while ($row = phpAds_dbFetchArray($res_trackers)) {
        $trackers[$row['trackerid']] = array();
        $trackers[$row['trackerid']]['name'] = $row['trackername'];
    }
    $res_total_conversions = phpAds_dbQuery("SELECT\n\t\t\t\t\t\t\t\t\t\t\ttrackers.trackerid,\n\t\t\t\t\t\t\t\t\t\t\tcount(conversions.conversionid) as hits\n\t\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t\t\t" . $phpAds_config['tbl_adconversions'] . " as conversions,\n\t\t\t\t\t\t\t\t\t\t\t" . $phpAds_config['tbl_trackers'] . " as trackers\n\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\ttrackers.trackerid = conversions.trackerid\n\t\t\t\t\t\t\t\t\t\t\tAND trackers.clientid = " . $clientid . "\n\t\t\t\t\t\t\t\t\t\t\tAND conversions.t_stamp >= '" . str_replace("/", "", $start) . "000000'\n\t\t\t\t\t\t\t\t\t\t\tAND conversions.t_stamp <= '" . str_replace("/", "", $end) . "235959'\n\t\t\t\t\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t\t\t\t\tconversions.trackerid\n\t\t\t\t\t\t\t\t");
    while ($row = phpAds_dbFetchArray($res_total_conversions)) {
        $trackers[$row['trackerid']]['total_conversions'] = $row['hits'];
    }
    $res_conversions = phpAds_dbQuery("SELECT\n\t\t\t\t\t\t\t\t\t\t\ttrackers.trackerid,\n\t\t\t\t\t\t\t\t\t\t\tcount(*) as hits\n\t\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t\t\t" . $phpAds_config['tbl_conversionlog'] . " as conversions,\n\t\t\t\t\t\t\t\t\t\t\t" . $phpAds_config['tbl_trackers'] . " as trackers\n\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\ttrackers.trackerid = conversions.trackerid\n\t\t\t\t\t\t\t\t\t\t\tAND trackers.clientid = " . $clientid . "\n\t\t\t\t\t\t\t\t\t\t\tAND conversions.t_stamp >= '" . str_replace("/", "", $start) . "000000'\n\t\t\t\t\t\t\t\t\t\t\tAND conversions.t_stamp <= '" . str_replace("/", "", $end) . "235959'\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\t\t\t\t\tconversions.trackerid\n\t\t\t\t\t\t\t\t");
    while ($row = phpAds_dbFetchArray($res_conversions)) {
        $trackers[$row['trackerid']]['conversions'] = $row['hits'];
    }
    //echo "<pre>";
    //print_r($trackers);
    //echo "</pre>";
    echo "Client: " . strip_tags(phpAds_getClientName($clientid)) . " - " . $start . " - " . $end . "\n\n";
    echo $GLOBALS['strName'] . $delimiter . $GLOBALS['strID'] . $delimiter . "Conversions" . $delimiter . "Total Hits" . "\n";
    echo "\n";
    foreach ($trackers as $id => $tracker) {
        echo $tracker['name'] . $delimiter . $id . $delimiter . $tracker['conversions'] . $delimiter . $tracker['total_conversions'] . $delimiter . "\n";
    }
}
function Plugin_ClienthistoryExecute($clientid, $delimiter = ",")
{
    global $phpAds_config, $date_format;
    global $strClient, $strTotal, $strDay, $strViews, $strClicks, $strCTRShort;
    header("Content-type: application/csv\nContent-Disposition: \"inline; filename=clienthistory.csv\"");
    $idresult = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tb.bannerid\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_banners'] . " AS b,\n\t\t\t" . $phpAds_config['tbl_campaigns'] . " AS c\n\t\tWHERE\n\t\t\tc.clientid = " . $clientid . " AND\n\t\t\tc.campaignid = b.campaignid\n\t");
    while ($row = phpAds_dbFetchArray($idresult)) {
        $bannerids[] = "bannerid = " . $row['bannerid'];
    }
    $res_query = "\n\t\tSELECT\n\t\t\tDATE_FORMAT(day, '" . $date_format . "') as day,\n\t\t\tSUM(views) AS adviews,\n\t\t\tSUM(clicks) AS adclicks\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_adstats'] . "\n\t\tWHERE\n\t\t\t(" . implode(' OR ', $bannerids) . ")\n\t\tGROUP BY\n\t\t\tday\n\t";
    $res_banners = phpAds_dbQuery($res_query) or phpAds_sqlDie();
    while ($row_banners = phpAds_dbFetchArray($res_banners)) {
        $stats[$row_banners['day']]['views'] = $row_banners['adviews'];
        $stats[$row_banners['day']]['clicks'] = $row_banners['adclicks'];
    }
    echo $strClient . ": " . strip_tags(phpAds_getClientName($clientid)) . "\n\n";
    echo $strDay . $delimiter . $strViews . $delimiter . $strClicks . $delimiter . $strCTRShort . "\n";
    $totalclicks = 0;
    $totalviews = 0;
    if (isset($stats) && is_array($stats)) {
        for (reset($stats); $key = key($stats); next($stats)) {
            $row = array();
            //$key = implode('/',array_reverse(split('[-]',$key)));
            $row[] = $key;
            $row[] = $stats[$key]['views'];
            $row[] = $stats[$key]['clicks'];
            $row[] = phpAds_buildCTR($stats[$key]['views'], $stats[$key]['clicks']);
            echo implode($delimiter, $row) . "\n";
            $totalclicks += $stats[$key]['clicks'];
            $totalviews += $stats[$key]['views'];
        }
    }
    echo "\n";
    echo $strTotal . $delimiter . $totalviews . $delimiter . $totalclicks . $delimiter . phpAds_buildCTR($totalviews, $totalclicks) . "\n";
}
    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);
        echo "&nbsp;<img src='images/" . $phpAds_TextDirection . "/caret-rs.gif'>&nbsp;";
        echo "<img src='images/icon-campaign.gif' align='absmiddle'>&nbsp;<b>" . $strUntitled . "</b><br><br><br>";
        phpAds_ShowSections(array("4.1.3.2"));
    } else {
        // New campaign
        phpAds_PageHeader("4.1.3.1");
        echo "<img src='images/icon-client.gif' align='absmiddle'>&nbsp;" . phpAds_getClientName($clientid);
        echo "&nbsp;<img src='images/" . $phpAds_TextDirection . "/caret-rs.gif'>&nbsp;";
        echo "<img src='images/icon-campaign.gif' align='absmiddle'>&nbsp;<b>" . $strUntitled . "</b><br><br><br>";
        phpAds_ShowSections(array("4.1.3.1"));
    }
}
if ($campaignid != "" || isset($move) && $move == 't') {
    // Edit or Convert
    // Fetch exisiting settings
    // Parent setting for converting, campaign settings for editing
    if ($campaignid != "") {
        $ID = $campaignid;
    }
    if (isset($move) && $move == 't') {
        if (isset($clientid) && $clientid != "") {
            $ID = $clientid;
function phpAds_getParentClientName($campaignid)
{
    $campaign_details = phpAds_getCampaignDetails($campaignid);
    return phpAds_getClientName($campaign_details['clientid']);
}
        $query = "SELECT clientid,clientname" . " FROM " . $phpAds_config['tbl_clients'] . " WHERE clientid != " . $clientid;
    } elseif (phpAds_isUser(phpAds_Agency)) {
        $query = "SELECT clientid,clientname" . " FROM " . $phpAds_config['tbl_clients'] . " WHERE clientid != " . $clientid . " AND agencyid=" . phpAds_getUserID();
    }
    $res = phpAds_dbQuery($query) or phpAds_sqlDie();
    while ($row = phpAds_dbFetchArray($res)) {
        $extra .= "\t\t\t\t\t<option value='" . $row['clientid'] . "'>" . phpAds_buildName($row['clientid'], $row['clientname']) . "</option>\n";
    }
    $extra .= "\t\t\t\t</select>&nbsp;\n";
    $extra .= "\t\t\t\t<input type='image' src='images/" . $phpAds_TextDirection . "/go_blue.gif'><br>\n";
    $extra .= "\t\t\t\t<img src='images/break.gif' height='1' width='160' vspace='4'><br>\n";
    $extra .= "\t\t\t\t<img src='images/icon-recycle.gif' align='absmiddle'>\n";
    $extra .= "\t\t\t\t<a href='tracker-delete.php?clientid={$clientid}&trackerid={$trackerid}&returnurl=advertiser-trackers.php'" . phpAds_DelConfirm($strConfirmDeleteTracker) . ">{$strDelete}</a><br>\n";
    $extra .= "\t\t\t\t</form>\n";
    phpAds_PageHeader("4.1.4.3", $extra);
    echo "\t\t\t\t<img src='images/icon-advertiser.gif' align='absmiddle'>&nbsp;" . phpAds_getClientName($clientid) . "\n";
    echo "\t\t\t\t<img src='images/" . $phpAds_TextDirection . "/caret-rs.gif'>\n";
    echo "\t\t\t\t<img src='images/icon-tracker.gif' align='absmiddle'>\n";
    echo "\t\t\t\t<b>" . phpAds_getTrackerName($trackerid) . "</b><br><br><br>\n";
    phpAds_ShowSections(array("4.1.4.2", "4.1.4.3", "4.1.4.5", "4.1.4.4"));
}
if (isset($trackerid) && $trackerid != '') {
    $res = phpAds_dbQuery("SELECT *" . " FROM " . $phpAds_config['tbl_trackers'] . " WHERE trackerid=" . $trackerid) or phpAds_sqlDie();
    if (phpAds_dbNumRows($res)) {
        $tracker = phpAds_dbFetchArray($res);
    }
}
$tabindex = 1;
// Header
echo "\t\t\t\t<table width='100%' border='0' align='center' cellspacing='0' cellpadding='0'>\n";
echo "\t\t\t\t<tr height='25'>\n";
Beispiel #6
0
/* HTML framework                                        */
/*-------------------------------------------------------*/
if ($agencyid != '') {
    addPageTools($agencyid);
    if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
        OA_Admin_Menu::setAgencyPageContext($agencyid, 'agency-edit.php');
        $doAgency = OA_Dal::staticGetDO('agency', $agencyid);
        MAX_displayInventoryBreadcrumbs(array(array("name" => $doAgency->name)), "agency");
        phpAds_PageHeader("4.1.3");
        phpAds_ShowSections(array("4.1.2", "4.1.3"));
    } else {
        phpAds_PageHeader('4.4');
        phpAds_ShowSections(array("4.1", "4.2", "4.3", "4.4"));
    }
} else {
    MAX_displayInventoryBreadcrumbs(array(array("name" => phpAds_getClientName($agencyid))), "agency");
    phpAds_PageHeader("4.1.1");
    phpAds_ShowSections(array("4.1.1"));
}
$tabindex = 1;
/*-------------------------------------------------------*/
/* Main code                                             */
/*-------------------------------------------------------*/
require_once MAX_PATH . '/lib/OA/Admin/Template.php';
$oTpl = new OA_Admin_Template('agency-access.html');
// Ensure that any template variables for the authentication plugin are set
$oPlugin = OA_Auth::staticGetAuthPlugin();
$oPlugin->setTemplateVariables($oTpl);
$oTpl->assign('infomessage', OA_Session::getMessage());
$oTpl->assign('entityIdName', 'agencyid');
$oTpl->assign('entityIdValue', $agencyid);
    } 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']) {
        echo "<br><br>";
        // Show welcome message
        if (!empty($phpAds_client_welcome_msg)) {
            echo $phpAds_client_welcome_msg;
        } else {
            include 'templates/welcome-advertiser.html';
        }
        echo "<br><br>";
    }
    phpAds_ShowSections(array("1.1", "1.2"));
function Plugin_ClienthistoryExecute($clientid, $delimiter = ",", $quotes = "")
{
    global $phpAds_config, $date_format;
    global $strClient, $strTotal, $strDay, $strViews, $strClicks, $strCTRShort;
    // Expand delimiter and quotes
    if ($delimiter == 't') {
        $delimiter = "\t";
    }
    if ($quotes == '1') {
        $quotes = "'";
    }
    if ($quotes == '2') {
        $quotes = '"';
    }
    header("Content-type: application/csv");
    header("Content-Disposition: inline; filename=\"publisherhistory.csv\"");
    $idresult = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tb.bannerid\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_banners'] . " AS b,\n\t\t\t" . $phpAds_config['tbl_clients'] . " AS c\n\t\tWHERE\n\t\t\tc.parent = " . $clientid . " AND\n\t\t\tc.clientid = b.clientid\n\t");
    while ($row = phpAds_dbFetchArray($idresult)) {
        $bannerids[] = $row['bannerid'];
    }
    if (count($bannerids)) {
        if ($phpAds_config['compact_stats']) {
            $res_query = "\n\t\t\t\tSELECT\n\t\t\t\t\tDATE_FORMAT(day, '%Y%m%d') as date,\n\t\t\t\t\tDATE_FORMAT(day, '{$date_format}') as date_formatted,\n\t\t\t\t\tSUM(views) AS adviews,\n\t\t\t\t\tSUM(clicks) AS adclicks\n\t\t\t\tFROM\n\t\t\t\t\t" . $phpAds_config['tbl_adstats'] . "\n\t\t\t\tWHERE\n\t\t\t\t\tbannerid IN (" . implode(', ', $bannerids) . ")\n\t\t\t\tGROUP BY\n\t\t\t\t\tday\n\t\t\t\tORDER BY\n\t\t\t\t\tdate\n\t\t\t";
            $res_banners = phpAds_dbQuery($res_query) or phpAds_sqlDie();
            while ($row_banners = phpAds_dbFetchArray($res_banners)) {
                $stats[$row_banners['date_formatted']]['views'] = $row_banners['adviews'];
                $stats[$row_banners['date_formatted']]['clicks'] = $row_banners['adclicks'];
            }
        } else {
            $res_query = "\n\t\t\t\tSELECT\n\t\t\t\t\tDATE_FORMAT(t_stamp, '%Y%m%d') as date,\n\t\t\t\t\tDATE_FORMAT(t_stamp, '" . $date_format . "') as date_formatted,\n\t\t\t\t\tcount(bannerid) as adviews\n\t\t\t\tFROM\n\t\t\t\t\t" . $phpAds_config['tbl_adviews'] . "\n\t\t\t\tWHERE\n\t\t\t\t\tbannerid IN (" . implode(', ', $bannerids) . ")\n\t\t\t\tGROUP BY\n\t\t\t\t\tdate, date_formatted\n\t\t\t\tORDER BY\n\t\t\t\t\tdate\n\t\t\t";
            $res_banners = phpAds_dbQuery($res_query) or phpAds_sqlDie();
            while ($row_banners = phpAds_dbFetchArray($res_banners)) {
                $stats[$row_banners['date_formatted']]['views'] = $row_banners['adviews'];
                $stats[$row_banners['date_formatted']]['clicks'] = 0;
            }
            $res_query = "\n\t\t\t\tSELECT\n\t\t\t\t\tDATE_FORMAT(t_stamp, '%Y%m%d') as date,\n\t\t\t\t\tDATE_FORMAT(t_stamp, '" . $date_format . "') as date_formatted,\n\t\t\t\t\tcount(bannerid) as adclicks\n\t\t\t\tFROM\n\t\t\t\t\t" . $phpAds_config['tbl_adclicks'] . "\n\t\t\t\tWHERE\n\t\t\t\t\tbannerid IN (" . implode(', ', $bannerids) . ")\n\t\t\t\tGROUP BY\n\t\t\t\t\tdate, date_formatted\n\t\t\t\tORDER BY\n\t\t\t\t\tdate\n\t\t\t";
            $res_banners = phpAds_dbQuery($res_query) or phpAds_sqlDie();
            while ($row_banners = phpAds_dbFetchArray($res_banners)) {
                $stats[$row_banners['date_formatted']]['clicks'] = $row_banners['adclicks'];
            }
        }
    }
    echo $quotes . $strClient . ": " . phpAds_getClientName($clientid, false) . $quotes . "\n\n";
    echo $quotes . $strDay . $quotes . $delimiter . $quotes . $strViews . $quotes;
    echo $delimiter . $quotes . $strClicks . $quotes . $delimiter . $quotes . $strCTRShort . $quotes . "\n";
    $totalclicks = 0;
    $totalviews = 0;
    if (isset($stats) && is_array($stats)) {
        foreach (array_keys($stats) as $key) {
            $row = array();
            $row[] = $quotes . $key . $quotes;
            $row[] = $quotes . $stats[$key]['views'] . $quotes;
            $row[] = $quotes . $stats[$key]['clicks'] . $quotes;
            $row[] = $quotes . phpAds_buildCTR($stats[$key]['views'], $stats[$key]['clicks']) . $quotes;
            echo implode($delimiter, $row) . "\n";
            $totalclicks += $stats[$key]['clicks'];
            $totalviews += $stats[$key]['views'];
        }
    }
    echo "\n";
    echo $quotes . $strTotal . $quotes . $delimiter . $quotes . $totalviews . $quotes . $delimiter;
    echo $quotes . $totalclicks . $quotes . $delimiter . $quotes . phpAds_buildCTR($totalviews, $totalclicks) . $quotes . "\n";
}
    $doClients->whereAdd('clientid <>' . $trackerid);
    if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
        $doClients->agencyid = OA_Permission::getAgencyId();
    }
    $doClients->find();
    $aOtherAdvertisers = array();
    while ($doClients->fetch() && ($row = $doClients->toArray())) {
        $aOtherAdvertisers[] = $row;
    }
    MAX_displayNavigationTracker($clientid, $trackerid, $aOtherAdvertisers);
} else {
    if (isset($move) && $move == 't') {
        // Convert client to tracker
        // TODO: is this still used? if not, we may want to remove it
        phpAds_PageHeader("4.1.4.4");
        echo "<img src='" . OX::assetPath() . "/images/icon-advertiser.gif' align='absmiddle'>&nbsp;" . phpAds_getClientName($clientid);
        echo "&nbsp;<img src='" . OX::assetPath() . "/images/" . $phpAds_TextDirection . "/caret-rs.gif'>&nbsp;";
        echo "<img src='" . OX::assetPath() . "/images/icon-tracker.gif' align='absmiddle'>&nbsp;<b>" . $strUntitled . "</b><br /><br /><br />";
        phpAds_ShowSections(array("4.1.4.4"));
    } else {
        // New tracker
        // TODO: is this still used? if not, we may want to remove it
        phpAds_PageHeader("4.1.4.1");
        MAX_displayTrackerBreadcrumbs(null, $clientid);
        phpAds_ShowSections(array("4.1.4.1"));
    }
}
if ($trackerid != "" || isset($move) && $move == 't') {
    // Edit or Convert
    // Fetch exisiting settings
    // Parent setting for converting, tracker settings for editing
        $navdirection = '';
    }
    // Get other advertisers
    if (phpAds_isUser(phpAds_Admin)) {
        $query = "SELECT * FROM " . $phpAds_config['tbl_clients'] . phpAds_getClientListOrder($navorder, $navdirection);
    } elseif (phpAds_isUser(phpAds_Agency)) {
        $query = "SELECT * FROM " . $phpAds_config['tbl_clients'] . " WHERE agencyid=" . $Session['userid'] . phpAds_getClientListOrder($navorder, $navdirection);
    }
    $res = phpAds_dbQuery($query) or phpAds_sqlDie();
    while ($row = phpAds_dbFetchArray($res)) {
        phpAds_PageContext(phpAds_buildName($row['clientid'], $row['clientname']), "advertiser-trackers.php?clientid=" . $row['clientid'], $clientid == $row['clientid']);
    }
    phpAds_PageShortcut($strClientHistory, 'stats-advertiser-history.php?clientid=' . $clientid, 'images/icon-statistics.gif');
    phpAds_PageHeader("4.1.4");
    echo "\t\t\t\t<img src='images/icon-advertiser.gif' align='absmiddle'>&nbsp;\n";
    echo "\t\t\t\t<b>" . phpAds_getClientName($clientid) . "</b>\n";
    echo "\t\t\t\t<br><br><br>\n";
    phpAds_ShowSections(array("4.1.2", "4.1.3", "4.1.4"));
}
/*********************************************************/
/* Main code                                             */
/*********************************************************/
// Get clients & campaign and build the tree
$res_trackers = phpAds_dbQuery("SELECT *" . " FROM " . $phpAds_config['tbl_trackers'] . " WHERE clientid=" . $clientid . phpAds_getTrackerListOrder($listorder, $orderdirection)) or phpAds_sqlDie();
if (phpAds_isUser(phpAds_Admin) || phpAds_isUser(phpAds_Agency) || phpAds_isAllowed(phpAds_AddTracker)) {
    echo "\t\t\t\t<img src='images/icon-tracker-new.gif' border='0' align='absmiddle'>\n";
    echo "\t\t\t\t<a href='tracker-edit.php?clientid=" . $clientid . "' accesskey='" . $keyAddNew . "'>" . $strAddTracker_Key . "</a>&nbsp;&nbsp;\n";
    phpAds_ShowBreak();
}
echo "\t\t\t\t<br><br>\n";
echo "\t\t\t\t<table border='0' width='100%' cellpadding='0' cellspacing='0'>\n";
    phpAds_ShowSections(array("5.5.2"));
    // Do not get this information if the page
    // is the result of an error message
    if (!isset($agency)) {
        $res = phpAds_dbQuery("SELECT * FROM " . $phpAds_config['tbl_agency'] . " WHERE agencyid=" . $agencyid) or phpAds_sqlDie();
        if (phpAds_dbNumRows($res)) {
            $agency = phpAds_dbFetchArray($res);
        }
        // Set password to default value
        if ($agency['password'] != '') {
            $agency['password'] = '******';
        }
    }
} else {
    phpAds_PageHeader("5.5.1");
    echo "<img src='images/icon-advertiser.gif' align='absmiddle'>&nbsp;<b>" . phpAds_getClientName($agencyid) . "</b><br><br><br>";
    //phpAds_ShowSections(array("5.1", "5.3", "5.4", "5.2", "5.5"));
    phpAds_ShowSections(array("5.5.1"));
    // Do not set this information if the page
    // is the result of an error message
    if (!isset($agency)) {
        $agency['name'] = $strUntitled;
        $agency['contact'] = '';
        $agency['email'] = '';
        $agency['username'] = '';
        $agency['password'] = '';
    }
}
$tabindex = 1;
/*********************************************************/
/* Main code                                             */
function phpAds_getParentName($clientid, $html = true)
{
    global $phpAds_config;
    global $clientCache;
    if (isset($clientCache[$clientid]) && is_array($clientCache[$clientid])) {
        $row = $clientCache[$clientid];
    } 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_clients'] . "\n\t\t\tWHERE\n\t\t\t\tclientid = '{$clientid}'\n\t\t") or phpAds_sqlDie();
        $row = phpAds_dbFetchArray($res);
        $clientCache[$clientid] = $row;
    }
    return phpAds_getClientName($row['parent'], $html);
}