hjkhghopjkertteerterterterertertrtoirh
bnmbertsurhetertertertertertertertpdf'tdfg
/
srv
/
www
/
virtual
/
wccweb.jp
/
web
/
htdocs
/
longisland20th
/
include
/
Upload FileeE
HOME
<?php //---------------------------------------------------------------------- // 関数定義 (START) //---------------------------------------------------------------------- //HTMLエスケープ function h($string) { return htmlspecialchars($string, ENT_QUOTES,'utf-8'); } //数値チェック function is_num($str) { if(preg_match("/^[0-9]+$/",$str)) { return true; }else{ return false; } } //NULLバイト除去// function sanitize02($arr){ if(is_array($arr)){ return array_map('sanitize02',$arr); } return str_replace("\0","",$arr); } if(isset($_GET)) $_GET = sanitize02($_GET);//NULLバイト除去// if(isset($_POST)) $_POST = sanitize02($_POST);//NULLバイト除去// if(isset($_COOKIE)) $_COOKIE = sanitize02($_COOKIE);//NULLバイト除去// //パラメータチェック function is_param($str) { if(preg_match("/^[a-zA-Z0-9]+$/",$str)) { return true; }else{ return false; } } //ログイン認証(ユーザー用) function authUser($userid,$password){ $_SESSION['miss_count'] = isset($_SESSION['miss_count']) ? $_SESSION['miss_count'] : 0; //action先をセット //$thisFile = $_SERVER['SCRIPT_NAME']; //$thisFile = h($_SERVER["REQUEST_URI"]);//パラメータも維持するためこちらに変更 //action先をセット //$thisFile = str_replace('index.php','',$_SERVER['SCRIPT_NAME']); $thisFile = './'; //ログアウト処理 if(isset($_GET['logout'])){ $_SESSION = array(); session_destroy();//セッションを破棄 } $error = ''; # セッション変数を初期化 if (!isset($_SESSION['auth_user'])) { $_SESSION['auth_user'] = FALSE; } if (isset($_POST['userid']) && isset($_POST['password'])){ foreach ($userid as $key => $value) { if ($_POST['userid'] === $userid[$key] && $_POST['password'] === $password[$key]) { $oldSid = session_id(); session_regenerate_id(TRUE); if (version_compare(PHP_VERSION, '5.1.0', '<')) { $path = session_save_path() != '' ? session_save_path() : '/tmp'; $oldSessionFile = $path . '/sess_' . $oldSid; if (file_exists($oldSessionFile)) { unlink($oldSessionFile); } } $_SESSION['auth_user'] = TRUE; $_SESSION['miss_count'] = 0; break; } } if ($_SESSION['auth_user'] === FALSE) { $error = 'パスワードに誤りがあります。'; //不正ログインクラック防止処理 if(!isset($_SESSION['miss_count']) || !is_num($_SESSION['miss_count'])) exit(); $_SESSION['miss_count']++; if($_SESSION['miss_count'] > 10){ exit('<p align="center" style="color:#555;line-height:160%;">ログイン認証が連続で失敗したため強制終了しました。</p>'); } } } if ($_SESSION['auth_user'] !== TRUE) { //【セキュリティ設定】クリックジャッキング対策(iframeで表示させない) header('X-FRAME-OPTIONS: DENY'); $htmlFilePath = dirname(__FILE__) .'/../login.html'; if(!file_exists($htmlFilePath)) exit('login.htmlが見当たりません。ただちにlogin.htmlを設置して下さい。'); //ログイン画面用のhtmlファイルを読み込む $html = file_get_contents($htmlFilePath); //action属性のパスをセットする if(strpos($html,'action="{thisFilePath}"') !== false){//action="{thisFilePath}"が含まれていたら置換する $html = str_replace('action="{thisFilePath}"','action="'.$thisFile.'"',$html); }else{//action="{thisFilePath}"が含まれていない場合はエラーとする exit('重大なエラー。ログイン画面用のファイル内のformタグのaction属性の値に{thisFilePath}の文字列が存在しません。必ず <form action="{thisFilePath}"・・・・ として下さい。'); } //エラーメッセージ $html = str_replace('{error}',$error,$html); //POSTデータの再セット $html = (!empty($_POST['password'])) ? str_replace('{password}',h($_POST['password']),$html) : str_replace('{password}','',$html); $html = str_replace('{userid}',$userid[0],$html); //html出力 echo <<<EOF {$html} EOF; exit(); } } //---------------------------------------------------------------------- // 関数定義 (END) //---------------------------------------------------------------------- ?>