Cimy User Extra Fields - Version 2.5.1

Version Description

Download this release

Release Info

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

Code changes from version 2.5.0 to 2.5.1

Files changed (109) hide show
  1. README_OFFICIAL.txt +5 -0
  2. cimy_uef_register.php +3 -3
  3. cimy_user_extra_fields.php +5 -4
  4. css/cimy_uef_register.css +5 -1
  5. readme.txt +5 -1
  6. securimage/README.txt +76 -3
  7. securimage/WavFile.php +1864 -0
  8. securimage/audio/0.wav +0 -0
  9. securimage/audio/1.wav +0 -0
  10. securimage/audio/2.wav +0 -0
  11. securimage/audio/3.wav +0 -0
  12. securimage/audio/4.wav +0 -0
  13. securimage/audio/5.wav +0 -0
  14. securimage/audio/6.wav +0 -0
  15. securimage/audio/7.wav +0 -0
  16. securimage/audio/8.wav +0 -0
  17. securimage/audio/9.wav +0 -0
  18. securimage/audio/A.wav +0 -0
  19. securimage/audio/B.wav +0 -0
  20. securimage/audio/C.wav +0 -0
  21. securimage/audio/D.wav +0 -0
  22. securimage/audio/E.wav +0 -0
  23. securimage/audio/F.wav +0 -0
  24. securimage/audio/G.wav +0 -0
  25. securimage/audio/H.wav +0 -0
  26. securimage/audio/I.wav +0 -0
  27. securimage/audio/J.wav +0 -0
  28. securimage/audio/K.wav +0 -0
  29. securimage/audio/L.wav +0 -0
  30. securimage/audio/M.wav +0 -0
  31. securimage/audio/N.wav +0 -0
  32. securimage/audio/O.wav +0 -0
  33. securimage/audio/P.wav +0 -0
  34. securimage/audio/Q.wav +0 -0
  35. securimage/audio/R.wav +0 -0
  36. securimage/audio/S.wav +0 -0
  37. securimage/audio/T.wav +0 -0
  38. securimage/audio/U.wav +0 -0
  39. securimage/audio/V.wav +0 -0
  40. securimage/audio/W.wav +0 -0
  41. securimage/audio/X.wav +0 -0
  42. securimage/audio/Y.wav +0 -0
  43. securimage/audio/Z.wav +0 -0
  44. securimage/audio/en/0.wav +0 -0
  45. securimage/audio/en/1.wav +0 -0
  46. securimage/audio/en/10.wav +0 -0
  47. securimage/audio/en/11.wav +0 -0
  48. securimage/audio/en/12.wav +0 -0
  49. securimage/audio/en/13.wav +0 -0
  50. securimage/audio/en/14.wav +0 -0
  51. securimage/audio/en/15.wav +0 -0
  52. securimage/audio/en/16.wav +0 -0
  53. securimage/audio/en/17.wav +0 -0
  54. securimage/audio/en/18.wav +0 -0
  55. securimage/audio/en/19.wav +0 -0
  56. securimage/audio/en/2.wav +0 -0
  57. securimage/audio/en/20.wav +0 -0
  58. securimage/audio/en/3.wav +0 -0
  59. securimage/audio/en/4.wav +0 -0
  60. securimage/audio/en/5.wav +0 -0
  61. securimage/audio/en/6.wav +0 -0
  62. securimage/audio/en/7.wav +0 -0
  63. securimage/audio/en/8.wav +0 -0
  64. securimage/audio/en/9.wav +0 -0
  65. securimage/audio/en/A.wav +0 -0
  66. securimage/audio/en/B.wav +0 -0
  67. securimage/audio/en/C.wav +0 -0
  68. securimage/audio/en/D.wav +0 -0
  69. securimage/audio/en/E.wav +0 -0
  70. securimage/audio/en/F.wav +0 -0
  71. securimage/audio/en/G.wav +0 -0
  72. securimage/audio/en/H.wav +0 -0
  73. securimage/audio/en/I.wav +0 -0
  74. securimage/audio/en/J.wav +0 -0
  75. securimage/audio/en/K.wav +0 -0
  76. securimage/audio/en/L.wav +0 -0
  77. securimage/audio/en/M.wav +0 -0
  78. securimage/audio/en/MINUS.wav +0 -0
  79. securimage/audio/en/N.wav +0 -0
  80. securimage/audio/en/O.wav +0 -0
  81. securimage/audio/en/P.wav +0 -0
  82. securimage/audio/en/PLUS.wav +0 -0
  83. securimage/audio/en/Q.wav +0 -0
  84. securimage/audio/en/R.wav +0 -0
  85. securimage/audio/en/S.wav +0 -0
  86. securimage/audio/en/T.wav +0 -0
  87. securimage/audio/en/TIMES.wav +0 -0
  88. securimage/audio/en/U.wav +0 -0
  89. securimage/audio/en/V.wav +0 -0
  90. securimage/audio/en/W.wav +0 -0
  91. securimage/audio/en/X.wav +0 -0
  92. securimage/audio/en/Y.wav +0 -0
  93. securimage/audio/en/Z.wav +0 -0
  94. securimage/audio/{error.wav → en/error.wav} +0 -0
  95. securimage/captcha.html +3 -3
  96. securimage/database/securimage.sq3 +0 -0
  97. securimage/database/securimage.sqlite +0 -0
  98. securimage/example_form.ajax.php +17 -16
  99. securimage/example_form.php +17 -16
  100. securimage/images/audio_icon.gif +0 -0
  101. securimage/images/audio_icon.png +0 -0
  102. securimage/images/refresh.gif +0 -0
  103. securimage/images/refresh.png +0 -0
  104. securimage/securimage.php +1188 -416
  105. securimage/securimage_play.php +2 -2
  106. securimage/securimage_play.swf +0 -0
  107. securimage/securimage_show.php +10 -10
  108. securimage/securimage_show_example.php +0 -65
  109. securimage/securimage_show_example2.php +0 -63
