$auth_cookie_html = ''; $mobile =& Net_UserAgent_Mobile::singleton(); require_once P2_LIB_DIR . '/HostCheck.php'; // EZ認証 if (!empty($_SERVER['HTTP_X_UP_SUBNO'])) { if ($_login->hasRegistedAuthCarrier('EZWEB')) { $atag = P2View::tagA(UriUtil::buildQueryUri($_SERVER['SCRIPT_NAME'], array('ctl_regist_ez' => '1', UA::getQueryKey() => UA::getQueryValue())), '解除'); $auth_ctl_html = sprintf('EZ端末ID認証登録済[%s]<br>', $atag); } else { if ($_login->pass_x) { $atag = P2View::tagA(UriUtil::buildQueryUri($_SERVER['SCRIPT_NAME'], array('ctl_regist_ez' => '1', 'regist_ez' => '1', UA::getQueryKey() => UA::getQueryValue())), 'EZ端末IDで認証を登録'); $auth_ctl_html = sprintf('[%s]<br>', $atag); } } // SoftBank認証 } elseif (HostCheck::isAddrSoftBank() && P2Util::getSoftBankID()) { if ($_login->hasRegistedAuthCarrier('SOFTBANK')) { $atag = P2View::tagA(UriUtil::buildQueryUri($_SERVER['SCRIPT_NAME'], array('ctl_regist_jp' => '1', UA::getQueryKey() => UA::getQueryValue())), '解除'); $auth_ctl_html = sprintf('SoftBank端末ID認証登録済[%s]<br>', $atag); } else { if ($_login->pass_x) { $atag = P2View::tagA(UriUtil::buildQueryUri($_SERVER['SCRIPT_NAME'], array('ctl_regist_jp' => '1', 'regist_jp' => '1', UA::getQueryKey() => UA::getQueryValue())), 'SoftBank端末IDで認証を登録'); $auth_ctl_html = sprintf('[%s]<br>', $atag); } } // docomo認証 } elseif ($mobile->isDoCoMo()) { if ($_login->hasRegistedAuthCarrier('DOCOMO')) { $atag = P2View::tagA(UriUtil::buildQueryUri($_SERVER['SCRIPT_NAME'], array('ctl_regist_docomo' => '1', UA::getQueryKey() => UA::getQueryValue())), '解除'); $auth_ctl_html = sprintf('docomo端末ID認証登録済[%s]<br>', $atag); } else {
/** * @return string HTML */ function _getAuthSubInputHtml($mobile) { $auth_sub_input_ht = ''; // EZ認証 if (!empty($_SERVER['HTTP_X_UP_SUBNO'])) { //if (!$_login->hasRegistedAuthCarrier('EZWEB')) { $auth_sub_input_ht = '<input type="hidden" name="ctl_regist_ez" value="1">' . "\n" . '<input type="checkbox" name="regist_ez" value="1" checked>EZ端末IDで認証を登録<br>'; //} // SoftBank認証 // http://www.dp.j-phone.com/dp/tool_dl/web/useragent.php } elseif (HostCheck::isAddrSoftBank() and P2Util::getSoftBankID()) { //if (!$_login->hasRegistedAuthCarrier('SOFTBANK')) { $auth_sub_input_ht = '<input type="hidden" name="ctl_regist_jp" value="1">' . "\n" . '<input type="checkbox" name="regist_jp" value="1" checked>SoftBank端末IDで認証を登録<br>'; //} // docomo認証 } elseif ($mobile->isDoCoMo()) { //if (!$_login->hasRegistedAuthCarrier('DOCOMO')) { $auth_sub_input_ht = '<input type="hidden" name="ctl_regist_docomo" value="1">' . "\n" . '<input type="checkbox" name="regist_docomo" value="1" checked>docomo端末IDで認証を登録<br>'; //} // Cookie認証 } else { $regist_cookie_checked = ' checked'; if (isset($_POST['submit_newuser']) || isset($_POST['submit_userlogin'])) { if (empty($_POST['regist_cookie'])) { $regist_cookie_checked = ''; } } $ignore_cip_checked = ''; if (isset($_POST['submit_newuser']) || isset($_POST['submit_userlogin'])) { if (geti($_POST['ignore_cip']) == '1') { $ignore_cip_checked = ' checked'; } } else { if (geti($_COOKIE['ignore_cip']) == '1') { $ignore_cip_checked = ' checked'; } } $auth_sub_input_ht = '<input type="hidden" name="ctl_regist_cookie" value="1">' . sprintf('<input type="checkbox" id="regist_cookie" name="regist_cookie" value="1"%s><label for="regist_cookie">ログイン情報をCookieに保存する(推奨)</label><br>', $regist_cookie_checked) . sprintf('<input type="checkbox" id="ignore_cip" name="ignore_cip" value="1"%s><label for="ignore_cip">Cookie認証時にIPの同一性をチェックしない</label><br>', $ignore_cip_checked); } return $auth_sub_input_ht; }
} $cont = serialize($conf_save); FileCtl::make_datafile($_conf['conf_user_file'], $_conf['conf_user_perm']); if (FileCtl::file_write_contents($_conf['conf_user_file'], $cont) === false) { $dispname = '$_conf[\'pref_dir\']/' . basename($_conf['conf_user_file']); p2die("ユーザー設定ファイル {$dispname} に書き込めませんでした。"); } } // }}} // {{{ ホストチェック if (!($_conf['secure']['auth_host_only_http'] && !empty($_SERVER['HTTPS']))) { if ($_conf['secure']['auth_host'] && !HostCheck::getHostAuth()) { HostCheck::forbidden(); } if ($_conf['secure']['auth_bbq'] && HostCheck::getHostBurned()) { HostCheck::forbidden(); } } // }}} // {{{ リクエスト変数の検証と文字コード変換 /** * 日本語を入力する可能性のあるフォームには隠し要素で * エンコーディング判定用の文字列を仕込んでいる * * $_COOKIE は $_REQUEST に含めない */ if (!empty($_GET) || !empty($_POST)) { $hint = null; // NULLバイトアタックとスクリプトインジェクションの検証、 // エンコーディング判定用文字列の取得 if (!empty($_POST)) {
/** * md5_encrypt, md5_decrypt のための password(salt) を得る * (クッキーのcidの生成に利用している) * * @static * @access private * @return string */ function getMd5CryptPassForCid() { //return md5($_SERVER['SERVER_NAME'] . $_SERVER['HTTP_USER_AGENT'] . $_SERVER['SERVER_SOFTWARE']); //$seed = $_SERVER['SERVER_NAME'] . $_SERVER['SERVER_SOFTWARE']; $seed = $_SERVER['SERVER_SOFTWARE']; require_once P2_LIB_DIR . '/HostCheck.php'; // ローカルチェックをして、HostCheck::isAddrDocomo() などでホスト名を引く機会を減らす $notK = (bool) (HostCheck::isAddrLocal() || HostCheck::isAddrPrivate()); // 携帯判定された場合は、 IPチェックなし if (!$notK and UA::isK(geti($_SERVER['HTTP_USER_AGENT'])) || HostCheck::isAddrDocomo() || HostCheck::isAddrAu() || HostCheck::isAddrSoftBank() || HostCheck::isAddrWillcom() || HostCheck::isAddrJigWeb() || HostCheck::isAddrJig() || HostCheck::isAddrIbis()) { } elseif (!empty($_COOKIE['ignore_cip'])) { } else { $now_ips = explode('.', $_SERVER['REMOTE_ADDR']); $seed .= $now_ips[0]; } return md5($seed); }
/** * (アクセスユーザの)リモートホストを取得する * * @param string $empty gethostbyaddr() がIPを返した時の時の代替文字。 * @return string */ function getRemoteHost($empty = '') { // gethostbyaddr() は、同じ実行スクリプト内でもキャッシュしないようなのでキャッシュする static $gethostbyaddr_ = null; if (isset($_SERVER['REMOTE_HOST'])) { return $_SERVER['REMOTE_HOST']; } if (php_sapi_name() == 'cli') { return 'cli'; } if (is_null($gethostbyaddr_)) { require_once P2_LIB_DIR . '/HostCheck.php'; $gethostbyaddr_ = HostCheck::cachedGetHostByAddr($_SERVER['REMOTE_ADDR']); } return $gethostbyaddr_ == $_SERVER['REMOTE_ADDR'] ? $empty : $gethostbyaddr_; }
/** * IPは emobile.ad.jp? * http://qb5.2ch.net/test/read.cgi/operate/1247654838/399 * * @static * @access public * @return boolean */ function isAddrEmobileAdJp($addr = null) { if (is_null($addr)) { $addr = $_SERVER['REMOTE_ADDR']; } // http://qb5.2ch.net/test/read.cgi/operate/1235553306/974 // http://developer.emnet.ne.jp/ipaddress.html $bands = array('60.254.209.99/32', '117.55.1.224/27'); return HostCheck::isAddrInBand($addr, $bands); }
/** * MD5Crypt::encrypt, MD5Crypt::decrypt のための password(salt) を得る * (クッキーのcidの生成に利用している) * * @param void * @access private * @return string */ private static function getMd5CryptPassForCid() { static $pass = null; if ($pass !== null) { return $pass; } $seed = $_SERVER['SERVER_SOFTWARE']; // IPチェックなしの場合と if (!empty($_COOKIE['ignore_cip'])) { // 携帯判定された場合は、 IPチェックなし } elseif (UA::isK(geti($_SERVER['HTTP_USER_AGENT'])) || HostCheck::isAddressMobile()) { } else { $now_ips = explode('.', $_SERVER['REMOTE_ADDR']); $seed .= $now_ips[0]; } $pass = md5($seed, true); return $pass; }