public function indexAction() { //get the aff_camapaign_id $mysql['use_pixel_payout'] = 0; //see if it has the cookie in the campaign id, then the general match, then do whatever we can to grab SOMETHING to tie this lead to if ($_COOKIE['btclickid']) { $click_pid = $_COOKIE['btclickid']; } else { //ok grab the last click from this ip_id $mysql['ip_address'] = DB::quote($_SERVER['REMOTE_ADDR']); $daysago = time() - 2592000; // 30 days ago $click_sql1 = "\tSELECT \tbt_s_clicks.click_id\n\t\t\t\t\t\t\tFROM \t\tbt_s_clicks\n\t\t\t\t\t\t\tLEFT JOIN\tbt_s_clicks_advanced USING (click_id)\n\t\t\t\t\t\t\tLEFT JOIN \tbt_s_ips USING (ip_id)\n\t\t\t\t\t\t\tWHERE \tbt_s_ips.ip_address='" . $mysql['ip_address'] . "'\n\t\t\t\t\t\t\tAND\t\tbt_s_clicks.time >= '" . $daysago . "'\n\t\t\t\t\t\t\tORDER BY \tbt_s_clicks.click_id DESC\n\t\t\t\t\t\t\tLIMIT \t\t1"; $click_row1 = DB::getRow($click_sql1); $click_pid = base_convert($click_row1['click_id'], 10, 36); $mysql['ad_account_id'] = DB::quote($click_row1['ad_account_id']); } $click = ClickModel::model()->getRow(array('conditions' => array('click_id' => base_convert($click_pid, 36, 10)))); if (!$click) { BTApp::end(); } if ($click->get('ad_account_id')) { if (getArrayVar($_GET, 'amount') && is_numeric($_GET['amount'])) { $mysql['use_pixel_payout'] = 1; } if ($mysql['use_pixel_payout'] == 1) { $click->convert(0, $_GET['amount']); } else { $click->convert(); } if ($click->campaign->option('pixel_type')->value) { $sql = "select v1.var_value as v1, v2.var_value as v2, v3.var_value as v3, v4.var_value as v4 from bt_s_clicks_advanced adv\n\t\t\t\t\tleft join bt_s_variables v1 on (v1.var_id=adv.v1_id)\n\t\t\t\t\tleft join bt_s_variables v2 on (v2.var_id=adv.v2_id)\n\t\t\t\t\tleft join bt_s_variables v3 on (v3.var_id=adv.v3_id)\n\t\t\t\t\tleft join bt_s_variables v4 on (v4.var_id=adv.v4_id)\n\t\t\t\t\twhere adv.click_id=?"; $st = DB::prepare($sql); $st->execute(array($click->id())); $row = $st->fetch(); $data['v1'] = $row['v1']; $data['v2'] = $row['v2']; $data['v3'] = $row['v3']; $data['v4'] = $row['v4']; $data['clickid'] = $click->id(); $data['keyword'] = ''; $data['amount'] = $click->payout; $code = replaceTrackerPlaceholders($click->campaign->option('pixel_code')->value, $data); $code = str_replace('[[amount]]', $data['amount'], $code); switch ($click->campaign->option('pixel_type')->value) { case 1: case 2: case 3: echo $code; break; case 4: $ch = curl_init($code); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 Postback-Bot v1.0'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_exec($ch); break; } } } }
public function ajaxAction($command = '', $params = array()) { switch ($command) { case 'view_accountlist': $userlist = UserModel::model()->getRows(); $this->setVar("userlist", $userlist); $this->loadView("admin/accounts_list"); break; case 'json_user': $user = UserModel::model()->getRowFromPk($_GET['user_id']); echo $user->toJSON(); break; case 'post_delete': $user_id = $_POST['user_id']; $user = UserModel::model()->getRowFromPk($user_id); $user->delete(); break; case 'post_add': $user = UserModel::model(); $user->user_name = $_POST['user_name']; $user->email = $_POST['email']; $user->plain_pass = $_POST['pass']; $user->pass = $_POST['pass']; $user->pass_confirm = $_POST['pass_confirm']; $user->privilege = $_POST['privilege']; $user->useRuleSet("admin_new"); if ($user->save()) { echo '0'; } else { echo join('<br>', $user->getErrors()); } break; case 'post_edit': $user = UserModel::model()->getRowFromPk($_POST['user_id']); if (!$user) { echo "Bad ID"; BTApp::end(); } $user->user_name = $_POST['user_name']; $user->email = $_POST['email']; if ($_POST['pass']) { $user->plain_pass = $_POST['pass']; $user->pass = $_POST['pass']; $user->pass_confirm = $_POST['pass_confirm']; } else { //to satisfy the validation $user->pass = $user->pass; $user->pass_confirm = $user->pass; } $user->privilege = $_POST['privilege']; $user->useRuleSet("admin_edit"); if ($user->save()) { echo '0'; } else { echo join('<br>', $user->getErrors()); } break; } }
public function lostPassAction() { if (BTAuth::logged_in()) { header('location: /overview'); BTApp::end(); } if (isset($_POST['cancel']) && $_POST['cancel']) { header("Location: /login"); BTApp::end(); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $mysql['user_name'] = $_POST['user_name']; $mysql['email'] = $_POST['email']; $user_row = UserModel::model()->getRow(array('conditions' => array('email' => $_POST['email']))); if ($user_row && $user_row->get('user_name') != $_POST['user_name']) { $user_row = null; } if (!$user_row) { $error['user'] = '******'; } //i there isn't any error, give this user, a new password, and email it to them! if (!$error) { $mysql['user_id'] = $user_row->id(); //generate random key $pass_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $pass_key = substr(str_shuffle($pass_key), 0, 40) . time(); $mysql['pass_key'] = $pass_key; //set the user pass time $mysql['pass_time'] = time(); //insert this verification key into the database, and the timestamp of inserting it $user_row->pass_key = $mysql['pass_key']; $user_row->pass_time = $mysql['pass_time']; $user_row->save(); //now email the user the script to reset their email $to = $_POST['email']; $subject = "Ballistic Tracking Password Reset"; $message = "\n\t\t<p>Someone has asked to reset the password for the following username.</p>\n\t\t\t\t\n\t\t<p>Username: "******"</p>\n\t\t\n\t\t<p>To reset your password visit the following address, otherwise just ignore this email and nothing will happen.</p>\n\t\t\n\t\t<p><a href=\"" . getBTUrl() . "/login/passReset?key={$pass_key}\">" . getBTUrl() . "/login/passReset?key={$pass_key}</a></p>"; $from = "ballistictracking@" . $_SERVER['SERVER_NAME']; $header = "From: Ballistic Tracking<" . $from . "> \r\n"; $header .= "Reply-To: " . $from . " \r\n"; $header .= "To: " . $to . " \r\n"; $header .= "Content-Type: text/html; charset=\"iso-8859-1\" \r\n"; $header .= "Content-Transfer-Encoding: 8bit \r\n"; $header .= "MIME-Version: 1.0 \r\n"; mail($to, $subject, $message, $header); $success = true; } $html['user_name'] = BTHtml::encode($_POST['user_name']); $html['email'] = BTHtml::encode($_POST['email']); } $this->setVar("title", "Reset Your Password"); $this->loadTemplate("public_header"); $this->setVar("success", $success); $this->setVar("html", $html); $this->setVar("error", $error); $this->loadView("login/lostpass"); $this->loadTemplate("public_footer"); }
public function addOption($name, $value) { BTApp::importModel('CampaignOptionModel'); $opt = CampaignOptionModel::model(); $opt->name = $name; $opt->value = $value; $opt->campaign_id = $this->id(); $opt->useRuleSet('new'); return $opt->save(); }
public function deleteAction() { $id = $_GET['id']; $source = TrafficSourceModel::model()->getRowFromPk($id); if ($source) { $source->delete(); } header("Location: /trafficsources"); BTApp::end(); }
public function clearDataAction() { BTApp::importModel("ClickModel"); BTApp::importModel("ClickSiteModel"); BTApp::importModel("ClickAdvancedModel"); BTApp::importModel("ClickPassthroughModel"); ClickSiteModel::model()->deleteOldData(); ClickAdvancedModel::model()->deleteOldData(); ClickModel::model()->deleteOldData(); ClickPassthroughModel::model()->deleteOldData(); }
public function beforeSave() { parent::beforeSave(); if ($this->isNew()) { $this->time = time(); BTApp::importModel("ClickCounterModel"); $cnt = ClickCounterModel::model()->getRow(); $cnt->inc(); $this->click_id = $cnt->click_count; } }
public function delete($bit = 0) { if (!$bit || $bit == DELETE_BIT_SELF) { $this->deleted = 1; $this->useRuleSet('delete'); $this->save(); BTApp::importModel('CampaignModel'); CampaignModel::model()->deleteAll(array('traffic_source_id' => $this->id()), DELETE_BIT_TRAFFIC_SOURCE); } return true; }
function error404() { //Failsafe, to prevent an infinite routing loop :) if (strpos($_SERVER['REQUEST_URI'], 'error') !== false) { //An error page 404'ed. This is bad. echo "Critical server error."; BTApp::log("Encountered error 404 while loading an error page: " . $_SERVER['REQUEST_URI'], "router", BT_SYSLOG_CRITICAL); BTApp::end(); } //Let's just "tell" the app/router to try again - this time loading the error controller & 404 page. $_SERVER['REQUEST_URI'] = '/error/error404'; BTApp::routeRequest(); BTApp::end(); }
public function indexAction() { if (isset($_COOKIE['user_inject'])) { setcookie("user_inject", '', time() - 60 * 60 * 24, "/", $_SERVER['HTTP_HOST']); BTAuth::require_user(); if (BTAuth::authUser()->isAdmin()) { if (BTAuth::user()->id() != BTAuth::authUser()->id()) { //if in a "view as" session header('Location: /admin/accounts'); BTApp::end(); } } } $redir_url = '/'; BTAuth::set_auth_cookie('', time() - 3600); header('location: ' . $redir_url); }
public function IndexAction() { if (!getArrayVar($_GET, 'clickid')) { BTApp::log("No SubID", 'postback_pixel', BT_SYSLOG_CRITICAL); } $click_pid = getArrayVar($_GET, 'clickid'); $mysql['click_id'] = DB::quote(base_convert($click_pid, 36, 10)); $mysql['pixel_id'] = 0; $mysql['use_pixel_payout'] = 0; if ($click_pid) { if ($_GET['amount'] && is_numeric($_GET['amount'])) { $mysql['use_pixel_payout'] = 1; $mysql['payout'] = DB::quote($_GET['amount']); } $click = ClickModel::model()->getRow(array('conditions' => array('click_id' => $mysql['click_id']))); if (!$click) { BTApp::end(); } if ($mysql['use_pixel_payout'] == 1) { $click->convert(0, $mysql['payout']); } else { $click->convert(); } if ($click->campaign->option('pixel_type')->value == 4) { $data = array(); $sql = "select v1.var_value as v1, v2.var_value as v2, v3.var_value as v3, v4.var_value as v4 from bt_s_clicks_advanced adv\n\t\t\t\t\tleft join bt_s_variables v1 on (v1.var_id=adv.v1_id)\n\t\t\t\t\tleft join bt_s_variables v2 on (v2.var_id=adv.v2_id)\n\t\t\t\t\tleft join bt_s_variables v3 on (v3.var_id=adv.v3_id)\n\t\t\t\t\tleft join bt_s_variables v4 on (v4.var_id=adv.v4_id)\n\t\t\t\t\twhere adv.click_id=?"; $st = DB::prepare($sql); $st->execute(array($click->id())); $row = $st->fetch(); $data['v1'] = $row['v1']; $data['v2'] = $row['v2']; $data['v3'] = $row['v3']; $data['v4'] = $row['v4']; $data['clickid'] = $click->id(); $data['keyword'] = ''; $data['amount'] = $click->payout; $pb_url = replaceTrackerPlaceholders($click->campaign->option('pixel_code')->value, $data); $pb_url = str_replace('[[amount]]', $data['amount'], $pb_url); $ch = curl_init($pb_url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 Postback-Bot v1.0'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_exec($ch); } } }
<?php BTApp::importModel('UserPrefModel'); class UserModel extends BTModel { public function tableName() { return 'bt_u_users'; } public function pk() { return 'user_id'; } public function relations() { return array('prefs' => array('UserPrefModel', 'user_id', self::REL_ONE_MANY, 'name', array(UserPrefModel::model(), 'setDefaultPreferences'))); } public function rules() { return array(array('user_name', 'required', array('message' => 'Please enter an account name', 'for' => array('admin_edit', 'admin_new'))), array('user_name', 'length', array('min' => 1, 'max' => 50, 'message' => 'Invalid account name', 'for' => array('admin_edit', 'admin_new'))), array('user_name', 'callback', array('func' => array('UserModel', 'usernameFree'), 'message' => 'That username is taken')), array('email', 'required', array('message' => 'Please enter your email', 'for' => array('user_profile', 'admin_edit', 'admin_new'))), array('email', 'email', array('message' => 'Invalid email', 'for' => array('user_profile', 'admin_edit', 'admin_new'))), array('email', 'callback', array('func' => array('UserModel', 'emailFree'), 'message' => 'That email is taken')), array('timezone', 'required', array('for' => 'user_profile')), array('old_pass', 'callback', array('for' => array('user_profile_password'), 'func' => array($this, 'checkUserPass'), 'message' => 'Please enter your current password')), array('pass', 'required', array('for' => array('user_profile_password', 'admin_new'), 'message' => "Please enter a password")), array('pass_confirm', 'required', array('for' => array('user_profile_password', 'admin_new'), 'message' => "Please confirm your password")), array('pass', 'optional', array('for' => array('admin_edit'))), array('pass_confirm', 'compare', array('to' => 'pass', 'for' => array('user_profile_password', 'admin_edit', 'admin_new'), 'message' => "Please confirm your password")), array('privilege', 'required', array('for' => array('admin_edit', 'admin_new')))); } public function filters() { return array('deleted' => 0); } public function deletedColumn() { return "deleted"; } public function delete($flag = 0) {
protected function editCampaign() { DB::startTransaction(); if (!($campaign = CampaignModel::model()->getRowFromPk($_POST['campaign_id']))) { echo json_encode(array('message' => 'Could not save: invalid campaign ID')); DB::rollback(); BTApp::end(); } $campaign->name = $_POST['name']; $campaign->cloaker_id = $_POST['cloaker_id']; $campaign->slug = $_POST['slug']; $campaign->save(); switch ($campaign->type) { case 1: foreach ($campaign->offers as $offer) { if (!in_array($offer->id(), $_POST['campaign_lpoffer_id'])) { $offer->delete(); } } for ($i = 0, $cnt = count($_POST['campaign_lpoffer_id']); $i < $cnt; $i++) { $id = $_POST['campaign_lpoffer_id'][$i]; if (!$id) { //new $offer = OfferModel::model(); $offer->aff_network_id = $_POST['lpoffer_aff_network_id'][$i]; $offer->name = $_POST['lpoffer_name'][$i]; $offer->url = $_POST['lpoffer_url'][$i]; $offer->payout = $_POST['lpoffer_payout'][$i]; if (!$offer->save()) { echo json_encode(array('message' => 'Could not add offers')); DB::rollback(); BTApp::end(); } $campoffer = CampaignOfferModel::model(); $campoffer->campaign_id = $campaign->id(); $campoffer->position = 0; $campoffer->weight = 0; $campoffer->offer_id = $offer->id(); if (!$campoffer->save()) { echo json_encode(array('message' => 'Could not add campaign offers')); DB::rollback(); BTApp::end(); } } else { //edit $campoffer = CampaignOfferModel::model()->getRowFRomPk($id); $offer = $campoffer->offer; $offer->aff_network_id = $_POST['lpoffer_aff_network_id'][$i]; $offer->name = $_POST['lpoffer_name'][$i]; $offer->url = $_POST['lpoffer_url'][$i]; $offer->payout = $_POST['lpoffer_payout'][$i]; if (!$offer->save()) { echo json_encode(array('message' => 'Could not save offers')); DB::rollback(); BTApp::end(); } } } foreach ($campaign->landing_pages as $lp) { if (!in_array($lp->id(), $_POST['campaign_lp_id'])) { $lp->delete(); } } for ($i = 0, $cnt = count($_POST['campaign_lp_id']); $i < $cnt; $i++) { $id = $_POST['campaign_lp_id'][$i]; if (!$id) { //new $lp = LandingPageModel::model(); $lp->name = $_POST['lp_name'][$i]; $lp->url = $_POST['lp_url'][$i]; if (!$lp->save()) { echo json_encode(array('message' => 'Could not add LPs')); DB::rollback(); BTApp::end(); } $camp_lp = CampaignLPModel::model(); $camp_lp->campaign_id = $campaign->id(); $camp_lp->landing_page_id = $lp->id(); $camp_lp->weight = $_POST['lp_weight'][$i]; if (!$camp_lp->save()) { echo json_encode(array('message' => 'Could not add campaign LPs')); DB::rollback(); BTApp::end(); } } else { //edit $camp_lp = CampaignLPModel::model()->getRowFromPk($id); $camp_lp->weight = $_POST['lp_weight'][$i]; if (!$camp_lp->save()) { echo json_encode(array('message' => 'Could not save campaign LPs')); DB::rollback(); BTApp::end(); } $lp = $camp_lp->landing_page; $lp->name = $_POST['lp_name'][$i]; $lp->url = $_POST['lp_url'][$i]; if (!$lp->save()) { echo json_encode(array('message' => 'Could not save LPs')); DB::rollback(); BTApp::end(); } } } break; case 2: foreach ($campaign->offers as $offer) { if (!in_array($offer->id(), $_POST['campaign_offer_id'])) { $offer->delete(); } } for ($i = 0, $cnt = count($_POST['campaign_offer_id']); $i < $cnt; $i++) { $id = $_POST['campaign_offer_id'][$i]; if (!$id) { //new $offer = OfferModel::model(); $offer->aff_network_id = $_POST['offer_aff_network_id'][$i]; $offer->name = $_POST['offer_name'][$i]; $offer->url = $_POST['offer_url'][$i]; $offer->payout = $_POST['offer_payout'][$i]; if (!$offer->save()) { echo json_encode(array('message' => 'Could not save offers')); DB::rollback(); BTApp::end(); } $campoffer = CampaignOfferModel::model(); $campoffer->campaign_id = $campaign->id(); $campoffer->position = 0; $campoffer->weight = $_POST['offer_weight'][$i]; $campoffer->offer_id = $offer->id(); if (!$campoffer->save()) { echo json_encode(array('message' => 'Could not save offers')); DB::rollback(); BTApp::end(); } } else { //edit $campoffer = CampaignOfferModel::model()->getRowFRomPk($id); $campoffer->weight = $_POST['offer_weight'][$i]; if (!$campoffer->save()) { echo json_encode(array('message' => 'Could not save offers')); DB::rollback(); BTApp::end(); } $offer = $campoffer->offer; $offer->name = $_POST['offer_name'][$i]; $offer->aff_network_id = $_POST['offer_aff_network_id'][$i]; $offer->url = $_POST['offer_url'][$i]; $offer->payout = $_POST['offer_payout'][$i]; if (!$offer->save()) { echo json_encode(array('message' => 'Could not save offers')); DB::rollback(); BTApp::end(); } } } break; } foreach ($_POST['opt'] as $name => $val) { $opt = $campaign->options[$name]; $opt->value = $val; if (!$opt->save()) { DB::rollback(); echo json_encode(array('message' => 'Could not save options')); BTApp::end(); } } foreach ($campaign->options as $option) { if (strpos($option->name, 'pass_') === 0) { $option->delete(); } } for ($j = 0, $cnt = count($_POST['variable_name']); $j < $cnt; $j++) { $name = $_POST['variable_name'][$j]; $name = 'pass_' . $name; if ($campaign->type == 1) { $pass_lp = $_POST['variable_lp'][$j]; $pass_offer = $_POST['variable_offer'][$j]; $val = json_encode(array('lp' => $pass_lp, 'offer' => $pass_offer)); } else { $val = json_encode(array('offer' => '1')); } if (!$campaign->addOption($name, $val)) { DB::rollback(); echo json_encode(array('message' => 'Could not save Variables Passthroughs')); BTApp::end(); } } DB::commit(); echo json_encode(array('message' => '2', 'campaign_id' => $campaign->id())); }
public function saveData($campaign, $cloaked = 0, $outbound_url = '') { $offer_id = 0; $landing_page_id = 0; if ($campaign->type == 2) { $campoffer = rotateDirectCampaign($campaign); if (!$campoffer) { BTApp::log("Direct Link: Invalid Offers For Tracker: " . $campaign->id(), 'direct', BT_SYSLOG_CRITICAL); } $payout = $campoffer->offer->payout; $offer_id = $campoffer->offer->id(); } else { if ($campaign->type == 1) { $camplp = rotateLPCampaign($campaign); $payout = 0; $landing_page = $camplp->landing_page; $landing_page_id = $landing_page->id(); if (!$landing_page) { BTApp::log("Landing Page: Invalid Landing Page ID: " . $landing_page_id . " For Tracker: " . $campaign->id(), 'direct', BT_SYSLOG_CRITICAL); } } } $ip_id = INDEXES::get_ip_id($_SERVER['REMOTE_ADDR']); $click = new ClickModel(); $click->offer_id = $offer_id; $click->landing_page_id = $landing_page_id; $click->traffic_source_id = $campaign->traffic_source_id; $click->payout = $payout; $click->filtered = FILTER::startFilter($ip_id); $click->user_id = $campaign->user_id; $click->cloaked = $cloaked; $click->campaign_id = $campaign->id(); $click->useRuleSet("track"); $click->save(); $vars = saveTrackingVariables($campaign); //if behind cloaker scripts, we use $_POST. Otherwise (normally) use HTTP_REFERER $referer = isset($_POST['referer']) ? $_POST['referer'] : getArrayVar($_SERVER, 'HTTP_REFERER'); $keyword = getArrayVar($_GET, $campaign->option('var_kw')->value); if (!$keyword) { $keyword = getArrayVar($_GET, 'kw'); if (!$keyword) { $keyword = getArrayVar($_GET, 'keyword'); } } $keyword_id = INDEXES::get_keyword_id($keyword); $platform = INDEXES::get_platform_and_browser_id(); $organization_id = 0; $geo_block_id = 0; $device_id = 0; require BT_ROOT . '/private/includes/traffic/devices_detect_inc.php'; $adv = new ClickAdvancedModel(); $adv->click_id = $click->id(); $adv->keyword_id = $keyword_id; $adv->ip_id = $ip_id; $adv->platform_id = $platform['platform']; $adv->browser_id = $platform['browser']; $adv->org_id = $organization_id; $adv->device_id = $device_id; $adv->v1_id = $vars['v1_id']; $adv->v2_id = $vars['v2_id']; $adv->v3_id = $vars['v3_id']; $adv->v4_id = $vars['v4_id']; $adv->location_id = $geo_block_id; $adv->campaign_id = $campaign->id(); $adv->useRuleSet('track'); $adv->save(); $data = $vars; $data['keyword'] = $keyword; $data['clickid'] = base_convert($click->click_id, 10, 36); if ($offer_id) { if ($outbound_url) { $redirect_url = $outbound_url; } else { $redirect_url = $campoffer->offer->url; $redirect_url = replaceTrackerPlaceholders($redirect_url, $data); } $landing_url = ''; } else { $redirect_url = ''; if ($outbound_url) { $landing_url = $outbound_url; } else { $landing_url = $landing_page->url; } } //set the cookie setClickIdCookie(base_convert($click->click_id, 10, 36)); $site = new ClickSiteModel(); $site->click_id = $click->id(); $site->referer_url = $referer; $site->referer_domain = getUrlDomain($referer); $site->offer_url = $redirect_url; $site->landing_url = $landing_url; $site->useRuleSet('track'); $site->save(); $pass_vars = array(); $to_append = ''; if ($landing_page_id) { $type = 'lp'; } else { $type = 'offer'; } foreach ($campaign->options as $option) { if (strpos($option->name, 'pass_') === 0) { $var_name = substr($option->name, 5); $val = getArrayVar($_GET, $var_name, ''); $pass = new ClickPassthroughModel(); $pass->click_id = $click->click_id; $pass->name = $var_name; $pass->value = $val; $pass->useRuleSet('track'); $pass->save(); $pass_vars[$var_name] = $pass; } } $to_append = http_build_query($this->getPassthroughsToAppend($campaign, $pass_vars, $type)); if ($offer_id) { //direct return appendQueryString($redirect_url, $to_append); } else { //lp return appendQueryString($landing_url, $to_append); } }
function printQueryLogFirePhp() { if (LIVE_SITE) { return; } $log = DB::queryLog(); foreach ($log as $entry) { BTApp::firelog($entry['query'] . ' - ' . $entry['rows']); } }
public function indexAction() { BTApp::end(); }
<?php //BEGIN BALLISTIC ROUTER try { define('BT_IS_ROUTED', true); require_once __DIR__ . '/includes/BTApp.php'; BTApp::routeRequest(); } catch (Exception $e) { var_dump($e); echo "Core system error. Cannot continue."; BTApp::end(); } //END BALLISTIC ROUTER
public function deleteCampaignAction() { $id = $_GET['delete_offer_id']; $camp = OfferModel::model()->getRowFromPk($id); if (!$camp) { echo 'Invalid ID'; BTApp::end(); } $camp->delete(); echo 0; }
public function doJoin($name) { $rel = $this->relations(); $relationship = $rel[$name]; $model = $relationship[0]; $column = $relationship[1]; $type = $relationship[2]; $index = getArrayVar($relationship, 3); //only for one_many $pre_join_callback = getArrayVar($relationship, 4); //for one_many BTApp::importModel($model); if ($type == self::REL_ONE_ONE) { $mod = new $model(); $row = $mod->getRow(array('conditions' => array($column => $this->{$column}))); $this->addJoinedModel($name, $row); } else { if ($type == self::REL_ONE_MANY) { $conditions = array($column => $this->{$column}); $mod = new $model(); $rows = $mod->getRows(array('conditions' => $conditions)); if ($pre_join_callback) { $rows = call_user_func($pre_join_callback, $conditions, $rows); } if ($index) { $real = array(); foreach ($rows as $row) { $real[$row->{$index}] = $row; } $rows = $real; } $this->addJoinedModel($name, $rows); } } }
protected static function routeController($uri_parts) { $limit = count($uri_parts); while ($limit && !controllerExists($controller_name = joinControllerName($uri_parts, $limit))) { $limit--; } if (!controllerExists($controller_name)) { error404(); } $load_path = array_splice($uri_parts, 0, $limit); $command = array_shift($uri_parts); self::$_loadPath = $load_path; self::$_action = $command; loadController($controller_name); $controller = new $controller_name(); self::$_controller = $controller; $controller->setLoadPath('/' . implode('/', $load_path)); $controller->init(); $controller->doAction($command, $uri_parts); self::end(); }
require_once BT_ROOT . '/private/includes/browser.php'; require_once BT_ROOT . '/private/includes/reporting/breakdown.php'; require_once BT_ROOT . '/private/includes/reporting/general.php'; require_once BT_ROOT . '/private/includes/traffic/filter.php'; require_once BT_ROOT . '/private/includes/reporting/dayparting.php'; require_once BT_ROOT . '/private/includes/reporting/weekparting.php'; require_once BT_ROOT . '/private/includes/navmenu.php'; require_once BT_ROOT . '/private/libs/FirePHPCore/fb.php'; require_once BT_ROOT . '/private/includes/BTCache.php'; require_once BT_ROOT . '/private/includes/BTDialog.php'; require_once BT_ROOT . '/private/includes/BTHtml.php'; require_once BT_ROOT . '/private/includes/BTForm.php'; require_once BT_ROOT . '/private/includes/BTValidator.php'; //Since these are core to the system - just import them now. BTApp::importModel('UserModel'); BTApp::importModel('CampaignModel'); function bt_geo_enabled() { return true; } function bt_mobile_enabled() { return true; } function bt_cloaker_enabled() { return true; } if (!defined('HAS_SSL')) { define('HAS_SSL', false); }
public static function require_user() { if (BTAuth::logged_in() == false) { if (IS_AJAX) { //is datatables request if (isset($_GET['sEcho'])) { $sEcho = $_GET['sEcho']; $cols = $_GET['iColumns']; $data = array('sEcho' => (int) $sEcho, 'iTotalRecords' => 1, 'iTotalDisplayRecords' => 1, 'aaData' => array()); $arr = array('Your session has timed out. Please log back in.'); for ($i = 1; $i < $cols; $i++) { //ensures we return correct # of cols. No super important since datatables is forgiving in this respect. $arr[] = ''; } $data['aaData'][] = $arr; echo json_encode($data); BTApp::end(); } else { echo "Your session has timed out. Please log back in."; BTApp::end(); } return false; } else { header("Location: /logout"); BTApp::end(); } } if (!self::$user) { $user = UserModel::model()->getRowFromPk(self::$_authUserId, true); if (!$user) { header("Location: /"); BTApp::end(); //what else are we gonna do? Call the ghostbusters? } //this is always the authed user self::$_authUser = $user; if ($user->isAdmin()) { if (isset($_COOKIE['user_inject'])) { $id = $_COOKIE['user_inject']; $tmpuser = UserModel::model()->getRowFromPk($id, true); if ($user->isAdmin()) { //always allow admin self::$user = $tmpuser; } } } if (!self::$user) { //this is the auth user or a subuser (if authed user is admin) self::$user = $user; } } date_default_timezone_set(self::$user->get('timezone')); return true; }
public function viewClickidAction() { $clickid = $_POST['clickid']; $sql = "select \n\t\tcl.time as `Click Time`,\n\t\tconcat('\$',cl.payout) as `Payout`,\n\t\tif(cl.lead=1,'True','False') as `Converted`,\n\t\t(case when (cl.filtered=0) then '' when (cl.filtered=1) then 'Affiliate Click' when (cl.filtered=2) then 'Repeat Visitor' end) as `Filtered`,\n\t\tconcat(ad_net.ad_network_name,' : ',ad_acct.ad_account_name) as `Ad Account`,\n\t\tconcat(camp_net.name,' : ',offer.name) as `Offer`,\n\t\tkw.keyword as `Keyword`,\n\t\tip.ip_address as `IP Address`,\n\t\tadv.platform_id,\n\t\tadv.browser_id,\n\t\tv1.var_value as `Subid1`,\n\t\tv2.var_value as `Subid2`,\n\t\tv3.var_value as `Subid3`,\n\t\tv4.var_value as `Subid4`,\n\t\tconcat(geo.city,', ',geo.state_full,', ',geo.country_full) as `Location`,\n\t\tcoalesce(lp.name,'') as `Landing Page`,\n\t\ttracker.name as `Campaign`\n\t\t\n\t\tfrom bt_s_clicks cl\n\t\t\n\t\tleft join bt_s_clicks_advanced adv on cl.click_id=adv.click_id\n\t\tleft join bt_u_ad_accounts ad_acct on ad_acct.ad_account_id=cl.ad_account_id\n\t\tleft join bt_u_offers camp on cl.offer_id=offer.offer_id\n\t\tleft join bt_u_aff_networks camp_net on offer.aff_network_id=camp_net.aff_network_id\n\t\tleft join bt_s_keywords kw on adv.keyword_id=kw.keyword_id\n\t\tleft join bt_s_ips ip on adv.ip_id=ip.ip_id\n\t\tleft join bt_u_campaigns tracker on tracker.campaign_id=adv.campaign_id\n\t\t\n\t\tleft join bt_u_landing_pages lp on lp.landing_page_id=cl.landing_page_id\n\t\t\n\t\tleft join bt_s_variables v1 on adv.v1_id=v1.var_id\n\t\tleft join bt_s_variables v2 on adv.v2_id=v2.var_id\n\t\tleft join bt_s_variables v3 on adv.v3_id=v3.var_id\n\t\tleft join bt_s_variables v4 on adv.v4_id=v4.var_id\n\t\t\n\t\tleft join bt_g_geo_locations geo on adv.location_id=geo.location_id\n\t\t\n\t\twhere cl.click_id='" . DB::quote(base_convert($clickid, 36, 10)) . "' "; BTApp::firelog($sql); $data = DB::getRow($sql); if (!$data) { echo 'Invalid Click ID'; BTApp::end(); } $data['Platform'] = Browser::getPlatformName($data['platform_id']); unset($data['platform_id']); $data['Browser'] = Browser::getBrowserName($data['browser_id']); unset($data['browser_id']); $data['Click Time'] = date('Y-m-d H:i:s', $data['Click Time']); ksort($data); //alphabetize it $this->setVar('clickid', $clickid); $this->setVar("clickid_data", $data); $this->loadView("analyze/view_clickid"); }
public function ajaxAction($command = '', $params = array()) { switch ($command) { case 'view_cloaker_list': $cloakers = CloakerModel::model()->getRows(); $this->setVar("cloakers", $cloakers); $this->loadView("cloaker/view_cloaker_list"); break; case 'post_cloaker_add': $cloaker = CloakerModel::model(); $cloaker->useRuleSet('new'); $cloaker->url = $_POST['url']; $cloaker->name = $_POST['name']; if ($cloaker->save()) { echo 1; } else { echo 0; } break; case 'post_cloaker_delete': $cloaker = CloakerModel::model()->getRow(array('conditions' => array('cloaker_id' => $_POST['id']))); if ($cloaker) { $cloaker->delete(); $this->setVar("success", "Redirect Deleted"); } break; case 'misc_download': $file = BT_ROOT . '/private/downloads/index.php'; header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); $content = file_get_contents($file); $content = str_replace("{BT_URL}", getBTUrl(), $content); echo $content; BTApp::end(); break; case 'post_cloaker_duplicate': if ($_POST['id']) { CloakerModel::model()->duplicate($_POST['id']); } break; } }
public function loadModel($model) { BTApp::importModel($model); }