Cimy User Extra Fields - Version 2.3.1

Version Description

Download this release

Release Info

Developer Cimmo
Plugin Icon wp plugin Cimy User Extra Fields
Version 2.3.1
Comparing to
See all releases

Code changes from version 2.3.0 to 2.3.1

README_OFFICIAL.txt CHANGED
@@ -130,7 +130,7 @@ Every registration will have Extra Fields defined by single blogs, every user wi
130
 
131
 
132
  UPDATE FROM A PREVIOUS VERSION:
133
- - go to Cimy User Extra Fields admin options, press "Fix the problem" button and confirm
134
 
135
 
136
  HOW TO ASSIGN A DEFAULT VALUE TO THE EXTRA FIELDS:
@@ -606,6 +606,10 @@ A lot of times I cannot reproduce the problem and I need more details, so if you
606
 
607
 
608
  CHANGELOG:
 
 
 
 
609
  v2.3.0 - 28/11/2011
610
  - Fixed security issue where reCAPTCHA and Securimage Captcha could be by-passed (thanks to corij)
611
  - Fixed tinyMCE was not working anymore since WP 3.3
130
 
131
 
132
  UPDATE FROM A PREVIOUS VERSION:
133
+ - visit Cimy User Extra Fields admin options, DB upgrade will be performed automatically
134
 
135
 
136
  HOW TO ASSIGN A DEFAULT VALUE TO THE EXTRA FIELDS:
606
 
607
 
608
  CHANGELOG:
609
+ v2.3.1 - 06/12/2011
610
+ - Fixed profiles cannot be updated anymore when captcha is selected (introduced with v2.3.0) (thanks to Miguel Morera and Takanudo)
611
+ - Fixed captcha error messages are not displayed under WordPress MS
612
+
613
  v2.3.0 - 28/11/2011
614
  - Fixed security issue where reCAPTCHA and Securimage Captcha could be by-passed (thanks to corij)
615
  - Fixed tinyMCE was not working anymore since WP 3.3
