WP Hide & Security Enhancer - Version 1.3.1

Version Description

  • Moved the Disable XML-RPC authentication within Rewrite -> XML-RPC
  • HTML Comments strip out will trigger only on front side, no need for admin
  • wp-cron.php block / allow access new setting
  • New style file name now include default / new theme path to avoid 404 resource loading when using internally relative urls.
  • Modules Menu order fix
  • Writable check notification improvements for htaccess / web.config file
  • Alternative request headers when apache_response_headers for LEMP / PHP-FPM
  • IIS windows server type compatibility
  • Rewrite rules for IIS servers with web.config set-up
  • apache_response_headers and headers_list PHP functions check if available within the server
  • Code Version add and updater class structure update
  • WriteCheckString check fix when .htaccess not exists
  • Remove description header from Style file
  • Router Engine - files post-processing
  • Separate theme, style, style proxy setting for parent and child
Download this release

Release Info

Developer nsp-code
Plugin Icon 128x128 WP Hide & Security Enhancer
Version 1.3.1
Comparing to
See all releases

Code changes from version 1.2.9 to 1.3.1

include/functions.class.php CHANGED
@@ -269,42 +269,15 @@
269
 
270
  }
271
 
 
 
272
  /**
273
- * Check if the .htaccess file is
274
  *
275
  */
276
- function is_htaccess_file_writable()
277
  {
278
- return false;
279
-
280
- $writable = FALSE;
281
-
282
- $iis7_permalinks = iis7_supports_permalinks();
283
-
284
- $home_path = get_home_path();
285
-
286
- if ( $iis7_permalinks )
287
- {
288
- if ( win_is_writable($home_path . 'web.config') )
289
- $writable = TRUE;
290
- }
291
- elseif ( $is_nginx )
292
- {
293
- $writable = FALSE;
294
- }
295
- else
296
- {
297
- if ( is_writable( $home_path . '.htaccess' ) )
298
- $writable = TRUE;
299
- }
300
-
301
- return $writable;
302
 
303
- }
304
-
305
-
306
- function get_write_check_string()
307
- {
308
  $home = set_url_scheme( get_option( 'home' ), 'http' );
309
  $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
310
  if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) )
@@ -321,38 +294,157 @@
321
 
322
  $home_path = str_replace( '\\', '/', $home_path );
323
 
324
- $result = '';
325
-
326
- if ( $markerdata = explode( "\n", implode( '', file( $home_path . '.htaccess' ) ) ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  {
328
- foreach ( $markerdata as $markerline )
 
329
  {
330
- if (strpos($markerline, '#WriteCheckString:') !== false)
331
  {
332
- $result = trim(str_replace( '#WriteCheckString:', '', $markerline));
333
- break;
 
 
 
334
  }
335
  }
336
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
 
338
  return $result;
339
 
340
  }
341
 
342
 
343
- function htaccess_rules_applied()
344
  {
345
  $status = TRUE;
346
 
347
  if(isset($this->wph->settings['write_check_string']) && !empty($this->wph->settings['write_check_string']))
348
  {
349
- $htaccess_write_check_string = $this->get_write_check_string();
350
- if(empty($htaccess_write_check_string) || $htaccess_write_check_string != $this->wph->settings['write_check_string'])
351
  $status = FALSE;
352
  }
353
  else
354
  {
355
- //disable, as settings never being saved
356
  $status = FALSE;
357
  }
358
 
@@ -459,6 +551,23 @@
459
  return $path;
460
 
461
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
462
 
463
  function untrailingslashit_all($value)
464
  {
@@ -592,7 +701,7 @@
592
  function is_other_template($template)
593
  {
594
 
595
- if($this->wph->templates_data['is_child_theme'] === TRUE)
596
  {
597
  if($this->wph->templates_data['child']['folder_name'] == $template)
598
  return FALSE;
@@ -1205,6 +1314,26 @@
1205
 
1206
  return $plugin_data;
1207
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1208
 
1209
 
1210
  }
269
 
270
  }
271
 
272
+
273
+
274
  /**
275
+ * return the server home path
276
  *
277
  */
278
+ function get_home_path()
279
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
 
 
 
 
 
 
281
  $home = set_url_scheme( get_option( 'home' ), 'http' );
282
  $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
283
  if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) )
294
 
295
  $home_path = str_replace( '\\', '/', $home_path );
296
 
297
+ return $home_path;
298
+
299
+ }
300
+
301
+
302
+ /**
303
+ * return whatever server using the .htaccess config file
304
+ *
305
+ */
306
+ function server_use_htaccess_config_file()
307
+ {
308
+ $home_path = $this->get_home_path();
309
+
310
+ $htaccess_file = $home_path.'.htaccess';
311
+
312
+ if (apache_mod_loaded('mod_rewrite', true))
313
+ return TRUE;
314
+
315
+ return FALSE;
316
+
317
+ }
318
+
319
+
320
+ /**
321
+ * return whatever the htaccess config file is writable
322
+ *
323
+ */
324
+ function is_writable_htaccess_config_file()
325
+ {
326
+ $home_path = $this->get_home_path();
327
+
328
+ $htaccess_file = $home_path.'.htaccess';
329
+
330
+ if ((!file_exists($htaccess_file) && is_writable($home_path) && $this->is_permalink_enabled()) || is_writable($htaccess_file))
331
+ return TRUE;
332
+
333
+ return FALSE;
334
+
335
+ }
336
+
337
+
338
+ /**
339
+ * return whatever server using the .htaccess config file
340
+ *
341
+ */
342
+ function server_use_web_config_file()
343
+ {
344
+ $home_path = $this->get_home_path();
345
+
346
+ $web_config_file = $home_path . 'web.config';
347
+
348
+ if ( iis7_supports_permalinks() )
349
+ return TRUE;
350
+
351
+ return FALSE;
352
+
353
+ }
354
+
355
+
356
+ /**
357
+ * return whatever the web.config config file is writable
358
+ *
359
+ */
360
+ function is_writable_web_config_file()
361
+ {
362
+ $home_path = $this->get_home_path();
363
+
364
+ $web_config_file = $home_path . 'web.config';
365
+
366
+ if ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $this->is_permalink_enabled() ) || win_is_writable($web_config_file) )
367
+ return TRUE;
368
+
369
+ return FALSE;
370
+
371
+ }
372
+
373
+
374
+ function get_write_check_string()
375
+ {
376
+ $home_path = $this->get_home_path();
377
+
378
+ global $wp_rewrite;
379
+
380
+ $result = FALSE;
381
+
382
+ //check for .htaccess
383
+ if ( $this->server_use_htaccess_config_file() && file_exists($home_path . '.htaccess'))
384
  {
385
+
386
+ if ( $markerdata = explode( "\n", implode( '', file( $home_path . '.htaccess' ) ) ));
387
  {
388
+ foreach ( $markerdata as $markerline )
389
  {
390
+ if (strpos($markerline, '#WriteCheckString:') !== false)
391
+ {
392
+ $result = trim(str_replace( '#WriteCheckString:', '', $markerline));
393
+ break;
394
+ }
395
  }
396
  }
397
  }
398
+
399
+ //check for web.config
400
+ if ( $this->server_use_web_config_file() && file_exists( $home_path . 'web.config' ))
401
+ {
402
+ $file_data = file( $home_path . 'web.config' );
403
+ if(!empty($file_data))
404
+ {
405
+ if ( $markerdata = explode( "\n", implode( '', $file_data ) ));
406
+ {
407
+ foreach ( $markerdata as $markerline )
408
+ {
409
+ preg_match("'<rule name=\"wph-.*?<!-- WriteCheckString:([0-9_]+) --></rule>'si", $markerline, $matches);
410
+ if(isset($matches[1]))
411
+ {
412
+ $result = $matches[1];
413
+ }
414
+
415
+ if (!isset($matches[1]) && strpos($markerline, '<!-- WriteCheckString:') !== false)
416
+ {
417
+ $result = trim(str_ireplace( '<!-- WriteCheckString:', '', $markerline));
418
+ $result = trim(str_replace( '-->', '', $result));
419
+ $result = trim($result);
420
+
421
+ break;
422
+ }
423
+ }
424
+ }
425
+
426
+ }
427
+
428
+ }
429
 
430
  return $result;
431
 
432
  }
433
 
434
 
435
+ function rewrite_rules_applied()
436
  {
437
  $status = TRUE;
438
 
439
  if(isset($this->wph->settings['write_check_string']) && !empty($this->wph->settings['write_check_string']))
440
  {
441
+ $_write_check_string = $this->get_write_check_string();
442
+ if(empty($_write_check_string) || $_write_check_string != $this->wph->settings['write_check_string'])
443
  $status = FALSE;
444
  }
445
  else
446
  {
447
+ //disable, as settings never being saved or came from old version
448
  $status = FALSE;
449
  }
450
 
551
  return $path;
552
 
553
  }
554
+
555
+
556
+ /**
557
+ * return the url relative to domain root
558
+ *
559
+ * @param mixed $url
560
+ */
561
+ function get_url_path_relative_to_domain_root($url)
562
+ {
563
+
564
+ $url = str_replace(trailingslashit( site_url() ), "" , $url);
565
+
566
+ return $url;
567
+
568
+ }
569
+
570
+
571
 
572
  function untrailingslashit_all($value)
573
  {
701
  function is_other_template($template)
702
  {
703
 
704
+ if($this->wph->templates_data['use_child_theme'] === TRUE)
705
  {
706
  if($this->wph->templates_data['child']['folder_name'] == $template)
707
  return FALSE;
1314
 
1315
  return $plugin_data;
1316
  }
1317
+
1318
+
1319
+ /**
1320
+ * Alternative when apache_response_headers() not available
1321
+ *
1322
+ */
1323
+ function parseRequestHeaders()
1324
+ {
1325
+ $headers = array();
1326
+ foreach($_SERVER as $key => $value)
1327
+ {
1328
+ if (substr($key, 0, 5) <> 'HTTP_')
1329
+ continue;
1330
+
1331
+ $header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
1332
+ $headers[$header] = $value;
1333
+ }
1334
+
1335
+ return $headers;
1336
+ }
1337
 
1338
 
1339
  }
include/update.class.php CHANGED
@@ -15,10 +15,11 @@
15
 
16
 
17
  private function _run()
18
- {
19
- $db_version = isset($this->wph->settings['version']) ? $this->wph->settings['version'] : '1';
20
 
21
  //structure and settings fields where changed since v1.1
 
22
  if( isset($this->wph->settings['module_settings']['rewrite_new_theme_path']) )
23
  {
24
  $module_settings = $this->wph->settings['module_settings'];
@@ -44,10 +45,70 @@
44
 
45
  //save the data
46
  $this->wph->functions->update_settings($this->wph->settings);
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  }
53
 
15
 
16
 
17
  private function _run()
18
+ {
19
+ $version = isset($this->wph->settings['version']) ? $this->wph->settings['version'] : 1;
20
 
21
  //structure and settings fields where changed since v1.1
22
+ //This block will be removed in a later version
23
  if( isset($this->wph->settings['module_settings']['rewrite_new_theme_path']) )
24
  {
25
  $module_settings = $this->wph->settings['module_settings'];
45
 
46
  //save the data
47
  $this->wph->functions->update_settings($this->wph->settings);
48
+ }
49
+
50
+
51
+ if (version_compare(WPH_VERSION, $version, '>'))
52
+ {
53
+
54
+ if(version_compare($version, '1.3', '<'))
55
+ {
56
+ //flush rules
57
+ add_action('wp_loaded', array($this, 'flush_rules') , -1);
58
+
59
+ $this->wph->settings['version'] = '1.3';
60
+ $this->wph->functions->update_settings($this->wph->settings);
61
+ }
62
+ else if(version_compare($version, '1.3.1', '<'))
63
+ {
64
+ //run update 2
65
+ }
66
+ else
67
+ {
68
+ //save the last code version
69
+ $this->wph->settings['version'] = WPH_VERSION;
70
+ $this->wph->functions->update_settings($this->wph->settings);
71
+
72
+ }
73
+ }
74
+
75
+
76
  }
77
 
78
 
79
+ /**
80
+ * Regenerate rewrite rules
81
+ *
82
+ */
83
+ function flush_rules()
84
+ {
85
+ /** WordPress Misc Administration API */
86
+ require_once(ABSPATH . 'wp-admin/includes/misc.php');
87
+
88
+ /** WordPress Administration File API */
89
+ require_once(ABSPATH . 'wp-admin/includes/file.php');
90
+
91
+ flush_rewrite_rules();
92
+
93
+ //clear the cache for W3 Cache
94
+ if (function_exists('w3tc_pgcache_flush'))
95
+ w3tc_pgcache_flush();
96
+
97
+ //recheck if permalinks where saved sucessfully and redirect
98
+
99
+ /**
100
+ * ToDo Possible not necesarely?
101
+ * 1) Through AJAX, plugin update - it trigger the first update so flush_rules()
102
+ * 2) Through regular plugin update, no new plugin files are being run
103
+ */
104
+ if( !defined( 'DOING_AJAX' ) && $this->wph->permalinks_not_applied === FALSE && $this->wph->functions->rewrite_rules_applied() === TRUE)
105
+ {
106
+ //reload the page
107
+ wp_redirect($this->wph->functions->get_current_url());
108
+ die();
109
+ }
110
+
111
+ }
112
 
113
  }
114
 
include/wph.class.php CHANGED
@@ -7,6 +7,9 @@
7
  var $templates_data = array();
8
  var $urls_replacement = array();
9
 
 
 
 
10
  var $modules = array();
11
 
12
  var $settings;
@@ -42,6 +45,10 @@
42
 
43
  $this->settings = $this->functions->get_settings();
44
 
 
 
 
 
45
  //check for recovery link run
46
  if(isset($_GET['wph-recovery']))
47
  $this->functions->do_recovery();
@@ -61,7 +68,7 @@
61
  }
62
 
63
  //check for permalink issues
64
- $this->permalinks_not_applied = ! $this->functions->htaccess_rules_applied();
65
 
66
  $this->get_default_variables();
67
 
@@ -78,7 +85,7 @@
78
  //process redirects
