Ejemplo n.º 1
0
 public function postAction()
 {
     try {
         if (!$this->request->getPost()) {
             throw new Exception('こらっ');
         }
         $schedule = new Schedule();
         $is_able_to_post_impression = $schedule->is_in_time('impre', $this->current_time);
         if ($is_able_to_post_impression) {
             $bms_no = $this->request->getPost('bms_no');
             $impression = new Impression($bms_no);
             $impression->post($this->request->getPost(), $this->current_time, $this->ip, $this->host);
             $bms_info = new BmsInfo();
             $bms_info->update_by_impression($bms_no, $this->request->getPost('point'), $this->current_time);
             header("Location: " . ROOT_URL . "/detail/thanks/{$bms_no}/");
         } else {
             throw new Exception('作品評価期間ではありません');
         }
     } catch (Exception $e) {
         $this->displayErrorView($e->getMessage());
     }
 }
Ejemplo n.º 2
0
 public function registerAction()
 {
     try {
         if (!$this->request->getPost()) {
             throw new Exception('こらっ');
         }
         $schedule = new Schedule();
         $is_able_to_register = $schedule->is_in_time('regist', $this->current_time);
         if ($is_able_to_register) {
             // BMSデータを登録
             $bms_info = new BmsInfo();
             $bms_info->register($this->request->getPost(), $this->current_time, $this->ip, $this->host);
             // インプレッション用のDBを新規作成
             $lastid = $bms_info->get_last_id();
             $impression = new Impression($lastid);
             $impression->create();
             header("Location: " . ROOT_URL . "/registration/thanks/");
         } else {
             throw new Exception('作品登録期間ではありません');
         }
     } catch (Exception $e) {
         $this->displayErrorView($e->getMessage());
     }
 }
Ejemplo n.º 3
0
 /**
  * Gets the Rate based on the type of record i.e 'publisher', or 'advertiser'
  * @param  array  $commissions Array of Commissions to search for ad_id
  * @param  String $type        Advertiser | Publisher
  * @return array
  */
 public static function campaignRate($adid, &$commissions = [], $country = null, $extra = [])
 {
     $commFetched = $extra['commFetched'] ?? false;
     if ($commFetched) {
         $comm = $commissions;
     } else {
         $comm = self::find($commissions, $adid);
     }
     $info = ['campaign' => 'cpc', 'rate' => 0, 'revenue' => 0, 'type' => $extra['type']];
     if (!is_array($comm)) {
         return $info;
     }
     $commission = array_key_exists($country, $comm) ? $comm[$country] : @$comm['ALL'];
     // because commission might not exists if country is null
     if (!is_object($commission)) {
         return $info;
     }
     $query = ['adid' => $adid, 'created' => Db::dateQuery($extra['start'], $extra['end'])];
     switch ($extra['type']) {
         case 'advertiser':
             $info['revenue'] = (double) $commission->revenue;
             break;
         case 'publisher':
             $info['rate'] = self::getPubRate($commission, $extra);
             $query['pid'] = $extra['publisher']->_id ?? null;
             break;
         case 'both':
             $info['revenue'] = (double) $commission->revenue;
             $info['rate'] = self::getPubRate($commission, $extra);
             if (isset($extra['publisher'])) {
                 $query['pid'] = $extra['publisher']->_id;
             }
             break;
     }
     switch (strtolower($commission->model)) {
         case 'cpa':
         case 'cpi':
             $count = \Conversion::count($query);
             $info['conversions'] = $count;
             break;
         case 'cpm':
             $info['impressions'] = \Impression::getStats($query);
             break;
     }
     $info['campaign'] = strtolower($commission->model);
     return $info;
 }
function impression_validate($data)
{
    $impression = new Impression();
    if (strpos($data['fn'], "edit")) {
        $type = "edit";
    }
    if (strpos($data['fn'], "delete")) {
        $type = "delete";
    }
    if (strpos($data['fn'], "create")) {
        $type = "create";
    }
    return $impression->_validate($data, $type, false);
}
Ejemplo n.º 5
0
 public function deleteimpAction()
 {
     try {
         $this->checkLogin();
         $bms_no = $this->request->getPost('bms_no');
         $imp_no = $this->request->getPost('imp_no');
         $impression = new Impression($bms_no);
         $impression_data = $impression->get_data($imp_no);
         $del_point = $impression_data['point'];
         $impression->delete($imp_no);
         $bms_info = new BmsInfo();
         $bms_info->update_by_impression_delete($bms_no, $del_point);
         header("Location: " . ROOT_URL . "/admin/finish/");
     } catch (Exception $e) {
         $this->displayErrorView($e->getMessage());
     }
 }