function is_valid_app_key($appName, $user_api_key, $user_app_key) { if ($user_app_key != '') { switch ($appName) { case "stats202": // check to make sure this is a valid stats202 app key $url = TRACKING202_API_URL . "/auth/isValidStats202AppKey?apiKey={$user_api_key}&stats202AppKey={$user_app_key}"; $xml = getUrl($url); $isValidStats202AppKey = convertXmlIntoArray($xml); $isValidStats202AppKey = $isValidStats202AppKey['isValidStats202AppKey']; if ($isValidStats202AppKey['isValid'] == 'true') { return true; } else { return false; } break; } } return false; }
} if (!$_SESSION['offers202_limit']) { $_SESSION['offers202_limit'] = 100; } if ($_POST['page']) { $get['offset'] = $get['limit'] * ($_POST['page'] - 1); } $query = http_build_query($get); if ($_SESSION['offers202_query']) { $html['query'] = htmlentities($_SESSION['offers202_query']); echo "\t<div style='text-align: center; padding: 5px 0px 15px;' id='addAlert'>\n\t\t\t\tWould you like to be notified every time a new <strong><em>{$html['query']}</em></strong> offer is found? \n\t\t\t\t Simply <a href='/alerts202/?addAlert=1&alertType=offer&alertValue={$html['query']}'>click here to create this alert</a>.\n\t\t\t</div>"; } //build the offers202 api string $url = TRACKING202_API_URL . "/offers202/getOffers?{$query}"; $xml = getUrl($url); $getOffers = convertXmlIntoArray($xml); //check for api errors checkForApiErrors($getOffers); //if there were no errors continue $getOffers = $getOffers['getOffers']; $summary = $getOffers['summary'][0]; $total_rows = $summary['total_rows']; $offset = $summary['offset']; $limit = $summary['limit']; #print_r_html($summary); //paging $page = $_POST['page']; if (!$page) { $page = 1; } $pages = ceil($total_rows / $limit);
<tr> <td bgcolor="#e0e5ff" style="padding: 5px;" colspan="5"><strong>My Offer Alerts</strong></td> </tr> </tr> <tr> <th style="text-align: left; background: rgb(222,222,222);">Search Terms</th> <th style="text-align: left; background: rgb(222,222,222);">How Often</th> <th style="text-align: left; background: rgb(222,222,222);">Feeds</th> <th style="background: rgb(222,222,222);"/> </tr> <?php $get = array('apiKey' => $_SESSION['user_api_key'], 'alertType' => 'offer'); $url = TRACKING202_API_URL . '/alerts202/getAlerts?' . http_build_query($get); $getAlertsXml = getUrl($url); $getAlerts = convertXmlIntoArray($getAlertsXml); if ($getAlerts['getAlerts']) { $alerts = $getAlerts['getAlerts']['alerts'][0]['alert']; } for ($x = 0; $x < count($alerts); $x++) { $html = array_map('htmlentities', $alerts[$x]); echo '<tr id="t202pro-row" onmouseover="lightUpRow(this);" onmouseout="dimDownRow(this);">'; echo "<td >{$html['alertValue']}</td>"; echo "<td>Daily</td>"; echo "<td><a href='" . TRACKING202_RSS_URL . "/offers?q={$html['alertValue']}'>RSS Feed</a></td>"; echo "<td class='center'><a href='#' onclick='if (confirm(\"Are you sure you wish to delete this alert?\")) { window.location=\"?deleteAlert=1&alertId={$html['alertId']}\"; }'>[delete]</a></td>"; echo "</tr>"; } if (!$alerts) { echo "<tr><td colspan='4' class='center'>You currently have no offer alerts setup.</td></tr>"; }
</tr> </table> </td> </tr> <tr> <td> <?php //build the get query for the offers202 restful api $get = array(); $get['apiKey'] = $_SESSION['user_api_key']; $query = http_build_query($get); //build the offers202 api string $url = TRACKING202_API_URL . "/offers202/getNetworks?{$query}"; //grab the url $xml = getUrl($url); $getNetworks = convertXmlIntoArray($xml); $getNetworks = $getNetworks['getNetworks']; $networks = $getNetworks['networks'][0]['network']; ?> <h3 class="green" style="margin: 40px 0px 10px;">Specific Affiliate Network RSS Feeds</h3> <table class="setup-table" cellpadding="0" cellspacing="0" style="margin: 0px;"> <tr> <th>Affiliate Network</th> <th>RSS Feed</th> </tr> <?php for ($x = 0; $x < count($networks); $x++) { $html = array_map('htmlentities', $networks[$x]);
AUTH::require_valid_app_key('stats202', $_SESSION['user_api_key'], $_SESSION['user_stats202_app_key']); if ($_GET['deletePostBack']) { $get = array('apiKey' => $_SESSION['user_api_key'], 'stats202AppKey' => $_SESSION['user_stats202_app_key'], 'postBackId' => $_GET['postBackId']); $url = TRACKING202_API_URL . '/stats202/deletePostBack?' . http_build_query($get); $xml = getUrl($url); header('location: ?deleteSuccess=1'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $get = array(); $get['apiKey'] = $_SESSION['user_api_key']; $get['stats202AppKey'] = $_SESSION['user_stats202_app_key']; $get['postBackUrl'] = $_POST['postBackUrl']; $query = http_build_query($get); $url = TRACKING202_API_URL . "/stats202/addPostBack?{$query}"; $xml = getUrl($url); $addPostBack = convertXmlIntoArray($xml); $errors = $addPostBack['errors']['error']; if (!$errors) { header('location: ?addSuccess=1'); } else { $html = array_map('htmlentities', $_POST); } } //build the get query for the offers202 restful api $get = array(); $get['apiKey'] = $_SESSION['user_api_key']; $get['stats202AppKey'] = $_SESSION['user_stats202_app_key']; $query = http_build_query($get); //build the offers202 api string $url = TRACKING202_API_URL . "/stats202/getPostBacks?{$query}"; #echo "<p>$url</p>";
$get['by'] = $_SESSION['stats202_by']; } if (!$_SESSION['stats202_by']) { $_SESSION['stats202_by'] = 'DESC'; } $get['limit'] = $_SESSION['stats202_limit']; if ($_POST['page']) { $get['offset'] = $get['limit'] * ($_POST['page'] - 1); } $query = http_build_query($get); //build the offers202 api string $url = TRACKING202_API_URL . "/stats202/getStats?{$query}"; #echo "$url<br/><br/>"; //grab the url $xml = getUrl($url); $getStats = convertXmlIntoArray($xml); checkForApiErrors($getStats); $getStats = $getStats['getStats']; $summary = $getStats['summary'][0]; $total_rows = $summary['total_rows']; $offset = $summary['offset']; $limit = $summary['limit']; $totalStatImpressions = $summary['totalStatImpressions']; $totalStatClicks = $summary['totalStatClicks']; $totalStatActions = $summary['totalStatActions']; $totalStatTotal = $summary['totalStatTotal']; $totalStatEpc = $summary['totalStatEpc']; $totalSubids = $summary['total_rows']; //paging $page = $_POST['page']; if (!$page) {
$_SESSION['stats202_limit'] = 500; } //only allow a 500 limit on this view if ($_SESSION['stats202_limit']) { $get['limit'] = $_SESSION['stats202_limit']; } if ($_POST['page']) { $get['offset'] = $get['limit'] * ($_POST['page'] - 1); } $query = http_build_query($get); //build the offers202 api string $url = TRACKING202_API_URL . "/stats202/getSubids?{$query}"; #echo "<p>$url</p>"; //grab the url $xml = getUrl($url); $getSubids = convertXmlIntoArray($xml); checkForApiErrors($getSubids); $getSubids = $getSubids['getSubids']; $summary = $getSubids['summary'][0]; $total_rows = $summary['total_rows']; $offset = $summary['offset']; $limit = $summary['limit']; $totalSubidActions = $summary['totalSubidActions']; $totalSubidAmount = $summary['totalSubidAmount']; $totalSubids = $summary['total_rows']; #print_r_html($summary); //paging $page = $_POST['page']; if (!$page) { $page = 1; }
$errors = $deleteStatAccount['errors']['error']; if (!$errors) { header('location: /stats202/setup/?delete=1'); die; } break; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $get = array('apiKey' => $_SESSION['user_api_key'], 'stats202AppKey' => $_SESSION['user_stats202_app_key'], 'statAccountId' => $_GET['statAccountId'], 'networkId' => $_POST['networkId'], 'statAccountNickName' => $_POST['statAccountNickName'], 'statAccountUser' => $_POST['statAccountUser'], 'statAccountPass' => $_POST['statAccountPass'], 'statAccountAffId' => $_POST['statAccountAffId']); if ($editing) { $url = TRACKING202_API_URL . '/stats202/editStatAccount?' . http_build_query($get); } else { $url = TRACKING202_API_URL . '/stats202/addStatAccount?' . http_build_query($get); } $addStatAccount = getUrl($url); $addStatAccount = convertXmlIntoArray($addStatAccount); #print_r_html($_POST); #print_r_html($addStatAccount); $errors = $addStatAccount['errors']['error']; if (!$errors) { $success = true; } if ($success) { header('location: /stats202/setup/?success=1'); die; } $html = array_map('htmlentities', $_POST); } if (isset($_GET['delete_stat_account_id'])) { $mysql['user_id'] = mysql_real_escape_string($_SESSION['user_id']); $mysql['stat_account_id'] = mysql_real_escape_string($_GET['delete_stat_account_id']);
//grab the url $xml = getUrl($url); $isDownloadComplete = convertXmlIntoArray($xml); checkForApiErrors($isDownloadComplete); $isDownloadComplete = $isDownloadComplete['isDownloadComplete']; $downloadComplete = $isDownloadComplete['downloadComplete']; if ($downloadComplete == 'false') { echo "<img src='/202-img/refresh-animated.gif' style='margin: 0px 5px -3px 0px;'/>Stats202 is now updating your subid conversions & earnings amount... this will only take a moment."; //mark this field that the download is not complete echo "<input type='hidden' id='downloadComplete' value='0'/>"; } else { //show the last time stats202 updated $url = TRACKING202_API_URL . "/stats202/getLastDownloadTime?{$query}"; //grab the url $xml = getUrl($url); $getLastDownloadTime = convertXmlIntoArray($xml); checkForApiErrors($getLastDownloadTime); $getLastDownloadTime = $getLastDownloadTime['getLastDownloadTime']; $lastDownloadTime = $getLastDownloadTime['lastDownloadTime']; //make a pretty date if ($lastDownloadTime != 'false') { $today_time = mktime(0, 0, 0, date('n', time()), date('j', time()), date('Y', time())); if ($lastDownloadTime >= $today_time) { $last_update_date = 'today at ' . date('g:i a', $lastDownloadTime); } else { //if yesterday $yesterday_time = $today_time - 86400; if ($lastDownloadTime >= $yesterday_time) { $last_update_date = 'yesterday at ' . date('g:i a', $lastDownloadTime); } else { //another day