Ultimate Member – User Profile & Membership Plugin - Version 1.3.69

Version Description

Download this release

Release Info

Developer champsupertramp
Plugin Icon 128x128 Ultimate Member – User Profile & Membership Plugin
Version 1.3.69
Comparing to
See all releases

Code changes from version 1.3.68 to 1.3.69

addons/generate_random_users.php CHANGED
@@ -55,9 +55,12 @@ class UM_ADDON_generate_random_users {
55
  $response = file_get_contents( $json_url );
56
  $json = json_decode( $response );
57
 
58
- if( ! empty( $json ) && ! get_option('um_generated_dumies') ){
59
 
60
- update_option('um_generated_dumies', $json );
 
 
 
61
 
62
  foreach( $json->results as $dummy ){
63
 
@@ -66,27 +69,46 @@ class UM_ADDON_generate_random_users {
66
  }else{
67
  $password = wp_generate_password( 8, false );
68
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  $userdata = array(
71
  'display_name' => ucfirst( $dummy->name->first )." ".ucfirst( $dummy->name->last ),
72
  'first_name' => ucfirst( $dummy->name->first ),
73
  'last_name' => ucfirst( $dummy->name->last ),
74
- 'user_email' => $dummy->email,
75
  'user_login' => $dummy->login->username,
76
  'user_pass' => $password,
77
  );
78
 
79
  $user_id = wp_insert_user( $userdata );
80
 
 
 
 
 
81
  $usermeta = array(
82
  'synced_profile_photo' => $dummy->picture->large,
83
  'gender' => ucfirst($dummy->gender),
84
- 'birth_date' => date("Y/m/d", $dummy->dob),
85
- '_um_last_login' => date("Y/m/d", $dummy->registered),
86
  'mobile_number' => $dummy->cell,
87
  'phone_number' => $dummy->phone,
88
  'synced_gravatar_hashed_id' => md5( strtolower( trim( $dummy->email ) ) ),
89
  'account_status' => 'approved',
 
 
90
  );
91
 
92
  if( isset( $_GET['add_cover_photo'] ) && $_GET['add_cover_photo'] == 1 ){
@@ -101,23 +123,39 @@ class UM_ADDON_generate_random_users {
101
  foreach ( $usermeta as $key => $value ) {
102
  update_user_meta( $user_id, $key, $value );
103
  }
 
 
104
  }
 
105
  }
106
 
107
  break;
108
 
109
  case 'remove_random_users':
110
 
111
- $json = get_option('um_generated_dumies');
112
-
113
- if( isset( $json->results ) ){
114
- foreach ( $json->results as $dummy ) {
115
- $user = get_user_by( 'email', $dummy->email );
116
- wp_delete_user( $user->ID );
 
 
 
 
 
 
 
 
 
 
117
  }
118
  }
119
-
120
  delete_option('um_generated_dumies');
 
 
 
121
  break;
122
 
123
  default:
@@ -149,9 +187,27 @@ class UM_ADDON_generate_random_users {
149
  } else { ?>
150
 
151
  <p>This tool allows you to add dummies as Ultimate Member users. </p>
152
- <form method="get">
153
- <?php if( ! get_option('um_generated_dumies') ):?>
154
- <label for="total_users">How many dummies? <br/><input type="text" name="total_users" value="30" /> <br/><br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  <label for="gender">Gender:</label> <br/>
156
  <label><input type='radio' name="gender" value="male"/> Male</label> <br/>
157
  <label><input type='radio' name="gender" value="female"/> Female</label> <br/>
@@ -178,23 +234,12 @@ class UM_ADDON_generate_random_users {
178
  <br/><small>if you leave this blank, it will generate random strings password</small>
179
  </label>
180
  <br/>
181
- <?php endif; ?>
182
- <p>
183
- <?php if( ! get_option('um_generated_dumies') ):?>
184
- <input type="submit" class="button button-primary" value="Start Generating Dummies"/>
185
- <input type="hidden" name="um-addon-hook" value="generate_random_users"/>
186
- <?php endif; ?>
187
-
188
- <?php if( get_option('um_generated_dumies') ):?>
189
- <?php $dummies = get_option('um_generated_dumies'); ?>
190
- &nbsp;<input type="submit" class="button button-secondary" value="Remove Generated Dummies (<?php echo $dummies->info->results;?>)"/>
191
- <input type="hidden" name="um-addon-hook" value="remove_random_users"/>
192
- <?php endif; ?>
193
 
194
- <?php } ?>
195
- <input type="hidden" name="page" value="generate_random_users"/>
196
- </form>
197
-
198
  </div><div class="clear"></div>
199
 
200
  <?php
55
  $response = file_get_contents( $json_url );
56
  $json = json_decode( $response );
57
 
58
+ if( ! empty( $json ) ){
59
 
60
+ remove_action('um_after_new_user_register', 'um_after_new_user_register', 10, 2);
61
+
62
+ $failed_dummies = 0;
63
+ $default_role = um_get_option("default_role");
64
 
65
  foreach( $json->results as $dummy ){
66
 
69
  }else{
70
  $password = wp_generate_password( 8, false );
71
  }
72
+
73
+ $site_url = @$_SERVER['SERVER_NAME'];
74
+ $random_generate = wp_generate_password( 4, false );
75
+
76
+ if( username_exists( $dummy->login->username ) ){
77
+ $dummy->login->username = $dummy->login->username.'_'. $random_generate;
78
+ }
79
+
80
+ $dummy->login->email = $dummy->login->username."_dummy@{$site_url}";
81
+
82
+ if( email_exists( $dummy->login->email ) ){
83
+ $dummy->login->email = $dummy->login->username."_dummy_{$random_generate}@{$site_url}";
84
+ }
85
 
86
  $userdata = array(
87
  'display_name' => ucfirst( $dummy->name->first )." ".ucfirst( $dummy->name->last ),
88
  'first_name' => ucfirst( $dummy->name->first ),
89
  'last_name' => ucfirst( $dummy->name->last ),
90
+ 'user_email' => $dummy->login->email,
91
  'user_login' => $dummy->login->username,
92
  'user_pass' => $password,
93
  );
94
 
95
  $user_id = wp_insert_user( $userdata );
96
 
97
+ if( is_wp_error( $user_id ) ){
98
+ $failed_dummies++;
99
+ }
100
+
101
  $usermeta = array(
102
  'synced_profile_photo' => $dummy->picture->large,
103
  'gender' => ucfirst($dummy->gender),
104
+ 'birth_date' => date("Y/m/d", strtotime( $dummy->dob) ),
105
+ '_um_last_login' => date("Y/m/d", strtotime( $dummy->registered ) ),
106
  'mobile_number' => $dummy->cell,
107
  'phone_number' => $dummy->phone,
108
  'synced_gravatar_hashed_id' => md5( strtolower( trim( $dummy->email ) ) ),
109
  'account_status' => 'approved',
110
+ '_um_profile_dummy' => true,
111
+ 'role' => isset( $default_role ) ? $default_role: 'member'
112
  );
113
 
114
  if( isset( $_GET['add_cover_photo'] ) && $_GET['add_cover_photo'] == 1 ){
123
  foreach ( $usermeta as $key => $value ) {
124
  update_user_meta( $user_id, $key, $value );
125
  }
126
+
127
+
128
  }
129
+ wp_redirect( admin_url("admin.php?page=generate_random_users") ); exit;
130
  }
131
 
132
  break;
133
 
134
  case 'remove_random_users':
135
 
136
+ $dummies = new WP_User_Query(
137
+ array(
138
+ 'fields' => array('ID'),
139
+ 'meta_key' => '_um_profile_dummy',
140
+ 'meta_value' => true,
141
+ 'meta_compare' => '='
142
+ )
143
+ );
144
+
145
+ if( $dummies->total_users > 0 ){
146
+ foreach ( $dummies->get_results() as $dummy ) {
147
+
148
+ if( isset( $dummy->ID ) ){
149
+ wp_delete_user( $dummy->ID );
150
+ }
151
+
152
  }
153
  }
154
+
155
  delete_option('um_generated_dumies');
156
+ wp_redirect( admin_url("admin.php?page=generate_random_users") );
157
+ exit;
158
+
159
  break;
160
 
161
  default:
187
  } else { ?>
188
 
189
  <p>This tool allows you to add dummies as Ultimate Member users. </p>
190
+ <?php
191
+ $dummies = new WP_User_Query(
192
+ array(
193
+ 'fields' => array('ID'),
194
+ 'meta_key' => '_um_profile_dummy',
195
+ 'meta_value' => true,
196
+ 'meta_compare' => '='
197
+ )
198
+ );
199
+ ?>
200
+ <?php if( $dummies->total_users > 0 ): ?>
201
+ <form method="get">
202
+ <p>
203
+ &nbsp;<input type="submit" class="button button-secondary" value="Remove Generated Dummies (<?php echo $dummies->total_users;?>)"/>
204
+ <input type="hidden" name="um-addon-hook" value="remove_random_users"/>
205
+ <input type="hidden" name="page" value="generate_random_users"/>
206
+ </form>
207
+ <br/>
208
+ <?php endif; ?>
209
+ <form method="get">
210
+ <label for="total_users">How many dummies? <br/><input type="text" name="total_users" value="30" /> <br/><br/>
211
  <label for="gender">Gender:</label> <br/>
212
  <label><input type='radio' name="gender" value="male"/> Male</label> <br/>
213
  <label><input type='radio' name="gender" value="female"/> Female</label> <br/>
234
  <br/><small>if you leave this blank, it will generate random strings password</small>
235
  </label>
236
  <br/>
237
+ <input type="submit" class="button button-primary" value="Start Generating Dummies"/>
238
+ <input type="hidden" name="um-addon-hook" value="generate_random_users"/>
239
+
240
+ <?php } ?>
241
+ </form>
 
 
 
 
 
 
 
242
 
 
 
 
 
243
  </div><div class="clear"></div>
244
 
245
  <?php
addons/system_info.php ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class UM_ADDON_system_info {
4
+
5
+ function __construct() {
6
+
7
+ add_action('admin_menu', array(&$this, 'admin_menu'), 1001);
8
+
9
+ add_action('admin_init', array(&$this, 'admin_init'), 1);
10
+
11
+ add_action('um_admin_addon_hook', array(&$this, 'um_admin_addon_hook') );
12
+
13
+ }
14
+
15
+
16
+ function admin_menu() {
17
+
18
+ global $ultimatemember;
19
+ $this->addon = $ultimatemember->addons['system_info'];
20
+ add_submenu_page('ultimatemember', "System Info","System Info", 'manage_options', 'um_system_info', array(&$this, 'content') );
21
+
22
+ }
23
+
24
+ function um_admin_addon_hook( $hook ) {
25
+ global $ultimatemember;
26
+
27
+ switch ( $hook ) {
28
+
29
+ case 'download_system_info':
30
+
31
+ nocache_headers();
32
+
33
+ header( "Content-type: text/plain" );
34
+ header( 'Content-Disposition: attachment; filename="ultimatemember-system-info.txt"' );
35
+
36
+ echo wp_strip_all_tags( $_POST['um-sysinfo'] );
37
+ exit;
38
+
39
+ break;
40
+
41
+ default:
42
+
43
+ break;
44
+ }
45
+
46
+ }
47
+
48
+ function admin_init() {
49
+ if ( isset( $_REQUEST['um-addon-hook'] ) ) {
50
+ $hook = $_REQUEST['um-addon-hook'];
51
+ do_action("um_admin_addon_hook", $hook );
52
+ }
53
+ }
54
+
55
+ function content() {
56
+ global $wpdb, $ultimatemember;
57
+
58
+ if( !class_exists( 'Browser' ) )
59
+ require_once um_path . 'core/lib/browser.php';
60
+
61
+ // Detect browser
62
+ $browser = new Browser();
63
+
64
+ // Get theme info
65
+ $theme_data = wp_get_theme();
66
+ $theme = $theme_data->Name . ' ' . $theme_data->Version;
67
+
68
+ // Identify Hosting Provider
69
+ $host = um_get_host();
70
+
71
+ ?>
72
+
73
+ <div class="wrap">
74
+
75
+ <h2>Ultimate Member</h2>
76
+
77
+ <h3><?php echo $this->addon[0]; ?></h3>
78
+
79
+ <?php if ( isset( $this->content ) ) {
80
+ echo $this->content;
81
+ } else { ?>
82
+
83
+ <form action="<?php echo esc_url( admin_url( 'admin.php?page=um_system_info' ) ); ?>" method="post" dir="ltr">
84
+ <textarea style="width:100%; height:400px;" readonly="readonly" onclick="this.focus();this.select()" id="system-info-textarea" name="um-sysinfo" title="<?php _e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'edd' ); ?>">
85
+ ### Begin System Info ###
86
+
87
+ ## Please include this information when posting support requests ##
88
+
89
+ <?php do_action( 'um_system_info_before' ); ?>
90
+
91
+ --- Site Info ---
92
+
93
+ Site URL: <?php echo site_url() . "\n"; ?>
94
+ Home URL: <?php echo home_url() . "\n"; ?>
95
+ Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
96
+
97
+ --- Hosting Provider ---
98
+
99
+ <?php if( $host ) : ?>
100
+ Host: <?php echo $host . "\n"; ?>
101
+ <?php endif; ?>
102
+
103
+ --- User Browser ---
104
+
105
+ <?php echo $browser ; ?>
106
+
107
+ --- WordPress Configurations ---
108
+
109
+ Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
110
+ Language: <?php echo get_locale()."\n"; ?>
111
+ Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
112
+ Active Theme: <?php echo $theme . "\n"; ?>
113
+ <?php $show_on_front = get_option( 'show_on_front' ); ?>
114
+ <?php if( $show_on_front == "posts" ): ?>
115
+ Show On Front: <?php echo get_option( 'show_on_front' ) . "/static\n" ?>
116
+ <?php elseif( $show_on_front == "page" ): ?>
117
+ Page On Front: <?php $id = get_option( 'page_on_front' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
118
+ Page For Posts: <?php $id = get_option( 'page_for_posts' ); echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
119
+ <?php endif; ?>
120
+ ABSPATH: <?php echo ABSPATH."\n"; ?>
121
+ <?php $wp_count_posts = wp_count_posts(); ?>
122
+ All Posts/Pages: <?php echo array_sum((array)$wp_count_posts)."\n";?>
123
+ <?php
124
+ $request['cmd'] = '_notify-validate';
125
+
126
+ $params = array(
127
+ 'sslverify' => false,
128
+ 'timeout' => 60,
129
+ 'user-agent' => 'UltimateMember/' . ultimatemember_version,
130
+ 'body' => $request
131
+ );
132
+
133
+ $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
134
+
135
+ if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
136
+ $WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
137
+ } else {
138
+ $WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
139
+ }
140
+ ?>
141
+ WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
142
+ WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
143
+ WP Table Prefix: <?php echo "Length: ". strlen( $wpdb->prefix ); echo ", Status:"; if ( strlen( $wpdb->prefix )>16 ) {echo " ERROR: Too Long";} else {echo " Acceptable";} echo "\n"; ?>
144
+ Memory Limit: <?php echo ( um_let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
145
+
146
+ --- UM Configurations ---
147
+
148
+ Version: <?php echo ultimatemember_version . "\n"; ?>
149
+ Upgraded From: <?php echo get_option( 'um_version_upgraded_from', 'None' ) . "\n"; ?>
150
+ Current URL Method: <?php echo um_get_option( 'current_url_method' ). "\n"; ?>
151
+ Cache User Profile: <?php if( um_get_option( 'um_profile_object_cache_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
152
+ Generate Slugs on Directories: <?php if( um_get_option( 'um_generate_slug_in_directory' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
153
+ Rewrite Rules: <?php if( um_get_option( 'um_flush_stop' ) == 1 ){ echo "No"; }else{ echo "Yes"; } echo "\n"; ?>
154
+ Force UTF-8 Encoding: <?php if( um_get_option( 'um_force_utf8_strings' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
155
+ Time Check Security: <?php if( um_get_option( 'enable_timebot' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
156
+ JS/CSS Compression: <?php if( um_get_option( 'disable_minify' ) == 0 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
157
+ <?php if( is_multisite() ): ?>
158
+ Network Structure: <?php echo um_get_option( 'network_permalink_structure' ). "\n"; ?>
159
+ <?php endif; ?>
160
+ Nav Menu Settings: <?php if( um_get_option( 'disable_menu' ) == 0 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
161
+ Port Forwarding in URL: <?php if( um_get_option( 'um_port_forwarding_url' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
162
+ Exclude CSS/JS on Home: <?php if( um_get_option( 'js_css_exlcude_home' ) == 1 ){ echo "Yes"; }else{ echo "No"; } echo "\n"; ?>
163
+
164
+ --- UM Pages Configuration ---
165
+
166
+ <?php do_action("um_system_info_before_page_config") ?>
167
+ User: <?php echo get_permalink( um_get_option('core_user') ) . "\n"; ?>
168
+ Account: <?php echo get_permalink( um_get_option('core_account') ) . "\n"; ?>
169
+ Members: <?php echo get_permalink( um_get_option('core_members') ) . "\n"; ?>
170
+ Register: <?php echo get_permalink( um_get_option('core_register') ) . "\n"; ?>
171
+ Login: <?php echo get_permalink( um_get_option('core_login') ) . "\n"; ?>
172
+ Logout: <?php echo get_permalink( um_get_option('core_logout') ) . "\n"; ?>
173
+ Password Reset: <?php echo get_permalink( um_get_option('core_password-reset') ) . "\n"; ?>
174
+ <?php do_action("um_system_info_after_page_config") ?>
175
+
176
+ -- UM Users Configuration ---
177
+
178
+ Default New User Role: <?php echo um_get_option('default_role') . "\n"; ?>
179
+ Profile Permalink Base: <?php echo um_get_option('permalink_base') . "\n"; ?>
180
+ User Display Name: <?php echo um_get_option('display_name') . "\n"; ?>
181
+ Force Name to Uppercase: <?php echo $this->value( um_get_option('force_display_name_capitlized'), 'yesno', true ); ?>
182
+ Redirect author to profile: <?php echo $this->value( um_get_option('author_redirect'), 'yesno', true ); ?>
183
+ Enable Members Directory: <?php echo $this->value( um_get_option('members_page'), 'yesno', true ); ?>
184
+ Use Gravatars: <?php echo $this->value( um_get_option('use_gravatars'), 'yesno', true ); ?>
185
+ <?php if( um_get_option('use_gravatars') ): ?>Gravatar builtin image: <?php echo um_get_option('use_um_gravatar_default_builtin_image') . "\n"; ?>
186
+ UM Avatar as blank Gravatar: <?php echo $this->value( um_get_option('use_um_gravatar_default_image'), 'yesno', true ); ?><?php endif; ?>
187
+ Require a strong password: <?php echo $this->value( um_get_option('reset_require_strongpass'), 'onoff', true ); ?>
188
+ Editable primary email field in profile view: <?php echo $this->value( um_get_option('editable_primary_email_in_profile'), 'onoff', true ); ?>
189
+
190
+ -- UM Access Configuration ---
191
+
192
+ Panic Key: <?php echo um_get_option('panic_key') . "\n"; ?>
193
+ Global Site Access: <?php $arr = array('Site accessible to Everyone','','Site accessible to Logged In Users'); echo $arr[ intval( um_get_option('accessible') ) ] . "\n"; ?>
194
+ <?php if( um_get_option('accessible') == 2 ):?>
195
+ Custom Redirect URL: <?php echo um_get_option('access_redirect')."\n";?>
196
+ Exclude the following URLs:<?php echo "\t\t\t\t".implode("\t\n\t\t\t\t\t\t\t\t\t\t",um_get_option('access_exclude_uris') )."\n";?><?php endif;?>
197
+ Backend Login Screen for Guests: <?php echo $this->value( um_get_option('wpadmin_login'), 'yesno', true ); ?>
198
+ <?php if( ! um_get_option('wpadmin_login') ):?>Redirect to alternative login page: <?php if( um_get_option('wpadmin_login_redirect') == 'um_login_page' ){ echo um_get_core_page('login')."\n"; }else{ echo um_get_option('wpadmin_login_redirect_url')."\n"; }?><?php endif; ?>
199
+ Backend Register Screen for Guests: <?php echo $this->value( um_get_option('wpadmin_register'), 'yesno', true ); ?>
200
+ <?php if( ! um_get_option('wpadmin_register') ):?>Redirect to alternative register page: <?php if( um_get_option('wpadmin_register_redirect') == 'um_register_page' ){ echo um_get_core_page('register')."\n"; }else{ echo um_get_option('wpadmin_register_redirect_url')."\n"; }?><?php endif; ?>
201
+ Access Control widget for Admins only: <?php echo $this->value( um_get_option('access_widget_admin_only'), 'yesno', true ); ?>
202
+ Enable the Reset Password Limit: <?php echo $this->value( um_get_option('enable_reset_password_limit'), 'yesno', true ); ?>
203
+ <?php if( um_get_option('enable_reset_password_limit') ) {
204
+ echo "Reset Password Limit:\t\t\t\t\t\t".um_get_option('reset_password_limit_number')."\n";
205
+ echo "Disable Reset Password Limit for Admins:\t".$this->value( um_get_option('disable_admin_reset_password_limit'), 'yesno', true );
206
+ } ?>
207
+ <?php $wpadmin_allow_ips = um_get_option('wpadmin_allow_ips'); if( ! empty( $wpadmin_allow_ips ) ){ ?>
208
+ Whitelisted Backend IPs: <?php echo count( explode("\n",trim(um_get_option('wpadmin_allow_ips') ) ) )."\n"; ?>
209
+ <?php }?>
210
+ <?php $blocked_ips = um_get_option('blocked_ips'); if( ! empty( $blocked_ips ) ){ ?>
211
+ Blocked IP Addresses: <?php echo count( explode("\n",um_get_option('blocked_ips') ) )."\n"; ?>
212
+ <?php }?>
213
+ <?php $blocked_emails = um_get_option('blocked_emails'); if( ! empty( $blocked_emails ) ){ ?>
214
+ Blocked Email Addresses: <?php echo count( explode("\n",um_get_option('blocked_emails') ) )."\n"; ?>
215
+ <?php }?>
216
+ <?php $blocked_words = um_get_option('blocked_words'); if( ! empty( $blocked_words ) ){ ?>
217
+ Blacklist Words: <?php echo count( explode("\n",um_get_option('blocked_words') ) )."\n"; ?>
218
+ <?php }?>
219
+
220
+
221
+ --- UM Email Configurations --
222
+
223
+ Mail appears from: <?php $mail_from = um_get_option('mail_from'); if( ! empty( $mail_from ) ){echo um_get_option('mail_from');}else{echo "-";}; echo "\n";?>
224
+ Mail appears from address: <?php $mail_from_addr = um_get_option('mail_from_addr'); if( ! empty( $mail_from_addr ) ){echo um_get_option('mail_from_addr');}else{echo "-";}; echo "\n";?>
225
+ Use HTML for E-mails: <?php echo $this->value( um_get_option('email_html'), 'yesno', true ); ?>
226
+ Account Welcome Email: <?php echo $this->value( um_get_option('welcome_email_on'), 'yesno', true ); ?>
227
+ Account Activation Email: <?php echo $this->value( um_get_option('checkmail_email_on'), 'yesno', true ); ?>
228
+ Pending Review Email: <?php echo $this->value( um_get_option('pending_email_on'), 'yesno', true ); ?>
229
+ Account Approved Email: <?php echo $this->value( um_get_option('approved_email_on'), 'yesno', true ); ?>
230
+ Account Rejected Email: <?php echo $this->value( um_get_option('rejected_email_on'), 'yesno', true ); ?>
231
+ Account Deactivated Email: <?php echo $this->value( um_get_option('inactive_email_on'), 'yesno', true ); ?>
232
+ Account Deleted Email: <?php echo $this->value( um_get_option('deletion_email_on'), 'yesno', true ); ?>
233
+ Password Reset Email: <?php echo $this->value( um_get_option('resetpw_email_on'), 'yesno', true ); ?>
234
+ Password Changed Email: <?php echo $this->value( um_get_option('changedpw_email_on'), 'yesno', true ); ?>
235
+
236
+
237
+ --- UM Total Users ---
238
+
239
+ <?php
240
+
241
+ $result = count_users();
242
+ echo 'All Users('.$result['total_users'].")\n";
243
+ foreach($result['avail_roles'] as $role => $count){
244
+ echo $role."(".$count.")\n";
245
+ }
246
+ ?>
247
+
248
+
249
+ --- UM Roles ---
250
+
251
+ <?php
252
+
253
+ foreach( $ultimatemember->query->get_roles() as $role_id => $role ) {
254
+ echo $role." ({$role_id})\n";
255
+ }
256
+
257
+ ?>
258
+
259
+
260
+ --- UM Custom Templates ---
261
+
262
+ <?php
263
+ // Show templates that have been copied to the theme's edd_templates dir
264
+
265
+ $dir = get_stylesheet_directory() . '/ultimate-member/templates/*.php';
266
+ if ( ! empty( $dir ) ){
267
+ $found = glob( $dir );
268
+ if( ! empty( $found ) ){
269
+ foreach ( glob( $dir ) as $file ) {
270
+ echo "File: " . $file . "\n";
271
+ }
272
+ }else {
273
+ echo 'N/A'."\n";
274
+ }
275
+ }
276
+ echo "\n\n";
277
+
278
+ $dir = get_stylesheet_directory() . '/ultimate-member/templates/emails/*.html';
279
+ echo "-- UM Email HTML Templates -- \n\n";
280
+
281
+ if ( ! empty( $dir ) ){
282
+ $found = glob( $dir );
283
+ if( ! empty( $found ) ){
284
+ foreach ( glob( $dir ) as $file ) {
285
+ echo "File: ". $file . "\n";
286
+ }
287
+ }else {
288
+ echo 'N/A'."\n";
289
+ }
290
+ }
291
+
292
+ ?>
293
+
294
+ --- Web Server Configurations ---
295
+
296
+ PHP Version: <?php echo PHP_VERSION . "\n"; ?>
297
+ MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?>
298
+ Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
299
+
300
+ --- PHP Configurations --
301
+
302
+ PHP Safe Mode: <?php echo $this->value( ini_get( 'safe_mode' ), 'yesno', true ); ?>
303
+ PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
304
+ PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
305
+ PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
306
+ PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
307
+ PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
308
+ PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
309
+ PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
310
+ PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes\n" : "No\n"; ?>
311
+
312
+
313
+ --- Web Server Extensions/Modules ---
314
+
315
+ DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
316
+ FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
317
+ cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
318
+ SOAP Client: <?php echo ( class_exists( 'SoapClient' ) ) ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.'; ?><?php echo "\n"; ?>
319
+ SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
320
+
321
+
322
+ --- Session Configurations ---
323
+
324
+ Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
325
+ Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
326
+ Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
327
+ Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
328
+ Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
329
+ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
330
+
331
+
332
+
333
+ --- WordPress Active Plugins ---
334
+
335
+ <?php
336
+ $plugins = get_plugins();
337
+ $active_plugins = get_option( 'active_plugins', array() );
338
+
339
+ foreach ( $plugins as $plugin_path => $plugin ) {
340
+ // If the plugin isn't active, don't show it.
341
+ if ( ! in_array( $plugin_path, $active_plugins ) )
342
+ continue;
343
+
344
+ echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
345
+ }
346
+
347
+ if ( is_multisite() ) :
348
+ ?>
349
+
350
+ --- WordPress Network Active Plugins ---
351
+
352
+ <?php
353
+ $plugins = wp_get_active_network_plugins();
354
+ $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
355
+
356
+ foreach ( $plugins as $plugin_path ) {
357
+ $plugin_base = plugin_basename( $plugin_path );
358
+
359
+ // If the plugin isn't active, don't show it.
360
+ if ( ! array_key_exists( $plugin_base, $active_plugins ) )
361
+ continue;
362
+
363
+ $plugin = get_plugin_data( $plugin_path );
364
+
365
+ echo $plugin['Name'] . ' :' . $plugin['Version'] ."\n";
366
+ }
367
+
368
+ endif;
369
+ ?>
370
+ <?php
371
+ do_action( 'um_system_info_after' );
372
+ ?>
373
+
374
+
375
+
376
+
377
+ ### End System Info ###</textarea>
378
+ <p class="submit">
379
+ <input type="hidden" name="um-addon-hook" value="download_system_info" />
380
+ <?php submit_button( 'Download System Info File', 'primary', 'download_system_info', false ); ?>
381
+ </p>
382
+ </form>
383
+
384
+ <?php } ?>
385
+
386
+ <?php
387
+
388
+ }
389
+
390
+ function value( $raw_value = '', $type = 'yesno', $default = '', $default_negate = '' ){
391
+
392
+ if( $type == 'yesno' ){
393
+ if( $default == $raw_value ){
394
+ $raw_value = "Yes";
395
+ }else{
396
+ $raw_value = "No";
397
+ }
398
+ }else if( $type == 'onoff' ){
399
+ if( $default == $raw_value ){
400
+ $raw_value = "On";
401
+ }else{
402
+ $raw_value = "Off";
403
+ }
404
+ }
405
+
406
+ return $raw_value."\n";
407
+ }
408
+
409
+ }
410
+
411
+ $UM_ADDON_system_info = new UM_ADDON_system_info();
admin/assets/css/um-admin-select2.css CHANGED
@@ -186,4 +186,8 @@ body.um-admin .select2-container--default .select2-results__option[aria-selected
186
 
187
  body.um-admin .select2-container .select2-search--inline {
188
  line-height: 37px !important;
 
 
 
 
189
  }
186
 
187
  body.um-admin .select2-container .select2-search--inline {
188
  line-height: 37px !important;
189
+ }
190
+
191
+ body.um-admin .select2-drop-active {
192
+ z-index: 99999 !important;
193
  }
admin/assets/js/um-admin-users.js CHANGED
@@ -1,3 +1,30 @@
1
  jQuery(document).ready(function() {
2
-
3
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  jQuery(document).ready(function() {
2
+
3
+ function getParameterByName(name, url) {
4
+ if (!url) url = window.location.href;
5
+ name = name.replace(/[\[\]]/g, "\\$&");
6
+ var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
7
+ results = regex.exec(url);
8
+ if (!results) return null;
9
+ if (!results[2]) return '';
10
+ return decodeURIComponent(results[2].replace(/\+/g, " "));
11
+ }
12
+
13
+ jQuery("#_um_synced_role").on("change",function(){
14
+ $sync_button = jQuery("#_um_button_sync_update_button");
15
+ var url = $sync_button.attr("href");
16
+
17
+ if ( ! getParameterByName('wp_role', url) ) {
18
+ console.log("wp_role is not set");
19
+ }
20
+
21
+ var um_role = getParameterByName('um_role', url);
22
+ var wp_role = jQuery(this).val();
23
+ $sync_button.attr("href", window.location.href+'&um_adm_action=mass_role_sync&um_role='+um_role+'&wp_role='+wp_role );
24
+
25
+ });
26
+
27
+
28
+
29
+ });
30
+
admin/core/um-admin-actions.php CHANGED
@@ -163,24 +163,25 @@
163
  add_action('um_admin_do_action__mass_role_sync', 'um_admin_do_action__mass_role_sync');
164
  function um_admin_do_action__mass_role_sync( $action ){
165
  global $ultimatemember;
166
- if ( !is_admin() || !current_user_can( 'edit_user' ) ) die();
167
 
168
- if ( !isset($_REQUEST['post']) || !is_numeric( $_REQUEST['post'] ) ) die();
169
 
170
  $post_id = (int) $_REQUEST['post'];
171
 
172
  $post = get_post( $post_id );
173
  $slug = $post->post_name;
174
-
175
  if ( $slug != $_REQUEST['um_role'] )
176
- die();
177
-
178
- if ( get_post_meta( $post_id, '_um_synced_role', true ) != $_REQUEST['wp_role'] )
179
- die();
180
 
 
 
181
  if ( $slug == 'admin' ) {
182
  $_REQUEST['wp_role'] = 'administrator';
183
  update_post_meta( $post_id, '_um_synced_role', 'administrator' );
 
 
184
  }
185
 
186
  $wp_role = ( $_REQUEST['wp_role'] ) ? $_REQUEST['wp_role'] : 'subscriber';
163
  add_action('um_admin_do_action__mass_role_sync', 'um_admin_do_action__mass_role_sync');
164
  function um_admin_do_action__mass_role_sync( $action ){
165
  global $ultimatemember;
166
+ if ( !is_admin() || !current_user_can( 'edit_user' ) ) wp_die('You don\'t have permissions to access this page.');
167
 
168
+ if ( !isset($_REQUEST['post']) || !is_numeric( $_REQUEST['post'] ) ) wp_die('You\'re not allowed to do this.');
169
 
170
  $post_id = (int) $_REQUEST['post'];
171
 
172
  $post = get_post( $post_id );
173
  $slug = $post->post_name;
174
+
175
  if ( $slug != $_REQUEST['um_role'] )
176
+ wp_die('Invalid community role.');
 
 
 
177
 
178
+ $um_synced_role = get_post_meta( $post_id, '_um_synced_role', true );
179
+
180
  if ( $slug == 'admin' ) {
181
  $_REQUEST['wp_role'] = 'administrator';
182
  update_post_meta( $post_id, '_um_synced_role', 'administrator' );
183
+ }else{
184
+ update_post_meta( $post_id, '_um_synced_role', $_REQUEST['wp_role'] );
185
  }
186
 
187
  $wp_role = ( $_REQUEST['wp_role'] ) ? $_REQUEST['wp_role'] : 'subscriber';
admin/core/um-admin-dashboard.php CHANGED
@@ -41,7 +41,7 @@ class UM_Admin_Dashboard {
41
  // Change the footer text
42
  if ( ! get_option( 'um_admin_footer_text_rated' ) ) {
43
 
44
- $footer_text = sprintf( __( 'If you like Ultimate Member please consider leaving a %s&#9733;&#9733;&#9733;&#9733;&#9733;%s review. It will help us to grow the plugin and make it more popular. Thank you.', 'ultimatemember' ), '<a href="https://wordpress.org/support/view/plugin-reviews/ultimate-member?filter=5#postform" target="_blank" class="um-admin-rating-link" data-rated="' . __( 'Thanks :)', 'ultimatemember' ) . '">', '</a>' );
45
 
46
  $footer_text .= "<script type='text/javascript'>
47
  jQuery('a.um-admin-rating-link').click(function() {
41
  // Change the footer text
42
  if ( ! get_option( 'um_admin_footer_text_rated' ) ) {
43
 
44
+ $footer_text = sprintf( __( 'If you like Ultimate Member please consider leaving a %s&#9733;&#9733;&#9733;&#9733;&#9733;%s review. It will help us to grow the plugin and make it more popular. Thank you.', 'ultimatemember' ), '<a href="https://wordpress.org/support/plugin/ultimate-member/reviews/?filter=5" target="_blank" class="um-admin-rating-link" data-rated="' . __( 'Thanks :)', 'ultimatemember' ) . '">', '</a>' );
45
 
46
  $footer_text .= "<script type='text/javascript'>
47
  jQuery('a.um-admin-rating-link').click(function() {
admin/templates/role/sync.php CHANGED
@@ -25,7 +25,7 @@ $url = add_query_arg('wp_role', $saved_r, $url);
25
  </span>
26
  </p><div class="um-admin-clear"></div>
27
 
28
- <p><a href="<?php echo $url; ?>" class="button"><?php _e('Sync / update all existing users','ultimatemember'); ?></a></p>
29
 
30
  </div>
31
 
25
  </span>
26
  </p><div class="um-admin-clear"></div>
27
 
28
+ <p><a href="<?php echo $url; ?>" id="_um_button_sync_update_button" class="button"><?php _e('Sync / update all existing users','ultimatemember'); ?></a></p>
29
 
30
  </div>
31
 
core/lib/browser.php ADDED
@@ -0,0 +1,1103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ /**
7
+ * Modified to remove var
8
+ * Chris Christoff on 12/26/2012
9
+ * Changes: Changes vars to publics
10
+ *
11
+ * Modified to work for EDD by
12
+ * Chris Christoff on 12/23/2012
13
+ * Changes: Removed the browser string return and added spacing. Also removed return HTML formatting.
14
+ *
15
+ * Modified to add formatted User Agent string for EDD System Info by
16
+ * Chris Christoff on 12/23/2012
17
+ * Changes: Split user string and add formatting so we can print a nicely
18
+ * formatted user agent string on the EDD System Info
19
+ *
20
+ * File: Browser.php
21
+ * Author: Chris Schuld (http://chrisschuld.com/)
22
+ * Last Modified: August 20th, 2010
23
+ *
24
+ * @version 1.9
25
+ * @package PegasusPHP
26
+ *
27
+ * Copyright (C) 2008-2010 Chris Schuld (chris@chrisschuld.com)
28
+ *
29
+ * This program is free software; you can redistribute it and/or
30
+ * modify it under the terms of the GNU General Public License as
31
+ * published by the Free Software Foundation; either version 2 of
32
+ * the License, or (at your option) any later version.
33
+ *
34
+ * This program is distributed in the hope that it will be useful,
35
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
36
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37
+ * GNU General Public License for more details at:
38
+ * http://www.gnu.org/copyleft/gpl.html
39
+ *
40
+ *
41
+ * Typical Usage:
42
+ *
43
+ * $browser = new Browser();
44
+ * if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
45
+ * echo 'You have FireFox version 2 or greater';
46
+ * }
47
+ *
48
+ * User Agents Sampled from: http://www.useragentstring.com/
49
+ *
50
+ * This implementation is based on the original work from Gary White
51
+ * http://apptools.com/phptools/browser/
52
+ *
53
+ * UPDATES:
54
+ *
55
+ * 2010-08-20 (v1.9):
56
+ * + Added MSN Explorer Browser (legacy)
57
+ * + Added Bing/MSN Robot (Thanks Rob MacDonald)
58
+ * + Added the Android Platform (PLATFORM_ANDROID)
59
+ * + Fixed issue with Android 1.6/2.2 (Thanks Tom Hirashima)
60
+ *
61
+ * 2010-04-27 (v1.8):
62
+ * + Added iPad Support
63
+ *
64
+ * 2010-03-07 (v1.7):
65
+ * + *MAJOR* Rebuild (preg_match and other "slow" routine removal(s))
66
+ * + Almost allof Gary's original code has been replaced
67
+ * + Large PHPUNIT testing environment created to validate new releases and additions
68
+ * + Added FreeBSD Platform
69
+ * + Added OpenBSD Platform
70
+ * + Added NetBSD Platform
71
+ * + Added SunOS Platform
72
+ * + Added OpenSolaris Platform
73
+ * + Added support of the Iceweazel Browser
74
+ * + Added isChromeFrame() call to check if chromeframe is in use
75
+ * + Moved the Opera check in front of the Firefox check due to legacy Opera User Agents
76
+ * + Added the __toString() method (Thanks Deano)
77
+ *
78
+ * 2009-11-15:
79
+ * + Updated the checkes for Firefox
80
+ * + Added the NOKIA platform
81
+ * + Added Checks for the NOKIA brower(s)
82
+ *
83
+ * 2009-11-08:
84
+ * + PHP 5.3 Support
85
+ * + Added support for BlackBerry OS and BlackBerry browser
86
+ * + Added support for the Opera Mini browser
87
+ * + Added additional documenation
88
+ * + Added support for isRobot() and isMobile()
89
+ * + Added support for Opera version 10
90
+ * + Added support for deprecated Netscape Navigator version 9
91
+ * + Added support for IceCat
92
+ * + Added support for Shiretoko
93
+ *
94
+ * 2010-04-27 (v1.8):
95
+ * + Added iPad Support
96
+ *
97
+ * 2009-08-18:
98
+ * + Updated to support PHP 5.3 - removed all deprecated function calls
99
+ * + Updated to remove all double quotes (") -- converted to single quotes (')
100
+ *
101
+ * 2009-04-27:
102
+ * + Updated the IE check to remove a typo and bug (thanks John)
103
+ *
104
+ * 2009-04-22:
105
+ * + Added detection for GoogleBot
106
+ * + Added detection for the W3C Validator.
107
+ * + Added detection for Yahoo! Slurp
108
+ *
109
+ * 2009-03-14:
110
+ * + Added detection for iPods.
111
+ * + Added Platform detection for iPhones
112
+ * + Added Platform detection for iPods
113
+ *
114
+ * 2009-02-16: (Rick Hale)
115
+ * + Added version detection for Android phones.
116
+ *
117
+ * 2008-12-09:
118
+ * + Removed unused constant
119
+ *
120
+ * 2008-11-07:
121
+ * + Added Google's Chrome to the detection list
122
+ * + Added isBrowser(string) to the list of functions special thanks to
123
+ * Daniel 'mavrick' Lang for the function concept (http://mavrick.id.au)
124
+ *
125
+ *
126
+ * Gary White noted: "Since browser detection is so unreliable, I am
127
+ * no longer maintaining this script. You are free to use and or
128
+ * modify/update it as you want, however the author assumes no
129
+ * responsibility for the accuracy of the detected values."
130
+ *
131
+ * Anyone experienced with Gary's script might be interested in these notes:
132
+ *
133
+ * Added class constants
134
+ * Added detection and version detection for Google's Chrome
135
+ * Updated the version detection for Amaya
136
+ * Updated the version detection for Firefox
137
+ * Updated the version detection for Lynx
138
+ * Updated the version detection for WebTV
139
+ * Updated the version detection for NetPositive
140
+ * Updated the version detection for IE
141
+ * Updated the version detection for OmniWeb
142
+ * Updated the version detection for iCab
143
+ * Updated the version detection for Safari
144
+ * Updated Safari to remove mobile devices (iPhone)
145
+ * Added detection for iPhone
146
+ * Added detection for robots
147
+ * Added detection for mobile devices
148
+ * Added detection for BlackBerry
149
+ * Removed Netscape checks (matches heavily with firefox & mozilla)
150
+ *
151
+ */
152
+
153
+ class Browser {
154
+ public $_agent = '';
155
+ public $_browser_name = '';
156
+ public $_version = '';
157
+ public $_platform = '';
158
+ public $_os = '';
159
+ public $_is_aol = false;
160
+ public $_is_mobile = false;
161
+ public $_is_robot = false;
162
+ public $_aol_version = '';
163
+
164
+ public $BROWSER_UNKNOWN = 'unknown';
165
+ public $VERSION_UNKNOWN = 'unknown';
166
+
167
+ public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/
168
+ public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/
169
+ public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/
170
+ public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/
171
+ public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile
172
+ public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/
173
+ public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/
174
+ public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/
175
+ public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/
176
+ public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html
177
+ public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/
178
+ public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko
179
+ public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/
180
+ public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/
181
+ public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx
182
+ public $BROWSER_SAFARI = 'Safari'; // Http://apple.com
183
+ public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com
184
+ public $BROWSER_IPOD = 'iPod'; // Http://apple.com
185
+ public $BROWSER_IPAD = 'iPad'; // Http://apple.com
186
+ public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome
187
+ public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/
188
+ public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot
189
+ public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp
190
+ public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/
191
+ public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/
192
+ public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat
193
+ public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60
194
+ public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform
195
+ public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/
196
+ public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm
197
+ // Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well)
198
+
199
+ public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED)
200
+ public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED)
201
+ public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED)
202
+ public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED)
203
+
204
+ public $PLATFORM_UNKNOWN = 'unknown';
205
+ public $PLATFORM_WINDOWS = 'Windows';
206
+ public $PLATFORM_WINDOWS_CE = 'Windows CE';
207
+ public $PLATFORM_APPLE = 'Apple';
208
+ public $PLATFORM_LINUX = 'Linux';
209
+ public $PLATFORM_OS2 = 'OS/2';
210
+ public $PLATFORM_BEOS = 'BeOS';
211
+ public $PLATFORM_IPHONE = 'iPhone';
212
+ public $PLATFORM_IPOD = 'iPod';
213
+ public $PLATFORM_IPAD = 'iPad';
214
+ public $PLATFORM_BLACKBERRY = 'BlackBerry';
215
+ public $PLATFORM_NOKIA = 'Nokia';
216
+ public $PLATFORM_FREEBSD = 'FreeBSD';
217
+ public $PLATFORM_OPENBSD = 'OpenBSD';
218
+ public $PLATFORM_NETBSD = 'NetBSD';
219
+ public $PLATFORM_SUNOS = 'SunOS';
220
+ public $PLATFORM_OPENSOLARIS = 'OpenSolaris';
221
+ public $PLATFORM_ANDROID = 'Android';
222
+
223
+ public $OPERATING_SYSTEM_UNKNOWN = 'unknown';
224
+
225
+ function __construct( $useragent="" ) {
226
+ $this->reset();
227
+ if ( $useragent != "" ) {
228
+ $this->setUserAgent( $useragent );
229
+ } else {
230
+ $this->determine();
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Reset all properties
236
+ */
237
+ function reset() {
238
+ $this->_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : "";
239
+ $this->_browser_name = $this->BROWSER_UNKNOWN;
240
+ $this->_version = $this->VERSION_UNKNOWN;
241
+ $this->_platform = $this->PLATFORM_UNKNOWN;
242
+ $this->_os = $this->OPERATING_SYSTEM_UNKNOWN;
243
+ $this->_is_aol = false;
244
+ $this->_is_mobile = false;
245
+ $this->_is_robot = false;
246
+ $this->_aol_version = $this->VERSION_UNKNOWN;
247
+ }
248
+
249
+ /**
250
+ * Check to see if the specific browser is valid
251
+ *
252
+ * @param string $browserName
253
+ * @return True if the browser is the specified browser
254
+ */
255
+ function isBrowser( $browserName ) { return 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ); }
256
+
257
+ /**
258
+ * The name of the browser. All return types are from the class contants
259
+ *
260
+ * @return string Name of the browser
261
+ */
262
+ function getBrowser() { return $this->_browser_name; }
263
+ /**
264
+ * Set the name of the browser
265
+ *
266
+ * @param unknown $browser The name of the Browser
267
+ */
268
+ function setBrowser( $browser ) { return $this->_browser_name = $browser; }
269
+ /**
270
+ * The name of the platform. All return types are from the class contants
271
+ *
272
+ * @return string Name of the browser
273
+ */
274
+ function getPlatform() { return $this->_platform; }
275
+ /**
276
+ * Set the name of the platform
277
+ *
278
+ * @param unknown $platform The name of the Platform
279
+ */
280
+ function setPlatform( $platform ) { return $this->_platform = $platform; }
281
+ /**
282
+ * The version of the browser.
283
+ *
284
+ * @return string Version of the browser (will only contain alpha-numeric characters and a period)
285
+ */
286
+ function getVersion() { return $this->_version; }
287
+ /**
288
+ * Set the version of the browser
289
+ *
290
+ * @param unknown $version The version of the Browser
291
+ */
292
+ function setVersion( $version ) { $this->_version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version ); }
293
+ /**
294
+ * The version of AOL.
295
+ *
296
+ * @return string Version of AOL (will only contain alpha-numeric characters and a period)
297
+ */
298
+ function getAolVersion() { return $this->_aol_version; }
299
+ /**
300
+ * Set the version of AOL
301
+ *
302
+ * @param unknown $version The version of AOL
303
+ */
304
+ function setAolVersion( $version ) { $this->_aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version ); }
305
+ /**
306
+ * Is the browser from AOL?
307
+ *
308
+ * @return boolean True if the browser is from AOL otherwise false
309
+ */
310
+ function isAol() { return $this->_is_aol; }
311
+ /**
312
+ * Is the browser from a mobile device?
313
+ *
314
+ * @return boolean True if the browser is from a mobile device otherwise false
315
+ */
316
+ function isMobile() { return $this->_is_mobile; }
317
+ /**
318
+ * Is the browser from a robot (ex Slurp,GoogleBot)?
319
+ *
320
+ * @return boolean True if the browser is from a robot otherwise false
321
+ */
322
+ function isRobot() { return $this->_is_robot; }
323
+ /**
324
+ * Set the browser to be from AOL
325
+ *
326
+ * @param unknown $isAol
327
+ */
328
+ function setAol( $isAol ) { $this->_is_aol = $isAol; }
329
+ /**
330
+ * Set the Browser to be mobile
331
+ *
332
+ * @param boolean $value is the browser a mobile brower or not
333
+ */
334
+ function setMobile( $value=true ) { $this->_is_mobile = $value; }
335
+ /**
336
+ * Set the Browser to be a robot
337
+ *
338
+ * @param boolean $value is the browser a robot or not
339
+ */
340
+ function setRobot( $value=true ) { $this->_is_robot = $value; }
341
+ /**
342
+ * Get the user agent value in use to determine the browser
343
+ *
344
+ * @return string The user agent from the HTTP header
345
+ */
346
+ function getUserAgent() { return $this->_agent; }
347
+ /**
348
+ * Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
349
+ *
350
+ * @param unknown $agent_string The value for the User Agent
351
+ */
352
+ function setUserAgent( $agent_string ) {
353
+ $this->reset();
354
+ $this->_agent = $agent_string;
355
+ $this->determine();
356
+ }
357
+ /**
358
+ * Used to determine if the browser is actually "chromeframe"
359
+ *
360
+ * @since 1.7
361
+ * @return boolean True if the browser is using chromeframe
362
+ */
363
+ function isChromeFrame() {
364
+ return strpos( $this->_agent, "chromeframe" ) !== false;
365
+ }
366
+ /**
367
+ * Returns a formatted string with a summary of the details of the browser.
368
+ *
369
+ * @return string formatted string with a summary of the browser
370
+ */
371
+ function __toString() {
372
+ $text1 = $this->getUserAgent(); //grabs the UA (user agent) string
373
+ $UAline1 = substr( $text1, 0, 32 ); //the first line we print should only be the first 32 characters of the UA string
374
+ $text2 = $this->getUserAgent();//now we grab it again and save it to a string
375
+ $towrapUA = str_replace( $UAline1, '', $text2 );//the rest of the printoff (other than first line) is equivolent
376
+ // To the whole string minus the part we printed off. IE
377
+ // User Agent: thefirst32charactersfromUAline1
378
+ // the rest of it is now stored in
379
+ // $text2 to be printed off
380
+ // But we need to add spaces before each line that is split other than line 1
381
+ $space = '';
382
+ for ( $i = 0; $i < 25; $i++ ) {
383
+ $space .= ' ';
384
+ }
385
+ // Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting
386
+ $wordwrapped = chunk_split( $towrapUA, 32, "\n $space" );
387
+ return "Platform: {$this->getPlatform()} \n".
388
+ "Browser Name: {$this->getBrowser()} \n" .
389
+ "Browser Version: {$this->getVersion()} \n" .
390
+ "User Agent String: $UAline1 \n\t\t\t " .
391
+ "$wordwrapped";
392
+ }
393
+ /**
394
+ * Protected routine to calculate and determine what the browser is in use (including platform)
395
+ */
396
+ function determine() {
397
+ $this->checkPlatform();
398
+ $this->checkBrowsers();
399
+ $this->checkForAol();
400
+ }
401
+ /**
402
+ * Protected routine to determine the browser type
403
+ *
404
+ * @return boolean True if the browser was detected otherwise false
405
+ */
406
+ function checkBrowsers() {
407
+ return (
408
+ // Well-known, well-used
409
+ // Special Notes:
410
+ // (1) Opera must be checked before FireFox due to the odd
411
+ // user agents used in some older versions of Opera
412
+ // (2) WebTV is strapped onto Internet Explorer so we must
413
+ // check for WebTV before IE
414
+ // (3) (deprecated) Galeon is based on Firefox and needs to be
415
+ // tested before Firefox is tested
416
+ // (4) OmniWeb is based on Safari so OmniWeb check must occur
417
+ // before Safari
418
+ // (5) Netscape 9+ is based on Firefox so Netscape checks
419
+ // before FireFox are necessary
420
+ $this->checkBrowserWebTv() ||
421
+ $this->checkBrowserInternetExplorer() ||
422
+ $this->checkBrowserOpera() ||
423
+ $this->checkBrowserGaleon() ||
424
+ $this->checkBrowserNetscapeNavigator9Plus() ||
425
+ $this->checkBrowserFirefox() ||
426
+ $this->checkBrowserChrome() ||
427
+ $this->checkBrowserOmniWeb() ||
428
+
429
+ // Common mobile
430
+ $this->checkBrowserAndroid() ||
431
+ $this->checkBrowseriPad() ||
432
+ $this->checkBrowseriPod() ||
433
+ $this->checkBrowseriPhone() ||
434
+ $this->checkBrowserBlackBerry() ||
435
+ $this->checkBrowserNokia() ||
436
+
437
+ // Common bots
438
+ $this->checkBrowserGoogleBot() ||
439
+ $this->checkBrowserMSNBot() ||
440
+ $this->checkBrowserSlurp() ||
441
+
442
+ // WebKit base check (post mobile and others)
443
+ $this->checkBrowserSafari() ||
444
+
445
+ // Everyone else
446
+ $this->checkBrowserNetPositive() ||
447
+ $this->checkBrowserFirebird() ||
448
+ $this->checkBrowserKonqueror() ||
449
+ $this->checkBrowserIcab() ||
450
+ $this->checkBrowserPhoenix() ||
451
+ $this->checkBrowserAmaya() ||
452
+ $this->checkBrowserLynx() ||
453
+
454
+ $this->checkBrowserShiretoko() ||
455
+ $this->checkBrowserIceCat() ||
456
+ $this->checkBrowserW3CValidator() ||
457
+ $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */
458
+ );
459
+ }
460
+
461
+ /**
462
+ * Determine if the user is using a BlackBerry (last updated 1.7)
463
+ *
464
+ * @return boolean True if the browser is the BlackBerry browser otherwise false
465
+ */
466
+ function checkBrowserBlackBerry() {
467
+ if ( stripos( $this->_agent, 'blackberry' ) !== false ) {
468
+ $aresult = explode( "/", stristr( $this->_agent, "BlackBerry" ) );
469
+ $aversion = explode( ' ', $aresult[1] );
470
+ $this->setVersion( $aversion[0] );
471
+ $this->_browser_name = $this->BROWSER_BLACKBERRY;
472
+ $this->setMobile( true );
473
+ return true;
474
+ }
475
+ return false;
476
+ }
477
+
478
+ /**
479
+ * Determine if the user is using an AOL User Agent (last updated 1.7)
480
+ *
481
+ * @return boolean True if the browser is from AOL otherwise false
482
+ */
483
+ function checkForAol() {
484
+ $this->setAol( false );
485
+ $this->setAolVersion( $this->VERSION_UNKNOWN );
486
+
487
+ if ( stripos( $this->_agent, 'aol' ) !== false ) {
488
+ $aversion = explode( ' ', stristr( $this->_agent, 'AOL' ) );
489
+ $this->setAol( true );
490
+ $this->setAolVersion( preg_replace( '/[^0-9\.a-z]/i', '', $aversion[1] ) );
491
+ return true;
492
+ }
493
+ return false;
494
+ }
495
+
496
+ /**
497
+ * Determine if the browser is the GoogleBot or not (last updated 1.7)
498
+ *
499
+ * @return boolean True if the browser is the GoogletBot otherwise false
500
+ */
501
+ function checkBrowserGoogleBot() {
502
+ if ( stripos( $this->_agent, 'googlebot' ) !== false ) {
503
+ $aresult = explode( '/', stristr( $this->_agent, 'googlebot' ) );
504
+ $aversion = explode( ' ', $aresult[1] );
505
+ $this->setVersion( str_replace( ';', '', $aversion[0] ) );
506
+ $this->_browser_name = $this->BROWSER_GOOGLEBOT;
507
+ $this->setRobot( true );
508
+ return true;
509
+ }
510
+ return false;
511
+ }
512
+
513
+ /**
514
+ * Determine if the browser is the MSNBot or not (last updated 1.9)
515
+ *
516
+ * @return boolean True if the browser is the MSNBot otherwise false
517
+ */
518
+ function checkBrowserMSNBot() {
519
+ if ( stripos( $this->_agent, "msnbot" ) !== false ) {
520
+ $aresult = explode( "/", stristr( $this->_agent, "msnbot" ) );
521
+ $aversion = explode( " ", $aresult[1] );
522
+ $this->setVersion( str_replace( ";", "", $aversion[0] ) );
523
+ $this->_browser_name = $this->BROWSER_MSNBOT;
524
+ $this->setRobot( true );
525
+ return true;
526
+ }
527
+ return false;
528
+ }
529
+
530
+ /**
531
+ * Determine if the browser is the W3C Validator or not (last updated 1.7)
532
+ *
533
+ * @return boolean True if the browser is the W3C Validator otherwise false
534
+ */
535
+ function checkBrowserW3CValidator() {
536
+ if ( stripos( $this->_agent, 'W3C-checklink' ) !== false ) {
537
+ $aresult = explode( '/', stristr( $this->_agent, 'W3C-checklink' ) );
538
+ $aversion = explode( ' ', $aresult[1] );
539
+ $this->setVersion( $aversion[0] );
540
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
541
+ return true;
542
+ } else if ( stripos( $this->_agent, 'W3C_Validator' ) !== false ) {
543
+ // Some of the Validator versions do not delineate w/ a slash - add it back in
544
+ $ua = str_replace( "W3C_Validator ", "W3C_Validator/", $this->_agent );
545
+ $aresult = explode( '/', stristr( $ua, 'W3C_Validator' ) );
546
+ $aversion = explode( ' ', $aresult[1] );
547
+ $this->setVersion( $aversion[0] );
548
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
549
+ return true;
550
+ }
551
+ return false;
552
+ }
553
+
554
+ /**
555
+ * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7)
556
+ *
557
+ * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false
558
+ */
559
+ function checkBrowserSlurp() {
560
+ if ( stripos( $this->_agent, 'slurp' ) !== false ) {
561
+ $aresult = explode( '/', stristr( $this->_agent, 'Slurp' ) );
562
+ $aversion = explode( ' ', $aresult[1] );
563
+ $this->setVersion( $aversion[0] );
564
+ $this->_browser_name = $this->BROWSER_SLURP;
565
+ $this->setRobot( true );
566
+ $this->setMobile( false );
567
+ return true;
568
+ }
569
+ return false;
570
+ }
571
+
572
+ /**
573
+ * Determine if the browser is Internet Explorer or not (last updated 1.7)
574
+ *
575
+ * @return boolean True if the browser is Internet Explorer otherwise false
576
+ */
577
+ function checkBrowserInternetExplorer() {
578
+
579
+ // Test for v1 - v1.5 IE
580
+ if ( stripos( $this->_agent, 'microsoft internet explorer' ) !== false ) {
581
+ $this->setBrowser( $this->BROWSER_IE );
582
+ $this->setVersion( '1.0' );
583
+ $aresult = stristr( $this->_agent, '/' );
584
+ if ( preg_match( '/308|425|426|474|0b1/i', $aresult ) ) {
585
+ $this->setVersion( '1.5' );
586
+ }
587
+ return true;
588
+ }
589
+ // Test for versions > 1.5
590
+ else if ( stripos( $this->_agent, 'msie' ) !== false && stripos( $this->_agent, 'opera' ) === false ) {
591
+ // See if the browser is the odd MSN Explorer
592
+ if ( stripos( $this->_agent, 'msnb' ) !== false ) {
593
+ $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'MSN' ) );
594
+ $this->setBrowser( $this->BROWSER_MSN );
595
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
596
+ return true;
597
+ }
598
+ $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'msie' ) );
599
+ $this->setBrowser( $this->BROWSER_IE );
600
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
601
+ return true;
602
+ }
603
+ // Test for Pocket IE
604
+ else if ( stripos( $this->_agent, 'mspie' ) !== false || stripos( $this->_agent, 'pocket' ) !== false ) {
605
+ $aresult = explode( ' ', stristr( $this->_agent, 'mspie' ) );
606
+ $this->setPlatform( $this->PLATFORM_WINDOWS_CE );
607
+ $this->setBrowser( $this->BROWSER_POCKET_IE );
608
+ $this->setMobile( true );
609
+
610
+ if ( stripos( $this->_agent, 'mspie' ) !== false ) {
611
+ $this->setVersion( $aresult[1] );
612
+ } else {
613
+ $aversion = explode( '/', $this->_agent );
614
+ $this->setVersion( $aversion[1] );
615
+ }
616
+ return true;
617
+ }
618
+ return false;
619
+ }
620
+
621
+ /**
622
+ * Determine if the browser is Opera or not (last updated 1.7)
623
+ *
624
+ * @return boolean True if the browser is Opera otherwise false
625
+ */
626
+ function checkBrowserOpera() {
627
+ if ( stripos( $this->_agent, 'opera mini' ) !== false ) {
628
+ $resultant = stristr( $this->_agent, 'opera mini' );
629
+ if ( preg_match( '/\//', $resultant ) ) {
630
+ $aresult = explode( '/', $resultant );
631
+ $aversion = explode( ' ', $aresult[1] );
632
+ $this->setVersion( $aversion[0] );
633
+ } else {
634
+ $aversion = explode( ' ', stristr( $resultant, 'opera mini' ) );
635
+ $this->setVersion( $aversion[1] );
636
+ }
637
+ $this->_browser_name = $this->BROWSER_OPERA_MINI;
638
+ $this->setMobile( true );
639
+ return true;
640
+ } else if ( stripos( $this->_agent, 'opera' ) !== false ) {
641
+ $resultant = stristr( $this->_agent, 'opera' );
642
+ if ( preg_match( '/Version\/(10.*)$/', $resultant, $matches ) ) {
643
+ $this->setVersion( $matches[1] );
644
+ } else if ( preg_match( '/\//', $resultant ) ) {
645
+ $aresult = explode( '/', str_replace( "(", " ", $resultant ) );
646
+ $aversion = explode( ' ', $aresult[1] );
647
+ $this->setVersion( $aversion[0] );
648
+ } else {
649
+ $aversion = explode( ' ', stristr( $resultant, 'opera' ) );
650
+ $this->setVersion( isset( $aversion[1] )?$aversion[1]:"" );
651
+ }
652
+ $this->_browser_name = $this->BROWSER_OPERA;
653
+ return true;
654
+ }
655
+ return false;
656
+ }
657
+
658
+ /**
659
+ * Determine if the browser is Chrome or not (last updated 1.7)
660
+ *
661
+ * @return boolean True if the browser is Chrome otherwise false
662
+ */
663
+ function checkBrowserChrome() {
664
+ if ( stripos( $this->_agent, 'Chrome' ) !== false ) {
665
+ $aresult = explode( '/', stristr( $this->_agent, 'Chrome' ) );
666
+ $aversion = explode( ' ', $aresult[1] );
667
+ $this->setVersion( $aversion[0] );
668
+ $this->setBrowser( $this->BROWSER_CHROME );
669
+ return true;
670
+ }
671
+ return false;
672
+ }
673
+
674
+
675
+ /**
676
+ * Determine if the browser is WebTv or not (last updated 1.7)
677
+ *
678
+ * @return boolean True if the browser is WebTv otherwise false
679
+ */
680
+ function checkBrowserWebTv() {
681
+ if ( stripos( $this->_agent, 'webtv' ) !== false ) {
682
+ $aresult = explode( '/', stristr( $this->_agent, 'webtv' ) );
683
+ $aversion = explode( ' ', $aresult[1] );
684
+ $this->setVersion( $aversion[0] );
685
+ $this->setBrowser( $this->BROWSER_WEBTV );
686
+ return true;
687
+ }
688
+ return false;
689
+ }
690
+
691
+ /**
692
+ * Determine if the browser is NetPositive or not (last updated 1.7)
693
+ *
694
+ * @return boolean True if the browser is NetPositive otherwise false
695
+ */
696
+ function checkBrowserNetPositive() {
697
+ if ( stripos( $this->_agent, 'NetPositive' ) !== false ) {
698
+ $aresult = explode( '/', stristr( $this->_agent, 'NetPositive' ) );
699
+ $aversion = explode( ' ', $aresult[1] );
700
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aversion[0] ) );
701
+ $this->setBrowser( $this->BROWSER_NETPOSITIVE );
702
+ return true;
703
+ }
704
+ return false;
705
+ }
706
+
707
+ /**
708
+ * Determine if the browser is Galeon or not (last updated 1.7)
709
+ *
710
+ * @return boolean True if the browser is Galeon otherwise false
711
+ */
712
+ function checkBrowserGaleon() {
713
+ if ( stripos( $this->_agent, 'galeon' ) !== false ) {
714
+ $aresult = explode( ' ', stristr( $this->_agent, 'galeon' ) );
715
+ $aversion = explode( '/', $aresult[0] );
716
+ $this->setVersion( $aversion[1] );
717
+ $this->setBrowser( $this->BROWSER_GALEON );
718
+ return true;
719
+ }
720
+ return false;
721
+ }
722
+
723
+ /**
724
+ * Determine if the browser is Konqueror or not (last updated 1.7)
725
+ *
726
+ * @return boolean True if the browser is Konqueror otherwise false
727
+ */
728
+ function checkBrowserKonqueror() {
729
+ if ( stripos( $this->_agent, 'Konqueror' ) !== false ) {
730
+ $aresult = explode( ' ', stristr( $this->_agent, 'Konqueror' ) );
731
+ $aversion = explode( '/', $aresult[0] );
732
+ $this->setVersion( $aversion[1] );
733
+ $this->setBrowser( $this->BROWSER_KONQUEROR );
734
+ return true;
735
+ }
736
+ return false;
737
+ }
738
+
739
+ /**
740
+ * Determine if the browser is iCab or not (last updated 1.7)
741
+ *
742
+ * @return boolean True if the browser is iCab otherwise false
743
+ */
744
+ function checkBrowserIcab() {
745
+ if ( stripos( $this->_agent, 'icab' ) !== false ) {
746
+ $aversion = explode( ' ', stristr( str_replace( '/', ' ', $this->_agent ), 'icab' ) );
747
+ $this->setVersion( $aversion[1] );
748
+ $this->setBrowser( $this->BROWSER_ICAB );
749
+ return true;
750
+ }
751
+ return false;
752
+ }
753
+
754
+ /**
755
+ * Determine if the browser is OmniWeb or not (last updated 1.7)
756
+ *
757
+ * @return boolean True if the browser is OmniWeb otherwise false
758
+ */
759
+ function checkBrowserOmniWeb() {
760
+ if ( stripos( $this->_agent, 'omniweb' ) !== false ) {
761
+ $aresult = explode( '/', stristr( $this->_agent, 'omniweb' ) );
762
+ $aversion = explode( ' ', isset( $aresult[1] )?$aresult[1]:"" );
763
+ $this->setVersion( $aversion[0] );
764
+ $this->setBrowser( $this->BROWSER_OMNIWEB );
765
+ return true;
766
+ }
767
+ return false;
768
+ }
769
+
770
+ /**
771
+ * Determine if the browser is Phoenix or not (last updated 1.7)
772
+ *
773
+ * @return boolean True if the browser is Phoenix otherwise false
774
+ */
775
+ function checkBrowserPhoenix() {
776
+ if ( stripos( $this->_agent, 'Phoenix' ) !== false ) {
777
+ $aversion = explode( '/', stristr( $this->_agent, 'Phoenix' ) );
778
+ $this->setVersion( $aversion[1] );
779
+ $this->setBrowser( $this->BROWSER_PHOENIX );
780
+ return true;
781
+ }
782
+ return false;
783
+ }
784
+
785
+ /**
786
+ * Determine if the browser is Firebird or not (last updated 1.7)
787
+ *
788
+ * @return boolean True if the browser is Firebird otherwise false
789
+ */
790
+ function checkBrowserFirebird() {
791
+ if ( stripos( $this->_agent, 'Firebird' ) !== false ) {
792
+ $aversion = explode( '/', stristr( $this->_agent, 'Firebird' ) );
793
+ $this->setVersion( $aversion[1] );
794
+ $this->setBrowser( $this->BROWSER_FIREBIRD );
795
+ return true;
796
+ }
797
+ return false;
798
+ }
799
+
800
+ /**
801
+ * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7)
802
+ * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
803
+ *
804
+ * @return boolean True if the browser is Netscape Navigator 9+ otherwise false
805
+ */
806
+ function checkBrowserNetscapeNavigator9Plus() {
807
+ if ( stripos( $this->_agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->_agent, $matches ) ) {
808
+ $this->setVersion( $matches[1] );
809
+ $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
810
+ return true;
811
+ } else if ( stripos( $this->_agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->_agent, $matches ) ) {
812
+ $this->setVersion( $matches[1] );
813
+ $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
814
+ return true;
815
+ }
816
+ return false;
817
+ }
818
+
819
+ /**
820
+ * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7)
821
+ *
822
+ * @return boolean True if the browser is Shiretoko otherwise false
823
+ */
824
+ function checkBrowserShiretoko() {
825
+ if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->_agent, $matches ) ) {
826
+ $this->setVersion( $matches[1] );
827
+ $this->setBrowser( $this->BROWSER_SHIRETOKO );
828
+ return true;
829
+ }
830
+ return false;
831
+ }
832
+
833
+ /**
834
+ * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7)
835
+ *
836
+ * @return boolean True if the browser is Ice Cat otherwise false
837
+ */
838
+ function checkBrowserIceCat() {
839
+ if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->_agent, $matches ) ) {
840
+ $this->setVersion( $matches[1] );
841
+ $this->setBrowser( $this->BROWSER_ICECAT );
842
+ return true;
843
+ }
844
+ return false;
845
+ }
846
+
847
+ /**
848
+ * Determine if the browser is Nokia or not (last updated 1.7)
849
+ *
850
+ * @return boolean True if the browser is Nokia otherwise false
851
+ */
852
+ function checkBrowserNokia() {
853
+ if ( preg_match( "/Nokia([^\/]+)\/([^ SP]+)/i", $this->_agent, $matches ) ) {
854
+ $this->setVersion( $matches[2] );
855
+ if ( stripos( $this->_agent, 'Series60' ) !== false || strpos( $this->_agent, 'S60' ) !== false ) {
856
+ $this->setBrowser( $this->BROWSER_NOKIA_S60 );
857
+ } else {
858
+ $this->setBrowser( $this->BROWSER_NOKIA );
859
+ }
860
+ $this->setMobile( true );
861
+ return true;
862
+ }
863
+ return false;
864
+ }
865
+
866
+ /**
867
+ * Determine if the browser is Firefox or not (last updated 1.7)
868
+ *
869
+ * @return boolean True if the browser is Firefox otherwise false
870
+ */
871
+ function checkBrowserFirefox() {
872
+ if ( stripos( $this->_agent, 'safari' ) === false ) {
873
+ if ( preg_match( "/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) {
874
+ $this->setVersion( $matches[1] );
875
+ $this->setBrowser( $this->BROWSER_FIREFOX );
876
+ return true;
877
+ } else if ( preg_match( "/Firefox$/i", $this->_agent, $matches ) ) {
878
+ $this->setVersion( "" );
879
+ $this->setBrowser( $this->BROWSER_FIREFOX );
880
+ return true;
881
+ }
882
+ }
883
+ return false;
884
+ }
885
+
886
+ /**
887
+ * Determine if the browser is Firefox or not (last updated 1.7)
888
+ *
889
+ * @return boolean True if the browser is Firefox otherwise false
890
+ */
891
+ function checkBrowserIceweasel() {
892
+ if ( stripos( $this->_agent, 'Iceweasel' ) !== false ) {
893
+ $aresult = explode( '/', stristr( $this->_agent, 'Iceweasel' ) );
894
+ $aversion = explode( ' ', $aresult[1] );
895
+ $this->setVersion( $aversion[0] );
896
+ $this->setBrowser( $this->BROWSER_ICEWEASEL );
897
+ return true;
898
+ }
899
+ return false;
900
+ }
901
+ /**
902
+ * Determine if the browser is Mozilla or not (last updated 1.7)
903
+ *
904
+ * @return boolean True if the browser is Mozilla otherwise false
905
+ */
906
+ function checkBrowserMozilla() {
907
+ if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
908
+ $aversion = explode( ' ', stristr( $this->_agent, 'rv:' ) );
909
+ preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion );
910
+ $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
911
+ $this->setBrowser( $this->BROWSER_MOZILLA );
912
+ return true;
913
+ } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
914
+ $aversion = explode( '', stristr( $this->_agent, 'rv:' ) );
915
+ $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
916
+ $this->setBrowser( $this->BROWSER_MOZILLA );
917
+ return true;
918
+ } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->_agent, $matches ) && stripos( $this->_agent, 'netscape' ) === false ) {
919
+ $this->setVersion( $matches[1] );
920
+ $this->setBrowser( $this->BROWSER_MOZILLA );
921
+ return true;
922
+ }
923
+ return false;
924
+ }
925
+
926
+ /**
927
+ * Determine if the browser is Lynx or not (last updated 1.7)
928
+ *
929
+ * @return boolean True if the browser is Lynx otherwise false
930
+ */
931
+ function checkBrowserLynx() {
932
+ if ( stripos( $this->_agent, 'lynx' ) !== false ) {
933
+ $aresult = explode( '/', stristr( $this->_agent, 'Lynx' ) );
934
+ $aversion = explode( ' ', ( isset( $aresult[1] )?$aresult[1]:"" ) );
935
+ $this->setVersion( $aversion[0] );
936
+ $this->setBrowser( $this->BROWSER_LYNX );
937
+ return true;
938
+ }
939
+ return false;
940
+ }
941
+
942
+ /**
943
+ * Determine if the browser is Amaya or not (last updated 1.7)
944
+ *
945
+ * @return boolean True if the browser is Amaya otherwise false
946
+ */
947
+ function checkBrowserAmaya() {
948
+ if ( stripos( $this->_agent, 'amaya' ) !== false ) {
949
+ $aresult = explode( '/', stristr( $this->_agent, 'Amaya' ) );
950
+ $aversion = explode( ' ', $aresult[1] );
951
+ $this->setVersion( $aversion[0] );
952
+ $this->setBrowser( $this->BROWSER_AMAYA );
953
+ return true;
954
+ }
955
+ return false;
956
+ }
957
+
958
+ /**
959
+ * Determine if the browser is Safari or not (last updated 1.7)
960
+ *
961
+ * @return boolean True if the browser is Safari otherwise false
962
+ */
963
+ function checkBrowserSafari() {
964
+ if ( stripos( $this->_agent, 'Safari' ) !== false && stripos( $this->_agent, 'iPhone' ) === false && stripos( $this->_agent, 'iPod' ) === false ) {
965
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
966
+ if ( isset( $aresult[1] ) ) {
967
+ $aversion = explode( ' ', $aresult[1] );
968
+ $this->setVersion( $aversion[0] );
969
+ } else {
970
+ $this->setVersion( $this->VERSION_UNKNOWN );
971
+ }
972
+ $this->setBrowser( $this->BROWSER_SAFARI );
973
+ return true;
974
+ }
975
+ return false;
976
+ }
977
+
978
+ /**
979
+ * Determine if the browser is iPhone or not (last updated 1.7)
980
+ *
981
+ * @return boolean True if the browser is iPhone otherwise false
982
+ */
983
+ function checkBrowseriPhone() {
984
+ if ( stripos( $this->_agent, 'iPhone' ) !== false ) {
985
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
986
+ if ( isset( $aresult[1] ) ) {
987
+ $aversion = explode( ' ', $aresult[1] );
988
+ $this->setVersion( $aversion[0] );
989
+ } else {
990
+ $this->setVersion( $this->VERSION_UNKNOWN );
991
+ }
992
+ $this->setMobile( true );
993
+ $this->setBrowser( $this->BROWSER_IPHONE );
994
+ return true;
995
+ }
996
+ return false;
997
+ }
998
+
999
+ /**
1000
+ * Determine if the browser is iPod or not (last updated 1.7)
1001
+ *
1002
+ * @return boolean True if the browser is iPod otherwise false
1003
+ */
1004
+ function checkBrowseriPad() {
1005
+ if ( stripos( $this->_agent, 'iPad' ) !== false ) {
1006
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
1007
+ if ( isset( $aresult[1] ) ) {
1008
+ $aversion = explode( ' ', $aresult[1] );
1009
+ $this->setVersion( $aversion[0] );
1010
+ } else {
1011
+ $this->setVersion( $this->VERSION_UNKNOWN );
1012
+ }
1013
+ $this->setMobile( true );
1014
+ $this->setBrowser( $this->BROWSER_IPAD );
1015
+ return true;
1016
+ }
1017
+ return false;
1018
+ }
1019
+
1020
+ /**
1021
+ * Determine if the browser is iPod or not (last updated 1.7)
1022
+ *
1023
+ * @return boolean True if the browser is iPod otherwise false
1024
+ */
1025
+ function checkBrowseriPod() {
1026
+ if ( stripos( $this->_agent, 'iPod' ) !== false ) {
1027
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
1028
+ if ( isset( $aresult[1] ) ) {
1029
+ $aversion = explode( ' ', $aresult[1] );
1030
+ $this->setVersion( $aversion[0] );
1031
+ } else {
1032
+ $this->setVersion( $this->VERSION_UNKNOWN );
1033
+ }
1034
+ $this->setMobile( true );
1035
+ $this->setBrowser( $this->BROWSER_IPOD );
1036
+ return true;
1037
+ }
1038
+ return false;
1039
+ }
1040
+
1041
+ /**
1042
+ * Determine if the browser is Android or not (last updated 1.7)
1043
+ *
1044
+ * @return boolean True if the browser is Android otherwise false
1045
+ */
1046
+ function checkBrowserAndroid() {
1047
+ if ( stripos( $this->_agent, 'Android' ) !== false ) {
1048
+ $aresult = explode( ' ', stristr( $this->_agent, 'Android' ) );
1049
+ if ( isset( $aresult[1] ) ) {
1050
+ $aversion = explode( ' ', $aresult[1] );
1051
+ $this->setVersion( $aversion[0] );
1052
+ } else {
1053
+ $this->setVersion( $this->VERSION_UNKNOWN );
1054
+ }
1055
+ $this->setMobile( true );
1056
+ $this->setBrowser( $this->BROWSER_ANDROID );
1057
+ return true;
1058
+ }
1059
+ return false;
1060
+ }
1061
+
1062
+ /**
1063
+ * Determine the user's platform (last updated 1.7)
1064
+ */
1065
+ function checkPlatform() {
1066
+ if ( stripos( $this->_agent, 'windows' ) !== false ) {
1067
+ $this->_platform = $this->PLATFORM_WINDOWS;
1068
+ } else if ( stripos( $this->_agent, 'iPad' ) !== false ) {
1069
+ $this->_platform = $this->PLATFORM_IPAD;
1070
+ } else if ( stripos( $this->_agent, 'iPod' ) !== false ) {
1071
+ $this->_platform = $this->PLATFORM_IPOD;
1072
+ } else if ( stripos( $this->_agent, 'iPhone' ) !== false ) {
1073
+ $this->_platform = $this->PLATFORM_IPHONE;
1074
+ } elseif ( stripos( $this->_agent, 'mac' ) !== false ) {
1075
+ $this->_platform = $this->PLATFORM_APPLE;
1076
+ } elseif ( stripos( $this->_agent, 'android' ) !== false ) {
1077
+ $this->_platform = $this->PLATFORM_ANDROID;
1078
+ } elseif ( stripos( $this->_agent, 'linux' ) !== false ) {
1079
+ $this->_platform = $this->PLATFORM_LINUX;
1080
+ } else if ( stripos( $this->_agent, 'Nokia' ) !== false ) {
1081
+ $this->_platform = $this->PLATFORM_NOKIA;
1082
+ } else if ( stripos( $this->_agent, 'BlackBerry' ) !== false ) {
1083
+ $this->_platform = $this->PLATFORM_BLACKBERRY;
1084
+ } elseif ( stripos( $this->_agent, 'FreeBSD' ) !== false ) {
1085
+ $this->_platform = $this->PLATFORM_FREEBSD;
1086
+ } elseif ( stripos( $this->_agent, 'OpenBSD' ) !== false ) {
1087
+ $this->_platform = $this->PLATFORM_OPENBSD;
1088
+ } elseif ( stripos( $this->_agent, 'NetBSD' ) !== false ) {
1089
+ $this->_platform = $this->PLATFORM_NETBSD;
1090
+ } elseif ( stripos( $this->_agent, 'OpenSolaris' ) !== false ) {
1091
+ $this->_platform = $this->PLATFORM_OPENSOLARIS;
1092
+ } elseif ( stripos( $this->_agent, 'SunOS' ) !== false ) {
1093
+ $this->_platform = $this->PLATFORM_SUNOS;
1094
+ } elseif ( stripos( $this->_agent, 'OS\/2' ) !== false ) {
1095
+ $this->_platform = $this->PLATFORM_OS2;
1096
+ } elseif ( stripos( $this->_agent, 'BeOS' ) !== false ) {
1097
+ $this->_platform = $this->PLATFORM_BEOS;
1098
+ } elseif ( stripos( $this->_agent, 'win' ) !== false ) {
1099
+ $this->_platform = $this->PLATFORM_WINDOWS;
1100
+ }
1101
+
1102
+ }
1103
+ }
core/lib/upload/um-file-upload.php CHANGED
@@ -21,10 +21,14 @@ $timestamp = $_POST['timestamp'];
21
  $ultimatemember->fields->set_id = $_POST['set_id'];
22
  $ultimatemember->fields->set_mode = $_POST['set_mode'];
23
 
24
- if ( ! wp_verify_nonce( $nonce, 'um_upload_nonce-'.$timestamp ) && is_user_logged_in() ) {
25
- // This nonce is not valid.
26
- $ret['error'] = 'Invalid nonce';
27
- die( json_encode( $ret ) );
 
 
 
 
28
  }
29
 
30
 
21
  $ultimatemember->fields->set_id = $_POST['set_id'];
22
  $ultimatemember->fields->set_mode = $_POST['set_mode'];
23
 
24
+ $um_file_upload_nonce = apply_filters("um_file_upload_nonce", true );
25
+
26
+ if( $um_file_upload_nonce ){
27
+ if ( ! wp_verify_nonce( $nonce, 'um_upload_nonce-'.$timestamp ) && is_user_logged_in()) {
28
+ // This nonce is not valid.
29
+ $ret['error'] = 'Invalid nonce';
30
+ die( json_encode( $ret ) );
31
+ }
32
  }
33
 
34
 
core/lib/upload/um-image-upload.php CHANGED
@@ -20,10 +20,14 @@ $nonce = $_POST['_wpnonce'];
20
  $ultimatemember->fields->set_id = $_POST['set_id'];
21
  $ultimatemember->fields->set_mode = $_POST['set_mode'];
22
 
23
- if ( ! wp_verify_nonce( $nonce, 'um_upload_nonce-'.$timestamp ) && is_user_logged_in() ) {
24
- // This nonce is not valid.
25
- $ret['error'] = 'Invalid nonce';
26
- die( json_encode( $ret ) );
 
 
 
 
27
  }
28
 
29
  if(isset($_FILES[$id]['name'])) {
20
  $ultimatemember->fields->set_id = $_POST['set_id'];
21
  $ultimatemember->fields->set_mode = $_POST['set_mode'];
22
 
23
+ $um_image_upload_nonce = apply_filters("um_image_upload_nonce", true );
24
+
25
+ if( $um_image_upload_nonce ){
26
+ if ( ! wp_verify_nonce( $nonce, 'um_upload_nonce-'.$timestamp ) && is_user_logged_in() ) {
27
+ // This nonce is not valid.
28
+ $ret['error'] = 'Invalid nonce';
29
+ die( json_encode( $ret ) );
30
+ }
31
  }
32
 
33
  if(isset($_FILES[$id]['name'])) {
core/um-access.php CHANGED
@@ -11,13 +11,16 @@ class UM_Access {
11
 
12
  }
13
 
14
- /***
15
- *** @do actions based on priority
16
- ***/
 
17
  function template_redirect() {
18
  global $post, $ultimatemember;
19
 
20
  do_action('um_access_global_settings');
 
 
21
 
22
  do_action('um_access_frontpage_per_role');
23
 
@@ -42,9 +45,12 @@ class UM_Access {
42
 
43
  }
44
 
45
- /***
46
- *** @get meta
47
- ***/
 
 
 
48
  function get_meta( $post_id ) {
49
  global $post;
50
  $meta = get_post_custom( $post_id );
@@ -62,4 +68,18 @@ class UM_Access {
62
  return array('');
63
  }
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
11
 
12
  }
13
 
14
+
15
+ /**
16
+ * Set custom access actions and redirection
17
+ */
18
  function template_redirect() {
19
  global $post, $ultimatemember;
20
 
21
  do_action('um_access_global_settings');
22
+
23
+ do_action('um_access_user_custom_homepage');
24
 
25
  do_action('um_access_frontpage_per_role');
26
 
45
 
46
  }
47
 
48
+
49
+ /**
50
+ * Get custom access settings meta
51
+ * @param integer $post_id
52
+ * @return array
53
+ */
54
  function get_meta( $post_id ) {
55
  global $post;
56
  $meta = get_post_custom( $post_id );
68
  return array('');
69
  }
70
 
71
+ /**
72
+ * Sets a custom access referer in a redirect URL
73
+ * @param string $url
74
+ * @param string $referer
75
+ */
76
+ function set_referer( $url, $referer ){
77
+
78
+ $enable_referer = apply_filters("um_access_enable_referer", false );
79
+ if( ! $enable_referer ) return $url;
80
+
81
+ $url = add_query_arg('um_ref',$referer, $url);
82
+ return $url;
83
+ }
84
+
85
  }
core/um-actions-access.php CHANGED
@@ -35,11 +35,8 @@
35
  if ( ( isset( $post->ID ) ) && ( in_array( $current_url, $redirects ) || in_array( $current_url_slash, $redirects ) ) ) {
36
  // allow
37
  }else {
38
- $ultimatemember->access->redirect_handler = $redirect;
39
  }
40
-
41
-
42
-
43
  }
44
 
45
 
@@ -49,6 +46,35 @@
49
  do_action("um_access_post_type_{$current_page_type}");
50
 
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
 
54
  /***
@@ -60,6 +86,7 @@
60
 
61
  if ( is_admin() ) return;
62
  if ( ! is_front_page() ) return;
 
63
 
64
  if ( ! isset( $um_post_id ) && isset( $post->ID ) ){
65
  $um_post_id = $post->ID;
@@ -99,7 +126,7 @@
99
 
100
  case 1:
101
 
102
- $redirect_to = esc_url( $access_redirect2 );
103
 
104
  if ( is_user_logged_in() ){
105
  $ultimatemember->access->allow_access = false;
@@ -110,13 +137,17 @@
110
  }
111
 
112
  if( ! empty( $redirect_to ) ){
 
113
  $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
114
  }else{
115
  if ( ! is_user_logged_in() ){
116
- $ultimatemember->access->redirect_handler = um_get_core_page("login");
117
  }else{
118
- $ultimatemember->access->redirect_handler = um_get_core_page("user");
119
  }
 
 
 
120
  }
121
 
122
 
@@ -130,7 +161,9 @@
130
  $access_redirect = um_get_core_page('login');
131
  }
132
 
133
- $redirect_to = esc_url( $access_redirect );
 
 
134
  }
135
 
136
  if ( is_user_logged_in() && isset( $access_roles ) && !empty( $access_roles ) ){
@@ -138,17 +171,20 @@
138
  $access_roles = array_filter($access_roles);
139
 
140
  if ( !empty( $access_roles ) && !in_array( um_user('role'), $access_roles ) ) {
141
- if ( !$access_redirect ) {
142
  if ( is_user_logged_in() ) {
143
- $access_redirect = esc_url( site_url() );
144
  } else {
145
- $access_redirect = esc_url( um_get_core_page('login') );
146
  }
147
  }
148
  $redirect_to = esc_url( $access_redirect );
 
 
149
  }
150
  }
151
-
 
152
  $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
153
 
154
  break;
@@ -165,7 +201,8 @@
165
  global $ultimatemember, $post;
166
 
167
  if ( is_admin() ) return;
168
- if ( ! is_home() ) return;
 
169
 
170
  $access = um_get_option('accessible');
171
 
@@ -230,13 +267,17 @@
230
  }
231
 
232
  if( ! empty( $redirect_to ) ){
 
233
  $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
234
  }else{
 
235
  if ( ! is_user_logged_in() ){
236
- $ultimatemember->access->redirect_handler = um_get_core_page("login");
237
  }else{
238
- $ultimatemember->access->redirect_handler = um_get_core_page("user");
239
  }
 
 
240
  }
241
 
242
 
@@ -250,7 +291,8 @@
250
  $access_redirect = um_get_core_page('login');
251
  }
252
 
253
- $redirect_to = esc_url( $access_redirect );
 
254
  }
255
 
256
  if ( is_user_logged_in() && isset( $access_roles ) && !empty( $access_roles ) ){
@@ -260,23 +302,23 @@
260
  if ( !empty( $access_roles ) && !in_array( um_user('role'), $access_roles ) ) {
261
  if ( !$access_redirect ) {
262
  if ( is_user_logged_in() ) {
263
- $access_redirect = esc_url( site_url() );
264
  } else {
265
- $access_redirect = esc_url( um_get_core_page('login') );
266
  }
267
  }
268
- $redirect_to = esc_url( $access_redirect );
 
 
 
269
  }
270
  }
271
-
272
  $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
273
 
274
  break;
275
 
276
  }
277
  }
278
-
279
-
280
  }
281
 
282
 
@@ -290,7 +332,8 @@
290
  if ( is_front_page() ||
291
  is_home() ||
292
  is_feed() ||
293
- is_page()
 
294
  ) {
295
 
296
  return;
@@ -328,14 +371,18 @@
328
 
329
  if ( is_user_logged_in() ){
330
 
331
- if( isset( $opt['_um_redirect'] ) ) {
332
- $redirect = esc_url( $opt['_um_redirect'] );
333
  }else{
334
  $redirect = site_url();
335
  }
336
  }
 
337
  $ultimatemember->access->allow_access = false;
338
- $ultimatemember->access->redirect_handler = $redirect;
 
 
 
339
 
340
  if ( ! is_user_logged_in() && ! empty( $redirect ) ){
341
  $ultimatemember->access->allow_access = true;
@@ -348,12 +395,16 @@
348
  if ( ! is_user_logged_in() ){
349
 
350
  if( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ){
351
- $redirect = esc_url( $opt['_um_redirect'] );
352
  }else{
353
  $redirect = um_get_core_page('login');
354
  }
 
355
  $ultimatemember->access->allow_access = false;
356
- $ultimatemember->access->redirect_handler = $redirect;
 
 
 
357
  }
358
 
359
  if ( is_user_logged_in() && isset( $opt['_um_roles'] ) && !empty( $opt['_um_roles'] ) ){
@@ -361,10 +412,11 @@
361
 
362
 
363
  if( isset( $opt['_um_redirect'] ) ){
364
- $redirect = esc_url( $opt['_um_redirect'] );
365
  }
366
-
367
- $ultimatemember->access->redirect_handler = $redirect;
 
368
 
369
  }
370
  }
@@ -377,6 +429,8 @@
377
 
378
  $ultimatemember->access->allow_access = false;
379
  $redirect = um_get_core_page('login');
 
 
380
  $ultimatemember->access->redirect_handler = $redirect;
381
 
382
  } else if ( is_tax() && get_post_taxonomies( $post ) ) {
@@ -406,8 +460,9 @@
406
  case 1:
407
 
408
  if ( is_user_logged_in() )
409
- $ultimatemember->access->redirect_handler = ( isset( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : site_url();
410
-
 
411
  if ( !is_user_logged_in() )
412
  $ultimatemember->access->allow_access = true;
413
 
@@ -415,17 +470,27 @@
415
 
416
  case 2:
417
 
418
- if ( ! is_user_logged_in() )
419
- $ultimatemember->access->redirect_handler = ( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : um_get_core_page('login');
 
 
 
 
 
420
 
421
  if ( is_user_logged_in() && isset( $opt['_um_roles'] ) && !empty( $opt['_um_roles'] ) ){
422
  if ( !in_array( um_user('role'), $opt['_um_roles'] ) ) {
 
 
 
 
423
 
424
- if ( is_user_logged_in() )
425
- $ultimatemember->access->redirect_handler = ( isset( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : site_url();
 
426
 
427
- if ( !is_user_logged_in() )
428
- $ultimatemember->access->redirect_handler = um_get_core_page('login');
429
  }
430
  }
431
 
@@ -459,7 +524,8 @@
459
  ! get_post_type() ||
460
  ! isset( $post->ID ) ||
461
  is_home() ||
462
- is_front_page()
 
463
  ) {
464
 
465
  return;
@@ -473,155 +539,182 @@
473
  $args = $ultimatemember->access->get_meta( $um_post_id );
474
  extract( $args );
475
 
476
- $categories = get_the_category( $post->ID );
477
- // Check post category restriction
478
- foreach( $categories as $cat ){
479
-
480
- $opt = get_option("category_{$cat->term_id}");
481
 
482
- if ( isset( $opt['_um_accessible'] ) ) {
483
- switch( $opt['_um_accessible'] ) {
484
 
485
- case 0: // Open to everyone
486
- $ultimatemember->access->allow_access = true;
487
- $ultimatemember->access->redirect_handler = false; // open to everyone
488
- break;
489
 
490
- case 1: // Logged out users only
491
-
492
- if ( is_user_logged_in() )
493
- $ultimatemember->access->redirect_handler = ( isset( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : site_url();
494
 
495
- if ( !is_user_logged_in() )
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  $ultimatemember->access->allow_access = true;
 
 
497
 
498
- break;
499
-
500
- case 2: // Logged in users only
 
 
 
 
 
501
 
502
- if ( ! is_user_logged_in() ){
503
- $ultimatemember->access->redirect_handler = ( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : um_get_core_page('login');
504
- $ultimatemember->access->allow_access = false;
505
- }
506
 
507
- if ( is_user_logged_in() ){
508
-
509
- if( isset( $opt['_um_roles'] ) && !empty( $opt['_um_roles'] ) ){
510
 
511
- if ( in_array( um_user('role'), $opt['_um_roles'] ) ) {
512
 
513
- $ultimatemember->access->allow_access = true;
514
-
515
- }else{
516
 
517
- $ultimatemember->access->redirect_handler = ( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : site_url();
518
- $ultimatemember->access->allow_access = false;
519
-
520
- }
521
 
522
- }else{ // if allowed all roles
523
- $ultimatemember->access->allow_access = true;
 
 
524
  }
525
 
526
- }
527
-
528
- }
529
 
 
530
 
531
- } // end if isset( $opt['_um_accessible'] )
 
 
532
 
533
- // if one of the categories has enabled restriction, apply its settings to the current post
534
- if( $ultimatemember->access->allow_access == false ){
535
- return;
536
- }
 
 
 
537
 
538
- } // end foreach
539
-
540
- if ( !isset( $args['custom_access_settings'] ) || $args['custom_access_settings'] == 0 ) {
541
 
542
- $um_post_id = apply_filters('um_access_control_for_parent_posts', $um_post_id );
 
 
543
 
544
- $args = $ultimatemember->access->get_meta( $um_post_id );
545
- extract( $args );
546
 
547
- if ( !isset( $args['custom_access_settings'] ) || $args['custom_access_settings'] == 0 ) {
548
- return;
549
- }
550
 
551
- }
 
 
 
552
 
553
- $redirect_to = null;
 
554
 
555
- if ( !isset( $accessible ) ) return;
 
 
 
556
 
557
- switch( $accessible ) {
558
 
559
- case 0:
560
- $ultimatemember->access->allow_access = true;
561
- $ultimatemember->access->redirect_handler = false; // open to everyone
562
 
563
- break;
 
 
564
 
565
- case 1:
566
 
567
- $redirect_to = esc_url( $access_redirect2 );
568
-
569
- if ( is_user_logged_in() ){
570
- $ultimatemember->access->allow_access = false;
571
- }
572
 
573
- if ( ! is_user_logged_in() ){
574
- $ultimatemember->access->allow_access = true;
575
- }
 
 
576
 
577
- if( ! empty( $redirect_to ) ){
578
- $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
579
- }else{
580
- if ( ! is_user_logged_in() ){
581
- $ultimatemember->access->redirect_handler = um_get_core_page("login");
 
 
582
  }else{
583
- $ultimatemember->access->redirect_handler = um_get_core_page("user");
 
 
 
 
 
 
 
584
  }
585
- }
586
 
587
 
588
- break;
589
 
590
- case 2:
591
 
592
- if ( ! is_user_logged_in() ){
593
 
594
- if ( empty( $access_redirect ) ) {
595
- $access_redirect = um_get_core_page('login');
 
 
 
 
 
596
  }
597
-
598
- $redirect_to = esc_url( $access_redirect );
599
- }
600
 
601
- if ( is_user_logged_in() && isset( $access_roles ) && !empty( $access_roles ) ){
602
- $access_roles = unserialize( $access_roles );
603
- $access_roles = array_filter($access_roles);
604
 
605
- if ( !empty( $access_roles ) && !in_array( um_user('role'), $access_roles ) ) {
606
- if ( !$access_redirect ) {
607
- if ( is_user_logged_in() ) {
608
- $access_redirect = esc_url( site_url() );
609
- } else {
610
- $access_redirect = esc_url( um_get_core_page('login') );
 
611
  }
 
 
612
  }
613
- $redirect_to = esc_url( $access_redirect );
614
  }
615
- }
616
-
617
- $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
618
-
619
- break;
620
 
 
621
  }
622
 
623
- if( um_is_core_page('user') && ! is_user_logged_in() ){
624
  $ultimatemember->access->allow_access = false;
 
625
  $ultimatemember->access->redirect_handler = esc_url( $access_redirect );
626
  wp_redirect( $ultimatemember->access->redirect_handler );
627
  exit;
35
  if ( ( isset( $post->ID ) ) && ( in_array( $current_url, $redirects ) || in_array( $current_url_slash, $redirects ) ) ) {
36
  // allow
37
  }else {
38
+ $ultimatemember->access->redirect_handler = $ultimatemember->access->set_referer( $redirect, "global" );
39
  }
 
 
 
40
  }
41
 
42
 
46
  do_action("um_access_post_type_{$current_page_type}");
47
 
48
 
49
+ }
50
+
51
+ /***
52
+ *** @Custom User homepage redirection
53
+ ***/
54
+ add_action("um_access_user_custom_homepage","um_access_user_custom_homepage");
55
+ function um_access_user_custom_homepage(){
56
+ global $ultimatemember;
57
+
58
+ if( ! is_user_logged_in() ) return;
59
+ if( ! is_front_page() ) return;
60
+
61
+ $role_meta = $ultimatemember->query->role_data( um_user('role') );
62
+
63
+ if( isset( $role_meta['default_homepage'] ) && $role_meta['default_homepage'] == 0 ){
64
+ $redirect_to = null;
65
+
66
+ if( ! empty( $role_meta['redirect_homepage'] ) ){
67
+ $redirect_to = $role_meta['redirect_homepage'];
68
+ }else{
69
+ $redirect_to = um_get_core_page('user');
70
+ }
71
+
72
+ $redirect_to = $ultimatemember->access->set_referer( $redirect_to, "custom_homepage" );
73
+ wp_redirect( $redirect_to ); exit;
74
+
75
+ }
76
+
77
+
78
  }
79
 
80
  /***
86
 
87
  if ( is_admin() ) return;
88
  if ( ! is_front_page() ) return;
89
+ if( is_404() ) return;
90
 
91
  if ( ! isset( $um_post_id ) && isset( $post->ID ) ){
92
  $um_post_id = $post->ID;
126
 
127
  case 1:
128
 
129
+ $redirect_to = $access_redirect2;
130
 
131
  if ( is_user_logged_in() ){
132
  $ultimatemember->access->allow_access = false;
137
  }
138
 
139
  if( ! empty( $redirect_to ) ){
140
+ $redirect_to = $ultimatemember->access->set_referer( $redirect_to, "frontpage_per_role_1a" );
141
  $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
142
  }else{
143
  if ( ! is_user_logged_in() ){
144
+ $redirect_to = um_get_core_page("login");
145
  }else{
146
+ $redirect_to = um_get_core_page("user");
147
  }
148
+
149
+ $redirect_to = $ultimatemember->access->set_referer( $redirect_to, "frontpage_per_role_1b" );
150
+ $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
151
  }
152
 
153
 
161
  $access_redirect = um_get_core_page('login');
162
  }
163
 
164
+ $redirect_to = $access_redirect;
165
+ $redirect_to = $ultimatemember->access->set_referer( $redirect_to, "frontpage_per_role_2a" );
166
+
167
  }
168
 
169
  if ( is_user_logged_in() && isset( $access_roles ) && !empty( $access_roles ) ){
171
  $access_roles = array_filter($access_roles);
172
 
173
  if ( !empty( $access_roles ) && !in_array( um_user('role'), $access_roles ) ) {
174
+ if ( empty( $access_redirect ) ) {
175
  if ( is_user_logged_in() ) {
176
+ $access_redirect = site_url();
177
  } else {
178
+ $access_redirect = um_get_core_page('login');
179
  }
180
  }
181
  $redirect_to = esc_url( $access_redirect );
182
+ $redirect_to = $ultimatemember->access->set_referer( $redirect_to, "frontpage_per_role_2b" );
183
+
184
  }
185
  }
186
+
187
+
188
  $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
189
 
190
  break;
201
  global $ultimatemember, $post;
202
 
203
  if ( is_admin() ) return;
204
+ if ( ! is_home() ) return;
205
+ if ( is_404() ) return;
206
 
207
  $access = um_get_option('accessible');
208
 
267
  }
268
 
269
  if( ! empty( $redirect_to ) ){
270
+ $redirect_to = $ultimatemember->access->set_referer( $redirect_to, "homepage_per_role_1a" );
271
  $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
272
  }else{
273
+ $redirect_to = null;
274
  if ( ! is_user_logged_in() ){
275
+ $redirect_to = um_get_core_page("login");
276
  }else{
277
+ $redirect_to = um_get_core_page("user");
278
  }
279
+ $redirect_to = $ultimatemember->access->set_referer( $redirect_to, "homepage_per_role_1b" );
280
+ $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
281
  }
282
 
283
 
291
  $access_redirect = um_get_core_page('login');
292
  }
293
 
294
+ $redirect_to = $access_redirect;
295
+ $redirect_to = $ultimatemember->access->set_referer( $redirect_to, "homepage_per_role_2a" );
296
  }
297
 
298
  if ( is_user_logged_in() && isset( $access_roles ) && !empty( $access_roles ) ){
302
  if ( !empty( $access_roles ) && !in_array( um_user('role'), $access_roles ) ) {
303
  if ( !$access_redirect ) {
304
  if ( is_user_logged_in() ) {
305
+ $access_redirect = site_url();
306
  } else {
307
+ $access_redirect = um_get_core_page('login');
308
  }
309
  }
310
+
311
+ $redirect_to = $access_redirect;
312
+ $redirect_to = $ultimatemember->access->set_referer( $redirect_to, "homepage_per_role_2b" );
313
+
314
  }
315
  }
 
316
  $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
317
 
318
  break;
319
 
320
  }
321
  }
 
 
322
  }
323
 
324
 
332
  if ( is_front_page() ||
333
  is_home() ||
334
  is_feed() ||
335
+ is_page() ||
336
+ is_404()
337
  ) {
338
 
339
  return;
371
 
372
  if ( is_user_logged_in() ){
373
 
374
+ if( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ) {
375
+ $redirect = $opt['_um_redirect'];
376
  }else{
377
  $redirect = site_url();
378
  }
379
  }
380
+
381
  $ultimatemember->access->allow_access = false;
382
+
383
+ $redirect = $ultimatemember->access->set_referer( $redirect, "category_1" );
384
+
385
+ $ultimatemember->access->redirect_handler = esc_url( $redirect );
386
 
387
  if ( ! is_user_logged_in() && ! empty( $redirect ) ){
388
  $ultimatemember->access->allow_access = true;
395
  if ( ! is_user_logged_in() ){
396
 
397
  if( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ){
398
+ $redirect = $opt['_um_redirect'];
399
  }else{
400
  $redirect = um_get_core_page('login');
401
  }
402
+
403
  $ultimatemember->access->allow_access = false;
404
+
405
+ $redirect = $ultimatemember->access->set_referer( $redirect, "category_2a" );
406
+
407
+ $ultimatemember->access->redirect_handler = esc_url( $redirect );
408
  }
409
 
410
  if ( is_user_logged_in() && isset( $opt['_um_roles'] ) && !empty( $opt['_um_roles'] ) ){
412
 
413
 
414
  if( isset( $opt['_um_redirect'] ) ){
415
+ $redirect = $opt['_um_redirect'];
416
  }
417
+ $redirect = $ultimatemember->access->set_referer( $redirect, "category_2b" );
418
+
419
+ $ultimatemember->access->redirect_handler = esc_url( $redirect );
420
 
421
  }
422
  }
429
 
430
  $ultimatemember->access->allow_access = false;
431
  $redirect = um_get_core_page('login');
432
+ $redirect = $ultimatemember->access->set_referer( $redirect, "category_archive" );
433
+
434
  $ultimatemember->access->redirect_handler = $redirect;
435
 
436
  } else if ( is_tax() && get_post_taxonomies( $post ) ) {
460
  case 1:
461
 
462
  if ( is_user_logged_in() )
463
+ $redirect = ( isset( $opt['_um_redirect'] ) && !empty( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : site_url();
464
+ $redirect = $ultimatemember->access->set_referer( $redirect, "categories_1" );
465
+ $ultimatemember->access->redirect_handler = $redirect;
466
  if ( !is_user_logged_in() )
467
  $ultimatemember->access->allow_access = true;
468
 
470
 
471
  case 2:
472
 
473
+ if ( ! is_user_logged_in() ){
474
+
475
+ $redirect = ( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : um_get_core_page('login');
476
+ $redirect = $ultimatemember->access->set_referer( $redirect, "categories_2a" );
477
+
478
+ $ultimatemember->access->redirect_handler = $redirect;
479
+ }
480
 
481
  if ( is_user_logged_in() && isset( $opt['_um_roles'] ) && !empty( $opt['_um_roles'] ) ){
482
  if ( !in_array( um_user('role'), $opt['_um_roles'] ) ) {
483
+ $redirect = null;
484
+ if ( is_user_logged_in() ){
485
+ $redirect = ( isset( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : site_url();
486
+ }
487
 
488
+ if ( !is_user_logged_in() ){
489
+ $redirect = um_get_core_page('login');
490
+ }
491
 
492
+ $redirect = $ultimatemember->access->set_referer( $redirect, "categories_2b" );
493
+ $ultimatemember->access->redirect_handler = $redirect;
494
  }
495
  }
496
 
524
  ! get_post_type() ||
525
  ! isset( $post->ID ) ||
526
  is_home() ||
527
+ is_front_page() ||
528
+ is_404()
529
  ) {
530
 
531
  return;
539
  $args = $ultimatemember->access->get_meta( $um_post_id );
540
  extract( $args );
541
 
542
+ // Check for parent page's custom access settings
543
+ if ( !isset( $args['custom_access_settings'] ) || $args['custom_access_settings'] == 0 ) {
 
 
 
544
 
545
+ $um_post_id = apply_filters('um_access_control_for_parent_posts', $um_post_id );
 
546
 
547
+ $args = $ultimatemember->access->get_meta( $um_post_id );
548
+ extract( $args );
 
 
549
 
550
+ }
 
 
 
551
 
552
+ $post_type = get_post_type( $post->ID );
553
+
554
+ // post's category restriction
555
+ if ( $post_type != 'page' && isset( $args['custom_access_settings'] ) && $args['custom_access_settings'] == 0 ) {
556
+
557
+ $categories = get_the_category( $post->ID );
558
+ foreach( $categories as $cat ){
559
+
560
+ $opt = get_option("category_{$cat->term_id}");
561
+
562
+ if ( isset( $opt['_um_accessible'] ) ) {
563
+ switch( $opt['_um_accessible'] ) {
564
+
565
+ case 0: // Open to everyone
566
  $ultimatemember->access->allow_access = true;
567
+ $ultimatemember->access->redirect_handler = false; // open to everyone
568
+ break;
569
 
570
+ case 1: // Logged out users only
571
+
572
+ if ( is_user_logged_in() ){
573
+ $redirect = ( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : site_url();
574
+ $redirect = $ultimatemember->access->set_referer( $redirect, "page_cat_1a_t{$cat->term_id}_pt{$post_type}" );
575
+ $ultimatemember->access->redirect_handler = $redirect;
576
+ $ultimatemember->access->allow_access = false;
577
+ }
578
 
579
+ if ( !is_user_logged_in() ){
580
+ $ultimatemember->access->allow_access = true;
581
+ }
 
582
 
583
+ break;
 
 
584
 
585
+ case 2: // Logged in users only
586
 
587
+ if ( ! is_user_logged_in() ){
 
 
588
 
589
+ $redirect = ( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : um_get_core_page('login');
 
 
 
590
 
591
+ $redirect = $ultimatemember->access->set_referer( $redirect, "page_cat_2a_t{$cat->term_id}_pt{$post_type}" );
592
+ $ultimatemember->access->redirect_handler = $redirect;
593
+
594
+ $ultimatemember->access->allow_access = false;
595
  }
596
 
597
+ if ( is_user_logged_in() ){
598
+
599
+ if( isset( $opt['_um_roles'] ) && !empty( $opt['_um_roles'] ) ){
600
 
601
+ if ( in_array( um_user('role'), $opt['_um_roles'] ) ) {
602
 
603
+ $ultimatemember->access->allow_access = true;
604
+
605
+ }else{
606
 
607
+ $redirect = ( isset( $opt['_um_redirect'] ) && ! empty( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : site_url();
608
+ $redirect = $ultimatemember->access->set_referer( $redirect, "page_cat_2b_t{$cat->term_id}_pt{$post_type}" );
609
+ $ultimatemember->access->redirect_handler = $redirect;
610
+
611
+ $ultimatemember->access->allow_access = false;
612
+
613
+ }
614
 
615
+ }else{ // if allowed all roles
616
+ $ultimatemember->access->allow_access = true;
617
+ }
618
 
619
+ }
620
+
621
+ }
622
 
 
 
623
 
624
+ } // end if isset( $opt['_um_accessible'] )
 
 
625
 
626
+ // if one of the categories has enabled restriction, apply its settings to the current post
627
+ if( $ultimatemember->access->allow_access == false ){
628
+ return;
629
+ }
630
 
631
+ } // end foreach
632
+ }
633
 
634
+ // post restriction
635
+ if ( isset( $args['custom_access_settings'] ) && $args['custom_access_settings'] == 1 ) {
636
+
637
+ $redirect_to = null;
638
 
639
+ if ( !isset( $accessible ) ) return;
640
 
641
+ switch( $accessible ) {
 
 
642
 
643
+ case 0:
644
+ $ultimatemember->access->allow_access = true;
645
+ $ultimatemember->access->redirect_handler = false; // open to everyone
646
 
647
+ break;
648
 
649
+ case 1:
 
 
 
 
650
 
651
+ $redirect_to = esc_url( $access_redirect2 );
652
+
653
+ if ( is_user_logged_in() ){
654
+ $ultimatemember->access->allow_access = false;
655
+ }
656
 
657
+ if ( ! is_user_logged_in() ){
658
+ $ultimatemember->access->allow_access = true;
659
+ }
660
+
661
+ if( ! empty( $redirect_to ) ){
662
+ $redirect_to = $ultimatemember->access->set_referer( $redirect_to, "post_1a" );
663
+ $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
664
  }else{
665
+ if ( ! is_user_logged_in() ){
666
+ $redirect_to = um_get_core_page("login");
667
+ }else{
668
+ $redirect_to = um_get_core_page("user");
669
+ }
670
+
671
+ $redirect_to = $ultimatemember->access->set_referer( $redirect_to, "post_1b" );
672
+ $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
673
  }
 
674
 
675
 
676
+ break;
677
 
678
+ case 2:
679
 
680
+ if ( ! is_user_logged_in() ){
681
 
682
+ if ( empty( $access_redirect ) ) {
683
+ $access_redirect = um_get_core_page('login');
684
+ }
685
+
686
+ $access_redirect = $ultimatemember->access->set_referer( $access_redirect, "post_2a" );
687
+
688
+ $redirect_to = esc_url( $access_redirect );
689
  }
 
 
 
690
 
691
+ if ( is_user_logged_in() && isset( $access_roles ) && !empty( $access_roles ) ){
692
+ $access_roles = unserialize( $access_roles );
693
+ $access_roles = array_filter($access_roles);
694
 
695
+ if ( !empty( $access_roles ) && !in_array( um_user('role'), $access_roles ) ) {
696
+ if ( !$access_redirect ) {
697
+ if ( is_user_logged_in() ) {
698
+ $access_redirect = esc_url( site_url() );
699
+ } else {
700
+ $access_redirect = esc_url( um_get_core_page('login') );
701
+ }
702
  }
703
+ $access_redirect = $ultimatemember->access->set_referer( $access_redirect, "post_2b" );
704
+ $redirect_to = esc_url( $access_redirect );
705
  }
 
706
  }
707
+
708
+ $ultimatemember->access->redirect_handler = esc_url( $redirect_to );
709
+
710
+ break;
 
711
 
712
+ }
713
  }
714
 
715
+ if( um_is_core_page('user') && ! is_user_logged_in() && ! empty( $access_redirect ) ){
716
  $ultimatemember->access->allow_access = false;
717
+ $access_redirect = $ultimatemember->access->set_referer( $access_redirect, "user_page" );
718
  $ultimatemember->access->redirect_handler = esc_url( $access_redirect );
719
  wp_redirect( $ultimatemember->access->redirect_handler );
720
  exit;
core/um-actions-account.php CHANGED
@@ -129,7 +129,10 @@
129
  $ultimatemember->account->current_tab = 'general';
130
 
131
  // change password
132
- if ( $_POST['current_user_password'] != '' || $_POST['user_password'] != '' || $_POST['confirm_user_password'] != '') {
 
 
 
133
  if ( $_POST['current_user_password'] == '' || ! wp_check_password( $_POST['current_user_password'], $user->data->user_pass, $user->data->ID ) ) {
134
 
135
  $ultimatemember->form->add_error('current_user_password', __('This is not your password','ultimatemember') );
129
  $ultimatemember->account->current_tab = 'general';
130
 
131
  // change password
132
+ if ( ( isset( $_POST['current_user_password'] ) && $_POST['current_user_password'] != '' ) ||
133
+ ( isset( $_POST['user_password'] ) && $_POST['user_password'] != '' ) ||
134
+ ( isset( $_POST['confirm_user_password'] ) && $_POST['confirm_user_password'] != '') ) {
135
+
136
  if ( $_POST['current_user_password'] == '' || ! wp_check_password( $_POST['current_user_password'], $user->data->user_pass, $user->data->ID ) ) {
137
 
138
  $ultimatemember->form->add_error('current_user_password', __('This is not your password','ultimatemember') );
core/um-actions-form.php CHANGED
@@ -443,10 +443,16 @@
443
  }
444
 
445
  if ( isset( $args['description'] ) ) {
 
446
  $max_chars = um_get_option('profile_bio_maxchars');
447
- if ( strlen( utf8_decode( $args['description'] ) ) > $max_chars && $max_chars ) {
448
- $ultimatemember->form->add_error('description', sprintf(__('Your user description must contain less than %s characters','ultimatemember'), $max_chars ) );
 
 
 
 
449
  }
 
450
  }
451
 
452
  } // end if ( isset in args array )
443
  }
444
 
445
  if ( isset( $args['description'] ) ) {
446
+
447
  $max_chars = um_get_option('profile_bio_maxchars');
448
+ $profile_show_bio = um_get_option('profile_show_bio');
449
+
450
+ if( $profile_show_bio ){
451
+ if ( strlen( utf8_decode( $args['description'] ) ) > $max_chars && $max_chars ) {
452
+ $ultimatemember->form->add_error('description', sprintf(__('Your user description must contain less than %s characters','ultimatemember'), $max_chars ) );
453
+ }
454
  }
455
+
456
  }
457
 
458
  } // end if ( isset in args array )
core/um-actions-password.php CHANGED
@@ -98,13 +98,19 @@
98
 
99
  if ( $live_timestamp - $form_timestamp < 3 && um_get_option('enable_timebot') == 1 )
100
  wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!') );
 
 
101
 
102
- if ( strlen(trim( $_POST['username_b'] ) ) == 0 ) {
 
 
 
 
 
 
103
  $ultimatemember->form->add_error('username_b', __('Please provide your username or email','ultimatemember') );
104
  }
105
 
106
- $user = $_POST['username_b'];
107
-
108
  if ( ( !is_email( $user ) && !username_exists( $user ) ) || ( is_email( $user ) && !email_exists( $user ) ) ) {
109
  $ultimatemember->form->add_error('username_b', __('We can\'t find an account registered with that address or username','ultimatemember') );
110
  } else {
@@ -155,7 +161,7 @@
155
  if ( $live_timestamp - $form_timestamp < 3 && um_get_option('enable_timebot') == 1 )
156
  wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!') );
157
 
158
- if ( !$args['user_password'] ) {
159
  $ultimatemember->form->add_error('user_password', __('You must enter a new password','ultimatemember') );
160
  }
161
 
@@ -175,11 +181,11 @@
175
 
176
  }
177
 
178
- if ( !$args['confirm_user_password'] ) {
179
  $ultimatemember->form->add_error('confirm_user_password', __('You must confirm your new password','ultimatemember') );
180
  }
181
 
182
- if ( $args['user_password'] != $args['confirm_user_password'] ) {
183
  $ultimatemember->form->add_error('confirm_user_password', __('Your passwords do not match','ultimatemember') );
184
  }
185
 
98
 
99
  if ( $live_timestamp - $form_timestamp < 3 && um_get_option('enable_timebot') == 1 )
100
  wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!') );
101
+
102
+ $user = "";
103
 
104
+ foreach ( $_POST as $key => $val ) {
105
+ if( strstr( $key, "username_b") ){
106
+ $user = trim( $val );
107
+ }
108
+ }
109
+
110
+ if ( empty( $user ) ) {
111
  $ultimatemember->form->add_error('username_b', __('Please provide your username or email','ultimatemember') );
112
  }
113
 
 
 
114
  if ( ( !is_email( $user ) && !username_exists( $user ) ) || ( is_email( $user ) && !email_exists( $user ) ) ) {
115
  $ultimatemember->form->add_error('username_b', __('We can\'t find an account registered with that address or username','ultimatemember') );
116
  } else {
161
  if ( $live_timestamp - $form_timestamp < 3 && um_get_option('enable_timebot') == 1 )
162
  wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!') );
163
 
164
+ if ( isset( $args['user_password'] ) && ! empty( $args['user_password'] ) ) {
165
  $ultimatemember->form->add_error('user_password', __('You must enter a new password','ultimatemember') );
166
  }
167
 
181
 
182
  }
183
 
184
+ if ( isset( $args['confirm_user_password'] ) && ! empty( $args['confirm_user_password'] ) ) {
185
  $ultimatemember->form->add_error('confirm_user_password', __('You must confirm your new password','ultimatemember') );
186
  }
187
 
188
+ if ( isset( $args['user_password'] ) && isset( $args['confirm_user_password'] ) && $args['user_password'] != $args['confirm_user_password'] ) {
189
  $ultimatemember->form->add_error('confirm_user_password', __('Your passwords do not match','ultimatemember') );
190
  }
191
 
core/um-actions-profile.php CHANGED
@@ -118,9 +118,10 @@
118
  do_action('um_after_user_updated', um_user('ID') );
119
  do_action('um_after_user_upload', um_user('ID') );
120
  do_action('um_user_after_updating_profile', $to_update );
 
121
 
122
  if ( !isset( $args['is_signup'] ) ) {
123
- $url = $ultimatemember->permalinks->profile_url();
124
  exit( wp_redirect( um_edit_my_profile_cancel_uri( $url ) ) );
125
  }
126
 
118
  do_action('um_after_user_updated', um_user('ID') );
119
  do_action('um_after_user_upload', um_user('ID') );
120
  do_action('um_user_after_updating_profile', $to_update );
121
+ do_action('um_update_profile_full_name', $to_update );
122
 
123
  if ( !isset( $args['is_signup'] ) ) {
124
+ $url = $ultimatemember->permalinks->profile_url( true );
125
  exit( wp_redirect( um_edit_my_profile_cancel_uri( $url ) ) );
126
  }
127
 
core/um-actions-register.php CHANGED
@@ -70,7 +70,7 @@
70
 
71
  $unique_userID = $ultimatemember->query->count_users() + 1;
72
 
73
- if ( ! isset( $user_login ) ) {
74
  $user_login = 'user' . $unique_userID;
75
  }
76
 
@@ -84,7 +84,8 @@
84
 
85
 
86
  if( ! isset( $user_email ) ) {
87
- $user_email = 'nobody' . $unique_userID . '@' . get_bloginfo('name');
 
88
  }
89
 
90
 
@@ -135,6 +136,8 @@
135
  do_action('um_post_registration_save', $user_id, $args);
136
 
137
  do_action('um_post_registration_listener', $user_id, $args);
 
 
138
 
139
  do_action('um_post_registration', $user_id, $args);
140
 
@@ -197,6 +200,7 @@
197
  if ( $status == 'approved' ) {
198
 
199
  $ultimatemember->user->auto_login( $user_id );
 
200
 
201
  do_action('um_registration_after_auto_login', $user_id );
202
 
@@ -219,6 +223,7 @@
219
  $url = $ultimatemember->permalinks->get_current_url();
220
  $url = add_query_arg( 'message', esc_attr( $status ), $url );
221
  $url = add_query_arg( 'uid', esc_attr( um_user('ID') ), $url );
 
222
 
223
  exit( wp_redirect( $url ) );
224
  }
@@ -272,6 +277,8 @@
272
  $role = um_get_option('default_role');
273
  }
274
 
 
 
275
  $role = apply_filters('um_register_hidden_role_field', $role );
276
  if( $role ){
277
  echo '<input type="hidden" name="role" id="role" value="' . $role . '" />';
70
 
71
  $unique_userID = $ultimatemember->query->count_users() + 1;
72
 
73
+ if ( ! isset( $user_login ) || strlen( $user_login ) > 30 ) {
74
  $user_login = 'user' . $unique_userID;
75
  }
76
 
84
 
85
 
86
  if( ! isset( $user_email ) ) {
87
+ $site_url = @$_SERVER['SERVER_NAME'];
88
+ $user_email = 'nobody' . $unique_userID . '@' . $site_url;
89
  }
90
 
91
 
136
  do_action('um_post_registration_save', $user_id, $args);
137
 
138
  do_action('um_post_registration_listener', $user_id, $args);
139
+
140
+ do_action('um_update_profile_full_name', $args );
141
 
142
  do_action('um_post_registration', $user_id, $args);
143
 
200
  if ( $status == 'approved' ) {
201
 
202
  $ultimatemember->user->auto_login( $user_id );
203
+ $ultimatemember->permalinks->profile_url( true );
204
 
205
  do_action('um_registration_after_auto_login', $user_id );
206
 
223
  $url = $ultimatemember->permalinks->get_current_url();
224
  $url = add_query_arg( 'message', esc_attr( $status ), $url );
225
  $url = add_query_arg( 'uid', esc_attr( um_user('ID') ), $url );
226
+ $url = add_query_arg( 'um_form_id', esc_attr( $form_id ), $url );
227
 
228
  exit( wp_redirect( $url ) );
229
  }
277
  $role = um_get_option('default_role');
278
  }
279
 
280
+ if( empty( $role ) ) return;
281
+
282
  $role = apply_filters('um_register_hidden_role_field', $role );
283
  if( $role ){
284
  echo '<input type="hidden" name="role" id="role" value="' . $role . '" />';
core/um-actions-save-profile.php CHANGED
@@ -7,46 +7,6 @@
7
  function um_update_profile_full_name( $changes ) {
8
  global $ultimatemember;
9
 
10
- if ( isset( $changes['first_name'] ) && isset( $changes['last_name'] ) ) {
11
-
12
- $full_name = $ultimatemember->user->profile['display_name'];
13
- $full_name = $ultimatemember->validation->safe_name_in_url( $full_name );
14
-
15
- /* duplicate or not */
16
- if ( $ultimatemember->user->user_has_metadata( 'full_name', $full_name ) ) {
17
-
18
- $duplicates = $ultimatemember->user->user_has_metadata( 'full_name', $full_name );
19
- if ( !get_option("um_duplicate_name_{$full_name}") ) {
20
-
21
- update_option("um_duplicate_name_{$full_name}", $duplicates );
22
- $full_name = $full_name . '.' . $duplicates;
23
-
24
- } else {
25
-
26
- if ( um_user('_duplicate_id') ) {
27
- $duplicates = um_user('_duplicate_id');
28
- } else {
29
- $duplicates = get_option("um_duplicate_name_{$full_name}") + 1;
30
- update_option("um_duplicate_name_{$full_name}", $duplicates );
31
- update_user_meta( $ultimatemember->user->id, '_duplicate_id', $duplicates );
32
- }
33
-
34
- $full_name = $full_name . '.' . $duplicates;
35
-
36
- }
37
-
38
- } else {
39
-
40
- if ( um_user('_duplicate_id') && $full_name != str_replace( '.' . um_user('_duplicate_id'), '' , um_user('full_name') ) ) {
41
- $duplicates = um_user('_duplicate_id');
42
- $full_name = str_replace( '.' . um_user('_duplicate_id'), '', $full_name);
43
- }
44
- }
45
-
46
- update_user_meta( $ultimatemember->user->id, 'full_name', $full_name );
47
-
48
-
49
- }
50
 
51
  // Sync display name changes
52
  $option = um_get_option('display_name');
@@ -78,6 +38,29 @@
78
  }
79
 
80
  if ( isset( $update_name ) ) {
81
- wp_update_user( array( 'ID' => $user_id, 'display_name' => $update_name ) );
 
 
 
 
 
 
 
82
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
7
  function um_update_profile_full_name( $changes ) {
8
  global $ultimatemember;
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  // Sync display name changes
12
  $option = um_get_option('display_name');
38
  }
39
 
40
  if ( isset( $update_name ) ) {
41
+
42
+ $return = wp_update_user( array( 'ID' => $user_id, 'display_name' => $update_name ) );
43
+
44
+ if( is_wp_error( $return ) ) {
45
+ wp_die( $return->get_error_message() );
46
+ }
47
+
48
+
49
  }
50
+
51
+ if ( isset( $changes['first_name'] ) && isset( $changes['last_name'] ) ) {
52
+
53
+ $full_name = $ultimatemember->user->profile['display_name'];
54
+ $full_name = $ultimatemember->validation->safe_name_in_url( $full_name );
55
+
56
+ update_user_meta( $ultimatemember->user->id, 'full_name', $full_name );
57
+
58
+
59
+ }
60
+
61
+ // regenerate slug
62
+ $ultimatemember->permalinks->profile_url( true );
63
+
64
+
65
+
66
  }
core/um-actions-user.php CHANGED
@@ -59,6 +59,9 @@
59
 
60
  do_action('um_update_profile_full_name', $_POST);
61
 
 
 
 
62
  }
63
 
64
  }
59
 
60
  do_action('um_update_profile_full_name', $_POST);
61
 
62
+ // generate profile slug
63
+ $ultimatemember->permalinks->profile_url( true );
64
+
65
  }
66
 
67
  }
core/um-builtin.php CHANGED
@@ -633,7 +633,7 @@ class UM_Builtin {
633
 
634
  'last_login' => array(
635
  'title' => __('Last Login','ultimatemember'),
636
- 'metakey' => 'last_login',
637
  'type' => 'text',
638
  'label' => __('Last Login','ultimatemember'),
639
  'required' => 0,
633
 
634
  'last_login' => array(
635
  'title' => __('Last Login','ultimatemember'),
636
+ 'metakey' => '_um_last_login',
637
  'type' => 'text',
638
  'label' => __('Last Login','ultimatemember'),
639
  'required' => 0,
core/um-enqueue.php CHANGED
@@ -52,7 +52,7 @@ class UM_Enqueue {
52
  $c_url = $ultimatemember->permalinks->get_current_url( get_option('permalink_structure') );
53
 
54
  foreach( $exclude as $match ) {
55
- if ( strstr( $c_url, untrailingslashit( $match ) ) ) {
56
  return;
57
  }
58
  }
52
  $c_url = $ultimatemember->permalinks->get_current_url( get_option('permalink_structure') );
53
 
54
  foreach( $exclude as $match ) {
55
+ if ( ! empty( $c_url ) && strstr( $c_url, untrailingslashit( $match ) ) ) {
56
  return;
57
  }
58
  }
core/um-fields.php CHANGED
@@ -351,7 +351,7 @@ class UM_Fields {
351
  }
352
 
353
  if ( isset($data['icon']) && $data['icon'] && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
354
- $classes .= 'um-iconed';
355
  }
356
 
357
  if ($add) {
@@ -366,6 +366,7 @@ class UM_Fields {
366
  ***/
367
  function field_value( $key, $default = false, $data = null ) {
368
  global $ultimatemember;
 
369
 
370
  if ( isset($_SESSION) && isset($_SESSION['um_social_profile'][$key]) && isset( $this->set_mode ) && $this->set_mode == 'register' )
371
  return $_SESSION['um_social_profile'][$key];
@@ -496,6 +497,10 @@ class UM_Fields {
496
  }
497
 
498
  $um_user_value = um_user( $key );
 
 
 
 
499
 
500
  if ( $um_user_value == $value ) {
501
  return true;
@@ -505,7 +510,15 @@ class UM_Fields {
505
  return true;
506
  }
507
 
508
-
 
 
 
 
 
 
 
 
509
  } else {
510
 
511
  if ( isset($data['default']) && $data['default'] == $value ) {
@@ -910,7 +923,8 @@ class UM_Fields {
910
  global $ultimatemember;
911
 
912
  $output = null;
913
-
 
914
  // get whole field data
915
  if ( isset( $data ) && is_array( $data ) ) {
916
  $data = $this->get_field($key);
@@ -1601,23 +1615,23 @@ class UM_Fields {
1601
 
1602
  // role field
1603
  if ( $form_key == 'role' ) {
1604
-
1605
  global $wpdb;
1606
  foreach($options as $key => $val ) {
1607
  $val = (string) $val;
1608
  $val = trim( $val );
1609
  $post_id = $wpdb->get_var(
1610
- $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'um_role' AND post_title = %s", $val)
1611
  );
1612
  $_role = get_post( $post_id );
1613
- $new_roles[ $_role->post_name ] = $_role->post_title;
 
 
1614
  wp_reset_postdata();
1615
  }
1616
 
1617
  $options = $new_roles;
1618
  }
1619
 
1620
-
1621
  // add an empty option!
1622
  $output .= '<option value=""></option>';
1623
 
@@ -1789,7 +1803,9 @@ class UM_Fields {
1789
  foreach($options as $rkey => $val ) {
1790
  $val = (string) $val;
1791
  $val = trim( $val );
1792
- $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'um_role' AND post_title = '$val'");
 
 
1793
  $_role = get_post($post_id);
1794
  $new_roles[$_role->post_name] = $_role->post_title;
1795
  wp_reset_postdata();
351
  }
352
 
353
  if ( isset($data['icon']) && $data['icon'] && isset( $this->field_icons ) && $this->field_icons == 'field' ) {
354
+ $classes .= 'um-iconed ';
355
  }
356
 
357
  if ($add) {
366
  ***/
367
  function field_value( $key, $default = false, $data = null ) {
368
  global $ultimatemember;
369
+
370
 
371
  if ( isset($_SESSION) && isset($_SESSION['um_social_profile'][$key]) && isset( $this->set_mode ) && $this->set_mode == 'register' )
372
  return $_SESSION['um_social_profile'][$key];
497
  }
498
 
499
  $um_user_value = um_user( $key );
500
+
501
+ if( $key == 'role' ){
502
+ $um_user_value = strtolower( $um_user_value );
503
+ }
504
 
505
  if ( $um_user_value == $value ) {
506
  return true;
510
  return true;
511
  }
512
 
513
+ if ( is_array( $um_user_value ) ){
514
+ foreach( $um_user_value as $u) {
515
+ if( $u == html_entity_decode( $value ) ){
516
+ return true;
517
+ }
518
+ }
519
+ }
520
+
521
+
522
  } else {
523
 
524
  if ( isset($data['default']) && $data['default'] == $value ) {
923
  global $ultimatemember;
924
 
925
  $output = null;
926
+ $disabled = '';
927
+
928
  // get whole field data
929
  if ( isset( $data ) && is_array( $data ) ) {
930
  $data = $this->get_field($key);
1615
 
1616
  // role field
1617
  if ( $form_key == 'role' ) {
 
1618
  global $wpdb;
1619
  foreach($options as $key => $val ) {
1620
  $val = (string) $val;
1621
  $val = trim( $val );
1622
  $post_id = $wpdb->get_var(
1623
+ $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'um_role' AND post_name = %s OR post_title = %s", $key, $val )
1624
  );
1625
  $_role = get_post( $post_id );
1626
+ if( isset( $_role->post_title ) ){
1627
+ $new_roles[ $_role->post_name ] = $_role->post_title;
1628
+ }
1629
  wp_reset_postdata();
1630
  }
1631
 
1632
  $options = $new_roles;
1633
  }
1634
 
 
1635
  // add an empty option!
1636
  $output .= '<option value=""></option>';
1637
 
1803
  foreach($options as $rkey => $val ) {
1804
  $val = (string) $val;
1805
  $val = trim( $val );
1806
+ $post_id = $wpdb->get_var(
1807
+ $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'um_role' AND post_name = %s OR post_title = %s", $rkey, $val )
1808
+ );
1809
  $_role = get_post($post_id);
1810
  $new_roles[$_role->post_name] = $_role->post_title;
1811
  wp_reset_postdata();
core/um-filters-arguments.php CHANGED
@@ -31,7 +31,9 @@
31
  if ($ultimatemember->shortcodes->message_mode == true) {
32
  $args['template'] = 'message';
33
  um_fetch_user( $_REQUEST['uid'] );
 
34
  $ultimatemember->shortcodes->custom_message = um_user( um_user('status') . '_message' );
 
35
  um_reset_user();
36
  }
37
 
31
  if ($ultimatemember->shortcodes->message_mode == true) {
32
  $args['template'] = 'message';
33
  um_fetch_user( $_REQUEST['uid'] );
34
+
35
  $ultimatemember->shortcodes->custom_message = um_user( um_user('status') . '_message' );
36
+
37
  um_reset_user();
38
  }
39
 
core/um-filters-fields.php CHANGED
@@ -87,8 +87,11 @@
87
  *** @last login date
88
  ***/
89
  add_filter('um_profile_field_filter_hook__last_login', 'um_profile_field_filter_hook__last_login', 99, 2);
 
90
  function um_profile_field_filter_hook__last_login( $value, $data ) {
 
91
  $value = sprintf( __('Last login: %s','ultimatemember'), um_user_last_login( um_user('ID') ) );
 
92
  return $value;
93
  }
94
 
87
  *** @last login date
88
  ***/
89
  add_filter('um_profile_field_filter_hook__last_login', 'um_profile_field_filter_hook__last_login', 99, 2);
90
+ add_filter('um_profile_field_filter_hook___um_last_login', 'um_profile_field_filter_hook__last_login', 99, 2);
91
  function um_profile_field_filter_hook__last_login( $value, $data ) {
92
+
93
  $value = sprintf( __('Last login: %s','ultimatemember'), um_user_last_login( um_user('ID') ) );
94
+
95
  return $value;
96
  }
97
 
core/um-filters-members.php CHANGED
@@ -16,14 +16,21 @@
16
  extract( $args );
17
 
18
  $query = $ultimatemember->permalinks->get_query_array();
 
19
 
20
  foreach( $ultimatemember->members->core_search_fields as $key ) {
21
 
22
- if ( isset( $query[$key] ) && ! empty( $query[$key] ) ) {
23
- $query_args['search'] = '*' . trim($query[$key]) . '*';
 
 
 
24
  }
25
  }
26
 
 
 
 
27
  return $query_args;
28
  }
29
 
@@ -36,7 +43,7 @@
36
 
37
  $query_args['meta_query']['relation'] = 'AND';
38
 
39
- if ( !um_user_can('can_edit_everyone') ) {
40
 
41
  $query_args['meta_query'][] = array(
42
  'key' => 'account_status',
@@ -46,12 +53,22 @@
46
 
47
  }
48
 
49
- $query_args['meta_query'][] = array(
50
- 'key' => 'hide_in_members',
51
- 'value' => '',
52
- 'compare' => 'NOT EXISTS'
53
- );
54
-
 
 
 
 
 
 
 
 
 
 
55
  return $query_args;
56
  }
57
 
@@ -77,40 +94,36 @@
77
 
78
  if(in_array($field, array('members_page'))) continue;
79
 
80
- if ( in_array( $field, array('gender') ) ) {
81
- $operator = '=';
82
- } else {
83
- $operator = 'LIKE';
84
- }
85
-
86
- $arr_filter_field_types = array('checkbox','multiselect');
87
- $arr_field_types = apply_filters('um_search_filter_field_types', $arr_filter_field_types );
88
 
89
- if ( in_array( $ultimatemember->fields->get_field_type( $field ), $arr_field_types ) ) {
90
- $operator = 'LIKE';
91
- if( ! empty( $value ) ){
92
- $value = serialize( strval( $value ) );
93
- }
94
- }
95
-
96
- if( in_array( $ultimatemember->fields->get_field_type( $field ) , array('select') ) ){
97
- $operator = '=';
98
- }
99
-
100
  if ( $value && $field != 'um_search' && $field != 'page_id' ) {
101
 
102
- if ( !in_array( $field, $ultimatemember->members->core_search_fields ) ) {
 
 
103
 
104
- if ( strstr($field, 'role_' ) ) {
105
- $field = 'role';
106
- $operator = '=';
107
- }
108
 
109
  $query_args['meta_query'][] = array(
110
- 'key' => $field,
111
- 'value' => trim($value),
112
- 'compare' => $operator,
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  );
 
 
114
 
115
  }
116
 
@@ -121,6 +134,8 @@
121
 
122
  }
123
 
 
 
124
  // allow filtering
125
  $query_args = apply_filters('um_query_args_filter', $query_args );
126
 
@@ -146,26 +161,42 @@
146
  $query_args['meta_query']['relation'] = 'AND';
147
 
148
  // must have a profile photo
149
- if ( $has_profile_photo == 1 && ! um_get_option('use_gravatars') ) {
150
- $query_args['meta_query'][] = array(
151
- 'relation' => 'OR',
152
- array(
153
- 'key' => 'synced_profile_photo', // addons
154
- 'value' => '',
155
- 'compare' => '!='
156
- ),
157
- array(
158
- 'key' => 'profile_photo', // from upload form
159
- 'value' => '',
160
- 'compare' => '!='
161
- ),
162
- array(
163
- 'key' => 'synced_gravatar_hashed_id', // gravatar
164
- 'value' => '',
165
- 'compare' => '!='
166
- )
167
-
168
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  }
170
 
171
  // must have a cover photo
@@ -237,8 +268,7 @@
237
 
238
  }
239
 
240
-
241
- return $query_args;
242
  }
243
 
244
  /***
@@ -261,7 +291,7 @@
261
  function um_modify_sortby_randomly( $query ){
262
 
263
  if( um_is_session_started() === FALSE ){
264
- session_start();
265
  }
266
 
267
  // Reset seed on load of initial
@@ -301,7 +331,7 @@
301
  } else {
302
  $result['no_users'] = 0;
303
  }
304
-
305
  return $result;
306
  }
307
 
16
  extract( $args );
17
 
18
  $query = $ultimatemember->permalinks->get_query_array();
19
+ $arr_columns = array();
20
 
21
  foreach( $ultimatemember->members->core_search_fields as $key ) {
22
 
23
+ if ( isset( $query[ $key ] ) && ! empty( $query[ $key ] ) ) {
24
+ $arr_columns[] = $key;
25
+ $query_args['search'] = '*' . $query[ $key ] .'*';
26
+
27
+
28
  }
29
  }
30
 
31
+ if( ! empty( $arr_columns ) ){
32
+ $query_args['search_columns'] = $arr_columns;
33
+ }
34
  return $query_args;
35
  }
36
 
43
 
44
  $query_args['meta_query']['relation'] = 'AND';
45
 
46
+ if ( ! um_user_can('can_edit_everyone') ) {
47
 
48
  $query_args['meta_query'][] = array(
49
  'key' => 'account_status',
53
 
54
  }
55
 
56
+ if ( ! um_user_can('can_edit_everyone') ) {
57
+ $query_args['meta_query'][] = array(
58
+ "relation" => "OR",
59
+ array(
60
+ 'key' => 'hide_in_members',
61
+ 'value' => '',
62
+ 'compare' => 'NOT EXISTS'
63
+ ),
64
+ array(
65
+ 'key' => 'hide_in_members',
66
+ 'value' => 'Yes',
67
+ 'compare' => 'NOT LIKE'
68
+ )
69
+ );
70
+ }
71
+
72
  return $query_args;
73
  }
74
 
94
 
95
  if(in_array($field, array('members_page'))) continue;
96
 
97
+ $serialize_value = serialize( strval( $value ) );
 
 
 
 
 
 
 
98
 
 
 
 
 
 
 
 
 
 
 
 
99
  if ( $value && $field != 'um_search' && $field != 'page_id' ) {
100
 
101
+ if( strstr( $field, 'role_') ){
102
+ $field = 'role';
103
+ }
104
 
105
+ if ( !in_array( $field, $ultimatemember->members->core_search_fields ) ) {
 
 
 
106
 
107
  $query_args['meta_query'][] = array(
108
+ array(
109
+ 'key' => $field,
110
+ 'value' => trim( $value ),
111
+ 'compare' => '=',
112
+ ),
113
+ array(
114
+ 'key' => $field,
115
+ 'value' => trim( $value ),
116
+ 'compare' => 'LIKE',
117
+ ),
118
+ array(
119
+ 'key' => $field,
120
+ 'value' => trim( $serialize_value ),
121
+ 'compare' => 'LIKE',
122
+ ),
123
+ 'relation' => 'OR',
124
  );
125
+
126
+
127
 
128
  }
129
 
134
 
135
  }
136
 
137
+
138
+
139
  // allow filtering
140
  $query_args = apply_filters('um_query_args_filter', $query_args );
141
 
161
  $query_args['meta_query']['relation'] = 'AND';
162
 
163
  // must have a profile photo
164
+ if ( $has_profile_photo == 1 ) {
165
+ if( um_get_option('use_gravatars') ){
166
+ $query_args['meta_query'][] = array(
167
+ 'relation' => 'OR',
168
+ array(
169
+ 'key' => 'synced_profile_photo', // addons
170
+ 'value' => '',
171
+ 'compare' => '!='
172
+ ),
173
+ array(
174
+ 'key' => 'profile_photo', // from upload form
175
+ 'value' => '',
176
+ 'compare' => '!='
177
+ ),
178
+ array(
179
+ 'key' => 'synced_gravatar_hashed_id', // gravatar
180
+ 'value' => '',
181
+ 'compare' => '!='
182
+ )
183
+
184
+ );
185
+ }else{
186
+ $query_args['meta_query'][] = array(
187
+ 'relation' => 'OR',
188
+ array(
189
+ 'key' => 'synced_profile_photo', // addons
190
+ 'value' => '',
191
+ 'compare' => '!='
192
+ ),
193
+ array(
194
+ 'key' => 'profile_photo', // from upload form
195
+ 'value' => '',
196
+ 'compare' => '!='
197
+ )
198
+ );
199
+ }
200
  }
201
 
202
  // must have a cover photo
268
 
269
  }
270
 
271
+ return $query_args;
 
272
  }
273
 
274
  /***
291
  function um_modify_sortby_randomly( $query ){
292
 
293
  if( um_is_session_started() === FALSE ){
294
+ @session_start();
295
  }
296
 
297
  // Reset seed on load of initial
331
  } else {
332
  $result['no_users'] = 0;
333
  }
334
+
335
  return $result;
336
  }
337
 
core/um-filters-profile.php CHANGED
@@ -49,7 +49,7 @@
49
  if( is_admin() )
50
  return $title;
51
 
52
- if ( $id == $ultimatemember->permalinks->core['user'] ) {
53
  if ( um_is_core_page('user') && um_get_requested_user() ) {
54
  $title = um_get_display_name( um_get_requested_user() );
55
  } else if ( um_is_core_page('user') && is_user_logged_in() ) {
49
  if( is_admin() )
50
  return $title;
51
 
52
+ if ( $id == $ultimatemember->permalinks->core['user'] && in_the_loop() ) {
53
  if ( um_is_core_page('user') && um_get_requested_user() ) {
54
  $title = um_get_display_name( um_get_requested_user() );
55
  } else if ( um_is_core_page('user') && is_user_logged_in() ) {
core/um-filters-user.php CHANGED
@@ -83,30 +83,34 @@
83
  global $wpdb;
84
 
85
  $permalink_base = um_get_option('permalink_base');
86
- $user_query = new WP_User_Query(
 
87
  array(
88
  'meta_query' => array(
89
  'relation' => 'AND',
90
  array(
91
- 'key' => 'um_user_profile_url_slug_name_'.$raw,
92
- ),
93
- array(
94
- 'key' => 'account_status',
95
- 'value' => 'awaiting_admin_review',
96
- 'compare' => '!='
97
  )
98
- )
99
- )
 
 
 
100
 
101
- );
102
- $result = current( $user_query->get_results() );
103
- $slugname = '';
 
104
 
105
- if( isset( $result->data->ID ) ){
106
- $slugname = get_user_meta( $result->data->ID, 'um_user_profile_url_slug_name_'.$raw, true );
107
- $value = $slugname;
 
108
  }
109
 
 
110
  $value = apply_filters("um_permalink_base_before_filter", $value );
111
  $raw_value = $value;
112
 
83
  global $wpdb;
84
 
85
  $permalink_base = um_get_option('permalink_base');
86
+
87
+ $user_query = new WP_User_Query(
88
  array(
89
  'meta_query' => array(
90
  'relation' => 'AND',
91
  array(
92
+ 'key' => 'um_user_profile_url_slug_'.$permalink_base,
93
+ 'value' => $raw,
94
+ 'compare' => '='
 
 
 
95
  )
96
+ ),
97
+ 'fields' => array('ID')
98
+ )
99
+
100
+ );
101
 
102
+ if( $user_query->total_users > 0 ){
103
+
104
+ $result = current( $user_query->get_results() );
105
+ $slugname = '';
106
 
107
+ if( isset( $result->ID ) ){
108
+ $slugname = get_user_meta( $result->ID, 'um_user_profile_url_slug_'.$permalink_base, true );
109
+ $value = $slugname;
110
+ }
111
  }
112
 
113
+
114
  $value = apply_filters("um_permalink_base_before_filter", $value );
115
  $raw_value = $value;
116
 
core/um-form.php CHANGED
@@ -34,9 +34,12 @@ class UM_Form {
34
  return 0;
35
  }
36
 
37
- /***
38
- *** @add errors
39
- ***/
 
 
 
40
  function add_error( $key, $error ) {
41
  if ( ! isset( $this->errors[ $key ] ) ){
42
 
@@ -46,18 +49,22 @@ class UM_Form {
46
  }
47
  }
48
 
49
- /***
50
- *** @has error
51
- ***/
 
 
 
52
  function has_error( $key ) {
53
  if ( isset($this->errors[$key]) )
54
  return true;
55
  return false;
56
  }
57
 
58
- /***
59
- *** @declare all fields
60
- ***/
 
61
  function field_declare(){
62
  global $ultimatemember;
63
  if ( isset( $ultimatemember->builtin->custom_fields ) ) {
@@ -67,9 +74,10 @@ class UM_Form {
67
  }
68
  }
69
 
70
- /***
71
- *** @Checks that we've a form
72
- ***/
 
73
  function form_init(){
74
  global $ultimatemember;
75
 
@@ -101,22 +109,35 @@ class UM_Form {
101
 
102
  $this->post_form = array_merge( $this->form_data, $this->post_form );
103
 
104
- $role = $this->assigned_role( $this->form_id );
105
-
106
  $secure_form_post = apply_filters('um_secure_form_post', true );
107
-
108
- if( $role && isset( $this->form_data['custom_fields'] ) && ! strstr( $this->form_data['custom_fields'], 'role_' ) && $secure_form_post ){ // has assigned role. Validate non-global forms
109
- if ( isset( $this->form_data['role'] ) && ( (boolean) $this->form_data['role'] ) && isset( $_POST['role'] ) && $_POST['role'] != $role ) {
 
 
 
 
 
 
 
 
 
 
 
110
  wp_die( __( 'This is not possible for security reasons.','ultimatemember') );
111
- } else {
112
- if ( isset( $_POST['role'] ) ) {
113
- if ( $role != $_POST['role'] ) {
114
- wp_die( __( 'This is not possible for security reasons.','ultimatemember') );
115
- }
116
- }
117
- }
118
- }
119
 
 
 
 
 
 
 
 
120
  if ( isset( $_POST[ $ultimatemember->honeypot ] ) && $_POST[ $ultimatemember->honeypot ] != '' ){
121
  wp_die('Hello, spam bot!');
122
  }
@@ -148,9 +169,12 @@ class UM_Form {
148
 
149
  }
150
 
151
- /***
152
- *** @Beautify form data
153
- ***/
 
 
 
154
  function beautify( $form ){
155
 
156
  if (isset($form['form_id'])){
@@ -172,12 +196,16 @@ class UM_Form {
172
  return $form;
173
  }
174
 
175
- /***
176
- *** @Display Form Type as Text
177
- ***/
178
- function display_form_type($mode, $post_id){
 
 
 
 
179
  $output = null;
180
- switch($mode){
181
  case 'login':
182
  $output = 'Login';
183
  break;
@@ -191,19 +219,66 @@ class UM_Form {
191
  return $output;
192
  }
193
 
 
 
 
 
 
194
  function assigned_role( $post_id ){
195
 
196
- $register_use_globals = get_post_meta( $post_id, '_um_register_use_globals', true);
 
 
 
197
 
198
- if( $register_use_globals == 1 ){
199
- $role = um_get_option('default_role');
200
- }else if( $register_use_globals == 0 ){
201
- $role = get_post_meta( $post_id, '_um_register_role', true );
202
  }
203
 
204
- if( ! $role ){
205
- $role = false;
206
  }
 
207
  return $role;
 
208
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  }
34
  return 0;
35
  }
36
 
37
+
38
+ /**
39
+ * Appends field errors
40
+ * @param string $key
41
+ * @param string $error
42
+ */
43
  function add_error( $key, $error ) {
44
  if ( ! isset( $this->errors[ $key ] ) ){
45
 
49
  }
50
  }
51
 
52
+
53
+ /**
54
+ * If a form has errors
55
+ * @param string $key
56
+ * @return boolean
57
+ */
58
  function has_error( $key ) {
59
  if ( isset($this->errors[$key]) )
60
  return true;
61
  return false;
62
  }
63
 
64
+
65
+ /**
66
+ * Declare all fields
67
+ */
68
  function field_declare(){
69
  global $ultimatemember;
70
  if ( isset( $ultimatemember->builtin->custom_fields ) ) {
74
  }
75
  }
76
 
77
+
78
+ /**
79
+ * Validate form
80
+ */
81
  function form_init(){
82
  global $ultimatemember;
83
 
109
 
110
  $this->post_form = array_merge( $this->form_data, $this->post_form );
111
 
112
+
 
113
  $secure_form_post = apply_filters('um_secure_form_post', true );
114
+
115
+ if( isset( $this->form_data['custom_fields'] )
116
+ && strstr( $this->form_data['custom_fields'], 'role_' )
117
+ && $secure_form_post ){ // Secure selected role
118
+
119
+ $custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] );
120
+
121
+ $role = $_POST['role'];
122
+
123
+ if( is_array( $_POST['role'] ) ){
124
+ $role = current( $_POST['role'] );
125
+ }
126
+
127
+ if ( isset( $custom_field_roles ) && ! in_array( $role , $custom_field_roles ) ) {
128
  wp_die( __( 'This is not possible for security reasons.','ultimatemember') );
129
+ }
130
+
131
+ $this->post_form['role'] = $role;
132
+ $this->post_form['submitted']['role'] = $role;
 
 
 
 
133
 
134
+ }else if( isset( $this->post_form['mode'] ) && $this->post_form['mode'] == 'register' ) {
135
+ $role = $this->assigned_role( $this->form_id );
136
+ $this->post_form['role'] = $role;
137
+ $this->post_form['submitted']['role'] = $role;
138
+ }
139
+
140
+
141
  if ( isset( $_POST[ $ultimatemember->honeypot ] ) && $_POST[ $ultimatemember->honeypot ] != '' ){
142
  wp_die('Hello, spam bot!');
143
  }
169
 
170
  }
171
 
172
+
173
+ /**
174
+ * Beautify form data
175
+ * @param array $form
176
+ * @return array $form
177
+ */
178
  function beautify( $form ){
179
 
180
  if (isset($form['form_id'])){
196
  return $form;
197
  }
198
 
199
+
200
+ /**
201
+ * Display form type as Title
202
+ * @param string $mode
203
+ * @param integer $post_id
204
+ * @return string $output
205
+ */
206
+ function display_form_type( $mode, $post_id ){
207
  $output = null;
208
+ switch( $mode ){
209
  case 'login':
210
  $output = 'Login';
211
  break;
219
  return $output;
220
  }
221
 
222
+ /**
223
+ * Assigned roles to a form
224
+ * @param integer $post_id
225
+ * @return string $role
226
+ */
227
  function assigned_role( $post_id ){
228
 
229
+ $mode = $this->form_type( $post_id );
230
+ $use_globals = get_post_meta( $post_id, "_um_{mode}_use_globals", true);
231
+
232
+ $global_role = um_get_option('default_role'); // Form Global settings
233
 
234
+ if( $use_globals == 0 ){ // Non-Global settings
235
+ $role = get_post_meta( $post_id, "_um_{mode}_role", true );
 
 
236
  }
237
 
238
+ if( ! $role || $role == 0 ){ // custom role is default, return default role's slug
239
+ $role = $global_role;
240
  }
241
+
242
  return $role;
243
+
244
  }
245
+
246
+ /**
247
+ * Get form type
248
+ * @param integer $post_id
249
+ * @return string
250
+ */
251
+ function form_type( $post_id ){
252
+
253
+ $mode = get_post_meta( $post_id, '_um_mode', true );
254
+
255
+ return $mode;
256
+ }
257
+
258
+ /**
259
+ * Get custom field roles
260
+ * @param string $custom_fields serialized
261
+ * @return array roles
262
+ */
263
+ function custom_field_roles( $custom_fields ){
264
+
265
+ if( is_serialized( $custom_fields ) ){
266
+ $fields = unserialize( $custom_fields );
267
+
268
+ if( ! is_array( $fields ) ) return false;
269
+
270
+ foreach ( $fields as $field_key => $field_settings ) {
271
+
272
+ if( strstr( $field_key , 'role_') ){
273
+ if( is_array( $field_settings['options'] ) ){
274
+ return array_keys( $field_settings['options'] );
275
+ }
276
+ }
277
+
278
+ }
279
+
280
+ }
281
+
282
+ return false;
283
+ }
284
  }
core/um-members.php CHANGED
@@ -23,8 +23,6 @@ class UM_Members {
23
  function user_search_columns( $search_columns ){
24
  if ( is_admin() ) {
25
  $search_columns[] = 'display_name';
26
- } else {
27
- $search_columns = array('display_name','user_email','user_login');
28
  }
29
  return $search_columns;
30
  }
@@ -149,29 +147,32 @@ class UM_Members {
149
 
150
  // Prepare for BIG SELECT query
151
  $wpdb->query('SET SQL_BIG_SELECTS=1');
152
- // Add filter to optimize BIG Select with multiple LEFT JOINs
153
- add_filter( 'pre_user_query', array( $this, 'um_optimize_member_query' ) );
154
-
155
- $users = new WP_User_Query( $query_args );
156
-
157
- remove_filter( 'pre_user_query', array( $this, 'um_optimize_member_query' ) );
158
 
159
  // number of profiles for mobile
160
- if ( $ultimatemember->mobile->isMobile() && isset( $profiles_per_page_mobile ) )
161
  $profiles_per_page = $profiles_per_page_mobile;
 
162
 
 
 
 
 
 
 
 
 
163
  $array['users'] = array_unique( $users->results );
164
 
165
  $array['total_users'] = (isset( $max_users ) && $max_users && $max_users <= $users->total_users ) ? $max_users : $users->total_users;
166
 
167
- $array['page'] = isset($_REQUEST['members_page']) ? $_REQUEST['members_page'] : 1;
168
 
169
  $array['total_pages'] = ceil( $array['total_users'] / $profiles_per_page );
170
 
171
  $array['header'] = $this->convert_tags( $header, $array );
172
  $array['header_single'] = $this->convert_tags( $header_single, $array );
173
 
174
- $array['users_per_page'] = array_slice($array['users'], ( ( $profiles_per_page * $array['page'] ) - $profiles_per_page ), $profiles_per_page );
175
 
176
  for( $i = $array['page']; $i <= $array['page'] + 2; $i++ ) {
177
  if ( $i <= $array['total_pages'] ) {
@@ -255,6 +256,7 @@ class UM_Members {
255
  }
256
 
257
  return apply_filters('um_prepare_user_results_array', $array );
 
258
  }
259
 
260
 
23
  function user_search_columns( $search_columns ){
24
  if ( is_admin() ) {
25
  $search_columns[] = 'display_name';
 
 
26
  }
27
  return $search_columns;
28
  }
147
 
148
  // Prepare for BIG SELECT query
149
  $wpdb->query('SET SQL_BIG_SELECTS=1');
 
 
 
 
 
 
150
 
151
  // number of profiles for mobile
152
+ if ( $ultimatemember->mobile->isMobile() && isset( $profiles_per_page_mobile ) ){
153
  $profiles_per_page = $profiles_per_page_mobile;
154
+ }
155
 
156
+ $query_args['number'] = $profiles_per_page;
157
+
158
+ $members_page = isset($_REQUEST['members_page']) ? $_REQUEST['members_page'] : 1;
159
+
160
+ $query_args['paged'] = $members_page;
161
+
162
+ $users = new WP_User_Query( $query_args );
163
+
164
  $array['users'] = array_unique( $users->results );
165
 
166
  $array['total_users'] = (isset( $max_users ) && $max_users && $max_users <= $users->total_users ) ? $max_users : $users->total_users;
167
 
168
+ $array['page'] = $members_page;
169
 
170
  $array['total_pages'] = ceil( $array['total_users'] / $profiles_per_page );
171
 
172
  $array['header'] = $this->convert_tags( $header, $array );
173
  $array['header_single'] = $this->convert_tags( $header_single, $array );
174
 
175
+ $array['users_per_page'] = $array['users'];
176
 
177
  for( $i = $array['page']; $i <= $array['page'] + 2; $i++ ) {
178
  if ( $i <= $array['total_pages'] ) {
256
  }
257
 
258
  return apply_filters('um_prepare_user_results_array', $array );
259
+
260
  }
261
 
262
 
core/um-navmenu-walker.php CHANGED
@@ -16,6 +16,8 @@ class UM_Menu_Item_Custom_Fields_Walker extends Walker_Nav_Menu_Edit {
16
  protected function get_fields( $item, $depth, $args = array(), $id = 0 ) {
17
  ob_start();
18
 
 
 
19
  do_action( 'wp_nav_menu_item_custom_fields', $id, $item, $depth, $args );
20
 
21
  return ob_get_clean();
16
  protected function get_fields( $item, $depth, $args = array(), $id = 0 ) {
17
  ob_start();
18
 
19
+ $id = esc_attr( $item->ID );
20
+
21
  do_action( 'wp_nav_menu_item_custom_fields', $id, $item, $depth, $args );
22
 
23
  return ob_get_clean();
core/um-permalinks.php CHANGED
@@ -12,7 +12,10 @@ class UM_Permalinks {
12
 
13
  add_action('init', array(&$this, 'activate_account_via_email_link'), 1);
14
 
 
 
15
  remove_action( 'wp_head', 'rel_canonical' );
 
16
  add_action('wp_head', array(&$this, 'um_rel_canonical_'), 9 );
17
 
18
  $this->current_url = $this->get_current_url();
@@ -62,7 +65,7 @@ class UM_Permalinks {
62
 
63
  $um_get_option = get_option('um_options');
64
 
65
- $server_name_method = ( $um_get_option['current_url_method'] ) ? $um_get_option['current_url_method'] : 'SERVER_NAME';
66
 
67
  $um_port_forwarding_url = ( isset( $um_get_option['um_port_forwarding_url'] ) ) ? $um_get_option['um_port_forwarding_url']: '';
68
 
@@ -196,8 +199,8 @@ class UM_Permalinks {
196
  global $ultimatemember;
197
 
198
  if ( !um_user('account_secret_hash') ) return false;
199
-
200
- $url = add_query_arg( 'act', 'activate_via_email', home_url() );
201
  $url = add_query_arg( 'hash', um_user('account_secret_hash'), $url );
202
  $url = add_query_arg( 'user_id', um_user('ID'), $url );
203
 
@@ -231,17 +234,23 @@ class UM_Permalinks {
231
  /***
232
  *** @get profile url for set user
233
  ***/
234
- function profile_url() {
235
  global $ultimatemember, $wpdb;
236
 
237
- $page_id = $this->core['user'];
238
- $profile_url = get_permalink( $page_id );
239
-
240
-
241
- $profile_url = apply_filters('um_localize_permalink_filter', $this->core, $page_id, $profile_url );
242
 
 
 
 
 
 
 
 
 
 
243
  // Username
244
- if ( um_get_option('permalink_base') == 'user_login' ) {
245
  $user_in_url = um_user('user_login');
246
 
247
  if ( is_email( $user_in_url ) ) {
@@ -252,7 +261,7 @@ class UM_Permalinks {
252
  $search_length = strlen( '.' );
253
  $user_in_url = substr_replace( $user_in_url , '-' , $pos , $search_length );
254
  }
255
- update_user_meta( um_user('ID') , 'um_email_as_username_'.$user_in_url , $user_email );
256
 
257
  } else {
258
 
@@ -261,29 +270,110 @@ class UM_Permalinks {
261
  }
262
 
263
  }
264
-
265
  // User ID
266
- if ( um_get_option('permalink_base') == 'user_id' ) {
267
  $user_in_url = um_user('ID');
268
  }
269
-
270
  // Fisrt and Last name
271
  $full_name_permalinks = array( 'name', 'name_dash', 'name_plus' );
272
- if( in_array( um_get_option( 'permalink_base'), $full_name_permalinks ) )
273
  {
274
- $full_name = um_user( 'full_name' );
275
- $last_name = um_user( 'last_name' );
276
  $first_name = um_user( 'first_name' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
 
278
- $count = intval( um_is_meta_value_exists( 'full_name', $full_name ) );
279
 
 
 
 
280
 
281
- if( $count > 1 )
282
- {
283
- $full_name .= ' ' . um_user( 'ID' );
284
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
 
286
- switch( um_get_option('permalink_base') )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
  {
288
  case 'name': // dotted
289
 
@@ -312,12 +402,6 @@ class UM_Permalinks {
312
  $difficulties++;
313
  }
314
 
315
-
316
- if( $difficulties > 0 ){
317
- update_user_meta( um_user('ID'), 'um_user_profile_url_slug_name_'.$full_name_slug, $full_name );
318
- }
319
-
320
-
321
  $user_in_url = rawurlencode( $full_name_slug );
322
 
323
  break;
@@ -349,10 +433,6 @@ class UM_Permalinks {
349
  $full_name_slug = str_replace( '.' , '-', $full_name_slug );
350
  $full_name_slug = str_replace( '--' , '-', $full_name_slug );
351
 
352
- if( $difficulties > 0 ){
353
- update_user_meta( um_user('ID'), 'um_user_profile_url_slug_name_'.$full_name_slug, $full_name );
354
- }
355
-
356
  $user_in_url = rawurlencode( $full_name_slug );
357
 
358
  break;
@@ -388,28 +468,13 @@ class UM_Permalinks {
388
  $full_name_slug = str_replace( '.' , '+', $full_name_slug );
389
  $full_name_slug = str_replace( '++' , '+', $full_name_slug );
390
 
391
- if( $difficulties > 0 ){
392
- update_user_meta( um_user('ID'), 'um_user_profile_url_slug_name_'.$full_name_slug, $full_name );
393
- }
394
-
395
  $user_in_url = $full_name_slug;
396
 
397
  break;
398
  }
399
- }
400
-
401
- if ( get_option('permalink_structure') ) {
402
-
403
- $profile_url = trailingslashit( untrailingslashit( $profile_url ) );
404
- $profile_url = $profile_url . $user_in_url . '/';
405
-
406
- } else {
407
 
408
- $profile_url = add_query_arg( 'um_user', $user_in_url, $profile_url );
409
-
410
- }
411
-
412
- return $profile_url;
413
  }
414
 
415
  /***
12
 
13
  add_action('init', array(&$this, 'activate_account_via_email_link'), 1);
14
 
15
+ add_action('um_user_after_updating_profile', array(&$this, 'profile_url'), 1 );
16
+
17
  remove_action( 'wp_head', 'rel_canonical' );
18
+
19
  add_action('wp_head', array(&$this, 'um_rel_canonical_'), 9 );
20
 
21
  $this->current_url = $this->get_current_url();
65
 
66
  $um_get_option = get_option('um_options');
67
 
68
+ $server_name_method = isset( $um_get_option['current_url_method'] ) ? $um_get_option['current_url_method'] : 'SERVER_NAME';
69
 
70
  $um_port_forwarding_url = ( isset( $um_get_option['um_port_forwarding_url'] ) ) ? $um_get_option['um_port_forwarding_url']: '';
71
 
199
  global $ultimatemember;
200
 
201
  if ( !um_user('account_secret_hash') ) return false;
202
+ $url = apply_filters( 'um_activate_url', home_url() );
203
+ $url = add_query_arg( 'act', 'activate_via_email', $url );
204
  $url = add_query_arg( 'hash', um_user('account_secret_hash'), $url );
205
  $url = add_query_arg( 'user_id', um_user('ID'), $url );
206
 
234
  /***
235
  *** @get profile url for set user
236
  ***/
237
+ function profile_url( $update_slug = false ) {
238
  global $ultimatemember, $wpdb;
239
 
240
+ // Permalink base
241
+ $permalink_base = um_get_option('permalink_base');
 
 
 
242
 
243
+ // Get user slug
244
+ $profile_slug = get_user_meta( um_user('ID'), "um_user_profile_url_slug_{$permalink_base}", true );
245
+ $generate_slug = um_get_option('um_generate_slug_in_directory');
246
+
247
+ // Return existing profile slug
248
+ if( $generate_slug && $update_slug == false && $profile_slug ){
249
+ return $this->profile_permalink( $profile_slug );
250
+ }
251
+
252
  // Username
253
+ if ( $permalink_base == 'user_login' ) {
254
  $user_in_url = um_user('user_login');
255
 
256
  if ( is_email( $user_in_url ) ) {
261
  $search_length = strlen( '.' );
262
  $user_in_url = substr_replace( $user_in_url , '-' , $pos , $search_length );
263
  }
264
+ update_user_meta( um_user('ID') , "um_email_as_username_{$user_in_url}" , $user_email );
265
 
266
  } else {
267
 
270
  }
271
 
272
  }
273
+
274
  // User ID
275
+ if ( $permalink_base == 'user_id' ) {
276
  $user_in_url = um_user('ID');
277
  }
278
+
279
  // Fisrt and Last name
280
  $full_name_permalinks = array( 'name', 'name_dash', 'name_plus' );
281
+ if( in_array( $permalink_base, $full_name_permalinks ) )
282
  {
283
+ $opt_display_name = um_get_option('display_name');
 
284
  $first_name = um_user( 'first_name' );
285
+ $last_name = um_user( 'last_name' );
286
+ $full_name = um_user( 'display_name' );
287
+ $full_name = preg_replace('/\s+/', ' ', $full_name); // Remove double spaces
288
+
289
+ $profile_slug = $this->profile_slug( $full_name, $first_name, $last_name );
290
+
291
+ $duplicate_slug_hash = md5( $profile_slug );
292
+
293
+ $args = array(
294
+ 'meta_query' => array(
295
+ 'relation' => 'AND',
296
+ array(
297
+ 'key' => "um_user_profile_url_slug_{$permalink_base}",
298
+ 'value' => $profile_slug,
299
+ 'compare' => '='
300
+ ),
301
+ ),
302
+ 'orderby' => 'registered',
303
+ 'order' => 'ASC',
304
+ 'fields' => array('user_registered','ID'),
305
+ );
306
+
307
+ $user_query = new WP_User_Query( $args );
308
+
309
+ if( $user_query->total_users > 1 ){
310
+
311
+ $duplicate_names = $user_query->get_results();
312
+
313
+ $current = end( $duplicate_names );
314
+
315
+ update_option("um_duplicate_name_{$duplicate_slug_hash}", $current->ID );
316
+
317
+ }
318
+
319
+ $duplicate_id = get_option("um_duplicate_name_{$duplicate_slug_hash}");
320
+
321
+ if( ! empty( $duplicate_id ) && $duplicate_id != um_user('ID') ){
322
+ $full_name = $full_name.' ' . um_user( 'ID' );
323
+ }
324
+
325
+ $user_in_url = $this->profile_slug( $full_name, $first_name, $last_name );
326
 
327
+ }
328
 
329
+ update_user_meta( um_user('ID'), "um_user_profile_url_slug_{$permalink_base}", $user_in_url );
330
+
331
+ $profile_url = $this->profile_permalink( $user_in_url );
332
 
333
+ return $profile_url;
334
+ }
335
+
336
+ /**
337
+ * Get Profile Permalink
338
+ * @param string $slug
339
+ * @return string $profile_url
340
+ */
341
+ function profile_permalink( $slug ){
342
+
343
+ $page_id = $this->core['user'];
344
+ $profile_url = get_permalink( $page_id );
345
+
346
+ $profile_url = apply_filters('um_localize_permalink_filter', $this->core, $page_id, $profile_url );
347
+
348
+ if ( get_option('permalink_structure') ) {
349
+
350
+ $profile_url = trailingslashit( untrailingslashit( $profile_url ) );
351
+ $profile_url = $profile_url . strtolower( $slug ). '/';
352
+
353
+ } else {
354
+
355
+ $profile_url = add_query_arg( 'um_user', $slug, $profile_url );
356
 
357
+ }
358
+
359
+ return ! empty( $profile_url ) ? strtolower( $profile_url ) : '';
360
+
361
+ }
362
+
363
+ /**
364
+ * Generate profile slug
365
+ * @param string $full_name
366
+ * @param string $first_name
367
+ * @param string $last_name
368
+ * @return string
369
+ */
370
+ function profile_slug( $full_name, $first_name, $last_name ){
371
+
372
+ $permalink_base = um_get_option('permalink_base');
373
+
374
+ $user_in_url = '';
375
+
376
+ switch( $permalink_base )
377
  {
378
  case 'name': // dotted
379
 
402
  $difficulties++;
403
  }
404
 
 
 
 
 
 
 
405
  $user_in_url = rawurlencode( $full_name_slug );
406
 
407
  break;
433
  $full_name_slug = str_replace( '.' , '-', $full_name_slug );
434
  $full_name_slug = str_replace( '--' , '-', $full_name_slug );
435
 
 
 
 
 
436
  $user_in_url = rawurlencode( $full_name_slug );
437
 
438
  break;
468
  $full_name_slug = str_replace( '.' , '+', $full_name_slug );
469
  $full_name_slug = str_replace( '++' , '+', $full_name_slug );
470
 
 
 
 
 
471
  $user_in_url = $full_name_slug;
472
 
473
  break;
474
  }
 
 
 
 
 
 
 
 
475
 
476
+ return $user_in_url ;
477
+
 
 
 
478
  }
479
 
480
  /***
core/um-short-functions.php CHANGED
@@ -203,8 +203,8 @@
203
  );
204
 
205
  $replace = apply_filters('um_template_tags_replaces_hook', $replace);
206
-
207
- $content = wp_kses_decode_entities( str_replace($search, $replace, $content) );
208
 
209
  if ( isset( $args['tags'] ) && isset( $args['tags_replace'] ) ) {
210
  $content = str_replace($args['tags'], $args['tags_replace'], $content);
@@ -268,18 +268,45 @@ function um_user_ip() {
268
  if ( !isset( $data['conditions'] ) ) return true;
269
 
270
  $state = 1;
271
-
272
  foreach( $data['conditions'] as $k => $arr ) {
273
  if ( $arr[0] == 'show' ) {
274
 
275
  $state = 1;
276
  $val = $arr[3];
277
  $op = $arr[2];
278
- $field = um_profile($arr[1]);
279
 
 
 
 
 
 
 
280
  switch( $op ) {
281
- case 'equals to': if ( $field != $val ) $state = 0; break;
282
- case 'not equals': if ( $field == $val ) $state = 0; break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  case 'empty': if ( $field ) $state = 0; break;
284
  case 'not empty': if ( !$field ) $state = 0; break;
285
  case 'greater than': if ( $field <= $val ) $state = 0; break;
@@ -296,8 +323,28 @@ function um_user_ip() {
296
  $field = um_profile($arr[1]);
297
 
298
  switch( $op ) {
299
- case 'equals to': if ( $field != $val ) $state = 1; break;
300
- case 'not equals': if ( $field == $val ) $state = 1; break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  case 'empty': if ( $field ) $state = 1; break;
302
  case 'not empty': if ( !$field ) $state = 1; break;
303
  case 'greater than': if ( $field <= $val ) $state = 1; break;
@@ -631,7 +678,7 @@ function um_profile_id() {
631
  $value = '';
632
  if ( isset($_REQUEST['um_search']) ) {
633
  $query = $ultimatemember->permalinks->get_query_array();
634
- if ( $query[ $filter ] != '' ) {
635
  $value = stripslashes_deep( $query[ $filter ] );
636
  }
637
  }
@@ -1311,18 +1358,36 @@ function um_fetch_user( $user_id ) {
1311
  default:
1312
 
1313
  $value = um_profile($data);
1314
-
1315
  if ( $ultimatemember->validation->is_serialized( $value ) ) {
1316
  $value = unserialize( $value );
1317
  }
1318
 
1319
- if( $data == 'role' ){
1320
- return strtolower($value);
 
 
 
1321
  }
1322
 
1323
  return $value;
1324
  break;
1325
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1326
  case 'full_name':
1327
 
1328
  if ( um_user('first_name') && um_user('last_name') ) {
@@ -1357,7 +1422,7 @@ function um_fetch_user( $user_id ) {
1357
  $f_and_l_initial = $ultimatemember->validation->safe_name_in_url( $f_and_l_initial );
1358
 
1359
  if( um_get_option('force_display_name_capitlized') ){
1360
- $name = ucwords( strtolower( $f_and_l_initial ) );
1361
  }else{
1362
  $name = $f_and_l_initial;
1363
  }
@@ -1446,7 +1511,7 @@ function um_fetch_user( $user_id ) {
1446
  }
1447
 
1448
  if( um_get_option('force_display_name_capitlized') ){
1449
- $name = ucwords( strtolower( $name ) );
1450
  }
1451
 
1452
  return apply_filters('um_user_display_name_filter', $name, um_user('ID'), ( $attrs == 'html' ) ? 1 : 0 );
@@ -1532,6 +1597,7 @@ function um_fetch_user( $user_id ) {
1532
 
1533
  break;
1534
 
 
1535
  }
1536
 
1537
  }
@@ -1743,4 +1809,75 @@ function um_fetch_user( $user_id ) {
1743
  || substr($_SERVER['HTTP_HOST'],0,3) == '10.'
1744
  || substr($_SERVER['HTTP_HOST'],0,7) == '192.168') return true;
1745
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1746
  }
203
  );
204
 
205
  $replace = apply_filters('um_template_tags_replaces_hook', $replace);
206
+
207
+ $content = wp_kses_decode_entities( str_replace($search, $replace, $content) );
208
 
209
  if ( isset( $args['tags'] ) && isset( $args['tags_replace'] ) ) {
210
  $content = str_replace($args['tags'], $args['tags_replace'], $content);
268
  if ( !isset( $data['conditions'] ) ) return true;
269
 
270
  $state = 1;
271
+
272
  foreach( $data['conditions'] as $k => $arr ) {
273
  if ( $arr[0] == 'show' ) {
274
 
275
  $state = 1;
276
  $val = $arr[3];
277
  $op = $arr[2];
 
278
 
279
+ if( strstr( $arr[1] , 'role_') ){
280
+ $arr[1] = 'role';
281
+ }
282
+
283
+ $field = um_profile( $arr[1] );
284
+
285
  switch( $op ) {
286
+ case 'equals to':
287
+
288
+ if( is_serialized( $field ) ){
289
+ if ( ! in_array( $val , unserialize( $field ) ) ) {
290
+ $state = 0;
291
+ }
292
+ }else{
293
+ if ( $field != $val ) {
294
+ $state = 0;
295
+ }
296
+ }
297
+
298
+ break;
299
+ case 'not equals':
300
+ if( is_serialized( $field ) ){
301
+ if ( in_array( $val , unserialize( $field ) ) ) {
302
+ $state = 0;
303
+ }
304
+ }else{
305
+ if ( $field == $val ) {
306
+ $state = 0;
307
+ }
308
+ }
309
+ break;
310
  case 'empty': if ( $field ) $state = 0; break;
311
  case 'not empty': if ( !$field ) $state = 0; break;
312
  case 'greater than': if ( $field <= $val ) $state = 0; break;
323
  $field = um_profile($arr[1]);
324
 
325
  switch( $op ) {
326
+ case 'equals to':
327
+ if( is_serialized( $field ) ){
328
+ if ( ! in_array( $val , unserialize( $field ) ) ) {
329
+ $state = 1;
330
+ }
331
+ }else{
332
+ if ( $field != $val ) {
333
+ $state = 1;
334
+ }
335
+ }
336
+ break;
337
+ case 'not equals':
338
+ if( is_serialized( $field ) ){
339
+ if ( in_array( $val , unserialize( $field ) ) ) {
340
+ $state = 1;
341
+ }
342
+ }else{
343
+ if ( $field == $val ) {
344
+ $state = 1;
345
+ }
346
+ }
347
+ break;
348
  case 'empty': if ( $field ) $state = 1; break;
349
  case 'not empty': if ( !$field ) $state = 1; break;
350
  case 'greater than': if ( $field <= $val ) $state = 1; break;
678
  $value = '';
679
  if ( isset($_REQUEST['um_search']) ) {
680
  $query = $ultimatemember->permalinks->get_query_array();
681
+ if ( isset( $query[ $filter ] ) && $query[ $filter ] != '' ) {
682
  $value = stripslashes_deep( $query[ $filter ] );
683
  }
684
  }
1358
  default:
1359
 
1360
  $value = um_profile($data);
1361
+
1362
  if ( $ultimatemember->validation->is_serialized( $value ) ) {
1363
  $value = unserialize( $value );
1364
  }
1365
 
1366
+ if( in_array( $data, array('role','gender') ) ){
1367
+ if( is_array( $value ) ){
1368
+ $value = implode(",", $value );
1369
+ }
1370
+ return $value;
1371
  }
1372
 
1373
  return $value;
1374
  break;
1375
 
1376
+ case 'first_name':
1377
+ case 'last_name':
1378
+
1379
+ $name = um_profile( $data );
1380
+
1381
+ if( um_get_option('force_display_name_capitlized') ){
1382
+ $name = implode('-', array_map('ucfirst', explode('-', $name ) ) );
1383
+ }
1384
+
1385
+ $name = apply_filters("um_user_{$data}_case", $name );
1386
+
1387
+ return $name;
1388
+
1389
+ break;
1390
+
1391
  case 'full_name':
1392
 
1393
  if ( um_user('first_name') && um_user('last_name') ) {
1422
  $f_and_l_initial = $ultimatemember->validation->safe_name_in_url( $f_and_l_initial );
1423
 
1424
  if( um_get_option('force_display_name_capitlized') ){
1425
+ $name = implode('-', array_map('ucfirst', explode('-', $f_and_l_initial ) ) );
1426
  }else{
1427
  $name = $f_and_l_initial;
1428
  }
1511
  }
1512
 
1513
  if( um_get_option('force_display_name_capitlized') ){
1514
+ $name = implode('-', array_map('ucfirst', explode('-', $name ) ) );
1515
  }
1516
 
1517
  return apply_filters('um_user_display_name_filter', $name, um_user('ID'), ( $attrs == 'html' ) ? 1 : 0 );
1597
 
1598
  break;
1599
 
1600
+
1601
  }
1602
 
1603
  }
1809
  || substr($_SERVER['HTTP_HOST'],0,3) == '10.'
1810
  || substr($_SERVER['HTTP_HOST'],0,7) == '192.168') return true;
1811
  return false;
1812
+ }
1813
+
1814
+ /**
1815
+ * Get user host
1816
+ *
1817
+ * Returns the webhost this site is using if possible
1818
+ *
1819
+ * @since 1.3.68
1820
+ * @return mixed string $host if detected, false otherwise
1821
+ */
1822
+ function um_get_host() {
1823
+ $host = false;
1824
+
1825
+ if( defined( 'WPE_APIKEY' ) ) {
1826
+ $host = 'WP Engine';
1827
+ } elseif( defined( 'PAGELYBIN' ) ) {
1828
+ $host = 'Pagely';
1829
+ } elseif( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
1830
+ $host = 'ICDSoft';
1831
+ } elseif( DB_HOST == 'mysqlv5' ) {
1832
+ $host = 'NetworkSolutions';
1833
+ } elseif( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
1834
+ $host = 'iPage';
1835
+ } elseif( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
1836
+ $host = 'IPower';
1837
+ } elseif( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
1838
+ $host = 'MediaTemple Grid';
1839
+ } elseif( strpos( DB_HOST, '.pair.com' ) !== false ) {
1840
+ $host = 'pair Networks';
1841
+ } elseif( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
1842
+ $host = 'Rackspace Cloud';
1843
+ } elseif( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
1844
+ $host = 'SysFix.eu Power Hosting';
1845
+ } elseif( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
1846
+ $host = 'Flywheel';
1847
+ } else {
1848
+ // Adding a general fallback for data gathering
1849
+ $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
1850
+ }
1851
+
1852
+ return $host;
1853
+ }
1854
+
1855
+ /**
1856
+ * Let To Num
1857
+ *
1858
+ * Does Size Conversions
1859
+ *
1860
+ * @since 1.3.68
1861
+ * @author Chris Christoff
1862
+ *
1863
+ * @param unknown $v
1864
+ * @return int|string
1865
+ */
1866
+ function um_let_to_num( $v ) {
1867
+ $l = substr( $v, -1 );
1868
+ $ret = substr( $v, 0, -1 );
1869
+
1870
+ switch ( strtoupper( $l ) ) {
1871
+ case 'P': // fall-through
1872
+ case 'T': // fall-through
1873
+ case 'G': // fall-through
1874
+ case 'M': // fall-through
1875
+ case 'K': // fall-through
1876
+ $ret *= 1024;
1877
+ break;
1878
+ default:
1879
+ break;
1880
+ }
1881
+
1882
+ return $ret;
1883
  }
core/um-user.php CHANGED
@@ -7,6 +7,7 @@ class UM_User {
7
  $this->id = 0;
8
  $this->usermeta = null;
9
  $this->data = null;
 
10
 
11
  $this->banned_keys = array(
12
  'metabox','postbox','meta-box',
@@ -117,7 +118,7 @@ class UM_User {
117
 
118
  function get_cached_data( $user_id ) {
119
 
120
- $disallow_cache = get_option('um_profile_object_cache_stop');
121
  if( $disallow_cache ){
122
  return '';
123
  }
@@ -134,7 +135,7 @@ class UM_User {
134
 
135
  function setup_cache( $user_id, $profile ) {
136
 
137
- $disallow_cache = get_option('um_profile_object_cache_stop');
138
  if( $disallow_cache ){
139
  return '';
140
  }
@@ -373,9 +374,10 @@ class UM_User {
373
 
374
  do_action('um_before_user_role_is_changed');
375
 
 
 
376
  do_action('um_member_role_upgrade', $role, $this->profile['role'] );
377
 
378
- $this->profile['role'] = $role;
379
  $this->update_usermeta_info('role');
380
 
381
  do_action('um_after_user_role_is_changed');
@@ -875,10 +877,7 @@ class UM_User {
875
  $args['ID'] = $this->id;
876
  $changes = apply_filters('um_before_update_profile', $changes, $this->id);
877
 
878
- // hook for name changes
879
- do_action('um_update_profile_full_name', $changes );
880
-
881
- // save or update profile meta
882
  foreach( $changes as $key => $value ) {
883
  if ( !in_array( $key, $this->update_user_keys ) ) {
884
 
@@ -929,27 +928,69 @@ class UM_User {
929
  function user_exists_by_name( $value ) {
930
 
931
  global $ultimatemember;
 
 
 
 
 
932
  $value = $ultimatemember->validation->safe_name_in_url( $value );
933
  $value = um_clean_user_basename( $value );
934
 
935
- // if duplicate full name, return the user id
936
- if( preg_match( '/( |\.|\-)\d+$/', $value, $matches ) )
937
- {
938
- return $matches[0];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
939
  }
 
 
 
 
 
 
 
940
 
941
- $ids = get_users(array( 'fields' => 'ID', 'meta_key' => 'full_name','meta_value' => $value ,'meta_compare' => '=') );
942
- if ( isset( $ids[0] ) && ! empty( $ids[0] ) ){
943
- return $ids[0];
 
 
944
  }
945
 
946
 
 
947
  $value = str_replace(".", "_", $value );
948
  $value = str_replace(" ", "", $value );
949
 
950
- $user = get_user_by( 'login', $value );
951
- if ( isset( $user->ID ) && $user->ID > 0 ){
952
- return $user->ID;
 
 
 
 
 
 
 
 
 
 
953
  }
954
 
955
  return false;
7
  $this->id = 0;
8
  $this->usermeta = null;
9
  $this->data = null;
10
+ $this->profile = null;
11
 
12
  $this->banned_keys = array(
13
  'metabox','postbox','meta-box',
118
 
119
  function get_cached_data( $user_id ) {
120
 
121
+ $disallow_cache = um_get_option('um_profile_object_cache_stop');
122
  if( $disallow_cache ){
123
  return '';
124
  }
135
 
136
  function setup_cache( $user_id, $profile ) {
137
 
138
+ $disallow_cache = um_get_option('um_profile_object_cache_stop');
139
  if( $disallow_cache ){
140
  return '';
141
  }
374
 
375
  do_action('um_before_user_role_is_changed');
376
 
377
+ $this->profile['role'] = $role;
378
+
379
  do_action('um_member_role_upgrade', $role, $this->profile['role'] );
380
 
 
381
  $this->update_usermeta_info('role');
382
 
383
  do_action('um_after_user_role_is_changed');
877
  $args['ID'] = $this->id;
878
  $changes = apply_filters('um_before_update_profile', $changes, $this->id);
879
 
880
+ // save or update profile meta
 
 
 
881
  foreach( $changes as $key => $value ) {
882
  if ( !in_array( $key, $this->update_user_keys ) ) {
883
 
928
  function user_exists_by_name( $value ) {
929
 
930
  global $ultimatemember;
931
+
932
+ // Permalink base
933
+ $permalink_base = um_get_option('permalink_base');
934
+
935
+ $raw_value = $value;
936
  $value = $ultimatemember->validation->safe_name_in_url( $value );
937
  $value = um_clean_user_basename( $value );
938
 
939
+ // Search by Profile Slug
940
+ $args = array(
941
+ "fields" => array("ID"),
942
+ 'meta_query' => array(
943
+ 'relation' => 'OR',
944
+ array(
945
+ 'key' => 'um_user_profile_url_slug_'.$permalink_base,
946
+ 'value' => strtolower( $raw_value ),
947
+ 'compare' => '='
948
+
949
+ )
950
+
951
+ )
952
+ );
953
+
954
+
955
+ $ids = new WP_User_Query( $args );
956
+
957
+ if( $ids->total_users > 0 ){
958
+ $um_user_query = current( $ids->get_results() );
959
+ return $um_user_query->ID;
960
  }
961
+
962
+ // Search by Display Name or ID
963
+ $args = array(
964
+ "fields" => array("ID"),
965
+ "search" => $value,
966
+ 'search_columns' => array( 'display_name','ID' )
967
+ );
968
 
969
+ $ids = new WP_User_Query( $args );
970
+
971
+ if( $ids->total_users > 0 ){
972
+ $um_user_query = current( $ids->get_results() );
973
+ return $um_user_query->ID;
974
  }
975
 
976
 
977
+ // Search By User Login
978
  $value = str_replace(".", "_", $value );
979
  $value = str_replace(" ", "", $value );
980
 
981
+ $args = array(
982
+ "fields" => array("ID"),
983
+ "search" => $value,
984
+ 'search_columns' => array(
985
+ 'user_login',
986
+ )
987
+ );
988
+
989
+ $ids = new WP_User_Query( $args );
990
+
991
+ if( $ids->total_users > 0 ){
992
+ $um_user_query = current( $ids->get_results() );
993
+ return $um_user_query->ID;
994
  }
995
 
996
  return false;
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Ultimate Member
4
  Plugin URI: http://ultimatemember.com/
5
  Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
6
- Version: 1.3.68
7
  Author: Ultimate Member
8
  Author URI: http://ultimatemember.com/
9
  Text Domain: ultimatemember
3
  Plugin Name: Ultimate Member
4
  Plugin URI: http://ultimatemember.com/
5
  Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
6
+ Version: 1.3.69
7
  Author: Ultimate Member
8
  Author URI: http://ultimatemember.com/
9
  Text Domain: ultimatemember
readme.txt CHANGED
@@ -5,9 +5,9 @@ Contributors: ultimatemember, champsupertramp
5
  Donate link:
6
  Tags: access control, author, authors, author profile, comments, community, communities, conditional fields, conditional logic, conditional menus, content protection, custom fields, file uploads, form builder, front-end login, front-end registration, gravatar, hide wp-admin, login, login page, logged-in users, mandrill, member, members, membership, member directory, online users, profile, profiles, profile builder, registration, restriction, restrict content, role creation, role menus, search filters, sign in, sign up, social network, star ratings, toolbar, user, users, user fields, user profile, user-profile, user profiles, user roles
7
  Requires at least: 4.1
8
- Tested up to: 4.5.3
9
 
10
- Stable Tag: 1.3.68
11
 
12
  License: GNU Version 2 or Any Later Version
13
 
@@ -149,6 +149,45 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
149
 
150
  == Changelog ==
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  = 1.3.68: August 02, 2016 =
153
 
154
  * Fixed: radio field in account page
5
  Donate link:
6
  Tags: access control, author, authors, author profile, comments, community, communities, conditional fields, conditional logic, conditional menus, content protection, custom fields, file uploads, form builder, front-end login, front-end registration, gravatar, hide wp-admin, login, login page, logged-in users, mandrill, member, members, membership, member directory, online users, profile, profiles, profile builder, registration, restriction, restrict content, role creation, role menus, search filters, sign in, sign up, social network, star ratings, toolbar, user, users, user fields, user profile, user-profile, user profiles, user roles
7
  Requires at least: 4.1
8
+ Tested up to: 4.6.1
9
 
10
+ Stable Tag: 1.3.69
11
 
12
  License: GNU Version 2 or Any Later Version
13
 
149
 
150
  == Changelog ==
151
 
152
+ = 1.3.69: September 08, 2016 =
153
+
154
+ * Enhancements:
155
+ * Adds a system information tool for support purposes
156
+ * Adds a new option to disable generating profile slugs on every load of member directory pages.
157
+ * Located in UM > Settings > Advanced > Stop generating profile slugs in member directory.
158
+ * This improves the performance when loading profiles in directories. It generates profile slug on Profile Update ( front and back-end ), Registration Process and viewing the Users in the back-end.
159
+ * Adds new filter hook `um_activate_url` to modify the account activation url.
160
+ * Adds new filter hooks to modify first and last name cases
161
+ * `um_user_first_name_case`
162
+ * `um_user_last_name_case`
163
+ * Adds new filter hooks to modify nonces of image and file uploads
164
+ * `um_file_upload_nonce`
165
+ * `um_image_upload_nonce`
166
+ * Improves search member filters and keyword sensitivity
167
+ * Improves generation of profile slugs
168
+ * Improves force capitalization of display names with dash
169
+ * Improves the pagination and loading of profiles in member directory
170
+
171
+ * Bugfixes:
172
+ * Fixes a bug where users in member directory are missing after updating their profile
173
+ * Fixes a bug to generate random email when email field is not added in a form.
174
+ * Fixes a bug to show hidden members in member directory for admins
175
+ * Fixes a bug to validate username length on registration process
176
+ * Fixes a bug to display profile name in dynamic menu and profile page title
177
+ * Fixes a bug where frequent security notices show on registration process
178
+ * Fixes a bug to assign correct role to a user on registration process
179
+ * Fixes a bug to display correct roles in radio and dropdown fields
180
+ * Fixes a bug to validate the reset password
181
+ * Fixes a bug to change the assign of role in navigation menu items
182
+ * Fixes a bug to select radio field in profile form
183
+ * Fixes a bug to allow frontpage and posts page to handle custom access settings
184
+ * Fixes a bug where profile role field's conditional logic doesn't show/hide the second field.
185
+ * Fixes a bug to show 'Last Login' field in profile edit and view mode.
186
+ * Fixes a bug to sync roles with users in Edit Roles.
187
+ * Fixes a bug to disable/enable UM profile cache
188
+ * Fixes a bug to disable biography field's character limit when added in form
189
+
190
+
191
  = 1.3.68: August 02, 2016 =
192
 
193
  * Fixed: radio field in account page
um-config.php CHANGED
@@ -1998,6 +1998,16 @@ $arr_advanced_fields = array(
1998
  'off' => __('Off','ultimatemember'),
1999
  ),
2000
 
 
 
 
 
 
 
 
 
 
 
2001
  array(
2002
  'id' => 'current_url_method',
2003
  'type' => 'select',
1998
  'off' => __('Off','ultimatemember'),
1999
  ),
2000
 
2001
+ array(
2002
+ 'id' => 'um_generate_slug_in_directory',
2003
+ 'type' => 'switch',
2004
+ 'title' => __( 'Stop generating profile slugs in member directory','ultimatemember' ),
2005
+ 'default' => 0,
2006
+ 'desc' => __('Turn on If you have performance issue in member directory.','ultimatemember'),
2007
+ 'on' => __('On','ultimatemember'),
2008
+ 'off' => __('Off','ultimatemember'),
2009
+ ),
2010
+
2011
  array(
2012
  'id' => 'current_url_method',
2013
  'type' => 'select',
um-init.php CHANGED
@@ -63,6 +63,11 @@ class UM_API {
63
  __('This add-on enables you to generate dummies.', 'ultimatemember'),
64
  );
65
 
 
 
 
 
 
66
  // include widgets
67
  require_once um_path . 'core/widgets/um-search-widget.php';
68
 
63
  __('This add-on enables you to generate dummies.', 'ultimatemember'),
64
  );
65
 
66
+ $this->addons['system_info'] = array(
67
+ __('System Info', 'ultimatemember'),
68
+ __('This add-on enables you to download system information file.', 'ultimatemember'),
69
+ );
70
+
71
  // include widgets
72
  require_once um_path . 'core/widgets/um-search-widget.php';
73