79
  add_action('wp_redirect', array($this, 'wp_redirect') , 999, 2);
80
  //hijack a redirect on permalink change
81
- add_action('admin_head', array($this, 'permalink_change_redirect') , 999, 2);
82
 
83
  add_action('logout_redirect', array($this, 'logout_redirect') , 999, 3);
84
 
@@ -90,8 +97,12 @@
90
 
91
  //rebuild and change uppon settings modified
92
  add_action('wph/settings_changed', array($this, 'settings_changed'));
93
- add_filter('mod_rewrite_rules', array($this, 'mod_rewrite_rules'), 999);
94
 
 
 
 
 
 
95
  //on switch theme
96
  add_action('switch_theme', array($this, 'switch_theme'));
97
 
@@ -156,7 +167,7 @@
156
  }
157
 
158
  //sort the modules array
159
- arsort($this->modules);
160
 
161
  //filter available for mu-plugins
162
  $this->modules = apply_filters('wp-hide/loaded_modules', $this->modules);
@@ -216,7 +227,7 @@
216
  {
217
  include_once(WPH_PATH . '/include/admin-interface.class.php');
218
 
219
- $this->admin_interface = new WPH_interface();
220
 
221
  $hookID = add_menu_page('WP Hide', 'WP Hide', 'manage_options', 'wp-hide');
222
 
@@ -252,13 +263,19 @@
252
  {
253
  echo "<div class='error'><p>". __('Permalink is required to be turned ON for WP Hide & Security Enhancer to work', 'wp-hide-security-enhancer') ."</p></div>";
254
  }
255
-
256
  //check if the htaccess file is not writable
257
  if(isset($this->settings['write_check_string']) && !empty($this->settings['write_check_string']))
258
- {
259
- $htaccess_write_check_string = $this->functions->get_write_check_string();
260
- if(empty($htaccess_write_check_string) || $htaccess_write_check_string != $this->settings['write_check_string'])
261
- echo "<div class='error'><p>". __('Unable to write custom rules to your .htaccess. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
 
 
 
 
 
 
262
  }
263
 
264
  if(isset($_GET['reset_settings']))
@@ -271,6 +288,14 @@
271
 
272
  if(isset($_GET['settings_updated']))
273
  {
 
 
 
 
 
 
 
 
274
  echo "<div class='updated'><p>". __('Settings saved', 'wp-hide-security-enhancer') ."</p></div>";
275
 
276
  $this->functions->settings_changed_check_for_cache_plugins();
@@ -287,7 +312,15 @@
287
  {
288
 
289
  //check headers fir content-encoding
290
- $response_headers = apache_response_headers();
 
 
 
 
 
 
 
 
291
  if(isset($response_headers['Content-Encoding']) && $response_headers['Content-Encoding'] == "gzip")
292
  return $buffer;
293
 
@@ -410,6 +443,51 @@
410
  if($this->uninstall === TRUE)
411
  return $rules;
412
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  $processing_data = array();
414
 
415
  //loop all module settings and run the callback functions
@@ -443,48 +521,190 @@
443
  }
444
  }
445
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  //post-process the htaccess data
447
- $_htaccess_data = array();
448
  $_page_refresh = FALSE;
449
  foreach($processing_data as $response)
450
  {
451
- if(isset($response['htaccess']))
452
  {
453
- //$_htaccess_line = trim($response['htaccess']);
454
- //$_htaccess_data[] = trim($response['htaccess']);
455
-
456
- $_htaccess_data[] = $response['htaccess'];
457
  }
458
 
459
  if(isset($response['page_refresh']) && $response['page_refresh'] === TRUE)
460
  $_page_refresh = TRUE;
461
  }
462
 
463
- $write_check_string = time() . '_' . mt_rand(10000, 99999);
464
  $this->settings['write_check_string'] = $write_check_string;
465
  $this->functions->update_settings($this->settings);
466
-
467
- if(count($_htaccess_data) > 0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
468
  {
469
- $new_rules = "RewriteRule ^index\.php$ - [L] \n\n#START - WP Hide & Security Enhancer\n#WriteCheckString:" . $write_check_string;
470
- foreach($_htaccess_data as $_htaccess_data_line)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
  {
472
- $new_rules .= "\n" . $_htaccess_data_line;
 
473
  }
474
 
475
- $new_rules .= "\n#END - WP Hide & Security Enhancer\n";
476
-
477
- $new_rules = apply_filters('wp-hide/mod_rewrite_rules', $new_rules);
478
-
479
- //update the main rule variable
480
- $rules = str_replace('RewriteRule ^index\\.php$ - [L]', $new_rules, $rules);
481
  }
482
-
483
- return $rules;
484
-
485
  }
486
 
487
 
 
488
  function get_default_variables()
489
  {
490
  $this->default_variables['include_url'] = trailingslashit( site_url() ) . WPINC;
@@ -502,14 +722,14 @@
502
 
503
  $template = get_template();
504
 
505
- $this->templates_data['is_child_theme'] = (get_option( 'stylesheet' ) != get_option( 'template' )) ? TRUE : FALSE;
506
  $this->templates_data['themes_url'] = trailingslashit( str_replace($template, "", get_bloginfo('template_url')) );
507
 
508
  $this->templates_data['main'] = array();
509
  $this->templates_data['main']['folder_name'] = $template;
510
  $this->templates_data['_template_' . $template] = 'main';
511
 
512
- if($this->templates_data['is_child_theme'])
513
  {
514
  $this->templates_data['child'] = array();
515
 
@@ -583,7 +803,7 @@
583
  return;
584
 
585
  //recheck if the permalinks where sucesfully saved
586
- $this->permalinks_not_applied = ! $this->functions->htaccess_rules_applied();
587
 
588
  //ignore if permalinks are available
589
  if($this->permalinks_not_applied === TRUE)
7
  var $templates_data = array();
8
  var $urls_replacement = array();
9
 
10
+ var $server_htaccess_config = FALSE;
11
+ var $server_web_config = FALSE;
12
+
13
  var $modules = array();
14
 
15
  var $settings;
45
 
46
  $this->settings = $this->functions->get_settings();
47
 
48
+ //set whatever the server use htaccess or web.config configuration file
49
+ $this->server_htaccess_config = $this->functions->server_use_htaccess_config_file();
50
+ $this->server_web_config = $this->functions->server_use_web_config_file();
51
+
52
  //check for recovery link run
53
  if(isset($_GET['wph-recovery']))
54
  $this->functions->do_recovery();
68
  }
69
 
70
  //check for permalink issues
71
+ $this->permalinks_not_applied = ! $this->functions->rewrite_rules_applied();
72
 
73
  $this->get_default_variables();
74
 
85
  //process redirects
86
  add_action('wp_redirect', array($this, 'wp_redirect') , 999, 2);
87
  //hijack a redirect on permalink change
88
+ add_action('admin_head', array($this, 'permalink_change_redirect') , 999, 2);
89
 
90
  add_action('logout_redirect', array($this, 'logout_redirect') , 999, 3);
91
 
97
 
98
  //rebuild and change uppon settings modified
99
  add_action('wph/settings_changed', array($this, 'settings_changed'));
 
100
 
101
+ //apache
102
+ add_filter('mod_rewrite_rules', array($this, 'mod_rewrite_rules'), 999);
103
+ //IIS7 server
104
+ add_filter('iis7_url_rewrite_rules', array($this, 'iis7_url_rewrite_rules'), 999);
105
+
106
  //on switch theme
107
  add_action('switch_theme', array($this, 'switch_theme'));
108
 
167
  }
168
 
169
  //sort the modules array
170
+ ksort($this->modules);
171
 
172
  //filter available for mu-plugins
173
  $this->modules = apply_filters('wp-hide/loaded_modules', $this->modules);
227
  {
228
  include_once(WPH_PATH . '/include/admin-interface.class.php');
229
 
230
+ $this->admin_interface = new WPH_interface();
231
 
232
  $hookID = add_menu_page('WP Hide', 'WP Hide', 'manage_options', 'wp-hide');
233
 
263
  {
264
  echo "<div class='error'><p>". __('Permalink is required to be turned ON for WP Hide & Security Enhancer to work', 'wp-hide-security-enhancer') ."</p></div>";
265
  }
266
+
267
  //check if the htaccess file is not writable
268
  if(isset($this->settings['write_check_string']) && !empty($this->settings['write_check_string']))
269
+ {
270
+ $_write_check_string = $this->functions->get_write_check_string();
271
+ if(empty($_write_check_string) || $_write_check_string != $this->settings['write_check_string'])
272
+ {
273
+ if($this->server_htaccess_config === TRUE)
274
+ echo "<div class='error'><p>". __('Unable to write custom rules to your .htaccess. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
275
+
276
+ if($this->server_web_config === TRUE)
277
+ echo "<div class='error'><p>". __('Unable to write custom rules to your web.config. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
278
+ }
279
  }
280
 
281
  if(isset($_GET['reset_settings']))
288
 
289
  if(isset($_GET['settings_updated']))
290
  {
291
+
292
+ //check for write permision
293
+ if($this->server_htaccess_config === TRUE && !$this->functions->is_writable_htaccess_config_file())
294
+ echo "<div class='error'><p>". __('Unable to write custom rules to your .htaccess. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
295
+
296
+ if($this->server_web_config === TRUE && !$this->functions->is_writable_web_config_file())
297
+ echo "<div class='error'><p>". __('Unable to write custom rules to your web.config. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
298
+
299
  echo "<div class='updated'><p>". __('Settings saved', 'wp-hide-security-enhancer') ."</p></div>";
300
 
301
  $this->functions->settings_changed_check_for_cache_plugins();
312
  {
313
 
314
  //check headers fir content-encoding
315
+ if(function_exists('apache_response_headers'))
316
+ {
317
+ $response_headers = apache_response_headers();
318
+ }
319
+ else
320
+ {
321
+ $response_headers = $this->functions->parseRequestHeaders();
322
+ }
323
+
324
  if(isset($response_headers['Content-Encoding']) && $response_headers['Content-Encoding'] == "gzip")
325
  return $buffer;
326
 
443
  if($this->uninstall === TRUE)
444
  return $rules;
445
 
446
+ $processing_data = $this->get_components_rules();
447
+
448
+ //post-process the htaccess data
449
+ $_rewrite_data = array();
450
+ $_page_refresh = FALSE;
451
+ foreach($processing_data as $response)
452
+ {
453
+ if(isset($response['rewrite']) && !empty($response['rewrite']))
454
+ {
455
+ $_rewrite_data[] = $response['rewrite'];
456
+ }
457
+
458
+ if(isset($response['page_refresh']) && $response['page_refresh'] === TRUE)
459
+ $_page_refresh = TRUE;
460
+ }
461
+
462
+ $write_check_string = time() . '_' . mt_rand(100, 99999);
463
+ $this->settings['write_check_string'] = $write_check_string;
464
+ $this->functions->update_settings($this->settings);
465
+
466
+ $new_rules = "RewriteRule ^index\.php$ - [L] \n\n#START - WP Hide & Security Enhancer\n#WriteCheckString:" . $write_check_string;
467
+
468
+ if(count($_rewrite_data) > 0)
469
+ {
470
+ foreach($_rewrite_data as $_htaccess_data_line)
471
+ {
472
+ $new_rules .= "\n" . $_htaccess_data_line;
473
+ }
474
+ }
475
+
476
+ $new_rules .= "\n#END - WP Hide & Security Enhancer\n";
477
+
478
+ $new_rules = apply_filters('wp-hide/mod_rewrite_rules', $new_rules);
479
+
480
+ //update the main rule variable
481
+ $rules = str_replace('RewriteRule ^index\\.php$ - [L]', $new_rules, $rules);
482
+
483
+ return $rules;
484
+
485
+ }
486
+
487
+
488
+ function get_components_rules()
489
+ {
490
+
491
  $processing_data = array();
492
 
493
  //loop all module settings and run the callback functions
521
  }
522
  }
523
 
524
+
525
+ return $processing_data;
526
+
527
+ }
528
+
529
+
530
+ function iis7_url_rewrite_rules( $wp_rules )
531
+ {
532
+ $home_path = get_home_path();
533
+ $web_config_file = $home_path . 'web.config';
534
+
535
+ //delete all WPH rules
536
+ $this->iis7_delete_rewrite_rules($web_config_file);
537
+
538
+ if($this->uninstall === TRUE)
539
+ return $wp_rules;
540
+
541
+ $processing_data = $this->get_components_rules();
542
+
543
  //post-process the htaccess data
544
+ $_rewrite_data = array();
545
  $_page_refresh = FALSE;
546
  foreach($processing_data as $response)
547
  {
548
+ if(isset($response['rewrite']) && !empty($response['rewrite']))
549
  {
550
+ $_rewrite_data[] = $response['rewrite'];
 
 
 
551
  }
552
 
553
  if(isset($response['page_refresh']) && $response['page_refresh'] === TRUE)
554
  $_page_refresh = TRUE;
555
  }
556
 
557
+ $write_check_string = time() . '_' . mt_rand(100, 99999);
558
  $this->settings['write_check_string'] = $write_check_string;
559
  $this->functions->update_settings($this->settings);
560
+
561
+ //add a write stricng
562
+ $_writestring_rule = '
563
+ <rule name="wph-CheckString">
564
+ <!-- WriteCheckString:'. $write_check_string .' -->
565
+ </rule>';
566
+ array_unshift($_rewrite_data, $_writestring_rule);
567
+
568
+ $this->iis7_add_rewrite_rule( $_rewrite_data, $web_config_file );
569
+
570
+ return $wp_rules;
571
+
572
+ }
573
+
574
+
575
+
576
+ /**
577
+ * Add a rewrite rule within specified file
578
+ *
579
+ * @param mixed $filename
580
+ */
581
+ function iis7_add_rewrite_rule( $rules, $filename )
582
+ {
583
+
584
+ if (!is_array($rules) || count($rules) < 1)
585
+ return false;
586
+
587
+ if ( ! class_exists( 'DOMDocument', false ) ) {
588
+ return false;
589
+ }
590
+
591
+ // If configuration file does not exist then we create one.
592
+ if ( ! file_exists($filename) ) {
593
+ $fp = fopen( $filename, 'w');
594
+ fwrite($fp, '<configuration/>');
595
+ fclose($fp);
596
+ }
597
+
598
+ $doc = new DOMDocument();
599
+ $doc->preserveWhiteSpace = false;
600
+
601
+ if ( $doc->load($filename) === false )
602
+ return false;
603
+
604
+ $xpath = new DOMXPath($doc);
605
+
606
+ // Check the XPath to the rewrite rule and create XML nodes if they do not exist
607
+ $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules');
608
+ if ( $xmlnodes->length > 0 ) {
609
+ $rules_node = $xmlnodes->item(0);
610
+ } else {
611
+ $rules_node = $doc->createElement('rules');
612
+
613
+ $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite');
614
+ if ( $xmlnodes->length > 0 ) {
615
+ $rewrite_node = $xmlnodes->item(0);
616
+ $rewrite_node->appendChild($rules_node);
617
+ } else {
618
+ $rewrite_node = $doc->createElement('rewrite');
619
+ $rewrite_node->appendChild($rules_node);
620
+
621
+ $xmlnodes = $xpath->query('/configuration/system.webServer');
622
+ if ( $xmlnodes->length > 0 ) {
623
+ $system_webServer_node = $xmlnodes->item(0);
624
+ $system_webServer_node->appendChild($rewrite_node);
625
+ } else {
626
+ $system_webServer_node = $doc->createElement('system.webServer');
627
+ $system_webServer_node->appendChild($rewrite_node);
628
+
629
+ $xmlnodes = $xpath->query('/configuration');
630
+ if ( $xmlnodes->length > 0 ) {
631
+ $config_node = $xmlnodes->item(0);
632
+ $config_node->appendChild($system_webServer_node);
633
+ } else {
634
+ $config_node = $doc->createElement('configuration');
635
+ $doc->appendChild($config_node);
636
+ $config_node->appendChild($system_webServer_node);
637
+ }
638
+ }
639
+ }
640
+ }
641
+
642
+ //append before other rules
643
+ $ref_node = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
644
+
645
+ foreach($rules as $rule)
646
  {
647
+ $rule_fragment = $doc->createDocumentFragment();
648
+ $rule_fragment->appendXML($rule);
649
+
650
+ if($ref_node->length > 0)
651
+ $rules_node->insertBefore($rule_fragment, $ref_node->item(0));
652
+ else
653
+ $rules_node->appendChild($rule_fragment);
654
+ }
655
+
656
+ $doc->encoding = "UTF-8";
657
+ $doc->formatOutput = true;
658
+ saveDomDocument($doc, $filename);
659
+
660
+ return true;
661
+
662
+
663
+ }
664
+
665
+
666
+
667
+ /**
668
+ * Delete all wph rules within specified filename
669
+ *
670
+ * @param mixed $filename
671
+ */
672
+ function iis7_delete_rewrite_rules( $filename )
673
+ {
674
+
675
+ if ( ! file_exists($filename) )
676
+ return true;
677
+
678
+ if ( ! class_exists( 'DOMDocument', false ) ) {
679
+ return false;
680
+ }
681
+
682
+ $doc = new DOMDocument();
683
+ $doc->preserveWhiteSpace = false;
684
+
685
+ if ( $doc -> load($filename) === false )
686
+ return false;
687
+ $xpath = new DOMXPath($doc);
688
+ $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wph\')]');
689
+ if ( $rules->length > 0 )
690
+ {
691
+
692
+ foreach($rules as $child)
693
  {
694
+ $parent = $child->parentNode;
695
+ $parent->removeChild($child);
696
  }
697
 
698
+ $doc->formatOutput = true;
699
+ saveDomDocument($doc, $filename);
 
 
 
 
700
  }
701
+
702
+ return true;
703
+
704
  }
705
 
706
 
707
+
708
  function get_default_variables()
709
  {
710
  $this->default_variables['include_url'] = trailingslashit( site_url() ) . WPINC;
722
 
723
  $template = get_template();
724
 
725
+ $this->templates_data['use_child_theme'] = (get_option( 'stylesheet' ) != get_option( 'template' )) ? TRUE : FALSE;
726
  $this->templates_data['themes_url'] = trailingslashit( str_replace($template, "", get_bloginfo('template_url')) );
727
 
728
  $this->templates_data['main'] = array();
729
  $this->templates_data['main']['folder_name'] = $template;
730
  $this->templates_data['_template_' . $template] = 'main';
731
 
732
+ if($this->templates_data['use_child_theme'])
733
  {
734
  $this->templates_data['child'] = array();
735
 
803
  return;
804
 
805
  //recheck if the permalinks where sucesfully saved
806
+ $this->permalinks_not_applied = ! $this->functions->rewrite_rules_applied();
807
 
808
  //ignore if permalinks are available
809
  if($this->permalinks_not_applied === TRUE)
modules/components/admin-admin_url.php CHANGED
@@ -96,11 +96,29 @@
96
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
97
  $path .= trailingslashit( $saved_field_data );
98
 
99
- $text = "\nRewriteCond %{REQUEST_URI} ". $saved_field_data ."$";
100
- $text .= "\nRewriteRule ^(.*)$ ". $saved_field_data ."/ [R=301,L]";
101
- $text .= "\nRewriteRule ^" . $path . '(.*) '. $admin_url .'$1 [L,QSA]';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
- $processing_response['htaccess'] = $text;
104
  $processing_response['page_refresh'] = TRUE;
105
 
106
  return $processing_response;
@@ -215,35 +233,75 @@
215
  return FALSE;
216
 
217
  $site_index = $this->wph->functions->get_url_path ( trailingslashit( site_url() ) . 'index.php', TRUE );
218
-
219
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
220
- $text .= "RewriteRule ^wp-admin(.*) $site_index [L]\n";
221
- $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
222
-
223
- //theme my login usage
224
- //$text .= "RewriteRule ^login(.*) $site_index?throw_404 [L]\n";
225
- //$text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
226
-
227
- $text .= "RewriteRule ^dashboard(.*) $site_index [L]\n";
228
- $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
229
- $text .= "RewriteRule ^admin(.*) $site_index [L]\n";
230
 
231
  $path = '';
232
  if(!empty($this->wph->default_variables['wordpress_directory']))
233
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
234
-
235
- if(!empty($path))
236
- {
237
- $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
238
- $text .= "RewriteRule ^".$path."wp-admin(.*) $site_index [L]\n";
239
  $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
240
- $text .= "RewriteRule ^".$path."dashboard(.*) $site_index [L]\n";
 
 
 
 
 
241
  $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
242
- $text .= "RewriteRule ^".$path."admin(.*) $site_index [L]";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  }
244
 
245
 
246
- $processing_response['htaccess'] = $text;
247
 
248
  return $processing_response;
249
  }
96
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
97
  $path .= trailingslashit( $saved_field_data );
98
 
99
+ if($this->wph->server_htaccess_config === TRUE)
100
+ {
101
+ $text = "\nRewriteCond %{REQUEST_URI} ". $saved_field_data ."$";
102
+ $text .= "\nRewriteRule ^(.*)$ ". $saved_field_data ."/ [R=301,L]";
103
+ $text .= "\nRewriteRule ^" . $path . '(.*) '. $admin_url .'$1 [L,QSA]';
104
+ }
105
+
106
+ if($this->wph->server_web_config === TRUE)
107
+ $text = '
108
+ <rule name="wph-admin_url1" stopProcessing="true">
109
+ <match url="^(.*)$" />
110
+ <conditions>
111
+ <add input="{REQUEST_URI}" matchType="Pattern" pattern="$saved_field_data$" />
112
+ </conditions>
113
+ <action type="Redirect" redirectType="Permanent" url="'. $saved_field_data .'{R:1}/" />
114
+ </rule>
115
+ <rule name="wph-admin_url2" stopProcessing="true">
116
+ <match url="^'. $path .'(.*)" />
117
+ <action type="Rewrite" url="'. $admin_url .'{R:1}" appendQueryString="true" />
118
+ </rule>
119
+ ';
120
 
121
+ $processing_response['rewrite'] = $text;
122
  $processing_response['page_refresh'] = TRUE;
123
 
124
  return $processing_response;
233
  return FALSE;
234
 
235
  $site_index = $this->wph->functions->get_url_path ( trailingslashit( site_url() ) . 'index.php', TRUE );
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
  $path = '';
238
  if(!empty($this->wph->default_variables['wordpress_directory']))
239
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
240
+
241
+ if($this->wph->server_htaccess_config === TRUE)
242
+ {
243
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
244
+ $text .= "RewriteRule ^wp-admin(.*) $site_index [L]\n";
245
  $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
246
+
247
+ //theme my login usage
248
+ //$text .= "RewriteRule ^login(.*) $site_index?throw_404 [L]\n";
249
+ //$text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
250
+
251
+ $text .= "RewriteRule ^dashboard(.*) $site_index [L]\n";
252
  $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
253
+ $text .= "RewriteRule ^admin(.*) $site_index [L]\n";
254
+
255
+ if(!empty($path))
256
+ {
257
+ $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
258
+ $text .= "RewriteRule ^".$path."wp-admin(.*) $site_index [L]\n";
259
+ $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
260
+ $text .= "RewriteRule ^".$path."dashboard(.*) $site_index [L]\n";
261
+ $text .= "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
262
+ $text .= "RewriteRule ^".$path."admin(.*) $site_index [L]";
263
+ }
264
+ }
265
+
266
+ if($this->wph->server_web_config === TRUE)
267
+ {
268
+ $text = '
269
+ <rule name="wph-block_default_admin_url1" stopProcessing="true">
270
+ <match url="^wp-admin(.*)" />
271
+ <action type="Rewrite" url="'. $site_index .'" />
272
+ </rule>
273
+ <rule name="wph-block_default_admin_url2" stopProcessing="true">
274
+ <match url="^dashboard(.*)" />
275
+ <action type="Rewrite" url="'. $site_index .'" />
276
+ </rule>
277
+ <rule name="wph-block_default_admin_url3" stopProcessing="true">
278
+ <match url="^admin(.*)" />
279
+ <action type="Rewrite" url="'. $site_index .'" />
280
+ </rule>
281
+ ';
282
+ if(!empty($path))
283
+ {
284
+ $text .= '
285
+ <rule name="wph-block_default_admin_url4" stopProcessing="true">
286
+ <match url="^'. $path .'wp-admin(.*)" />
287
+ <action type="Rewrite" url="'. $site_index .'" />
288
+ </rule>
289
+ <rule name="wph-block_default_admin_url5" stopProcessing="true">
290
+ <match url="^'. $path .'dashboard(.*)" />
291
+ <action type="Rewrite" url="'. $site_index .'" />
292
+ </rule>
293
+ <rule name="wph-block_default_admin_url6" stopProcessing="true">
294
+ <match url="^'. $path .'admin(.*)" />
295
+ <action type="Rewrite" url="'. $site_index .'" />
296
+ </rule>
297
+ ';
298
+ }
299
+
300
+
301
  }
302
 
303
 
304
+ $processing_response['rewrite'] = $text;
305
 
306
  return $processing_response;
307
  }
modules/components/admin-new_wp_login_php.php CHANGED
@@ -92,7 +92,16 @@
92
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
93
  $path .= $saved_field_data;
94
 
95
- $processing_response['htaccess'] = "\nRewriteRule ^" . $path . '(.*) '. $new_wp_login_php .'$1 [L,QSA]';
 
 
 
 
 
 
 
 
 
96
 
97
  return $processing_response;
98
  }
@@ -122,11 +131,22 @@
122
  if(!empty($this->wph->default_variables['wordpress_directory']))
123
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
124
  $path .= 'wp-login.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
127
- $text .= "RewriteRule ^" . $path ." ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
128
-
129
- $processing_response['htaccess'] = $text;
130
 
131
  return $processing_response;
132
  }
92
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
93
  $path .= $saved_field_data;
94
 
95
+ if($this->wph->server_htaccess_config === TRUE)
96
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.*) '. $new_wp_login_php .'$1 [L,QSA]';
97
+
98
+ if($this->wph->server_web_config === TRUE)
99
+ $processing_response['rewrite'] = '
100
+ <rule name="wph-new_wp_login_php" stopProcessing="true">
101
+ <match url="^'. $path .'(.*)" />
102
+ <action type="Rewrite" url="'. $new_wp_login_php .'{R:1}" appendQueryString="true" />
103
+ </rule>
104
+ ';
105
 
106
  return $processing_response;
107
  }
131
  if(!empty($this->wph->default_variables['wordpress_directory']))
132
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
133
  $path .= 'wp-login.php';
134
+
135
+ if($this->wph->server_htaccess_config === TRUE)
136
+ {
137
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
138
+ $text .= "RewriteRule ^" . $path ." ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
139
+ }
140
+
141
+ if($this->wph->server_web_config === TRUE)
142
+ $text = '
143
+ <rule name="wph-block_default_wp_login_php" stopProcessing="true">
144
+ <match url="^'. $path .'" />
145
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
146
+ </rule>
147
+ ';
148
 
149
+ $processing_response['rewrite'] = $text;
 
 
 
150
 
151
  return $processing_response;
152
  }
