function phpAds_getAffiliateName($affiliateid)
{
    $conf = $GLOBALS['_MAX']['CONF'];
    global $affiliateCache;
    global $strUntitled;
    if ($affiliateid != '' && $affiliateid != 0) {
        if (isset($affiliateCache[$affiliateid]) && is_array($affiliateCache[$affiliateid])) {
            $row = $affiliateCache[$affiliateid];
        } else {
            $doAffiliates = OA_Dal::staticGetDO('affiliates', $affiliateid);
            $row = $doAffiliates->toArray();
            $affiliateCache[$affiliateid] = $row;
        }
        return phpAds_BuildAffiliateName($affiliateid, $row['name']);
    } else {
        return $strUntitled;
    }
}
/*-------------------------------------------------------*/
/* HTML framework                                        */
/*-------------------------------------------------------*/
if (!isset($variables)) {
    if (isset($session['prefs']['tracker-variables.php']['variables']) && $session['prefs']['tracker-variables.php']['trackerid'] == $trackerid) {
        $variables = $session['prefs']['tracker-variables.php']['variables'];
    }
}
if (!empty($trackerid)) {
    // Get publisher list
    $dalAffiliates = OA_Dal::factoryDAL('affiliates');
    $rsAffiliates = $dalAffiliates->getPublishersByTracker($trackerid);
    $rsAffiliates->find();
    $publishers = array();
    while ($rsAffiliates->fetch() && ($row = $rsAffiliates->toArray())) {
        $publishers[$row['affiliateid']] = strip_tags(phpAds_BuildAffiliateName($row['affiliateid'], $row['name']));
    }
    if (!isset($variablemethod)) {
        // get variable method
        $doTrackers = OA_Dal::factoryDO('trackers');
        if ($doTrackers->get($trackerid)) {
            $variablemethod = $doTrackers->variablemethod;
        }
    }
    if (!isset($variables)) {
        // get variables from db
        $doVariables = OA_Dal::factoryDO('variables');
        $doVariables->trackerid = $trackerid;
        $doVariables->find();
        $variables = array();
        while ($doVariables->fetch() && ($vars = $doVariables->toArray())) {
function phpAds_getAffiliateName($affiliateid, $html = true)
{
    global $phpAds_config;
    global $affiliateCache;
    global $strUntitled;
    if ($affiliateid != '' && $affiliateid != 0) {
        if (isset($affiliateCache[$affiliateid]) && is_array($affiliateCache[$affiliateid])) {
            $row = $affiliateCache[$affiliateid];
        } else {
            $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_affiliates'] . "\n\t\t\t\tWHERE\n\t\t\t\t\taffiliateid = '{$affiliateid}'\n\t\t\t") or phpAds_sqlDie();
            $row = phpAds_dbFetchArray($res);
            $affiliateCache[$affiliateid] = $row;
        }
        return phpAds_BuildAffiliateName($affiliateid, $row['name'], $html);
    } else {
        return $strUntitled;
    }
}