README_OFFICIAL.txt CHANGED
@@ -627,6 +627,11 @@ A lot of times I cannot reproduce the problem and I need more details, so if you
627
 
628
 
629
  CHANGELOG:
 
 
 
 
 
630
  v2.5.0 - 18/03/2013
631
  - Added support for hiding the username under standard WP registration, email will substitute it (non-MS only) (thanks to Matt Hoffman)
632
  - Added support for WordPress hidden fields rules under profile update
627
 
628
 
629
  CHANGELOG:
630
+ v2.5.1 - 06/05/2013
631
+ - Updated Securimage Captcha to v3.5.0
632
+ - Fixed captcha check was performed on /wp-admin/user-new.php page even without a captcha showed (MS only) (thanks to KZeni)
633
+ - Fixed strength password hint description is showed inline with the password strength when reCAPTCHA is also showed (thanks to coopersita)
634
+
635
  v2.5.0 - 18/03/2013
636
  - Added support for hiding the username under standard WP registration, email will substitute it (non-MS only) (thanks to Matt Hoffman)
637
  - Added support for WordPress hidden fields rules under profile update
cimy_uef_register.php CHANGED
@@ -296,7 +296,7 @@ function cimy_registration_check_mu_wrapper($data) {
296
  $errors = $data['errors'];
297
 
298
  // no we don't want to check again at this stage
299
- if (($_REQUEST['stage'] == "validate-blog-signup") && !empty($_REQUEST['confirm_form_nonce']) && ($_REQUEST['confirm_form_nonce'] == wp_create_nonce('confirm_form', 'confirm_form_nonce')))
300
  return $data;
301
 
302
  $errors = cimy_registration_check($user_login, $user_email, $errors);
@@ -1218,10 +1218,10 @@ function cimy_registration_form($errors=null, $show_type=0) {
1218
  <img id="captcha" align="left" style="padding-right: 5px; border: 0" src="<?php echo $cuef_securimage_webpath; ?>/securimage_show_captcha.php" alt="CAPTCHA Image" />
1219
  <object type="application/x-shockwave-flash" data="<?php echo $cuef_securimage_webpath; ?>/securimage_play.swf?audio_file=<?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_file=<?php echo $cuef_securimage_webpath; ?>/securimage_play.php&#038;bgColor1=#fff&#038;bgColor2=#fff&#038;iconColor=#777&#038;borderWidth=1&#038;borderColor=#000" /></object>
1220
  <br /><br /><br />
1221
- <a align="right" <?php if (!empty($obj_tabindex)) echo "tabindex=\"".$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>
1222
  </div>
1223
  <div style="width: <?php echo $width; ?>px; float: left; height: 50px; vertical-align: bottom; padding: 5px;">
1224
- <?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++; ?>" />
1225
  </div>
1226
  <?php
1227
  }
296
  $errors = $data['errors'];
297
 
298
  // no we don't want to check again at this stage
299
+ if ((!empty($_REQUEST['stage']) && $_REQUEST['stage'] == "validate-blog-signup") && !empty($_REQUEST['confirm_form_nonce']) && ($_REQUEST['confirm_form_nonce'] == wp_create_nonce('confirm_form', 'confirm_form_nonce')))
300
  return $data;
301
 
302
  $errors = cimy_registration_check($user_login, $user_email, $errors);
1218
  <img id="captcha" align="left" style="padding-right: 5px; border: 0" src="<?php echo $cuef_securimage_webpath; ?>/securimage_show_captcha.php" alt="CAPTCHA Image" />
1219
  <object type="application/x-shockwave-flash" data="<?php echo $cuef_securimage_webpath; ?>/securimage_play.swf?audio_file=<?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_file=<?php echo $cuef_securimage_webpath; ?>/securimage_play.php&#038;bgColor1=#fff&#038;bgColor2=#fff&#038;iconColor=#777&#038;borderWidth=1&#038;borderColor=#000" /></object>
1220
  <br /><br /><br />
1221
+ <a align="right" <?php if (!empty($obj_tabindex)) echo "tabindex=\"".$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.png" alt="<?php _e("Change image", $cimy_uef_domain); ?>" border="0" onclick="this.blur()" align="bottom" height="19" width="19" /></a>
1222
  </div>
1223
  <div style="width: <?php echo $width; ?>px; float: left; height: 50px; vertical-align: bottom; padding: 5px;">
1224
+ <?php _e("Insert the code:", $cimy_uef_domain); ?>&nbsp;<input type="text" name="securimage_response_field" size="12" maxlength="16" tabindex="<?php echo $tabindex; $tabindex++; ?>" />
1225
  </div>
1226
  <?php
1227
  }
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.5.0
7
  Author: Marco Cimmino