modules/components/general-headers.php CHANGED
@@ -45,12 +45,32 @@
45
 
46
  if(empty($saved_field_data) || $saved_field_data == 'no')
47
  return FALSE;
48
-
49
- $processing_response['htaccess'] = "\n" . '<FilesMatch "">
50
- <IfModule mod_headers.c>
51
- Header unset X-Powered-By
52
- </IfModule>
53
- </FilesMatch>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  return $processing_response;
56
  }
45
 
46
  if(empty($saved_field_data) || $saved_field_data == 'no')
47
  return FALSE;
48
+
49
+ if($this->wph->server_htaccess_config === TRUE)
50
+ $processing_response['rewrite'] = '
51
+ <FilesMatch "">
52
+ <IfModule mod_headers.c>
53
+ Header unset X-Powered-By
54
+ </IfModule>
55
+ </FilesMatch>';
56
+
57
+ if($this->wph->server_web_config === TRUE)
58
+ {
59
+ //this goes after </rules> section
60
+ //to be implemented at a later versoin
61
+ /*
62
+ $processing_response['rewrite'] = '
63
+ <outboundRules>
64
+ <rule name="wph-bcdscsdh">
65
+ <match serverVariable="RESPONSE_X-POWERED-BY" pattern=".*" ignoreCase="true" />
66
+ <action type="Rewrite" value="" />
67
+ </rule>
68
+ </outboundRules>
69
+ ';
70
+ */
71
+
72
+ $processing_response['rewrite'] = '';
73
+ }
74
 
