function _default() { $this->output->secure(); $f = $this->input->f; if ($f[email] && $f[password] && $f[name] && $f[url]) { if ($_SESSION[user][admin] == 3) { $this->db->update("adrev_users", "id", $_REQUEST[id], $f); $this->output->redirect(lib_lang("The profile was updated"), "index.php?section=" . $_REQUEST[redir], 1); } else { $this->db->update("adrev_users", "id", $_SESSION[user][id], $f); $this->output->redirect(lib_lang("Your profile was updated"), "index.php?section=profile", 1); } exit; } if ($_SESSION[user][admin] == 3 && $_REQUEST[id]) { $id = $_REQUEST[id]; } else { $id = $_SESSION[user][id]; } $rec = $this->db->getsql("SELECT * FROM adrev_users WHERE id=?", array($id)); $f = $rec[0]; // Grab the list of language modules $modules = array(); if ($handle = opendir("lang")) { while (FALSE !== ($file = readdir($handle))) { if (preg_match('/^(.*?)\\.lng/i', $file, $match)) { $modules[$match[1]] = $match[1]; } } closedir($handle); } $form = new formgen(); $form->input("<b>" . lib_lang("Email") . "</b>", "f[email]", stripslashes($f[email]), 40); $form->input("<b>" . lib_lang("Password") . "</b>", "f[password]", stripslashes($f[password]), 20); $form->input("<b>" . lib_lang("Name") . "</b>", "f[name]", stripslashes($f[name]), 40); $form->input(lib_lang("Organization"), "f[organization]", stripslashes($f[organization]), 40); $form->dropdown(lib_lang("Country"), "f[country]", lib_htlist_array($this->default[country], $f[country])); $form->input(lib_lang("Street"), "f[street]", stripslashes($f[street]), 40); $form->input(lib_lang("City"), "f[city]", stripslashes($f[city]), 20); $form->input(lib_lang("State"), "f[state]", stripslashes($f[state]), 10); $form->input(lib_lang("Zip"), "f[postalcode]", stripslashes($f[postalcode]), 10); $form->input("<b>" . lib_lang("Url") . "</b>", "f[url]", stripslashes($f[url]), 50); $form->dropdown(lib_lang("Language"), "f[lang]", lib_htlist_array($modules, $f[lang])); $form->hidden("section", "profile"); $form->hidden("id", $id); $form->hidden("redir", $_REQUEST[redir]); $this->title = lib_lang("Edit Profile"); $this->content = $form->generate("post", lib_lang("Save Profile")); $this->display(); $this->printpage(); exit; }
function payment_form() { // Show the form $month = array(1 => "01", 2 => "02", 3 => "03", 4 => "04", 5 => "05", 6 => "06", 7 => "07", 8 => "08", 9 => "09", 10 => "10", 11 => "11", 12 => "12"); $year = array(date("Y"), date("Y") + 1, date("Y") + 2, date("Y") + 3, date("Y") + 4, date("Y") + 5, date("Y") + 6, date("Y") + 7, date("Y") + 8); $cards = array('Visa' => lib_lang('Visa'), 'MC' => lib_lang('Mastercard'), 'AMEX' => lib_lang('American Express'), 'Discover' => lib_lang('Discover')); $form = new formgen(); $form->comment(lib_lang("Your Billing Information")); $form->input("<b>" . lib_lang("First Name") . "</b>", "f[first_name]", $f[first_name], 30); $form->input("<b>" . lib_lang("Last Name") . "</b>", "f[last_name]", $f[last_name], 30); $form->dropdown("<b>" . lib_lang("Card Type") . "</b>", "f[cardtype]", lib_htlist_array($cards, $f[cardtype])); $form->dropdown("<b>" . lib_lang("Expire Month") . "</b>", "f[last_name]", lib_htlist_array($month, $f[month])); $form->dropdown("<b>" . lib_lang("Expire Year") . "</b>", "f[last_year]", lib_htlist_array($year, $f[year])); $form->input("<b>" . lib_lang("Card Number") . "</b>", "f[cardnumber]", $f[cardnumber], 20); $form->line(); $form->comment("<font size=3><b>" . lib_lang("Billing Address") . "</b></font>"); $form->dropdown(lib_lang("Country"), "f[country]", lib_htlist_array($this->default[country], $f[country])); $form->input("<b>" . lib_lang("Address 1") . "</b>", "f[address1]", $f[address1], 50); $form->input("<b>" . lib_lang("Address 2") . "</b>", "f[address2]", $f[address2], 50); $form->input("<b>" . lib_lang("City") . "</b>", "f[city]", $f[city], 25); if ($this->default[adrevenue][country] == "US") { $form->dropdown(lib_lang("US State"), "f[state]", lib_htlist_array($this->default[states], $f[state])); } else { $form->input("<b>" . lib_lang("State") . "</b>", "f[state]", $f[state], 20); } $form->input("<b>" . lib_lang("Phone") . "</b>", "f[phone]", $f[phone], 25); $form->input("<b>" . lib_lang("Email") . "</b>", "f[email]", $f[email], 25); $form->hidden("section", "pay"); $form->hidden("action", "form"); $form->hidden("f[amount]", $f[amount]); $this->output->title = lib_lang("Edit Your Profile"); $this->output->content = $form->generate("post", lib_lang("Save Profile")); $this->output->display(); $this->output->printpage(); exit; }
function stats() { $this->output->secure(); $f = $this->input->f; $uid = $_SESSION[user][id]; $dates = array('today' => 'Today', 'yesterday' => 'Yesterday', 'last7' => 'Last 7 days', 'thismonth' => 'This Month', 'lastmonth' => 'Last Month'); // Get the balance $bal = $this->db->getsql('SELECT sum(amount) as balance FROM adrev_aff_traffic WHERE affid=?', array($uid)); $balance = $bal[0]['balance']; if (is_numeric($_GET['transfer']) && $_GET['transfer'] > 0 && $_GET['transfer'] <= $balance) { // Make credit $i = array(); $i['date'] = time(); $i['affid'] = $uid; $i['adtype'] = 'XFER'; $i['adid'] = 0; $i['ip'] = $_SERVER['REMOTE_ADDR']; $i['referer'] = 'Transfer to Advertising credit.'; $i['amount'] = $_GET['transfer'] * -1; $this->db->insert('adrev_aff_traffic', $i); // Post to adrev_payments $i = array(); $i['date'] = time(); $i['userid'] = $uid; $i['description'] = 'Transferred publisher credit'; $i['amount'] = $_GET['transfer']; $this->db->insert('adrev_payments', $i); $this->output->redirect('@@Amount transferred to advertiser credit@@', 'index.php?section=account', 1); exit; } $start = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $end = mktime(23, 59, 59, date('m'), date('d'), date('Y')); if ($_GET['date'] == 'yesterday') { $start = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')); $end = mktime(23, 59, 59, date('m'), date('d') - 1, date('Y')); } elseif ($_GET['date'] == 'last7') { $start = time() - 86400 * 7; $end = time(); } elseif ($_GET['date'] == 'thismonth') { $start = mktime(0, 0, 0, date('m'), 1, date('Y')); $end = mktime(0, 0, 0, date('m'), date('t'), date('Y')); } elseif ($_GET['date'] == 'lastmonth') { $start = mktime(0, 0, 0, date('m') - 1, 1, date('Y')); $end = mktime(0, 0, 0, date('m') - 1, date('t', $start), date('Y')); } // By Zone $data = $this->db->getsql('SELECT count(a.id) as num, sum(a.amount) as total, a.adtype, b.zone FROM adrev_aff_traffic a, adrev_ads b WHERE a.affid=? AND a.adid=b.id AND (a.date BETWEEN ? AND ?) AND a.amount > 0 GROUP BY b.zone ORDER BY b.zone', array($uid, $start, $end)); // By Ad $data2 = $this->db->getsql('SELECT count(*) as num, adid, sum(amount) as earned, sum(spend) AS spend, max(referer) AS referer FROM adrev_aff_traffic WHERE affid=? AND (date BETWEEN ? AND ?) GROUP BY adid', array($uid, $start, $end)); $htlist = lib_htlist_array($dates, $_GET['date']); $table = '<form method="GET"><strong>@@View@@: </strong><select name="date" onChange="submit();">' . $htlist . '</select><input type="submit" value="Go" />' . '<input type="hidden" name="section" value="pub" /><input type="hidden" name="action" value="stats" /></form><hr size=1 noshade />'; $records = array(); if (count($data) > 0) { $table .= '<div style="width: 100%; text-align: right;"> <form method="GET">@@Transfer balance for advertiser credit@@: <input type="text" name="transfer" value="' . number_format($balance, 3) . '" size="8" /> <input type="submit" value="@@Transfer@@" /><input type="hidden" name="section" value="pub" /><input type="hidden" name="action" value="stats" /> </div>'; foreach ($data as $rec) { $records[$rec[zone]] = array($rec[adtype], $rec[num], $rec[total]); } if (count($records) > 0) { $gen = new formgen(); $gen->startrow("#CCCCCC"); $gen->column("<b>" . lib_lang("Zone") . "</b>"); $gen->column("<b>" . lib_lang("Earned") . "</b>", "", "", "", "right"); $gen->column(); $gen->endrow(); reset($records); $earned = 0; while (list($zone, $rec) = each($records)) { if ($rec[0] == "CPC") { $type = "Clicks"; } elseif ($rec[0] == "CPM") { $type = "Impressions"; } else { $type = "Days"; } // Get zone name $z = $this->db->getsql("SELECT name FROM adrev_zones WHERE id=?", array($zone)); $bgcolor = $bgcolor == "#FFFFFF" ? "#FFFFEE" : "#FFFFFF"; $gen->startrow($bgcolor); $gen->column(stripslashes($z[0][name])); $gen->column($rec[2], "", "", "", "right"); $gen->column("<a href=\"?section=pub&action=download&f[id]={$zone}\" title=\"Download to CSV\">@@Download Stats to CSV@@</a>"); $gen->endrow(); $earned += $rec[2]; } $gen->startrow("#FFFFFF"); $gen->column(); $gen->column("<b>" . number_format($earned, 2) . "</b>", "#CCCCCC", "", "", "right"); $gen->column(); $table .= $gen->gentable("75%", 0, 1, 3, "#FFFFFF"); } if (count($data2) > 0) { $table .= '<br/><h1>@@Detail by Units@@</h1>'; $gen = new formgen(); $gen->startrow('#CCCCCC'); $gen->column('<b>@@Description@@</b>'); $gen->column('<b>Impressions</b>', '', '', '', 'right'); $gen->column('<b>@@Earned@@</b>', '', '', '', 'right'); $gen->column('<b>@@Spend@@</b>', '', '', '', 'right'); $gen->column('<b>@@Avg@@%', '', '', '', 'right'); $gen->endrow(); $hits = 0; $earned = 0; $spend = 0; foreach ($data2 as $rec) { $bgcolor = $bgcolor == "#FFFFFF" ? "#FFFFEE" : "#FFFFFF"; $gen->startrow($bgcolor); if ($rec['adid'] == 0) { $gen->column($rec['referer']); } else { $a = $this->db->getsql('SELECT title,url FROM adrev_ads WHERE id=?', array($rec['adid'])); $gen->column($a[0]['title'] ? '<a href="' . $a[0]['url'] . '" target="_new">' . $a[0]['title'] . '</a>' : '[@@Deleted Ad@@]'); } $avg = $rec['earned'] > 0 && $rec['spend'] > 0 ? $rec['earned'] * 100 / $rec['spend'] : 0; $gen->column(number_format($rec['num']), '', '', '', 'right'); $gen->column(number_format($rec['earned'], 3), '', '', '', 'right'); $gen->column(number_format($rec['spend'], 3), '', '', '', 'right'); $gen->column(number_format($avg, 1) . '%', '', '', '', 'right'); $gen->endrow(); $hits += $rec['num']; $earned += $rec['earned']; $spend += $rec['spend']; } $gen->startrow('#FFFFFF'); $gen->column(); $gen->column('<b>' . number_format($hits) . '<b/>', '#CCCCCC', '', '', 'right'); $gen->column('<b>' . number_format($earned, 3) . '<b/>', '#CCCCCC', '', '', 'right'); $gen->column("<b>" . number_format($spend, 2) . "</b>", "#CCCCCC", "", "", "right"); $gen->column(); $table .= $gen->gentable("75%", 0, 1, 3, "#FFFFFF"); $table .= '<li><b>@@Impressions@@</b>: @@How many hits your website contributed for each unit@@</li>'; $table .= '<li><b>@@Earned@@</b>: @@How much you actually earned@@</li>'; $table .= '<li><b>@@Spend@@</b>: @@How much Revenue you contributed@@</li>'; $table .= '<li><b>@@Avg@@%</b>: @@The average percentage rate used to calculate your Earnings@@</li>'; } } $this->title = lib_lang("My Earnings") . ': <span style="color: green;">' . number_format($balance, 3) . '</span>'; $this->content = $table; $this->display(); $this->printpage(); exit; }
function view() { $this->output->admin(); $f = $this->input->f; $tpl = new XTemplate("templates/admin_user.html"); // Compute the balance and update it $b = $this->db->getsql("SELECT sum(amount) as spend FROM adrev_traffic WHERE userid=?", array($f['id'])); $spend = $b[0][spend]; // Grab payment history summary $h = $this->db->getsql("SELECT sum(amount) as paid FROM adrev_payments WHERE userid=?", array($f['id'])); $paid = $h[0][paid]; // Update balance $balance = $paid - $spend; if ($balance < 0) { $balance = 0.0; } $ts = time(); $this->db->getsql("UPDATE adrev_users SET balance='{$balance}',balance_update=? WHERE id=?", array($ts, $f['id'])); // Grab Payment History records $h = $this->db->getsql("SELECT * FROM adrev_payments WHERE userid=?", array($f['id'])); if (count($h) > 0) { foreach ($h as $rec) { $bgcolor = iif($bgcolor == "#FFFFFF", "#FFFFEE", "#FFFFFF"); $tpl->assign("BGCOLOR", $bgcolor); $tpl->assign("DATE", date("M d Y", $rec[date])); $tpl->assign("TYPE", iif($amount < 0, "DEBIT", "CREDIT")); $tpl->assign("DESC", stripslashes($rec[description])); $tpl->assign("AMOUNT", number_format($rec[amount], 2)); $tpl->parse("main.history"); } } // Load the user $u = $this->db->getsql("SELECT * FROM adrev_users WHERE id=?", array($f['id'])); $user = $u[0]; // Grab the list of ads $a = $this->db->getsql("SELECT a.id,a.title,a.status,a.zid,b.name,b.rate_type \r\n\t\t\t\t\t\t\t\tFROM adrev_ads a, adrev_zones b \r\n\t\t\t\t\t\t\t\tWHERE a.zone=b.id AND a.userid=? \r\n\t\t\t\t\t\t\t\tORDER BY date DESC LIMIT 50", array($f['id'])); if (count($a) > 0) { foreach ($a as $rec) { $bgcolor = iif($bgcolor == "#FFFFFF", "#FFFFEE", "#FFFFFF"); $tpl->assign("BGCOLOR", $bgcolor); $tpl->assign("TITLE", stripslashes($rec[title])); $tpl->assign("ZONE", $rec[name]); $tpl->assign("TYPE", $rec[rate_type]); $tpl->assign("STATUS", $this->default[status][$rec[status]]); $tpl->assign("ZID", $rec[zid]); $tpl->parse("main.ads"); } } // Setup the user section $admin = array(1 => lib_lang('Advertiser'), 2 => lib_lang('Publisher'), 3 => lib_lang('Administrator')); $status = array(1 => lib_lang('Active'), 0 => lib_lang('Inactive')); $tpl->assign("NAME", stripslashes($user[name])); $tpl->assign("EMAIL", stripslashes($user[email])); $tpl->assign("ID", $user[id]); $tpl->assign("ADMIN", lib_htlist_array($admin, $user[admin])); $tpl->assign("STATUS", lib_htlist_array($status, $user[status])); $tpl->assign("PASSWORD", stripslashes($user[password])); $tpl->assign("ORGANIZATION", stripslashes($user[organization])); $tpl->assign("COUNTRY", lib_htlist_array($this->default[country], $user[country])); $tpl->assign("STREET", stripslashes($user[street])); $tpl->assign("CITY", stripslashes($user[city])); $tpl->assign("STATE", stripslashes($user[state])); $tpl->assign("POSTALCODE", stripslashes($user[postalcode])); $tpl->assign("URL", stripslashes($user[url])); $tpl->assign("REF", stripslashes($user[ref])); $tpl->parse("main.user"); $tpl->assign("SEARCH", stripslashes($f[search])); $tpl->parse("users"); $tpl->assign("BALANCE", number_format($balance, 2)); $tpl->parse("main"); $this->title = lib_lang("Manage Users"); $this->content = $tpl->text("users") . "<br>" . $tpl->text("main"); $this->display(); $this->printpage(); exit; }
function register() { global $DEFAULT; $f = $this->input->f; if ($f[email] && $f[name] && $f[password] && $f[postalcode] && $f[city] && $f[state] && $f[country]) { // Check email for duplication $em = $this->db->getsql("SELECT id FROM adrev_users WHERE email=?", array($f['email'])); if ($em[0][id]) { $errormsg .= "<li> " . lib_lang("That email address was already used"); } if (!lib_checkemail($f[email])) { $errormsg .= "<li> " . lib_lang("Invalid Email Address Entered"); } if (!$f[postalcode]) { $errormsg .= "<li> " . lib_lang("Please enter your Postal/Zip Code"); } if (!$f[country]) { $errormsg .= "<li> " . lib_lang("Please choose a country"); } if (!$errormsg) { $i = array(); $i[email] = trim(strtolower($f[email])); $i[country] = $f[country] ? $f[country] : "US"; $i[password] = $f[password]; $i[name] = $f[name]; $i[organization] = $f[organization]; $i[country] = $f[country]; $i[street] = $f[street]; $i[city] = $f[city]; $i[state] = $f[state]; $i[postalcode] = $f[postalcode]; $i[url] = $f[url]; $i[admin] = $_REQUEST[t] == "pub" ? 2 : 1; $i[zid] = uniqid(""); $i['date'] = time(); $i[ip] = $_SERVER['REMOTE_ADDR']; $i[status] = $this->default[adrevenue][confirm_registration] ? 0 : 1; $i[ref] = $f[ref]; $this->db->insert("adrev_users", $i); // Notify us about new signups $d = array(); reset($i); while (list($key, $val) = each($i)) { $d[] = strtoupper($key) . '=' . $val; } $data = implode("\n", $d); mail($this->default[adrevenue][email], lib_lang('New Advertiser Signup'), lib_lang('A new advertiser signed up') . "\n", $data); // Send a confirmation email if ($this->default[adrevenue][confirm_registration]) { $tpl = new XTemplate("templates/user_confirm.txt"); $tpl->assign("ZID", $i[zid]); $tpl->parse("main"); $msg = $tpl->text("main"); mail($i[email], "[" . $this->default[adrevenue][name] . "] - " . lib_lang("Welcome - confirm your registration!"), $msg, "From: <" . $this->default[adrevenue][email] . ">"); $this->output->redirect(lib_lang("Please check your email for confirmation instructions"), "index.php?section=user&action=login", 5); } else { $this->output->redirect(lib_lang("Saving your registration"), "index.php?section=user&action=login", 2); } exit; } } // Set default country if (!$f[country]) { $f[country] = "US"; } $form = new formgen(); $adname = "Advertiser"; if ($_REQUEST[t] == "pub") { $adname = lib_lang("Publisher Registration"); } else { $adname = lib_lang("Advertiser Registration"); } $form->comment(lib_lang("Welcome! Please enter your information below.")); if ($this->default[adrevenue][confirm_registration]) { $form->comment(lib_lang("Please enter a valid email address, since you will receive account activation instructions there.")); } $form->comment("<font color=red>{$errormsg}</font>"); $form->input("<b>" . lib_lang("Email") . "</b>", "f[email]", stripslashes($f[email]), 40, lib_lang("Your email will also be your login name")); $form->input("<b>" . lib_lang("Password") . "</b>", "f[password]", stripslashes($f[password]), 20); $form->input("<b>" . lib_lang("Name") . "</b>", "f[name]", stripslashes($f[name]), 40); $form->input(lib_lang("Organization"), "f[organization]", stripslashes($f[organization]), 40); $form->dropdown("<b>" . lib_lang("Country") . "</b>", "f[country]", lib_htlist_array($this->default[country], $f[country])); $form->input("<b>" . lib_lang("Street") . "</b>", "f[street]", stripslashes($f[street]), 40); $form->input("<b>" . lib_lang("City") . "</b>", "f[city]", stripslashes($f[city]), 20); $form->input("<b>" . lib_lang("State") . "</b>", "f[state]", stripslashes($f[state]), 10); $form->input("<b>" . lib_lang("Zip/Postal Code") . "</b>", "f[postalcode]", stripslashes($f[postalcode]), 10); $form->input(lib_lang("Url"), "f[url]", stripslashes($f[url]), 50); $form->input(lib_lang("Referrer"), "f[ref]", stripslashes($f[ref]), 30); $form->hidden("section", "user"); $form->hidden("action", "register"); $form->hidden("t", $_REQUEST[t]); $this->title = $adname; $this->content = $form->generate("post", lib_lang("Register")); $this->display(); $this->printpage(); exit; }
function stats() { $this->output->secure(); $f = $this->input->f; $uid = $_SESSION['user']['id']; $tpl = new XTemplate("templates/ads_keywords.html"); // Grab the ad info $ad = $this->db->getsql("SELECT * FROM adrev_ads WHERE zid=?", array($f['id'])); $id = $ad['0']['id']; $zoneid = $ad['0']['zone']; // Grab the zone information $zone = $this->db->getsql("SELECT * FROM adrev_zones WHERE id=?", array($zoneid)); // Setup some defaults list($startdate, $enddate) = lib_date_range($f['period']); $dates = array("today" => lib_lang('Today'), "yesterday" => lib_lang('Yesterday'), "thisweek" => lib_lang('This Week'), "lastweek" => lib_lang('Last Week'), "thismonth" => lib_lang('This Month'), "lastmonth" => lib_lang('Last Month'), all => lib_lang('All Time')); // Show the stats for this word (up to 100 days worth) if (!$f['kid']) { $f['kid'] = 0; } $uid = $_SESSION['user']['id']; $stats = $this->db->getsql("SELECT * FROM adrev_traffic \r\n\t\t\t\t\t\t\t\t\t\tWHERE adid=? AND keywordid=? \r\n\t\t\t\t\t\t\t\t\t\tAND date BETWEEN ? AND ?\r\n\t\t\t\t\t\t\t\t\t\tORDER BY date DESC\r\n\t\t\t\t\t\t\t\t\t\tLIMIT 100", array($id, $f['kid'], $startdate, $enddate)); if (count($stats) > 0) { foreach ($stats as $rec) { $bgcolor = iif($bgcolor == "#FFFFFF", "#FFFFEE", "#FFFFFF"); $tpl->assign("BGCOLOR", $bgcolor); $tpl->assign("DATE", date("M d Y", strtotime($rec['date']))); $tpl->assign("CLICKS", number_format($rec['clicks'])); $tpl->assign("VIEWS", number_format($rec['impressions'])); $tpl->assign("ORDERS", number_format($rec['orders'])); $tpl->assign("SPEND", number_format($rec['amount'], 2)); $tpl->assign("CTR", number_format($rec['clicks'] * 100 / iif(!$rec['impressions'], 1, $rec['impressions']), 2)); $tpl->parse("main.list"); $t_impressions += $rec['impressions']; $t_clicks += $rec['clicks']; $t_orders += $rec['orders']; $t_spend += $rec['amount']; } $tpl->assign("TVIEWS", number_format($t_impressions)); $tpl->assign("TCLICKS", number_format($t_clicks)); $tpl->assign("TCTR", number_format($t_clicks * 100 / iif(!$t_impressions, 1, $t_impressions), 2)); $tpl->assign("TORDERS", number_format($t_orders)); $tpl->assign("TSPEND", number_format($t_spend, 2)); $tpl->parse("main.totals"); } // Show the keyword list if ($f['kid']) { $keywords = $this->db->getsql("SELECT b.id,b.keyword FROM adrev_keyword_map a, adrev_keywords b\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE a.keywordid=b.id AND a.zoneid=? AND a.adid=?\r\n\t\t\t\t\t\t\t\t\t\t\tORDER BY b.keyword", array($zoneid, $id)); $klist = array(); if (count($keywords) > 0) { foreach ($keywords as $rec) { $klist[$rec['id']] = $rec['keyword']; } $tpl->assign("KEYWORDLIST", lib_htlist_array($klist, $f['kid'])); } } $tpl->assign("PERIOD", date("D M d, Y", strtotime($startdate)) . " - " . date("D M d, Y", strtotime($enddate))); $tpl->assign("ID", $f['id']); $tpl->assign("KID", $f['kid']); $tpl->assign("PERIODLIST", lib_htlist_array($dates, $f['period'])); $tpl->assign("ADS_MENU", $this->menu($_REQUEST['f']['id'])); $tpl->parse("main"); $this->title = lib_lang("View Ad Stats"); $this->content = $tpl->text("main"); $this->display(); $this->printpage(); exit; }
function stats() { $this->output->admin(); $f = $this->input->f; $tpl = new XTemplate("templates/pub_user.html"); if (!$f[page]) { $f[page] = 1; } if (!$f[date]) { $f[date] = "thismonth"; } if (!$f[sort]) { $f[sort] = "date DESC,ip"; } list($startdate, $enddate) = lib_date_range($f['date']); // Grab the data for that page $limit = 100; $offset = ($f[page] - 1) * $limit; // Count records in set first $sdate = strtotime($startdate); $edate = strtotime($enddate) + 86400; $recs = $this->db->getsql("SELECT count(*) as num, sum(amount) as amount FROM adrev_aff_traffic \r\n\t\t\t\t\t\t\t\t\tWHERE affid=? AND date BETWEEN ? AND ?", array($f['id'], $sdate, $edate)); $z = $recs[0][num]; $amount = $recs[0][amount]; $pages = ceil($z / $limit); $prevpage = $f[page] - 1; $nextpage = $f[page] + 1; if ($f[page] > 1) { $pager .= "<a href=?section=pubadmin&action=stats&f[id]={$f['id']}&f[page]={$prevpage}&f[date]={$f['date']}&f[sort]={$f['sort']}&f[ip]={$f['ip']}>«Previous</a> "; } $pager .= "<b>" . number_format($z) . "</b> records. Page <font color=red>{$f['page']}</font> of <b>{$pages}</b> pages. "; if ($pages > $f[page]) { $pager .= " <a href=?section=pubadmin&action=stats&f[id]={$f['id']}&f[page]={$nextpage}&f[date]={$f['date']}&f[sort]={$f['sort']}&f[ip]={$f['ip']}>Next»</a>"; } // Show up to 20 page selector $pagelist = ""; for ($x = 1; $x <= $pages; $x++) { if ($x == $f[page]) { $pagelist .= " <b>{$x}</b>"; } else { $pagelist .= " <a href=?section=pubadmin&action=stats&f[id]={$f['id']}&f[page]={$x}&f[date]={$f['date']}&f[sort]={$f['sort']}&f[ip]={$f['ip']}>{$x}</a>"; } if ($x >= 20) { break; } } $pager .= " {$pagelist}"; $tpl->assign("PAGER", $pager); if ($z > 0) { if ($f[ip]) { $extra = "AND ip='{$f['ip']}'"; } $recs = $this->db->getsql("SELECT * FROM adrev_aff_traffic \r\n\t\t\t\t\t\t\t\t\tWHERE affid=? AND (date BETWEEN ? AND ?) {$extra}\r\n\t\t\t\t\t\t\t\t\tORDER BY ? LIMIT {$limit} OFFSET {$offset}", array($f['id'], $sdate, $edate, $f['sort'])); $gen = new formgen(); $gen->startrow("#CCCCCC"); $gen->column("<b>" . lib_lang("Date") . "</b>"); $gen->column("<b>" . lib_lang("Type") . "</b>"); $gen->column("<b>" . lib_lang("IP") . "</b>"); $gen->column("<b>" . lib_lang("Amount") . "</b>", "", "", "", "right"); $gen->column("<b>" . lib_lang("Page") . "</b>"); $gen->endrow(); foreach ($recs as $rec) { $ref = stripslashes($rec[referer]); if (strlen($ref) > 60) { $ref = substr($ref, 0, 30) . "..." . substr($ref, -30); } $bgcolor = $bgcolor == "#FFFFFF" ? "#FFFFEE" : "#FFFFFF"; $gen->startrow($bgcolor); $gen->column(date("m-d-Y h:i:sa", $rec[date])); $gen->column($rec[adtype]); $gen->column($rec[ip]); $gen->column(number_format($rec[amount], 3), "", "", "", "right"); $gen->column("<A href=\"{$rec['referer']}\" title=\"Open in new window\" target=\"_new\">{$ref}</a>"); $gen->endrow(); } $tpl->assign("TABLE", $gen->gentable("100%", 0, 1, 3, "#FFFFFF")); } $dates = array("today" => lib_lang('Today'), "yesterday" => lib_lang('Yesterday'), "thisweek" => lib_lang('This Week'), "lastweek" => lib_lang('Last Week'), "thismonth" => lib_lang('This Month'), "lastmonth" => lib_lang('Last Month'), all => lib_lang('All Time')); $tpl->assign("DATELIST", lib_htlist_array($dates, $f[date])); $tpl->assign("SORTLIST", lib_htlist_array(array('ip,date DESC' => 'IP Address', 'date DESC,ip' => 'Date'), $f[sort])); $tpl->assign("ID", $f[id]); $tpl->assign("IP", $f[ip]); $tpl->assign("BALANCE", number_format($amount, 3)); $tpl->parse("stats"); $this->title = lib_lang("Publisher Statistics"); $this->content = $tpl->text("stats"); $this->display(); $this->printpage(); exit; }
if (!$f[currency]) { $f[currency] = "USD"; } if (!$f[organization]) { $f[organization] = "My Advertising Portal"; } $dbs = array("mysql" => "MySQL"); if ($errormsg) { $form->comment("<font color=red>{$errormsg}</font>"); } $form->comment("<font size=3><b>Enter your database settings:</b></font>"); $form->dropdown("<b>DB Type</b>", "f[engine]", lib_htlist_array($dbs, $f[engine]), "Choose the kind of database server you have"); $form->input("<b>Hostname</b>", "f[host]", stripslashes($f[host]), 40, "The Domain Name or IP Address for your Database Server"); $form->input("<b>Username</b>", "f[user]", stripslashes($f[user]), 20, "Database Login"); $form->input("Password", "f[password]", stripslashes($f[password]), 20, "Database Password"); $form->input("<b>DB Name</b>", "f[database]", stripslashes($f[database]), 20, "The name of the database where Revsense Data will live. You should have already created this."); $form->comment("<hr size=1><b><font size=3>Enter your Site Settings:</font></b><br>"); $form->input("<b>Admin Email</b>", "f[email]", stripslashes($f[email]), 30); $form->input("<b>Admin Password</b>", "f[admin_password]", stripslashes($f[admin_password]), 20); $form->input("<b>Site Name</b>", "f[organization]", stripslashes($f[organization]), 30); $form->input("<b>URL</b>", "f[url]", stripslashes($f[url]), 50, "The URL where Revsense is installed. (It must have the trailing slash \"/\" at the end)."); $form->dropdown("<b>Country</b>", "f[country]", lib_htlist_array($DEFAULT[country], $f[country])); $form->input("<b>Currency</b>", "f[currency]", $f[currency], 5, "Your currency code -- eg: USD"); $out = $form->generate("post", "Create Revsense Installation") . "<p> "; $tpl->assign("BODY", $out); $tpl->assign("TITLE", "INSTALLATION STEP 2: Database Settings"); $tpl->parse("main"); echo $tpl->text("main"); exit; } exit;
function form() { // Secured $this->output->secure(); $f = $this->input->f; $parts = explode(" ", $_SESSION[user][name]); if (!$f[country]) { $f[country] = "US"; } if (!$f[email]) { $f[email] = $_SESSION[user][email]; } if (!$f[first_name]) { $f[first_name] = trim($parts[0]); } if (!$f[last_name]) { $f[last_name] = trim($parts[1]); } if (!$f[city]) { $f[city] = $_SESSION[user][city]; } if (!$f[state]) { $f[state] = $_SESSION[user][state]; } if (!$f[zip]) { $f[zip] = $_SESSION[user][postalcode]; } if (!$f[address]) { $f[address] = $_SESSION[user][street]; } if (!$f[amount]) { $f[amount] = $f[amount]; } // Setup a form $form = new formgen(); if ($f[errormsg]) { $form->comment("<li> <font color=red><b>{$f['errormsg']}</b></font>"); } $form->comment("<i>@@Please fill all applicable fields@@</i><br> "); $form->comment("<b>@@Address Information@@</b>"); $form->input("@@First Name@@", "f[first_name]", $f[first_name], 30); $form->input("@@Last Name@@", "f[last_name]", $f[last_name], 30); $form->input("@@Telephone@@", "f[phone]", $f[phone], 15); $form->input("@@Email@@", "f[email]", $f[email], 30); $form->input("@@Address@@", "f[address]", $f[address], 50); $form->input("@@City@@", "f[city]", $f[city], 20); $form->input("@@State@@", "f[state]", $f[state], 20); $form->input("@@Zip@@", "f[zip]", $f[zip], 10); $form->dropdown("@@Country@@", "f[country]", lib_htlist_array($this->default[country], $f[country])); // You can comment out these sections or add new fields as necessary $form->comment("<b>@@Billing Information@@</b>"); $form->input("@@CardNumber@@", "f[card_num]", $f[card_num], 30); $form->input("@@ExpireDate@@", "f[exp_date]", $f[exp_date], 10, "@@Format should be MM/YYYY@@"); $form->input("@@Card Code@@", "f[card_code]", $f[card_code], 5, "@@3 or 4 digit number on the back of your card@@"); $form->hidden("f[amount]", $f[amount]); $form->hidden("section", "pay"); $form->hidden("action", "process"); $this->title = lib_lang("Enter your Credit Card Information"); $this->content = $form->generate("post", lib_lang("Submit")); $this->display(); $this->printpage(); exit; }
function _default() { $this->output->admin(); $f = $this->input->f; // Save Settings if (count($f) > 0) { // set defaults for checkboxes if (!$f[confirm_registration]) { $f[confirm_registration] = 0; } if (!$f[approve_ads]) { $f[approve_ads] = 0; } reset($f); while (list($key, $val) = each($f)) { $this->save($key, $val); } $this->output->redirect("The site settings were updated", "index.php?section=settings", 1); exit; } // Loadup stuff $settings = $this->db->getsql("SELECT * FROM adrev_settings"); $set = array(); foreach ($settings as $rec) { $set[$rec[name]] = stripslashes($rec[value]); } // Grab list of payment modules $modules = array(); if ($handle = opendir("modules")) { while (FALSE !== ($file = readdir($handle))) { if (preg_match('/pay\\.(.*?)\\.php/i', $file, $match)) { $modules[$match[1]] = lib_lang(ucfirst($match[1])); } } closedir($handle); } $form = new formgen(); $form->comment("<font size=3><b>" . lib_lang("Site Properties") . "</b></font>"); $form->input(lib_lang("Site Name"), "f[name]", stripslashes($set[name]), 40); $form->input(lib_lang("URL"), "f[url]", stripslashes($set[url]), 50); $form->input(lib_lang("Email"), "f[email]", stripslashes($set[email]), 30); $form->input(lib_lang("Language"), "f[language]", stripslashes($set[language]), 5); $form->input(lib_lang("P3P Header"), "f[p3p]", stripslashes($set[p3p]), 60, lib_lang('Compact Privacy Policy Header') . '. <a href="http://www.w3.org/P3P/usep3p.html" target="_new">@@More about P3P@@</a>'); $form->input(lib_lang("Caching"), "f[cache]", stripslashes($set[cache]), 5, lib_lang("Caching time in seconds")); $form->checkbox(lib_lang("Registrations must be confirmed by email"), "f[confirm_registration]", 1, iif($set[confirm_registration] == 1, "CHECKED", "")); $form->line(); $form->comment("<font size=3><b>" . lib_lang("Fraud Protection") . "</b></font>"); $form->input(lib_lang("Duplicate Clicks"), "f[dup_clicks]", stripslashes($set[dup_clicks]), 5, lib_lang("This is the duplicate clicks threshold seconds.")); $form->input(lib_lang("Duplicate Impressions"), "f[dup_impressions]", stripslashes($set[dup_impressions]), 5, lib_lang("This is the duplicate impressions threshold seconds.")); $form->line(); $form->comment("<font size=3><b>" . lib_lang("Ad Settings") . "</b></font>"); $form->checkbox(lib_lang("Automatically approve ads."), "f[approve_ads]", 1, iif($set[approve_ads], "CHECKED", "")); $form->input(lib_lang("Min Bid"), "f[min_bid]", stripslashes($set[min_bid]), 10); $form->input(lib_lang("Max Bid"), "f[max_bid]", stripslashes($set[max_bid]), 10); $form->input(lib_lang("Min Payment"), "f[min_payment]", stripslashes($set[min_payment]), 10); $form->input(lib_lang("Currency"), "f[currency]", stripslashes($set[currency]), 5); $form->input(lib_lang("Symbol"), "f[currency_symbol]", stripslashes($set[currency_symbol]), 5); $form->input(lib_lang("Default Redir"), "f[default_redir]", stripslashes($set[default_redir]), 40, lib_lang("This is the URL that ads will go to if the url in the ad fails.")); if ($set[payment_module]) { $modlink = "<a href=?section=settings&action=pay_settings>@@Edit Payment Module Settings@@</a>"; } $form->dropdown(lib_lang("Payment Module"), "f[payment_module]", lib_htlist_array($modules, $set[payment_module]), $modlink); $form->line(); $form->comment("<font size=3><b>" . lib_lang("Content") . "</b></font>"); $form->comment("<font size=2>" . lib_lang("You can use HTML and images in any of the content fields below") . "</font>"); $form->textarea(lib_lang("Terms and Conditions"), "f[terms]", $set[terms], 6, 60, lib_lang("Enter your terms and conditions")); $form->textarea(lib_lang("Frontpage Content"), "f[frontpage]", $set[frontpage], 6, 60, lib_lang("This content will appear to users who are not logged in.")); $form->textarea(lib_lang("Advertiser Welcome Page"), "f[content_adv_login]", $set[content_adv_login], 6, 60, lib_lang("This content will appear to logged in advertisers")); $form->textarea(lib_lang("Publisher Welcome Page"), "f[content_pub_login]", $set[content_pub_login], 6, 60, lib_lang("This content will appear to logged in publishers")); $form->textarea(lib_lang("FAQ"), "f[faq]", $set[faq], 6, 60, lib_lang("Your FAQ")); $form->hidden("section", "settings"); $this->title = lib_lang("Edit AdRevenue Settings"); $this->content = $form->generate("post", lib_lang("Save Settings")); $this->display(); $this->printpage(); exit; }
function zone_format() { $this->output->admin(); $f = $this->input->f; $field_types = $this->default[field_types]; // Loadup the zone $z = $this->db->getsql("SELECT * FROM adrev_zones WHERE id=?", array($f['id'])); if (count($f[ad_format]) == 0) { $f[ad_format] = unserialize(stripslashes($z[0][ad_format])); } // Error finding zone if (!$z[0][id]) { $this->output->redirect(lib_lang("The zone could not be found"), "index.php?section=zone", 3); exit; } // Save the data if ($f[submit]) { // Cleanup the ad_format array(); reset($f[ad_format]); $n = count($f[ad_format]); for ($x = 0; $x <= $n; $x++) { if (!$f[ad_format][$x][type]) { unset($f[ad_format][$x]); } } $i = array(); $i[ad_sort] = iif($z[0][rtype] == 2, "bid", $f[ad_sort]); $i[urls_target] = $f[urls_target]; $i[urls_hide] = $f[urls_hide] ? 1 : 0; $i[urls_tracking] = $f[urls_tracking] ? 1 : 0; $i[ad_format] = serialize($f[ad_format]); $i[template] = trim(stripslashes($f[template])); $this->db->update("adrev_zones", "id", $f[id], $i); $this->output->redirect(lib_lang("Zone Format options were updated"), "index.php?section=zone&action=zone_format&f[id]={$f['id']}", 1); exit; } // Show the form $tpl = new XTemplate("templates/zone_format.html"); $sortlist = array("asc" => lib_lang("Oldest at top"), "desc" => lib_lang("Newest at Top"), "rand" => lib_lang("Random"), "bid" => lib_lang("By Bid Price")); $tpl->assign("AD_SORT", lib_htlist_array($sortlist, $z[0][ad_sort])); $target = array("_self" => lib_lang("Open ad in same window"), "_new" => lib_lang("Open ad in new window")); $tpl->assign("URLS_TARGET", lib_htlist_array($target, $z[0][urls_target])); $tpl->assign("URLS_HIDE", $z[0][urls_hide] ? "CHECKED" : ""); $tpl->assign("URLS_TRACKING", $z[0][urls_tracking] ? "CHECKED" : ""); // Show the rows $row = 0; while (list($key, $val) = each($field_types)) { $row++; $tpl->assign("NAME", iif($f[ad_format][$row][name], $f[ad_format][$row][name], $val)); $tpl->assign("TYPE", $key); $tpl->assign("ROW", $row); $tpl->assign("CHECKED", iif($f[ad_format][$row][type], "CHECKED", "")); $tpl->assign("BGCOLOR", iif($f[ad_format][$row][type], "#D2FFC4", "#FFFFFF")); // Non Image formats if ($key != "IMAGE") { $font = iif(!$f[ad_format][$row][font], "Verdana,Arial,Helvetica,sans-serif", $f[ad_format][$row][font]); $tpl->assign("FONT", "<input type=text name=\"f[ad_format][{$row}][font]\" value=\"{$font}\" size=10>"); $size = iif(!$f[ad_format][$row][size], "1", $f[ad_format][$row][size]); $tpl->assign("SIZE", "<input type=text name=\"f[ad_format][{$row}][size]\" value=\"{$size}\" size=1>"); $color = iif(!$f[ad_format][$row][color], "black", $f[ad_format][$row][color]); $tpl->assign("COLOR", "<input type=text name=\"f[ad_format][{$row}][color]\" value=\"{$color}\" size=6>"); $bold = iif(!$f[ad_format][$row][bold], "", "CHECKED"); $tpl->assign("BOLD", "<input type=checkbox name=\"f[ad_format][{$row}][bold]\" value=\"1\" {$bold}>"); // Set some better default sizes $size = 20; if ($key == "TITLE") { $size = 25; } if ($key == "DESCRIPTION") { $size = 64; } if ($key == "URL") { $size = 512; } if ($key == "DISPLAY_URL") { $size = 25; } if ($key == "EMAIL") { $size = 64; } if ($key == "PHONE") { $size = 15; } if ($key == "FAX") { $size = 15; } if ($key == "CONTENT") { $size = 8192; } if (preg_match('/CUSTOM/', $key)) { $size = 32; } $max_length = iif(!$f[ad_format][$row][max_length], $size, $f[ad_format][$row][max_length]); $tpl->assign("MAX_LENGTH", "<input type=text name=\"f[ad_format][{$row}][max_length]\" value=\"{$max_length}\" size=5>"); $tpl->assign("MAX_UPLOAD", " "); $tpl->assign("HEIGHT", " "); $tpl->assign("WIDTH", " "); } else { $tpl->assign("BOLD", " "); $tpl->assign("COLOR", " "); $tpl->assign("SIZE", " "); $tpl->assign("FONT", " "); $tpl->assign("MAX_LENGTH", " "); $max_upload = iif(!$f[ad_format][$row][max_length], "65536", $f[ad_format][$row][max_length]); $tpl->assign("MAX_UPLOAD", "<input type=text name=\"f[ad_format][{$row}][max_length]\" value=\"{$max_upload}\" size=5>"); $height = iif(!$f[ad_format][$row][height], "60", $f[ad_format][$row][height]); $tpl->assign("HEIGHT", "<input type=text name=\"f[ad_format][{$row}][height]\" value=\"{$height}\" size=4>"); $width = iif(!$f[ad_format][$row][width], "480", $f[ad_format][$row][width]); $tpl->assign("WIDTH", "<input type=text name=\"f[ad_format][{$row}][width]\" value=\"{$width}\" size=4>"); } $tpl->parse("main.formatlist"); } // Grab the ad type for this zone $style = $z[0][style]; $s = $this->db->getsql("SELECT * FROM adrev_ad_types WHERE id=?", array($style)); $tpl->assign("FIELD_TYPES", lib_htlist_array($field_types, '0')); $tpl->assign("ID", $f[id]); $tpl->assign("ZONE_MENU", $this->zone_menu($f[id])); $tpl->assign("TEMPLATE", htmlentities(stripslashes($z[0][template]), ENT_QUOTES)); // Preview the template $ad = $this->db->getsql("SELECT zid FROM adrev_ads WHERE zone=? LIMIT 1", array($f['id'])); if (!$ad[0][zid]) { $tpl->assign("PREVIEW", lib_lang("You need to place at least one ad in this zone for a preview to be generated")); } else { include_once "modules/preview.php"; $p = new preview(); $p->main(); $p->zid = $ad[0][zid]; $preview = $p->display(); $tpl->assign("PREVIEW", $preview); } $tpl->parse("main"); $this->title = lib_lang("Manage") . " [" . stripslashes($z[0][name]) . "] : " . lib_lang("Format"); $this->content = $tpl->text("main"); $this->display(); $this->printpage(); exit; }