wsl.components.tools.actions.job.php ➔ wsl_component_tools_do_sysinfo()   F
last analyzed

Complexity

Conditions 22
Paths 432

Size

Total Lines 113

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 22
nc 432
nop 0
dl 0
loc 113
rs 0.6311
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*!
3
* WordPress Social Login
4
*
5
* https://miled.github.io/wordpress-social-login/ | https://github.com/miled/wordpress-social-login
6
*   (c) 2011-2020 Mohamed Mrassi and contributors | https://wordpress.org/plugins/wordpress-social-login/
7
*/
8
9
// Exit if accessed directly
10
if ( !defined( 'ABSPATH' ) ) exit;
11
12
// --------------------------------------------------------------------
13
14
function wsl_component_tools_do_diagnostics()
15
{
16
?>
17
<style>
18
	table td, table th { border: 1px solid #DDDDDD; }
19
	table th label { font-weight: bold; }
20
</style>
21
<div class="metabox-holder columns-2" id="post-body">
22
	<div class="stuffbox">
23
		<h3>
24
			<label><?php _wsl_e("WordPress Social Login Diagnostics", 'wordpress-social-login') ?></label>
25
		</h3>
26
		<div class="inside">
27
			<br />
28
			<table class="wp-list-table widefat">
29
				<?php
30
					$test = version_compare( PHP_VERSION, '5.4.0', '>=' );
31
					// $test = 0;
32
				?>
33
				<tr>
34
					<th width="200">
35
						<label>PHP Version</label>
36
					</th>
37
					<td>
38
						<p>PHP >= 5.4.0 installed.</p>
39
						<?php
40
							if( ! $test )
41
							{
42
								?>
43
									<div class="fade error" style="margin: 20px  0;">
44
										<p><b>Error</b>: An old version of PHP is installed.</p>
45
										<p>The solution is to make a trouble ticket to your web host and request them to upgrade to newer version of PHP.</p>
46
									</div>
47
								<?php
48
							}
49
						?>
50
					</td>
51
					<td width="60">
52
						<?php
53
							if( $test )
54
							{
55
								echo "<b style='color:green;'>OK!</b>";
56
							}
57
							else
58
							{
59
								echo "<b style='color:red;'>FAIL!</b>";
60
							}
61
						?>
62
					</td>
63
				</tr>
64
65
				<?php
66
					$test = isset( $_SESSION["wsl::plugin"] ) && $_SESSION["wsl::plugin"];
67
					// $test = 0;
68
				?>
69
				<tr>
70
					<th width="200">
71
						<label>PHP Sessions</label>
72
					</th>
73
					<td>
74
						<p>PHP/Session must be enabled and working.</p>
75
						<?php
76
							if( ! $test )
77
							{
78
								?>
79
								<div class="fade error" style="margin: 20px  0;">
80
									<p><b>Error</b>: PHP Sessions are not working as expected.</p>
81
82
									<p>
83
										This error may occur for many reasons:
84
									</p>
85
86
									<p>
87
										1. PHP session are either disabled, renamed or there is files permissions issues.
88
									</p>
89
									<p>
90
										2. When using a reverse proxy like Varnish or a caching engine that might strip cookies. On this case, WSL will requires these two urls to be white-listed:
91
									</p>
92
									<div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;">
93
										<?php
94
											echo '<a href="' . site_url( 'wp-login.php', 'login_post' ) . '" target="_blank">' . site_url( 'wp-login.php', 'login_post' ) . '</a>';
95
											echo '<br />';
96
											echo '<a href="' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '" target="_blank">' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '</a>';
97
										?>
98
									</div>
99
								</div>
100
								<?php
101
							}
102
							else
103
							{
104
						?>
105
							<hr />
106
							<h4>Notes:</h4>
107
							<p>
108
								1. If you're hosting your website on <b>WP Engine</b>, refer this topic: <a href="https://wordpress.org/support/topic/500-internal-server-error-when-redirecting" target="_blank">https://wordpress.org/support/topic/500-internal-server-error-when-redirecting</a>
109
							</p>
110
							<p>2. In case you're using a reverse proxy like Varnish or a caching engine that might strip cookies, WSL will requires these two urls to be white-listed:</p>
111
							<div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;">
112
								<?php
113
									echo '<a href="' . site_url( 'wp-login.php', 'login_post' ) . '" target="_blank">' . site_url( 'wp-login.php', 'login_post' ) . '</a>';
114
									echo '<br />';
115
									echo '<a href="' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '" target="_blank">' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '</a>';
116
								?>
117
							</div>
118
						<?php
119
							}
120
						?>
121
					</td>
122
					<td>
123
						<?php
124
							if( $test )
125
							{
126
								echo "<b style='color:green;'>OK!</b>";
127
							}
128
							else
129
							{
130
								echo "<b style='color:red;'>FAIL!</b>";
131
							}
132
						?>
133
					</td>
134
				</tr>
135
136
				<?php
137
					$test = false;
138
139
					if ( function_exists('curl_init') )
140
					{
141
						$curl_version = curl_version();
142
143
						if ( $curl_version['features'] & CURL_VERSION_SSL )
144
						{
145
							$test = true;
146
						}
147
					}
148
					// $test = 0;
149
				?>
150
				<tr>
151
					<th width="200">
152
						<label>PHP CURL/SSL Extension</label>
153
					</th>
154
					<td>
155
						<p>PHP CURL extension with SSL must be enabled and working.</p>
156
						<?php
157
							if( ! $test )
158
							{
159
								?>
160
									<div class="fade error" style="margin: 20px  0;">
161
										<p><b>Error</b>: CURL library is either not installed or SSL is not enabled.</p>
162
										<p>The solution is to make a trouble ticket to your web host and request them to enable the PHP CURL.</p>
163
									</div>
164
								<?php
165
							}
166
						?>
167
					</td>
168
					<td>
169
						<?php
170
							if( $test )
171
							{
172
								echo "<b style='color:green;'>OK!</b>";
173
							}
174
							else
175
							{
176
								echo "<b style='color:red;'>FAIL!</b>";
177
							}
178
						?>
179
					</td>
180
				</tr>
181
182
				<?php
183
					$test = ! ini_get('register_globals') ? true : false;
184
					// $test = 0;
185
				?>
186
				<tr>
187
					<th width="200">
188
						<label>PHP Register Globals</label>
189
					</th>
190
					<td>
191
						<p>PHP Register Globals must be OFF.</p>
192
					<?php
193
						if(  ! $test )
194
						{
195
							?>
196
								<div class="fade error" style="margin: 20px  0;">
197
									<p><b>Error</b>: REGISTER_GLOBALS are On.</p>
198
									<p>This will prevent WSL from working properly and will result on an infinite loop on the authentication page.</p>
199
									<p>The solution is to make a trouble ticket with your web host to disable it, Or, if you have a dedicated server and you know what are you doing then edit php.ini file and turn it Off.</p>
200
								</div>
201
							<?php
202
						}
203
					?>
204
					</td>
205
					<td>
206
						<?php
207
							if( $test )
208
							{
209
								echo "<b style='color:green;'>OK!</b>";
210
							}
211
							else
212
							{
213
								echo "<b style='color:red;'>FAIL!</b>";
214
							}
215
						?>
216
					</td>
217
				</tr>
218
219
				<!-- this should keep Mika happy -->
220
				<tr>
221
					<th width="200">
222
						<label>WSL end-points</label>
223
					</th>
224
					<td>
225
						<p>Check if WSL end-points urls are reachable.</p>
226
227
						<div id="end_points_warn" class="fade error" style="margin: 20px  0;display:none;">
228
							<p><b>Error</b>: Your web server returned <span id="end_points_error"></span> when checking WSL end-points.</p>
229
230
							<p>This issue usually happen when :</p>
231
							<p>1. Your web host uses <code>mod_security</code> to block requests containing URLs (eg. hosts like HostGator, GoDaddy and The Planet). On this case, you should contact your provider to have WSL end-points urls white-listed.</p>
232
							<p>2. There is a <code>.htaccess</code> file that prevent direct access to the WordPress plugins directory.</p>
233
234
							<p>In any case, WSL requires this url to be white-listed:</p>
235
236
							<div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;">
237
								<?php
238
									echo '<a href="' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '" target="_blank">' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '</a>';
239
								?>
240
							</div>
241
						</div>
242
243
						<div id="end_points_note" style="margin: 20px  0;">
244
							<hr />
245
246
							<p><b>Note</b>: In case you're using <code>mod_security</code> to block requests containing URLs or a <code>.htaccess</code> file to protect the WordPress plugins directory, WSL will requires this url to be white-listed:</p>
247
248
							<div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;">
249
								<?php
250
									echo '<a href="' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '" target="_blank">' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '</a>';
251
								?>
252
							</div>
253
						</div>
254
255
						<p>You may double-check this test manually by clicking this <a href="<?php echo WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL; ?>?end_points_test=http://example.com" target="_blank">direct link</a>.</p>
256
					</td>
257
					<td width="60">
258
						<span id="end_points">testing..</span>
259
						<script>
260
							jQuery(document).ready(function($) {
261
								jQuery.ajax({
262
									url: '<?php echo WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL; ?>',
263
									data: 'end_points_test=http://example.com',
264
									success: function () {
265
										jQuery('#end_points').html( '<b style="color:green;">OK!</b>' );
266
									},
267
									error: function (xhr, ajaxOptions, thrownError) {
268
										jQuery('#end_points_error').html( '"<b style="color:red;">' + xhr.status + ' ' + xhr.statusText + '</b>"' );
269
										jQuery('#end_points').html( '<b style="color:red;">FAIL!</b>' );
270
										jQuery('#end_points_warn').show();
271
										jQuery('#end_points_note').hide();
272
									}
273
								});
274
							});
275
						</script>
276
					</td>
277
				</tr>
278
279
				<?php
280
					global $wpdb;
281
282
					$db_check_profiles = $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wslusersprofiles'" ) === $wpdb->prefix . 'wslusersprofiles' ? 1 : 0;
283
					$db_check_contacts = $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wsluserscontacts'" ) === $wpdb->prefix . 'wsluserscontacts' ? 1 : 0;
284
285
					$test = $db_check_profiles && $db_check_contacts ? true : false;
286
				?>
287
				<tr>
288
					<th width="200">
289
						<label>WSL database tables</label>
290
					</th>
291
					<td>
292
						<p>Check if WSL database tables (<code>wslusersprofiles</code> and <code>wsluserscontacts</code>) exist.</p>
293
						<?php
294
							if( ! $test )
295
							{
296
								?>
297
									<div class="fade error" style="margin: 20px  0;">
298
										<p><b>Error:</b> One or more of WordPress Social Login tables do not exist.</p>
299
										<p>This may prevent this plugin form working correctly. To fix this, navigate to <b>Tools</b> tab then <b><a href="options-general.php?page=wordpress-social-login&wslp=tools#repair-tables">Repair WSL tables</a></b>.</p>
300
									</div>
301
								<?php
302
							}
303
						?>
304
					</td>
305
					<td width="60">
306
						<?php
307
							if( $test )
308
							{
309
								echo "<b style='color:green;'>OK!</b>";
310
							}
311
							else
312
							{
313
								echo "<b style='color:red;'>FAIL!</b>";
314
							}
315
						?>
316
					</td>
317
				</tr>
318
319
				<?php
320
					$test = class_exists( 'Hybridauth\Hybridauth', false ) ? false : true;
321
				?>
322
				<tr>
323
					<th width="200">
324
						<label>Hybridauth Library</label>
325
					</th>
326
					<td>
327
						<p>Check if the Hybridauth Library is auto-loaded by another plugin.</p>
328
						<?php
329 View Code Duplication
							if( ! $test )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
330
							{
331
								?>
332
									<div class="fade error" style="margin: 20px  0;">
333
										<p>Hybridauth Library is auto-included by another plugin.</p>
334
										<p>This is not critical but it may prevent WSL from working.</p>
335
										<p>Please, inform the developer of that plugin not to auto-include the file below and to use Hybridauth Library only when required.</p>
336
										<div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;">
337
										<?php try{$reflector = new ReflectionClass( 'Hybridauth\Hybridauth' ); echo $reflector->getFileName(); } catch( Exception $e ){} ?>
0 ignored issues
show
introduced by
Consider moving this CATCH statement to a new line.
Loading history...
338
										</div>
339
									</div>
340
								<?php
341
							}
342
						?>
343
					</td>
344
					<td>
345
						<?php
346
							if( $test )
347
							{
348
								echo "<b style='color:green;'>OK!</b>";
349
							}
350
							else
351
							{
352
								echo "<b style='color:orange;'>PASS</b>";
353
							}
354
						?>
355
					</td>
356
				</tr>
357
358
				<?php
359
					$test = class_exists( 'OAuthConsumer', false ) ? false : true;
360
				?>
361
				<tr>
362
					<th width="200">
363
						<label>OAUTH Library</label>
364
					</th>
365
					<td>
366
						<p>Check if OAUTH Library is auto-loaded by another plugin.</p>
367
						<?php
368 View Code Duplication
							if( ! $test )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
369
							{
370
								?>
371
									<div class="fade error" style="margin: 20px  0;">
372
										<p>OAUTH Library is auto-included by another plugin.</p>
373
										<p>This is not critical but it may prevent Twitter, LinkedIn and few other providers from working.</p>
374
										<p>Please, inform the developer of that plugin not to auto-include the file below and to use OAUTH Library only when required.</p>
375
										<div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;">
376
										<?php try{$reflector = new ReflectionClass( 'OAuthConsumer' ); echo $reflector->getFileName(); } catch( Exception $e ){} ?>
0 ignored issues
show
introduced by
Consider moving this CATCH statement to a new line.
Loading history...
377
										</div>
378
									</div>
379
								<?php
380
							}
381
						?>
382
					</td>
383
					<td>
384
						<?php
385
							if( $test )
386
							{
387
								echo "<b style='color:green;'>OK!</b>";
388
							}
389
							else
390
							{
391
								echo "<b style='color:orange;'>PASS</b>";
392
							}
393
						?>
394
					</td>
395
				</tr>
396
397
				<?php
398
					$test = class_exists( 'BaseFacebook', false ) ? false : true;
399
				?>
400
				<tr>
401
					<th width="200">
402
						<label>Facebook SDK</label>
403
					</th>
404
					<td>
405
						<p>Check if Facebook SDK is auto-loaded by another plugin.</p>
406
						<?php
407 View Code Duplication
							if( ! $test )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
408
							{
409
								?>
410
									<div class="fade error" style="margin: 20px  0;">
411
										<p><b>Error:</b> Facebook SDK is auto-included by another plugin.</p>
412
										<p>This will prevent Facebook from working.</p>
413
										<p>Please, inform the developer of that plugin not to auto-include the file below and to use Facebook SDK only when required.</p>
414
										<div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;">
415
										<?php try{$reflector = new ReflectionClass( 'BaseFacebook' ); echo $reflector->getFileName(); } catch( Exception $e ){} ?>
0 ignored issues
show
introduced by
Consider moving this CATCH statement to a new line.
Loading history...
416
										</div>
417
									</div>
418
								<?php
419
							}
420
						?>
421
					</td>
422
					<td>
423
						<?php
424
							if( $test )
425
							{
426
								echo "<b style='color:green;'>OK!</b>";
427
							}
428
							else
429
							{
430
								echo "<b style='color:red;'>FAIL!</b>";
431
							}
432
						?>
433
					</td>
434
				</tr>
435
436
				<?php
437
					$test = class_exists( 'LightOpenID', false ) ? false : true;
438
				?>
439
				<tr>
440
					<th width="200">
441
						<label>Class LightOpenID</label>
442
					</th>
443
					<td>
444
						<p>Check if the LightOpenID Class is auto-loaded by another plugin.</p>
445
						<?php
446 View Code Duplication
							if( ! $test )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
447
							{
448
								?>
449
									<div class="fade error" style="margin: 20px  0;">
450
										<p>Class LightOpenID is auto-included by another plugin.</p>
451
										<p>This is not critical but it may prevent Yahoo, Steam, and few other providers from working.</p>
452
										<p>Please, inform the developer of that plugin not to auto-include the file below and to use Class LightOpenID only when required.</p>
453
										<div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;">
454
										<?php try{$reflector = new ReflectionClass( 'LightOpenID' ); echo $reflector->getFileName(); } catch( Exception $e ){} ?>
0 ignored issues
show
introduced by
Consider moving this CATCH statement to a new line.
Loading history...
455
										</div>
456
									</div>
457
								<?php
458
							}
459
						?>
460
					</td>
461
					<td>
462
						<?php
463
							if( $test )
464
							{
465
								echo "<b style='color:green;'>OK!</b>";
466
							}
467
							else
468
							{
469
								echo "<b style='color:orange;'>PASS</b>";
470
							}
471
						?>
472
					</td>
473
				</tr>
474
475
				<?php
476
					$curl = '';
477
					$test = true;
478
479
					if( ! class_exists( 'Hybridauth\Hybridauth', false ) )
480
					{
481
						require_once WORDPRESS_SOCIAL_LOGIN_ABS_PATH . 'hybridauth/library/src/autoload.php';
482
483
						$curl = Hybridauth\HttpClient\Util::getCurrentUrl();
484
					}
485
486
					$headers = array( 'HTTP_VIA', 'HTTP_X_FORWARDED_FOR', 'HTTP_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_FORWARDED', 'HTTP_CLIENT_IP', 'HTTP_FORWARDED_FOR_IP', 'VIA', 'X_FORWARDED_FOR', 'FORWARDED_FOR', 'X_FORWARDED', 'FORWARDED', 'CLIENT_IP', 'FORWARDED_FOR_IP', 'HTTP_PROXY_CONNECTION' );
487
					foreach( $headers as $v )
488
					{
489
						if( isset( $_SERVER[ $v ] ) ) $test = true;
490
					}
491
				?>
492
				<tr>
493
					<th width="200">
494
						<label>HTTP Proxies</label>
495
					</th>
496
					<td>
497
						<p>Check for proxified urls.</p>
498
						<?php
499
							if( ! $test )
500
							{
501
								?>
502
									<div class="fade error" style="margin: 20px  0;">
503
										<p>WSL has detected that you are using a proxy in your website. The URL shown below should match the URL on your browser address bar.</p>
504
										<div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;">
505
											<?php
506
												echo $curl;
507
											?>
508
										</div>
509
									</div>
510
								<?php
511
							}
512
						?>
513
					</td>
514
					<td>
515
						<?php
516
							if( $test )
517
							{
518
								echo "<b style='color:green;'>OK!</b>";
519
							}
520
							else
521
							{
522
								echo "<b style='color:orange;'>PASS</b>";
523
							}
524
						?>
525
					</td>
526
				</tr>
527
528
				<?php
529
					$test = ! stristr( plugins_url(), home_url() ) ? false : true;
530
				?>
531
				<tr>
532
					<th width="200">
533
						<label>WordPress functions</label>
534
					</th>
535
					<td>
536
						<p>Check for WordPress directories functions.</p>
537
						<?php
538
							if( ! $test )
539
							{
540
								?>
541
									<hr />
542
									<p><code>plugins_url()</code> is not returning an expected result : <?php echo plugins_url(); ?></p>
543
								<?php
544
							}
545
						?>
546
					</td>
547
					<td>
548
						<?php
549
							if( $test )
550
							{
551
								echo "<b style='color:green;'>OK!</b>";
552
							}
553
							else
554
							{
555
								echo "<b style='color:orange;'>PASS</b>";
556
							}
557
						?>
558
					</td>
559
				</tr>
560
561
				<?php
562
					$test = true;
563
					$used = array();
564
565
					$depreciated = array(
566
					// auth
567
						'wsl_hook_process_login_alter_userdata',
568
						'wsl_hook_process_login_before_insert_user',
569
						'wsl_hook_process_login_after_create_wp_user',
570
						'wsl_hook_process_login_before_set_auth_cookie',
571
						'wsl_hook_process_login_before_redirect',
572
573
					// widget
574
						'wsl_render_login_form_start',
575
						'wsl_alter_hook_provider_icon_markup',
576
						'wsl_render_login_form_alter_provider_icon_markup',
577
						'wsl_render_login_form_end',
578
					);
579
580
					foreach( $depreciated as $v )
581
					{
582
						if( has_filter( $v ) || has_action( $v ) )
583
						{
584
							$test = false;
585
							$used[] = $v;
586
						}
587
					}
588
				?>
589
				<tr>
590
					<th width="200">
591
						<label>WSL depreciated hooks</label>
592
					</th>
593
					<td>
594
						<p>Check for depreciated WSL actions and filters in use.</p>
595
						<?php
596
							if( ! $test )
597
							{
598
								?>
599
									<div class="fade error" style="margin: 20px  0;">
600
										<p>WSL has detected that you are using depreciated WSL: <code><?php echo implode( '</code>, <code>', $used ); ?></code></p>
601
										<p>Please update the WSL hooks you were using accordingly to the new developer API at <a href="http://miled.github.io/wordpress-social-login/documentation.html" target="_blank">http://miled.github.io/wordpress-social-login/documentation.html</a></p>
602
									</div>
603
								<?php
604
							}
605
						?>
606
						<p> Note: this test is not reliable 100% as we simply match the depreciated hooks against <code>has_filter</code> and <code>has_action</code>.</p>
607
					</td>
608
					<td>
609
						<?php
610
							if( $test )
611
							{
612
								echo "<b style='color:green;'>OK!</b>";
613
							}
614
							else
615
							{
616
								echo "<b style='color:orange;'>PASS</b>";
617
							}
618
						?>
619
					</td>
620
				</tr>
621
622
				<?php
623
					$itsec_tweaks = get_option( 'itsec_tweaks' );
624
625
					$test = $itsec_tweaks && $itsec_tweaks['long_url_strings'] ? false : true;
626
				?>
627
				<tr>
628
					<th width="200">
629
						<label>iThemes Security</label>
630
					</th>
631
					<td>
632
						<p>Check if 'Prevent long URL strings' option is enabled.</p>
633
						<?php
634
							if( ! $test )
635
							{
636
								?>
637
									<div class="fade error" style="margin: 20px  0;">
638
										<p><b>Error:</b> 'Prevent long URL strings' option is in enabled.</p>
639
										<p>This may prevent Facebook and few other providers from working.</p>
640
									</div>
641
								<?php
642
							}
643
						?>
644
					</td>
645
					<td>
646
						<?php
647
							if( $test )
648
							{
649
								echo "<b style='color:green;'>OK!</b>";
650
							}
651
							else
652
							{
653
								echo "<b style='color:red;'>FAIL!</b>";
654
							}
655
						?>
656
					</td>
657
				</tr>
658
659
				<?php
660
					/**
661
					* Check twitter timestamp
662
					*
663
					* Thanks much Joe for the cool idea
664
					* https://wordpress.org/plugins/wp-to-twitter/
665
					*/
666
					$test         = true;
667
					$error        = '';
668
					$hint         = '';
669
					$server_time  = date( DATE_COOKIE );
670
					$response     = wp_remote_get( "https://api.twitter.com/1.1/help/test.json", array( 'timeout' => 2, 'redirection' => 1 ) );
671
672
					if ( is_wp_error( $response ) )
673
					{
674
						$test = false;
675
						$error = __("There was an error querying Twitter's servers", 'wordpress-social-login');
676
					}
677
					else
678
					{
679
						if( time() < strtotime( $response['headers']['date'] )- 300 || time() > strtotime( $response['headers']['date'] ) + 300 )
680
						{
681
							$test  = false;
682
							$error = _wsl__("Your web server date is set incorrectly. This may prevent Twitter and LinkedIn and few other providers from working", 'wordpress-social-login');
683
							$hint = sprintf( _wsl__("Please check if your web server time is correct: <code>%s</code>", 'wordpress-social-login'), $server_time );
684
						}
685
					}
686
				?>
687
				<tr>
688
					<th width="200">
689
						<label>Server Timestamp</label>
690
					</th>
691
					<td>
692
						<p>Check if your web server clock is in sync.</p>
693
						<?php
694
							if( ! $test )
695
							{
696
								?>
697
									<div class="fade error" style="margin: 20px  0;">
698
										<p><b>Error:</b> <?php echo $error; ?>.</p>
699
										<?php if( $hint ) echo '<p>' . $hint . '.</p>'; ?>
700
									</div>
701
								<?php
702
							}
703
						?>
704
					</td>
705
					<td>
706
						<?php
707
							if( $test )
708
							{
709
								echo "<b style='color:green;'>OK!</b>";
710
							}
711
							else
712
							{
713
								echo "<b style='color:orange;'>PASS</b>";
714
							}
715
						?>
716
					</td>
717
				</tr>
718
			</table>
719
720
			<br />
721
			<hr />
722
723
			<a class="button-secondary" href="options-general.php?page=wordpress-social-login&wslp=tools">&larr; <?php _wsl_e("Back to Tools", 'wordpress-social-login') ?></a>
724
		</div>
725
	</div>
726
</div>
727
<?php
728
}
729
730
add_action( 'wsl_component_tools_do_diagnostics', 'wsl_component_tools_do_diagnostics' );
731
732
// --------------------------------------------------------------------
733
734
function wsl_component_tools_do_sysinfo()
735
{
736
	global $wpdb;
737
	global $WORDPRESS_SOCIAL_LOGIN_VERSION;
738
	global $WORDPRESS_SOCIAL_LOGIN_COMPONENTS;
739
	global $WORDPRESS_SOCIAL_LOGIN_ADMIN_TABS;
740
	global $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG;
741
?>
742
<div class="metabox-holder columns-2" id="post-body">
743
	<div class="stuffbox">
744
		<h3>
745
			<label><?php _wsl_e("System information", 'wordpress-social-login') ?></label>
746
		</h3>
747
		<div class="inside">
748
			<ul style="padding-left:15px;">
749
				<li>Please include this information when posting support requests. It will help me immensely to better understand any issues.</li>
750
				<li>These information should be communicated to the plugin developer <b>PRIVATELY VIA EMAIL</b> : Miled &lt;<a href="mailto:[email protected]">[email protected]</a>&gt;</li>
751
			</ul>
752
<textarea onclick="this.focus(); this.select()" style="height: 500px;overflow: auto;white-space: pre;width: 100%;font-family: Menlo,Monaco,monospace;">
753
# GENERAL
754
755
SITE_URL:                 <?php echo site_url() . "\n"; ?>
756
HOME_URL:                 <?php echo home_url() . "\n"; ?>
757
PLUGIN_URL:               <?php echo plugins_url() . "\n"; ?>
758
759
# WORDPRESS SOCIAL LOGIN
760
761
WSL VERSION:              <?php echo $WORDPRESS_SOCIAL_LOGIN_VERSION . "\n"; ?>
762
WSL PROFILES TABLE:       <?php echo $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wslusersprofiles'" ) . ' (' . $wpdb->get_var( "SELECT COUNT( * ) FROM {$wpdb->prefix}wslusersprofiles" ) . ")\n"; ?>
763
WSL CONTACTS TABLE:       <?php echo $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wsluserscontacts'" ) . ' (' . $wpdb->get_var( "SELECT COUNT( * ) FROM {$wpdb->prefix}wsluserscontacts" ) . ")\n"; ?>
764
WSL COMPONENTS:           <?php foreach( $WORDPRESS_SOCIAL_LOGIN_COMPONENTS as $name => $settings ){ if( $settings["enabled"] ){ echo strtoupper( $name ) . ' '; } } echo "\n"; ?>
765
WSL TABS:                 <?php foreach( $WORDPRESS_SOCIAL_LOGIN_ADMIN_TABS as $name => $settings ){ if( $settings["enabled"] && $settings["visible"] ){ echo strtoupper( $name ) . ' '; } } echo "\n"; ?>
766
WSL NETWORKS:             <?php foreach( $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG as $provider ){ if( get_option( 'wsl_settings_' . $provider['provider_id'] . '_enabled' ) ){ echo strtoupper( $provider['provider_id'] ) . ' '; } } echo "\n"; ?>
767
WSL ABS URL:              <?php echo WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . "\n"; ?>
768
WSL ENDPOINT:             <?php echo WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . "\n"; ?>
769
770
# WORDPRESS
771
772
WORDPRESS VERSION:        <?php echo get_bloginfo( 'version' ) . "\n"; ?>
773
WORDPRESS MULTI-SITE:     <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
774
775
# SOFTWARE
776
777
USER AGENT:               <?php echo esc_html( $_SERVER['HTTP_USER_AGENT'] ) . "\n"; ?>
778
SERVER INFO:              <?php echo esc_html( $_SERVER['SERVER_SOFTWARE'] ) . "\n"; ?>
779
SERVER TIME:              <?php echo date( DATE_RFC2822 ) . ' / ' . time() . "\n"; ?>
780
PHP VERSION:              <?php echo PHP_VERSION . "\n"; ?>
781
MYSQL VERSION:            <?php echo $wpdb->db_version() . "\n"; ?>
782
783
# SESSION and COOKIEIS
784
785
SESSION:                  <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; echo "\n"; ?>
786
SESSION:NAME:             <?php echo esc_html( ini_get( 'session.name' ) ); echo "\n"; ?>
787
SESSION:WSL               <?php echo $_SESSION["wsl::plugin"]; echo "\n"; ?>
788
789
COOKIE PATH:              <?php echo esc_html( ini_get( 'session.cookie_path' ) ); echo "\n"; ?>
790
SAVE PATH:                <?php echo esc_html( ini_get( 'session.save_path' ) ); echo "\n"; ?>
791
USE COOKIES:              <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; echo "\n"; ?>
792
USE ONLY COOKIES:         <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; echo "\n"; ?>
793
794
# REQUIRED PHP EXTENSIONS
795
796
PHP/CURL:                 <?php echo function_exists( 'curl_init'   ) ? "Supported" : "Not supported"; echo "\n"; ?>
797
<?php if( function_exists( 'curl_init' ) ): ?>
798
PHP/CURL/VER:             <?php $v = curl_version(); echo $v['version']; echo "\n"; ?>
799
PHP/CURL/SSL:             <?php $v = curl_version(); echo $v['ssl_version']; echo "\n"; ?><?php endif; ?>
800
PHP/FSOCKOPEN:            <?php echo function_exists( 'fsockopen'   ) ? "Supported" : "Not supported"; echo "\n"; ?>
801
PHP/JSON:                 <?php echo function_exists( 'json_decode' ) ? "Supported" : "Not supported"; echo "\n"; ?>
802
803
# HTTP
804
805
HTTP_HOST:                <?php echo $_SERVER['HTTP_HOST'] . "\n"; ?>
806
SERVER_PORT:              <?php echo isset( $_SERVER['SERVER_PORT'] ) ? 'On (' . $_SERVER['SERVER_PORT'] . ')' : 'N/A'; echo "\n"; ?>
807
HTTP_X_FORWARDED_PROTO:   <?php echo isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ? 'On (' . $_SERVER['HTTP_X_FORWARDED_PROTO'] . ')' : 'N/A'; echo "\n"; ?>
808
809
# ACTIVE PLUGINS
810
811
<?php
812
if( function_exists("get_plugins") ):
813
	$plugins = get_plugins();
814
	foreach ( $plugins as $plugin_path => $plugin ):
815
		echo str_pad( $plugin['Version'], 10, " ", STR_PAD_LEFT ); ?>. <?php echo $plugin['Name']."\n";
816
	endforeach;
817
else:
818
	$active_plugins = get_option( 'active_plugins', array() );
819
	foreach ( $active_plugins as $plugin ):
820
		echo $plugin ."\n";
821
	endforeach;
822
endif; ?>
823
824
# CURRENT THEME
825
826
<?php
827
if ( get_bloginfo( 'version' ) < '3.4' ) {
828
	$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
829
	echo str_pad( $theme_data['Version'], 10, " ", STR_PAD_LEFT ) . '. ' . $theme_data['Name'];
830
} else {
831
	$theme_data = wp_get_theme();
832
	echo str_pad( $theme_data->Version, 10, " ", STR_PAD_LEFT ) . '. ' . $theme_data->Name;
833
}
834
?>
835
836
837
# EOF</textarea>
838
839
			<br />
840
			<br />
841
			<a class="button-secondary" href="options-general.php?page=wordpress-social-login&wslp=tools">&larr; <?php _wsl_e("Back to Tools", 'wordpress-social-login') ?></a>
842
		</div>
843
	</div>
844
</div>
845
<?php
846
}
847
848
add_action( 'wsl_component_tools_do_sysinfo', 'wsl_component_tools_do_sysinfo' );
849
850
// --------------------------------------------------------------------
851
852
function wsl_component_tools_do_repair()
853
{
854
	global $wpdb;
855
856
	wsl_database_install();
857
858
	// update_option( 'wsl_settings_development_mode_enabled', 1 );
859
?>
860
<div class="metabox-holder columns-2" id="post-body">
861
	<div class="stuffbox">
862
		<h3>
863
			<label><?php _wsl_e("Repair Wordpress Social Login tables", 'wordpress-social-login') ?></label>
864
		</h3>
865
		<div class="inside">
866
			<p>
867
				<?php _wsl_e("All Wordpress Social Login tables and fields <em>should</em> be now restored", 'wordpress-social-login') ?>.
868
			</p>
869
			<p>
870
				<?php _wsl_e("If this still didn't work, please report this as a issue", 'wordpress-social-login') ?>.
871
			</p>
872
			<hr />
873
			<a class="button-secondary" href="options-general.php?page=wordpress-social-login&wslp=tools">&larr; <?php _wsl_e("Back to Tools", 'wordpress-social-login') ?></a>
874
		</div>
875
	</div>
876
</div>
877
<?php
878
	# ain't this clever :p
879
	$db_check_profiles = $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wslusersprofiles'" ) === $wpdb->prefix . 'wslusersprofiles' ? 1 : 0;
880
	$db_check_contacts = $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wsluserscontacts'" ) === $wpdb->prefix . 'wsluserscontacts' ? 1 : 0;
881
882
	if( $db_check_profiles && $db_check_contacts )
883
	{
884
		?>
885
			<style>.wsl-error-db-tables{display:none;}</style>
886
		<?php
887
	}
888
889
}
890
891
add_action( 'wsl_component_tools_do_repair', 'wsl_component_tools_do_repair' );
892
893
// --------------------------------------------------------------------
894
895 View Code Duplication
function wsl_component_tools_do_uninstall()
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
896
{
897
	wsl_database_uninstall();
898
?>
899
<div class="metabox-holder columns-2" id="post-body">
900
	<div class="stuffbox">
901
		<h3>
902
			<label><?php _wsl_e("Uninstall", 'wordpress-social-login') ?></label>
903
		</h3>
904
		<div class="inside">
905
			<p>
906
				<?php _wsl_e("All Wordpress Social Login tables and stored options are permanently deleted from your WordPress database", 'wordpress-social-login') ?>.
907
			</p>
908
			<p>
909
				<?php _wsl_e("To delete Wordpress Social Login files from your WordPress website, you may deactivate and uninstall it through the 'Plugins' menu in WordPress", 'wordpress-social-login') ?>.
910
			</p>
911
			<p>
912
				<?php _wsl_e("Thank you for using Wordpress Social Login", 'wordpress-social-login') ?>.
913
			</p>
914
			<p>
915
				<?php _wsl_e("Good bye", 'wordpress-social-login') ?>.
916
			</p>
917
			<hr />
918
			<a class="button-secondary" href="options-general.php?page=wordpress-social-login&wslp=tools">&larr; <?php _wsl_e("Back to Tools", 'wordpress-social-login') ?></a>
919
		</div>
920
	</div>
921
</div>
922
<?php
923
}
924
925
add_action( 'wsl_component_tools_do_uninstall', 'wsl_component_tools_do_uninstall' );
926
927
// --------------------------------------------------------------------
928