75
  return $processing_response;
76
  }
modules/components/general-html-comments.php CHANGED
@@ -43,6 +43,9 @@
43
 
44
  function remove_html_comments($buffer)
45
  {
 
 
 
46
 
47
  //replace any comments
48
  $buffer = preg_replace('/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->)(.|\n))*-->/sm', "" , $buffer);
43
 
44
  function remove_html_comments($buffer)
45
  {
46
+ //do not run when within admin
47
+ if(defined('WP_ADMIN'))
48
+ return $buffer;
49
 
50
  //replace any comments
51
  $buffer = preg_replace('/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->)(.|\n))*-->/sm', "" , $buffer);
modules/components/rewrite-new_include_path.php CHANGED
@@ -75,8 +75,17 @@
75
  if(!empty($this->wph->default_variables['wordpress_directory']))
76
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
77
  $path .= trailingslashit( $saved_field_data );
78
-
79
- $processing_response['htaccess'] = "\nRewriteRule ^" . $path . '(.*) '. $include_path .'$1 [L,QSA]';
 
 
 
 
 
 
 
 
 
80
 
81
  return $processing_response;
82
  }
@@ -148,12 +157,28 @@
148
  if (empty( $new_include_path ))
149
  return FALSE;
150
 
151
-
152
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
153
- $text .= "RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]\n";
154
- $text .= "RewriteRule ^wp-includes(.*) ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
 
156
- $processing_response['htaccess'] = $text;
157
 
158
  return $processing_response;
159
 
75
  if(!empty($this->wph->default_variables['wordpress_directory']))
76
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
77
  $path .= trailingslashit( $saved_field_data );
78
+
79
+ if($this->wph->server_htaccess_config === TRUE)
80
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.*) '. $include_path .'$1 [L,QSA]';
81
+
82
+ if($this->wph->server_web_config === TRUE)
83
+ $processing_response['rewrite'] = '
84
+ <rule name="wph-new_include_path" stopProcessing="true">
85
+ <match url="^'. $path .'(.*)" />
86
+ <action type="Rewrite" url="'. $include_path .'{R:1}" appendQueryString="true" />
87
+ </rule>
88
+ ';
89
 
90
  return $processing_response;
91
  }
157
  if (empty( $new_include_path ))
158
  return FALSE;
159
 
160
+ if($this->wph->server_htaccess_config === TRUE)
161
+ {
162
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
163
+ $text .= "RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]\n";
164
+ $text .= "RewriteRule ^wp-includes(.*) ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
165
+ }
166
+
167
+ if($this->wph->server_web_config === TRUE)
168
+ {
169
+ $text = '
170
+ <rule name="wph-block_wpinclude_url" stopProcessing="true">
171
+ <match url="^wp-includes(.*)" />
172
+ <conditions>
173
+ <add input="{HTTP_COOKIE}" matchType="Pattern" pattern="wordpress_logged_in_[^.]+" negate="true" />
174
+ </conditions>
175
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
176
+ </rule>
177
+ ';
178
+
179
+ }
180
 
181
+ $processing_response['rewrite'] = $text;
182
 
183
  return $processing_response;
184
 
modules/components/rewrite-new_plugin_path.php CHANGED
@@ -150,7 +150,7 @@
150
  {
151
  $processing_response = array();
152
 
153
- $htaccess = '';
154
 
155
  $plugin_path = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
156
 
@@ -181,15 +181,33 @@
181
  if($path != '/')
182
  $new_url = trailingslashit( $new_url ) . $path;
183
 
184
-
185
- $htaccess .= "\nRewriteRule ^" . trailingslashit( $plugin_custom_path ) . '(.*) '. trailingslashit($plugin_path) . trailingslashit($active_plugin_directory) .'$1 [L,QSA]';
186
-
 
 
 
 
 
 
 
187
  }
188
 
189
  if($path != '/')
190
- $htaccess .= "\nRewriteRule ^" . trailingslashit( $path ) . '(.*) '. $plugin_path .'$1 [L,QSA]';
 
 
 
 
 
 
 
 
 
 
 
191
 
192
- $processing_response['htaccess'] = $htaccess;
193
 
194
  return $processing_response;
195
  }
@@ -213,11 +231,22 @@
213
  $default_plugin_url = untrailingslashit ( WP_PLUGIN_URL );
214
  $default_plugin_url = str_replace( $home_url, "", $default_plugin_url);
215
  $default_plugin_url = ltrim(rtrim($default_plugin_url, "/"), "/");
216
-
217
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
218
- $text .= "RewriteRule ^". $default_plugin_url ."(.*) ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
 
 
 
 
 
 
 
 
 
 
 
219
 
220
- $processing_response['htaccess'] = $text;
221
 
222
  return $processing_response;
223
 
150
  {
151
  $processing_response = array();
152
 
153
+ $rewrite = '';
154
 
155
  $plugin_path = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
156
 
181
  if($path != '/')
182
  $new_url = trailingslashit( $new_url ) . $path;
183
 
184
+ if($this->wph->server_htaccess_config === TRUE)
185
+ $rewrite .= "\nRewriteRule ^" . trailingslashit( $plugin_custom_path ) . '(.*) '. trailingslashit($plugin_path) . trailingslashit($active_plugin_directory) .'$1 [L,QSA]';
186
+
187
+ if($this->wph->server_web_config === TRUE)
188
+ $rewrite .= '
189
+ <rule name="wph-new_plugin_path-'. $plugin_slug .'" stopProcessing="true">
190
+ <match url="^'. trailingslashit( $plugin_custom_path ) .'(.*)" />
191
+ <action type="Rewrite" url="'. trailingslashit($plugin_path) . trailingslashit($active_plugin_directory) .'{R:1}" appendQueryString="true" />
192
+ </rule>
193
+ ';
194
  }
195
 
196
  if($path != '/')
197
+ {
198
+ if($this->wph->server_htaccess_config === TRUE)
199
+ $rewrite .= "\nRewriteRule ^" . trailingslashit( $path ) . '(.*) '. $plugin_path .'$1 [L,QSA]';
200
+
201
+ if($this->wph->server_web_config === TRUE)
202
+ $rewrite .= '
203
+ <rule name="wph-new_plugin_path" stopProcessing="true">
204
+ <match url="^'. trailingslashit( $path ) .'(.*)" />
205
+ <action type="Rewrite" url="'. $plugin_path .'{R:1}" appendQueryString="true" />
206
+ </rule>
207
+ ';
208
+ }
209
 
210
+ $processing_response['rewrite'] = $rewrite;
211
 
212
  return $processing_response;
213
  }
231
  $default_plugin_url = untrailingslashit ( WP_PLUGIN_URL );
232
  $default_plugin_url = str_replace( $home_url, "", $default_plugin_url);
233
  $default_plugin_url = ltrim(rtrim($default_plugin_url, "/"), "/");
234
+
235
+ if($this->wph->server_htaccess_config === TRUE)
236
+ {
237
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
238
+ $text .= "RewriteRule ^". $default_plugin_url ."(.*) ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
239
+ }
240
+
241
+ if($this->wph->server_web_config === TRUE)
242
+ $text = '
243
+ <rule name="wph-block_plugins_url" stopProcessing="true">
244
+ <match url="^'. $default_plugin_url .'(.*)" />
245
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
246
+ </rule>
247
+ ';
248
 
249
+ $processing_response['rewrite'] = $text;
250
 
251
  return $processing_response;
252
 
modules/components/rewrite-new_theme_path.php CHANGED
@@ -24,11 +24,51 @@
24
  'processing_order' => 10
25
  );
26
 