8
  Author URI: mailto:cimmino.marco@gmail.com
9
  License: GPL2
@@ -160,7 +160,7 @@ require_once($cuef_plugin_dir.'/cimy_uef_profile.php');
160
  add_action('admin_init', 'cimy_uef_admin_init');
161
 
162
  $cimy_uef_name = "Cimy User Extra Fields";
163
- $cimy_uef_version = "2.5.0";
164
  $cimy_uef_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/";
165
  $cimy_project_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/support-the-cimy-project-paypal/";
166
 
@@ -506,8 +506,9 @@ if (is_multisite()) {
506
  // add extra fields to registration form
507
  add_action('signup_extra_fields', 'cimy_registration_form', 1);
508
 
509
- // add checks for extra fields in the registration form
510
- add_filter('wpmu_validate_user_signup', 'cimy_registration_check_mu_wrapper');
 
511
 
512
  // add custom login/registration css
513
  add_action('signup_header', 'cimy_uef_register_css');
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.5.1
7
  Author: Marco Cimmino
8
  Author URI: mailto:cimmino.marco@gmail.com
9
  License: GPL2
160
  add_action('admin_init', 'cimy_uef_admin_init');
161
 
162
  $cimy_uef_name = "Cimy User Extra Fields";
163
+ $cimy_uef_version = "2.5.1";
164
  $cimy_uef_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/";
165
  $cimy_project_url = "http://www.marcocimmino.net/cimy-wordpress-plugins/support-the-cimy-project-paypal/";
166
 
506
  // add extra fields to registration form
507
  add_action('signup_extra_fields', 'cimy_registration_form', 1);
508
 
509
+ // add checks for extra fields in the registration form only
510
+ if (!is_admin() && !is_network_admin())
511
+ add_filter('wpmu_validate_user_signup', 'cimy_registration_check_mu_wrapper');
512
 
513
  // add custom login/registration css
514
  add_action('signup_header', 'cimy_uef_register_css');
css/cimy_uef_register.css CHANGED
@@ -23,7 +23,7 @@
23
  display: inline;
24
  }
