root/tags/2.0/wp-register.php

Revision 3272, 5.3 kB (checked in by ryan, 3 years ago)

i18n fix from pandem. fixes #2028

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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&#8217;t correct.');
28     }
29
30   if ( username_exists( $user_login ) )
31         $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
32
33     /* checking the email isn't already used by another user */
34     $email_exists = $wpdb->get_row("SELECT user_email FROM $wpdb->users WHERE user_email = '$user_email'");
35     if ( $email_exists)
36         die (__('<strong>ERROR</strong>: This email address is already registered, please supply another.'));
37
38     if ( 0 == count($errors) ) {
39         $password = substr( md5( uniqid( microtime() ) ), 0, 7);
40
41         $user_id = wp_create_user( $user_login, $password, $user_email );
42         if ( !$user_id )
43             $errors['user_id'] = sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_settings('admin_email'));
44         else
45             wp_new_user_notification($user_id, $password);
46     }
47     
48     if ( 0 == count($errors) ) {
49             
50     ?>
51 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
52 <html xmlns="http://www.w3.org/1999/xhtml">
53 <head>
54     <title>WordPress &raquo; <?php _e('Registration Complete') ?></title>
55     <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />   
56     <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
57     <style type="text/css">
58     .submit {
59         font-size: 1.7em;
60     }
61     </style>
62 </head>
63 <body>
64
65 <div id="login">
66     <h2><?php _e('Registration Complete') ?></h2>
67     <p><?php printf(__('Username: %s'), "<strong>$user_login</strong>") ?><br />
68     <?php printf(__('Password: %s'), '<strong>' . __('emailed to you') . '</strong>') ?> <br />
69     <?php printf(__('E-mail: %s'), "<strong>$user_email</strong>") ?></p>
70     <p class="submit"><a href="wp-login.php"><?php _e('Login'); ?> &raquo;</a></p>
71 </div>
72 </body>
73 </html>
74
75         <?php
76         break;
77     }
78
79 default:
80
81 ?>
82 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
83 <html xmlns="http://www.w3.org/1999/xhtml">
84 <head>
85     <title>WordPress &raquo; <?php _e('Registration Form') ?></title>
86     <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
87     <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css" />
88     <style type="text/css">
89     #user_email, #user_login, #submit {
90         font-size: 1.7em;
91     }
92     </style>
93 </head>
94
95 <body>
96 <div id="login">
97 <h1><a href="http://wordpress.org/">WordPress</a></h1>
98 <h2><?php _e('Register for this blog') ?></h2>
99 <?php if ( isset($errors) ) : ?>
100 <div class="error">
101     <ul>
102     <?php
103     foreach($errors as $error) echo "<li>$error</li>";
104     ?>
105     </ul>
106 </div>
107 <?php endif; ?>
108 <form method="post" action="wp-register.php" id="registerform">
109     <p><input type="hidden" name="action" value="register" />
110     <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 $user_login; ?>" /><br /></p>
111     <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 $user_email; ?>" /></p>
112     <p><?php _e('A password will be emailed to you.') ?></p>
113     <p class="submit"><input type="submit" value="<?php _e('Register') ?> &raquo;" id="submit" name="submit" /></p>
114 </form>
115 <ul>
116     <li><a href="<?php bloginfo('home'); ?>/" title="<?php _e('Are you lost?') ?>">&laquo; <?php _e('Back to blog') ?></a></li>
117     <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li>
118     <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>
119 </ul>
120 </div>
121
122 </body>
123 </html>
124 <?php
125
126 break;
127
128 case 'disabled':
129
130     ?>
131 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
132 <html xmlns="http://www.w3.org/1999/xhtml">
133 <head>
134     <title>WordPress &raquo; <?php _e('Registration Currently Disabled') ?></title>
135     <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
136     <link rel="stylesheet" href="wp-admin/wp-admin.css" type="text/css">
137 </head>
138
139 <body>
140
141 <div id="login">
142     <h2><?php _e('Registration Disabled') ?></h2>
143     <p><?php _e('User registration is currently not allowed.') ?><br />
144     <a href="<?php echo get_settings('home'); ?>/" title="<?php _e('Go back to the blog') ?>"><?php _e('Home') ?></a>
145     </p>
146 </div>
147
148 </body>
149 </html>
150
151     <?php
152 break;
153
154 }
155 ?>
156
Note: See TracBrowser for help on using the browser.