27
- if($this->wph->templates_data['is_child_theme'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  {
 
 
 
 
 
29
  $this->module_settings[] = array(
30
  'id' => 'new_theme_child_path',
31
- 'label' => __('New Theme Child Path', 'wp-hide-security-enhancer'),
32
  'description' => __('The default theme path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' , trailingslashit($this->wph->templates_data['themes_url']) . $this->wph->templates_data['child']['folder_name']) .'</strong>
33
  '.__('More details can be found at', 'wp-hide-security-enhancer') .' <a href="http://www.nsp-code.com" target="_blank">Link</a>',
34
 
@@ -38,20 +78,39 @@
38
  'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
39
  'processing_order' => 15
40
  );
41
- }
42
-
43
- $this->module_settings[] = array(
44
- 'id' => 'new_style_file_path',
45
- 'label' => __('New Style File Path', 'wp-hide-security-enhancer'),
46
- 'description' => __('The default theme style file style.css path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' , $this->wph->default_variables['template_url']) .'/style.css</strong>',
47
-
48
- 'value_description' => __('e.g. custom-style-file.css', 'wp-hide-security-enhancer'),
49
- 'input_type' => 'text',
50
-
51
- 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
 
 
 
52
 
53
- 'processing_order' => 5
54
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  return $this->module_settings;
57
  }
@@ -66,8 +125,21 @@
66
  */
67
  function _init_new_theme_path($saved_field_data)
68
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  //check for child
70
- if($this->wph->templates_data['is_child_theme'] === TRUE)
71
  {
72
  $child_theme_saved_field_data = $this->wph->functions->get_module_item_setting('new_theme_child_path');
73
  if(empty($child_theme_saved_field_data) && empty($saved_field_data))
@@ -78,6 +150,7 @@
78
  if(empty($saved_field_data))
79
  return FALSE;
80
  }
 
81
 
82
  //applay when not admin and not customize.php
83
  /*
@@ -106,7 +179,16 @@
106
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
107
  $path .= trailingslashit( $saved_field_data );
108
 
109
- $processing_response['htaccess'] = "\nRewriteRule ^" . $path . '(.*) '. $theme_path .'$1 [L,QSA]';
 
 
 
 
 
 
 
 
 
110
 
111
  return $processing_response;
112
  }
@@ -211,7 +293,16 @@
211
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
212
  $path .= trailingslashit( $saved_field_data );
213
 
214
- $processing_response['htaccess'] = "\nRewriteRule ^" . $path . '(.*) '. $theme_path .'$1 [L,QSA]';
 
 
 
 
 
 
 
 
 
215
 
216
  return $processing_response;
217
  }
@@ -225,27 +316,33 @@
225
 
226
  if($this->wph->functions->is_theme_customize())
227
  return;
228
-
229
- add_filter('stylesheet_uri', array(&$this, 'stylesheet_uri'), 999, 2);
230
 
231
  //add default replacements
232
- $old_style_file_path = $this->wph->default_variables['stylesheet_uri'];;
233
- $new_style_file_path = trailingslashit( site_url() ) . $saved_field_data;
234
- $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
235
 
236
- //add replacement for style.css when already template name replaced
237
- $template_slug = get_option('stylesheet');
238
- if($this->wph->templates_data['_template_' . $template_slug] == 'main')
239
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
 
240
  else
241
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
 
 
 
 
242
 
 
 
243
  if(!empty($new_theme_path))
244
  {
245
  $old_style_file_path = trailingslashit( site_url() ) . trailingslashit( $new_theme_path ) . 'style.css';
246
- $new_style_file_path = trailingslashit( site_url() ) . $saved_field_data;
247
  $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
248
  }
 
249
  }
250
 
251
  function _callback_saved_new_style_file_path($saved_field_data)
@@ -256,31 +353,291 @@
256
  if(empty($saved_field_data))
257
  return $processing_response;
258
 
259
- $current_stylesheet_uri = $this->wph->default_variables['stylesheet_uri'];
260
-
261
- $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri, TRUE );
262
 
263
  $path = '';
264
  if(!empty($this->wph->default_variables['wordpress_directory']))
265
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
266
- $path .= $saved_field_data;
 
 
 
 
 
 
 
 
 
 
267
 
268
- $processing_response['htaccess'] = "\nRewriteRule ^" . $path . ' '. $current_stylesheet_uri .' [L,QSA]';
 
 
 
 
 
 
 
 
 
269
 
270
  return $processing_response;
271
  }
 
 
272
 
273
- function stylesheet_uri($stylesheet_uri, $stylesheet_dir_uri)
274
  {
275
- if ( $this->wph->disable_filters )
276
- return $stylesheet_uri;
277
 
278
- $new_style_file_path = $this->wph->functions->get_module_item_setting('new_style_file_path');
279
-
280
- $new_style_file_path = trailingslashit( site_url() ) . $new_style_file_path;
281
-
282
- return $new_style_file_path;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  }
 
 
 
 
 
284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  }
286
  ?>
24
  'processing_order' => 10
25
  );
26
 
27
+
28
+ $this->module_settings[] = array(
29
+ 'id' => 'new_style_file_path',
30
+ 'label' => __('New Style File Path', 'wp-hide-security-enhancer'),
31
+ 'description' => __('The default theme style file style.css path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' , $this->wph->default_variables['template_url']) .'/style.css</strong>'
32
+ .'<div class="description"><div class="notice-error"><div alt="f534" class="dashicons dashicons-warning">warning</div> <span class="important">'. __('If style file contain relative URLs it should not include additional path, just the actual filename.', 'wp-hide-security-enhancer') .'. '. __('More details at', 'wp-hide-security-enhancer') .' <a href="http://www.wp-hide.com/new-style-file-path-along-relative-urls/" target="_blank">New Style File Path along with relative URLs</a></span></div></div>'
33
+ ,
34
+
35
+ 'value_description' => __('e.g. custom-style-file.css', 'wp-hide-security-enhancer'),
36
+ 'input_type' => 'text',
37
+
38
+ 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
39
+
40
+ 'processing_order' => 5
41
+ );
42
+
43
+ $this->module_settings[] = array(
44
+ 'id' => 'style_file_clean',
45
+ 'label' => __('Remove description header from Style file', 'wp-hide-security-enhancer'),
46
+ 'description' => __('Strip out all meta data from style file e.g. Theme Name, Theme URI, Author etc. Those are important information to find out possible theme security breaches.', 'wp-hide-security-enhancer')
47
+ . '<br />' . __('This feature may not work if style file url not available on html (being concatenated).', 'wp-hide-security-enhancer'),
48
+
49
+ 'input_type' => 'radio',
50
+ 'options' => array(
51
+ 'yes' => __('Yes', 'wp-hide-security-enhancer'),
52
+ 'no' => __('No', 'wp-hide-security-enhancer'),
53
+ ),
54
+ 'default_value' => 'no',
55
+
56
+ 'sanitize_type' => array('sanitize_title', 'strtolower'),
57
+ 'processing_order' => 3
58
+
59
+ );
60
+
61
+
62
+ if($this->wph->templates_data['use_child_theme'])
63
  {
64
+ $this->module_settings[] = array(
65
+ 'type' => 'split'
66
+
67
+ );
68
+
69
  $this->module_settings[] = array(
70
  'id' => 'new_theme_child_path',
71
+ 'label' => __('Child - New Theme Path', 'wp-hide-security-enhancer'),
72
  'description' => __('The default theme path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' , trailingslashit($this->wph->templates_data['themes_url']) . $this->wph->templates_data['child']['folder_name']) .'</strong>
73
  '.__('More details can be found at', 'wp-hide-security-enhancer') .' <a href="http://www.nsp-code.com" target="_blank">Link</a>',
74
 
78
  'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
79
  'processing_order' => 15
80
  );
81
+
82
+ $this->module_settings[] = array(
83
+ 'id' => 'child_style_file_path',
84
+ 'label' => __('Child - New Style File Path', 'wp-hide-security-enhancer'),
85
+ 'description' => __('The default theme style file style.css path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' , $this->wph->default_variables['stylesheet_uri']) .'</strong>'
86
+ .'<div class="description"><div class="notice-error"><div alt="f534" class="dashicons dashicons-warning">warning</div> <span class="important">'. __('If style file contain relative URLs it should not include additional path, just the actual filename.', 'wp-hide-security-enhancer') .'. '. __('More details at', 'wp-hide-security-enhancer') .' <a href="http://www.wp-hide.com/new-style-file-path-along-relative-urls/" target="_blank">New Style File Path along with relative URLs</a></span></div></div>',
87
+
88
+ 'value_description' => __('e.g. custom-style-file.css', 'wp-hide-security-enhancer'),
89
+ 'input_type' => 'text',
90
+
91
+ 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
92
+
93
+ 'processing_order' => 5
94
+ );
95
 
96
+ $this->module_settings[] = array(
97
+ 'id' => 'child_style_file_clean',
98
+ 'label' => __('Child - Remove description header from Style file', 'wp-hide-security-enhancer'),
99
+ 'description' => __('Strip out all meta data from style file e.g. Theme Name, Theme URI, Author etc. Those are important information to find out possible theme security breaches.', 'wp-hide-security-enhancer')
100
+ . '<br />' . __('This feature may not work if style file url not available on html (being concatenated).', 'wp-hide-security-enhancer'),
101
+
102
+ 'input_type' => 'radio',
103
+ 'options' => array(
104
+ 'yes' => __('Yes', 'wp-hide-security-enhancer'),
105
+ 'no' => __('No', 'wp-hide-security-enhancer'),
106
+ ),
107
+ 'default_value' => 'no',
108
+
109
+ 'sanitize_type' => array('sanitize_title', 'strtolower'),
110
+ 'processing_order' => 3
111
+
112
+ );
113
+ }
114
 
115
  return $this->module_settings;
116
  }
125
  */
126
  function _init_new_theme_path($saved_field_data)
127
  {
128
+ //rely on this callback function for booth parent and child theme
129
+ $child_theme_saved_field_data = $this->wph->functions->get_module_item_setting('new_theme_child_path');
130
+
131
+ if(
132
+ ($this->wph->templates_data['use_child_theme'] === FALSE && empty($saved_field_data))
133
+ || ($this->wph->templates_data['use_child_theme'] === TRUE && empty($saved_field_data) && empty( $child_theme_saved_field_data ))
134
+ )
135
+ {
136
+ return FALSE;
137
+ }
138
+
139
+
140
+ /*
141
  //check for child
142
+ if($this->wph->templates_data['use_child_theme'] === TRUE)
143
  {
144
  $child_theme_saved_field_data = $this->wph->functions->get_module_item_setting('new_theme_child_path');
145
  if(empty($child_theme_saved_field_data) && empty($saved_field_data))
150
  if(empty($saved_field_data))
151
  return FALSE;
152
  }
153
+ */
154
 
155
  //applay when not admin and not customize.php
156
  /*
179
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
180
  $path .= trailingslashit( $saved_field_data );
181
 
182
+ if($this->wph->server_htaccess_config === TRUE)
183
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.*) '. $theme_path .'$1 [L,QSA]';
184
+
185
+ if($this->wph->server_web_config === TRUE)
186
+ $processing_response['rewrite'] = '
187
+ <rule name="wph-new_theme_path" stopProcessing="true">
188
+ <match url="^'. $path .'(.*)" />
189
+ <action type="Rewrite" url="'. $theme_path .'{R:1}" appendQueryString="true" />
190
+ </rule>
191
+ ';
192
 
193
  return $processing_response;
194
  }
293
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
294
  $path .= trailingslashit( $saved_field_data );
295
 
296
+ if($this->wph->server_htaccess_config === TRUE)
297
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.*) '. $theme_path .'$1 [L,QSA]';
298
+
299
+ if($this->wph->server_web_config === TRUE)
300
+ $processing_response['rewrite'] = '
301
+ <rule name="wph-new_theme_child_path" stopProcessing="true">
302
+ <match url="^'. $path .'(.*)" />
303
+ <action type="Rewrite" url="'. $theme_path .'{R:1}" appendQueryString="true" />
304
+ </rule>
305
+ ';
306
 
307
  return $processing_response;
308
  }
316
 
317
  if($this->wph->functions->is_theme_customize())
318
  return;
319
+
320
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
321
 
322
  //add default replacements
323
+ $template_url = trailingslashit( $this->wph->default_variables['template_url'] );
324
+ $old_style_file_path = trailingslashit( $this->wph->default_variables['template_url'] ) . 'style.css';
 
325
 
326
+ if(!empty($new_theme_path))
327
+ {
328
+ $new_style_file_path = trailingslashit( site_url() ) . trailingslashit($new_theme_path) . $saved_field_data;
329
+ $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
330
+ }
331
  else
332
+ {
333
+ $new_style_file_path = $template_url . $saved_field_data;
334
+ $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
335
+ }
336
+
337
 
338
+
339
+ //add replacement for style.css when already template name replaced
340
  if(!empty($new_theme_path))
341
  {
342
  $old_style_file_path = trailingslashit( site_url() ) . trailingslashit( $new_theme_path ) . 'style.css';
 
343
  $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
344
  }
345
+
346
  }
347
 
348
  function _callback_saved_new_style_file_path($saved_field_data)
353
  if(empty($saved_field_data))
354
  return $processing_response;
355
 
356
+ $current_stylesheet_uri = $this->wph->default_variables['template_url'];
357
+ $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri );
358
+ $current_stylesheet_uri = trailingslashit( $current_stylesheet_uri ) . 'style.css';
359
 
360
  $path = '';
361
  if(!empty($this->wph->default_variables['wordpress_directory']))
362
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
363
+
364
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
365
+ if(!empty($new_theme_path))
366
+ {
367
+ $path .= trailingslashit($new_theme_path) . $saved_field_data;
368
+ }
369
+ else
370
+ {
371
+ $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
372
+ $path .= trailingslashit($template_relative_url) . $saved_field_data;
373
+ }
374
 
375
+ if($this->wph->server_htaccess_config === TRUE)
376
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $current_stylesheet_uri .' [L,QSA]';
377
+
378
+ if($this->wph->server_web_config === TRUE)
379
+ $processing_response['rewrite'] = '
380
+ <rule name="wph-new_style_file_path" stopProcessing="true">
381
+ <match url="^'. $path .'" />
382
+ <action type="Rewrite" url="'. $current_stylesheet_uri .'" appendQueryString="true" />
383
+ </rule>
384
+ ';
385
 
386
  return $processing_response;
387
  }
388
+
389
+
390
 
391
+ function _callback_saved_style_file_clean($saved_field_data)
392
  {
 
 
393
 
394
+ if(empty($saved_field_data) || $saved_field_data == 'no')
395
+ return FALSE;
396
+
397
+ $processing_response = array();
398
+
399
+ //actual style file path
400
+ $current_stylesheet_uri = $this->wph->default_variables['template_url'];
401
+ $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri );
402
+ $current_stylesheet_uri = trailingslashit( $current_stylesheet_uri ) . 'style.css';
403
+
404
+ //current style file path
405
+ $path = '';
406
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
407
+ $new_style_file_path = $this->wph->functions->get_module_item_setting('new_style_file_path');
408
+ if(!empty($new_style_file_path))
409
+ {
410
+ if(!empty($this->wph->default_variables['wordpress_directory']))
411
+ $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
412
+
413
+ if(!empty($new_theme_path))
414
+ {
415
+ $path .= trailingslashit($new_theme_path) . $new_style_file_path;
416
+ }
417
+ else
418
+ {
419
+ $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
420
+ $path .= trailingslashit($template_relative_url) . $new_style_file_path;
421
+ }
422
+
423
+ }
424
+ else if(!empty($new_theme_path))
425
+ {
426
+ $path = trailingslashit( $new_theme_path ) . 'style.css';
427
+ }
428
+ else
429
+ {
430
+ //use the default
431
+ // cont/themes/twentyfifteen/style.css
432
+
433
+ $default_path = get_template_directory_uri();
434
+
435
+ //check for modified wp-content folder
436
+ $new_content_path = $this->wph->functions->get_module_item_setting('new_content_path');
437
+ if(!empty($new_content_path))
438
+ {
439
+ $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
440
+ $path = $new_content_path . $path;
441
+ }
442
+ else
443
+ {
444
+ $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
445
+
446
+ $wp_content_folder = str_replace( site_url() , '' , WP_CONTENT_URL);
447
+ $wp_content_folder = trim($wp_content_folder, '/');
448
+
449
+ $path = $wp_content_folder . $path;
450
+ }
451
+
452
+ //$path = $this->wph->functions->get_url_path( get_template_directory_uri() );
453
+ $path = trailingslashit( $path ) . 'style.css';
454
+ }
455
+
456
+ //plugin File Processor router path
457
+ $file_processor = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
458
+ $file_processor = trailingslashit( $file_processor ) . 'wp-hide-security-enhancer/router/file-process.php';
459
+
460
+ if($this->wph->server_htaccess_config === TRUE)
461
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $file_processor . '?action=style-clean&file_path=' . $current_stylesheet_uri .' [L,QSA]';
462
+
463
+ if($this->wph->server_web_config === TRUE)
464
+ $processing_response['rewrite'] = '
465
+ <rule name="wph-style_file_clean" stopProcessing="true">
466
+ <match url="^'. $path .'" />
467
+ <action type="Rewrite" url="'. $file_processor .'?action=style-clean&amp;file_path=' . $current_stylesheet_uri .'" appendQueryString="true" />
468
+ </rule>
469
+ ';
470
+
471
+ return $processing_response;
472
+
473
  }
474
+
475
+
476
+
477
+ function _init_child_style_file_path($saved_field_data)
478
+ {
479
 
480
+ if(empty($saved_field_data))
481
+ return FALSE;
482
+
483
+ if($this->wph->functions->is_theme_customize())
484
+ return;
485
+
486
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
487
+
488
+ //add default replacements
489
+ $template_url = trailingslashit( $this->wph->default_variables['stylesheet_uri'] );
490
+ $old_style_file_path = trailingslashit( $this->wph->default_variables['stylesheet_uri'] ) . 'style.css';
491
+
492
+ if(!empty($new_theme_path))
493
+ {
494
+ $new_style_file_path = trailingslashit( site_url() ) . trailingslashit($new_theme_path) . $saved_field_data;
495
+ $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
496
+ }
497
+ else
498
+ {
499
+ $new_style_file_path = $template_url . $saved_field_data;
500
+ $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
501
+ }
502
+
503
+
504
+
505
+ //add replacement for style.css when already template name replaced
506
+ if(!empty($new_theme_path))
507
+ {
508
+ $old_style_file_path = trailingslashit( site_url() ) . trailingslashit( $new_theme_path ) . 'style.css';
509
+ $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
510
+ }
511
+
512
+
513
+ }
514
+
515
+ function _callback_saved_child_style_file_path($saved_field_data)
516
+ {
517
+
518
+ $processing_response = array();
519
+
520
+ //check if the field is noe empty
521
+ if(empty($saved_field_data))
522
+ return $processing_response;
523
+
524
+ $current_stylesheet_uri = $this->wph->default_variables['stylesheet_uri'];
525
+
526
+ $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri, TRUE );
527
+
528
+ $path = '';
529
+ if(!empty($this->wph->default_variables['wordpress_directory']))
530
+ $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
531
+
532
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
533
+ if(!empty($new_theme_path))
534
+ {
535
+ $path .= trailingslashit($new_theme_path) . $saved_field_data;
536
+ }
537
+ else
538
+ {
539
+ $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
540
+ $path .= trailingslashit($template_relative_url) . $saved_field_data;
541
+ }
542
+
543
+ if($this->wph->server_htaccess_config === TRUE)
544
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $current_stylesheet_uri .' [L,QSA]';
545
+
546
+ if($this->wph->server_web_config === TRUE)
547
+ $processing_response['rewrite'] = '
548
+ <rule name="wph-child_style_file_path" stopProcessing="true">
549
+ <match url="^'. $path .'" />
550
+ <action type="Rewrite" url="'. $current_stylesheet_uri .'" appendQueryString="true" />
551
+ </rule>
552
+ ';
553
+
554
+ return $processing_response;
555
+ }
556
+
557
+
558
+ function _callback_saved_child_style_file_clean($saved_field_data)
559
+ {
560
+
561
+ if(empty($saved_field_data) || $saved_field_data == 'no')
562
+ return FALSE;
563
+
564
+ $processing_response = array();
565
+
566
+ //actual style file path
567
+ $current_stylesheet_uri = trailingslashit ( $this->wph->templates_data['themes_url'] ) . $this->wph->templates_data['child']['folder_name'];
568
+ $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri );
569
+ $current_stylesheet_uri = trailingslashit( $current_stylesheet_uri ) . 'style.css';
570
+
571
+ //current style file path
572
+ $path = '';
573
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
574
+ $new_style_file_path = $this->wph->functions->get_module_item_setting('child_style_file_path');
575
+ if(!empty($new_style_file_path))
576
+ {
577
+ if(!empty($this->wph->default_variables['wordpress_directory']))
578
+ $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
579
+
580
+ if(!empty($new_theme_path))
581
+ {
582
+ $path .= trailingslashit($new_theme_path) . $new_style_file_path;
583
+ }
584
+ else
585
+ {
586
+ $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
587
+ $path .= trailingslashit($template_relative_url) . $new_style_file_path;
588
+ }
589
+ }
590
+ else if(!empty($new_theme_path))
591
+ {
592
+ $path = trailingslashit( $new_theme_path ) . 'style.css';
593
+ }
594
+ else
595
+ {
596
+ //use the default
597
+ // cont/themes/twentyfifteen/style.css
598
+
599
+ $default_path = trailingslashit ( $this->wph->templates_data['themes_url'] ) . $this->wph->templates_data['child']['folder_name'];
600
+
601
+ //check for modified wp-content folder
602
+ $new_content_path = $this->wph->functions->get_module_item_setting('new_content_path');
603
+ if(!empty($new_content_path))
604
+ {
605
+ $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
606
+ $path = $new_content_path . $path;
607
+ }
608
+ else
609
+ {
610
+ $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
611
+
612
+ $wp_content_folder = str_replace( site_url() , '' , WP_CONTENT_URL);
613
+ $wp_content_folder = trim($wp_content_folder, '/');
614
+
615
+ $path = $wp_content_folder . $path;
616
+ }
617
+
618
+ //$path = $this->wph->functions->get_url_path( get_template_directory_uri() );
619
+ $path = trailingslashit( $path ) . 'style.css';
620
+ }
621
+
622
+ //plugin File Processor router path
623
+ $file_processor = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
624
+ $file_processor = trailingslashit( $file_processor ) . 'wp-hide-security-enhancer/router/file-process.php';
625
+
626
+
627
+ if($this->wph->server_htaccess_config === TRUE)
628
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $file_processor . '?action=style-clean&file_path=' . $current_stylesheet_uri .' [L,QSA]';
629
+
630
+
631
+ if($this->wph->server_web_config === TRUE)
632
+ $processing_response['rewrite'] = '
633
+ <rule name="wph-style_file_clean" stopProcessing="true">
634
+ <match url="^'. $path .'" />
635
+ <action type="Rewrite" url="'. $file_processor .'?action=style-clean&amp;file_path=' . $current_stylesheet_uri .'" appendQueryString="true" />
636
+ </rule>
637
+ ';
638
+
639
+ return $processing_response;
640
+
641
+ }
642
  }
643
  ?>
modules/components/rewrite-new_upload_path.php CHANGED
@@ -77,7 +77,16 @@
77
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
78
  $path .= trailingslashit( $saved_field_data );
79
 
80
- $processing_response['htaccess'] = "\nRewriteRule ^" . $path . '(.*) '. $uploads_path .'$1 [L,QSA]';
 
 
 
 
 
 
 
 
 
81
 
82
  return $processing_response;
83
  }
@@ -128,11 +137,22 @@
128
  if(!empty($this->wph->default_variables['wordpress_directory']))
129
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
130
  $path .= $default_upload_url;
131
-
132
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
133
- $text .= "RewriteRule ^". $path ."(.*) ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
 
 
 
 
 
 
 
 
 
 
 
134
 
135
- $processing_response['htaccess'] = $text;
136
 
137
  return $processing_response;
138
 
77
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
78
  $path .= trailingslashit( $saved_field_data );
79
 
80
+ if($this->wph->server_htaccess_config === TRUE)
81
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.*) '. $uploads_path .'$1 [L,QSA]';
82
+
83
+ if($this->wph->server_web_config === TRUE)
84
+ $processing_response['rewrite'] = '
85
+ <rule name="wph-new_upload_path" stopProcessing="true">
86
+ <match url="^'. $path .'(.*)" />
87
+ <action type="Rewrite" url="'. $uploads_path .'{R:1}" appendQueryString="true" />
88
+ </rule>
89
+ ';
90
 
91
  return $processing_response;
92
  }
137
  if(!empty($this->wph->default_variables['wordpress_directory']))
138
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
139
  $path .= $default_upload_url;
140
+
141
+ if($this->wph->server_htaccess_config === TRUE)
142
+ {
143
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
144
+ $text .= "RewriteRule ^". $path ."(.*) ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
145
+ }
146
+
147
+ if($this->wph->server_web_config === TRUE)
148
+ $text = '
149
+ <rule name="wph-block_upload_url" stopProcessing="true">
150
+ <match url="^'. $path .'(.*)" />
151
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
152
+ </rule>
153
+ ';
154
 
155
+ $processing_response['rewrite'] = $text;
156
 
157
  return $processing_response;
158
 
modules/components/rewrite-new_xml-rpc-path.php CHANGED
@@ -38,6 +38,23 @@
38
  'processing_order' => 55
39
 
40
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  $this->module_settings[] = array(
43
  'id' => 'remove_xml_rpc_tag',
@@ -80,7 +97,16 @@
80
  if(empty($saved_field_data))
81
  return $processing_response;
82
 
83
- $processing_response['htaccess'] = "\nRewriteRule ^" . $saved_field_data . ' '. $this->wph->default_variables['site_relative_path'] .'xmlrpc.php [L,QSA]';
 
 
 
 
 
 
 
 
 
84
 
85
  return $processing_response;
86
  }
@@ -92,17 +118,40 @@
92
 
93
  if(empty($saved_field_data) || $saved_field_data == 'no')
94
  return FALSE;
95
-
96
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
97
- $text .= "RewriteRule ^xmlrpc.php ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
- $processing_response['htaccess'] = $text;
100
 
101
  return $processing_response;
102
 
103
 
104
  }
105
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  function _init_remove_xml_rpc_tag($saved_field_data)
108
  {
38
  'processing_order' => 55
39
 
40
  );
41
+
42
+ $this->module_settings[] = array(
43
+ 'id' => 'disable_xml_rpc_auth',
44
+ 'label' => __('Disable XML-RPC authentication', 'wp-hide-security-enhancer'),
45
+ 'description' => __('Filter whether XML-RPC methods requiring authentication, such as for publishing purposes, are enabled.', 'wp-hide-security-enhancer'),
46
+
47
+ 'input_type' => 'radio',
48
+ 'options' => array(
49
+ 'yes' => __('Yes', 'wp-hide-security-enhancer'),
50
+ 'no' => __('No', 'wp-hide-security-enhancer'),
51
+ ),
52
+ 'default_value' => 'no',
53
+
54
+ 'sanitize_type' => array('sanitize_title', 'strtolower'),
55
+ 'processing_order' => 55
56
+
57
+ );
58
 
59
  $this->module_settings[] = array(
60
  'id' => 'remove_xml_rpc_tag',
97
  if(empty($saved_field_data))
98
  return $processing_response;
99
 
100
+ if($this->wph->server_htaccess_config === TRUE)
101
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $saved_field_data . ' '. $this->wph->default_variables['site_relative_path'] .'xmlrpc.php [L,QSA]';
102
+
103
+ if($this->wph->server_web_config === TRUE)
104
+ $processing_response['rewrite'] = '
105
+ <rule name="wph-new_xml_rpc_path" stopProcessing="true">
106
+ <match url="^'. $saved_field_data .'" />
107
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'xmlrpc.php" appendQueryString="true" />
108
+ </rule>
109
+ ';
110
 
111
  return $processing_response;
112
  }
118
 
119
  if(empty($saved_field_data) || $saved_field_data == 'no')
120
  return FALSE;
121
+
122
+ if($this->wph->server_htaccess_config === TRUE)
123
+ {
124
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
125
+ $text .= "RewriteRule ^xmlrpc.php ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
126
+ }
127
+
128
+ if($this->wph->server_web_config === TRUE)
129
+ $text = '
130
+ <rule name="wph-block_xml_rpc" stopProcessing="true">
131
+ <match url="^xmlrpc.php" />
132
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
133
+ </rule>
134
+ ';
135
+
136
 
137
+ $processing_response['rewrite'] = $text;
138
 
139
  return $processing_response;
140
 
141
 
142
  }
143
 
144
+ function _init_disable_xml_rpc_auth($saved_field_data)
145
+ {
146
+
147
+ if(empty($saved_field_data) || $saved_field_data == 'no')
148
+ return FALSE;
149
+
150
+
151
+ add_filter( 'xmlrpc_enabled', '__return_false' );
152
+
153
+ }
154
+
155
 
156
  function _init_remove_xml_rpc_tag($saved_field_data)
157
  {
modules/components/rewrite-root-files.php CHANGED
@@ -94,6 +94,22 @@
94
  'sanitize_type' => array('sanitize_title', 'strtolower'),
95
  'processing_order' => 60
96
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  $this->module_settings[] = array(
99
  'id' => 'block_default_wp_signup_php',
@@ -157,7 +173,16 @@
157
 
158
  $default_path = $this->wph->functions->get_url_path( trailingslashit(site_url()) . 'wp-comments-post.php', TRUE );
159
 
160
- $processing_response['htaccess'] = "\nRewriteRule ^" . $saved_field_data . ' '. $default_path .' [L,QSA]';
 
 
 
 
 
 
 
 
 
161
 
162
  return $processing_response;
163
 
@@ -176,11 +201,22 @@
176
  $new_wp_comments_post = ltrim(rtrim($this->wph->functions->get_module_item_setting('new_wp_comments_post'), "/"), "/");
177
  if (empty( $new_wp_comments_post ))
178
  return FALSE;
179
-
180
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
181
- $text .= "RewriteRule ^wp-comments-post.php ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
 
 
 
 
 
 
 
 
 
 
 
182
 
183
- $processing_response['htaccess'] = $text;
184
 
185
  return $processing_response;
186
 
@@ -195,10 +231,21 @@
195
  if(empty($saved_field_data) || $saved_field_data == 'no')
196
  return FALSE;
197
 
198
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
199
- $text .= "RewriteRule ^license.txt ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
 
 
 
 
 
 
 
 
 
 
 
200
 
201
- $processing_response['htaccess'] = $text;
202
 
203
  return $processing_response;
204
 
@@ -211,11 +258,22 @@
211
 
212
  if(empty($saved_field_data) || $saved_field_data == 'no')
213
  return FALSE;
214
-
215
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
216
- $text .= "RewriteRule ^readme.html ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
 
 
 
 
 
 
 
 
 
 
 
217
 
218
- $processing_response['htaccess'] = $text;
219
 
220
  return $processing_response;
221
 
@@ -228,11 +286,51 @@
228
 
229
  if(empty($saved_field_data) || $saved_field_data == 'no')
230
  return FALSE;
231
-
232
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
233
- $text .= "RewriteRule ^wp-activate.php ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
- $processing_response['htaccess'] = $text;
236
 
237
  return $processing_response;
238
 
@@ -245,11 +343,22 @@
245
 
246
  if(empty($saved_field_data) || $saved_field_data == 'no')
247
  return $processing_response;
248
-
249
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
250
- $text .= "RewriteRule ^wp-signup.php ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
 
 
 
 
 
 
 
 
 
 
 
251
 
252
- $processing_response['htaccess'] = $text;
253
 
254
  return $processing_response;
255
  }
@@ -260,18 +369,38 @@
260
 
261
  if(empty($saved_field_data) || $saved_field_data == 'no')
262
  return $processing_response;
263
-
264
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
265
- $text .= "RewriteCond %{REQUEST_FILENAME} -f\n";
266
-
267
- $text .= "RewriteCond %{REQUEST_FILENAME} !wp-activate.php [NC]\n";
268
- $text .= "RewriteCond %{REQUEST_FILENAME} !wp-signup.php [NC]\n";
269
- $text .= "RewriteCond %{REQUEST_FILENAME} !wp-comments-post.php [NC]\n";
270
- $text .= "RewriteCond %{REQUEST_FILENAME} !wp-login.php [NC]\n";
271
 
272
- $text .= "RewriteRule ^wp-([a-z-])+.php ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
 
274
- $processing_response['htaccess'] = $text;
275
 
276
  return $processing_response;
277
  }
94
  'sanitize_type' => array('sanitize_title', 'strtolower'),
95
  'processing_order' => 60
96
  );
97
+
98
+ $this->module_settings[] = array(
99
+ 'id' => 'block_wp_cron_php',
100
+ 'label' => __('Block wp-cron.php', 'wp-hide-security-enhancer'),
101
+ 'description' => __('Block access to wp-cron.php file. If remote cron calls not being used this can be set to Yes.', 'wp-hide-security-enhancer'),
102
+
103
+ 'input_type' => 'radio',
104
+ 'options' => array(
105
+ 'yes' => __('Yes', 'wp-hide-security-enhancer'),
106
+ 'no' => __('No', 'wp-hide-security-enhancer'),
107
+ ),
108
+ 'default_value' => 'no',
109
+
110
+ 'sanitize_type' => array('sanitize_title', 'strtolower'),
111
+ 'processing_order' => 60
112
+ );
113
 
114
  $this->module_settings[] = array(
115
  'id' => 'block_default_wp_signup_php',
173
 
174
  $default_path = $this->wph->functions->get_url_path( trailingslashit(site_url()) . 'wp-comments-post.php', TRUE );
175
 
176
+ if($this->wph->server_htaccess_config === TRUE)
177
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $saved_field_data . ' '. $default_path .' [L,QSA]';
178
+
179
+ if($this->wph->server_web_config === TRUE)
180
+ $processing_response['rewrite'] = '
181
+ <rule name="wph-new_wp_comments_post" stopProcessing="true">
182
+ <match url="^'. $saved_field_data .'" />
183
+ <action type="Rewrite" url="'. $default_path .'" appendQueryString="true" />
184
+ </rule>
185
+ ';
186
 
187
  return $processing_response;
188
 
201
  $new_wp_comments_post = ltrim(rtrim($this->wph->functions->get_module_item_setting('new_wp_comments_post'), "/"), "/");
202
  if (empty( $new_wp_comments_post ))
203
  return FALSE;
204
+
205
+ if($this->wph->server_htaccess_config === TRUE)
206
+ {
207
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
208
+ $text .= "RewriteRule ^wp-comments-post.php ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
209
+ }
210
+
211
+ if($this->wph->server_web_config === TRUE)
212
+ $text = '
213
+ <rule name="wph-block_wp_comments_post_url" stopProcessing="true">
214
+ <match url="^wp-comments-post.php" />
215
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
216
+ </rule>
217
+ ';
218
 
219
+ $processing_response['rewrite'] = $text;
220
 
221
  return $processing_response;
222
 
231
  if(empty($saved_field_data) || $saved_field_data == 'no')
232
  return FALSE;
233
 
234
+ if($this->wph->server_htaccess_config === TRUE)
235
+ {
236
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
237
+ $text .= "RewriteRule ^license.txt ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
238
+ }
239
+
240
+ if($this->wph->server_web_config === TRUE)
241
+ $text = '
242
+ <rule name="wph-block_license_txt" stopProcessing="true">
243
+ <match url="^license.txt" />
244
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
245
+ </rule>
246
+ ';
247
 
248
+ $processing_response['rewrite'] = $text;
249
 
250
  return $processing_response;
251
 
258
 
259
  if(empty($saved_field_data) || $saved_field_data == 'no')
260
  return FALSE;
261
+
262
+ if($this->wph->server_htaccess_config === TRUE)
263
+ {
264
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
265
+ $text .= "RewriteRule ^readme.html ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
266
+ }
267
+
268
+ if($this->wph->server_web_config === TRUE)
269
+ $text = '
270
+ <rule name="wph-block_readme_html" stopProcessing="true">
271
+ <match url="^readme.html" />
272
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
273
+ </rule>
274
+ ';
275
 
276
+ $processing_response['rewrite'] = $text;
277
 
278
  return $processing_response;
279
 
286
 
287
  if(empty($saved_field_data) || $saved_field_data == 'no')
288
  return FALSE;
289
+
290
+ if($this->wph->server_htaccess_config === TRUE)
291
+ {
292
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
293
+ $text .= "RewriteRule ^wp-activate.php ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
294
+ }
295
+
296
+ if($this->wph->server_web_config === TRUE)
297
+ $text = '
298
+ <rule name="wph-block_wp_activate_php" stopProcessing="true">
299
+ <match url="^wp-activate.php" />
300
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
301
+ </rule>
302
+ ';
303
+
304
+ $processing_response['rewrite'] = $text;
305
+
306
+ return $processing_response;
307
+
308
+
309
+ }
310
+
311
+
312
+ function _callback_saved_block_wp_cron_php($saved_field_data)
313
+ {
314
+ $processing_response = array();
315
+
316
+ if(empty($saved_field_data) || $saved_field_data == 'no')
317
+ return FALSE;
318
+
319
+ if($this->wph->server_htaccess_config === TRUE)
320
+ {
321
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
322
+ $text .= "RewriteRule ^wp-cron.php ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
323
+ }
324
+
325
+ if($this->wph->server_web_config === TRUE)
326
+ $text = '
327
+ <rule name="wph-block_wp_cron_php" stopProcessing="true">
328
+ <match url="^wp-cron.php" />
329
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
330
+ </rule>
331
+ ';
332
 
333
+ $processing_response['rewrite'] = $text;
334
 
335
  return $processing_response;
336
 
343
 
344
  if(empty($saved_field_data) || $saved_field_data == 'no')
345
  return $processing_response;
346
+
347
+ if($this->wph->server_htaccess_config === TRUE)
348
+ {
349
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
350
+ $text .= "RewriteRule ^wp-signup.php ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
351
+ }
352
+
353
+ if($this->wph->server_web_config === TRUE)
354
+ $text = '
355
+ <rule name="wph-block_default_wp_signup_php" stopProcessing="true">
356
+ <match url="^wp-signup.php" />
357
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
358
+ </rule>
359
+ ';
360
 
361
+ $processing_response['rewrite'] = $text;
362
 
363
  return $processing_response;
364
  }
369
 
370
  if(empty($saved_field_data) || $saved_field_data == 'no')
371
  return $processing_response;
 
 
 
 
 
 
 
 
372
 
373
+ if($this->wph->server_htaccess_config === TRUE)
374
+ {
375
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
376
+ $text .= "RewriteCond %{REQUEST_FILENAME} -f\n";
377
+
378
+ $text .= "RewriteCond %{REQUEST_FILENAME} !wp-activate.php [NC]\n";
379
+ $text .= "RewriteCond %{REQUEST_FILENAME} !wp-cron.php [NC]\n";
380
+ $text .= "RewriteCond %{REQUEST_FILENAME} !wp-signup.php [NC]\n";
381
+ $text .= "RewriteCond %{REQUEST_FILENAME} !wp-comments-post.php [NC]\n";
382
+ $text .= "RewriteCond %{REQUEST_FILENAME} !wp-login.php [NC]\n";
383
+
384
+ $text .= "RewriteRule ^wp-([a-z-])+.php ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
385
+ }
386
+
387
+ if($this->wph->server_web_config === TRUE)
388
+ $text = '
389
+ <rule name="wph-block_other_wp_files" stopProcessing="true">
390
+ <match url="^wp-([a-z-])+.php" />
391
+ <conditions>
392
+ <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="true" />
393
+ <add input="{REQUEST_FILENAME}" pattern="wp-activate.php" ignoreCase="true" negate="true" />
394
+ <add input="{REQUEST_FILENAME}" pattern="wp-cron.php" ignoreCase="true" negate="true" />
395
+ <add input="{REQUEST_FILENAME}" pattern="wp-signup.php" ignoreCase="true" negate="true" />
396
+ <add input="{REQUEST_FILENAME}" pattern="wp-comments-post.php" ignoreCase="true" negate="true" />
397
+ <add input="{REQUEST_FILENAME}" pattern="wp-login.php" ignoreCase="true" negate="true" />
398
+ </conditions>
399
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
400
+ </rule>
401
+ ';
402
 
403
+ $processing_response['rewrite'] = $text;
404
 
405
  return $processing_response;
406
  }
modules/components/rewrite-slash.php CHANGED
@@ -12,7 +12,7 @@
12
  $this->module_settings[] = array(
13
  'id' => 'add_slash',
14
  'label' => __('URL\'s add Slash', 'wp-hide-security-enhancer'),
15
- 'description' => __('Add a slash to any links without. This disguise any existing uppon a file, folder or a wrong url, they all be be slashed.', 'wp-hide-security-enhancer') . '<br /> '. __('On certain systems this can produce a small lag measured in milliseconds, so it should be perceptible.', 'wp-hide-security-enhancer'),
16
 
17
  'input_type' => 'radio',
18
  'options' => array(
@@ -44,11 +44,25 @@
44
 
45
  if(empty($saved_field_data) || $saved_field_data == 'no')
46
  return FALSE;
47
-
48
- $processing_response['htaccess'] = "\nRewriteCond %{ENV:REDIRECT_STATUS} !^$"
49
- . "\nRewriteCond %{REQUEST_URI} /+[^\.]+$"
50
- . "\nRewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]";
 
 
 
 
51
 
 
 
 
 
 
 
 
 
 
 
52
  return $processing_response;
53
  }
54
 
12
  $this->module_settings[] = array(
13
  'id' => 'add_slash',
14
  'label' => __('URL\'s add Slash', 'wp-hide-security-enhancer'),
15
+ 'description' => __('Add an end slash to any links without. This disguise any existance uppon a file, folder or a wrong url, they will be all slashed.', 'wp-hide-security-enhancer') . '<br /> '. __('On certain systems this can produce a small lag measured in milliseconds.', 'wp-hide-security-enhancer'),
16
 
17
  'input_type' => 'radio',
18
  'options' => array(
44
 
45
  if(empty($saved_field_data) || $saved_field_data == 'no')
46
  return FALSE;
47
+
48
+ if($this->wph->server_htaccess_config === TRUE)
49
+ //\nRewriteCond %{ENV:REDIRECT_STATUS} !^$"
50
+ $processing_response['rewrite'] = "\nRewriteCond %{REQUEST_URI} /+[^\.]+$"
51
+ . "\nRewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]";
52
+
53
+ if($this->wph->server_web_config === TRUE)
54
+ $processing_response['rewrite'] = '
55
 
56
+ <rule name="wph-add_slash" stopProcessing="true">
57
+ <match url="^(.+[^/])$" />
58
+ <conditions>
59
+ <add input="{REQUEST_URI}" matchType="Pattern" pattern="/+[^\.]+$" />
60
+ </conditions>
61
+ <action type="Redirect" redirectType="Permanent" url="{R:1}/" />
62
+ </rule>
63
+
64
+ ';
65
+
66
  return $processing_response;
67
  }
68
 
modules/components/rewrite-wp_content_path.php CHANGED
@@ -74,7 +74,16 @@
74
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
75
  $path .= trailingslashit( $saved_field_data );
76
 
77
- $processing_response['htaccess'] = "\nRewriteRule ^" . $path . '(.*) '. $content_path .'$1 [L,QSA]';
 
 
 
 
 
 
 
 
 
78
 
79
  return $processing_response;
80
  }
@@ -98,12 +107,27 @@
98
  return FALSE;
99
 
100
  $content_directory = $this->wph->default_variables['content_directory'];
101
-
102
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
103
- $text .= "RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]\n";
104
- $text .= "RewriteRule ^". $content_directory ."(.*) ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
105
-
106
- $processing_response['htaccess'] = $text;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  return $processing_response;
109
  }
74
  $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
75
  $path .= trailingslashit( $saved_field_data );
76
 
77
+ if($this->wph->server_htaccess_config === TRUE)
78
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.*) '. $content_path .'$1 [L,QSA]';
79
+
80
+ if($this->wph->server_web_config === TRUE)
81
+ $processing_response['rewrite'] = '
82
+ <rule name="wph-new_content_path" stopProcessing="true">
83
+ <match url="^'. $path .'(.*)" />
84
+ <action type="Rewrite" url="'. $content_path .'{R:1}" appendQueryString="true" />
85
+ </rule>
86
+ ';
87
 
88
  return $processing_response;
89
  }
107
  return FALSE;
108
 
109
  $content_directory = $this->wph->default_variables['content_directory'];
110
+
111
+ if($this->wph->server_htaccess_config === TRUE)
112
+ {
113
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
114
+ $text .= "RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]\n";
115
+ $text .= "RewriteRule ^". $content_directory ."(.*) ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
116
+
117
+ $processing_response['rewrite'] = $text;
118
+ }
119
+
120
+ if($this->wph->server_web_config === TRUE)
121
+ $processing_response['rewrite'] = '
122
+ <rule name="wph-block_wp_content_path" stopProcessing="true">
123
+ <match url="^'. $content_directory .'(.*)" />
124
+ <conditions>
125
+ <add input="{HTTP_COOKIE}" matchType="Pattern" pattern="wordpress_logged_in_[^.]+" negate="true" />
126
+ </conditions>
127
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
128
+ </rule>
129
+ ';
130
+
131
 
132
  return $processing_response;
133
  }
readme.txt CHANGED
@@ -4,13 +4,13 @@ Donate link: http://www.nsp-code.com/donate.php
4
  Tags: hide, security, improve security, hacking, wp hide, wordpress hide, custom login url, wp-loging.php, ap-admin
5
  Requires at least: 2.8
6
  Tested up to: 4.5.2
7
- Stable tag: 1.2.9
8
 
9
  Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
10
 
11
  == Description ==
12
 
13
- The **easy way to completely hide your WordPress** core files path from being show on front side. This is a huge improvement over Site Security. Provide a simple way to clean up html by removing WordPress fingerprints.
14
 
15
  Change the default WordPress login urls from wp-admin and wp-login.php to something totally arbitrary. No one will ever know where to try to guess a login and hack into your site. Totally invisible !!
16
 
@@ -20,7 +20,7 @@ Over 99,9% of hacked WordPress websites are target of automated malware scripts,
20
 
21
  Works fine with custom WordPress directory structures e.g. custom plugins, themes, uplaods folder.
22
 
23
- Once configured, you need to clear server cache data and / or any cache plugins (e.g. W3 Cache), for a new html data to generate. If use CDN this should be cache clear as well.
24
 
25
  **Main plugin functionality:**
26
 
@@ -35,6 +35,7 @@ Once configured, you need to clear server cache data and / or any cache plugins
35
  * Adjustable theme url
36
  * New child Theme url
37
  * Change theme style file name
 
38
  * Custom wp-include
39
  * Block default wp-include paths
40
  * Block defalt wp-content
@@ -53,11 +54,11 @@ Once configured, you need to clear server cache data and / or any cache plugins
53
 
54
  and many more.
55
 
56
- **No other plugin functionality is being blocked or interfered in any way, everything will function the same**
57
 
58
  This plugin allow to change default Admin Url's from **wp-login.php** and **wp-admin** to something else. All original links return default theme 404 Not Found page, like nothing exists there. Beside the huge security advantage, this save lots of server processing time by reducing php code and MySQL usage since brute-force attacks trigger wrong urls.
59
 
60
- **Important:** Compared to all other similar plugins which mainly use redirects, this plugin return a default theme 404 error page for all **block url** functionality, so is not reveal at all the link existence.
61
 
62
  Since version 1.2 Change individual plugin urls which make them unrecognizable, for example change default WooCommerce plugin urls and dependencies from domain.com/wp-content/plugins/woocommerce/ to domain.com/ecommerce/cdn/ or anything customized.
63
 
@@ -66,8 +67,11 @@ Since version 1.2 Change individual plugin urls which make them unrecognizable,
66
  **Rewrite > Theme**
67
 
68
  * New Theme Path - Change default theme path
69
- * New Theme Child Path - Change default child theme path
70
- * New Style File Path - Change theme stylesheed file path and name
 
 
 
71
 
72
  **Rewrite > WP includes**
73
 
@@ -84,6 +88,7 @@ Since version 1.2 Change individual plugin urls which make them unrecognizable,
84
  * New Plugins Path - Change default wp-content/plugins path / url
85
  * Block plugins URL - Block default wp-content/plugins url
86
  * New path / url for Every Active Plugin
 
87
 
88
  **Rewrite > Uploads**
89
 
@@ -94,19 +99,22 @@ Since version 1.2 Change individual plugin urls which make them unrecognizable,
94
 
95
  * New XML-RPC Path - Change default XML-RPC path / url
96
  * Block default xmlrpc.php - Block default XML-RPC url
 
97
  * Remove pingback - Remove pingback link tag from theme
98
 
99
  **Rewrite > Root Files**
100
-
 
101
  * Block license.txt - Block access to license.txt root file
102
  * Block readme.html - Block access to readme.html root file
103
  * Block wp-activate.php - Block access to wp-activate.php file
 
104
  * Block wp-signup.php - Block default wp-signup.php file
105
  * Block other wp-*.php files - Block other wp-*.php files within WordPress Root
106
 
107
  **Rewrite > Root Files**
108
 
109
- * URL's add Slash - Add a slash to any links without. This disguise any existing uppon a file, folder or a wrong url, they all be be slashed.
110
 
111
 
112
  **General / Html > Meta**
@@ -146,7 +154,7 @@ Since version 1.2 Change individual plugin urls which make them unrecognizable,
146
  * New Admin Url - Create a new admin url instead default /wp-admin. This also apply for admin-ajax.php calls
147
  * Block default Admin Url - Block default admin url and files from being accesible
148
 
149
- <br />Something is wrong with this plugin on your site? Just use the forum or get in touch with us at <a target="_blank" href="http://www.nsp-code.com">Contact</a> and we'll check it out.
150
 
151
  <br />A website example can be found at <a target="_blank" href="http://nsp-code.com/demo/wp-hide/">http://nsp-code.com/demo/wp-hide/</a>
152
 
@@ -170,8 +178,9 @@ Feel free to contact us at electronice_delphi@yahoo.com
170
  * First, stay calm. There will be no harm, guaranteed :)
171
  * Go to admin and change some of plugin options to see which one cause the problem. Then report it to forum or get in touch with us to fix it.
172
  * If you can't login to admin, use the Recovery Link which has been sent to your e-mail. This will reset the login to default.
173
- * If for some reason the site appear broken, you should back-up then replace the .htaccess file located on your WordPress root. Then remove the wp-hide-security-enhancer from your plugin directory.
174
- * If still no luck, please get in touch with us at electronice_delphi@yahoo.com and we'll fix it for you in no time!
 
175
 
176
  = I have no PHP knowledge at all, is this plugin for me? =
177
 
@@ -188,6 +197,23 @@ Please get in touch with us and we'll do our best to include it for a next versi
188
 
189
  == Changelog ==
190
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  = 1.2.9 =
192
  * Load plugin styles and scripts only when one of plugin admin menus
193
  * Use default_value when input field is empty
@@ -288,4 +314,6 @@ Always keep plugin up to date.
288
 
289
 
290
  == Localization ==
291
- Please help and translate this plugin to your language at https://translate.wordpress.org/projects/wp-plugins/wp-hide-security-enhancer
 
 
4
  Tags: hide, security, improve security, hacking, wp hide, wordpress hide, custom login url, wp-loging.php, ap-admin
5
  Requires at least: 2.8
6
  Tested up to: 4.5.2
7
+ Stable tag: 1.3.1
8
 
9
  Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
10
 
11
  == Description ==
12
 
13
+ The **easy way to completely hide your WordPress** core files path from being show on front side. This is a huge improvement over Site Security, no one will know you actually run a WordPress. Provide a simple way to clean up html by removing all WordPress fingerprints.
14
 
15
  Change the default WordPress login urls from wp-admin and wp-login.php to something totally arbitrary. No one will ever know where to try to guess a login and hack into your site. Totally invisible !!
16
 
20
 
21
  Works fine with custom WordPress directory structures e.g. custom plugins, themes, uplaods folder.
22
 
23
+ Once configured, you need to **clear server cache data and / or any cache plugins** (e.g. W3 Cache), for a new html data to be created. If use CDN this should be cache clear as well.
24
 
25
  **Main plugin functionality:**
26
 
35
  * Adjustable theme url
36
  * New child Theme url
37
  * Change theme style file name
38
+ * Clean any headers for a style file
39
  * Custom wp-include
40
  * Block default wp-include paths
41
  * Block defalt wp-content
54
 
55
  and many more.
56
 
57
+ **No other plugins functionality is being blocked or interfered in any way, everything will function the same**
58
 
59
  This plugin allow to change default Admin Url's from **wp-login.php** and **wp-admin** to something else. All original links return default theme 404 Not Found page, like nothing exists there. Beside the huge security advantage, this save lots of server processing time by reducing php code and MySQL usage since brute-force attacks trigger wrong urls.
60
 
61
+ **Important:** Compared to all other similar plugins which mainly use redirects, this plugin return a default theme 404 error page for all **block url** functionality, so is not revealing at all the link existence.
62
 
63
  Since version 1.2 Change individual plugin urls which make them unrecognizable, for example change default WooCommerce plugin urls and dependencies from domain.com/wp-content/plugins/woocommerce/ to domain.com/ecommerce/cdn/ or anything customized.
64
 
67
  **Rewrite > Theme**
68
 
69
  * New Theme Path - Change default theme path
70
+ * New Style File Path - Change default style file name and path
71
+ * Remove description header from Style file - Replace any WordPress metadata informations (like theme name, version etc) from style file
72
+ * Child - New Theme Path - Change default child theme path
73
+ * Child - New Style File Path - Change child theme stylesheed file path and name
74
+ * Child - Remove description header from Style file - Replace any WordPress metadata informations (like theme name, version etc) from style file
75
 
76
  **Rewrite > WP includes**
77
 
88
  * New Plugins Path - Change default wp-content/plugins path / url
89
  * Block plugins URL - Block default wp-content/plugins url
90
  * New path / url for Every Active Plugin
91
+ * Custom path and name for any active plugins
92
 
93
  **Rewrite > Uploads**
94
 
99
 
100
  * New XML-RPC Path - Change default XML-RPC path / url
101
  * Block default xmlrpc.php - Block default XML-RPC url
102
+ * Disable XML-RPC authentication - Filter whether XML-RPC methods requiring authentication
103
  * Remove pingback - Remove pingback link tag from theme
104
 
105
  **Rewrite > Root Files**
106
+ * New wp-comments-post.php Path
107
+ * Block wp-comments-post.php
108
  * Block license.txt - Block access to license.txt root file
109
  * Block readme.html - Block access to readme.html root file
110
  * Block wp-activate.php - Block access to wp-activate.php file
111
+ * Block wp-cron.php - Block access to wp-cron.php file
112
  * Block wp-signup.php - Block default wp-signup.php file
113
  * Block other wp-*.php files - Block other wp-*.php files within WordPress Root
114
 
115
  **Rewrite > Root Files**
116
 
117
+ * URL's add Slash - Add a slash to any links without. This disguise any existing uppon a file, folder or a wrong url, they all be all slashed.
118
 
119
 
120
  **General / Html > Meta**
154
  * New Admin Url - Create a new admin url instead default /wp-admin. This also apply for admin-ajax.php calls
155
  * Block default Admin Url - Block default admin url and files from being accesible
156
 
157
+ <br />Something is wrong with this plugin on your site? Just use the forum or get in touch with us at <a target="_blank" href="http://www.wp-hide.com">Contact</a> and we'll check it out.
158
 
159
  <br />A website example can be found at <a target="_blank" href="http://nsp-code.com/demo/wp-hide/">http://nsp-code.com/demo/wp-hide/</a>
160
 
178
  * First, stay calm. There will be no harm, guaranteed :)
179
  * Go to admin and change some of plugin options to see which one cause the problem. Then report it to forum or get in touch with us to fix it.
180
  * If you can't login to admin, use the Recovery Link which has been sent to your e-mail. This will reset the login to default.
181
+ * If for some reason the site appear broken, you should back-up then **replace the .htaccess file** located on your WordPress root. Then **remove the wp-hide-security-enhancer** from your plugin directory.
182
+
183
+ * At this point the site should run as before. If for some reason still not working, you missed something, please get in touch with us at electronice_delphi@yahoo.com and we'll fix it for you in no time!
184
 
185
  = I have no PHP knowledge at all, is this plugin for me? =
186
 
197
 
198
  == Changelog ==
199
 
200
+ = 1.3.1 =
201
+ * Moved the Disable XML-RPC authentication within Rewrite -> XML-RPC
202
+ * HTML Comments strip out will trigger only on front side, no need for admin
203
+ * wp-cron.php block / allow access new setting
204
+ * New style file name now include default / new theme path to avoid 404 resource loading when using internally relative urls.
205
+ * Modules Menu order fix
206
+ * Writable check notification improvements for htaccess / web.config file
207
+ * Alternative request headers when apache_response_headers for LEMP / PHP-FPM
208
+ * IIS windows server type compatibility
209
+ * Rewrite rules for IIS servers with web.config set-up
210
+ * apache_response_headers and headers_list PHP functions check if available within the server
211
+ * Code Version add and updater class structure update
212
+ * WriteCheckString check fix when .htaccess not exists
213
+ * Remove description header from Style file
214
+ * Router Engine - files post-processing
215
+ * Separate theme, style, style proxy setting for parent and child
216
+
217
  = 1.2.9 =
218
  * Load plugin styles and scripts only when one of plugin admin menus
219
  * Use default_value when input field is empty
314
 
315
 
316
  == Localization ==
317
+ Please help and translate this plugin to your language at https://translate.wordpress.org/projects/wp-plugins/wp-hide-security-enhancer
318
+
319
+ Please help by promoting this plugin with an article on your site or any other place. If this code helped in your your project, consider to leave a 5 star review on this board.
router/file-process.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ error_reporting(0);
4
+
5
+ $action = isset($_GET['action']) ? $_GET['action'] : '';
6
+ $file_path = isset($_GET['file_path']) ? $_GET['file_path'] : '';
7
+
8
+ if(empty($action) || empty($file_path))
9
+ die();
10
+
11
+ //append doc root to path
12
+ $file_path = $_SERVER["DOCUMENT_ROOT"] . $file_path;
13
+
14
+ //check if file exists
15
+ if (!file_exists($file_path))
16
+ die();
17
+
18
+ $WPH_FileProcess = new WPH_FileProcess();
19
+
20
+ $WPH_FileProcess->action = $action;
21
+ $WPH_FileProcess->file_path = $file_path;
22
+
23
+ $WPH_FileProcess->run();
24
+
25
+ class WPH_FileProcess
26
+ {
27
+ var $action;
28
+ var $file_path;
29
+
30
+ function __construct()
31
+ {
32
+ ob_start("ob_gzhandler");
33
+ }
34
+
35
+ function __destruct()
36
+ {
37
+ $out = ob_get_contents();
38
+ ob_end_clean();
39
+
40
+ echo $out;
41
+ }
42
+
43
+ function run()
44
+ {
45
+ switch($this->action)
46
+ {
47
+ case 'style-clean' :
48
+ $this->style_clean();
49
+ break;
50
+
51
+ }
52
+ }
53
+
54
+
55
+ function style_clean()
56
+ {
57
+ //output headers
58
+ $expires_offset = 31536000;
59
+
60
+ header('Content-Type: text/css; charset=UTF-8');
61
+ header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
62
+ header("Cache-Control: public, max-age=$expires_offset");
63
+
64
+ $handle = fopen($this->file_path, "r");
65
+ $file_data = fread($handle, filesize($this->file_path));
66
+ fclose($handle);
67
+
68
+ $file_data = preg_replace('!/\*.*?\*/!s', '', $file_data);
69
+ $file_data = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $file_data);
70
+
71
+ echo $file_data;
72
+
73
+ }
74
+ }
75
+
76
+
77
+ ?>
wp-hide.php CHANGED
@@ -5,13 +5,14 @@ Plugin URI: http://www.nsp-code.com
5
  Description: Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
