コード例 #1
0
 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;
             }
         }
     }
 }
コード例 #2
0
 public static function routeRequest()
 {
     $uri = trim($_SERVER['REQUEST_URI'], '/');
     if (($pos = strpos($uri, '?')) !== false) {
         $uri = substr($uri, 0, $pos);
     }
     $uri = str_replace("..", '', $uri);
     $uri_parts = explode('/', $uri);
     //no parts? Goto login.
     if (!$uri_parts[0]) {
         header("Location: /login");
         BTApp::end();
     }
     //Is ajax call?
     $is_ajax = $uri_parts[0] == 'ajax' ? true : false;
     if ($is_ajax) {
         array_shift($uri_parts);
     }
     if (!defined("IS_AJAX")) {
         define("IS_AJAX", $is_ajax);
     }
     //end ajax
     self::routeController($uri_parts);
     self::end();
 }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
 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");
 }
コード例 #5
0
 public function deleteAction()
 {
     $id = $_GET['id'];
     $source = TrafficSourceModel::model()->getRowFromPk($id);
     if ($source) {
         $source->delete();
     }
     header("Location: /trafficsources");
     BTApp::end();
 }
コード例 #6
0
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();
}
コード例 #7
0
 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);
 }
コード例 #8
0
 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);
         }
     }
 }
コード例 #9
0
 public function doAction($action, $params = array())
 {
     $this->_loadAction = $action;
     if (!$this->_loadAction) {
         $this->_loadAction = '/';
     }
     if (!$action) {
         $this->indexAction();
         BTApp::end();
     }
     $tmp = $action . 'Action';
     if (method_exists($this, $tmp)) {
         $this->{$tmp}($params);
         BTApp::end();
     }
     if (IS_AJAX) {
         $this->ajaxAction($action, $params);
         BTApp::end();
     }
     error404();
 }
コード例 #10
0
 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;
     }
 }
コード例 #11
0
 public function advRedirectAction()
 {
     $click_id_public = $_GET['click_id'];
     $type = $_GET['t'];
     $click = ClickModel::model()->getRow(array('conditions' => array('click_id' => base_convert($click_id_public, 36, 10))));
     if (!$click) {
         echo 'Invalid data';
         BTApp::end();
     }
     $campaign = $click->campaign;
     setClickIdCookie(base_convert($click->click_id, 10, 36));
     if ($click->landing_page_id) {
         $url = $click->site->landing_url;
         $pass_type = 'lp';
     } else {
         $url = $click->site->offer_url;
         $pass_type = 'offer';
     }
     $append = array();
     foreach ($click->passthroughs as $pass) {
         $opt = json_decode($campaign->options['pass_' . $pass->name]->value);
         if ($opt->{$pass_type}) {
             $append[$pass->name] = $pass->value;
         }
     }
     $_GET = array();
     $_GET['url'] = appendQueryString($url, http_build_query($append));
     $_GET['c'] = 0;
     $_GET['t'] = $type;
     $this->redirectAction();
 }
コード例 #12
0
 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");
 }
コード例 #13
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()));
 }
コード例 #14
0
 public function indexAction()
 {
     BTApp::end();
 }
コード例 #15
0
 public function deleteCampaignAction()
 {
     $id = $_GET['delete_offer_id'];
     $camp = OfferModel::model()->getRowFromPk($id);
     if (!$camp) {
         echo 'Invalid ID';
         BTApp::end();
     }
     $camp->delete();
     echo 0;
 }
コード例 #16
0
<?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
コード例 #17
0
 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;
 }