コード例 #1
0
ファイル: insert.php プロジェクト: iyeanmot/usingtemplet
// 현재 시간(년-월-일-시-분) 저장
$ip = $REMOTE_ADDR;
// 방문자의 IP 주소 저장
$connect = mysqli_connect("localhost", "root", "apmsetup", "Task");
if (mysqli_connect_errno()) {
    die('Connect Error: ' . mysqli_connect_error());
}
$sql = "select * from student_list where Mail='{$email}'";
$result = mysqli_query($connect, $sql);
$exist_id = mysqli_num_rows($result);
//넘버 받아오기
if ($exist_id) {
    echo "\n    <script>\n          window.alert('exist ID.')\n          history.go(-1)\n        </script>\n    ";
    exit;
} else {
    if ($passwd != $passwd_confirm) {
        echo "\n        <script>\n          window.alert('Please check re-password.')\n          history.go(-1)\n        </script>\n            ";
        exit;
    } else {
        // 레코드 삽입 명령을 $sql에 입력
        $salt = mt_rand(1000, 9999);
        $hashed = Hashed($passwd, $salt);
        $sql = "INSERT INTO student_list (Name, Nick, Mail, HashedPW, Salt, loginCount) ";
        $sql .= "values('{$name}', '{$nick}', '{$email}', '{$hashed}', '{$salt}', 0)";
        mysqli_query($connect, $sql);
        // $sql 에 저장된 명령 실행
    }
}
mysqli_close($connect);
// 데이터베이스 연결 끊기
echo "\n  <script>\n    location.href = '../index.html';\n  </script>\n  ";
コード例 #2
0
ファイル: changePW.php プロジェクト: iyeanmot/usingtemplet
    $arr[0] = $ip_pass;
    $arr[1] = $salt;
    $hashedPW = implode($arr);
    $hashedPW = md5($hashedPW);
    //echo($hashedPW);
    return $hashedPW;
}
if ($newPW != $RenewPW) {
    echo "\n      <script>\n                   window.alert('Please check PW check')\n                  history.go(-1)\n                 </script>\n    ";
} else {
    $connect = mysqli_connect("localhost", "root", "apmsetup", "Task");
    if (mysqli_connect_errno()) {
        die('Connect Error: ' . mysqli_connect_error());
    }
    $mail = $_SESSION['userid'];
    $sql = "select * from student_list where Mail='{$mail}'";
    $result = mysqli_query($connect, $sql);
    $row = mysqli_fetch_array($result);
    //넘버 받아오기
    echo $_SESSION['userid'];
    //newPW로 비번 변경
    $salt = mt_rand(1000, 9999);
    $hashedPW = Hashed($newPW, $salt);
    $sql = "UPDATE student_list SET HashedPW = '{$hashedPW}' where Mail = '{$mail}'";
    mysqli_query($connect, $sql);
    $sql = "UPDATE student_list SET Salt = '{$salt}' where Mail = '{$mail}'";
    mysqli_query($connect, $sql);
    mysqli_close($connect);
    // DB 연결 끊기
    echo 'Your PW is changed.';
}
コード例 #3
0
ファイル: findpw.php プロジェクト: iyeanmot/usingtemplet
{
    $arr = array();
    $arr[0] = $ip_pass;
    $arr[1] = $salt;
    $hashedPW = implode($arr);
    $hashedPW = md5($hashedPW);
    //echo($hashedPW);
    return $hashedPW;
}
$connect = mysqli_connect("localhost", "root", "apmsetup", "Task");
if (mysqli_connect_errno()) {
    die('Connect Error: ' . mysqli_connect_error());
}
$sql = "select * from student_list where Mail='{$mail}'";
$result = mysqli_query($connect, $sql);
$num_match = mysqli_num_rows($result);
//넘버 받아오기
if (!$num_match) {
    echo "\n      <script>\n                   window.alert('등록되지 않은 아이디입니다.')\n                  history.go(-1)\n                 </script>\n    ";
} else {
    $tmpPW = mt_rand(1000, 9999);
    $salt = mt_rand(1000, 9999);
    $tmphashedPW = Hashed($tmpPW, $salt);
    $sql = "UPDATE student_list SET HashedPW = '{$tmphashedPW}' where Mail = '{$mail}'";
    mysqli_query($connect, $sql);
    $sql = "UPDATE student_list SET Salt = '{$salt}' where Mail = '{$mail}'";
    mysqli_query($connect, $sql);
    mysqli_close($connect);
    // DB 연결 끊기
    echo 'New PW is ' . $tmpPW;
}
コード例 #4
0
ファイル: login.php プロジェクト: iyeanmot/usingtemplet
        $sql = "UPDATE student_list SET loginCount = '{$loginCnt}' where Mail = '{$userid}'";
        mysqli_query($connect, $sql);
        //로그인 시도 횟수 초기화
        $tryLogin = 0;
        $sql = "UPDATE student_list SET tryTologin = '******' where Mail = '{$userid}'";
        mysqli_query($connect, $sql);
        echo "It's your " . $loginCnt . "th login";
        //echo($hashedPass);
        $_SESSION['userid'] = $userid;
        $_SESSION['username'] = $username;
        $_SESSION['usernick'] = $usernick;
        //로그인 열번째일때 salt 및 hashedPW 변경
        if ($loginCnt % 10 == 0) {
            $salt = mt_rand(1000, 9999);
            //$arr = array();
            //$arr[0] = $pass;
            //$arr[1] = $salt;
            //$NEWhashedPW = implode($arr);
            //$NEWhashedPW = md5($NEWhashedPW);
            $NEWhashedPW = Hashed($pass, $salt);
            echo $salt;
            $sql = "UPDATE student_list SET HashedPW = '{$NEWhashedPW}' where Mail = '{$userid}'";
            mysqli_query($connect, $sql);
            $sql = "UPDATE student_list SET Salt = '{$salt}' where Mail = '{$userid}'";
            mysqli_query($connect, $sql);
        }
        mysqli_close($connect);
        // DB 연결 끊기
        echo "\n        <script>\n                       location.href='./index.html';\n\t\t\t\t\t   window.alert('로그인 성공.')\n                     </script>\n      ";
    }
}