6
  Author: Nsp Code
7
  Author URI: http://www.nsp-code.com
8
- Version: 1.2.9
9
  Text Domain: wp-hide-security-enhancer
10
  Domain Path: /languages/
11
  */
12
 
13
-
14
- define('WPH_PATH', plugin_dir_path(__FILE__));
 
15
 
16
  //load language files
17
  add_action( 'plugins_loaded', 'WPH_load_textdomain');
@@ -63,6 +64,5 @@ Domain Path: /languages/
63
 
64
  add_action( 'activated_plugin', array($wph, 'activated_plugin'), 999, 2 );
65
 
66
- add_filter( 'xmlrpc_enabled', '__return_false' );
67
-
68
  ?>
5
  Description: Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
6
  Author: Nsp Code
7
  Author URI: http://www.nsp-code.com
8
+ Version: 1.3.1
9
  Text Domain: wp-hide-security-enhancer
10
  Domain Path: /languages/
11
  */
12
 
13
+
14
+ define('WPH_PATH', plugin_dir_path(__FILE__));
15
+ define('WPH_VERSION', '1.3.1');
16
 
17
  //load language files
18
  add_action( 'plugins_loaded', 'WPH_load_textdomain');
64
 
65
  add_action( 'activated_plugin', array($wph, 'activated_plugin'), 999, 2 );
66
 
67
+
 
68
  ?>