Example #1
0
 /**
  * 実行します
  */
 public function main()
 {
     try {
         //--------------------------
         // 案件特定
         // AnkenNotFountException
         //--------------------------
         $anken =& $this->getAnken($this->_code);
         $this->_anken =& $anken;
         $this->_log->debug('anken_id.' . $this->_anken['anken_id'] . '.' . $this->_code);
         //--------------------------
         // 不正アクセス防止
         // UnauthorizedAccessException
         //--------------------------
         if ($anken['use_foreign_ip_address_check'] == 1) {
             require_once 'AccessManager.php';
             $nam = new AccessManager();
             // 海外IPはすべて不許可
             $nam->killNoJapanAccess();
             $this->_log->debug('foreign_ip_address_check.ok');
         }
         //--------------------------
         // 提携メディア特定
         // TeikeiMediaNotFountException
         //--------------------------
         $teikei =& $this->getTeikeiMedia($this->_mediaId);
         $this->_teikeiMedia =& $teikei;
         $this->_log->debug('media_id.' . $this->_teikeiMedia['media_id']);
         //--------------------------
         // 期間チェック
         // DeadLineException
         //--------------------------
         $this->checkKikan($anken, $teikei);
         $this->_log->debug('kikan_check.ok');
         //--------------------------
         // クッキー処理準備
         //--------------------------
         header("P3P: policyref'/w3c/p3p.xml', CP='UNI CUR OUR'");
         //---------------------------
         // lpo
         //---------------------------
         $lpo = new LpoModel($this->_core, $this->_code, $this->_anken['anken_id']);
         $patternId = $lpo->getSelectedPatternId();
         //--------------------------
         // PVクッキーを取得とカウントアップ
         // DBException
         //--------------------------
         $pv = $this->getCookiePv();
         // PVクッキー情報がない場合は設定
         if (empty($pv) == true) {
             // クッキーを設定
             $this->setCookiePv();
             // PVカウントアップ(DB)
             $this->countUpPv($teikei);
             $this->_log->debug('db.pv.countup');
             // LPO PVカウントアップ
             $this->countUpLpoPv($teikei, $patternId);
             $this->_log->debug('db.lpopv.countup');
         } else {
             $this->_log->debug('cookie.pv.exist');
         }
         //--------------------------
         // クッキーIDを更新
         // 訪問回数関係なくクッキー更新、DB追加
         // DBException
         //--------------------------
         // 新しいクッキーIDを作成
         $cookieId = $this->createNewCookieId();
         $this->_log->debug('cookie.id.new.' . $cookieId);
         // 新しいクッキーIDをクッキーに書き込む
         $this->setCookieId($cookieId);
         // 新しいクッキーIDでDB(セッションテーブル)に追加
         $sessionId = $this->insertDbSeesion($cookieId, $teikei, $patternId);
         $this->_log->debug('db.session_id.' . $sessionId);
         //--------------------------
         // 実施タイプ別に実行します
         // RedirectUrlException
         // Index_LandingPageNotFountException
         //--------------------------
         // 1:リダイレクト 2:ランディング
         $type = $anken['type_cd'];
         if ($type == 1) {
             // リダイレクト
             $this->_log->debug('db.redirect');
             // 飛び先取得しリダイレクト
             $url = $this->getRedirectUrl($anken, $teikei);
             $this->_log->debug('db.redirect.' . $url);
             $this->redirect($url);
         } else {
             if ($type == 2) {
                 // ランディングタイプ
                 $this->_log->debug('db.landing');
                 // ランディングページパス取得し、表示
                 $path = $this->getLandingPagePath();
                 $this->_log->debug('db.landing.' . $path);
                 $this->landing($path, $lpo);
             } else {
                 // 未知の実施タイプ
                 throw new Index_UnknownAnkenTypeException($type);
             }
         }
         exit;
     } catch (CampaignException $e) {
         //--------------------------
         // 例外処理
         //--------------------------
         // 例外表示用(企業名とリンク)
         $name = $anken['campaign_error_link_name'];
         $url = $anken['campaign_error_link_url'];
         if (empty($name) == false && empty($url) == false) {
             $e->assign('client_name', $name);
             $e->assign('client_url', $url);
         }
         throw $e;
     } catch (Exception $e) {
         //--------------------------
         // 想定外の例外処理
         //--------------------------
         $this->_log->fatal('unexpected: ' . get_class($e));
         throw $e;
     }
 }
