-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
390 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: dell1 | ||
* Date: 2016/7/27 | ||
* Time: 22:59 | ||
*/ | ||
$a="<br/>"; | ||
$check=$_POST["check"]; | ||
session_set_cookie_params(60); | ||
session_start(); | ||
$user = $_SESSION['user']; | ||
$check_mobile=$_SESSION['rand']; | ||
$ps=$_SESSION['password']; | ||
$mobile=$_SESSION['mobile']; | ||
$check_allow='/^[a-zA-Z0-9]{4}$/u'; | ||
|
||
if (!preg_match($check_allow, $check)) { | ||
exit('please input the valid verification code!<a href="javascript:history.back(-1);">back'); | ||
} | ||
|
||
|
||
|
||
if ($check_mobile != $check) { | ||
exit('please input the right verification code!<a href="javascript:history.back(-1);">back'); | ||
} | ||
|
||
else{ | ||
//连接数据库 | ||
$mysql=new mysqli('127.0.0.1','root','123','user'); | ||
$mysql->query("set names gbk"); | ||
if (mysqli_connect_errno($mysql)) | ||
{ echo 'ERROR: could not connect the database'; | ||
exit(1); | ||
} | ||
else { | ||
|
||
//对用户口令哈希后连同手机号用户名一起存储 | ||
$ps_hs = password_hash($ps, PASSWORD_DEFAULT); | ||
|
||
$sql = "insert into users(users,password,mobile)values(?,?,?)"; | ||
|
||
$mysqli_stmt = $mysql->prepare($sql); | ||
|
||
$mysqli_stmt->bind_param("sss",$user,$ps_hs,$mobile); | ||
|
||
$b = $mysqli_stmt->execute(); | ||
|
||
if(!$b){ | ||
die("failed".$mysqli_stmt->error); | ||
exit(); | ||
}else { | ||
echo "register successfully"; | ||
} | ||
|
||
|
||
|
||
} | ||
} | ||
|
||
|
||
session_destroy(); | ||
echo $a; | ||
echo('Ha ha! Welcome to be a member of my system though there is nothing!'); | ||
echo $a; | ||
echo "<input type=\"button\" onclick=\"window.location.href='../html/index.html'\" value=\"return to the home page\">"; | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: dell1 | ||
* Date: 2016/12/30 | ||
* Time: 14:23 | ||
*/ | ||
function phonecheck($code,$mobile){ | ||
include ("../mobilesdk/TopSdk.php"); | ||
date_default_timezone_set('Asia/Shanghai'); | ||
$c = new TopClient; | ||
$c ->appkey = "23584723"; | ||
$c ->secretKey = "**********" ; | ||
$req = new AlibabaAliqinFcSmsNumSendRequest; | ||
$req ->setExtend( "" ); | ||
$req ->setSmsType( "normal" ); | ||
$req ->setSmsFreeSignName( "信息安全2014" ); | ||
$req->setSmsParam('{"code":"'. $code .'"}'); | ||
$req ->setRecNum( "{$mobile}" ); | ||
$req ->setSmsTemplateCode( "SMS_37170038" ); | ||
$resp = $c ->execute( $req ); | ||
var_dump($resp); | ||
} | ||
function GetfourStr() | ||
{ | ||
$chars_array = array( | ||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", | ||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", | ||
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", | ||
"w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", | ||
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", | ||
"S", "T", "U", "V", "W", "X", "Y", "Z", | ||
|
||
); | ||
$charsLen = count($chars_array) - 1; | ||
|
||
$outputstr = ""; | ||
for ($i=0; $i<4; $i++) | ||
{ | ||
$outputstr .= $chars_array[mt_rand(0, $charsLen)]; | ||
} | ||
return $outputstr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: dell1 | ||
* Date: 2017/1/1 | ||
* Time: 23:22 | ||
*/ | ||
$a="<br/>"; | ||
$check=$_POST["check"]; | ||
session_start(); | ||
$user = $_SESSION['user']; | ||
$check_mobile=$_SESSION['rand']; | ||
$mobile=$_SESSION['mobile']; | ||
$check_allow='/^[a-zA-Z0-9]{4}$/u'; | ||
|
||
if (!preg_match($check_allow, $check)) { | ||
exit('please input the valid verification code!<a href="javascript:history.back(-1);">back'); | ||
} | ||
|
||
if ($check_mobile != $check) { | ||
exit('please input the right verification code!<a href="javascript:history.back(-1);">back'); | ||
} | ||
else | ||
{ | ||
|
||
echo ('WELCOME TO BACK ! '); | ||
echo $user; | ||
echo $a; | ||
echo('Ha ha!This is my lovely system though there is nothing!'); | ||
echo $a; | ||
session_destroy(); | ||
echo "<input type=\"button\" onclick=\"window.location.href='system.php'\" value=\"go into the system\">"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: dell1 | ||
* Date: 2016/7/27 | ||
* Time: 0:22 | ||
*/ | ||
include ("demo.php"); | ||
if(isset($_POST["submit"]) && $_POST["submit"]=="登入") | ||
{ | ||
$user=$_POST["username"]; | ||
$ps=$_POST["password"]; | ||
$name_allow = '/^[a-zA-Z0-9\x{4e00}-\x{9fa5}]{3,20}$/u'; | ||
//echo $user; | ||
echo "<br/>"; | ||
if (!preg_match($name_allow, $user)) { | ||
|
||
exit('This is an invalid username!<a href="javascript:history.back(-1);">back'); | ||
} | ||
//连接数据库 | ||
$mysql=new mysqli('127.0.0.1','root','123','user'); | ||
if (mysqli_connect_errno($mysql)) | ||
{ echo 'ERROR: could not connect the database'; | ||
exit(1); | ||
} | ||
$mysql->query("set names gbk"); | ||
|
||
|
||
$check_name="select users from users where users=?"; | ||
$check_name_stmt = $mysql->prepare($check_name); | ||
$check_name_stmt->bind_param("s",$user); | ||
$c = $check_name_stmt->execute(); | ||
|
||
if(!$c){ | ||
die("failed".$check_stmt->error); | ||
exit(); | ||
} | ||
if(!$check_name_stmt->fetch()) | ||
{ $check_name_stmt->close(); | ||
exit('Invalid username!Please register at first!<a href="javascript:history.back(-1);">back'); | ||
}else{ | ||
$check_name_stmt->close(); | ||
} | ||
|
||
|
||
//验证口令哈希值 | ||
$ps_hs = password_hash($ps, PASSWORD_DEFAULT); | ||
$check_ps="select password from users where users=?"; | ||
$check_ps_stmt = $mysql->prepare($check_ps); | ||
$check_ps_stmt->bind_param("s",$user); | ||
$check_ps_stmt->bind_result($password); | ||
$d = $check_ps_stmt->execute(); | ||
echo $user; | ||
if(!$d){ | ||
die("failed".$check_ps_stmt->error); | ||
exit(); | ||
} | ||
|
||
if(!$check_ps_stmt->fetch()) | ||
{ | ||
$check_ps_stmt->close(); | ||
exit('Error!<a href="javascript:history.back(-1);">back'); | ||
} | ||
else{ | ||
echo $password; | ||
$verify=$password; | ||
$check_ps_stmt->close(); | ||
} | ||
|
||
|
||
|
||
//获得该用户手机号 | ||
$phone="select mobile from users where users=?"; | ||
$phone_stmt = $mysql->prepare($phone); | ||
$phone_stmt->bind_param("s",$user); | ||
$phone_stmt->bind_result($mob); | ||
$e = $phone_stmt->execute(); | ||
|
||
if(!$e){ | ||
die("failed".$phone_stmt->error); | ||
exit(); | ||
} | ||
else{ | ||
while($phone_stmt->fetch()) { | ||
|
||
$mobile = $mob; | ||
$phone_stmt->close(); | ||
} | ||
} | ||
|
||
if(password_verify($ps,$verify)) | ||
{ | ||
|
||
$rand = GetfourStr(); | ||
mysqli_close($mysql); | ||
phonecheck($rand,$mobile); | ||
session_start(); | ||
$_SESSION['user'] = $user; | ||
$_SESSION['mobile']=$mobile['mobile']; | ||
$_SESSION['rand'] = $rand; | ||
echo "<script>location.href='../html/login check.html';</script>"; | ||
} | ||
else | ||
{ | ||
exit('Password Error!<a href="javascript:history.back(-1);">back'); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: dell1 | ||
* Date: 2016/7/26 | ||
* Time: 9:05 | ||
*/ | ||
include ("demo.php"); | ||
$a="<br/>"; | ||
|
||
if(isset($_POST["submit"]) && $_POST["submit"]=="注册") { | ||
$user = $_POST["username"]; | ||
$ps = $_POST["password"]; | ||
$va = $_POST["validate"]; | ||
$mobile = $_POST["mobile"]; | ||
$name_allow = '/^[a-zA-Z0-9\x{4e00}-\x{9fa5}]{3,20}$/u'; | ||
$ps_allow = '/^(?!([\d_])+$)(?!([a-zA-Z_]{3,20}+)$)\w+$/'; | ||
$mobile_allow = '/^0?(13|14|15|17|18)[0-9]{9}$/'; | ||
//echo 1; | ||
//禁止输入空值 | ||
if ($user == "" || $ps == "" || $va == "" || $mobile == "") { | ||
exit('Do not input the invalid value!<a href="javascript:history.back(-1);">back'); | ||
|
||
} | ||
|
||
|
||
//用户名规范限制 | ||
if (!preg_match($name_allow, $user)) { | ||
|
||
exit('This is an invalid username!<a href="javascript:history.back(-1);">back'); | ||
} | ||
//手机号规范限制 | ||
if (!preg_match($mobile_allow, $mobile)) { | ||
|
||
exit('This is an invalid phone number!<a href="javascript:history.back(-1);">back'); | ||
} | ||
//密码长度限制 | ||
if (strlen($ps) > 10) { | ||
exit('your password is out of limit!<a href="javascript:history.back(-1);">back'); | ||
} | ||
|
||
//禁止输入弱口令 | ||
if (!preg_match($ps_allow, $ps)) { | ||
|
||
exit('This password is too simple!<a href="javascript:history.back(-1);">back'); | ||
} | ||
|
||
//验证密码 | ||
if ($ps != $va) { | ||
exit('please input the same password!<a href="javascript:history.back(-1);">back'); | ||
} | ||
|
||
//检查是否存在相同用户名 | ||
$mysql=new mysqli('127.0.0.1','root','123','user'); | ||
if (mysqli_connect_errno($mysql)) | ||
{ echo 'ERROR: could not connect the database'; | ||
exit(1); | ||
} | ||
$mysql->query("set names gbk"); | ||
//检查是否存在相同用户名 | ||
$check="select users from users where users=?"; | ||
$check_stmt = $mysql->prepare($check); | ||
$check_stmt->bind_param("s",$user); | ||
$c = $check_stmt->execute(); | ||
|
||
if(!$c){ | ||
die("failed".$check_stmt->error); | ||
exit(); | ||
} | ||
if($check_stmt->fetch()) | ||
{ $check_stmt->close(); | ||
exit('The username exits!<a href="javascript:history.back(-1);">back'); | ||
} | ||
|
||
|
||
$rand = GetfourStr(); | ||
session_start(); | ||
$_SESSION['user'] = $user; | ||
$_SESSION['password'] = $ps; | ||
$_SESSION['mobile'] = $mobile; | ||
$_SESSION['rand'] = $rand; | ||
|
||
phonecheck($rand,$mobile); | ||
echo "<script>location.href='../html/mobile check.html';</script>"; | ||
} | ||
|
||
//连接数据库 | ||
|
||
/* $mysql=new mysqli('127.0.0.1','root','123','user'); | ||
if (mysqli_connect_errno($mysql)) | ||
{ echo 'ERROR: could not connect the database'; | ||
exit(1); | ||
} | ||
mysqli_query("set names 'utf8'"); | ||
//检查是否存在相同用户名 | ||
$check=mysqli_query($mysql,"select users from users where users='$user'"); | ||
$result=mysqli_num_rows($check); | ||
if($result) | ||
{ | ||
exit('the username exists!<a href="javascript:history.back(-1);">back'); | ||
} | ||
else | ||
{ | ||
//对用户口令哈希后存储 | ||
$ps_hs = password_hash($ps, PASSWORD_DEFAULT); | ||
$mysql_insert = "insert into users(users,password)values('$user','$ps_hs')"; | ||
if (!mysqli_query($mysql, $mysql_insert)) | ||
{ | ||
die('ERROR:' . mysqli_error($mysql)); | ||
} else | ||
{ | ||
echo "用户名为 $user 注册成功"; | ||
} | ||
} | ||
}*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: dell1 | ||
* Date: 2016/7/27 | ||
* Time: 22:59 | ||
*/ | ||
echo 'Ha ha!welcome to my system though there is nothing!'; |