25
 
26
- #pass-strength-result{
27
  padding-top: 3px;
28
  padding-right: 5px;
29
  padding-bottom: 3px;
@@ -41,3 +41,7 @@
41
  display: block;
42
  width: 93%;
43
  }
 
 
 
 
23
  display: inline;
24
  }
25
 
26
+ #pass-strength-result {
27
  padding-top: 3px;
28
  padding-right: 5px;
29
  padding-bottom: 3px;
41
  display: block;
42
  width: 93%;
43
  }
44
+
45
+ .indicator-hint {
46
+ display: table;
47
+ }
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.5
8
- Stable tag: 2.5.0
9
 
10
  Add some useful fields to registration and user's info
11
 
@@ -138,3 +138,7 @@ There are two supported ways of using this plug-in under WordPress MultiSite:
138
  2. User's profile with extra fields
139
  3. Main options page
140
  4. Add a new field form
 
 
 
 
5
  Tags: cimy, admin, registration, profile, extra fields, avatar, gravatar, recaptcha, captcha
6
  Requires at least: 3.1
7
  Tested up to: 3.5
8
+ Stable tag: 2.5.1
9
 
10
  Add some useful fields to registration and user's info
11
 
138
  2. User's profile with extra fields
139
  3. Main options page
140
  4. Add a new field form
141
+
142
+ == Changelog ==
143
+
144
+ http://www.marcocimmino.net/cimy-wordpress-plugins/cimy-user-extra-fields/all-versions-and-changelog/
securimage/README.txt CHANGED
@@ -2,7 +2,7 @@ NAME:
2
 
3
  Securimage - A PHP class for creating captcha images and audio with many options.
4
 
5
- VERSION: 3.0
6
 
7
  AUTHOR:
8
 
@@ -22,6 +22,7 @@ REQUIREMENTS:
22
  PHP 5.2 or greater
23
  GD 2.0
24
  FreeType (Required, for TTF fonts)
 
25
 
26
  SYNOPSIS:
27
 
@@ -52,7 +53,7 @@ DESCRIPTION:
52
 
53
 
54
  COPYRIGHT:
55
- Copyright (c) 2011 Drew Phillips
56
  All rights reserved.
57
 
58
  Redistribution and use in source and binary forms, with or without modification,
@@ -77,7 +78,13 @@ COPYRIGHT:
77
  POSSIBILITY OF SUCH DAMAGE.
78
 
79
  -----------------------------------------------------------------------------
80
- Flash code created for Securimage by Mario Romero (animario@hotmail.com)
 
 
 
 
 
 
81
  Many thanks for releasing this to the project!
82
 
83
  ------------------------------------------------------------------------------
@@ -106,3 +113,69 @@ COPYRIGHT:
106
  www.yannlecoroller.com
107
  yann@lecoroller.com
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  Securimage - A PHP class for creating captcha images and audio with many options.
4
 
5
+ VERSION: 3.5
6
 
7
  AUTHOR:
8
 
22
  PHP 5.2 or greater
23
  GD 2.0
24
  FreeType (Required, for TTF fonts)
25
+ PDO (if using Sqlite, MySQL, or PostgreSQL)
26
 
