function phpAds_LoadDbConfig($agencyid = 0)
{
    global $phpAds_config, $phpAds_settings_information;
    if ((!empty($GLOBALS['phpAds_db_link']) || phpAds_dbConnect()) && isset($phpAds_config['tbl_config'])) {
        $query = "SELECT *" . " FROM " . $phpAds_config['tbl_config'] . " WHERE agencyid=" . $agencyid;
        if ($res = phpAds_dbQuery($query)) {
            if ($row = phpAds_dbFetchArray($res, 0)) {
                while (list($k, $v) = each($phpAds_settings_information)) {
                    if (!$v['sql'] || !isset($row[$k])) {
                        continue;
                    }
                    switch ($v['type']) {
                        case 'boolean':
                            $row[$k] = $row[$k] == 't';
                            break;
                        case 'integer':
                            $row[$k] = (int) $row[$k];
                            break;
                        case 'array':
                            $row[$k] = unserialize($row[$k]);
                            break;
                        case 'float':
                            $row[$k] = (double) $row[$k];
                            break;
                    }
                    $phpAds_config[$k] = $row[$k];
                }
                reset($phpAds_settings_information);
                return true;
            }
        }
    }
    return false;
}
function Plugin_GlobalhistoryExecute($delimiter = ",")
{
    global $phpAds_config, $date_format;
    global $strGlobalHistory, $strTotal, $strDay, $strViews, $strClicks, $strCTRShort;
    header("Content-type: application/csv\nContent-Disposition: \"inline; filename=globalhistory.csv\"");
    if (phpAds_isUser(phpAds_Admin)) {
        $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\tGROUP BY\n\t\t\tday\n\t";
    } else {
        $res_query = "SELECT\n\t\t\t\t\t\tDATE_FORMAT(s.day, '" . $date_format . "') as day,\n\t\t\t\t\t\tSUM(s.views) AS adviews,\n\t\t\t\t\t\tSUM(s.clicks) AS adclicks\n\t\t\t\t\tFROM\n\t\t\t\t\t\t" . $phpAds_config['tbl_adstats'] . " \tas s,\n\t\t\t\t\t\t" . $phpAds_config['tbl_banners'] . " \tas b,\n\t\t\t\t\t\t" . $phpAds_config['tbl_campaigns'] . " as m,\n\t\t\t\t\t\t" . $phpAds_config['tbl_clients'] . " \tas c\n\t\t\t\t\tWHERE\n\t\t\t\t\t\ts.bannerid \t\t= b.bannerid AND\n\t\t\t\t\t\tb.campaignid \t= m.campaignid AND\n\t\t\t\t\t\tm.clientid \t\t= c.clientid AND\n\t\t\t\t\t\tc.agencyid \t\t= " . phpAds_getUserID() . "\n\t\t\t\t\tGROUP BY\n\t\t\t\t\t\tday";
    }
    $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 $strGlobalHistory . "\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";
}
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_AffiliatehistoryExecute($affiliateid, $delimiter = ",")
{
    global $phpAds_config, $date_format;
    global $strAffiliate, $strTotal, $strDay, $strViews, $strClicks, $strCTRShort;
    header("Content-type: application/csv\nContent-Disposition: \"inline; filename=affiliatehistory.csv\"");
    $idresult = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tzoneid\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_zones'] . "\n\t\tWHERE\n\t\t\taffiliateid = '" . $affiliateid . "'\n\t");
    while ($row = phpAds_dbFetchArray($idresult)) {
        $zoneids[] = "zoneid = " . $row['zoneid'];
    }
    $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 ', $zoneids) . ")\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 $strAffiliate . ": " . strip_tags(phpAds_getAffiliateName($affiliateid)) . "\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";
}
function phpAds_getCampaign($query)
{
    $campaigns = array();
    $res = phpAds_dbQuery($query) or phpAds_sqlDie();
    while ($row = phpAds_dbFetchArray($res)) {
        $campaigns[$row['campaignid']] = $row;
    }
    return $campaigns;
}
function Plugin_GlobalhistoryExecute($delimiter = 't', $quotes = '')
{
    global $phpAds_config, $date_format;
    global $strGlobalHistory, $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\"");
    if ($phpAds_config['compact_stats']) {
        $res_query = "\n\t\t\tSELECT\n\t\t\t\tDATE_FORMAT(day, '%Y%m%d') as date,\n\t\t\t\tDATE_FORMAT(day, '{$date_format}') as date_formatted,\n\t\t\t\tSUM(views) AS adviews,\n\t\t\t\tSUM(clicks) AS adclicks\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_adstats'] . "\n\t\t\tGROUP BY\n\t\t\t\tday\n\t\t\tORDER BY\n\t\t\t\tdate\n\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\tSELECT\n\t\t\t\tDATE_FORMAT(t_stamp, '%Y%m%d') as date,\n\t\t\t\tDATE_FORMAT(t_stamp, '" . $date_format . "') as date_formatted,\n\t\t\t\tcount(bannerid) as adviews\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_adviews'] . "\n\t\t\tGROUP BY\n\t\t\t\tdate, date_formatted\n\t\t\tORDER BY\n\t\t\t\tdate\n\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\tSELECT\n\t\t\t\tDATE_FORMAT(t_stamp, '%Y%m%d') as date,\n\t\t\t\tDATE_FORMAT(t_stamp, '" . $date_format . "') as date_formatted,\n\t\t\t\tcount(bannerid) as adclicks\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_adclicks'] . "\n\t\t\tGROUP BY\n\t\t\t\tdate, date_formatted\n\t\t\tORDER BY\n\t\t\t\tdate\n\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 . $strGlobalHistory . $quotes . "\n\n";
    echo $quotes . $strDay . $quotes . $delimiter . $quotes . $strViews . $quotes . $delimiter;
    echo $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";
}
function phpAds_showBanners()
{
    global $phpAds_config;
    global $strUntitled, $strName, $strID, $strWeight;
    global $strProbability, $strPriority, $strRecalculatePriority;
    global $phpAds_TextDirection;
    $res = phpAds_dbQuery("\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\tORDER BY\n\t\t\tpriority DESC\n\t");
    $rows = array();
    $prioritysum = 0;
    while ($tmprow = phpAds_dbFetchArray($res)) {
        if ($tmprow['priority']) {
            $prioritysum += $tmprow['priority'];
            $rows[$tmprow['bannerid']] = $tmprow;
        }
    }
    if (is_array($rows)) {
        $i = 0;
        // Header
        echo "<table width='100%' border='0' align='center' cellspacing='0' cellpadding='0'>";
        echo "<tr height='25'>";
        echo "<td height='25'><b>&nbsp;&nbsp;" . $strName . "</b></td>";
        echo "<td height='25'><b>" . $strID . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
        echo "<td height='25'><b>" . $strPriority . "</b></td>";
        echo "<td height='25'><b>" . $strProbability . "</b></td>";
        echo "</tr>";
        echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
        // Banners
        foreach (array_keys($rows) as $key) {
            $name = phpAds_getBannerName($rows[$key]['bannerid'], 60, false);
            if ($i > 0) {
                echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break-l.gif' height='1' width='100%'></td></tr>";
            }
            echo "<tr height='25' " . ($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . ">";
            echo "<td height='25'>";
            echo "&nbsp;&nbsp;";
            // Banner icon
            if ($rows[$key]['storagetype'] == 'html') {
                echo "<img src='images/icon-banner-html.gif' align='absmiddle'>&nbsp;";
            } elseif ($rows[$key]['storagetype'] == 'url') {
                echo "<img src='images/icon-banner-url.gif' align='absmiddle'>&nbsp;";
            } else {
                echo "<img src='images/icon-banner-stored.gif' align='absmiddle'>&nbsp;";
            }
            // Name
            echo $name;
            echo "</td>";
            echo "<td height='25'>" . $rows[$key]['bannerid'] . "</td>";
            echo "<td height='25'>" . $rows[$key]['priority'] . "</td>";
            echo "<td height='25'>" . number_format($rows[$key]['priority'] / $prioritysum * 100, $phpAds_config['percentage_decimals']) . "%</td>";
            echo "</tr>";
            $i++;
        }
        // Footer
        echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
        echo "</table>";
    }
}
function phpAds_MaintenanceSelection($section)
{
    global $phpAds_config;
    global $phpAds_TextDirection;
    global $strChooseSection, $strPriority, $strCache, $strBanners, $strStats, $strStorage, $strMaintenance;
    if ($phpAds_config['compact_stats']) {
        // Determine left over verbose stats
        $viewresult = phpAds_dbQuery("SELECT COUNT(*) AS cnt FROM " . $phpAds_config['tbl_adviews']);
        $viewrow = phpAds_dbFetchArray($viewresult);
        if (isset($viewrow["cnt"]) && $viewrow["cnt"] != '') {
            $verboseviews = $viewrow["cnt"];
        } else {
            $verboseviews = 0;
        }
        $clickresult = phpAds_dbQuery("SELECT COUNT(*) AS cnt FROM " . $phpAds_config['tbl_adclicks']);
        $clickrow = phpAds_dbFetchArray($viewresult);
        if (isset($clickrow["cnt"]) && $clickrow["cnt"] != '') {
            $verboseclicks = $clickrow["cnt"];
        } else {
            $verboseclicks = 0;
        }
    }
    ?>
<script language="JavaScript">
<!--
function maintenance_goto_section()
{
	s = document.maintenance_selection.section.selectedIndex;

	s = document.maintenance_selection.section.options[s].value;
	document.location = 'maintenance-' + s + '.php';
}
// -->
</script>
<?php 
    echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
    echo "<tr><form name='maintenance_selection'><td height='35'>";
    echo "<b>" . $strChooseSection . ":&nbsp;</b>";
    echo "<select name='section' onChange='maintenance_goto_section();'>";
    echo "<option value='maintenance'" . ($section == 'maintenance' ? ' selected' : '') . ">" . $strMaintenance . "</option>";
    echo "<option value='banners'" . ($section == 'banners' ? ' selected' : '') . ">" . $strBanners . "</option>";
    echo "<option value='priority'" . ($section == 'priority' ? ' selected' : '') . ">" . $strPriority . "</option>";
    if ($phpAds_config['compact_stats'] && ($verboseviews > 0 || $verboseclicks > 0)) {
        echo "<option value='stats'" . ($section == 'stats' ? ' selected' : '') . ">" . $strStats . "</option>";
    }
    if ($phpAds_config['type_web_allow'] == true && ($phpAds_config['type_web_mode'] == 0 && $phpAds_config['type_web_dir'] != '' || $phpAds_config['type_web_mode'] == 1 && $phpAds_config['type_web_ftp'] != '') && $phpAds_config['type_web_url'] != '') {
        echo "<option value='storage'" . ($section == 'storage' ? ' selected' : '') . ">" . $strStorage . "</option>";
    }
    if ($phpAds_config['delivery_caching'] != 'none') {
        echo "<option value='cache'" . ($section == 'zones' ? ' selected' : '') . ">" . $strCache . "</option>";
    }
    echo "</select>&nbsp;<a href='javascript:void(0)' onClick='maintenance_goto_section();'>";
    echo "<img src='images/" . $phpAds_TextDirection . "/go_blue.gif' border='0'></a>";
    echo "</td></form></tr>";
    echo "</table>";
    phpAds_ShowBreak();
}
Exemplo n.º 9
0
function phpAds_cacheInfo()
{
    global $phpAds_config;
    $result = array();
    $cacheres = phpAds_dbQuery("SELECT * FROM " . $phpAds_config['tbl_cache']);
    while ($cacherow = phpAds_dbFetchArray($cacheres)) {
        $result[$cacherow['cacheid']] = strlen($cacherow['content']);
    }
    return $result;
}
Exemplo n.º 10
0
function phpAds_cacheInfo()
{
    global $phpAds_config;
    $result = array();
    $cacheres = phpAds_dbQuery("SELECT cacheid, LENGTH(content) AS len FROM " . $phpAds_config['tbl_cache']);
    while ($cacherow = phpAds_dbFetchArray($cacheres)) {
        $result[$cacherow['cacheid']] = $cacherow['len'];
    }
    return $result;
}
Exemplo n.º 11
0
function phpAds_getSourceStats($query, $listorder, $orderdirection)
{
    $res_stats = phpAds_dbQuery($query) or phpAds_sqlDie();
    while ($row_stats = phpAds_dbFetchArray($res_stats)) {
        $source = $row_stats['source'];
        if (strlen($source) > 0) {
            $sources = phpAds_buildSourceArray($sources, $source, '', $row_stats);
        }
    }
    // Sort the array
    $ascending = !($orderdirection == 'down' || $orderdirection == '');
    phpAds_qsort($sources, $listorder, $ascending);
}
function phpAds_SessionDataFetch()
{
    global $phpAds_config;
    global $Session;
    if (isset($_COOKIE['sessionID']) && preg_match('/^[0-9a-f]+$/D', $_COOKIE['sessionID'])) {
        $result = phpAds_dbQuery("SELECT sessiondata FROM " . $phpAds_config['tbl_session'] . " WHERE sessionid='" . addslashes($_COOKIE['sessionID']) . "'" . " AND UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(lastused) < 3600");
        if ($row = phpAds_dbFetchArray($result)) {
            $Session = unserialize($row['sessiondata']);
            // Reset LastUsed, prevent from timing out
            phpAds_dbQuery("UPDATE " . $phpAds_config['tbl_session'] . " SET lastused = NOW() WHERE sessionid = '" . addslashes($_COOKIE['sessionID']) . "'");
        }
    } else {
        $_COOKIE['sessionID'] = '';
        return False;
    }
}
Exemplo n.º 13
0
 function _getTrackerArray()
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     $where = "c.clientid = t.clientid";
     if (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $where .= " AND c.agencyid = " . OA_Permission::getEntityId();
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
         $where .= " AND t.clientid = " . OA_Permission::getEntityId();
     }
     $query = "\n            SELECT\n                c.clientname AS client_name,\n                c.clientid AS client_id,\n                t.trackername AS tracker_name,\n                t.trackerid AS tracker_id\n            FROM\n                {$conf['table']['trackers']} AS t,\n                {$conf['table']['clients']} AS c\n            WHERE\n                {$where}\n            ORDER BY\n                c.clientname,t.trackername\n        ";
     $res = phpAds_dbQuery($query);
     while ($row = phpAds_dbFetchArray($res)) {
         $trackerArray[$row['tracker_id']] = "<span dir='" . $GLOBALS['phpAds_TextDirection'] . "'>[id" . $row['client_id'] . "] " . $row['client_name'] . " - [id" . $row['tracker_id'] . "] " . $row['tracker_name'] . "</span> ";
     }
     return $trackerArray;
 }