Example #2
0
 /**
  * Index実行の有効性チェック
  */
 public function checkIndexValidity(&$anken, &$teikei)
 {
     //--------------------------
     // 不正アクセス防止
     // UnauthorizedAccessException
     //--------------------------
     if ($anken['use_foreign_ip_address_check'] == 1) {
         require_once 'AccessManager.php';
         $nam = new AccessManager();
         // 海外IPはすべて不許可
         $nam->killNoJapanAccess();
         $this->_log->debug('foreign_ip_address_check.ok');
     }
     //--------------------------
     // 期間チェック
     // DeadLineException
     //--------------------------
     $this->checkKikan($anken, $teikei);
     $this->_log->debug('kikan_check.ok');
     //--------------------------
     // 休止期間チェック
     // Index_SuspendLineException
     //--------------------------
     $this->checkSuspend($anken, $teikei);
     $this->_log->debug('suspend_check.ok');
 }
Example #3
0
	/**
	 * 実行します
	 * @exception Index_AnkenNotFountException "案件情報を特定できない"
	 * @exception Index_MediaNotFountException "提携メディアテーブルがありません" "提携メディア特定できない"
	 * @exception Index_DeadLineException 実施期間外
	 * @exception Index_UnknownAnkenTypeException "未知の実施タイプです"
	 * @exception Index_UnknownDeviceTypeException "未知のデバイスタイプです"
	 * @exception Index_LandingPageNotFountException "未知のデバイスタイプです"
	 */
	public function main() {
$log =& $this->_core->getLogger($this->_code.".index");
$log->debug('index.main.begin');
		try {
			// パラメータ値
			$code = $this->_code;
			$mediaId = $this->_mediaId;
$log->debug('index.main.mediaid.'.$mediaId);

			/////////////////////////
			// 案件特定
			/////////////////////////

			$anken =& $this->getAnken($code);
			$this->_anken =& $anken;
$log->debug('index.main.get.anken');

			/////////////////////////
			// 提携メディア特定
			/////////////////////////

			$teikei =& $this->getTeikeiMedia($mediaId);
			$this->_teikeiMedia =& $teikei;
$log->debug('index.main.get.teikei');

$log->debug('index.main.check.foreign_ip_address_check');
			//--------------------------
			// 不正アクセス防止
			// UnauthorizedAccessException
			//--------------------------
			require_once('AccessManager.php');
			$nam = new AccessManager();
			// 海外IPはすべて不許可
			$nam->killNoJapanAccess();
$log->debug('index.main.check.foreign_ip_address_check.ok');

$log->debug('index.main.check.kikan');
			// 期間チェック
			$this->checkKikan($anken, $teikei);
$log->debug('index.main.check.kikan,ok');


			/////////////////////////
			// クッキー処理
			/////////////////////////

			header("P3P: policyref'/w3c/p3p.xml', CP='UNI CUR OUR'");


			/////////////////////////
			// PVクッキーを取得
			/////////////////////////

			$pv = $this->getCookiePv();
			// PVクッキー情報がない場合は設定
			if (empty($pv) == true) {
$log->debug('index.main.set.cookiePv');
				// クッキーを設定
				$this->setCookiePv();
				// PVカウントアップ(DB)
				$this->countUpPv($teikei);
			}

			/////////////////////////
			// クッキーIDを更新
			// 訪問回数関係なくクッキー更新、DB更新
			/////////////////////////

			// 新しいクッキーIDを作成
			$cookieId = $this->createNewCookieId();
			// 新しいクッキーIDをクッキーに書き込む
			$this->setCookieId($cookieId);
			// 新しいクッキーIDでDBも更新
			$sessionId = $this->insertDbSeesion($cookieId, $teikei);


			/////////////////////////
			// 実施タイプ別に実行します。
			// 0:リダイレクト 1:ランディング
			/////////////////////////
			$type = $anken['type_cd'];
			if ($type == 1) {

$log->debug('index.main.type.redirect');
				// リダイレクト
				$url = $this->getRedirectUrl($anken, $teikei);
				if (empty($url) == true) {

					// 本番飛び先URLが未設定
					throw new Index_RealUrlException();

				} else {

					$this->redirect($url);

				}

			} else if ($type == 2) {

$log->debug('index.main.type.landing');
				// ランディングタイプ
				$page = $this->getLandingPagePath();
				$this->landing($page);
				exit;

			} else {

$log->debug('index.main.type.unkown');
				// 未知の実施タイプ
				throw new Index_UnknownAnkenTypeException("未知の実施タイプです。type:".$type);
			}
$log->debug('index.main.end');

		} catch (CampaignException $e) {

			/////////////////////////
			// 例外処理
			// 表示用にパラメータを設定
			/////////////////////////

$log->debug('index.campaignexception');
			// 例外表示用
			$name = $anken['campaign_error_link_name'];
			$url = $anken['campaign_error_link_url'];
			if (empty($name) == false && empty($url) == false) {
				$e->assign('client_name', $name);
				$e->assign('client_url', $url);
			}

			// 例外ページを表示するため、上へスロー
			throw $e;

		} catch (Exception $e) {

			/////////////////////////
			// 想定外の例外処理
			/////////////////////////

$log->debug('index.exception');
			throw $e;
		}
	}