Пример #1
0
 /**
  * 認証を行う
  *
  * @access  public
  * @return  void
  */
 function authorize()
 {
     global $_conf, $_p2session;
     // 認証チェック
     if (!$this->authCheck()) {
         // ログイン失敗
         require_once P2_LIB_DIR . '/login_first.inc.php';
         printLoginFirst($this);
         exit;
     }
     // 以下、ログインOKなら
     // {{{ ログアウトの指定があれば
     if (!empty($_REQUEST['logout'])) {
         // セッションをクリア(アクティブ、非アクティブを問わず)
         Session::unSession();
         // 補助認証をクリア
         $this->clearCookieAuth();
         $mobile =& Net_UserAgent_Mobile::singleton();
         if (isset($_SERVER['HTTP_X_UP_SUBNO'])) {
             $this->removeRegistedAuthCarrier('EZWEB');
         } elseif ($mobile->isSoftBank()) {
             $this->removeRegistedAuthCarrier('SOFTBANK');
             /* docomoはログイン画面が表示されるので、補助認証情報を自動破棄しない
                } elseif ($mobile->isDoCoMo()) {
                    $this->removeRegistedAuthCarrier('DOCOMO');
                */
         }
         // $user_u_q = empty($_conf['ktai']) ? '' : '?user='******'/') . '/';
         // . $user_u_q;
         header('Location: ' . $url);
         exit;
     }
     // }}}
     // {{{ セッションが利用されているなら、セッション変数の更新
     if (isset($_p2session)) {
         // ユーザ名とパスXを更新
         $_SESSION['login_user'] = $this->user_u;
         $_SESSION['login_pass_x'] = $this->pass_x;
     }
     // }}}
     // 要求があれば、補助認証を登録
     $this->registCookie();
     $this->registKtaiId();
     // 認証後はセッションを閉じる
     session_write_close();
 }
Пример #2
0
 /**
  * 認証のチェックを行う
  *
  * @return bool
  */
 private function _authCheck()
 {
     global $_conf;
     global $_login_failed_flag;
     global $_p2session;
     $this->checkAuthUserFile();
     // 認証ユーザ設定(ファイル)を読み込みできたら
     if (file_exists($_conf['auth_user_file'])) {
         include $_conf['auth_user_file'];
         // ユーザ名が違ったら、認証失敗で抜ける
         if ($this->user_u != $rec_login_user_u) {
             P2Util::pushInfoHtml('<p>p2 error: ログインエラー</p>');
             // ログイン失敗ログを記録する
             if (!empty($_conf['login_log_rec'])) {
                 $recnum = isset($_conf['login_log_rec_num']) ? intval($_conf['login_log_rec_num']) : 100;
                 P2Util::recAccessLog($_conf['login_failed_log_file'], $recnum);
             }
             return false;
         }
         // パスワード設定があれば、セットする
         if (isset($rec_login_pass_x) && strlen($rec_login_pass_x) > 0) {
             $this->pass_x = $rec_login_pass_x;
         }
     }
     // 認証設定 or パスワード記録がなかった場合はここまで
     if (!$this->pass_x) {
         // 新規登録でなければエラー表示
         if (empty($_POST['submit_new'])) {
             P2Util::pushInfoHtml('<p>p2 error: ログインエラー</p>');
         }
         return false;
     }
     // {{{ クッキー認証パススルー
     if (isset($_COOKIE['cid'])) {
         if ($this->checkUserPwWithCid($_COOKIE['cid'])) {
             return true;
             // Cookie認証が通らなければ
         } else {
             // 古いクッキーをクリアしておく
             $this->clearCookieAuth();
         }
     }
     // }}}
     // {{{ すでにセッションが登録されていたら、セッションで認証
     if (isset($_SESSION['login_user']) && isset($_SESSION['login_pass_x'])) {
         // セッションが利用されているなら、セッションの妥当性チェック
         if (isset($_p2session)) {
             if ($msg = $_p2session->checkSessionError()) {
                 P2Util::pushInfoHtml('<p>p2 error: ' . htmlspecialchars($msg) . '</p>');
                 //Session::unSession();
                 // ログイン失敗
                 return false;
             }
         }
         if ($this->user_u == $_SESSION['login_user']) {
             if ($_SESSION['login_pass_x'] != $this->pass_x) {
                 Session::unSession();
                 return false;
             } else {
                 return true;
             }
         }
     }
     // }}}
     $mobile = Net_UserAgent_Mobile::singleton();
     // {{{ フォームからログインした時
     if (!empty($_POST['submit_member'])) {
         // フォームログイン成功なら
         if ($_POST['form_login_id'] == $this->user_u and sha1($_POST['form_login_pass']) == $this->pass_x) {
             // 古いクッキーをクリアしておく
             $this->clearCookieAuth();
             // ログインログを記録する
             $this->logLoginSuccess();
             // リダイレクト
             return $_SERVER['REQUEST_URI'];
             //return true;
             // フォームログイン失敗なら
         } else {
             P2Util::pushInfoHtml('<p>p2 info: ログインできませんでした。<br>ユーザ名かパスワードが違います。</p>');
             $_login_failed_flag = true;
             // ログイン失敗ログを記録する
             $this->logLoginFailed();
             return false;
         }
     }
     // }}}
     return false;
 }