Exemplo n.º 14
0
function phpAds_DeleteBanner($bannerid)
{
    global $phpAds_config;
    // Cleanup webserver stored image
    $res = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tstoragetype, filename\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\tWHERE\n\t\t\tbannerid = '{$bannerid}'\n\t") or phpAds_sqlDie();
    if ($row = phpAds_dbFetchArray($res)) {
        if (($row['storagetype'] == 'web' || $row['storagetype'] == 'sql') && $row['filename'] != '') {
            phpAds_ImageDelete($row['storagetype'], $row['filename']);
        }
    }
    // Delete banner
    $res = phpAds_dbQuery("\n\t\tDELETE FROM\n\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\tWHERE\n\t\t\tbannerid = '{$bannerid}'\n\t\t") or phpAds_sqlDie();
    // Delete banner ACLs
    $res = phpAds_dbQuery("\n\t\tDELETE FROM\n\t\t\t" . $phpAds_config['tbl_acls'] . "\n\t\tWHERE\n\t\t\tbannerid = '{$bannerid}'\n\t\t") or phpAds_sqlDie();
    // Delete statistics for this banner
    phpAds_deleteStatsByBannerID($bannerid);
}
Exemplo n.º 15
0
 /**
  * @todo Handle cases where user is not Admin, Agency or Advertiser
  */
 function _getPublisherArray($orderBy = null)
 {
     $conf = $GLOBALS['_MAX']['CONF'];
     if (OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
         $query = "SELECT affiliateid,name" . " FROM " . $conf['table']['prefix'] . $conf['table']['affiliates'];
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) {
         $query = "SELECT affiliateid,name" . " FROM " . $conf['table']['prefix'] . $conf['table']['affiliates'] . " WHERE agencyid=" . OA_Permission::getEntityId();
     } elseif (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
         $query = "SELECT affiliateid,name" . " FROM " . $conf['table']['prefix'] . $conf['table']['affiliates'] . " WHERE affiliateid=" . OA_Permission::getEntityId();
     }
     $orderBy ? $query .= " ORDER BY {$orderBy} ASC" : 0;
     $res = phpAds_dbQuery($query);
     while ($row = phpAds_dbFetchArray($res)) {
         $affiliateArray[$row['affiliateid']] = phpAds_buildAffiliateName($row['affiliateid'], $row['name']);
     }
     return $affiliateArray;
 }
