public static function now($pin, $uid, $method = 'pin')
 {
     $voucher = Voucher::where('pin', $pin)->firstOrFail();
     $rc['voucher_id'] = $voucher->id;
     $rc['recharged_on'] = date('Y-m-d H:i:s');
     $rc['aq_invocked'] = 0;
     $rc['expiration'] = AccessManager::makeExpiry($voucher->validity, $voucher->validity_unit, 'd M Y H:i');
     $rc['time_limit'] = NULL;
     $rc['data_limit'] = NULL;
     if ($voucher->plan_type == 1) {
         //if limited
         $limit = $voucher->limits;
         // $rc['limit_type'] = $limit->limit_type;
         if ($limit->limit_type == 0 || $limit->limit_type == 2) {
             $rc['time_limit'] = $limit->time_limit * constant($limit->time_unit);
         }
         if ($limit->limit_type == 1 || $limit->limit_type == 2) {
             $rc['data_limit'] = $limit->data_limit * constant($limit->data_unit);
         }
     }
     $recharge = Recharge::firstOrNew(['user_id' => $uid]);
     $recharge->fill($rc);
     if (!$recharge->save()) {
         return FALSE;
     }
     $voucher->fill(['user_id' => $uid, 'method' => $method]);
     if (!$voucher->save()) {
         return FALSE;
     }
     return TRUE;
 }
 public static function generate($postData)
 {
     $postData['expires_on'] = AccessManager::makeExpiry($postData['validity'], $postData['validity_unit']);
     return DB::transaction(function () use($postData) {
         for ($i = 0; $i < $postData['count']; $i++) {
             $postData['pin'] = self::_generatePin();
             if (!($coupon = static::create($postData))) {
                 throw new Exception("Voucher Creation Failed.");
             }
             $pins[] = $coupon->pin;
         }
         return $pins;
     });
 }
Exemple #3
0
 public function isGranted($resource, $username, $permission)
 {
     $allowed = false;
     // Logic is as follows:
     // * If a policy has usernames, one must match (simplified regex)
     // * If a policy has a resource, one must match (simplified regex)
     // * One policy must contain the requested permission
     // * if any policies has effect=deny, it wins over an allow policy
     // * at least one policy must allow, other it also denies
     //
     // see also https://github.com/ory-am/ladon/blob/master/guard/guard.go
     foreach ($this->policies as $policy) {
         // Check usernames match
         if (sizeof($policy->usernames) > 0) {
             if (!AccessManager::matches($username, $policy->usernames)) {
                 continue;
             }
         }
         // Check resources
         if (sizeof($policy->resources) > 0) {
             if (!AccessManager::matches($resource, $policy->resources)) {
                 continue;
             }
         }
         // Check permissions (one MUST match)
         if (!AccessManager::matches($permission, $policy->permissions)) {
             continue;
         }
         // Apply result
         if (!$policy->hasAccess()) {
             #echo "isGranted($username, $prefix, $permission) = false # access\n";
             return false;
         }
         $allowed = true;
     }
     #echo "isGranted($username, $prefix, $permission) = $allowed # allowed\n";
     return $allowed;
 }
Exemple #4
0
<?php

require_once 'modules/access_manager.php';
$access = new AccessManager();
$access->logout();
Exemple #5
0
<?php

include "../lib/jpgraph/jpgraph.php";
include "../lib/jpgraph/jpgraph_bar.php";
include "../lib/jpgraph/jpgraph_date.php";
require_once '../modules/statistics.php';
require_once '../modules/access_manager.php';
$access = new AccessManager();
$filename = basename($_SERVER['PHP_SELF']);
if ($filename != "login.php") {
    $access->checkAuth();
}
$period = $_GET['p'];
try {
    $stat = new CallsStatistics();
    $data = $stat->getCalls($period);
} catch (StatisticException $e) {
    echo "Error generating statistic: {$e}";
    exit;
}
$datax = array();
$datay = array();
foreach ($data as $entry) {
    array_push($datax, $entry[0]);
    array_push($datay, $entry[1]);
}
# 1 = 2
# 2 = 5
# 3 = 5
# 4 = 5
# 5 = 2
Exemple #6
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');
 }
Exemple #7
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;
     }
 }
Exemple #8
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;
		}
	}
Exemple #9
0
<?php

require_once 'include/menu.php';
require_once 'modules/access_manager.php';
if (isset($_POST['access']) && $error_txt == "") {
    $access = new AccessManager();
    $access->login($_POST['username'], $_POST['password'], $_POST['language']);
}
require_once 'include/header.php';
?>
	<script type="text/javascript" src="js/jquery.ddslick.js"></script>
	<script>
	$( document ).ready(function() {
		$('#language-select').ddslick({
			width: 200,
			onSelected: function(data){
				$('#language').val(data.selectedData.value);
			}
			
		});	
	});		

	</script>
			<br/><br/><br/><br/>

<?php 
function print_form($post_data, $errors)
{
    $username = $_POST['username'] != '' ? $_POST['username'] : '';
    $password = $_POST['password'] != '' ? $_POST['password'] : '';
    ?>