Пример #3
0
 /**
  * 認証のチェックを行う
  *
  * @return bool
  */
 private function _authCheck()
 {
     global $_conf;
     global $_login_failed_flag;
     global $_p2session;
     $this->checkAuthUserFile();
     // 認証ユーザ設定(ファイル)を読み込みできたら
     if (file_exists($_conf['auth_user_file'])) {
         include $_conf['auth_user_file'];
         // ユーザ名が違ったら、認証失敗で抜ける
         if ($this->user_u != $rec_login_user_u) {
             P2Util::pushInfoHtml('<p>p2 error: ログインエラー</p>');
             // ログイン失敗ログを記録する
             if (!empty($_conf['login_log_rec'])) {
                 $recnum = isset($_conf['login_log_rec_num']) ? intval($_conf['login_log_rec_num']) : 100;
                 P2Util::recAccessLog($_conf['login_failed_log_file'], $recnum);
             }
             return false;
         }
         // パスワード設定があれば、セットする
         if (isset($rec_login_pass_x) && strlen($rec_login_pass_x) > 0) {
             $this->pass_x = $rec_login_pass_x;
         }
     }
     // 認証設定 or パスワード記録がなかった場合はここまで
     if (!$this->pass_x) {
         // 新規登録でなければエラー表示
         if (empty($_POST['submit_new'])) {
             P2Util::pushInfoHtml('<p>p2 error: ログインエラー</p>');
         }
         return false;
     }
     // {{{ クッキー認証パススルー
     if (isset($_COOKIE['cid'])) {
         if ($this->checkUserPwWithCid($_COOKIE['cid'])) {
             return true;
             // Cookie認証が通らなければ
         } else {
             // 古いクッキーをクリアしておく
             $this->clearCookieAuth();
         }
     }
     // }}}
     // {{{ すでにセッションが登録されていたら、セッションで認証
     if (isset($_SESSION['login_user']) && isset($_SESSION['login_pass_x'])) {
         // セッションが利用されているなら、セッションの妥当性チェック
         if (isset($_p2session)) {
             if ($msg = $_p2session->checkSessionError()) {
                 P2Util::pushInfoHtml('<p>p2 error: ' . htmlspecialchars($msg) . '</p>');
                 //Session::unSession();
                 // ログイン失敗
                 return false;
             }
         }
         if ($this->user_u == $_SESSION['login_user']) {
             if ($_SESSION['login_pass_x'] != $this->pass_x) {
                 Session::unSession();
                 return false;
             } else {
                 return true;
             }
         }
     }
     // }}}
     $mobile = Net_UserAgent_Mobile::singleton();
     // {{{ docomo iモードID認証
     /**
      * @link http://www.nttdocomo.co.jp/service/imode/make/content/ip/index.html#imodeid
      */
     if (!isset($_GET['auth_type']) || $_GET['auth_type'] == 'imodeid') {
         if ($mobile->isDoCoMo() && ($UID = $mobile->getUID()) !== null) {
             if (file_exists($_conf['auth_imodeid_file'])) {
                 include $_conf['auth_imodeid_file'];
                 if (isset($registed_imodeid) && $registed_imodeid == $UID) {
                     if (!$this->_checkIp('docomo')) {
                         p2die('端末ID認証エラー', "UAがdocomo端末ですが、iモードのIPアドレス帯域とマッチしません。({$_SERVER['REMOTE_ADDR']})");
                     }
                     return true;
                 }
             }
         }
     }
     // }}}
     // {{{ docomo 端末製造番号認証
     /**
      * ログインフォーム入力からは利用せず、専用認証リンクからのみ利用
      * @link http://www.nttdocomo.co.jp/service/imode/make/content/html/tag/utn.html
      */
     if (isset($_GET['auth_type']) && $_GET['auth_type'] == 'utn') {
         if ($mobile->isDoCoMo() && ($SN = $mobile->getSerialNumber()) !== null) {
             if (file_exists($_conf['auth_docomo_file'])) {
                 include $_conf['auth_docomo_file'];
                 if (isset($registed_docomo) && $registed_docomo == $SN) {
                     if (!$this->_checkIp('docomo')) {
                         p2die('端末ID認証エラー', "UAがdocomo端末ですが、iモードのIPアドレス帯域とマッチしません。({$_SERVER['REMOTE_ADDR']})");
                     }
                     return true;
                 }
             }
         }
     }
     // }}}
     // {{{ EZweb サブスクライバID認証
     /**
      * @link http://www.au.kddi.com/ezfactory/tec/spec/4_4.html
      */
     if ($mobile->isEZweb() && ($UID = $mobile->getUID()) !== null) {
         if (file_exists($_conf['auth_ez_file'])) {
             include $_conf['auth_ez_file'];
             if (isset($registed_ez) && $registed_ez == $UID) {
                 if (!$this->_checkIp('au')) {
                     p2die('端末ID認証エラー', "UAがau端末ですが、EZwebのIPアドレス帯域とマッチしません。({$_SERVER['REMOTE_ADDR']})");
                 }
                 return true;
             }
         }
     }
     // }}}
     // {{{ SoftBank 端末シリアル番号認証
     /**
      * パケット対応機 要ユーザID通知ONの設定
      * @link http://creation.mb.softbank.jp/web/web_ua_about.html
      */
     if ($mobile->isSoftBank() && ($SN = $mobile->getSerialNumber()) !== null) {
         if (file_exists($_conf['auth_jp_file'])) {
             include $_conf['auth_jp_file'];
             if (isset($registed_jp) && $registed_jp == $SN) {
                 if (!$this->_checkIp('softbank')) {
                     p2die('端末ID認証エラー', "UAがSoftBank端末ですが、SoftBank MobileのIPアドレス帯域とマッチしません。({$_SERVER['REMOTE_ADDR']})");
                 }
                 return true;
             }
         }
     }
     // }}}
     // {{{ フォームからログインした時
     if (!empty($_POST['submit_member'])) {
         // フォームログイン成功なら
         if ($_POST['form_login_id'] == $this->user_u and sha1($_POST['form_login_pass']) == $this->pass_x) {
             // 古いクッキーをクリアしておく
             $this->clearCookieAuth();
             // ログインログを記録する
             $this->logLoginSuccess();
             // リダイレクト
             return $_SERVER['REQUEST_URI'];
             //return true;
             // フォームログイン失敗なら
         } else {
             P2Util::pushInfoHtml('<p>p2 info: ログインできませんでした。<br>ユーザ名かパスワードが違います。</p>');
             $_login_failed_flag = true;
             // ログイン失敗ログを記録する
             $this->logLoginFailed();
             return false;
         }
     }
     // }}}
     // {{{ Basic認証 (disabled)
     /*
     if (!empty($_REQUEST['basic'])) {
         if (isset($_SERVER['PHP_AUTH_USER']) and ($_SERVER['PHP_AUTH_USER'] == $this->user_u) && (sha1($_SERVER['PHP_AUTH_PW']) == $this->pass_x)) {
     
             // 古いクッキーをクリアしておく
             $this->clearCookieAuth();
     
             // ログインログを記録する
             $this->logLoginSuccess();
     
             return true;
     
         } else {
     
             header('WWW-Authenticate: Basic realm="zone"');
             header('HTTP/1.0 401 Unauthorized');
             echo 'Login Failed. ユーザ認証に失敗しました。';
     
             // ログイン失敗ログを記録する
             $this->logLoginFailed();
     
             exit;
         }
     }
     */
     // }}}
     return false;
 }