function phpAds_fetchJavascriptVariables($trackerid)
{
    global $phpAds_config;
    include phpAds_path . '/libraries/deliverycache/cache-' . $phpAds_config['delivery_caching'] . '.inc.php';
    // Get cache
    $cache = phpAds_cacheFetch('what=tracker:' . $trackerid);
    if (!$cache) {
        $variables_result = phpAds_dbQuery("\n\t\t\t\t\t\t\t\tSELECT \n\t\t\t\t\t\t\t\t\tvariableid,\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tvariabletype\n\t\t\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\t\t\t" . $phpAds_config['tbl_variables'] . "\n\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\ttrackerid='" . $trackerid . "'");
        while ($variable = phpAds_dbFetchArray($variables_result)) {
            $cache[$variable['variableid']] = array('name' => $variable['name'], 'variabletype' => $variable['variabletype']);
        }
        if (count(cache) > 0) {
            phpAds_cacheStore('what=tracker:' . $trackerid, $cache);
        } else {
            return;
        }
    }
    return $cache;
}
function phpAds_DeleteCampaign($campaignid)
{
    global $phpAds_config;
    // Delete Campaign
    $res = phpAds_dbQuery("\n\t\tDELETE FROM\n\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\tWHERE\n\t\t\tclientid = '{$campaignid}'\n\t") or phpAds_sqlDie();
    // Loop through each banner
    $res_banners = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tbannerid,\n\t\t\tstoragetype,\n\t\t\tfilename\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\tWHERE\n\t\t\tclientid = '{$campaignid}'\n\t") or phpAds_sqlDie();
    while ($row = phpAds_dbFetchArray($res_banners)) {
        // Cleanup stored images for each banner
        if (($row['storagetype'] == 'web' || $row['storagetype'] == 'sql') && $row['filename'] != '') {
            phpAds_ImageDelete($row['storagetype'], $row['filename']);
        }
        // Delete Banner ACLs
        phpAds_dbQuery("\n\t\t\tDELETE FROM\n\t\t\t\t" . $phpAds_config['tbl_acls'] . "\n\t\t\tWHERE\n\t\t\t\tbannerid = " . $row['bannerid'] . "\n\t\t") or phpAds_sqlDie();
        // Delete stats for each banner
        phpAds_deleteStats($row['bannerid']);
    }
    // Delete Banners
    phpAds_dbQuery("\n\t\tDELETE FROM\n\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\tWHERE\n\t\t\tclientid = '{$campaignid}'\n\t") or phpAds_sqlDie();
}
function phpAds_getSources($name = '', $parent = '')
{
    global $phpAds_config;
    if (strlen($parent) > 0) {
        $n = substr_count($parent, '/') + 2;
        $query = "SELECT" . " SUBSTRING_INDEX(SUBSTRING_INDEX(source,'/'," . $n . "),'/',-1) AS source_part" . ",COUNT(*) AS sum_views" . " FROM " . $phpAds_config['tbl_adviews'] . " WHERE source LIKE '" . $parent . "/%'" . " AND t_stamp > DATE_SUB(NOW(), INTERVAL 7 DAY)" . " GROUP BY source_part" . " ORDER BY sum_views DESC";
    } else {
        $query = "SELECT" . " SUBSTRING_INDEX(source, '/', 1) AS source_part" . ",COUNT(*) AS sum_views" . " FROM " . $phpAds_config['tbl_adviews'] . " WHERE t_stamp > DATE_SUB(NOW(), INTERVAL 7 DAY)" . " GROUP BY source_part" . " ORDER BY sum_views DESC";
    }
    $source_arr = array();
    $res_sources = phpAds_dbQuery($query) or phpAds_sqlDie();
    while ($row_sources = phpAds_dbFetchArray($res_sources)) {
        $source_arr[] = $row_sources;
        //echo "filing source: ".$row_sources['source']."...<br>\n";
        //phpAds_buildSourceArrayChildren($source_arr, $row_sources['source']);
    }
    // Sort the array
    //$ascending = !( ($orderdirection == 'down') || ($orderdirection == '') );
    //phpAds_sortSources($source_arr, $listorder, $ascending);
    return $source_arr;
}
function phpAds_getVerbose($base, $count)
{
    global $phpAds_config;
    $begin_timestamp = date('YmdHis', phpAds_makeTimestamp($base, $count * 60 * 60 * 24));
    $end_timestamp = date('YmdHis', phpAds_makeTimestamp($base, ($count + 1) * 60 * 60 * 24 - 1));
    // Get views
    $result = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tbannerid,\n\t\t\tzoneid,\n\t\t\tsource,\n\t\t\tHOUR(t_stamp) AS hour,\n\t\t\tCOUNT(*) AS qnt\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_adviews'] . "\n\t\tWHERE\n\t\t\tt_stamp >= {$begin_timestamp} AND t_stamp <= {$end_timestamp}\n\t\tGROUP BY \n\t\t\tbannerid, zoneid, source, hour\n\t") or phpAds_sqlDie();
    while ($row = phpAds_dbFetchArray($result)) {
        $stats["'" . $row['bannerid'] . "'"]["'" . $row['zoneid'] . "'"]["'" . $row['hour'] . "'"]["'" . $row['source'] . "'"] = array('views' => $row['qnt'], 'clicks' => 0);
    }
    // Get clicks
    $result = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tbannerid,\n\t\t\tzoneid,\n\t\t\tsource,\n\t\t\tHOUR(t_stamp) AS hour,\n\t\t\tCOUNT(*) AS qnt\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_adclicks'] . "\n\t\tWHERE\n\t\t\tt_stamp >= {$begin_timestamp} AND t_stamp <= {$end_timestamp}\n\t\tGROUP BY \n\t\t\tbannerid, zoneid, source, hour\n\t") or phpAds_sqlDie();
    while ($row = phpAds_dbFetchArray($result)) {
        if (isset($stats["'" . $row['bannerid'] . "'"]["'" . $row['zoneid'] . "'"]["'" . $row['hour'] . "'"]["'" . $row['source'] . "'"])) {
            $stats["'" . $row['bannerid'] . "'"]["'" . $row['zoneid'] . "'"]["'" . $row['hour'] . "'"]["'" . $row['source'] . "'"]['clicks'] = $row['qnt'];
        } else {
            $stats["'" . $row['bannerid'] . "'"]["'" . $row['zoneid'] . "'"]["'" . $row['hour'] . "'"]["'" . $row['source'] . "'"] = array('views' => 0, 'clicks' => $row['qnt']);
        }
    }
    if (isset($stats) && count($stats)) {
        return $stats;
    }
}
Exemplo n.º 20
0
echo "<input type='hidden' name='previousactive' value='" . (isset($row["active"]) ? $row["active"] : '') . "'>";
echo "</td></tr></table>";
echo "</td></tr>";
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='submit' name='submit' value='" . $strSaveChanges . "' tabindex='" . $tabindex++ . "'>";
echo "</form>";
/*********************************************************/
/* Form requirements                                     */
/*********************************************************/
// Get unique affiliate
$unique_names = array();
$res = phpAds_dbQuery("SELECT * FROM " . $phpAds_config['tbl_clients'] . " WHERE parent = " . $clientid . " AND clientid != '" . $campaignid . "'");
while ($row = phpAds_dbFetchArray($res)) {
    $unique_names[] = $row['clientname'];
}
?>