27
  SYNOPSIS:
28
 
53
 
54
 
55
  COPYRIGHT:
56
+ Copyright (c) 2013 Drew Phillips
57
  All rights reserved.
58
 
59
  Redistribution and use in source and binary forms, with or without modification,
78
  POSSIBILITY OF SUCH DAMAGE.
79
 
80
  -----------------------------------------------------------------------------
81
+ The WavFile.php class used in Securimage by Drew Phillips and Paul Voegler is
82
+ used under the BSD License. See WavFile.php for details.
83
+ Many thanks to Paul Voegler (http://www.voegler.eu/) for contributing to
84
+ Securimage.
85
+
86
+ -----------------------------------------------------------------------------
87
+ Flash code created for Securimage by Age Bosma & Mario Romero (animario@hotmail.com)
88
  Many thanks for releasing this to the project!
89
 
90
  ------------------------------------------------------------------------------
113
  www.yannlecoroller.com
114
  yann@lecoroller.com
115
 
116
+ -------------------------------------------------------------------------------
117
+ Portions of securimage_play.swf use the PopForge flash library for playing audio
118
+
119
+ /**
120
+ * Copyright(C) 2007 Andre Michelle and Joa Ebert
121
+ *
122
+ * PopForge is an ActionScript3 code sandbox developed by Andre Michelle and Joa Ebert
123
+ * http://sandbox.popforge.de
124
+ *
125
+ * PopforgeAS3Audio is free software; you can redistribute it and/or modify
126
+ * it under the terms of the GNU General Public License as published by
127
+ * the Free Software Foundation; either version 3 of the License, or
128
+ * (at your option) any later version.
129
+ *
130
+ * PopforgeAS3Audio is distributed in the hope that it will be useful,
131
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
132
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
133
+ * GNU General Public License for more details.
134
+ *
135
+ * You should have received a copy of the GNU General Public License
136
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
137
+ */
138
+
139
+ -------------------------------------------------------------------------------
140
+ Some graphics used are from the Humility Icon Pack by WorLord
141
+
142
+ License: GNU/GPL (http://findicons.com/pack/1723/humility)
143
+ http://findicons.com/icon/192558/gnome_volume_control
144
+ http://findicons.com/icon/192562/gtk_refresh
145
+
146
+ -------------------------------------------------------------------------------
147
+ Background noise sound files are from SoundJay.com
148
+ http://www.soundjay.com/tos.html
149
+
150
+ All sound effects on this website are created by us and protected under
151
+ the copyright laws, international treaty provisions and other applicable
152
+ laws. By downloading sounds, music or any material from this site implies
153
+ that you have read and accepted these terms and conditions:
154
+
155
+ Sound Effects
156
+ You are allowed to use the sounds free of charge and royalty free in your
157
+ projects (such as films, videos, games, presentations, animations, stage
158
+ plays, radio plays, audio books, apps) be it for commercial or
159
+ non-commercial purposes.
160
+
161
+ But you are NOT allowed to
162
+ - post the sounds (as sound effects or ringtones) on any website for
163
+ others to download, copy or use
164
+ - use them as a raw material to create sound effects or ringtones that
165
+ you will sell, distribute or offer for downloading
166
+ - sell, re-sell, license or re-license the sounds (as individual sound
167
+ effects or as a sound effects library) to anyone else
168
+ - claim the sounds as yours
169
+ - link directly to individual sound files
170
+ - distribute the sounds in apps or computer programs that are clearly
171
+ sound related in nature (such as sound machine, sound effect
172
+ generator, ringtone maker, funny sounds app, sound therapy app, etc.)
173
+ or in apps or computer programs that use the sounds as the program's
174
+ sound resource library for other people's use (such as animation
175
+ creator, digital book creator, song maker software, etc.). If you are
176
+ developing such computer programs, contact us for licensing options.
177
+
178
+ If you use the sound effects, please consider giving us a credit and
179
+ linking back to us but it's not required.
180
+
181
+
securimage/WavFile.php ADDED
@@ -0,0 +1,1864 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // error_reporting(E_ALL); ini_set('display_errors', 1); // uncomment this line for debugging
4
+
5
+ /**
6
+ * Project: PHPWavUtils: Classes for creating, reading, and manipulating WAV files in PHP<br />
7
+ * File: WavFile.php<br />
8
+ *
9
+ * Copyright (c) 2012, Drew Phillips
10
+ * All rights reserved.
11
+ *
12
+ * Redistribution and use in source and binary forms, with or without modification,
13
+ * are permitted provided that the following conditions are met:
14
+ *
15
+ * - Redistributions of source code must retain the above copyright notice,
16
+ * this list of conditions and the following disclaimer.
17
+ * - Redistributions in binary form must reproduce the above copyright notice,
18
+ * this list of conditions and the following disclaimer in the documentation
19
+ * and/or other materials provided with the distribution.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+ * POSSIBILITY OF SUCH DAMAGE.
32
+ *
33
+ * Any modifications to the library should be indicated clearly in the source code
34
+ * to inform users that the changes are not a part of the original software.<br /><br />
35
+ *
36
+ * @copyright 2012 Drew Phillips
37
+ * @author Drew Phillips <drew@drew-phillips.com>
38
+ * @author Paul Voegler <http://www.voegler.eu/>
39
+ * @version 1.0 (October 2012)
40
+ * @package PHPWavUtils
41
+ * @license BSD License
42
+ *
43
+ * Changelog:
44
+ *
45
+ * 1.0 (10/2/2012)
46
+ * - Fix insertSilence() creating invalid block size
47
+ *
48
+ * 1.0 RC1 (4/20/2012)
49
+ * - Initial release candidate
50
+ * - Supports 8, 16, 24, 32 bit PCM, 32-bit IEEE FLOAT, Extensible Format
51
+ * - Support for 18 channels of audio
52
+ * - Ability to read an offset from a file to reduce memory footprint with large files
53
+ * - Single-pass audio filter processing
54
+ * - Highly accurate and efficient mix and normalization filters (http://www.voegler.eu/pub/audio/)
55
+ * - Utility filters for degrading audio, and inserting silence
56
+ *
57
+ * 0.6 (4/12/2012)
58
+ * - Support 8, 16, 24, 32 bit and PCM float (Paul Voegler)
59
+ * - Add normalize filter, misc improvements and fixes (Paul Voegler)
60
+ * - Normalize parameters to filter() to use filter constants as array indices
61
+ * - Add option to mix filter to loop the target file if the source is longer
62
+ *
63
+ * 0.5 (4/3/2012)
64
+ * - Fix binary pack routine (Paul Voegler)
65
+ * - Add improved mixing function (Paul Voegler)
66
+ *
67
+ */
68
+
69
+ class WavFile
70
+ {
71
+ /*%******************************************************************************************%*/
72
+ // Class constants
73
+
74
+ /** @var int Filter flag for mixing two files */
75
+ const FILTER_MIX = 0x01;
76
+
77
+ /** @var int Filter flag for normalizing audio data */
78
+ const FILTER_NORMALIZE = 0x02;
79
+
80
+ /** @var int Filter flag for degrading audio data */
81
+ const FILTER_DEGRADE = 0x04;
82
+
83
+ /** @var int Maximum number of channels */
84
+ const MAX_CHANNEL = 18;
85
+
86
+ /** @var int Maximum sample rate */
87
+ const MAX_SAMPLERATE = 192000;
88
+
89
+ /** Channel Locations for ChannelMask */
90
+ const SPEAKER_DEFAULT = 0x000000;
91
+ const SPEAKER_FRONT_LEFT = 0x000001;
92
+ const SPEAKER_FRONT_RIGHT = 0x000002;
93
+ const SPEAKER_FRONT_CENTER = 0x000004;
94
+ const SPEAKER_LOW_FREQUENCY = 0x000008;
95
+ const SPEAKER_BACK_LEFT = 0x000010;
96
+ const SPEAKER_BACK_RIGHT = 0x000020;
97
+ const SPEAKER_FRONT_LEFT_OF_CENTER = 0x000040;
98
+ const SPEAKER_FRONT_RIGHT_OF_CENTER = 0x000080;
99
+ const SPEAKER_BACK_CENTER = 0x000100;
100
+ const SPEAKER_SIDE_LEFT = 0x000200;
101
+ const SPEAKER_SIDE_RIGHT = 0x000400;
102
+ const SPEAKER_TOP_CENTER = 0x000800;
103
+ const SPEAKER_TOP_FRONT_LEFT = 0x001000;
104
+ const SPEAKER_TOP_FRONT_CENTER = 0x002000;
105
+ const SPEAKER_TOP_FRONT_RIGHT = 0x004000;
106
+ const SPEAKER_TOP_BACK_LEFT = 0x008000;
107
+ const SPEAKER_TOP_BACK_CENTER = 0x010000;
108
+ const SPEAKER_TOP_BACK_RIGHT = 0x020000;
109
+ const SPEAKER_ALL = 0x03FFFF;
110
+
111
+ /** @var int PCM Audio Format */
112
+ const WAVE_FORMAT_PCM = 0x0001;
113
+
114
+ /** @var int IEEE FLOAT Audio Format */
115
+ const WAVE_FORMAT_IEEE_FLOAT = 0x0003;
116
+
117
+ /** @var int EXTENSIBLE Audio Format - actual audio format defined by SubFormat */
118
+ const WAVE_FORMAT_EXTENSIBLE = 0xFFFE;
119
+
120
+ /** @var string PCM Audio Format SubType - LE hex representation of GUID {00000001-0000-0010-8000-00AA00389B71} */
121
+ const WAVE_SUBFORMAT_PCM = "0100000000001000800000aa00389b71";
122
+
123
+ /** @var string IEEE FLOAT Audio Format SubType - LE hex representation of GUID {00000003-0000-0010-8000-00AA00389B71} */
124
+ const WAVE_SUBFORMAT_IEEE_FLOAT = "0300000000001000800000aa00389b71";
125
+
126
+
127
+ /*%******************************************************************************************%*/
128
+ // Properties
129
+
130
+ /** @var array Log base modifier lookup table for a given threshold (in 0.05 steps) used by normalizeSample.
131
+ * Adjusts the slope (1st derivative) of the log function at the threshold to 1 for a smooth transition
132
+ * from linear to logarithmic amplitude output. */
133
+ protected static $LOOKUP_LOGBASE = array(
134
+ 2.513, 2.667, 2.841, 3.038, 3.262,
135
+ 3.520, 3.819, 4.171, 4.589, 5.093,
136
+ 5.711, 6.487, 7.483, 8.806, 10.634,
137
+ 13.302, 17.510, 24.970, 41.155, 96.088
138
+ );
139
+
140
+ /** @var int The actual physical file size */
141
+ protected $_actualSize;
142
+
143
+ /** @var int The size of the file in RIFF header */
144
+ protected $_chunkSize;
145
+
146
+ /** @var int The size of the "fmt " chunk */
147
+ protected $_fmtChunkSize;
148
+
149
+ /** @var int The size of the extended "fmt " data */
150
+ protected $_fmtExtendedSize;
151
+
152
+ /** @var int The size of the "fact" chunk */
153
+ protected $_factChunkSize;
154
+
155
+ /** @var int Size of the data chunk */
156
+ protected $_dataSize;
157
+
158
+ /** @var int Size of the data chunk in the opened wav file */
159
+ protected $_dataSize_fp;
160
+
161
+ /** @var int Does _dataSize really reflect strlen($_samples)? Case when a wav file is read with readData = false */
162
+ protected $_dataSize_valid;
163
+
164
+ /** @var int Starting offset of data chunk */
165
+ protected $_dataOffset;
166
+
167
+ /** @var int The audio format - WavFile::WAVE_FORMAT_* */
168