cimy_uef_db.php CHANGED
@@ -341,6 +341,9 @@ function cimy_manage_db($command) {
341
  'fieldset_title' => '',
342
  'captcha' => 'none',
343
  'welcome_email' => $welcome_email,
 
 
 
344
  'file_fields' => array(
345
  'show_in_reg' => 0,
346
  'show_in_profile' => 0,
341
  'fieldset_title' => '',
342
  'captcha' => 'none',
343
  'welcome_email' => $welcome_email,
344
+ 'confirm_form' => false,
345
+ 'confirm_email' => false,
346
+ 'redirect_to' => '',
347
  'file_fields' => array(
348
  'show_in_reg' => 0,
349
  'show_in_profile' => 0,
cimy_uef_register.php CHANGED
@@ -3,8 +3,10 @@
3
  function cimy_register_user_extra_hidden_fields_stage2() {
4
  global $start_cimy_uef_comment, $end_cimy_uef_comment;
5
 
6
- echo "\n".$start_cimy_uef_comment;
 
7
 
 
8
  foreach ($_POST as $name=>$value) {
9
  if (!(stristr($name, "cimy_uef_")) === FALSE) {
10
  echo "\t\t<input type=\"hidden\" name=\"".$name."\" value=\"".esc_attr($value)."\" />\n";
@@ -12,7 +14,7 @@ function cimy_register_user_extra_hidden_fields_stage2() {
12
  echo "\t\t<input type=\"hidden\" name=\"".$name."\" value=\"".esc_attr($value)."\" />\n";
13
  }
14
  }
15
-
16
  echo $end_cimy_uef_comment;
17
  }
18
 
@@ -278,7 +280,13 @@ function cimy_registration_check_mu_wrapper($data) {
278
  $user_email = $data['user_email'];
279
  $errors = $data['errors'];
280
 
281
- $data['errors'] = cimy_registration_check($user_login, $user_email, $errors);
 
 
 
 
 
 
282
 
283
  return $data;
284
  }
@@ -527,13 +535,11 @@ function cimy_registration_check($user_login, $user_email, $errors) {
527
 
528
  if (in_array($type, $cimy_uef_file_types)) {
529
  if ($file_size > $maxlen) {
530
-
531
  $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have size more than', $cimy_uef_domain).' '.$maxlen.' KB.');
532
  }
533
  }
534
  else {
535
  if (strlen($value) > $maxlen) {
536
-
537
  $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have length more than', $cimy_uef_domain).' '.$maxlen.'.');
538
  }
539
  }
@@ -543,15 +549,22 @@ function cimy_registration_check($user_login, $user_email, $errors) {
543
  $i++;
544
  }
545
 
546
- if ($options['captcha'] == "securimage") {
547
- global $cuef_plugin_dir;
548
- require_once($cuef_plugin_dir.'/securimage/securimage.php');
549
- $securimage = new Securimage();
550
- if ($securimage->check($_POST['securimage_response_field']) == false) {
551
- $errors->add("securimage_code", '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.__('Typed code is not correct.', $cimy_uef_domain));
552
  }
553
  }
554
 
 
 
 
 
 
 
 
 
 
 
555
  if (($options['captcha'] == "recaptcha") && (!empty($options['recaptcha_private_key']))) {
556
  $recaptcha_code_ok = false;
557
 
@@ -571,14 +584,14 @@ function cimy_registration_check($user_login, $user_email, $errors) {
571
  $errors->add("recaptcha_code", '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.__('Typed code is not correct.', $cimy_uef_domain));
572
  }
573
 
574
- if ($options['confirm_form']) {
575
- if ((empty($errors->errors)) && (isset($_POST["register_confirmation"])) && ($_POST["register_confirmation"] == 1)) {
576
- $errors->add('register_confirmation', 'true');
 
 
 
577
  }
578
  }
579
-
580
- cimy_switch_current_blog();
581
-
582
  return $errors;
583
  }
584
 
@@ -1102,14 +1115,21 @@ function cimy_registration_form($errors=null, $show_type=0) {
1102
 
1103
  if (($show_type != 2) && ($options['captcha'] == "securimage")) {
1104
  global $cuef_securimage_webpath;
 
 
 
 
 
 
 
1105
  ?>
1106
- <div style="width: 278px; float: left; height: 80px; vertical-align: text-top;">
1107
  <img id="captcha" align="left" style="padding-right: 5px; border: 0" src="<?php echo $cuef_securimage_webpath; ?>/securimage_show_captcha.php" alt="CAPTCHA Image" />
1108
  <object type="application/x-shockwave-flash" data="<?php echo $cuef_securimage_webpath; ?>/securimage_play.swf?audio=<?php echo $cuef_securimage_webpath; ?>/securimage_play.php&#038;bgColor1=#fff&#038;bgColor2=#fff&#038;iconColor=#777&#038;borderWidth=1&#038;borderColor=#000" height="19" width="19"><param name="movie" value="<?php echo $cuef_securimage_webpath; ?>/securimage_play.swf?audio=<?php echo $cuef_securimage_webpath; ?>/securimage_play.php&#038;bgColor1=#fff&#038;bgColor2=#fff&#038;iconColor=#777&#038;borderWidth=1&#038;borderColor=#000" /></object>
1109
- <br /><br /><br /><br />
1110
  <a align="right" tabindex="<?php echo $tabindex; $tabindex++; ?>" style="border-style: none" href="#" onclick="document.getElementById('captcha').src = '<?php echo $cuef_securimage_webpath; ?>/securimage_show_captcha.php?' + Math.random(); return false"><img src="<?php echo $cuef_securimage_webpath; ?>/images/refresh.gif" alt="<?php _e("Change image", $cimy_uef_domain); ?>" border="0" onclick="this.blur()" align="bottom" /></a>
1111
  </div>
1112
- <div style="width: 278px; float: left; height: 50px; vertical-align: bottom; padding: 5px;">
1113
  <?php _e("Insert the code:", $cimy_uef_domain); ?>&nbsp;<input type="text" name="securimage_response_field" size="10" maxlength="6" tabindex="<?php echo $tabindex; $tabindex++; ?>" />
1114
  </div>
1115
  <?php
@@ -1117,24 +1137,26 @@ function cimy_registration_form($errors=null, $show_type=0) {
1117
 
1118
  if (($show_type != 2) && ($options['captcha'] == "recaptcha") && (!empty($options['recaptcha_public_key'])) && (!empty($options['recaptcha_private_key']))) {
1119
  require_once($cuef_plugin_dir.'/recaptcha/recaptchalib.php');
1120
-
1121
- ?>
1122
- <script type='text/javascript'>
1123
- var RecaptchaOptions = {
1124
- lang: '<?php echo substr(get_locale(), 0, 2); ?>',
1125
- tabindex : <?php echo strval($tabindex); $tabindex++; ?>
1126
- };
1127
- </script>
1128
- <?php
 
 
1129
 
1130
  // no need if Tiny MCE is present already
1131
  if (empty($tiny_mce_objects)) {
1132
- ?>
1133
  <script type='text/javascript'>
1134
  var login_div = document.getElementById("login");
1135
  login_div.style.width = "375px";
1136
  </script>
1137
- <?php
1138
  }
1139
  echo recaptcha_get_html($options['recaptcha_public_key']);
1140
  }
@@ -1145,6 +1167,8 @@ function cimy_registration_form($errors=null, $show_type=0) {
1145
  }
1146
 
1147
  function cimy_confirmation_form() {
 
 
1148
  $confirmation = false;
1149
  $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
1150
  $user_login = '';
@@ -1154,9 +1178,14 @@ function cimy_confirmation_form() {
1154
  $user_login = $_POST['user_login'];
1155
  $user_email = $_POST['user_email'];
1156
 
1157
- // Might be Theme My Login, they have its own register_new_user but they don't have login_header seems so, so let's return for now!
1158
- if (function_exists("register_new_user"))
1159
  $errors = register_new_user($user_login, $user_email);
 
 
 
 
 
1160
  else
1161
  return;
1162
 
@@ -1184,6 +1213,7 @@ function cimy_confirmation_form() {
1184
  <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p>
1185
  <br class="clear" />
1186
  <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
 
1187
  <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Register'); ?>" tabindex="100" /></p>
1188
  </form>
1189
 
3
  function cimy_register_user_extra_hidden_fields_stage2() {
4
  global $start_cimy_uef_comment, $end_cimy_uef_comment;
5
 
6
+ if (empty($_POST))
7
+ return;
8
 
9
+ echo "\n".$start_cimy_uef_comment;
10
  foreach ($_POST as $name=>$value) {
11
  if (!(stristr($name, "cimy_uef_")) === FALSE) {
12
  echo "\t\t<input type=\"hidden\" name=\"".$name."\" value=\"".esc_attr($value)."\" />\n";
14
  echo "\t\t<input type=\"hidden\" name=\"".$name."\" value=\"".esc_attr($value)."\" />\n";
15
  }
16
  }
17
+ wp_nonce_field('confirm_form', 'confirm_form_nonce');
18
  echo $end_cimy_uef_comment;
19
  }
20
 
280
  $user_email = $data['user_email'];
281
  $errors = $data['errors'];
282
 
283
+ // no we don't want to check again at this stage
284
+ if (($_REQUEST['stage'] == "validate-blog-signup") && !empty($_REQUEST['confirm_form_nonce']) && ($_REQUEST['confirm_form_nonce'] == wp_create_nonce('confirm_form', 'confirm_form_nonce')))
285
+ return $data;
286
+
287
+ $errors = cimy_registration_check($user_login, $user_email, $errors);
288
+ $errors = cimy_registration_captcha_check($user_login, $user_email, $errors);
289
+ $data['errors'] = $errors;
290
 
291
  return $data;
292
  }
535
 
536
  if (in_array($type, $cimy_uef_file_types)) {
537
  if ($file_size > $maxlen) {
 
538
  $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have size more than', $cimy_uef_domain).' '.$maxlen.' KB.');
539
  }
540
  }
541
  else {
542
  if (strlen($value) > $maxlen) {
 
543
  $errors->add($unique_id, '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.$label.' '.__('couldn&#8217;t have length more than', $cimy_uef_domain).' '.$maxlen.'.');
544
  }
545
  }
549
  $i++;
550
  }
551
 
552
+ if ($options['confirm_form']) {
553
+ if ((empty($errors->errors)) && (isset($_POST["register_confirmation"])) && ($_POST["register_confirmation"] == 1)) {
554
+ $errors->add('register_confirmation', 'true');
 
 
 
555
  }
556
  }
557
 
558
+ cimy_switch_current_blog();
559
+ return $errors;
560
+ }
561
+
562
+ function cimy_registration_captcha_check($user_login, $user_email, $errors) {
563
+ global $cimy_uef_domain;
564
+ // no we don't want to check again at this stage
565
+ if (!empty($_POST['register_confirmation']) && ($_POST['register_confirmation'] == 2) && (wp_verify_nonce($_REQUEST['confirm_form_nonce'], 'confirm_form')))
566
+ return $errors;
567
+ $options = cimy_get_options();
568
  if (($options['captcha'] == "recaptcha") && (!empty($options['recaptcha_private_key']))) {
569
  $recaptcha_code_ok = false;
570
 
584
  $errors->add("recaptcha_code", '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.__('Typed code is not correct.', $cimy_uef_domain));
585
  }
586
 
587
+ if ($options['captcha'] == "securimage") {
588
+ global $cuef_plugin_dir;
589
+ require_once($cuef_plugin_dir.'/securimage/securimage.php');
590
+ $securimage = new Securimage();
591
+ if ($securimage->check($_POST['securimage_response_field']) == false) {
592
+ $errors->add("securimage_code", '<strong>'.__("ERROR", $cimy_uef_domain).'</strong>: '.__('Typed code is not correct.', $cimy_uef_domain));
593
  }
594
  }
 
 
 
595
  return $errors;
596
  }
597
 
1115
 
1116
  if (($show_type != 2) && ($options['captcha'] == "securimage")) {
1117
  global $cuef_securimage_webpath;
1118
+ if (is_multisite()) {
1119
+ $width = 500;
1120
+ if ($errmsg = $errors->get_error_message("securimage_code"))
1121
+ echo '<p class="error">'.$errmsg.'</p>';
1122
+ }
1123
+ else
1124
+ $width = 278;
1125
  ?>
1126
+ <div style="width: <?php echo $width; ?>px; float: left; height: 80px; vertical-align: text-top;">
1127
  <img id="captcha" align="left" style="padding-right: 5px; border: 0" src="<?php echo $cuef_securimage_webpath; ?>/securimage_show_captcha.php" alt="CAPTCHA Image" />
1128
  <object type="application/x-shockwave-flash" data="<?php echo $cuef_securimage_webpath; ?>/securimage_play.swf?audio=<?php echo $cuef_securimage_webpath; ?>/securimage_play.php&#038;bgColor1=#fff&#038;bgColor2=#fff&#038;iconColor=#777&#038;borderWidth=1&#038;borderColor=#000" height="19" width="19"><param name="movie" value="<?php echo $cuef_securimage_webpath; ?>/securimage_play.swf?audio=<?php echo $cuef_securimage_webpath; ?>/securimage_play.php&#038;bgColor1=#fff&#038;bgColor2=#fff&#038;iconColor=#777&#038;borderWidth=1&#038;borderColor=#000" /></object>
1129
+ <br /><br /><br />
1130
  <a align="right" tabindex="<?php echo $tabindex; $tabindex++; ?>" style="border-style: none" href="#" onclick="document.getElementById('captcha').src = '<?php echo $cuef_securimage_webpath; ?>/securimage_show_captcha.php?' + Math.random(); return false"><img src="<?php echo $cuef_securimage_webpath; ?>/images/refresh.gif" alt="<?php _e("Change image", $cimy_uef_domain); ?>" border="0" onclick="this.blur()" align="bottom" /></a>
1131
  </div>
1132
+ <div style="width: <?php echo $width; ?>px; float: left; height: 50px; vertical-align: bottom; padding: 5px;">
1133
  <?php _e("Insert the code:", $cimy_uef_domain); ?>&nbsp;<input type="text" name="securimage_response_field" size="10" maxlength="6" tabindex="<?php echo $tabindex; $tabindex++; ?>" />
1134
  </div>
1135
  <?php
1137
 
1138
  if (($show_type != 2) && ($options['captcha'] == "recaptcha") && (!empty($options['recaptcha_public_key'])) && (!empty($options['recaptcha_private_key']))) {
1139
  require_once($cuef_plugin_dir.'/recaptcha/recaptchalib.php');
1140
+ if (is_multisite() && $errmsg = $errors->get_error_message("recaptcha_code")) {
1141
+ echo '<p class="error">'.$errmsg.'</p>';
1142
+ }
1143
+ ?>
1144
+ <script type='text/javascript'>
1145
+ var RecaptchaOptions = {
1146
+ lang: '<?php echo substr(get_locale(), 0, 2); ?>',
1147
+ tabindex : <?php echo strval($tabindex); $tabindex++; ?>
1148
+ };
1149
+ </script>
1150
+ <?php
1151
 
1152
  // no need if Tiny MCE is present already
1153
  if (empty($tiny_mce_objects)) {
1154
+ ?>
1155
  <script type='text/javascript'>
1156
  var login_div = document.getElementById("login");
1157
  login_div.style.width = "375px";
1158
  </script>
1159
+ <?php
1160
  }
1161
  echo recaptcha_get_html($options['recaptcha_public_key']);
1162
  }
1167
  }
1168
 
1169
  function cimy_confirmation_form() {
1170
+ if (empty($_POST['register_confirmation']))
1171
+ return;
1172
  $confirmation = false;
1173
  $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
1174
  $user_login = '';
1178
  $user_login = $_POST['user_login'];
1179
  $user_email = $_POST['user_email'];
1180
 
1181
+ if (function_exists("register_new_user")) {
1182
+ // fake registration to check if no errors then we'll proceed to confirmation phase
1183
  $errors = register_new_user($user_login, $user_email);
1184
+ // ok we can remove registration checks
1185
+ remove_action('register_post', 'cimy_registration_check');
1186
+ remove_action('register_post', 'cimy_registration_captcha_check');
1187
+ }
1188
+ // Might be Theme My Login, they have its own register_new_user but they don't have login_header seems so, so let's return for now!
1189
  else
1190
  return;
1191
 
1213
  <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p>
1214
  <br class="clear" />
1215
  <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
1216
+ <?php wp_nonce_field('confirm_form', 'confirm_form_nonce'); ?>
1217
  <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Register'); ?>" tabindex="100" /></p>
1218
  </form>
1219
 
cimy_user_extra_fields.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Cimy User Extra Fields
4
  Plugin URI: http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/
5
  Description: Add some useful fields to registration and user's info
6
- Version: 2.3.0
7
  Author: Marco Cimmino
8
  Author URI: mailto:cimmino.marco@gmail.com
9
  License: GPL2
@@ -175,7 +175,7 @@ require_once($cuef_plugin_dir.'/cimy_uef_options.php');
175
  require_once($cuef_plugin_dir.'/cimy_uef_admin.php');
176
 
177
  $cimy_uef_name = "Cimy User Extra Fields";
178
- $cimy_uef_version = "2.3.0";
179
  $cimy_uef_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/";
180
  $cimy_project_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/support-the-cimy-project-paypal/";
181
 
@@ -519,6 +519,7 @@ else {
519
 
520
  // add checks for extra fields in the registration form
521
  add_action('register_post', 'cimy_registration_check', 10, 3);
 
522
 
523
  // add extra fields to registration form
524
  add_action('register_form', 'cimy_registration_form', 1);
@@ -530,6 +531,7 @@ else {
530
  add_action('login_head', 'cimy_change_login_registration_logo');
531
 
532
  // add confirmation form
 
533
  add_action('login_form_register', 'cimy_confirmation_form');
534
 
535
  // add filter for email activation
3
  Plugin Name: Cimy User Extra Fields
4
  Plugin URI: http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/
5
  Description: Add some useful fields to registration and user's info
6
+ Version: 2.3.1
7
  Author: Marco Cimmino
8
  Author URI: mailto:cimmino.marco@gmail.com
9
  License: GPL2
175
  require_once($cuef_plugin_dir.'/cimy_uef_admin.php');
176
 
177
  $cimy_uef_name = "Cimy User Extra Fields";
178
+ $cimy_uef_version = "2.3.1";
179
  $cimy_uef_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/";
180
  $cimy_project_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/support-the-cimy-project-paypal/";
181
 
519
 
520
  // add checks for extra fields in the registration form
521
  add_action('register_post', 'cimy_registration_check', 10, 3);
522
+ add_action('register_post', 'cimy_registration_captcha_check', 11, 3);
523
 
524
  // add extra fields to registration form
525
  add_action('register_form', 'cimy_registration_form', 1);
531
  add_action('login_head', 'cimy_change_login_registration_logo');
532
 
533
  // add confirmation form
534
+ // WARNING: this trick will trigger the registration twice!
535
  add_action('login_form_register', 'cimy_confirmation_form');
536
 
537
  // add filter for email activation
readme.txt CHANGED
@@ -5,7 +5,7 @@ Website link: http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra
5
  Tags: cimy, admin, registration, profile, extra fields, avatar, gravatar, recaptcha, captcha
6
  Requires at least: 3.1
7
  Tested up to: 3.3
8
- Stable tag: 2.3.0
9
 
10
  Add some useful fields to registration and user's info
11
 
5
  Tags: cimy, admin, registration, profile, extra fields, avatar, gravatar, recaptcha, captcha
6
  Requires at least: 3.1
7
  Tested up to: 3.3
8
+ Stable tag: 2.3.1
9
 
10
  Add some useful fields to registration and user's info
11