<script language='JavaScript'>
<!--
	phpAds_formSetRequirements('clientname', '<?php 
echo addslashes($strName);
?>
', true, 'unique');
	phpAds_formSetRequirements('views', '<?php 
echo addslashes($strViewsPurchased);
?>
', false, 'number+');
	phpAds_formSetRequirements('clicks', '<?php 
Exemplo n.º 21
0
    // Delete stats for this banner
    phpAds_deleteStats($bannerid);
    // Return to campaign statistics
    Header("Location: stats-campaign-banners.php?clientid=" . $clientid . "&campaignid=" . $campaignid);
} elseif (isset($campaignid) && $campaignid != '') {
    // Get all banners for this client
    $idresult = phpAds_dbQuery(" SELECT\n\t\t\t\t\t\t\t\tbannerid\n\t\t\t\t\t\t\t  FROM\n\t\t\t\t\t\t\t  \t" . $phpAds_config['tbl_banners'] . "\n\t\t\t\t\t\t\t  WHERE\n\t\t\t\t\t\t\t\tclientid = '{$campaignid}'\n\t\t  \t\t\t\t ");
    // Loop to all banners for this client
    while ($row = phpAds_dbFetchArray($idresult)) {
        // Delete stats for the banner
        phpAds_deleteStats($row['bannerid']);
    }
    // Return to campaign statistics
    Header("Location: stats-client-campaigns.php?clientid=" . $clientid);
} elseif (isset($clientid) && $clientid != '') {
    // Get all banners for this client
    $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");
    // Loop to all banners for this client
    while ($row = phpAds_dbFetchArray($idresult)) {
        // Delete stats for the banner
        phpAds_deleteStats($row['bannerid']);
    }
    // Return to campaign statistics
    Header("Location: stats-global-client.php");
} elseif (isset($all) && $all == 'tr' . 'ue') {
    phpAds_dbQuery("DELETE FROM " . $phpAds_config['tbl_adviews']) or phpAds_sqlDie();
    phpAds_dbQuery("DELETE FROM " . $phpAds_config['tbl_adclicks']) or phpAds_sqlDie();
    phpAds_dbQuery("DELETE FROM " . $phpAds_config['tbl_adstats']) or phpAds_sqlDie();
    // Return to campaign statistics
    Header("Location: stats-global-client.php");
}
Exemplo n.º 22
0
         header("Location: " . $returnurl . "?affiliateid=" . $moveto . "&zoneid=" . $zoneid);
         exit;
     }
 } elseif (isset($duplicate) && $duplicate == 'true') {
     // Duplicate the zone
     $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\tzoneid = '" . $zoneid . "'\n\t\t") or phpAds_sqlDie();
     if ($row = phpAds_dbFetchArray($res)) {
         // Get names
         if (ereg("^(.*) \\([0-9]+\\)\$", $row['zonename'], $regs)) {
             $basename = $regs[1];
         } else {
             $basename = $row['zonename'];
         }
         $names = array();
         $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_zones'] . "\n\t\t\t") or phpAds_sqlDie();
         while ($name = phpAds_dbFetchArray($res)) {
             $names[] = $name['zonename'];
         }
         // Get unique name
         $i = 2;
         while (in_array($basename . ' (' . $i . ')', $names)) {
             $i++;
         }
         $row['zonename'] = $basename . ' (' . $i . ')';
         // Remove bannerid
         unset($row['zoneid']);
         $values = array();
         while (list($name, $value) = each($row)) {
             $values[] = $name . " = '" . addslashes($value) . "'";
         }
         $res = phpAds_dbQuery("\n\t\t   \t\tINSERT INTO\n\t\t   \t\t\t" . $phpAds_config['tbl_zones'] . "\n\t\t\t\tSET\n\t\t\t\t\t" . implode(", ", $values) . "\n\t   \t\t") or phpAds_sqlDie();
            $manual['clicks'] += $row_stats['clicks'];
            $manual['views'] += $row_stats['views'];
        }
    }
} else {
    $res_stats = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tzoneid,\n\t\t\tcount(*) as views\n\t\tFROM \n\t\t\t" . $phpAds_config['tbl_adviews'] . "\n\t\tWHERE\n\t\t\tbannerid = '" . $bannerid . "'\n\t\tGROUP BY\n\t\t\tzoneid\n\t\t") or phpAds_sqlDie();
    while ($row_stats = phpAds_dbFetchArray($res_stats)) {
        if (isset($zones[$row_stats['zoneid']])) {
            $zones[$row_stats['zoneid']]['views'] = $row_stats['views'];
            $zones[$row_stats['zoneid']]['clicks'] = 0;
        } else {
            $manual['views'] += $row_stats['views'];
        }
    }
    $res_stats = phpAds_dbQuery("\n\t\tSELECT\n\t\t\tzoneid,\n\t\t\tcount(*) as clicks\n\t\tFROM \n\t\t\t" . $phpAds_config['tbl_adclicks'] . "\n\t\tWHERE\n\t\t\tbannerid = '" . $bannerid . "'\n\t\tGROUP BY\n\t\t\tzoneid\n\t\t") or phpAds_sqlDie();
    while ($row_stats = phpAds_dbFetchArray($res_stats)) {
        if (isset($zones[$row_stats['zoneid']])) {
            $zones[$row_stats['zoneid']]['clicks'] = $row_stats['clicks'];
        } else {
            $manual['clicks'] += $row_stats['clicks'];
        }
    }
}
// Add ID found in expand to expanded nodes
if (isset($expand) && $expand != '') {
    $node_array[] = $expand;
}
for ($i = 0; $i < sizeof($node_array); $i++) {
    if (isset($collapse) && $collapse == $node_array[$i]) {
        unset($node_array[$i]);
    } else {
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
// Include required files
require "config.php";
require "lib-banner.inc.php";
require "lib-storage.inc.php";
// Security check
phpAds_checkAccess(phpAds_Admin);
/*********************************************************/
/* Main code                                             */
/*********************************************************/
$res = phpAds_dbQuery("\n\tSELECT\n\t\t*\n\tFROM\n\t\t" . $phpAds_config['tbl_banners'] . "\n");
while ($current = phpAds_dbFetchArray($res)) {
    if ($current['storagetype'] == 'sql') {
        // Get the filename
        $filename = $current['filename'];
        // Copy the file
        $buffer = phpAds_ImageRetrieve('sql', $filename);
        $current['filename'] = phpAds_ImageStore('web', $filename, $buffer);
        if ($current['filename'] != false) {
            // Delete the original file
            phpAds_ImageDelete('sql', $filename);
            // Update fields
            $current['imageurl'] = '{image_url_prefix}/' . $current['filename'];
            $current['storagetype'] = 'web';
            // Rebuild banner cache
            $current['htmltemplate'] = stripslashes($current['htmltemplate']);
            $current['htmlcache'] = addslashes(phpAds_getBannerCache($current));
function days_left($clientid)
{
    global $phpAds_config;
    global $date_format;
    // uses the following language settings:
    global $strExpiration, $strNoExpiration, $strDaysLeft, $strEstimated;
    // preset return values
    $estimated_end = "-";
    $days_left = "-";
    $description = "";
    $absolute = 0;
    // Get client record
    $client_query = "\n\t\tSELECT\n\t\t\tviews,\n\t\t\tclicks,\n\t\t\texpire,\n\t\t\tDATE_FORMAT(expire, '" . $date_format . "') as expire_f,\n\t\t\tTO_DAYS(expire)-TO_DAYS(NOW()) as days_left\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\tWHERE \n\t\t\tclientid = " . $clientid;
    $res_client = phpAds_dbQuery($client_query) or phpAds_sqlDie();
    if (phpAds_dbNumRows($res_client) == 1) {
        $row_client = phpAds_dbFetchArray($res_client);
        // Check if the expiration date is set
        if ($row_client['expire'] != '0000-00-00' && $row_client['expire'] != '') {
            $expiration[] = array("days_left" => round($row_client["days_left"]), "date" => $row_client["expire_f"], "absolute" => true);
        }
        if ($row_client["views"] != -1) {
            if ($phpAds_config['compact_stats']) {
                $view_query = "\n\t               \tSELECT\n\t                   \tSUM(views) as total_views,\n\t                    MAX(TO_DAYS(day))-TO_DAYS(NOW()) as days_since_last_view,\n\t                    TO_DAYS(NOW())-MIN(TO_DAYS(day)) as days_since_start\n\t                FROM\n\t                   \t" . $phpAds_config['tbl_banners'] . " AS b\n\t                    LEFT JOIN " . $phpAds_config['tbl_adstats'] . " AS v USING (bannerid)\n\t                WHERE\n\t                  \tb.clientid = {$clientid}";
            } else {
                $view_query = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tcount(*) as total_views,\n\t\t\t\t\t\tMAX(TO_DAYS(v.t_stamp))-TO_DAYS(NOW()) as days_since_last_view,\n\t\t\t\t\t\tTO_DAYS(NOW())-MIN(TO_DAYS(v.t_stamp)) as days_since_start\n\t\t\t\t\tFROM\n\t\t\t\t\t\t" . $phpAds_config['tbl_adviews'] . " AS v, \n\t\t\t\t\t\t" . $phpAds_config['tbl_banners'] . " AS b \n\t\t\t\t\tWHERE\n\t\t\t\t\t\tb.clientid = {$clientid} \n\t\t\t\t\t\tAND\n\t\t\t\t\t\tb.bannerid = v.bannerid";
            }
            $res_views = phpAds_dbQuery($view_query) or phpAds_sqlDie();
            if (phpAds_dbNumRows($res_views) == 1) {
                $row_views = phpAds_dbFetchArray($res_views);
                if (!isset($row_views["days_since_start"]) || $row_views["days_since_start"] == '' || $row_views["days_since_start"] == 0 || $row_views["days_since_start"] == null) {
                    $row_views["days_since_start"] = 1;
                }
                if (!empty($row_views["total_views"]) && $row_views["total_views"] > 0) {
                    $days_left = round($row_client["views"] / ($row_views["total_views"] / $row_views["days_since_start"]));
                    if ($row_client["views"] > 0) {
                        $estimated_end = strftime($date_format, @mktime(0, 0, 0, date("m"), date("d") + $days_left, date("Y")));
                        $expiration[] = array("days_left" => $days_left, "date" => $estimated_end, "absolute" => false);
                    } else {
                        $estimated_end = strftime($date_format, @mktime(0, 0, 0, date("m"), date("d") - $row_views["days_since_last_view"], date("Y")));
                        $expiration[] = array("days_left" => 0 - $row_views["days_since_last_view"], "date" => $estimated_end, "absolute" => true);
                    }
                }
            }
        }
        if ($row_client["clicks"] != -1) {
            if ($phpAds_config['compact_stats']) {
                $click_query = "\n                \tSELECT\n                    \tSUM(clicks) as total_clicks,\n                        MAX(TO_DAYS(day))-TO_DAYS(NOW()) as days_since_last_click,\n                        TO_DAYS(NOW())-MIN(TO_DAYS(day)) as days_since_start\n\t\t\t\t\tFROM\n\t\t\t\t\t\t" . $phpAds_config['tbl_adstats'] . "\n\t\t\t\t\t\tLEFT JOIN " . $phpAds_config['tbl_banners'] . " USING (bannerid)\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tclientid = '{$clientid}' AND\n\t\t\t\t\t\tclicks > 0";
            } else {
                $click_query = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tcount(*) as total_clicks,\n\t\t\t\t\t\tMAX(TO_DAYS(c.t_stamp))- TO_DAYS(NOW()) as days_since_last_click,\n\t\t\t\t\t\tTO_DAYS(NOW())-MIN(TO_DAYS(c.t_stamp)) as days_since_start\n\t\t\t\t\tFROM\n\t\t\t\t\t\t" . $phpAds_config['tbl_adclicks'] . " AS c, \n\t\t\t\t\t\t" . $phpAds_config['tbl_banners'] . " AS b \n\t\t\t\t\tWHERE \n\t\t\t\t\t\tb.clientid = {$clientid} AND\n\t\t\t\t\t\tb.bannerid = c.bannerid";
            }
            $res_clicks = phpAds_dbQuery($click_query) or phpAds_sqlDie();
            if (phpAds_dbNumRows($res_clicks) == 1) {
                $row_clicks = phpAds_dbFetchArray($res_clicks);
                if (!isset($row_clicks["days_since_start"]) || $row_clicks["days_since_start"] == '' || $row_clicks["days_since_start"] == 0 || $row_clicks["days_since_start"] == null) {
                    $row_clicks["days_since_start"] = 1;
                }
                if (!empty($row_clicks["total_clicks"]) && $row_clicks["total_clicks"] > 0) {
                    $days_left = round($row_client["clicks"] / ($row_clicks["total_clicks"] / $row_clicks["days_since_start"]));
                    if ($row_client["clicks"] > 0) {
                        $estimated_end = strftime($date_format, @mktime(0, 0, 0, date("m"), date("d") + $days_left, date("Y")));
                        $expiration[] = array("days_left" => $days_left, "date" => $estimated_end, "absolute" => false);
                    } else {
                        $estimated_end = strftime($date_format, @mktime(0, 0, 0, date("m"), date("d") - $row_clicks["days_since_last_view"], date("Y")));
                        $expiration[] = array("days_left" => 0 - $row_clicks["days_since_last_view"], "date" => $estimated_end, "absolute" => true);
                    }
                }
            }
        }
    }
    // Build Return value
    if (isset($expiration) && sizeof($expiration) > 0) {
        $sooner = $expiration[0];
        for ($i = 0; $i < sizeof($expiration); $i++) {
            if ($expiration[$i]['days_left'] < $sooner['days_left']) {
                $sooner = $expiration[$i];
            }
        }
        if ($sooner['days_left'] < 0) {
            $sooner['days_left'] = 0;
        }
        if ($sooner['absolute']) {
            $ret_val[] = $strExpiration . ": " . $sooner['date'] . " (" . $strDaysLeft . ": " . $sooner['days_left'] . ")";
        } else {
            $ret_val[] = $strEstimated . ": " . $sooner['date'] . " (" . $strDaysLeft . ": " . $sooner['days_left'] . ")";
        }
        $ret_val[] = $sooner['date'];
        $ret_val[] = $sooner['days_left'];
    } else {
        // Unknown
        $ret_val[] = $strExpiration . ": " . $strNoExpiration;
        $ret_val[] = '';
        $ret_val[] = '';
    }
    return isset($ret_val) ? $ret_val : false;
}
Exemplo n.º 26
0
     $extra .= "<br><br>";
     $extra .= "<b>{$strModifyBanner}</b><br>";
     $extra .= "<img src='images/break.gif' height='1' width='160' vspace='4'><br>";
     $extra .= "<img src='images/icon-duplicate-banner.gif' align='absmiddle'>&nbsp;<a href='banner-modify.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&bannerid=" . $bannerid . "&duplicate=true&returnurl=banner-edit.php'>{$strDuplicate}</a><br>";
     $extra .= "<img src='images/break.gif' height='1' width='160' vspace='4'><br>";
     $extra .= "<img src='images/icon-move-banner.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: 110;'>";
     if (phpAds_isUser(phpAds_Admin)) {
         $query = "SELECT campaignid,campaignname FROM " . $phpAds_config['tbl_campaigns'] . " WHERE campaignid !=" . $campaignid;
     } elseif (phpAds_isUser(phpAds_Agency)) {
         $query = "SELECT campaignid,campaignname" . " FROM " . $phpAds_config['tbl_campaigns'] . "," . $phpAds_config['tbl_clients'] . " WHERE " . $phpAds_config['tbl_clients'] . ".clientid=" . $phpAds_config['tbl_campaigns'] . ".clientid" . " AND agencyid=" . phpAds_getUserID() . " AND campaignid !=" . $campaignid;
     }
     $res = phpAds_dbQuery($query) or phpAds_sqlDie();
     while ($others = phpAds_dbFetchArray($res)) {
         $extra .= "<option value='" . $others['campaignid'] . "'>" . phpAds_buildName($others['campaignid'], $others['campaignname']) . "</option>";
     }
     $extra .= "</select>&nbsp;<input type='image' name='moveto' 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='banner-delete.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&bannerid=" . $bannerid . "&returnurl=campaign-banners.php'" . phpAds_DelConfirm($strConfirmDeleteBanner) . ">{$strDelete}</a><br>";
     $extra .= "</form>";
     phpAds_PageHeader("4.1.3.3.2", $extra);
     echo "<img src='images/icon-advertiser.gif' align='absmiddle'>&nbsp;" . phpAds_getParentClientName($campaignid);
     echo "&nbsp;<img src='images/" . $phpAds_TextDirection . "/caret-rs.gif'>&nbsp;";
     echo "<img src='images/icon-campaign.gif' align='absmiddle'>&nbsp;" . phpAds_getCampaignName($campaignid);
     echo "&nbsp;<img src='images/" . $phpAds_TextDirection . "/caret-rs.gif'>&nbsp;";
     echo "<img src='images/icon-banner-stored.gif' align='absmiddle'>&nbsp;<b>" . phpAds_getBannerName($bannerid) . "</b><br><br>";
     echo phpAds_buildBannerCode($bannerid) . "<br><br><br><br>";
     phpAds_ShowSections(array("4.1.3.3.2", "4.1.3.3.3", "4.1.3.3.6", "4.1.3.3.4"));
 } else {
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
// Include required files
require "config.php";
require "lib-statistics.inc.php";
// Initialize random generator
mt_srand((double) microtime() * 1000000);
/*********************************************************/
/* Main code                                             */
/*********************************************************/
$res = phpAds_dbQuery("\n\tSELECT\n\t\t*\n\tFROM\n\t\t" . $phpAds_config['tbl_banners'] . "\n\tWHERE\n\t\tbannerid = '{$bannerid}'\n\t") or phpAds_sqlDie();
if ($res) {
    $row = phpAds_dbFetchArray($res);
    echo "<html><head><title>" . strip_tags(phpAds_buildBannerName($bannerid, $row['description'], $row['alt'])) . "</title>";
    echo "<link rel='stylesheet' href='images/" . $phpAds_TextDirection . "/interface.css'></head>";
    echo "<body marginheight='0' marginwidth='0' leftmargin='0' topmargin='0' bgcolor='#EFEFEF'>";
    echo "<table cellpadding='0' cellspacing='0' border='0'>";
    echo "<tr height='32'><td width='32'><img src='images/cropmark-tl.gif' width='32' height='32'></td>";
    echo "<td background='images/ruler-top.gif'>&nbsp;</td><td width='32'><img src='images/cropmark-tr.gif' width='32' height='32'></td></tr>";
    echo "<tr height='" . $row['height'] . "'><td width='32' background='images/ruler-left.gif'>&nbsp;</td><td bgcolor='#FFFFFF' width='" . $row['width'] . "'>";
    if ($row['contenttype'] == 'html') {
        $htmlcode = $row['htmlcache'];
        // Basic modifications
        $htmlcode = str_replace('{url_prefix}', $phpAds_config['url_prefix'], $htmlcode);
        $htmlcode = str_replace('{bannerid}', $bannerid, $htmlcode);
        $htmlcode = str_replace('{zoneid}', '', $htmlcode);
        $htmlcode = str_replace('{source}', '', $htmlcode);
        $htmlcode = str_replace('{target}', '_blank', $htmlcode);
// Register input variables
phpAds_registerGlobal('value');
// Security check
phpAds_checkAccess(phpAds_Admin + phpAds_Client);
/*********************************************************/
/* Main code                                             */
/*********************************************************/
if ($value == "t") {
    $value = "f";
} else {
    $value = "t";
}
if (phpAds_isUser(phpAds_Client)) {
    if ($value == 'f' && phpAds_isAllowed(phpAds_DisableBanner) || $value == 't' && phpAds_isAllowed(phpAds_ActivateBanner)) {
        $result = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\tclientid\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\tWHERE\n\t\t\t\tbannerid = '{$bannerid}'\n\t\t\t") or phpAds_sqlDie();
        $row = phpAds_dbFetchArray($result);
        if ($row["clientid"] == '' || phpAds_getUserID() != phpAds_getParentID($row["clientid"])) {
            phpAds_PageHeader("1");
            phpAds_Die($strAccessDenied, $strNotAdmin);
        } else {
            $campaignid = $row["clientid"];
            $res = phpAds_dbQuery("\n\t\t\t\tUPDATE\n\t\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\t\tSET\n\t\t\t\t\tactive = '{$value}'\n\t\t\t\tWHERE\n\t\t\t\t\tbannerid = '{$bannerid}'\n\t\t\t\t") or phpAds_sqlDie();
            // Rebuild priorities
            phpAds_PriorityCalculate();
            // Rebuild cache
            if (!defined('LIBVIEWCACHE_INCLUDED')) {
                include phpAds_path . '/libraries/deliverycache/cache-' . $phpAds_config['delivery_caching'] . '.inc.php';
            }
            phpAds_cacheDelete();
            Header("Location: stats-campaign-banners.php?clientid=" . $clientid . "&campaignid=" . $campaignid);
        }
        echo '<img src="images/caret-u.gif" border="0" alt="" title="">';
    }
    echo '</a>';
}
echo "</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
echo "<td height='25'>&nbsp;</td>";
echo "</tr>";
echo "<tr height='1'><td colspan='4' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
if (phpAds_dbNumRows($res_zones) == 0) {
    echo "<tr height='25' bgcolor='#F6F6F6'><td height='25' colspan='4'>";
    echo "&nbsp;&nbsp;" . $strNoZones;
    echo "</td></tr>";
    echo "<td colspan='4' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td>";
}
$i = 0;
while ($row_zones = phpAds_dbFetchArray($res_zones)) {
    if ($i > 0) {
        echo "<td colspan='4' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td>";
    }
    echo "<tr height='25' " . ($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . ">";
    echo "<td height='25'>&nbsp;&nbsp;";
    if ($row_zones['what'] != '') {
        if ($row_zones['delivery'] == phpAds_ZoneBanner) {
            echo "<img src='images/icon-zone.gif' align='absmiddle'>&nbsp;";
        } elseif ($row_zones['delivery'] == phpAds_ZoneInterstitial) {
            echo "<img src='images/icon-interstitial.gif' align='absmiddle'>&nbsp;";
        } elseif ($row_zones['delivery'] == phpAds_ZonePopup) {
            echo "<img src='images/icon-popup.gif' align='absmiddle'>&nbsp;";
        } elseif ($row_zones['delivery'] == phpAds_ZoneText) {
            echo "<img src='images/icon-textzone.gif' align='absmiddle'>&nbsp;";
        }
Exemplo n.º 30
0
function phpAds_compileLimitation($bannerid = '')
{
    global $phpAds_config;
    if ($bannerid == '') {
        // Loop through all banners
        $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\tbannerid\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t");
        while ($current = phpAds_dbFetchArray($res)) {
            phpAds_compileLimitation($current['bannerid']);
        }
    } else {
        // Compile limitation
        $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_acls'] . "\n\t\t\tWHERE\n\t\t\t\tbannerid = '" . $bannerid . "'\n\t\t\tORDER BY\n\t\t\t\texecutionorder\n\t\t") or phpAds_sqlDie();
        while ($row = phpAds_dbFetchArray($res)) {
            $acl[$row['executionorder']]['logical'] = $row['logical'];
            $acl[$row['executionorder']]['type'] = $row['type'];
            $acl[$row['executionorder']]['comparison'] = $row['comparison'];
            $acl[$row['executionorder']]['data'] = addslashes($row['data']);
        }
        $expression = '';
        $i = 0;
        if (isset($acl) && count($acl)) {
            reset($acl);
            while (list($key, ) = each($acl)) {
                if ($i > 0) {
                    $expression .= ' ' . $acl[$key]['logical'] . ' ';
                }
                switch ($acl[$key]['type']) {
                    case 'clientip':
                        $expression .= "phpAds_aclCheckClientIP(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'browser':
                        $expression .= "phpAds_aclCheckUseragent(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'os':
                        $expression .= "phpAds_aclCheckUseragent(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'useragent':
                        $expression .= "phpAds_aclCheckUseragent(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'language':
                        $expression .= "phpAds_aclCheckLanguage(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'country':
                        $expression .= "phpAds_aclCheckCountry(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'continent':
                        $expression .= "phpAds_aclCheckContinent(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'region':
                        $expression .= "phpAds_aclCheckRegion(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'weekday':
                        $expression .= "phpAds_aclCheckWeekday(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'domain':
                        $expression .= "phpAds_aclCheckDomain(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'source':
                        $expression .= "phpAds_aclCheckSource(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\', \$" . "source)";
                        break;
                    case 'time':
                        $expression .= "phpAds_aclCheckTime(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'date':
                        $expression .= "phpAds_aclCheckDate(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    case 'referer':
                        $expression .= "phpAds_aclCheckReferer(\\'" . addslashes($acl[$key]['data']) . "\\', \\'" . $acl[$key]['comparison'] . "\\')";
                        break;
                    default:
                        return 0;
                }
                $i++;
            }
        }
        if ($expression == '') {
            $expression = 'true';
        }
        $res = phpAds_dbQuery("\n\t\t\tUPDATE\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\tSET\n\t\t\t\tcompiledlimitation='" . $expression . "'\n\t\t\tWHERE\n\t\t\t\tbannerid='" . $bannerid . "'\n\t\t") or phpAds_sqlDie();
    }
}