PHP Cross Reference of WordPress Latest 2.0 Branch |
| [ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] |
[Summary view] [Print] [Text view]
1 <?php 2 require('./wp-config.php'); 3 require_once( ABSPATH . WPINC . '/registration-functions.php'); 4 5 $action = $_REQUEST['action']; 6 if ( !get_settings('users_can_register') ) 7 $action = 'disabled'; 8 9 header( 'Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset') ); 10 11 switch( $action ) { 12 13 case 'register': 14 15 $user_login = sanitize_user( $_POST['user_login'] ); 16 $user_email = $_POST['user_email']; 17 18 $errors = array(); 19 20 if ( $user_login == '' ) 21 $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.'); 22 23 /* checking e-mail address */ 24 if ($user_email == '') { 25 $errors['user_email'] = __('<strong>ERROR</strong>: Please type your e-mail address.'); 26 } else if (!is_email($user_email)) { 27 $errors['user_email'] = __('<strong>ERROR</strong>: The email address isn’t correct.'); 28 $user_email = ''; 29 } 30 31 if ( ! validate_username($user_login) ) { 32 $errors['user_login'] = __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'); 33 $user_login = ''; 34 } 35 36 if ( username_exists( $user_login ) ) 37 $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.'); 38 39 /* checking the email isn't already used by another user */ 40 $email_exists = $wpdb->get_row("SELECT user_email FROM $wpdb->users WHERE user_email = '$user_email'"); 41 if ( $email_exists) 42 die (__('<strong>ERROR</strong>: This email address is already registered, please supply another.')); 43 44 if ( 0 == count($errors) ) { 45 $password = substr( md5( uniqid( microtime() ) ), 0, 7); 46 47 $user_id = wp_create_user( $user_login, $password, $user_email ); 48 if ( !$user_id ) 49 $errors['user_id'] = sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email')); 50 else 51 wp_new_user_notification($user_id, $password); 52 } 53 54 if ( 0 == count($errors) ) { 55 56 ?> 57 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 58 <html xmlns="http://www.w3.org/1999/xhtml"> 59 <head> 60 <title>WordPress » <?php _e('Registration Complete') ?></title> 61 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" /> 62 <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" /> 63 <style type="text/css"> 64 .submit { 65 font-size: 1.7em; 66 } 67 </style> 68 </head> 69 <body> 70 71 <div id="login"> 72 <h2><?php _e('Registration Complete') ?></h2> 73 <p><?php printf(__('Username: %s'), "<strong>" . wp_specialchars($user_login) . "</strong>") ?><br /> 74 <?php printf(__('Password: %s'), '<strong>' . __('emailed to you') . '</strong>') ?> <br /> 75 <?php printf(__('E-mail: %s'), "<strong>" . wp_specialchars($user_email) . "</strong>") ?></p> 76 <p class="submit"><a href="wp-login.php"><?php _e('Login'); ?> »</a></p> 77 </div> 78 </body> 79 </html> 80 81 <?php 82 break; 83 } 84 85 default: 86 87 ?> 88 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 89 <html xmlns="http://www.w3.org/1999/xhtml"> 90 <head> 91 <title>WordPress » <?php _e('Registration Form') ?></title> 92 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" /> 93 <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" /> 94 <style type="text/css"> 95 #user_email, #user_login, #submit { 96 font-size: 1.7em; 97 } 98 </style> 99 </head> 100 101 <body> 102 <div id="login"> 103 <h1><a href="http://wordpress.org/">WordPress</a></h1> 104 <h2><?php _e('Register for this blog') ?></h2> 105 <?php if ( isset($errors) ) : ?> 106 <div class="error"> 107 <ul> 108 <?php 109 foreach($errors as $error) echo "<li>$error</li>"; 110 ?> 111 </ul> 112 </div> 113 <?php endif; ?> 114 <form method="post" action="wp-register.php" id="registerform"> 115 <p><input type="hidden" name="action" value="register" /> 116 <label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" value="<?php echo attribute_escape($user_login); ?>" /><br /></p> 117 <p><label for="user_email"><?php _e('E-mail:') ?></label><br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" value="<?php echo attribute_escape($user_email); ?>" /></p> 118 <p><?php _e('A password will be emailed to you.') ?></p> 119 <p class="submit"><input type="submit" value="<?php _e('Register') ?> »" id="submit" name="submit" /></p> 120 </form> 121 <ul> 122 <li><a href="<?php bloginfo('home'); ?>/" title="<?php _e('Are you lost?') ?>">« <?php _e('Back to blog') ?></a></li> 123 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> 124 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li> 125 </ul> 126 </div> 127 128 </body> 129 </html> 130 <?php 131 132 break; 133 134 case 'disabled': 135 136 ?> 137 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 138 <html xmlns="http://www.w3.org/1999/xhtml"> 139 <head> 140 <title>WordPress » <?php _e('Registration Currently Disabled') ?></title> 141 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" /> 142 <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css"> 143 </head> 144 145 <body> 146 147 <div id="login"> 148 <h2><?php _e('Registration Disabled') ?></h2> 149 <p><?php _e('User registration is currently not allowed.') ?><br /> 150 <a href="<?php echo get_settings('home'); ?>/" title="<?php _e('Go back to the blog') ?>"><?php _e('Home') ?></a> 151 </p> 152 </div> 153 154 </body> 155 </html> 156 157 <?php 158 break; 159 160 } 161 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated Sun Dec 2 06:47:37 2007 for RedAlt XRefs | Cross-referenced by PHPXref 0.6 and RedAlt |