public function indexAction()
 {
     $this->setupUser();
     $this->useActionAsCurrentNav();
     $this->setVar("redirects", CloakerModel::model()->getRows());
     if (getArrayVar($_GET, 'campaign_id')) {
         $campaign = CampaignModel::model()->getRowFromPk($_GET['campaign_id']);
     } else {
         $campaign = CampaignModel::model();
     }
     $this->setVar('campaign', $campaign);
     $this->setVar("title", "Add A Campaign");
     $this->setVar('traffic_sources', TrafficSourceModel::model()->getRows());
     $campaign->randomizeVariableNames();
     $this->render("tracker/code");
 }
 public function getUrl($cloaked = true)
 {
     $tracking_variables = array();
     $tracking_variables[$this->option('var_v1')->value] = $this->option('default_var_v1')->value;
     $tracking_variables[$this->option('var_v2')->value] = $this->option('default_var_v2')->value;
     $tracking_variables[$this->option('var_v3')->value] = $this->option('default_var_v3')->value;
     $tracking_variables[$this->option('var_v4')->value] = $this->option('default_var_v4')->value;
     $tracking_variables[$this->option('var_kw')->value] = $this->option('default_var_kw')->value;
     $tracking_variable_string = '';
     if ($tracking_variables) {
         $tracking_variable_string = bt_build_http_query($tracking_variables);
     }
     if ($this->cloaker_id && $cloaked) {
         $cloaker = CloakerModel::model()->getRowFromPk($this->cloaker_id);
         if ($cloaker) {
             return $cloaker->getUrl() . '/' . $this->slug . '?' . $tracking_variable_string;
         }
     }
     if ($this->type == 1) {
         return 'http://' . getTrackingDomain() . '/tracker/lp/' . $this->get('campaign_id') . '?' . $tracking_variable_string;
     }
     return 'http://' . getTrackingDomain() . '/tracker/direct/' . $this->get('campaign_id') . '?' . $tracking_variable_string;
 }
 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;
     }
 }