2018-05-26 18:59:29 +08:00
< ? php
/**
Template Name : Register
*/
get_header ();
if ( ! empty ( $_POST [ 'register_reg' ]) ) {
$error = '' ;
$sanitized_user_login = sanitize_user ( $_POST [ 'user_login' ] );
$user_email = apply_filters ( 'user_registration_email' , $_POST [ 'user_email' ] );
// Check the username
if ( $sanitized_user_login == '' ) {
2019-10-31 17:25:24 +08:00
$error .= '<strong>' . __ ( " Error " , " sakura " ) ./* 错误 */ '</strong>: ' . __ ( " Please enter username. " , " sakura " ) ./* 请输入用户名。 */ '<br />' ;
2018-05-26 18:59:29 +08:00
} elseif ( ! validate_username ( $sanitized_user_login ) ) {
2019-10-31 17:25:24 +08:00
$error .= '<strong>' . __ ( " Error " , " sakura " ) ./* 错误 */ '</strong>: ' . __ ( " Invalid characters, please enter a valid username. " , " sakura " ) ./* 此用户名包含无效字符,请输入有效的用户名。 */ '<br />' ;
2018-05-26 18:59:29 +08:00
$sanitized_user_login = '' ;
} elseif ( username_exists ( $sanitized_user_login ) ) {
2019-10-31 17:25:24 +08:00
$error .= '<strong>' . __ ( " Error " , " sakura " ) ./* 错误 */ '</strong>: ' . __ ( " This username has been registered. " , " sakura " ) ./* 该用户名已被注册。 */ '<br />' ;
2018-05-26 18:59:29 +08:00
}
// Check the e-mail address
if ( $user_email == '' ) {
2019-10-31 17:25:24 +08:00
$error .= '<strong>' . __ ( " Error " , " sakura " ) ./* 错误 */ '</strong>: ' . __ ( " Please enter email address. " , " sakura " ) ./* 请填写电子邮件地址。 */ '<br />' ;
2018-05-26 18:59:29 +08:00
} elseif ( ! is_email ( $user_email ) ) {
2019-11-17 21:36:51 +08:00
$error .= '<strong>' . __ ( " Error " , " sakura " ) ./* 错误 */ '</strong>: ' . __ ( " Invalid email address. " , " sakura " ) ./* 电子邮件地址不正确。 */ '<br />' ;
2018-05-26 18:59:29 +08:00
$user_email = '' ;
} elseif ( email_exists ( $user_email ) ) {
2019-10-31 17:25:24 +08:00
$error .= '<strong>' . __ ( " Error " , " sakura " ) ./* 错误 */ '</strong>: ' . __ ( " This email address has been registered. " , " sakura " ) ./* 该电子邮件地址已经被注册。 */ '<br />' ;
2018-05-26 18:59:29 +08:00
}
// Check the password
if ( strlen ( $_POST [ 'user_pass' ]) < 6 ){
2019-11-17 21:36:51 +08:00
$error .= '<strong>' . __ ( " Error " , " sakura " ) ./* 错误 */ '</strong>: ' . __ ( " Password length is at least 6 digits. " , " sakura " ) ./* 密码长度至少6位。 */ '<br />' ;
2018-05-26 18:59:29 +08:00
} elseif ( $_POST [ 'user_pass' ] != $_POST [ 'user_pass2' ]){
2019-11-17 21:36:51 +08:00
$error .= '<strong>' . __ ( " Error " , " sakura " ) ./* 错误 */ '</strong>: ' . __ ( " Inconsistent password entered twice. " , " sakura " ) ./* 两次输入的密码不一致。 */ '<br />' ;
2018-05-26 18:59:29 +08:00
}
// verification
if ( akina_option ( 'login_validate' ) && strlen ( $_POST [ 'verification' ]) > 0 ){
2019-10-31 17:25:24 +08:00
$error .= '<strong>' . __ ( " Error " , " sakura " ) ./* 错误 */ '</strong>: ' . __ ( " Please drag the slider to verify identity " , " sakura " ) ./* 请拖动滑块验证身份 */ '<br />' ;
2018-05-26 18:59:29 +08:00
}
if ( $error == '' ) {
$user_id = wp_create_user ( $sanitized_user_login , $_POST [ 'user_pass' ], $user_email );
if ( ! $user_id ) {
2019-10-31 17:25:24 +08:00
$error .= '<strong>' . __ ( " Error " , " sakura " ) ./* 错误 */ '</strong>: ' . __ ( " Unable to complete registration request...Please contact " , " sakura " ) ./* 无法完成注册请求 ... 请联系 */ '<a href=\"mailto:' . get_option ( 'admin_email' ) . '\">' . __ ( " administrator " , " sakura " ) ./* 管理员 */ '</a>! <br />' ;
2018-05-26 18:59:29 +08:00
} else if ( ! is_user_logged_in ()) {
$user = get_userdatabylogin ( $sanitized_user_login );
$user_id = $user -> ID ;
// 自动登录
wp_set_current_user ( $user_id , $user_login );
wp_set_auth_cookie ( $user_id );
do_action ( 'wp_login' , $user_login );
}
}
}
?>
< div id = " primary " class = " content-area " >
< main id = " main " class = " site-main " role = " main " >
< ? php if ( akina_option ( 'ex_register_open' )) : ?>
< ? php if ( ! is_user_logged_in ()){ ?>
< div class = " ex-register " >
< div class = " ex-register-title " >
< h3 > New Account </ h3 >
</ div >
< form action = " <?php echo $_SERVER["REQUEST_URI"] ; ?> " method = " post " >
< p >< input type = " text " name = " user_login " tabindex = " 1 " id = " user_login " class = " input " value = " <?php if(!empty( $sanitized_user_login )) echo $sanitized_user_login ; ?> " placeholder = " 用户名 " required /></ p >
< p >< input type = " text " name = " user_email " tabindex = " 2 " id = " user_email " class = " input " value = " <?php if(!empty( $user_email )) echo $user_email ; ?> " size = " 25 " placeholder = " 电子邮箱 " required /></ p >
< p >< input id = " user_pwd1 " class = " input " tabindex = " 3 " type = " password " tabindex = " 21 " size = " 25 " value = " " name = " user_pass " placeholder = " 密码 " required /></ p >
< p >< input id = " user_pwd2 " class = " input " tabindex = " 4 " type = " password " tabindex = " 21 " size = " 25 " value = " " name = " user_pass2 " placeholder = " 确认密码 " required /></ p >
< ? php if ( akina_option ( 'login_validate' )) : ?>
< div id = " verification-slider " >
< div id = " slider " >
< div id = " slider_bg " ></ div >
2019-10-31 17:25:24 +08:00
< span id = " label " > » </ span >< span id = " labelTip " >< ? php _e ( " Drag the slider to verify " , " sakura " ) /*拖动滑块验证*/ ?> </span>
2018-05-26 18:59:29 +08:00
</ div >
< input type = " hidden " name = " verification " value = " verification " />
</ div >
< ? php endif ; ?>
< input type = " hidden " name = " register_reg " value = " ok " />
< ? php if ( ! empty ( $error )) { echo '<p class="user-error">' . $error . '</p>' ; } ?>
2019-10-31 17:25:24 +08:00
< input class = " button register-button " name = " submit " type = " submit " value = " <?php _e( " Sign up " , " sakura " )/*注 册*/?> " >
2018-05-26 18:59:29 +08:00
</ form >
</ div >
< ? php } else {
$loadurl = akina_option ( 'exlogin_url' ) ? akina_option ( 'exlogin_url' ) : get_bloginfo ( 'url' );
?>
< script >// window . location . href = '<?php echo $loadurl; ?>' ; </ script >
< ? php } ?>
< ? php else : ?>
2019-11-17 21:36:51 +08:00
< div class = " register-close " >< p >< ? php _e ( " Registration is not open yet. " , " sakura " ) /*暂未开放注册。*/ ?> </p></div>
2018-05-26 18:59:29 +08:00
< ? php endif ; ?>
</ main ><!-- #main -->
</ div ><!-- #primary -->
< style type = " text/css " >
#slider {
margin : 0 auto 20 px auto ;
width : 300 px ;
height : 46 px ;
position : relative ;
border - radius : 3 px ;
background - color : #eee;
overflow : hidden ;
text - align : center ;
user - select : none ;
- moz - user - select : none ;
- webkit - user - select : none ;
}
#slider_bg {
position : absolute ;
left : 0 ;
top : 0 ;
height : 100 % ;
background - color : #444;
z - index : 1 ;
border - radius : 3 px 0 0 3 px ;
}
#label {
width : 46 px ;
position : absolute ;
left : 0 ;
top : 0 ;
height : 46 px ;
line - height : 38 px ;
border : 1 px solid #ddd;
background : #fff;
z - index : 3 ;
cursor : move ;
color : #E67474;
font - size : 38 px ;
font - weight : 900 ;
border - radius : 3 px ;
}
#labelTip {
position : absolute ;
left : 0 ;
width : 100 % ;
height : 100 % ;
font - size : 13 px ;
font - family : 'Microsoft Yahei' , serif ;
color : #888;
line - height : 46 px ;
text - align : center ;
z - index : 2 ;
}
#verification-slider{
margin : 1 em ;
}
#verification-ok{
color : #777;
}
</ style >
< ? php
get_footer ();
?>
< script type = " text/javascript " >
var startTime = 0 ;
var endTime = 0 ;
var numTime = 0 ;
$ ( function () {
var slider = new SliderUnlock ( " #slider " ,{
successLabelTip : " OK "
}, function (){
var sli_width = $ ( " #slider_bg " ) . width ();
$ ( '#verification-slider' ) . html ( '' ) . append ( '<input id="verification-ok" class="input" type="text" size="25" value="Pass!" name="verification" disabled="true" />' );
endTime = nowTime ();
numTime = endTime - startTime ;
endTime = 0 ;
startTime = 0 ;
// 获取到滑动使用的时间 滑动的宽度
// alert( numTime );
// alert( sli_width );
});
slider . init ();
})
/**
* 获取时间精确到毫秒
* @ type
*/
function nowTime (){
var myDate = new Date ();
var H = myDate . getHours (); //获取小时
var M = myDate . getMinutes (); //获取分钟
var S = myDate . getSeconds (); //获取秒
var MS = myDate . getMilliseconds (); //获取毫秒
var milliSeconds = H * 3600 * 1000 + M * 60 * 1000 + S * 1000 + MS ;
return milliSeconds ;
}
</ script >
2019-11-17 21:36:51 +08:00
< script type = 'text/javascript' src = '<?php bloginfo("template_url"); ?>/user/verification.js' ></ script >