Ticket #489: wpmu-1.2.3-emaildomain2.patch.txt

File wpmu-1.2.3-emaildomain2.patch.txt, 5.7 kB (added by russgrue, 1 year ago)
Line 
1 diff -c -r wpmu-1.2.3/wp-admin/wpmu-edit.php wpmu-1.2.3-patched/wp-admin/wpmu-edit.php
2 *** wpmu-1.2.3/wp-admin/wpmu-edit.php   Thu Aug 16 10:50:50 2007
3 --- wpmu-1.2.3-patched/wp-admin/wpmu-edit.php   Thu Aug 16 11:37:53 2007
4 ***************
5 *** 24,33 ****
6                                 $names[] = trim( $name );
7                 }
8                 update_site_option( "illegal_names", $names );
9 !               if( $_POST[ 'limited_email_domains' ] != '' ) {
10 !                       update_site_option( "limited_email_domains", split( ' ', $_POST[ 'limited_email_domains' ] ) );
11                 } else {
12 !                       update_site_option( "limited_email_domains", '' );
13                 }
14                 if( $_POST[ 'banned_email_domains' ] != '' ) {
15                         $banned_email_domains = split( "\n", stripslashes($_POST[ 'banned_email_domains' ]) );
16 --- 24,37 ----
17                                 $names[] = trim( $name );
18                 }
19                 update_site_option( "illegal_names", $names );
20 !               if( $_POST[ 'allowed_email_domains' ] != '' ) {
21 !                       $allowed_email_domains = split( "\n", stripslashes($_POST[ 'allowed_email_domains' ]) );
22 !                       foreach( $allowed_email_domains as $domain ) {
23 !                               $allowed[] = trim( $domain );
24 !                       }
25 !                       update_site_option( "allowed_email_domains", $allowed );
26                 } else {
27 !                       update_site_option( "allowed_email_domains", '' );
28                 }
29                 if( $_POST[ 'banned_email_domains' ] != '' ) {
30                         $banned_email_domains = split( "\n", stripslashes($_POST[ 'banned_email_domains' ]) );
31 ***************
32 *** 417,420 ****
33                 wpmu_admin_do_redirect( "wpmu-admin.php" );
34         break;
35   }
36 ! ?>
37 \ No newline at end of file
38 --- 421,424 ----
39                 wpmu_admin_do_redirect( "wpmu-admin.php" );
40         break;
41   }
42 ! ?>
43 diff -c -r wpmu-1.2.3/wp-admin/wpmu-options.php wpmu-1.2.3-patched/wp-admin/wpmu-options.php
44 *** wpmu-1.2.3/wp-admin/wpmu-options.php        Thu Aug 16 10:50:50 2007
45 --- wpmu-1.2.3-patched/wp-admin/wpmu-options.php        Thu Aug 16 11:37:53 2007
46 ***************
47 *** 53,62 ****
48                 <?php _e('Users are not allowed to register these blogs. Separate names by spaces.') ?></td>
49                 </tr>
50                 <tr valign="top">
51 !               <th scope="row"><?php _e('Limited Email Registrations:') ?></th>
52 !               <td><input name="limited_email_domains" type="text" id="limited_email_domains" style="width: 95%" value="<?php echo get_site_option('limited_email_domains') == '' ? '' : @implode( " ", get_site_option('limited_email_domains') ); ?>" size="45" />
53                 <br />
54 !               <?php _e('If you want to limit blog registrations to certain domains. Separate domains by spaces.') ?></td>
55                 </tr>
56                 <tr valign="top">
57                 <th scope="row"><?php _e('Banned Email Domains:') ?></th>
58 --- 53,62 ----
59                 <?php _e('Users are not allowed to register these blogs. Separate names by spaces.') ?></td>
60                 </tr>
61                 <tr valign="top">
62 !               <th scope="row"><?php _e('Allowed Email Domains:') ?></th>
63 !               <td><textarea name="allowed_email_domains" id="allowed_email_domains" cols='40' rows='5'><?php echo get_site_option('allowed_email_domains') == '' ? '' : @implode( "\n", get_site_option('allowed_email_domains') ); ?></textarea>
64                 <br />
65 !               <?php _e('If you want to allow certain email domains from blog registrations. One domain per line.') ?></td>
66                 </tr>
67                 <tr valign="top">
68                 <th scope="row"><?php _e('Banned Email Domains:') ?></th>
69 diff -c -r wpmu-1.2.3/wp-includes/wpmu-functions.php wpmu-1.2.3-patched/wp-includes/wpmu-functions.php
70 *** wpmu-1.2.3/wp-includes/wpmu-functions.php   Thu Aug 16 10:50:50 2007
71 --- wpmu-1.2.3-patched/wp-includes/wpmu-functions.php   Thu Aug 16 11:37:53 2007
72 ***************
73 *** 878,886 ****
74   }
75  
76   function is_email_address_unsafe( $user_email ) {
77         $banned_names = get_site_option( "banned_email_domains" );
78         if ( is_array( $banned_names ) && empty( $banned_names ) == false ) {
79 -               $email_domain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );
80                 foreach( $banned_names as $banned_domain ) {
81                         if( $banned_domain == '' )
82                                 continue;
83 --- 878,887 ----
84   }
85  
86   function is_email_address_unsafe( $user_email ) {
87 +       $allowed_names = get_site_option( "allowed_email_domains" );
88         $banned_names = get_site_option( "banned_email_domains" );
89 +       $email_domain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );
90         if ( is_array( $banned_names ) && empty( $banned_names ) == false ) {
91                 foreach( $banned_names as $banned_domain ) {
92                         if( $banned_domain == '' )
93                                 continue;
94 ***************
95 *** 894,900 ****
96                         return true;
97                 }
98         }
99 !       return false;
100   }
101  
102   function wpmu_validate_user_signup($user_name, $user_email) {
103 --- 895,917 ----
104                         return true;
105                 }
106         }
107 !       if ( is_array( $allowed_names ) && empty( $allowed_names ) == false ) {
108 !               foreach( $allowed_names as $allowed_domain ) {
109 !                       if( $allowed_domain == '' )
110 !                               continue;
111 !                       if (
112 !                               strstr( $email_domain, $allowed_domain ) ||
113 !                               (
114 !                                       strstr( $allowed_domain, '/' ) &&
115 !                                       preg_match( $allowed_domain, $email_domain )
116 !                               )
117 !                       )
118 !                       return false;
119 !               }
120 !       } else {
121 !               return false;
122 !       }
123 !       return true;
124   }
125  
126   function wpmu_validate_user_signup($user_name, $user_email) {
127 ***************
128 *** 943,956 ****
129         if ( !validate_email( $user_email ) )
130                 $errors->add('user_email', __("Please check your email address."));
131  
132 -       $limited_email_domains = get_site_option( 'limited_email_domains' );
133 -       if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
134 -               $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
135 -               if( in_array( $emaildomain, $limited_email_domains ) == false ) {
136 -                       $errors->add('user_email', __("Sorry, that email address is not allowed!"));
137 -               }
138 -       }
139 -
140         // Check if the username has been used already.
141         if ( username_exists($user_name) )
142                 $errors->add('user_name', __("Sorry, that username already exists!"));
143 --- 960,965 ----