public function offersByAffNetworkAction() { if (@$_GET['aff_network_id']) { $campoffers = OfferModel::model()->getRows(array('conditions' => array('aff_network_id' => $_GET['aff_network_id']), 'order' => 'name asc')); } else { $campoffers = OfferModel::model()->getRows(array('order' => 'name asc')); } $arr = array(); foreach ($campoffers as $offer) { $arr[] = array('id' => $offer->offer_id, 'name' => $offer->name); } echo json_encode($arr); }
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 offerAction($params = array()) { $campaign_id = getArrayVar($params, 0, 0); $offer_id = getArrayVar($params, 1, 0); //just one param if (!$offer_id) { if (!($campoffer = CampaignOfferModel::model()->getRowFromPk($campaign_id))) { echo "Error 0: Invalid offer ID"; exit; } $campaign_id = $campoffer->campaign_id; $offer_id = $campoffer->offer_id; } //two params if (!($campaign = CampaignModel::model()->getRowFromPk($campaign_id))) { echo "Error 1: Invalid offer ID"; exit; } if (!($offer = OfferModel::model()->getRowFromPk($offer_id))) { echo "Error 3: Invalid offer ID"; exit; } //no LP id set, direct link? if ($campaign->type != 1) { echo "Error 2: Invalid LP ID"; exit; } if ($_COOKIE['btclickid']) { $click = ClickModel::model()->getRow(array('conditions' => array('click_id' => base_convert($_COOKIE['btclickid'], 36, 10)))); if (!$click) { echo "Error 4: Invalid click"; exit; } else { if (!$click->landing_page_id) { echo "Error 8: Invalid click"; exit; } else { if ($click->offer_id) { //new click (offer already set). Use old data $new_click = clone $click; $new_click->offer_id = 0; $new_click->filtered = 2; //always filter as repeat visitor $new_click->lead = 0; $new_click->useRuleSet('track'); $new_click->save(false, true); $id = $new_click->id(); $new_adv = clone $click->advanced; $new_adv->click_id = $id; $new_adv->save(false, true); $new_site = clone $click->site; $new_site->click_id = $id; $new_site->save(false, true); $passes = array(); foreach ($click->passthroughs as $pass) { $new_pass = clone $pass; $new_pass->click_id = $id; $new_pass->name = $pass->name; $new_pass->save(false, true); $passes[$new_pass->name] = $new_pass; } $click = $new_click; $click->addJoinedModel('advanced', $new_adv); $click->addJoinedModel('site', $new_site); $click->addJoinedModel('passthroughs', $passes); setClickIdCookie(base_convert($click->click_id, 10, 36)); } } } } else { //if no cookie, generate new click $this->saveData($campaign, 0, ''); if (!$_COOKIE['btclickid']) { echo "Error 2: Database Error"; exit; } $click = ClickModel::model()->getRow(array('conditions' => array('click_id' => base_convert($_COOKIE['btclickid'], 36, 10)))); } if (!$click) { echo "Error 6: Invalid click"; exit; } $data = $click->advanced->getAdvPlaceholderData(); $data['clickid'] = base_convert($click->click_id, 10, 36); //set campaign id $click->offer_id = $offer->id(); $click->payout = $offer->payout; $click->useRuleSet('lpoffer'); $click->save(); //set offer urls $redirect_url = $offer->url; $redirect_url = replaceTrackerPlaceholders($redirect_url, $data); $click->site->offer_url = $redirect_url; $click->site->useRuleSet('lpoffer'); $click->site->save(); $append = array(); foreach ($click->passthroughs as $pass) { $opt = json_decode($campaign->options['pass_' . $pass->name]->value); if ($opt->offer) { $append[$pass->name] = $pass->value; } } $_GET = array(); $_GET['url'] = appendQueryString($redirect_url, http_build_query($append)); $_GET['c'] = 0; $_GET['t'] = $campaign->options['redirect_method']->value; $this->redirectAction(); }