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 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 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";
}
예제 #5
0
function phpAds_DeleteTracker($trackerid)
{
    global $phpAds_config;
    // Delete Campaign
    $res = phpAds_dbQuery("DELETE FROM " . $phpAds_config['tbl_trackers'] . " WHERE trackerid=" . $trackerid) or phpAds_sqlDie();
    // Delete Campaign/Tracker links
    $res = phpAds_dbQuery("DELETE FROM " . $phpAds_config['tbl_campaigns_trackers'] . " WHERE trackerid=" . $trackerid) or phpAds_sqlDie();
    // Delete Conversions Logged to this Tracker
    $res = phpAds_dbQuery("DELETE FROM " . $phpAds_config['tbl_conversionlog'] . " WHERE trackerid=" . $trackerid) or phpAds_sqlDie();
    // Delete stats for each banner
    phpAds_deleteStatsByTrackerID($trackerid);
}
function phpAds_updateSources($old_source, $new_source)
{
    global $phpAds_config;
    $old_source_len = strlen($old_source);
    echo "Converting: " . $old_source . " to " . $new_source . " ...";
    $query = "UPDATE " . $phpAds_config['tbl_adclicks'] . " SET source=CONCAT('" . $new_source . "',SUBSTRING(source," . ($old_source_len + 1) . ")) WHERE source LIKE '" . $old_source . "%'";
    $res = phpAds_dbQuery($query) or phpAds_sqlDie();
    $query = "UPDATE " . $phpAds_config['tbl_conversionlog'] . " SET action_source=CONCAT('" . $new_source . "',SUBSTRING(action_source," . ($old_source_len + 1) . ")) WHERE action_source LIKE '" . $old_source . "%'";
    $res = phpAds_dbQuery($query) or phpAds_sqlDie();
    $query = "UPDATE " . $phpAds_config['tbl_adviews'] . " SET source=CONCAT('" . $new_source . "',SUBSTRING(source," . ($old_source_len + 1) . "))" . " WHERE source='" . $old_source . "%'" . " OR source LIKE '" . $old_source . "/%'";
    $res = phpAds_dbQuery($query) or phpAds_sqlDie();
    echo "Done.<br>";
}
예제 #7
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);
}
예제 #8
0
function RaiseErrorHandler($group, $id, $info = NULL)
{
    if (function_exists('phpAds_sqlDie')) {
        global $phpAds_last_query;
        $phpAds_last_query = $info['sql'];
        phpAds_sqlDie();
    } else {
        $oError =& new ErrorInfo();
        $oError->group = $group;
        $oError->id = $id;
        $oError->info = $info;
        $errorstr = sprintf('[%s: message="%s" group=%d id=%s]', strtolower(get_class($oError)), implode(', ', $oError->info), $oError->group, $oError->id);
        trigger_error($errorstr, E_USER_ERROR);
    }
}
예제 #9
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);
}
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;
}
 if (!empty($duplicate)) {
     // Duplicate the campaign
     $doCampaigns = OA_Dal::factoryDO('campaigns');
     $doCampaigns->get($campaignid);
     $oldName = $doCampaigns->campaignname;
     $newCampaignId = $doCampaigns->duplicate();
     if ($newCampaignId) {
         // Queue confirmation message
         $newName = $doCampaigns->campaignname;
         $translation = new OX_Translation();
         $translated_message = $translation->translate($GLOBALS['strCampaignHasBeenDuplicated'], array(MAX::constructURL(MAX_URL_ADMIN, "campaign-edit.php?clientid={$clientid}&campaignid={$campaignid}"), htmlspecialchars($oldName), MAX::constructURL(MAX_URL_ADMIN, "campaign-edit.php?clientid={$clientid}&campaignid={$newCampaignId}"), htmlspecialchars($newName)));
         OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
         Header("Location: {$returnurl}?clientid={$clientid}&campaignid={$newCampaignId}");
         exit;
     } else {
         phpAds_sqlDie();
     }
 } else {
     if (!empty($newclientid)) {
         /*-------------------------------------------------------*/
         /* Restore cache of $node_array, if it exists            */
         /*-------------------------------------------------------*/
         if (isset($session['prefs']['advertiser-index.php']['nodes'])) {
             $node_array = $session['prefs']['advertiser-index.php']['nodes'];
         }
         /*-------------------------------------------------------*/
         // Delete any campaign-tracker links
         $doCampaign_trackers = OA_Dal::factoryDO('campaigns_trackers');
         $doCampaign_trackers->campaignid = $campaignid;
         $doCampaign_trackers->delete();
         // Move the campaign
예제 #13
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");
}
/*                                                                      */
/* 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";
require "../libraries/lib-reports.inc.php";
// Register input variables
phpAds_registerGlobal('startday', 'startmonth', 'startyear', 'endday', 'endmonth', 'endyear');
// Security check
phpAds_checkAccess(phpAds_Admin + phpAds_Agency);
if (phpAds_isUser(phpAds_Agency)) {
    $query = "SELECT clientid FROM " . $phpAds_config['tbl_clients'] . " WHERE clientid=" . $clientid . " AND agencyid=" . phpAds_getUserID();
    $res = phpAds_dbQuery($query) or phpAds_sqlDie();
    if (phpAds_dbNumRows($res) == 0) {
        phpAds_PageHeader("2");
        phpAds_Die($strAccessDenied, $strNotAdmin);
    }
}
/*********************************************************/
/* Main code                                             */
/*********************************************************/
if (isset($clientid) && $clientid != '') {
    if (isset($startyear) && isset($startmonth) && isset($startday) && $startyear != '' && $startmonth != '' && $startday != '') {
        $first_unixtimestamp = mktime(0, 0, 0, $startmonth, $startday, $startyear);
    } else {
        $first_unixtimestamp = 0;
    }
    if (isset($endyear) && isset($endmonth) && isset($endday)) {
    $query = "SELECT campaignid" . " FROM " . $phpAds_config['tbl_campaigns'] . "," . $phpAds_config['tbl_clients'] . " WHERE clientid=" . $clientid . " AND campaignid=" . $campaignid . " AND agencyid=" . phpAds_getUserID();
    $res = phpAds_dbQuery($query) or phpAds_sqlDie();
    if (phpAds_dbNumRows($res) == 0) {
        phpAds_PageHeader("1");
        phpAds_Die($strAccessDenied, $strNotAdmin);
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
$bannerids = array();
$idresult = phpAds_dbQuery("\n\tSELECT\n\t\tbannerid\n\tFROM\n\t\t" . $phpAds_config['tbl_banners'] . "\n\tWHERE\n\t\tcampaignid = '{$campaignid}'\n");
while ($row = phpAds_dbFetchArray($idresult)) {
    $bannerids[] = "bannerid = " . $row['bannerid'];
}
$res = phpAds_dbQuery("\n\tSELECT\n\t\tDATE_FORMAT(day, '%Y%m%d') as date,\n\t\tDATE_FORMAT(day, '{$date_format}') as date_formatted\n\tFROM\n\t\t" . $phpAds_config['tbl_adstats'] . "\n\tWHERE\n\t\t(" . implode(' OR ', $bannerids) . ")\n\tGROUP BY\n\t\tday\n\tORDER BY\n\t\tday DESC\n\tLIMIT 7\n") or phpAds_sqlDie();
while ($row = phpAds_dbFetchArray($res)) {
    phpAds_PageContext($row['date_formatted'], "stats-campaign-daily-hosts.php?day=" . $row['date'] . "&clientid=" . $clientid . "&campaignid=" . $campaignid, $day == $row['date']);
}
if (phpAds_isUser(phpAds_Admin) || phpAds_isUser(phpAds_Agency)) {
    phpAds_PageShortcut($strClientProperties, 'advertiser-edit.php?clientid=' . $clientid, 'images/icon-advertiser.gif');
    phpAds_PageShortcut($strCampaignProperties, 'campaign-edit.php?clientid=' . $clientid . '&campaignid=' . $campaignid, 'images/icon-campaign.gif');
    phpAds_PageHeader("2.1.2.1.2");
    echo "<img src='images/icon-advertiser.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;" . phpAds_getCampaignName($campaignid);
    echo "&nbsp;<img src='images/" . $phpAds_TextDirection . "/caret-rs.gif'>&nbsp;";
    echo "<img src='images/icon-date.gif' align='absmiddle'>&nbsp;<b>" . date(str_replace('%', '', $date_format), mktime(0, 0, 0, substr($day, 4, 2), substr($day, 6, 2), substr($day, 0, 4))) . "</b><br><br><br>";
    phpAds_ShowSections(array("2.1.2.1.1", "2.1.2.1.2"));
}
if (phpAds_isUser(phpAds_Client)) {
        } else {
            $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]);
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
if (phpAds_isUser(phpAds_Admin)) {
    if (isset($Session['prefs']['stats-global-client.php']['listorder'])) {
        $navorder = $Session['prefs']['stats-global-client.php']['listorder'];
    } else {
        $navorder = '';
    }
    if (isset($Session['prefs']['stats-global-client.php']['orderdirection'])) {
        $navdirection = $Session['prefs']['stats-global-client.php']['orderdirection'];
    } 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)) {
예제 #18
0
$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.3", $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"));
/*********************************************************/
/* Main code                                             */
/*********************************************************/
if (!isset($acl) && $phpAds_config['acl']) {
    // Fetch all ACLs from the database
    $res = phpAds_dbQuery("\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_acls'] . "\n\t\tWHERE\n\t\t\tbannerid = '" . $bannerid . "'\n\t\tORDER BY\n\t\t\texecutionorder\n\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'];
        // Misc lists
        if ($row['type'] == 'time' || $row['type'] == 'weekday' || $row['type'] == 'country' || $row['type'] == 'continent' || $row['type'] == 'region') {
            $acl[$row['executionorder']]['data'] = explode(',', $row['data']);
        } elseif ($row['type'] == 'language') {
            if (ereg("^\\(.*\\)\$", $row['data'])) {
                $row['data'] = substr($row['data'], 1, strlen($row['data']) - 2);
            }
            $acl[$row['executionorder']]['data'] = explode(')|(', $row['data']);
        } elseif ($row['type'] == 'browser') {
            if (ereg("^\\(.*\\)\$", $row['data'])) {
                $row['data'] = substr($row['data'], 1, strlen($row['data']) - 2);
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
if (isset($Session['prefs']['stats-campaign-banners.php']['listorder'])) {
    $navorder = $Session['prefs']['stats-campaign-banners.php']['listorder'];
} else {
    $navorder = '';
}
if (isset($Session['prefs']['stats-campaign-banners.php']['orderdirection'])) {
    $navdirection = $Session['prefs']['stats-campaign-banners.php']['orderdirection'];
} else {
    $navdirection = '';
}
$res = phpAds_dbQuery("\n\tSELECT\n\t\t*\n\tFROM\n\t\t" . $phpAds_config['tbl_banners'] . "\n\tWHERE\n\t\tcampaignid = '{$campaignid}'\n\t" . phpAds_getBannerListOrder($navorder, $navdirection) . "\n") or phpAds_sqlDie();
while ($row = phpAds_dbFetchArray($res)) {
    phpAds_PageContext(phpAds_buildBannerName($row['bannerid'], $row['description'], $row['alt']), "stats-banner-history.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&bannerid=" . $row['bannerid'], $bannerid == $row['bannerid']);
}
if (phpAds_isUser(phpAds_Admin) || phpAds_isUser(phpAds_Agency)) {
    phpAds_PageShortcut($strClientProperties, 'advertiser-edit.php?clientid=' . $clientid, 'images/icon-advertiser.gif');
    phpAds_PageShortcut($strCampaignProperties, 'campaign-edit.php?clientid=' . $clientid . '&campaignid=' . $campaignid, 'images/icon-campaign.gif');
    phpAds_PageShortcut($strBannerProperties, 'banner-edit.php?clientid=' . $clientid . '&campaignid=' . $campaignid . '&bannerid=' . $bannerid, 'images/icon-banner-stored.gif');
    phpAds_PageShortcut($strModifyBannerAcl, 'banner-acl.php?clientid=' . $clientid . '&campaignid=' . $campaignid . '&bannerid=' . $bannerid, 'images/icon-acl.gif');
    if (phpAds_isUser(phpAds_Admin)) {
        $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}&campaignid={$campaignid}&bannerid={$bannerid}'" . phpAds_DelConfirm($strConfirmResetBannerStats) . ">";
        $extra .= "<img src='images/" . $phpAds_TextDirection . "/icon-undo.gif' align='absmiddle' border='0'>&nbsp;{$strResetStats}</a>";
        $extra .= "<br><br>";
    echo "<img src='images/icon-affiliate.gif' align='absmiddle'>&nbsp;<b>" . phpAds_getAffiliateName($affiliateid) . "</b><br><br><br>";
    phpAds_ShowSections(array("4.2.2", "4.2.3"));
} else {
    $sections[] = "2.1";
    if (phpAds_isAllowed(phpAds_ModifyInfo)) {
        $sections[] = "2.2";
    }
    phpAds_PageHeader("2.1");
    echo "<img src='images/icon-affiliate.gif' align='absmiddle'>&nbsp;<b>" . phpAds_getAffiliateName($affiliateid) . "</b><br><br><br>";
    phpAds_ShowSections($sections);
}
/*********************************************************/
/* Main code                                             */
/*********************************************************/
// Get clients & campaign and build the tree
$res_zones = phpAds_dbQuery("\n\t\tSELECT \n\t\t\t*\n\t\tFROM \n\t\t\t" . $phpAds_config['tbl_zones'] . "\n\t\tWHERE\n\t\t\taffiliateid = '" . $affiliateid . "'\n\t\t" . phpAds_getZoneListOrder($listorder, $orderdirection) . "\n\t\t") or phpAds_sqlDie();
if (phpAds_isUser(phpAds_Admin) || phpAds_isAllowed(phpAds_AddZone)) {
    echo "<img src='images/icon-zone-new.gif' border='0' align='absmiddle'>&nbsp;";
    echo "<a href='zone-edit.php?affiliateid=" . $affiliateid . "' accesskey='" . $keyAddNew . "'>" . $strAddNewZone_Key . "</a>&nbsp;&nbsp;";
    phpAds_ShowBreak();
}
echo "<br><br>";
echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
echo "<tr height='25'>";
echo '<td height="25"><b>&nbsp;&nbsp;<a href="affiliate-zones.php?affiliateid=' . $affiliateid . '&listorder=name">' . $GLOBALS['strName'] . '</a>';
if ($listorder == "name" || $listorder == "") {
    if ($orderdirection == "" || $orderdirection == "down") {
        echo ' <a href="affiliate-zones.php?affiliateid=' . $affiliateid . '&orderdirection=up">';
        echo '<img src="images/caret-ds.gif" border="0" alt="" title="">';
    } else {
        echo ' <a href="affiliate-zones.php?affiliateid=' . $affiliateid . '&orderdirection=down">';
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;
}
            $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);
        }
    } else {
        phpAds_PageHeader("1");
        phpAds_Die($strAccessDenied, $strNotAdmin);
    }
}
if (phpAds_isUser(phpAds_Admin)) {
    if (isset($bannerid) && $bannerid != '') {
        $res = phpAds_dbQuery("\n\t\t\tUPDATE\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\tSET\n\t\t\t\tactive = '{$value}'\n\t\t\tWHERE\n\t\t\t\tbannerid = '{$bannerid}'\n\t\t") or phpAds_sqlDie();
    } elseif (isset($campaignid) && $campaignid != '') {
        $res = phpAds_dbQuery("\n\t\t\tUPDATE\n\t\t\t\t" . $phpAds_config['tbl_banners'] . "\n\t\t\tSET\n\t\t\t\tactive = '{$value}'\n\t\t\tWHERE\n\t\t\t\tclientid = '{$campaignid}'\n\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: campaign-banners.php?clientid=" . $clientid . "&campaignid=" . $campaignid);
}
        } else {
            $affiliateid = phpAds_getUserID();
        }
    } else {
        phpAds_PageHeader("1");
        phpAds_Die($strAccessDenied, $strNotAdmin);
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
if (phpAds_isUser(phpAds_Admin)) {
    if ($phpAds_config['compact_stats']) {
        $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\tDISTINCT bannerid\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_adstats'] . "\n\t\t\tWHERE\n\t\t\t\tzoneid = '" . $zoneid . "'\n\t\t") or phpAds_sqlDie();
    } else {
        $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\tDISTINCT bannerid\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_adviews'] . "\n\t\t\tWHERE\n\t\t\t\tzoneid = '" . $zoneid . "'\n\t\t") or phpAds_sqlDie();
    }
    while ($row = phpAds_dbFetchArray($res)) {
        phpAds_PageContext(phpAds_getBannerName($row['bannerid']), "stats-linkedbanner-history.php?affiliateid=" . $affiliateid . "&zoneid=" . $zoneid . "&bannerid=" . $row['bannerid'], $bannerid == $row['bannerid']);
    }
    phpAds_PageShortcut($strAffiliateProperties, 'affiliate-edit.php?affiliateid=' . $affiliateid, 'images/icon-affiliate.gif');
    phpAds_PageShortcut($strZoneProperties, 'zone-edit.php?affiliateid=' . $affiliateid . '&zoneid=' . $zoneid, 'images/icon-zone.gif');
    phpAds_PageShortcut($strIncludedBanners, 'zone-include.php?affiliateid=' . $affiliateid . '&zoneid=' . $zoneid, 'images/icon-zone-linked.gif');
    phpAds_PageHeader("2.4.2.2.1");
    echo "<img src='images/icon-affiliate.gif' align='absmiddle'>&nbsp;" . phpAds_getAffiliateName($affiliateid);
    echo "&nbsp;<img src='images/" . $phpAds_TextDirection . "/caret-rs.gif'>&nbsp;";
    echo "<img src='images/icon-zone.gif' align='absmiddle'>&nbsp;" . phpAds_getZoneName($zoneid);
    echo "&nbsp;<img src='images/" . $phpAds_TextDirection . "/caret-rs.gif'>&nbsp;";
    echo "<img src='images/icon-zone-linked.gif' align='absmiddle'>&nbsp;<b>" . phpAds_getBannerName($bannerid) . "</b><br><br><br>";
    phpAds_ShowSections(array("2.4.2.2.1"));
} else {
예제 #24
0
// $Revision: 2.2 $
/************************************************************************/
/* phpAdsNew 2                                                          */
/* ===========                                                          */
/*                                                                      */
/* Copyright (c) 2000-2002 by the phpAdsNew developers                  */
/* For more information visit: http://www.phpadsnew.com                 */
/*                                                                      */
/* 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.       */
/************************************************************************/
/*********************************************************/
/* Show hourly statistics                                */
/*********************************************************/
$result = phpAds_dbQuery("\n\tSELECT\n\t\thour,\n\t\tSUM(views) AS views,\n\t\tSUM(clicks) AS clicks,\n\t\tSUM(conversions) AS conversions\n\tFROM\n\t\t" . $phpAds_config['tbl_adstats'] . "\n\tWHERE\n\t\tday = " . $day . "\n\t\t" . (isset($lib_hourly_where) ? 'AND ' . $lib_hourly_where : '') . "\n\tGROUP BY \n\t\thour\n") or phpAds_sqlDie();
while ($row = phpAds_dbFetchArray($result)) {
    $views[$row['hour']] = $row['views'];
    $clicks[$row['hour']] = $row['clicks'];
    $conversions[$row['hour']] = $row['conversions'];
}
echo "<br><br>";
echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
echo "<tr bgcolor='#FFFFFF' height='25'>";
echo "<td align='" . $phpAds_TextAlignLeft . "' nowrap height='25'><b>{$strHour}</b></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>";
예제 #25
0
                $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();
            $new_zoneid = phpAds_dbInsertID();
            Header("Location: " . $returnurl . "?affiliateid=" . $affiliateid . "&zoneid=" . $new_zoneid);
            exit;
        }
    }
}
// Prevent HTTP response splitting
if (!preg_match('/[\\r\\n]/', $returnurl)) {
    $url = stripslashes($returnurl);
    header("Location: " . $returnurl . "?affiliateid=" . $affiliateid . "&zoneid=" . $zoneid);
}
    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"));
}
/*********************************************************/
/* Main code                                             */
/*********************************************************/
$idresult = phpAds_dbQuery("SELECT b.bannerid" . " FROM " . $phpAds_config['tbl_banners'] . " AS b" . "," . $phpAds_config['tbl_campaigns'] . " AS c" . " WHERE c.clientid=" . $clientid . " AND c.campaignid=b.campaignid") or phpAds_sqlDie();
if (phpAds_dbNumRows($idresult) > 0) {
    while ($row = phpAds_dbFetchArray($idresult)) {
        $bannerids[] = "bannerid=" . $row['bannerid'];
    }
    $lib_history_where = "(" . implode(' OR ', $bannerids) . ")";
    $lib_history_params = array('clientid' => $clientid);
    $lib_history_hourlyurl = "stats-advertiser-daily.php";
    include "lib-history.inc.php";
    /*********************************************************/
    /* Maintenance                                           */
    /*********************************************************/
    if (phpAds_isUser(phpAds_Admin) || phpAds_isUser(phpAds_Agency)) {
        echo "<br><br><br>";
        echo "<table width='100%' border='0' align='center' cellspacing='0' cellpadding='0'>";
        echo "<tr><td height='25'><b>{$strMaintenance}</b></td></tr>";
echo "\t\t\t\t\t<td>\n";
echo "\t\t\t\t\t\t<b>" . $GLOBALS['strConversionWindow'] . "</b>\n";
echo "\t\t\t\t\t</td>\n";
echo "\t\t\t\t</tr>\n";
echo "\t\t\t\t<tr height='1'>\n";
echo "\t\t\t\t\t<td colspan='4' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td>\n";
echo "\t\t\t\t</tr>\n";
$i = 0;
$checkedall = true;
if (isset($campaignid) && $campaignid > 0) {
    $res = phpAds_dbQuery("SELECT *" . " FROM " . $phpAds_config['tbl_campaigns_trackers'] . " WHERE campaignid=" . $campaignid) or phpAds_sqlDie();
    while ($row = phpAds_dbFetchArray($res)) {
        $campaign_tracker_row[$row['trackerid']] = $row;
    }
}
$res = phpAds_dbQuery("SELECT *" . " FROM " . $phpAds_config['tbl_trackers'] . " WHERE clientid=" . $clientid . phpAds_getTrackerListOrder($listorder, $orderdirection)) or phpAds_sqlDie();
if (phpAds_dbNumRows($res) == 0) {
    echo "\t\t\t\t<tr bgcolor='#F6F6F6'>\n";
    echo "\t\t\t\t\t<td colspan='4' height='25'>&nbsp;&nbsp;" . $strNoTrackersToLink . "</td>\n";
    echo "\t\t\t\t</tr>\n";
} else {
    echo "\t\t\t\t<form name='availabletrackers' method='post' action='campaign-trackers.php'>\n";
    echo "\t\t\t\t<input type='hidden' name='campaignid' value='" . $GLOBALS['campaignid'] . "'>\n";
    echo "\t\t\t\t<input type='hidden' name='clientid' value='" . $GLOBALS['clientid'] . "'>\n";
    echo "\t\t\t\t<input type='hidden' name='action' value='set'>\n";
    while ($row = phpAds_dbFetchArray($res)) {
        $trackers[$row['trackerid']] = $row;
    }
    for (reset($trackers); $tkey = key($trackers); next($trackers)) {
        $tracker = $trackers[$tkey];
        if ($i > 0) {
/* Copyright (c) 2000-2002 by the phpAdsNew developers                  */
/* For more information visit: http://www.phpadsnew.com                 */
/*                                                                      */
/* 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);
예제 #29
0
        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;
        }
    }
    $res = phpAds_dbQuery("\n\t\tSELECT\n\t\t\t*,\n\t\t\tto_days(expire) as expire_day,\n\t\t\tto_days(curdate()) as cur_date,\n\t\t\tUNIX_TIMESTAMP(expire) as timestamp,\n\t\t\tDATE_FORMAT(expire, '{$date_format}') as expire_f,\n\t\t\tdayofmonth(expire) as expire_dayofmonth,\n\t\t\tmonth(expire) as expire_month,\n\t\t\tyear(expire) as expire_year,\n\t\t\tDATE_FORMAT(activate, '{$date_format}') as activate_f,\n\t\t\tdayofmonth(activate) as activate_dayofmonth,\n\t\t\tmonth(activate) as activate_month,\n\t\t\tyear(activate) as activate_year\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\tWHERE\n\t\t\tclientid = {$ID}\n\t\t") or phpAds_sqlDie();
    $row = phpAds_dbFetchArray($res);
    if ($row['target'] > 0) {
        $priority = 't';
        $row['weight'] = '-';
    } else {
        $priority = 'f';
        $row['target'] = '-';
    }
    // Set parent when editing an campaign, don't set it
    // when moving an campaign.
    //if ($campaignid != "" && isset($row["parent"]))
    //	$clientid = $row["parent"];
    // Set default activation settings
    if (!isset($row["activate_dayofmonth"])) {
        $row["activate_dayofmonth"] = 0;
    } else {
        $period = '';
    }
}
if (!isset($period_range)) {
    if (isset($Session['prefs']['stats-zone-linkedbanners.php']['period_range'])) {
        $period_range = $Session['prefs']['stats-zone-linkedbanners.php']['period_range'];
    } else {
        $period_range = array('start_day' => 0, 'start_month' => 0, 'start_year' => 0, 'end_day' => 0, 'end_month' => 0, 'end_year' => 0);
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
if (phpAds_isUser(phpAds_Admin)) {
    $res = phpAds_dbQuery("\n\t\tSELECT\n\t\t\t*\n\t\tFROM\n\t\t\t" . $phpAds_config['tbl_zones'] . "\n\t\tWHERE\n\t\t\taffiliateid = '" . $affiliateid . "'\n\t") or phpAds_sqlDie();
    while ($row = phpAds_dbFetchArray($res)) {
        phpAds_PageContext(phpAds_buildZoneName($row['zoneid'], $row['zonename']), "stats-zone-linkedbanners.php?affiliateid=" . $affiliateid . "&zoneid=" . $row['zoneid'], $zoneid == $row['zoneid']);
    }
    phpAds_PageShortcut($strAffiliateProperties, 'affiliate-edit.php?affiliateid=' . $affiliateid, 'images/icon-affiliate.gif');
    phpAds_PageShortcut($strZoneProperties, 'zone-edit.php?affiliateid=' . $affiliateid . '&zoneid=' . $zoneid, 'images/icon-zone.gif');
    phpAds_PageShortcut($strIncludedBanners, 'zone-include.php?affiliateid=' . $affiliateid . '&zoneid=' . $zoneid, 'images/icon-zone-linked.gif');
    phpAds_PageHeader("2.4.2.2");
    echo "<img src='images/icon-affiliate.gif' align='absmiddle'>&nbsp;" . phpAds_getAffiliateName($affiliateid);
    echo "&nbsp;<img src='images/" . $phpAds_TextDirection . "/caret-rs.gif'>&nbsp;";
    echo "<img src='images/icon-zone.gif' align='absmiddle'>&nbsp;<b>" . phpAds_getZoneName($zoneid) . "</b><br><br><br>";
    phpAds_ShowSections(array("2.4.2.1", "2.4.2.2"));
} else {
    phpAds_PageHeader("1.1.2");
    echo "<img src='images/icon-zone.gif' align='absmiddle'>&nbsp;<b>" . phpAds_getZoneName($zoneid) . "</b><br><br><br>";
    phpAds_ShowSections(array("1.1.1", "1.1.2"));