コード例 #1
0
 public function duplicate($id)
 {
     DB::startTransaction();
     if (!DB::query("insert into " . $this->tableName() . " (name, user_id, url) select concat(name,' copy') as name, user_id, url from " . $this->tableName() . " where cloaker_id='" . DB::quote($id) . "'")) {
         DB::rollback();
         return false;
     }
     $new_id = DB::insertId();
     if (!$new_id) {
         DB::rollback();
         return false;
     }
     if (!CloakerOptionModel::model()->duplicate($id, $new_id)) {
         DB::rollback();
         return false;
     }
     if (!CloakerHostnameModel::model()->duplicate($id, $new_id)) {
         DB::rollback();
         return false;
     }
     if (!CloakerIpModel::model()->duplicate($id, $new_id)) {
         DB::rollback();
         return false;
     }
     if (!CloakerRefererModel::model()->duplicate($id, $new_id)) {
         DB::rollback();
         return false;
     }
     if (!CloakerUaModel::model()->duplicate($id, $new_id)) {
         DB::rollback();
         return false;
     }
     DB::commit();
     return $new_id;
 }
コード例 #2
0
 public function editAdvancedAction()
 {
     if (!($cloaker = CloakerModel::model()->getRowFromPk($_GET['id']))) {
         echo 'Invalid redirect ID';
         BTApp::end();
     } else {
         $cloaker->useRuleSet('edit');
     }
     /*
      * When saved, we simply delete all existing entries for the respective models & readd them. Easier than
      * tracking entry IDs and such.
      */
     if (isset($_POST['save'])) {
         if ($cloaker->ips) {
             $cloaker->ips[0]->delete();
         }
         if ($cloaker->hostnames) {
             $cloaker->hostnames[0]->delete();
         }
         if ($cloaker->referers) {
             $cloaker->referers[0]->delete();
         }
         if ($cloaker->user_agents) {
             $cloaker->user_agents[0]->delete();
         }
         for ($i = 0; $i < count($_POST['exclude_hostname']); $i++) {
             $obj = new CloakerHostnameModel();
             $obj->hostname = $_POST['exclude_hostname'][$i];
             $obj->cloaker_id = $cloaker->id();
             $obj->url = $_POST['exclude_hostname_url'][$i];
             $obj->memo = $_POST['exclude_hostname_memo'][$i];
             $obj->regex = $_POST['hostname_regex'][$i];
             $obj->useRuleSet('new');
             $obj->save();
         }
         for ($i = 0; $i < count($_POST['exclude_user_agent']); $i++) {
             $obj = new CloakerUaModel();
             $obj->user_agent = $_POST['exclude_user_agent'][$i];
             $obj->cloaker_id = $cloaker->id();
             $obj->url = $_POST['exclude_user_agent_url'][$i];
             $obj->memo = $_POST['exclude_user_agent_memo'][$i];
             $obj->regex = $_POST['user_agent_regex'][$i];
             $obj->useRuleSet('new');
             $obj->save();
         }
         for ($i = 0; $i < count($_POST['exclude_ip_range_from']); $i++) {
             $obj = new CloakerIpModel();
             $obj->ip_from = $_POST['exclude_ip_range_from'][$i];
             $obj->ip_to = $_POST['exclude_ip_range_to'][$i];
             $obj->url = $_POST['exclude_ip_range_url'][$i];
             $obj->memo = $_POST['exclude_ip_range_memo'][$i];
             $obj->cloaker_id = $cloaker->id();
             $obj->useRuleSet('new');
             $obj->save();
         }
         for ($i = 0; $i < count($_POST['exclude_referer']); $i++) {
             $obj = new CloakerRefererModel();
             $obj->referer = $_POST['exclude_referer'][$i];
             $obj->cloaker_id = $cloaker->id();
             $obj->url = $_POST['exclude_referer_url'][$i];
             $obj->memo = $_POST['exclude_referer_memo'][$i];
             $obj->regex = $_POST['referer_regex'][$i];
             $obj->useRuleSet('new');
             $obj->save();
         }
         $this->setVar("success", "Settings saved");
     }
     $cloaker->clearJoin();
     //clear the join
     global $cloaker_orgs;
     $this->setVar("cloaker_orgs", $cloaker_orgs);
     $this->setVar("cloaker", $cloaker);
     $this->setVar("title", "Edit Advanced Options");
     $this->render("cloaker/edit_advanced");
 }