LiteSpeed Cache - Version 1.0.15

Version Description

  • April 20 2017 =
  • [NEW] Added Purge Pages and Purge Recent Posts Widget pages options.
  • [NEW] Added wp-cli command for setting and getting options.
  • [NEW] Added an import/export options cli command.
  • [NEW] Added wpForo integration.
  • [NEW] Added Theme My Login integration.
  • [UPDATE] Purge adjacent posts when publish a new post.
  • [UPDATE] Change environment report file to .php and increase security.
  • [UPDATE] Added new purgeby option to wp-cli.
  • [UPDATE] Remove nag for multiple sites.
  • [UPDATE] Only inject LiteSpeed javascripts in LiteSpeed pages.
  • [REFACTOR] Properly check for zero in ttl settings.
  • [BUGFIX] Fixed the 404 issue that can be caused by some certain plugins when save the settings.
  • [BUGFIX] Fixed mu-plugin compatibility.
  • [BUGFIX] Fixed problem with creating zip backup.
  • [BUGFIX] Fixed conflict with jetpack.
Download this release

Release Info

Developer LiteSpeedTech
Plugin Icon 128x128 LiteSpeed Cache
Version 1.0.15
Comparing to
See all releases

Code changes from version 1.3.1.1 to 1.0.15

Files changed (117) hide show
  1. admin/class-litespeed-cache-admin-display.php +2974 -0
  2. admin/class-litespeed-cache-admin-error.php +368 -0
  3. admin/class-litespeed-cache-admin-rules.php +1520 -0
  4. admin/class-litespeed-cache-admin.php +1213 -2
  5. admin/css/litespeed-cache-admin.css +394 -0
  6. admin/js/litespeed-cache-admin.js +190 -0
  7. admin/litespeed-cache-admin-display.class.php +0 -826
  8. admin/litespeed-cache-admin-error.class.php +0 -262
  9. admin/litespeed-cache-admin-optimize.class.php +0 -188
  10. admin/litespeed-cache-admin-report.class.php +0 -197
  11. admin/litespeed-cache-admin-rules.class.php +0 -854
  12. admin/litespeed-cache-admin-settings.class.php +0 -975
  13. admin/litespeed-cache-admin.class.php +0 -276
  14. admin/tpl/admin_footer.php +0 -19
  15. admin/tpl/crawler.php +0 -228
  16. admin/tpl/debug_log.php +0 -27
  17. admin/tpl/edit_htaccess.php +0 -75
  18. admin/tpl/esi_widget_edit.php +0 -80
  19. admin/tpl/help_tabs.php +0 -26
  20. admin/tpl/info.php +0 -42
  21. admin/tpl/info_admin_ip.php +0 -33
  22. admin/tpl/info_common_rewrite.php +0 -58
  23. admin/tpl/info_compatibility.php +0 -57
  24. admin/tpl/info_config.php +0 -68
  25. admin/tpl/info_crawler.php +0 -67
  26. admin/tpl/info_faqs.php +0 -110
  27. admin/tpl/manage.php +0 -58
  28. admin/tpl/manage_db.php +0 -85
  29. admin/tpl/manage_purge.php +0 -187
  30. admin/tpl/network_settings.php +0 -59
  31. admin/tpl/network_settings_cache.php +0 -19
  32. admin/tpl/network_settings_excludes.php +0 -15
  33. admin/tpl/network_settings_general.php +0 -34
  34. admin/tpl/network_settings_purge.php +0 -10
  35. admin/tpl/report.php +0 -46
  36. admin/tpl/settings.php +0 -148
  37. admin/tpl/settings_advanced.php +0 -80
  38. admin/tpl/settings_cache.php +0 -78
  39. admin/tpl/settings_cdn.php +0 -104
  40. admin/tpl/settings_compatibilities.php +0 -38
  41. admin/tpl/settings_crawler.php +0 -196
  42. admin/tpl/settings_debug.php +0 -146
  43. admin/tpl/settings_esi.php +0 -90
  44. admin/tpl/settings_excludes.php +0 -116
  45. admin/tpl/settings_general.php +0 -144
  46. admin/tpl/settings_inc.cache_browser.php +0 -19
  47. admin/tpl/settings_inc.cache_favicon.php +0 -19
  48. admin/tpl/settings_inc.cache_mobile.php +0 -70
  49. admin/tpl/settings_inc.cache_resources.php +0 -20
  50. admin/tpl/settings_inc.exclude_cookies.php +0 -27
  51. admin/tpl/settings_inc.exclude_useragent.php +0 -26
  52. admin/tpl/settings_inc.purge_on_upgrade.php +0 -14
  53. admin/tpl/settings_optimize.php +0 -182
  54. admin/tpl/settings_purge.php +0 -95
  55. admin/tpl/show_display_installed.php +0 -21
  56. admin/tpl/show_error_cookie.php +0 -13
  57. admin/tpl/show_rule_conflict.php +0 -13
  58. cli/class-litespeed-cache-cli-admin.php +328 -0
  59. cli/class-litespeed-cache-cli-purge.php +316 -0
  60. cli/litespeed-cache-cli-admin.class.php +0 -363
  61. cli/litespeed-cache-cli-purge.class.php +0 -302
  62. css/fonts/litespeedfont.eot +0 -0
  63. css/fonts/litespeedfont.svg +0 -11
  64. css/fonts/litespeedfont.ttf +0 -0
  65. css/fonts/litespeedfont.woff +0 -0
  66. css/litespeed.css +0 -1180
  67. img/Litespeed.icon.svg +0 -30
  68. img/icons/all.svg +0 -65
  69. img/icons/all_transients.svg +0 -33
  70. img/icons/auto_draft.svg +0 -54
  71. img/icons/cross_icon.svg +0 -41
  72. img/icons/db.svg +0 -21
  73. img/icons/empty-cache.svg +0 -60
  74. img/icons/expired_transient.svg +0 -38
  75. img/icons/optimize_tables.svg +0 -30
  76. img/icons/purge-403.svg +0 -47
  77. img/icons/purge-404.svg +0 -41
  78. img/icons/purge-500.svg +0 -46
  79. img/icons/purge-all.svg +0 -46
  80. img/icons/purge-cssjs.svg +0 -50
  81. img/icons/purge-front.svg +0 -31
  82. img/icons/purge-pages.svg +0 -41
  83. img/icons/revision.svg +0 -64
  84. img/icons/spam_comment.svg +0 -38
  85. img/icons/success_icon.svg +0 -42
  86. img/icons/trackback-pingback.svg +0 -30
  87. img/icons/trash_comment.svg +0 -64
  88. img/icons/trash_post.svg +0 -48
  89. inc/data.class.php +0 -177
  90. includes/class-litespeed-cache-config.php +677 -0
  91. includes/class-litespeed-cache-tags.php +237 -0
  92. includes/class-litespeed-cache.php +2630 -0
  93. includes/deprecated-litespeed-cache-tags.class.php +0 -12
  94. includes/litespeed-cache-activation.class.php +0 -235
  95. includes/litespeed-cache-api.class.php +0 -427
  96. includes/litespeed-cache-cdn.class.php +0 -400
  97. includes/litespeed-cache-config.class.php +0 -819
  98. includes/litespeed-cache-control.class.php +0 -610
  99. includes/litespeed-cache-crawler-sitemap.class.php +0 -155
  100. includes/litespeed-cache-crawler.class.php +0 -450
  101. includes/litespeed-cache-esi-dummy.tpl.php +0 -9
  102. includes/litespeed-cache-esi.class.php +0 -569
  103. includes/litespeed-cache-esi.tpl.php +0 -9
  104. includes/litespeed-cache-gui.class.php +0 -116
  105. includes/litespeed-cache-log.class.php +0 -321
  106. includes/litespeed-cache-optimize.class.php +0 -1002
  107. includes/litespeed-cache-purge.class.php +0 -753
  108. includes/litespeed-cache-router.class.php +0 -397
  109. includes/litespeed-cache-tag.class.php +0 -367
  110. includes/litespeed-cache-task.class.php +0 -128
  111. includes/litespeed-cache-utility.class.php +0 -254
  112. includes/litespeed-cache-vary.class.php +0 -465
  113. includes/litespeed-cache.class.php +0 -594
  114. includes/litespeed.autoload.php +0 -75
  115. js/css_async.js +0 -4
  116. js/litespeed-cache-admin.js +0 -385
  117. languages/litespeed-cache.pot +570 -1740
admin/class-litespeed-cache-admin-display.php ADDED
@@ -0,0 +1,2974 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The admin-panel specific functionality of the plugin.
5
+ *
6
+ *
7
+ * @since 1.0.0
8
+ * @package LiteSpeed_Cache
9
+ * @subpackage LiteSpeed_Cache/admin
10
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
11
+ */
12
+ class LiteSpeed_Cache_Admin_Display
13
+ {
14
+ private static $instance;
15
+
16
+ const NOTICE_BLUE = 'notice notice-info';
17
+ const NOTICE_GREEN = 'notice notice-success';
18
+ const NOTICE_RED = 'notice notice-error';
19
+ const NOTICE_YELLOW = 'notice notice-warning';
20
+
21
+ const PURGEBY_CAT = '0';
22
+ const PURGEBY_PID = '1';
23
+ const PURGEBY_TAG = '2';
24
+ const PURGEBY_URL = '3';
25
+
26
+ const PURGEBYOPT_SELECT = 'purgeby';
27
+ const PURGEBYOPT_LIST = 'purgebylist';
28
+
29
+ private $notices = array();
30
+ private $disable_all = false;
31
+
32
+ /**
33
+ * Initialize the class and set its properties.
34
+ *
35
+ * @since 1.0.7
36
+ * @access private
37
+ */
38
+ private function __construct()
39
+ {
40
+ }
41
+
42
+ /**
43
+ * Get the LiteSpeed_Cache_Admin_Display object.
44
+ *
45
+ * @since 1.0.7
46
+ * @access public
47
+ * @return LiteSpeed_Cache_Admin_Display Static instance of the
48
+ * LiteSpeed_Cache_Admin_Display class.
49
+ */
50
+ public static function get_instance()
51
+ {
52
+ if (!isset(self::$instance)) {
53
+ self::$instance = new LiteSpeed_Cache_Admin_Display();
54
+ }
55
+
56
+ return self::$instance;
57
+ }
58
+
59
+ /**
60
+ * Change the admin footer text on LiteSpeed Cache admin pages.
61
+ *
62
+ * @since 1.0.13
63
+ * @param string $footer_text
64
+ * @return string
65
+ */
66
+ public function admin_footer_text($footer_text)
67
+ {
68
+ $rate_us = sprintf(wp_kses(
69
+ __('Rate <strong>LiteSpeed Cache</strong> with %s on WordPress.org if you like us!', 'litespeed-cache'),
70
+ array('strong' => array())
71
+ ),
72
+ '<a href="https://wordpress.org/support/plugin/litespeed-cache/reviews/?filter=5#new-post" '
73
+ . 'rel="noopener noreferer" target="_blank">&#10030;&#10030;&#10030;&#10030;&#10030;</a>'
74
+ );
75
+ $questions = sprintf(wp_kses(
76
+ __('If there are any questions that are not answered in the <a href="%s">FAQs</a>, do not hesitate to ask them on the <a href="%s" rel="%s" target="%s">support forum</a>.',
77
+ 'litespeed-cache'),
78
+ array(
79
+ 'a' => array(
80
+ 'href' => array(),
81
+ 'rel' => array(),
82
+ 'target' => array(),
83
+ ),
84
+ )),
85
+ get_admin_url() . 'admin.php?page=lscache-info',
86
+ 'https://wordpress.org/support/plugin/litespeed-cache',
87
+ 'noopener noreferrer', '_blank'
88
+ );
89
+ // Change the footer text
90
+ if (!is_multisite() || is_network_admin()){
91
+ $footer_text = self::build_paragraph($rate_us, $questions);
92
+ }else{
93
+ $footer_text = self::build_paragraph($questions);
94
+ }
95
+
96
+ return $footer_text;
97
+ }
98
+
99
+ /**
100
+ * Whether to disable all settings or not.
101
+ *
102
+ * Currently used for 'use primary subsite settings'
103
+ *
104
+ * @since 1.0.13
105
+ * @access public
106
+ * @return bool True to disable all settings, false otherwise.
107
+ */
108
+ public function get_disable_all()
109
+ {
110
+ return $this->disable_all;
111
+ }
112
+
113
+ /**
114
+ * Set to disable all settings.
115
+ *
116
+ * @since 1.0.13
117
+ * @access public
118
+ */
119
+ public function set_disable_all()
120
+ {
121
+ $this->disable_all = true;
122
+ }
123
+
124
+ /**
125
+ * Displays the help tab in the admin pages.
126
+ *
127
+ * @since 1.0.0
128
+ * @access public
129
+ */
130
+ public function add_help_tabs()
131
+ {
132
+ $content_para = self::build_paragraph(
133
+ __('LiteSpeed Cache is a page cache built into LiteSpeed Web Server.', 'litespeed-cache'),
134
+ __('This plugin communicates with LiteSpeed Web Server to let it know which pages are cache-able and when to purge them.', 'litespeed-cache')
135
+ );
136
+
137
+ $screen = get_current_screen();
138
+ $screen->add_help_tab(array(
139
+ 'id' => 'lsc-overview',
140
+ 'title' => __('Overview', 'litespeed-cache'),
141
+ 'content' => '<p>' . $content_para . '</p><p>'
142
+ . __('A LiteSpeed server (OLS, LSWS, WebADC) and its LSCache module must be installed and enabled.', 'litespeed-cache')
143
+ . '</p>',
144
+ ));
145
+
146
+ // $screen->add_help_tab(array(
147
+ // 'id' => 'lst-purgerules',
148
+ // 'title' => __('Auto Purge Rules', 'litespeed-cache'),
149
+ // 'content' => '<p>' . __('You can set what pages will be purged when a post is published or updated.', 'litespeed-cache') . '</p>',
150
+ // ));
151
+
152
+ $screen->set_help_sidebar(
153
+ '<p><strong>' . __('For more information:', 'litespeed-cache') . '</strong></p>' .
154
+ // '<p><a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache" rel="noopener noreferrer" target="_blank">' . __('LSCache Documentation', 'litespeed-cache') . '</a></p>' .
155
+ '<p><a href="https://wordpress.org/support/plugin/litespeed-cache" rel="noopener noreferrer" target="_blank">' . __('Support Forum', 'litespeed-cache') . '</a></p>'
156
+ );
157
+ }
158
+
159
+ /**
160
+ * Check to make sure that caching is enabled.
161
+ *
162
+ * @since 1.0.0
163
+ * @access public
164
+ * @param LiteSpeed_Cache_Config $config The current configurations object.
165
+ * @return mixed True if enabled, error message otherwise.
166
+ */
167
+ public function check_license($config)
168
+ {
169
+ if ($config->is_caching_allowed() == false) {
170
+ $sentences = LiteSpeed_Cache_Admin_Error::get_error(
171
+ LiteSpeed_Cache_Admin_Error::E_SERVER
172
+ );
173
+
174
+ return $sentences;
175
+ }
176
+
177
+ return true;
178
+ }
179
+
180
+ /**
181
+ * Helper function to build paragraphs out of all the string sentences
182
+ * passed in.
183
+ *
184
+ * @since 1.0.11
185
+ * @access public
186
+ * @param string $args,... Variable number of strings to combine to a paragraph.
187
+ * @return string The built paragraph.
188
+ */
189
+ public static function build_paragraph()
190
+ {
191
+ $args = func_get_args();
192
+ $para = implode(' ', $args);
193
+ return $para;
194
+ }
195
+
196
+ /**
197
+ * Helper function to build a list out of an array of strings.
198
+ *
199
+ * @since 1.0.14
200
+ * @access public
201
+ * @param array $items The list of strings to build into a list.
202
+ * @param bool $ordered Whether to make it an ordered or unordered list.
203
+ * @param string $style Any styling to apply to the list.
204
+ * @return string The built list.
205
+ */
206
+ public static function build_list($items, $ordered = false, $style = '')
207
+ {
208
+ $buf = '<';
209
+ if ($ordered) {
210
+ $type = 'ol';
211
+ }
212
+ else {
213
+ $type = 'ul';
214
+ }
215
+ $buf .= $type;
216
+ if ($style) {
217
+ $buf .= ' style="' . $style . '"';
218
+ }
219
+ $buf .= '><li>';
220
+ $buf .= implode('</li><li>', $items);
221
+ $buf .= '</li></' . $type . '>';
222
+ return $buf;
223
+ }
224
+
225
+ /**
226
+ * Builds the html for a single notice.
227
+ *
228
+ * @since 1.0.7
229
+ * @access private
230
+ * @param string $color The color to use for the notice.
231
+ * @param string $str The notice message.
232
+ * @return string The built notice html.
233
+ */
234
+ private static function build_notice($color, $str)
235
+ {
236
+ return '<div class="' . $color . ' is-dismissible"><p>'
237
+ . $str . '</p></div>';
238
+ }
239
+
240
+ /**
241
+ * Builds the html for a tooltip text.
242
+ *
243
+ * @since 1.0.14
244
+ * @access private
245
+ * @param string $msg Text that needs to be displayed in tooltip
246
+ * @param string $class_suffix Class name for the tooltip
247
+ * @param string $field_style Extra styles if required for outer span
248
+ * @param string $tip_style Extra styles if required for inner span
249
+ * @return string tooltip message.
250
+ */
251
+ private static function build_tip($msg, $class_suffix = '',
252
+ $field_style = '', $tip_style = '')
253
+ {
254
+ $buf = '<span class="litespeed-cache-field-tip';
255
+ if (!empty($class_suffix)) {
256
+ $buf .= $class_suffix;
257
+ }
258
+ if (!empty($field_style)) {
259
+ $buf .= '" style="' . $field_style;
260
+ }
261
+ $buf .= '"><span class="litespeed-cache-tip-content';
262
+ if (!empty($class_suffix)) {
263
+ $buf .= $class_suffix;
264
+ }
265
+ if (!empty($tip_style)) {
266
+ $buf .= '" style="' . $tip_style;
267
+ }
268
+
269
+ $buf .= '">' . $msg . '</span></span>';
270
+
271
+ return $buf;
272
+ }
273
+
274
+ /**
275
+ * Builds the html for buttons that depend on rtl/ltr orientation.
276
+ *
277
+ * @since 1.0.14
278
+ * @access private
279
+ * @param string $class_suffix The class name used for the button
280
+ * @param string $button_text The text used for the button
281
+ * @param string $notice The notice message to be display after button
282
+ * click
283
+ * @param boolean $extra_br Optional if extra br is required to adjust the
284
+ * layout.
285
+ * @return string button text.
286
+ */
287
+ private static function build_button($class_suffix, $button_text = '',
288
+ $notice = '', $extra_br = true)
289
+ {
290
+ $buf = '<span class="' . $class_suffix . '"';
291
+
292
+ if (!is_rtl()) {
293
+ $buf .= ' style="float:left;"';
294
+ }
295
+
296
+ $buf .= '>' . $button_text . '</span>';
297
+
298
+ if (!empty($notice)) {
299
+ $buf .= '<span class="copy-select-all-span" style="display:none; font-size:11px; font-style:italic;margin-left:10px; position:relative; top:3px; color: green;">'
300
+ . $notice . '</span>';
301
+ }
302
+
303
+ $buf .= '<br>';
304
+
305
+ if ($extra_br) {
306
+ $buf .= '<br>';
307
+ }
308
+
309
+ return $buf;
310
+ }
311
+
312
+ /**
313
+ * Builds the html for the expand/collapse all button.
314
+ *
315
+ * @since 1.0.14
316
+ * @access private
317
+ * @param boolean $br Whether to include an extra br tag at the end or not.
318
+ * @return string The built button html.
319
+ */
320
+ private static function build_expand_collapse($extra_br = true)
321
+ {
322
+ $buf = self::build_button('litespeed-cache-jquery-button', '', '', $extra_br);
323
+
324
+ $buf .= self::get_instance()->input_field_hidden('litespeed-cache-jquery-button-expand-val', __("Expand All", "litespeed-cache"))
325
+ . self::get_instance()->input_field_hidden('litespeed-cache-jquery-button-collapse-val', __("Collapse All", "litespeed-cache"));
326
+
327
+
328
+ return $buf;
329
+ }
330
+
331
+ /**
332
+ * Adds a notice to display on the admin page. Multiple messages of the
333
+ * same color may be added in a single call. If the list is empty, this
334
+ * method will add the action to display notices.
335
+ *
336
+ * @since 1.0.7
337
+ * @access public
338
+ * @param string $color One of the available constants provided by this
339
+ * class.
340
+ * @param mixed $msg May be a string for a single message or an array for
341
+ * multiple.
342
+ */
343
+ public function add_notice($color, $msg)
344
+ {
345
+ if (empty($this->notices)) {
346
+ add_action(
347
+ (is_network_admin() ? 'network_admin_notices' : 'admin_notices'),
348
+ array($this, 'display_notices'));
349
+ }
350
+ if (!is_array($msg)) {
351
+ $this->notices[] = self::build_notice($color, $msg);
352
+
353
+ return;
354
+ }
355
+ foreach ($msg as $str) {
356
+ $this->notices[] = self::build_notice($color, $str);
357
+ }
358
+ }
359
+
360
+ /**
361
+ * Callback function to display any notices from editing cache settings.
362
+ *
363
+ * @since 1.0.7
364
+ * @access public
365
+ */
366
+ public function display_notices()
367
+ {
368
+ foreach ($this->notices as $msg) {
369
+ echo $msg;
370
+ }
371
+ }
372
+
373
+ /**
374
+ * add_submenu_page callback to determine which submenu page to display
375
+ * if the admin selected a LiteSpeed Cache dashboard page.
376
+ *
377
+ * @since 1.0.4
378
+ */
379
+ public function show_menu_select()
380
+ {
381
+ $page = $_REQUEST['page'];
382
+ if (strncmp($page, 'lscache-', 8) != 0) {
383
+ // either I messed up writing the slug, or someone entered this function elsewhere.
384
+ die();
385
+ }
386
+ $selection = substr($page, 8);
387
+ $selection_len = strlen($selection);
388
+ add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1);
389
+
390
+ //install, faqs
391
+ switch ($selection[0]) {
392
+ case 'd':
393
+ if (($selection_len == 4)
394
+ && (strncmp($selection, 'dash', $selection_len) == 0)
395
+ ) {
396
+ $this->show_menu_manage();
397
+ }
398
+ break;
399
+ case 'i':
400
+ if (($selection_len == 4)
401
+ && (strncmp($selection, 'info', $selection_len) == 0)
402
+ ) {
403
+ $this->show_menu_info();
404
+ }
405
+ break;
406
+ case 's':
407
+ if (($selection_len == 8)
408
+ && (strncmp($selection, 'settings', $selection_len) == 0)
409
+ ) {
410
+ if (is_network_admin()) {
411
+ $this->show_menu_network_settings();
412
+ }
413
+ else {
414
+ settings_errors();
415
+ $this->show_menu_settings();
416
+ }
417
+ }
418
+ break;
419
+ case 'e':
420
+ if (($selection_len == 13)
421
+ && (strncmp($selection, 'edit-htaccess', $selection_len) == 0)
422
+ ) {
423
+ $this->show_menu_edit_htaccess();
424
+ }
425
+ break;
426
+ case 'r':
427
+ if (($selection_len == 6)
428
+ && (strncmp($selection, 'report', $selection_len) == 0)
429
+ ) {
430
+ $this->show_menu_report();
431
+ }
432
+ break;
433
+ default:
434
+ break;
435
+ }
436
+ }
437
+
438
+ /**
439
+ * Displays the cache management page.
440
+ *
441
+ * @since 1.0.0
442
+ * @access public
443
+ */
444
+ public function show_menu_manage()
445
+ {
446
+ $config = LiteSpeed_Cache::config();
447
+ $intro_sentences =
448
+ __('From this screen, one can inform the server to purge the selected cached pages or empty the entire cache.', 'litespeed-cache');
449
+ $purgeall_confirm_para = self::build_paragraph(
450
+ __('This will purge everything for all blogs.', 'litespeed-cache'),
451
+ __('Are you sure you want to purge all?', 'litespeed-cache')
452
+ );
453
+ $purgeby_desc_para = self::build_paragraph(
454
+ __('Select dropdown below for "Purge by" options.', 'litespeed-cache'),
455
+ __('Please enter one per line.', 'litespeed-cache')
456
+ );
457
+ $clearcache_confirm_para = self::build_paragraph(
458
+ __('This will clear EVERYTHING inside the cache.', 'litespeed-cache'),
459
+ __('This may cause heavy load on the server.', 'litespeed-cache'),
460
+ __('If only the WordPress site should be purged, use purge all.', 'litespeed-cache')
461
+ );
462
+ $clearcache_desc_para = self::build_paragraph(
463
+ wp_kses(__('Clears all cache entries related to this site, <i>including other web applications</i>.', 'litespeed-cache'),
464
+ array('i' => array())),
465
+ wp_kses(__('<b>This action should only be used if things are cached incorrectly.</b>', 'litespeed-cache'),
466
+ array('b' => array()))
467
+ );
468
+
469
+ $purgeby_cat_desc =
470
+ sprintf(__('Purge pages by category name - e.g. %2$s should be used for the URL %1$s.', "litespeed-cache"),
471
+ 'http://example.com/category/category-name/', 'category-name');
472
+
473
+ $purgeby_url_desc = self::build_paragraph(
474
+ __('Purge pages by relative URL.', 'litespeed-cache'),
475
+ __('Must be exact match.', 'litespeed-cache'),
476
+ sprintf(__('e.g. Use %s for %s.', 'litespeed-cache'),
477
+ '<b><u>/2016/02/24/hello-world/</u></b>',
478
+ 'http://www.myexamplesite.com<b><u>/2016/02/24/hello-world/</u></b>'
479
+ ));
480
+
481
+ $purgeby_tag_desc =
482
+ sprintf(__('Purge pages by tag name - e.g. %2$s should be used for the URL %1$s.', "litespeed-cache"),
483
+ 'http://example.com/tag/tag-name/', 'tag-name');
484
+
485
+ if (($error_msg = $this->check_license($config)) !== true) {
486
+ echo '<div class="error"><p>' . $error_msg . '</p></div>' . "\n";
487
+ }
488
+
489
+ $purgeby_options = array(
490
+ __('Category', 'litespeed-cache'),
491
+ __('Post ID', 'litespeed-cache'),
492
+ __('Tag', 'litespeed-cache'),
493
+ __('URL', 'litespeed-cache'),
494
+ );
495
+
496
+ // Page intro
497
+ $buf = '<div class="wrap"><h2>'
498
+ . __('LiteSpeed Cache Management', 'litespeed-cache') . '</h2>'
499
+ . '<div class="litespeed-cache-welcome-panel"><p>'
500
+ . $intro_sentences . '</p>';
501
+
502
+ // Begin form
503
+ $buf .= '<form method="post">'
504
+ . '<input type="hidden" name="lscwp_management" value="manage_lscwp" />'
505
+ . wp_nonce_field('lscwp_manage', 'management_run');
506
+
507
+ $purge_front = get_submit_button(
508
+ __('Purge Front Page', 'litespeed-cache'), 'primary', 'purgefront', false);
509
+
510
+ $purge_pages = get_submit_button(
511
+ __('Purge Pages', 'litespeed-cache'), 'primary', 'purgepages', false);
512
+
513
+ $atts = array();
514
+ $atts['id'] = 'litespeedcache-purgeall';
515
+
516
+ $purge_all = get_submit_button(
517
+ __('Purge All', 'litespeed-cache'), 'primary', 'purgeall', false,
518
+ $atts);
519
+
520
+ $atts['id'] = 'litespeedcache-purgeerrors';
521
+
522
+ $purge_errors = get_submit_button(
523
+ __('Purge Error Pages', 'litespeed-cache'), 'primary',
524
+ 'purgeerrors', false, $atts);
525
+
526
+ $incl_403 = $this->input_field_checkbox('include_403', true, true,
527
+ __('Include 403', 'litespeed-cache'));
528
+
529
+ $incl_404 = $this->input_field_checkbox('include_404', true, false,
530
+ __('Include 404', 'litespeed-cache'));
531
+
532
+ $incl_500 = $this->input_field_checkbox('include_500', true, true,
533
+ __('Include 500s', 'litespeed-cache'));
534
+
535
+ // Form entries purge front, purge all
536
+ $buf .= '<div class="litespeed-cache-div-table>">';
537
+ $buf .= '<table class="form-table"><tbody>'
538
+ . '<tr><th>'
539
+ . __('Purge the Front Page.', 'litespeed-cache')
540
+ . '</th><td>'
541
+ . self::build_tip(
542
+ __('This will Purge Front Page only', 'litespeed-cache'))
543
+ . $purge_front
544
+ . '</td></tr>'
545
+ . '<tr><th>'
546
+ . __('Purge Pages.', 'litespeed-cache')
547
+ . '</th><td>'
548
+ . self::build_tip(
549
+ __('This will Purge Pages only', 'litespeed-cache'))
550
+ . $purge_pages
551
+ . '</td></tr>'
552
+ . '<tr><th>'
553
+ . __('Purge all WordPress pages.', 'litespeed-cache')
554
+ . '</th><td>'
555
+ . self::build_tip(
556
+ __('Purge the cache entries created by this plugin.', 'litespeed-cache'))
557
+ . $purge_all
558
+ . '</td></tr>'
559
+ . '<tr><th>'
560
+ . __('Purge the error pages.', 'litespeed-cache')
561
+ . '</th><td>'
562
+ . self::build_tip(
563
+ __('Purges the error page cache entries created by this plugin.', 'litespeed-cache'))
564
+ . $incl_403 . '&nbsp;&nbsp;' . $incl_404 . '&nbsp;&nbsp;' . $incl_500 . '<br>'
565
+ . $purge_errors . '&nbsp;'
566
+ . '</td></tr>';
567
+
568
+ if ((!is_multisite()) || (is_network_admin())) {
569
+ $buf .=
570
+ '<tr><th>'
571
+ . __('Clear all cache entries.', 'litespeed-cache')
572
+ . '</th><td>'
573
+ . self::build_tip(__($clearcache_desc_para, 'litespeed-cache'))
574
+ . '<input type="submit" class="litespeedcache-button-danger" name="clearcache"'
575
+ . 'id="litespeedcache-clearcache" value="'
576
+ . __('Empty Entire Cache', 'litespeed-cache')
577
+ . '" />'
578
+ . $this->input_field_hidden('litespeedcache-clearcache-confirm',
579
+ $clearcache_confirm_para)
580
+ . '</td></tr>';
581
+ }
582
+
583
+ if ((is_multisite()) && (is_network_admin())) {
584
+ echo $buf
585
+ . $this->input_field_hidden('litespeedcache-purgeall-confirm',
586
+ $purgeall_confirm_para)
587
+ . "<br><br></tbody></table></form></div></div>\n";
588
+
589
+ return;
590
+ }
591
+ $buf .= '</tbody></table></div>';
592
+
593
+ $buf .= $this->input_field_hidden('litespeedcache-purgeall-confirm',
594
+ __('Are you sure you want to purge all?', 'litespeed-cache'));
595
+
596
+
597
+ // Purge by description.
598
+ $buf .= '<h3>' . __('Purge By...', 'litespeed-cache') . '</h3>';
599
+ $buf .= '<hr/>' . '<p>' . $purgeby_desc_para . '</p>';
600
+
601
+
602
+ if (($_POST) && (isset($_POST[LiteSpeed_Cache_Config::OPTION_NAME]))) {
603
+ $selected = $_POST[LiteSpeed_Cache_Config::OPTION_NAME][self::PURGEBYOPT_SELECT];
604
+ if ((intval($selected) < 0) || (intval($selected) > 3)) {
605
+ $selected = 0;
606
+ }
607
+ }
608
+ else {
609
+ $selected = 0;
610
+ }
611
+
612
+ $buf .= $this->input_field_select(self::PURGEBYOPT_SELECT,
613
+ $purgeby_options, $selected)
614
+ . '&nbsp;&nbsp;<span class="litespeed-cache-purgeby-text" style="font-size: 11px;font-style: italic; "></span>'
615
+ . $this->input_field_hidden('purgeby-category', $purgeby_cat_desc)
616
+ . $this->input_field_hidden('purgeby-postid',
617
+ __("Purge pages by post ID.", "litespeed-cache"))
618
+ . $this->input_field_hidden('purgeby-tag', $purgeby_tag_desc)
619
+ . $this->input_field_hidden('purgeby-url', $purgeby_url_desc)
620
+ . '<br>'
621
+ . $this->input_field_textarea(self::PURGEBYOPT_LIST, '', '5', '', 'code')
622
+ . '<input type="submit" class="button button-primary" '
623
+ . 'name="purgelist" value="' . __('Purge List', 'litespeed-cache')
624
+ . '" />';
625
+
626
+ // End form
627
+ $buf .= "<br><br></form></div></div>";
628
+
629
+ echo $buf;
630
+ }
631
+
632
+ /**
633
+ * Outputs the LiteSpeed Cache settings page.
634
+ *
635
+ * @since 1.0.0
636
+ * @access public
637
+ */
638
+ public function show_menu_settings()
639
+ {
640
+ $config = LiteSpeed_Cache::config();
641
+
642
+ if (($error_msg = $this->check_license($config)) !== true) {
643
+ echo '<div class="error"><p>' . $error_msg . '</p></div>' . "\n";
644
+
645
+ }
646
+
647
+ $options = $config->get_options();
648
+
649
+ /**
650
+ * This hook allows third party plugins to create litespeed cache
651
+ * specific configurations.
652
+ *
653
+ * Each config should append an array containing the following:
654
+ * 'title' (required) - The tab's title.
655
+ * 'slug' (required) - The slug used for the tab. [a-z][A-Z], [0-9], -, _ permitted.
656
+ * 'content' (required) - The tab's content.
657
+ *
658
+ * Upon saving, only the options with the option group in the input's
659
+ * name will be retrieved.
660
+ * For example, name="litespeed-cache-conf[my-opt]".
661
+ *
662
+ * @see TODO: add option save filter.
663
+ * @since 1.0.9
664
+ * @param array $tabs An array of third party configurations.
665
+ * @param array $options The current configuration options.
666
+ * @param string $option_group The option group to use for options.
667
+ * @param boolean $disableall Whether to disable the settings or not.
668
+ * @return mixed An array of third party configs else false on failure.
669
+ */
670
+ $tp_tabs = apply_filters('litespeed_cache_add_config_tab', array(),
671
+ $options, LiteSpeed_Cache_Config::OPTION_NAME,
672
+ $this->get_disable_all());
673
+
674
+ echo '<div class="wrap"><h2>'
675
+ . __('LiteSpeed Cache Settings', 'litespeed-cache')
676
+ . '<span style="font-size:0.5em"> v'
677
+ . LiteSpeed_Cache::PLUGIN_VERSION
678
+ . '</span></h2><form method="post" action="options.php" id="ls_form_options">';
679
+ if ($this->get_disable_all()) {
680
+ $desc = self::build_paragraph(
681
+ __('The network admin selected use primary site configs for all subsites.', 'litespeed-cache'),
682
+ __('The following options are selected, but are not editable in this settings page.', 'litespeed-cache')
683
+ );
684
+ echo '<p>' . $desc . '</p>';
685
+ }
686
+
687
+ $lscwp_active_tab = 0;
688
+ $tab_count = 5;
689
+ if (!empty($tp_tabs)) {
690
+ $tab_count += count($tp_tabs);
691
+ }
692
+
693
+ settings_fields(LiteSpeed_Cache_Config::OPTION_NAME);
694
+
695
+ $compatibilities_tab = '';
696
+ $compatibilities_settings = '';
697
+ $compatibilities_buf = $this->show_settings_compatibilities();
698
+ if (!empty($compatibilities_buf)) {
699
+ $compatibilities_tab .= '<li><a href="#wp-compatibilities-settings">'
700
+ . __('Plugin Compatibilities', 'litespeed-cache') . '</a></li>';
701
+ $compatibilities_settings .= '<div id ="wp-compatibilities-settings">'
702
+ . $compatibilities_buf .
703
+ '</div>';
704
+ ++$tab_count;
705
+ }
706
+
707
+ $advanced_tab = '';
708
+ $advanced_settings = '';
709
+ if (!is_multisite()) {
710
+ $advanced_tab = '<li><a href="#advanced-settings">'
711
+ . __('Advanced Settings', 'litespeed-cache') . '</a></li>';
712
+ $advanced_settings = '<div id="advanced-settings">'
713
+ . $this->show_settings_advanced($options)
714
+ . '</div>';
715
+ ++$tab_count;
716
+ }
717
+
718
+ if (isset($_REQUEST['tab'])) {
719
+ $lscwp_active_tab = intval($_REQUEST['tab']);
720
+ if (($lscwp_active_tab < 0) || ($lscwp_active_tab >= $tab_count)) {
721
+ $lscwp_active_tab = 0;
722
+ }
723
+ }
724
+
725
+ echo '<input type="hidden" name="active_tab" id="active_tab" value="'
726
+ . $lscwp_active_tab . '" />
727
+ <div id="lsc-tabs">
728
+ <ul>
729
+ <li><a href="#general-settings">' . __('General', 'litespeed-cache') . '</a></li>
730
+ <li><a href="#specific-settings">' . __('Specific Pages', 'litespeed-cache') . '</a></li>
731
+ <li><a href="#purge-settings">' . __('Purge Rules', 'litespeed-cache') . '</a></li>
732
+ <li><a href="#exclude-settings">' . __('Do Not Cache Rules', 'litespeed-cache') . '</a></li>
733
+ ' . $advanced_tab . '
734
+ <li><a href="#debug-settings">' . __('Debug', 'litespeed-cache') . '</a></li>'
735
+ . $compatibilities_tab;
736
+
737
+ if ((!empty($tp_tabs)) && (is_array($tp_tabs))) {
738
+ foreach ($tp_tabs as $key => $tab) {
739
+ if ((!is_array($tab))
740
+ || (!isset($tab['title']))
741
+ || (!isset($tab['slug']))
742
+ || (!isset($tab['content']))
743
+ ) {
744
+ if (defined('LSCWP_LOG')) {
745
+ LiteSpeed_Cache::debug_log(
746
+ __('WARNING: Third party tab input invalid.',
747
+ 'litespeed-cache'));
748
+ }
749
+ unset($tp_tabs[$key]);
750
+ continue;
751
+ }
752
+ elseif (preg_match('/[^-\w]/', $tab['slug'])) {
753
+ if (defined('LSCWP_LOG')) {
754
+ LiteSpeed_Cache::debug_log(
755
+ __('WARNING: Third party config slug contains invalid characters.',
756
+ 'litespeed-cache'));
757
+ }
758
+ unset($tp_tabs[$key]);
759
+ continue;
760
+ }
761
+ echo '
762
+ <li><a href="#' . $tab['slug'] . '-settings">'
763
+ . $tab['title'] . '</a></li>';
764
+ }
765
+ }
766
+ else {
767
+ $tp_tabs = false;
768
+ }
769
+
770
+ echo '
771
+ </ul>
772
+ <div id="general-settings">'
773
+ . $this->show_settings_general($options) .
774
+ '</div>
775
+ <div id="specific-settings">'
776
+ . $this->show_settings_specific($options) .
777
+ '</div>
778
+ <div id="purge-settings">'
779
+ . $this->show_settings_purge($config->get_purge_options()) .
780
+ '</div>
781
+ <div id="exclude-settings">'
782
+ . $this->show_settings_excludes($options) .
783
+ '</div>'
784
+ . $advanced_settings .
785
+ '<div id ="debug-settings">'
786
+ . $this->show_settings_test($options) .
787
+ '</div>'
788
+ . $compatibilities_settings;
789
+
790
+ if (!empty($tp_tabs)) {
791
+ foreach ($tp_tabs as $tab) {
792
+ echo '
793
+ <div id ="' . $tab['slug'] . '-settings">'
794
+ . $tab['content'] . '</div>';
795
+ }
796
+ }
797
+
798
+ echo '</div>';
799
+
800
+ if ($this->get_disable_all()) {
801
+ submit_button(__('Save Changes', 'litespeed-cache'),
802
+ 'primary', 'submit', true, array('disabled' => true));
803
+ }
804
+ else {
805
+ submit_button();
806
+ }
807
+ echo "</form></div>\n";
808
+ }
809
+
810
+ /**
811
+ * Display the network admin settings page.
812
+ *
813
+ * Since multisite setups only have one .htaccess file, these settings
814
+ * are only available for the network admin in multisite setups.
815
+ *
816
+ * @since 1.0.4
817
+ * @access private
818
+ */
819
+ private function show_menu_network_settings()
820
+ {
821
+ $network_desc =
822
+ __('These configurations are only available network wide.', 'litespeed-cache')
823
+ . '<br>'
824
+ . self::build_paragraph(
825
+ __('Separate Mobile Views should be enabled if any of the network enabled themes require a different view for mobile devices.', 'litespeed-cache'),
826
+ __('Responsive themes can handle this part automatically.', 'litespeed-cache'));
827
+ $enable_desc =
828
+ __('Enabling LiteSpeed Cache for WordPress here enables the cache for the network.', 'litespeed-cache')
829
+ . '<br>'
830
+ . wp_kses(__('It is <b>STRONGLY</b> recommend that the compatibility with other plugins on a single/few sites is tested first.', 'litespeed-cache'),
831
+ array('b' => array()))
832
+ . __('This is to ensure compatibility prior to enabling the cache for all sites.', 'litespeed-cache');
833
+
834
+
835
+ if (isset($_REQUEST['tab'])) {
836
+ $lscwp_active_tab = intval($_REQUEST['tab']);
837
+ if (($lscwp_active_tab < 0) || ($lscwp_active_tab >= 3)) {
838
+ $lscwp_active_tab = 0;
839
+ }
840
+ }
841
+
842
+ $buf = '<div class="wrap"><h2>' . __('LiteSpeed Cache Settings', 'litespeed-cache') . '</h2>';
843
+
844
+ $config = LiteSpeed_Cache::config();
845
+
846
+ $buf .= '<form method="post" action="admin.php?page=lscache-settings">'
847
+ . '<input type="hidden" name="lscwp_settings_save" value="save_settings" />'
848
+ . wp_nonce_field('lscwp_settings', 'save');
849
+
850
+ $buf .= '<input type="hidden" name="active_tab" id="active_tab" value="'
851
+ . $lscwp_active_tab . '" />';
852
+
853
+ $buf .= '<div id="lsc-tabs">'
854
+ . '<ul>'
855
+ . '<li><a href="#general">' . __('General', 'litespeed-cache') . '</a></li>'
856
+ . '<li><a href="#exclude">' . __('Do Not Cache Rules', 'litespeed-cache') . '</a></li>'
857
+ . '<li><a href="#advanced">' . __('Advanced', 'litespeed-cache') . '</a></li>'
858
+ . '</ul>';
859
+
860
+ $buf .= '<div id="general">'
861
+ . $this->input_group_start(__('General Network Configurations',
862
+ 'litespeed-cache'), $network_desc);
863
+ $id = LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED;
864
+
865
+ $site_options = $config->get_site_options();
866
+
867
+ $network_enable = $this->input_field_checkbox('lscwp_' . $id, $id,
868
+ $site_options[$id]);
869
+ $buf .= $this->display_config_row(
870
+ __('Network Enable Cache', 'litespeed-cache'), $network_enable, '',
871
+ '', $enable_desc);
872
+
873
+ $id = LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY;
874
+ $use_primary = $this->input_field_checkbox('lscwp_' . $id, $id,
875
+ $site_options[$id]);
876
+
877
+ $use_primary_desc = self::build_paragraph(
878
+ __("Check this option to use the primary site's configurations for all subsites.",
879
+ 'litespeed-cache'),
880
+ __('This will disable the settings page on all subsites.', 'litespeed-cache')
881
+ );
882
+
883
+ $buf .= $this->display_config_row(
884
+ __('Use Primary Site Configurations', 'litespeed-cache'),
885
+ $use_primary,
886
+ '',
887
+ '',
888
+ $use_primary_desc
889
+ );
890
+
891
+ $buf .= $this->build_setting_purge_on_upgrade($site_options);
892
+ $buf .= $this->build_setting_cache_favicon($site_options);
893
+ $buf .= $this->build_setting_cache_resources($site_options);
894
+ $buf .= $this->build_setting_mobile_view($site_options);
895
+ $buf .= $this->input_group_end() . '</div>';
896
+
897
+ $buf .= '<div id="exclude">'
898
+ . $this->input_group_start(__('Network Do Not Cache Rules', 'litespeed-cache'));
899
+ $ua_title = '';
900
+ $ua_desc = '';
901
+ $ua_buf = $this->build_setting_exclude_useragent($site_options, $ua_title, $ua_desc);
902
+ $buf .= $this->display_config_row(
903
+ __('Do Not Cache User Agents', 'litespeed-cache'),
904
+ $ua_buf,
905
+ $ua_desc
906
+ );
907
+
908
+ $cookie_title = '';
909
+ $cookie_desc = '';
910
+ $cookie_buf = $this->build_setting_exclude_cookies($site_options, $cookie_title, $cookie_desc);
911
+ $buf .= $this->display_config_row(
912
+ __('Do Not Cache Cookies', 'litespeed-cache'),
913
+ $cookie_buf,
914
+ $cookie_desc
915
+ );
916
+
917
+ $buf .= $this->input_group_end() . '</div>';
918
+
919
+ $buf .= '<div id="advanced">'
920
+ . $this->show_settings_advanced($site_options) . '</div></div>';
921
+
922
+ $buf .= '<br><br>'
923
+ . '<input type="submit" class="button button-primary" name="submit" value="'
924
+ . __('Save', 'litespeed-cache') . '" /></td></tr>';
925
+ $buf .= '</form><br><br></div>';
926
+ echo $buf;
927
+ }
928
+
929
+ /**
930
+ * Displays the edit_htaccess admin page.
931
+ *
932
+ * This function will try to load the .htaccess file contents.
933
+ * If it fails, it will echo the error message.
934
+ *
935
+ * @since 1.0.4
936
+ * @access private
937
+ */
938
+ private function show_menu_edit_htaccess()
939
+ {
940
+ $warning_para = self::build_paragraph(
941
+ __('Any changes made to the .htaccess file may break the site.', 'litespeed-cache'),
942
+ __('Please consult the host/server admin before making any changes.', 'litespeed-cache')
943
+ );
944
+ $buf = '<div class="wrap"><h2>' . __('LiteSpeed Cache Edit .htaccess', 'litespeed-cache') . '</h2>';
945
+ $buf .= '<div class="litespeed-cache-welcome-panel">';
946
+ $contents = '';
947
+ $rules = LiteSpeed_Cache_Admin_Rules::get_instance();
948
+ if (defined('DISALLOW_FILE_EDIT') && (constant('DISALLOW_FILE_EDIT'))) {
949
+ $buf .= '<h3>'
950
+ . __('File editing is disabled in configuration.', 'litespeed-cache')
951
+ . '</h3></div>';
952
+ echo $buf;
953
+
954
+ return;
955
+ }
956
+ elseif (LiteSpeed_Cache_Admin_Rules::file_get($contents) === false) {
957
+ $buf .= '<h3>' . $contents . '</h3></div>';
958
+ echo $buf;
959
+
960
+ return;
961
+ }
962
+ $file_writable = $rules->is_file_able(
963
+ LiteSpeed_Cache_Admin_Rules::WRITABLE);
964
+
965
+ $buf .= '<p><span class="attention">'
966
+ . __('WARNING: This page is meant for advanced users.', 'litespeed-cache')
967
+ . '</span><br>' . $warning_para . '</p>';
968
+
969
+ $buf .= $this->show_info_common_rewrite();
970
+
971
+ $buf .= '<form method="post" action="admin.php?page=lscache-edit-htaccess">';
972
+ $buf .= '<input type="hidden" name="'
973
+ . LiteSpeed_Cache_Admin_Rules::EDITOR_INPUT_NAME . '" value="'
974
+ . LiteSpeed_Cache_Admin_Rules::EDITOR_INPUT_VAL . '" />';
975
+ $buf .= wp_nonce_field(LiteSpeed_Cache_Admin_Rules::EDITOR_NONCE_NAME,
976
+ LiteSpeed_Cache_Admin_Rules::EDITOR_NONCE_VAL);
977
+
978
+ $buf .= '<h3>' . sprintf(__('Current %s contents:', 'litespeed-cache'), '.htaccess') . '</h3>';
979
+
980
+ $buf .= '<p><span class="attention">'
981
+ . sprintf(__('DO NOT EDIT ANYTHING WITHIN %s', 'litespeed-cache'),
982
+ '###LSCACHE START/END XXXXXX###')
983
+ . '</span><br>'
984
+ . __('These are added by the LS Cache plugin and may cause problems if they are changed.', 'litespeed-cache')
985
+ . '</p>';
986
+
987
+ $buf .= '<textarea id="wpwrap" name="'
988
+ . LiteSpeed_Cache_Admin_Rules::EDITOR_TEXTAREA_NAME
989
+ . '" wrap="off" rows="20" class="code" ';
990
+ if (!$file_writable) {
991
+ $buf .= 'readonly';
992
+ }
993
+ $buf .= '>' . esc_textarea($contents) . '</textarea>';
994
+ unset($contents);
995
+
996
+ $buf .= '<input type="submit" class="button button-primary" name="submit" value="'
997
+ . __('Save', 'litespeed-cache') . '" /></form><br><br>';
998
+
999
+ $buf .= '</div></div>';
1000
+ echo $buf;
1001
+ }
1002
+
1003
+ /**
1004
+ * Outputs the html for the info page.
1005
+ *
1006
+ * This page includes three tabs:
1007
+ * - configurations
1008
+ * - third party plugin compatibilities
1009
+ * - common rewrite rules.
1010
+ *
1011
+ * @since 1.0.4
1012
+ * @access private
1013
+ */
1014
+ private function show_menu_info()
1015
+ {
1016
+ $trial_para = self::build_paragraph(
1017
+ __('Make sure that the server license has the LSCache module enabled.', 'litespeed-cache'),
1018
+ sprintf(wp_kses(
1019
+ __('A <a href="%1$s" rel="%2$s" target="%3$s">2-CPU trial license with LSCache module</a> is available for free for %4$d days.',
1020
+ 'litespeed-cache'),
1021
+ array(
1022
+ 'a' => array(
1023
+ 'href' => array(), 'rel' => array(),
1024
+ 'target' => array(),
1025
+ ),
1026
+ )),
1027
+ 'https://www.litespeedtech.com/products/litespeed-web-server/download/get-a-trial-license',
1028
+ 'noopener noreferrer', '_blank', 15)
1029
+ );
1030
+
1031
+ $caching_para = self::build_paragraph(
1032
+ __('The server must be configured to have caching enabled.', 'litespeed-cache'),
1033
+ sprintf(wp_kses(
1034
+ __('If you are the server admin, <a href="%s" rel="%s" target="%s">click here.</a>',
1035
+ 'litespeed-cache'),
1036
+ array(
1037
+ 'a' => array(
1038
+ 'href' => array(), 'rel' => array(),
1039
+ 'target' => array(),
1040
+ ),
1041
+ )),
1042
+ 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:common_installation#web_server_configuration',
1043
+ 'noopener noreferrer', '_blank'),
1044
+ __('Otherwise request that the server admin configure the cache root for the server.', 'litespeed-cache')
1045
+ );
1046
+
1047
+ $ols_para =
1048
+ self::build_list(
1049
+ array(
1050
+ __('This integration utilizes OLS\'s cache module.', 'litespeed-cache'),
1051
+ self::build_paragraph(
1052
+ sprintf(wp_kses(
1053
+ __('If it is a fresh OLS installation, the easiest way to integrate is to use <a href="%s" rel="%s" target="%s">ols1clk.</a>',
1054
+ 'litespeed-cache'),
1055
+ array(
1056
+ 'a' => array(
1057
+ 'href' => array(), 'rel' => array(),
1058
+ 'target' => array(),
1059
+ ),
1060
+ )),
1061
+ 'http://open.litespeedtech.com/mediawiki/index.php/Help:1-Click_Install',
1062
+ 'noopener noreferrer', '_blank'),
1063
+ sprintf(__('If using an existing WordPress installation, use the %s parameter.', 'litespeed-cache'),
1064
+ '--wordpresspath')
1065
+ ),
1066
+ sprintf(wp_kses(
1067
+ __('Else if OLS and WordPress are already installed, please follow the instructions <a href="%s" rel="%s" target="%s">here.</a>',
1068
+ 'litespeed-cache'),
1069
+ array(
1070
+ 'a' => array(
1071
+ 'href' => array(), 'rel' => array(),
1072
+ 'target' => array(),
1073
+ ),
1074
+ )),
1075
+ 'http://open.litespeedtech.com/mediawiki/index.php/Help:How_To_Set_Up_LSCache_For_WordPress',
1076
+ 'noopener noreferrer', '_blank'
1077
+ )
1078
+ )
1079
+ );
1080
+
1081
+ $test_para = self::build_paragraph(
1082
+ sprintf(__('Subsequent requests should have the %s response header until the page is updated, expired, or purged.',
1083
+ 'litespeed-cache'), '<code>X-LiteSpeed-Cache-Control:hit</code><br>'),
1084
+ sprintf(wp_kses(
1085
+ __('Please visit <a href="%s" rel="%s" target="%s">this page</a> for more information.',
1086
+ 'litespeed-cache'),
1087
+ array(
1088
+ 'a' => array(
1089
+ 'href' => array(), 'rel' => array(),
1090
+ 'target' => array(),
1091
+ ),
1092
+ )),
1093
+ 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:installation#testing',
1094
+ 'noopener noreferrer', '_blank')
1095
+ );
1096
+
1097
+ // Configurations help.
1098
+ $buf = '<div class="wrap"><h2>'
1099
+ . __('LiteSpeed Cache Information', 'litespeed-cache') . '</h2>';
1100
+
1101
+ $buf .= '<div id="lsc-tabs">'
1102
+ . '<ul>'
1103
+ . '<li><a href="#faq">' . __('FAQs', 'litespeed-cache') . '</a></li>'
1104
+ . '<li><a href="#config">' . __('Configurations', 'litespeed-cache') . '</a></li>'
1105
+ . '<li><a href="#compat">' . __('Plugin Compatibilities', 'litespeed-cache') . '</a></li>'
1106
+ . '<li><a href="#commonrw">' . __('Common Rewrite Rules', 'litespeed-cache') . '</a></li>'
1107
+ . '<li><a href="#adminip">' . __('Admin IP Commands', 'litespeed-cache') . '</a></li>'
1108
+ . '</ul>';
1109
+
1110
+ // FAQs.
1111
+ $buf .= '<div id="faq">';
1112
+ $buf .= $this->show_info_faqs();
1113
+ $buf .= '</div>'; // id=faq
1114
+
1115
+ $buf .= '<div id="config"><h3>'
1116
+ . __('LiteSpeed Cache Configurations', 'litespeed-cache') . '</h3>'
1117
+ . '<h4>' . __('Instructions for LiteSpeed Web Server Enterprise', 'litespeed-cache') . '</h4>';
1118
+
1119
+ $buf .=
1120
+ self::build_list(
1121
+ array(
1122
+ $trial_para,
1123
+ $caching_para,
1124
+ __('In the .htaccess file for the WordPress installation, add the following:',
1125
+ 'litespeed-cache')
1126
+ . '<textarea id="wpwrap" rows="3" readonly>&lt;IfModule LiteSpeed&gt;
1127
+ CacheLookup public on
1128
+ &lt;/IfModule&gt;</textarea>'
1129
+ )
1130
+ );
1131
+
1132
+ $buf .= '<h4>' . __('Instructions for OpenLiteSpeed', 'litespeed-cache') . '</h4>';
1133
+ $buf .= '<p>' . $ols_para . '</p>';
1134
+
1135
+ $buf .= '<h3>' . __('How to test the plugin', 'litespeed-cache') . '</h3>';
1136
+ $buf .= '<p>' . __('The LiteSpeed Cache Plugin utilizes LiteSpeed specific response headers.', 'litespeed-cache')
1137
+ . '<br>'
1138
+ . sprintf(__('Visiting a page for the first time should result in a %s or %s response header for the page.',
1139
+ 'litespeed-cache'), '<br><code>X-LiteSpeed-Cache-Control:miss</code><br>',
1140
+ '<br><code>X-LiteSpeed-Cache-Control:no-cache</code><br>')
1141
+ . '<br>'
1142
+ . $test_para
1143
+ . '</p>';
1144
+
1145
+ $buf .= '</div>'; // id=config
1146
+
1147
+ // Compatibility with other plugins.
1148
+ $buf .= '<div id="compat">';
1149
+ $buf .= $this->show_info_compatibility();
1150
+ $buf .= '</div>'; // id=compat
1151
+
1152
+ $buf .= '<div id="commonrw">';
1153
+ $buf .= $this->show_info_common_rewrite();
1154
+ $buf .= '</div>'; // id=commonrw
1155
+
1156
+ $buf .= '<div id="adminip">';
1157
+ $buf .= $this->show_info_admin_ip();
1158
+ $buf .= '</div>'; // id=adminip
1159
+
1160
+ $buf .= '</div></div>'; // id=lsc_tabs and class=wrap
1161
+ echo $buf;
1162
+ }
1163
+
1164
+ /**
1165
+ * Outputs the html for the Environment Report page.
1166
+ *
1167
+ * @since 1.0.12
1168
+ * @access private
1169
+ */
1170
+ private function show_menu_report()
1171
+ {
1172
+ $report = LiteSpeed_Cache::generate_environment_report();
1173
+ $desc =
1174
+ self::build_list(
1175
+ array(
1176
+ __('The environment report contains detailed information about the WordPress configuration.', 'litespeed-cache'),
1177
+ __('If you run into any issues, please include the contents of this text area in your support message.', 'litespeed-cache'),
1178
+ wp_kses(
1179
+ __('To easily grab the content, click the <b>Select All and Copy to Clipboard</b> button, to select and copy to clipboard.', 'litespeed-cache'),
1180
+ array('b' => array())),
1181
+ sprintf(__('Alternatively, this information is also saved in %s.', 'litespeed-cache'),
1182
+ 'wp-content/plugins/litespeed-cache/environment_report.php')
1183
+ )
1184
+ )
1185
+ . '<p><b>'
1186
+ . __('The text area below contains the following content:', 'litespeed-cache')
1187
+ . '</b><br><span style="font-size:11px; font-style:italic">'
1188
+ . __('Server Variables, Plugin Options, WordPress information (version, locale, active plugins, etc.), and .htaccess file content.', 'litespeed-cache')
1189
+ . '</span></p>';
1190
+
1191
+ $buf = '<div class="wrap"><h2>LiteSpeed Cache Report</h2>';
1192
+ $buf .= '<div class="litespeed-cache-welcome-panel">' . $desc;
1193
+ $buf .= $this->build_button('litespeed-cache-select-all-button',
1194
+ __("Select All and Copy to Clipboard", "litespeed-cache"),
1195
+ __("Environment Report copied to Clipboard!", "litespeed-cache"));
1196
+ $buf .= $this->input_field_textarea('litespeed-report', $report, '20',
1197
+ '80', '', true);
1198
+
1199
+ $buf .= '</div></div>';
1200
+
1201
+ echo $buf;
1202
+ }
1203
+
1204
+ /**
1205
+ * Builds the html for the general settings tab.
1206
+ *
1207
+ * @since 1.0.0
1208
+ * @access private
1209
+ * @param array $options The current configuration options.
1210
+ * @return string The html for the general tab.
1211
+ */
1212
+ private function show_settings_general($options)
1213
+ {
1214
+ $feed_ttl_desc = self::build_paragraph(
1215
+ __('Specify how long, in seconds, feeds are cached.', 'litespeed-cache'),
1216
+ __('If this is set to a number less than 30, feeds will not be cached.', 'litespeed-cache')
1217
+ );
1218
+ $notfound_ttl_desc = self::build_paragraph(
1219
+ __('Specify how long, in seconds, 404 pages are cached.', 'litespeed-cache'),
1220
+ __('If this is set to a number less than 30, 404 pages will not be cached.', 'litespeed-cache')
1221
+ );
1222
+ $forbidden_ttl_desc = self::build_paragraph(
1223
+ __('Specify how long, in seconds, 403 pages are cached.', 'litespeed-cache'),
1224
+ __('If this is set to a number less than 30, 403 pages will not be cached.', 'litespeed-cache')
1225
+ );
1226
+ $ise_ttl_desc = self::build_paragraph(
1227
+ __('Specify how long, in seconds, 500 pages are cached.', 'litespeed-cache'),
1228
+ __('If this is set to a number less than 30, 500 pages will not be cached.', 'litespeed-cache')
1229
+ );
1230
+ $cache_commenters_desc = self::build_paragraph(
1231
+ __('When checked, commenters will not be able to see their comments awaiting moderation.', 'litespeed-cache'),
1232
+ __('Disabling this option will display those types of comments, but the cache will not perform as well.', 'litespeed-cache')
1233
+ );
1234
+ $buf = $this->input_group_start(__('General', 'litespeed-cache'));
1235
+
1236
+ $id = LiteSpeed_Cache_Config::OPID_ENABLED_RADIO;
1237
+
1238
+ $enable_levels = array(
1239
+ LiteSpeed_Cache_Config::OPID_ENABLED_ENABLE => __('Enable', 'litespeed-cache'),
1240
+ LiteSpeed_Cache_Config::OPID_ENABLED_DISABLE => __('Disable', 'litespeed-cache'),
1241
+ );
1242
+
1243
+ //IF multisite: Add 'Use Network Admin' option,
1244
+ //ELSE: Change 'Enable LiteSpeed Cache' selection to 'Enabled' if the 'Use Network Admin' option was previously selected.
1245
+ // Selection will not actually be changed unless settings are saved.
1246
+ if (is_multisite()) {
1247
+ $enable_levels[LiteSpeed_Cache_Config::OPID_ENABLED_NOTSET] = __('Use Network Admin Setting', 'litespeed-cache');
1248
+ }
1249
+ elseif (intval($options[$id]) === 2) {
1250
+ $options[$id] = 1;
1251
+ }
1252
+
1253
+ $below_text = sprintf(wp_kses(
1254
+ __('Please visit the <a href="%sadmin.php?page=lscache-info">information</a> page on how to test the cache.',
1255
+ 'litespeed-cache'),
1256
+ array('a' => array('href' => array()))), get_admin_url());
1257
+
1258
+
1259
+ $input_enable = $this->input_field_radio($id, $enable_levels, intval($options[$id]), $below_text);
1260
+
1261
+ $enable_desc = '<strong>' . __('NOTICE', 'litespeed-cache') . ': </strong>'
1262
+ . __('When disabling the cache, all cached entries for this blog will be purged.', 'litespeed-cache');
1263
+
1264
+ if (is_multisite()) {
1265
+ $enable_desc .= '<br>'
1266
+ . __('The network admin setting can be overridden here.', 'litespeed-cache');
1267
+ }
1268
+
1269
+ $buf .= $this->display_config_row(
1270
+ __('Enable LiteSpeed Cache', 'litespeed-cache'),
1271
+ $input_enable, '', $enable_desc);
1272
+
1273
+ $id = LiteSpeed_Cache_Config::OPID_PUBLIC_TTL;
1274
+ $input_public_ttl = $this->input_field_text($id, $options[$id], 10, 'regular-text',
1275
+ __('seconds', 'litespeed-cache'));
1276
+
1277
+ $buf .= $this->display_config_row(
1278
+ __('Default Public Cache TTL', 'litespeed-cache'),
1279
+ $input_public_ttl,
1280
+ __('Specify how long, in seconds, public pages are cached. Minimum is 30 seconds.', 'litespeed-cache')
1281
+ );
1282
+
1283
+ $id = LiteSpeed_Cache_Config::OPID_FRONT_PAGE_TTL;
1284
+ $input_front_ttl = $this->input_field_text($id, $options[$id], 10, 'regular-text',
1285
+ __('seconds', 'litespeed-cache'));
1286
+ $buf .= $this->display_config_row(
1287
+ __('Default Front Page TTL', 'litespeed-cache'),
1288
+ $input_front_ttl,
1289
+ __('Specify how long, in seconds, the front page is cached. Minimum is 30 seconds.', 'litespeed-cache')
1290
+ );
1291
+
1292
+ $id = LiteSpeed_Cache_Config::OPID_FEED_TTL;
1293
+ $input_feed_ttl = $this->input_field_text($id, $options[$id], 10, 'regular-text',
1294
+ __('seconds', 'litespeed-cache'));
1295
+ $buf .= $this->display_config_row(
1296
+ __('Default Feed TTL', 'litespeed-cache'),
1297
+ $input_feed_ttl,
1298
+ $feed_ttl_desc
1299
+ );
1300
+
1301
+ $id = LiteSpeed_Cache_Config::OPID_404_TTL;
1302
+ $input_404_ttl = $this->input_field_text($id, $options[$id], 10, 'regular-text',
1303
+ __('seconds', 'litespeed-cache'));
1304
+ $buf .= $this->display_config_row(
1305
+ __('Default 404 Page TTL', 'litespeed-cache'),
1306
+ $input_404_ttl,
1307
+ $notfound_ttl_desc
1308
+ );
1309
+
1310
+ $id = LiteSpeed_Cache_Config::OPID_403_TTL;
1311
+ $input_403_ttl = $this->input_field_text($id, $options[$id], 10, 'regular-text',
1312
+ __('seconds', 'litespeed-cache'));
1313
+ $buf .= $this->display_config_row(
1314
+ __('Default 403 Page TTL', 'litespeed-cache'),
1315
+ $input_403_ttl,
1316
+ $forbidden_ttl_desc
1317
+ );
1318
+
1319
+ $id = LiteSpeed_Cache_Config::OPID_500_TTL;
1320
+ $input_500_ttl = $this->input_field_text($id, $options[$id], 10, 'regular-text',
1321
+ __('seconds', 'litespeed-cache'));
1322
+ $buf .= $this->display_config_row(
1323
+ __('Default 500 Page TTL', 'litespeed-cache'),
1324
+ $input_500_ttl,
1325
+ $ise_ttl_desc
1326
+ );
1327
+
1328
+ $id = LiteSpeed_Cache_Config::OPID_CACHE_COMMENTERS;
1329
+ $cache_commenters = $this->input_field_checkbox('lscwp_' . $id, $id, $options[$id]);
1330
+ $buf .= $this->display_config_row(
1331
+ __('Enable Cache for Commenters', 'litespeed-cache'),
1332
+ $cache_commenters,
1333
+ $cache_commenters_desc
1334
+ );
1335
+
1336
+ if (!is_multisite()) {
1337
+ $buf .= $this->build_setting_purge_on_upgrade($options);
1338
+ $buf .= $this->build_setting_mobile_view($options);
1339
+ }
1340
+
1341
+ $buf .= $this->input_group_end();
1342
+
1343
+ return $buf;
1344
+ }
1345
+
1346
+ /**
1347
+ * Builds the html for the specific pages settings tab.
1348
+ *
1349
+ * @since 1.0.10
1350
+ * @access private
1351
+ * @param array $options The current configuration options.
1352
+ * @return string The html for the specific pages tab.
1353
+ */
1354
+ private function show_settings_specific($options)
1355
+ {
1356
+ $buf = $this->input_group_start(__('Specific Pages', 'litespeed-cache'));
1357
+
1358
+ $id = LiteSpeed_Cache_Config::OPID_CACHE_LOGIN;
1359
+ $cache_login = $this->input_field_checkbox('lscwp_' . $id, $id, $options[$id]);
1360
+ $buf .= $this->display_config_row(
1361
+ __('Enable Cache for Login Page', 'litespeed-cache'),
1362
+ $cache_login,
1363
+ __('Unchecking this option may negatively affect performance.', 'litespeed-cache')
1364
+ );
1365
+
1366
+ if (!is_multisite()) {
1367
+ $buf .= $this->build_setting_cache_favicon($options);
1368
+ $buf .= $this->build_setting_cache_resources($options);
1369
+ }
1370
+
1371
+ $buf .= $this->input_group_end();
1372
+
1373
+ return $buf;
1374
+ }
1375
+
1376
+ /**
1377
+ * Builds the html for the purge settings tab.
1378
+ *
1379
+ * @since 1.0.0
1380
+ * @access private
1381
+ * @param array $purge_options The current configuration purge options.
1382
+ * @return string The html for the purge tab.
1383
+ */
1384
+ private function show_settings_purge($purge_options)
1385
+ {
1386
+ $select_all_desc =
1387
+ self::build_list(
1388
+ array(
1389
+ __('Select "All" if there are dynamic widgets linked to posts on pages other than the front or home pages.', 'litespeed-cache'),
1390
+ __('Other checkboxes will be ignored.', 'litespeed-cache'),
1391
+ __('Select only the archive types that are currently used, the others can be left unchecked.', 'litespeed-cache')
1392
+ ),
1393
+ false,
1394
+ 'top: -12px;position: relative;font-style:italic; font-size:11px;'
1395
+ );
1396
+
1397
+ $buf = $this->input_group_start(__('Auto Purge Rules For Publish/Update', 'litespeed-cache'),
1398
+ __('Select which pages will be automatically purged when posts are published/updated.', 'litespeed-cache')
1399
+ . '<br>'
1400
+ . '<b style="font-style:italic;">' . __('Note:', 'litespeed-cache') . '</b>' . $select_all_desc
1401
+ );
1402
+
1403
+ $tr = '<tr><th scope="row" colspan="2" class="th-full">';
1404
+ $endtr = "</th></tr>\n";
1405
+ $buf .= $tr;
1406
+
1407
+ $spacer = '&nbsp;&nbsp;&nbsp;';
1408
+
1409
+ $pval = LiteSpeed_Cache_Config::PURGE_ALL_PAGES;
1410
+ $buf .= $this->input_field_checkbox(
1411
+ 'purge_' . $pval, $pval, in_array($pval, $purge_options),
1412
+ __('All pages', 'litespeed-cache'));
1413
+
1414
+ $buf .= $spacer;
1415
+
1416
+ $pval = LiteSpeed_Cache_Config::PURGE_FRONT_PAGE;
1417
+ $buf .= $this->input_field_checkbox(
1418
+ 'purge_' . $pval, $pval, in_array($pval, $purge_options),
1419
+ __('Front page', 'litespeed-cache'));
1420
+
1421
+ $buf .= $spacer;
1422
+
1423
+ $pval = LiteSpeed_Cache_Config::PURGE_HOME_PAGE;
1424
+ $buf .= $this->input_field_checkbox(
1425
+ 'purge_' . $pval, $pval, in_array($pval, $purge_options),
1426
+ __('Home page', 'litespeed-cache'));
1427
+
1428
+ $buf .= $spacer;
1429
+ $pval = LiteSpeed_Cache_Config::PURGE_PAGES;
1430
+ $buf .= $this->input_field_checkbox(
1431
+ 'purge_' . $pval, $pval, in_array($pval, $purge_options),
1432
+ __('Pages', 'litespeed-cache'));
1433
+
1434
+ $buf .= $endtr . $tr;
1435
+
1436
+ $pval = LiteSpeed_Cache_Config::PURGE_PAGES_WITH_RECENT_POSTS;
1437
+ $buf .= $this->input_field_checkbox(
1438
+ 'purge_' . $pval, $pval, in_array($pval, $purge_options),
1439
+ __('All pages with Recent Posts Widget', 'litespeed-cache'));
1440
+
1441
+ $buf .= $endtr . $tr;
1442
+
1443
+ $pval = LiteSpeed_Cache_Config::PURGE_AUTHOR;
1444
+ $buf .= $this->input_field_checkbox(
1445
+ 'purge_' . $pval, $pval, in_array($pval, $purge_options),
1446
+ __('Author archive', 'litespeed-cache'));
1447
+
1448
+ $buf .= $spacer;
1449
+
1450
+ $pval = LiteSpeed_Cache_Config::PURGE_POST_TYPE;
1451
+ $buf .= $this->input_field_checkbox(
1452
+ 'purge_' . $pval, $pval, in_array($pval, $purge_options),
1453
+ __('Post type archive', 'litespeed-cache'));
1454
+
1455
+ $buf .= $endtr . $tr;
1456
+
1457
+ $pval = LiteSpeed_Cache_Config::PURGE_YEAR;
1458
+ $buf .= $this->input_field_checkbox(
1459
+ 'purge_' . $pval, $pval, in_array($pval, $purge_options),
1460
+ __('Yearly archive', 'litespeed-cache'));
1461
+
1462
+ $buf .= $spacer;
1463
+
1464
+ $pval = LiteSpeed_Cache_Config::PURGE_MONTH;
1465
+ $buf .= $this->input_field_checkbox(
1466
+ 'purge_' . $pval, $pval, in_array($pval, $purge_options),
1467
+ __('Monthly archive', 'litespeed-cache'));
1468
+
1469
+ $buf .= $spacer;
1470
+
1471
+ $pval = LiteSpeed_Cache_Config::PURGE_DATE;
1472
+ $buf .= $this->input_field_checkbox(
1473
+ 'purge_' . $pval, $pval, in_array($pval, $purge_options),
1474
+ __('Daily archive', 'litespeed-cache'));
1475
+
1476
+ $buf .= $endtr . $tr;
1477
+
1478
+ $pval = LiteSpeed_Cache_Config::PURGE_TERM;
1479
+ $buf .= $this->input_field_checkbox(
1480
+ 'purge_' . $pval, $pval, in_array($pval, $purge_options),
1481
+ __('Term archive (include category, tag, and tax)', 'litespeed-cache'));
1482
+
1483
+ $buf .= $endtr;
1484
+ $buf .= $this->input_group_end();
1485
+
1486
+ return $buf;
1487
+ }
1488
+
1489
+ /**
1490
+ * Builds the html for the do not cache settings tab.
1491
+ *
1492
+ * @since 1.0.1
1493
+ * @access private
1494
+ * @param array $options The current configuration options.
1495
+ * @return string The html for the do not cache tab.
1496
+ */
1497
+ private function show_settings_excludes($options)
1498
+ {
1499
+
1500
+ $uri_description =
1501
+ self::build_list(
1502
+ array(
1503
+ __('Enter a list of urls that should not be cached.', 'litespeed-cache'),
1504
+ __('The urls will be compared to the REQUEST_URI server variable.', 'litespeed-cache'),
1505
+ __('There should only be one url per line.', 'litespeed-cache')
1506
+ ),
1507
+ true
1508
+ );
1509
+
1510
+ $uri_do_not_cache_text = '<b>' . __('NOTE:', 'litespeed-cache') . ' </b>'
1511
+ . self::build_list(
1512
+ array(
1513
+ __('URLs must start with a \'/\' to be correctly matched.', 'litespeed-cache'),
1514
+ __('To do an exact match, add \'$\' to the end of the URL.', 'litespeed-cache'),
1515
+ __('Any surrounding whitespaces will be trimmed.', 'litespeed-cache'),
1516
+ sprintf(__('e.g. to exclude %1$s, insert %2$s', 'litespeed-cache'),
1517
+ 'http://www.example.com/excludethis.php',
1518
+ '/excludethis.php'),
1519
+ sprintf(__('Similarly, to exclude %1$s(accessed with the /blog), insert %2$s', 'litespeed-cache'),
1520
+ 'http://www.example.com/blog/excludethis.php',
1521
+ '/blog/excludethis.php')
1522
+ ),
1523
+ true
1524
+ );
1525
+
1526
+ $cat_description =
1527
+ self::build_list(
1528
+ array(
1529
+ '<b>'
1530
+ . __('All categories are cached by default.', 'litespeed-cache')
1531
+ . '</b>',
1532
+ __('To prevent a category from being cached, enter it in the text area below, one per line.', 'litespeed-cache')
1533
+ ),
1534
+ true
1535
+ );
1536
+ $cat_do_not_cache_text =
1537
+ '<b>' . __('NOTE:', 'litespeed-cache') . '</b>'
1538
+ . self::build_list(
1539
+ array(
1540
+ __('If the Category ID is not found, the name will be removed on save.', 'litespeed-cache'),
1541
+ sprintf(__('e.g. to exclude %1$s, insert %2$s', 'litespeed-cache'),
1542
+ '<code style="font-size: 11px;">http://www.example.com/category/category/category-id/</code>',
1543
+ 'category-id')
1544
+ . '</code>'
1545
+ ),
1546
+ true
1547
+ );
1548
+
1549
+ $tag_description =
1550
+ self::build_list(
1551
+ array(
1552
+ '<b>'
1553
+ . __('All tags are cached by default.', 'litespeed-cache')
1554
+ . '</b>',
1555
+ __('To prevent tags from being cached, enter the tag in the text area below, one per line.', 'litespeed-cache')
1556
+ ),
1557
+ true
1558
+ );
1559
+ $tag_do_not_cache_text =
1560
+ '<b>' . __('NOTE:', 'litespeed-cache')
1561
+ . '</b>'
1562
+ . self::build_list(
1563
+ array(
1564
+ __('If the Tag ID is not found, the name will be removed on save.', 'litespeed-cache'),
1565
+ sprintf(__('e.g. to exclude %1$s, insert %2$s', 'litespeed-cache'),
1566
+ 'http://www.example.com/tag/category/tag-id/', 'tag-id')
1567
+ ),
1568
+ true
1569
+ );
1570
+
1571
+
1572
+ $tr = '<tr><td>';
1573
+ $endtr = "</td></tr>\n";
1574
+
1575
+ $excludes_id = LiteSpeed_Cache_Config::OPID_EXCLUDES_URI;
1576
+ $excludes_buf = $options[$excludes_id];
1577
+ $buf = $this->input_group_start(__('URI List', 'litespeed-cache'),
1578
+ $uri_description);
1579
+ $buf .= $tr;
1580
+ $buf .= self::build_tip($uri_do_not_cache_text,
1581
+ '-do-not',
1582
+ 'margin-right:5px; top:-5px;',
1583
+ 'margin-right:-420px; width:400px;'
1584
+ );
1585
+ $buf .= '<span style="font-size: 11px; font-style:italic;display:inline-block;">'
1586
+ . __('SYNTAX: URLs must start with a \'/\' to be correctly matched.', 'litespeed-cache')
1587
+ . "<br>"
1588
+ . __('To do an exact match, add \'$\' to the end of the URL. One URL per line.', 'litespeed-cache')
1589
+ . '</span><br>';
1590
+
1591
+ $buf .= $this->input_field_textarea($excludes_id, $excludes_buf,
1592
+ '10', '80', '');
1593
+ $buf .= $endtr;
1594
+
1595
+ $buf .= $this->input_group_end();
1596
+
1597
+ $excludes_id = LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT;
1598
+ $excludes_buf = '';
1599
+ $cat_ids = $options[$excludes_id];
1600
+ if ($cat_ids != '') {
1601
+ $id_list = explode(',', $cat_ids);
1602
+ $excludes_buf = implode("\n", array_map('get_cat_name', $id_list));
1603
+ }
1604
+ $buf .= $this->input_group_start(__('Category List', 'litespeed-cache'),
1605
+ $cat_description);
1606
+ $buf .= $tr;
1607
+ $buf .= self::build_tip($cat_do_not_cache_text,
1608
+ '-do-not',
1609
+ 'margin-right:5px; top:1px;',
1610
+ 'margin-right:-420px; width:400px;'
1611
+ );
1612
+ $buf .= '<span style="font-size: 11px; font-style:italic;">'
1613
+ . __('SYNTAX: One category id per line.', 'litespeed-cache')
1614
+ . '</span><br>';
1615
+
1616
+ $buf .= $this->input_field_textarea($excludes_id, $excludes_buf,
1617
+ '5', '80', '');
1618
+ $buf .= $endtr;
1619
+
1620
+ $buf .= $this->input_group_end();
1621
+
1622
+ $excludes_id = LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG;
1623
+ $excludes_buf = '';
1624
+ $tag_ids = $options[$excludes_id];
1625
+ if ($tag_ids != '') {
1626
+ $id_list = explode(',', $tag_ids);
1627
+ $tags_list = array_map('get_tag', $id_list);
1628
+ $tag_names = array();
1629
+ foreach ($tags_list as $tag) {
1630
+ $tag_names[] = $tag->name;
1631
+ }
1632
+ if (!empty($tag_names)) {
1633
+ $excludes_buf = implode("\n", $tag_names);
1634
+ }
1635
+ }
1636
+ $buf .= $this->input_group_start(__('Tag List', 'litespeed-cache'),
1637
+ $tag_description);
1638
+ $buf .= $tr;
1639
+ $buf .= self::build_tip($tag_do_not_cache_text,
1640
+ '-do-not',
1641
+ 'margin-right:5px; top:1px;',
1642
+ 'margin-right:-420px; width:400px;'
1643
+ );
1644
+ $buf .= '<span style="font-size: 11px; font-style:italic;">'
1645
+ . __('SYNTAX: One tag id per line.', 'litespeed-cache')
1646
+ . '</span><br>';
1647
+
1648
+ $buf .= $this->input_field_textarea($excludes_id, $excludes_buf,
1649
+ '5', '80', '');
1650
+ $buf .= $endtr;
1651
+
1652
+ $buf .= $this->input_group_end();
1653
+
1654
+ if (is_multisite()) {
1655
+ return $buf;
1656
+ }
1657
+ $cookie_title = '';
1658
+ $cookie_desc = '';
1659
+ $cookie_buf = $this->build_setting_exclude_cookies($options, $cookie_title, $cookie_desc, false);
1660
+
1661
+ $syntax = self::build_paragraph(
1662
+ __('SYNTAX: Cookies should be listed one per line.', 'litespeed-cache'),
1663
+ sprintf(__('Spaces should have a backslash in front of them, %s', 'litespeed-cache'), "'\ '.")
1664
+ );
1665
+
1666
+ $cookie_title = __('Cookie List', 'litespeed-cache');
1667
+ $cookie_desc = __('To prevent cookies from being cached, enter it in the text area below.', 'litespeed-cache');
1668
+ $htaccess_notice = '<br><strong>' . __('NOTICE:', 'litespeed-cache') . ' </strong>'
1669
+ . __('This setting will edit the .htaccess file.', 'litespeed-cache');
1670
+
1671
+ $buf .= $this->input_group_start($cookie_title, $cookie_desc);
1672
+ $buf .= $tr;
1673
+ $buf .= self::build_tip($htaccess_notice,
1674
+ '-do-not',
1675
+ 'margin-right:5px; top:1px;',
1676
+ 'margin-right:-280px; width:260px;'
1677
+ );
1678
+ $buf .= '<span style="font-size: 11px; font-style:italic;">' . $syntax
1679
+ . '</span><br>' . $cookie_buf . $endtr;
1680
+ $buf .= $this->input_group_end();
1681
+
1682
+ $ua_title = '';
1683
+ $ua_desc = '';
1684
+ $ua_buf = $this->build_setting_exclude_useragent($options, $ua_title, $ua_desc, false);
1685
+
1686
+ $syntax = self::build_paragraph(
1687
+ sprintf(__('SYNTAX: Separate each user agent with a bar, <style="font-style:normal">%s</style>.', 'litespeed-cache'), "'|'"),
1688
+ sprintf(__('Spaces should have a backslash in front of them, %s.', 'litespeed-cache'), "'\'")
1689
+ );
1690
+
1691
+ $ua_title = __('User Agent List', 'litespeed-cache');
1692
+ $ua_desc = __('To prevent user agents from being cached, enter it in the text field below.', 'litespeed-cache');
1693
+
1694
+ $buf .= $tr;
1695
+ $buf .= $this->input_group_start($ua_title, $ua_desc);
1696
+ $buf .= self::build_tip($htaccess_notice,
1697
+ '-do-not',
1698
+ 'margin-right:5px; top:1px;',
1699
+ 'margin-right:-280px; width:260px; z-index:9999 !important;'
1700
+ );
1701
+ $buf .= '<span style="font-size: 11px; font-style:italic;">' . $syntax
1702
+ . '</span><br>' . $ua_buf . $endtr;
1703
+ $buf .= $this->input_group_end();
1704
+
1705
+ return $buf;
1706
+ }
1707
+
1708
+ /**
1709
+ * Builds the html for the advanced settings tab.
1710
+ *
1711
+ * @since 1.0.1
1712
+ * @access private
1713
+ * @param array $options The current configuration options.
1714
+ * @return string The html for the advanced settings tab.
1715
+ */
1716
+ private function show_settings_advanced($options)
1717
+ {
1718
+ $cookie_title = '';
1719
+ $cookie_desc = '';
1720
+ $buf = '<div class="litespeed-cache-advanced-settings">';
1721
+ $advanced_desc = self::build_paragraph(
1722
+ '<strong>' . __('NOTICE', 'litespeed-cache') . ':</strong>',
1723
+ __('These settings are meant for ADVANCED USERS ONLY.', 'litespeed-cache'),
1724
+ __('Please take great care when changing any of these settings.', 'litespeed-cache'),
1725
+ __("If there are any questions, do not hesitate to submit a support thread.", 'litespeed-cache')
1726
+ );
1727
+
1728
+ $adv_cache_desc = self::build_paragraph(
1729
+ __('The advanced-cache.php file is used by many caching plugins to signal that a cache is active.', 'litespeed-cache'),
1730
+ __('When this option is checked and this file is detected as belonging to another plugin, LiteSpeed Cache will not cache.', 'litespeed-cache')
1731
+ );
1732
+
1733
+ $tag_prefix_desc = self::build_paragraph(
1734
+ __('Add an alpha-numeric prefix to cache and purge tags.', 'litespeed-cache'),
1735
+ __('This can be used to prevent issues when using multiple LiteSpeed caching extensions on the same server.', 'litespeed-cache')
1736
+ );
1737
+
1738
+ $buf .= $this->input_group_start(__('Advanced Settings', 'litespeed-cache'),
1739
+ '', '', $advanced_desc, true);
1740
+ $buf .= $this->input_group_end();
1741
+ $buf .= '<hr>';
1742
+ $buf .= self::build_expand_collapse(false);
1743
+
1744
+ $id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE;
1745
+ $check_adv = $this->input_field_checkbox('lscwp_' . $id, $id, $options[$id]);
1746
+ $ac_title = __('Check advanced-cache.php', 'litespeed-cache');
1747
+ $ac_desc = $check_adv . "&nbsp;" . __('Check this option to include advanced-cache.php', 'litespeed-cache')
1748
+ . '<ul><li>'
1749
+ . $adv_cache_desc
1750
+ . '</li><li>'
1751
+ . __('<i>Uncheck this option only if the other plugin is used for non-caching purposes, such as minifying css/js files.</i>', 'litespeed-cache')
1752
+ . '</li></ul>';
1753
+
1754
+
1755
+ $cookie_buf = $this->build_setting_login_cookie($options,
1756
+ $cookie_title, $cookie_desc);
1757
+
1758
+ $cookie_desc = $cookie_desc . '<br>' . $cookie_buf;
1759
+
1760
+ $id = LiteSpeed_Cache_Config::OPID_TAG_PREFIX;
1761
+ $tag_title = __('Cache Tag Prefix', 'litespeed-cache');
1762
+ $tag_inputs = $this->input_field_text($id, $options[$id]);
1763
+ $tag_prefix_desc = $tag_prefix_desc . '<br>' . $tag_inputs;
1764
+
1765
+ $buf .= $this->input_collapsible_start();
1766
+
1767
+ $buf .= $this->input_field_collapsible($ac_title, $ac_desc);
1768
+ $buf .= $this->input_field_collapsible($cookie_title, $cookie_desc);
1769
+ $buf .= $this->input_field_collapsible($tag_title, $tag_prefix_desc);
1770
+ $buf .= $this->input_collapsible_end();
1771
+
1772
+ $buf .= '</div>';
1773
+
1774
+ return $buf;
1775
+
1776
+ }
1777
+
1778
+ /**
1779
+ * Builds the html for the debug settings tab.
1780
+ *
1781
+ * @since 1.0.0
1782
+ * @access private
1783
+ * @param array $options The current configuration options.
1784
+ * @return string The html for the debug settings tab.
1785
+ */
1786
+ private function show_settings_test($options)
1787
+ {
1788
+ $buf = $this->input_group_start(__('Developer Testing', 'litespeed-cache'));
1789
+
1790
+ $admin_ip_desc =
1791
+ __('Allows listed IPs (space or comma separated) to perform certain actions from their browsers.', 'litespeed-cache');
1792
+
1793
+ $below_text = '<br><i style="font-size:11px;margin-left: 22px;">'
1794
+ . sprintf(wp_kses(__('More information about the available commands can be found <a href="%s">here</a>.', 'litespeed-cache'),
1795
+ array('a' => array('href' => array()))),
1796
+ get_admin_url() . 'admin.php?page=lscache-info#adminip')
1797
+ . '</i>';
1798
+
1799
+ $debug_desc = self::build_paragraph(
1800
+ __('Outputs to WordPress debug log.', 'litespeed-cache'),
1801
+ __('This should be set to off once everything is working to prevent filling the disk.', 'litespeed-cache'),
1802
+ __('The Admin IP option will only output log messages on requests from admin IPs.', 'litespeed-cache'),
1803
+ __('The logs will be outputted to the debug.log in the wp-content directory.', 'litespeed-cache')
1804
+ );
1805
+
1806
+ $id = LiteSpeed_Cache_Config::OPID_ADMIN_IPS;
1807
+ $input_admin_ips = $this->input_field_text($id, $options[$id], '',
1808
+ 'regular-text', $below_text);
1809
+ $buf .= $this->display_config_row(
1810
+ __('Admin IPs', 'litespeed-cache'),
1811
+ $input_admin_ips,
1812
+ $admin_ip_desc
1813
+ );
1814
+
1815
+ $id = LiteSpeed_Cache_Config::OPID_DEBUG;
1816
+ $debug_levels = array(
1817
+ LiteSpeed_Cache_Config::OPID_ENABLED_DISABLE => __('Off', 'litespeed-cache'),
1818
+ LiteSpeed_Cache_Config::OPID_ENABLED_ENABLE => __('On', 'litespeed-cache'),
1819
+ LiteSpeed_Cache_Config::OPID_ENABLED_NOTSET => __('Admin IP only', 'litespeed-cache'),
1820
+ );
1821
+ $input_debug = $this->input_field_select($id, $debug_levels, $options[$id]);
1822
+ $buf .= $this->display_config_row(
1823
+ __('Debug Log', 'litespeed-cache'),
1824
+ $input_debug,
1825
+ $debug_desc
1826
+ );
1827
+
1828
+ /* Maybe add this feature later
1829
+ $id = LiteSpeed_Cache_Config::OPID_TEST_IPS;
1830
+ $input_test_ips = $this->input_field_text($id, $options[$id], '', 'regular-text');
1831
+ $buf .= $this->display_config_row('Test IPs', $input_test_ips,
1832
+ 'Enable LiteSpeed Cache only for specified IPs. (Space or comma separated.)
1833
+ * Allows testing on a live site. If empty, cache will be served to everyone.');
1834
+ *
1835
+ */
1836
+
1837
+ $buf .= $this->input_group_end();
1838
+
1839
+ return $buf;
1840
+ }
1841
+
1842
+ /**
1843
+ * Checks if wp_postviews is installed. If so, show this tab.
1844
+ *
1845
+ * @since 1.0.4
1846
+ * @access private
1847
+ * @return string The html for the compatibility tab.
1848
+ */
1849
+ private function show_settings_compatibilities()
1850
+ {
1851
+
1852
+ $buf = '';
1853
+
1854
+ if (function_exists('the_views')) {
1855
+ $buf .= $this->build_compatibility_wp_postviews();
1856
+ }
1857
+
1858
+ return $buf;
1859
+ }
1860
+
1861
+ /**
1862
+ * Builds the html for the mobile views configurations.
1863
+ *
1864
+ * @since 1.0.4
1865
+ * @access private
1866
+ * @param array $options The currently configured options.
1867
+ * @return string The html for mobile views configurations.
1868
+ */
1869
+ private function build_setting_mobile_view($options)
1870
+ {
1871
+ $checkbox_desc = self::build_paragraph(
1872
+ __('When checked, mobile views will be cached separately.', 'litespeed-cache'),
1873
+ __('A site built with responsive design does not need to check this.', 'litespeed-cache')
1874
+ );
1875
+ $list_para = self::build_paragraph(
1876
+ sprintf(__('SYNTAX: Each entry should be separated with a bar, %s', 'litespeed-cache'), "'|'."),
1877
+ sprintf(__('Any spaces should be escaped with a backslash before the space, %s', 'litespeed-cache'), "'\\ '.")
1878
+ );
1879
+ $file_writable = LiteSpeed_Cache_Admin_Rules::is_file_able(
1880
+ LiteSpeed_Cache_Admin_Rules::WRITABLE);
1881
+ $wp_default_mobile = 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi';
1882
+
1883
+ $id = LiteSpeed_Cache_Config::OPID_MOBILEVIEW_ENABLED;
1884
+ $list_id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST;
1885
+ $default_id = 'lscwp_' . $id . '_default';
1886
+ $warning_id = 'lscwp_' . $id . '_warning';
1887
+ $cache_enable_id = is_network_admin()
1888
+ ? LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED
1889
+ : LiteSpeed_Cache_Config::OPID_ENABLED;
1890
+ $enabled = $options[$id];
1891
+
1892
+ clearstatcache();
1893
+ $buf = $this->input_field_hidden($warning_id,
1894
+ self::build_paragraph(
1895
+ __('WARNING: Unchecking this option will clear the Mobile View List.', 'litespeed-cache'),
1896
+ __('Press OK to confirm this action.', 'litespeed-cache')
1897
+ ));
1898
+ $mv_enabled = $this->input_field_checkbox('lscwp_' . $id, $id, $enabled, '',
1899
+ 'lscwpCheckboxConfirm(this, \'' . $list_id . '\')', !$file_writable);
1900
+
1901
+ $buf .= $this->display_config_row(
1902
+ __('Enable Separate Mobile View', 'litespeed-cache'), $mv_enabled,
1903
+ $checkbox_desc);
1904
+
1905
+ $mv_list_desc = $list_para . '<br>'
1906
+ . sprintf(__('The default list WordPress uses is %s', 'litespeed-cache'), $wp_default_mobile);
1907
+
1908
+ $notice_settings = '<strong>' . __('NOTICE:', 'litespeed-cache') . ' </strong>'
1909
+ . __('This setting will edit the .htaccess file.', 'litespeed-cache');
1910
+
1911
+ $mv_str = '';
1912
+ if (($options[$cache_enable_id]) && ($enabled)) {
1913
+ $ret = LiteSpeed_Cache_Admin_Rules::get_instance()->get_common_rule(
1914
+ 'MOBILE VIEW', 'HTTP_USER_AGENT', $mv_str);
1915
+ }
1916
+ elseif ($enabled) {
1917
+ $ret = true;
1918
+ $mv_str = $options[LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST];
1919
+ }
1920
+ elseif ($options[LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST] == false) {
1921
+ $ret = true;
1922
+ $mv_str = '';
1923
+ }
1924
+ else {
1925
+ $ret = false;
1926
+ $mv_str = sprintf(__('Expected false, got %s', 'litespeed-cache'),
1927
+ $mv_str);
1928
+ }
1929
+ if ($ret !== true) {
1930
+ $mv_list = '<p class="attention">'
1931
+ . sprintf(__('Error getting current rules: %s', 'litespeed-cache'),
1932
+ $mv_str) . '</p>';
1933
+ }
1934
+ elseif ((($enabled) && ($mv_str === $options[LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST]))
1935
+ || ((!$enabled) && ($mv_str === ''))
1936
+ ) {
1937
+ // can also use class 'mejs-container' for 100% width.
1938
+ $mv_list = $this->input_field_text($list_id, $mv_str, '', 'widget ui-draggable-dragging code', '',
1939
+ ($options[$id] ? false : true));
1940
+
1941
+ $default_fill = (($mv_str == '') ? $wp_default_mobile : $mv_str);
1942
+ $buf .= $this->input_field_hidden($default_id, $default_fill);
1943
+ }
1944
+ else {
1945
+ $list_error = self::build_paragraph(
1946
+ __('Htaccess did not match configuration option.', 'litespeed-cache'),
1947
+ __('Please re-enter the mobile view setting.', 'litespeed-cache'),
1948
+ sprintf(__('List in WordPress database: %s', 'litespeed-cache'),
1949
+ $options[LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST])
1950
+ );
1951
+ $mv_list = $this->input_field_text($list_id, '', '',
1952
+ 'widget ui-draggable-dragging code', '', ($options[$id] ? false : true))
1953
+ . '<p class="attention">' . $list_error . '</p>';
1954
+
1955
+ $default_fill = (($mv_str == '') ? $wp_default_mobile : $mv_str);
1956
+ $buf .= $this->input_field_hidden($default_id, $default_fill);
1957
+ }
1958
+ $buf .= $this->display_config_row(__('List of Mobile View User Agents', 'litespeed-cache'),
1959
+ $mv_list, '', $notice_settings, $mv_list_desc);
1960
+
1961
+ //$buf .= '<span style="font-size: 11px; font-style:italic;"">'.$mv_list_desc.'</span>';
1962
+ return $buf;
1963
+ }
1964
+
1965
+ /**
1966
+ * Builds the html for the cookie excludes configuration.
1967
+ *
1968
+ * @since 1.0.4
1969
+ * @access private
1970
+ * @param array $options The currently configured options.
1971
+ * @param string $cookie_title Returns the cookie title string.
1972
+ * @param string $cookie_desc Returns the cookie description string.
1973
+ * @return string Returns the cookie text area on success, error message on
1974
+ * failure.
1975
+ */
1976
+ private function build_setting_exclude_cookies($options, &$cookie_title,
1977
+ &$cookie_desc, $do_not = false)
1978
+ {
1979
+ if ($do_not) {
1980
+ $desc_para = self::build_paragraph(
1981
+ __('SYNTAX: Cookies should be listed one per line.', 'litespeed-cache'),
1982
+ sprintf(__('Spaces should have a backslash in front of them, %s', 'litespeed-cache'), "'\ '.")
1983
+ );
1984
+ $file_writable = LiteSpeed_Cache_Admin_Rules::is_file_able(
1985
+ LiteSpeed_Cache_Admin_Rules::WRITABLE);
1986
+ $id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES;
1987
+ $cookie_title = __('Cookie List', 'litespeed-cache');
1988
+ $cookie_desc = __('To prevent cookies from being cached, enter it in the text area below.', 'litespeed-cache')
1989
+ . '<br>' . $desc_para
1990
+ . '<br><strong>' . __('NOTICE:', 'litespeed-cache') . ' </strong>'
1991
+ . __('This setting will edit the .htaccess file.', 'litespeed-cache');
1992
+
1993
+ $excludes_buf = str_replace('|', "\n", $options[$id]);
1994
+ }
1995
+ else {
1996
+ $file_writable = LiteSpeed_Cache_Admin_Rules::is_file_able(
1997
+ LiteSpeed_Cache_Admin_Rules::WRITABLE);
1998
+ $id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES;
1999
+ $excludes_buf = str_replace('|', "\n", $options[$id]);
2000
+ }
2001
+
2002
+ return $this->input_field_textarea($id, $excludes_buf, '5', '80', '',
2003
+ !$file_writable);
2004
+ }
2005
+
2006
+ /**
2007
+ * Builds the html for the user agent excludes configuration.
2008
+ *
2009
+ * @since 1.0.4
2010
+ * @access private
2011
+ * @param array $options The currently configured options.
2012
+ * @param string $ua_title Returns the user agent title string.
2013
+ * @param string $ua_desc Returns the user agent description string.
2014
+ * @return string Returns the user agent text field on success,
2015
+ * error message on failure.
2016
+ */
2017
+ private function build_setting_exclude_useragent($options, &$ua_title,
2018
+ &$ua_desc, $user_agent_text = false)
2019
+ {
2020
+ if ($user_agent_text) {
2021
+ $desc_para = self::build_paragraph(
2022
+ sprintf(__('SYNTAX: Separate each user agent with a bar, %s.', 'litespeed-cache'), "'|'"),
2023
+ sprintf(__('Spaces should have a backslash in front of them, %s.', 'litespeed-cache'), "")
2024
+ );
2025
+ $file_writable = LiteSpeed_Cache_Admin_Rules::is_file_able(
2026
+ LiteSpeed_Cache_Admin_Rules::WRITABLE);
2027
+ $id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS;
2028
+ $ua_title = __('User Agent List', 'litespeed-cache');
2029
+ $ua_desc = __('To prevent user agents from being cached, enter it in the text field below.', 'litespeed-cache')
2030
+ . '<br>' . $desc_para
2031
+ . '<br><strong>' . __('NOTICE:', 'litespeed-cache') . ' </strong>'
2032
+ . __('This setting will edit the .htaccess file.', 'litespeed-cache');
2033
+ $ua_list = $this->input_field_text($id, $options[$id], '',
2034
+ 'widget ui-draggable-dragging', '', !$file_writable);
2035
+ }
2036
+ else {
2037
+ $file_writable = LiteSpeed_Cache_Admin_Rules::is_file_able(
2038
+ LiteSpeed_Cache_Admin_Rules::WRITABLE);
2039
+ $id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS;
2040
+ $ua_list = $this->input_field_text($id, $options[$id], '',
2041
+ 'widget ui-draggable-dragging', '', !$file_writable);
2042
+ }
2043
+
2044
+ return $ua_list;
2045
+ }
2046
+
2047
+ /**
2048
+ * Builds the html for the user agent excludes configuration.
2049
+ *
2050
+ * @since 1.0.7
2051
+ * @access private
2052
+ * @param array $options The currently configured options.
2053
+ * @param string $cookie_title Returns the cookie title string.
2054
+ * @param string $cookie_desc Returns the cookie description string.
2055
+ * @return string Returns the cookie text field on success,
2056
+ * error message on failure.
2057
+ */
2058
+ private function build_setting_login_cookie($options, &$cookie_title,
2059
+ &$cookie_desc)
2060
+ {
2061
+ $file_writable = LiteSpeed_Cache_Admin_Rules::is_file_able(
2062
+ LiteSpeed_Cache_Admin_Rules::WRITABLE);
2063
+ $id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE;
2064
+ $cookie = '';
2065
+ $match = '';
2066
+ $sub = '';
2067
+
2068
+ $cookie_title = __('Login Cookie', 'litespeed-cache');
2069
+ $cookie_desc =
2070
+ self::build_paragraph(
2071
+ __('SYNTAX: alphanumeric and "_".', 'litespeed-cache'),
2072
+ __('No spaces and case sensitive.', 'litespeed-cache'),
2073
+ __('MUST BE UNIQUE FROM OTHER WEB APPLICATIONS.', 'litespeed-cache')
2074
+ ) . '<br>'
2075
+ . self::build_paragraph(
2076
+ sprintf(__('The default login cookie is %s.', 'litespeed-cache'),
2077
+ '_lscache_vary'),
2078
+ __('The server will determine if the user is logged in based on the existance of this cookie.', 'litespeed-cache'),
2079
+ __('This setting is useful for those that have multiple web applications for the same domain.', 'litespeed-cache'),
2080
+ __('If every web application uses the same cookie, the server may confuse whether a user is logged in or not.', 'litespeed-cache'),
2081
+ __('The cookie set here will be used for this WordPress installation.', 'litespeed-cache')
2082
+ )
2083
+ . '<br><br>'
2084
+ . __('Example use case:', 'litespeed-cache')
2085
+ . '<br>'
2086
+ . sprintf(__('There is a WordPress install for %s.', 'litespeed-cache'),
2087
+ '<u>www.example.com</u>')
2088
+ . '<br>'
2089
+ . sprintf(__('Then there is another WordPress install (NOT MULTISITE) at %s', 'litespeed-cache'),
2090
+ '<u>www.example.com/blog/</u>')
2091
+ . '<br>'
2092
+ . __('The cache needs to distinguish who is logged into which WordPress site in order to cache correctly.', 'litespeed-cache');
2093
+
2094
+
2095
+ if (LiteSpeed_Cache_Admin_Rules::get_instance()->get_rewrite_rule('LOGIN COOKIE',
2096
+ $match, $sub, $cookie) === false
2097
+ ) {
2098
+ return '<p class="attention">'
2099
+ . sprintf(__('Error getting current rules: %s', 'litespeed-cache'), $match) . '</p>';
2100
+ }
2101
+ if (!empty($cookie)) {
2102
+ $cookie = trim($cookie, '"');
2103
+ if (strncasecmp($cookie, 'Cache-Vary:', 11)) {
2104
+ return '<p class="attention">'
2105
+ . sprintf(__('Error: invalid login cookie. Please check the %s file', 'litespeed-cache'), '.htaccess')
2106
+ . '</p>';
2107
+ }
2108
+ $cookie = substr($cookie, 11);
2109
+ $cookie_arr = explode(',', $cookie);
2110
+ }
2111
+ if (($options[LiteSpeed_Cache_Config::OPID_ENABLED])
2112
+ && (isset($options[$id]))
2113
+ && (isset($cookie_arr))
2114
+ && (!in_array($options[$id], $cookie_arr))
2115
+ ) {
2116
+ echo $this->build_notice(self::NOTICE_YELLOW,
2117
+ __('WARNING: The .htaccess login cookie and Database login cookie do not match.', 'litespeed-cache'));
2118
+ }
2119
+
2120
+ return $this->input_field_text($id, $options[$id], '', '', '',
2121
+ !$file_writable);
2122
+ }
2123
+
2124
+ /**
2125
+ * Builds the html for the purge on upgrade configurations.
2126
+ *
2127
+ * @since 1.0.10
2128
+ * @access private
2129
+ * @param array $options The currently configured options.
2130
+ * @return string The html for purging on upgrade configurations.
2131
+ */
2132
+ private function build_setting_purge_on_upgrade($options)
2133
+ {
2134
+ $id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE;
2135
+ $purge_upgrade = $this->input_field_checkbox('lscwp_' . $id, $id, $options[$id]);
2136
+
2137
+ return $this->display_config_row(__('Purge All on upgrade', 'litespeed-cache'), $purge_upgrade,
2138
+ __('When checked, the cache will automatically purge when any plugins, themes, or WordPress core is upgraded.', 'litespeed-cache'));
2139
+ }
2140
+
2141
+ /**
2142
+ * Builds the html for the cache favicon configurations.
2143
+ *
2144
+ * @since 1.0.8
2145
+ * @access private
2146
+ * @param array $options The currently configured options.
2147
+ * @return string The html for caching favicon configurations.
2148
+ */
2149
+ private function build_setting_cache_favicon($options)
2150
+ {
2151
+ $file_writable = LiteSpeed_Cache_Admin_Rules::is_file_able(
2152
+ LiteSpeed_Cache_Admin_Rules::WRITABLE);
2153
+ $title = __('Cache favicon.ico', 'litespeed-cache');
2154
+ $desc = self::build_paragraph(
2155
+ __('favicon.ico is requested on most pages.', 'litespeed-cache'),
2156
+ __('Caching this recource may improve server performance by avoiding unnecessary PHP calls.', 'litespeed-cache')
2157
+ );
2158
+ $id = LiteSpeed_Cache_Config::OPID_CACHE_FAVICON;
2159
+ $cache_favicon = $this->input_field_checkbox('lscwp_' . $id, $id,
2160
+ $options[$id], '', '', !$file_writable);
2161
+
2162
+ return $this->display_config_row($title, $cache_favicon, $desc);
2163
+ }
2164
+
2165
+ /**
2166
+ * Builds the html for the cache PHP resources configurations.
2167
+ *
2168
+ * @since 1.0.8
2169
+ * @access private
2170
+ * @param array $options The currently configured options.
2171
+ * @return string The html for caching resource configurations.
2172
+ */
2173
+ private function build_setting_cache_resources($options)
2174
+ {
2175
+ $file_writable = LiteSpeed_Cache_Admin_Rules::is_file_able(
2176
+ LiteSpeed_Cache_Admin_Rules::WRITABLE);
2177
+ $title = __('Enable Cache for PHP Resources', 'litespeed-cache');
2178
+ $desc = self::build_paragraph(
2179
+ __('Some themes and plugins add resources via a PHP request.', 'litespeed-cache'),
2180
+ __('Caching these pages may improve server performance by avoiding unnecessary PHP calls.', 'litespeed-cache'));
2181
+ $id = LiteSpeed_Cache_Config::OPID_CACHE_RES;
2182
+ $cache_res = $this->input_field_checkbox('lscwp_' . $id, $id,
2183
+ $options[$id], '', '', !$file_writable);
2184
+
2185
+ return $this->display_config_row($title, $cache_res, $desc);
2186
+ }
2187
+
2188
+ /**
2189
+ * Builds the html for the wp_postviews help page.
2190
+ *
2191
+ * @since 1.0.1
2192
+ * @access private
2193
+ * @return string The html for the wp_postviews help page.
2194
+ */
2195
+ private function build_compatibility_wp_postviews()
2196
+ {
2197
+ $buf = '';
2198
+ $example_src = htmlspecialchars('<?php if(function_exists(\'the_views\' )) { the_views(); } ?>');
2199
+ $example_div = htmlspecialchars('<div id="postviews_lscwp" > </div>');
2200
+ $example_ajax_path = '/wp-content/plugins/wp-postviews/postviews-cache.js';
2201
+ $example_ajax = 'jQuery.ajax({
2202
+ type:"GET",
2203
+ url:viewsCacheL10n.admin_ajax_url,
2204
+ data:"postviews_id="+viewsCacheL10n.post_id+"&action=postviews",
2205
+ cache:!1,
2206
+ success:function(data) {
2207
+ if(data) {
2208
+ jQuery(\'#postviews_lscwp\').html(data+\' views\');
2209
+ }
2210
+ }
2211
+ });';
2212
+ $wp_postviews_desc = __('To make LiteSpeed Cache compatible with WP-PostViews:', 'litespeed-cache')
2213
+ . '<br>'
2214
+ . self::build_list(
2215
+ array(
2216
+ __('Replace the following calls in the active theme\'s template files with a div or span with a unique ID.', 'litespeed-cache')
2217
+ . '<br>'
2218
+ . sprintf(wp_kses(__('e.g. Replace <br> <pre>%1$s</pre> with<br> <pre>%2$s</pre>', 'litespeed-cache'),
2219
+ array('br' => array(), 'pre' => array())),
2220
+ $example_src,
2221
+ $example_div),
2222
+ __('Update the ajax request to output the results to that div.', 'litespeed-cache')
2223
+ . '<br><br>'
2224
+ . __('Example:', 'litespeed-cache')
2225
+ . '<br>'
2226
+ . '<pre>' . $example_ajax . '</pre><br>'
2227
+ . __('The ajax code can be found at', 'litespeed-cache') . '<br>'
2228
+ . '<pre>' . $example_ajax_path . '</pre>',
2229
+ __('After purging the cache, the view count should be updating.', 'litespeed-cache')
2230
+ ),
2231
+ true
2232
+ );
2233
+ $buf .= $this->input_group_start(
2234
+ __('Compatibility with WP-PostViews', 'litespeed-cache'), $wp_postviews_desc);
2235
+ $buf .= $this->input_group_end();
2236
+
2237
+ return $buf;
2238
+ }
2239
+
2240
+ /**
2241
+ * Builds the html for the third party compatibilities tab.
2242
+ *
2243
+ * @since 1.0.4
2244
+ * @access private
2245
+ * @return string The html for the compatibilities tab.
2246
+ */
2247
+ private function show_info_compatibility()
2248
+ {
2249
+ $known_compat = array(
2250
+ 'bbPress',
2251
+ 'WooCommerce',
2252
+ 'Contact Form 7',
2253
+ 'Google XML Sitemaps',
2254
+ 'Yoast SEO',
2255
+ 'Wordfence Security',
2256
+ 'NextGen Gallery',
2257
+ );
2258
+
2259
+ $known_uncompat = array();
2260
+
2261
+ $compat_desc = self::build_paragraph(
2262
+ __('Please add a comment listing the plugins that you are using and how they are functioning on the support thread.', 'litespeed-cache'),
2263
+ __('With your help, we can provide the best WordPress caching solution.', 'litespeed-cache')
2264
+ );
2265
+
2266
+
2267
+ $buf = '<h3>' . __('LiteSpeed Cache Plugin Compatibility', 'litespeed-cache') . '</h3>'
2268
+ . '<h4>'
2269
+ . $compat_desc
2270
+ . '<br /><a href="https://wordpress.org/support/topic/known-supported-plugins?replies=1" rel="noopener noreferrer" target="_blank">'
2271
+ . __('Link Here', 'litespeed-cache') . '</a>'
2272
+ . '</h4>'
2273
+ . '<h4>'
2274
+ . __('This is a list of plugins that are confirmed to be compatible with LiteSpeed Cache Plugin:', 'litespeed-cache')
2275
+ . '</h4>'
2276
+ . '<ul>';
2277
+ foreach ($known_compat as $plugin_name) {
2278
+ $buf .= '<li>' . $plugin_name . '</li>';
2279
+ }
2280
+ $buf .= '</ul><br><br>'
2281
+ . '<h4>' . __('This is a list of known UNSUPPORTED plugins:', 'litespeed-cache') . '</h4>'
2282
+ . '<ul>';
2283
+ foreach ($known_uncompat as $plugin_name) {
2284
+ $buf .= '<li>' . $plugin_name . '</li>';
2285
+ }
2286
+
2287
+ $buf .= '</ul><br><br>';
2288
+
2289
+ return $buf;
2290
+ }
2291
+
2292
+ /**
2293
+ * Builds the html for the admin ip tab.
2294
+ *
2295
+ * @since 1.0.7
2296
+ * @access private
2297
+ * @return string The html for the admin ip tab.
2298
+ */
2299
+ private function show_info_admin_ip()
2300
+ {
2301
+ $nocache_desc = self::build_paragraph(
2302
+ __('This is used to display a page without caching it.', 'litespeed-cache'),
2303
+ __('An example use case is to compare a cached version of a page with an uncached version.', 'litespeed-cache')
2304
+ );
2305
+ $purge_desc = self::build_paragraph(
2306
+ __('This is used to purge most cache tags associated with the page.', 'litespeed-cache'),
2307
+ __('The lone exception is the blog ID tag.', 'litespeed-cache'),
2308
+ __('Note that this means that pages with the same cache tag will be purged as well.', 'litespeed-cache')
2309
+ );
2310
+ $showheaders_desc = self::build_paragraph(
2311
+ __('This is used to show all the cache headers associated with a page.', 'litespeed-cache'),
2312
+ __('This may be useful for debugging purposes.', 'litespeed-cache')
2313
+ );
2314
+ $buf = '<h3>'
2315
+ . __('Admin IP Query String Actions', 'litespeed-cache') . '</h3>';
2316
+
2317
+ $buf .= '<h4>'
2318
+ . __('The following commands are available to the admin and do not require log-in, providing quick access to actions on the various pages.', 'litespeed-cache')
2319
+ . '</h4>';
2320
+
2321
+ $buf .= '<h4>' . __('Action List:', 'litespeed-cache') . '</h4>';
2322
+ $buf .=
2323
+ self::build_list(
2324
+ array(
2325
+ 'NOCACHE - ' . $nocache_desc,
2326
+ 'PURGE - ' . $purge_desc,
2327
+ 'PURGEALL - '
2328
+ . __('This is used to purge all entries in the cache.', 'litespeed-cache'),
2329
+ 'PURGESINGLE - '
2330
+ . __('This is used to purge the first cache tag associated with the page.', 'litespeed-cache'),
2331
+ 'SHOWHEADERS - ' . $showheaders_desc
2332
+ )
2333
+ );
2334
+
2335
+ $buf .= '<h5>'
2336
+ . sprintf(__('To trigger the action for a page, access the page with the query string %s', 'litespeed-cache'),
2337
+ '<code>?LSCWP_CTRL=ACTION</code>')
2338
+ . '</h5>';
2339
+
2340
+ return $buf;
2341
+ }
2342
+
2343
+ /**
2344
+ * Builds the html for the common rewrite rules tab.
2345
+ *
2346
+ * @since 1.0.4
2347
+ * @access private
2348
+ * @return string The html for the common rewrites tab.
2349
+ */
2350
+ private function show_info_common_rewrite()
2351
+ {
2352
+ $mv_header = __('Mobile Views:', 'litespeed-cache');
2353
+ $mv_desc =
2354
+ self::build_paragraph(
2355
+ __('Some sites have adaptive views, meaning the page sent will adapt to the browser type (desktop vs mobile).', 'litespeed-cache'),
2356
+ __('This rewrite rule is used for sites that load a different page for each type.', 'litespeed-cache')
2357
+ )
2358
+ . '<br>'
2359
+ . __('This configuration can be added on the settings page in the General tab.', 'litespeed-cache');
2360
+ $mv_example = 'RewriteCond %{HTTP_USER_AGENT} Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi [NC]
2361
+ RewriteRule .* - [E=Cache-Control:vary=ismobile]';
2362
+
2363
+
2364
+ $cookie_header = __('Do Not Cache Cookies:', 'litespeed-cache');
2365
+ $cookie_desc =
2366
+ __('Another common rewrite rule is to notify the cache not to cache when it sees a specified cookie name.', 'litespeed-cache')
2367
+ . '<br>'
2368
+ . __('This configuration can be added on the settings page in the Do Not Cache tab.', 'litespeed-cache');
2369
+ $cookie_example = 'RewriteCond %{HTTP_COOKIE} dontcachecookie
2370
+ RewriteRule .* - [E=Cache-Control:no-cache]';
2371
+
2372
+
2373
+ $ua_header = __('Do Not Cache User Agent:', 'litespeed-cache');
2374
+ $ua_desc =
2375
+ __('A not so commonly used rewrite rule is to notify the cache not to cache when it sees a specified User Agent.', 'litespeed-cache')
2376
+ . '<br>'
2377
+ . __('This configuration can be added on the settings page in the Do Not Cache tab.', 'litespeed-cache');
2378
+ $ua_example = 'RewriteCond %{HTTP_USER_AGENT} dontcacheuseragent
2379
+ RewriteRule .* - [E=Cache-Control:no-cache]';
2380
+
2381
+
2382
+ $notice_buf = '';
2383
+
2384
+ if ((is_multisite()) && (!is_network_admin())) {
2385
+
2386
+ $notice_buf = __('<b>NOTE:</b>', 'litespeed-cache')
2387
+ . __('The following configurations can only be changed by the network admin.', 'litespeed-cache')
2388
+ . '<br>'
2389
+ . __('Please contact the network admin to make any changes.', 'litespeed-cache');
2390
+ }
2391
+ else {
2392
+ $notice_buf = __('<b>NOTICE:</b>', 'litespeed-cache')
2393
+ . __('The following rewrite rules can be configured in the LiteSpeed Cache settings page.', 'litespeed-cache')
2394
+ . self::build_paragraph(
2395
+ __('Please make any needed changes on that page.', 'litespeed-cache'),
2396
+ __('It will automatically generate the correct rules in the htaccess file.', 'litespeed-cache')
2397
+ );
2398
+
2399
+ }
2400
+
2401
+ // begin buffer
2402
+ $buf = '';
2403
+ $page = ($_GET['page']) ? $_GET['page'] : '';
2404
+ if ($page == 'lscache-info') {
2405
+ $buf = '<div class="litespeed-cache-advanced-settings">';
2406
+ }
2407
+
2408
+ $buf .= self::build_tip(
2409
+ $notice_buf,
2410
+ '-clear-all',
2411
+ 'position: relative; cursor: help; margin-right: 10px; top: 2px; font-size: 25px;',
2412
+ 'z-index: 9999 !important;'
2413
+ );
2414
+ $buf .= '<h3 class="title" style="display: inline-block;">'
2415
+ . __('LiteSpeed Cache Common Rewrite Rules', 'litespeed-cache') . '</h3><br>';
2416
+
2417
+ if ($page == 'lscache-edit-htaccess') {
2418
+ $buf .= self::build_expand_collapse();
2419
+ }
2420
+ else {
2421
+ $buf .= self::build_expand_collapse(false);
2422
+ }
2423
+
2424
+ $buf .= $this->input_collapsible_start();
2425
+ $buf .= $this->input_field_collapsible($mv_header, $mv_desc, $mv_example);
2426
+ $buf .= $this->input_field_collapsible($cookie_header, $cookie_desc, $cookie_example);
2427
+ $buf .= $this->input_field_collapsible($ua_header, $ua_desc, $ua_example);
2428
+ $buf .= $this->input_collapsible_end();
2429
+ if ($page == 'lscache-info') {
2430
+ $buf .= '</div>';
2431
+ }
2432
+
2433
+ return $buf;
2434
+ }
2435
+
2436
+ /**
2437
+ * Builds the html for the faqs tab.
2438
+ *
2439
+ * @since 1.0.4
2440
+ * @access private
2441
+ * @return string The html for the faqs tab.
2442
+ */
2443
+ private function show_info_faqs()
2444
+ {
2445
+ $plugin_free_answer = self::build_paragraph(
2446
+ __('Yes, the plugin itself will remain free and open source.', 'litespeed-cache'),
2447
+ __('That said, a LiteSpeed server is required (see question 2)', 'litespeed-cache')
2448
+ );
2449
+
2450
+ $plugin_free_question = __('Is the LiteSpeed Cache Plugin for WordPress free?', 'litespeed-cache');
2451
+
2452
+ $server_software_answer =
2453
+ __('A LiteSpeed server is required in order to use this plugin.', 'litespeed-cache')
2454
+ . '<ol><li>LiteSpeed Web Server Enterprise with LSCache Module (v5.0.10+)</li>'
2455
+ . '<li>OpenLiteSpeed (v1.4.17+)</li>'
2456
+ . '<li>LiteSpeed WebADC (v2.0+)</li></ol>'
2457
+ . __('Any single server or cluster including a LiteSpeed server will work.', 'litespeed-cache');
2458
+
2459
+ $server_software_question = __('What server software is required for this plugin?', 'litespeed-cache');
2460
+
2461
+ $cluster_answer = self::build_paragraph(
2462
+ __('The cache entries are stored at the litespeed server level.', 'litespeed-cache'),
2463
+ __('The simplest solution is to use LiteSpeed WebADC, as the cache entries will be cached at that level.', 'litespeed-cache')
2464
+ )
2465
+ . '<br>'
2466
+ . self::build_paragraph(
2467
+ __('If using another load balancer, the cache entries will only be stored at the backend nodes, not at the load balancer.', 'litespeed-cache'),
2468
+ __('The purges will also not be synchronized across the nodes, so this is not recommended.', 'litespeed-cache')
2469
+ )
2470
+ . '<br>'
2471
+ . sprintf(__('If a customized solution is required, please contact %s at %s', 'litespeed-cache'),
2472
+ 'LiteSpeed Technologies', 'info@litespeedtech.com')
2473
+ . '<br>'
2474
+ . __('NOTICE: The rewrite rules created by this plugin must be copied to the WebADC', 'litespeed-cache');
2475
+
2476
+
2477
+ $cluster_question = __('Does this plugin work in a clustered environment?', 'litespeed-cache');
2478
+
2479
+
2480
+ $files_answer = self::build_paragraph(
2481
+ __('The actual cached pages are stored and managed by LiteSpeed Servers. Nothing is stored on the PHP side.', 'litespeed-cache')
2482
+ );
2483
+
2484
+ $files_question = __('Where are the cache entries stored?', 'litespeed-cache');
2485
+
2486
+
2487
+ $wc_themes = self::build_paragraph(
2488
+ __('Some themes like Storefront and Shop Isle are built such that the cart works without the rule.', 'litespeed-cache'),
2489
+ __('However, other themes like the E-Commerce theme, do not, so please verify the theme used.', 'litespeed-cache')
2490
+ );
2491
+
2492
+ $wc_answer = self::build_paragraph(
2493
+ __('In short, yes.', 'litespeed-cache'),
2494
+ __('However, for some woocommerce themes, the cart may not be updated correctly.', 'litespeed-cache')
2495
+ );
2496
+
2497
+ $wc_answer .= '<p><b>' . __('To test the cart:', 'litespeed-cache')
2498
+ . '</b></p>'
2499
+ . self::build_list(
2500
+ array(
2501
+ __('On a non-logged-in browser, visit and cache a page, then visit and cache a product page.', 'litespeed-cache'),
2502
+ __('The first page should be accessible from the product page (e.g. the shop).', 'litespeed-cache'),
2503
+ __('Once both pages are confirmed cached, add the product to the cart.', 'litespeed-cache'),
2504
+ __('After adding to the cart, visit the first page.', 'litespeed-cache'),
2505
+ __('The page should still be cached, and the cart should be up to date.', 'litespeed-cache'),
2506
+ __('If that is not the case, please add woocommerce_items_in_cart to the do not cache cookie list.', 'litespeed-cache')
2507
+ )
2508
+ )
2509
+ . '<p>' . $wc_themes . '</p>';
2510
+
2511
+ $wc_question = __('Is WooCommerce supported?', 'litespeed-cache');
2512
+
2513
+ $postviews_answer =
2514
+ self::build_list(
2515
+ array(
2516
+ sprintf(__('Use %1$s to replace %2$s', 'litespeed-cache'),
2517
+ '<code>&lt;div id="postviews_lscwp"&gt;&lt;/div&gt;</code>',
2518
+ '<code>&lt;?php if(function_exists(\'the_views\')) { the_views(); } ?&gt;</code>')
2519
+ . '<ul><li>'
2520
+ . __('NOTE: The id can be changed, but the div id and the ajax function must match.', 'litespeed-cache')
2521
+ . '</li></ul>',
2522
+ sprintf(__('Replace the ajax query in %1$s with %2$s', 'litespeed-cache'),
2523
+ '<code>wp-content/plugins/wp-postviews/postviews-cache.js</code>',
2524
+ '<textarea id="wpwrap" rows="11" readonly>jQuery.ajax({
2525
+ type:"GET",
2526
+ url:viewsCacheL10n.admin_ajax_url,
2527
+ data:"postviews_id="+viewsCacheL10n.post_id+"&amp;action=postviews",
2528
+ cache:!1,
2529
+ success:function(data) {
2530
+ if(data) {
2531
+ jQuery(\'#postviews_lscwp\').html(data+\' views\');
2532
+ }
2533
+ }
2534
+ });</textarea>'),
2535
+ __('Purge the cache to use the updated pages.', 'litespeed-cache')
2536
+ ),
2537
+ true
2538
+ );
2539
+
2540
+ $postviews_question =
2541
+ __('How do I get WP-PostViews to display an updating view count?', 'litespeed-cache');
2542
+
2543
+ $img_answer = self::build_paragraph(
2544
+ __('The cache plugin does not do anything with the images themselves.', 'litespeed-cache'),
2545
+ sprintf(__('We recommend you trying an image optimization plugin like %s to optimize your images.', 'litespeed-cache'),
2546
+ '<a href="https://shortpixel.com/h/af/CXNO4OI28044" rel="friend noopener noreferer" target="_blank">ShortPixel</a>'),
2547
+ __("It can reduce your site's images up to 90%.", 'litespeed-cache')
2548
+ );
2549
+
2550
+ $img_question = __('Are my images optimized?', 'litespeed-cache');
2551
+
2552
+ $style = 'style="border:none; box-shadow:none;"';
2553
+ $buf = '<div class="wrap"><h3>LiteSpeed Cache FAQs</h3>';
2554
+ $buf .= '<div class="litespeed-cache-welcome-panel" ' . $style . '>';
2555
+ $buf .= self::build_expand_collapse();
2556
+ $buf .= $this->input_collapsible_start();
2557
+ $buf .= $this->input_field_collapsible($plugin_free_question, $plugin_free_answer);
2558
+ $buf .= $this->input_field_collapsible($server_software_question, $server_software_answer);
2559
+ $buf .= $this->input_field_collapsible($cluster_question, $cluster_answer);
2560
+ $buf .= $this->input_field_collapsible($files_question, $files_answer);
2561
+ $buf .= $this->input_field_collapsible($wc_question, $wc_answer);
2562
+ $buf .= $this->input_field_collapsible($img_question, $img_answer);
2563
+ $buf .= $this->input_field_collapsible($postviews_question, $postviews_answer);
2564
+ $buf .= '</ul>';
2565
+ $buf .= $this->input_collapsible_end();
2566
+ $buf .= '</div>';
2567
+ $buf .= '</div>';
2568
+
2569
+ return $buf;
2570
+ }
2571
+
2572
+ /**
2573
+ * Outputs a notice to the admin panel when the plugin is installed
2574
+ * via the WHM plugin.
2575
+ *
2576
+ * @since 1.0.12
2577
+ * @access public
2578
+ */
2579
+ public function show_display_installed()
2580
+ {
2581
+ $buf = self::build_paragraph(
2582
+ '<h3>'
2583
+ . __('LiteSpeed Cache plugin is installed!', 'litespeed-cache')
2584
+ . '</h3>',
2585
+ __('This message indicates that the plugin was installed by the server admin.', 'litespeed-cache'),
2586
+ __('The LiteSpeed Cache plugin is used to cache pages - a simple way to improve the performance of the site.', 'litespeed-cache'),
2587
+ __('However, there is no way of knowing all the possible customizations that were implemented.', 'litespeed-cache'),
2588
+ __('For that reason, please test the site to make sure everything still functions properly.', 'litespeed-cache')
2589
+ );
2590
+ $buf .= '<br><br>'
2591
+ . __('Examples of test cases include:', 'litespeed-cache')
2592
+ . self::build_list(array(
2593
+ __('Visit the site while logged out.', 'litespeed-cache'),
2594
+ __('Create a post, make sure the front page is accurate.', 'litespeed-cache')
2595
+ ));
2596
+
2597
+ $buf .=
2598
+ sprintf(wp_kses(
2599
+ __('If there are any questions, the team is always happy to answer any questions on the <a href="%s" rel="%s" target="%s">support forum</a>.',
2600
+ 'litespeed-cache'),
2601
+ array(
2602
+ 'a' => array(
2603
+ 'href' => array(), 'rel' => array(),
2604
+ 'target' => array(),
2605
+ ),
2606
+ )),
2607
+ 'https://wordpress.org/support/plugin/litespeed-cache',
2608
+ 'noopener noreferrer', '_blank');
2609
+ $buf .= '<br>'
2610
+ . __('If you would rather not move at litespeed, you can deactivate this plugin.',
2611
+ 'litespeed-cache');
2612
+
2613
+
2614
+ $this->add_notice(self::NOTICE_BLUE . ' lscwp-whm-notice', $buf);
2615
+ }
2616
+
2617
+ public static function show_error_cookie()
2618
+ {
2619
+ $err = self::build_paragraph(
2620
+ __('NOTICE: Database login cookie did not match your login cookie.', 'litespeed-cache'),
2621
+ __('If the login cookie was recently changed in the settings, please log out and back in.', 'litespeed-cache'),
2622
+ sprintf(wp_kses(__('If not, please verify the setting in the <a href="%1$s">Advanced tab</a>.', 'litespeed-cache'),
2623
+ array(
2624
+ 'a' => array(
2625
+ 'href' => array()
2626
+ )
2627
+ )),
2628
+ admin_url('admin.php?page=lscache-settings&tab=4')
2629
+ )
2630
+ );
2631
+ if (is_openlitespeed()) {
2632
+ $err .= ' '
2633
+ . __('If using OpenLiteSpeed, the server must be restarted once for the changes to take effect.', 'litespeed-cache');
2634
+ }
2635
+ self::get_instance()->add_notice(self::NOTICE_YELLOW, $err);
2636
+ }
2637
+
2638
+ /**
2639
+ * Generates the HTMl to start a configuration options table.
2640
+ *
2641
+ * @since 1.0.0
2642
+ * @access private
2643
+ * @param string $title The title of the configuration group.
2644
+ * @param string $description The description of the configuration group.
2645
+ * @return string The start configuration option table html.
2646
+ */
2647
+ private function input_group_start($title = '', $description = '',
2648
+ $tooltip = '', $exclamation = '', $exclude_hr = false)
2649
+ {
2650
+ $buf = '';
2651
+ if (!empty($tooltip)) {
2652
+ $buf .= self::build_tip($tooltip);
2653
+ }
2654
+ if (!empty($exclamation)) {
2655
+ $buf .= self::build_tip($exclamation, '-clear-all',
2656
+ 'position: relative; cursor: help; margin-right: 10px; top: 2px; font-size: 25px; z-index:9999 !important;');
2657
+ }
2658
+ if (!empty($title)) {
2659
+ $buf .= '<h3 class="title">' . $title . "</h3>"
2660
+ . ($exclude_hr ? "\n" : '<hr>');
2661
+ }
2662
+ if (!empty($description)) {
2663
+ $buf .= '<p>' . $description . "</p>\n";
2664
+ }
2665
+ $buf .= '<div class="litespeed-cache-div-table>">';
2666
+ $buf .= '<table class="form-table">' . "\n";
2667
+
2668
+ return $buf;
2669
+ }
2670
+
2671
+ /**
2672
+ * Generates the HTML to end the configuration options table.
2673
+ *
2674
+ * @since 1.0.0
2675
+ * @access private
2676
+ * @return string The end table html.
2677
+ */
2678
+ private function input_group_end()
2679
+ {
2680
+ return "</table></div>\n";
2681
+ }
2682
+
2683
+ /**
2684
+ * Generates the HTML for an entry in the configuration options table.
2685
+ *
2686
+ * @since 1.0.0
2687
+ * @access private
2688
+ * @param string $label The option name.
2689
+ * @param string $input_field The option html.
2690
+ * @param string $notes The description to display under the option html.
2691
+ * @return string The config row html.
2692
+ */
2693
+ private function display_config_row($label, $input_field, $tooltip = '',
2694
+ $exclamation = '', $below = '')
2695
+ {
2696
+ $buf = '<tr><th scope="row">' . $label . '</th><td>';
2697
+
2698
+ if (!empty($tooltip)) {
2699
+ $buf .= self::build_tip($tooltip);
2700
+ }
2701
+ if (!empty($exclamation)) {
2702
+ $buf .= self::build_tip($exclamation, '-clear-all',
2703
+ '', 'z-index:9999 !important');
2704
+ }
2705
+ $buf .= $input_field;
2706
+ if (!empty($below)) {
2707
+ $buf .=
2708
+ '<br><span style="font-size: 11px; font-style:italic;padding-left:24px;display:inline-block;">'
2709
+ . $below . '</span>';
2710
+ }
2711
+ $buf .= '</td></tr>' . "\n";
2712
+
2713
+ return $buf;
2714
+ }
2715
+
2716
+ /**
2717
+ * Generates the HTML for a check box.
2718
+ *
2719
+ * @since 1.0.0
2720
+ * @access private
2721
+ * @param string $id The option ID for the field.
2722
+ * @param string $value The value for the field.
2723
+ * @param mixed $checked_value The current value.
2724
+ * @param string $label The label to display.
2725
+ * @param string $on_click The action to do on click.
2726
+ * @param boolean $disabled True for disabled check box, false otherwise.
2727
+ * @return string The check box html.
2728
+ */
2729
+ private function input_field_checkbox($id, $value, $checked_value,
2730
+ $label = '', $on_click = '', $disabled = false)
2731
+ {
2732
+ if ($this->get_disable_all()) {
2733
+ $disabled = true;
2734
+ }
2735
+ $buf = '<input name="'
2736
+ . LiteSpeed_Cache_Config::OPTION_NAME . '[' . $id
2737
+ . ']" type="checkbox" id="'
2738
+ . $id . '" value="' . $value . '"';
2739
+ if (($checked_value === $value) || (true === $checked_value)) {
2740
+ $buf .= ' checked="checked" ';
2741
+ }
2742
+ if ($on_click != '') {
2743
+ $buf .= 'onclick="' . $on_click . '"';
2744
+ }
2745
+ if ($disabled) {
2746
+ $buf .= ' disabled ';
2747
+ }
2748
+ $buf .= '/>';
2749
+ if ($label) {
2750
+ $buf .= '<label for="' . $id . '">' . $label . '</label>';
2751
+ }
2752
+
2753
+ return $buf;
2754
+ }
2755
+
2756
+ /**
2757
+ * Generates the HTML for a radio group.
2758
+ *
2759
+ * @since 1.0.3
2760
+ * @access private
2761
+ * @param string $id The option ID for the field.
2762
+ * @param array $radiooptions The options available for selection.
2763
+ * @param string $checked_value The currently selected option.
2764
+ * @return string The select field html.
2765
+ */
2766
+ private function input_field_radio($id, $radiooptions, $checked_value,
2767
+ $below_text = '')
2768
+ {
2769
+ $buf = '';
2770
+ foreach ($radiooptions as $val => $label) {
2771
+ $buf .= '<label>';
2772
+ $buf .= '<input name="' . LiteSpeed_Cache_Config::OPTION_NAME
2773
+ . '[' . $id . ']" type="radio" id="'
2774
+ . LiteSpeed_Cache_Config::OPTION_NAME . '[' . $label . ']" value="' . $val . '"';
2775
+ if (($checked_value === $val)) {
2776
+ $buf .= ' checked="checked"';
2777
+ }
2778
+ if ($this->get_disable_all()) {
2779
+ $buf .= ' disabled="true"';
2780
+ }
2781
+ $buf .= '><span>' . $label . '&nbsp;&nbsp;</span></label>';
2782
+ $buf .= '&nbsp;&nbsp;&nbsp;&nbsp;';
2783
+ }
2784
+ if ($below_text) {
2785
+ $buf .=
2786
+ '<br><span style="padding-left:24px; font-size: 11px;"><i>'
2787
+ . $below_text . '</i></span>';
2788
+ }
2789
+
2790
+ return $buf;
2791
+ }
2792
+
2793
+ /**
2794
+ * Generates the HTML for a drop down select.
2795
+ *
2796
+ * @since 1.0.0
2797
+ * @access private
2798
+ * @param string $id The option ID for the field.
2799
+ * @param array $seloptions The options available for selection.
2800
+ * @param string $selected_value The currently selected option.
2801
+ * @return string The select field html.
2802
+ */
2803
+ private function input_field_select($id, $seloptions, $selected_value)
2804
+ {
2805
+ $buf = '<select name="'
2806
+ . LiteSpeed_Cache_Config::OPTION_NAME . '[' . $id
2807
+ . ']" id="' . $id . '" ';
2808
+
2809
+ if ($this->get_disable_all()) {
2810
+ $buf .= 'disabled="true" ';
2811
+ }
2812
+
2813
+ $buf .= '>';
2814
+ foreach ($seloptions as $val => $label) {
2815
+ $buf .= '<option value="' . $val . '"';
2816
+ if ($selected_value == $val) {
2817
+ $buf .= ' selected="selected"';
2818
+ }
2819
+ $buf .= '>' . $label . '</option>';
2820
+ }
2821
+ $buf .= '</select>';
2822
+
2823
+ return $buf;
2824
+ }
2825
+
2826
+ /**
2827
+ * Generates the HTML for a text input field.
2828
+ *
2829
+ * @since 1.0.0
2830
+ * @access private
2831
+ * @param string $id The option ID for the field.
2832
+ * @param string $value The value for the field.
2833
+ * @param string $size The length to display.
2834
+ * @param string $style The class to format the display.
2835
+ * @param string $after The units to display after the text field.
2836
+ * @param boolean $readonly True for read only text fields, false otherwise.
2837
+ * @return string The input text html.
2838
+ */
2839
+ private function input_field_text($id, $value, $size = '', $style = '',
2840
+ $after = '', $readonly = false)
2841
+ {
2842
+ if ($this->get_disable_all()) {
2843
+ $readonly = true;
2844
+ }
2845
+ $buf = '<input name="' . LiteSpeed_Cache_Config::OPTION_NAME . '[' . $id . ']" type="text" id="'
2846
+ . $id . '" value="' . esc_textarea($value) . '"';
2847
+ if ($size) {
2848
+ $buf .= ' size="' . $size . '"';
2849
+ }
2850
+ if ($style) {
2851
+ $buf .= ' class="' . $style . '"';
2852
+ }
2853
+ if ($readonly) {
2854
+ $buf .= ' readonly';
2855
+ }
2856
+ $buf .= '/>';
2857
+ if ($after) {
2858
+ $buf .= ' ' . $after;
2859
+ }
2860
+
2861
+ return $buf;
2862
+ }
2863
+
2864
+ /**
2865
+ * Generates the HTML for a textarea.
2866
+ *
2867
+ * @since 1.0.1
2868
+ * @access private
2869
+ * @param string $id The option ID for the field.
2870
+ * @param string $value The value for the field.
2871
+ * @param string $rows Number of rows to display.
2872
+ * @param string $cols Number of columns to display.
2873
+ * @param string $style The class to format the display.
2874
+ * @param boolean $readonly True for read only text areas, false otherwise.
2875
+ * @return string The textarea html.
2876
+ */
2877
+ private function input_field_textarea($id, $value, $rows = '', $cols = '',
2878
+ $style = '', $readonly = false)
2879
+ {
2880
+ if ($this->get_disable_all()) {
2881
+ $readonly = true;
2882
+ }
2883
+ $buf = '<textarea name="' . LiteSpeed_Cache_Config::OPTION_NAME . '[' . $id . ']" type="text"
2884
+ id="' . $id . '"';
2885
+ if ($rows) {
2886
+ $buf .= ' rows="' . $rows . '"';
2887
+ }
2888
+ if ($cols) {
2889
+ $buf .= ' cols="' . $cols . '"';
2890
+ }
2891
+ if ($style) {
2892
+ $buf .= ' class="' . $style . '"';
2893
+ }
2894
+ if ($readonly) {
2895
+ $buf .= ' readonly ';
2896
+ }
2897
+ $buf .= '>' . esc_textarea($value) . '</textarea>';
2898
+
2899
+ return $buf;
2900
+ }
2901
+
2902
+ /**
2903
+ * Generates the HTML for a hidden input field.
2904
+ *
2905
+ * @since 1.0.4
2906
+ * @access private
2907
+ * @param string $id The option ID for the field.
2908
+ * @param string $value The value for the field.
2909
+ * @return string The hidden field html.
2910
+ */
2911
+ private function input_field_hidden($id, $value)
2912
+ {
2913
+ $buf = '<input name="' . LiteSpeed_Cache_Config::OPTION_NAME . '[' . $id . ']" type="hidden" id="'
2914
+ . $id . '" value="' . esc_html($value) . '"';
2915
+ $buf .= '/>';
2916
+
2917
+ return $buf;
2918
+ }
2919
+
2920
+ /**
2921
+ * Generates the HTMl to start a collapsible group.
2922
+ *
2923
+ * @since 1.0.7
2924
+ * @access private
2925
+ * @return string The start collapsible group html.
2926
+ */
2927
+ private function input_collapsible_start()
2928
+ {
2929
+ return '<div class="metabox-holder">'
2930
+ . '<div class="meta-box-sortables ui-sortable">';
2931
+ }
2932
+
2933
+ /**
2934
+ * Generates the HTMl to end the collapsible group.
2935
+ *
2936
+ * @since 1.0.7
2937
+ * @access private
2938
+ * @return string The end collapsible group html.
2939
+ */
2940
+ private function input_collapsible_end()
2941
+ {
2942
+ return '</div></div>';
2943
+ }
2944
+
2945
+ /**
2946
+ * Helper function to build the html for collapsible content.
2947
+ *
2948
+ * @since 1.0.5
2949
+ * @access private
2950
+ * @param string $header The title of the collapsible content.
2951
+ * @param string $desc A description inside the collapsible content.
2952
+ * @param string $example An example to display after the description.
2953
+ * @return string The html of the collapsible content.
2954
+ */
2955
+ private function input_field_collapsible($header, $desc, $example = '')
2956
+ {
2957
+ $buf = '<div class="postbox closed">'
2958
+ . '<button type="button" class="handlediv button-link litespeedcache-postbox-button" aria-expanded="">'
2959
+ . '<span class="toggle-indicator" aria-hidden="true"></span></button>'
2960
+ . '<h2 class="hndle ui-sortable-handle"><span>' . $header . '</span></h2>';
2961
+
2962
+
2963
+ $buf .= '<div class="welcome-panel-content"><div class="inside"><p>'
2964
+ . $desc . '</p>';
2965
+
2966
+ if ($example !== '') {
2967
+ $buf .= '<textarea id="wpwrap" readonly>' . $example . '</textarea>';
2968
+ }
2969
+ $buf .= '</div></div></div>';
2970
+
2971
+ return $buf;
2972
+ }
2973
+
2974
+ }
admin/class-litespeed-cache-admin-error.php ADDED
@@ -0,0 +1,368 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ /**
6
+ * The admin errors
7
+ *
8
+ *
9
+ * @since 1.0.15
10
+ * @package LiteSpeed_Cache
11
+ * @subpackage LiteSpeed_Cache/admin
12
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
13
+ */
14
+ class LiteSpeed_Cache_Admin_Error
15
+ {
16
+ private static $instance;
17
+
18
+ const NOTICE_BLUE = 'notice notice-info';
19
+ const NOTICE_GREEN = 'notice notice-success';
20
+ const NOTICE_RED = 'notice notice-error';
21
+ const NOTICE_YELLOW = 'notice notice-warning';
22
+ const E_PHP_VER = 1000;
23
+ const E_WP_VER = 1010;
24
+
25
+ const E_PURGE_FORM = 2000;
26
+ const E_PURGEBY_EMPTY = 2010;
27
+ const E_PURGEBY_BAD = 2020;
28
+ const E_PURGEBY_CAT_INV = 2030;
29
+ const E_PURGEBY_TAG_INV = 2040;
30
+ const E_PURGEBY_URL_BAD = 2050;
31
+
32
+ const E_PURGEBY_PID_NUM = 2500;
33
+ const E_PURGEBY_PID_DNE = 2510;
34
+ const E_PURGEBY_URL_INV = 2520;
35
+ const E_PURGEBY_CAT_DNE = 2530;
36
+ const E_PURGEBY_TAG_DNE = 2540;
37
+
38
+ const E_SETTING_ADMIN_IP_INV = 3000;
39
+ const E_SETTING_TEST_IP_INV = 3010;
40
+
41
+ const E_SETTING_TTL = 3500;
42
+ const E_SETTING_CAT = 3510;
43
+ const E_SETTING_TAG = 3520;
44
+ const E_SETTING_LC = 3530; // login cookie setting
45
+ const E_SETTING_REWRITE = 3540;
46
+
47
+ const E_LC_HTA = 4000; // login cookie .htaccess not correct
48
+
49
+ const E_HTA_DNF = 4500; // .htaccess did not find.
50
+
51
+ const E_LC_MISMATCH = 5000; // login cookie mismatch
52
+
53
+ const E_SERVER = 6000;
54
+
55
+ const E_CONF = 9000; // general config failed to write.
56
+ const E_HTA_BU = 9010; // backup
57
+ const E_HTA_PUT = 9020; // failed to put
58
+ const E_HTA_GET = 9030; // failed to get
59
+ const E_HTA_RW = 9040; // read write
60
+ const E_HTA_ORDER = 9050; // prefix found after suffix
61
+ const E_HTA_SAVE = 9060;
62
+ const E_CONF_WRITE = 9070;
63
+ const E_CONF_FIND = 9080;
64
+
65
+ private $notices = array();
66
+
67
+ /**
68
+ * Initialize the class and set its properties.
69
+ *
70
+ * @since 1.0.15
71
+ * @access private
72
+ */
73
+ private function __construct()
74
+ {
75
+ }
76
+
77
+ /**
78
+ * Get the LiteSpeed_Cache_Admin_Error object.
79
+ *
80
+ * @since 1.0.15
81
+ * @access public
82
+ * @return LiteSpeed_Cache_Admin_Error Static instance of the
83
+ * LiteSpeed_Cache_Admin_Error class.
84
+ */
85
+ public static function get_instance()
86
+ {
87
+ if (!isset(self::$instance)) {
88
+ self::$instance = new LiteSpeed_Cache_Admin_Error();
89
+ }
90
+
91
+ return self::$instance;
92
+ }
93
+
94
+ /**
95
+ * Get the error message by code.
96
+ *
97
+ * @access private
98
+ * @since 1.0.15
99
+ * @param int $err_code The error code to retrieve.
100
+ * @return string The error message if matching, else an empty string.
101
+ */
102
+ private function _get($err_code)
103
+ {
104
+
105
+ switch ($err_code)
106
+ {
107
+ case self::E_PHP_VER:
108
+ return '<strong>'
109
+ . __('The installed PHP version is too old for the LiteSpeed Cache Plugin.', 'litespeed-cache')
110
+ . '</strong><br /> '
111
+ . sprintf(__('The LiteSpeed Cache Plugin requires at least PHP %s.', 'litespeed-cache'), '5.3')
112
+ . ' '
113
+ . sprintf(__('The currently installed version is PHP %s, which is out-dated and insecure.', 'litespeed-cache'), PHP_VERSION)
114
+ . ' '
115
+ . sprintf(wp_kses(__('Please upgrade or go to <a href="%s">active plugins</a> and deactivate the LiteSpeed Cache plugin to hide this message.', 'litespeed-cache'),
116
+ array('a' => array('href' => array()))), 'plugins.php?plugin_status=active');
117
+ case self::E_WP_VER:
118
+ return '<strong>'
119
+ . __('The installed WordPress version is too old for the LiteSpeed Cache Plugin.', 'litespeed-cache')
120
+ . '</strong><br />'
121
+ . sprintf(__('The LiteSpeed Cache Plugin requires at least WordPress %s.', 'litespeed-cache'), '3.3')
122
+ . ' '
123
+ . sprintf(wp_kses(__('Please upgrade or go to <a href="%s">active plugins</a> and deactivate the LiteSpeed Cache plugin to hide this message.', 'litespeed-cache'),
124
+ array('a' => array('href' => array()))), 'plugins.php?plugin_status=active');
125
+ // Admin action errors.
126
+ case self::E_PURGE_FORM:
127
+ return __('Something went wrong with the form! Please try again.', 'litespeed-cache');
128
+ case self::E_PURGEBY_EMPTY:
129
+ return __('Tried to purge list with empty list.', 'litespeed-cache');
130
+ case self::E_PURGEBY_BAD:
131
+ return __('Bad Purge By selected value.', 'litespeed-cache');
132
+ case self::E_PURGEBY_CAT_INV:
133
+ return __('Failed to purge by category, invalid category slug.', 'litespeed-cache');
134
+ case self::E_PURGEBY_TAG_INV:
135
+ return __('Failed to purge by tag, invalid tag slug.', 'litespeed-cache');
136
+ case self::E_PURGEBY_URL_BAD:
137
+ return __('Failed to purge by url, contained "<".', 'litespeed-cache');
138
+
139
+ // Admin actions with expected parameters for message.
140
+ case self::E_PURGEBY_PID_NUM:
141
+ return __('Failed to purge by Post ID, given ID is not numeric: %s', 'litespeed-cache');
142
+ case self::E_PURGEBY_PID_DNE:
143
+ return __('Failed to purge by Post ID, given ID does not exist or is not published: %s',
144
+ 'litespeed-cache');
145
+ case self::E_PURGEBY_URL_INV:
146
+ return __('Failed to purge by url, invalid input: %s.', 'litespeed-cache');
147
+ case self::E_PURGEBY_CAT_DNE:
148
+ return __('Failed to purge by category, does not exist: %s', 'litespeed-cache');
149
+ case self::E_PURGEBY_TAG_DNE:
150
+ return __('Failed to purge by tag, does not exist: %s', 'litespeed-cache');
151
+
152
+ // Admin settings errors.
153
+ case self::E_SETTING_ADMIN_IP_INV:
154
+ return __('Invalid data in Admin IPs.', 'litespeed-cache');
155
+ case self::E_SETTING_TEST_IP_INV:
156
+ return __('Invalid data in Test IPs.', 'litespeed-cache');
157
+
158
+ // Admin settings with expected parameters for message.
159
+ case self::E_SETTING_TTL:
160
+ // %1 is the name of the TTL, %2 is the minimum integer allowed.
161
+ return __('%1$s TTL must be an integer between %2$d and 2147483647',
162
+ 'litespeed-cache');
163
+ case self::E_SETTING_CAT:
164
+ // %s is the category attempted to be added.
165
+ return __('Removed category "%s" from list, ID does not exist.',
166
+ 'litespeed-cache');
167
+ case self::E_SETTING_TAG:
168
+ // %s is the tag attempted to be added.
169
+ return __('Removed tag "%s" from list, ID does not exist.',
170
+ 'litespeed-cache');
171
+ case self::E_SETTING_LC:
172
+ return __('Invalid login cookie. Invalid characters found: %s',
173
+ 'litespeed-cache');
174
+ case self::E_SETTING_REWRITE:
175
+ return LiteSpeed_Cache_Admin_Display::build_paragraph(
176
+ __('Invalid Rewrite List.', 'litespeed-cache'),
177
+ __('Empty or invalid rule.', 'litespeed-cache'),
178
+ __('Rule: %1$s, list: %2$s', 'litespeed-cache')
179
+ );
180
+ // Login cookie in settings did not match .htaccess.
181
+ case self::E_LC_HTA:
182
+ return LiteSpeed_Cache_Admin_Display::build_paragraph(
183
+ __('Tried to parse for existing login cookie.', 'litespeed-cache'),
184
+ sprintf(__('%s file not valid. Please verify contents.',
185
+ 'litespeed-cache'), '.htaccess')
186
+ );
187
+
188
+ // Could not find something in the .htaccess file. Expect parameter.
189
+ case self::E_HTA_DNF:
190
+ return __('Could not find %s.', 'litespeed-cache');
191
+
192
+ // Mismatched login cookie.
193
+ case self::E_LC_MISMATCH:
194
+ return LiteSpeed_Cache_Admin_Display::build_paragraph(
195
+ __('This site is a subdirectory install.', 'litespeed-cache'),
196
+ __('Login cookies do not match.', 'litespeed-cache'),
197
+ __('Please remove both and set the login cookie in LiteSpeed Cache advanced settings.',
198
+ 'litespeed-cache'));
199
+
200
+ // Either running another server or doesn't have cache module.
201
+ case self::E_SERVER:
202
+ return LiteSpeed_Cache_Admin_Display::build_paragraph(
203
+ __('Notice: This plugin requires a LiteSpeed Server with the LSCache Module enabled.', 'litespeed-cache'),
204
+ __('If you are unable to change your server stack, please contact your hosting provider to request the required changes.', 'litespeed-cache'),
205
+ __('This plugin will NOT work properly.', 'litespeed-cache')
206
+ );
207
+ case self::E_CONF:
208
+ return LiteSpeed_Cache_Admin_Display::build_paragraph(
209
+ __('LiteSpeed Cache was unable to write to the wp-config.php file.', 'litespeed-cache'),
210
+ sprintf(__('Please add the following to the wp-config.php file: %s', 'litespeed-cache'),
211
+ '<br><pre>define(\'WP_CACHE\', true);</pre>')
212
+ );
213
+
214
+ // .htaccess problem.
215
+ case self::E_HTA_BU:
216
+ return __('Failed to back up file, aborted changes.', 'litespeed-cache');
217
+ case self::E_HTA_PUT:
218
+ return sprintf(__('Failed to put contents into %s', 'litespeed-cache'),
219
+ '.htaccess');
220
+ case self::E_HTA_GET:
221
+ return sprintf(__('Failed to get %s file contents.', 'litespeed-cache'),
222
+ '.htaccess');
223
+ case self::E_HTA_RW:
224
+ return sprintf(__('%s file not readable or not writable.', 'litespeed-cache'),
225
+ '.htaccess');
226
+ case self::E_HTA_ORDER:
227
+ return __('Prefix was found after suffix.', 'litespeed-cache');
228
+ case self::E_HTA_SAVE:
229
+ return sprintf(__('Failed to overwrite %s.', 'litespeed-cache'),
230
+ '.htaccess');
231
+
232
+
233
+ // wp-config problem.
234
+ case self::E_CONF_WRITE:
235
+ $err = sprintf(__('The %1$s file not writeable for %2$s', 'litespeed-cache'),
236
+ 'wp-config', '\'WP_CACHE\'');
237
+ break;
238
+ case self::E_CONF_FIND:
239
+ $err = sprintf(__('%s file did not find a place to insert define.', 'litespeed-cache'),
240
+ 'wp-config');
241
+ break;
242
+ default:
243
+ return '';
244
+ }
245
+
246
+ return $err . '<br>'
247
+ . LiteSpeed_Cache_Admin_Display::build_paragraph(
248
+ __('LiteSpeed Cache was unable to write to the wp-config.php file.', 'litespeed-cache'),
249
+ sprintf(__('Please add the following to the wp-config.php file: %s', 'litespeed-cache'),
250
+ '<br><pre>define(\'WP_CACHE\', true);</pre>')
251
+ );
252
+ }
253
+
254
+ /**
255
+ * Prefix the error message with the error code.
256
+ *
257
+ * @access private
258
+ * @since 1.0.15
259
+ * @param string $error The error message.
260
+ * @param int $err_code The error code.
261
+ * @return string The prefixed error message.
262
+ */
263
+ private static function prefix_message($error, $err_code)
264
+ {
265
+ return 'ERROR ' . $err_code . ': ' . $error;
266
+ }
267
+
268
+ /**
269
+ * Gets an error message by error code.
270
+ *
271
+ * This function will validate if the error code passed in is numeric.
272
+ *
273
+ * @access public
274
+ * @since 1.0.15
275
+ * @param int $err_code The error code to retrieve.
276
+ * @return string The error message if valid, else empty string.
277
+ */
278
+ public static function get_error($err_code)
279
+ {
280
+ if (!is_numeric($err_code)) {
281
+ return '';
282
+ }
283
+ $error = self::get_instance()->_get($err_code);
284
+ if (empty($error)) {
285
+ return '';
286
+ }
287
+ return self::prefix_message($error, $err_code);
288
+ }
289
+
290
+ /**
291
+ * Builds an error message by error code.
292
+ *
293
+ * This function assumes that the error message retrieved expects
294
+ * arguments.
295
+ *
296
+ * @access public
297
+ * @since 1.0.15
298
+ * @param int $err_code The error code to retrieve.
299
+ * @param mixed $args An array if multiple arguments, else a single arg.
300
+ * @return string The built string on success, else empty string.
301
+ */
302
+ public static function build_error($err_code, $args)
303
+ {
304
+ if (!is_numeric($err_code)) {
305
+ return '';
306
+ }
307
+ $error = self::get_instance()->_get($err_code);
308
+ if (empty($error)) {
309
+ return '';
310
+ }
311
+ $error = self::prefix_message($error, $err_code);
312
+ if (is_array($args)) {
313
+ return vsprintf($error, $args);
314
+ }
315
+ return sprintf($error, $args);
316
+ }
317
+
318
+ /**
319
+ * Adds an error to the admin notice system.
320
+ *
321
+ * This function will get the error message by error code and arguments
322
+ * and append it to the list of outgoing errors.
323
+ *
324
+ * @access public
325
+ * @since 1.0.15
326
+ * @param int $err_code The error code to retrieve.
327
+ * @param mixed $args Null if no arguments, an array if multiple arguments,
328
+ * else a single argument.
329
+ */
330
+ public static function add_error($err_code, $args = null)
331
+ {
332
+ if (!is_null($args)) {
333
+ $error = self::build_error($err_code, $args);
334
+ }
335
+ else {
336
+ $error = self::get_error($err_code);
337
+ }
338
+ if (empty($error)) {
339
+ return;
340
+ }
341
+
342
+ $errors = self::get_instance();
343
+
344
+ if (empty($errors->notices)) {
345
+ add_action(
346
+ (is_network_admin() ? 'network_admin_notices' : 'admin_notices'),
347
+ array($errors, 'display_errors'));
348
+ }
349
+
350
+ $errors->notices[] =
351
+ '<div class="notice notice-error is-dismissible"><p>' . $error
352
+ . '</p></div>';
353
+ }
354
+
355
+ /**
356
+ * Hooked to the applicable notice display hook. Displays all error messages.
357
+ *
358
+ * @access public
359
+ * @since 1.0.15
360
+ */
361
+ public function display_errors()
362
+ {
363
+ foreach ($this->notices as $msg) {
364
+ echo $msg;
365
+ }
366
+ }
367
+
368
+ }
admin/class-litespeed-cache-admin-rules.php ADDED
@@ -0,0 +1,1520 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The admin-panel specific functionality of the plugin.
5
+ *
6
+ *
7
+ * @since 1.0.0
8
+ * @package LiteSpeed_Cache
9
+ * @subpackage LiteSpeed_Cache/admin
10
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
11
+ */
12
+ class LiteSpeed_Cache_Admin_Rules
13
+ {
14
+ private static $instance;
15
+
16
+ const EDITOR_INPUT_NAME = 'lscwp_htaccess_save';
17
+ const EDITOR_INPUT_VAL = 'save_htaccess';
18
+ const EDITOR_NONCE_NAME = 'lscwp_edit_htaccess';
19
+ const EDITOR_NONCE_VAL = 'save';
20
+ const EDITOR_TEXTAREA_NAME = 'lscwp_ht_editor';
21
+
22
+ const READABLE = 1;
23
+ const WRITABLE = 2;
24
+ const RW = 3; // Readable and writable.
25
+
26
+ private $filerw = null;
27
+ private $is_subdir_install = null;
28
+ private $home_path = null;
29
+ private $site_path = null;
30
+
31
+ private static $RW_BLOCK_START = '<IfModule LiteSpeed>';
32
+ private static $RW_BLOCK_END = '</IfModule>';
33
+ private static $RW_WRAPPER = 'PLUGIN - Do not edit the contents of this block!';
34
+ private static $RW_PREREQ = "\nRewriteEngine on\nCacheLookup Public on\n";
35
+
36
+ private static $RW_PATTERN_COND_START = '/RewriteCond\s%{';
37
+ private static $RW_PATTERN_COND_END = '}\s+([^[\n]*)\s+[[]*/';
38
+ private static $RW_PATTERN_RULE = '/RewriteRule\s+(\S+)\s+(\S+)(?:\s+\[E=([^\]\s]*)\])?/';
39
+ private static $RW_PATTERN_LOGIN = '/(RewriteRule\s+\.[\?\*]\s+-\s+\[E=Cache-Vary:([^\]\s]*)\])/';
40
+ private static $RW_PATTERN_LOGIN_BLOCK = '!(</?IfModule(?:\s+(LiteSpeed))?>)!';
41
+ private static $RW_PATTERN_UPGRADE_BLOCK = '!(<IfModule\s+LiteSpeed>[^<]*)(</IfModule>)!';
42
+ private static $RW_PATTERN_WRAPPERS = '/###LSCACHE START[^#]*###[^#]*###LSCACHE END[^#]*###\n?/';
43
+ static $RW_PATTERN_RES = 'wp-content/.*/[^/]*(loader|fonts|\.css|\.js)\.php';
44
+
45
+ /**
46
+ * Initialize the class and set its properties.
47
+ *
48
+ * @since 1.0.7
49
+ * @access private
50
+ */
51
+ private function __construct()
52
+ {
53
+ $this->setup();
54
+ }
55
+
56
+ /**
57
+ * Get the LiteSpeed_Cache_Admin_Rules object.
58
+ *
59
+ * @since 1.0.7
60
+ * @access public
61
+ * @return LiteSpeed_Cache_Admin_Rules Static instance of the LiteSpeed_Cache_Admin_Rules class.
62
+ */
63
+ public static function get_instance()
64
+ {
65
+ if (!isset(self::$instance)) {
66
+ self::$instance = new LiteSpeed_Cache_Admin_Rules();
67
+ }
68
+ return self::$instance;
69
+ }
70
+
71
+ /**
72
+ * Gets the currently used rules file path.
73
+ *
74
+ * @since 1.0.4
75
+ * @access public
76
+ * @return string The rules file path.
77
+ */
78
+ public static function get_home_path()
79
+ {
80
+ $rules = self::get_instance();
81
+ return $rules->home_path;
82
+ }
83
+
84
+ /**
85
+ * Gets the site .htaccess path. Useful if subdirectory install.
86
+ *
87
+ * @since 1.0.7
88
+ * @access public
89
+ * @return string The site path.
90
+ */
91
+ public static function get_site_path()
92
+ {
93
+ $rules = self::get_instance();
94
+ return $rules->site_path;
95
+ }
96
+
97
+ /**
98
+ * Checks if the WP install is a subdirectory install. If so, need to test
99
+ * multiple .htaccess files.
100
+ *
101
+ * @since 1.0.7
102
+ * @access private
103
+ * @return boolean True if it is a subdirectory install, false otherwise.
104
+ */
105
+ private static function is_subdir()
106
+ {
107
+ $rules = self::get_instance();
108
+ return $rules->is_subdir_install;
109
+ }
110
+
111
+ /**
112
+ * Checks the .htaccess file(s) permissions. If the file(s) has the given
113
+ * permissions, it will return so.
114
+ *
115
+ * @since 1.0.7
116
+ * @access public
117
+ * @param int $permissions The requested permissions. Consts from this class.
118
+ * @param string $path Optional path to check permissions of. If not given,
119
+ * will assume it is a .htaccess file.
120
+ * @return mixed True/non-zero if the file(s) has the given permissions.
121
+ * False/zero otherwise.
122
+ */
123
+ public static function is_file_able($permissions, $path = null)
124
+ {
125
+ $home = self::get_home_path();
126
+ $site = self::get_site_path();
127
+
128
+ if (($path === null) || ($path === $home) || ($path === $site)) {
129
+ $rules = self::get_instance();
130
+ return (($rules->filerw & $permissions) === $permissions);
131
+ }
132
+ $perms = 0;
133
+ $test_permissions = file_exists($path) ? $path : dirname($path);
134
+
135
+ if (is_readable($test_permissions)) {
136
+ $perms |= self::READABLE;
137
+ }
138
+ if (is_writable($test_permissions)) {
139
+ $perms |= self::WRITABLE;
140
+ }
141
+ return (($perms & $permissions) === $permissions);
142
+ }
143
+
144
+ /**
145
+ * Build the wrapper string for common rewrite rules.
146
+ *
147
+ * @since 1.0.4
148
+ * @access private
149
+ * @param string $wrapper The common rule wrapper.
150
+ * @param string $end Returns the ending wrapper.
151
+ * @return string Returns the opening wrapper.
152
+ */
153
+ private function build_wrappers($wrapper, &$end)
154
+ {
155
+ $end = '###LSCACHE END ' . $wrapper . '###';
156
+ return '###LSCACHE START ' . $wrapper . '###';
157
+ }
158
+
159
+ /**
160
+ * Set up the paths used for searching.
161
+ *
162
+ * @since 1.0.11
163
+ * @access private
164
+ * @param string $common The common part of the paths.
165
+ * @param string $install The install path portion. Will contain full path on return.
166
+ * @param string $access The access path portion. Will contain full path on return.
167
+ */
168
+ private static function path_search_setup(&$common, &$install, &$access)
169
+ {
170
+ $partial_dir = false;
171
+
172
+ if ( substr($common, -1) != '/' ) {
173
+
174
+ if ( $install !== '' && $install[0] != '/' ) {
175
+ $partial_dir = true;
176
+ }
177
+ elseif ( $access !== '' && $access[0] != '/' ) {
178
+ $partial_dir = true;
179
+ }
180
+ }
181
+ $install = rtrim($common . $install, '/');
182
+ $access = rtrim($common . $access, '/');
183
+
184
+ if ($partial_dir) {
185
+ $common = dirname($common);
186
+ }
187
+ else {
188
+ $common = rtrim($common, '/');
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Check to see if a file exists starting at $start_path and going up
194
+ * directories until it hits stop_path.
195
+ *
196
+ * As dirname() strips the ending '/', paths passed in must exclude the
197
+ * final '/', and the file must start with a '/'.
198
+ *
199
+ * @since 1.0.11
200
+ * @access private
201
+ * @param string $stop_path The last directory level to search.
202
+ * @param string $start_path The first directory level to search.
203
+ * @param string $file The file to search for.
204
+ * @return string The deepest path where the file exists,
205
+ * or the last path used if it does not exist.
206
+ */
207
+ private static function path_search($stop_path, $start_path, $file)
208
+ {
209
+ while ((!file_exists($start_path . $file))) {
210
+ if ($start_path === $stop_path) {
211
+ break;
212
+ }
213
+ $start_path = dirname($start_path);
214
+ }
215
+ return $start_path . $file;
216
+ }
217
+
218
+ /**
219
+ * Set the path class variables.
220
+ *
221
+ * @since 1.0.11
222
+ * @access private
223
+ */
224
+ private function path_set()
225
+ {
226
+ $install = ABSPATH;
227
+ $access = get_home_path();
228
+
229
+ if ($access === '/') {
230
+ // get home path failed. Trac ticket #37668
231
+ $install = set_url_scheme( get_option( 'siteurl' ), 'http' );
232
+ $access = set_url_scheme( get_option( 'home' ), 'http' );
233
+ }
234
+
235
+ /**
236
+ * Converts the intersection of $access and $install to \0
237
+ * then counts the number of \0 characters before the first non-\0.
238
+ */
239
+ $common_count = strspn($access ^ $install, "\0");
240
+
241
+ $install_part = substr($install, $common_count);
242
+ $access_part = substr($access, $common_count);
243
+ if ($access_part !== false) {
244
+ // access is longer than install or they are in different dirs.
245
+ if ($install_part === false) {
246
+ $install_part = '';
247
+ }
248
+ }
249
+ elseif ($install_part !== false) {
250
+ // Install is longer than access
251
+ $access_part = '';
252
+ $install_part = rtrim($install_part, '/');
253
+ }
254
+ else {
255
+ // they are equal - no need to find paths.
256
+ $this->home_path = ABSPATH . '.htaccess';
257
+ $this->site_path = ABSPATH . '.htaccess';
258
+ return;
259
+ }
260
+ $common_path = substr(ABSPATH, 0, -(strlen($install_part) + 1));
261
+
262
+ self::path_search_setup($common_path, $install_part, $access_part);
263
+
264
+ $this->site_path = self::path_search($common_path, $install_part,
265
+ '/.htaccess');
266
+ $this->home_path = self::path_search($common_path, $access_part,
267
+ '/.htaccess');
268
+ return;
269
+ }
270
+
271
+ /**
272
+ * Sets up the class variables.
273
+ *
274
+ * @since 1.0.11
275
+ * @access private
276
+ */
277
+ private function setup()
278
+ {
279
+ $this->path_set();
280
+ clearstatcache();
281
+
282
+ if ($this->home_path === $this->site_path) {
283
+ $this->is_subdir_install = false;
284
+ }
285
+ else {
286
+ $this->is_subdir_install = true;
287
+ }
288
+
289
+ $this->filerw = 0;
290
+ $test_permissions = file_exists($this->home_path) ? $this->home_path
291
+ : dirname($this->home_path);
292
+
293
+ if (is_readable($test_permissions)) {
294
+ $this->filerw |= self::READABLE;
295
+ }
296
+ if (is_writable($test_permissions)) {
297
+ $this->filerw |= self::WRITABLE;
298
+ }
299
+ if (!$this->is_subdir_install) {
300
+ return;
301
+ }
302
+ elseif (!file_exists($this->site_path)) {
303
+ $ret = file_put_contents($this->site_path, "\n", LOCK_EX);
304
+ if (!$ret) {
305
+ $this->filerw = 0;
306
+ return;
307
+ }
308
+ }
309
+
310
+ // If site file is not readable/writable, remove the flag.
311
+ if (!is_readable($this->site_path)) {
312
+ $this->filerw &= ~self::READABLE;
313
+ }
314
+ if (!is_writable($this->site_path)) {
315
+ $this->filerw &= ~self::WRITABLE;
316
+ }
317
+ }
318
+
319
+ /**
320
+ * Gets the contents of the rules file.
321
+ *
322
+ * @since 1.0.4
323
+ * @access public
324
+ * @param string $content Returns the content of the file or an error description.
325
+ * @param string $path The path to get the content from.
326
+ * @return boolean True if succeeded, false otherwise.
327
+ */
328
+ public static function file_get(&$content, $path = '')
329
+ {
330
+ if (empty($path)) {
331
+ $path = self::get_home_path();
332
+ if (!file_exists($path)) {
333
+ $content = "\n";
334
+ return true;
335
+ }
336
+ }
337
+ if (!self::is_file_able(self::RW)) {
338
+ LiteSpeed_Cache_Admin_Error::add_error(
339
+ LiteSpeed_Cache_Admin_Error::E_HTA_RW
340
+ );
341
+
342
+ $content = LiteSpeed_Cache_Admin_Error::get_error(
343
+ LiteSpeed_Cache_Admin_Error::E_HTA_RW
344
+ );
345
+ return false;
346
+ }
347
+
348
+ $content = file_get_contents($path);
349
+ if ($content === false) {
350
+ LiteSpeed_Cache_Admin_Error::add_error(
351
+ LiteSpeed_Cache_Admin_Error::E_HTA_GET
352
+ );
353
+
354
+ $content = LiteSpeed_Cache_Admin_Error::get_error(
355
+ LiteSpeed_Cache_Admin_Error::E_HTA_GET
356
+ );
357
+ return false;
358
+ }
359
+ // Remove ^M characters.
360
+ $content = str_ireplace("\x0D", "", $content);
361
+ return true;
362
+ }
363
+
364
+ /**
365
+ * Get the ifmodule block if it exists in the content.
366
+ *
367
+ * @since 1.0.12
368
+ * @access public
369
+ * @param string $content The content to search.
370
+ * @param int $off_begin Will be set to the beginning offset. Starts
371
+ * just after the opening <IfModule>.
372
+ * @param int $off_end Will be set to the ending offset. Starts just
373
+ * before the closing </IfModule>.
374
+ * @return bool|string False if not found, True if found. Error message if
375
+ * it failed.
376
+ */
377
+ public static function file_get_ifmodule_block($content, &$off_begin,
378
+ &$off_end)
379
+ {
380
+ $off_begin = stripos($content, self::$RW_BLOCK_START);
381
+ //if not found
382
+ if ($off_begin === false) {
383
+ return false;
384
+ }
385
+ $off_begin += strlen(self::$RW_BLOCK_START);
386
+ $off_end = stripos($content, self::$RW_BLOCK_END, $off_begin);
387
+ $off_next = stripos($content, '<IfModule', $off_begin);
388
+ if ($off_end === false) {
389
+ $buf = LiteSpeed_Cache_Admin_Error::build_error(
390
+ LiteSpeed_Cache_Admin_Error::E_HTA_DNF, 'IfModule close'
391
+ );
392
+ return $buf;
393
+ }
394
+ elseif (($off_next !== false) && ($off_next < $off_end)) {
395
+ $buf = LiteSpeed_Cache_Admin_Display::build_paragraph(
396
+ LiteSpeed_Cache_Admin_Error::get_error(
397
+ LiteSpeed_Cache_Admin_Error::E_HTA_ORDER),
398
+ sprintf(__('The .htaccess file is missing a %s.', 'litespeed-cache'),
399
+ '&lt;/IfModule&gt;'));
400
+ return $buf;
401
+ }
402
+ --$off_end; // go to end of previous line.
403
+ return true;
404
+ }
405
+
406
+ /**
407
+ * Searches for the LiteSpeed section in contents.
408
+ *
409
+ * @since 1.0.7
410
+ * @access private
411
+ * @param string $content The content to search
412
+ * @param string $buf The portion before and including the beginning of
413
+ * the section.
414
+ * @param string $after The content after the relevant section.
415
+ * @return mixed False on failure, the haystack on success.
416
+ * The haystack may be a string or null if it did not exist.
417
+ */
418
+ private function file_split($content, &$buf, &$after)
419
+ {
420
+ $wrapper_end = '';
421
+ $wrapper_begin = $this->build_wrappers(self::$RW_WRAPPER, $wrapper_end);
422
+ $off_begin = 0;
423
+ $off_end = 0;
424
+
425
+ $ret = self::file_get_ifmodule_block($content, $off_begin, $off_end);
426
+
427
+ if ($ret === false) {
428
+ $buf = self::$RW_BLOCK_START . "\n" . $wrapper_begin
429
+ . self::$RW_PREREQ;
430
+ $after = $wrapper_end . "\n" . self::$RW_BLOCK_END . "\n" . $content;
431
+ return NULL;
432
+ }
433
+ elseif ($ret !== true) {
434
+ $buf = $ret;
435
+ return false;
436
+ }
437
+
438
+ $off_wrapper = stripos($content, $wrapper_begin, $off_begin);
439
+ // If the wrapper exists
440
+ if ($off_wrapper !== false) {
441
+ $off_wrapper += strlen($wrapper_begin);
442
+ $off_wrapper_end = stripos($content, $wrapper_end, $off_wrapper);
443
+ if ($off_wrapper_end === false) {
444
+ $buf = LiteSpeed_Cache_Admin_Error::build_error(
445
+ LiteSpeed_Cache_Admin_Error::E_HTA_DNF,
446
+ 'Plugin wrapper close'
447
+ );
448
+ return false;
449
+ }
450
+ --$off_wrapper_end;
451
+
452
+ $buf = substr($content, 0, $off_wrapper + 1);
453
+ $after = substr($content, $off_wrapper_end);
454
+ $block = substr($content, $off_wrapper,
455
+ $off_wrapper_end - $off_wrapper);
456
+ return $block;
457
+ }
458
+ $buf = substr($content, 0, $off_end) . "\n" . $wrapper_begin
459
+ . self::$RW_PREREQ;
460
+ $after = $wrapper_end . substr($content, $off_end);
461
+ $rules = array();
462
+ $matched = preg_replace_callback(self::$RW_PATTERN_WRAPPERS,
463
+ function ($matches) use (&$rules)
464
+ {
465
+ $rules[] = $matches[0];
466
+ return '';
467
+ },
468
+ $buf);
469
+ if (empty($rules)) {
470
+ return NULL;
471
+ }
472
+ $buf = $matched;
473
+ $block = implode('', $rules);
474
+ return $block;
475
+ }
476
+
477
+ /**
478
+ * Complete the validate changes and save to file.
479
+ *
480
+ * @since 1.0.7
481
+ * @access private
482
+ * @param string $beginning The portion that includes the edits.
483
+ * @param string $haystack The source section from the original file.
484
+ * @param string $after The content after the relevant section.
485
+ * @param string $path If path is set, use path, else use home path.
486
+ * @return mixed true on success, else error message on failure.
487
+ */
488
+ private function file_combine($beginning, $haystack, $after, $path = '')
489
+ {
490
+ if (!is_null($haystack)) {
491
+ $beginning .= $haystack;
492
+ }
493
+ $beginning .= $after;
494
+ return self::file_save($beginning, false, $path);
495
+ }
496
+
497
+ /**
498
+ * Try to backup the .htaccess file.
499
+ * This function will attempt to create a .htaccess_lscachebak_orig first.
500
+ * If that is already created, it will attempt to create .htaccess_lscachebak_[1-10]
501
+ * If 10 are already created, zip the current set of backups (sans _orig).
502
+ * If a zip already exists, overwrite it.
503
+ *
504
+ * @since 1.0.10
505
+ * @access private
506
+ * @param String $path The .htaccess file path.
507
+ * @return boolean True on success, else false on failure.
508
+ */
509
+ private static function file_backup($path)
510
+ {
511
+ $bak = '_lscachebak_orig';
512
+ $i = 1;
513
+
514
+ if ( file_exists($path . $bak) ) {
515
+ $bak = sprintf("_lscachebak_%02d", $i);
516
+ while (file_exists($path . $bak)) {
517
+ $i++;
518
+ $bak = sprintf("_lscachebak_%02d", $i);
519
+ }
520
+ }
521
+
522
+ if (($i <= 10) || (!class_exists('ZipArchive'))) {
523
+ $ret = copy($path, $path . $bak);
524
+ return $ret;
525
+ }
526
+
527
+ $zip = new ZipArchive;
528
+ $dir = dirname($path);
529
+ $arr = scandir($dir);
530
+ $parsed = preg_grep('/\.htaccess_lscachebak_[0-9]+/', $arr);
531
+
532
+ if (empty($parsed)) {
533
+ return false;
534
+ }
535
+
536
+ $res = $zip->open($dir . '/lscache_htaccess_bak.zip',
537
+ ZipArchive::CREATE | ZipArchive::OVERWRITE);
538
+ if ($res !== true) {
539
+ error_log('Warning: Failed to archive wordpress backups in ' . $dir);
540
+ $ret = copy($path, $path . $bak);
541
+ return $ret;
542
+ }
543
+
544
+ foreach ($parsed as $key => $val) {
545
+ $parsed[$key] = $dir . '/' . $val;
546
+ if (!$zip->addFile($parsed[$key], $val)) {
547
+ error_log('Warning: Failed to archive backup file ' . $val);
548
+ $zip->close();
549
+ $ret = copy($path, $path . $bak);
550
+ return $ret;
551
+ }
552
+ }
553
+
554
+ $ret = $zip->close();
555
+ if (!$ret) {
556
+ error_log('Warning: Failed to close archive.');
557
+ return $ret;
558
+ }
559
+ $bak = '_lscachebak_01';
560
+
561
+ foreach ($parsed as $delFile) {
562
+ unlink($delFile);
563
+ }
564
+
565
+ $ret = copy($path, $path . $bak);
566
+ return $ret;
567
+ }
568
+
569
+ /**
570
+ * Try to save the rules file changes.
571
+ *
572
+ * This function is used by both the edit .htaccess admin page and
573
+ * the common rewrite rule configuration options.
574
+ *
575
+ * This function will create a backup with _lscachebak appended to the file name
576
+ * prior to making any changese. If creating the backup fails, an error is returned.
577
+ *
578
+ * If $cleanup is true, this function strip extra slashes.
579
+ *
580
+ * @since 1.0.4
581
+ * @since 1.0.12 - Introduce $backup parameter and make function public
582
+ * @access public
583
+ * @param string $content The new content to put into the rules file.
584
+ * @param boolean $cleanup True to strip extra slashes, false otherwise.
585
+ * @param string $path The file path to edit.
586
+ * @param boolean $backup Whether to create backups or not.
587
+ * @return boolean true on success, else false.
588
+ */
589
+ public static function file_save($content, $cleanup = true, $path = '',
590
+ $backup = true)
591
+ {
592
+ while (true) {
593
+ if (empty($path)) {
594
+ $path = self::get_home_path();
595
+ if (!file_exists($path)) {
596
+ break;
597
+ }
598
+ }
599
+
600
+ if (self::is_file_able(self::RW, $path) == 0) {
601
+ LiteSpeed_Cache_Admin_Error::add_error(
602
+ LiteSpeed_Cache_Admin_Error::E_HTA_RW);
603
+ return false;
604
+ }
605
+
606
+ //failed to backup, not good.
607
+ if (($backup) && (self::file_backup($path) === false)) {
608
+ LiteSpeed_Cache_Admin_Error::add_error(
609
+ LiteSpeed_Cache_Admin_Error::E_HTA_BU);
610
+ return false;
611
+ }
612
+
613
+ break;
614
+ }
615
+
616
+ if ($cleanup) {
617
+ $content = LiteSpeed_Cache_Admin::cleanup_text($content);
618
+ }
619
+
620
+ // File put contents will truncate by default. Will create file if doesn't exist.
621
+ $ret = file_put_contents($path, $content, LOCK_EX);
622
+ if (!$ret) {
623
+ LiteSpeed_Cache_Admin_Error::add_error(
624
+ LiteSpeed_Cache_Admin_Error::E_HTA_SAVE
625
+ );
626
+ return false;
627
+ }
628
+
629
+ return true;
630
+ }
631
+
632
+ /**
633
+ * Updates the specified common rewrite rule based on original content.
634
+ *
635
+ * If the specified rule is not found, just return the rule.
636
+ * Else if it IS found, need to keep the content surrounding the rule.
637
+ *
638
+ * The return value is mixed.
639
+ * Returns true if the rule is not found in the content.
640
+ * Returns an array (false, error_msg) on error.
641
+ * Returns an array (true, new_content) if the rule is found.
642
+ *
643
+ * new_content is the original content minus the matched rule. This is
644
+ * to prevent losing any of the original content.
645
+ *
646
+ * @since 1.0.4
647
+ * @access private
648
+ * @param string $content The original content in the .htaccess file.
649
+ * @param string $output Returns the added rule if success.
650
+ * @param string $wrapper The wrapper that surrounds the rule.
651
+ * @param string $cond The rewrite condition to use with the rule.
652
+ * @param string $match The rewrite rule to match against the condition.
653
+ * @param string $env The environment change to do if the rule matches.
654
+ * @param string $flag The flags to use with the rewrite condition.
655
+ * @return mixed Explained above.
656
+ */
657
+ private function set_common_rule($content, &$output, $wrapper, $cond,
658
+ $match, $env, $flag = '')
659
+ {
660
+
661
+ $wrapper_end = '';
662
+ $wrapper_begin = $this->build_wrappers($wrapper, $wrapper_end);
663
+ $rw_cond = 'RewriteCond %{' . $cond . '} ' . $match;
664
+ if ($flag != '') {
665
+ $rw_cond .= ' [' . $flag . ']';
666
+ }
667
+ $out = $wrapper_begin . "\n" . $rw_cond . "\n"
668
+ . 'RewriteRule .* - [' . $env . ']' . "\n" . $wrapper_end . "\n";
669
+
670
+ // just create the whole buffer.
671
+ if (is_null($content)) {
672
+ if ($match != '') {
673
+ $output .= $out;
674
+ }
675
+ return true;
676
+ }
677
+ $wrap_begin = stripos($content, $wrapper_begin);
678
+ if ($wrap_begin === false) {
679
+ if ($match != '') {
680
+ $output .= $out;
681
+ }
682
+ return true;
683
+ }
684
+ $wrap_end = stripos($content, $wrapper_end,
685
+ $wrap_begin + strlen($wrapper_begin));
686
+
687
+ if ($wrap_end === false) {
688
+ $err = LiteSpeed_Cache_Admin_Error::build_error(
689
+ LiteSpeed_Cache_Admin_Error::E_HTA_DNF, 'wrapper end');
690
+ return array(false, $err);
691
+ }
692
+ elseif ($match != '') {
693
+ $output .= $out;
694
+ }
695
+ $buf = substr($content, 0, $wrap_begin); // Remove everything between wrap_begin and wrap_end
696
+ $buf .= substr($content, $wrap_end + strlen($wrapper_end));
697
+ return array(true, trim($buf));
698
+ }
699
+
700
+ /**
701
+ * Finds a specified common rewrite rule from the .htaccess file.
702
+ *
703
+ * @since 1.0.4
704
+ * @access public
705
+ * @param string $wrapper The wrapper to look for.
706
+ * @param string $cond The condition to look for.
707
+ * @param string $match Returns the rewrite rule on success, error message on failure.
708
+ * @return boolean True on success, false otherwise.
709
+ */
710
+ public function get_common_rule($wrapper, $cond, &$match)
711
+ {
712
+
713
+ if (self::file_get($match) === false) {
714
+ return false;
715
+ }
716
+ $suffix = '';
717
+ $prefix = $this->build_wrappers($wrapper, $suffix);
718
+ $off_begin = stripos($match, $prefix);
719
+ if ($off_begin === false) {
720
+ $match = '';
721
+ return true; // It does not exist yet, not an error.
722
+ }
723
+ $off_begin += strlen($prefix);
724
+ $off_end = stripos($match, $suffix, $off_begin);
725
+ if ($off_end === false) {
726
+ $match = LiteSpeed_Cache_Admin_Error::build_error(
727
+ LiteSpeed_Cache_Admin_Error::E_HTA_DNF,
728
+ 'suffix ' . $suffix);
729
+ return false;
730
+ }
731
+ elseif ($off_begin >= $off_end) {
732
+ $match = LiteSpeed_Cache_Admin_Error::get_error(
733
+ LiteSpeed_Cache_Admin_Error::E_HTA_ORDER
734
+ );
735
+ return false;
736
+ }
737
+
738
+ $subject = substr($match, $off_begin, $off_end - $off_begin);
739
+ $pattern = self::$RW_PATTERN_COND_START . $cond
740
+ . self::$RW_PATTERN_COND_END;
741
+ $matches = array();
742
+ $num_matches = preg_match($pattern, $subject, $matches);
743
+ if ($num_matches === false) {
744
+ $match = LiteSpeed_Cache_Admin_Error::build_error(
745
+ LiteSpeed_Cache_Admin_Error::E_HTA_DNF, 'a match'
746
+ );
747
+ return false;
748
+ }
749
+ $match = trim($matches[1]);
750
+ return true;
751
+ }
752
+
753
+ /**
754
+ * Updates the specified rewrite rule based on original content.
755
+ *
756
+ * If the specified rule is not found, just return the rule.
757
+ * Else if it IS found, need to keep the content surrounding the rule.
758
+ *
759
+ * The return value is mixed.
760
+ * Returns true if the rule is not found in the content.
761
+ * Returns an array (false, error_msg) on error.
762
+ * Returns an array (true, new_content) if the rule is found.
763
+ *
764
+ * new_content is the original content minus the matched rule. This is
765
+ * to prevent losing any of the original content.
766
+ *
767
+ * @since 1.0.4
768
+ * @access private
769
+ * @param string $content The original content in the .htaccess file.
770
+ * @param string $output Returns the added rule if success.
771
+ * @param string $wrapper The wrapper that surrounds the rule.
772
+ * @param string $match The rewrite rule to match against.
773
+ * @param string $sub The substitute for the rule match.
774
+ * @param string $env The environment change to do if the rule matches.
775
+ * @return mixed Explained above.
776
+ */
777
+ private function set_rewrite_rule($content, &$output, $wrapper, $match,
778
+ $sub, $env)
779
+ {
780
+
781
+ $wrapper_end = '';
782
+ $wrapper_begin = $this->build_wrappers($wrapper, $wrapper_end);
783
+ $out = $wrapper_begin . "\nRewriteRule " . $match . ' ' . $sub
784
+ . ' [' . $env . ']' . "\n" . $wrapper_end . "\n";
785
+
786
+ // just create the whole buffer.
787
+ if (is_null($content)) {
788
+ if ($match != '') {
789
+ $output .= $out;
790
+ }
791
+ return true;
792
+ }
793
+ $wrap_begin = stripos($content, $wrapper_begin);
794
+ if ($wrap_begin === false) {
795
+ if ($match != '') {
796
+ $output .= $out;
797
+ }
798
+ return true;
799
+ }
800
+ $wrap_end = stripos($content, $wrapper_end, $wrap_begin + strlen($wrapper_begin));
801
+ if ($wrap_end === false) {
802
+ $err =LiteSpeed_Cache_Admin_Error::build_error(
803
+ LiteSpeed_Cache_Admin_Error::E_HTA_DNF, 'wrapper end'
804
+ );
805
+ return array(false, $err);
806
+ }
807
+ elseif ($match != '') {
808
+ $output .= $out;
809
+ }
810
+ $buf = substr($content, 0, $wrap_begin); // Remove everything between wrap_begin and wrap_end
811
+ $buf .= substr($content, $wrap_end + strlen($wrapper_end));
812
+ return array(true, trim($buf));
813
+ }
814
+
815
+ /**
816
+ * FInds a specified rewrite rule from the .htaccess file.
817
+ *
818
+ * @since 1.0.4
819
+ * @access public
820
+ * @param string $wrapper The wrapper to look for.
821
+ * @param string $match Returns the rewrite rule on success, error message on failure.
822
+ * @param string $sub Returns the substitute on success, error message on failure.
823
+ * @param string $env Returns the environment on success, error message on failure.
824
+ * @return boolean True on success, false otherwise.
825
+ */
826
+ public function get_rewrite_rule($wrapper, &$match, &$sub, &$env)
827
+ {
828
+
829
+ if (self::file_get($match) === false) {
830
+ return false;
831
+ }
832
+ $suffix = '';
833
+ $prefix = $this->build_wrappers($wrapper, $suffix);
834
+ $off_begin = stripos($match, $prefix);
835
+ if ($off_begin === false) {
836
+ $match = '';
837
+ return true; // It does not exist yet, not an error.
838
+ }
839
+ $off_begin += strlen($prefix);
840
+ $off_end = stripos($match, $suffix, $off_begin);
841
+ if ($off_end === false) {
842
+ $match = LiteSpeed_Cache_Admin_Error::build_error(
843
+ LiteSpeed_Cache_Admin_Error::E_HTA_DNF,
844
+ 'suffix ' . $suffix
845
+ );
846
+ return false;
847
+ }
848
+ elseif ($off_begin >= $off_end) {
849
+ $match = LiteSpeed_Cache_Admin_Error::get_error(
850
+ LiteSpeed_Cache_Admin_Error::E_HTA_ORDER
851
+ );
852
+ return false;
853
+ }
854
+
855
+ $subject = substr($match, $off_begin, $off_end - $off_begin);
856
+ $pattern = self::$RW_PATTERN_RULE;
857
+ $matches = array();
858
+ $num_matches = preg_match($pattern, $subject, $matches);
859
+ if ($num_matches === false) {
860
+ $match = LiteSpeed_Cache_Admin_Error::build_error(
861
+ LiteSpeed_Cache_Admin_Error::E_HTA_DNF, 'a match');
862
+ return false;
863
+ }
864
+ $match = trim($matches[1]);
865
+ $sub = trim($matches[2]);
866
+ if (isset($matches[3])) {
867
+ $env = trim($matches[3]);
868
+ }
869
+ else {
870
+ $env = '';
871
+ }
872
+ return true;
873
+ }
874
+
875
+ /**
876
+ * Do the setting cache favicon logic.
877
+ *
878
+ * @since 1.0.8
879
+ * @access private
880
+ * @param string $haystack The original content in the .htaccess file.
881
+ * @param boolean $action Whether to add or remove the rule.
882
+ * @param string $output The current output buffer for the HOME PATH file.
883
+ * @param array $errors Errors array to add error messages to.
884
+ * @return mixed False on failure/do not update,
885
+ * original content sans favicon on success.
886
+ */
887
+ private function set_favicon($haystack, $action, &$output, &$errors)
888
+ {
889
+ $match = 'favicon\.ico$';
890
+ $sub = '-';
891
+ $env = 'E=cache-control:max-age=86400';
892
+ $rule_buf = '';
893
+ if ($action == 0) {
894
+ $match = '';
895
+ $sub = '';
896
+ $env = '';
897
+ }
898
+ $ret = $this->set_rewrite_rule($haystack, $rule_buf, 'FAVICON',
899
+ $match, $sub, $env);
900
+
901
+ if ($this->parse_ret($ret, $haystack, $errors) === false) {
902
+ return false;
903
+ }
904
+ $output .= $rule_buf;
905
+ return $haystack;
906
+ }
907
+
908
+ /**
909
+ * Do the setting cache resource logic.
910
+ *
911
+ * @since 1.0.8
912
+ * @access private
913
+ * @param string $haystack The original content in the .htaccess file.
914
+ * @param boolean $set Whether to add or remove the rule.
915
+ * @param string $output The current output buffer for the HOME PATH file.
916
+ * @param array $errors Errors array to add error messages to.
917
+ * @return mixed False on failure/do not update,
918
+ * original content sans favicon on success.
919
+ */
920
+ private function set_cache_resource($haystack, $set, &$output, &$errors)
921
+ {
922
+ $match = self::$RW_PATTERN_RES;
923
+ $sub = '-';
924
+ $env = 'E=cache-control:max-age=3600';
925
+ $rule_buf = '';
926
+ if ($set == 0) {
927
+ $match = '';
928
+ $sub = '';
929
+ $env = '';
930
+ }
931
+ $ret = $this->set_rewrite_rule($haystack, $rule_buf, 'RESOURCE',
932
+ $match, $sub, $env);
933
+
934
+ if ($this->parse_ret($ret, $haystack, $errors) === false) {
935
+ return false;
936
+ }
937
+ $output .= $rule_buf;
938
+ return $haystack;
939
+ }
940
+
941
+ /**
942
+ * Parses the input to see if there is a need to edit the .htaccess file.
943
+ *
944
+ * @since 1.0.8
945
+ * @access public
946
+ * @param array $options The current options
947
+ * @param array $input The input
948
+ * @param array $errors Errors array to add error messages to.
949
+ * @return mixed False if there is an error, diff array otherwise.
950
+ */
951
+ public function check_input($options, $input, &$errors)
952
+ {
953
+ $diff = array();
954
+ $val_check = array(
955
+ LiteSpeed_Cache_Config::OPID_MOBILEVIEW_ENABLED,
956
+ LiteSpeed_Cache_Config::OPID_CACHE_FAVICON,
957
+ LiteSpeed_Cache_Config::OPID_CACHE_RES
958
+ );
959
+ $has_error = false;
960
+
961
+ foreach ($val_check as $opt) {
962
+ $ret = LiteSpeed_Cache_Admin::parse_checkbox($opt, $input, $input);
963
+ if (($ret) || ($options[$opt] !== $ret)) {
964
+ $diff[$opt] = $ret;
965
+ }
966
+ }
967
+
968
+ $id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST;
969
+ if ($input[LiteSpeed_Cache_Config::OPID_MOBILEVIEW_ENABLED]) {
970
+ $list = $input[$id];
971
+ if ((empty($list)) || (self::check_rewrite($list) === false)) {
972
+ $err_args = array(
973
+ $id,
974
+ (empty($list) ? 'EMPTY' : esc_html($list))
975
+ );
976
+ $errors[] =
977
+ LiteSpeed_Cache_Admin_Error::build_error(
978
+ LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE,
979
+ $err_args
980
+ );
981
+ $has_error = true;
982
+ }
983
+ $diff[$id] = $list;
984
+ }
985
+ elseif (isset($diff[LiteSpeed_Cache_Config::OPID_MOBILEVIEW_ENABLED])) {
986
+ $diff[$id] = false;
987
+ }
988
+
989
+ $id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES;
990
+ if ((isset($input[$id])) && ($input[$id])) {
991
+ $cookie_list = preg_replace("/[\r\n]+/", '|', $input[$id]);
992
+ }
993
+ else {
994
+ $cookie_list = '';
995
+ }
996
+
997
+ if ((empty($cookie_list)) || (self::check_rewrite($cookie_list))) {
998
+ $diff[$id] = $cookie_list;
999
+ }
1000
+ else {
1001
+ $errors[] =
1002
+ LiteSpeed_Cache_Admin_Error::build_error(
1003
+ LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE,
1004
+ array($id, esc_html($cookie_list)));
1005
+ $has_error = true;
1006
+ }
1007
+
1008
+ $id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS;
1009
+ if ((isset($input[$id])) && (self::check_rewrite($input[$id]))) {
1010
+ $diff[$id] = $input[$id];
1011
+ }
1012
+ else {
1013
+ $err_args = array($id);
1014
+ if ((!isset($input[$id])) || (empty($input[$id]))) {
1015
+ $err_args[] = 'EMPTY';
1016
+ }
1017
+ else {
1018
+ $err_args[] = esc_html($input[$id]);
1019
+ }
1020
+
1021
+ $errors[] =
1022
+ LiteSpeed_Cache_Admin_Error::build_error(
1023
+ LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, $err_args);
1024
+ $has_error = true;
1025
+ }
1026
+
1027
+ $id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE;
1028
+ $aExceptions = array('-', '_');
1029
+ if (isset($input[$id])) {
1030
+ if (($input[$id] === '')
1031
+ || ((ctype_alnum(str_replace($aExceptions, '', $input[$id])))
1032
+ && (self::check_rewrite($input[$id])))) {
1033
+ $diff[$id] = $input[$id];
1034
+ }
1035
+ else {
1036
+ $errors[] =
1037
+ LiteSpeed_Cache_Admin_Error::build_error(
1038
+ LiteSpeed_Cache_Admin_Error::E_SETTING_LC,
1039
+ esc_html($input[$id]));
1040
+ $has_error = true;
1041
+ }
1042
+ }
1043
+
1044
+ if ($has_error) {
1045
+ return false;
1046
+ }
1047
+ return $diff;
1048
+ }
1049
+
1050
+ /**
1051
+ * Parse rewrite input to check for possible issues (e.g. unescaped spaces).
1052
+ *
1053
+ * Issues tracked:
1054
+ * Starts with |
1055
+ * Ends with |
1056
+ * Double |
1057
+ * Unescaped space
1058
+ * Invalid character (NOT \w, -, \, |, \s, /, ., +, *, (, ))
1059
+ *
1060
+ * @since 1.0.9
1061
+ * @access private
1062
+ * @param String $rule Input rewrite rule.
1063
+ * @return boolean True for valid rules, false otherwise.
1064
+ */
1065
+ private static function check_rewrite($rule)
1066
+ {
1067
+ $escaped = str_replace('@', '\@', $rule);
1068
+ return (@preg_match('@' . $escaped . '@', null) !== false);
1069
+ }
1070
+
1071
+ /**
1072
+ * Parse the return value from set_common_rule and set_rewrite_rule.
1073
+ *
1074
+ * @since 1.0.7
1075
+ * @access private
1076
+ * @param mixed $ret The return value from the called function.
1077
+ * @param string $haystack Where to start the next search.
1078
+ * @param string $errors Errors array in case of error.
1079
+ * @return boolean False on function failure, true otherwise.
1080
+ */
1081
+ private function parse_ret($ret, &$haystack, &$errors)
1082
+ {
1083
+ if (!is_array($ret)) {
1084
+ return true;
1085
+ }
1086
+ if ($ret[0]) {
1087
+ $haystack = $ret[1];
1088
+ }
1089
+ else {
1090
+ // failed.
1091
+ $errors[] = $ret[1];
1092
+ return false;
1093
+ }
1094
+ return true;
1095
+ }
1096
+
1097
+ /**
1098
+ * Do the setting subdir cookies logic. If it is a subdirectory install,
1099
+ * will write to both .htaccess files.
1100
+ *
1101
+ * @since 1.0.7
1102
+ * @access private
1103
+ * @param array $diff The rules that need to be set
1104
+ * @param string $haystack The original content in the .htaccess file.
1105
+ * @param string $buf The current output buffer for the HOME PATH file.
1106
+ * @param array $errors Errors array to add error messages to.
1107
+ * @return mixed False on failure/do not update,
1108
+ * original content sans login cookie on success.
1109
+ */
1110
+ private function set_subdir_cookie($diff, &$haystack, &$buf, &$errors)
1111
+ {
1112
+ $login_id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE;
1113
+ $res_id = LiteSpeed_Cache_Config::OPID_CACHE_RES;
1114
+ if (isset($diff[$login_id])) {
1115
+ if ($diff[$login_id] !== '') {
1116
+ $match = '.?';
1117
+ $sub = '-';
1118
+ if (is_openlitespeed()) {
1119
+ $env = 'E="Cache-Vary:' . $diff[$login_id] . '"';
1120
+ }
1121
+ else {
1122
+ $env = 'E=Cache-Vary:' . $diff[$login_id];
1123
+ }
1124
+ }
1125
+ else {
1126
+ $match = '';
1127
+ $sub = '';
1128
+ $env = '';
1129
+ }
1130
+
1131
+ $ret = $this->set_rewrite_rule($haystack, $buf, 'LOGIN COOKIE',
1132
+ $match, $sub, $env);
1133
+ $this->parse_ret($ret, $haystack, $errors);
1134
+ }
1135
+
1136
+ if (!self::is_subdir()) {
1137
+ if (isset($diff[$res_id])) {
1138
+ $ret = $this->set_cache_resource($haystack, $diff[$res_id],
1139
+ $buf, $errors);
1140
+ if ($ret !== false) {
1141
+ $haystack = $ret;
1142
+ }
1143
+ }
1144
+ return true;
1145
+ }
1146
+
1147
+ $path = self::get_site_path();
1148
+ $content2 = '';
1149
+ $before2 = '';
1150
+ $rule_buf2 = "\n";
1151
+ if (self::file_get($content2, $path) === false) {
1152
+ $errors[] = $content2;
1153
+ return false;
1154
+ }
1155
+
1156
+ $haystack2 = $this->file_split($content2, $before2, $after2);
1157
+ if ($haystack2 === false) {
1158
+ $errors[] = $rule_buf2;
1159
+ return false;
1160
+ }
1161
+ if (isset($diff[$login_id])) {
1162
+ $ret = $this->set_rewrite_rule($haystack2, $rule_buf2,
1163
+ 'LOGIN COOKIE', $match, $sub, $env);
1164
+ $this->parse_ret($ret, $haystack2, $errors);
1165
+ }
1166
+ if (isset($diff[$res_id])) {
1167
+ $ret = $this->set_cache_resource($haystack2, $diff[$res_id],
1168
+ $rule_buf2, $errors);
1169
+ if ($ret !== false) {
1170
+ $haystack2 = $ret;
1171
+ }
1172
+ }
1173
+
1174
+ $ret = $this->file_combine($before2, $haystack2 . $rule_buf2,
1175
+ $after2, $path);
1176
+ if ($ret !== true) {
1177
+ $errors[] = LiteSpeed_Cache_Admin_Error::get_error(
1178
+ LiteSpeed_Cache_Admin_Error::E_HTA_PUT);
1179
+ return false;
1180
+ }
1181
+ return true;
1182
+ }
1183
+
1184
+ /**
1185
+ * Helper function to set rewrite rules on upgrade.
1186
+ *
1187
+ * @since 1.0.8
1188
+ * @access private
1189
+ * @param string $wrapper A wrapper to a specific rule
1190
+ * @param string $match The match to set the rewrite rule to search for.
1191
+ * @param string $sub The substitution to set the rewrite rule to replace with.
1192
+ * @param string $flag The flag the rewrite rule should set.
1193
+ * @param string $content The original content/new content after replacement.
1194
+ */
1195
+ private function set_on_upgrade($wrapper, $match, $sub, $flag, &$content)
1196
+ {
1197
+ $split_rule = preg_split(self::$RW_PATTERN_UPGRADE_BLOCK, $content, -1,
1198
+ PREG_SPLIT_DELIM_CAPTURE);
1199
+ $rule_buf = '';
1200
+ $ret = $this->set_rewrite_rule($content, $rule_buf, $wrapper, $match, $sub,
1201
+ $flag);
1202
+ if ($ret !== true) {
1203
+ return;
1204
+ }
1205
+ elseif (count($split_rule) == 1) {
1206
+ //not found
1207
+ $content = self::$RW_BLOCK_START . "\n" . $rule_buf
1208
+ . self::$RW_BLOCK_END . "\n" . $content;
1209
+ }
1210
+ else {
1211
+ //else found
1212
+ // split_rule[0] = pre match
1213
+ // split_rule[1] = contents of IfModule
1214
+ // split_rule[2] = closing IfModule
1215
+ // split_rule[3] = post match
1216
+ $split_rule[2] = $rule_buf . "\n" . $split_rule[2];
1217
+ $content = implode('', $split_rule);
1218
+ }
1219
+ }
1220
+
1221
+ /**
1222
+ * Given a file's contents, search for an existing login cookie.
1223
+ * If the login cookie exists, this function will modify the content to
1224
+ * correct the cookie's placement.
1225
+ *
1226
+ * @since 1.0.7
1227
+ * @access private
1228
+ * @param string $content The content to parse through.
1229
+ * @return string The login cookie if found, empty string otherwise.
1230
+ */
1231
+ private function parse_existing_login_cookie(&$content)
1232
+ {
1233
+ // If match found, split_rule will look like:
1234
+ // $split_rule[0] = pre match content.
1235
+ // $split_rule[1] = matching rule.
1236
+ // $split_rule[2] = login cookie
1237
+ // $split_rule[3] = post match content.
1238
+ $split_rule = preg_split(self::$RW_PATTERN_LOGIN, $content, -1,
1239
+ PREG_SPLIT_DELIM_CAPTURE);
1240
+ if (count($split_rule) == 1) {
1241
+ return '';
1242
+ }
1243
+ $suffix = '';
1244
+ $prefix = $this->build_wrappers('LOGIN COOKIE', $suffix);
1245
+ if (strpos($split_rule[0], $prefix) !== false) {
1246
+ return $split_rule[2];
1247
+ }
1248
+ $replacement = $prefix . "\n" . $split_rule[1] . "\n" . $suffix . "\n";
1249
+ $without_rule = $split_rule[0] . $split_rule[3];
1250
+ $split_blocks = preg_split(self::$RW_PATTERN_LOGIN_BLOCK,
1251
+ $without_rule, -1, PREG_SPLIT_DELIM_CAPTURE);
1252
+ $index = array_search('LiteSpeed', $split_blocks);
1253
+ if ($index === false) {
1254
+ // IfModule LiteSpeed not found.
1255
+ $content = self::$RW_BLOCK_START . "\n" . $replacement
1256
+ . self::$RW_BLOCK_END . "\n" . $without_rule;
1257
+ return $split_rule[2];
1258
+ }
1259
+ elseif ($index + 2 > count($split_blocks)) {
1260
+ LiteSpeed_Cache_Admin_Display::get_instance()->add_notice(
1261
+ LiteSpeed_Cache_Admin_Display::NOTICE_YELLOW,
1262
+ LiteSpeed_Cache_Admin_Error::get_error(
1263
+ LiteSpeed_Cache_Admin_Error::E_LC_HTA));
1264
+ return '';
1265
+ }
1266
+ $split_blocks[$index + 1] .= $replacement;
1267
+ array_splice($split_blocks, $index, 1);
1268
+ $content = implode('', $split_blocks);
1269
+ return $split_rule[2];
1270
+ }
1271
+
1272
+ /**
1273
+ * Scans the .htaccess file(s) for existing login cookie rewrite rule.
1274
+ *
1275
+ * @since 1.0.7
1276
+ * @access public
1277
+ * @return string The login cookie if found, empty string otherwise.
1278
+ */
1279
+ public function scan_upgrade()
1280
+ {
1281
+ $config = LiteSpeed_Cache::plugin()->get_config();
1282
+ if (is_multisite()) {
1283
+ $options = $config->get_site_options();
1284
+ $enabled = $options[LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED];
1285
+ }
1286
+ else {
1287
+ $options = $config->get_options();
1288
+ $enabled = $options[LiteSpeed_Cache_Config::OPID_ENABLED];
1289
+ }
1290
+ $content = '';
1291
+ $site_content = '';
1292
+ if (!self::is_file_able(self::RW)) {
1293
+ return '';
1294
+ }
1295
+ if (self::file_get($content) === false) {
1296
+ return '';
1297
+ }
1298
+
1299
+ if ($enabled) {
1300
+ $this->set_on_upgrade('FAVICON', '^favicon\.ico$', '-',
1301
+ 'E=cache-control:max-age=86400', $content);
1302
+ }
1303
+
1304
+ $home_cookie = $this->parse_existing_login_cookie($content);
1305
+ if (!self::is_subdir()) {
1306
+ if ($enabled) {
1307
+ $this->set_on_upgrade('RESOURCE', 'wp-content/.*/(loader|fonts)\.php',
1308
+ '-', 'E=cache-control:max-age=3600', $content);
1309
+ }
1310
+ self::file_save($content, false);
1311
+ return $home_cookie;
1312
+ }
1313
+ $site_path = self::get_site_path();
1314
+
1315
+ if (self::file_get($site_content, $site_path) === false) {
1316
+ return '';
1317
+ }
1318
+
1319
+ if ($enabled) {
1320
+ $this->set_on_upgrade('RESOURCE', 'wp-content/.*/(loader|fonts)\.php',
1321
+ '-', 'E=cache-control:max-age=3600', $site_content);
1322
+ }
1323
+
1324
+ $site_cookie = $this->parse_existing_login_cookie($site_content);
1325
+ if ((empty($home_cookie) && !empty($site_cookie))
1326
+ || (!empty($home_cookie) && empty($site_cookie))
1327
+ || ($home_cookie != $site_cookie)) {
1328
+ LiteSpeed_Cache_Admin_Display::get_instance()->add_notice(
1329
+ LiteSpeed_Cache_Admin_Display::NOTICE_YELLOW,
1330
+ LiteSpeed_Cache_Admin_Error::get_error(
1331
+ LiteSpeed_Cache_Admin_Error::E_LC_MISMATCH)
1332
+ . '<br>' . self::get_home_path() . ': ' . $home_cookie
1333
+ . '<br>' . $site_path . ': ' . $site_cookie);
1334
+ return 'err';
1335
+ }
1336
+ self::file_save($content, false);
1337
+ self::file_save($site_content, false, $site_path);
1338
+ return $home_cookie;
1339
+ }
1340
+
1341
+ /**
1342
+ * Validate common rewrite rules configured by the admin.
1343
+ *
1344
+ * @since 1.0.4
1345
+ * @access public
1346
+ * @param array $diff The rules that need to be set.
1347
+ * @param array $errors Returns error messages added if failed.
1348
+ * @return mixed Returns updated options array on success, false otherwise.
1349
+ */
1350
+ public function validate_common_rewrites($diff, &$errors)
1351
+ {
1352
+ $content = '';
1353
+ $buf = "\n";
1354
+ $before = '';
1355
+ $after = '';
1356
+
1357
+ if (self::file_get($content) === false) {
1358
+ $errors[] = $content;
1359
+ return false;
1360
+ }
1361
+
1362
+ $haystack = $this->file_split($content, $before, $after);
1363
+ if ($haystack === false) {
1364
+ $errors[] = $buf;
1365
+ return false;
1366
+ }
1367
+
1368
+ if (is_openlitespeed()) {
1369
+ $id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE;
1370
+ if ($diff[$id]) {
1371
+ $diff[$id] .= ',wp-postpass_' . COOKIEHASH;
1372
+ }
1373
+ else {
1374
+ $diff[$id] = 'wp-postpass_' . COOKIEHASH;
1375
+ }
1376
+
1377
+ $tp_cookies = apply_filters('litespeed_cache_get_vary', array());
1378
+ if ((!empty($tp_cookies)) && (is_array($tp_cookies))) {
1379
+ $diff[$id] .= ',' . implode(',', $tp_cookies);
1380
+ }
1381
+ }
1382
+
1383
+ $id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST;
1384
+
1385
+ if (isset($diff[$id])) {
1386
+ if ($diff[$id]) {
1387
+ $ret = $this->set_common_rule($haystack, $buf, 'MOBILE VIEW',
1388
+ 'HTTP_USER_AGENT', $diff[$id],
1389
+ 'E=Cache-Control:vary=ismobile', 'NC');
1390
+ }
1391
+ else {
1392
+ $ret = $this->set_common_rule($haystack, $buf,
1393
+ 'MOBILE VIEW', '', '', '');
1394
+ }
1395
+ $this->parse_ret($ret, $haystack, $errors);
1396
+ }
1397
+
1398
+ $id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES;
1399
+
1400
+ if (isset($diff[$id])) {
1401
+ $ret = $this->set_common_rule($haystack, $buf, 'COOKIE',
1402
+ 'HTTP_COOKIE', $diff[$id], 'E=Cache-Control:no-cache');
1403
+ $this->parse_ret($ret, $haystack, $errors);
1404
+ }
1405
+
1406
+ $id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS;
1407
+ if (isset($diff[$id])) {
1408
+ $ret = $this->set_common_rule($haystack, $buf, 'USER AGENT',
1409
+ 'HTTP_USER_AGENT', $diff[$id], 'E=Cache-Control:no-cache');
1410
+ $this->parse_ret($ret, $haystack, $errors);
1411
+ }
1412
+
1413
+ if (((isset($diff[LiteSpeed_Cache_Config::OPID_CACHE_RES]))
1414
+ || (isset($diff[LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE])))
1415
+ && ($this->set_subdir_cookie($diff, $haystack, $buf, $errors)
1416
+ === false)) {
1417
+ return false;
1418
+ }
1419
+
1420
+ $id = LiteSpeed_Cache_Config::OPID_CACHE_FAVICON;
1421
+
1422
+ if (isset($diff[$id])) {
1423
+ $ret = $this->set_favicon($haystack, $diff[$id], $buf, $errors);
1424
+ if ($ret !== false) {
1425
+ $haystack = $ret;
1426
+ }
1427
+
1428
+ }
1429
+
1430
+ $ret = $this->file_combine($before, $haystack . $buf, $after);
1431
+ if ($ret !== true) {
1432
+ $errors[] = LiteSpeed_Cache_Admin_Error::get_error(
1433
+ LiteSpeed_Cache_Admin_Error::E_HTA_PUT
1434
+ );
1435
+ return false;
1436
+ }
1437
+ return $diff;
1438
+ }
1439
+
1440
+ /**
1441
+ * Clear the rules file of any changes added by the plugin specifically.
1442
+ *
1443
+ * @since 1.0.4
1444
+ * @access public
1445
+ * @param string $wrapper A wrapper to a specific rule to match.
1446
+ */
1447
+ public static function clear_rules($wrapper = '')
1448
+ {
1449
+ $content = '';
1450
+ $site_content = '';
1451
+
1452
+ clearstatcache();
1453
+ if (self::file_get($content) === false) {
1454
+ return;
1455
+ }
1456
+ elseif (!self::is_file_able(self::WRITABLE)) {
1457
+ return;
1458
+ }
1459
+
1460
+ if (empty($wrapper)) {
1461
+ $wrapper = self::$RW_WRAPPER;
1462
+ }
1463
+ $pattern = '/###LSCACHE START ' . $wrapper
1464
+ . '###.*###LSCACHE END ' . $wrapper . '###\n?/s';
1465
+ $buf = preg_replace($pattern, '', $content);
1466
+
1467
+ self::file_save($buf, false);
1468
+
1469
+ if (!self::is_subdir()) {
1470
+ return;
1471
+ }
1472
+ $site_path = self::get_site_path();
1473
+ if (self::file_get($site_content, $site_path) === false) {
1474
+ return;
1475
+ }
1476
+
1477
+ if (empty($wrapper)) {
1478
+ $wrapper = self::$RW_WRAPPER;
1479
+ }
1480
+ $pattern = '/###LSCACHE START ' . $wrapper
1481
+ . '###.*###LSCACHE END ' . $wrapper . '###\n?/s';
1482
+ $site_buf = preg_replace($pattern, '', $site_content);
1483
+ self::file_save($site_buf, false, $site_path);
1484
+
1485
+ return;
1486
+ }
1487
+
1488
+ /**
1489
+ * Parses the .htaccess buffer when the admin saves changes in the edit
1490
+ * .htaccess page.
1491
+ *
1492
+ * @since 1.0.4
1493
+ * @access public
1494
+ */
1495
+ public static function htaccess_editor_save()
1496
+ {
1497
+ if ((is_multisite()) && (!is_network_admin())) {
1498
+ return;
1499
+ }
1500
+ if (empty($_POST) || empty($_POST['submit'])) {
1501
+ return;
1502
+ }
1503
+ if ((isset($_POST[self::EDITOR_INPUT_NAME]))
1504
+ && ($_POST[self::EDITOR_INPUT_NAME] === self::EDITOR_INPUT_VAL)
1505
+ && (check_admin_referer(self::EDITOR_NONCE_NAME,
1506
+ self::EDITOR_NONCE_VAL))
1507
+ && (isset($_POST[self::EDITOR_TEXTAREA_NAME]))) {
1508
+ $msg = self::file_save($_POST[self::EDITOR_TEXTAREA_NAME]);
1509
+ if ($msg === true) {
1510
+ $msg = __('File Saved.', 'litespeed-cache');
1511
+ $color = LiteSpeed_Cache_Admin_Display::NOTICE_GREEN;
1512
+ }
1513
+ else {
1514
+ $color = LiteSpeed_Cache_Admin_Display::NOTICE_RED;
1515
+ }
1516
+ LiteSpeed_Cache_Admin_Display::get_instance()->add_notice($color, $msg);
1517
+ }
1518
+
1519
+ }
1520
+ }
admin/class-litespeed-cache-admin.php CHANGED
@@ -1,7 +1,1218 @@
1
  <?php
 
2
  /**
3
- * ONLY for WHM plugin old version backward compatibility @Aug/2/2017
 
 
 
 
 
 
4
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- require_once dirname(__FILE__) . '/litespeed-cache-admin.class.php' ;
1
  <?php
2
+
3
  /**
4
+ * The admin-panel specific functionality of the plugin.
5
+ *
6
+ *
7
+ * @since 1.0.0
8
+ * @package LiteSpeed_Cache
9
+ * @subpackage LiteSpeed_Cache/admin
10
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
11
  */
12
+ class LiteSpeed_Cache_Admin
13
+ {
14
+
15
+ /**
16
+ * The ID of this plugin.
17
+ *
18
+ * @since 1.0.0
19
+ * @access private
20
+ * @var string $plugin_name The ID of this plugin.
21
+ */
22
+ private $plugin_name;
23
+
24
+ /**
25
+ * The version of this plugin.
26
+ *
27
+ * @since 1.0.0
28
+ * @access private
29
+ * @var string $version The current version of this plugin.
30
+ */
31
+ private $version;
32
+
33
+ /**
34
+ * Initialize the class and set its properties.
35
+ *
36
+ * @since 1.0.0
37
+ * @param string $plugin_name The name of this plugin.
38
+ * @param string $version The version of this plugin.
39
+ */
40
+ public function __construct($plugin_name, $version)
41
+ {
42
+ $this->plugin_name = $plugin_name;
43
+ $this->version = $version;
44
+ $plugin_file = plugin_dir_path(dirname(__FILE__)) . $plugin_name . '.php';
45
+ if (defined('lscache_debug')) {
46
+ require_once(ABSPATH . '/wp-admin/includes/file.php');
47
+ $plugin_file = ABSPATH . '/wp-content/plugins/litespeed-cache/' . $plugin_name . '.php';
48
+ }
49
+
50
+ $plugin_base = plugin_basename($plugin_file);
51
+
52
+ if (!function_exists('is_plugin_active_for_network')) {
53
+ require_once(ABSPATH . '/wp-admin/includes/plugin.php');
54
+ }
55
+
56
+ if(!empty($_GET['page']) && (substr($_GET['page'], 0, 8) == 'lscache-' || $_GET['page'] == 'litespeedcache')){
57
+ add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
58
+ }
59
+ add_action('admin_print_styles-settings_page_litespeedcache',
60
+ array($this, 'enqueue_style'));
61
+
62
+
63
+ //Additional links on the plugin page
64
+ if ((is_network_admin()) && (is_plugin_active_for_network($plugin_base))) {
65
+ add_action('network_admin_menu', array($this, 'register_admin_menu'));
66
+ }
67
+ else {
68
+ add_action('admin_menu', array($this, 'register_admin_menu'));
69
+ }
70
+
71
+ add_action('admin_init', array($this, 'admin_init'));
72
+ add_filter('plugin_action_links_' . $plugin_base,
73
+ array($this, 'add_plugin_links'));
74
+ }
75
+
76
+ /**
77
+ * Register the stylesheets for the admin area.
78
+ *
79
+ * @since 1.0.14
80
+ */
81
+ public function enqueue_style()
82
+ {
83
+ wp_enqueue_style($this->plugin_name,
84
+ plugin_dir_url(__FILE__) . 'css/litespeed-cache-admin.css',
85
+ array(), $this->version, 'all');
86
+ }
87
+
88
+ /**
89
+ * Register the JavaScript for the admin area.
90
+ *
91
+ * @since 1.0.0
92
+ */
93
+ public function enqueue_scripts()
94
+ {
95
+ wp_register_script($this->plugin_name,
96
+ plugin_dir_url(__FILE__) . 'js/litespeed-cache-admin.js',
97
+ array('jquery-ui-tabs'), $this->version, false);
98
+ if (get_transient(LiteSpeed_Cache::WHM_TRANSIENT)
99
+ === LiteSpeed_Cache::WHM_TRANSIENT_VAL
100
+ ) {
101
+ $data = array(
102
+ 'lscwpctrl' => LiteSpeed_Cache::ADMINQS_DISMISS,
103
+ 'nonce' => wp_create_nonce('litespeed-dismiss')
104
+ );
105
+ wp_localize_script($this->plugin_name, 'lscwp_data', $data);
106
+
107
+ }
108
+ wp_enqueue_script('jquery-ui-tabs');
109
+ wp_enqueue_script($this->plugin_name);
110
+ }
111
+
112
+ /**
113
+ * Register the admin menu display.
114
+ *
115
+ * @since 1.0.0
116
+ */
117
+ public function register_admin_menu()
118
+ {
119
+ $capability = is_network_admin() ? 'manage_network_options' : 'manage_options';
120
+ if (current_user_can($capability)) {
121
+ $display = LiteSpeed_Cache_Admin_Display::get_instance();
122
+
123
+ $this->register_dash_menu();
124
+
125
+ $lscache_admin_settings_page = add_options_page('LiteSpeed Cache',
126
+ 'LiteSpeed Cache', $capability, 'litespeedcache',
127
+ array($display, 'show_menu_settings'));
128
+ // adds help tab
129
+ add_action('load-' . $lscache_admin_settings_page,
130
+ array($display, 'add_help_tabs'));
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Builds an admin url with an action and a nonce.
136
+ *
137
+ * Assumes user capabilities are already checked.
138
+ *
139
+ * @param string $val The LSCWP_CTRL action to do in the url.
140
+ * @param string $nonce The nonce to use.
141
+ * @return string The built url.
142
+ */
143
+ public static function build_lscwpctrl_url($val, $nonce)
144
+ {
145
+ global $pagenow;
146
+ $prefix = '?';
147
+
148
+ $params = $_GET;
149
+
150
+ if (!empty($params)) {
151
+ if (isset($params['LSCWP_CTRL'])) {
152
+ unset($params['LSCWP_CTRL']);
153
+ }
154
+ if (isset($params['_wpnonce'])) {
155
+ unset($params['_wpnonce']);
156
+ }
157
+ if (!empty($params)) {
158
+ $prefix .= http_build_query($params) . '&';
159
+ }
160
+ }
161
+
162
+ $combined = $pagenow . $prefix . LiteSpeed_Cache::ADMINQS_KEY
163
+ . '=' . $val;
164
+
165
+ if (is_network_admin()) {
166
+ $prenonce = network_admin_url($combined);
167
+ }
168
+ else {
169
+ $prenonce = admin_url($combined);
170
+ }
171
+ $url = wp_nonce_url($prenonce, $nonce);
172
+
173
+ return $url;
174
+ }
175
+
176
+ /**
177
+ * Hooked to wp_before_admin_bar_render.
178
+ * Adds a link to the admin bar so users can quickly purge all.
179
+ *
180
+ * @global WP_Admin_Bar $wp_admin_bar
181
+ * @global string $pagenow
182
+ */
183
+ public function add_quick_purge()
184
+ {
185
+ global $wp_admin_bar;
186
+ $url = self::build_lscwpctrl_url(LiteSpeed_Cache::ADMINQS_PURGEALL,
187
+ 'litespeed-purgeall');
188
+
189
+ $wp_admin_bar->add_node(array(
190
+ 'id' => 'lscache-quick-purge',
191
+ 'title' => __('LiteSpeed Cache Purge All', 'litespeed-cache'),
192
+ 'href' => $url,
193
+ ));
194
+ }
195
+
196
+ /**
197
+ * Helper function to set up a submenu page.
198
+ *
199
+ * @since 1.0.4
200
+ * @access private
201
+ * @param string $page_title The page title.
202
+ * @param string $menu_title The title that appears on the menu.
203
+ * @param string $menu_slug The slug of the page.
204
+ * @param string $cb The callback to call if selected.
205
+ */
206
+ private function add_submenu($page_title, $menu_title, $menu_slug, $cb = '')
207
+ {
208
+ $fn = '';
209
+ $display = LiteSpeed_Cache_Admin_Display::get_instance();
210
+ if (!empty($cb)) {
211
+ $fn = array($display, $cb);
212
+ }
213
+ $submenu_page = add_submenu_page('lscache-dash', $page_title,
214
+ $menu_title, 'manage_options', $menu_slug, $fn);
215
+ add_action('load-' . $submenu_page, array($display, 'add_help_tabs'));
216
+ add_action("admin_print_styles-{$submenu_page}", array($this, 'enqueue_style'));
217
+ }
218
+
219
+ /**
220
+ * Registers management submenu pages.
221
+ *
222
+ * @since 1.0.4
223
+ * @access private
224
+ */
225
+ private function register_submenu_manage()
226
+ {
227
+ $this::add_submenu(sprintf(__('%s Manager', 'litespeed-cache'), 'LiteSpeed Cache'),
228
+ __('Manage', 'litespeed-cache'), 'lscache-dash', 'show_menu_select');
229
+ }
230
+
231
+ /**
232
+ * Registers settings submenu pages.
233
+ *
234
+ * @since 1.0.4
235
+ * @access private
236
+ */
237
+ private function register_submenu_settings()
238
+ {
239
+ $this::add_submenu(sprintf(__('%s Settings', 'litespeed-cache'), 'LiteSpeed Cache'),
240
+ __('Settings', 'litespeed-cache'), 'lscache-settings', 'show_menu_select');
241
+
242
+ if ((!is_multisite()) || (is_network_admin())) {
243
+ $this::add_submenu(sprintf(__('%s Edit .htaccess', 'litespeed-cache'), 'LiteSpeed Cache'),
244
+ sprintf(__('Edit %s', 'litespeed-cache'), '.htaccess'), 'lscache-edit-htaccess', 'show_menu_select');
245
+ }
246
+
247
+ }
248
+
249
+ /**
250
+ * Registers informational submenu pages.
251
+ *
252
+ * @since 1.0.4
253
+ * @access private
254
+ */
255
+ private function register_submenu_info()
256
+ {
257
+ $this::add_submenu(sprintf(__('%s Information', 'litespeed-cache'), 'LiteSpeed Cache'),
258
+ __('Information', 'litespeed-cache'), 'lscache-info', 'show_menu_select');
259
+ if ((!is_multisite()) ||
260
+ ((is_network_admin()) && (current_user_can('manage_network_options')))
261
+ ) {
262
+ $this::add_submenu(sprintf(__('%s Environment Report', 'litespeed-cache'), 'LiteSpeed Cache'),
263
+ __('Environment Report', 'litespeed-cache'), 'lscache-report', 'show_menu_select');
264
+ }
265
+
266
+ }
267
+
268
+ /**
269
+ * Registers all the submenu page types.
270
+ *
271
+ * @since 1.0.4
272
+ * @access private
273
+ */
274
+ private function register_submenus()
275
+ {
276
+ $this->register_submenu_manage();
277
+ $this->register_submenu_settings();
278
+ $this->register_submenu_info();
279
+
280
+ }
281
+
282
+ /**
283
+ * Registers the submenu options for the LiteSpeed Cache menu option.
284
+ *
285
+ * @since 1.0.4
286
+ * @access private
287
+ */
288
+ private function register_dash_menu()
289
+ {
290
+ $svg =
291
+ 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vV' .
292
+ 'zNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvb' .
293
+ 'j0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vc' .
294
+ 'mcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIzNjBweCIgaGVpZ2h0PSIzNjBweCIgdmlld0JveD0iMCAwIDM2MCAzNjAiIGVuY' .
295
+ 'WJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDM2MCAzNjAiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwYXRoIGZpbGw9IiMyNzI1MjUiIGQ9Ik0zNTguM' .
296
+ 'zA1LDE3OC45MTNjLTAuMDMzLTAuMTY1LTAuMDk1LTAuMzIyLTAuMTQyLTAuNDgzYy0wLjA1NS0wLjE4Ny0wLjEtMC4zNzYtMC4xNzQtMC41NTJjL' .
297
+ 'TAuMDc4LTAuMTkzLTAuMTg3LTAuMzczLTAuMjg5LTAuNTUyYy0wLjA3Mi0wLjEzNS0wLjEzNC0wLjI3Ny0wLjIxOS0wLjQwNWMtMC4yMDEtMC4zL' .
298
+ 'TAuNDMxLTAuNTg1LTAuNjk1LTAuODUybC0wLjAwNS0wLjAwNEwxODMuOTMyLDMuMjE2bC0wLjAwNS0wLjAwN2MtMC4wMTQtMC4wMTEtMC4wMjktM' .
299
+ 'C4wMjItMC4wNDMtMC4wMzNjLTEuMDAxLTAuOTgzLTIuMzctMS41OTMtMy44ODUtMS41OTNjLTEuNTE3LDAtMi44ODUsMC42MS0zLjg4NiwxLjU5M' .
300
+ '2MtMC4wMTUsMC4wMTEtMC4wMzEsMC4wMjItMC4wNDQsMC4wMzNsLTAuMDA0LDAuMDA3TDMuMjE0LDE3Ni4wNjVsLTAuMDAzLDAuMDA0Yy0wLjI2N' .
301
+ 'SwwLjI2Ny0wLjQ5NSwwLjU1Mi0wLjY5NiwwLjg1MmMtMC4wODUsMC4xMjctMC4xNDQsMC4yNy0wLjIxOSwwLjQwNWMtMC4xLDAuMTc5LTAuMjEyL' .
302
+ 'DAuMzU4LTAuMjg5LDAuNTUyYy0wLjA3NSwwLjE3Ni0wLjExNywwLjM2NS0wLjE3MSwwLjU1MmMtMC4wNDksMC4xNjEtMC4xMTEsMC4zMTgtMC4xN' .
303
+ 'DMsMC40ODNjLTAuMDcyLDAuMzU0LTAuMTEsMC43MTYtMC4xMSwxLjA4OGMwLDAuMzczLDAuMDM4LDAuNzM0LDAuMTEsMS4wODZjMC4wMzEsMC4xN' .
304
+ 'jQsMC4wOTMsMC4zMiwwLjE0MywwLjQ4MWMwLjA1NSwwLjE4NywwLjA5NywwLjM4MiwwLjE3MSwwLjU1OGMwLjA3NywwLjE4OSwwLjE4OCwwLjM2O' .
305
+ 'SwwLjI4OSwwLjU1MmMwLjA3NSwwLjEzNSwwLjEzNCwwLjI3MywwLjIxOSwwLjQwNWMwLjIwMSwwLjI5NiwwLjQzMSwwLjU4NSwwLjY5NiwwLjg0O' .
306
+ 'GwwLjAwMywwLjAwNGwxNzIuODUsMTcyLjg1bDAuMDA1LDAuMDA3YzAuMjU5LDAuMjYxLDAuNTQxLDAuNDg2LDAuODQyLDAuNjg4YzAuMDU5LDAuM' .
307
+ 'DQsMC4xMjYsMC4wNjYsMC4xODgsMC4xMDVjMC4yNDcsMC4xNDYsMC40OTcsMC4yOTcsMC43NjUsMC40MDZjMC4wOTksMC4wNDQsMC4yMSwwLjA2M' .
308
+ 'iwwLjMxNCwwLjA5OWMwLjIzOCwwLjA4NCwwLjQ3MywwLjE2NywwLjcyMiwwLjIyYzAuMzU0LDAuMDY4LDAuNzIyLDAuMTA4LDEuMDk5LDAuMTA4Y' .
309
+ 'zAuMzc0LDAsMC43NDMtMC4wNCwxLjA5OC0wLjEwOGMwLjI0Ny0wLjA1MywwLjQ4My0wLjEzNiwwLjcyLTAuMjJjMC4xMDQtMC4wMzcsMC4yMTYtM' .
310
+ 'C4wNTUsMC4zMTUtMC4wOTljMC4yNjctMC4xMDksMC41MTgtMC4yNjEsMC43NjctMC40MDZjMC4wNi0wLjAzOSwwLjEyOS0wLjA2NSwwLjE4Ny0wL' .
311
+ 'jEwNWMwLjMwMS0wLjIwMSwwLjU4My0wLjQyNywwLjg0Mi0wLjY4OGwwLjAwNS0wLjAwN2wxNzIuODUtMTcyLjg1bDAuMDA1LTAuMDA0YzAuMjY1L' .
312
+ 'TAuMjYzLDAuNDk0LTAuNTUyLDAuNjk1LTAuODQ4YzAuMDg1LTAuMTMyLDAuMTQ2LTAuMjcxLDAuMjE5LTAuNDA1YzAuMTAzLTAuMTgzLDAuMjExL' .
313
+ 'TAuMzYyLDAuMjg5LTAuNTUyYzAuMDc0LTAuMTc2LDAuMTE5LTAuMzcxLDAuMTc0LTAuNTU4YzAuMDQ3LTAuMTYxLDAuMTA4LTAuMzE3LDAuMTQyL' .
314
+ 'TAuNDgxYzAuMDY5LTAuMzUyLDAuMTExLTAuNzEzLDAuMTExLTEuMDg2QzM1OC40MTcsMTc5LjYyOCwzNTguMzc1LDE3OS4yNjYsMzU4LjMwNSwxN' .
315
+ 'zguOTEzeiBNMzMwLjg1NCwxODAuMzEzbC0wLjA1OSwwLjE1NmwtMC4wNDgsMC4xN2wtMC4xNzMsMC4zMDljLTAuMDQzLDAuMDU5LTAuMDk3LDAuM' .
316
+ 'TIyLTAuMTU2LDAuMTgxTDE4MS4xMzYsMzMwLjQxM2MtMC4wNTMsMC4wNTYtMC4xMDUsMC4xMDItMC4xNjIsMC4xNDJjLTAuMDUsMC4wMzMtMC4yN' .
317
+ 'DUsMC4xNDktMC4yOTksMC4xNzhsLTAuNDEsMC4xMzVjLTAuMDQ3LDAuMDExLTAuMTU2LDAuMDIxLTAuMjY3LDAuMDIxYy0wLjExMSwwLTAuMjE4L' .
318
+ 'TAuMDExLTAuMzIzLTAuMDM0YzAsMC0wLjI4NS0wLjEwMi0wLjM0OS0wLjEyMmMtMC4wNjYtMC4wMzUtMC4zMDktMC4xOC0wLjMwOS0wLjE4Yy0wL' .
319
+ 'jA1Ny0wLjA0Ni0wLjEwNC0wLjA4Ny0wLjE1LTAuMTM0TDI5LjU4NCwxODEuMTM2Yy0wLjA1OS0wLjA2LTAuMTEtMC4xMjEtMC4xNTYtMC4xODVsL' .
320
+ 'TAuMTgzLTAuMzM2bC0wLjEyLTAuMzkyYy0wLjAwMi0wLjAxNC0wLjAxNi0wLjExNS0wLjAxNi0wLjIyM2MwLTAuMTA3LDAuMDE0LTAuMjExLDAuM' .
321
+ 'DM1LTAuMzEybDAuMDYtMC4xNTZsMC4wNTMtMC4xODFsMC4wNzktMC4xMjVsMC4wOTMtMC4xODFjMC4wNDctMC4wNjMsMC4wOTYtMC4xMjUsMC4xN' .
322
+ 'DktMC4xNzhMMTc4LjkwMSwyOS41NTNjMC4xNTgtMC4xNTMsMC41MzYtMC40NDMsMS4wOTktMC40NDNzMC45NDIsMC4yOSwxLjExOCwwLjQ2NGwxN' .
323
+ 'DkuMjk3LDE0OS4yODljMC4wNTksMC4wNTksMC4xMDksMC4xMjEsMC4xNTMsMC4xODRsMC4xOCwwLjMyOWwwLjEyNCwwLjM5NmMwLjAwMiwwLjAxO' .
324
+ 'CwwLjAxNywwLjEyMiwwLjAxNywwLjIyOUMzMzAuODg4LDE4MC4xMDgsMzMwLjg3NCwxODAuMjA5LDMzMC44NTQsMTgwLjMxM3ogTTI2OC43ODcsM' .
325
+ 'Tc5LjQ2MmMtMC4wMjEtMC4wNzktMC4wNTUtMC4xNi0wLjA3NC0wLjI0Yy0wLjAyNS0wLjA5My0wLjA0Ny0wLjE4OC0wLjA4Ni0wLjI3NWMtMC4wM' .
326
+ 'zktMC4wOTQtMC4wOTItMC4xODctMC4xNDUtMC4yNzJjLTAuMDM3LTAuMDY5LTAuMDY2LTAuMTQyLTAuMTA5LTAuMjA0Yy0wLjA5OC0wLjE0OC0wL' .
327
+ 'jIxOS0wLjI5LTAuMzQyLTAuNDIxbC0wLjAwNi0wLjAwN0wxODEuOTYsOTEuOTc5bC0wLjAwNi0wLjAwNGMtMC4wMDYtMC4wMDQtMC4wMTYtMC4wM' .
328
+ 'TMtMC4wMi0wLjAxOWMtMC40OTgtMC40ODgtMS4xNzgtMC43OTMtMS45MzUtMC43OTNjLTAuNzUyLDAtMS40MzcsMC4zMDUtMS45MzUsMC43OTNjL' .
329
+ 'TAuMDA3LDAuMDA2LTAuMDE1LDAuMDE1LTAuMDIsMC4wMTlsLTAuMDA0LDAuMDA0bC04Ni4wNjYsODYuMDYzbC0wLjAwMSwwLjAwN2MtMC4xMzIsM' .
330
+ 'C4xMzEtMC4yNDgsMC4yNzItMC4zNDcsMC40MjFjLTAuMDQ1LDAuMDYzLTAuMDcxLDAuMTM1LTAuMTA4LDAuMjA0Yy0wLjA1MywwLjA4Ni0wLjEwN' .
331
+ 'iwwLjE3OS0wLjE0MywwLjI3MmMtMC4wMzksMC4wODgtMC4wNTksMC4xODMtMC4wODcsMC4yNzVjLTAuMDI2LDAuMDgtMC4wNTgsMC4xNjEtMC4wN' .
332
+ 'zMsMC4yNGMtMC4wMzYsMC4xNzctMC4wNTQsMC4zNTgtMC4wNTQsMC41NDZjMCwwLjE4MywwLjAxOCwwLjM2MSwwLjA1NCwwLjUzNmMwLjAxNiwwL' .
333
+ 'jA4MiwwLjA0NywwLjE2LDAuMDczLDAuMjQ1YzAuMDI4LDAuMDg5LDAuMDQ4LDAuMTg0LDAuMDg3LDAuMjcxYzAuMDM2LDAuMDk0LDAuMDksMC4xO' .
334
+ 'DYsMC4xNDMsMC4yNzdjMC4wMzcsMC4wNjQsMC4wNjMsMC4xMzcsMC4xMDgsMC4xOTljMC4wOTksMC4xNDgsMC4yMTUsMC4yODksMC4zNDcsMC40M' .
335
+ 'jJsMC4wMDEsMC4wMDJsODYuMDY1LDg2LjA3bDAuMDA1LDAuMDAyYzAuMTMsMC4xMjksMC4yNzEsMC4yNDIsMC40MTgsMC4zNGMwLjAyOSwwLjAyM' .
336
+ 'ywwLjA2NSwwLjAzMywwLjA5NSwwLjA1MWMwLjEyMiwwLjA3NiwwLjI0OSwwLjE1NCwwLjM4MSwwLjIwN2MwLjA0OCwwLjAyLDAuMTA1LDAuMDI1L' .
337
+ 'DAuMTU1LDAuMDQzYzAuMTE1LDAuMDQ3LDAuMjMzLDAuMDg2LDAuMzYsMC4xMTNjMC4xNzcsMC4wMzUsMC4zNTgsMC4wNTEsMC41NDUsMC4wNTFjM' .
338
+ 'C4xODgsMCwwLjM3Mi0wLjAxNiwwLjU0OS0wLjA1MWMwLjEyMi0wLjAyNywwLjI0LTAuMDY2LDAuMzU3LTAuMTEzYzAuMDUyLTAuMDE4LDAuMTA3L' .
339
+ 'TAuMDIzLDAuMTYtMC4wNDNjMC4xMzEtMC4wNTMsMC4yNTYtMC4xMzEsMC4zNzktMC4yMDdjMC4wMjktMC4wMTgsMC4wNjYtMC4wMjcsMC4wOTQtM' .
340
+ 'C4wNTFjMC4xNS0wLjA5OCwwLjI5MS0wLjIxMSwwLjQxNi0wLjM0bDAuMDA2LTAuMDAybDg2LjA2NC04Ni4wN2wwLjAwNi0wLjAwMmMwLjEyMy0wL' .
341
+ 'jEzMywwLjI0NC0wLjI3MywwLjM0Mi0wLjQyMmMwLjA0My0wLjA2MywwLjA3Mi0wLjEzNSwwLjEwOS0wLjE5OWMwLjA1My0wLjA5MiwwLjEwNS0wL' .
342
+ 'jE4NCwwLjE0NS0wLjI3N2MwLjAzOS0wLjA4NywwLjA2MS0wLjE4MiwwLjA4Ni0wLjI3MWMwLjAyLTAuMDg1LDAuMDUzLTAuMTYzLDAuMDc0LTAuM' .
343
+ 'jQ1YzAuMDMxLTAuMTc1LDAuMDUxLTAuMzU0LDAuMDUxLTAuNTM2QzI2OC44MzcsMTc5LjgyLDI2OC44MTgsMTc5LjYzOSwyNjguNzg3LDE3OS40N' .
344
+ 'jJ6IE0yMTIuNjExLDEzMy4wMmwtMjcuNTQ1LDM0Ljk1MmwxNC45MTIsMjEuNDQ2YzAuMDE4LDAuMDI1LDAuMDM1LDAuMDUzLDAuMDU1LDAuMDhjM' .
345
+ 'C4yNSwwLjM4OSwwLjQzMiwwLjc4MSwwLjU2MSwxLjI1NmMwLjg4MSwzLjQzOSwwLjI2Miw2LjE3LTEuNzI1LDcuNjc2bC00NS4yMzksMzQuNzIzY' .
346
+ 'y0wLjc3OSwwLjYxNS0xLjg2MywxLjMyNC0zLjMxNSwxLjMyNGMtMS42MTMsMC0zLjEwNC0wLjkzMi0zLjc4Ni0yLjM0OGMtMC44MTktMS42NTItM' .
347
+ 'C41MTktMy40LDAuODkxLTUuMTkzbDI3LjUzNy0zNC45NTlsLTE1LjEzLTIxLjc2OWMtMS45MzQtMi43NDYtMS4zMzMtNi42NDUsMS4zMzMtOC42O' .
348
+ 'DRsNDUuMjY4LTM0Ljc1MWMwLjc4MS0wLjYwNCwxLjg1OS0xLjI5NiwzLjI4MS0xLjI5NmMxLjYwOSwwLDMuMTAyLDAuOTMsMy44MDUsMi4zNzRDM' .
349
+ 'jE0LjMwOCwxMjkuNDg3LDIxNC4wMDcsMTMxLjIyMSwyMTIuNjExLDEzMy4wMnogTTgyLjAzNywxOTAuMDJsODcuODIyLDg3LjgyNnYyMC40NEw2M' .
350
+ 'S41OSwxOTAuMDJIODIuMDM3eiBNMTY5Ljg1OSw4Mi4xNjZsLTg3LjgxOCw4Ny44MTVINjEuNTlMMTY5Ljg1OSw2MS43MTNWODIuMTY2eiBNMjc3L' .
351
+ 'jk3NiwxOTAuMDA3aDE5LjEzNUwxODguODM0LDI5OC4yODd2LTE5LjEzMUwyNzcuOTc2LDE5MC4wMDd6IE0yNzcuOTY5LDE2OS45OWwtODkuMTM1L' .
352
+ 'Tg5LjEzNFY2MS43MTNMMjk4LjQxLDE2OS45OUgyNzcuOTY5eiIvPjwvc3ZnPg==';
353
+ add_menu_page('LiteSpeed Cache', 'LiteSpeed Cache', 'manage_options',
354
+ 'lscache-dash', '', $svg);
355
+ $this->register_submenus();
356
+ }
357
+
358
+ /**
359
+ * Callback that initializes the admin options for LiteSpeed Cache.
360
+ *
361
+ * @since 1.0.0
362
+ * @access public
363
+ */
364
+ public function admin_init()
365
+ {
366
+ $config = LiteSpeed_Cache::config();
367
+ // check for upgrade
368
+ $config->plugin_upgrade();
369
+ if ((is_network_admin()) && (current_user_can('manage_network_options'))) {
370
+ $config->plugin_site_upgrade();
371
+ }
372
+
373
+ // check management action
374
+ if ($config->is_plugin_enabled()) {
375
+ $this->check_cache_mangement_actions();
376
+ if ((defined('WP_CACHE')) && (constant('WP_CACHE') === true)) {
377
+ $this->check_advanced_cache();
378
+ }
379
+ }
380
+
381
+ $option_name = LiteSpeed_Cache_Config::OPTION_NAME;
382
+ if (!is_network_admin()) {
383
+ register_setting($option_name, $option_name,
384
+ array($this, 'validate_plugin_settings'));
385
+ }
386
+
387
+ if (!is_multisite()) {
388
+ if (!current_user_can('manage_options')) {
389
+ return;
390
+ }
391
+ }
392
+ elseif (!is_network_admin()) {
393
+ if (!current_user_can('manage_options')) {
394
+ return;
395
+ }
396
+ if ((get_current_blog_id() !== BLOG_ID_CURRENT_SITE)) {
397
+ $use_primary = LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY;
398
+ $site_options = $config->get_site_options();
399
+ if (isset($site_options[$use_primary])
400
+ && ($site_options[$use_primary])
401
+ ) {
402
+ LiteSpeed_Cache_Admin_Display::get_instance()->set_disable_all();
403
+ }
404
+ }
405
+
406
+ return;
407
+ }
408
+ elseif (!current_user_can('manage_network_options')) {
409
+ return;
410
+ }
411
+
412
+ if (get_transient(LiteSpeed_Cache::WHM_TRANSIENT)
413
+ !== LiteSpeed_Cache::WHM_TRANSIENT_VAL
414
+ ) {
415
+ return;
416
+ }
417
+
418
+ LiteSpeed_Cache_Admin_Display::get_instance()->show_display_installed();
419
+ }
420
+
421
+ /**
422
+ * Checks the admin selected option for enabling the cache.
423
+ *
424
+ * The actual value depends on the type of site.
425
+ *
426
+ * If not set is selected, the default action on multisite is to use
427
+ * the network selection, on singlesite it is enabled.
428
+ *
429
+ * @since 1.0.2
430
+ * @access private
431
+ * @param array $input The input configurations.
432
+ * @param array $options Returns the up to date options array.
433
+ * @return boolean True if enabled, false otherwise.
434
+ */
435
+ private function validate_enabled($input, &$options)
436
+ {
437
+ $id = LiteSpeed_Cache_Config::OPID_ENABLED_RADIO;
438
+ if (!isset($input[$id])) {
439
+ return false;
440
+ }
441
+ $radio_enabled = intval($input[$id]);
442
+ $options[$id] = $radio_enabled;
443
+ if ($radio_enabled != LiteSpeed_Cache_Config::OPID_ENABLED_NOTSET) {
444
+ return $radio_enabled == LiteSpeed_Cache_Config::OPID_ENABLED_ENABLE;
445
+ }
446
+ if (is_multisite()) {
447
+ return $options[LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED];
448
+ }
449
+
450
+ return true;
451
+ }
452
+
453
+ /**
454
+ * Checks the admin selected option for cache tag prefixes.
455
+ *
456
+ * Prefixes are only allowed to be alphanumeric. On failure, will
457
+ * return error message.
458
+ *
459
+ * @since 1.0.9
460
+ * @access private
461
+ * @param array $input The configurations selected by the admin when
462
+ * clicking save.
463
+ * @param array $options The current configuration options.
464
+ * @return mixed True on success, error message otherwise.
465
+ */
466
+ private function validate_tag_prefix($input, &$options)
467
+ {
468
+ $id = LiteSpeed_Cache_Config::OPID_TAG_PREFIX;
469
+ if (!isset($input[$id])) {
470
+ return true;
471
+ }
472
+ $prefix = $input[$id];
473
+ if (($prefix !== '') && (!ctype_alnum($prefix))) {
474
+ $prefix_err = LiteSpeed_Cache_Admin_Display::build_paragraph(
475
+ __('Invalid Tag Prefix input.', 'litespeed-cache'),
476
+ __('Input should only contain letters and numbers.', 'litespeed-cache')
477
+ );
478
+
479
+ return $prefix_err;
480
+ }
481
+ if ($options[$id] !== $prefix) {
482
+ $options[$id] = $prefix;
483
+ LiteSpeed_Cache::plugin()->purge_all();
484
+ }
485
+
486
+ return true;
487
+ }
488
+
489
+ /**
490
+ * Helper function to validate TTL settings. Will check if it's set,
491
+ * is an integer, and is greater than 0 and less than INT_MAX.
492
+ *
493
+ * @since 1.0.12
494
+ * @access private
495
+ * @param array $input Input array
496
+ * @param string $id Option ID
497
+ * @return bool True if valid, false otherwise.
498
+ */
499
+ private function validate_ttl($input, $id)
500
+ {
501
+ if (!isset($input[$id])) {
502
+ return false;
503
+ }
504
+
505
+ $val = $input[$id];
506
+
507
+ $ival = intval($val);
508
+ $sval = strval($val);
509
+
510
+ return ((ctype_digit($sval)) && ($ival >= 0) && ($ival < 2147483647));
511
+ }
512
+
513
+ /**
514
+ * Validates the general settings.
515
+ *
516
+ * @since 1.0.12
517
+ * @access private
518
+ * @param array $input The input options.
519
+ * @param array $options The current options.
520
+ * @param array $errors The errors list.
521
+ */
522
+ private function validate_general(&$input, &$options, &$errors)
523
+ {
524
+ $err = LiteSpeed_Cache_Admin_Error::get_error(
525
+ LiteSpeed_Cache_Admin_Error::E_SETTING_TTL
526
+ );
527
+ $id = LiteSpeed_Cache_Config::OPID_ENABLED;
528
+ $enabled = $this->validate_enabled($input, $options);
529
+ if ($enabled !== $options[$id]) {
530
+ $options[$id] = $enabled;
531
+ $ret = LiteSpeed_Cache_Config::wp_cache_var_setter($enabled);
532
+ if ($ret !== true) {
533
+ $errors[] = $ret;
534
+ }
535
+ if (!$enabled) {
536
+ LiteSpeed_Cache::plugin()->purge_all();
537
+ }
538
+ elseif ($options[LiteSpeed_Cache_Config::OPID_CACHE_FAVICON]) {
539
+ $options[LiteSpeed_Cache_Config::OPID_CACHE_FAVICON] = false;
540
+ }
541
+ $input[$id] = 'changed';
542
+ }
543
+ else {
544
+ $input[$id] = $enabled;
545
+ }
546
+
547
+ $id = LiteSpeed_Cache_Config::OPID_PUBLIC_TTL;
548
+ if ((!$this->validate_ttl($input, $id)) || ($input[$id] < 30)) {
549
+ $errors[] = sprintf($err,
550
+ __('Default Public Cache', 'litespeed-cache'), 30);
551
+ }
552
+ else {
553
+ $options[$id] = $input[$id];
554
+ }
555
+
556
+ $id = LiteSpeed_Cache_Config::OPID_FRONT_PAGE_TTL;
557
+ if ((!$this->validate_ttl($input, $id)) || ($input[$id] < 30)) {
558
+ $errors[] = sprintf($err,
559
+ __('Default Front Page', 'litespeed-cache'), 30);
560
+ }
561
+ else {
562
+ $options[$id] = $input[$id];
563
+ }
564
+
565
+ $id = LiteSpeed_Cache_Config::OPID_FEED_TTL;
566
+ if (!$this->validate_ttl($input, $id)) {
567
+ $errors[] = sprintf($err, __('Feed', 'litespeed-cache'), 0);
568
+ }
569
+ elseif ($input[$id] < 30) {
570
+ $options[$id] = 0;
571
+ }
572
+ else {
573
+ $options[$id] = intval($input[$id]);
574
+ }
575
+
576
+ $id = LiteSpeed_Cache_Config::OPID_404_TTL;
577
+ if (!$this->validate_ttl($input, $id)) {
578
+ $errors[] = sprintf($err, __('404', 'litespeed-cache'), 0);
579
+ }
580
+ elseif ($input[$id] < 30) {
581
+ $options[$id] = 0;
582
+ }
583
+ else {
584
+ $options[$id] = intval($input[$id]);
585
+ }
586
+
587
+ $id = LiteSpeed_Cache_Config::OPID_403_TTL;
588
+ if (!$this->validate_ttl($input, $id)) {
589
+ $errors[] = sprintf($err, __('403', 'litespeed-cache'), 0);
590
+ }
591
+ elseif ($input[$id] < 30) {
592
+ $options[$id] = 0;
593
+ }
594
+ else {
595
+ $options[$id] = intval($input[$id]);
596
+ }
597
+
598
+ $id = LiteSpeed_Cache_Config::OPID_500_TTL;
599
+ if (!$this->validate_ttl($input, $id)) {
600
+ $errors[] = sprintf($err, __('500', 'litespeed-cache'), 0);
601
+ }
602
+ elseif ($input[$id] < 30) {
603
+ $options[$id] = 0;
604
+ }
605
+ else {
606
+ $options[$id] = intval($input[$id]);
607
+ }
608
+
609
+ self::parse_checkbox(LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE,
610
+ $input, $options);
611
+
612
+ self::parse_checkbox(LiteSpeed_Cache_Config::OPID_CACHE_COMMENTERS,
613
+ $input, $options);
614
+
615
+ if (self::parse_checkbox(LiteSpeed_Cache_Config::OPID_CACHE_LOGIN,
616
+ $input, $options) === false
617
+ ) {
618
+ LiteSpeed_Cache_Tags::add_purge_tag(
619
+ LiteSpeed_Cache_Tags::TYPE_LOGIN);
620
+ }
621
+ }
622
+
623
+ /**
624
+ * Validates the purge rules settings.
625
+ *
626
+ * @since 1.0.12
627
+ * @access private
628
+ * @param array $input The input options.
629
+ * @param array $options The current options.
630
+ * @param array $errors The errors list.
631
+ */
632
+ private function validate_purge($input, &$options, &$errors)
633
+ {
634
+
635
+ // get purge options
636
+ $pvals = array(
637
+ LiteSpeed_Cache_Config::PURGE_ALL_PAGES,
638
+ LiteSpeed_Cache_Config::PURGE_FRONT_PAGE,
639
+ LiteSpeed_Cache_Config::PURGE_HOME_PAGE,
640
+ LiteSpeed_Cache_Config::PURGE_PAGES,
641
+ LiteSpeed_Cache_Config::PURGE_PAGES_WITH_RECENT_POSTS,
642
+ LiteSpeed_Cache_Config::PURGE_AUTHOR,
643
+ LiteSpeed_Cache_Config::PURGE_YEAR,
644
+ LiteSpeed_Cache_Config::PURGE_MONTH,
645
+ LiteSpeed_Cache_Config::PURGE_DATE,
646
+ LiteSpeed_Cache_Config::PURGE_TERM,
647
+ LiteSpeed_Cache_Config::PURGE_POST_TYPE,
648
+ );
649
+ $input_purge_options = array();
650
+ foreach ($pvals as $pval) {
651
+ $input_name = 'purge_' . $pval;
652
+ if (isset($input[$input_name]) && ($pval === $input[$input_name])) {
653
+ $input_purge_options[] = $pval;
654
+ }
655
+ }
656
+ sort($input_purge_options);
657
+ $purge_by_post = implode('.', $input_purge_options);
658
+ if ($purge_by_post !== $options[LiteSpeed_Cache_Config::OPID_PURGE_BY_POST]) {
659
+ $options[LiteSpeed_Cache_Config::OPID_PURGE_BY_POST] = $purge_by_post;
660
+ }
661
+ }
662
+
663
+ /**
664
+ * Validates the exclude settings.
665
+ *
666
+ * @since 1.0.12
667
+ * @access private
668
+ * @param array $input The input options.
669
+ * @param array $options The current options.
670
+ * @param array $errors The errors list.
671
+ */
672
+ private function validate_exclude($input, &$options, &$errors)
673
+ {
674
+ $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_URI;
675
+ if (isset($input[$id])) {
676
+ $uri_arr = array_map('trim', explode("\n", $input[$id]));
677
+ $options[$id] = implode("\n", array_filter($uri_arr));
678
+ }
679
+
680
+ $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT;
681
+ $options[$id] = '';
682
+ if (isset($input[$id])) {
683
+ $cat_ids = array();
684
+ $cats = explode("\n", $input[$id]);
685
+ foreach ($cats as $cat) {
686
+ $cat_name = trim($cat);
687
+ if ($cat_name == '') {
688
+ continue;
689
+ }
690
+ $cat_id = get_cat_ID($cat_name);
691
+ if ($cat_id == 0) {
692
+ $errors[] =
693
+ LiteSpeed_Cache_Admin_Error::build_error(
694
+ LiteSpeed_Cache_Admin_Error::E_SETTING_CAT,
695
+ $cat_name);
696
+ }
697
+ else {
698
+ $cat_ids[] = $cat_id;
699
+ }
700
+ }
701
+ if (!empty($cat_ids)) {
702
+ $options[$id] = implode(',', $cat_ids);
703
+ }
704
+ }
705
+
706
+ $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG;
707
+ $options[$id] = '';
708
+ if (!isset($input[$id])) {
709
+ return;
710
+ }
711
+ $tag_ids = array();
712
+ $tags = explode("\n", $input[$id]);
713
+ foreach ($tags as $tag) {
714
+ $tag_name = trim($tag);
715
+ if ($tag_name == '') {
716
+ continue;
717
+ }
718
+ $term = get_term_by('name', $tag_name, 'post_tag');
719
+ if ($term == 0) {
720
+ $errors[] =
721
+ LiteSpeed_Cache_Admin_Error::build_error(
722
+ LiteSpeed_Cache_Admin_Error::E_SETTING_TAG,
723
+ $tag_name);
724
+ }
725
+ else {
726
+ $tag_ids[] = $term->term_id;
727
+ }
728
+ }
729
+ if (!empty($tag_ids)) {
730
+ $options[$id] = implode(',', $tag_ids);
731
+ }
732
+ }
733
+
734
+ /**
735
+ * Validates the single site specific settings.
736
+ *
737
+ * @since 1.0.12
738
+ * @access private
739
+ * @param array $input The input options.
740
+ * @param array $options The current options.
741
+ * @param array $errors The errors list.
742
+ */
743
+ private function validate_singlesite($input, &$options, &$errors)
744
+ {
745
+ $rules = LiteSpeed_Cache_Admin_Rules::get_instance();
746
+
747
+ $id = LiteSpeed_Cache_Config::OPID_ENABLED;
748
+ if ($input[$id] !== 'changed') {
749
+ $diff = $rules->check_input($options, $input, $errors);
750
+ }
751
+ elseif ($options[$id]) {
752
+ $reset = LiteSpeed_Cache_Config::get_rule_reset_options();
753
+ $added_and_changed = $rules->check_input($reset, $input, $errors);
754
+ // Merge to include the newly disabled options
755
+ $diff = array_merge($reset, $added_and_changed);
756
+ }
757
+ else {
758
+ LiteSpeed_Cache_Admin_Rules::clear_rules();
759
+ $diff = $rules->check_input($options, $input, $errors);
760
+ }
761
+
762
+ if ((!empty($diff)) && (($options[$id] === false)
763
+ || ($rules->validate_common_rewrites($diff, $errors) !== false))
764
+ ) {
765
+ $options = array_merge($options, $diff);
766
+ }
767
+
768
+ $out = $this->validate_tag_prefix($input, $options);
769
+ if (is_string($out)) {
770
+ $errors[] = $out;
771
+ }
772
+
773
+ self::parse_checkbox(LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE,
774
+ $input, $options);
775
+
776
+ }
777
+
778
+ /**
779
+ * Validates the debug settings.
780
+ *
781
+ * @since 1.0.12
782
+ * @access private
783
+ * @param array $input The input options.
784
+ * @param array $options The current options.
785
+ * @param array $errors The errors list.
786
+ */
787
+ private function validate_debug($input, &$options, &$errors)
788
+ {
789
+ $pattern = "/[\s,]+/";
790
+ $id = LiteSpeed_Cache_Config::OPID_ADMIN_IPS;
791
+ if (isset($input[$id])) {
792
+ $admin_ips = trim($input[$id]);
793
+ $has_err = false;
794
+ if ($admin_ips) {
795
+ $ips = preg_split($pattern, $admin_ips, null, PREG_SPLIT_NO_EMPTY);
796
+ foreach ($ips as $ip) {
797
+ if (!WP_Http::is_ip_address($ip)) {
798
+ $has_err = true;
799
+ break;
800
+ }
801
+ }
802
+ }
803
+
804
+ if ($has_err) {
805
+ $errors[] =
806
+ LiteSpeed_Cache_Admin_Error::get_error(
807
+ LiteSpeed_Cache_Admin_Error::E_SETTING_ADMIN_IP_INV
808
+ );
809
+ }
810
+ else if ($admin_ips != $options[$id]) {
811
+ $options[$id] = $admin_ips;
812
+ }
813
+ }
814
+
815
+ $id = LiteSpeed_Cache_Config::OPID_TEST_IPS;
816
+ if (isset($input[$id])) {
817
+ // this feature has not implemented yet
818
+ $test_ips = trim($input[$id]);
819
+ $has_err = false;
820
+ if ($test_ips) {
821
+ $ips = preg_split($pattern, $test_ips, null, PREG_SPLIT_NO_EMPTY);
822
+ foreach ($ips as $ip) {
823
+ if (!WP_Http::is_ip_address($ip)) {
824
+ $has_err = true;
825
+ break;
826
+ }
827
+ }
828
+ }
829
+
830
+ if ($has_err) {
831
+ $errors[] =
832
+ LiteSpeed_Cache_Admin_Error::get_error(
833
+ LiteSpeed_Cache_Admin_Error::E_SETTING_TEST_IP_INV
834
+ );
835
+ }
836
+ else if ($test_ips != $options[$id]) {
837
+ $options[$id] = $test_ips;
838
+ }
839
+ }
840
+
841
+ $id = LiteSpeed_Cache_Config::OPID_DEBUG;
842
+ $debug_level = isset($input[$id]) ? intval($input[$id])
843
+ : LiteSpeed_Cache_Config::OPID_ENABLED_DISABLE;
844
+ if (($debug_level != $options[$id])
845
+ && ($debug_level >= LiteSpeed_Cache_Config::OPID_ENABLED_DISABLE)
846
+ && ($debug_level <= LiteSpeed_Cache_Config::OPID_ENABLED_NOTSET)
847
+ ) {
848
+ $options[$id] = $debug_level;
849
+ }
850
+ elseif ($debug_level > LiteSpeed_Cache_Config::OPID_ENABLED_NOTSET) {
851
+ $options[$id] = LiteSpeed_Cache_Config::OPID_ENABLED_DISABLE;
852
+ }
853
+ }
854
+
855
+ /**
856
+ * Validates the third party settings.
857
+ *
858
+ * @since 1.0.12
859
+ * @access private
860
+ * @param LiteSpeed_Cache_Config $config The config class.
861
+ * @param array $input The input options.
862
+ * @param array $options The current options.
863
+ */
864
+ private function validate_thirdparty($config, $input, &$options)
865
+ {
866
+ $tp_default_options = $config->get_thirdparty_options();
867
+ if (empty($tp_default_options)) {
868
+ return;
869
+ }
870
+ $tp_input = array_intersect_key($input, $tp_default_options);
871
+ if (empty($tp_input)) {
872
+ return;
873
+ }
874
+ $tp_options = apply_filters('litespeed_cache_save_options',
875
+ array_intersect_key($options, $tp_default_options), $tp_input);
876
+ if ((!empty($tp_options)) && is_array($tp_options)) {
877
+ $options = array_merge($options, $tp_options);
878
+ }
879
+ }
880
+
881
+ /**
882
+ * Callback function that will validate any changes made in the settings
883
+ * page.
884
+ *
885
+ * @since 1.0.0
886
+ * @access public
887
+ * @param array $input The configurations selected by the admin when
888
+ * clicking save.
889
+ * @return array The updated configuration options.
890
+ */
891
+ public function validate_plugin_settings($input)
892
+ {
893
+ $config = LiteSpeed_Cache::config();
894
+ $options = $config->get_options();
895
+ $errors = array();
896
+
897
+ if (LiteSpeed_Cache_Admin_Display::get_instance()->get_disable_all()) {
898
+ add_settings_error(LiteSpeed_Cache_Config::OPTION_NAME,
899
+ LiteSpeed_Cache_Config::OPTION_NAME,
900
+ __('\'Use primary site settings\' set by Network Administrator.', 'litespeed-cache'));
901
+
902
+ return $options;
903
+ }
904
+
905
+ $this->validate_general($input, $options, $errors);
906
+
907
+ $this->validate_purge($input, $options, $errors);
908
+
909
+ $this->validate_exclude($input, $options, $errors);
910
+
911
+ $this->validate_debug($input, $options, $errors);
912
+
913
+ if (!is_multisite()) {
914
+ $this->validate_singlesite($input, $options, $errors);
915
+ }
916
+
917
+ if (!empty($errors)) {
918
+ add_settings_error(LiteSpeed_Cache_Config::OPTION_NAME,
919
+ LiteSpeed_Cache_Config::OPTION_NAME, implode('<br>', $errors));
920
+
921
+ return $options;
922
+ }
923
+
924
+ $this->validate_thirdparty($config, $input, $options);
925
+
926
+ return $options;
927
+ }
928
+
929
+ /**
930
+ * Callback that adds LiteSpeed Cache's action links.
931
+ *
932
+ * @since 1.0.0
933
+ * @access public
934
+ * @param array $links Previously added links from other plugins.
935
+ * @return array Links array with the litespeed cache one appended.
936
+ */
937
+ public function add_plugin_links($links)
938
+ {
939
+ //$links[] = '<a href="' . admin_url('admin.php?page=litespeedcache') .'">Settings</a>';
940
+ $links[] = '<a href="' . admin_url('options-general.php?page=litespeedcache') . '">' . __('Settings', 'litespeed-cache') . '</a>';
941
+
942
+ return $links;
943
+ }
944
+
945
+ /**
946
+ * Check if the admin pressed a button in the management page.
947
+ *
948
+ * @since 1.0.0
949
+ * @access private
950
+ */
951
+ private function check_cache_mangement_actions()
952
+ {
953
+ if ((empty($_POST))
954
+ || (!isset($_POST['lscwp_management']))
955
+ || ($_POST['lscwp_management'] !== 'manage_lscwp')
956
+ || (!check_admin_referer('lscwp_manage', 'management_run'))
957
+ ) {
958
+ return;
959
+ }
960
+ if (isset($_POST['purgeall'])) {
961
+ LiteSpeed_Cache::plugin()->purge_all();
962
+ $msg = __('Notified LiteSpeed Web Server to purge the public cache.', 'litespeed-cache');
963
+ }
964
+ elseif (isset($_POST['purgefront'])) {
965
+ LiteSpeed_Cache::plugin()->purge_front();
966
+ $msg = __('Notified LiteSpeed Web Server to purge the front page.', 'litespeed-cache');
967
+ }
968
+ elseif (isset($_POST['purgepages'])) {
969
+ LiteSpeed_Cache::plugin()->purge_pages();
970
+ $msg = __('Notified LiteSpeed Web Server to purge pages.', 'litespeed-cache');
971
+ }
972
+ elseif (isset($_POST['purgeerrors'])) {
973
+ LiteSpeed_Cache::plugin()->purge_errors();
974
+ $msg = __('Notified LiteSpeed Web Server to purge error pages.', 'litespeed-cache');
975
+ }
976
+ elseif (isset($_POST['purgelist'])) {
977
+ LiteSpeed_Cache::plugin()->purge_list();
978
+
979
+ return;
980
+ }
981
+ elseif (isset($_POST['clearcache'])) {
982
+ LiteSpeed_Cache::plugin()->purge_all();
983
+ $msg = __('Notified LiteSpeed Web Server to purge everything.', 'litespeed-cache');
984
+ }
985
+ else {
986
+ return;
987
+ }
988
+ LiteSpeed_Cache_Admin_Display::get_instance()->add_notice(
989
+ LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg);
990
+ }
991
+
992
+ /**
993
+ * Check to make sure that the advanced-cache.php file is ours.
994
+ * If it doesn't exist, try to make it ours.
995
+ *
996
+ * If it is not ours and the config is set to check, output an error.
997
+ *
998
+ * @since 1.0.11
999
+ * @access private
1000
+ */
1001
+ private function check_advanced_cache()
1002
+ {
1003
+
1004
+ $capability = is_network_admin() ? 'manage_network_options' : 'manage_options';
1005
+ if (((defined('LSCACHE_ADV_CACHE'))
1006
+ && (constant('LSCACHE_ADV_CACHE') === true))
1007
+ || (!current_user_can($capability))
1008
+ ) {
1009
+ if (LiteSpeed_Cache::config(
1010
+ LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE) === false
1011
+ ) {
1012
+ // If it exists because I added it at runtime, try to create the file anyway.
1013
+ // Result does not matter.
1014
+ LiteSpeed_Cache::plugin()->try_copy_advanced_cache();
1015
+ }
1016
+
1017
+ return;
1018
+ }
1019
+
1020
+ if (LiteSpeed_Cache::plugin()->try_copy_advanced_cache()) {
1021
+ return;
1022
+ }
1023
+
1024
+ if ((is_multisite()) && ((!is_network_admin())
1025
+ || (!current_user_can('manage_network_options')))
1026
+ ) {
1027
+ $third = __('For this scenario only, the network admin may uncheck "Check Advanced Cache" in LiteSpeed Cache settings.', 'litespeed-cache');
1028
+ }
1029
+ else {
1030
+ $third = __('For this scenario only, please uncheck "Check Advanced Cache" in LiteSpeed Cache settings.', 'litespeed-cache');
1031
+ }
1032
+ $msg = LiteSpeed_Cache_Admin_Display::build_paragraph(
1033
+ __('Please disable/deactivate any other Full Page Cache solutions that are currently being used.', 'litespeed-cache'),
1034
+ __('LiteSpeed Cache does work with other cache solutions, but only their non-page caching offerings—such as minifying css/js files.', 'litespeed-cache'),
1035
+ $third
1036
+ );
1037
+
1038
+ LiteSpeed_Cache_Admin_Display::get_instance()->add_notice(
1039
+ LiteSpeed_Cache_Admin_Display::NOTICE_YELLOW, $msg);
1040
+ }
1041
+
1042
+ /**
1043
+ * Clean up the input string of any extra slashes/spaces.
1044
+ *
1045
+ * @since 1.0.4
1046
+ * @access public
1047
+ * @param string $input The input string to clean.
1048
+ * @return string The cleaned up input.
1049
+ */
1050
+ public static function cleanup_text($input)
1051
+ {
1052
+ return stripslashes(trim($input));
1053
+ }
1054
+
1055
+ /**
1056
+ * Helper function to parse checkbox input.
1057
+ *
1058
+ * @since 1.0.11
1059
+ * @access public
1060
+ * @param string $id The id of the checkbox value.
1061
+ * @param array $input The input array.
1062
+ * @param array $options The config options array.
1063
+ * @return boolean True if checked, false otherwise.
1064
+ */
1065
+ public static function parse_checkbox($id, $input, &$options)
1066
+ {
1067
+ if (isset($input['lscwp_' . $id])) {
1068
+ $options[$id] = ($input['lscwp_' . $id] === $id);
1069
+ }
1070
+ else {
1071
+ $options[$id] = false;
1072
+ }
1073
+
1074
+ return $options[$id];
1075
+ }
1076
+
1077
+ /**
1078
+ * Parses any changes made by the network admin on the network settings.
1079
+ *
1080
+ * @since 1.0.4
1081
+ * @access public
1082
+ */
1083
+ public function validate_network_settings()
1084
+ {
1085
+ if ((!is_multisite()) || (!is_network_admin())) {
1086
+ return;
1087
+ }
1088
+ if (empty($_POST) || empty($_POST['submit'])) {
1089
+ return;
1090
+ }
1091
+ if ((!isset($_POST['lscwp_settings_save']))
1092
+ || (empty($_POST[LiteSpeed_Cache_Config::OPTION_NAME]))
1093
+ || ($_POST['lscwp_settings_save'] !== 'save_settings')
1094
+ || (!check_admin_referer('lscwp_settings', 'save'))
1095
+ ) {
1096
+ return;
1097
+ }
1098
+
1099
+ $input = array_map("LiteSpeed_Cache_Admin::cleanup_text",
1100
+ $_POST[LiteSpeed_Cache_Config::OPTION_NAME]);
1101
+ $config = LiteSpeed_Cache::config();
1102
+ $options = $config->get_site_options();
1103
+ $errors = array();
1104
+
1105
+ $id = LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED;
1106
+ $network_enabled = (is_null($input['lscwp_' . $id])
1107
+ ? false : ($input['lscwp_' . $id] === $id));
1108
+ if ($options[$id] !== $network_enabled) {
1109
+ $options[$id] = $network_enabled;
1110
+ if ($network_enabled) {
1111
+ $ret = LiteSpeed_Cache_Config::wp_cache_var_setter(true);
1112
+ if ($ret !== true) {
1113
+ $errors[] = $ret;
1114
+ }
1115
+ }
1116
+ else {
1117
+ LiteSpeed_Cache::plugin()->purge_all();
1118
+ }
1119
+ $input[$id] = 'changed';
1120
+ $reset = LiteSpeed_Cache_Config::get_rule_reset_options();
1121
+ }
1122
+
1123
+ $id = LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY;
1124
+ $orig_primary = $options[$id];
1125
+ $ret = self::parse_checkbox($id, $input, $options);
1126
+ if ($orig_primary !== $ret) {
1127
+ LiteSpeed_Cache::plugin()->purge_all();
1128
+ }
1129
+
1130
+ self::parse_checkbox(LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE,
1131
+ $input, $options);
1132
+
1133
+ self::parse_checkbox(LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE,
1134
+ $input, $options);
1135
+
1136
+ $out = $this->validate_tag_prefix($input, $options);
1137
+ if (is_string($out)) {
1138
+ $errors[] = $out;
1139
+ }
1140
+
1141
+ $rules = LiteSpeed_Cache_Admin_Rules::get_instance();
1142
+
1143
+ if ($input[LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED]
1144
+ !== 'changed'
1145
+ ) {
1146
+ $diff = $rules->check_input($options, $input, $errors);
1147
+ }
1148
+ elseif ($network_enabled) {
1149
+ $added_and_changed = $rules->check_input($reset, $input, $errors);
1150
+ // Merge to include the newly disabled options
1151
+ $diff = array_merge($reset, $added_and_changed);
1152
+ }
1153
+ else {
1154
+ $rules->validate_common_rewrites($reset, $errors);
1155
+ $diff = $rules->check_input($options, $input, $errors);
1156
+ }
1157
+
1158
+ if ((!empty($diff)) && (($network_enabled === false)
1159
+ || ($rules->validate_common_rewrites($diff, $errors) !== false))
1160
+ ) {
1161
+ $options = array_merge($options, $diff);
1162
+ }
1163
+
1164
+ if (!empty($errors)) {
1165
+ LiteSpeed_Cache_Admin_Display::get_instance()->add_notice(
1166
+ LiteSpeed_Cache_Admin_Display::NOTICE_RED, $errors);
1167
+
1168
+ return;
1169
+ }
1170
+ LiteSpeed_Cache_Admin_Display::get_instance()->add_notice(
1171
+ LiteSpeed_Cache_Admin_Display::NOTICE_GREEN,
1172
+ __('File saved.', 'litespeed-cache'));
1173
+ update_site_option(LiteSpeed_Cache_Config::OPTION_NAME, $options);
1174
+ }
1175
+
1176
+ /**
1177
+ * Add text to recommend updating upon update success.
1178
+ *
1179
+ * @since 1.0.8.1
1180
+ * @access public
1181
+ * @param string $translations
1182
+ * @param string $text
1183
+ * @return string
1184
+ */
1185
+ public function add_update_text($translations, $text)
1186
+ {
1187
+ if ($text !== 'Updated!') {
1188
+ return $translations;
1189
+ }
1190
+
1191
+ return $translations . ' ' .
1192
+ __('It is recommended that LiteSpeed Cache be purged after updating a plugin.',
1193
+ 'litespeed-cache');
1194
+ }
1195
+
1196
+ /**
1197
+ * Add the filter to update plugin update text.
1198
+ *
1199
+ * @since 1.0.8.1
1200
+ * @access public
1201
+ */
1202
+ public function set_update_text()
1203
+ {
1204
+ add_filter('gettext', array($this, 'add_update_text'), 10, 2);
1205
+ }
1206
 
1207
+ /**
1208
+ * Remove the filter to update plugin update text.
1209
+ *
1210
+ * @since 1.0.8.1
1211
+ * @access public
1212
+ */
1213
+ public function unset_update_text()
1214
+ {
1215
+ remove_filter('gettext', array($this, 'add_update_text'));
1216
+ }
1217
 
1218
+ }
admin/css/litespeed-cache-admin.css ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * All of the CSS for your admin-specific functionality should be
3
+ * included in this file.
4
+ */
5
+ @import "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css";
6
+ @import "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css";
7
+
8
+ .litespeedcache-button-danger {
9
+ background: #eb3100 !important;
10
+ border-color: #eb3100 #eb3100 #eb3100 !important;
11
+ -webkit-box-shadow: 0 1px 0 #eb3100 !important;
12
+ box-shadow: 0 1px 0 #eb3100 !important;
13
+ color: #fff;
14
+ text-decoration: none;
15
+ display: inline-block;
16
+ font-size: 13px;
17
+ line-height: 26px;
18
+ height: 28px;
19
+ margin: 0;
20
+ padding: 0 10px 1px;
21
+ cursor: pointer;
22
+ border-width: 1px;
23
+ border-style: solid;
24
+ border-radius: 3px;
25
+ white-space: nowrap;
26
+ box-sizing: border-box;
27
+ }
28
+
29
+ /* Hover tooltips */
30
+ .litespeed-cache-field-tip {
31
+ position:relative;
32
+ cursor:help;
33
+ z-index: 9999 !important;
34
+ margin-right:10px;
35
+ }
36
+
37
+ .litespeed-cache-field-tip:before{
38
+ font-family: FontAwesome;
39
+ content:"\f059";
40
+ color:#0085ba;
41
+ }
42
+
43
+ .litespeed-cache-field-tip .litespeed-cache-tip-content {
44
+ position:absolute;
45
+ top:-10px; /* - top padding */
46
+ right:9999px;
47
+ width:200px;
48
+ margin-right:-220px; /* width + left/right padding */
49
+ padding:10px;
50
+ color:#fff;
51
+ background:#333;
52
+ -webkit-box-shadow:2px 2px 5px #aaa;
53
+ -moz-box-shadow:2px 2px 5px #aaa;
54
+ box-shadow:2px 2px 5px #aaa;
55
+ opacity:0;
56
+ -webkit-transition:opacity 250ms ease-out;
57
+ -moz-transition:opacity 250ms ease-out;
58
+ -ms-transition:opacity 250ms ease-out;
59
+ -o-transition:opacity 250ms ease-out;
60
+ transition:opacity 250ms ease-out;
61
+ font:normal 10px/1.5 Verdana,Arial,sans-serif;
62
+ font-size:12px;
63
+ }
64
+
65
+ /* <http://css-tricks.com/snippets/css/css-triangle/> */
66
+ .litespeed-cache-field-tip .litespeed-cache-tip-content:before {
67
+ content:'';
68
+ position:absolute;
69
+ top:50%;
70
+ left:-16px; /* 2 x border width */
71
+ width:0;
72
+ height:0;
73
+ margin-top:-8px; /* - border width */
74
+ border:8px solid transparent;
75
+ border-right-color:#333;
76
+ color:#ccc;
77
+ }
78
+
79
+ .litespeed-cache-field-tip:hover .litespeed-cache-tip-content {
80
+ right:-20px;
81
+ opacity:1;
82
+ }
83
+
84
+ /* Hover tooltips */
85
+ .litespeed-cache-field-tip-do-not {
86
+ position:relative;
87
+ cursor:help;
88
+ margin-right:10px;
89
+ top:4px;
90
+ }
91
+
92
+ .litespeed-cache-field-tip-do-not:before{
93
+ font-family: FontAwesome;
94
+ content:"\f059";
95
+ color:#0085ba;
96
+ }
97
+
98
+ .litespeed-cache-field-tip-do-not .litespeed-cache-tip-content-do-not {
99
+ position:absolute;
100
+ top:-10px; /* - top padding */
101
+ right:9999px;
102
+ width:200px;
103
+ margin-right:-220px; /* width + left/right padding */
104
+ padding:10px;
105
+ color:#fff;
106
+ background:#333;
107
+ -webkit-box-shadow:2px 2px 5px #aaa;
108
+ -moz-box-shadow:2px 2px 5px #aaa;
109
+ box-shadow:2px 2px 5px #aaa;
110
+ opacity:0;
111
+ -webkit-transition:opacity 250ms ease-out;
112
+ -moz-transition:opacity 250ms ease-out;
113
+ -ms-transition:opacity 250ms ease-out;
114
+ -o-transition:opacity 250ms ease-out;
115
+ transition:opacity 250ms ease-out;
116
+ font:normal 10px/1.5 Verdana,Arial,sans-serif;
117
+ font-size: 12px;
118
+ }
119
+
120
+ /* <http://css-tricks.com/snippets/css/css-triangle/> */
121
+ .litespeed-cache-field-tip-do-not .litespeed-cache-tip-content-do-not:before {
122
+ content:'';
123
+ position:absolute;
124
+ top:50%;
125
+ left:-16px; /* 2 x border width */
126
+ width:0;
127
+ height:0;
128
+ margin-top:-8px; /* - border width */
129
+ border:8px solid transparent;
130
+ border-right-color:#333;
131
+ color:#ccc;
132
+ }
133
+
134
+ .litespeed-cache-field-tip-do-not:hover .litespeed-cache-tip-content-do-not {
135
+ right:-20px;
136
+ opacity:1;
137
+ }
138
+
139
+ /* Hover tooltips */
140
+ .litespeed-cache-field-tip-clear-all {
141
+ position:relative;
142
+ cursor:help;
143
+ margin-right:10px;
144
+ top:4px;
145
+ }
146
+
147
+ .litespeed-cache-field-tip-clear-all:before{
148
+ font-family: FontAwesome;
149
+ content:"\f06a";
150
+ color:#ff0000 !important;
151
+ }
152
+
153
+ .litespeed-cache-field-tip-clear-all .litespeed-cache-tip-content-clear-all {
154
+ position:absolute;
155
+ top:-10px; /* - top padding */
156
+ right:9999px;
157
+ width:200px;
158
+ margin-right:-220px; /* width + left/right padding */
159
+ padding:10px;
160
+ color:#fff;
161
+ background:#333;
162
+ -webkit-box-shadow:2px 2px 5px #aaa;
163
+ -moz-box-shadow:2px 2px 5px #aaa;
164
+ box-shadow:2px 2px 5px #aaa;
165
+ opacity:0;
166
+ -webkit-transition:opacity 250ms ease-out;
167
+ -moz-transition:opacity 250ms ease-out;
168
+ -ms-transition:opacity 250ms ease-out;
169
+ -o-transition:opacity 250ms ease-out;
170
+ transition:opacity 250ms ease-out;
171
+ font:normal 10px/1.5 Verdana,Arial,sans-serif;
172
+ font-size:12px;
173
+ }
174
+
175
+ /* <http://css-tricks.com/snippets/css/css-triangle/> */
176
+ .litespeed-cache-field-tip-clear-all .litespeed-cache-tip-content-clear-all:before {
177
+ content:'';
178
+ position:absolute;
179
+ top:50%;
180
+ left:-16px; /* 2 x border width */
181
+ width:0;
182
+ height:0;
183
+ margin-top:-8px; /* - border width */
184
+ border:8px solid transparent;
185
+ border-right-color:#333;
186
+ color:#ccc;
187
+ }
188
+
189
+ .litespeed-cache-field-tip-clear-all:hover .litespeed-cache-tip-content-clear-all {
190
+ right:-20px;
191
+ opacity:1;
192
+ }
193
+
194
+
195
+ #litespeedcache-purgeerrors{
196
+ margin:5px 0 15px 22px;
197
+ }
198
+
199
+ .litespeed-cache-div-table .form-table input[type=checkbox]{
200
+ margin-top:5px;
201
+ }
202
+
203
+ .litespeed-cache-div-table .form-table input[type=text]{
204
+ margin: 1px;
205
+ padding: 3px 5px;
206
+ line-height: 1.50em;
207
+ }
208
+
209
+ .litespeed-cache-div-table .form-table label{
210
+ padding-top:4px;
211
+ }
212
+
213
+ .litespeed-cache-div-table .form-table select, select#purgeby, select#debug{
214
+ background: transparent !important;
215
+ width: 150px !important;
216
+ padding: 2px !important;
217
+ font-size: 14px !important;
218
+ cursor: pointer !important;
219
+ border-width: 1px !important;
220
+ border-style: solid !important;
221
+ border-radius: 3px !important;
222
+ white-space: nowrap !important;
223
+ box-sizing: border-box !important;
224
+ -webkit-appearance: none !important;
225
+ -moz-appearance: none !important;
226
+ appearance: none !important;
227
+ background: url(https://cdn0.iconfinder.com/data/icons/slim-square-icons-basics/100/basics-08-128.png) 96% / 15% no-repeat #fff !important;
228
+ }
229
+ /*target Internet Explorer 9 and Internet Explorer 10:*/
230
+ @media screen and (min-width:0\0) {
231
+ .litespeed-cache-div-table .form-table select, select#purgeby, select#debug{
232
+ background:none !important;
233
+ padding: 5px !important;
234
+ }
235
+ }
236
+
237
+ .litespeed-cache-div-table .form-table select, select#wc_update_interval{
238
+ background: transparent !important;
239
+ width: auto !important;
240
+ padding: 2px !important;
241
+ font-size: 14px !important;
242
+ cursor: pointer !important;
243
+ border-width: 1px !important;
244
+ border-style: solid !important;
245
+ border-radius: 3px !important;
246
+ white-space: nowrap !important;
247
+ box-sizing: border-box !important;
248
+ -webkit-appearance: none !important;
249
+ -moz-appearance: none !important;
250
+ appearance: none !important;
251
+ background: url(https://cdn0.iconfinder.com/data/icons/slim-square-icons-basics/100/basics-08-128.png) 98% / 3.7% no-repeat #fff !important;
252
+ max-width:90% !important;
253
+ }
254
+ /*target Internet Explorer 9 and Internet Explorer 10:*/
255
+ @media screen and (min-width:0\0) {
256
+ .litespeed-cache-div-table .form-table select, select#wc_update_interval{
257
+ background:none !important;
258
+ padding: 5px !important;
259
+ }
260
+ }
261
+
262
+ @media all and (max-width: 600px){
263
+ .litespeed-cache-div-table .form-table select, select#wc_update_interval {
264
+ width: 100% !important;
265
+ max-width: 100% !important;
266
+ background: url(https://cdn0.iconfinder.com/data/icons/slim-square-icons-basics/100/basics-08-128.png) 98% / 3.7% no-repeat #fff !important;
267
+ white-space:pre-wrap !important;
268
+ }
269
+ }
270
+ .litespeed-cache-welcome-panel{
271
+ position: relative;
272
+ overflow: auto;
273
+ margin: 16px 0;
274
+ padding: 23px 10px 0;
275
+ border: 1px solid #e5e5e5;
276
+ -webkit-box-shadow: 0 1px 1px rgba(0,0,0,.04);
277
+ box-shadow: 0 1px 1px rgba(0,0,0,.04);
278
+ background: #fff;
279
+ font-size: 14px;
280
+ }
281
+
282
+ .litespeed-cache-welcome-panel p{
283
+ font-size: 14px !important;
284
+ }
285
+
286
+ .litespeed-cache-welcome-panel .hndle{
287
+ background-color: #eee;
288
+ cursor: pointer !important;
289
+ }
290
+
291
+ .litespeed-cache-welcome-panel .hndle:before{
292
+ font-family: FontAwesome;
293
+ content:"\f05a";
294
+ color:#939393;
295
+ margin-right:10px;
296
+
297
+ }
298
+
299
+ .litespeed-cache-welcome-panel .postbox ol{
300
+ font-size: 14px;
301
+ line-height: 1.0em;
302
+ }
303
+
304
+ .litespeed-cache-advanced-settings{
305
+ position: relative;
306
+ background: #fff;
307
+ font-size: 14px;
308
+ line-height: 2.1em;
309
+ }
310
+
311
+ .litespeed-cache-advanced-settings .hndle{
312
+ background-color: #eee;
313
+ cursor: pointer !important;
314
+ }
315
+
316
+ .litespeed-cache-advanced-settings .hndle:before{
317
+ font-family: FontAwesome;
318
+ content:"\f05a";
319
+ color:#939393;
320
+ margin-right:10px;
321
+ }
322
+
323
+ .litespeed-cache-advanced-settings .postbox ol{
324
+ font-size: 14px;
325
+ line-height: 1.0em;
326
+ }
327
+
328
+ .litespeedcache-postbox-button{
329
+ display:none !important;
330
+ }
331
+
332
+ .litespeed-cache-advanced-settings h3{
333
+ display:inline;
334
+ }
335
+
336
+ .litespeed-cache-jquery-button {
337
+ background: #0085ba !important;
338
+ border-color: #0085ba #0085ba #0085ba !important;
339
+ -webkit-box-shadow: 0 1px 0 #0085ba !important;
340
+ box-shadow: 0 1px 0 #0085ba !important;
341
+ color: #fff;
342
+ text-decoration: none;
343
+ display: inline-block;
344
+ font-size: 13px;
345
+ line-height: 26px;
346
+ height: 28px;
347
+ margin: 0;
348
+ padding: 0 10px 1px;
349
+ cursor: pointer;
350
+ border-width: 1px;
351
+ border-style: solid;
352
+ border-radius: 3px;
353
+ white-space: nowrap;
354
+ box-sizing: border-box;
355
+ float:right;
356
+ text-align: center;
357
+ }
358
+
359
+ .litespeed-cache-welcome-panel .litespeed-cache-select-all-button {
360
+ background: #0085ba !important;
361
+ border-color: #0085ba #0085ba #0085ba !important;
362
+ -webkit-box-shadow: 0 1px 0 #0085ba !important;
363
+ box-shadow: 0 1px 0 #0085ba !important;
364
+ color: #fff;
365
+ text-decoration: none;
366
+ display: inline-block;
367
+ font-size: 13px;
368
+ line-height: 26px;
369
+ height: 28px;
370
+ margin: 0;
371
+ padding: 0 10px 1px;
372
+ cursor: pointer;
373
+ border-width: 1px;
374
+ border-style: solid;
375
+ border-radius: 3px;
376
+ white-space: nowrap;
377
+ box-sizing: border-box;
378
+ float:right;
379
+ width: auto;
380
+ text-align: center;
381
+ }
382
+
383
+ textarea#purgebylist{
384
+ height: auto;
385
+ min-height: 100%;
386
+ width: 100%;
387
+ position: relative;
388
+ -webkit-font-smoothing: subpixel-antialiased;
389
+ }
390
+ .litespeed-cache-welcome-panel ul {
391
+ list-style: disc outside;
392
+ margin-left: 20px;
393
+ padding-left: 0;
394
+ }
admin/js/litespeed-cache-admin.js ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * All of the code for your public-facing JavaScript source
6
+ * should reside in this file.
7
+ *
8
+ * Note: It has been assumed you will write jQuery code here, so the
9
+ * $ function reference has been prepared for usage within the scope
10
+ * of this function.
11
+ *
12
+ * This enables you to define handlers, for when the DOM is ready:
13
+ *
14
+ * $(function() {
15
+ *
16
+ * });
17
+ *
18
+ * When the window is loaded:
19
+ *
20
+ * $( window ).load(function() {
21
+ *
22
+ * });
23
+ *
24
+ * ...and/or other possibilities.
25
+ *
26
+ * Ideally, it is not considered best practise to attach more than a
27
+ * single DOM-ready or window-load handler for a particular page.
28
+ * Although scripts in the WordPress core, Plugins and Themes may be
29
+ * practising this, we should strive to set a better example in our own work.
30
+ */
31
+
32
+ jQuery(document).ready(function () {
33
+
34
+ var tabs = $("#lsc-tabs").tabs({
35
+ activate: function (event, ui) {
36
+ event.preventDefault();
37
+
38
+ //get the active tab index
39
+ var active = $("#lsc-tabs").tabs("option", "active");
40
+
41
+ //save it to hidden field
42
+ $("input[name=active_tab]").val(active);
43
+ var action = $("form#ls_form_options").attr("action");
44
+ if (action == 'options.php') {
45
+ var referer = $("input[name=_wp_http_referer]").val();
46
+ var new_url = lscwpInsertParam(referer, 'tab', active);
47
+ $("input[name=_wp_http_referer]").val(new_url);
48
+ }
49
+ else {
50
+ var new_url = lscwpInsertParam(action, 'tab', active);
51
+ $("form#ls_form_options").attr("action", new_url);
52
+ }
53
+ }
54
+ });
55
+
56
+ //read the hidden field
57
+ var activeTabIndex = $("input[name=active_tab]").val();
58
+
59
+ //make active needed tab
60
+ if (activeTabIndex !== undefined) {
61
+ tabs.tabs("option", "active", activeTabIndex);
62
+ }
63
+
64
+ tabs.removeClass('ui-widget');
65
+
66
+ $(".postbox .hndle").click(function () {
67
+ $(this).parent().toggleClass("closed");
68
+ });
69
+
70
+ $('.litespeed-cache-jquery-button').html($("#litespeed-cache-jquery-button-expand-val").val());
71
+ $(".litespeed-cache-jquery-button").click(function () {
72
+ if ($('.litespeed-cache-jquery-button').html() == $("#litespeed-cache-jquery-button-expand-val").val()) {
73
+ $('.litespeed-cache-jquery-button').html($("#litespeed-cache-jquery-button-collapse-val").val());
74
+ $('div.postbox').removeClass('closed');
75
+ } else {
76
+ $('.litespeed-cache-jquery-button').html($("#litespeed-cache-jquery-button-expand-val").val());
77
+ $('div.postbox').addClass('closed');
78
+ }
79
+ });
80
+
81
+ var purgebyValue = purgebySelect($('#purgeby').val());
82
+ $('.litespeed-cache-purgeby-text').html(purgebyValue);
83
+
84
+ $('#purgeby').change(function () {
85
+ purgebyValue = purgebySelect($(this).val());
86
+ $('.litespeed-cache-purgeby-text').html(purgebyValue);
87
+ });
88
+
89
+ //WHM Notice
90
+ $(document).on('click', '.lscwp-whm-notice .notice-dismiss', function () {
91
+ $.ajax({
92
+ url: ajaxurl,
93
+ data: {
94
+ action: 'lscache_dismiss_whm',
95
+ LSCWP_CTRL: lscwp_data.lscwpctrl,
96
+ _wpnonce: lscwp_data.nonce
97
+ }
98
+ })
99
+ })
100
+
101
+ // Select All and Copy to Clipboard
102
+ $(".litespeed-cache-select-all-button").click(function() {
103
+ $('#litespeed-report').select();
104
+ document.execCommand('copy');
105
+ $('span.copy-select-all-span').css('display','inline-block');
106
+ $('span.copy-select-all-span').fadeIn('slow').delay(1000).fadeOut('slow');
107
+ });
108
+
109
+ //Toggle postbox class Buttons
110
+ $(".litespeedcache-postbox-button").on('click', function () {
111
+ var pbDiv = $(this).parent().get(0);
112
+ $(pbDiv).toggleClass('closed');
113
+ $(this).attr('aria-expanded',
114
+ $(this).attr('aria-expanded') === 'true' ? 'false' : 'true');
115
+ });
116
+
117
+
118
+ //Purge All Button
119
+ $('#litespeedcache-purgeall').click(function () {
120
+ if (confirm($('#litespeedcache-purgeall-confirm').val())) {
121
+ $(this).submit();
122
+ }
123
+ else {
124
+ return false;
125
+ }
126
+ });
127
+
128
+ //Confirm Clear Cache
129
+ $('#litespeedcache-clearcache').click(function () {
130
+ if (confirm(jQuery('#litespeedcache-clearcache-confirm').val())) {
131
+ $(this).submit();
132
+ }
133
+ else {
134
+ return false;
135
+ }
136
+ });
137
+ });
138
+ })(jQuery);
139
+
140
+ function lscwpCheckboxConfirm(the_checkbox, list_id) {
141
+ var id = the_checkbox.id;
142
+ var default_id = id.concat("_default");
143
+ var warning_id = id.concat("_warning");
144
+ var the_list = document.getElementById(list_id);
145
+ if (the_checkbox.checked) {
146
+ the_list.value = document.getElementById(default_id).value;
147
+ the_list.readOnly = false;
148
+ return;
149
+ }
150
+ if (!confirm(document.getElementById(warning_id).value)) {
151
+ the_checkbox.checked = !the_checkbox.checked;
152
+ return;
153
+ }
154
+ the_list.value = '';
155
+ the_list.readOnly = true;
156
+ }
157
+
158
+ function purgebySelect(value) {
159
+ var category = jQuery('#purgeby-category').val();
160
+ var postid = jQuery('#purgeby-postid').val();
161
+ var tag = jQuery('#purgeby-tag').val();
162
+ var url = jQuery('#purgeby-url').val();
163
+
164
+ if (value == 0) {
165
+ var purgebyValue = category;
166
+ }
167
+ else if (value == 1) {
168
+ var purgebyValue = postid;
169
+ }
170
+ else if (value == 2) {
171
+ var purgebyValue = tag;
172
+ }
173
+ else if (value == 3) {
174
+ var purgebyValue = url;
175
+ }
176
+ return purgebyValue;
177
+ }
178
+
179
+ // Append params to uri
180
+ function lscwpInsertParam(uri, key, val){
181
+ var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
182
+ var separator = uri.indexOf('?') !== -1 ? "&" : "?";
183
+ if (uri.match(re)) {
184
+ return uri.replace(re, '$1' + key + "=" + val + '$2');
185
+ }
186
+ else {
187
+ return uri + separator + key + "=" + val;
188
+ }
189
+
190
+ }
admin/litespeed-cache-admin-display.class.php DELETED
@@ -1,826 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The admin-panel specific functionality of the plugin.
5
- *
6
- *
7
- * @since 1.0.0
8
- * @package LiteSpeed_Cache
9
- * @subpackage LiteSpeed_Cache/admin
10
- * @author LiteSpeed Technologies <info@litespeedtech.com>
11
- */
12
- class LiteSpeed_Cache_Admin_Display
13
- {
14
- private static $_instance ;
15
-
16
- const NOTICE_BLUE = 'notice notice-info' ;
17
- const NOTICE_GREEN = 'notice notice-success' ;
18
- const NOTICE_RED = 'notice notice-error' ;
19
- const NOTICE_YELLOW = 'notice notice-warning' ;
20
- const TRANSIENT_LITESPEED_MESSAGE = 'litespeed_messages' ;
21
-
22
- const PURGEBY_CAT = '0' ;
23
- const PURGEBY_PID = '1' ;
24
- const PURGEBY_TAG = '2' ;
25
- const PURGEBY_URL = '3' ;
26
-
27
- const PURGEBYOPT_SELECT = 'purgeby' ;
28
- const PURGEBYOPT_LIST = 'purgebylist' ;
29
-
30
- const DISMISS_MSG = 'litespeed-cache-dismiss' ;
31
- const RULECONFLICT_ON = 'ExpiresDefault_1' ;
32
- const RULECONFLICT_DISMISSED = 'ExpiresDefault_0' ;
33
-
34
- private $config ;
35
- private $messages = array() ;
36
- private $disable_all = false ;
37
- private $default_settings = array() ;
38
-
39
- /**
40
- * Initialize the class and set its properties.
41
- *
42
- * @since 1.0.7
43
- * @access private
44
- */
45
- private function __construct()
46
- {
47
- // load assets
48
- if( ! empty($_GET['page']) &&
49
- (substr($_GET['page'], 0, 8) == 'lscache-' || $_GET['page'] == 'litespeedcache') ) {
50
- add_action('admin_enqueue_scripts', array($this, 'load_assets')) ;
51
- }
52
-
53
- // main css
54
- add_action('admin_enqueue_scripts', array($this, 'enqueue_style')) ;
55
- // Main js
56
- add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')) ;
57
-
58
- $is_network_admin = is_network_admin() ;
59
-
60
- // Quick access menu
61
- if ( is_multisite() && $is_network_admin ) {
62
- $manage = 'manage_network_options' ;
63
- }
64
- else {
65
- $manage = 'manage_options' ;
66
- }
67
- if ( current_user_can($manage) ) {
68
- if ( defined( 'LITESPEED_ON' ) ) {
69
- add_action('wp_before_admin_bar_render', array($this, 'add_quick_purge')) ;
70
- }
71
- add_action('admin_enqueue_scripts', array($this, 'check_messages')) ;// We can do this cos admin_notices hook is after admin_enqueue_scripts hook in wp-admin/admin-header.php
72
- }
73
-
74
- // add menus
75
- if ( $is_network_admin && is_plugin_active_for_network(LSWCP_BASENAME) ) {
76
- add_action('network_admin_menu', array($this, 'register_admin_menu')) ;
77
- }
78
- else {
79
- add_action('admin_menu', array($this, 'register_admin_menu')) ;
80
- }
81
-
82
- $this->config = LiteSpeed_Cache_Config::get_instance() ;
83
-
84
- // get default setting values
85
- $this->default_settings = $this->config->get_default_options() ;
86
- }
87
-
88
- /**
89
- * Load LiteSpeed assets
90
- *
91
- * @since 1.1.0
92
- * @access public
93
- * @param array $hook WP hook
94
- */
95
- public function load_assets($hook)
96
- {
97
- // Admin footer
98
- add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1) ;
99
-
100
- if( defined( 'LITESPEED_ON' ) ) {
101
- // Help tab
102
- $this->add_help_tabs() ;
103
-
104
- global $pagenow ;
105
- if ( $pagenow === 'plugins.php' ) {//todo: check if work
106
- add_action('wp_default_scripts', array($this, 'set_update_text'), 0) ;
107
- add_action('wp_default_scripts', array($this, 'unset_update_text'), 20) ;
108
- }
109
- }
110
- }
111
-
112
- /**
113
- * Output litespeed form info
114
- *
115
- * @since 1.1.0
116
- * @access public
117
- * @param string $action
118
- */
119
- public function form_action($action)
120
- {
121
- echo '<input type="hidden" name="' . LiteSpeed_Cache::ACTION_KEY . '" value="' . $action . '" />' ;
122
- wp_nonce_field($action, LiteSpeed_Cache::NONCE_NAME) ;
123
- }
124
-
125
-
126
- /**
127
- * Register the admin menu display.
128
- *
129
- * @since 1.0.0
130
- * @access public
131
- */
132
- public function register_admin_menu()
133
- {
134
- $capability = is_network_admin() ? 'manage_network_options' : 'manage_options' ;
135
- if ( current_user_can($capability) ) {
136
- // root menu
137
- add_menu_page('LiteSpeed Cache', 'LiteSpeed Cache', 'manage_options', 'lscache-dash') ;
138
-
139
- // sub menus
140
- $this->add_submenu(__('Manage', 'litespeed-cache'), 'lscache-dash', 'show_menu_manage') ;
141
-
142
- $this->add_submenu(__('Settings', 'litespeed-cache'), 'lscache-settings', 'show_menu_settings') ;
143
-
144
- if ( ! is_multisite() || is_network_admin() ) {
145
- $this->add_submenu(__('Edit .htaccess', 'litespeed-cache'), LiteSpeed_Cache::PAGE_EDIT_HTACCESS, 'show_menu_edit_htaccess') ;
146
- }
147
-
148
- $this->add_submenu(__('Information', 'litespeed-cache'), 'lscache-info', 'show_info') ;
149
- if ( ! is_multisite() || is_network_admin() ) {
150
- $this->add_submenu(__('Environment Report', 'litespeed-cache'), 'lscache-report', 'show_report') ;
151
- }
152
-
153
- if ( ! is_network_admin() ) {
154
- $this->add_submenu(__('Crawler', 'litespeed-cache'), 'lscache-crawler', 'show_crawler') ;
155
- }
156
-
157
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
158
- $this->add_submenu(__('Debug Log', 'litespeed-cache'), 'lscache-debug', 'show_debug_log') ;
159
- }
160
-
161
- // sub menus under options
162
- add_options_page('LiteSpeed Cache', 'LiteSpeed Cache', $capability, 'litespeedcache', array($this, 'show_menu_settings')) ;
163
- }
164
- }
165
-
166
- /**
167
- * Helper function to set up a submenu page.
168
- *
169
- * @since 1.0.4
170
- * @access private
171
- * @param string $menu_title The title that appears on the menu.
172
- * @param string $menu_slug The slug of the page.
173
- * @param string $callback The callback to call if selected.
174
- */
175
- private function add_submenu($menu_title, $menu_slug, $callback)
176
- {
177
- add_submenu_page('lscache-dash', $menu_title, $menu_title, 'manage_options', $menu_slug, array($this, $callback)) ;
178
- }
179
-
180
- /**
181
- * Register the stylesheets for the admin area.
182
- *
183
- * @since 1.0.14
184
- * @access public
185
- */
186
- public function enqueue_style()
187
- {
188
- wp_enqueue_style(LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'css/litespeed.css', array(), LiteSpeed_Cache::PLUGIN_VERSION, 'all') ;
189
- }
190
-
191
- /**
192
- * Register the JavaScript for the admin area.
193
- *
194
- * @since 1.0.0
195
- * @access public
196
- */
197
- public function enqueue_scripts()
198
- {
199
- wp_register_script(LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'js/litespeed-cache-admin.js', array(), LiteSpeed_Cache::PLUGIN_VERSION, false) ;
200
-
201
- if ( LiteSpeed_Cache_Router::has_whm_msg() ) {
202
- $ajax_url_dismiss_whm = LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_DISMISS_WHM, LiteSpeed_Cache::ACTION_DISMISS_WHM) ;
203
- wp_localize_script(LiteSpeed_Cache::PLUGIN_NAME, 'litespeed_data', array('ajax_url_dismiss_whm' => $ajax_url_dismiss_whm)) ;
204
- }
205
-
206
- if ( LiteSpeed_Cache_Router::has_msg_ruleconflict() ) {
207
- $ajax_url = LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT, LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT) ;
208
- wp_localize_script(LiteSpeed_Cache::PLUGIN_NAME, 'litespeed_data', array('ajax_url_dismiss_ruleconflict' => $ajax_url)) ;
209
- }
210
-
211
- wp_enqueue_script(LiteSpeed_Cache::PLUGIN_NAME) ;
212
- }
213
-
214
- /**
215
- * Callback that adds LiteSpeed Cache's action links.
216
- *
217
- * @since 1.0.0
218
- * @access public
219
- * @param array $links Previously added links from other plugins.
220
- * @return array Links array with the litespeed cache one appended.
221
- */
222
- public function add_plugin_links($links)
223
- {
224
- //$links[] = '<a href="' . admin_url('admin.php?page=litespeedcache') .'">Settings</a>';
225
- $links[] = '<a href="' . admin_url('options-general.php?page=litespeedcache') . '">' . __('Settings', 'litespeed-cache') . '</a>' ;
226
-
227
- return $links ;
228
- }
229
-
230
- /**
231
- * Add text to recommend updating upon update success.
232
- *
233
- * @since 1.0.8.1
234
- * @access public
235
- * @param string $translations
236
- * @param string $text
237
- * @return string
238
- */
239
- public function add_update_text($translations, $text)
240
- {
241
- if ( $text !== 'Updated!' ) {
242
- return $translations ;
243
- }
244
-
245
- return $translations . ' ' . __('It is recommended that LiteSpeed Cache be purged after updating a plugin.', 'litespeed-cache') ;
246
- }
247
-
248
- /**
249
- * Add the filter to update plugin update text.
250
- *
251
- * @since 1.0.8.1
252
- * @access public
253
- */
254
- public function set_update_text()
255
- {
256
- add_filter('gettext', array($this, 'add_update_text'), 10, 2) ;
257
- }
258
-
259
- /**
260
- * Remove the filter to update plugin update text.
261
- *
262
- * @since 1.0.8.1
263
- * @access public
264
- */
265
- public function unset_update_text()
266
- {
267
- remove_filter('gettext', array($this, 'add_update_text')) ;
268
- }
269
-
270
- /**
271
- * Hooked to wp_before_admin_bar_render.
272
- * Adds a link to the admin bar so users can quickly purge all.
273
- *
274
- * @access public
275
- * @global WP_Admin_Bar $wp_admin_bar
276
- * @global string $pagenow
277
- */
278
- public function add_quick_purge()
279
- {
280
- global $wp_admin_bar ;
281
- $url = LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_PURGE_ALL) ;
282
-
283
- $wp_admin_bar->add_node(array(
284
- 'id' => 'lscache-quick-purge',
285
- 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __('LiteSpeed Cache Purge All', 'litespeed-cache') . '</span>',
286
- 'href' => $url,
287
- 'meta' => array('class' => 'litespeed-top-toolbar'),
288
- )) ;
289
- }
290
-
291
- /**
292
- * Change the admin footer text on LiteSpeed Cache admin pages.
293
- *
294
- * @since 1.0.13
295
- * @param string $footer_text
296
- * @return string
297
- */
298
- public function admin_footer_text($footer_text)
299
- {
300
- require_once LSWCP_DIR . 'admin/tpl/admin_footer.php' ;
301
-
302
- return $footer_text ;
303
- }
304
-
305
- /**
306
- * Whether to disable all settings or not.
307
- *
308
- * Currently used for 'use primary subsite settings'
309
- *
310
- * @since 1.0.13
311
- * @access public
312
- * @return bool True to disable all settings, false otherwise.
313
- */
314
- public function get_disable_all()
315
- {
316
- return $this->disable_all ;
317
- }
318
-
319
- /**
320
- * Set to disable all settings.
321
- *
322
- * @since 1.0.13
323
- * @access public
324
- */
325
- public function set_disable_all()
326
- {
327
- $this->disable_all = true ;
328
- }
329
-
330
- /**
331
- * If show compatibility tab in settings
332
- * @since 1.1.0
333
- * @return bool True if shows
334
- */
335
- public function show_compatibility_tab()
336
- {
337
- return function_exists('the_views') ;
338
- }
339
-
340
- /**
341
- * Displays the help tab in the admin pages.
342
- *
343
- * @since 1.0.0
344
- * @access public
345
- */
346
- public function add_help_tabs()
347
- {
348
- require_once LSWCP_DIR . 'admin/tpl/help_tabs.php' ;
349
- }
350
-
351
- /**
352
- * Check to make sure that caching is enabled.
353
- *
354
- * @since 1.0.0
355
- * @access public
356
- * @return mixed True if enabled, error message otherwise.
357
- */
358
- public function check_license()
359
- {
360
- if ( ! defined( 'LITESPEED_ALLOWED' ) ) {
361
- self::add_error(LiteSpeed_Cache_Admin_Error::E_SERVER) ;
362
- self::display_messages() ;
363
- }
364
- }
365
-
366
- /**
367
- * Builds the html for a single notice.
368
- *
369
- * @since 1.0.7
370
- * @access private
371
- * @param string $color The color to use for the notice.
372
- * @param string $str The notice message.
373
- * @return string The built notice html.
374
- */
375
- private static function build_notice($color, $str)
376
- {
377
- return '<div class="' . $color . ' is-dismissible"><p>'. $str . '</p></div>' ;
378
- }
379
-
380
- /**
381
- * Get the error description
382
- *
383
- * @since 1.1.0
384
- * @param init $err_code
385
- * @param mixed $args
386
- * @return mixed String or false
387
- */
388
- public static function get_error($err_code, $args = null)
389
- {
390
- $error = LiteSpeed_Cache_Admin_Error::get_instance()->convert_code_to_error($err_code) ;
391
- if ( empty($error) ) {
392
- return false ;
393
- }
394
- $error = 'ERROR ' . $err_code . ': ' . $error ;
395
- if ( ! is_null($args) ) {
396
- if ( is_array($args) ) {
397
- $error = vsprintf($error, $args) ;
398
- }
399
- else {
400
- $error = sprintf($error, $args) ;
401
- }
402
- }
403
- return $error ;
404
- }
405
-
406
- /**
407
- * Adds an error to the admin notice system.
408
- *
409
- * This function will get the error message by error code and arguments
410
- * and append it to the list of outgoing errors.
411
- *
412
- * @access public
413
- * @since 1.1.0
414
- * @param int $err_code The error code to retrieve.
415
- * @param mixed $args Null if no arguments, an array if multiple arguments,
416
- * else a single argument.
417
- */
418
- public static function add_error($err_code, $args = null)
419
- {
420
- $error = self::get_error($err_code, $args) ;
421
- if( ! $error ) {
422
- return false ;
423
- }
424
- self::add_notice(self::NOTICE_RED, $error) ;
425
- }
426
-
427
- /**
428
- * Adds a notice to display on the admin page. Multiple messages of the
429
- * same color may be added in a single call. If the list is empty, this
430
- * method will add the action to display notices.
431
- *
432
- * @since 1.0.7
433
- * @access public
434
- * @param string $color One of the available constants provided by this
435
- * class.
436
- * @param mixed $msg May be a string for a single message or an array for
437
- * multiple.
438
- */
439
- public static function add_notice($color, $msg)
440
- {
441
- $messages = (array)get_transient(self::TRANSIENT_LITESPEED_MESSAGE) ;
442
- if( ! $messages ) {
443
- $messages = array() ;
444
- }
445
- if ( is_array($msg) ) {
446
- foreach ($msg as $str) {
447
- $messages[] = self::build_notice($color, $str) ;
448
- }
449
- }
450
- else {
451
- $messages[] = self::build_notice($color, $msg) ;
452
- }
453
- set_transient(self::TRANSIENT_LITESPEED_MESSAGE, $messages, 86400) ;
454
- }
455
-
456
- /**
457
- * Display notices and errors in dashboard
458
- *
459
- * @since 1.1.0
460
- * @access public
461
- */
462
- public function display_messages()
463
- {
464
- $messages = get_transient(self::TRANSIENT_LITESPEED_MESSAGE) ;
465
- if( is_array($messages) ) {
466
- $messages = array_unique($messages) ;
467
- foreach ($messages as $msg) {
468
- echo $msg ;
469
- }
470
- }
471
- delete_transient(self::TRANSIENT_LITESPEED_MESSAGE) ;
472
- }
473
-
474
- /**
475
- * Check if has new messages
476
- *
477
- * @since 1.1.0
478
- * @access public
479
- */
480
- public function check_messages()
481
- {
482
- $messages = get_transient(self::TRANSIENT_LITESPEED_MESSAGE) ;
483
- if( ! $messages ) {
484
- return ;
485
- }
486
- add_action(is_network_admin() ? 'network_admin_notices' : 'admin_notices', array($this, 'display_messages')) ;
487
- }
488
-
489
- /**
490
- * Hooked to the in_widget_form action.
491
- * Appends LiteSpeed Cache settings to the widget edit settings screen.
492
- * This will append the esi on/off selector and ttl text.
493
- *
494
- * @access public
495
- * @since 1.1.0
496
- * @param type $widget
497
- * @param type $return
498
- * @param type $instance
499
- */
500
- public function show_widget_edit($widget, $return, $instance)
501
- {
502
- require LSWCP_DIR . 'admin/tpl/esi_widget_edit.php' ;
503
- }
504
-
505
- /**
506
- * Displays the cache management page.
507
- *
508
- * @since 1.0.0
509
- * @access public
510
- */
511
- public function show_menu_manage()
512
- {
513
- require_once LSWCP_DIR . 'admin/tpl/manage.php' ;
514
- }
515
-
516
- /**
517
- * Outputs the LiteSpeed Cache settings page.
518
- *
519
- * @since 1.0.0
520
- * @access public
521
- */
522
- public function show_menu_settings()
523
- {
524
- if ( is_network_admin() ) {
525
- require_once LSWCP_DIR . 'admin/tpl/network_settings.php' ;
526
- }
527
- else {
528
- if ( $_GET['page'] != 'litespeedcache' ) {// ls settings msg need to display manually
529
- settings_errors() ;
530
- }
531
- require_once LSWCP_DIR . 'admin/tpl/settings.php' ;
532
- }
533
- }
534
-
535
- /**
536
- * Displays the edit_htaccess admin page.
537
- *
538
- * This function will try to load the .htaccess file contents.
539
- * If it fails, it will echo the error message.
540
- *
541
- * @since 1.0.4
542
- * @access public
543
- */
544
- public function show_menu_edit_htaccess()
545
- {
546
- require_once LSWCP_DIR . 'admin/tpl/edit_htaccess.php' ;
547
- }
548
-
549
- /**
550
- * Outputs the html for the Environment Report page.
551
- *
552
- * @since 1.0.12
553
- * @access public
554
- */
555
- public function show_report()
556
- {
557
- require_once LSWCP_DIR . 'admin/tpl/report.php' ;
558
- }
559
-
560
- /**
561
- * Outputs the crawler operation page.
562
- *
563
- * @since 1.1.0
564
- * @access public
565
- */
566
- public function show_crawler()
567
- {
568
- require_once LSWCP_DIR . 'admin/tpl/crawler.php' ;
569
- }
570
-
571
- /**
572
- * Outputs the debug log.
573
- *
574
- * @since 1.1.5
575
- * @access public
576
- */
577
- public function show_debug_log()
578
- {
579
- require_once LSWCP_DIR . 'admin/tpl/debug_log.php' ;
580
- }
581
-
582
- /**
583
- * Outputs the html for the info page.
584
- *
585
- * This page includes three tabs:
586
- * - configuration
587
- * - third party plugin compatibilities
588
- * - common rewrite rules.
589
- *
590
- * @since 1.1.0
591
- * @access public
592
- */
593
- public function show_info()
594
- {
595
- require_once LSWCP_DIR . 'admin/tpl/info.php' ;
596
- }
597
-
598
- /**
599
- * Outputs a notice to the admin panel when ExpiresDefault is detected
600
- *
601
- * @since 1.1.5
602
- * @access public
603
- */
604
- public function show_rule_conflict()
605
- {
606
- require_once LSWCP_DIR . 'admin/tpl/show_rule_conflict.php' ;
607
- }
608
-
609
- /**
610
- * Outputs a notice to the admin panel when the plugin is installed
611
- * via the WHM plugin.
612
- *
613
- * @since 1.0.12
614
- * @access public
615
- */
616
- public function show_display_installed()
617
- {
618
- require_once LSWCP_DIR . 'admin/tpl/show_display_installed.php' ;
619
- }
620
-
621
- /**
622
- * Display error cookie msg.
623
- *
624
- * @since 1.0.12
625
- * @access public
626
- */
627
- public static function show_error_cookie()
628
- {
629
- require_once LSWCP_DIR . 'admin/tpl/show_error_cookie.php' ;
630
- }
631
-
632
- /**
633
- * Build a textarea
634
- *
635
- * @since 1.1.0
636
- * @access public
637
- * @param string $id
638
- * @param string $val Value of input
639
- * @param boolean $disabled If this input is disabled or not
640
- * @param int $cols The width of textarea
641
- */
642
- public function build_textarea($id, $val = null, $disabled = false, $cols = false)
643
- {
644
- if ( $val === null ) {
645
- global $_options ;
646
- $val = $_options[$id] ;
647
- }
648
- $disabled = $disabled ? ' disabled ' : '' ;
649
-
650
- if ( $cols === false ) {
651
- $cols = 80 ;
652
- }
653
-
654
- echo "<textarea name='" . LiteSpeed_Cache_Config::OPTION_NAME . "[$id]' rows='5' cols='$cols' $disabled>" . esc_textarea($val) . "</textarea>" ;
655
- }
656
-
657
- /**
658
- * Build a text input field
659
- *
660
- * @since 1.1.0
661
- * @access public
662
- * @param string $id
663
- * @param string $style Appending styles
664
- * @param boolean $disabled Disable this field
665
- * @param boolean $readonly If is readonly
666
- * @param string $id_attr ID for this field
667
- * @param string $val Field value
668
- * @param string $attrs Additional attributes
669
- * @param string $type Input type
670
- */
671
- public function build_input( $id, $style = false, $disabled = false, $readonly = false, $id_attr = null, $val = null, $attrs = '', $type = 'text' )
672
- {
673
- if ( $val === null ) {
674
- global $_options ;
675
- $val = $_options[ $id ] ;
676
- }
677
- $disabled = $disabled ? ' disabled ' : '' ;
678
- $readonly = $readonly ? ' readonly ' : '' ;
679
- if ( $id_attr !== null ) {
680
- $id_attr = " id='$id_attr' " ;
681
- }
682
-
683
- if ( $type == 'text' ) {
684
- $style = "litespeed-regular-text $style" ;
685
- }
686
-
687
- echo "<input type='$type' class='$style' name='" . LiteSpeed_Cache_Config::OPTION_NAME . "[$id]' value='" . esc_textarea( $val ) ."' $disabled $readonly $id_attr $attrs /> " ;
688
- }
689
-
690
- /**
691
- * Build a switch div html snippet
692
- *
693
- * @since 1.1.0
694
- * @access public
695
- * @param string $id
696
- * @param boolean $disabled Disable this field
697
- * @param boolean $return Return the html or echo it
698
- * @param boolean $checked If the value is on
699
- * @param string $id_attr ID for this field, set to true if want to use a not specified unique value
700
- */
701
- public function build_switch($id, $disabled = false, $return = false, $checked = null, $id_attr = null)
702
- {
703
- $id_attr_on = $id_attr === null ? null : $id_attr . '_' . LiteSpeed_Cache_Config::VAL_ON ;
704
- $id_attr_off = $id_attr === null ? null : $id_attr . '_' . LiteSpeed_Cache_Config::VAL_OFF ;
705
- $html = '<div class="litespeed-switch">' ;
706
- $html .= $this->build_radio($id, LiteSpeed_Cache_Config::VAL_OFF, null, $checked === null ? null : !$checked, $disabled, $id_attr_off) ;
707
- $html .= $this->build_radio($id, LiteSpeed_Cache_Config::VAL_ON, null, $checked, $disabled, $id_attr_on) ;
708
- $html .= '</div>' ;
709
-
710
- if ( $return ) {
711
- return $html ;
712
- }
713
- else {
714
- echo $html ;
715
- }
716
- }
717
-
718
- /**
719
- * Build a checkbox html snippet
720
- *
721
- * @since 1.1.0
722
- * @access public
723
- * @param string $id
724
- * @param string $title
725
- * @param bool $checked
726
- */
727
- public function build_checkbox($id, $title, $checked, $is_mini = false)
728
- {
729
- $checked = $checked ? ' checked ' : '' ;
730
- $is_mini = $is_mini ? ' litespeed-mini ' : '' ;
731
-
732
- echo "<div class='litespeed-tick $is_mini'>
733
- <label for='conf_$id'>$title</label>
734
- <input type='checkbox' name='" . LiteSpeed_Cache_Config::OPTION_NAME . "[$id]' id='conf_$id' value='1' $checked />
735
- </div>" ;
736
- }
737
-
738
- /**
739
- * Build a radio input html codes and output
740
- *
741
- * @since 1.1.0
742
- * @access public
743
- * @param string $id
744
- * @param string $val Default value of this input
745
- * @param string $txt Title of this input
746
- * @param bool $checked If checked or not
747
- * @param string $id_attr ID for this field, set to true if want to use a not specified unique value
748
- */
749
- public function build_radio($id, $val, $txt = null, $checked = null, $disabled = false, $id_attr = null)
750
- {
751
- if ( $checked === null ) {
752
- global $_options ;
753
- $to_be_checked = null ;
754
- if ( isset( $_options[ $id ] ) ) {
755
- $to_be_checked = is_int( $val ) ? (int)$_options[ $id ] : $_options[ $id ] ;
756
- }
757
-
758
- $checked = $to_be_checked === $val ? true : false ;
759
- }
760
-
761
- if ( $id_attr === null ) {
762
- $id_attr = is_int($val) ? "conf_{$id}_$val" : md5($val) ;
763
- }
764
- elseif ( $id_attr === true ) {
765
- $id_attr = md5($val) ;
766
- }
767
-
768
- if ( $txt === null ){
769
- if ( $val === LiteSpeed_Cache_Config::VAL_ON ){
770
- $txt = __( 'ON', 'litespeed-cache' ) ;
771
- }
772
-
773
- if ( $val === LiteSpeed_Cache_Config::VAL_OFF ){
774
- $txt = __( 'OFF', 'litespeed-cache' ) ;
775
- }
776
- }
777
-
778
- $checked = $checked ? ' checked ' : '' ;
779
- $disabled = $disabled ? ' disabled ' : '' ;
780
-
781
- return "<input type='radio' "
782
- . " name='". LiteSpeed_Cache_Config::OPTION_NAME . "[$id]' "
783
- . " id='$id_attr' "
784
- . " value='$val' "
785
- . " $checked "
786
- . " $disabled "
787
- . " />"
788
- . " <label for='$id_attr'>$txt</label>" ;
789
- }
790
-
791
- /**
792
- * Display default value
793
- *
794
- * @since 1.1.1
795
- * @access public
796
- * @param string $id The setting tag
797
- */
798
- public function recommended($id) {
799
- $val = isset($this->default_settings[$id]) ? $this->default_settings[$id] : '' ;
800
- if ( $val ) {
801
- if ( ! is_numeric( $val ) && strpos( $val, "\n" ) !== false ) {
802
- $val = "<textarea readonly rows='5' class='litespeed-left10'>$val</textarea>" ;
803
- }
804
- else {
805
- $val = "<code>$val</code>" ;
806
- }
807
- echo sprintf( __( 'Recommended value: %s', 'litespeed-cache' ), $val ) ;
808
- }
809
- }
810
-
811
- /**
812
- * Get the current instance object.
813
- *
814
- * @since 1.1.0
815
- * @access public
816
- * @return Current class instance.
817
- */
818
- public static function get_instance()
819
- {
820
- if ( ! isset(self::$_instance) ) {
821
- self::$_instance = new self() ;
822
- }
823
-
824
- return self::$_instance ;
825
- }
826
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/litespeed-cache-admin-error.class.php DELETED
@@ -1,262 +0,0 @@
1
- <?php
2
-
3
-
4
-
5
- /**
6
- * The admin errors
7
- *
8
- *
9
- * @since 1.0.15
10
- * @package LiteSpeed_Cache
11
- * @subpackage LiteSpeed_Cache/admin
12
- * @author LiteSpeed Technologies <info@litespeedtech.com>
13
- */
14
- class LiteSpeed_Cache_Admin_Error
15
- {
16
- private static $_instance ;
17
-
18
- const NOTICE_BLUE = 'notice notice-info' ;
19
- const NOTICE_GREEN = 'notice notice-success' ;
20
- const NOTICE_RED = 'notice notice-error' ;
21
- const NOTICE_YELLOW = 'notice notice-warning' ;
22
- const E_PHP_VER = 1000 ;
23
- const E_WP_VER = 1010 ;
24
-
25
- const E_PURGE_FORM = 2000 ;
26
- const E_PURGEBY_EMPTY = 2010 ;
27
- const E_PURGEBY_BAD = 2020 ;
28
- const E_PURGEBY_CAT_INV = 2030 ;
29
- const E_PURGEBY_TAG_INV = 2040 ;
30
- const E_PURGEBY_URL_BAD = 2050 ;
31
-
32
- const E_PURGEBY_PID_NUM = 2500 ;
33
- const E_PURGEBY_PID_DNE = 2510 ;
34
- const E_PURGEBY_URL_INV = 2520 ;
35
- const E_PURGEBY_CAT_DNE = 2530 ;
36
- const E_PURGEBY_TAG_DNE = 2540 ;
37
-
38
- const E_SETTING_ADMIN_IP_INV = 3000 ;
39
- const E_SETTING_TEST_IP_INV = 3010 ;
40
- const E_SETTING_SITE_IP = 3020 ;
41
- const E_SETTING_CUSTOM_SITEMAP_READ = 3030 ;
42
- const E_SETTING_CUSTOM_SITEMAP_PARSE = 3031 ;
43
-
44
- const E_SETTING_NUMERIC = 3500 ;
45
- const E_SETTING_CAT = 3510 ;
46
- const E_SETTING_TAG = 3520 ;
47
- const E_SETTING_LC = 3530 ; // login cookie setting
48
- const E_SETTING_REWRITE = 3540 ;
49
-
50
- const E_LC_HTA = 4000 ; // login cookie .htaccess not correct
51
-
52
- const E_HTA_DNF = 4500 ; // .htaccess did not find.
53
-
54
- const E_LC_MISMATCH = 5000 ; // login cookie mismatch
55
-
56
- const E_SERVER = 6000 ;
57
-
58
- const E_CONF = 9000 ; // general config failed to write.
59
- const E_HTA_BU = 9010 ; // backup
60
- const E_HTA_PUT = 9020 ; // failed to put
61
- const E_HTA_GET = 9030 ; // failed to get
62
- const E_HTA_RW = 9040 ; // read write
63
- const E_HTA_R = 9041 ; // read
64
- const E_HTA_W = 9042 ; // write
65
- const E_HTA_ORDER = 9050 ; // prefix found after suffix
66
- const E_HTA_SAVE = 9060 ;
67
- const E_CONF_WRITE = 9070 ;
68
- const E_CONF_FIND = 9080 ;
69
-
70
- /**
71
- * Get the error message by code.
72
- *
73
- * @since 1.0.15
74
- * @access public
75
- * @param int $err_code The error code to retrieve.
76
- * @return string The error message if matching, else an empty string.
77
- */
78
- public function convert_code_to_error($err_code)
79
- {
80
- if ( ! is_numeric($err_code) ) {
81
- return false ;
82
- }
83
-
84
- switch ($err_code){
85
- case self::E_PHP_VER:
86
- return '<strong>'
87
- . __('The installed PHP version is too old for the LiteSpeed Cache Plugin.', 'litespeed-cache')
88
- . '</strong><br /> '
89
- . sprintf(__('The LiteSpeed Cache Plugin requires at least PHP %s.', 'litespeed-cache'), '5.3')
90
- . ' '
91
- . sprintf(__('The currently installed version is PHP %s, which is out-dated and insecure.', 'litespeed-cache'), PHP_VERSION)
92
- . ' '
93
- . sprintf(wp_kses(__('Please upgrade or go to <a href="%s">active plugins</a> and deactivate the LiteSpeed Cache plugin to hide this message.', 'litespeed-cache'),
94
- array('a' => array('href' => array()))), 'plugins.php?plugin_status=active') ;
95
-
96
- case self::E_WP_VER:
97
- return '<strong>'
98
- . __('The installed WordPress version is too old for the LiteSpeed Cache Plugin.', 'litespeed-cache')
99
- . '</strong><br />'
100
- . sprintf(__('The LiteSpeed Cache Plugin requires at least WordPress %s.', 'litespeed-cache'), '3.3')
101
- . ' '
102
- . sprintf(wp_kses(__('Please upgrade or go to <a href="%s">active plugins</a> and deactivate the LiteSpeed Cache plugin to hide this message.', 'litespeed-cache'),
103
- array('a' => array('href' => array()))), 'plugins.php?plugin_status=active') ;
104
-
105
- // Admin action errors.
106
- case self::E_PURGE_FORM:
107
- return __('Something went wrong with the form! Please try again.', 'litespeed-cache') ;
108
-
109
- case self::E_PURGEBY_EMPTY:
110
- return __('Tried to purge list with empty list.', 'litespeed-cache') ;
111
-
112
- case self::E_PURGEBY_BAD:
113
- return __('Bad Purge By selected value.', 'litespeed-cache') ;
114
-
115
- case self::E_PURGEBY_CAT_INV:
116
- return __('Failed to purge by category, invalid category slug.', 'litespeed-cache') ;
117
-
118
- case self::E_PURGEBY_TAG_INV:
119
- return __('Failed to purge by tag, invalid tag slug.', 'litespeed-cache') ;
120
-
121
- case self::E_PURGEBY_URL_BAD:
122
- return __('Failed to purge by url, contained "<".', 'litespeed-cache') ;
123
-
124
- // Admin actions with expected parameters for message.
125
- case self::E_PURGEBY_PID_NUM:
126
- return __('Failed to purge by Post ID, given ID is not numeric: %s', 'litespeed-cache') ;
127
-
128
- case self::E_PURGEBY_PID_DNE:
129
- return __('Failed to purge by Post ID, given ID does not exist or is not published: %s',
130
- 'litespeed-cache') ;
131
-
132
- case self::E_PURGEBY_URL_INV:
133
- return __('Failed to purge by url, invalid input: %s.', 'litespeed-cache') ;
134
-
135
- case self::E_PURGEBY_CAT_DNE:
136
- return __('Failed to purge by category, does not exist: %s', 'litespeed-cache') ;
137
-
138
- case self::E_PURGEBY_TAG_DNE:
139
- return __('Failed to purge by tag, does not exist: %s', 'litespeed-cache') ;
140
-
141
- // Admin settings errors.
142
- case self::E_SETTING_ADMIN_IP_INV:
143
- return __('Invalid data in Admin IPs.', 'litespeed-cache') ;
144
-
145
- case self::E_SETTING_TEST_IP_INV:
146
- return __('Invalid data in Test IPs.', 'litespeed-cache') ;
147
-
148
- case self::E_SETTING_SITE_IP:
149
- return __('Invalid Site IP: %s', 'litespeed-cache') ;
150
-
151
- case self::E_SETTING_CUSTOM_SITEMAP_READ:
152
- return __('Can not fetch Custom Sitemap: %s', 'litespeed-cache') ;
153
-
154
- case self::E_SETTING_CUSTOM_SITEMAP_PARSE:
155
- return __('Can not parse custom sitemap xml file: %s.', 'litespeed-cache') . ' '
156
- . sprintf(__('Please make sure the file is xml format and the %s extension is installed on the server.', 'litespeed-cache'), 'php-xml') ;
157
-
158
- // Admin settings with expected parameters for message.
159
- case self::E_SETTING_NUMERIC:
160
- // %1 is the name of the option, %2 is the minimum integer allowed.
161
- return __('%1$s must be an integer between %2$d and %3$d',
162
- 'litespeed-cache') ;
163
-
164
- case self::E_SETTING_CAT:
165
- // %s is the category attempted to be added.
166
- return __('Removed category "%s" from list, ID does not exist.',
167
- 'litespeed-cache') ;
168
-
169
- case self::E_SETTING_TAG:
170
- // %s is the tag attempted to be added.
171
- return __('Removed tag "%s" from list, ID does not exist.',
172
- 'litespeed-cache') ;
173
-
174
- case self::E_SETTING_LC:
175
- return __('Invalid login cookie. Invalid characters found: %s',
176
- 'litespeed-cache') ;
177
-
178
- case self::E_SETTING_REWRITE:
179
- return __('Invalid Rewrite List.', 'litespeed-cache') . ' '
180
- . __('Empty or invalid rule.', 'litespeed-cache') . ' '
181
- . __('Rule: %1$s, list: %2$s', 'litespeed-cache') ;
182
-
183
- // Login cookie in settings did not match .htaccess.
184
- case self::E_LC_HTA:
185
- return __('Tried to parse for existing login cookie.', 'litespeed-cache') . ' '
186
- . sprintf(__('%s file not valid. Please verify contents.', 'litespeed-cache'), '.htaccess') ;
187
-
188
- // Could not find something in the .htaccess file. Expect parameter.
189
- case self::E_HTA_DNF:
190
- return __('Could not find %s.', 'litespeed-cache') ;
191
-
192
- // Mismatched login cookie.
193
- case self::E_LC_MISMATCH:
194
- return __('This site is a subdirectory install.', 'litespeed-cache') . ' '
195
- . __('Login cookies do not match.', 'litespeed-cache') . ' '
196
- . __('Please remove both and set the login cookie in LiteSpeed Cache advanced settings.', 'litespeed-cache') ;
197
-
198
- // Either running another server or doesn't have cache module.
199
- case self::E_SERVER:
200
- return __('Notice: This plugin requires a LiteSpeed Server with the LSCache Module enabled.', 'litespeed-cache') . ' '
201
- . __('If you are unable to change your server stack, please contact your hosting provider to request the required changes.', 'litespeed-cache') . ' '
202
- . __('This plugin will NOT work properly.', 'litespeed-cache') ;
203
-
204
- case self::E_CONF:
205
- return __('LiteSpeed Cache was unable to write to the wp-config.php file.', 'litespeed-cache') . ' '
206
- . sprintf(__('Please add the following to the wp-config.php file: %s', 'litespeed-cache'), '<br><pre>define(\'WP_CACHE\', true);</pre>') ;
207
-
208
- // .htaccess problem.
209
- case self::E_HTA_BU:
210
- return __('Failed to back up file, aborted changes.', 'litespeed-cache') ;
211
-
212
- case self::E_HTA_PUT:
213
- return sprintf(__('Failed to put contents into %s', 'litespeed-cache'), '.htaccess') ;
214
-
215
- case self::E_HTA_GET:
216
- return sprintf(__('Failed to get %s file contents.', 'litespeed-cache'), '.htaccess') ;
217
-
218
- case self::E_HTA_RW:
219
- return sprintf(__('%s file not readable or not writable.', 'litespeed-cache'), '.htaccess') ;
220
-
221
- case self::E_HTA_R:
222
- return sprintf(__('%s file not readable.', 'litespeed-cache'), '.htaccess') ;
223
-
224
- case self::E_HTA_W:
225
- return sprintf(__('%s file not writable.', 'litespeed-cache'), '.htaccess') ;
226
-
227
- case self::E_HTA_SAVE:
228
- return sprintf(__('Failed to overwrite %s.', 'litespeed-cache'), '.htaccess') ;
229
-
230
- // wp-config problem.
231
- case self::E_CONF_WRITE:
232
- $err = sprintf(__('The %1$s file not writable for %2$s', 'litespeed-cache'), 'wp-config', '\'WP_CACHE\'') ;
233
- break ;
234
-
235
- case self::E_CONF_FIND:
236
- $err = sprintf(__('%s file did not find a place to insert define.', 'litespeed-cache'), 'wp-config') ;
237
- break ;
238
-
239
- default:
240
- return false ;
241
- }
242
-
243
- return $err . '<br />' . __('LiteSpeed Cache was unable to write to the wp-config.php file.', 'litespeed-cache') . ' '
244
- . sprintf(__('Please add the following to the wp-config.php file: %s', 'litespeed-cache'), '<br><pre>define(\'WP_CACHE\', true);</pre>') ;
245
- }
246
-
247
- /**
248
- * Get the current instance object.
249
- *
250
- * @since 1.1.0
251
- * @access public
252
- * @return Current class instance.
253
- */
254
- public static function get_instance()
255
- {
256
- if ( ! isset(self::$_instance) ) {
257
- self::$_instance = new self() ;
258
- }
259
-
260
- return self::$_instance ;
261
- }
262
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/litespeed-cache-admin-optimize.class.php DELETED
@@ -1,188 +0,0 @@
1
- <?php
2
- /**
3
- * The admin optimize tool
4
- *
5
- *
6
- * @since 1.2.1
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/admin
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
- class LiteSpeed_Cache_Admin_Optimize
12
- {
13
-
14
- const TYPE = 'ls_opt_type' ;
15
-
16
- private static $_types = array( 'revision', 'auto_draft', 'trash_post', 'spam_comment', 'trash_comment', 'trackback-pingback', 'expired_transient', 'all_transients' ) ;
17
-
18
- /**
19
- * Generate operation URL
20
- *
21
- * @since 1.2.1
22
- * @access public
23
- * @param string $type The type to proceed
24
- * @return string The final URL
25
- */
26
- public static function generate_url( $type )
27
- {
28
- $url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DB_OPTIMIZE, false, self::TYPE . '=' . $type ) ;
29
- return $url ;
30
- }
31
-
32
- /**
33
- * Run DB Cleaner
34
- *
35
- * @since 1.2.1
36
- * @access public
37
- */
38
- public static function run_db_clean()
39
- {
40
- if( empty( $_GET[ self::TYPE ] ) ) {
41
- return ;
42
- }
43
-
44
- $res = '' ;
45
-
46
- if ( is_multisite() && is_network_admin() ) {
47
- $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
48
- foreach ( $blogs as $blog_id ) {
49
- switch_to_blog( $blog_id ) ;
50
- $res = self::db_clean( $_GET[ self::TYPE ] ) ;
51
- restore_current_blog() ;
52
- }
53
- }
54
- else {
55
- $res = self::db_clean( $_GET[ self::TYPE ] ) ;
56
- }
57
-
58
- return $res ;
59
-
60
- }
61
-
62
- /**
63
- * Clean/Optimize WP tables
64
- *
65
- * @since 1.2.1
66
- * @access public
67
- * @param string $type The type to clean
68
- * @param bool $ignore_multisite If ignore multisite check
69
- * @return int The rows that will be affected
70
- */
71
- public static function db_count( $type, $ignore_multisite = false )
72
- {
73
- if ( $type === 'all' ) {
74
- $num = 0 ;
75
- foreach ( self::$_types as $val ) {
76
- $num += self::db_count( $val ) ;
77
- }
78
- return $num ;
79
- }
80
-
81
- if ( ! $ignore_multisite ) {
82
- if ( is_multisite() && is_network_admin() ) {
83
- $num = 0 ;
84
- $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
85
- foreach ( $blogs as $blog_id ) {
86
- switch_to_blog( $blog_id ) ;
87
- $num += self::db_count( $type, true ) ;
88
- restore_current_blog() ;
89
- }
90
- return $num ;
91
- }
92
- }
93
-
94
- global $wpdb ;
95
-
96
- switch ( $type ) {
97
- case 'revision':
98
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_type = 'revision'" ) ;
99
-
100
- case 'auto_draft':
101
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_status = 'auto-draft'" ) ;
102
-
103
- case 'trash_post':
104
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_status = 'trash'" ) ;
105
-
106
- case 'spam_comment':
107
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_approved = 'spam'" ) ;
108
-
109
- case 'trash_comment':
110
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_approved = 'trash'" ) ;
111
-
112
- case 'trackback-pingback':
113
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback'" ) ;
114
-
115
- case 'expired_transient':
116
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time() ) ;
117
-
118
- case 'all_transients':
119
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '%_transient_%'" ) ;
120
-
121
- case 'optimize_tables':
122
- return $wpdb->get_var( "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '" . DB_NAME . "' and Engine <> 'InnoDB' and data_free > 0" ) ;
123
- }
124
- }
125
-
126
- /**
127
- * Clean/Optimize WP tables
128
- *
129
- * @since 1.2.1
130
- * @access public
131
- * @param string $type The type to clean
132
- */
133
- public static function db_clean( $type )
134
- {
135
- if ( $type === 'all' ) {
136
- foreach ( self::$_types as $val ) {
137
- self::db_clean( $val ) ;
138
- }
139
- return __( 'Clean all successfully.', 'litespeed-cache' ) ;
140
- }
141
-
142
- global $wpdb ;
143
- switch ( $type ) {
144
- case 'revision':
145
- $wpdb->query( "DELETE FROM `$wpdb->posts` WHERE post_type = 'revision'" ) ;
146
- return __( 'Clean post revisions successfully.', 'litespeed-cache' ) ;
147
-
148
- case 'auto_draft':
149
- $wpdb->query( "DELETE FROM `$wpdb->posts` WHERE post_status = 'auto-draft'" ) ;
150
- return __( 'Clean auto drafts successfully.', 'litespeed-cache' ) ;
151
-
152
- case 'trash_post':
153
- $wpdb->query( "DELETE FROM `$wpdb->posts` WHERE post_status = 'trash'" ) ;
154
- return __( 'Clean trashed posts and pages successfully.', 'litespeed-cache' ) ;
155
-
156
- case 'spam_comment':
157
- $wpdb->query( "DELETE FROM `$wpdb->comments` WHERE comment_approved = 'spam'" ) ;
158
- return __( 'Clean spam comments successfully.', 'litespeed-cache' ) ;
159
-
160
- case 'trash_comment':
161
- $wpdb->query( "DELETE FROM `$wpdb->comments` WHERE comment_approved = 'trash'" ) ;
162
- return __( 'Clean trashed comments successfully.', 'litespeed-cache' ) ;
163
-
164
- case 'trackback-pingback':
165
- $wpdb->query( "DELETE FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback'" ) ;
166
- return __( 'Clean trackbacks and pingbacks successfully.', 'litespeed-cache' ) ;
167
-
168
- case 'expired_transient':
169
- $wpdb->query( "DELETE FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time() ) ;
170
- return __( 'Clean expired transients successfully.', 'litespeed-cache' ) ;
171
-
172
- case 'all_transients':
173
- $wpdb->query( "DELETE FROM `$wpdb->options` WHERE option_name LIKE '%_transient_%'" ) ;
174
- return __( 'Clean all transients successfully.', 'litespeed-cache' ) ;
175
-
176
- case 'optimize_tables':
177
- $sql = "SELECT table_name, data_free FROM information_schema.tables WHERE table_schema = '" . DB_NAME . "' and Engine <> 'InnoDB' and data_free > 0" ;
178
- $result = $wpdb->get_results( $sql ) ;
179
- if ( $result ) {
180
- foreach ( $result as $row ) {
181
- $wpdb->query( 'OPTIMIZE TABLE ' . $row->table_name ) ;
182
- }
183
- }
184
- return __( 'Optimized all tables.', 'litespeed-cache' ) ;
185
- }
186
-
187
- }
188
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/litespeed-cache-admin-report.class.php DELETED
@@ -1,197 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The report class
5
- *
6
- *
7
- * @since 1.1.0
8
- * @package LiteSpeed_Cache
9
- * @subpackage LiteSpeed_Cache/admin
10
- * @author LiteSpeed Technologies <info@litespeedtech.com>
11
- */
12
- class LiteSpeed_Cache_Admin_Report
13
- {
14
- private static $_instance;
15
-
16
- /**
17
- * Gathers the environment details and creates the report.
18
- * Will write to the environment report file.
19
- *
20
- * @since 1.0.12
21
- * @access public
22
- * @param mixed $options Array of options to output. If null, will skip
23
- * the options section.
24
- * @return string The built report.
25
- */
26
- public function generate_environment_report($options = null)
27
- {
28
- global $wp_version, $_SERVER ;
29
- $frontend_htaccess = LiteSpeed_Cache_Admin_Rules::get_frontend_htaccess() ;
30
- $backend_htaccess = LiteSpeed_Cache_Admin_Rules::get_backend_htaccess() ;
31
- $paths = array($frontend_htaccess) ;
32
- if ( $frontend_htaccess != $backend_htaccess ) {
33
- $paths[] = $backend_htaccess ;
34
- }
35
-
36
- if ( is_multisite() ) {
37
- $active_plugins = get_site_option('active_sitewide_plugins') ;
38
- if ( ! empty($active_plugins) ) {
39
- $active_plugins = array_keys($active_plugins) ;
40
- }
41
- }
42
- else {
43
- $active_plugins = get_option('active_plugins') ;
44
- }
45
-
46
- if ( function_exists('wp_get_theme') ) {
47
- $theme_obj = wp_get_theme() ;
48
- $active_theme = $theme_obj->get('Name') ;
49
- }
50
- else {
51
- $active_theme = get_current_theme() ;
52
- }
53
-
54
- $extras = array(
55
- 'wordpress version' => $wp_version,
56
- 'locale' => get_locale(),
57
- 'active theme' => $active_theme,
58
- 'active plugins' => $active_plugins,
59
- ) ;
60
- if ( is_null($options) ) {
61
- $options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
62
- }
63
-
64
- if ( ! is_null($options) && is_multisite() ) {
65
- $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
66
- if ( ! empty($blogs) ) {
67
- foreach ( $blogs as $blog_id ) {
68
- $opts = get_blog_option($blog_id, LiteSpeed_Cache_Config::OPTION_NAME, array()) ;
69
- if ( isset($opts[LiteSpeed_Cache_Config::OPID_ENABLED_RADIO]) ) {
70
- $options['blog ' . $blog_id . ' radio select'] = $opts[LiteSpeed_Cache_Config::OPID_ENABLED_RADIO] ;
71
- }
72
- }
73
- }
74
- }
75
-
76
- $report = $this->build_environment_report($_SERVER, $options, $extras, $paths) ;
77
- $this->write_environment_report($report) ;
78
- return $report ;
79
- }
80
-
81
- /**
82
- * Write the environment report to the report location.
83
- *
84
- * @since 1.0.12
85
- * @access private
86
- * @param string $content What to write to the environment report.
87
- */
88
- private function write_environment_report( $content )
89
- {
90
- $content = "<" . "?php die() ; ?" . ">\n\n" . $content ;
91
-
92
- $ret = Litespeed_File::save( LSWCP_DIR . 'environment_report.php', $content, false, false, false ) ;
93
-
94
- if ( $ret !== true && LiteSpeed_Cache_Log::get_enabled() ) {
95
- LiteSpeed_Cache_Log::push( $ret ) ;
96
- }
97
- }
98
-
99
- /**
100
- * Builds the environment report buffer with the given parameters
101
- *
102
- * @access private
103
- * @param array $server - server variables
104
- * @param array $options - cms options
105
- * @param array $extras - cms specific attributes
106
- * @param array $htaccess_paths - htaccess paths to check.
107
- * @return string The Environment Report buffer.
108
- */
109
- private function build_environment_report($server, $options, $extras = array(), $htaccess_paths = array())
110
- {
111
- $server_keys = array(
112
- 'DOCUMENT_ROOT'=>'',
113
- 'SERVER_SOFTWARE'=>'',
114
- 'X-LSCACHE'=>'',
115
- 'HTTP_X_LSCACHE'=>''
116
- ) ;
117
- $server_vars = array_intersect_key($server, $server_keys) ;
118
- $server_vars[] = "LSWCP_TAG_PREFIX = " . LSWCP_TAG_PREFIX ;
119
-
120
- $buf = $this->format_report_section('Server Variables', $server_vars) ;
121
-
122
- $buf .= $this->format_report_section('LSCache Plugin Options', $options) ;
123
-
124
- $buf .= $this->format_report_section('Wordpress Specific Extras', $extras) ;
125
-
126
- if ( empty($htaccess_paths) ) {
127
- return $buf ;
128
- }
129
-
130
- foreach ( $htaccess_paths as $path ) {
131
- if ( ! file_exists($path) || ! is_readable($path) ) {
132
- $buf .= $path . " does not exist or is not readable.\n" ;
133
- continue ;
134
- }
135
-
136
- $content = file_get_contents($path) ;
137
- if ( $content === false ) {
138
- $buf .= $path . " returned false for file_get_contents.\n" ;
139
- continue ;
140
- }
141
- $buf .= $path . " contents:\n" . $content . "\n\n" ;
142
- }
143
- return $buf ;
144
- }
145
-
146
- /**
147
- * Creates a part of the environment report based on a section header
148
- * and an array for the section parameters.
149
- *
150
- * @since 1.0.12
151
- * @access private
152
- * @param string $section_header The section heading
153
- * @param array $section An array of information to output
154
- * @return string The created report block.
155
- */
156
- private function format_report_section($section_header, $section)
157
- {
158
- $tab = ' ' ; // four spaces
159
- $nl = "\n" ;
160
-
161
- if ( empty($section) ) {
162
- return 'No matching ' . $section_header . $nl . $nl ;
163
- }
164
- $buf = $section_header ;
165
-
166
- foreach ( $section as $key=>$val ) {
167
- $buf .= $nl . $tab ;
168
- if ( ! is_numeric($key) ) {
169
- $buf .= $key . ' = ' ;
170
- }
171
-
172
- if ( ! is_string($val) ) {
173
- $buf .= var_export($val, true) ;
174
- }
175
- else {
176
- $buf .= $val ;
177
- }
178
- }
179
- return $buf . $nl . $nl ;
180
- }
181
-
182
- /**
183
- * Get the current instance object.
184
- *
185
- * @since 1.1.0
186
- * @access public
187
- * @return Current class instance.
188
- */
189
- public static function get_instance()
190
- {
191
- if ( ! isset(self::$_instance) ) {
192
- self::$_instance = new self() ;
193
- }
194
-
195
- return self::$_instance ;
196
- }
197
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/litespeed-cache-admin-rules.class.php DELETED
@@ -1,854 +0,0 @@
1
- <?php
2
- /**
3
- * The admin-panel specific functionality of the plugin.
4
- *
5
- *
6
- * @since 1.0.0
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/admin
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
- class LiteSpeed_Cache_Admin_Rules
12
- {
13
- private static $_instance ;
14
-
15
- const EDITOR_TEXTAREA_NAME = 'lscwp_ht_editor' ;
16
-
17
- private $frontend_htaccess = null ;
18
- private $backend_htaccess = null ;
19
- private $theme_htaccess = null ;
20
- private $frontend_htaccess_readable = false ;
21
- private $frontend_htaccess_writable = false ;
22
- private $backend_htaccess_readable = false ;
23
- private $backend_htaccess_writable = false ;
24
- private $theme_htaccess_readable = false ;
25
- private $theme_htaccess_writable = false ;
26
-
27
- const RW_LOOKUP_BOTH = "CacheLookup on" ;
28
- const RW_PRIV_BYPASS_POST_PURGE = "RewriteRule .* - [E=Cache-Control:no-autoflush]" ;
29
- const RW_OPTM_NO_VARY = "RewriteRule min/\w+\.(css|js) - [E=cache-control:no-vary]" ;
30
-
31
- const LS_MODULE_START = '<IfModule LiteSpeed>' ;
32
- const LS_MODULE_END = '</IfModule>' ;
33
- const LS_MODULE_REWRITE_START = '<IfModule mod_rewrite.c>' ;
34
- private static $LS_MODULE_REWRITE_ON ;
35
- const LS_MODULE_DONOTEDIT = "## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##" ;
36
- const MARKER = 'LSCACHE' ;
37
- const MARKER_LOGIN_COOKIE = '### marker LOGIN COOKIE' ;
38
- const MARKER_MOBILE = '### marker MOBILE' ;
39
- const MARKER_NOCACHE_COOKIES = '### marker NOCACHE COOKIES' ;
40
- const MARKER_NOCACHE_USER_AGENTS = '### marker NOCACHE USER AGENTS' ;
41
- const MARKER_CACHE_RESOURCE = '### marker CACHE RESOURCE' ;
42
- const MARKER_FAVICON = '### marker FAVICON' ;
43
- const MARKER_BROWSER_CACHE = '### marker BROWSER CACHE' ;
44
- const MARKER_MINIFY = '### marker MINIFY' ;
45
- const MARKER_START = ' start ###' ;
46
- const MARKER_END = ' end ###' ;
47
-
48
- const RW_PATTERN_RES = '/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php' ;
49
-
50
- /**
51
- * Initialize the class and set its properties.
52
- *
53
- * @since 1.0.7
54
- * @access private
55
- */
56
- private function __construct()
57
- {
58
- $this->path_set() ;
59
- clearstatcache() ;
60
-
61
- // frontend .htaccess privilege
62
- $test_permissions = file_exists($this->frontend_htaccess) ? $this->frontend_htaccess : dirname($this->frontend_htaccess) ;
63
- if ( is_readable($test_permissions) ) {
64
- $this->frontend_htaccess_readable = true ;
65
- }
66
- if ( is_writable($test_permissions) ) {
67
- $this->frontend_htaccess_writable = true ;
68
- }
69
-
70
- self::$LS_MODULE_REWRITE_ON = array(
71
- 'RewriteEngine on',
72
- self::RW_LOOKUP_BOTH,
73
- self::RW_PRIV_BYPASS_POST_PURGE,
74
- self::RW_OPTM_NO_VARY,
75
- ) ;
76
-
77
- // backend .htaccess privilege
78
- if ( $this->frontend_htaccess === $this->backend_htaccess ) {
79
- $this->backend_htaccess_readable = $this->frontend_htaccess_readable;
80
- $this->backend_htaccess_writable = $this->frontend_htaccess_writable;
81
- }
82
- else{
83
- $test_permissions = file_exists($this->backend_htaccess) ? $this->backend_htaccess : dirname($this->backend_htaccess);
84
- if ( is_readable($test_permissions) ) {
85
- $this->backend_htaccess_readable = true;
86
- }
87
- if ( is_writable($test_permissions) ) {
88
- $this->backend_htaccess_writable = true;
89
- }
90
- }
91
- }
92
-
93
- /**
94
- * Get if htaccess file is readable
95
- *
96
- * @since 1.1.0
97
- * @return string
98
- */
99
- public static function readable($kind = 'frontend')
100
- {
101
- if( $kind === 'frontend' ) {
102
- return self::get_instance()->frontend_htaccess_readable ;
103
- }
104
- if( $kind === 'backend' ) {
105
- return self::get_instance()->backend_htaccess_readable ;
106
- }
107
- }
108
-
109
- /**
110
- * Get if htaccess file is writable
111
- *
112
- * @since 1.1.0
113
- * @return string
114
- */
115
- public static function writable($kind = 'frontend')
116
- {
117
- if( $kind === 'frontend' ) {
118
- return self::get_instance()->frontend_htaccess_writable ;
119
- }
120
- if( $kind === 'backend' ) {
121
- return self::get_instance()->backend_htaccess_writable ;
122
- }
123
- }
124
-
125
- /**
126
- * Get frontend htaccess path
127
- *
128
- * @since 1.1.0
129
- * @return string
130
- */
131
- public static function get_frontend_htaccess()
132
- {
133
- return self::get_instance()->frontend_htaccess ;
134
- }
135
-
136
- /**
137
- * Get backend htaccess path
138
- *
139
- * @since 1.1.0
140
- * @return string
141
- */
142
- public static function get_backend_htaccess()
143
- {
144
- return self::get_instance()->backend_htaccess ;
145
- }
146
-
147
- /**
148
- * Check to see if .htaccess exists starting at $start_path and going up directories until it hits DOCUMENT_ROOT.
149
- *
150
- * As dirname() strips the ending '/', paths passed in must exclude the final '/'
151
- *
152
- * If can't find, return false
153
- *
154
- * @since 1.0.11
155
- * @access private
156
- * @param string $start_path The first directory level to search.
157
- * @return string The deepest path where .htaccess exists, False if not.
158
- */
159
- private function htaccess_search( $start_path )
160
- {
161
- while ( ! file_exists( $start_path . '/.htaccess' ) ) {
162
- if ( $start_path === '/' || ! $start_path ) {
163
- return false ;
164
- }
165
- if ( ! empty( $_SERVER[ 'DOCUMENT_ROOT' ] ) && $start_path === $_SERVER[ 'DOCUMENT_ROOT' ] ) {
166
- return false ;
167
- }
168
- $start_path = dirname( $start_path ) ;
169
- }
170
-
171
- return $start_path ;
172
- }
173
-
174
- /**
175
- * Set the path class variables.
176
- *
177
- * @since 1.0.11
178
- * @access private
179
- */
180
- private function path_set()
181
- {
182
- $this->theme_htaccess = LSWCP_CONTENT_DIR ;
183
-
184
- $frontend = LiteSpeed_Cache_Router::frontend_path() ;
185
- $frontend_htaccess_search = $this->htaccess_search( $frontend ) ;// The existing .htaccess path to be used for frontend .htaccess
186
- $this->frontend_htaccess = ( $frontend_htaccess_search ?: $frontend ) . '/.htaccess' ;
187
-
188
- $backend = realpath( ABSPATH ) ; // /home/user/public_html/backend/
189
- if ( $frontend == $backend ) {
190
- $this->backend_htaccess = $this->frontend_htaccess ;
191
- return ;
192
- }
193
-
194
- // Backend is a different path
195
- $backend_htaccess_search = $this->htaccess_search( $backend ) ;
196
- // Found affected .htaccess
197
- if ( $backend_htaccess_search ) {
198
- $this->backend_htaccess = $backend_htaccess_search . '/.htaccess' ;
199
- return ;
200
- }
201
-
202
- // Frontend path is the parent of backend path
203
- if ( stripos( $backend, $frontend . '/' ) === 0 ) {
204
- // backend use frontend htaccess
205
- $this->backend_htaccess = $this->frontend_htaccess ;
206
- return ;
207
- }
208
-
209
- $this->backend_htaccess = $backend . '/.htaccess' ;
210
- }
211
-
212
- /**
213
- * Get corresponding htaccess path
214
- *
215
- * @since 1.1.0
216
- * @param string $kind Frontend or backend
217
- * @return string Path
218
- */
219
- public function htaccess_path($kind = 'frontend')
220
- {
221
- switch ( $kind ) {
222
- case 'frontend':
223
- $path = $this->frontend_htaccess ;
224
- break ;
225
-
226
- case 'backend':
227
- $path = $this->backend_htaccess ;
228
- break ;
229
-
230
- default:
231
- $path = $this->frontend_htaccess ;
232
- break ;
233
- }
234
- return $path ;
235
- }
236
-
237
- /**
238
- * Get the content of the rules file.
239
- * If can't read, will add error msg to dashboard
240
- * Only when need to add error msg, this function is used, otherwise use file_get_contents directly
241
- *
242
- * @since 1.0.4
243
- * @access public
244
- * @param string $path The path to get the content from.
245
- * @return boolean True if succeeded, false otherwise.
246
- */
247
- public function htaccess_read($kind = 'frontend')
248
- {
249
- $path = $this->htaccess_path($kind) ;
250
-
251
- if( ! $path || ! file_exists($path) ) {
252
- return "\n" ;
253
- }
254
- if ( ! self::readable($kind) || ! self::writable($kind) ) {
255
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_RW) ;
256
- return false ;
257
- }
258
-
259
- $content = file_get_contents($path) ;
260
- if ( $content === false ) {
261
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_GET) ;
262
- return false ;
263
- }
264
-
265
- // Remove ^M characters.
266
- $content = str_ireplace("\x0D", "", $content) ;
267
- return $content ;
268
- }
269
-
270
- /**
271
- * Try to save the rules file changes.
272
- *
273
- * This function is used by both the edit .htaccess admin page and
274
- * the common rewrite rule configuration options.
275
- *
276
- * This function will create a backup with _lscachebak appended to the file name
277
- * prior to making any changese. If creating the backup fails, an error is returned.
278
- *
279
- * @since 1.0.4
280
- * @since 1.0.12 - Introduce $backup parameter and make function public
281
- * @access public
282
- * @param string $content The new content to put into the rules file.
283
- * @param string $kind The htaccess to edit. Default is frontend htaccess file.
284
- * @param boolean $backup Whether to create backups or not.
285
- * @return boolean true on success, else false.
286
- */
287
- public function htaccess_save($content, $kind = 'frontend', $backup = true)
288
- {
289
- $path = $this->htaccess_path($kind) ;
290
-
291
- if ( ! self::readable($kind) ) {
292
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_R) ;
293
- return false ;
294
- }
295
-
296
- if ( ! self::writable($kind) ) {
297
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_W) ;
298
- return false ;
299
- }
300
-
301
- //failed to backup, not good.
302
- if ( $backup && $this->htaccess_backup($kind) === false ) {
303
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_BU) ;
304
- return false ;
305
- }
306
-
307
- // File put contents will truncate by default. Will create file if doesn't exist.
308
- $ret = file_put_contents($path, $content, LOCK_EX) ;
309
- if ( $ret === false ) {
310
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_SAVE) ;
311
- return false ;
312
- }
313
-
314
- return true ;
315
- }
316
-
317
- /**
318
- * Try to backup the .htaccess file.
319
- * This function will attempt to create a .htaccess_lscachebak_orig first.
320
- * If that is already created, it will attempt to create .htaccess_lscachebak_[1-10]
321
- * If 10 are already created, zip the current set of backups (sans _orig).
322
- * If a zip already exists, overwrite it.
323
- *
324
- * @since 1.0.10
325
- * @access private
326
- * @param string $kind The htaccess to edit. Default is frontend htaccess file.
327
- * @return boolean True on success, else false on failure.
328
- */
329
- private function htaccess_backup($kind = 'frontend')
330
- {
331
- $path = $this->htaccess_path($kind) ;
332
- $bak = '_lscachebak_orig' ;
333
- $i = 1 ;
334
-
335
- if ( ! file_exists($path) ) {
336
- return true ;
337
- }
338
-
339
- if ( file_exists($path . $bak) ) {
340
- $bak = sprintf("_lscachebak_%02d", $i) ;
341
- while (file_exists($path . $bak)) {
342
- $i++ ;
343
- $bak = sprintf("_lscachebak_%02d", $i) ;
344
- }
345
- }
346
-
347
- if ( $i <= 10 || ! class_exists('ZipArchive') ) {
348
- $ret = copy($path, $path . $bak) ;
349
- return $ret ;
350
- }
351
-
352
- $zip = new ZipArchive ;
353
- $dir = dirname($path) ;
354
- $arr = scandir($dir) ;
355
- $parsed = preg_grep('/\.htaccess_lscachebak_[0-9]+/', $arr) ;
356
-
357
- if ( empty($parsed) ) {
358
- return false ;
359
- }
360
-
361
- $res = $zip->open($dir . '/.lscache_htaccess_bak.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE) ;
362
- if ( $res !== true ) {
363
- error_log('Warning: Failed to archive wordpress backups in ' . $dir) ;
364
- $ret = copy($path, $path . $bak) ;
365
- return $ret ;
366
- }
367
-
368
- foreach ($parsed as $key => $val) {
369
- $parsed[$key] = $dir . '/' . $val ;
370
- if ( ! $zip->addFile($parsed[$key], $val) ) {
371
- error_log('Warning: Failed to archive backup file ' . $val) ;
372
- $zip->close() ;
373
- $ret = copy($path, $path . $bak) ;
374
- return $ret ;
375
- }
376
- }
377
-
378
- $ret = $zip->close() ;
379
- if ( ! $ret ) {
380
- error_log('Warning: Failed to close archive.') ;
381
- return $ret ;
382
- }
383
- $bak = '_lscachebak_01' ;
384
-
385
- foreach ($parsed as $delFile) {
386
- unlink($delFile) ;
387
- }
388
-
389
- $ret = copy($path, $path . $bak) ;
390
- return $ret ;
391
- }
392
-
393
- /**
394
- * Get mobile view rule from htaccess file
395
- *
396
- * @since 1.1.0
397
- * @return string Mobile Agents value
398
- */
399
- public function get_rewrite_rule_mobile_agents()
400
- {
401
- $rules = $this->_get_rule_by(self::MARKER_MOBILE) ;
402
- if( ! isset($rules[0]) ) {
403
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_DNF, self::MARKER_MOBILE) ;
404
- return false ;
405
- }
406
- $rule = trim($rules[0]) ;
407
- $pattern = '/RewriteCond\s%{HTTP_USER_AGENT}\s+([^[\n]*)\s+[[]*/' ;
408
- $matches = array() ;
409
- $num_matches = preg_match($pattern, $rule, $matches) ;
410
- if ( $num_matches === false ) {
411
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_DNF, 'a match') ;
412
- return false ;
413
- }
414
- $match = trim($matches[1]) ;
415
- return $match ;
416
- }
417
-
418
- /**
419
- * Parse rewrites rule from the .htaccess file.
420
- *
421
- * @since 1.1.0
422
- * @access public
423
- * @param string $kind The kind of htaccess to search in
424
- * @return array
425
- */
426
- public function get_rewrite_rule_login_cookie($kind = 'frontend')
427
- {
428
- $rule = $this->_get_rule_by(self::MARKER_LOGIN_COOKIE, $kind) ;
429
- if( substr($rule, 0, strlen('RewriteRule .? - [E=')) !== 'RewriteRule .? - [E=' ) {//todo: use regex
430
- return false ;
431
- }
432
-
433
- return substr($rule, strlen('RewriteRule .? - [E='), -1) ;//todo:user trim('"')
434
- }
435
-
436
- /**
437
- * Get rewrite rules based on tags
438
- * @param string $cond The tag to be used
439
- * @param string $kind Frontend or backend .htaccess file
440
- * @return mixed Rules
441
- */
442
- private function _get_rule_by($cond, $kind = 'frontend')
443
- {
444
- clearstatcache() ;
445
- $path = $this->htaccess_path($kind) ;
446
- if ( ! self::readable($kind) ) {
447
- return false ;
448
- }
449
-
450
- $rules = Litespeed_File::extract_from_markers($path, self::MARKER) ;
451
- if( ! in_array($cond . self::MARKER_START, $rules) || ! in_array($cond . self::MARKER_END, $rules) ) {
452
- return false ;
453
- }
454
-
455
- $key_start = array_search($cond . self::MARKER_START, $rules) ;
456
- $key_end = array_search($cond . self::MARKER_END, $rules) ;
457
- if( $key_start === false || $key_end === false ) {
458
- return false ;
459
- }
460
-
461
- $results = array_slice($rules, $key_start+1, $key_end-$key_start-1) ;
462
- if( ! $results ) {
463
- return false ;
464
- }
465
- if( count($results) == 1 ) {
466
- return trim($results[0]) ;
467
- }
468
- return array_filter($results) ;
469
- }
470
-
471
- /**
472
- * Generate browser cache rules
473
- *
474
- * @since 1.3
475
- * @access private
476
- * @return array Rules set
477
- */
478
- private function _browser_cache_rules()
479
- {
480
- $rules = array(
481
- '<FilesMatch "\.(pdf|ico|svg|xml|jpg|jpeg|png|gif|webp|ogg|mp4|webm|js|css|woff|woff2|ttf|eot)(\.gz)?$">',
482
- '<IfModule mod_expires.c>',
483
- 'ExpiresActive on',
484
- 'ExpiresByType application/pdf A2592000',
485
- 'ExpiresByType image/x-icon A2592000',
486
- 'ExpiresByType image/vnd.microsoft.icon A2592000',
487
- 'ExpiresByType image/svg+xml A2592000',
488
- '',
489
- 'ExpiresByType image/jpg A2592000',
490
- 'ExpiresByType image/jpeg A2592000',
491
- 'ExpiresByType image/png A2592000',
492
- 'ExpiresByType image/gif A2592000',
493
- 'ExpiresByType image/webp A2592000',
494
- '',
495
- 'ExpiresByType video/ogg A2592000',
496
- 'ExpiresByType audio/ogg A2592000',
497
- 'ExpiresByType video/mp4 A2592000',
498
- 'ExpiresByType video/webm A2592000',
499
- '',
500
- 'ExpiresByType text/css A2592000',
501
- 'ExpiresByType text/javascript A2592000',
502
- 'ExpiresByType application/javascript A2592000',
503
- 'ExpiresByType application/x-javascript A2592000',
504
- '',
505
- 'ExpiresByType application/x-font-ttf A2592000',
506
- 'ExpiresByType application/font-woff A2592000',
507
- 'ExpiresByType application/font-woff2 A2592000',
508
- 'ExpiresByType application/vnd.ms-fontobject A2592000',
509
- '',
510
- '</IfModule>',
511
- '</FilesMatch>',
512
- ) ;
513
- return $rules ;
514
- }
515
-
516
- /**
517
- * Generate rewrite rules based on settings
518
- *
519
- * @since 1.3
520
- * @access private
521
- * @param array $cfg The settings to be used for rewrite rule
522
- * @return array Rules array
523
- */
524
- private function _generate_rules( $cfg )
525
- {
526
- $new_rules = array() ;
527
- $new_rules_backend = array() ;
528
-
529
- // mobile agents
530
- $id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
531
- if ( ! empty( $cfg[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) && ! empty( $cfg[ $id ] ) ) {
532
- $new_rules[] = self::MARKER_MOBILE . self::MARKER_START ;
533
- $new_rules[] = 'RewriteCond %{HTTP_USER_AGENT} ' . $cfg[ $id ] . ' [NC]' ;
534
- $new_rules[] = 'RewriteRule .* - [E=Cache-Control:vary=ismobile]' ;
535
- $new_rules[] = self::MARKER_MOBILE . self::MARKER_END ;
536
- $new_rules[] = '' ;
537
- }
538
-
539
- // nocache cookie
540
- $id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES ;
541
- if ( ! empty( $cfg[ $id ] ) ) {
542
- $new_rules[] = self::MARKER_NOCACHE_COOKIES . self::MARKER_START ;
543
- $new_rules[] = 'RewriteCond %{HTTP_COOKIE} ' . $cfg[ $id ] ;
544
- $new_rules[] = 'RewriteRule .* - [E=Cache-Control:no-cache]' ;
545
- $new_rules[] = self::MARKER_NOCACHE_COOKIES . self::MARKER_END ;
546
- $new_rules[] = '' ;
547
- }
548
-
549
- // nocache user agents
550
- $id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS ;
551
- if ( ! empty( $cfg[ $id ] ) ) {
552
- $new_rules[] = self::MARKER_NOCACHE_USER_AGENTS . self::MARKER_START ;
553
- $new_rules[] = 'RewriteCond %{HTTP_USER_AGENT} ' . $cfg[ $id ] ;
554
- $new_rules[] = 'RewriteRule .* - [E=Cache-Control:no-cache]' ;
555
- $new_rules[] = self::MARKER_NOCACHE_USER_AGENTS . self::MARKER_END ;
556
- $new_rules[] = '' ;
557
- }
558
-
559
- // caching php resource
560
- $id = LiteSpeed_Cache_Config::OPID_CACHE_RES ;
561
- if ( ! empty( $cfg[ $id ] ) ) {
562
- $new_rules[] = $new_rules_backend[] = self::MARKER_CACHE_RESOURCE . self::MARKER_START ;
563
- $new_rules[] = $new_rules_backend[] = 'RewriteRule ' . LSWCP_CONTENT_FOLDER . self::RW_PATTERN_RES . ' - [E=cache-control:max-age=3600]' ;
564
- $new_rules[] = $new_rules_backend[] = self::MARKER_CACHE_RESOURCE . self::MARKER_END ;
565
- $new_rules[] = $new_rules_backend[] = '' ;
566
- }
567
-
568
- // check login cookie
569
- $id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ;
570
- if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
571
- if ( ! empty( $cfg[ $id ] ) ) {
572
- $cfg[ $id ] .= ',wp-postpass_' . COOKIEHASH ;
573
- }
574
- else {
575
- $cfg[ $id ] = 'wp-postpass_' . COOKIEHASH ;
576
- }
577
-
578
- $tp_cookies = apply_filters( 'litespeed_cache_api_vary', array() ) ;
579
- if ( ! empty( $tp_cookies ) && is_array( $tp_cookies ) ) {
580
- $cfg[ $id ] .= ',' . implode( ',', $tp_cookies ) ;
581
- }
582
- }
583
- // frontend and backend
584
- if ( ! empty( $cfg[ $id ] ) ) {
585
- $env = 'Cache-Vary:' . $cfg[ $id ] ;
586
- if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
587
- $env = '"' . $env . '"' ;
588
- }
589
- $new_rules[] = $new_rules_backend[] = self::MARKER_LOGIN_COOKIE . self::MARKER_START ;
590
- $new_rules[] = $new_rules_backend[] = 'RewriteRule .? - [E=' . $env . ']' ;
591
- $new_rules[] = $new_rules_backend[] = self::MARKER_LOGIN_COOKIE . self::MARKER_END ;
592
- $new_rules[] = '' ;
593
- }
594
-
595
- // favicon
596
- // frontend and backend
597
- $id = LiteSpeed_Cache_Config::OPID_CACHE_FAVICON ;
598
- if ( ! empty( $cfg[ $id ] ) ) {
599
- $new_rules[] = $new_rules_backend[] = self::MARKER_FAVICON . self::MARKER_START ;
600
- $new_rules[] = $new_rules_backend[] = 'RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]' ;
601
- $new_rules[] = $new_rules_backend[] = self::MARKER_FAVICON . self::MARKER_END ;
602
- $new_rules[] = '' ;
603
- }
604
-
605
- // Browser cache
606
- $id = LiteSpeed_Cache_Config::OPID_CACHE_BROWSER ;
607
- if ( ! empty( $cfg[ $id ] ) ) {
608
- $new_rules[] = $new_rules_backend[] = self::MARKER_BROWSER_CACHE . self::MARKER_START ;
609
- $new_rules = array_merge( $new_rules, $this->_browser_cache_rules() ) ;
610
- $new_rules_backend = array_merge( $new_rules_backend, $this->_browser_cache_rules() ) ;
611
- $new_rules[] = $new_rules_backend[] = self::MARKER_BROWSER_CACHE . self::MARKER_END ;
612
- $new_rules[] = '' ;
613
- }
614
-
615
- return array( $new_rules, $new_rules_backend ) ;
616
-
617
- }
618
-
619
- /**
620
- * Output the msg with rules plain data for manual insert
621
- *
622
- * @since 1.1.5
623
- * @param string $file
624
- * @param array $rules
625
- * @return string final msg to output
626
- */
627
- private function rewrite_codes_msg( $file, $rules )
628
- {
629
- return sprintf( __( '<p>Please add/replace the following codes into the beginning of %1$s:</p> %2$s' , 'litespeed-cache' ),
630
- $file,
631
- '<textarea style="width:100%;" rows="10" readonly>' . htmlspecialchars( $this->_wrap_rules_with_marker( $rules ) ) . '</textarea>'
632
- ) ;
633
- }
634
-
635
- /**
636
- * Generate rules plain data for manual insert
637
- *
638
- * @since 1.1.5
639
- * @param array $rules
640
- * @return array final rules data for htaccess
641
- */
642
- private function _wrap_rules_with_marker( $rules )
643
- {
644
- $marker = self::MARKER ;
645
- $start_marker = "# BEGIN {$marker}" ;
646
- $end_marker = "# END {$marker}" ;
647
- $new_file_data = implode( "\n", array_merge(
648
- array( $start_marker ),
649
- $this->_wrap_rules($rules),
650
- array( $end_marker )
651
- ) ) ;
652
-
653
- return $new_file_data ;
654
- }
655
-
656
- /**
657
- * wrap rules with module on info
658
- *
659
- * @since 1.1.5
660
- * @param array $rules
661
- * @return array wrapped rules with module info
662
- */
663
- private function _wrap_rules( $rules )
664
- {
665
- if ( $rules !== false ) {
666
- $rules = array_merge(
667
- array(self::LS_MODULE_DONOTEDIT),
668
- array(self::LS_MODULE_START),
669
- self::$LS_MODULE_REWRITE_ON,
670
- array(''),
671
- $rules,
672
- array(self::LS_MODULE_END),
673
- array(self::LS_MODULE_DONOTEDIT)
674
- ) ;
675
- }
676
- return $rules ;
677
- }
678
-
679
- /**
680
- * Write to htaccess with rules
681
- *
682
- * @since 1.1.0
683
- * @param array $rules
684
- * @param string $kind which htaccess
685
- */
686
- public function insert_wrapper( $rules = array(), $kind = 'frontend' )
687
- {
688
- $res = $this->htaccess_backup( $kind ) ;
689
- if ( ! $res ) {
690
- return false ;
691
- }
692
-
693
- return Litespeed_File::insert_with_markers( $this->htaccess_path($kind), $this->_wrap_rules( $rules ), self::MARKER, true ) ;
694
- }
695
-
696
- /**
697
- * Update rewrite rules based on setting
698
- *
699
- * @since 1.3
700
- * @access public
701
- * @param array $cfg The rules that need to be set.
702
- */
703
- public function update( $cfg )
704
- {
705
- if ( ! LiteSpeed_Cache_Admin_Rules::readable() ) {
706
- return LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_R ) ;
707
- }
708
-
709
- if ( $this->frontend_htaccess !== $this->backend_htaccess ) {
710
- if ( ! LiteSpeed_Cache_Admin_Rules::readable( 'backend' ) ) {
711
- return LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_R ) ;
712
- }
713
- }
714
-
715
- list( $frontend_rules, $backend_rules ) = $this->_generate_rules( $cfg ) ;
716
- // Check frontend content
717
- if ( $this->_wrap_rules( $frontend_rules ) != $this->extract_rules() ) {
718
- // Need to update frontend htaccess
719
- if ( ! $this->insert_wrapper( $frontend_rules ) ) {
720
- $manual_guide_codes = $this->rewrite_codes_msg( $this->frontend_htaccess, $frontend_rules ) ;
721
- return array( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_W ), $manual_guide_codes ) ;
722
- }
723
- }
724
-
725
- if ( $this->frontend_htaccess !== $this->backend_htaccess ) {
726
- // Check backend content
727
- if ( $this->_wrap_rules( $backend_rules ) != $this->extract_rules( 'backend' ) ) {
728
- // Need to update backend htaccess
729
- if ( ! $this->insert_wrapper( $backend_rules, 'backend' ) ) {
730
- $manual_guide_codes = $this->rewrite_codes_msg( $this->backend_htaccess, $backend_rules ) ;
731
- return array( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_W ), $manual_guide_codes ) ;
732
- }
733
- }
734
- }
735
-
736
- return true ;
737
- }
738
-
739
- /**
740
- * Get existing rewrite rules
741
- *
742
- * @since 1.3
743
- * @access public
744
- * @param string $kind Frontend or backend .htaccess file
745
- * @return bool|array False if failed to read, rules array otherwise
746
- */
747
- public function extract_rules( $kind = 'frontend' )
748
- {
749
- clearstatcache() ;
750
- $path = $this->htaccess_path( $kind ) ;
751
- if ( ! self::readable( $kind ) ) {
752
- return false ;
753
- }
754
-
755
- $rules = Litespeed_File::extract_from_markers( $path, self::MARKER ) ;
756
-
757
- return $rules ;
758
- }
759
-
760
- /**
761
- * Clear the rules file of any changes added by the plugin specifically.
762
- *
763
- * @since 1.0.4
764
- * @access public
765
- */
766
- public function clear_rules( $clear_all = false )
767
- {
768
- $keep_wrapper = $clear_all === true ? false : array() ;
769
- $this->insert_wrapper( $keep_wrapper ) ;
770
- if ( $this->frontend_htaccess !== $this->backend_htaccess ) {
771
- $this->insert_wrapper( $keep_wrapper, 'backend' ) ;
772
- }
773
- }
774
-
775
- /**
776
- * Only used to clear old rules when upgrade to v1.1.0
777
- */
778
- public function deprecated_clear_rules()
779
- {
780
- $RW_WRAPPER = 'PLUGIN - Do not edit the contents of this block!' ;
781
- $pattern = '/###LSCACHE START ' . $RW_WRAPPER . '###.*###LSCACHE END ' . $RW_WRAPPER . '###\n?/s' ;
782
- clearstatcache() ;
783
- if ( ! file_exists($this->frontend_htaccess) || ! self::writable() ) {
784
- return ;
785
- }
786
- $content = file_get_contents($this->frontend_htaccess) ;
787
- if( ! $content ) {
788
- return ;
789
- }
790
-
791
- $buf = preg_replace($pattern, '', $content) ;
792
- $buf = preg_replace("|<IfModule LiteSpeed>\s*</IfModule>|isU", '', $buf) ;
793
-
794
- $this->htaccess_save($buf) ;
795
-
796
- // clear backend htaccess
797
- if ( $this->frontend_htaccess === $this->backend_htaccess ) {
798
- return ;
799
- }
800
-
801
- if ( ! file_exists($this->backend_htaccess) || ! self::writable('backend') ) {
802
- return ;
803
- }
804
- $content = file_get_contents($this->backend_htaccess) ;
805
- if( ! $content ) {
806
- return ;
807
- }
808
-
809
- $buf = preg_replace($pattern, '', $content) ;
810
- $buf = preg_replace("|<IfModule LiteSpeed>\n*</IfModule>|isU", '', $buf) ;
811
- $this->htaccess_save($buf, 'backend') ;
812
- }
813
-
814
- /**
815
- * Parses the .htaccess buffer when the admin saves changes in the edit .htaccess page.
816
- * Only admin can do this
817
- *
818
- * @since 1.0.4
819
- * @access public
820
- */
821
- public function htaccess_editor_save()
822
- {
823
- if ( isset($_POST[self::EDITOR_TEXTAREA_NAME]) ) {
824
- $content = LiteSpeed_Cache_Admin::cleanup_text($_POST[self::EDITOR_TEXTAREA_NAME]) ;
825
- $msg = $this->htaccess_save($content) ;
826
- if ( $msg === true ) {
827
- $msg = __('File Saved.', 'litespeed-cache') ;
828
- $color = LiteSpeed_Cache_Admin_Display::NOTICE_GREEN ;
829
- }
830
- else {
831
- $color = LiteSpeed_Cache_Admin_Display::NOTICE_RED ;
832
- }
833
- LiteSpeed_Cache_Admin_Display::add_notice($color, $msg) ;
834
- }
835
-
836
- }
837
-
838
- /**
839
- * Get the current instance object.
840
- *
841
- * @since 1.1.0
842
- * @access public
843
- * @return Current class instance.
844
- */
845
- public static function get_instance()
846
- {
847
- if ( ! isset( self::$_instance ) ) {
848
- self::$_instance = new self() ;
849
- }
850
-
851
- return self::$_instance ;
852
- }
853
- }
854
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/litespeed-cache-admin-settings.class.php DELETED
@@ -1,975 +0,0 @@
1
- <?php
2
- /**
3
- * The admin settings handler of the plugin.
4
- *
5
- *
6
- * @since 1.1.0
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/admin
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
- class LiteSpeed_Cache_Admin_Settings
12
- {
13
- private static $_instance ;
14
-
15
- private $_input ;
16
- private $_options ;
17
- private $_err ;
18
-
19
- private $_err_msg_numeric ;
20
-
21
- private $_max_int = 2147483647 ;
22
-
23
- /**
24
- * Init
25
- *
26
- * @since 1.3
27
- * @access private
28
- */
29
- private function __construct()
30
- {
31
- $this->_err_msg_numeric = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_NUMERIC ) ;
32
- }
33
-
34
- /**
35
- * Callback function that will validate any changes made in the settings page.
36
- *
37
- * NOTE: Anytime that validate_plugin_settings is called, `convert_options_to_input` must be done first if not from option page
38
- *
39
- * @since 1.0.0
40
- * @access public
41
- * @param array $input The configuration selected by the admin when clicking save.
42
- * @return array The updated configuration options.
43
- */
44
- public function validate_plugin_settings( $input )
45
- {
46
- LiteSpeed_Cache_Log::debug( 'Settings: validate_plugin_settings called' ) ;
47
- $this->_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
48
-
49
- if ( LiteSpeed_Cache_Admin_Display::get_instance()->get_disable_all() ) {
50
- add_settings_error( LiteSpeed_Cache_Config::OPTION_NAME, LiteSpeed_Cache_Config::OPTION_NAME, __( '\'Use primary site settings\' set by Network Administrator.', 'litespeed-cache' ) ) ;
51
-
52
- return $this->_options ;
53
- }
54
-
55
- $this->_input = $input ;
56
-
57
- $this->_validate_general() ;
58
-
59
- $this->_validate_cache() ;
60
-
61
- $this->_validate_purge() ;
62
-
63
- $this->_validate_exclude() ;
64
-
65
- $this->_validate_optimize() ;
66
-
67
- $this->_validate_cdn() ;
68
-
69
- $this->_validate_debug() ;
70
-
71
- $this->_validate_crawler() ; // Network setup doesn't run validate_plugin_settings
72
-
73
- if ( ! is_multisite() ) {
74
- $this->_validate_singlesite() ;
75
- }
76
-
77
- if ( LSWCP_ESI_SUPPORT ) {
78
- $orig_esi_enabled = $this->_options[ LiteSpeed_Cache_Config::OPID_ESI_ENABLE ] ;
79
-
80
- $this->_validate_esi() ;
81
-
82
- $new_esi_enabled = $this->_options[ LiteSpeed_Cache_Config::OPID_ESI_ENABLE ] ;
83
-
84
- if ( $orig_esi_enabled !== $new_esi_enabled ) {
85
- LiteSpeed_Cache_Purge::purge_all() ;
86
- }
87
- }
88
-
89
- if ( ! empty( $this->_err ) ) {
90
- add_settings_error( LiteSpeed_Cache_Config::OPTION_NAME, LiteSpeed_Cache_Config::OPTION_NAME, implode( '<br />', $this->_err ) ) ;
91
-
92
- return $this->_options ;
93
- }
94
-
95
- $cron_changed = false ;
96
- if ( defined( 'LITESPEED_CLI' ) ) {
97
- $id = LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ;
98
- $cron_val = $this->_options[ $id ] ;
99
- // assign crawler_cron_active to $this->_options if exists in $this->_input separately for CLI
100
- // This has to be specified cos crawler cron activation is not set in admin setting page
101
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
102
- if ( $cron_val != $this->_options[ $id ] ) {
103
- $cron_changed = true ;
104
- }
105
- }
106
-
107
- // check if need to enable crawler cron
108
- if ( defined( 'LITESPEED_ON_CHANGED' ) || $cron_changed ) {
109
- LiteSpeed_Cache_Task::update( $this->_options ) ;
110
- }
111
-
112
- $this->_validate_thirdparty( ) ;
113
-
114
- return $this->_options ;
115
- }
116
-
117
- /**
118
- * Validates the single site specific settings.
119
- *
120
- * @since 1.0.12
121
- * @access private
122
- */
123
- private function _validate_singlesite()
124
- {
125
- $id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
126
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
127
-
128
- // Parse rewrite rule settings
129
- $new_options = $this->_validate_rewrite_settings() ;
130
- $this->_options = array_merge( $this->_options, $new_options ) ;
131
-
132
- // Try to update rewrite rules
133
- if ( ! defined( 'LITESPEED_NEW_OFF' ) ) {
134
- // Only update needs to get error, for clear rules, can ignore for now
135
- $res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $this->_options ) ;
136
- if ( $res !== true ) {
137
- if ( ! is_array( $res ) ) {
138
- $this->_err[] = $res ;
139
- }
140
- else {
141
- $this->_err = array_merge( $this->_err, $res ) ;
142
- }
143
- }
144
- }
145
- else {
146
- LiteSpeed_Cache_Admin_Rules::get_instance()->clear_rules() ;
147
- }
148
- }
149
-
150
- /**
151
- * Parses any changes made by the network admin on the network settings.
152
- *
153
- * @since 1.0.4
154
- * @access public
155
- */
156
- public function validate_network_settings()
157
- {
158
- $input = array_map( 'LiteSpeed_Cache_Admin::cleanup_text', $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ;
159
- $this->_input = $input ;
160
-
161
- $options = LiteSpeed_Cache_Config::get_instance()->get_site_options() ;
162
-
163
- $id = LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ;
164
- $network_enabled = self::parse_onoff( $this->_input, $id ) ;
165
- if ( $options[ $id ] != $network_enabled ) {
166
- $options[ $id ] = $network_enabled ;
167
- if ( $network_enabled ) {
168
- $ret = LiteSpeed_Cache_Config::wp_cache_var_setter( true ) ;
169
- if ( $ret !== true ) {
170
- $this->_err[] = $ret ;
171
- }
172
- }
173
- else {
174
- LiteSpeed_Cache_Purge::purge_all() ;
175
- }
176
- }
177
-
178
- $id = LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY ;
179
- $orig_primary = $options[ $id ] ;
180
- $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
181
- if ( $orig_primary != $options[ $id ] ) {
182
- LiteSpeed_Cache_Purge::purge_all() ;
183
- }
184
-
185
- $id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ;
186
- $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
187
-
188
- $id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
189
- $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
190
-
191
- // Parse rewrite settings from input
192
- $new_options = $this->_validate_rewrite_settings() ;
193
- $options = array_merge( $options, $new_options ) ;
194
-
195
- // Update htaccess
196
- if ( $network_enabled ) {
197
- $res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $options ) ;
198
- if ( $res !== true ) {
199
- if ( ! is_array( $res ) ) {
200
- $this->_err[] = $res ;
201
- }
202
- else {
203
- $this->_err = array_merge( $this->_err, $res ) ;
204
- }
205
- }
206
- }
207
- else {
208
- // Need to set cachePublicOn in case subblogs turn on cache manually
209
- LiteSpeed_Cache_Admin_Rules::get_instance()->insert_wrapper() ;
210
- }
211
-
212
- if ( ! empty( $this->_err ) ) {
213
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_RED, $this->_err ) ;
214
- return ;
215
- }
216
-
217
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, __( 'Site options saved.', 'litespeed-cache' ) ) ;
218
- update_site_option( LiteSpeed_Cache_Config::OPTION_NAME, $options ) ;
219
- return $options ;
220
- }
221
-
222
- /**
223
- * Validates the general settings.
224
- *
225
- * @since 1.0.12
226
- * @access private
227
- */
228
- private function _validate_general()
229
- {
230
- // Cache enabled setting
231
- $id = LiteSpeed_Cache_Config::OPID_ENABLED_RADIO ;
232
- $this->_options[ $id ] = self::is_checked_radio( $this->_input[ $id ] ) ;
233
-
234
- $enabled = $this->_options[ $id ] ;
235
- // Use network setting
236
- if( $enabled === LiteSpeed_Cache_Config::VAL_ON2 ) {
237
- $enabled = is_multisite() ? defined( 'LITESPEED_NETWORK_ON' ) : true ; // Default to true
238
- }
239
-
240
- // Purge when disabled
241
- if ( ! $enabled ) {
242
- LiteSpeed_Cache_Purge::purge_all() ;
243
- ! defined( 'LITESPEED_NEW_OFF' ) && define( 'LITESPEED_NEW_OFF', true ) ; // Latest status is off
244
- }
245
- else {
246
- ! defined( 'LITESPEED_NEW_ON' ) && define( 'LITESPEED_NEW_ON', true ) ; // Latest status is on
247
- }
248
-
249
- // Status changed
250
- if ( defined( 'LITESPEED_ON' ) xor $enabled ) {
251
- define( 'LITESPEED_ON_CHANGED', true ) ;
252
- }
253
-
254
- // TTL check
255
- $ids = array(
256
- LiteSpeed_Cache_Config::OPID_PUBLIC_TTL => array( __( 'Default Public Cache', 'litespeed-cache' ), 30, $this->_max_int ),
257
- LiteSpeed_Cache_Config::OPID_PRIVATE_TTL => array( __( 'Default Private Cache', 'litespeed-cache' ), 60, 3600 ),
258
- LiteSpeed_Cache_Config::OPID_FRONT_PAGE_TTL => array( __( 'Default Front Page', 'litespeed-cache' ), 30, $this->_max_int ),
259
- LiteSpeed_Cache_Config::OPID_FEED_TTL => array( __( 'Feed', 'litespeed-cache' ), 0, $this->_max_int, 30 ),
260
- LiteSpeed_Cache_Config::OPID_404_TTL => array( __( '404', 'litespeed-cache' ), 0, $this->_max_int, 30 ),
261
- LiteSpeed_Cache_Config::OPID_403_TTL => array( __( '403', 'litespeed-cache' ), 0, $this->_max_int, 30 ),
262
- LiteSpeed_Cache_Config::OPID_500_TTL => array( __( '500', 'litespeed-cache' ), 0, $this->_max_int, 30 ),
263
- ) ;
264
- foreach ( $ids as $id => $v ) {
265
- list( $desc, $min, $max ) = $v ;
266
- if ( ! $this->_check_ttl( $this->_input, $id, $min, $max ) ) {
267
- $this->_err[] = sprintf( $this->_err_msg_numeric, $desc, $min, $max ) ;
268
- }
269
- else {
270
- if ( ! empty( $v[ 3 ] ) && $this->_input[ $id ] < $v[ 3 ] ) {
271
- $this->_options[ $id ] = 0 ;
272
- }
273
- else {
274
- $this->_options[ $id ] = $this->_input[ $id ] ;
275
- }
276
- }
277
- }
278
-
279
- }
280
-
281
- /**
282
- * Validates the cache control settings.
283
- *
284
- * @since 1.1.6
285
- * @access private
286
- */
287
- private function _validate_cache()
288
- {
289
- $ids = array(
290
- LiteSpeed_Cache_Config::OPID_CACHE_PRIV,
291
- LiteSpeed_Cache_Config::OPID_CACHE_COMMENTER,
292
- LiteSpeed_Cache_Config::OPID_CACHE_REST,
293
- );
294
- foreach ( $ids as $id ) {
295
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
296
- }
297
-
298
- $id = LiteSpeed_Cache_Config::OPID_CACHE_PAGE_LOGIN ;
299
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
300
- if( ! $this->_options[ $id ] ) {
301
- LiteSpeed_Cache_Purge::add( LiteSpeed_Cache_Tag::TYPE_LOGIN ) ;
302
- }
303
-
304
- $id = LiteSpeed_Cache_Config::OPID_CACHE_URI_PRIV ;
305
- if ( isset( $this->_input[ $id ]) ) {
306
- $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'relative' ) ;
307
- }
308
- }
309
-
310
- /**
311
- * Validates the purge settings.
312
- *
313
- * @since 1.0.12
314
- * @access private
315
- */
316
- private function _validate_purge()
317
- {
318
- $id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ;
319
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
320
-
321
- // get auto purge rules options
322
- $pvals = array(
323
- LiteSpeed_Cache_Config::PURGE_ALL_PAGES,
324
- LiteSpeed_Cache_Config::PURGE_FRONT_PAGE,
325
- LiteSpeed_Cache_Config::PURGE_HOME_PAGE,
326
- LiteSpeed_Cache_Config::PURGE_PAGES,
327
- LiteSpeed_Cache_Config::PURGE_PAGES_WITH_RECENT_POSTS,
328
- LiteSpeed_Cache_Config::PURGE_AUTHOR,
329
- LiteSpeed_Cache_Config::PURGE_YEAR,
330
- LiteSpeed_Cache_Config::PURGE_MONTH,
331
- LiteSpeed_Cache_Config::PURGE_DATE,
332
- LiteSpeed_Cache_Config::PURGE_TERM,
333
- LiteSpeed_Cache_Config::PURGE_POST_TYPE,
334
- ) ;
335
- $input_purge_options = array() ;
336
- foreach ( $pvals as $v) {
337
- $input_name = 'purge_' . $v ;
338
- if ( self::parse_onoff( $this->_input, $input_name ) ) {
339
- $input_purge_options[] = $v ;
340
- }
341
- }
342
- sort( $input_purge_options ) ;
343
- $purge_by_post = implode( '.', $input_purge_options ) ;
344
- if ( $purge_by_post !== $this->_options[ LiteSpeed_Cache_Config::OPID_PURGE_BY_POST ] ) {
345
- $this->_options[ LiteSpeed_Cache_Config::OPID_PURGE_BY_POST ] = $purge_by_post ;
346
- }
347
-
348
- // Filter scheduled purge URLs
349
- $id = LiteSpeed_Cache_Config::OPID_TIMED_URLS ;
350
- if ( isset( $this->_input[ $id ] ) ) {
351
- $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'relative' ) ;
352
- }
353
-
354
- // Schduled Purge Time
355
- $id = LiteSpeed_Cache_Config::OPID_TIMED_URLS_TIME ;
356
- $this->_options[ $id ] = $this->_input[ $id ] ;
357
- }
358
-
359
- /**
360
- * Validates the exclude settings.
361
- *
362
- * @since 1.0.12
363
- * @access private
364
- */
365
- private function _validate_exclude()
366
- {
367
- $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_URI ;
368
- if ( isset( $this->_input[ $id ] ) ) {
369
- $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'relative' ) ;
370
- }
371
-
372
- $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_QS ;
373
- if ( isset( $this->_input[ $id ] ) ) {
374
- $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ] ) ;
375
- }
376
-
377
- $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT ;
378
- $this->_options[ $id ] = '' ;
379
- if ( isset( $this->_input[ $id ] ) ) {
380
- $cat_ids = array() ;
381
- $cats = explode( "\n", $this->_input[ $id ] ) ;
382
- foreach ( $cats as $cat ) {
383
- $cat_name = trim( $cat ) ;
384
- if ( $cat_name == '' ) {
385
- continue ;
386
- }
387
- $cat_id = get_cat_ID( $cat_name ) ;
388
- if ( $cat_id == 0 ) {
389
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_CAT, $cat_name ) ;
390
- }
391
- else {
392
- $cat_ids[] = $cat_id ;
393
- }
394
- }
395
- if ( ! empty( $cat_ids ) ) {
396
- $this->_options[ $id ] = implode( ',', $cat_ids ) ;
397
- }
398
- }
399
-
400
- $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG ;
401
- $this->_options[ $id ] = '' ;
402
- if ( isset( $this->_input[ $id ] ) ) {
403
- $tag_ids = array() ;
404
- $tags = explode( "\n", $this->_input[ $id ] ) ;
405
- foreach ( $tags as $tag ) {
406
- $tag_name = trim( $tag ) ;
407
- if ( $tag_name == '' ) {
408
- continue ;
409
- }
410
- $term = get_term_by( 'name', $tag_name, 'post_tag' ) ;
411
- if ( $term == 0 ) {
412
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_TAG, $tag_name ) ;
413
- }
414
- else {
415
- $tag_ids[] = $term->term_id ;
416
- }
417
- }
418
- if ( ! empty( $tag_ids ) ) {
419
- $this->_options[ $id ] = implode( ',', $tag_ids ) ;
420
- }
421
- }
422
- }
423
-
424
- /**
425
- * Validates the CDN settings.
426
- *
427
- * @since 1.2.2
428
- * @access private
429
- */
430
- private function _validate_cdn()
431
- {
432
- $ids = array(
433
- LiteSpeed_Cache_Config::OPID_CDN,
434
- LiteSpeed_Cache_Config::OPID_CDN_INC_IMG,
435
- LiteSpeed_Cache_Config::OPID_CDN_INC_CSS,
436
- LiteSpeed_Cache_Config::OPID_CDN_INC_JS,
437
- ) ;
438
- foreach ( $ids as $id ) {
439
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
440
- }
441
-
442
- $id = LiteSpeed_Cache_Config::OPID_CDN_ORI ;
443
- $this->_options[ $id ] = $this->_input[ $id ] ;
444
- if ( $this->_options[ $id ] ) {
445
- $tmp = parse_url( $this->_options[ $id ] ) ;
446
- if ( ! empty( $tmp[ 'scheme' ] ) ) {
447
- $this->_options[ $id ] = str_replace( $tmp[ 'scheme' ] . ':', '', $this->_options[ $id ] ) ;
448
- }
449
- }
450
-
451
- $id = LiteSpeed_Cache_Config::OPID_CDN_URL ;
452
- $this->_options[ $id ] = $this->_input[ $id ] ;
453
-
454
- $ids = array(
455
- LiteSpeed_Cache_Config::OPID_CDN_FILETYPE,
456
- LiteSpeed_Cache_Config::OPID_CDN_EXCLUDE,
457
- ) ;
458
- foreach ( $ids as $id ) {
459
- $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ] ) ;
460
- }
461
- }
462
-
463
- /**
464
- * Validates the optimize settings.
465
- *
466
- * @since 1.2.2
467
- * @access private
468
- */
469
- private function _validate_optimize()
470
- {
471
- $ids = array(
472
- LiteSpeed_Cache_Config::OPID_CSS_MINIFY,
473
- LiteSpeed_Cache_Config::OPID_CSS_COMBINE,
474
- LiteSpeed_Cache_Config::OPID_CSS_HTTP2,
475
- LiteSpeed_Cache_Config::OPID_JS_MINIFY,
476
- LiteSpeed_Cache_Config::OPID_JS_COMBINE,
477
- LiteSpeed_Cache_Config::OPID_JS_HTTP2,
478
- LiteSpeed_Cache_Config::OPID_HTML_MINIFY,
479
- LiteSpeed_Cache_Config::OPID_OPTM_QS_RM,
480
- LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM,
481
- LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC,
482
- LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER,
483
- LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM,
484
- ) ;
485
- foreach ( $ids as $id ) {
486
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
487
- }
488
-
489
- $ids = array(
490
- LiteSpeed_Cache_Config::OPID_CSS_EXCLUDES,
491
- LiteSpeed_Cache_Config::OPID_JS_EXCLUDES,
492
- ) ;
493
- foreach ( $ids as $id ) {
494
- $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'uri' ) ;
495
- }
496
-
497
- $id = LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ;
498
- if ( ! $this->_check_ttl( $this->_input, $id, 3600 ) ) {
499
- $this->_input[ $id ] = 3600 ;
500
- }
501
- $this->_options[ $id ] = $this->_input[ $id ] ;
502
-
503
- // Update critical css
504
- update_option( LiteSpeed_Cache_Config::ITEM_OPTM_CSS, $this->_input[ LiteSpeed_Cache_Config::ITEM_OPTM_CSS ] ) ;
505
- }
506
-
507
- /**
508
- * Validates the debug settings.
509
- *
510
- * @since 1.0.12
511
- * @access private
512
- */
513
- private function _validate_debug()
514
- {
515
- $id = LiteSpeed_Cache_Config::OPID_ADMIN_IPS ;
516
- if ( isset( $this->_input[ $id ] ) ) {
517
- $admin_ips = array_map( 'trim', explode( "\n", trim( $this->_input[ $id ] ) ) ) ;
518
- $admin_ips = array_filter( $admin_ips ) ;
519
- $has_err = false ;
520
- if ( $admin_ips ) {
521
- foreach ( $admin_ips as $ip ) {
522
- if ( ! WP_Http::is_ip_address( $ip ) ) {
523
- $has_err = true ;
524
- break ;
525
- }
526
- }
527
- }
528
- $admin_ips = implode( "\n", $admin_ips ) ;
529
-
530
- if ( $has_err ) {
531
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_ADMIN_IP_INV ) ;
532
- }
533
- else {
534
- $this->_options[ $id ] = $admin_ips ;
535
- }
536
- }
537
-
538
- $id = LiteSpeed_Cache_Config::OPID_DEBUG ;
539
- $this->_options[ $id ] = self::is_checked_radio( $this->_input[ $id ] ) ;
540
-
541
- $id = LiteSpeed_Cache_Config::OPID_LOG_FILE_SIZE ;
542
- if ( ! $this->_check_ttl( $this->_input, $id, 3, 3000 ) ) {
543
- $this->_err[] = sprintf( $this->_err_msg_numeric, __( 'Log File Size Limit', 'litespeed-cache' ), 3, 3000 ) ;
544
- }
545
- else {
546
- $this->_options[ $id ] = $this->_input[ $id ] ;
547
- }
548
-
549
- $ids = array(
550
- LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
551
- LiteSpeed_Cache_Config::OPID_HEARTBEAT,
552
- LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE,
553
- LiteSpeed_Cache_Config::OPID_COLLAPS_QS,
554
- LiteSpeed_Cache_Config::OPID_LOG_FILTERS,
555
- ) ;
556
- foreach ( $ids as $id ) {
557
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
558
- }
559
-
560
- // Filters ignored
561
- $ids = array(
562
- LiteSpeed_Cache_Config::OPID_LOG_IGNORE_FILTERS,
563
- LiteSpeed_Cache_Config::OPID_LOG_IGNORE_PART_FILTERS,
564
- ) ;
565
- foreach ( $ids as $id ) {
566
- $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ] ) ;
567
- }
568
- }
569
-
570
- /**
571
- * Validates the crawler settings.
572
- *
573
- * @since 1.0.12
574
- * @access private
575
- */
576
- private function _validate_crawler()
577
- {
578
- $ids = array(
579
- LiteSpeed_Cache_Config::CRWL_POSTS,
580
- LiteSpeed_Cache_Config::CRWL_PAGES,
581
- LiteSpeed_Cache_Config::CRWL_CATS,
582
- LiteSpeed_Cache_Config::CRWL_TAGS,
583
- ) ;
584
- foreach ( $ids as $id ) {
585
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
586
- }
587
-
588
- $id = LiteSpeed_Cache_Config::CRWL_EXCLUDES_CPT ;
589
- if ( isset( $this->_input[ $id ] ) ) {
590
- $arr = array_map( 'trim', explode( "\n", $this->_input[ $id ] ) ) ;
591
- $arr = array_filter( $arr ) ;
592
- $ori = array_diff( get_post_types( '', 'names' ), array( 'post', 'page' ) ) ;
593
- $this->_options[ $id ] = implode( "\n", array_intersect( $arr, $ori ) ) ;
594
- }
595
-
596
- $id = LiteSpeed_Cache_Config::CRWL_ORDER_LINKS ;
597
- if( ! isset( $this->_input[ $id ] ) || ! in_array( $this->_input[ $id ], array(
598
- LiteSpeed_Cache_Config::CRWL_DATE_DESC,
599
- LiteSpeed_Cache_Config::CRWL_DATE_ASC,
600
- LiteSpeed_Cache_Config::CRWL_ALPHA_DESC,
601
- LiteSpeed_Cache_Config::CRWL_ALPHA_ASC,
602
- ) )
603
- ) {
604
- $this->_input[ $id ] = LiteSpeed_Cache_Config::CRWL_DATE_DESC ;
605
- }
606
- $this->_options[ $id ] = $this->_input[ $id ] ;
607
-
608
- $ids = array(
609
- LiteSpeed_Cache_Config::CRWL_USLEEP => array( __( 'Delay', 'litespeed-cache' ), 0, 30000 ),
610
- LiteSpeed_Cache_Config::CRWL_RUN_DURATION => array( __( 'Run Duration', 'litespeed-cache' ), 0, $this->_max_int ),
611
- LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL => array( __( 'Cron Interval', 'litespeed-cache' ), 60, $this->_max_int ),
612
- LiteSpeed_Cache_Config::CRWL_CRAWL_INTERVAL => array( __( 'Whole Interval', 'litespeed-cache' ), 0, $this->_max_int ),
613
- LiteSpeed_Cache_Config::CRWL_THREADS => array( __( 'Threads', 'litespeed-cache' ), 1, 16 ),
614
- ) ;
615
- foreach ( $ids as $id => $v ) {
616
- list( $desc, $min, $max ) = $v ;
617
- if ( ! $this->_check_ttl( $this->_input, $id, $min, $max ) ) {
618
- $this->_err[] = sprintf( $this->_err_msg_numeric, $desc, $min, $max ) ;
619
- }
620
- else {
621
- $this->_options[ $id ] = $this->_input[ $id ] ;
622
- }
623
- }
624
-
625
-
626
- $id = LiteSpeed_Cache_Config::CRWL_LOAD_LIMIT ;
627
- $this->_options[ $id ] = $this->_input[ $id ] ;
628
-
629
- $id = LiteSpeed_Cache_Config::CRWL_DOMAIN_IP ;
630
- if ( ! empty( $this->_input[ $id ] ) && ! WP_Http::is_ip_address( $this->_input[ $id ] ) ) {
631
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_SITE_IP, $this->_input[ $id ] ) ;
632
- }
633
- else {
634
- $this->_options[ $id ] = $this->_input[ $id ] ;
635
- }
636
-
637
- $id = LiteSpeed_Cache_Config::CRWL_CUSTOM_SITEMAP ;
638
- if ( ! empty( $this->_input[ $id ] ) && ( $err = $this->_validate_custom_sitemap( $this->_input[ $id ] ) ) !== true ) {
639
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( $err, $this->_input[ $id ] ) ;
640
- }
641
- else {
642
- $this->_options[ $id ] = $this->_input[ $id ] ;
643
- }
644
-
645
- }
646
-
647
- /**
648
- * Validates the custom sitemap settings.
649
- *
650
- * @since 1.1.1
651
- * @access private
652
- * @param string $url The sitemap url
653
- */
654
- private function _validate_custom_sitemap( $url )
655
- {
656
- return LiteSpeed_Cache_Crawler::get_instance()->parse_custom_sitemap( $url, false ) ;
657
- }
658
-
659
- /**
660
- * Validates settings related to rewrite rules
661
- *
662
- * @since 1.3
663
- * @access private
664
- * @return array New options related to rewrite rule
665
- */
666
- private function _validate_rewrite_settings()
667
- {
668
- $new_options = array() ;
669
-
670
- $ids = array(
671
- LiteSpeed_Cache_Config::OPID_CACHE_MOBILE,
672
- LiteSpeed_Cache_Config::OPID_CACHE_FAVICON,
673
- LiteSpeed_Cache_Config::OPID_CACHE_RES,
674
- LiteSpeed_Cache_Config::OPID_CACHE_BROWSER,
675
- ) ;
676
- foreach ( $ids as $id ) {
677
- $new_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
678
- }
679
-
680
- // check mobile agents
681
- $id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
682
- if ( ! $this->_input[ $id ] && $new_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) {
683
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, 'EMPTY' ) ) ;
684
- }
685
- elseif ( $this->_input[ $id ] && ! $this->_syntax_checker( $this->_input[ $id ] ) ) {
686
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, esc_html( $this->_input[ $id ] ) ) ) ;
687
- }
688
- else {
689
- $new_options[ $id ] = $this->_input[ $id ] ;
690
- }
691
-
692
- // No cache cookie settings
693
- $id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES ;
694
- $this->_input[ $id ] = preg_replace( "/[\r\n]+/", '|', $this->_input[ $id ] ) ;
695
- if ( $this->_input[ $id ] && ! $this->_syntax_checker( $this->_input[ $id ] ) ) {
696
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, esc_html( $this->_input[ $id ] ) ) ) ;
697
- }
698
- else {
699
- $new_options[ $id ] = $this->_input[ $id ] ;
700
- }
701
-
702
- // No cache user agent settings
703
- $id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS ;
704
- if ( $this->_input[ $id ] && ! $this->_syntax_checker( $this->_input[ $id ] ) ) {
705
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, esc_html( $this->_input[ $id ] ) ) ) ;
706
- }
707
- else {
708
- $new_options[ $id ] = $this->_input[ $id ] ;
709
- }
710
-
711
- // Login cookie
712
- $id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ;
713
- if ( $this->_input[ $id ] && preg_match( '#[^\w\-]#', $this->_input[ $id ] ) ) {
714
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_LC, esc_html( $this->_input[ $id ] ) ) ;
715
- }
716
- else {
717
- $new_options[ $id ] = $this->_input[ $id ] ;
718
- }
719
-
720
- return $new_options ;
721
- }
722
-
723
- /**
724
- * Validates the third party settings.
725
- *
726
- * @since 1.0.12
727
- * @access private
728
- */
729
- private function _validate_thirdparty()
730
- {
731
- $tp_default_options = LiteSpeed_Cache_Config::get_instance()->get_thirdparty_options() ;
732
- if ( empty( $tp_default_options ) ) {
733
- return ;
734
- }
735
-
736
- $tp_input = array_intersect_key( $this->_input, $tp_default_options ) ;
737
- if ( empty( $tp_input ) ) {
738
- return ;
739
- }
740
-
741
- $tp_options = apply_filters( 'litespeed_cache_save_options', array_intersect_key( $this->_options, $tp_default_options ), $tp_input ) ;
742
- if ( ! empty( $tp_options ) && is_array( $tp_options ) ) {
743
- $this->_options = array_merge( $this->_options, $tp_options ) ;
744
- }
745
- }
746
-
747
- /**
748
- * Validates the esi settings.
749
- *
750
- * @since 1.1.3
751
- * @access private
752
- */
753
- private function _validate_esi()
754
- {
755
- $ids = array(
756
- LiteSpeed_Cache_Config::OPID_ESI_ENABLE,
757
- LiteSpeed_Cache_Config::OPID_ESI_CACHE_ADMBAR,
758
- LiteSpeed_Cache_Config::OPID_ESI_CACHE_COMMFORM,
759
- ) ;
760
- foreach ( $ids as $id ) {
761
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
762
- }
763
-
764
- // Save vary group settings
765
- $vary_groups = $_POST[ LiteSpeed_Cache_Config::VARY_GROUP ] ;
766
- $vary_groups = array_map( 'trim', $vary_groups ) ;
767
- $vary_groups = array_filter( $vary_groups ) ;
768
- update_option( LiteSpeed_Cache_Config::VARY_GROUP, $vary_groups ) ;
769
- }
770
-
771
- /**
772
- * Hooked to the wp_redirect filter.
773
- * This will only hook if there was a problem when saving the widget.
774
- *
775
- * @since 1.1.3
776
- * @access public
777
- * @param string $location The location string.
778
- * @return string the updated location string.
779
- */
780
- public static function widget_save_err( $location )
781
- {
782
- return str_replace( '?message=0', '?error=0', $location ) ;
783
- }
784
-
785
- /**
786
- * Hooked to the widget_update_callback filter.
787
- * Validate the LiteSpeed Cache settings on edit widget save.
788
- *
789
- * @since 1.1.3
790
- * @access public
791
- * @param array $instance The new settings.
792
- * @param array $new_instance
793
- * @param array $old_instance The original settings.
794
- * @param WP_Widget $widget The widget
795
- * @return mixed Updated settings on success, false on error.
796
- */
797
- public static function validate_widget_save( $instance, $new_instance, $old_instance, $widget )
798
- {
799
- if ( empty( $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ) {
800
- return $instance ;
801
- }
802
- $current = ! empty( $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ? $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] : false ;
803
- $input = $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ;
804
- $esistr = $input[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ;
805
- $ttlstr = $input[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ;
806
-
807
- if ( ! is_numeric( $ttlstr ) || ! is_numeric( $esistr ) ) {
808
- add_filter( 'wp_redirect', 'LiteSpeed_Cache_Admin_Settings::widget_save_err' ) ;
809
- return false ;
810
- }
811
-
812
- $esi = self::is_checked_radio( $esistr ) ;
813
- $ttl = intval( $ttlstr ) ;
814
-
815
- if ( $ttl != 0 && $ttl < 30 ) {
816
- add_filter( 'wp_redirect', 'LiteSpeed_Cache_Admin_Settings::widget_save_err' ) ;
817
- return false ; // invalid ttl.
818
- }
819
-
820
- if ( empty( $instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ) {
821
- $instance[ LiteSpeed_Cache_Config::OPTION_NAME ] = array() ;
822
- }
823
- $instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] = $esi ;
824
- $instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] = $ttl ;
825
-
826
- if ( ! $current || $esi != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ) {
827
- LiteSpeed_Cache_Purge::purge_all() ;
828
- }
829
- elseif ( $ttl != 0 && $ttl != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ) {
830
- LiteSpeed_Cache_Purge::add( LiteSpeed_Cache_Tag::TYPE_WIDGET . $widget->id ) ;
831
- }
832
-
833
- LiteSpeed_Cache_Purge::purge_all() ;
834
- return $instance ;
835
- }
836
-
837
- /**
838
- * Parse rewrite input to check for possible issues (e.g. unescaped spaces).
839
- *
840
- * Issues tracked:
841
- * Starts with |
842
- * Ends with |
843
- * Double |
844
- * Unescaped space
845
- * Invalid character (NOT \w, -, \, |, \s, /, ., +, *, (, ))
846
- *
847
- * @since 1.0.9
848
- * @access private
849
- * @param String $rule Input rewrite rule.
850
- * @return bool True for valid rules, false otherwise.
851
- */
852
- private function _syntax_checker( $rule )
853
- {
854
- $escaped = str_replace( '@', '\@', $rule ) ;
855
-
856
- $success = true ;
857
-
858
- set_error_handler( 'litespeed_exception_handler' ) ;
859
-
860
- try {
861
- preg_match( '@' . $escaped . '@', null ) ;
862
- } catch ( ErrorException $e ) {
863
- $success = false ;
864
- }
865
-
866
- restore_error_handler() ;
867
-
868
- return $success ;
869
- }
870
-
871
- /**
872
- * Helper function to validate TTL settings. Will check if it's set, is an integer, and is greater than 0 and less than INT_MAX.
873
- *
874
- * @since 1.0.12
875
- * @access private
876
- * @param array $input Input array
877
- * @param string $id Option ID
878
- * @param number $min Minimum number
879
- * @param number $max Maximum number
880
- * @return bool True if valid, false otherwise.
881
- */
882
- private function _check_ttl( $input, $id, $min = false, $max = null )
883
- {
884
- if ( ! isset( $input[ $id ] ) ) {
885
- return false ;
886
- }
887
-
888
- $val = $input[ $id ] ;
889
-
890
- $ival = intval( $val ) ;
891
- $sval = strval( $val ) ;
892
-
893
- if( $min && $ival < $min ) {
894
- return false ;
895
- }
896
-
897
- if ( $max === null ) {
898
- $max = $this->_max_int ;
899
- }
900
-
901
- return ctype_digit( $sval ) && $ival >= 0 && $ival < $max ;
902
- }
903
-
904
- /**
905
- * Filter the value for checkbox via input and id (enabled/disabled)
906
- *
907
- * @since 1.1.6
908
- * @access public
909
- * @param int $input The whole input array
910
- * @param string $id The ID of the option
911
- * @return bool Filtered value
912
- */
913
- public static function parse_onoff( $input, $id )
914
- {
915
- return isset( $input[ $id ] ) && self::is_checked( $input[ $id ] ) ;
916
- }
917
-
918
- /**
919
- * Filter the value for checkbox (enabled/disabled)
920
- *
921
- * @since 1.1.0
922
- * @access public
923
- * @param int $val The checkbox value
924
- * @return bool Filtered value
925
- */
926
- public static function is_checked( $val )
927
- {
928
- $val = intval( $val ) ;
929
-
930
- if( $val === LiteSpeed_Cache_Config::VAL_ON ) {
931
- return true ;
932
- }
933
-
934
- return false ;
935
- }
936
-
937
- /**
938
- * Filter the value for radio (enabled/disabled/notset)
939
- *
940
- * @since 1.1.0
941
- * @access public
942
- * @param int $val The radio value
943
- * @return int Filtered value
944
- */
945
- public static function is_checked_radio( $val )
946
- {
947
- $val = intval( $val ) ;
948
-
949
- if( $val === LiteSpeed_Cache_Config::VAL_ON ) {
950
- return LiteSpeed_Cache_Config::VAL_ON ;
951
- }
952
-
953
- if( $val === LiteSpeed_Cache_Config::VAL_ON2 ) {
954
- return LiteSpeed_Cache_Config::VAL_ON2 ;
955
- }
956
-
957
- return LiteSpeed_Cache_Config::VAL_OFF ;
958
- }
959
-
960
- /**
961
- * Get the current instance object.
962
- *
963
- * @since 1.1.0
964
- * @access public
965
- * @return Current class instance.
966
- */
967
- public static function get_instance()
968
- {
969
- if ( ! isset( self::$_instance ) ) {
970
- self::$_instance = new self() ;
971
- }
972
-
973
- return self::$_instance ;
974
- }
975
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/litespeed-cache-admin.class.php DELETED
@@ -1,276 +0,0 @@
1
- <?php
2
- /**
3
- * The admin-panel specific functionality of the plugin.
4
- *
5
- *
6
- * @since 1.0.0
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/admin
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
- class LiteSpeed_Cache_Admin
12
- {
13
- private static $_instance ;
14
- private $config ;
15
- private $display ;
16
- private $main ;
17
-
18
- /**
19
- * Initialize the class and set its properties.
20
- * Run in hook `after_setup_theme` when is_admin()
21
- *
22
- * @since 1.0.0
23
- */
24
- private function __construct()
25
- {
26
- // Additional litespeed assets on admin display
27
- // Also register menu
28
- $this->display = LiteSpeed_Cache_Admin_Display::get_instance() ;
29
-
30
- $this->config = LiteSpeed_Cache_Config::get_instance() ;
31
-
32
- if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
33
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' ) ;//todo: check if needed
34
- }
35
-
36
- // initialize admin actions
37
- add_action( 'admin_init', array( $this, 'admin_init' ) ) ;
38
- // add link to plugin list page
39
- add_filter( 'plugin_action_links_' . LSWCP_BASENAME, array( $this->display, 'add_plugin_links' ) ) ;
40
-
41
- if ( defined( 'LITESPEED_ON' ) ) {
42
- // register purge_all actions
43
- $purge_all_events = array(
44
- 'switch_theme',
45
- 'wp_create_nav_menu', 'wp_update_nav_menu', 'wp_delete_nav_menu',
46
- 'create_term', 'edit_terms', 'delete_term',
47
- 'add_link', 'edit_link', 'delete_link'
48
- ) ;
49
- // purge all on upgrade
50
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ) ) {
51
- $purge_all_events[] = 'upgrader_process_complete' ;
52
- $purge_all_events[] = 'admin_action_do-plugin-upgrade' ;
53
- }
54
- foreach ( $purge_all_events as $event ) {
55
- add_action( $event, 'LiteSpeed_Cache_Purge::purge_all' ) ;
56
- }
57
- // add_filter( 'upgrader_pre_download', 'LiteSpeed_Cache_Purge::filter_with_purge_all' ) ;
58
- }
59
- }
60
-
61
- /**
62
- * Callback that initializes the admin options for LiteSpeed Cache.
63
- *
64
- * @since 1.0.0
65
- * @access public
66
- */
67
- public function admin_init()
68
- {
69
- // check for upgrade
70
- // NOTE: upgrade checking needs to be before `register_setting` to avoid update_options() be checked by our filter
71
- $this->config->plugin_upgrade() ;
72
- if ( is_network_admin() && current_user_can('manage_network_options') ) {
73
- $this->config->plugin_site_upgrade() ;
74
- }
75
-
76
- load_plugin_textdomain(LiteSpeed_Cache::PLUGIN_NAME, false, 'litespeed-cache/languages/') ;
77
-
78
- $this->proceed_admin_action() ;
79
-
80
- // Terminate if user doesn't have the access to settings
81
- if( is_network_admin() ) {
82
- $capability = 'manage_network_options' ;
83
- }
84
- else {
85
- $capability = 'manage_options' ;
86
- }
87
- if ( ! current_user_can($capability) ) {
88
- return ;
89
- }
90
-
91
- // Save setting from admin settings page
92
- // NOTE: cli will call `validate_plugin_settings` manually. Cron activation doesn't need to validate
93
- global $pagenow ;
94
- if ( ! is_network_admin() && $pagenow === 'options.php' ) {
95
- register_setting(LiteSpeed_Cache_Config::OPTION_NAME, LiteSpeed_Cache_Config::OPTION_NAME, array(LiteSpeed_Cache_Admin_Settings::get_instance(), 'validate_plugin_settings')) ;
96
- }
97
-
98
- // step out if plugin is not enabled
99
- if ( ! defined( 'LITESPEED_ON' ) ) {
100
- return ;
101
- }
102
-
103
- LiteSpeed_Cache_Control::set_nocache( 'Admin page' ) ;
104
-
105
- if ( LiteSpeed_Cache_Router::esi_enabled() ) {
106
- add_action( 'in_widget_form', array( $this->display, 'show_widget_edit' ), 100, 3 ) ;
107
- add_filter( 'widget_update_callback', 'LiteSpeed_Cache_Admin_Settings::validate_widget_save', 10, 4 ) ;
108
- }
109
-
110
- // check if WP_CACHE is defined and true in the wp-config.php file.
111
- if ( ! defined('WP_CACHE') || ! WP_CACHE ) {
112
- $add_var = LiteSpeed_Cache_Config::wp_cache_var_setter(true) ;
113
- if ( $add_var !== true ) {
114
- LiteSpeed_Cache_Admin_Display::add_error($add_var) ;
115
- }
116
- }
117
-
118
- // check management action
119
- if ( defined('WP_CACHE') && WP_CACHE ) {
120
- $this->check_advanced_cache() ;
121
- }
122
-
123
- if ( ! is_multisite() ) {
124
- if( ! current_user_can('manage_options') ){
125
- return ;
126
- }
127
- }
128
- elseif ( ! is_network_admin() ) {
129
- if ( ! current_user_can('manage_options') ) {
130
- return ;
131
- }
132
- if ( get_current_blog_id() !== BLOG_ID_CURRENT_SITE ) {
133
- $use_primary = LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY ;
134
- $site_options = $this->config->get_site_options() ;
135
- if ( isset($site_options[$use_primary]) && $site_options[$use_primary] ) {
136
- $this->display->set_disable_all() ;
137
- }
138
- }
139
- return ;
140
- }
141
- elseif ( ! current_user_can('manage_network_options') ) {
142
- return ;
143
- }
144
-
145
- if ( LiteSpeed_Cache_Router::has_whm_msg() ) {
146
- $this->display->show_display_installed() ;
147
- }
148
- }
149
-
150
- /**
151
- * Run litespeed admin actions
152
- *
153
- * @since 1.1.0
154
- */
155
- public function proceed_admin_action()
156
- {
157
- // handle actions
158
- switch (LiteSpeed_Cache_Router::get_action()) {
159
-
160
- // Save htaccess
161
- case LiteSpeed_Cache::ACTION_SAVE_HTACCESS:
162
- LiteSpeed_Cache_Admin_Rules::get_instance()->htaccess_editor_save() ;
163
- break ;
164
-
165
- // Save network settings
166
- case LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK:
167
- $options = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_network_settings() ;// todo: use wp network setting saving
168
- LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report($options) ;
169
- break ;
170
-
171
- default:
172
- break ;
173
- }
174
-
175
- }
176
-
177
- /**
178
- * Check to make sure that the advanced-cache.php file is ours.
179
- * If it doesn't exist, try to make it ours.
180
- *
181
- * If it is not ours and the config is set to check, output an error.
182
- *
183
- * @since 1.0.11
184
- * @access private
185
- */
186
- private function check_advanced_cache()
187
- {
188
- $capability = is_network_admin() ? 'manage_network_options' : 'manage_options' ;
189
- if ( (defined('LSCACHE_ADV_CACHE') && LSCACHE_ADV_CACHE) || ! current_user_can($capability) ) {
190
- if ( ! LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE) ) {
191
- // If it exists because I added it at runtime, try to create the file anyway.
192
- // Result does not matter.
193
- LiteSpeed_Cache_Activation::try_copy_advanced_cache() ;
194
- }
195
- return ;
196
- }
197
-
198
- if ( LiteSpeed_Cache_Activation::try_copy_advanced_cache() ) {
199
- return ;
200
- }
201
-
202
- if ( is_multisite() && ( ! is_network_admin() || ! current_user_can('manage_network_options')) ) {
203
- $third = __('For this scenario only, the network admin may uncheck "Check Advanced Cache" in LiteSpeed Cache settings.', 'litespeed-cache') ;
204
- }else {
205
- $third = __('For this scenario only, please uncheck "Check Advanced Cache" in LiteSpeed Cache settings.', 'litespeed-cache') ;
206
- }
207
- $msg = __('Please disable/deactivate any other Full Page Cache solutions that are currently being used.', 'litespeed-cache') . ' '
208
- . __('LiteSpeed Cache does work with other cache solutions, but only their non-page caching offerings—such as minifying css/js files.', 'litespeed-cache') . ' '
209
- . $third ;
210
-
211
- $this->display->add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_YELLOW, $msg) ;
212
- }
213
-
214
- /**
215
- * Clean up the input string of any extra slashes/spaces.
216
- *
217
- * @since 1.0.4
218
- * @access public
219
- * @param string $input The input string to clean.
220
- * @return string The cleaned up input.
221
- */
222
- public static function cleanup_text($input)
223
- {
224
- return stripslashes(trim($input)) ;
225
- }
226
-
227
- /**
228
- * After a LSCWP_CTRL action, need to redirect back to the same page
229
- * without the nonce and action in the query string.
230
- *
231
- * @since 1.0.12
232
- * @access public
233
- * @global string $pagenow
234
- */
235
- public static function redirect()
236
- {
237
- global $pagenow ;
238
- $qs = '' ;
239
-
240
- if ( ! empty($_GET) ) {
241
- if ( isset($_GET[LiteSpeed_Cache::ACTION_KEY]) ) {
242
- unset($_GET[LiteSpeed_Cache::ACTION_KEY]) ;
243
- }
244
- if ( isset($_GET[LiteSpeed_Cache::NONCE_NAME]) ) {
245
- unset($_GET[LiteSpeed_Cache::NONCE_NAME]) ;
246
- }
247
- if ( ! empty($_GET) ) {
248
- $qs = '?' . http_build_query($_GET) ;
249
- }
250
- }
251
- if ( is_network_admin() ) {
252
- $url = network_admin_url($pagenow . $qs) ;
253
- }
254
- else {
255
- $url = admin_url($pagenow . $qs) ;
256
- }
257
- wp_redirect($url) ;
258
- exit() ;
259
- }
260
-
261
- /**
262
- * Get the current instance object.
263
- *
264
- * @since 1.1.0
265
- * @access public
266
- * @return Current class instance.
267
- */
268
- public static function get_instance()
269
- {
270
- if ( ! isset(self::$_instance) ) {
271
- self::$_instance = new self() ;
272
- }
273
-
274
- return self::$_instance ;
275
- }
276
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/admin_footer.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
-
5
- $rate_us = sprintf(__('Rate <strong>LiteSpeed Cache</strong> with %s on WordPress.org if you like us!', 'litespeed-cache'),
6
- '<a href="https://wordpress.org/support/plugin/litespeed-cache/reviews/?filter=5#new-post" rel="noopener noreferer" target="_blank">&#10030;&#10030;&#10030;&#10030;&#10030;</a>'
7
- );
8
- $questions = sprintf(__('If there are any questions that are not answered in the <a %s>FAQs</a>, do not hesitate to ask them on the <a %s>support forum</a>.', 'litespeed-cache'),
9
- 'href="' . get_admin_url() . 'admin.php?page=lscache-info"',
10
- 'href="https://wordpress.org/support/plugin/litespeed-cache" rel="noopener noreferrer" target="_blank"');
11
- // Change the footer text
12
- if ( !is_multisite()
13
- || is_network_admin())
14
- {
15
- $footer_text = $rate_us . ' ' . $questions;
16
- }
17
- else{
18
- $footer_text = $questions;
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/crawler.php DELETED
@@ -1,228 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die ;
3
-
4
- $_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
5
-
6
- $sitemap_time = LiteSpeed_Cache_Crawler::get_instance()->sitemap_time() ;
7
-
8
- $disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
9
-
10
- ?>
11
-
12
- <div class="wrap">
13
- <h2>
14
- <?php echo __('LiteSpeed Cache Crawler', 'litespeed-cache') ; ?>
15
- <span class="litespeed-desc">
16
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION; ?>
17
- </span>
18
- </h2>
19
- </div>
20
- <div class="litespeed-wrap">
21
- <div class="litespeed-body">
22
- <h3 class="litespeed-title"><?php echo __('Crawler File', 'litespeed-cache') ; ?></h3>
23
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_CRAWLER_GENERATE_FILE) ; ?>" class="litespeed-btn-success">
24
- <?php echo __('Generate Crawler File', 'litespeed-cache') ; ?>
25
- </a>
26
-
27
- <?php
28
- if ( $sitemap_time ) {
29
- echo sprintf(__('Generated at %s', 'litespeed-cache'), $sitemap_time) ;
30
- }
31
- ?>
32
- <div class="litespeed-desc">
33
- <?php echo sprintf(__('On click, this will create a crawler sitemap file in plugin directory %s.', 'litespeed-cache'), '`./var`') ; ?>
34
- </div>
35
-
36
- <?php
37
- $seconds = $_options[LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL] ;
38
- if($seconds > 0):
39
- $recurrence = '' ;
40
- $hours = (int)floor($seconds / 3600) ;
41
- if ( $hours ) {
42
- if ( $hours > 1) {
43
- $recurrence .= sprintf(__('%d hours', 'litespeed-cache'), $hours);
44
- }
45
- else {
46
- $recurrence .= sprintf(__('%d hour', 'litespeed-cache'), $hours);
47
- }
48
- }
49
- $minutes = (int)floor( ($seconds % 3600 ) / 60 ) ;
50
- if ( $minutes ) {
51
- $recurrence .= ' ' ;
52
- if ( $minutes > 1) {
53
- $recurrence .= sprintf(__('%d minutes', 'litespeed-cache'), $minutes);
54
- }
55
- else {
56
- $recurrence .= sprintf(__('%d minute', 'litespeed-cache'), $minutes);
57
- }
58
- }
59
- ?>
60
- <h3 class="litespeed-title"><?php echo __('Crawler Cron', 'litespeed-cache') ; ?></h3>
61
- <?php if ( ! LiteSpeed_Cache_Router::can_crawl() ): ?>
62
- <div class="litespeed-callout-danger">
63
- <h4><?php echo __('WARNING', 'litespeed-cache'); ?></h4>
64
- <p><?php echo __('The crawler feature is not enabled on the LiteSpeed server. Please consult your server admin.', 'litespeed-cache'); ?></p>
65
- <p><?php echo sprintf(__('See <a %s>Introduction for Enabling the Crawler</a> for detailed infomation.', 'litespeed-cache'), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:enabling_the_crawler" target="_blank"') ; ?></p>
66
- </div>
67
- <?php endif; ?>
68
- <table class="litespeed-table">
69
- <thead><tr >
70
- <th scope="col"><?php echo __('Cron Name', 'litespeed-cache') ; ?></th>
71
- <th scope="col"><?php echo __('Run Frequency', 'litespeed-cache') ; ?></th>
72
- <th scope="col"><?php echo __('Last Status', 'litespeed-cache') ; ?></th>
73
- <th scope="col"><?php echo __('Activation', 'litespeed-cache') ; ?></th>
74
- <th scope="col"><?php echo __('Actions', 'litespeed-cache') ; ?></th>
75
- </tr></thead>
76
- <tbody>
77
- <tr>
78
- <td>
79
- <?php
80
- echo __('LiteSpeed Cache Crawler', 'litespeed-cache');
81
- ?>
82
- <div class='litespeed-desc'>
83
- <?php
84
- $meta = LiteSpeed_Cache_Crawler::get_instance()->get_meta() ;
85
- $is_running = $meta && $meta->is_running && time() - $meta->is_running <= $_options[LiteSpeed_Cache_Config::CRWL_RUN_DURATION] ;
86
- if ( $meta && $meta->this_full_beginning_time ) {
87
- if ( $is_running ) {
88
- echo sprintf(__('The current sitemap crawl started at %s', 'litespeed-cache'),
89
- date('m/d/Y H:i:s' ,$meta->this_full_beginning_time + LITESPEED_TIME_OFFSET ));
90
-
91
- }
92
- else {
93
- echo sprintf(__('The current sitemap crawl started at %s', 'litespeed-cache'),
94
- date('m/d/Y H:i:s' ,$meta->this_full_beginning_time + LITESPEED_TIME_OFFSET ));
95
- echo "</div><div class='litespeed-desc'>";
96
- echo sprintf(__('The next complete sitemap crawl will start at %s', 'litespeed-cache'),
97
- date('m/d/Y H:i:s',$meta->this_full_beginning_time + LITESPEED_TIME_OFFSET
98
- + $meta->last_full_time_cost + $_options[LiteSpeed_Cache_Config::CRWL_CRAWL_INTERVAL]));
99
- }
100
-
101
- }
102
- ?>
103
- </div>
104
- </td>
105
- <td>
106
- <?php echo $recurrence ; ?>
107
- <div class='litespeed-desc'>
108
- <?php
109
- if ( $meta && $meta->last_full_time_cost ) {
110
- echo sprintf(__('The last complete run cost %s seconds', 'litespeed-cache'), $meta->last_full_time_cost) ;
111
- }
112
- ?>
113
- </div>
114
- </td>
115
- <td>
116
- <?php
117
- if ( $meta ) {
118
- echo "Size: {$meta->list_size}<br />Position: " . ($meta->last_pos + 1) ;
119
- if ( $is_running ) {
120
- echo "<br /><div class='litespeed-label-success'>" . __('Is running', 'litespeed-cache') . "</div>" ;
121
- }
122
- }
123
- else {
124
- echo "-" ;
125
- }
126
- ?>
127
- </td>
128
- <td>
129
- <div class="litespeed-switch-drag">
130
- <input type="checkbox" name="litespeed_crawler_cron_enable" id="litespeed_crawler_cron_enable" value="1"
131
- data-url="<?php echo LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE, 'cron_enable') ; ?>"
132
- <?php if( $_options[LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE] && LiteSpeed_Cache_Router::can_crawl() ) echo "checked"; ?>
133
- <?php echo $disabled ; ?>
134
- />
135
- <label class="litespeed-switch-drag-label" for="litespeed_crawler_cron_enable">
136
- <span class="litespeed-switch-drag-inner" data-on="<?php echo __('Enable', 'litespeed-cache'); ?>" data-off="<?php echo __('Disable', 'litespeed-cache'); ?>"></span>
137
- <span class="litespeed-switch-drag-switch"></span>
138
- </label>
139
- </div>
140
- </td>
141
- <td>
142
- <?php
143
- echo " <a href='" . LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_CRAWLER_RESET_POS) . "' class='litespeed-btn-warning litespeed-btn-xs'>" . __('Reset position', 'litespeed-cache') . "</a>" ;
144
-
145
- $href = LiteSpeed_Cache_Router::can_crawl() ? LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_DO_CRAWL) : 'javascript:;' ;
146
- echo " <a href='$href' id='litespeed_manual_trigger' target='litespeedHiddenIframe' class='litespeed-btn-success litespeed-btn-xs' $disabled>" . __('Manually run', 'litespeed-cache') . "</a>" ;
147
- ?>
148
- <?php if ( $meta && $meta->last_start_time ): ?>
149
- <div class='litespeed-desc'>
150
- <?php echo sprintf(__('<b>Last interval:</b> %s', 'litespeed-cache'), date('m/d/Y H:i:s' ,$meta->last_start_time+ LITESPEED_TIME_OFFSET )) ; ?>
151
- </div>
152
- <?php endif ; ?>
153
-
154
- <?php if ( $meta && $meta->end_reason ): ?>
155
- <div class='litespeed-desc'>
156
- <?php echo sprintf(__('<b>Ended reason:</b> %s', 'litespeed-cache'), $meta->end_reason) ; ?>
157
- </div>
158
- <?php endif ; ?>
159
-
160
- <?php if ( $meta && $meta->last_crawled ): ?>
161
- <div class='litespeed-desc'>
162
- <?php echo sprintf(__('<b>Last crawled:</b> %s item(s)', 'litespeed-cache'), $meta->last_crawled) ; ?>
163
- </div>
164
- <?php endif ; ?>
165
- </td>
166
- </tr>
167
- </tbody>
168
- </table>
169
- <div class="litespeed-desc">
170
- <div><?php echo __('Run frequency is set by the Interval Between Runs setting.','litespeed-cache') ; ?></div>
171
- <div><?php echo __('Only one crawler can run concurrently.', 'litespeed-cache')
172
- . __('If both the cron and manual run start at a similar time, the first one to start will run.','litespeed-cache') ; ?></div>
173
- <div><?php echo sprintf(__('Please follow <a %s>Hooking WP-Cron Into the System Task Scheduler</a> to create the system cron task.','litespeed-cache'), ' href="https://developer.wordpress.org/plugins/cron/hooking-into-the-system-task-scheduler/" target="_blank" ') ; ?></div>
174
- </div>
175
- <?php endif ; ?>
176
-
177
-
178
- <h3 class="litespeed-title"><?php echo __('Watch Crawler Status', 'litespeed-cache') ; ?></h3>
179
-
180
- <?php
181
- $ajaxUrl = LiteSpeed_Cache_Crawler::get_instance()->get_crawler_json_path() ;
182
- if ( $ajaxUrl ):
183
- ?>
184
-
185
- <input type="button" id="litespeed-crawl-url-btn" value="<?php echo __('Show crawler status', 'litespeed-cache') ; ?>" class="litespeed-btn-primary" data-url="<?php echo $ajaxUrl ; ?>" />
186
-
187
- <div class="litespeed-shell litespeed-hide">
188
- <div class="litespeed-shell-header-bar"></div>
189
- <div class="litespeed-shell-header">
190
- <div class="litespeed-shell-header-bg"></div>
191
- <div class="litespeed-shell-header-icon-container">
192
- <img id="litespeed-shell-icon" src="<?php echo LSWCP_PLUGIN_URL . 'img/Litespeed.icon.svg' ; ?>" />
193
- </div>
194
- </div>
195
- <ul class="litespeed-shell-body">
196
- <li>Start watching...</li>
197
- <li id="litespeed-loading-dot"></li>
198
- </ul>
199
- </div>
200
-
201
- <?php else: ?>
202
- <p>
203
- <?php echo __('No crawler meta file generated yet', 'litespeed-cache') ; ?>
204
- </p>
205
- <?php endif ; ?>
206
-
207
-
208
- <h3 class="litespeed-title"><?php echo __('Sitemap Generation Blacklist', 'litespeed-cache') ; ?></h3>
209
-
210
- <form method="post" action="admin.php?page=lscache-crawler">
211
- <?php $this->form_action(LiteSpeed_Cache::ACTION_BLACKLIST_SAVE); ?>
212
- <p>
213
- <textarea name="<?php echo LiteSpeed_Cache_Crawler::CRWL_BLACKLIST; ?>" rows="10" class="litespeed-textarea"><?php echo LiteSpeed_Cache_Crawler::get_instance()->get_blacklist(); ?></textarea>
214
- </p>
215
-
216
- <p>
217
- <button type="submit" class="litespeed-btn-success"><?php echo __('Save', 'litespeed-cache'); ?></button>
218
- </p>
219
- </form>
220
- <div class="litespeed-desc">
221
- <p><?php echo sprintf(__('Current blacklist has %s item(s).', 'litespeed-cache'), LiteSpeed_Cache_Crawler::get_instance()->count_blacklist()); ?></p>
222
- <p><?php echo __('All Urls which returned no-cache tags will be added here, after the initial crawling.', 'litespeed-cache'); ?></p>
223
- </div>
224
-
225
- </div>
226
- </div>
227
-
228
- <iframe name="litespeedHiddenIframe" src="" width="0" height="0" frameborder="0"></iframe>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/debug_log.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
-
5
- ?>
6
-
7
- <div class="wrap">
8
- <h2>
9
- <?php echo __( 'LiteSpeed Cache Debug Log Viewer', 'litespeed-cache' ) ; ?>
10
- <span class="litespeed-desc">
11
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION ; ?>
12
- </span>
13
- </h2>
14
- </div>
15
- <div class="wrap">
16
- <?php
17
-
18
- $file = LSWCP_CONTENT_DIR . '/debug.log' ;
19
- $lines = Litespeed_File::count_lines( $file ) ;
20
- $start = $lines > 1000 ? $lines - 1000 : 0 ;
21
- $logs = Litespeed_File::read( $file, $start ) ;
22
- $logs = implode( "\n", $logs ) ;
23
-
24
- echo nl2br( htmlspecialchars( $logs ) ) ;
25
-
26
- ?>
27
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/edit_htaccess.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $readonly = LiteSpeed_Cache_Admin_Rules::writable() ? '' : 'readonly';
5
- $content = LiteSpeed_Cache_Admin_Rules::get_instance()->htaccess_read();
6
-
7
- // Check if there is `ExpiresDefault` in .htaccess
8
- if ( defined( 'LITESPEED_ON' ) ) {
9
- $htaccess_con = Litespeed_File::read( LiteSpeed_Cache_Admin_Rules::get_frontend_htaccess() ) ;
10
- if ( $content && stripos( $content, "\nExpiresDefault" ) !== false ) {
11
- $is_dismissed = get_option( self::DISMISS_MSG ) ;
12
- if ( $is_dismissed !== self::RULECONFLICT_DISMISSED ) {
13
- // Need to add a notice for browser cache compatibility
14
- if ( $is_dismissed !== self::RULECONFLICT_ON ) {
15
- update_option( self::DISMISS_MSG, self::RULECONFLICT_ON ) ;
16
- }
17
- $this->show_rule_conflict() ;
18
- }
19
- }
20
- // don't dismiss the msg automatically
21
- // elseif ( $is_dismissed === LiteSpeed_Cache_Admin_Display::RULECONFLICT_ON ) {
22
- // update_option( self::DISMISS_MSG, LiteSpeed_Cache_Admin_Display::RULECONFLICT_DISMISSED ) ;
23
- // }
24
- }
25
-
26
-
27
- ?>
28
-
29
- <div class="wrap">
30
- <h2>
31
- <?php echo __('LiteSpeed Cache Edit .htaccess', 'litespeed-cache'); ?>
32
- <span class="litespeed-desc">
33
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION; ?>
34
- </span>
35
- </h2>
36
- </div>
37
- <div class="litespeed-wrap">
38
- <div class="litespeed-body">
39
- <div class="litespeed-callout-danger">
40
- <h4><?php echo __('WARNING: This page is meant for advanced users.', 'litespeed-cache'); ?></h4>
41
- <p>
42
- <?php echo __('Any changes made to the .htaccess file may break the site.', 'litespeed-cache'); ?>
43
- <?php echo __('Please consult the host/server admin before making any changes.', 'litespeed-cache'); ?>
44
- </p>
45
- </div>
46
-
47
- <?php if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT): ?>
48
- <div class="litespeed-h3"><?php echo __('File editing is disabled in configuration.', 'litespeed-cache'); ?></div>
49
-
50
- <?php elseif($content === false): ?>
51
- <div class="litespeed-h3"><?php $this->display_messages(); ?></div>
52
-
53
- <?php else: ?>
54
-
55
- <form method="post" action="admin.php?page=<?php echo LiteSpeed_Cache::PAGE_EDIT_HTACCESS; ?>">
56
- <?php $this->form_action(LiteSpeed_Cache::ACTION_SAVE_HTACCESS); ?>
57
-
58
- <div class="litespeed-title"><?php echo sprintf(__('Current %s Contents', 'litespeed-cache'), '.htaccess'); ?></div>
59
-
60
- <!--p><span class="attention"><?php echo sprintf(__('DO NOT EDIT ANYTHING WITHIN %s', 'litespeed-cache'), LiteSpeed_Cache_Admin_Rules::LS_MODULE_DONOTEDIT); ?></span></p-->
61
-
62
- <p><?php echo __('These are added by the LS Cache plugin and may cause problems if they are changed.', 'litespeed-cache'); ?></p>
63
-
64
- <textarea name="<?php echo LiteSpeed_Cache_Admin_Rules::EDITOR_TEXTAREA_NAME; ?>" wrap="off" rows="30" class="litespeed-input-long"
65
- <?php echo $readonly; ?>
66
- ><?php echo esc_textarea($content); ?></textarea>
67
-
68
- <button type="submit" class="litespeed-btn-primary"><?php echo __('Save', 'litespeed-cache'); ?></button>
69
- </form>
70
-
71
- <?php require LSWCP_DIR . 'admin/tpl/info_common_rewrite.php'; ?>
72
-
73
- <?php endif; ?>
74
- </div>
75
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/esi_widget_edit.php DELETED
@@ -1,80 +0,0 @@
1
- <?php
2
- if ( !defined('WPINC') ) die;
3
- // $widget, $return, $instance
4
-
5
- $options = LiteSpeed_Cache_ESI::widget_load_get_options( $widget ) ;
6
- if ( empty( $options ) ) {
7
- $options = array(
8
- LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE => LiteSpeed_Cache_Config::VAL_OFF,
9
- LiteSpeed_Cache_ESI::WIDGET_OPID_TTL => '28800'
10
- ) ;
11
- $options = apply_filters( 'litespeed_cache_widget_default_options', $options, $widget ) ;
12
- }
13
-
14
- if ( empty( $options ) ) {
15
- $esi = LiteSpeed_Cache_Config::VAL_OFF ;
16
- $ttl = '28800' ;
17
- }
18
- else {
19
- $esi = $options[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ;
20
- $ttl = $options[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ;
21
- }
22
-
23
- $display = LiteSpeed_Cache_Admin_Display::get_instance() ;
24
-
25
- ?>
26
- <div class="litespeed-widget-setting">
27
-
28
- <h4>LiteSpeed Cache:</h4>
29
-
30
- <b><?php echo __( 'Enable ESI', 'litespeed-cache' ) ; ?>:</b>
31
- &nbsp;&nbsp;
32
- <div class="litespeed-inline">
33
- <div class="litespeed-switch litespeed-mini">
34
- <?php
35
- $id = LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ;
36
-
37
- echo $this->build_radio(
38
- $id,
39
- LiteSpeed_Cache_Config::VAL_ON,
40
- __( 'Public', 'litespeed-cache' ),
41
- $esi === LiteSpeed_Cache_Config::VAL_ON,
42
- false,
43
- 'litespeed-cfg-' . $widget->id . '_' . LiteSpeed_Cache_Config::VAL_ON
44
- );
45
-
46
- echo $this->build_radio(
47
- $id,
48
- LiteSpeed_Cache_Config::VAL_ON2,
49
- __( 'Private', 'litespeed-cache' ),
50
- $esi === LiteSpeed_Cache_Config::VAL_ON2,
51
- false,
52
- 'litespeed-cfg-' . $widget->id . '_' . LiteSpeed_Cache_Config::VAL_ON2
53
- );
54
-
55
- echo $this->build_radio(
56
- $id,
57
- LiteSpeed_Cache_Config::VAL_OFF,
58
- __( 'Disable', 'litespeed-cache' ),
59
- $esi === LiteSpeed_Cache_Config::VAL_OFF,
60
- false,
61
- 'litespeed-cfg-' . $widget->id . '_' . LiteSpeed_Cache_Config::VAL_OFF
62
- );
63
- ?>
64
-
65
- </div>
66
- </div>
67
- <br /><br />
68
-
69
- <b><?php echo __( 'Widget Cache TTL:', 'litespeed-cache' ) ; ?></b>
70
- &nbsp;&nbsp;
71
- <?php $display->build_input( LiteSpeed_Cache_ESI::WIDGET_OPID_TTL, 'litespeed-reset', false, false, null, $ttl, 'size="7"' ) ; ?>
72
- <?php echo __( 'seconds', 'litespeed-cache' ) ; ?>
73
-
74
- <p class="install-help">
75
- <?php echo __( 'Recommended value: 28800 seconds (8 hours).', 'litespeed-cache' ) ; ?>
76
- <?php echo __( 'A TTL of 0 indicates do not cache.', 'litespeed-cache' ) ; ?>
77
- </p>
78
- </div>
79
-
80
- <br />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/help_tabs.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $screen = get_current_screen();
5
- $screen->add_help_tab(array(
6
- 'id' => 'lsc-overview',
7
- 'title' => __('Overview', 'litespeed-cache'),
8
- 'content' => '<p>'
9
- . __('LiteSpeed Cache is a page cache built into LiteSpeed Web Server.', 'litespeed-cache') . ' '
10
- . __('This plugin communicates with LiteSpeed Web Server to let it know which pages are cacheable and when to purge them.', 'litespeed-cache')
11
- . '</p><p>' . __('A LiteSpeed server (OLS, LSWS, WebADC) and its LSCache module must be installed and enabled.', 'litespeed-cache')
12
- . '</p>',
13
- ));
14
-
15
- // $screen->add_help_tab(array(
16
- // 'id' => 'lst-purgerules',
17
- // 'title' => __('Auto Purge Rules', 'litespeed-cache'),
18
- // 'content' => '<p>' . __('You can set what pages will be purged when a post is published or updated.', 'litespeed-cache') . '</p>',
19
- // ));
20
-
21
- $screen->set_help_sidebar(
22
- '<p><strong>' . __('For more information:', 'litespeed-cache') . '</strong></p>' .
23
- // '<p><a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache" rel="noopener noreferrer" target="_blank">' . __('LSCache Documentation', 'litespeed-cache') . '</a></p>' .
24
- '<p><a href="https://wordpress.org/support/plugin/litespeed-cache" rel="noopener noreferrer" target="_blank">' . __('Support Forum', 'litespeed-cache') . '</a></p>'
25
- );
26
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $menuArr = array(
5
- 'faqs' => __('FAQs', 'litespeed-cache'),
6
- 'config' => __('Configuration', 'litespeed-cache'),
7
- 'compatibility' => __('Plugin Compatibilities', 'litespeed-cache'),
8
- 'common_rewrite' => __('Common Rewrite Rules', 'litespeed-cache'),
9
- 'admin_ip' => __('Admin IP Commands', 'litespeed-cache'),
10
- 'crawler' => __('Crawler', 'litespeed-cache'),
11
- );
12
-
13
- ?>
14
- <div class="wrap">
15
- <h2>
16
- <?php echo __('LiteSpeed Cache Information', 'litespeed-cache'); ?>
17
- <span class="litespeed-desc">
18
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION ; ?>
19
- </span>
20
- </h2>
21
- </div>
22
- <div class="litespeed-wrap">
23
- <h2 class="litespeed-header">
24
- <?php
25
- foreach ($menuArr as $tab => $val){
26
- echo "<a class='litespeed-tab' href='?page=lscache-info#$tab' data-litespeed-tab='$tab'>$val</a>";
27
- }
28
- ?>
29
- </h2>
30
- <div class="litespeed-body">
31
-
32
- <?php
33
- // include all tpl for faster UE
34
- foreach ($menuArr as $tab => $val) {
35
- echo "<div data-litespeed-layout='$tab'>";
36
- require LSWCP_DIR . "admin/tpl/info_$tab.php";
37
- echo "</div>";
38
- }
39
-
40
- ?>
41
- </div>
42
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info_admin_ip.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $nocache_desc =
5
- __('This is used to display a page without caching it.', 'litespeed-cache').' '.
6
- __('An example use case is to compare a cached version of a page with an uncached version.', 'litespeed-cache');
7
-
8
- $purge_desc =
9
- __('This is used to purge most cache tags associated with the page.', 'litespeed-cache').' '.
10
- __('The lone exception is the blog ID tag.', 'litespeed-cache').' '.
11
- __('Note that this means that pages with the same cache tag will be purged as well.', 'litespeed-cache');
12
-
13
- $showheaders_desc =
14
- __('This is used to show all the cache headers associated with a page.', 'litespeed-cache').' '.
15
- __('This may be useful for debugging purposes.', 'litespeed-cache');
16
-
17
- ?>
18
-
19
- <h3 class="litespeed-title"><?php echo __('Admin IP Query String Actions', 'litespeed-cache'); ?></h3>
20
-
21
- <h4><?php echo __('The following commands are available to the admin and do not require log-in, providing quick access to actions on the various pages.', 'litespeed-cache'); ?></h4>
22
-
23
- <h4><?php echo __('Action List:', 'litespeed-cache'); ?></h4>
24
-
25
- <ul>
26
- <li><?php echo LiteSpeed_Cache::ACTION_QS_NOCACHE; ?> - <?php echo $nocache_desc; ?></li>
27
- <li><?php echo LiteSpeed_Cache::ACTION_QS_PURGE; ?> - <?php echo $purge_desc; ?></li>
28
- <li><?php echo LiteSpeed_Cache::ACTION_QS_PURGE_SINGLE; ?> - <?php echo __('This is used to purge the first cache tag associated with the page.', 'litespeed-cache'); ?></li>
29
- <li><?php echo LiteSpeed_Cache::ACTION_QS_SHOW_HEADERS; ?> - <?php echo $showheaders_desc; ?></li>
30
- </ul>
31
-
32
- <h5><?php echo sprintf(__('To trigger the action for a page, access the page with the query string %s', 'litespeed-cache'),
33
- '<code>?'.LiteSpeed_Cache::ACTION_KEY.'=ACTION</code>'); ?></h5>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info_common_rewrite.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $notice_title = '';
5
- $notice_content = '';
6
-
7
- if ((is_multisite()) && (!is_network_admin())) {
8
- $notice_title = __('NOTE:', 'litespeed-cache');
9
- $notice_content =
10
- '<p>'.__('The following configuration can only be changed by the network admin.', 'litespeed-cache').'</p>'.
11
- '<p>'.__('Please contact the network admin to make any changes.', 'litespeed-cache').'</p>';
12
- }
13
- else {
14
- $notice_title = __('NOTICE:', 'litespeed-cache');
15
- $notice_content =
16
- '<p>'.
17
- __('The following rewrite rules can be configured in the LiteSpeed Cache settings page.', 'litespeed-cache').' '.
18
- __('Please make any needed changes on that page.', 'litespeed-cache').' '.
19
- __('It will automatically generate the correct rules in the htaccess file.', 'litespeed-cache').
20
- '</p>';
21
- }
22
- ?>
23
-
24
- <h3 class="litespeed-title"><?php echo __('LiteSpeed Cache Common Rewrite Rules', 'litespeed-cache'); ?></h3>
25
-
26
- <div class="litespeed-callout-warning">
27
- <h4><?php echo $notice_title; ?></h4>
28
- <?php echo $notice_content; ?>
29
- </div>
30
-
31
- <h4 class="litespeed-question litespeed-down"><?php echo __('Mobile Views:', 'litespeed-cache'); ?></h4>
32
- <div class="litespeed-answer">
33
- <p>
34
- <?php echo __('Some sites have adaptive views, meaning the page sent will adapt to the browser type (desktop vs mobile).', 'litespeed-cache'); ?>
35
- <?php echo __('This rewrite rule is used for sites that load a different page for each type.', 'litespeed-cache'); ?>
36
- </p>
37
- <p>
38
- <?php echo __('This configuration can be added on the settings page in the General tab.', 'litespeed-cache'); ?>
39
- </p>
40
- <textarea class="litespeed-textarea" rows="2" readonly>RewriteCond %{HTTP_USER_AGENT} Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi [NC]
41
- RewriteRule .* - [E=Cache-Control:vary=ismobile]</textarea>
42
- </div>
43
-
44
- <h4 class="litespeed-question litespeed-down"><?php echo __('Do Not Cache Cookies:', 'litespeed-cache'); ?></h4>
45
- <div class="litespeed-answer">
46
- <p><?php echo __('Another common rewrite rule is to notify the cache not to cache when it sees a specified cookie name.', 'litespeed-cache'); ?></p>
47
- <p><?php echo __('This configuration can be added on the settings page in the Do Not Cache tab.', 'litespeed-cache'); ?></p>
48
- <textarea class="litespeed-textarea" rows="2" readonly>RewriteCond %{HTTP_COOKIE} dontcachecookie
49
- RewriteRule .* - [E=Cache-Control:no-cache]</textarea>
50
- </div>
51
-
52
- <h4 class="litespeed-question litespeed-down"><?php echo __('Do Not Cache User Agent:', 'litespeed-cache'); ?></h4>
53
- <div class="litespeed-answer">
54
- <p><?php echo __('A not so commonly used rewrite rule is to notify the cache not to cache when it sees a specified User Agent.', 'litespeed-cache'); ?></p>
55
- <p><?php echo __('This configuration can be added on the settings page in the Do Not Cache tab.', 'litespeed-cache'); ?></p>
56
- <textarea class="litespeed-textarea" rows="2" readonly>RewriteCond %{HTTP_USER_AGENT} dontcacheuseragent
57
- RewriteRule .* - [E=Cache-Control:no-cache]</textarea>
58
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info_compatibility.php DELETED
@@ -1,57 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $known_compat = array(
5
- 'bbPress',
6
- 'WooCommerce',
7
- 'Contact Form 7',
8
- 'Google XML Sitemaps',
9
- 'Yoast SEO',
10
- 'Wordfence Security',
11
- 'NextGen Gallery',
12
- 'Aelia CurrencySwitcher',
13
- 'Fast Velocity Minify, thanks to Raul Peixoto',
14
- 'Autoptimize',
15
- 'Better WP Minify',
16
- 'WP Touch',
17
- 'Theme My Login',
18
- 'wpForo',
19
- 'WPLister',
20
- 'Avada',
21
- 'WP-PostRatings',
22
- );
23
-
24
- $known_uncompat = array();
25
-
26
- ?>
27
- <h3 class="litespeed-title"><?php echo __('LiteSpeed Cache Plugin Compatibility', 'litespeed-cache'); ?></h3>
28
-
29
- <p><a href="https://wordpress.org/support/topic/known-supported-plugins?replies=1" rel="noopener noreferrer" target="_blank"><?php echo __('Link Here', 'litespeed-cache'); ?></a></p>
30
- <p>
31
- <?php echo __('Please add a comment listing the plugins that you are using and how they are functioning on the support thread.', 'litespeed-cache'); ?>
32
- <?php echo __('With your help, we can provide the best WordPress caching solution.', 'litespeed-cache'); ?>
33
- </p>
34
-
35
- <h4><?php echo __('This is a list of plugins that are confirmed to be compatible with LiteSpeed Cache Plugin:', 'litespeed-cache'); ?></h4>
36
- <ul>
37
- <?php
38
- foreach ($known_compat as $plugin_name) {
39
- echo '<li>' . $plugin_name . '</li>';
40
- }
41
- ?>
42
- </ul>
43
-
44
- <h4><?php echo __('This is a list of known UNSUPPORTED plugins:', 'litespeed-cache'); ?></h4>
45
- <ul>
46
- <?php
47
- if($known_uncompat) {
48
- foreach ($known_uncompat as $plugin_name) {
49
- echo '<li>' . $plugin_name . '</li>';
50
- }
51
- }else{
52
- echo "<li>Nil</li>";
53
- }
54
- ?>
55
- </ul>
56
-
57
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info_config.php DELETED
@@ -1,68 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
- ?>
4
- <h3 class="litespeed-title"><?php echo __('LiteSpeed Cache Configuration', 'litespeed-cache'); ?></h3>
5
-
6
-
7
- <h4><?php echo __('Instructions for LiteSpeed Web Server Enterprise', 'litespeed-cache'); ?></h4>
8
- <p>
9
- <?php echo __('Make sure that the server license has the LSCache module enabled.', 'litespeed-cache'); ?>
10
- <?php echo sprintf(__('A <a %s>2-CPU trial license with LSCache module</a> is available for free for %d days.', 'litespeed-cache'),
11
- 'href="https://www.litespeedtech.com/products/litespeed-web-server/download/get-a-trial-license" rel="noopener noreferrer" target="_blank"', 15); ?>
12
- </p>
13
- <p>
14
- <?php echo __('The server must be configured to have caching enabled.', 'litespeed-cache'); ?>
15
- <?php echo sprintf(__('If you are the server admin, <a %s>click here.</a>', 'litespeed-cache'),
16
- 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:common_installation#web_server_configuration" rel="noopener noreferrer" target="_blank"'); ?>
17
- <?php echo __('Otherwise request that the server admin configure the cache root for the server.', 'litespeed-cache'); ?>
18
- </p>
19
- <p>
20
- <?php echo __('In the .htaccess file for the WordPress installation, add the following:', 'litespeed-cache'); ?>
21
- </p>
22
- <textarea class="litespeed-textarea" rows="3" readonly>&lt;IfModule LiteSpeed&gt;
23
- CacheLookup public on
24
- &lt;/IfModule&gt;</textarea>
25
-
26
-
27
- <h4><?php echo __('Instructions for OpenLiteSpeed', 'litespeed-cache'); ?></h4>
28
- <p><?php echo __('This integration utilizes OLS\'s cache module.', 'litespeed-cache'); ?></p>
29
- <p>
30
- <?php echo sprintf(__('If it is a fresh OLS installation, the easiest way to integrate is to use <a %s>ols1clk.</a>', 'litespeed-cache'),
31
- 'href="http://open.litespeedtech.com/mediawiki/index.php/Help:1-Click_Install" rel="noopener noreferrer" target="_blank"'); ?>
32
- <?php echo sprintf(__('If using an existing WordPress installation, use the %s parameter.', 'litespeed-cache'), '--wordpresspath'); ?>
33
- <?php echo sprintf(__('Else if OLS and WordPress are already installed, please follow the instructions <a %s>here.</a>', 'litespeed-cache'),
34
- 'href="http://open.litespeedtech.com/mediawiki/index.php/Help:How_To_Set_Up_LSCache_For_WordPress" rel="noopener noreferrer" target="_blank"'); ?>
35
- </p>
36
-
37
-
38
- <div class="litespeed-h3"><?php echo __('How to test the plugin', 'litespeed-cache'); ?></div>
39
- <p><?php echo __('The LiteSpeed Cache Plugin utilizes LiteSpeed specific response headers.', 'litespeed-cache'); ?></p>
40
- <p>
41
- <?php echo sprintf(__('Visiting a page for the first time should result in a %s or %s response header for the page.', 'litespeed-cache'),
42
- '<br><code>X-LiteSpeed-Cache-Control:miss</code><br>',
43
- '<br><code>X-LiteSpeed-Cache-Control:no-cache</code><br>'); ?>
44
- </p>
45
- <p>
46
- <?php echo sprintf(__('Subsequent requests should have the %s response header until the page is updated, expired, or purged.', 'litespeed-cache'), '<code>X-LiteSpeed-Cache-Control:hit</code><br>'); ?>
47
- </p>
48
- <p>
49
- <?php echo sprintf(__('Please visit <a %s>this page</a> for more information.', 'litespeed-cache'),
50
- 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:installation#testing" rel="noopener noreferrer" target="_blank"'); ?>
51
- </p>
52
-
53
- <div class="litespeed-h3"><?php echo __( 'Cache tag prefix setting', 'litespeed-cache' ) ; ?></div>
54
- <p>
55
- <?php echo sprintf(
56
- __( 'The value of this wordpress cache tag prefix is %1$s. If you want to change the value to avoid conflicts with multiple sites, please add %2$s to %3$s.', 'litespeed-cache' ),
57
- '<code>' . LSWCP_TAG_PREFIX . '</code>',
58
- '<code>define( "LSWCP_TAG_PREFIX", "YourUniqueStringHere" ) ;</code>',
59
- '<code>wp-config.php</code>'
60
- ) ; ?>
61
- </p>
62
-
63
-
64
-
65
-
66
-
67
-
68
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info_crawler.php DELETED
@@ -1,67 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
-
6
- <h3 class="litespeed-title">
7
- <?php echo __('Crawler Introduction', 'litespeed-cache'); ?>
8
- <a href="javascript:;" class="litespeed-expend" data-litespeed-expend-all="crawler">+</a>
9
- </h3>
10
-
11
- <h4 class="litespeed-question litespeed-down"><?php echo __('How Does the Crawler Work?', 'litespeed-cache'); ?></h4>
12
- <div class="litespeed-answer">
13
- <p><?php echo __('Using a sitemap as a guide, LSCache’s crawler, travels its way throughout the backend, refreshing pages that have expired in the cache. The purpose is to keep the cache as fresh as possible while minimizing visitor exposure to uncached content.', 'litespeed-cache'); ?></p>
14
-
15
- <p><?php echo __('The sitemap can be generated by the crawler, or you can provide your own custom map.', 'litespeed-cache'); ?></p>
16
-
17
- <p><?php echo sprintf(__('To learn more about each of the crawler settings, see <a %s>our wiki - Crawler Settings</a>.', 'litespeed-cache'), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration#crawler_settings" target="_blank"'); ?></p>
18
- </div>
19
-
20
-
21
- <h4 class="litespeed-question litespeed-down"><?php echo __('Should I Enable the Crawler?', 'litespeed-cache'); ?></h4>
22
- <div class="litespeed-answer">
23
- <p><?php echo __('Not every site needs a crawler.', 'litespeed-cache'); ?></p>
24
-
25
- <p><?php echo __('In WordPress, the first visitor to an uncached page waits for the page to be dynamically-generated and served, and the page is then cached for subsequent visitors.', 'litespeed-cache'); ?></p>
26
-
27
- <p><?php echo __('The LSCache crawler makes the first visitor’s experience better by essentially becoming the first visitor. The crawler caches the page, and the visitor who would have been first is spared the wait. As such, the crawler realistically only benefits the first out of the many users who visit that page before it expires. If you have a small user base, then crawling impacts a greater percentage of your visitors than it would on a site that draws a large crowd.', 'litespeed-cache'); ?></p>
28
-
29
- <p><?php echo __('You should weigh this benefit against your server’s resources. If resources are plentiful, then the crawler is a nice thing to have.', 'litespeed-cache'); ?></p>
30
-
31
- <p><?php echo __('If your site is busy, you’ll find that commonly-visited pages are quickly re-cached by new visitors, without the aid of a crawler. An extra crawler task would compete for server resources while delivering minimal benefits.', 'litespeed-cache'); ?></p>
32
-
33
- <p><?php echo __('The decision to use a crawler depends on the busy-ness of the site and the availability of server resources. Ultimately, it is the hosting provider who can best make this call.', 'litespeed-cache'); ?></p>
34
- </div>
35
-
36
-
37
-
38
- <h4 class="litespeed-question litespeed-down"><?php echo __('Enabling the Crawler', 'litespeed-cache'); ?></h4>
39
- <div class="litespeed-answer">
40
- <p><?php echo __('Due to the potential of the crawler to consume considerable resources, we have put the on/off switch in the hands of the server administrators. The crawler is disabled by default and can only be enabled by an admin.', 'litespeed-cache'); ?></p>
41
-
42
- <p><?php echo sprintf(__('Instructions for enabling the crawler can be found in <a %s>our wiki - Enabling the Crawler</a>. If you do not have access to server configuration files or virtual host include files, you will need to ask your web host for assistance.', 'litespeed-cache'), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:enabling_the_crawler" target="_blank"'); ?></p>
43
- </div>
44
-
45
-
46
-
47
- <h4 class="litespeed-question litespeed-down"><?php echo __('Testing the Crawler', 'litespeed-cache'); ?></h4>
48
- <div class="litespeed-answer">
49
- <p><?php echo __('To determine whether the crawler is working as expected, you can test it with a single URL.', 'litespeed-cache'); ?></p>
50
-
51
- <ul>
52
- <li>
53
- <?php echo __('Pick a URL from your sitemap and purge it:', 'litespeed-cache'); ?><br />
54
- <?php echo __('Navigate to <b>LiteSpeed Cache > Manage > Purge By… > URL</b> and enter the full URL in the text box.', 'litespeed-cache'); ?>
55
- </li>
56
- <li>
57
- <?php echo __('Manually run the crawler:', 'litespeed-cache'); ?><br />
58
- <?php echo __('Navigate to <b>LiteSpeed Cache > Crawler</b>, make sure <b>Activation</b> is set to Enable, and press the <b>Manually run</b> button. Wait for it to finish.', 'litespeed-cache'); ?>
59
- </li>
60
- <li>
61
- <?php echo __('See if the purged URL was cached during the crawl:', 'litespeed-cache'); ?><br />
62
- <?php echo __('Turn on your browser’s Developer Tool/Inspector. Visit the URL that should have been crawled. Select the <b>Network</b> tab in the inspector, select the page request (the URL we just visited - it should be the first entry in the list), and select the <b>Header</b> tab. If the URL was crawled correctly, you will see the response header X-LiteSpeed-Cache: hit.', 'litespeed-cache'); ?>
63
- </li>
64
- </ul>
65
- </div>
66
-
67
- <h5><?php echo sprintf(__('If you don’t see X-LiteSpeed-Cache: hit, and you can’t figure out why the crawler didn’t cache the purged URL, you can visit <a %s>our support forum</a> for help.', 'litespeed-cache'), 'href="https://wordpress.org/support/plugin/litespeed-cache" target="_blank"'); ?></h5>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info_faqs.php DELETED
@@ -1,110 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
- ?>
4
- <h3 class="litespeed-title">
5
- <?php echo __('LiteSpeed Cache FAQs', 'litespeed-cache'); ?>
6
- <a href="javascript:;" class="litespeed-expend" data-litespeed-expend-all="faqs">+</a>
7
- </h3>
8
-
9
- <h4 class="litespeed-question litespeed-down"><?php echo __('Is the LiteSpeed Cache Plugin for WordPress free?', 'litespeed-cache'); ?></h4>
10
- <div class="litespeed-answer">
11
- <p>
12
- <?php echo __('Yes, the plugin itself will remain free and open source.', 'litespeed-cache'); ?>
13
- <?php echo __('That said, a LiteSpeed server is required (see question 2)', 'litespeed-cache'); ?>
14
- </p>
15
- </div>
16
-
17
- <h4 class="litespeed-question litespeed-down"><?php echo __('What server software is required for this plugin?', 'litespeed-cache'); ?></h4>
18
- <div class="litespeed-answer">
19
- <p><?php echo __('A LiteSpeed server is required in order to use this plugin.', 'litespeed-cache'); ?></p>
20
- <ol>
21
- <li>LiteSpeed Web Server Enterprise with LSCache Module (v5.0.10+)</li>
22
- <li>OpenLiteSpeed (v1.4.17+)</li>
23
- <li>LiteSpeed WebADC (v2.0+)</li>
24
- </ol>
25
- <p><?php echo __('Any single server or cluster including a LiteSpeed server will work.', 'litespeed-cache'); ?>
26
- </div>
27
-
28
- <h4 class="litespeed-question litespeed-down"><?php echo __('Does this plugin work in a clustered environment?', 'litespeed-cache'); ?></h4>
29
- <div class="litespeed-answer">
30
- <p>
31
- <?php echo __('The cache entries are stored at the litespeed server level.', 'litespeed-cache'); ?>
32
- <?php echo __('The simplest solution is to use LiteSpeed WebADC, as the cache entries will be cached at that level.', 'litespeed-cache'); ?>
33
- </p>
34
- <p>
35
- <?php echo __('If using another load balancer, the cache entries will only be stored at the backend nodes, not at the load balancer.', 'litespeed-cache'); ?>
36
- <?php echo __('The purges will also not be synchronized across the nodes, so this is not recommended.', 'litespeed-cache'); ?>
37
- </p>
38
- <p>
39
- <?php echo sprintf(__('If a customized solution is required, please contact %s at %s', 'litespeed-cache'),
40
- 'LiteSpeed Technologies', 'info@litespeedtech.com'); ?>
41
- </p>
42
- <p><?php echo __('NOTICE: The rewrite rules created by this plugin must be copied to the WebADC', 'litespeed-cache'); ?></p>
43
- </div>
44
-
45
- <h4 class="litespeed-question litespeed-down"><?php echo __('Where are the cache entries stored?', 'litespeed-cache'); ?></h4>
46
- <div class="litespeed-answer">
47
- <p><?php echo __('The actual cached pages are stored and managed by LiteSpeed Servers. Nothing is stored on the PHP side.', 'litespeed-cache'); ?></p>
48
- </div>
49
-
50
- <h4 class="litespeed-question litespeed-down"><?php echo __('Is WooCommerce supported?', 'litespeed-cache'); ?></h4>
51
- <div class="litespeed-answer">
52
- <p>
53
- <?php echo __('In short, yes.', 'litespeed-cache'); ?>
54
- <?php echo __('However, for some woocommerce themes, the cart may not be updated correctly.', 'litespeed-cache'); ?>
55
- </p>
56
- <p><b><?php echo __('To test the cart:', 'litespeed-cache'); ?></b></p>
57
- <ul>
58
- <li><?php echo __('On a non-logged-in browser, visit and cache a page, then visit and cache a product page.', 'litespeed-cache'); ?></li>
59
- <li><?php echo __('The first page should be accessible from the product page (e.g. the shop).', 'litespeed-cache'); ?></li>
60
- <li><?php echo __('Once both pages are confirmed cached, add the product to the cart.', 'litespeed-cache'); ?></li>
61
- <li><?php echo __('After adding to the cart, visit the first page.', 'litespeed-cache'); ?></li>
62
- <li><?php echo __('The page should still be cached, and the cart should be up to date.', 'litespeed-cache'); ?></li>
63
- <li><?php echo __('If that is not the case, please add woocommerce_items_in_cart to the do not cache cookie list.', 'litespeed-cache'); ?></li>
64
- </ul>
65
- <p>
66
- <?php echo __('Some themes like Storefront and Shop Isle are built such that the cart works without the rule.', 'litespeed-cache'); ?>
67
- <?php echo __('However, other themes like the E-Commerce theme, do not, so please verify the theme used.', 'litespeed-cache'); ?>
68
- </p>
69
- </div>
70
-
71
- <h4 class="litespeed-question litespeed-down"><?php echo __('Are my images optimized?', 'litespeed-cache'); ?></h4>
72
- <div class="litespeed-answer">
73
- <p>
74
- <?php echo __('The cache plugin does not do anything with the images themselves.', 'litespeed-cache'); ?>
75
- <?php echo sprintf(__('We recommend you trying an image optimization plugin like %s to optimize your images.', 'litespeed-cache'),
76
- '<a href="https://shortpixel.com/h/af/CXNO4OI28044" rel="friend noopener noreferer" target="_blank">ShortPixel</a>'); ?>
77
- <?php echo __("It can reduce your site's images up to 90%.", 'litespeed-cache'); ?>
78
- </p>
79
- </div>
80
-
81
- <h4 class="litespeed-question litespeed-down"><?php echo __('How do I get WP-PostViews to display an updating view count?', 'litespeed-cache'); ?></h4>
82
- <div class="litespeed-answer">
83
- <ol>
84
- <li><?php echo sprintf(__('Use %1$s to replace %2$s', 'litespeed-cache'),
85
- '<code>&lt;div id="postviews_lscwp"&gt;&lt;/div&gt;</code>',
86
- '<code>&lt;?php if(function_exists(\'the_views\')) { the_views(); } ?&gt;</code>'); ?>
87
- <ul>
88
- <li><?php echo __('NOTE: The id can be changed, but the div id and the ajax function must match.', 'litespeed-cache'); ?></li>
89
- </ul>
90
- </li>
91
- <li><?php echo sprintf(__('Replace the ajax query in %1$s with %2$s', 'litespeed-cache'),
92
- '<code>wp-content/plugins/wp-postviews/postviews-cache.js</code>',
93
- '<br /><textarea class="litespeed-textarea" rows="11" readonly>jQuery.ajax({
94
- type:"GET",
95
- url:viewsCacheL10n.admin_ajax_url,
96
- data:"postviews_id="+viewsCacheL10n.post_id+"&amp;action=postviews",
97
- cache:!1,
98
- success:function(data) {
99
- if(data) {
100
- jQuery(\'#postviews_lscwp\').html(data+\' views\');
101
- }
102
- }
103
- });</textarea>'); ?>
104
- </li>
105
- <li>
106
- <?php echo __('Purge the cache to use the updated pages.', 'litespeed-cache'); ?>
107
- </li>
108
- </ol>
109
- </div>
110
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/manage.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- LiteSpeed_Cache_Admin_Display::get_instance()->check_license();
5
-
6
- $menu_list = array(
7
- 'purge' => __('Purge', 'litespeed-cache'),
8
- 'db' => __('DB Optimizer', 'litespeed-cache'),
9
- ) ;
10
-
11
- ?>
12
-
13
- <div class="wrap">
14
- <h2>
15
- <?php
16
- if ( is_network_admin() ) {
17
- echo __('LiteSpeed Cache Network Management', 'litespeed-cache');
18
- }
19
- else {
20
- echo __('LiteSpeed Cache Management', 'litespeed-cache');
21
- }
22
- ?>
23
- <span class="litespeed-desc">
24
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION ; ?>
25
- </span>
26
- </h2>
27
- </div>
28
- <div class="litespeed-wrap">
29
- <h2 class="litespeed-header">
30
- <?php
31
- $i = 1 ;
32
- foreach ($menu_list as $tab => $val){
33
- $accesskey = $i <= 9 ? "litespeed-accesskey='$i'" : '' ;
34
- echo "<a class='litespeed-tab' href='#$tab' data-litespeed-tab='$tab' $accesskey>$val</a>" ;
35
- $i ++ ;
36
- }
37
- ?>
38
- </h2>
39
-
40
- <?php if ( ! defined( 'LITESPEED_ON' ) ) : ?>
41
- <div class="litespeed-callout-warning">
42
- <h4><?php echo __('WARNING: LiteSpeed cache is disabled. The functionalities here can not work.', 'litespeed-cache'); ?></h4>
43
- </div>
44
- <?php endif ; ?>
45
-
46
- <div class="litespeed-body">
47
- <?php
48
-
49
- // include all tpl for faster UE
50
- foreach ($menu_list as $tab => $val) {
51
- echo "<div data-litespeed-layout='$tab'>" ;
52
- require LSWCP_DIR . "admin/tpl/manage_$tab.php" ;
53
- echo "</div>" ;
54
- }
55
-
56
- ?>
57
- </div>
58
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/manage_db.php DELETED
@@ -1,85 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- $_panels = array(
5
- 'all' => array(
6
- 'title' => __( 'Clean All', 'litespeed-cache' ),
7
- 'desc' => '',
8
- ),
9
- 'revision' => array(
10
- 'title' => __( 'Post Revisions', 'litespeed-cache' ),
11
- 'desc' => __( 'Clean all post revisions', 'litespeed-cache' ),
12
- ),
13
- 'auto_draft' => array(
14
- 'title' => __( 'Auto Drafts', 'litespeed-cache' ),
15
- 'desc' => __( 'Clean all auto saved drafts', 'litespeed-cache' ),
16
- ),
17
- 'trash_post' => array(
18
- 'title' => __( 'Trashed Posts', 'litespeed-cache' ),
19
- 'desc' => __( 'Clean all trashed posts and pages', 'litespeed-cache' ),
20
- ),
21
- 'spam_comment' => array(
22
- 'title' => __( 'Spam Comments', 'litespeed-cache' ),
23
- 'desc' => __( 'Clean all spam comments', 'litespeed-cache' ),
24
- ),
25
- 'trash_comment' => array(
26
- 'title' => __( 'Trashed Comments', 'litespeed-cache' ),
27
- 'desc' => __( 'Clean all trashed comments', 'litespeed-cache' ),
28
- ),
29
- 'trackback-pingback' => array(
30
- 'title' => __( 'Trackbacks/Pingbacks', 'litespeed-cache' ),
31
- 'desc' => __( 'Clean all trackbacks and pingbacks', 'litespeed-cache' ),
32
- ),
33
- 'expired_transient' => array(
34
- 'title' => __( 'Expired Transients', 'litespeed-cache' ),
35
- 'desc' => __( 'Clean expired transient options', 'litespeed-cache' ),
36
- ),
37
- 'all_transients' => array(
38
- 'title' => __( 'All Transients', 'litespeed-cache' ),
39
- 'desc' => __( 'Clean all transient options', 'litespeed-cache' ),
40
- ),
41
- 'optimize_tables' => array(
42
- 'title' => __( 'Optimize Tables', 'litespeed-cache' ),
43
- 'desc' => __( 'Optimize all tables in your database', 'litespeed-cache' ),
44
- ),
45
- ) ;
46
-
47
- $total = 0 ;
48
- foreach ( $_panels as $tag => $val ) {
49
- if ( $tag != 'all' ) {
50
- $_panels[ $tag ][ 'count' ] = LiteSpeed_Cache_Admin_Optimize::db_count( $tag ) ;
51
- if ( $tag != 'optimize_tables' ) {
52
- $total += $_panels[ $tag ][ 'count' ] ;
53
- }
54
- }
55
- $_panels[ $tag ][ 'link' ] = LiteSpeed_Cache_Admin_Optimize::generate_url( $tag ) ;
56
- }
57
-
58
- $_panels[ 'all' ][ 'count' ] = $total ;
59
-
60
- ?>
61
-
62
- <h3 class="litespeed-title"><?php echo __('Database Optimizer', 'litespeed-cache'); ?></h3>
63
-
64
- <div class="litespeed-panel-wrapper">
65
-
66
- <?php foreach ( $_panels as $tag => $val ): ?>
67
-
68
- <a href="<?php echo $val[ 'link' ] ; ?>" class="litespeed-panel">
69
- <section class="litespeed-panel-wrapper-icon">
70
- <span class="litespeed-panel-icon-<?php echo $tag ; ?>"></span>
71
- </section>
72
- <section class="litespeed-panel-content">
73
- <div class="litespeed-h3">
74
- <?php echo $val[ 'title' ] ; ?>
75
- <span class="litespeed-panel-counter<?php if ( $val[ 'count' ] > 0 ) echo '-red' ; ?>">(<?php echo $val[ 'count' ] ; ?>)</span>
76
- </div>
77
- <span class="litespeed-panel-para"><?php echo $val[ 'desc' ] ; ?></span>
78
- </section>
79
- <section class="litespeed-panel-wrapper-top-right">
80
- <span class="litespeed-panel-top-right-icon<?php echo $val[ 'count' ] > 0 ? '-cross' : '-tick' ; ?>"></span>
81
- </section>
82
- </a>
83
- <?php endforeach; ?>
84
-
85
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/manage_purge.php DELETED
@@ -1,187 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
-
5
- $_panels = array(
6
- array(
7
- 'title' => __( 'Purge Front Page', 'litespeed-cache' ),
8
- 'desc' => __( 'This will Purge Front Page only', 'litespeed-cache' ),
9
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_FRONT,
10
- 'icon' => 'purge-front',
11
- ),
12
- array(
13
- 'title' => __( 'Purge Pages', 'litespeed-cache' ),
14
- 'desc' => __( 'This will Purge Pages only', 'litespeed-cache' ),
15
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_PAGES,
16
- 'icon' => 'purge-pages',
17
- ),
18
- array(
19
- 'title' => __( 'Purge CSS/JS Cache', 'litespeed-cache' ),
20
- 'desc' => __( 'This will purge all minified/combined CSS/JS entries only', 'litespeed-cache' ),
21
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_CSSJS,
22
- 'icon' => 'purge-cssjs',
23
- ),
24
- array(
25
- 'title' => __( 'Purge 403 Error', 'litespeed-cache' ),
26
- 'desc' => __( 'Purge error pages, including 403 pages', 'litespeed-cache' ),
27
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
28
- 'icon' => 'purge-403',
29
- 'append_url' => 'lserr=403',
30
- ),
31
- array(
32
- 'title' => __( 'Purge 404 Error', 'litespeed-cache' ),
33
- 'desc' => __( 'Purge error pages, including 404 pages', 'litespeed-cache' ),
34
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
35
- 'icon' => 'purge-404',
36
- 'append_url' => 'lserr=404',
37
- ),
38
- array(
39
- 'title' => __( 'Purge 500 Error', 'litespeed-cache' ),
40
- 'desc' => __( 'Purge error pages, including 500 pages', 'litespeed-cache' ),
41
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
42
- 'icon' => 'purge-500',
43
- 'append_url' => 'lserr=500',
44
- ),
45
- array(
46
- 'title' => __( 'Purge All', 'litespeed-cache' ),
47
- 'desc' => __( 'Purge the cache entries created by this plugin', 'litespeed-cache' ),
48
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_ALL,
49
- 'icon' => 'purge-all',
50
- 'title_cls' => 'litespeed-warning',
51
- 'cfm' => is_multisite() && is_network_admin() ?
52
- esc_html( __( 'This will purge everything for all blogs.', 'litespeed-cache' ) ) . ' ' .
53
- esc_html( __( 'Are you sure you want to purge all?', 'litespeed-cache' ) )
54
- :
55
- esc_html( __( 'Are you sure you want to purge all?', 'litespeed-cache' ) )
56
- ),
57
- ) ;
58
-
59
- if ( ! is_multisite() || is_network_admin() ) {
60
- $_panels[] = array(
61
- 'title' => __( 'Empty Entire Cache', 'litespeed-cache' ),
62
- 'desc' => __( 'Clears all cache entries related to this site, <i>including other web applications</i>.', 'litespeed-cache' ) . ' <b>' .
63
- __('This action should only be used if things are cached incorrectly.', 'litespeed-cache') . '</b>',
64
- 'tag' => LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE,
65
- 'icon' => 'empty-cache',
66
- 'title_cls' => 'litespeed-danger',
67
- 'cfm' => esc_html( __( 'This will clear EVERYTHING inside the cache.', 'litespeed-cache' ) ) . ' ' .
68
- esc_html( __( 'This may cause heavy load on the server.', 'litespeed-cache' ) ) . ' ' .
69
- esc_html( __( 'If only the WordPress site should be purged, use purge all.', 'litespeed-cache' ) )
70
- ) ;
71
- }
72
-
73
- ?>
74
-
75
- <h3 class="litespeed-title"><?php echo __('Purge', 'litespeed-cache'); ?></h3>
76
-
77
- <div class="litespeed-panel-wrapper">
78
-
79
- <?php foreach ( $_panels as $val ): ?>
80
-
81
- <a class="litespeed-panel"
82
- href="<?php echo LiteSpeed_Cache_Utility::build_url( $val[ 'tag' ], false, ! empty( $val[ 'append_url' ] ) ? $val[ 'append_url' ] : false ) ; ?>"
83
- <?php if ( ! empty( $val[ 'cfm' ] ) ) echo 'data-litespeed-cfm="' . $val[ 'cfm' ] . '"' ; ?>
84
- >
85
- <section class="litespeed-panel-wrapper-icon">
86
- <span class="litespeed-panel-icon-<?php echo $val[ 'icon' ] ; ?>"></span>
87
- </section>
88
- <section class="litespeed-panel-content">
89
- <div class="litespeed-h3 <?php if ( ! empty( $val[ 'title_cls' ] ) ) echo $val[ 'title_cls' ] ; ?>">
90
- <?php echo $val[ 'title' ] ; ?>
91
- </div>
92
- <span class="litespeed-panel-para"><?php echo $val[ 'desc' ] ; ?></span>
93
- </section>
94
- </a>
95
-
96
- <?php endforeach; ?>
97
-
98
- </div>
99
-
100
- <?php if (!is_multisite() || !is_network_admin()): ?>
101
-
102
- <div class="litespeed-title"><?php echo __('Purge By...', 'litespeed-cache'); ?></div>
103
- <div class="litespeed-desc">
104
- <?php echo __('Select below for "Purge by" options.', 'litespeed-cache'); ?>
105
- <?php echo __('Please enter one per line.', 'litespeed-cache'); ?>
106
- </div>
107
-
108
- <?php
109
- $purgeby_option = false;
110
- $_option_field = LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT;
111
- if(!empty($_REQUEST[$_option_field])){
112
- $purgeby_option = $_REQUEST[$_option_field];
113
- }
114
- if( !in_array($purgeby_option, array(
115
- LiteSpeed_Cache_Admin_Display::PURGEBY_CAT,
116
- LiteSpeed_Cache_Admin_Display::PURGEBY_PID,
117
- LiteSpeed_Cache_Admin_Display::PURGEBY_TAG,
118
- LiteSpeed_Cache_Admin_Display::PURGEBY_URL,
119
- )) ) {
120
- $purgeby_option = LiteSpeed_Cache_Admin_Display::PURGEBY_CAT;
121
- }
122
- ?>
123
-
124
- <form method="post" action="admin.php?page=lscache-dash">
125
- <?php $this->form_action(LiteSpeed_Cache::ACTION_PURGE_BY); ?>
126
- <div class="litespeed-row">
127
- <div class="litespeed-switch litespeed-mini">
128
- <?php $val = LiteSpeed_Cache_Admin_Display::PURGEBY_CAT;?>
129
- <input type="radio" name="<?php echo $_option_field; ?>" id="purgeby_option_category"
130
- value="<?php echo $val; ?>" <?php if( $purgeby_option == $val ) echo 'checked'; ?>
131
- />
132
- <label for="purgeby_option_category"><?php echo __('Category', 'litespeed-cache'); ?></label>
133
-
134
- <?php $val = LiteSpeed_Cache_Admin_Display::PURGEBY_PID;?>
135
- <input type="radio" name="<?php echo $_option_field; ?>" id="purgeby_option_postid"
136
- value="<?php echo $val; ?>" <?php if( $purgeby_option == $val ) echo 'checked'; ?>
137
- />
138
- <label for="purgeby_option_postid"><?php echo __('Post ID', 'litespeed-cache'); ?></label>
139
-
140
- <?php $val = LiteSpeed_Cache_Admin_Display::PURGEBY_TAG;?>
141
- <input type="radio" name="<?php echo $_option_field; ?>" id="purgeby_option_tag"
142
- value="<?php echo $val; ?>" <?php if( $purgeby_option == $val ) echo 'checked'; ?>
143
- />
144
- <label for="purgeby_option_tag"><?php echo __('Tag', 'litespeed-cache'); ?></label>
145
-
146
- <?php $val = LiteSpeed_Cache_Admin_Display::PURGEBY_URL;?>
147
- <input type="radio" name="<?php echo $_option_field; ?>" id="purgeby_option_url"
148
- value="<?php echo $val; ?>" <?php if( $purgeby_option == $val ) echo 'checked'; ?>
149
- />
150
- <label for="purgeby_option_url"><?php echo __('URL', 'litespeed-cache'); ?></label>
151
- </div>
152
-
153
- <div class="litespeed-cache-purgeby-text">
154
- <div class="<?php if($purgeby_option != LiteSpeed_Cache_Admin_Display::PURGEBY_CAT) echo 'litespeed-hide'; ?>"
155
- data-purgeby="<?php echo LiteSpeed_Cache_Admin_Display::PURGEBY_CAT; ?>">
156
- <?php echo sprintf(__('Purge pages by category name - e.g. %2$s should be used for the URL %1$s.', "litespeed-cache"),
157
- 'http://example.com/category/category-name/', 'category-name'); ?>
158
- </div>
159
- <div class="<?php if($purgeby_option != LiteSpeed_Cache_Admin_Display::PURGEBY_PID) echo 'litespeed-hide'; ?>"
160
- data-purgeby="<?php echo LiteSpeed_Cache_Admin_Display::PURGEBY_PID; ?>">
161
- <?php echo __("Purge pages by post ID.", "litespeed-cache"); ?>
162
- </div>
163
- <div class="<?php if($purgeby_option != LiteSpeed_Cache_Admin_Display::PURGEBY_TAG) echo 'litespeed-hide'; ?>"
164
- data-purgeby="<?php echo LiteSpeed_Cache_Admin_Display::PURGEBY_TAG; ?>">
165
- <?php echo sprintf(__('Purge pages by tag name - e.g. %2$s should be used for the URL %1$s.', "litespeed-cache"),
166
- 'http://example.com/tag/tag-name/', 'tag-name'); ?>
167
- </div>
168
- <div class="<?php if($purgeby_option != LiteSpeed_Cache_Admin_Display::PURGEBY_URL) echo 'litespeed-hide'; ?>"
169
- data-purgeby="<?php echo LiteSpeed_Cache_Admin_Display::PURGEBY_URL; ?>">
170
- <?php echo __('Purge pages by relative or full URL.', 'litespeed-cache'); ?>
171
- <?php echo sprintf(__('e.g. Use %s or %s.', 'litespeed-cache'),
172
- '<b><u>/2016/02/24/hello-world/</u></b>',
173
- '<b><u>http://www.myexamplesite.com/2016/02/24/hello-world/</u></b>'); ?>
174
- </div>
175
- </div>
176
-
177
- </div>
178
-
179
- <p>
180
- <textarea name="<?php echo LiteSpeed_Cache_Admin_Display::PURGEBYOPT_LIST; ?>" rows="5" class="litespeed-textarea"></textarea>
181
- </p>
182
-
183
- <p>
184
- <button type="submit" class="litespeed-btn-success"><?php echo __('Purge List', 'litespeed-cache'); ?></button>
185
- </p>
186
- </form>
187
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/network_settings.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $menuArr = array(
5
- 'general' => __('General', 'litespeed-cache'),
6
- 'cache' => __('Cache', 'litespeed-cache'),
7
- 'purge' => __('Purge', 'litespeed-cache'),
8
- 'excludes' => __('Excludes', 'litespeed-cache'),
9
- 'advanced' => __('Advanced', 'litespeed-cache'),
10
- );
11
-
12
- global $_options;
13
- $_options = LiteSpeed_Cache_Config::get_instance()->get_site_options();
14
-
15
- ?>
16
-
17
- <div class="wrap">
18
- <h2>
19
- <?php echo __('LiteSpeed Cache Network Settings', 'litespeed-cache'); ?>
20
- <span class="litespeed-desc">
21
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION; ?>
22
- </span>
23
- </h2>
24
- </div>
25
- <div class="litespeed-wrap">
26
- <h2 class="litespeed-header">
27
- <?php
28
- $i = 1 ;
29
- foreach ($menuArr as $tab => $val){
30
- $accesskey = $i <= 9 ? "litespeed-accesskey='$i'" : '' ;
31
- echo "<a class='litespeed-tab' href='#$tab' data-litespeed-tab='$tab' $accesskey>$val</a>";
32
- $i ++ ;
33
- }
34
- ?>
35
- </h2>
36
- <div class="litespeed-body">
37
- <form method="post" action="admin.php?page=lscache-settings" id="litespeed_form_options" class="litespeed-relative">
38
- <?php
39
- $this->form_action(LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK);
40
-
41
- // include all tpl for faster UE
42
- foreach ($menuArr as $tab => $val) {
43
- echo "<div data-litespeed-layout='$tab'>";
44
- if($tab == 'advanced') {
45
- require LSWCP_DIR . 'admin/tpl/settings_advanced.php';
46
- }else{
47
- require LSWCP_DIR . "admin/tpl/network_settings_$tab.php";
48
- }
49
- echo "</div>";
50
- }
51
-
52
- echo "<div class='litespeed-top20'></div>";
53
-
54
- submit_button();
55
-
56
- ?>
57
- </form>
58
- </div>
59
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/network_settings_cache.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
- ?>
4
- <h3 class="litespeed-title"><?php echo __( 'Cache Control Network Settings', 'litespeed-cache' ) ; ?></h3>
5
-
6
- <p>
7
- <?php echo __( 'Separate Mobile Views should be enabled if any of the network enabled themes require a different view for mobile devices.', 'litespeed-cache' ) ; ?>
8
- <?php echo __( 'Responsive themes can handle this part automatically.', 'litespeed-cache' ) ; ?>
9
- </p>
10
-
11
- <table><tbody>
12
-
13
- <?php require LSWCP_DIR . 'admin/tpl/settings_inc.cache_favicon.php' ; ?>
14
- <?php require LSWCP_DIR . 'admin/tpl/settings_inc.cache_resources.php' ; ?>
15
- <?php require LSWCP_DIR . 'admin/tpl/settings_inc.cache_mobile.php' ; ?>
16
- <?php require LSWCP_DIR . 'admin/tpl/settings_inc.cache_browser.php' ; ?>
17
-
18
- </tbody></table>
19
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/network_settings_excludes.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
- <h3 class="litespeed-title"><?php echo __('Network Do Not Cache Rules', 'litespeed-cache'); ?></h3>
6
-
7
- <table><tbody>
8
-
9
- <!-- User Agent List -->
10
- <?php require LSWCP_DIR . 'admin/tpl/settings_inc.exclude_useragent.php'; ?>
11
-
12
- <!-- Cookie List -->
13
- <?php require LSWCP_DIR . 'admin/tpl/settings_inc.exclude_cookies.php'; ?>
14
-
15
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/network_settings_general.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
- <h3 class="litespeed-title"><?php echo __('General Network Configuration', 'litespeed-cache'); ?></h3>
6
-
7
- <p><?php echo __('These configuration are only available network wide.', 'litespeed-cache'); ?></p>
8
-
9
- <table><tbody>
10
- <tr>
11
- <th><?php echo __('Network Enable Cache', 'litespeed-cache'); ?></th>
12
- <td>
13
- <?php $this->build_switch(LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED); ?>
14
- <div class="litespeed-desc">
15
- <?php echo __('Enabling LiteSpeed Cache for WordPress here enables the cache for the network.', 'litespeed-cache'); ?><br />
16
- <?php echo __('It is <b>STRONGLY</b> recommend that the compatibility with other plugins on a single/few sites is tested first.', 'litespeed-cache'); ?>
17
- <?php echo __('This is to ensure compatibility prior to enabling the cache for all sites.', 'litespeed-cache'); ?>
18
- </div>
19
- </td>
20
- </tr>
21
-
22
- <tr>
23
- <th><?php echo __('Use Primary Site Configuration', 'litespeed-cache'); ?></th>
24
- <td>
25
- <?php $this->build_switch(LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY); ?>
26
- <div class="litespeed-desc">
27
- <?php echo __("Check this option to use the primary site's configuration for all subsites.", 'litespeed-cache'); ?>
28
- <?php echo __('This will disable the settings page on all subsites.', 'litespeed-cache'); ?>
29
- </div>
30
- </td>
31
- </tr>
32
-
33
- </tbody></table>
34
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/network_settings_purge.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
- ?>
4
- <h3 class="litespeed-title"><?php echo __( 'Purge Network Settings', 'litespeed-cache' ) ; ?></h3>
5
-
6
- <table><tbody>
7
-
8
- <?php require LSWCP_DIR . 'admin/tpl/settings_inc.purge_on_upgrade.php' ; ?>
9
-
10
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
admin/tpl/report.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $report = LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report();
5
-
6
- ?>
7
-
8
- <div class="wrap">
9
- <h2>
10
- <?php echo __('LiteSpeed Cache Report', 'litespeed-cache'); ?>
11
- <span class="litespeed-desc">
12
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION; ?>
13
- </span>
14
- </h2>
15
- </div>
16
- <div class="litespeed-wrap">
17
- <div class="litespeed-body">
18
- <ul>
19
- <li><?php echo __('The environment report contains detailed information about the WordPress configuration.', 'litespeed-cache'); ?></li>
20
- <li><?php echo __('If you run into any issues, please include the contents of this text area in your support message.', 'litespeed-cache'); ?></li>
21
- <li><?php echo __('To easily grab the content, click the <b>Select All and Copy to Clipboard</b> button, to select and copy to clipboard.', 'litespeed-cache'); ?></li>
22
- <?php if ( is_writable(LSWCP_DIR) ): ?>
23
- <li><?php echo sprintf(__('Alternatively, this information is also saved in %s.', 'litespeed-cache'),
24
- LSWCP_CONTENT_FOLDER . '/plugins/litespeed-cache/environment_report.php'); ?></li>
25
- <?php endif; ?>
26
- </ul>
27
- <p>
28
- <b><?php echo __('The text area below contains the following content:', 'litespeed-cache'); ?></b>
29
- </p>
30
- <p>
31
- <span style="font-size:11px; font-style:italic">
32
- <?php echo __('Server Variables, Plugin Options, WordPress information (version, locale, active plugins, etc.), and .htaccess file content.', 'litespeed-cache'); ?>
33
- </span>
34
- </p>
35
- <p>
36
- <button class="litespeed-btn-success" id='litespeed_cache_report_copy'>
37
- <?php echo __("Select All and Copy to Clipboard", "litespeed-cache"); ?>
38
- </button>
39
- <span class="litespeed-hide" id="copy_select_all_span">
40
- <?php echo __("Environment Report copied to Clipboard!", "litespeed-cache"); ?>
41
- </span>
42
- </p>
43
- <textarea id="litespeed-report" rows="40" cols="80" readonly><?php echo $report; ?></textarea>
44
- </div>
45
- </div>
46
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings.php DELETED
@@ -1,148 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die ;
3
-
4
- $this->check_license() ;
5
-
6
- $menu_list = array(
7
- 'general' => __('General', 'litespeed-cache'),
8
- 'cache' => __('Cache', 'litespeed-cache'),
9
- 'purge' => __('Purge', 'litespeed-cache'),
10
- 'excludes' => __('Excludes', 'litespeed-cache'),
11
- 'optimize' => __('Optimize', 'litespeed-cache'),
12
- 'cdn' => __('CDN', 'litespeed-cache'),
13
- ) ;
14
-
15
- $menu_list['esi'] = __('ESI', 'litespeed-cache') ;
16
-
17
- if (!is_multisite()) {
18
- $menu_list['advanced'] = __('Advanced', 'litespeed-cache') ;
19
- }
20
-
21
- $menu_list['debug'] = __('Debug', 'litespeed-cache') ;
22
-
23
- if ($this->show_compatibility_tab()){
24
- $menu_list['compatibilities'] = __('Compatibilities', 'litespeed-cache') ;
25
- }
26
-
27
- $menu_list['crawler'] = __('Crawler', 'litespeed-cache') ;
28
-
29
- global $_options ;
30
- $_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
31
-
32
-
33
- /**
34
- * This hook allows third party plugins to create litespeed cache
35
- * specific configuration.
36
- *
37
- * Each config should append an array containing the following:
38
- * 'title' (required) - The tab's title.
39
- * 'slug' (required) - The slug used for the tab. [a-z][A-Z], [0-9], -, _ permitted.
40
- * 'content' (required) - The tab's content.
41
- *
42
- * Upon saving, only the options with the option group in the input's
43
- * name will be retrieved.
44
- * For example, name="litespeed-cache-conf[my-opt]".
45
- *
46
- * @see TODO: add option save filter.
47
- * @since 1.0.9
48
- * @param array $tabs An array of third party configuration.
49
- * @param array $options The current configuration options.
50
- * @param string $option_group The option group to use for options.
51
- * @param boolean $disableall Whether to disable the settings or not.
52
- * @return mixed An array of third party configs else false on failure.
53
- */
54
- $tp_tabs = apply_filters('litespeed_cache_add_config_tab',
55
- array(),
56
- $_options,
57
- LiteSpeed_Cache_Config::OPTION_NAME,
58
- $this->get_disable_all()
59
- ) ;
60
- if ( !empty($tp_tabs) && is_array($tp_tabs) ) {
61
- foreach ($tp_tabs as $key => $tab) {
62
- if ( !is_array($tab) || !isset($tab['title']) || !isset($tab['slug']) || !isset($tab['content']) ) {
63
- if (LiteSpeed_Cache_Log::get_enabled()) {
64
- LiteSpeed_Cache_Log::push(__('WARNING: Third party tab input invalid.', 'litespeed-cache')) ;
65
- }
66
- unset($tp_tabs[$key]) ;
67
- continue ;
68
- }
69
- if ( preg_match('/[^-\w]/', $tab['slug']) ) {
70
- if (LiteSpeed_Cache_Log::get_enabled()) {
71
- LiteSpeed_Cache_Log::push(__('WARNING: Third party config slug contains invalid characters.', 'litespeed-cache')) ;
72
- }
73
- unset($tp_tabs[$key]) ;
74
- continue ;
75
- }
76
- }
77
- }
78
- else {
79
- $tp_tabs = array() ;
80
- }
81
-
82
-
83
- ?>
84
- <div class="wrap">
85
- <h2>
86
- <?php echo __('LiteSpeed Cache Settings', 'litespeed-cache') ; ?>
87
- <span class="litespeed-desc">
88
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION ; ?>
89
- </span>
90
- </h2>
91
- </div>
92
- <div class="litespeed-wrap">
93
- <h2 class="litespeed-header">
94
- <?php
95
- $i = 1 ;
96
- foreach ($menu_list as $tab => $val){
97
- $accesskey = $i <= 9 ? "litespeed-accesskey='$i'" : '' ;
98
- echo "<a class='litespeed-tab' href='#$tab' data-litespeed-tab='$tab' $accesskey>$val</a>" ;
99
- $i ++ ;
100
- }
101
- foreach ($tp_tabs as $val){
102
- $accesskey = $i <= 9 ? "litespeed-accesskey='$i'" : '' ;
103
- echo "<a class='litespeed-tab' href='#$val[slug]' data-litespeed-tab='$val[slug]' $accesskey>$val[title]</a>" ;
104
- $i ++ ;
105
- }
106
- ?>
107
- </h2>
108
- <div class="litespeed-body">
109
- <form method="post" action="options.php" id="litespeed_form_options" class="litespeed-relative">
110
- <!--input type="hidden" name="<?php echo LiteSpeed_Cache::ACTION_KEY ; ?>" value="<?php echo LiteSpeed_Cache::ACTION_SAVE_SETTINGS ; ?>" /-->
111
-
112
- <?php if ($this->get_disable_all()): ?>
113
- <div class="litespeed-callout-danger">
114
- <h4><?php echo __( 'WARNING', 'litespeed-cache' ) ; ?></h4>
115
- <p>
116
- <?php echo __('The network admin selected use primary site configs for all subsites.', 'litespeed-cache') ; ?>
117
- <?php echo __('The following options are selected, but are not editable in this settings page.', 'litespeed-cache') ; ?>
118
- </p>
119
- </div>
120
- <?php endif ; ?>
121
-
122
- <?php
123
- settings_fields(LiteSpeed_Cache_Config::OPTION_NAME) ;
124
-
125
- // include all tpl for faster UE
126
- foreach ($menu_list as $tab => $val) {
127
- echo "<div data-litespeed-layout='$tab'>" ;
128
- require LSWCP_DIR . "admin/tpl/settings_$tab.php" ;
129
- echo "</div>" ;
130
- }
131
-
132
- foreach ($tp_tabs as $val) {
133
- echo "<div data-litespeed-layout='$val[slug]'>$val[content]</div>" ;
134
- }
135
-
136
- echo "<div class='litespeed-top20'></div>" ;
137
-
138
- if ( $this->get_disable_all() ) {
139
- submit_button(__('Save Changes', 'litespeed-cache'), 'litespeed-btn-primary', 'litespeed-submit', true, array('disabled' => true)) ;
140
- }
141
- else {
142
- submit_button(__('Save Changes', 'litespeed-cache'), 'litespeed-btn-primary', 'litespeed-submit') ;
143
- }
144
-
145
- ?>
146
- </form>
147
- </div>
148
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_advanced.php DELETED
@@ -1,80 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
- <div class="litespeed-callout-danger">
6
- <h4><?php echo __('NOTICE:', 'litespeed-cache'); ?></h4>
7
- <ol>
8
- <li><?php echo __('These settings are meant for ADVANCED USERS ONLY.', 'litespeed-cache'); ?></li>
9
- <li><?php echo __('Please take great care when changing any of these settings.', 'litespeed-cache'); ?></li>
10
- <li><?php echo __('If there are any questions, do not hesitate to submit a support thread.', 'litespeed-cache'); ?></li>
11
- </ol>
12
- </div>
13
-
14
- <h3 class="litespeed-title"><?php echo __('Check Advanced Cache', 'litespeed-cache'); ?></h3>
15
- <?php
16
- $id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE;
17
- $this->build_checkbox($id, __('Include advanced-cache.php', 'litespeed-cache'), $_options[$id]);
18
- ?>
19
- <p>
20
- <?php echo __('The advanced-cache.php file is used by many caching plugins to signal that a cache is active.', 'litespeed-cache'); ?>
21
- <?php echo __('When this option is checked and this file is detected as belonging to another plugin, LiteSpeed Cache will not cache.', 'litespeed-cache'); ?>
22
- </p>
23
- <p>
24
- <i><?php echo __('Uncheck this option only if the other plugin is used for non-caching purposes, such as minifying css/js files.', 'litespeed-cache'); ?></i>
25
- </p>
26
-
27
- <h3 class="litespeed-title"><?php echo __('Login Cookie', 'litespeed-cache'); ?></h3>
28
- <?php
29
-
30
- echo '<p>' . __('SYNTAX: alphanumeric and "_".', 'litespeed-cache')
31
- . ' ' . __('No spaces and case sensitive.', 'litespeed-cache')
32
- . ' ' . __('MUST BE UNIQUE FROM OTHER WEB APPLICATIONS.', 'litespeed-cache')
33
- . '</p>'
34
- . '<p>'
35
- . sprintf(__('The default login cookie is %s.', 'litespeed-cache'), '_lscache_vary')
36
- . ' ' . __('The server will determine if the user is logged in based on the existance of this cookie.', 'litespeed-cache')
37
- . ' ' . __('This setting is useful for those that have multiple web applications for the same domain.', 'litespeed-cache')
38
- . ' ' . __('If every web application uses the same cookie, the server may confuse whether a user is logged in or not.', 'litespeed-cache')
39
- . ' ' . __('The cookie set here will be used for this WordPress installation.', 'litespeed-cache')
40
- . '</p>'
41
- . '<p>'
42
- . __('Example use case:', 'litespeed-cache')
43
- . '<br />'
44
- . sprintf(__('There is a WordPress installed for %s.', 'litespeed-cache'), '<u>www.example.com</u>')
45
- . '<br />'
46
- . sprintf(__('Then another WordPress is installed (NOT MULTISITE) at %s', 'litespeed-cache'), '<u>www.example.com/blog/</u>')
47
- . ' ' . __('The cache needs to distinguish who is logged into which WordPress site in order to cache correctly.', 'litespeed-cache')
48
- . '</p>';
49
-
50
- $cookie_rule = LiteSpeed_Cache_Admin_Rules::get_instance()->get_rewrite_rule_login_cookie();
51
- if ( $cookie_rule && substr($cookie_rule, 0, 11) !== 'Cache-Vary:' ){
52
- echo '<div class="litespeed-callout-danger">'
53
- . sprintf(__('Error: invalid login cookie. Please check the %s file', 'litespeed-cache'), '.htaccess')
54
- . '</div>';
55
- }
56
-
57
- $id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE;
58
- if ( defined( 'LITESPEED_ON' ) && $_options[$id] ){
59
-
60
- if (!$cookie_rule){
61
- echo '<div class="litespeed-callout-danger">'
62
- . sprintf(__('Error getting current rules from %s: %s', 'litespeed-cache'), '.htaccess', LiteSpeed_Cache_Admin_Rules::MARKER_LOGIN_COOKIE)
63
- . '</div>';
64
- }
65
- else{
66
- $cookie_rule = substr($cookie_rule, 11);
67
- $cookie_arr = explode(',', $cookie_rule);
68
- if(!in_array($_options[$id], $cookie_arr)) {
69
- echo '<div class="litespeed-callout-warning">' .
70
- __( 'WARNING: The .htaccess login cookie and Database login cookie do not match.', 'litespeed-cache' ) .
71
- '</div>';
72
- }
73
- }
74
-
75
- }
76
-
77
- $file_writable = LiteSpeed_Cache_Admin_Rules::writable();
78
- $this->build_input($id, 'litespeed-input-long');// , !$file_writable
79
-
80
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_cache.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
- ?>
4
- <h3 class="litespeed-title"><?php echo __( 'Cache Control Settings', 'litespeed-cache' ) ; ?></h3>
5
-
6
- <table><tbody>
7
- <tr>
8
- <th><?php echo __( 'Cache Logged-in Users', 'litespeed-cache' ) ; ?></th>
9
- <td>
10
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_PRIV ) ; ?>
11
- <div class="litespeed-desc">
12
- <?php echo sprintf( __( 'Privately cache frontend pages for logged-in users. (LSWS %s required)', 'litespeed-cache' ), 'v5.2.1+' ) ; ?>
13
- </div>
14
- </td>
15
- </tr>
16
-
17
- <tr>
18
- <th><?php echo __( 'Cache Commenters', 'litespeed-cache' ) ; ?></th>
19
- <td>
20
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_COMMENTER ) ; ?>
21
- <div class="litespeed-desc">
22
- <?php echo sprintf( __( 'Privately cache commenters that have pending comments. Disabling this option will serve non-cacheable pages to commenters. (LSWS %s required)', 'litespeed-cache' ), 'v5.2.1+' ) ; ?>
23
- </div>
24
- </td>
25
- </tr>
26
-
27
- <tr>
28
- <th><?php echo __( 'Cache REST API', 'litespeed-cache' ) ; ?></th>
29
- <td>
30
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_REST ) ; ?>
31
- <div class="litespeed-desc">
32
- <?php echo __( 'Cache requests made by WordPress REST API calls.', 'litespeed-cache' ) ; ?>
33
- </div>
34
- </td>
35
- </tr>
36
-
37
- <tr>
38
- <th><?php echo __( 'Cache Login Page', 'litespeed-cache' ) ; ?></th>
39
- <td>
40
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_PAGE_LOGIN ) ; ?>
41
- <div class="litespeed-desc">
42
- <?php echo __( 'Disabling this option may negatively affect performance.', 'litespeed-cache' ) ; ?>
43
- </div>
44
- </td>
45
- </tr>
46
-
47
- <?php
48
- if ( ! is_multisite() ) :
49
- require LSWCP_DIR . 'admin/tpl/settings_inc.cache_favicon.php' ;
50
- require LSWCP_DIR . 'admin/tpl/settings_inc.cache_resources.php' ;
51
- require LSWCP_DIR . 'admin/tpl/settings_inc.cache_mobile.php' ;
52
- endif ;
53
- ?>
54
-
55
- <tr>
56
- <th><?php echo __( 'Private Cached URIs', 'litespeed-cache' ) ; ?></th>
57
- <td>
58
- <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_CACHE_URI_PRIV); ?>
59
- <div class="litespeed-desc">
60
- <?php echo __('URI Paths containing these strings will NOT be cached as public.', 'litespeed-cache'); ?>
61
- <?php echo __('The URLs will be compared to the REQUEST_URI server variable.', 'litespeed-cache'); ?>
62
- <br />
63
- <i>
64
- <?php echo sprintf( __( 'To do an exact match, add %s to the end of the URL.', 'litespeed-cache' ), '<code>$</code>' ) ; ?>
65
- <?php echo __('One per line.', 'litespeed-cache'); ?>
66
- </i>
67
- </div>
68
- </td>
69
- </tr>
70
-
71
- <?php
72
- if ( ! is_multisite() ) :
73
- require LSWCP_DIR . 'admin/tpl/settings_inc.cache_browser.php' ;
74
- endif ;
75
- ?>
76
-
77
- </tbody></table>
78
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_cdn.php DELETED
@@ -1,104 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- $home_url = home_url( '/' ) ;
5
- $parsed = parse_url( $home_url ) ;
6
- $home_url = str_replace( $parsed[ 'scheme' ] . ':', '', $home_url ) ;
7
- $cdn_url = 'https://cdn.' . substr( $home_url, 2 ) ;
8
-
9
- ?>
10
-
11
- <h3 class="litespeed-title"><?php echo __( 'CDN Settings', 'litespeed-cache' ) ; ?></h3>
12
-
13
- <table><tbody>
14
- <tr>
15
- <th><?php echo __( 'Enable CDN', 'litespeed-cache' ) ; ?></th>
16
- <td>
17
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CDN ) ; ?>
18
- <div class="litespeed-desc">
19
- <?php echo __( 'Enable Content Delivery Network use.', 'litespeed-cache' ) ; ?>
20
- </div>
21
- </td>
22
- </tr>
23
-
24
- <tr>
25
- <th><?php echo __( 'CDN URL', 'litespeed-cache' ) ; ?></th>
26
- <td>
27
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_CDN_URL, 'litespeed-input-long' ) ; ?>
28
- <div class="litespeed-desc">
29
- <?php echo sprintf( __( 'CDN URL to be used. For example, %s', 'litespeed-cache' ), '<code>' . $cdn_url . '</code>' ) ; ?>
30
- </div>
31
- </td>
32
- </tr>
33
-
34
- <tr>
35
- <th><?php echo __( 'Original URL', 'litespeed-cache' ) ; ?></th>
36
- <td>
37
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_CDN_ORI, 'litespeed-input-long' ) ; ?>
38
- <div class="litespeed-desc">
39
- <?php echo sprintf( __( 'Site URL to be served through the CDN. Beginning with %1$s. For example, %2$s', 'litespeed-cache' ), '<code>//</code>', '<code>' . $home_url . '</code>' ) ; ?>
40
- </div>
41
- </td>
42
- </tr>
43
-
44
- <tr>
45
- <th><?php echo __( 'Include Images', 'litespeed-cache' ) ; ?></th>
46
- <td>
47
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CDN_INC_IMG ) ; ?>
48
- <div class="litespeed-desc">
49
- <?php echo sprintf( __( 'Serve all image files through the CDN. This will affect all attachments, HTML %s tags, and CSS %s attributes.', 'litespeed-cache' ), '<code>&lt;img</code>', '<code>url()</code>' ) ; ?>
50
- </div>
51
- </td>
52
- </tr>
53
-
54
- <tr>
55
- <th><?php echo __( 'Include CSS', 'litespeed-cache' ) ; ?></th>
56
- <td>
57
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CDN_INC_CSS ) ; ?>
58
- <div class="litespeed-desc">
59
- <?php echo __( 'Serve all CSS files through the CDN. This will affect all enqueued WP CSS files.', 'litespeed-cache' ) ; ?>
60
- </div>
61
- </td>
62
- </tr>
63
-
64
- <tr>
65
- <th><?php echo __( 'Include JS', 'litespeed-cache' ) ; ?></th>
66
- <td>
67
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CDN_INC_JS ) ; ?>
68
- <div class="litespeed-desc">
69
- <?php echo __( 'Serve all JavaScript files through the CDN. This will affect all enqueued WP JavaScript files.', 'litespeed-cache' ) ; ?>
70
- </div>
71
- </td>
72
- </tr>
73
-
74
- <tr>
75
- <th><?php echo __( 'Include File Types', 'litespeed-cache' ) ; ?></th>
76
- <td>
77
- <div style="float:left; margin-right: 125px;">
78
- <?php $id = LiteSpeed_Cache_Config::OPID_CDN_FILETYPE ; ?>
79
- <?php $this->build_textarea( $id, null, false, 30 ) ; ?>
80
- <div class="litespeed-desc">
81
- <p><?php echo __( 'Static file type links to be replaced by CDN links. One per line.', 'litespeed-cache' ) ; ?></p>
82
- <p><?php echo sprintf( __( 'This will affect all tags containing attributes: %s %s %s.', 'litespeed-cache' ), '<code>src=""</code>', '<code>data-src=""</code>', '<code>href=""</code>' ) ; ?></p>
83
- </div>
84
- </div>
85
- <div style="float:left; display:flex;">
86
- <div style="display: flex; margin-right: 50px;">
87
- <?php $this->recommended($id) ; ?>
88
- </div>
89
- </div>
90
- </td>
91
- </tr>
92
-
93
- <tr>
94
- <th><?php echo __( 'Exclude Path', 'litespeed-cache' ) ; ?></th>
95
- <td>
96
- <?php $id = LiteSpeed_Cache_Config::OPID_CDN_EXCLUDE ; ?>
97
- <?php $this->build_textarea( $id ) ; ?>
98
- <div class="litespeed-desc">
99
- <?php echo __( 'Paths containing these strings will not be served from the CDN.', 'litespeed-cache' ) ; ?>
100
- </div>
101
- </td>
102
- </tr>
103
-
104
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_compatibilities.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- if (!LiteSpeed_Cache_Admin_Display::get_instance()->show_compatibility_tab()) return;
5
- ?>
6
-
7
- <h3 class="litespeed-title"><?php echo __('Compatibility with WP-PostViews', 'litespeed-cache'); ?></h3>
8
-
9
- <p><?php echo __('To make LiteSpeed Cache compatible with WP-PostViews:', 'litespeed-cache'); ?></p>
10
-
11
- <ol>
12
- <li>
13
- <p><?php echo __('Replace the following calls in the active theme\'s template files with a div or span with a unique ID.', 'litespeed-cache'); ?></p>
14
- <p><?php echo sprintf(__('e.g. Replace <br> <pre>%1$s</pre> with<br> <pre>%2$s</pre>', 'litespeed-cache'),
15
- htmlspecialchars('<?php if(function_exists(\'the_views\' )) { the_views(); } ?>'),
16
- htmlspecialchars('<div id="postviews_lscwp" > </div>')
17
- ); ?>
18
- </p>
19
- </li>
20
- <li>
21
- <p><?php echo __('Update the ajax request to output the results to that div.', 'litespeed-cache'); ?></p>
22
- <p><?php echo __('Example:', 'litespeed-cache'); ?></p>
23
- <pre>jQuery.ajax({
24
- type:"GET",
25
- url:viewsCacheL10n.admin_ajax_url,
26
- data:"postviews_id="+viewsCacheL10n.post_id+"&action=postviews",
27
- cache:!1,
28
- success:function(data) {
29
- if(data) {
30
- jQuery(\'#postviews_lscwp\').html(data+\' views\');
31
- }
32
- }
33
- });</pre>
34
- <p><?php echo __('The ajax code can be found at', 'litespeed-cache'); ?></p>
35
- <pre>/wp-content/plugins/wp-postviews/postviews-cache.js</pre>
36
- </li>
37
- <li><?php echo __('After purging the cache, the view count should be updating.', 'litespeed-cache'); ?></li>
38
- </ol>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_crawler.php DELETED
@@ -1,196 +0,0 @@
1
- <?php
2
- if ( !defined('WPINC') ) die;
3
-
4
- ?>
5
-
6
- <h3 class="litespeed-title"><?php echo __('Crawler Settings', 'litespeed-cache'); ?></h3>
7
-
8
- <table><tbody>
9
- <tr>
10
- <th><?php echo __('Delay', 'litespeed-cache'); ?></th>
11
- <td>
12
- <?php $id = LiteSpeed_Cache_Config::CRWL_USLEEP ; ?>
13
- <?php $this->build_input($id); ?> <?php echo __('microseconds', 'litespeed-cache'); ?>
14
- <div class="litespeed-desc">
15
- <?php echo __('Specify time in microseconds for the delay between requests during a crawl.', 'litespeed-cache'); ?>
16
- <?php $this->recommended($id) ; ?>
17
- </div>
18
- </td>
19
- </tr>
20
-
21
- <tr>
22
- <th><?php echo __('Run Duration', 'litespeed-cache'); ?></th>
23
- <td>
24
- <?php $id = LiteSpeed_Cache_Config::CRWL_RUN_DURATION ; ?>
25
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
26
- <div class="litespeed-desc">
27
- <?php echo __('Specify time in seconds for the duration of the crawl interval.', 'litespeed-cache'); ?>
28
- <?php $this->recommended($id) ; ?>
29
- </div>
30
- </td>
31
- </tr>
32
-
33
- <tr>
34
- <th><?php echo __('Interval Between Runs', 'litespeed-cache'); ?></th>
35
- <td>
36
- <?php $id = LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL ; ?>
37
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
38
- <div class="litespeed-desc">
39
- <?php echo __('Specify time in seconds for the time between each run interval. Must be greater than 60.', 'litespeed-cache'); ?>
40
- <?php $this->recommended($id) ; ?>
41
- </div>
42
- </td>
43
- </tr>
44
-
45
- <tr>
46
- <th><?php echo __('Crawl Interval', 'litespeed-cache'); ?></th>
47
- <td>
48
- <?php $id = LiteSpeed_Cache_Config::CRWL_CRAWL_INTERVAL ; ?>
49
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
50
- <div class="litespeed-desc">
51
- <?php echo __('Specify how long in seconds before the crawler should initiate crawling the entire sitemap again.', 'litespeed-cache'); ?>
52
- <?php $this->recommended($id) ; ?>
53
- </div>
54
- </td>
55
- </tr>
56
-
57
- <tr>
58
- <th><?php echo __('Threads', 'litespeed-cache'); ?></th>
59
- <td>
60
- <?php $id = LiteSpeed_Cache_Config::CRWL_THREADS ; ?>
61
- <?php $this->build_input( $id, 'litespeed-input-short' ) ; ?>
62
- <div class="litespeed-desc">
63
- <?php echo __('Specify Number of Threads to use while crawling.', 'litespeed-cache'); ?>
64
- <?php $this->recommended($id) ; ?>
65
- </div>
66
- </td>
67
- </tr>
68
-
69
- <tr>
70
- <th><?php echo __('Server Load Limit', 'litespeed-cache'); ?></th>
71
- <td>
72
- <?php $id = LiteSpeed_Cache_Config::CRWL_LOAD_LIMIT ; ?>
73
- <?php $this->build_input($id); ?>
74
- <div class="litespeed-desc">
75
- <?php echo __( 'The maximum average server load allowed while crawling. The number of crawler threads in use will be actively reduced until average server load falls under this limit. If this cannot be achieved with a single thread, the current crawler run will be terminated.', 'litespeed-cache' ) ;
76
- ?>
77
- <?php $this->recommended($id) ; ?>
78
- </div>
79
- </td>
80
- </tr>
81
-
82
- <tr>
83
- <th><?php echo __('Site IP', 'litespeed-cache'); ?></th>
84
- <td>
85
- <?php $id = LiteSpeed_Cache_Config::CRWL_DOMAIN_IP ; ?>
86
- <?php $this->build_input($id); ?>
87
- <div class="litespeed-desc">
88
- <?php echo __('Enter this site\'s IP address to crawl by IP instead of domain name. This eliminates the overhead of DNS and CDN lookups. (optional)', 'litespeed-cache'); ?>
89
- </div>
90
- </td>
91
- </tr>
92
-
93
- <tr>
94
- <th><?php echo __('Custom Sitemap', 'litespeed-cache'); ?></th>
95
- <td>
96
- <?php $id = LiteSpeed_Cache_Config::CRWL_CUSTOM_SITEMAP ; ?>
97
- <?php $this->build_input($id, false, false, false, 'litespeed_custom_sitemap'); ?>
98
- <div class="litespeed-desc">
99
- <?php echo __('The crawler can use your Google XML Sitemap instead of its own. Enter the full URL to your sitemap here.', 'litespeed-cache'); ?>
100
- </div>
101
- </td>
102
- </tr>
103
-
104
- <tr data-litespeed-selfsitemap="1">
105
- <th><?php echo __('Include Posts', 'litespeed-cache'); ?></th>
106
- <td>
107
- <?php $this->build_switch(LiteSpeed_Cache_Config::CRWL_POSTS); ?>
108
- <div class="litespeed-desc">
109
- <?php echo __('Include Posts in crawler sitemap generation.', 'litespeed-cache'); ?>
110
- </div>
111
- </td>
112
- </tr>
113
-
114
- <tr data-litespeed-selfsitemap="1">
115
- <th><?php echo __('Include Pages', 'litespeed-cache'); ?></th>
116
- <td>
117
- <?php $this->build_switch(LiteSpeed_Cache_Config::CRWL_PAGES); ?>
118
- <div class="litespeed-desc">
119
- <?php echo __('Include Pages in crawler sitemap generation.', 'litespeed-cache'); ?>
120
- </div>
121
- </td>
122
- </tr>
123
-
124
- <tr data-litespeed-selfsitemap="1">
125
- <th><?php echo __('Include Categories', 'litespeed-cache'); ?></th>
126
- <td>
127
- <?php $this->build_switch(LiteSpeed_Cache_Config::CRWL_CATS); ?>
128
- <div class="litespeed-desc">
129
- <?php echo __('Include Categories pages in crawler sitemap generation.', 'litespeed-cache'); ?>
130
- </div>
131
- </td>
132
- </tr>
133
-
134
- <tr data-litespeed-selfsitemap="1">
135
- <th><?php echo __('Include Tags', 'litespeed-cache'); ?></th>
136
- <td>
137
- <?php $this->build_switch(LiteSpeed_Cache_Config::CRWL_TAGS); ?>
138
- <div class="litespeed-desc">
139
- <?php echo __('Include Tags pages in crawler sitemap generation.', 'litespeed-cache'); ?>
140
- </div>
141
- </td>
142
- </tr>
143
-
144
- <tr data-litespeed-selfsitemap="1">
145
- <th><?php echo __('Exclude Custom Post Types', 'litespeed-cache'); ?></th>
146
- <td>
147
- <?php $this->build_textarea(LiteSpeed_Cache_Config::CRWL_EXCLUDES_CPT); ?>
148
-
149
- <div class="litespeed-desc">
150
- <?php echo __('If you want to exclude certain Custom Post Types in sitemap, add the Custom Post Types in the box, one per line.', 'litespeed-cache'); ?>
151
- </div>
152
-
153
- <div class="litespeed-callout-warning">
154
- <h4><?php echo __('Available Custom Post Type','litespeed-cache'); ?></h4>
155
- <p>
156
- <?php echo implode('<br />', array_diff(get_post_types( '', 'names' ), array('post', 'page'))); ?>
157
- </p>
158
- </div>
159
- </td>
160
- </tr>
161
-
162
- <tr data-litespeed-selfsitemap="1">
163
- <th><?php echo __('Order links by', 'litespeed-cache'); ?></th>
164
- <td>
165
- <div class="litespeed-switch">
166
- <?php echo $this->build_radio(
167
- LiteSpeed_Cache_Config::CRWL_ORDER_LINKS,
168
- LiteSpeed_Cache_Config::CRWL_DATE_DESC,
169
- __('Date, descending (Default)', 'litespeed-cache')
170
- ); ?>
171
-
172
- <?php echo $this->build_radio(
173
- LiteSpeed_Cache_Config::CRWL_ORDER_LINKS,
174
- LiteSpeed_Cache_Config::CRWL_DATE_ASC,
175
- __('Date, ascending', 'litespeed-cache')
176
- ); ?>
177
-
178
- <?php echo $this->build_radio(
179
- LiteSpeed_Cache_Config::CRWL_ORDER_LINKS,
180
- LiteSpeed_Cache_Config::CRWL_ALPHA_DESC,
181
- __('Alphabetical, descending', 'litespeed-cache')
182
- ); ?>
183
-
184
- <?php echo $this->build_radio(
185
- LiteSpeed_Cache_Config::CRWL_ORDER_LINKS,
186
- LiteSpeed_Cache_Config::CRWL_ALPHA_ASC,
187
- __('Alphabetical, ascending', 'litespeed-cache')
188
- ); ?>
189
- </div>
190
- <div class="litespeed-desc">
191
- <?php echo __('Please choose one of the above options to set the order in which the sitemap will be parsed.', 'litespeed-cache'); ?>
192
- </div>
193
- </td>
194
- </tr>
195
-
196
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_debug.php DELETED
@@ -1,146 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- ?>
5
-
6
- <h3 class="litespeed-title"><?php echo __( 'Developer Testing', 'litespeed-cache' ) ; ?></h3>
7
-
8
- <table><tbody>
9
- <tr>
10
- <th><?php echo __( 'Debug Log', 'litespeed-cache' ) ; ?></th>
11
- <td>
12
- <div class="litespeed-switch">
13
- <?php echo $this->build_radio(
14
- LiteSpeed_Cache_Config::OPID_DEBUG,
15
- LiteSpeed_Cache_Config::VAL_OFF,
16
- __( 'Off', 'litespeed-cache' )
17
- ) ; ?>
18
-
19
- <?php echo $this->build_radio(
20
- LiteSpeed_Cache_Config::OPID_DEBUG,
21
- LiteSpeed_Cache_Config::VAL_ON,
22
- __( 'On', 'litespeed-cache' )
23
- ) ; ?>
24
-
25
- <?php echo $this->build_radio(
26
- LiteSpeed_Cache_Config::OPID_DEBUG,
27
- LiteSpeed_Cache_Config::VAL_ON2,
28
- __( 'Admin IP only', 'litespeed-cache' )
29
- ) ; ?>
30
- </div>
31
- <div class="litespeed-desc">
32
- <?php echo __( 'Outputs to WordPress debug log.', 'litespeed-cache' ) ; ?>
33
- <?php echo __( 'This should be set to off once everything is working to prevent filling the disk.', 'litespeed-cache' ) ; ?>
34
- <?php echo __( 'The Admin IP option will only output log messages on requests from admin IPs.', 'litespeed-cache' ) ; ?>
35
- <?php echo sprintf( __( 'The logs will be outputted to %s.', 'litespeed-cache' ), '<code>wp-content/debug.log</code>' ) ; ?>
36
- </div>
37
- </td>
38
- </tr>
39
-
40
- <tr>
41
- <th><?php echo __( 'Admin IPs', 'litespeed-cache' ) ; ?></th>
42
- <td>
43
- <?php $this->build_textarea( LiteSpeed_Cache_Config::OPID_ADMIN_IPS, null, false, 30 ) ; ?>
44
- <div class="litespeed-desc">
45
- <?php echo __( 'Allows listed IPs (one per line) to perform certain actions from their browsers.', 'litespeed-cache' ) ; ?><br />
46
- <?php echo sprintf( __( 'More information about the available commands can be found <a href="%s">here</a>.', 'litespeed-cache' ),
47
- get_admin_url() . 'admin.php?page=lscache-info#admin_ip' ) ; ?>
48
- </div>
49
- </td>
50
- </tr>
51
-
52
- <tr>
53
- <th><?php echo __( 'Debug Level', 'litespeed-cache' ) ; ?></th>
54
- <td>
55
- <div class="litespeed-switch">
56
- <?php echo $this->build_radio(
57
- LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
58
- LiteSpeed_Cache_Config::VAL_OFF,
59
- __( 'Basic', 'litespeed-cache' )
60
- ) ; ?>
61
-
62
- <?php echo $this->build_radio(
63
- LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
64
- LiteSpeed_Cache_Config::VAL_ON,
65
- __( 'Advanced', 'litespeed-cache' )
66
- ) ; ?>
67
- </div>
68
- <div class="litespeed-desc">
69
- <?php echo __( 'Advanced level will log more details.', 'litespeed-cache' ) ; ?>
70
- </div>
71
- </td>
72
- </tr>
73
-
74
- <tr>
75
- <th><?php echo __( 'Log File Size Limit', 'litespeed-cache' ) ; ?></th>
76
- <td>
77
- <?php $id = LiteSpeed_Cache_Config::OPID_LOG_FILE_SIZE ; ?>
78
- <?php $this->build_input( $id, 'litespeed-input-short' ) ; ?> <?php echo __( 'MB', 'litespeed-cache' ) ; ?>
79
- <div class="litespeed-desc">
80
- <?php echo __( 'Specify the maximum size of the log file. Minimum is 3MB. Maximum is 3000MB.', 'litespeed-cache' ) ; ?>
81
- <?php $this->recommended( $id ) ; ?>
82
- </div>
83
- </td>
84
- </tr>
85
-
86
- <tr>
87
- <th><?php echo __( 'Heartbeat', 'litespeed-cache' ) ; ?></th>
88
- <td>
89
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ; ?>
90
- <div class="litespeed-desc">
91
- <?php echo __( 'Disable WordPress heartbeat to prevent AJAX calls from breaking debug logging. WARNING: Disabling this may cause WordPress tasks triggered by AJAX to stop working.', 'litespeed-cache' ) ; ?>
92
- </div>
93
- </td>
94
- </tr>
95
-
96
- <tr>
97
- <th><?php echo __( 'Log Cookies', 'litespeed-cache' ) ; ?></th>
98
- <td>
99
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE ) ; ?>
100
- <div class="litespeed-desc">
101
- <?php echo __( 'Log request cookie values.', 'litespeed-cache' ) ; ?>
102
- </div>
103
- </td>
104
- </tr>
105
-
106
- <tr>
107
- <th><?php echo __( 'Collapse Query Strings', 'litespeed-cache' ) ; ?></th>
108
- <td>
109
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_COLLAPS_QS ) ; ?>
110
- <div class="litespeed-desc">
111
- <?php echo __( 'Shorten query strings in the debug log to improve readability.', 'litespeed-cache' ) ; ?>
112
- </div>
113
- </td>
114
- </tr>
115
-
116
- <tr>
117
- <th><?php echo __( 'Log Filters', 'litespeed-cache' ) ; ?></th>
118
- <td>
119
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_LOG_FILTERS ) ; ?>
120
- <div class="litespeed-desc">
121
- <?php echo __( 'Log all WordPress filter hooks. WARNING: Enabling this option will cause log file size to grow quickly.', 'litespeed-cache' ) ; ?>
122
- </div>
123
- </td>
124
- </tr>
125
-
126
- <tr>
127
- <th><?php echo __( 'Exclude Filters', 'litespeed-cache' ) ; ?></th>
128
- <td>
129
- <?php $this->build_textarea( LiteSpeed_Cache_Config::OPID_LOG_IGNORE_FILTERS, null, false, 30 ) ; ?>
130
- <div class="litespeed-desc">
131
- <?php echo __( 'Listed filters (one per line) will not be logged.', 'litespeed-cache' ) ; ?><br />
132
- </div>
133
- </td>
134
- </tr>
135
-
136
- <tr>
137
- <th><?php echo __( 'Exclude Part Filters', 'litespeed-cache' ) ; ?></th>
138
- <td>
139
- <?php $this->build_textarea( LiteSpeed_Cache_Config::OPID_LOG_IGNORE_PART_FILTERS, null, false, 30 ) ; ?>
140
- <div class="litespeed-desc">
141
- <?php echo __( 'Filters containing these strings (one per line) will not be logged.', 'litespeed-cache' ) ; ?><br />
142
- </div>
143
- </td>
144
- </tr>
145
-
146
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_esi.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- global $wp_roles ;
5
- if ( !isset( $wp_roles ) ) {
6
- $wp_roles = new WP_Roles() ;
7
- }
8
- $roles = array_keys( $wp_roles->roles ) ;
9
-
10
- sort( $roles ) ;
11
-
12
- ?>
13
-
14
- <h3 class="litespeed-title"><?php echo __('ESI Settings', 'litespeed-cache'); ?></h3>
15
-
16
- <div class="litespeed-desc">
17
- <p><?php echo __('With ESI (Edge Side Includes), pages may be served from cache for logged-in users.', 'litespeed-cache'); ?></p>
18
- <p><?php echo __('ESI allows you to designate parts of your dynamic page as separate fragments that are then assembled together to make the whole page. In other words, ESI lets you “punch holes” in a page, and then fill those holes with content that may be cached privately, cached publicly with its own TTL, or not cached at all.', 'litespeed-cache'); ?></p>
19
- <p><?php echo sprintf(
20
- __( 'Learn more about public cache vs. private cache <a %s>on our blog</a>.', 'litespeed-cache' ),
21
- 'href="https://blog.litespeedtech.com/2017/08/30/wpw-private-cache-vs-public-cache/" target="_blank"'
22
- ) ; ?></p>
23
- </div>
24
-
25
- <div class="litespeed-relative">
26
-
27
- <?php if ( ! LSWCP_ESI_SUPPORT ) : ?>
28
- <div class="litespeed-ent-notice">
29
- <div class="litespeed-ent-notice-desc"><?php echo __('Available in LiteSpeed Enterprise version', 'litespeed-cache'); ?></div>
30
- </div>
31
- <?php endif; ?>
32
-
33
- <table><tbody>
34
- <tr>
35
- <th><?php echo __('Enable ESI', 'litespeed-cache'); ?></th>
36
- <td>
37
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_ESI_ENABLE); ?>
38
- <div class="litespeed-desc">
39
- <?php echo __('Enable caches public pages for logged in users and serves the Admin Bar and Comment Form via ESI blocks. These two blocks will be uncached unless enabled below.', 'litespeed-cache'); ?>
40
- </div>
41
- </td>
42
- </tr>
43
-
44
- <tr>
45
- <th><?php echo __('Cache Admin Bar', 'litespeed-cache'); ?></th>
46
- <td>
47
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_ESI_CACHE_ADMBAR); ?>
48
- <div class="litespeed-desc">
49
- <?php echo __('Cache the build-in Admin Bar ESI block.', 'litespeed-cache'); ?>
50
- </div>
51
- </td>
52
- </tr>
53
-
54
- <tr>
55
- <th><?php echo __('Cache Comment Form', 'litespeed-cache'); ?></th>
56
- <td>
57
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_ESI_CACHE_COMMFORM); ?>
58
- <div class="litespeed-desc">
59
- <?php echo __('Cache the build-in Comment Form ESI block.', 'litespeed-cache'); ?>
60
- </div>
61
- </td>
62
- </tr>
63
-
64
- <tr>
65
- <th><?php echo __('Vary Group', 'litespeed-cache'); ?></th>
66
- <td>
67
- <table class="litespeed-vary-table"><tbody>
68
- <?php foreach ( $roles as $role ): ?>
69
- <tr>
70
- <td class='litespeed-vary-title'><?php echo $role ; ?></td>
71
- <td class='litespeed-vary-val'>
72
- <input type="text" class="litespeed-input-short"
73
- name="<?php echo LiteSpeed_Cache_Config::VARY_GROUP ; ?>[<?php echo $role ; ?>]"
74
- value="<?php echo $this->config->in_vary_group( $role ) ; ?>" />
75
- </td>
76
- </tr>
77
- <?php endforeach; ?>
78
- </tbody></table>
79
- <div class="litespeed-desc">
80
- <?php echo __( 'If your site contains public content that certain user roles can see but other roles cannot, you can specify a Vary Group for those user roles. For example, specifying an administrator vary group allows there to be a separate publicly-cached page tailored to administrators (with “edit” links, etc), while all other user roles see the default public page.', 'litespeed-cache' ) ; ?>
81
- </div>
82
- </td>
83
- </tr>
84
-
85
-
86
-
87
-
88
- </tbody></table>
89
-
90
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_excludes.php DELETED
@@ -1,116 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
- ?>
4
- <h3 class="litespeed-title"><?php echo __( 'Do Not Cache Settings', 'litespeed-cache' ) ; ?></h3>
5
-
6
- <table><tbody>
7
- <tr>
8
- <th><?php echo __( 'Do Not Cache URIs', 'litespeed-cache' ) ; ?></th>
9
- <td>
10
- <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_EXCLUDES_URI); ?>
11
- <div class="litespeed-desc">
12
- <?php echo __('Paths containing these strings will not be cached.', 'litespeed-cache'); ?>
13
- <?php echo __('The URLs will be compared to the REQUEST_URI server variable.', 'litespeed-cache'); ?>
14
- <br />
15
- <i>
16
- <?php echo sprintf( __( 'To do an exact match, add %s to the end of the URL.', 'litespeed-cache' ), '<code>$</code>' ) ; ?>
17
- <?php echo __('One per line.', 'litespeed-cache'); ?>
18
- </i>
19
- </div>
20
- </td>
21
- </tr>
22
-
23
- <tr>
24
- <th><?php echo __( 'Do Not Cache Query Strings', 'litespeed-cache' ) ; ?></th>
25
- <td>
26
- <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_EXCLUDES_QS); ?>
27
- <div class="litespeed-desc">
28
- <?php echo __('Query string containing these parameters will not be cached.', 'litespeed-cache'); ?>
29
- <i>
30
- <?php echo __('One per line.', 'litespeed-cache'); ?>
31
- </i>
32
- </div>
33
- </td>
34
- </tr>
35
-
36
- <tr>
37
- <th><?php echo __( 'Do Not Cache Categories', 'litespeed-cache' ) ; ?></th>
38
- <td>
39
- <?php
40
- $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT;
41
- $excludes_buf = '';
42
- $cat_ids = $_options[$id];
43
- if ($cat_ids != '') {
44
- $id_list = explode(',', $cat_ids);
45
- $excludes_buf = implode("\n", array_map('get_cat_name', $id_list));
46
- }
47
- $this->build_textarea($id, $excludes_buf);
48
- ?>
49
- <div class="litespeed-desc">
50
- <b><?php echo __('All categories are cached by default.', 'litespeed-cache'); ?></b>
51
- <?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'categories', 'litespeed-cache') ) ; ?>
52
- <i>
53
- <?php echo __('One per line.', 'litespeed-cache'); ?>
54
- </i>
55
- </div>
56
- <div class="litespeed-callout-warning">
57
- <h4><?php echo __('NOTE:', 'litespeed-cache'); ?></h4>
58
- <ol>
59
- <li><?php echo __('If the Category ID is not found, the name will be removed on save.', 'litespeed-cache'); ?></li>
60
- <li><?php echo sprintf(__('To exclude %1$s, insert %2$s.', 'litespeed-cache'),
61
- '<code>http://www.example.com/category/category-id/</code>', '<code>category-id</code>'); ?></li>
62
- </ol>
63
- </div>
64
- </td>
65
- </tr>
66
-
67
- <tr>
68
- <th><?php echo __( 'Do Not Cache Tags', 'litespeed-cache' ) ; ?></th>
69
- <td>
70
- <?php
71
- $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG;
72
- $excludes_buf = '';
73
- $ids = $_options[$id];
74
- if ($ids != '') {
75
- $id_list = explode(',', $ids);
76
- $tags_list = array_map('get_tag', $id_list);
77
- $tag_names = array();
78
- foreach ($tags_list as $tag) {
79
- $tag_names[] = $tag->name;
80
- }
81
- if (!empty($tag_names)) {
82
- $excludes_buf = implode("\n", $tag_names);
83
- }
84
- }
85
- $this->build_textarea($id, $excludes_buf);
86
- ?>
87
- <div class="litespeed-desc">
88
- <b><?php echo __('All tags are cached by default.', 'litespeed-cache'); ?></b>
89
- <?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'tags', 'litespeed-cache') ) ; ?>
90
- <i>
91
- <?php echo __('One per line.', 'litespeed-cache'); ?>
92
- </i>
93
- </div>
94
- <div class="litespeed-callout-warning">
95
- <h4><?php echo __('NOTE:', 'litespeed-cache'); ?></h4>
96
- <ol>
97
- <li><?php echo __('If the Tag ID is not found, the name will be removed on save.', 'litespeed-cache'); ?></li>
98
- <li><?php echo sprintf(__('To exclude %1$s, insert %2$s.', 'litespeed-cache'),
99
- '<code>http://www.example.com/tag/category/tag-id/</code>', '<code>tag-id</code>'); ?></li>
100
- </ol>
101
- </div>
102
- </td>
103
- </tr>
104
-
105
- <?php
106
- if ( ! is_multisite() ) :
107
- // Cookie
108
- require LSWCP_DIR . 'admin/tpl/settings_inc.exclude_cookies.php' ;
109
-
110
- // User Agent
111
- require LSWCP_DIR . 'admin/tpl/settings_inc.exclude_useragent.php' ;
112
-
113
- endif ;
114
- ?>
115
-
116
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_general.php DELETED
@@ -1,144 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
- <h3 class="litespeed-title"><?php echo __('General', 'litespeed-cache'); ?></h3>
6
-
7
- <table><tbody>
8
- <tr>
9
- <th><?php echo __('Enable LiteSpeed Cache', 'litespeed-cache'); ?></th>
10
- <td>
11
- <?php
12
- $id = LiteSpeed_Cache_Config::OPID_ENABLED_RADIO;
13
- //IF multisite: Add 'Use Network Admin' option,
14
- //ELSE: Change 'Enable LiteSpeed Cache' selection to 'Enabled' if the 'Use Network Admin' option was previously selected.
15
- // Selection will not actually be changed unless settings are saved.
16
- if(!is_multisite() && intval($_options[$id]) === 2){
17
- $_options[$id] = 1;
18
- }
19
- ?>
20
- <div class="litespeed-switch">
21
- <?php echo $this->build_radio(
22
- $id,
23
- LiteSpeed_Cache_Config::VAL_OFF,
24
- __('Disable', 'litespeed-cache')
25
- ); ?>
26
-
27
- <?php echo $this->build_radio(
28
- $id,
29
- LiteSpeed_Cache_Config::VAL_ON,
30
- __('Enable', 'litespeed-cache')
31
- ); ?>
32
-
33
- <?php
34
- if ( is_multisite() ){
35
- echo $this->build_radio(
36
- $id,
37
- LiteSpeed_Cache_Config::VAL_ON2,
38
- __('Use Network Admin Setting', 'litespeed-cache')
39
- );
40
- }
41
- ?>
42
- </div>
43
- <div class="litespeed-desc">
44
- <?php echo sprintf(__('Please visit the <a %s>Information</a> page on how to test the cache.', 'litespeed-cache'),
45
- 'href="'.get_admin_url().'admin.php?page=lscache-info"'); ?>
46
-
47
- <strong><?php echo __('NOTICE', 'litespeed-cache'); ?>: </strong><?php echo __('When disabling the cache, all cached entries for this blog will be purged.', 'litespeed-cache'); ?>
48
- <?php if ( is_multisite() ): ?>
49
- <br><?php echo __('The network admin setting can be overridden here.', 'litespeed-cache'); ?>
50
- <?php endif; ?>
51
- </div>
52
- </td>
53
- </tr>
54
-
55
- <tr>
56
- <th><?php echo __('Default Public Cache TTL', 'litespeed-cache'); ?></th>
57
- <td>
58
- <?php $id = LiteSpeed_Cache_Config::OPID_PUBLIC_TTL ; ?>
59
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
60
- <div class="litespeed-desc">
61
- <?php echo __('Specify how long, in seconds, public pages are cached. Minimum is 30 seconds.', 'litespeed-cache'); ?>
62
- <?php $this->recommended($id) ; ?>
63
- </div>
64
- </td>
65
- </tr>
66
-
67
- <tr>
68
- <th><?php echo __('Default Private Cache TTL', 'litespeed-cache'); ?></th>
69
- <td>
70
- <?php $id = LiteSpeed_Cache_Config::OPID_PRIVATE_TTL ; ?>
71
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
72
- <div class="litespeed-desc">
73
- <?php echo sprintf( __( 'Specify how long, in seconds, private pages are cached. Minimum is %1$s seconds. Maximum is %2$s seconds.', 'litespeed-cache' ), 60, 3600 ) ; ?>
74
- <?php $this->recommended($id) ; ?>
75
- </div>
76
- </td>
77
- </tr>
78
-
79
- <tr>
80
- <th><?php echo __('Default Front Page TTL', 'litespeed-cache'); ?></th>
81
- <td>
82
- <?php $id = LiteSpeed_Cache_Config::OPID_FRONT_PAGE_TTL ; ?>
83
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
84
- <div class="litespeed-desc">
85
- <?php echo __('Specify how long, in seconds, the front page is cached. Minimum is 30 seconds.', 'litespeed-cache'); ?>
86
- <?php $this->recommended($id) ; ?>
87
- </div>
88
- </td>
89
- </tr>
90
-
91
- <tr>
92
- <th><?php echo __('Default Feed TTL', 'litespeed-cache'); ?></th>
93
- <td>
94
- <?php $id = LiteSpeed_Cache_Config::OPID_FEED_TTL ; ?>
95
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
96
- <div class="litespeed-desc">
97
- <?php echo __('Specify how long, in seconds, feeds are cached.', 'litespeed-cache'); ?>
98
- <?php echo __('If this is set to a number less than 30, feeds will not be cached.', 'litespeed-cache'); ?>
99
- <?php $this->recommended($id) ; ?>
100
- </div>
101
- </td>
102
- </tr>
103
-
104
- <tr>
105
- <th><?php echo __('Default 404 Page TTL', 'litespeed-cache'); ?></th>
106
- <td>
107
- <?php $id = LiteSpeed_Cache_Config::OPID_404_TTL ; ?>
108
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
109
- <div class="litespeed-desc">
110
- <?php echo __('Specify how long, in seconds, 404 pages are cached.', 'litespeed-cache'); ?>
111
- <?php echo __('If this is set to a number less than 30, 404 pages will not be cached.', 'litespeed-cache'); ?>
112
- <?php $this->recommended($id) ; ?>
113
- </div>
114
- </td>
115
- </tr>
116
-
117
- <tr>
118
- <th><?php echo __('Default 403 Page TTL', 'litespeed-cache'); ?></th>
119
- <td>
120
- <?php $id = LiteSpeed_Cache_Config::OPID_403_TTL ; ?>
121
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
122
- <div class="litespeed-desc">
123
- <?php echo __('Specify how long, in seconds, 403 pages are cached.', 'litespeed-cache'); ?>
124
- <?php echo __('If this is set to a number less than 30, 403 pages will not be cached.', 'litespeed-cache'); ?>
125
- <?php $this->recommended($id) ; ?>
126
- </div>
127
- </td>
128
- </tr>
129
-
130
- <tr>
131
- <th><?php echo __('Default 500 Page TTL', 'litespeed-cache'); ?></th>
132
- <td>
133
- <?php $id = LiteSpeed_Cache_Config::OPID_500_TTL ; ?>
134
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
135
- <div class="litespeed-desc">
136
- <?php echo __('Specify how long, in seconds, 500 pages are cached.', 'litespeed-cache'); ?>
137
- <?php echo __('If this is set to a number less than 30, 500 pages will not be cached.', 'litespeed-cache'); ?>
138
- <?php $this->recommended($id) ; ?>
139
- </div>
140
- </td>
141
- </tr>
142
-
143
- </tbody></table>
144
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_inc.cache_browser.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- ?>
5
- <tr>
6
- <th><?php echo __( 'Browser Cache', 'litespeed-cache' ) ; ?></th>
7
- <td>
8
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_BROWSER ) ; ?>
9
- <div class="litespeed-desc">
10
- <?php echo __( 'Browser caching stores static files locally in the user\'s browser. Turn on this setting to reduce repeated requests for static files.', 'litespeed-cache' ) ; ?>
11
- <i class="litespeed-warning">
12
- <?php echo __('NOTE:', 'litespeed-cache'); ?>
13
- <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
14
- </i>
15
- <p><?php echo sprintf( __( 'You can turn on browser caching in server admin too. <a %s>Learn more about LiteSpeed browser cache setting</a>.', 'litespeed-cache' ), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:browser_cache" target="_blank"' ) ; ?></p>
16
- </div>
17
- </td>
18
- </tr>
19
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_inc.cache_favicon.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $file_writable = LiteSpeed_Cache_Admin_Rules::writable();
5
- ?>
6
- <tr>
7
- <th><?php echo __('Cache favicon.ico', 'litespeed-cache'); ?></th>
8
- <td>
9
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_CACHE_FAVICON);/*, !$file_writable*/ ?>
10
- <div class="litespeed-desc">
11
- <?php echo __('favicon.ico is requested on most pages.', 'litespeed-cache'); ?>
12
- <?php echo __('Caching this resource may improve server performance by avoiding unnecessary PHP calls.', 'litespeed-cache'); ?>
13
- <i class="litespeed-warning">
14
- <?php echo __('NOTE:', 'litespeed-cache'); ?>
15
- <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
16
- </i>
17
- </div>
18
- </td>
19
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_inc.cache_mobile.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
-
6
- <!-- build_setting_mobile_view start -->
7
- <tr>
8
- <th><?php echo __('Cache Mobile', 'litespeed-cache'); ?></th>
9
- <td>
10
- <?php
11
- $file_writable = LiteSpeed_Cache_Admin_Rules::writable();
12
- $this->build_switch(LiteSpeed_Cache_Config::OPID_CACHE_MOBILE); //, !$file_writable
13
- ?>
14
- <div class="litespeed-desc">
15
- <?php echo __('When enabled, mobile views will be cached separately.', 'litespeed-cache'); ?>
16
- <?php echo __('A site built with responsive design does not need to check this.', 'litespeed-cache'); ?>
17
- <i class="litespeed-warning">
18
- <?php echo __( 'NOTE:', 'litespeed-cache' ) ; ?>
19
- <?php echo __( 'This setting will edit the .htaccess file.', 'litespeed-cache' ) ; ?>
20
- </i>
21
- </div>
22
- </td>
23
- </tr>
24
-
25
- <tr>
26
- <th><?php echo __('List of Mobile User Agents', 'litespeed-cache'); ?></th>
27
- <td>
28
- <?php
29
- $id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
30
- $wp_default_mobile = 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi' ;
31
-
32
- // if set, use value as input value
33
- if ( $_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) {
34
-
35
- // if enabled, check the setting in file
36
- if ( defined( 'LITESPEED_ON' ) ) {
37
-
38
- $this->display_messages() ;
39
-
40
- $mobile_agents = LiteSpeed_Cache_Admin_Rules::get_instance()->get_rewrite_rule_mobile_agents() ;
41
- if ( $mobile_agents !== $_options[ $id ] ) {
42
- echo '<div class="litespeed-callout-danger">'
43
- . __( 'Htaccess did not match configuration option.', 'litespeed-cache' )
44
- . ' ' . __( 'Please re-enter the mobile view setting.', 'litespeed-cache' )
45
- . ' ' . sprintf( __( 'List in WordPress database is: %s', 'litespeed-cache' ), '<b>' . $_options[ $id ] . '</b>' )
46
- . '</div>' ;
47
- }
48
- }
49
- }
50
-
51
- $this->build_input( $id, 'litespeed-input-long', false, ! $_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ], 'litespeed-mobileview-rules' ) ;
52
- ?>
53
-
54
- <input type="hidden" name="<?php echo LiteSpeed_Cache_Config::OPTION_NAME; ?>[<?php echo $id; ?>__default]"
55
- id="litespeed-mobileview-rules-default"
56
- value="<?php echo esc_textarea( $wp_default_mobile ) ; ?>"
57
- />
58
-
59
- <div class="litespeed-desc">
60
- <i>
61
- <?php echo sprintf( __( 'SYNTAX: Each entry should be separated with a bar, %s.', 'litespeed-cache'), "<code>|</code>" ) ; ?>
62
- <?php echo sprintf( __( 'Any spaces should be escaped with a backslash before the space, %s.', 'litespeed-cache' ), "<code>\\</code>" ) ; ?>
63
- </i>
64
- <p>
65
- <?php echo sprintf( __( 'The default list WordPress uses is %s', 'litespeed-cache' ), "<code>$wp_default_mobile</code>" ) ; ?>
66
- </p>
67
- </div>
68
- </td>
69
- </tr>
70
- <!-- build_setting_mobile_view end -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_inc.cache_resources.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $file_writable = LiteSpeed_Cache_Admin_Rules::writable();
5
- ?>
6
- <!-- build_setting_cache_resources -->
7
- <tr>
8
- <th><?php echo __('Cache PHP Resources', 'litespeed-cache'); ?></th>
9
- <td>
10
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_CACHE_RES);/*, !$file_writable*/ ?>
11
- <div class="litespeed-desc">
12
- <?php echo __('Some themes and plugins add resources via a PHP request.', 'litespeed-cache'); ?>
13
- <?php echo __('Caching these pages may improve server performance by avoiding unnecessary PHP calls.', 'litespeed-cache'); ?>
14
- <i class="litespeed-warning">
15
- <?php echo __('NOTE:', 'litespeed-cache'); ?>
16
- <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
17
- </i>
18
- </div>
19
- </td>
20
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_inc.exclude_cookies.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
- ?>
4
-
5
- <tr>
6
- <th><?php echo __( 'Do Not Cache Cookies', 'litespeed-cache' ) ; ?></th>
7
- <td>
8
- <?php
9
- $id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES;
10
-
11
- $file_writable = LiteSpeed_Cache_Admin_Rules::writable();
12
-
13
- $this->build_textarea($id, str_replace('|', "\n", $_options[$id]));//, !$file_writable
14
- ?>
15
- <div class="litespeed-desc">
16
- <?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'cookies', 'litespeed-cache') ) ; ?>
17
- <i>
18
- <?php echo sprintf(__('Spaces should have a backslash in front of them, %s.', 'litespeed-cache'), '<code>\ </code>'); ?>
19
- <?php echo __('One per line.', 'litespeed-cache'); ?>
20
- </i>
21
- <i class="litespeed-warning">
22
- <?php echo __('NOTE:', 'litespeed-cache'); ?>
23
- <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
24
- </i>
25
- </div>
26
- </td>
27
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_inc.exclude_useragent.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
-
6
- <tr>
7
- <th><?php echo __( 'Do Not Cache User Agents', 'litespeed-cache' ) ; ?></th>
8
- <td>
9
- <?php
10
- $file_writable = LiteSpeed_Cache_Admin_Rules::writable();
11
-
12
- $this->build_input(LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS, 'litespeed-input-long');//, !$file_writable
13
- ?>
14
- <div class="litespeed-desc">
15
- <?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'user agents', 'litespeed-cache') ) ; ?>
16
- <i>
17
- <?php echo sprintf( __( 'SYNTAX: Separate each user agent with a bar, %s.', 'litespeed-cache' ), '<code>|</code>' ) ; ?>
18
- <?php echo sprintf( __( 'Spaces should have a backslash in front of them, %s.', 'litespeed-cache' ), '<code>\</code>' ) ; ?>
19
- </i>
20
- <i class="litespeed-warning">
21
- <?php echo __('NOTE:', 'litespeed-cache'); ?>
22
- <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
23
- </i>
24
- </div>
25
- </td>
26
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_inc.purge_on_upgrade.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
- <!-- build_setting_purge_on_upgrade -->
6
- <tr>
7
- <th><?php echo __('Purge All On Upgrade', 'litespeed-cache'); ?></th>
8
- <td>
9
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE); ?>
10
- <div class="litespeed-desc">
11
- <?php echo __('When enabled, the cache will automatically purge when any plugins, themes, or WordPress core is upgraded.', 'litespeed-cache'); ?>
12
- </div>
13
- </td>
14
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_optimize.php DELETED
@@ -1,182 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
-
5
- ?>
6
-
7
- <h3 class="litespeed-title"><?php echo __( 'Optimization Settings', 'litespeed-cache' ) ; ?></h3>
8
-
9
- <div class="litespeed-callout-warning">
10
- <h4><?php echo __( 'NOTICE:', 'litespeed-cache' ) ; ?></h4>
11
- <p><?php echo __( 'Please test thoroughly when enabling any option in this list. After changing Minify/Combine settings, please do a Purge All action.', 'litespeed-cache' ) ; ?></p>
12
- </div>
13
-
14
-
15
- <table><tbody>
16
- <tr>
17
- <th><?php echo __( 'CSS Minify', 'litespeed-cache' ) ; ?></th>
18
- <td>
19
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CSS_MINIFY ) ; ?>
20
- <div class="litespeed-desc">
21
- <?php echo __( 'Minify CSS files.', 'litespeed-cache' ) ; ?>
22
- </div>
23
- </td>
24
- </tr>
25
-
26
- <tr>
27
- <th><?php echo __( 'CSS Combine', 'litespeed-cache' ) ; ?></th>
28
- <td>
29
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CSS_COMBINE ) ; ?>
30
- <div class="litespeed-desc">
31
- <?php echo __( 'Combine CSS files.', 'litespeed-cache' ) ; ?>
32
- </div>
33
- </td>
34
- </tr>
35
-
36
- <tr>
37
- <th><?php echo __( 'CSS HTTP/2 Push', 'litespeed-cache' ) ; ?></th>
38
- <td>
39
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CSS_HTTP2 ) ; ?>
40
- <div class="litespeed-desc">
41
- <?php echo __( 'Pre-send internal CSS files to the browser before they are requested. (Requires the HTTP/2 protocol)', 'litespeed-cache' ) ; ?>
42
- </div>
43
- </td>
44
- </tr>
45
-
46
- <tr>
47
- <th><?php echo __( 'CSS Excludes', 'litespeed-cache' ) ; ?></th>
48
- <td>
49
- <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_CSS_EXCLUDES); ?>
50
- <div class="litespeed-desc">
51
- <?php echo __( 'Listed CSS files will not be minified/combined. The full URL or a partial string can be used.', 'litespeed-cache' ) ; ?>
52
- </div>
53
- </td>
54
- </tr>
55
-
56
- <tr>
57
- <th><?php echo __( 'JS Minify', 'litespeed-cache' ) ; ?></th>
58
- <td>
59
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_JS_MINIFY ) ; ?>
60
- <div class="litespeed-desc">
61
- <?php echo __( 'Minify JS files.', 'litespeed-cache' ) ; ?>
62
- </div>
63
- </td>
64
- </tr>
65
-
66
- <tr>
67
- <th><?php echo __( 'JS Combine', 'litespeed-cache' ) ; ?></th>
68
- <td>
69
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ; ?>
70
- <div class="litespeed-desc">
71
- <?php echo __( 'Combine JS files.', 'litespeed-cache' ) ; ?>
72
- </div>
73
- </td>
74
- </tr>
75
-
76
- <tr>
77
- <th><?php echo __( 'JS HTTP/2 Push', 'litespeed-cache' ) ; ?></th>
78
- <td>
79
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_JS_HTTP2 ) ; ?>
80
- <div class="litespeed-desc">
81
- <?php echo __( 'Pre-send internal JS files to the browser before they are requested. (Requires the HTTP/2 protocol)', 'litespeed-cache' ) ; ?>
82
- </div>
83
- </td>
84
- </tr>
85
-
86
- <tr>
87
- <th><?php echo __( 'JS Excludes', 'litespeed-cache' ) ; ?></th>
88
- <td>
89
- <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_JS_EXCLUDES); ?>
90
- <div class="litespeed-desc">
91
- <?php echo __( 'Listed JS files will not be minified/combined. The full URL or a partial string can be used.', 'litespeed-cache' ) ; ?>
92
- </div>
93
- </td>
94
- </tr>
95
-
96
- <tr>
97
- <th><?php echo __( 'CSS/JS Cache TTL', 'litespeed-cache' ) ; ?></th>
98
- <td>
99
- <?php $id = LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ; ?>
100
- <?php $this->build_input( $id ) ; ?> <?php echo __( 'seconds', 'litespeed-cache' ) ; ?>
101
- <div class="litespeed-desc">
102
- <?php echo sprintf( __( 'Specify how long, in seconds, CSS/JS files are cached. Minimum is %1$s seconds.', 'litespeed-cache' ), 3600 ) ; ?>
103
- <?php $this->recommended( $id ) ; ?>
104
- </div>
105
- </td>
106
- </tr>
107
-
108
- <tr>
109
- <th><?php echo __( 'HTML Minify', 'litespeed-cache' ) ; ?></th>
110
- <td>
111
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_HTML_MINIFY ) ; ?>
112
- <div class="litespeed-desc">
113
- <?php echo __( 'Minify HTML content.', 'litespeed-cache' ) ; ?>
114
- </div>
115
- </td>
116
- </tr>
117
-
118
- <tr>
119
- <th><?php echo __( 'Remove Query Strings', 'litespeed-cache' ) ; ?></th>
120
- <td>
121
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ; ?>
122
- <div class="litespeed-desc">
123
- <?php echo __( 'Remove query strings from static resources.', 'litespeed-cache' ) ; ?>
124
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
125
- </div>
126
- </td>
127
- </tr>
128
-
129
- <tr>
130
- <th><?php echo __( 'Remove Google Fonts', 'litespeed-cache' ) ; ?></th>
131
- <td>
132
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ; ?>
133
- <div class="litespeed-desc">
134
- <?php echo __( 'Prevent google fonts from loading on all your pages.', 'litespeed-cache' ) ; ?>
135
- </div>
136
- </td>
137
- </tr>
138
-
139
- <tr>
140
- <th><?php echo __( 'Load CSS Asynchronously', 'litespeed-cache' ) ; ?></th>
141
- <td>
142
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC ) ; ?>
143
- <div class="litespeed-desc">
144
- <?php echo __( 'Optimize CSS delivery. This will load Google Fonts asynchronously too.', 'litespeed-cache' ) ; ?>
145
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
146
- </div>
147
- </td>
148
- </tr>
149
-
150
- <tr>
151
- <th><?php echo __( 'Critical CSS Rules', 'litespeed-cache' ) ; ?></th>
152
- <td>
153
- <?php $this->build_textarea( LiteSpeed_Cache_Config::ITEM_OPTM_CSS, get_option( LiteSpeed_Cache_Config::ITEM_OPTM_CSS ) ) ; ?>
154
- <div class="litespeed-desc">
155
- <?php echo sprintf( __( 'Specify critical CSS rules for above-the-fold content when enabling %s.', 'litespeed-cache' ), __( 'Load CSS Asynchronously', 'litespeed-cache' ) ) ; ?>
156
- </div>
157
- </td>
158
- </tr>
159
-
160
- <tr>
161
- <th><?php echo __( 'Load JS Deferred', 'litespeed-cache' ) ; ?></th>
162
- <td>
163
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ; ?>
164
- <div class="litespeed-desc">
165
- <?php echo __( 'Doing so can help reduce resource contention and improve performance.', 'litespeed-cache' ) ; ?>
166
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
167
- </div>
168
- </td>
169
- </tr>
170
-
171
- <tr>
172
- <th><?php echo __( 'Remove WordPress Emoji', 'litespeed-cache' ) ; ?></th>
173
- <td>
174
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM ) ; ?>
175
- <div class="litespeed-desc">
176
- <?php echo __( 'Enable this setting to stop loading emoji from wordpress.org. The visitor\'s browser default emoji will be displayed instead.', 'litespeed-cache' ) ; ?>
177
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
178
- </div>
179
- </td>
180
- </tr>
181
-
182
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings_purge.php DELETED
@@ -1,95 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
- <h3 class="litespeed-title"><?php echo __('Purge Settings', 'litespeed-cache'); ?></h3>
6
-
7
- <?php
8
- $purge_options = LiteSpeed_Cache_Config::get_instance()->get_purge_options();
9
- $optionArr = array(
10
- LiteSpeed_Cache_Config::PURGE_ALL_PAGES => __('All pages', 'litespeed-cache'),
11
- LiteSpeed_Cache_Config::PURGE_FRONT_PAGE => __('Front page', 'litespeed-cache'),
12
- LiteSpeed_Cache_Config::PURGE_HOME_PAGE => __('Home page', 'litespeed-cache'),
13
- LiteSpeed_Cache_Config::PURGE_PAGES => __('Pages', 'litespeed-cache'),
14
-
15
- LiteSpeed_Cache_Config::PURGE_PAGES_WITH_RECENT_POSTS => __('All pages with Recent Posts Widget', 'litespeed-cache'),
16
-
17
- LiteSpeed_Cache_Config::PURGE_AUTHOR => __('Author archive', 'litespeed-cache'),
18
- LiteSpeed_Cache_Config::PURGE_POST_TYPE => __('Post type archive', 'litespeed-cache'),
19
-
20
- LiteSpeed_Cache_Config::PURGE_YEAR => __('Yearly archive', 'litespeed-cache'),
21
- LiteSpeed_Cache_Config::PURGE_MONTH => __('Monthly archive', 'litespeed-cache'),
22
- LiteSpeed_Cache_Config::PURGE_DATE => __('Daily archive', 'litespeed-cache'),
23
-
24
- LiteSpeed_Cache_Config::PURGE_TERM => __('Term archive (include category, tag, and tax)', 'litespeed-cache'),
25
- );
26
-
27
- // break line at these ids
28
- $breakArr = array(
29
- LiteSpeed_Cache_Config::PURGE_PAGES,
30
- LiteSpeed_Cache_Config::PURGE_PAGES_WITH_RECENT_POSTS,
31
- LiteSpeed_Cache_Config::PURGE_POST_TYPE,
32
- LiteSpeed_Cache_Config::PURGE_DATE,
33
- );
34
-
35
- ?>
36
-
37
- <table><tbody>
38
-
39
- <?php if (!is_multisite()): ?>
40
- <?php require LSWCP_DIR . 'admin/tpl/settings_inc.purge_on_upgrade.php'; ?>
41
- <?php endif; ?>
42
-
43
- <tr>
44
- <th><?php echo __('Auto Purge Rules For Publish/Update', 'litespeed-cache'); ?></th>
45
- <td>
46
- <div class="litespeed-callout-warning">
47
- <h4><?php echo __('Note:', 'litespeed-cache'); ?></h4>
48
- <i>
49
- <?php echo __('Select "All" if there are dynamic widgets linked to posts on pages other than the front or home pages.', 'litespeed-cache'); ?><br />
50
- <?php echo __('Other checkboxes will be ignored.', 'litespeed-cache'); ?><br />
51
- <?php echo __('Select only the archive types that are currently used, the others can be left unchecked.', 'litespeed-cache'); ?>
52
- </i>
53
- </div>
54
- <div class="litespeed-top20">
55
- <?php
56
- foreach ($optionArr as $id => $title){
57
-
58
- $this->build_checkbox("purge_$id", $title, in_array($id, $purge_options));
59
-
60
- if ( in_array($id, $breakArr) ){
61
- echo '</div><div class="litespeed-top20">';
62
- }
63
- }
64
- ?>
65
- </div>
66
- <div class="litespeed-desc">
67
- <?php echo __('Select which pages will be automatically purged when posts are published/updated.', 'litespeed-cache'); ?>
68
- </div>
69
- </td>
70
- </tr>
71
-
72
- <tr>
73
- <th><?php echo __( 'Scheduled Purge URLs', 'litespeed-cache' ) ; ?></th>
74
- <td>
75
- <?php $this->build_textarea( LiteSpeed_Cache_Config::OPID_TIMED_URLS, null, false, 80 ) ; ?>
76
- <div class="litespeed-desc">
77
- <?php echo sprintf( __( 'The URLs here (one per line) will be purged automatically at the time set in the option "%s".', 'litespeed-cache' ), __( 'Scheduled Purge Time', 'litespeed-cache' ) ) ; ?><br />
78
- <?php echo sprintf( __( 'Both %1$s and %2$s are acceptable.', 'litespeed-cache' ), '<i>http://www.example.com/path/url.php</i>', '<i>/path/url.php</i>' ) ; ?>
79
- </div>
80
- </td>
81
- </tr>
82
-
83
- <tr>
84
- <th><?php echo __( 'Scheduled Purge Time', 'litespeed-cache' ) ; ?></th>
85
- <td>
86
- <?php $id = LiteSpeed_Cache_Config::OPID_TIMED_URLS_TIME ; ?>
87
- <?php $this->build_input( $id, '', false, false, null, null, '', 'time' ) ; ?>
88
- <div class="litespeed-desc">
89
- <?php echo sprintf( __( 'Specify the time to purge the "%s" list.', 'litespeed-cache' ), __( 'Scheduled Purge URLs', 'litespeed-cache' ) ) ; ?>
90
- <?php echo sprintf( __( 'Current server time is %s.', 'litespeed-cache' ), '<i>' . date( 'H:i:s' ) . '</i>' ) ; ?>
91
- </div>
92
- </td>
93
- </tr>
94
- </tbody></table>
95
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/show_display_installed.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
-
5
- $buf = '<h3>'. __('LiteSpeed Cache plugin is installed!', 'litespeed-cache'). '</h3>' . ' '
6
- . __('This message indicates that the plugin was installed by the server admin.', 'litespeed-cache') . ' '
7
- . __('The LiteSpeed Cache plugin is used to cache pages - a simple way to improve the performance of the site.', 'litespeed-cache') . ' '
8
- . __('However, there is no way of knowing all the possible customizations that were implemented.', 'litespeed-cache') . ' '
9
- . __('For that reason, please test the site to make sure everything still functions properly.', 'litespeed-cache')
10
- . '<br /><br />'
11
- . __('Examples of test cases include:', 'litespeed-cache')
12
- . '<ul>'
13
- . '<li>' . __('Visit the site while logged out.', 'litespeed-cache') . '</li>'
14
- . '<li>' . __('Create a post, make sure the front page is accurate.', 'litespeed-cache') . '</li>'
15
- . '</ul>'
16
- . sprintf(__('If there are any questions, the team is always happy to answer any questions on the <a %s>support forum</a>.', 'litespeed-cache'),
17
- 'href="https://wordpress.org/support/plugin/litespeed-cache" rel="noopener noreferrer" target="_blank"')
18
- . '<br />'
19
- . __('If you would rather not move at litespeed, you can deactivate this plugin.', 'litespeed-cache');
20
-
21
- self::add_notice(self::NOTICE_BLUE . ' lscwp-whm-notice', $buf);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/show_error_cookie.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $err = __('NOTICE: Database login cookie did not match your login cookie.', 'litespeed-cache') . ' '
5
- . __('If the login cookie was recently changed in the settings, please log out and back in.', 'litespeed-cache') . ' '
6
- . sprintf(__('If not, please verify the setting in the <a href="%1$s">Advanced tab</a>.', 'litespeed-cache'),
7
- admin_url('admin.php?page=lscache-settings#advanced'));
8
-
9
- if (LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS') {
10
- $err .= ' ' . __('If using OpenLiteSpeed, the server must be restarted once for the changes to take effect.', 'litespeed-cache');
11
- }
12
-
13
- self::add_notice(self::NOTICE_YELLOW, $err);
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/show_rule_conflict.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
-
5
- $err = sprintf( __( 'Unexpected cache rule %2$s found in %1$s file. This rule may cause visitors to see old versions of pages due to the browser caching html pages. If you are sure that html pages are not being browser cached, this message can be dismissed. (<a %3$s>Learn More</a>)', 'litespeed-cache' ),
6
- '.htaccess',
7
- '`ExpiresDefault`',
8
- 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:troubleshooting:browser_displays_stale_content" target="_blank"'
9
- );
10
-
11
- // other plugin left cache expired rules in .htaccess which will cause conflicts
12
- echo self::build_notice( self::NOTICE_YELLOW . ' lscwp-notice-ruleconflict', $err ) ;
13
-
 
 
 
 
 
 
 
 
 
 
 
 
 
cli/class-litespeed-cache-cli-admin.php ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * LiteSpeed Cache Admin Interface
5
+ */
6
+ class LiteSpeed_Cache_Cli_Admin
7
+ {
8
+
9
+ private static $checkboxes;
10
+ private static $purges;
11
+
12
+ function __construct()
13
+ {
14
+ self::$checkboxes =
15
+ array(
16
+ LiteSpeed_Cache_Config::OPID_MOBILEVIEW_ENABLED,
17
+ LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE,
18
+ LiteSpeed_Cache_Config::OPID_CACHE_COMMENTERS,
19
+ LiteSpeed_Cache_Config::OPID_CACHE_LOGIN,
20
+ LiteSpeed_Cache_Config::OPID_CACHE_FAVICON,
21
+ LiteSpeed_Cache_Config::OPID_CACHE_RES,
22
+ LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE,
23
+ );
24
+ self::$purges =
25
+ array(
26
+ 'purge_' . LiteSpeed_Cache_Config::PURGE_ALL_PAGES =>
27
+ LiteSpeed_Cache_Config::PURGE_ALL_PAGES,
28
+ 'purge_' . LiteSpeed_Cache_Config::PURGE_FRONT_PAGE =>
29
+ LiteSpeed_Cache_Config::PURGE_FRONT_PAGE,
30
+ 'purge_' . LiteSpeed_Cache_Config::PURGE_HOME_PAGE =>
31
+ LiteSpeed_Cache_Config::PURGE_HOME_PAGE,
32
+ 'purge_' . LiteSpeed_Cache_Config::PURGE_AUTHOR =>
33
+ LiteSpeed_Cache_Config::PURGE_AUTHOR,
34
+ 'purge_' . LiteSpeed_Cache_Config::PURGE_YEAR =>
35
+ LiteSpeed_Cache_Config::PURGE_YEAR,
36
+ 'purge_' . LiteSpeed_Cache_Config::PURGE_MONTH =>
37
+ LiteSpeed_Cache_Config::PURGE_MONTH,
38
+ 'purge_' . LiteSpeed_Cache_Config::PURGE_DATE =>
39
+ LiteSpeed_Cache_Config::PURGE_DATE,
40
+ 'purge_' . LiteSpeed_Cache_Config::PURGE_TERM =>
41
+ LiteSpeed_Cache_Config::PURGE_TERM,
42
+ 'purge_' . LiteSpeed_Cache_Config::PURGE_POST_TYPE =>
43
+ LiteSpeed_Cache_Config::PURGE_POST_TYPE,
44
+ );
45
+ }
46
+
47
+ /**
48
+ * Set an individual LiteSpeed Cache option.
49
+ *
50
+ * ## OPTIONS
51
+ *
52
+ * <key>
53
+ * : The option key to update.
54
+ *
55
+ * <newvalue>
56
+ * : The new value to set the option to.
57
+ *
58
+ * ## EXAMPLES
59
+ *
60
+ * # Set to not cache the login page
61
+ * $ wp lscache-admin set_option cache_login false
62
+ *
63
+ */
64
+ function set_option($args, $assoc_args)
65
+ {
66
+ $plugin_dir = plugin_dir_path(dirname(__FILE__));
67
+ require_once $plugin_dir . 'admin/class-litespeed-cache-admin.php';
68
+ require_once $plugin_dir . 'admin/class-litespeed-cache-admin-display.php';
69
+ require_once $plugin_dir . 'admin/class-litespeed-cache-admin-rules.php';
70
+
71
+ $key = $args[0];
72
+ $val = $args[1];
73
+
74
+ $config = LiteSpeed_Cache::plugin()->get_config();
75
+ $options = $config->get_options();
76
+
77
+ if (!isset($options) || ((!isset($options[$key]))
78
+ && (!isset(self::$purges[$key])))) {
79
+ WP_CLI::error('The options array is empty or the key is not valid.');
80
+ return;
81
+ }
82
+
83
+ LiteSpeed_Cache_Config::convert_options_to_input($options);
84
+
85
+ switch ($key) {
86
+ case LiteSpeed_Cache_Config::OPID_VERSION:
87
+ //do not allow
88
+ WP_CLI::error('This option is not available for setting.');
89
+ return;
90
+ case LiteSpeed_Cache_Config::OPID_MOBILEVIEW_ENABLED:
91
+ // set list then do checkbox
92
+ if ($val === 'true') {
93
+ $options[LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST] =
94
+ 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi';
95
+ }
96
+ //fall through
97
+ case LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE:
98
+ case LiteSpeed_Cache_Config::OPID_CACHE_COMMENTERS:
99
+ case LiteSpeed_Cache_Config::OPID_CACHE_LOGIN:
100
+ case LiteSpeed_Cache_Config::OPID_CACHE_FAVICON:
101
+ case LiteSpeed_Cache_Config::OPID_CACHE_RES:
102
+ case LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE:
103
+ //checkbox
104
+ if ($val === 'true') {
105
+ $options['lscwp_' . $key] = $key;
106
+ }
107
+ elseif ($val === 'false') {
108
+ unset($options['lscwp_' . $key]);
109
+ }
110
+ else {
111
+ WP_CLI::error('Checkbox value must be true or false.');
112
+ return;
113
+ }
114
+ break;
115
+ case LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST:
116
+ $enable_key = LiteSpeed_Cache_Config::OPID_MOBILEVIEW_ENABLED;
117
+ if (!$options[$enable_key]) {
118
+ $options['lscwp_' . $enable_key] = $enable_key;
119
+ }
120
+ $options[$key] = $val;
121
+ break;
122
+ default:
123
+ if (substr($key, 0, 6) === 'purge_') {
124
+ if ($val === 'true') {
125
+ WP_CLI::line('key is ' . $key . ', substr is ' . substr($key, 6));
126
+ $options[$key] = substr($key, 6);
127
+ }
128
+ elseif ($val === 'false') {
129
+ unset($options[$key]);
130
+ }
131
+ else {
132
+ WP_CLI::error('Purge checkbox value must be true or false.');
133
+ return;
134
+ }
135
+ }
136
+ else {
137
+ // Everything else, just set the value
138
+ $options[$key] = $val;
139
+ }
140
+ break;
141
+ }
142
+
143
+ $admin = new LiteSpeed_Cache_Admin(LiteSpeed_Cache::PLUGIN_NAME,
144
+ LiteSpeed_Cache::PLUGIN_VERSION);
145
+
146
+ $output = $admin->validate_plugin_settings($options);
147
+
148
+ global $wp_settings_errors;
149
+
150
+ if (!empty($wp_settings_errors)) {
151
+ foreach ($wp_settings_errors as $err) {
152
+ WP_CLI::error($err['message']);
153
+ }
154
+ return;
155
+ }
156
+
157
+ $ret = update_option(LiteSpeed_Cache_Config::OPTION_NAME, $output);
158
+
159
+ if ($ret) {
160
+ WP_CLI::success('Options updated. Please purge the cache.');
161
+ }
162
+ else {
163
+ WP_CLI::error('No options updated.');
164
+ }
165
+
166
+
167
+ }
168
+
169
+ /**
170
+ * Get the plugin options.
171
+ *
172
+ * ## OPTIONS
173
+ *
174
+ * ## EXAMPLES
175
+ *
176
+ * # Get all options
177
+ * $ wp lscache-admin get_options
178
+ *
179
+ */
180
+ function get_options($args, $assoc_args)
181
+ {
182
+ $config = LiteSpeed_Cache::plugin()->get_config();
183
+ $options = $config->get_options();
184
+ $purge_options = $config->get_purge_options();
185
+ unset($options[LiteSpeed_Cache_Config::OPID_PURGE_BY_POST]);
186
+ $option_out = array();
187
+ $purge_diff = array_diff(self::$purges, $purge_options);
188
+ $purge_out = array();
189
+
190
+ $buf = WP_CLI::colorize("%CThe list of options:%n\n");
191
+ WP_CLI::line($buf);
192
+
193
+ foreach($options as $key => $value) {
194
+ if (in_array($key, self::$checkboxes)) {
195
+ if ($value) {
196
+ $value = 'true';
197
+ }
198
+ else {
199
+ $value = 'false';
200
+ }
201
+ }
202
+ elseif ($value === '') {
203
+ $value = "''";
204
+ }
205
+ $option_out[] = array('key' => $key, 'value' => $value);
206
+ }
207
+
208
+ foreach ($purge_options as $opt_name) {
209
+ $purge_out[] = array('key' => 'purge_' . $opt_name, 'value' => 'true');
210
+ }
211
+
212
+ foreach ($purge_diff as $opt_name) {
213
+ $purge_out[] = array('key' => 'purge_' . $opt_name, 'value' => 'false');
214
+ }
215
+
216
+ WP_CLI\Utils\format_items('table', $option_out, array('key', 'value'));
217
+
218
+ $buf = WP_CLI::colorize("%CThe list of PURGE ON POST UPDATE options:%n\n");
219
+ WP_CLI::line($buf);
220
+ WP_CLI\Utils\format_items('table', $purge_out, array('key', 'value'));
221
+ }
222
+
223
+ /**
224
+ * Export plugin options to a file.
225
+ *
226
+ * ## OPTIONS
227
+ *
228
+ * [--filename=<path>]
229
+ * : The default path used is CURRENTDIR/lscache_wp_options_DATE-TIME.txt.
230
+ * To select a different file, use this option.
231
+ *
232
+ * ## EXAMPLES
233
+ *
234
+ * # Export options to a file.
235
+ * $ wp lscache-admin export_options
236
+ *
237
+ */
238
+ function export_options($args, $assoc_args)
239
+ {
240
+ $options = LiteSpeed_Cache::plugin()->get_config()->get_options();
241
+ $output = '';
242
+ if (isset($assoc_args['filename'])) {
243
+ $file = $assoc_args['filename'];
244
+ }
245
+ else {
246
+ $file = getcwd() . '/lscache_wp_options_' . date('d_m_Y-His')
247
+ . '.txt';
248
+ }
249
+
250
+ if (!is_writable(dirname($file))) {
251
+ WP_CLI::error('Directory not writable.');
252
+ return;
253
+ }
254
+
255
+ foreach ($options as $key => $val)
256
+ {
257
+ $output .= sprintf("%s=%s\n", $key, $val);
258
+ }
259
+ $output .= "\n";
260
+
261
+ if (file_put_contents($file, $output) === false) {
262
+ WP_CLI::error('Failed to create file.');
263
+ }
264
+ else {
265
+ WP_CLI::success('Created file ' . $file);
266
+ }
267
+ }
268
+
269
+ /**
270
+ * Import plugin options from a file.
271
+ *
272
+ * The file must be formatted as such:
273
+ * option_key=option_value
274
+ * One per line.
275
+ * A Semicolon at the beginning of the line indicates a comment and will be skipped.
276
+ *
277
+ * ## OPTIONS
278
+ *
279
+ * <file>
280
+ * : The file to import options from.
281
+ *
282
+ * ## EXAMPLES
283
+ *
284
+ * # Import options from CURRENTDIR/options.txt
285
+ * $ wp lscache-admin import_options options.txt
286
+ *
287
+ */
288
+ function import_options($args, $assoc_args)
289
+ {
290
+ $file = $args[0];
291
+ if (!file_exists($file) || !is_readable($file)) {
292
+ WP_CLI::error('File does not exist or is not readable.');
293
+ }
294
+ $config = LiteSpeed_Cache::plugin()->get_config();
295
+ $content = file_get_contents($file);
296
+ preg_match_all("/^[^;][^=]+=[^=\n\r]*$/m", $content, $input);
297
+ $options = array();
298
+ $default = $config->get_options();
299
+
300
+ foreach ($input as $opt) {
301
+ $kv = explode('=', $opt);
302
+ $options[$kv[0]] = $kv[1];
303
+ }
304
+
305
+ LiteSpeed_Cache_Config::option_diff($default, $options);
306
+
307
+ LiteSpeed_Cache_Config::convert_options_to_input($options);
308
+
309
+ $admin = new LiteSpeed_Cache_Admin(LiteSpeed_Cache::PLUGIN_NAME,
310
+ LiteSpeed_Cache::PLUGIN_VERSION);
311
+
312
+ $output = $admin->validate_plugin_settings($options);
313
+
314
+ global $wp_settings_errors;
315
+
316
+ if (!empty($wp_settings_errors)) {
317
+ foreach ($wp_settings_errors as $err) {
318
+ WP_CLI::error($err['message']);
319
+ }
320
+ return;
321
+ }
322
+ WP_CLI::success('Options updated. Please purge the cache. New options: '
323
+ . print_r($output, true));
324
+
325
+ }
326
+ }
327
+
328
+ WP_CLI::add_command( 'lscache-admin', 'LiteSpeed_Cache_Cli_Admin' );
cli/class-litespeed-cache-cli-purge.php ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * LiteSpeed Cache Purge Interface
5
+ */
6
+ class LiteSpeed_Cache_Cli_Purge
7
+ {
8
+
9
+ /**
10
+ * Sends an ajax request to the site. Takes an action and the nonce string
11
+ * to perform.
12
+ *
13
+ * @since 1.0.14
14
+ * @param string $action The action to perform
15
+ * @param string $nonce_val The value to use for the nonce.
16
+ * @param array $extra Any extra parameters needed to be sent.
17
+ * @return mixed The http request return.
18
+ */
19
+ private function send_request($action, $nonce_val, $extra = array())
20
+ {
21
+ $nonce = wp_create_nonce($nonce_val);
22
+
23
+ $data = array(
24
+ 'action' => 'lscache_cli',
25
+ LiteSpeed_Cache::ADMINQS_KEY => $action,
26
+ '_wpnonce' => $nonce
27
+ );
28
+ if (!empty($extra)) {
29
+ $data = array_merge($data, $extra);
30
+ }
31
+
32
+ $url = admin_url('admin-ajax.php');
33
+ WP_CLI::debug('url is ' . $url);
34
+
35
+ $out = WP_CLI\Utils\http_request('GET', $url, $data);
36
+ return $out;
37
+ }
38
+
39
+ /**
40
+ * Purges all cache entries for the blog (the entire network if multisite).
41
+ *
42
+ * ## EXAMPLES
43
+ *
44
+ * # Purge Everything associated with the WordPress install.
45
+ * $ wp lscache-purge all
46
+ *
47
+ */
48
+ function all($args, $assoc_args)
49
+ {
50
+ if (is_multisite()) {
51
+ $nonce_val = LiteSpeed_Cache::ADMINNONCE_PURGENETWORKALL;
52
+ }
53
+ else {
54
+ $nonce_val = LiteSpeed_Cache::ADMINNONCE_PURGEALL;
55
+ }
56
+
57
+ $purge_ret = $this->send_request(LiteSpeed_Cache::ADMINQS_PURGEALL,
58
+ $nonce_val);
59
+ if ($purge_ret->success) {
60
+ WP_CLI::success(__('Purged All!', 'litespeed-cache'));
61
+ }
62
+ else {
63
+ WP_CLI::error('Something went wrong! Got '
64
+ . $purge_ret->status_code);
65
+ }
66
+ }
67
+
68
+ /**
69
+ * List all site domains and ids on the network.
70
+ *
71
+ * For use with the blog subcommand.
72
+ *
73
+ * ## EXAMPLES
74
+ *
75
+ * # List all the site domains and ids in a table.
76
+ * $ wp lscache-purge network_list
77
+ */
78
+ function network_list($args, $assoc_args)
79
+ {
80
+ if (!is_multisite()) {
81
+ WP_CLI::error('This is not a multisite installation!');
82
+
83
+ return;
84
+ }
85
+ $buf = WP_CLI::colorize("%CThe list of installs:%n\n");
86
+
87
+ if (version_compare($GLOBALS['wp_version'], '4.6', '<')) {
88
+ $sites = wp_get_sites();
89
+ foreach ($sites as $site) {
90
+ $buf .= WP_CLI::colorize('%Y' . $site['domain'] . $site['path']
91
+ . ':%n ID ' . $site['blog_id']) . "\n";
92
+ }
93
+ }
94
+ else {
95
+ $sites = get_sites();
96
+ foreach ($sites as $site) {
97
+ $buf .= WP_CLI::colorize('%Y' . $site->domain . $site->path
98
+ . ':%n ID ' . $site->blog_id) . "\n";
99
+ }
100
+ }
101
+
102
+ WP_CLI::line($buf);
103
+ }
104
+
105
+ /**
106
+ * Purges all cache entries for the blog.
107
+ *
108
+ * ## OPTIONS
109
+ *
110
+ * <blogid>
111
+ * : The blog id to purge
112
+ *
113
+ * ## EXAMPLES
114
+ *
115
+ * # In a multisite install, purge only the shop.example.com cache (stored as blog id 2).
116
+ * $ wp lscache-purge blog 2
117
+ *
118
+ */
119
+ function blog($args, $assoc_args)
120
+ {
121
+ if (!is_multisite()) {
122
+ WP_CLI::error('Not a multisite installation.');
123
+ return;
124
+ }
125
+ $blogid = $args[0];
126
+ if (!is_numeric($blogid)) {
127
+ $error = WP_CLI::colorize('%RError: invalid blog id entered.%n');
128
+ WP_CLI::line($error);
129
+ $this->network_list($args, $assoc_args);
130
+ return;
131
+ }
132
+ $site = get_blog_details($blogid);
133
+ if ($site === false) {
134
+ $error = WP_CLI::colorize('%RError: invalid blog id entered.%n');
135
+ WP_CLI::line($error);
136
+ $this->network_list($args, $assoc_args);
137
+ return;
138
+ }
139
+ switch_to_blog($blogid);
140
+
141
+ $purge_ret = $this->send_request(LiteSpeed_Cache::ADMINQS_PURGEALL,
142
+ LiteSpeed_Cache::ADMINNONCE_PURGEALL);
143
+ if ($purge_ret->success) {
144
+ WP_CLI::success(__('Purged the blog!', 'litespeed-cache'));
145
+ }
146
+ else {
147
+ WP_CLI::error('Something went wrong! Got '
148
+ . $purge_ret->status_code);
149
+ }
150
+ }
151
+
152
+ /**
153
+ * Purges all cache tags related to a url.
154
+ *
155
+ * ## OPTIONS
156
+ *
157
+ * <url>
158
+ * : The url to purge.
159
+ *
160
+ * ## EXAMPLES
161
+ *
162
+ * # Purge the front page.
163
+ * $ wp lscache-purge url https://mysite.com/
164
+ *
165
+ */
166
+ function url($args, $assoc_args)
167
+ {
168
+ $data = array(
169
+ LiteSpeed_Cache::ADMINQS_KEY => LiteSpeed_Cache::ADMINQS_PURGE,
170
+ );
171
+ $url = $args[0];
172
+ $deconstructed = wp_parse_url($url);
173
+ if (empty($deconstructed)) {
174
+ WP_CLI::error('url passed in is invalid.');
175
+ return;
176
+ }
177
+
178
+ if (is_multisite()) {
179
+ if (get_blog_id_from_url($deconstructed['host'], '/') === 0) {
180
+ WP_CLI::error('Multisite url passed in is invalid.');
181
+ return;
182
+ }
183
+ }
184
+ else {
185
+ $site_url = get_site_url();
186
+ $deconstructed_site = wp_parse_url($site_url);
187
+ if ($deconstructed['host'] !== $deconstructed_site['host']) {
188
+ WP_CLI::error('Single site url passed in is invalid.');
189
+ return;
190
+ }
191
+ }
192
+
193
+ WP_CLI::debug('url is ' . $url);
194
+
195
+ $purge_ret = WP_CLI\Utils\http_request('GET', $url, $data);
196
+ if ($purge_ret->success) {
197
+ WP_CLI::success(__('Purged the url!', 'litespeed-cache'));
198
+ }
199
+ else {
200
+ WP_CLI::error('Something went wrong! Got '
201
+ . $purge_ret->status_code);
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Helper function for purging by ids.
207
+ *
208
+ * @access private
209
+ * @since 1.0.15
210
+ * @param array $args The id list to parse.
211
+ * @param string $prefix
212
+ * @param function(int $id) $callback The callback function to check the id.
213
+ */
214
+ private function purgeby_helper($args, $prefix, $callback)
215
+ {
216
+ $filtered = array();
217
+ foreach ($args as $val) {
218
+ if (!ctype_digit($val)) {
219
+ WP_CLI::debug('[LSCACHE] Skip val, not a number. ' . $val);
220
+ continue;
221
+ }
222
+ $term = $callback($val);
223
+ if (!empty($term)) {
224
+ $filtered[] = $prefix . $val;
225
+ }
226
+ else {
227
+ WP_CLI::debug('[LSCACHE] Skip val, not a valid term. ' . $val);
228
+ }
229
+ }
230
+
231
+ if (empty($filtered)) {
232
+ WP_CLI::error('Arguments must be integer ids.');
233
+ return;
234
+ }
235
+
236
+ $str = implode(',', $filtered);
237
+
238
+ WP_CLI::line('Will purge the following cache tags: ' . $str);
239
+
240
+ $purge_ret = $this->send_request(LiteSpeed_Cache::ADMINQS_PURGEBY,
241
+ LiteSpeed_Cache::ADMINNONCE_PURGEBY, array('purge_tags' => $str));
242
+ if ($purge_ret->success) {
243
+ WP_CLI::success(__('Purged the tags!', 'litespeed-cache'));
244
+ }
245
+ else {
246
+ WP_CLI::error('Something went wrong! Got '
247
+ . $purge_ret->status_code);
248
+ }
249
+
250
+ }
251
+
252
+ /**
253
+ * Purges all cache tags for a WordPress tag
254
+ *
255
+ * ## OPTIONS
256
+ *
257
+ * <ids>...
258
+ * : the Term IDs to purge.
259
+ *
260
+ * ## EXAMPLES
261
+ *
262
+ * # Purge the tag ids 1, 3, and 5
263
+ * $ wp lscache-purge tag 1 3 5
264
+ *
265
+ */
266
+ function tag($args, $assoc_args)
267
+ {
268
+ $this->purgeby_helper($args,
269
+ LiteSpeed_Cache_Tags::TYPE_ARCHIVE_TERM, 'get_tag');
270
+ }
271
+
272
+ /**
273
+ * Purges all cache tags for a WordPress category
274
+ *
275
+ * ## OPTIONS
276
+ *
277
+ * <ids>...
278
+ * : the Term IDs to purge.
279
+ *
280
+ * ## EXAMPLES
281
+ *
282
+ * # Purge the category ids 1, 3, and 5
283
+ * $ wp lscache-purge category 1 3 5
284
+ *
285
+ */
286
+ function category($args, $assoc_args)
287
+ {
288
+ $this->purgeby_helper($args,
289
+ LiteSpeed_Cache_Tags::TYPE_ARCHIVE_TERM, 'get_category');
290
+ }
291
+
292
+ /**
293
+ * Purges all cache tags for a WordPress Post/Product
294
+ *
295
+ * @alias product
296
+ *
297
+ * ## OPTIONS
298
+ *
299
+ * <ids>...
300
+ * : the Post IDs to purge.
301
+ *
302
+ * ## EXAMPLES
303
+ *
304
+ * # Purge the post ids 1, 3, and 5
305
+ * $ wp lscache-purge post_id 1 3 5
306
+ *
307
+ */
308
+ function post_id($args, $assoc_args)
309
+ {
310
+ $this->purgeby_helper($args,
311
+ LiteSpeed_Cache_Tags::TYPE_POST, 'get_post');
312
+ }
313
+
314
+ }
315
+
316
+ WP_CLI::add_command( 'lscache-purge', 'LiteSpeed_Cache_Cli_Purge' );
cli/litespeed-cache-cli-admin.class.php DELETED
@@ -1,363 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * LiteSpeed Cache Admin Interface
5
- */
6
- class LiteSpeed_Cache_Cli_Admin
7
- {
8
-
9
- private static $checkboxes ;
10
- private static $purges ;
11
-
12
- public function __construct()
13
- {
14
- self::$checkboxes = array(
15
- LiteSpeed_Cache_Config::OPID_CACHE_PRIV,
16
- LiteSpeed_Cache_Config::OPID_CACHE_COMMENTER,
17
- LiteSpeed_Cache_Config::OPID_CACHE_REST,
18
- LiteSpeed_Cache_Config::OPID_CACHE_PAGE_LOGIN,
19
- LiteSpeed_Cache_Config::OPID_CACHE_MOBILE,
20
- LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE,
21
- LiteSpeed_Cache_Config::OPID_CACHE_FAVICON,
22
- LiteSpeed_Cache_Config::OPID_CACHE_RES,
23
- LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE,
24
- LiteSpeed_Cache_Config::OPID_ESI_ENABLE,
25
- LiteSpeed_Cache_Config::OPID_ESI_CACHE_ADMBAR,
26
- LiteSpeed_Cache_Config::OPID_ESI_CACHE_COMMFORM,
27
- LiteSpeed_Cache_Config::CRWL_POSTS,
28
- LiteSpeed_Cache_Config::CRWL_PAGES,
29
- LiteSpeed_Cache_Config::CRWL_CATS,
30
- LiteSpeed_Cache_Config::CRWL_TAGS,
31
- LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE,
32
- LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
33
- LiteSpeed_Cache_Config::OPID_HEARTBEAT,
34
- LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE,
35
- LiteSpeed_Cache_Config::OPID_COLLAPS_QS,
36
- LiteSpeed_Cache_Config::OPID_LOG_FILTERS,
37
-
38
- LiteSpeed_Cache_Config::OPID_CSS_MINIFY,
39
- LiteSpeed_Cache_Config::OPID_CSS_COMBINE,
40
- LiteSpeed_Cache_Config::OPID_CSS_HTTP2,
41
- LiteSpeed_Cache_Config::OPID_JS_MINIFY,
42
- LiteSpeed_Cache_Config::OPID_JS_COMBINE,
43
- LiteSpeed_Cache_Config::OPID_JS_HTTP2,
44
- LiteSpeed_Cache_Config::OPID_HTML_MINIFY,
45
- LiteSpeed_Cache_Config::OPID_OPTM_QS_RM,
46
- LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM,
47
- LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC,
48
- LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER,
49
- LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM,
50
-
51
- LiteSpeed_Cache_Config::OPID_CDN,
52
- LiteSpeed_Cache_Config::OPID_CDN_INC_IMG,
53
- LiteSpeed_Cache_Config::OPID_CDN_INC_CSS,
54
- LiteSpeed_Cache_Config::OPID_CDN_INC_JS,
55
- ) ;
56
- self::$purges = array(
57
- 'purge_' . LiteSpeed_Cache_Config::PURGE_ALL_PAGES => LiteSpeed_Cache_Config::PURGE_ALL_PAGES,
58
- 'purge_' . LiteSpeed_Cache_Config::PURGE_FRONT_PAGE => LiteSpeed_Cache_Config::PURGE_FRONT_PAGE,
59
- 'purge_' . LiteSpeed_Cache_Config::PURGE_HOME_PAGE => LiteSpeed_Cache_Config::PURGE_HOME_PAGE,
60
- 'purge_' . LiteSpeed_Cache_Config::PURGE_AUTHOR => LiteSpeed_Cache_Config::PURGE_AUTHOR,
61
- 'purge_' . LiteSpeed_Cache_Config::PURGE_YEAR => LiteSpeed_Cache_Config::PURGE_YEAR,
62
- 'purge_' . LiteSpeed_Cache_Config::PURGE_MONTH => LiteSpeed_Cache_Config::PURGE_MONTH,
63
- 'purge_' . LiteSpeed_Cache_Config::PURGE_DATE => LiteSpeed_Cache_Config::PURGE_DATE,
64
- 'purge_' . LiteSpeed_Cache_Config::PURGE_TERM => LiteSpeed_Cache_Config::PURGE_TERM,
65
- 'purge_' . LiteSpeed_Cache_Config::PURGE_POST_TYPE => LiteSpeed_Cache_Config::PURGE_POST_TYPE,
66
- ) ;
67
- }
68
-
69
- /**
70
- * Set an individual LiteSpeed Cache option.
71
- *
72
- * ## OPTIONS
73
- *
74
- * <key>
75
- * : The option key to update.
76
- *
77
- * <newvalue>
78
- * : The new value to set the option to.
79
- *
80
- * ## EXAMPLES
81
- *
82
- * # Set to not cache the login page
83
- * $ wp lscache-admin set_option cache_login false
84
- *
85
- */
86
- public function set_option($args, $assoc_args)
87
- {
88
- $key = $args[0] ;
89
- $val = $args[1] ;
90
-
91
- $options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
92
-
93
- if ( ! isset($options) || ( ! isset($options[$key]) && ! isset(self::$purges[$key])) ) {
94
- WP_CLI::error('The options array is empty or the key is not valid.') ;
95
- return ;
96
- }
97
-
98
- $options = LiteSpeed_Cache_Config::convert_options_to_input($options) ;
99
-
100
- switch ($key) {
101
- case LiteSpeed_Cache_Config::OPID_VERSION:
102
- //do not allow
103
- WP_CLI::error('This option is not available for setting.') ;
104
- return ;
105
-
106
- case LiteSpeed_Cache_Config::OPID_CACHE_MOBILE:
107
- // set list then do checkbox
108
- if ( $val === 'true' && empty( $options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] ) ) {
109
- $options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] = 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi' ;
110
- }
111
- //fall through
112
- case LiteSpeed_Cache_Config::OPID_CACHE_PRIV:
113
- case LiteSpeed_Cache_Config::OPID_CACHE_COMMENTER:
114
- case LiteSpeed_Cache_Config::OPID_CACHE_REST:
115
- case LiteSpeed_Cache_Config::OPID_CACHE_PAGE_LOGIN:
116
- case LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE:
117
- case LiteSpeed_Cache_Config::OPID_CACHE_FAVICON:
118
- case LiteSpeed_Cache_Config::OPID_CACHE_RES:
119
- case LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE:
120
- case LiteSpeed_Cache_Config::OPID_ESI_ENABLE:
121
- case LiteSpeed_Cache_Config::OPID_ESI_CACHE_ADMBAR:
122
- case LiteSpeed_Cache_Config::OPID_ESI_CACHE_COMMFORM:
123
- case LiteSpeed_Cache_Config::CRWL_POSTS:
124
- case LiteSpeed_Cache_Config::CRWL_PAGES:
125
- case LiteSpeed_Cache_Config::CRWL_CATS:
126
- case LiteSpeed_Cache_Config::CRWL_TAGS:
127
- case LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE:
128
- case LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL:
129
- case LiteSpeed_Cache_Config::OPID_HEARTBEAT:
130
- case LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE:
131
- case LiteSpeed_Cache_Config::OPID_COLLAPS_QS:
132
- case LiteSpeed_Cache_Config::OPID_LOG_FILTERS:
133
-
134
- case LiteSpeed_Cache_Config::OPID_CSS_MINIFY:
135
- case LiteSpeed_Cache_Config::OPID_CSS_COMBINE:
136
- case LiteSpeed_Cache_Config::OPID_JS_MINIFY:
137
- case LiteSpeed_Cache_Config::OPID_JS_COMBINE:
138
- case LiteSpeed_Cache_Config::OPID_HTML_MINIFY:
139
- case LiteSpeed_Cache_Config::OPID_OPTM_QS_RM:
140
- case LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM:
141
- case LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC:
142
- case LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER:
143
- case LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM:
144
-
145
- case LiteSpeed_Cache_Config::OPID_CDN:
146
- case LiteSpeed_Cache_Config::OPID_CDN_INC_IMG:
147
- case LiteSpeed_Cache_Config::OPID_CDN_INC_CSS:
148
- case LiteSpeed_Cache_Config::OPID_CDN_INC_JS:
149
- //checkbox
150
- if ( $val === 'true' ) {
151
- $options[$key] = LiteSpeed_Cache_Config::VAL_ON ;
152
- }
153
- elseif ( $val === 'false' ) {
154
- unset($options[$key]) ;
155
- }
156
- else {
157
- WP_CLI::error('Checkbox value must be true or false.') ;
158
- return ;
159
- }
160
- break ;
161
-
162
- case LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST:
163
- $enable_key = LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ;
164
- if ( ! isset($options[$enable_key]) || ! $options[$enable_key] ) {
165
- $options[$enable_key] = LiteSpeed_Cache_Config::VAL_ON ;
166
- }
167
- $options[$key] = $val ;
168
- break ;
169
-
170
- default:
171
- if ( substr($key, 0, 6) === 'purge_' ) {
172
- if ( $val === 'true' ) {
173
- WP_CLI::line('key is ' . $key . ', val is ' . $val) ;
174
- $options[$key] = LiteSpeed_Cache_Config::VAL_ON ;
175
- }
176
- elseif ( $val === 'false' ) {
177
- unset($options[$key]) ;
178
- }
179
- else {
180
- WP_CLI::error('Purge checkbox value must be true or false.') ;
181
- return ;
182
- }
183
- }
184
- else {
185
- // Everything else, just set the value
186
- $options[$key] = $val ;
187
- }
188
- break ;
189
- }
190
-
191
- $this->_update_options($options) ;
192
- }
193
-
194
- /**
195
- * Get the plugin options.
196
- *
197
- * ## OPTIONS
198
- *
199
- * ## EXAMPLES
200
- *
201
- * # Get all options
202
- * $ wp lscache-admin get_options
203
- *
204
- */
205
- public function get_options($args, $assoc_args)
206
- {
207
- $options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
208
- $purge_options = LiteSpeed_Cache_Config::get_instance()->get_purge_options() ;
209
- unset($options[LiteSpeed_Cache_Config::OPID_PURGE_BY_POST]) ;
210
- $option_out = array() ;
211
- $purge_diff = array_diff(self::$purges, $purge_options) ;
212
- $purge_out = array() ;
213
-
214
- $buf = WP_CLI::colorize("%CThe list of options:%n\n") ;
215
- WP_CLI::line($buf) ;
216
-
217
- foreach($options as $key => $value) {
218
- if ( in_array($key, self::$checkboxes) ) {
219
- if ( $value ) {
220
- $value = 'true' ;
221
- }
222
- else {
223
- $value = 'false' ;
224
- }
225
- }
226
- elseif ( $value === '' ) {
227
- $value = "''" ;
228
- }
229
- $option_out[] = array('key' => $key, 'value' => $value) ;
230
- }
231
-
232
- foreach ($purge_options as $opt_name) {
233
- $purge_out[] = array('key' => 'purge_' . $opt_name, 'value' => 'true') ;
234
- }
235
-
236
- foreach ($purge_diff as $opt_name) {
237
- $purge_out[] = array('key' => 'purge_' . $opt_name, 'value' => 'false') ;
238
- }
239
-
240
- WP_CLI\Utils\format_items('table', $option_out, array('key', 'value')) ;
241
-
242
- $buf = WP_CLI::colorize("%CThe list of PURGE ON POST UPDATE options:%n\n") ;
243
- WP_CLI::line($buf) ;
244
- WP_CLI\Utils\format_items('table', $purge_out, array('key', 'value')) ;
245
- }
246
-
247
- /**
248
- * Export plugin options to a file.
249
- *
250
- * ## OPTIONS
251
- *
252
- * [--filename=<path>]
253
- * : The default path used is CURRENTDIR/lscache_wp_options_DATE-TIME.txt.
254
- * To select a different file, use this option.
255
- *
256
- * ## EXAMPLES
257
- *
258
- * # Export options to a file.
259
- * $ wp lscache-admin export_options
260
- *
261
- */
262
- public function export_options($args, $assoc_args)
263
- {
264
- $options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
265
- $output = '' ;
266
- if ( isset($assoc_args['filename']) ) {
267
- $file = $assoc_args['filename'] ;
268
- }
269
- else {
270
- $file = getcwd() . '/lscache_wp_options_' . date('d_m_Y-His') . '.txt' ;
271
- }
272
-
273
- if ( ! is_writable(dirname($file)) ) {
274
- WP_CLI::error('Directory not writable.') ;
275
- return ;
276
- }
277
-
278
- foreach ($options as $key => $val) {
279
- $output .= sprintf("%s=%s\n", $key, $val) ;
280
- }
281
- $output .= "\n" ;
282
-
283
- if ( file_put_contents($file, $output) === false ) {
284
- WP_CLI::error('Failed to create file.') ;
285
- }
286
- else {
287
- WP_CLI::success('Created file ' . $file) ;
288
- }
289
- }
290
-
291
- /**
292
- * Import plugin options from a file.
293
- *
294
- * The file must be formatted as such:
295
- * option_key=option_value
296
- * One per line.
297
- * A Semicolon at the beginning of the line indicates a comment and will be skipped.
298
- *
299
- * ## OPTIONS
300
- *
301
- * <file>
302
- * : The file to import options from.
303
- *
304
- * ## EXAMPLES
305
- *
306
- * # Import options from CURRENTDIR/options.txt
307
- * $ wp lscache-admin import_options options.txt
308
- *
309
- */
310
- public function import_options($args, $assoc_args)
311
- {
312
- $file = $args[0] ;
313
- if ( ! file_exists($file) || ! is_readable($file) ) {
314
- WP_CLI::error('File does not exist or is not readable.') ;
315
- }
316
- $content = file_get_contents($file) ;
317
- preg_match_all("/^[^;][^=]+=[^=\n\r]*$/m", $content, $input) ;
318
- $options = array() ;
319
- $default = LiteSpeed_Cache_Config::get_instance()->get_options() ;
320
-
321
- foreach ($input[0] as $opt) {
322
- $kv = explode('=', $opt) ;
323
- $options[$kv[0]] = $kv[1] ;
324
- }
325
-
326
- $options = LiteSpeed_Cache_Config::option_diff($default, $options) ;
327
-
328
- $options = LiteSpeed_Cache_Config::convert_options_to_input($options) ;
329
-
330
- $this->_update_options($options) ;
331
- }
332
-
333
- /**
334
- * Update options
335
- *
336
- * @access private
337
- * @since 1.1.0
338
- * @param array $options The options array to store
339
- */
340
- private function _update_options($options)
341
- {
342
- $output = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings($options) ;
343
-
344
- global $wp_settings_errors ;
345
-
346
- if ( ! empty($wp_settings_errors) ) {
347
- foreach ($wp_settings_errors as $err) {
348
- WP_CLI::error($err['message']) ;
349
- }
350
- return ;
351
- }
352
-
353
- $ret = LiteSpeed_Cache_Config::get_instance()->update_options($output) ;
354
-
355
- if ( $ret ) {
356
- WP_CLI::success('Options updated. Please purge the cache. New options: ' . var_export($output, true)) ;
357
- }
358
- else {
359
- WP_CLI::error('No options updated.') ;
360
- }
361
- }
362
- }
363
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cli/litespeed-cache-cli-purge.class.php DELETED
@@ -1,302 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * LiteSpeed Cache Purge Interface
5
- */
6
- class LiteSpeed_Cache_Cli_Purge
7
- {
8
- /**
9
- * List all site domains and ids on the network.
10
- *
11
- * For use with the blog subcommand.
12
- *
13
- * ## EXAMPLES
14
- *
15
- * # List all the site domains and ids in a table.
16
- * $ wp lscache-purge network_list
17
- */
18
- public function network_list($args, $assoc_args)
19
- {
20
- if ( ! is_multisite() ) {
21
- WP_CLI::error('This is not a multisite installation!') ;
22
-
23
- return ;
24
- }
25
- $buf = WP_CLI::colorize("%CThe list of installs:%n\n") ;
26
-
27
- if ( version_compare($GLOBALS['wp_version'], '4.6', '<') ) {
28
- $sites = wp_get_sites() ;
29
- foreach ($sites as $site) {
30
- $buf .= WP_CLI::colorize('%Y' . $site['domain'] . $site['path'] . ':%n ID ' . $site['blog_id']) . "\n" ;
31
- }
32
- }
33
- else {
34
- $sites = get_sites() ;
35
- foreach ($sites as $site) {
36
- $buf .= WP_CLI::colorize('%Y' . $site->domain . $site->path . ':%n ID ' . $site->blog_id) . "\n" ;
37
- }
38
- }
39
-
40
- WP_CLI::line($buf) ;
41
- }
42
-
43
- /**
44
- * Sends an ajax request to the site. Takes an action and the nonce string
45
- * to perform.
46
- *
47
- * @since 1.0.14
48
- * @param string $action The action to perform
49
- * @param array $extra Any extra parameters needed to be sent.
50
- * @return mixed The http request return.
51
- */
52
- private function _send_request($action, $extra = array())
53
- {
54
- $data = array(
55
- LiteSpeed_Cache::ACTION_KEY => $action,
56
- LiteSpeed_Cache::NONCE_NAME => wp_create_nonce($action),
57
- ) ;
58
- if ( ! empty($extra) ) {
59
- $data = array_merge($data, $extra) ;
60
- }
61
-
62
- $url = admin_url('admin-ajax.php') ;
63
- WP_CLI::debug('url is ' . $url) ;
64
-
65
- $out = WP_CLI\Utils\http_request('GET', $url, $data) ;
66
- return $out ;
67
- }
68
-
69
- /**
70
- * Purges all cache entries for the blog (the entire network if multisite).
71
- *
72
- * ## EXAMPLES
73
- *
74
- * # Purge Everything associated with the WordPress install.
75
- * $ wp lscache-purge all
76
- *
77
- */
78
- public function all( $args, $assoc_args )
79
- {
80
- if ( is_multisite() ) {
81
- $action = LiteSpeed_Cache::ACTION_QS_PURGE_EMPTYCACHE ;
82
- }
83
- else {
84
- $action = LiteSpeed_Cache::ACTION_QS_PURGE_ALL ;
85
- }
86
-
87
- $purge_ret = $this->_send_request( $action ) ;
88
-
89
- if ( $purge_ret->success ) {
90
- WP_CLI::success(__('Purged All!', 'litespeed-cache')) ;
91
- }
92
- else {
93
- WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code) ;
94
- }
95
- }
96
-
97
- /**
98
- * Purges all cache entries for the blog.
99
- *
100
- * ## OPTIONS
101
- *
102
- * <blogid>
103
- * : The blog id to purge
104
- *
105
- * ## EXAMPLES
106
- *
107
- * # In a multisite install, purge only the shop.example.com cache (stored as blog id 2).
108
- * $ wp lscache-purge blog 2
109
- *
110
- */
111
- public function blog($args, $assoc_args)
112
- {
113
- if ( ! is_multisite() ) {
114
- WP_CLI::error('Not a multisite installation.') ;
115
- return ;
116
- }
117
- $blogid = $args[0] ;
118
- if ( ! is_numeric($blogid) ) {
119
- $error = WP_CLI::colorize('%RError: invalid blog id entered.%n') ;
120
- WP_CLI::line($error) ;
121
- $this->network_list($args, $assoc_args) ;
122
- return ;
123
- }
124
- $site = get_blog_details($blogid) ;
125
- if ( $site === false ) {
126
- $error = WP_CLI::colorize('%RError: invalid blog id entered.%n') ;
127
- WP_CLI::line($error) ;
128
- $this->network_list($args, $assoc_args) ;
129
- return ;
130
- }
131
- switch_to_blog($blogid) ;
132
-
133
- $purge_ret = $this->_send_request(LiteSpeed_Cache::ACTION_QS_PURGE_ALL) ;
134
- if ( $purge_ret->success ) {
135
- WP_CLI::success(__('Purged the blog!', 'litespeed-cache')) ;
136
- }
137
- else {
138
- WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code) ;
139
- }
140
- }
141
-
142
- /**
143
- * Purges all cache tags related to a url.
144
- *
145
- * ## OPTIONS
146
- *
147
- * <url>
148
- * : The url to purge.
149
- *
150
- * ## EXAMPLES
151
- *
152
- * # Purge the front page.
153
- * $ wp lscache-purge url https://mysite.com/
154
- *
155
- */
156
- public function url($args, $assoc_args)
157
- {
158
- $data = array(
159
- LiteSpeed_Cache::ACTION_KEY => LiteSpeed_Cache::ACTION_QS_PURGE,
160
- ) ;
161
- $url = $args[0] ;
162
- $deconstructed = wp_parse_url($url) ;
163
- if ( empty($deconstructed) ) {
164
- WP_CLI::error('url passed in is invalid.') ;
165
- return ;
166
- }
167
-
168
- if ( is_multisite() ) {
169
- if ( get_blog_id_from_url($deconstructed['host'], '/') === 0 ) {
170
- WP_CLI::error('Multisite url passed in is invalid.') ;
171
- return ;
172
- }
173
- }
174
- else {
175
- $deconstructed_site = wp_parse_url( get_home_url() ) ;
176
- if ( $deconstructed['host'] !== $deconstructed_site['host'] ) {
177
- WP_CLI::error('Single site url passed in is invalid.') ;
178
- return ;
179
- }
180
- }
181
-
182
- WP_CLI::debug('url is ' . $url) ;
183
-
184
- $purge_ret = WP_CLI\Utils\http_request('GET', $url, $data) ;
185
- if ( $purge_ret->success ) {
186
- WP_CLI::success(__('Purged the url!', 'litespeed-cache')) ;
187
- }
188
- else {
189
- WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code) ;
190
- }
191
- }
192
-
193
- /**
194
- * Helper function for purging by ids.
195
- *
196
- * @access private
197
- * @since 1.0.15
198
- * @param array $args The id list to parse.
199
- * @param string $select The purge by kind
200
- * @param function(int $id) $callback The callback function to check the id.
201
- */
202
- private function _purgeby_helper($args, $select, $callback)
203
- {
204
- $filtered = array() ;
205
- foreach ($args as $val) {
206
- if ( ! ctype_digit($val) ) {
207
- WP_CLI::debug('[LSCACHE] Skip val, not a number. ' . $val) ;
208
- continue ;
209
- }
210
- $term = $callback($val) ;
211
- if ( ! empty($term) ) {WP_CLI::line($term->name);
212
- $filtered[] = in_array( $callback, array( 'get_tag', 'get_category' ) ) ? $term->name : $val ;
213
- }
214
- else {
215
- WP_CLI::debug('[LSCACHE] Skip val, not a valid term. ' . $val) ;
216
- }
217
- }
218
-
219
- if ( empty($filtered) ) {
220
- WP_CLI::error('Arguments must be integer ids.') ;
221
- return ;
222
- }
223
-
224
- $str = implode(',', $filtered) ;
225
-
226
- WP_CLI::line('Will purge the following cache tags: ' . $str) ;
227
-
228
- $data = array(
229
- LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT => $select,
230
- LiteSpeed_Cache_Admin_Display::PURGEBYOPT_LIST => $str,
231
- ) ;
232
-
233
- $purge_ret = $this->_send_request(LiteSpeed_Cache::ACTION_PURGE_BY, $data) ;
234
- if ( $purge_ret->success ) {
235
- WP_CLI::success(__('Purged the tags!', 'litespeed-cache')) ;
236
- }
237
- else {
238
- WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code) ;
239
- }
240
-
241
- }
242
-
243
- /**
244
- * Purges cache tags for a WordPress tag
245
- *
246
- * ## OPTIONS
247
- *
248
- * <ids>...
249
- * : the Term IDs to purge.
250
- *
251
- * ## EXAMPLES
252
- *
253
- * # Purge the tag ids 1, 3, and 5
254
- * $ wp lscache-purge tag 1 3 5
255
- *
256
- */
257
- public function tag($args, $assoc_args)
258
- {
259
- $this->_purgeby_helper($args, LiteSpeed_Cache_Admin_Display::PURGEBY_TAG, 'get_tag') ;
260
- }
261
-
262
- /**
263
- * Purges cache tags for a WordPress category
264
- *
265
- * ## OPTIONS
266
- *
267
- * <ids>...
268
- * : the Term IDs to purge.
269
- *
270
- * ## EXAMPLES
271
- *
272
- * # Purge the category ids 1, 3, and 5
273
- * $ wp lscache-purge category 1 3 5
274
- *
275
- */
276
- public function category($args, $assoc_args)
277
- {
278
- $this->_purgeby_helper($args, LiteSpeed_Cache_Admin_Display::PURGEBY_CAT, 'get_category') ;
279
- }
280
-
281
- /**
282
- * Purges cache tags for a WordPress Post/Product
283
- *
284
- * @alias product
285
- *
286
- * ## OPTIONS
287
- *
288
- * <ids>...
289
- * : the Post IDs to purge.
290
- *
291
- * ## EXAMPLES
292
- *
293
- * # Purge the post ids 1, 3, and 5
294
- * $ wp lscache-purge post_id 1 3 5
295
- *
296
- */
297
- public function post_id($args, $assoc_args)
298
- {
299
- $this->_purgeby_helper($args, LiteSpeed_Cache_Admin_Display::PURGEBY_PID, 'get_post') ;
300
- }
301
-
302
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/fonts/litespeedfont.eot DELETED
Binary file
css/fonts/litespeedfont.svg DELETED
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
- <svg xmlns="http://www.w3.org/2000/svg">
4
- <metadata>Generated by IcoMoon</metadata>
5
- <defs>
6
- <font id="litespeedfont" horiz-adv-x="1024">
7
- <font-face units-per-em="1024" ascent="960" descent="-64" />
8
- <missing-glyph horiz-adv-x="1024" />
9
- <glyph unicode="&#x20;" horiz-adv-x="512" d="" />
10
- <glyph unicode="&#xe900;" glyph-name="wp_lscache" d="M1019.179 451.092c-0.094 0.469-0.27 0.916-0.404 1.374-0.156 0.532-0.284 1.070-0.495 1.57-0.222 0.549-0.532 1.061-0.822 1.57-0.205 0.384-0.381 0.788-0.623 1.152-0.572 0.853-1.226 1.664-1.977 2.423l-0.014 0.011-491.674 491.679c-0.040 0.031-0.082 0.063-0.122 0.094-2.847 2.796-6.741 4.531-11.051 4.531-4.315 0-8.206-1.735-11.054-4.531-0.043-0.031-0.088-0.063-0.125-0.094l-0.011-0.020-491.674-491.671c-0.754-0.759-1.408-1.57-1.98-2.423-0.242-0.361-0.41-0.768-0.623-1.152-0.284-0.509-0.603-1.018-0.822-1.57-0.213-0.501-0.333-1.038-0.486-1.57-0.139-0.458-0.316-0.905-0.407-1.374-0.205-1.007-0.313-2.037-0.313-3.095 0-1.061 0.108-2.088 0.313-3.089 0.088-0.466 0.265-0.91 0.407-1.368 0.156-0.532 0.276-1.087 0.486-1.587 0.219-0.538 0.535-1.050 0.822-1.57 0.213-0.384 0.381-0.777 0.623-1.152 0.572-0.842 1.226-1.664 1.98-2.412l0.009-0.011 491.676-491.682c0.737-0.742 1.539-1.382 2.395-1.957 0.168-0.114 0.358-0.188 0.535-0.299 0.703-0.415 1.414-0.845 2.176-1.155 0.282-0.125 0.597-0.176 0.893-0.282 0.677-0.239 1.345-0.475 2.054-0.626 1.007-0.193 2.054-0.307 3.126-0.307 1.064 0 2.113 0.114 3.123 0.307 0.703 0.151 1.374 0.387 2.048 0.626 0.296 0.105 0.614 0.156 0.896 0.282 0.759 0.31 1.473 0.742 2.182 1.155 0.171 0.111 0.367 0.185 0.532 0.299 0.856 0.572 1.658 1.215 2.395 1.957l0.014 0.020 491.676 491.674c0.754 0.748 1.405 1.57 1.977 2.412 0.242 0.375 0.415 0.771 0.623 1.152 0.293 0.521 0.6 1.030 0.822 1.57 0.21 0.501 0.338 1.055 0.495 1.587 0.134 0.458 0.307 0.902 0.404 1.368 0.196 1.001 0.316 2.028 0.316 3.089-0.003 1.061-0.122 2.091-0.321 3.095zM941.096 447.11l-0.168-0.444-0.137-0.484-0.492-0.879c-0.122-0.168-0.276-0.347-0.444-0.515l-424.624-424.63c-0.151-0.159-0.299-0.29-0.461-0.404-0.142-0.094-0.697-0.424-0.85-0.506l-1.166-0.384c-0.134-0.031-0.444-0.060-0.759-0.060s-0.62 0.031-0.919 0.097c0 0-0.811 0.29-0.993 0.347-0.188 0.1-0.879 0.512-0.879 0.512-0.162 0.131-0.296 0.247-0.427 0.381l-424.627 424.627c-0.168 0.171-0.313 0.344-0.444 0.526l-0.521 0.956-0.341 1.115c-0.006 0.040-0.046 0.327-0.046 0.634 0 0.304 0.040 0.6 0.1 0.887l0.171 0.444 0.151 0.515 0.225 0.356 0.265 0.515c0.134 0.179 0.273 0.356 0.424 0.506l424.741 424.715c0.449 0.435 1.525 1.26 3.126 1.26s2.679-0.825 3.18-1.32l424.667-424.644c0.168-0.168 0.31-0.344 0.435-0.523l0.512-0.936 0.353-1.126c0.006-0.051 0.048-0.347 0.048-0.651-0.003-0.304-0.043-0.592-0.1-0.887zM764.55 449.53c-0.060 0.225-0.156 0.455-0.21 0.683-0.071 0.265-0.134 0.535-0.245 0.782-0.111 0.267-0.262 0.532-0.412 0.774-0.105 0.196-0.188 0.404-0.31 0.58-0.279 0.421-0.623 0.825-0.973 1.198l-0.017 0.020-244.824 244.816c-0.017 0.011-0.046 0.037-0.057 0.054-1.417 1.388-3.351 2.256-5.504 2.256-2.139 0-4.087-0.868-5.504-2.256-0.020-0.017-0.043-0.043-0.057-0.054l-244.824-244.833c-0.375-0.373-0.705-0.774-0.987-1.198-0.128-0.179-0.202-0.384-0.307-0.58-0.151-0.245-0.302-0.509-0.407-0.774-0.111-0.25-0.168-0.521-0.247-0.782-0.074-0.228-0.165-0.458-0.208-0.683-0.102-0.503-0.154-1.018-0.154-1.553 0-0.521 0.051-1.027 0.154-1.525 0.046-0.233 0.134-0.455 0.208-0.697 0.080-0.253 0.137-0.523 0.247-0.771 0.102-0.267 0.256-0.529 0.407-0.788 0.105-0.182 0.179-0.39 0.307-0.566 0.282-0.421 0.612-0.822 0.987-1.2l0.003-0.006 244.821-244.827c0.37-0.367 0.771-0.688 1.189-0.967 0.082-0.065 0.185-0.094 0.27-0.145 0.347-0.216 0.708-0.438 1.084-0.589 0.137-0.057 0.299-0.071 0.441-0.122 0.327-0.134 0.663-0.245 1.024-0.321 0.503-0.1 1.018-0.145 1.55-0.145 0.535 0 1.058 0.046 1.562 0.145 0.347 0.077 0.683 0.188 1.015 0.321 0.148 0.051 0.304 0.065 0.455 0.122 0.373 0.151 0.728 0.373 1.078 0.589 0.082 0.051 0.188 0.077 0.267 0.145 0.427 0.279 0.828 0.6 1.183 0.967l0.017 0.006 244.821 244.827c0.35 0.378 0.694 0.777 0.973 1.2 0.122 0.179 0.205 0.384 0.31 0.566 0.151 0.262 0.299 0.523 0.412 0.788 0.111 0.247 0.174 0.518 0.245 0.771 0.057 0.242 0.151 0.464 0.21 0.697 0.088 0.498 0.145 1.007 0.145 1.525 0.003 0.532-0.051 1.047-0.139 1.55zM604.76 581.632l-78.35-99.419 42.416-61.002c0.051-0.071 0.1-0.151 0.156-0.228 0.711-1.106 1.229-2.222 1.596-3.573 2.506-9.782 0.745-17.55-4.907-21.834l-128.68-98.768c-2.216-1.749-5.299-3.766-9.429-3.766-4.588 0-8.829 2.651-10.769 6.679-2.33 4.699-1.476 9.671 2.534 14.771l78.327 99.439-43.036 61.921c-5.501 7.811-3.792 18.901 3.792 24.701l128.762 98.847c2.222 1.718 5.288 3.686 9.333 3.686 4.577 0 8.823-2.645 10.823-6.753 2.258-4.654 1.402-9.586-2.569-14.703zM233.35 419.499l249.805-249.816v-58.14l-307.965 307.957h58.16zM483.154 726.283l-249.793-249.785h-58.172l307.965 307.962v-58.177zM790.687 419.536h54.428l-307.988-307.996v54.417l253.559 253.579zM790.667 476.473l-253.54 253.537v54.451l311.683-307.988h-58.143z" />
11
- </font></defs></svg>
 
 
 
 
 
 
 
 
 
 
 
css/fonts/litespeedfont.ttf DELETED
Binary file
css/fonts/litespeedfont.woff DELETED
Binary file
css/litespeed.css DELETED
@@ -1,1180 +0,0 @@
1
- /********************************* common *******************************/
2
- *[litespeed-accesskey]:before {
3
- content: '[' attr(litespeed-accesskey) '] ';
4
- }
5
-
6
- .litespeed-row {
7
- display: block;
8
- margin-top: 5px;
9
- margin-left: 5px;
10
- }
11
-
12
- .litespeed-reset{
13
- width: initial;
14
- }
15
-
16
- .litespeed-inline{
17
- display: inline-block;
18
- }
19
-
20
- .litespeed-warning {
21
- color: #e59544!important;
22
- }
23
-
24
- .litespeed-danger {
25
- color: #dc3545!important;
26
- }
27
-
28
- .litespeed-left10 {
29
- margin-left: 10px;
30
- }
31
-
32
- .litespeed-top10 {
33
- margin-top: 10px;
34
- }
35
-
36
- .litespeed-top20 {
37
- margin-top: 20px;
38
- }
39
-
40
- .litespeed-desc {
41
- font-size: 12px;
42
- font-weight: normal;
43
- color: #9e9e9e;
44
- color: #7a919e;
45
- margin: 10px 5px;
46
- }
47
-
48
- .litespeed-hide {
49
- display: none;
50
- }
51
-
52
- .litespeed-relative {
53
- position: relative ;
54
- }
55
-
56
- .litespeed-h3{
57
- font-family: "Open Sans", Arial, sans-serif;
58
- line-height: 18px;
59
- color: #264d73;
60
- font-size: 18px;
61
- font-weight: 600;
62
- margin: 2px 0;
63
- }
64
-
65
- /********************************* logo *******************************/
66
- @font-face {
67
- font-family: 'litespeedfont';
68
- src: url('fonts/litespeedfont.eot?rs8ttq');
69
- src: url('fonts/litespeedfont.eot?rs8ttq#iefix') format('embedded-opentype'),
70
- url('fonts/litespeedfont.ttf?rs8ttq') format('truetype'),
71
- url('fonts/litespeedfont.woff?rs8ttq') format('woff'),
72
- url('fonts/litespeedfont.svg?rs8ttq#litespeedfont') format('svg');
73
- font-weight: normal;
74
- font-style: normal;
75
- }
76
-
77
- #adminmenu #toplevel_page_lscache-dash .menu-icon-generic div.wp-menu-image:before,
78
- .litespeed-top-toolbar .ab-icon::before{
79
- content: "\e900";
80
- font-family: 'litespeedfont' !important;
81
- speak: none;
82
- font-style: normal;
83
- font-weight: normal;
84
- font-variant: normal;
85
- text-transform: none;
86
- line-height: 1;
87
-
88
- /* Better Font Rendering =========== */
89
- -webkit-font-smoothing: antialiased;
90
- -moz-osx-font-smoothing: grayscale;
91
-
92
- }
93
-
94
- /********************************* layout *******************************/
95
- .litespeed-body{
96
- background: none repeat scroll 0 0 #fff;
97
- border: 1px solid #6699cc;
98
- box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05);
99
- font-size: 14px;
100
- /*line-height: 2em;*/
101
- margin: 0px 0px 20px 0;
102
- overflow: auto;
103
- padding: 10px 15px 15px 15px;
104
- position: relative;
105
- border-top: none;
106
- color: #264d73;
107
- }
108
-
109
- .litespeed-body code{
110
- color: #998c85 ;
111
- background-color: #dde9f5;
112
- border-radius: 3px;
113
- font-size: 11px;
114
- font-style: normal;
115
- }
116
-
117
- .litespeed-body ul{
118
- margin-left: 2em;
119
- }
120
-
121
- .litespeed-body i {
122
- font-size: 13px;
123
- line-height: 16px;
124
- }
125
-
126
- .litespeed-body .litespeed-desc i {
127
- font-size: 12px;
128
- }
129
-
130
- .litespeed-body p {
131
- margin: 1em ;
132
- }
133
-
134
- .litespeed-desc p {
135
- margin-left: 0;
136
- }
137
-
138
- .litespeed-title {
139
- font-size: 18px;
140
- font-weight: 600;
141
- color: #264d73;
142
- border-bottom: 1px solid #6699cc;
143
- margin: 35px 0px 20px 0;
144
- display: table;
145
- padding-right: 50px;
146
- padding-left: 3px;
147
- }
148
-
149
- .litespeed-title a {
150
- text-decoration: none;
151
- }
152
-
153
- /********************************* nav tabs *******************************/
154
- .litespeed-wrap {
155
- margin: 10px 20px 0 2px;
156
- }
157
-
158
- .litespeed-header {
159
- border-bottom: 1px solid #6699cc;
160
- margin: 0;
161
- padding-top: 9px;
162
- padding-bottom: 0;
163
- line-height: 24px;
164
- font-size: 13px;
165
- font-weight: 600;
166
- color: #264d73;
167
- }
168
-
169
- .litespeed-header:not(.wp-clearfix):after {
170
- content: "";
171
- display: table;
172
- clear: both;
173
- }
174
-
175
- .litespeed-tab {
176
- text-decoration: none;
177
- float: left;
178
- border: 1px solid #6699cc;
179
- border-top-left-radius: 3px;
180
- border-top-right-radius: 3px;
181
- font-size: 13px;
182
- line-height: 24px;
183
- border-bottom: none;
184
- margin-left: .5em;
185
- padding: 2px 9px;
186
- min-width: 50px;
187
- background: #f9fafc;
188
- background: #f1f1f1;
189
- color: #6699cc;
190
- text-align: center;
191
- font-weight: 400;
192
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
193
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
194
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
195
- }
196
-
197
- .litespeed-tab-active {
198
- margin-bottom: -1px;
199
- color: #264d73;
200
- border-bottom: 1px solid #fff;
201
-
202
- }
203
-
204
- .litespeed-tab-active, .litespeed-tab-active:focus, .litespeed-tab-active:focus:active, .litespeed-tab-active:hover {
205
- border-bottom: 1px solid #fff;
206
- background: #fff;
207
- color: #264d73;
208
- }
209
-
210
- .litespeed-tab-active, .litespeed-tab:focus:active {
211
- -webkit-box-shadow: none;
212
- box-shadow: none;
213
- font-size: 13px;
214
- color: #264d73;
215
- }
216
-
217
- .litespeed-tab:focus, .litespeed-tab:hover {
218
- background-color: #fff;
219
- color: #264d73;
220
- -moz-box-shadow: none;
221
- -webkit-box-shadow: none;
222
- box-shadow: none;
223
- font-size: 13px;
224
- border-bottom: 1px solid #fff;
225
- margin-bottom: -1px;
226
- }
227
-
228
- /********************************* panel *******************************/
229
- .litespeed-panel-wrapper {
230
- display: flex;
231
- width: 100%;
232
- flex-flow: row wrap;
233
- justify-content: flex-start;
234
- }
235
-
236
- .litespeed-panel {
237
- text-decoration: none;
238
- display: flex;
239
- justify-content: space-between;
240
- border: 1px solid #6699cc;
241
- -moz-box-shadow: 0 0 0 1px rgba(102, 153, 204, 0.25);
242
- -webkit-box-shadow: 0 0 0 1px rgba(102, 153, 204, 0.25);
243
- box-shadow: 0 0 0 1px rgba(102, 153, 204, 0.25);
244
- border-radius: 3px;
245
- background: #f9fafc;
246
- padding: 6px 0px 4px 5px;
247
- width: 310px;
248
- margin: 15px 5px 15px 15px;
249
- min-height: 75px;
250
- }
251
-
252
- .litespeed-panel:hover {
253
- color: #538ac6;
254
- border: 1px solid #00a3cc;
255
- background: #fff;
256
- -moz-box-shadow: none;
257
- -webkit-box-shadow: none;
258
- box-shadow: none;
259
- }
260
-
261
- .litespeed-panel-wrapper-icon {
262
- width: 25%;
263
- height:100%;
264
- }
265
-
266
- [class*="litespeed-panel-icon-"] {
267
- background-size: contain;
268
- width: 60px;
269
- height: 60px;
270
- margin: 5px;
271
- background-repeat: no-repeat;
272
- display: inline-block;
273
- }
274
-
275
- .litespeed-panel-icon-all { background-image: url("../img/icons/all.svg") ; }
276
- .litespeed-panel-icon-revision { background-image: url("../img/icons/revision.svg") ; }
277
- .litespeed-panel-icon-auto_draft { background-image: url("../img/icons/auto_draft.svg") ; }
278
- .litespeed-panel-icon-trash_post { background-image: url("../img/icons/trash_post.svg") ; }
279
- .litespeed-panel-icon-spam_comment { background-image: url("../img/icons/spam_comment.svg") ; }
280
- .litespeed-panel-icon-trash_comment { background-image: url("../img/icons/trash_comment.svg") ; }
281
- .litespeed-panel-icon-trackback-pingback{ background-image: url("../img/icons/trackback-pingback.svg") ; }
282
- .litespeed-panel-icon-expired_transient { background-image: url("../img/icons/expired_transient.svg") ; }
283
- .litespeed-panel-icon-all_transients { background-image: url("../img/icons/all_transients.svg") ; }
284
- .litespeed-panel-icon-optimize_tables { background-image: url("../img/icons/optimize_tables.svg") ; }
285
- .litespeed-panel-icon-purge-front { background-image: url("../img/icons/purge-front.svg") ; }
286
- .litespeed-panel-icon-purge-pages { background-image: url("../img/icons/purge-pages.svg") ; }
287
- .litespeed-panel-icon-purge-cssjs { background-image: url("../img/icons/purge-cssjs.svg") ; }
288
- .litespeed-panel-icon-purge-all { background-image: url("../img/icons/purge-all.svg") ; }
289
- .litespeed-panel-icon-empty-cache { background-image: url("../img/icons/empty-cache.svg") ; }
290
- .litespeed-panel-icon-purge-403 { background-image: url("../img/icons/purge-403.svg") ; }
291
- .litespeed-panel-icon-purge-404 { background-image: url("../img/icons/purge-404.svg") ; }
292
- .litespeed-panel-icon-purge-500 { background-image: url("../img/icons/purge-500.svg") ; }
293
- .litespeed-panel-top-right-icon-cross { background-image: url("../img/icons/cross_icon.svg") ; }
294
- .litespeed-panel-top-right-icon-tick { background-image: url("../img/icons/success_icon.svg") ; }
295
-
296
-
297
- .litespeed-panel-content {
298
- width: 75%;
299
- height:100%;
300
- margin-top: 10px;
301
- }
302
-
303
- .litespeed-panel-para {
304
- font-family: "Open Sans", Arial, sans-serif;
305
- line-height: 18px;
306
- color: #264d73;
307
- }
308
-
309
- .litespeed-panel .litespeed-h3{
310
- font-size: 14px;
311
- }
312
-
313
- .litespeed-panel-counter {
314
- color: #3abfbf;
315
- }
316
-
317
- .litespeed-panel-counter-red {
318
- color: #cc3d6a ;
319
- }
320
-
321
- .litespeed-panel-para {
322
- margin-top: -12px;
323
- font-size: 13px;
324
- }
325
-
326
- .litespeed-panel-wrapper-top-right {
327
- width: 10%;
328
- height:100%;
329
- }
330
-
331
- .litespeed-panel-top-right-icon-tick,
332
- .litespeed-panel-top-right-icon-cross {
333
- background-size: contain;
334
- width: 20px;
335
- height: 20px;
336
- background-repeat: no-repeat;
337
- display: inline-block;
338
- }
339
-
340
- /********************************* btn *******************************/
341
- .litespeed-body [class*="litespeed-btn-"] {
342
- padding: 5px 10px;
343
- font-size: 14px !important;
344
- font-weight:400;
345
- border-radius: 3px;
346
- margin: 15px 5px;
347
- text-align: center;
348
- background: #fff;
349
- min-width: 155px;
350
- cursor: pointer;
351
- text-decoration: none;
352
- display: inline-block;
353
- height: initial;
354
- }
355
-
356
- .litespeed-body [class*="litespeed-btn-"]:hover {
357
- font-weight: 400;
358
- color: #fff;
359
- -moz-box-shadow: none;
360
- -webkit-box-shadow: none;
361
- box-shadow: none;
362
- }
363
-
364
- .litespeed-body .litespeed-btn-danger {
365
- color: #cc3d6a;
366
- border: 1px solid #cc3d6a;
367
- -moz-box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
368
- -webkit-box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
369
- box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
370
- }
371
-
372
- .litespeed-body .litespeed-btn-danger:hover {
373
- background: #cc3d6a;
374
- }
375
-
376
- .litespeed-body .litespeed-btn-warning {
377
- color: #e59544;
378
- border: 1px solid #e59544;
379
- -moz-box-shadow: 0 0 0 1px rgba(230, 150, 69, 0.25);
380
- -webkit-box-shadow: 00 0 0 1px rgba(230, 150, 69, 0.25);
381
- box-shadow: 0 0 0 1px rgba(230, 150, 69, 0.25);
382
- }
383
-
384
- .litespeed-body .litespeed-btn-warning:hover {
385
- background: #e59544;
386
- }
387
-
388
- .litespeed-body .litespeed-btn-success {
389
- color: #36b0b0;
390
- border: 1px solid #36b0b0;
391
- -moz-box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
392
- -webkit-box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
393
- box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
394
- }
395
-
396
- .litespeed-body .litespeed-btn-success:hover {
397
- background: #36b0b0;
398
- }
399
-
400
- .litespeed-body .litespeed-btn-primary {
401
- color: #538ac6;
402
- border: 1px solid #538ac6;
403
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
404
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
405
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
406
- }
407
-
408
- .litespeed-body .litespeed-btn-primary:hover {
409
- background: #538ac6;
410
- border-color: #538ac6;
411
- }
412
-
413
- .litespeed-body .litespeed-btn-xs {
414
- padding: 1px 8px;
415
- font-size: 13px;
416
- line-height: 1.5;
417
- border-radius: 2px;
418
- min-width: 100px;
419
- }
420
-
421
-
422
- /********************************* switch *******************************/
423
- .litespeed-switch {
424
- border: 1px solid #538ac6;
425
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
426
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
427
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
428
- border-radius: 3px;
429
- font-size: 14px;
430
- font-weight: 600;
431
- margin: 0 0 0 ;
432
- background-color: #fff;
433
- padding: -1px;
434
- display: inline-block;
435
- }
436
-
437
- .litespeed-switch input:checked + label {
438
- background-color: #36b0b0;
439
- color: #fff;
440
- font-weight: 600;
441
- border: 1px solid #36b0b0;
442
- }
443
-
444
- .litespeed-switch label {
445
- font-size: 14px;
446
- display: inline-block;
447
- min-width: 75px;
448
- background-color: #fff;
449
- color: #6699cc;
450
- font-weight: 400;
451
- text-align: center;
452
- padding: 5px 9px;
453
- float: left;
454
- cursor: pointer;
455
- border: 1px solid #f9fafc;
456
- }
457
-
458
- .litespeed-switch label:hover {
459
- background-color: #f9fafc;
460
- font-weight: 400;
461
- color: #538ac6;
462
- }
463
-
464
- .litespeed-switch input {
465
- display: none;
466
- }
467
-
468
- .litespeed-cache-purgeby-text {
469
- font-size: 13px;
470
- padding-left: 20px;
471
- display: inline-block;
472
- vertical-align: top;
473
- margin-top: 5px;
474
- }
475
-
476
-
477
- /********************************* switch drag *******************************/
478
- .litespeed-switch-drag {
479
- position: relative;
480
- width: 100px;
481
- -webkit-user-select:none;
482
- -moz-user-select:none;
483
- -ms-user-select: none;
484
- border: 1px solid #538ac6;
485
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
486
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
487
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
488
- border-radius: 3px;
489
- display: inline-block;
490
- }
491
-
492
- .litespeed-switch-drag input {
493
- display: none;
494
- }
495
-
496
- .litespeed-switch-drag-label {
497
- display: block;
498
- overflow: hidden;
499
- cursor: pointer;
500
- }
501
-
502
- .litespeed-switch-drag-inner {
503
- display: block;
504
- width: 200%;
505
- margin-left: -100%;
506
- transition: margin 0.1s ease-in 0s;
507
- }
508
-
509
- .litespeed-switch-drag-inner:before, .litespeed-switch-drag-inner:after {
510
- display: block;
511
- float: left;
512
- width: 50%;
513
- height: 25px;
514
- padding: 0;
515
- line-height: 25px;
516
- font-size: 13px;
517
- color: #fff;
518
- font-weight: 600;
519
- box-sizing: border-box;
520
- -moz-box-shadow: inset 0 0 1px 2px rgba(38, 77, 115, .15);
521
- -webkit-box-shadow: inset 0 0 1px 2px rgba(38, 77, 115, .15);
522
- box-shadow: inset 0 0 1px 2px rgba(38, 77, 115, .15);
523
- }
524
-
525
- .litespeed-switch-drag-inner:before {
526
- content: attr(data-on);
527
- padding-left: 10px;
528
- background-color: #36b0b0;
529
- color: #FFFFFF;
530
-
531
- }
532
-
533
- .litespeed-switch-drag-inner:after {
534
- content: attr(data-off);
535
- padding-right: 8px;
536
- background-color: #f9fafc;
537
- color: #6699cc;
538
- text-align: right;
539
- font-weight: 400;
540
- }
541
-
542
- .litespeed-switch-drag-switch {
543
- display: block;
544
- width: 25px;
545
- margin: 0px;
546
- background: #F9FAFC;
547
- position: absolute;
548
- top: 0;
549
- bottom: 0;
550
- right: 73px;
551
- border: 1px solid #6699CC;
552
- border-radius: 2px;
553
- -moz-box-shadow: 0 0 1px 1px rgba(102, 153, 204, 0.5);
554
- -webkit-box-shadow: 0 0 1px 1px rgba(102, 153, 204, 0.5);
555
- box-shadow: 0 0 1px 1px rgba(102, 153, 204, 0.5);
556
- transition: all 0.1s ease-in 0s;
557
- }
558
-
559
- .litespeed-switch-drag input:checked + .litespeed-switch-drag-label .litespeed-switch-drag-inner {
560
- margin-left: 0;
561
- }
562
-
563
- .litespeed-switch-drag input:checked + .litespeed-switch-drag-label .litespeed-switch-drag-switch {
564
- right: 0px;
565
- }
566
-
567
- /********************************* label *******************************/
568
- [class*="litespeed-label-"] {
569
- display: inline;
570
- padding: .2em .6em .3em;
571
- font-size: 75%;
572
- font-weight: bold;
573
- line-height: 1;
574
- color: #fff;
575
- text-align: center;
576
- white-space: nowrap;
577
- vertical-align: baseline;
578
- border-radius: .25em;
579
- }
580
- [class*="litespeed-label-"]:hover,
581
- [class*="litespeed-label-"]:focus {
582
- color: #fff;
583
- text-decoration: none;
584
- cursor: pointer;
585
- }
586
- [class*="litespeed-label-"]:empty {
587
- display: none;
588
- }
589
- .litespeed-label-default {
590
- background-color: #777;
591
- }
592
- .litespeed-label-default[href]:hover,
593
- .litespeed-label-default[href]:focus {
594
- background-color: #5e5e5e;
595
- }
596
- .litespeed-label-primary {
597
- background-color: #337ab7;
598
- }
599
- .litespeed-label-primary[href]:hover,
600
- .litespeed-label-primary[href]:focus {
601
- background-color: #286090;
602
- }
603
- .litespeed-label-success {
604
- background-color: #5cb85c;
605
- }
606
- .litespeed-label-success[href]:hover,
607
- .litespeed-label-success[href]:focus {
608
- background-color: #449d44;
609
- }
610
- .litespeed-label-info {
611
- background-color: #5bc0de;
612
- }
613
- .litespeed-label-info[href]:hover,
614
- .litespeed-label-info[href]:focus {
615
- background-color: #31b0d5;
616
- }
617
- .litespeed-label-warning {
618
- background-color: #f0ad4e;
619
- }
620
- .litespeed-label-warning[href]:hover,
621
- .litespeed-label-warning[href]:focus {
622
- background-color: #ec971f;
623
- }
624
- .litespeed-label-danger {
625
- background-color: #d9534f;
626
- }
627
- .litespeed-label-danger[href]:hover,
628
- .litespeed-label-danger[href]:focus {
629
- background-color: #c9302c;
630
- }
631
-
632
- /********************************* shell *******************************/
633
- .litespeed-shell {
634
- width: 98%;
635
- background: #141414;
636
- margin: 20px auto 0 10px;
637
- box-shadow: 0 0 5px rgba(0,0,0,0.4);
638
- -webkit-border-radius: 3px;
639
- -moz-border-radius: 3px;
640
- border-radius: 3px;
641
- position: relative;
642
- height: 224px;
643
- }
644
-
645
- .litespeed-shell-header {
646
- z-index: 999;
647
- position: absolute;
648
- top: 0;
649
- right: 0;
650
- width: 50px;
651
- height: 34px;
652
- padding: 5px 0;
653
- }
654
-
655
- .litespeed-shell-header-bg {
656
- opacity: 0.4;
657
- background-color: #CCCCCC;
658
- position: absolute;
659
- top: 0;
660
- bottom: 0;
661
- right: 0;
662
- left: 0;
663
- z-index: 4;
664
- -webkit-border-radius: 3px;
665
- -moz-border-radius: 3px;
666
- border-top-radius: 3px;
667
- }
668
-
669
- .litespeed-shell-header-bar {
670
- position: absolute;
671
- top: 0;
672
- left: 0;
673
- z-index: 10;
674
- height: 2px;
675
- background-color: #F48024;
676
- }
677
-
678
- /*.litespeed-shell-header-num{
679
- position: absolute;
680
- bottom: 2px;
681
- right: 2px;
682
- width: 14px;
683
- height: 14px;
684
- text-align: left;
685
- color: #808080;
686
- font-size: 0.85em;
687
- z-index: 5;
688
- display: none;
689
- }*/
690
-
691
- .litespeed-shell-header-icon-container{
692
- position: absolute;
693
- top: 10px;
694
- right: 10px;
695
- width: 29px;
696
- height: 34px;
697
- z-index: 6;
698
- }
699
-
700
- ul.litespeed-shell-body {
701
- position: absolute;
702
- top: 0;
703
- left: 0;
704
- right: 0;
705
- bottom: 0;
706
- overflow-y: scroll;
707
- margin: 0;
708
- padding: 5px;
709
- list-style: none;
710
- background: #141414;
711
- color: #45D40C;
712
- font: 0.8em 'Andale Mono', Consolas, 'Courier New';
713
- line-height: 1.6em;
714
-
715
- -webkit-border-bottom-right-radius: 3px;
716
- -webkit-border-bottom-left-radius: 3px;
717
- -moz-border-radius-bottomright: 3px;
718
- -moz-border-radius-bottomleft: 3px;
719
- border-bottom-right-radius: 3px;
720
- border-bottom-left-radius: 3px;
721
-
722
- }
723
-
724
- .litespeed-shell-body li:before {
725
- content: '>';
726
- position: absolute;
727
- left: 0;
728
- top: 0;
729
- }
730
-
731
- .litespeed-shell-body li {
732
- word-wrap: break-word;
733
- position: relative;
734
- padding: 0 0 0 15px;
735
- margin: 0;
736
- }
737
-
738
- .litespeed-widget-setting{
739
- background-color: #ecebdc;
740
- padding: 5px 14px;
741
- margin: 5px -15px;
742
- }
743
-
744
-
745
- /********************************* callout *******************************/
746
- [class*="litespeed-callout-"] {
747
- padding: 15px 25px 20px 20px;
748
- border: 1px solid #6699cc;
749
- border-radius: 3px;
750
- line-height: 18px;
751
- border-left-color: #6699cc;
752
- border-left-width: 5px;
753
- color: #538ac6;
754
- margin: 13px 0;
755
- background: #f2f9ff;
756
- }
757
-
758
- [class*="litespeed-callout-"] h4 {
759
- margin-top: 0;
760
- margin-bottom: 8px;
761
- font-size: 14px;
762
- font-family: inherit;
763
- font-weight: 500;
764
- line-height: 1.1;
765
- }
766
-
767
- [class*="litespeed-callout-"] p {
768
- margin-bottom: 0;
769
- }
770
-
771
- [class*="litespeed-callout-"] ol {
772
- padding-left: 15px;
773
- margin-left: 10px;
774
- margin-bottom: 0;
775
- }
776
-
777
- .litespeed-callout-warning h4 {
778
- color: #e59544;
779
- }
780
-
781
- .litespeed-callout-warning {
782
- border-left-color: #e59544 !important;
783
- border-left-width: 5px;
784
- }
785
-
786
- .litespeed-callout-danger h4 {
787
- color: #cc3d6a;
788
- }
789
-
790
- .litespeed-callout-danger {
791
- border-left-color: #cc3d6a !important;
792
- border-left-width: 5px;
793
- }
794
-
795
- /********************************* inline table *******************************/
796
- .litespeed-body table {
797
- background: #fff;
798
- padding: 10px;
799
- word-wrap: break-word;
800
- -webkit-font-smoothing: subpixel-antialiased;
801
- border-spacing: 0;
802
- width: 100%;
803
- clear: both;
804
- }
805
-
806
- .litespeed-body table thead tr th{
807
- color: #264d73;
808
- padding-left: 10px;
809
- }
810
-
811
- .litespeed-table {
812
- border: 1px solid #538ac6;
813
- border-radius: 3px;
814
- }
815
-
816
- /********************************* small table *******************************/
817
- .litespeed-body .litespeed-vary-table {
818
- margin-top: -15px;
819
- padding-left: 0;
820
- width: 250px;
821
- }
822
-
823
- .litespeed-body .litespeed-vary-table tr {
824
- width: 200px;
825
- }
826
-
827
- .litespeed-body .litespeed-vary-table tr:first-child td {
828
- /* border-top: 1px solid #cccccc; */
829
- }
830
- .litespeed-body .litespeed-vary-table .litespeed-vary-title {
831
- width: 50%;
832
- /* border-bottom: 1px solid #cccccc;
833
- border-right: 1px solid #cccccc;*/
834
- }
835
- .litespeed-body .litespeed-vary-table .litespeed-vary-val {
836
- /* border-bottom: 1px solid #cccccc;*/
837
- }
838
-
839
-
840
- /********************************* tick checkbox *******************************/
841
- .litespeed-tick {
842
- display: inline-block;
843
- min-width: 125px;
844
- background: #f9fafc;
845
- padding: 5px 0 5px 0px;
846
- border-radius: 3px;
847
- cursor: pointer;
848
- margin: 5px;
849
- }
850
-
851
- .litespeed-tick input[type="checkbox"] {
852
- height: 18px;
853
- width: 18px;
854
- vertical-align: middle;
855
- margin: 0 10px 0 20px;
856
- border: 1px solid #538ac6;
857
- -webkit-appearance: none;
858
- -moz-appearance: none;
859
- appearance: none;
860
- -webkit-border-radius: 3px;
861
- border-radius: 3px;
862
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
863
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
864
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
865
- cursor: pointer;
866
- }
867
-
868
- .litespeed-tick input[type="checkbox"]:not(:disabled):hover {
869
- border-color: #538ac6;
870
-
871
- }
872
-
873
- .litespeed-tick input[type="checkbox"]:active:not(:disabled) {
874
- border-color: #538ac6;
875
- }
876
-
877
- .litespeed-tick input[type="checkbox"]:focus {
878
- outline:none;
879
- }
880
-
881
- .litespeed-tick input[type="checkbox"]:checked {
882
- border-color: #538ac6;
883
- background-color: #538ac6;
884
- -moz-box-shadow: none;
885
- -webkit-box-shadow: none;
886
- box-shadow: none;
887
- }
888
-
889
- .litespeed-tick input[type="checkbox"]:checked:before {
890
- content: '';
891
- display: block;
892
- width: 5px;
893
- height: 11px;
894
- border: solid #fff;
895
- border-width: 0 2px 2px 0;
896
- -webkit-transform: rotate(45deg);
897
- transform: rotate(45deg);
898
- margin-left: 5px;
899
- margin-top: -1px;
900
- cursor: pointer;
901
- }
902
-
903
- .litespeed-tick label {
904
- padding: 2px 5px 10px 15px;
905
- font-size: 14px;
906
- color: #264d73;
907
- }
908
-
909
- .litespeed-tick label:hover {
910
- min-width: 115px;
911
- color: #6699cc;
912
- }
913
-
914
-
915
- /********************************* vertical radio *******************************/
916
-
917
- .litespeed-radio-vertical {
918
- border-left: 1px solid #538ac6;
919
- height: 100%;
920
- margin-left: 8px;
921
- display: inline-block;
922
- min-width: 150px;
923
- background: #f9fafc;
924
- padding: 5px 0 5px 0px;
925
- border-radius: 3px;
926
- cursor: pointer;
927
- }
928
-
929
- .litespeed-radio-vertical label {
930
- min-width: 115px;
931
- padding: 3px 10px 6px 8px;
932
- }
933
-
934
- .litespeed-radio-vertical label:hover {
935
- min-width: 115px;
936
- color: #6699cc;
937
- padding: 3px 10px 6px 8px;
938
- }
939
-
940
-
941
- .litespeed-radio-vertical-row {
942
- margin: 20px 10px 25px 0px;
943
- width: 100%;
944
- }
945
-
946
- .litespeed-radio-vertical-row input {
947
- height: 15.5px;
948
- min-width: 15px;
949
- vertical-align: middle;
950
- margin: -2px 0 0 -8px;
951
- border: 1px solid #538ac6;
952
- -webkit-appearance: none;
953
- -moz-appearance:none;
954
- appearance: none;
955
- background: #fff;
956
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
957
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
958
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
959
- -webkit-border-radius: 50% !important;
960
- border-radius: 50% !important;
961
- cursor: pointer;
962
- }
963
-
964
- .litespeed-radio-vertical-row input:not(:disabled):hover {
965
- border-color: #538ac6;
966
- -moz-box-shadow: inset 0 0 1px 3px #36b0b0;
967
- -webkit-box-shadow: inset 0 1px 3px #36b0b0;
968
- box-shadow: inset 0 0 1px 3px #36b0b0;
969
-
970
- }
971
-
972
- .litespeed-radio-vertical-row input:active:not(:disabled) {
973
- border-color: #538ac6;
974
- }
975
-
976
- .litespeed-radio-vertical-row input:focus {
977
- outline:none;
978
- }
979
-
980
- .litespeed-radio-vertical-row input:checked {
981
- border-color: #538ac6;
982
- -moz-box-shadow: inset 0 0 0.5px 3px #fff;
983
- -webkit-box-shadow: inset 0 0 0.5px 3px #fff;
984
- box-shadow: inset 0 0 0.5px 3px #fff;
985
- background: #36b0b0;
986
- }
987
-
988
- .litespeed-radio-vertical-row input:checked:before {
989
- /*content: '\25CF';
990
- font-size: 16px;*/
991
- text-indent: -9999px;
992
- -webkit-border-radius: 50px;
993
- border-radius: 50px;
994
- font-size: 24px;
995
- width: 6px;
996
- height: 6px;
997
- margin: 4px;
998
- line-height: 16px;
999
- }
1000
-
1001
- /********************************* Q&A *******************************/
1002
- .litespeed-question:hover {
1003
- color: #6699cc;
1004
- cursor: pointer;
1005
- background: #fff;
1006
- border-left: 5px solid #6699cc;
1007
- }
1008
-
1009
- .litespeed-question {
1010
- background-color: #f9fafc;
1011
- border: 1px solid #f9fafc;
1012
- border-left: 5px solid #538ac6 !important;
1013
- border-radius: 3px;
1014
- padding: 20px;
1015
- margin: 0 20px 5px 5px;
1016
- font-family: "Open Sans", Arial, sans-serif;
1017
- font-weight: 600;
1018
- font-size: 14px;
1019
- line-height: 1.1;
1020
- color: #264d73;
1021
- }
1022
-
1023
- .litespeed-answer {
1024
- margin-left: 20px;
1025
- padding: 0 20px 20px 10px;
1026
- }
1027
-
1028
- .litespeed-up:after {
1029
- content: ' ';
1030
- border: solid #36b0b0;
1031
- border-width: 0 2px 2px 0;
1032
- display: inline-block;
1033
- padding: 3px;
1034
- margin-left: 15px;
1035
- transform: rotate(-135deg);
1036
- -webkit-transform: rotate(-135deg);
1037
- -webkit-transition: all .3s ease;
1038
- -moz-transition: all .3s ease;
1039
- -ms-transition: all .3s ease;
1040
- -o-transition: all .3s ease;
1041
- }
1042
-
1043
- .litespeed-down:after {
1044
- content: ' ';
1045
- border: solid #36b0b0;
1046
- border-width: 0 2px 2px 0;
1047
- display: inline-block;
1048
- padding: 3px;
1049
- margin-left: 15px;
1050
- transform: rotate(45deg);
1051
- -webkit-transform: rotate(45deg);
1052
- -webkit-transition: all .3s ease;
1053
- -moz-transition: all .3s ease;
1054
- -ms-transition: all .3s ease;
1055
- -o-transition: all .3s ease;
1056
- }
1057
-
1058
-
1059
- /********************************* enterprise notice *******************************/
1060
- .litespeed-ent-notice {
1061
- position: absolute ;
1062
- left: 0 ;
1063
- top: 0 ;
1064
- right: 0 ;
1065
- bottom: 0 ;
1066
- background-color: #333 ;
1067
- z-index: 999 ;
1068
- opacity: 0.8 ;
1069
- text-align: center ;
1070
- font-size: 3rem ;
1071
- color: #1865c5 ;
1072
- }
1073
-
1074
- .litespeed-ent-notice-desc {
1075
- position: relative ;
1076
- top: 30% ;
1077
- transform: rotate(-20deg) ;
1078
- text-shadow: 2px 2px 4px #000000 ;
1079
- }
1080
-
1081
- /********************************* todo *******************************/
1082
- /********************************* todo *******************************/
1083
- /* input field */
1084
- .litespeed-textarea {
1085
- width: 60% ;
1086
- }
1087
-
1088
- .litespeed-body tbody > tr > th{
1089
- padding-left: 10px;
1090
- }
1091
-
1092
- .litespeed-body tbody > tr:nth-of-type(odd){
1093
- background-color: #f9f9f9;
1094
- background-color: #f9fafc;
1095
- }
1096
-
1097
- .litespeed-body input[type=radio] {/* todo: to be deleted */
1098
- margin-top: 0px;
1099
- margin-right: 4px;
1100
- float: none;
1101
- }
1102
-
1103
- .litespeed-body th {
1104
- vertical-align: top;
1105
- text-align: left;
1106
- padding: 18px 10px 20px 0;
1107
- width: 200px;
1108
- font-family: "Open Sans", Arial, sans-serif;
1109
- font-weight: 600;
1110
- font-size: 14px;
1111
- color: #264d73;
1112
- border-radius: 3px;
1113
- }
1114
-
1115
- .litespeed-body td {
1116
- margin-bottom: 9px;
1117
- padding: 15px 10px;
1118
- line-height: 1.3;
1119
- vertical-align: middle;
1120
- font-family: "Open Sans", Arial, sans-serif;
1121
- font-weight: 400;
1122
- font-size: 14px;
1123
- color: #264d73;
1124
- border-radius: 3px;
1125
- }
1126
-
1127
- .litespeed-float-submit {
1128
- position: absolute;
1129
- right: 10px;
1130
- top: 10px;
1131
- }
1132
-
1133
- .litespeed-body input,.litespeed-body textarea {
1134
- border: 1px solid #6699cc;
1135
- border-radius: 3px;
1136
- background: #fff;
1137
- color: #264d73;
1138
- margin-right: 8px;
1139
- font-size: 14px;
1140
- font-family: "Open Sans", Arial, sans-serif;
1141
- }
1142
-
1143
- .litespeed-regular-text {
1144
- padding-left: 5px;
1145
- width: 25em;
1146
- font-size: 14px;
1147
- font-family: "Open Sans", Arial, sans-serif;
1148
- }
1149
-
1150
- .litespeed-input-long {
1151
- width: 99%;
1152
- }
1153
-
1154
- .litespeed-input-short {
1155
- width: 45px;
1156
- padding: 1px 6px;
1157
- }
1158
-
1159
- /*text area */
1160
-
1161
- .litespeed-body textarea {
1162
- margin-top: 0px;
1163
- margin-bottom: 0px;
1164
- z-index: auto;
1165
- position: relative;
1166
- line-height: 19.6px;
1167
- font-size: 14px;
1168
- transition: none;
1169
- background: transparent;
1170
- padding: 5px 10px;
1171
- box-sizing: border-box;
1172
- }
1173
-
1174
- /*text area read only */
1175
-
1176
- .litespeed-body input[readonly], .litespeed-body textarea[readonly] {
1177
- background-color: #eee;
1178
- background-color: #f2f9ff;
1179
- }
1180
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/Litespeed.icon.svg DELETED
@@ -1,30 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- viewBox="0 0 300 300" enable-background="new 0 0 300 300" xml:space="preserve">
6
- <g>
7
- <path fill="#5E8CDA" d="M254.859,146.258l-68.508-68.516l-29.203,37.055l31.461,31.461c2.922,2.922,2.922,7.68,0,10.57
8
- l-9.086,9.086c0,0,6.148,9.195,6.414,9.75c1.422,2.836,1.742,9.492-2.273,12.547l-71.57,54.969c0,18.422-0.016,56.336,0,56.344
9
- c0.031,0,142.766-142.695,142.766-142.695C257.75,153.898,257.75,149.18,254.859,146.258z"/>
10
- <path fill="#093071" d="M95.703,154.891c-2.898-2.875-2.898-7.641,0-10.531l9.109-9.125l-6.219-8.938
11
- c-2.977-4.219-2.039-10.203,2.055-13.344l71.602-54.938l0.023-56.328l-0.023-0.031l-0.039-0.047L29.477,144.359
12
- c-2.922,2.891-2.922,7.656,0,10.539l68.5,68.508l29.219-37.055L95.703,154.891z"/>
13
- </g>
14
- <path fill="#5E8CDA" d="M208.297,35.727c1.092,0,2.147,0.654,2.624,1.624c0.804,1.658-0.217,3.189-1.236,4.495l-0.04,0.051
15
- l-62.727,79.64c-0.829,1.05-0.891,3.144-0.132,4.218c0.339,0.491,33.879,49.111,35.027,50.794c1.342,1.918,1.425,7.623-1.657,9.978
16
- L79.348,263.915c-1.305,0.993-2.252,1.535-3.492,1.546c-0.99-0.082-2.015-0.756-2.44-1.601c-0.783-1.612,0.143-3.176,1.253-4.616
17
- l62.727-79.607c0.83-1.114,0.908-3.081,0.152-4.231l-35.019-50.348c-2.308-3.283-1.585-7.943,1.611-10.39l100.851-77.445
18
- C206.396,36.146,207.321,35.727,208.297,35.727 M208.297,34.727c-1.211,0-2.336,0.492-3.914,1.703l-100.852,77.445
19
- c-3.625,2.773-4.445,8.023-1.82,11.758l35.016,50.344c0.508,0.773,0.438,2.297-0.133,3.063l-62.711,79.586
20
- c-0.813,1.055-2.523,3.289-1.367,5.672c0.594,1.18,1.945,2.07,3.305,2.164c1.555,0,2.695-0.656,4.133-1.75l100.813-77.391
21
- c3.508-2.68,3.523-8.977,1.867-11.344c-1.156-1.695-35.023-50.789-35.023-50.789c-0.508-0.719-0.461-2.328,0.094-3.031
22
- l62.727-79.641c0.805-1.031,2.555-3.203,1.391-5.602C211.172,35.594,209.766,34.727,208.297,34.727L208.297,34.727z"/>
23
- <path fill="#F5CD21" d="M178.992,176.898c0.82,1.25,1.563,5.867-0.477,7.422L77.641,261.75c-0.836,0.664-1.391,0.984-1.617,0.961
24
- c-0.359,0.023-0.102-0.586,0.82-1.797l62.688-79.555c1.586-2.039,1.688-5.414,0.227-7.516l-34.977-50.367
25
- C104.781,123.477,178.188,175.664,178.992,176.898z"/>
26
- <path fill="#FDDD75" d="M178.992,176.898l-34.461-49.555c-1.438-2.125-1.336-5.492,0.242-7.508l62.695-79.578
27
- c0.945-1.203,1.164-1.781,0.828-1.781c-0.227,0-0.805,0.281-1.625,0.945l-100.875,77.422c-2.016,1.555-2.477,4.547-1.016,6.633
28
- L178.992,176.898z"/>
29
- </svg>
30
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/all.svg DELETED
@@ -1,65 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M56.164,37.484c-0.059-0.082-0.122-0.162-0.212-0.215c-0.005-0.002-0.01-0.001-0.015-0.004
8
- c-0.004-0.002-0.005-0.006-0.009-0.008l-2.159-1.183c-0.606-4.582-3.073-8.809-6.781-11.605c-0.079-0.059-0.167-0.093-0.256-0.123
9
- v-2.987c0-0.135-0.037-0.264-0.104-0.376c-0.021-0.037-0.061-0.057-0.088-0.09c-0.055-0.064-0.102-0.135-0.177-0.179
10
- c-0.004-0.002-0.009-0.001-0.013-0.003c-0.004-0.002-0.005-0.007-0.009-0.009l-8.482-4.647c-0.225-0.123-0.496-0.123-0.721,0
11
- l-8.483,4.647c-0.004,0.002-0.005,0.006-0.009,0.008c-0.004,0.002-0.009,0.001-0.013,0.004c-0.075,0.044-0.124,0.115-0.178,0.181
12
- c-0.026,0.032-0.066,0.053-0.087,0.088c-0.065,0.113-0.103,0.242-0.103,0.376v3.111c-0.087,0.03-0.174,0.063-0.251,0.121
13
- c-3.66,2.766-6.112,6.938-6.745,11.458l-2.203,1.207c-0.004,0.002-0.005,0.007-0.009,0.009c-0.004,0.002-0.009,0.001-0.013,0.003
14
- c-0.075,0.044-0.122,0.114-0.176,0.179c-0.027,0.033-0.067,0.053-0.089,0.09c-0.065,0.113-0.103,0.242-0.103,0.376v10.221
15
- c0,0.272,0.148,0.524,0.387,0.656l8.483,4.695c0.113,0.063,0.238,0.094,0.363,0.094s0.25-0.031,0.363-0.094l2.121-1.174
16
- c0.097,0.127,0.215,0.239,0.376,0.3c2.006,0.758,4.12,1.143,6.283,1.143c2.454,0,4.83-0.491,7.061-1.459
17
- c0.079-0.034,0.14-0.089,0.202-0.142l2.406,1.332c0.113,0.063,0.238,0.094,0.363,0.094s0.25-0.031,0.363-0.094l8.482-4.696
18
- c0.238-0.132,0.387-0.384,0.387-0.656v-10.22c0-0.136-0.039-0.266-0.105-0.379C56.202,37.515,56.179,37.503,56.164,37.484z
19
- M39.354,47.691v-8.511l6.984,3.824v8.553L39.354,47.691z M47.775,41.328l-0.688,0.376l-6.923-3.79l6.923-3.792l6.92,3.792
20
- L47.775,41.328z M29.767,22.625l6.983,3.825v8.554l-6.983-3.867V22.625z M38.251,26.449l6.981-3.825v8.512l-6.981,3.867V26.449z
21
- M37.5,17.566l6.921,3.792L37.5,25.15l-6.922-3.792L37.5,17.566z M28.927,41.148l-1.015,0.556l-6.922-3.79l6.922-3.792l6.921,3.792
22
- L28.927,41.148z M20.179,39.181l6.983,3.823v8.554l-6.983-3.865V39.181z M28.662,43.004l6.983-3.824v8.513l-6.983,3.865V43.004z
23
- M32.29,51.265l4.469-2.474c0.239-0.132,0.387-0.384,0.387-0.656V37.914c0-0.136-0.038-0.265-0.104-0.377
24
- c-0.017-0.028-0.048-0.043-0.068-0.069c-0.057-0.073-0.113-0.149-0.195-0.198c-0.004-0.002-0.01-0.001-0.014-0.004
25
- c-0.003-0.002-0.005-0.007-0.009-0.009l-8.482-4.647c-0.225-0.123-0.496-0.123-0.721,0l-4.299,2.355
26
- c0.743-3.207,2.516-6.133,5.015-8.303v4.917c0,0.273,0.148,0.524,0.387,0.656l8.483,4.697c0.113,0.063,0.238,0.094,0.363,0.094
27
- s0.25-0.031,0.363-0.094l8.482-4.697c0.238-0.132,0.387-0.383,0.387-0.656v-5.045c2.547,2.205,4.339,5.188,5.065,8.46l-4.35-2.384
28
- c-0.225-0.123-0.496-0.123-0.721,0l-8.484,4.647c-0.004,0.002-0.006,0.007-0.009,0.009c-0.005,0.002-0.01,0.001-0.014,0.004
29
- c-0.075,0.044-0.123,0.115-0.177,0.18c-0.027,0.032-0.066,0.053-0.087,0.088c-0.065,0.113-0.103,0.242-0.103,0.376v10.22
30
- c0,0.272,0.148,0.524,0.387,0.656l4.14,2.291C39.143,52.218,35.566,52.28,32.29,51.265z M54.82,47.691l-6.982,3.866v-8.554
31
- l4.363-2.39l2.619-1.435V47.691z"/>
32
- <path fill="#6699CC" d="M66.554,43.38l-4.544-3.116c0.121-1.014,0.178-1.903,0.178-2.765c0-0.859-0.057-1.75-0.178-2.769
33
- l4.543-3.11c0.297-0.203,0.439-0.567,0.358-0.918c-0.412-1.793-0.948-3.472-1.594-4.992c-0.141-0.331-0.435-0.543-0.83-0.532
34
- l-5.511,0.151c-0.905-1.59-2.004-3.092-3.274-4.478l1.841-5.181c0.121-0.339,0.021-0.717-0.25-0.953
35
- c-1.303-1.134-2.73-2.171-4.244-3.083c-0.307-0.186-0.699-0.165-0.984,0.056l-4.357,3.352c-1.702-0.773-3.47-1.349-5.269-1.714
36
- l-1.552-5.281c-0.103-0.346-0.405-0.594-0.765-0.625c-1.425-0.122-3.825-0.122-5.243,0c-0.359,0.031-0.663,0.279-0.764,0.625
37
- l-1.555,5.281c-1.798,0.365-3.565,0.94-5.266,1.714l-4.355-3.352c-0.286-0.22-0.676-0.243-0.983-0.057
38
- c-1.515,0.908-2.946,1.945-4.253,3.084c-0.271,0.236-0.37,0.614-0.25,0.953l1.844,5.18c-1.275,1.391-2.375,2.893-3.277,4.478
39
- l-5.509-0.151c-0.358-0.016-0.689,0.202-0.829,0.533c-0.652,1.535-1.173,3.167-1.593,4.991c-0.081,0.351,0.061,0.715,0.358,0.918
40
- l4.543,3.11c-0.119,0.998-0.177,1.909-0.177,2.769c0,0.858,0.058,1.768,0.177,2.767L8.446,43.38
41
- c-0.296,0.203-0.438,0.566-0.358,0.917c0.41,1.786,0.945,3.464,1.593,4.987c0.14,0.332,0.474,0.531,0.829,0.533l5.51-0.151
42
- c0.902,1.586,2.001,3.09,3.276,4.481l-1.843,5.181c-0.121,0.339-0.021,0.717,0.25,0.953c1.297,1.129,2.727,2.166,4.251,3.084
43
- c0.309,0.188,0.7,0.164,0.985-0.056l4.356-3.355c1.701,0.775,3.467,1.351,5.265,1.715l1.553,5.28
44
- c0.102,0.345,0.403,0.593,0.761,0.624c1.039,0.094,1.849,0.135,2.625,0.135c0.776,0,1.585-0.041,2.625-0.135
45
- c0.357-0.031,0.66-0.279,0.762-0.624l1.552-5.28c1.8-0.365,3.565-0.94,5.263-1.715l4.363,3.355c0.285,0.22,0.677,0.241,0.985,0.056
46
- c1.521-0.917,2.949-1.955,4.249-3.085c0.271-0.236,0.371-0.614,0.25-0.954l-1.845-5.18c1.272-1.391,2.372-2.895,3.277-4.48
47
- l5.506,0.151c0.401-0.007,0.688-0.202,0.829-0.532c0.646-1.516,1.182-3.193,1.595-4.987C66.992,43.947,66.85,43.583,66.554,43.38z
48
- M63.932,48.051l-5.433-0.149c-0.369-0.005-0.637,0.169-0.794,0.459c-0.961,1.778-2.185,3.451-3.637,4.975
49
- c-0.229,0.238-0.303,0.586-0.191,0.897l1.82,5.112c-0.951,0.792-1.972,1.532-3.045,2.21l-4.307-3.313
50
- c-0.261-0.202-0.617-0.238-0.913-0.095c-1.871,0.902-3.835,1.542-5.837,1.901c-0.326,0.059-0.592,0.297-0.686,0.614l-1.533,5.217
51
- c-1.425,0.108-2.333,0.106-3.754,0l-1.535-5.217c-0.093-0.318-0.359-0.556-0.685-0.614c-2-0.358-3.964-0.998-5.839-1.901
52
- c-0.298-0.145-0.651-0.107-0.914,0.095l-4.3,3.313c-1.076-0.678-2.096-1.418-3.046-2.209l1.819-5.114
53
- c0.111-0.312,0.037-0.658-0.191-0.897c-1.456-1.523-2.678-3.196-3.634-4.973c-0.157-0.29-0.467-0.472-0.794-0.46l-5.438,0.149
54
- c-0.44-1.112-0.821-2.308-1.134-3.567l4.489-3.076c0.273-0.187,0.417-0.512,0.373-0.84c-0.155-1.135-0.23-2.139-0.23-3.068
55
- c0-0.932,0.075-1.937,0.23-3.07c0.044-0.328-0.1-0.653-0.373-0.84l-4.488-3.072c0.318-1.28,0.692-2.458,1.135-3.573l5.437,0.149
56
- c0.326,0.02,0.637-0.169,0.794-0.459c0.957-1.774,2.18-3.446,3.635-4.969c0.229-0.239,0.303-0.586,0.192-0.898l-1.82-5.114
57
- c0.956-0.796,1.976-1.536,3.045-2.207l4.299,3.309c0.262,0.202,0.616,0.239,0.913,0.095c1.875-0.902,3.841-1.542,5.842-1.901
58
- c0.326-0.059,0.591-0.296,0.685-0.614l1.536-5.216c1.131-0.084,2.618-0.084,3.753,0l1.533,5.215
59
- c0.094,0.318,0.358,0.556,0.685,0.615c2.002,0.36,3.968,1,5.845,1.901c0.297,0.143,0.651,0.106,0.912-0.095l4.301-3.309
60
- c1.068,0.673,2.087,1.413,3.04,2.207l-1.817,5.114c-0.111,0.312-0.037,0.659,0.191,0.897c1.449,1.516,2.672,3.188,3.632,4.969
61
- c0.157,0.291,0.414,0.481,0.795,0.459l5.438-0.149c0.44,1.111,0.82,2.308,1.136,3.573l-4.487,3.072
62
- c-0.272,0.187-0.417,0.511-0.373,0.839c0.157,1.169,0.23,2.146,0.23,3.072c0,0.929-0.073,1.903-0.23,3.067
63
- c-0.044,0.327,0.1,0.652,0.372,0.839l4.488,3.077C64.752,45.747,64.371,46.943,63.932,48.051z"/>
64
- </g>
65
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/all_transients.svg DELETED
@@ -1,33 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M65.485,21.85c-0.045-0.113-0.106-0.219-0.2-0.308l-8.679-8.336c-0.027-0.026-0.063-0.038-0.096-0.059
8
- c-0.057-0.043-0.112-0.088-0.18-0.115c-0.068-0.028-0.138-0.033-0.21-0.042c-0.036-0.005-0.068-0.021-0.106-0.021h-0.017h-0.002
9
- h-2.861c-0.022-0.031-0.037-0.068-0.066-0.096l-5.014-4.817c-0.03-0.029-0.069-0.041-0.103-0.065
10
- c-0.056-0.04-0.106-0.082-0.171-0.108c-0.069-0.028-0.142-0.034-0.214-0.043c-0.035-0.004-0.066-0.021-0.104-0.021h-0.017
11
- c-0.001,0-0.001,0-0.002,0h-2.758c-0.045-0.116-0.107-0.226-0.202-0.317l-5.566-5.346c-0.027-0.028-0.063-0.039-0.095-0.062
12
- c-0.059-0.042-0.112-0.086-0.178-0.113c-0.071-0.029-0.146-0.036-0.222-0.045c-0.032-0.004-0.063-0.02-0.097-0.02h-0.016
13
- c0,0-0.002,0-0.004,0H12.87c-1.328,0-2.409,1.081-2.409,2.409v52.485c0,1.327,1.081,2.407,2.409,2.407h3.292
14
- c0.135,0,0.258-0.037,0.373-0.095v4.823c0,1.349,1.097,2.445,2.444,2.445h3.913v4.391c0,1.374,1.118,2.492,2.493,2.492h37.689
15
- c1.374,0,2.492-1.117,2.492-2.492V22.204C65.566,22.077,65.532,21.959,65.485,21.85z M56.867,15.82l5.768,5.541l-5.768,0.022V15.82
16
- z M48.315,10.67l2.393,2.298h-2.393V10.67z M39.182,4.769l3.175,3.049h-3.175V4.769z M16.535,10.262v47.348
17
- c-0.114-0.058-0.238-0.096-0.373-0.096H12.87c-0.389,0-0.705-0.315-0.705-0.703V4.326c0-0.388,0.316-0.705,0.705-0.705h24.607
18
- v4.197H18.979C17.631,7.818,16.535,8.914,16.535,10.262z M18.979,64.688c-0.408,0-0.74-0.332-0.74-0.741V10.262
19
- c0-0.407,0.332-0.739,0.74-0.739h27.632v3.446H25.385c-1.375,0-2.493,1.118-2.493,2.493v49.226L18.979,64.688L18.979,64.688z
20
- M63.862,70.782c0,0.435-0.354,0.788-0.788,0.788H25.385c-0.435,0-0.789-0.353-0.789-0.788V15.461c0-0.435,0.354-0.789,0.789-0.789
21
- h29.777v6.71c0,0.922,0.752,1.673,1.673,1.673h7.027V70.782z"/>
22
- <path fill="#6699CC" d="M44.111,31.051c-5.154,0-9.888,2.696-12.542,7.079l-2.011-0.76l0.963,5.869l4.603-3.769l-1.931-0.729
23
- c2.222-3.477,5.952-5.688,10.066-5.958v0.826c0,0.47,0.382,0.852,0.852,0.852c0.471,0,0.853-0.382,0.853-0.852v-0.811
24
- c6.473,0.423,11.653,5.604,12.077,12.078H56.3c-0.47,0-0.852,0.381-0.852,0.852c0,0.47,0.382,0.853,0.852,0.853h0.741
25
- c-0.422,6.433-5.542,11.593-11.959,12.071v-0.85c0-0.472-0.382-0.852-0.853-0.852c-0.47,0-0.852,0.38-0.852,0.852v0.868
26
- c-5.945-0.335-10.939-4.687-12.017-10.604c-0.084-0.464-0.529-0.767-0.992-0.687c-0.463,0.084-0.77,0.528-0.686,0.991
27
- c1.27,6.975,7.338,12.036,14.428,12.036c0.031,0,0.063-0.006,0.095-0.006c0.009,0,0.016,0.006,0.023,0.006
28
- c0.015,0,0.024-0.009,0.04-0.009c8.019-0.086,14.519-6.631,14.519-14.67C58.788,37.636,52.204,31.051,44.111,31.051z"/>
29
- <path fill="#6699CC" d="M43.238,53.289c0,0.471,0.383,0.852,0.853,0.852s0.853-0.381,0.853-0.852v-7.206l4.024-4.023
30
- c0.331-0.333,0.333-0.872,0-1.204c-0.334-0.334-0.875-0.334-1.206-0.002l-4.272,4.273c-0.079,0.079-0.142,0.173-0.184,0.277
31
- c-0.044,0.104-0.066,0.215-0.066,0.325l0,0L43.238,53.289L43.238,53.289z"/>
32
- </g>
33
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/auto_draft.svg DELETED
@@ -1,54 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M61.821,13.089c-0.041-0.114-0.104-0.222-0.197-0.311L51.641,3.19c-0.032-0.03-0.071-0.042-0.104-0.066
8
- c-0.054-0.039-0.103-0.08-0.166-0.104c-0.07-0.029-0.145-0.036-0.219-0.044c-0.032-0.004-0.063-0.02-0.097-0.02h-0.015
9
- c-0.002,0-0.004,0-0.004,0H15.826c-1.506,0-2.731,1.224-2.731,2.729v63.631c0,1.505,1.225,2.729,2.731,2.729h43.351
10
- c1.506,0,2.729-1.225,2.729-2.729V13.441C61.906,13.314,61.872,13.196,61.821,13.089z M51.899,5.776l7.105,6.823h-7.004
11
- c-0.058,0-0.102-0.044-0.102-0.101V5.776L51.899,5.776z M60.222,69.315c0,0.576-0.47,1.045-1.045,1.045H15.826
12
- c-0.578,0-1.046-0.469-1.046-1.045V5.684c0-0.576,0.469-1.043,1.046-1.043h34.388v7.857c0,0.985,0.801,1.786,1.785,1.786h8.221
13
- v55.031H60.222z"/>
14
- <path fill="#6699CC" d="M42.681,38.698l-7.151-4.129c-0.261-0.15-0.582-0.15-0.843,0c-0.26,0.15-0.421,0.428-0.421,0.73v8.257
15
- c0,0.302,0.161,0.579,0.421,0.73c0.13,0.074,0.277,0.112,0.422,0.112c0.146,0,0.291-0.038,0.422-0.112l7.152-4.13
16
- c0.261-0.149,0.424-0.428,0.424-0.729C43.105,39.126,42.94,38.847,42.681,38.698z M35.951,42.096v-5.338l4.624,2.669L35.951,42.096
17
- z"/>
18
- <path fill="#6699CC" d="M48.729,29.417l1.035-2.911c0.116-0.326,0.021-0.691-0.239-0.918c-0.797-0.69-1.664-1.32-2.581-1.872
19
- c-0.297-0.179-0.672-0.157-0.947,0.054l-2.448,1.885c-0.924-0.406-1.877-0.717-2.846-0.928l-0.873-2.968
20
- c-0.099-0.333-0.39-0.572-0.736-0.601c-0.861-0.074-2.321-0.074-3.185,0c-0.346,0.029-0.637,0.269-0.736,0.601l-0.874,2.968
21
- c-0.969,0.21-1.923,0.521-2.846,0.928l-2.447-1.885c-0.276-0.212-0.651-0.234-0.948-0.055c-0.92,0.552-1.789,1.183-2.582,1.873
22
- c-0.261,0.228-0.358,0.592-0.241,0.918l1.036,2.911c-0.678,0.757-1.271,1.568-1.771,2.421l-3.096-0.084
23
- c-0.34-0.009-0.663,0.193-0.799,0.512c-0.39,0.918-0.716,1.937-0.969,3.03c-0.078,0.338,0.059,0.688,0.345,0.885l2.552,1.747
24
- c-0.058,0.539-0.085,1.024-0.085,1.499c0,0.474,0.028,0.958,0.085,1.497l-2.552,1.748c-0.287,0.196-0.423,0.546-0.345,0.884
25
- c0.25,1.089,0.577,2.106,0.968,3.03c0.136,0.32,0.436,0.505,0.8,0.513l3.096-0.085c0.5,0.853,1.093,1.664,1.771,2.422l-1.035,2.912
26
- c-0.117,0.326-0.02,0.689,0.241,0.918c0.785,0.683,1.653,1.313,2.58,1.872c0.297,0.18,0.675,0.157,0.95-0.055l2.448-1.886
27
- c0.922,0.405,1.874,0.716,2.844,0.929l0.875,2.968c0.098,0.332,0.39,0.571,0.735,0.602c0.428,0.037,0.996,0.078,1.592,0.078
28
- c0.596,0,1.163-0.041,1.592-0.078c0.347-0.03,0.638-0.27,0.737-0.602l0.873-2.968c0.969-0.213,1.921-0.521,2.843-0.929l2.45,1.885
29
- c0.275,0.213,0.653,0.233,0.949,0.056c0.928-0.561,1.798-1.191,2.583-1.876c0.261-0.227,0.356-0.592,0.239-0.916l-1.035-2.91
30
- c0.677-0.758,1.271-1.569,1.771-2.422l3.098,0.085c0.394-0.011,0.663-0.192,0.798-0.513c0.393-0.926,0.719-1.945,0.969-3.03
31
- c0.078-0.338-0.06-0.688-0.345-0.884l-2.553-1.749c0.06-0.536,0.087-1.028,0.087-1.496c0-0.476-0.027-0.962-0.086-1.499
32
- l2.552-1.747c0.286-0.197,0.423-0.547,0.345-0.884c-0.251-1.09-0.577-2.11-0.971-3.031c-0.132-0.311-0.437-0.512-0.775-0.512
33
- c-0.008,0-0.015,0-0.022,0l-3.098,0.084C49.998,30.983,49.404,30.172,48.729,29.417z M53.587,35.12l-2.494,1.708
34
- c-0.263,0.18-0.4,0.493-0.358,0.809c0.092,0.676,0.135,1.243,0.135,1.791c0,0.545-0.043,1.114-0.135,1.787
35
- c-0.042,0.316,0.096,0.629,0.358,0.81l2.494,1.708c-0.152,0.583-0.33,1.141-0.528,1.667l-3.019-0.084
36
- c-0.352-0.007-0.612,0.163-0.765,0.443c-0.559,1.035-1.271,2.011-2.118,2.896c-0.221,0.229-0.292,0.564-0.184,0.864l1.01,2.841
37
- c-0.448,0.361-0.926,0.708-1.425,1.03l-2.39-1.839c-0.25-0.193-0.591-0.229-0.878-0.091c-1.092,0.525-2.236,0.899-3.402,1.106
38
- c-0.314,0.059-0.57,0.287-0.66,0.593l-0.852,2.899c-0.55,0.034-1.203,0.034-1.752,0l-0.854-2.899
39
- c-0.091-0.306-0.345-0.535-0.66-0.593c-1.167-0.207-2.312-0.581-3.403-1.106c-0.287-0.14-0.626-0.103-0.879,0.091l-2.388,1.84
40
- c-0.497-0.322-0.974-0.668-1.424-1.03l1.01-2.842c0.107-0.301,0.036-0.635-0.185-0.864c-0.849-0.887-1.562-1.862-2.119-2.896
41
- c-0.152-0.281-0.438-0.45-0.766-0.444l-3.018,0.084c-0.199-0.526-0.375-1.083-0.528-1.667l2.493-1.706
42
- c0.263-0.18,0.402-0.492,0.359-0.809c-0.092-0.68-0.135-1.25-0.135-1.79c0-0.544,0.042-1.111,0.135-1.791
43
- c0.042-0.316-0.097-0.628-0.359-0.808l-2.493-1.707c0.154-0.586,0.33-1.145,0.528-1.667l3.019,0.083
44
- c0.316,0.025,0.613-0.161,0.765-0.442c0.558-1.035,1.271-2.009,2.12-2.896c0.22-0.229,0.292-0.564,0.185-0.865l-1.011-2.84
45
- c0.452-0.364,0.928-0.709,1.423-1.03l2.388,1.838c0.253,0.194,0.593,0.229,0.879,0.091c1.093-0.526,2.239-0.9,3.404-1.108
46
- c0.314-0.057,0.569-0.285,0.66-0.591l0.854-2.898c0.551-0.035,1.199-0.035,1.752,0l0.852,2.898c0.092,0.306,0.345,0.535,0.66,0.591
47
- c1.165,0.208,2.311,0.582,3.405,1.108c0.285,0.138,0.625,0.102,0.879-0.091l2.387-1.838c0.494,0.321,0.971,0.666,1.423,1.031
48
- l-1.01,2.84c-0.108,0.301-0.036,0.636,0.184,0.864c0.845,0.882,1.558,1.857,2.12,2.896c0.146,0.274,0.43,0.442,0.741,0.442
49
- c0.007,0,0.014,0,0.021,0l3.02-0.083C53.257,33.978,53.435,34.536,53.587,35.12z"/>
50
- <path fill="#6699CC" d="M37.5,29.626c-5.404,0-9.801,4.396-9.801,9.799c0,5.402,4.397,9.803,9.801,9.803s9.8-4.398,9.8-9.803
51
- C47.3,34.022,42.904,29.626,37.5,29.626z M37.5,47.543c-4.475,0-8.116-3.641-8.116-8.117c0-4.475,3.642-8.114,8.116-8.114
52
- c4.474,0,8.114,3.639,8.114,8.114S41.974,47.543,37.5,47.543z"/>
53
- </g>
54
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/cross_icon.svg DELETED
@@ -1,41 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
6
- <g id="Layer_1_1_" display="none">
7
- <path display="inline" fill="#E8AE4A" d="M10,0C4.477,0,0,4.478,0,10c0,5.521,4.477,10,10,10c5.521,0,10-4.479,10-10
8
- C20,4.478,15.521,0,10,0z M11.329,16.83c-0.362,0.361-0.804,0.545-1.313,0.545s-0.949-0.184-1.312-0.545
9
- c-0.361-0.362-0.544-0.805-0.544-1.313c0-0.51,0.18-0.951,0.537-1.316c0.357-0.363,0.802-0.551,1.318-0.551
10
- c0.512,0,0.953,0.184,1.313,0.543c0.359,0.361,0.542,0.808,0.542,1.324C11.871,16.027,11.688,16.468,11.329,16.83z M11.389,7.468
11
- l-0.535,2.207c-0.185,0.771-0.321,1.7-0.409,2.763c-0.01,0.111-0.104,0.198-0.216,0.198H9.783c-0.114,0-0.209-0.089-0.216-0.202
12
- c-0.046-0.754-0.201-1.683-0.46-2.759L8.58,7.467C8.257,6.115,8.099,5.169,8.099,4.572c0-0.576,0.177-1.049,0.527-1.406
13
- c0.351-0.358,0.813-0.541,1.37-0.541c0.543,0,1.004,0.183,1.363,0.544c0.357,0.36,0.541,0.822,0.541,1.373
14
- C11.9,5.077,11.734,6.033,11.389,7.468z"/>
15
- </g>
16
- <g id="Layer_1_copy_3" display="none">
17
- <path display="inline" fill="#4675B8" d="M10,0C4.477,0,0,4.478,0,10c0,5.521,4.477,10,10,10c5.521,0,10-4.479,10-10
18
- C20,4.478,15.521,0,10,0z M11.329,16.83c-0.362,0.361-0.804,0.545-1.313,0.545s-0.949-0.184-1.312-0.545
19
- c-0.361-0.362-0.544-0.805-0.544-1.313c0-0.51,0.18-0.951,0.537-1.316c0.357-0.363,0.802-0.551,1.318-0.551
20
- c0.512,0,0.953,0.184,1.313,0.543c0.359,0.361,0.542,0.808,0.542,1.324C11.871,16.027,11.688,16.468,11.329,16.83z M11.389,7.468
21
- l-0.535,2.207c-0.185,0.771-0.321,1.7-0.409,2.763c-0.01,0.111-0.104,0.198-0.216,0.198H9.783c-0.114,0-0.209-0.089-0.216-0.202
22
- c-0.046-0.754-0.201-1.683-0.46-2.759L8.58,7.467C8.257,6.115,8.099,5.169,8.099,4.572c0-0.576,0.177-1.049,0.527-1.406
23
- c0.351-0.358,0.813-0.541,1.37-0.541c0.543,0,1.004,0.183,1.363,0.544c0.357,0.36,0.541,0.822,0.541,1.373
24
- C11.9,5.077,11.734,6.033,11.389,7.468z"/>
25
- </g>
26
- <g id="Layer_1_copy" display="none">
27
- <path display="inline" fill="#A32430" d="M10,0C4.477,0,0,4.478,0,10c0,5.521,4.477,10,10,10c5.521,0,10-4.479,10-10
28
- C20,4.478,15.521,0,10,0z M15.159,13.764c0.187,0.188,0.288,0.438,0.288,0.697c0,0.262-0.102,0.51-0.288,0.695
29
- c-0.185,0.184-0.438,0.289-0.698,0.289c-0.262,0-0.518-0.105-0.697-0.291L10,11.393l-3.764,3.766c-0.361,0.359-1.033,0.359-1.393,0
30
- c-0.187-0.186-0.29-0.434-0.29-0.695s0.103-0.512,0.289-0.695L8.606,10L4.842,6.234c-0.385-0.384-0.385-1.01,0-1.394
31
- c0.359-0.361,1.032-0.361,1.394,0L10,8.604l3.766-3.765c0.356-0.359,1.033-0.361,1.396,0c0.188,0.185,0.288,0.433,0.288,0.697
32
- c0.001,0.264-0.104,0.511-0.288,0.697l-3.767,3.764L15.159,13.764z"/>
33
- </g>
34
- <g>
35
- <circle fill="#CC3D6A" cx="10" cy="10" r="9.967"/>
36
- </g>
37
- <path fill="#FFFFFF" d="M11.414,10l3.503-3.503c0.392-0.391,0.392-1.024,0-1.414c-0.392-0.391-1.022-0.391-1.414,0L10,8.586
38
- L6.497,5.082c-0.391-0.391-1.023-0.391-1.414,0c-0.391,0.39-0.391,1.023,0,1.414L8.586,10l-3.503,3.504
39
- c-0.391,0.391-0.391,1.023,0,1.414c0.195,0.195,0.451,0.293,0.707,0.293s0.512-0.098,0.707-0.293L10,11.414l3.502,3.503
40
- c0.195,0.194,0.451,0.293,0.707,0.293s0.512-0.099,0.707-0.293c0.391-0.392,0.391-1.022,0-1.414L11.414,10z"/>
41
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/db.svg DELETED
@@ -1,21 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <path fill="#21A0DF" d="M66.478,27.294c0,0,0-0.001,0-0.001V11.727c0-0.054-0.006-0.107-0.017-0.159
7
- c0-0.001-0.001-0.002-0.001-0.004c0.006-0.089,0.018-0.178,0.018-0.268c0-0.163-0.049-0.313-0.132-0.439
8
- c-0.628-2.732-3.608-5.213-8.528-7.054c-5.19-1.943-12.039-3.013-19.281-3.013c-7.244,0-14.091,1.07-19.283,3.013
9
- c-4.92,1.841-7.9,4.322-8.527,7.055c-0.083,0.126-0.132,0.276-0.132,0.438c0,0.089,0.012,0.178,0.017,0.267c0,0.001,0,0.003,0,0.004
10
- c-0.011,0.052-0.017,0.105-0.017,0.161v50.829c0,0.057,0.006,0.111,0.017,0.164c0.505,6.453,12.718,11.491,27.925,11.491
11
- c15.204,0,27.415-5.037,27.923-11.489c0.013-0.053,0.019-0.109,0.019-0.166v-17.66c0-0.002,0-0.002,0-0.003v-0.001V27.296
12
- C66.478,27.296,66.478,27.295,66.478,27.294z M19.813,5.299c5.017-1.878,11.665-2.911,18.723-2.911
13
- c7.057,0,13.706,1.033,18.722,2.911c4.615,1.727,7.365,4.025,7.598,6.326c-0.5,4.419-10.945,9.024-26.319,9.024
14
- c-15.375,0-25.821-4.604-26.319-9.024C12.449,9.324,15.199,7.026,19.813,5.299z M38.536,22.248c12.32,0,22.537-2.975,26.343-7.232
15
- v12.281c-0.004,5.589-12.066,10.311-26.343,10.311c-14.279,0-26.343-4.723-26.343-10.313V15.015
16
- C15.999,19.272,26.216,22.248,38.536,22.248z M64.879,62.442c-0.004,0.023-0.006,0.047-0.008,0.068
17
- c-0.142,2.551-2.929,5.097-7.648,6.987c-5.01,2.008-11.646,3.114-18.687,3.114c-7.041,0-13.678-1.106-18.687-3.114
18
- c-4.72-1.891-7.507-4.437-7.65-6.987c-0.001-0.021-0.003-0.045-0.006-0.067V48.938c3.806,4.631,14.023,7.867,26.343,7.867
19
- c12.32,0,22.537-3.236,26.343-7.866V62.442z M64.879,44.895c-0.004,5.59-12.066,10.313-26.343,10.313
20
- c-14.279,0-26.343-4.724-26.343-10.314V31.34c3.806,4.63,14.023,7.865,26.343,7.865c12.32,0,22.537-3.235,26.343-7.865V44.895z"/>
21
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/empty-cache.svg DELETED
@@ -1,60 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M61.125,33.733h-1.583V11.637c0-0.003-0.002-0.007-0.002-0.01c-0.001-0.077-0.024-0.151-0.046-0.227
8
- c-0.01-0.035-0.01-0.074-0.023-0.107c-0.01-0.023-0.029-0.04-0.041-0.062c-0.043-0.079-0.089-0.156-0.152-0.219
9
- c-0.002-0.002-0.004-0.005-0.006-0.007L50.12,2.247h-0.001l-0.014-0.013c-0.028-0.027-0.065-0.039-0.098-0.061
10
- c-0.059-0.043-0.113-0.089-0.183-0.116s-0.14-0.033-0.212-0.042C49.575,2.008,49.541,1.99,49.5,1.99H18.478
11
- c-1.585,0-2.875,1.29-2.875,2.875v28.868h-1.478c-1.585,0-2.875,1.29-2.875,2.875v6.028c0,1.585,1.29,2.875,2.875,2.875h1.876
12
- c0.037,0,0.067-0.017,0.103-0.021c0.081,3.687-0.345,7.248-0.771,10.725c-0.626,5.098-1.273,10.367-0.339,16.061
13
- c0.07,0.43,0.441,0.733,0.862,0.733c0.047,0,0.095-0.004,0.143-0.012c0.477-0.078,0.8-0.528,0.722-1.005
14
- c-0.894-5.446-0.262-10.59,0.349-15.563c0.621-5.06,1.259-10.289,0.356-15.933h1.765c-0.001,0.053-0.014,0.103-0.005,0.155
15
- c0.893,5.445,0.261,10.588-0.35,15.562c-0.626,5.097-1.274,10.367-0.338,16.062c0.07,0.43,0.441,0.733,0.862,0.733
16
- c0.047,0,0.095-0.004,0.143-0.012c0.477-0.078,0.8-0.528,0.722-1.005c-0.895-5.446-0.262-10.592,0.349-15.565
17
- c0.621-5.058,1.26-10.286,0.356-15.93h1.767c-0.001,0.053-0.015,0.103-0.006,0.155c0.893,5.447,0.261,10.591-0.35,15.563
18
- c-0.626,5.097-1.273,10.366-0.34,16.06c0.07,0.429,0.441,0.732,0.862,0.732c0.047,0,0.095-0.004,0.143-0.012
19
- c0.477-0.078,0.8-0.528,0.722-1.005c-0.893-5.445-0.261-10.589,0.351-15.562c0.621-5.06,1.26-10.289,0.356-15.935h1.764
20
- c-0.001,0.053-0.015,0.103-0.006,0.155c0.893,5.445,0.261,10.589-0.35,15.563c-0.626,5.098-1.273,10.367-0.339,16.061
21
- c0.07,0.43,0.441,0.733,0.862,0.733c0.047,0,0.095-0.004,0.143-0.012c0.477-0.078,0.8-0.528,0.722-1.005
22
- c-0.894-5.446-0.262-10.59,0.349-15.563c0.621-5.059,1.259-10.288,0.356-15.932H29.7c-0.001,0.053-0.015,0.103-0.006,0.155
23
- c0.891,5.443,0.259,10.586-0.351,15.559c-0.626,5.1-1.274,10.37-0.339,16.064c0.07,0.429,0.441,0.732,0.862,0.732
24
- c0.047,0,0.095-0.004,0.143-0.012c0.477-0.078,0.8-0.528,0.722-1.005c-0.894-5.447-0.262-10.593,0.35-15.567
25
- c0.621-5.057,1.259-10.285,0.357-15.928h1.764c-0.001,0.053-0.015,0.104-0.006,0.156c0.894,5.445,0.262,10.59-0.349,15.563
26
- c-0.626,5.098-1.274,10.366-0.339,16.059c0.07,0.43,0.441,0.733,0.862,0.733c0.047,0,0.095-0.004,0.143-0.012
27
- c0.477-0.078,0.8-0.528,0.722-1.005c-0.894-5.445-0.262-10.588,0.35-15.563c0.622-5.059,1.26-10.289,0.355-15.934h1.766
28
- c-0.001,0.053-0.015,0.104-0.006,0.156c0.893,5.444,0.261,10.59-0.35,15.563c-0.626,5.097-1.273,10.365-0.34,16.058
29
- c0.07,0.43,0.441,0.733,0.862,0.733c0.047,0,0.095-0.004,0.143-0.012c0.477-0.078,0.8-0.528,0.722-1.005
30
- c-0.892-5.444-0.261-10.588,0.35-15.563c0.621-5.059,1.259-10.289,0.356-15.934h1.767c-0.001,0.053-0.015,0.103-0.006,0.156
31
- c0.892,5.443,0.26,10.588-0.351,15.562c-0.625,5.099-1.271,10.368-0.34,16.062c0.07,0.429,0.441,0.732,0.862,0.732
32
- c0.047,0,0.095-0.004,0.144-0.012c0.477-0.078,0.799-0.527,0.722-1.006c-0.892-5.444-0.261-10.588,0.35-15.563
33
- c0.62-5.058,1.259-10.288,0.356-15.931h1.765c-0.001,0.053-0.015,0.103-0.006,0.156c0.894,5.444,0.262,10.59-0.349,15.564
34
- c-0.625,5.096-1.271,10.365-0.34,16.057c0.07,0.43,0.441,0.733,0.862,0.733c0.047,0,0.095-0.004,0.144-0.012
35
- c0.477-0.078,0.799-0.527,0.722-1.005c-0.892-5.443-0.261-10.588,0.351-15.562c0.619-5.06,1.258-10.29,0.354-15.935h1.765
36
- c-0.001,0.053-0.015,0.103-0.006,0.156c0.894,5.445,0.263,10.592-0.349,15.567c-0.625,5.097-1.271,10.363-0.342,16.054
37
- c0.07,0.43,0.441,0.733,0.862,0.733c0.047,0,0.095-0.004,0.144-0.013c0.477-0.077,0.799-0.526,0.722-1.004
38
- c-0.89-5.442-0.259-10.584,0.351-15.558c0.621-5.061,1.26-10.293,0.355-15.938h1.768c-0.001,0.054-0.015,0.104-0.006,0.156
39
- c0.891,5.445,0.26,10.59-0.352,15.565c-0.625,5.097-1.271,10.365-0.34,16.058c0.069,0.428,0.44,0.732,0.861,0.732
40
- c0.047,0,0.096-0.004,0.143-0.012c0.478-0.078,0.801-0.527,0.723-1.006c-0.891-5.442-0.26-10.586,0.352-15.561
41
- c0.621-5.061,1.258-10.29,0.356-15.936h1.769c-0.002,0.053-0.016,0.103-0.007,0.156c0.89,5.442,0.259,10.586-0.352,15.56
42
- c-0.626,5.099-1.272,10.37-0.341,16.063c0.07,0.428,0.441,0.732,0.863,0.732c0.047,0,0.094-0.004,0.143-0.012
43
- c0.477-0.078,0.8-0.527,0.722-1.006c-0.892-5.444-0.261-10.59,0.351-15.566c0.619-5.057,1.258-10.287,0.357-15.928h1.764
44
- c0,0.052-0.015,0.102-0.006,0.154c0.889,5.443,0.258,10.586-0.352,15.561c-0.626,5.099-1.271,10.369-0.34,16.063
45
- c0.07,0.43,0.44,0.733,0.861,0.733c0.047,0,0.096-0.004,0.144-0.013c0.477-0.078,0.8-0.526,0.722-1.004
46
- c-0.893-5.445-0.261-10.592,0.35-15.567c0.434-3.524,0.863-7.14,0.787-10.914h1.236c1.585,0,2.875-1.29,2.875-2.875v-6.028
47
- C64,35.023,62.71,33.733,61.125,33.733z M50.375,4.913l6.111,5.849H51.5c-0.62,0-1.125-0.505-1.125-1.125V4.913z M17.353,4.865
48
- c0-0.62,0.505-1.125,1.125-1.125h30.147v5.896c0,1.585,1.29,2.875,2.875,2.875h6.292v21.222H17.353V4.865z M62.25,42.637
49
- c0,0.62-0.505,1.125-1.125,1.125h-1.313c-0.07-1.085-0.179-2.181-0.356-3.296c0.403-0.077,0.715-0.416,0.715-0.843
50
- c0-0.482-0.392-0.875-0.875-0.875H15.139c-0.483,0-0.875,0.393-0.875,0.875s0.392,0.875,0.875,0.875h0.548
51
- c-0.001,0.053-0.015,0.104-0.006,0.156c0.172,1.05,0.273,2.084,0.343,3.111c-0.008,0-0.015-0.005-0.023-0.005h-1.876
52
- c-0.62,0-1.125-0.505-1.125-1.125v-6.028c0-0.62,0.505-1.125,1.125-1.125h47c0.62,0,1.125,0.505,1.125,1.125V42.637z"/>
53
- <path fill="#6699CC" d="M21.625,17.888H52.25c0.482,0,0.875-0.392,0.875-0.875s-0.393-0.875-0.875-0.875H21.625
54
- c-0.483,0-0.875,0.392-0.875,0.875S21.142,17.888,21.625,17.888z"/>
55
- <path fill="#6699CC" d="M52.25,29.148H21.625c-0.483,0-0.875,0.392-0.875,0.875s0.392,0.875,0.875,0.875H52.25
56
- c0.482,0,0.875-0.392,0.875-0.875S52.732,29.148,52.25,29.148z"/>
57
- <path fill="#6699CC" d="M52.25,22.644H21.625c-0.483,0-0.875,0.392-0.875,0.875s0.392,0.875,0.875,0.875H52.25
58
- c0.482,0,0.875-0.392,0.875-0.875S52.732,22.644,52.25,22.644z"/>
59
- </g>
60
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/expired_transient.svg DELETED
@@ -1,38 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M62.406,13.464c-0.043-0.11-0.104-0.216-0.195-0.303L52.215,3.56c-0.026-0.026-0.062-0.038-0.092-0.059
8
- c-0.057-0.041-0.109-0.085-0.177-0.111c-0.064-0.026-0.136-0.032-0.204-0.042c-0.035-0.004-0.067-0.021-0.104-0.021h-0.017H51.62
9
- H15.233c-1.502,0-2.724,1.222-2.724,2.723v63.723c0,1.501,1.222,2.723,2.724,2.723h44.535c1.501,0,2.723-1.222,2.723-2.723V13.818
10
- C62.491,13.69,62.458,13.573,62.406,13.464z M52.471,6.117l7.151,6.868h-7.041c-0.062,0-0.11-0.049-0.11-0.112V6.117z
11
- M60.825,69.773c0,0.582-0.475,1.056-1.057,1.056H15.233c-0.583,0-1.057-0.474-1.057-1.056V6.05c0-0.583,0.474-1.057,1.057-1.057
12
- h35.571v7.879c0,0.98,0.798,1.778,1.776,1.778h8.244V69.773z"/>
13
- <path fill="#6699CC" d="M48.729,51.256c0-0.625-0.237-1.467-1.205-2.305c-1.33-2.633-2.331-4.074-4.078-6.423
14
- c-0.821-1.105-1.484-1.938-2.035-2.611c0.551-0.672,1.21-1.505,2.035-2.613c2.146-2.881,3.215-4.476,5.181-8.708
15
- c0.103-0.222,0.098-0.472,0.002-0.686c0-0.006,0.002-0.012,0.002-0.018c0-3.198-9.991-3.292-11.13-3.292
16
- s-11.129,0.092-11.129,3.292c0,0.004,0.001,0.008,0.001,0.011c-0.097,0.217-0.103,0.468,0,0.691
17
- c1.964,4.232,3.034,5.828,5.178,8.709c0.819,1.102,1.481,1.935,2.037,2.611c-0.553,0.675-1.215,1.51-2.037,2.612
18
- c-1.747,2.35-2.747,3.791-4.079,6.427c-0.961,0.834-1.202,1.675-1.202,2.301c0,0.1,0.022,0.193,0.034,0.291
19
- c-0.004,0.089,0.006,0.177,0.03,0.261c0.628,2.83,6.047,4.35,11.167,4.35c5.116,0,10.532-1.518,11.165-4.345
20
- c0.026-0.091,0.039-0.184,0.033-0.279C48.709,51.44,48.729,51.351,48.729,51.256z M41.804,49.128
21
- c-1.129,1.13-2.541,1.291-4.304,1.291s-3.12-0.108-4.303-1.291c0.818-1.763,1.247-2.388,2.112-3.55
22
- c0.865-1.164,1.309-1.616,2.19-2.693c0.88,1.077,1.325,1.529,2.189,2.693C40.555,46.742,40.983,47.366,41.804,49.128z
23
- M32.099,50.228c1.612,1.611,3.474,1.746,5.401,1.746c1.769,0,3.79-0.135,5.4-1.746c0.395-0.395,0.524-0.96,0.387-1.486
24
- c0.854,0.238,1.614,0.524,2.225,0.852c0.263,0.142,0.489,0.289,0.69,0.438c0.21,0.421,0.428,0.87,0.66,1.365
25
- c-2.329,2.055-5.235,2.472-9.362,2.472c-3.839,0-6.8-0.185-9.363-2.47c0.233-0.497,0.452-0.946,0.663-1.37
26
- c0.21-0.155,0.453-0.31,0.732-0.456c0,0,0-0.001,0.001-0.001s0,0,0,0c0.6-0.316,1.345-0.594,2.18-0.827
27
- C31.576,49.268,31.706,49.833,32.099,50.228z M46.795,27.78c-3.325,1.332-5.402,1.703-9.295,1.703c-3.892,0-5.968-0.37-9.293-1.702
28
- c0.833-0.623,4.14-1.513,9.294-1.513C42.653,26.267,45.96,27.156,46.795,27.78z M32.887,43.522c1.029-1.38,1.801-2.328,2.421-3.073
29
- c0.257-0.31,0.257-0.758,0-1.066c-0.622-0.747-1.396-1.698-2.421-3.074c-1.672-2.246-2.638-3.645-3.91-6.153
30
- c3.044,0.983,7.762,1.026,8.523,1.026s5.476-0.043,8.52-1.025c-1.271,2.509-2.238,3.907-3.911,6.153
31
- c-1.033,1.388-1.803,2.333-2.42,3.073c-0.257,0.309-0.257,0.757,0,1.066c0.619,0.741,1.391,1.688,2.42,3.073
32
- c1.122,1.507,1.924,2.636,2.714,3.963c-0.712-0.258-1.497-0.481-2.347-0.656l0,0h-0.004c-0.002,0-0.002-0.001-0.004-0.001
33
- c0,0,0,0-0.001,0l-0.093-0.02c-0.437-0.782-0.845-1.358-1.438-2.157c-0.606-0.814-1.013-1.292-1.482-1.849
34
- c-0.225-0.266-0.465-0.548-0.753-0.901c-0.589-0.72-1.814-0.72-2.405,0c-0.289,0.354-0.53,0.64-0.754,0.903
35
- c-0.469,0.557-0.874,1.034-1.479,1.847c-0.595,0.801-1.002,1.375-1.438,2.157c-0.89,0.179-1.711,0.409-2.452,0.679
36
- C30.963,46.158,31.766,45.031,32.887,43.522z"/>
37
- </g>
38
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/optimize_tables.svg DELETED
@@ -1,30 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <polygon fill="#6699CC" points="33.496,19.622 41.335,23.493 48.044,17.635 49.146,18.897 50.775,14.133 45.835,15.104
8
- 46.937,16.367 41.075,21.487 33.354,17.676 22.786,24.961 23.741,26.347 "/>
9
- <path fill="#6699CC" d="M64.08,13.12c-0.041-0.11-0.104-0.216-0.195-0.303L53.709,3.043c-0.027-0.027-0.063-0.039-0.095-0.061
10
- c-0.057-0.042-0.11-0.084-0.175-0.112c-0.067-0.027-0.138-0.033-0.209-0.042c-0.036-0.004-0.068-0.021-0.104-0.021h-0.017
11
- c-0.002,0-0.002,0-0.002,0h-39.51c-1.524,0-2.765,1.241-2.765,2.765v64.853c0,1.525,1.24,2.765,2.765,2.765h47.807
12
- c1.522,0,2.765-1.239,2.765-2.765V13.478C64.167,13.349,64.133,13.229,64.08,13.12z M53.968,5.625l7.3,7.011h-7.18
13
- c-0.065,0-0.12-0.054-0.12-0.12V5.625z M62.483,70.427c0,0.597-0.484,1.082-1.081,1.082H13.598c-0.597,0-1.082-0.485-1.082-1.082
14
- V5.574c0-0.596,0.485-1.082,1.082-1.082h38.688v8.025c0,0.995,0.809,1.803,1.803,1.803h8.396V70.427z"/>
15
- <path fill="#6699CC" d="M17.724,28.494c-0.464,0-0.842,0.377-0.842,0.842v28.058c0,0.465,0.377,0.841,0.842,0.841h39.185
16
- c0.065,0,0.122-0.023,0.184-0.036c0.061,0.013,0.118,0.036,0.183,0.036c0.464,0,0.842-0.376,0.842-0.841V29.336
17
- c0-0.465-0.378-0.842-0.842-0.842c-0.064,0-0.122,0.023-0.183,0.037c-0.062-0.014-0.118-0.037-0.184-0.037H17.724z M56.435,37.847
18
- H41.649v-2.992h14.785V37.847z M18.565,34.854h4.931v2.992h-4.931V34.854z M18.565,39.529h4.931v2.993h-4.931V39.529z
19
- M39.966,47.199H25.18v-2.994h14.786V47.199z M41.649,44.205h14.785v2.994H41.649V44.205z M25.18,42.522v-2.993h14.786v2.993H25.18
20
- z M23.497,44.205v2.994h-4.931v-2.994H23.497z M23.497,48.882v2.992h-4.931v-2.992H23.497z M25.18,48.882h14.786v2.992H25.18
21
- V48.882z M41.649,48.882h14.785v2.992H41.649V48.882z M56.435,42.522H41.649v-2.993h14.785V42.522z M39.966,37.847H25.18v-2.992
22
- h14.786V37.847z M25.18,33.171v-2.994h14.786v2.994H25.18z M23.497,33.171h-4.931v-2.994h4.931V33.171z M18.565,53.559h4.931v2.993
23
- h-4.931V53.559z M25.18,53.559h14.786v2.993H25.18V53.559z M41.649,53.559h14.785v2.993H41.649V53.559z M56.435,33.171H41.649
24
- v-2.994h14.785V33.171z"/>
25
- <path fill="#6699CC" d="M28.019,37.043h9.289c0.398,0,0.721-0.323,0.721-0.721s-0.323-0.721-0.721-0.721h-9.289
26
- c-0.398,0-0.721,0.323-0.721,0.721S27.62,37.043,28.019,37.043z"/>
27
- <path fill="#6699CC" d="M44.5,37.043h9.29c0.397,0,0.721-0.323,0.721-0.721s-0.323-0.721-0.721-0.721H44.5
28
- c-0.398,0-0.721,0.323-0.721,0.721S44.102,37.043,44.5,37.043z"/>
29
- </g>
30
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/purge-403.svg DELETED
@@ -1,47 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M30.075,34.094H28.1v-9.829c0-0.138-0.112-0.25-0.25-0.25h-1.805c-0.082,0-0.158,0.04-0.205,0.106
8
- l-7.116,10.142c-0.03,0.042-0.045,0.092-0.045,0.144v1.486c0,0.138,0.112,0.25,0.25,0.25h7.041v3.195c0,0.138,0.112,0.25,0.25,0.25
9
- h1.63c0.138,0,0.25-0.112,0.25-0.25v-3.195h1.975c0.138,0,0.25-0.112,0.25-0.25v-1.549C30.325,34.206,30.213,34.094,30.075,34.094z
10
- M25.97,29.361v4.732h-4.857l4.413-6.275c0.16-0.241,0.328-0.517,0.5-0.826C25.988,27.85,25.97,28.644,25.97,29.361z"/>
11
- <path fill="#6699CC" d="M40.443,37.76c0.839-1.313,1.264-3.31,1.264-5.938c0-2.539-0.439-4.513-1.305-5.867
12
- c-0.891-1.389-2.209-2.094-3.918-2.094c-1.751,0-3.074,0.677-3.933,2.011c-0.836,1.3-1.26,3.301-1.26,5.95
13
- c0,2.566,0.438,4.548,1.301,5.892c0.886,1.379,2.195,2.079,3.892,2.079C38.248,39.793,39.58,39.109,40.443,37.76z M38.726,36.452
14
- c-0.467,0.925-1.2,1.375-2.242,1.375c-1.029,0-1.758-0.443-2.229-1.356c-0.492-0.955-0.741-2.519-0.741-4.648
15
- c0-2.131,0.25-3.691,0.741-4.638c0.47-0.906,1.199-1.347,2.229-1.347c1.042,0,1.776,0.447,2.243,1.365
16
- c0.489,0.961,0.737,2.515,0.737,4.619C39.464,33.925,39.216,35.483,38.726,36.452z"/>
17
- <path fill="#6699CC" d="M53.068,27.874c0-1.234-0.438-2.222-1.301-2.936c-0.85-0.702-2.045-1.057-3.553-1.057
18
- c-0.913,0-1.794,0.145-2.619,0.43c-0.824,0.283-1.564,0.681-2.201,1.183c-0.107,0.084-0.127,0.238-0.046,0.346l0.861,1.148
19
- c0.078,0.105,0.224,0.131,0.335,0.061c0.723-0.463,1.371-0.785,1.928-0.956c0.556-0.169,1.155-0.255,1.783-0.255
20
- c0.798,0,1.432,0.191,1.886,0.567c0.446,0.37,0.663,0.871,0.663,1.53c0,0.84-0.303,1.478-0.926,1.949
21
- c-0.636,0.48-1.521,0.723-2.629,0.723h-1.496c-0.138,0-0.25,0.112-0.25,0.25v1.467c0,0.138,0.112,0.25,0.25,0.25h1.477
22
- c2.715,0,4.035,0.811,4.035,2.478c0,1.881-1.189,2.796-3.636,2.796c-0.635,0-1.318-0.083-2.031-0.246
23
- c-0.713-0.162-1.393-0.402-2.021-0.713c-0.077-0.038-0.17-0.034-0.243,0.012s-0.118,0.126-0.118,0.212v1.619
24
- c0,0.096,0.055,0.184,0.141,0.225c0.639,0.311,1.308,0.529,1.987,0.652c0.669,0.122,1.417,0.184,2.224,0.184
25
- c1.873,0,3.346-0.405,4.378-1.206c1.051-0.815,1.583-1.991,1.583-3.494c0-1.06-0.316-1.932-0.939-2.592
26
- c-0.466-0.493-1.12-0.849-1.951-1.062c0.637-0.243,1.16-0.595,1.563-1.051C52.776,29.735,53.068,28.889,53.068,27.874z"/>
27
- <path fill="#6699CC" d="M17.361,5h-0.05c-0.483,0-0.85,0.392-0.85,0.875s0.417,0.875,0.9,0.875c0.483,0,0.875-0.392,0.875-0.875
28
- S17.845,5,17.361,5z"/>
29
- <path fill="#6699CC" d="M20.898,5h-0.086c-0.483,0-0.832,0.392-0.832,0.875s0.435,0.875,0.918,0.875s0.875-0.392,0.875-0.875
30
- S21.382,5,20.898,5z"/>
31
- <path fill="#6699CC" d="M24.398,5h-0.05c-0.483,0-0.85,0.392-0.85,0.875s0.417,0.875,0.9,0.875s0.875-0.392,0.875-0.875
32
- S24.882,5,24.398,5z"/>
33
- <path fill="#6699CC" d="M37.626,59.27c0,5.621,4.574,10.195,10.196,10.195c5.623,0,10.197-4.574,10.197-10.195
34
- c0-5.623-4.574-10.197-10.197-10.197C42.2,49.07,37.626,53.646,37.626,59.27z M56.27,59.27c0,4.656-3.789,8.445-8.446,8.445
35
- s-8.446-3.789-8.446-8.445c0-4.658,3.789-8.447,8.446-8.447C52.48,50.82,56.27,54.609,56.27,59.27z"/>
36
- <path fill="#6699CC" d="M42.833,64.257c0.171,0.171,0.396,0.257,0.619,0.257c0.223,0,0.448-0.086,0.618-0.257l3.753-3.752
37
- l3.752,3.752c0.171,0.171,0.396,0.257,0.618,0.257c0.224,0,0.449-0.086,0.619-0.257c0.342-0.342,0.342-0.896,0-1.237l-3.752-3.752
38
- l3.752-3.752c0.342-0.343,0.342-0.896,0-1.238s-0.896-0.342-1.237,0l-3.752,3.752l-3.753-3.752c-0.342-0.342-0.896-0.342-1.237,0
39
- c-0.341,0.342-0.341,0.896,0,1.238l3.752,3.752l-3.752,3.752C42.492,63.361,42.492,63.915,42.833,64.257z"/>
40
- <path fill="#6699CC" d="M62.77,13.878c-0.041-0.079-0.082-0.158-0.148-0.225L50.535,1.569c-0.004-0.003-0.01-0.004-0.012-0.008
41
- c-0.08-0.076-0.17-0.138-0.272-0.181c-0.106-0.044-0.222-0.067-0.335-0.067H14.812c-1.585,0-2.875,1.29-2.875,2.875v66.625
42
- c0,1.586,1.29,2.875,2.875,2.875h45.377c1.584,0,2.875-1.289,2.875-2.875v-56.29C63.063,14.265,62.947,14.039,62.77,13.878z
43
- M50.791,4.3l9.348,9.348h-8.223c-0.62,0-1.125-0.505-1.125-1.125V4.3z M13.687,4.188c0-0.621,0.504-1.125,1.125-1.125h34.229
44
- v6.126H13.687V4.188z M61.313,70.813c0,0.621-0.504,1.125-1.125,1.125H14.812c-0.62,0-1.125-0.504-1.125-1.125V10.938h35.354v1.584
45
- c0,1.585,1.29,2.875,2.875,2.875h9.396V70.813z"/>
46
- </g>
47
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/purge-404.svg DELETED
@@ -1,41 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M30.075,34.093H28.1v-9.829c0-0.138-0.112-0.25-0.25-0.25h-1.805c-0.082,0-0.158,0.04-0.205,0.106
8
- l-7.116,10.142c-0.03,0.042-0.045,0.092-0.045,0.144v1.486c0,0.138,0.112,0.25,0.25,0.25h7.041v3.195c0,0.138,0.112,0.25,0.25,0.25
9
- h1.63c0.138,0,0.25-0.112,0.25-0.25v-3.195h1.975c0.138,0,0.25-0.112,0.25-0.25v-1.549C30.325,34.205,30.213,34.093,30.075,34.093z
10
- M21.113,34.093l4.413-6.275c0.16-0.241,0.328-0.517,0.5-0.826c-0.037,0.857-0.056,1.651-0.056,2.369v4.732H21.113z"/>
11
- <path fill="#6699CC" d="M40.443,37.759c0.839-1.313,1.264-3.31,1.264-5.938c0-2.539-0.439-4.513-1.305-5.867
12
- c-0.891-1.389-2.209-2.094-3.918-2.094c-1.751,0-3.074,0.677-3.933,2.011c-0.836,1.3-1.26,3.301-1.26,5.95
13
- c0,2.566,0.438,4.548,1.301,5.892c0.886,1.379,2.195,2.079,3.892,2.079C38.248,39.792,39.58,39.108,40.443,37.759z M36.484,37.825
14
- c-1.029,0-1.758-0.443-2.229-1.356c-0.492-0.955-0.741-2.519-0.741-4.648c0-2.131,0.25-3.691,0.741-4.638
15
- c0.47-0.906,1.199-1.347,2.229-1.347c1.042,0,1.776,0.447,2.243,1.365c0.489,0.961,0.737,2.515,0.737,4.619
16
- c0,2.103-0.248,3.661-0.738,4.629C38.259,37.375,37.526,37.825,36.484,37.825z"/>
17
- <path fill="#6699CC" d="M50.061,24.014c-0.081,0-0.158,0.04-0.205,0.106l-7.117,10.142c-0.029,0.042-0.045,0.092-0.045,0.144v1.486
18
- c0,0.138,0.112,0.25,0.25,0.25h7.041v3.195c0,0.138,0.112,0.25,0.25,0.25h1.631c0.138,0,0.25-0.112,0.25-0.25v-3.195h1.975
19
- c0.138,0,0.25-0.112,0.25-0.25v-1.549c0-0.138-0.112-0.25-0.25-0.25h-1.975v-9.829c0-0.138-0.112-0.25-0.25-0.25H50.061z
20
- M45.128,34.093l4.412-6.275c0.16-0.241,0.327-0.517,0.5-0.826c-0.037,0.857-0.056,1.651-0.056,2.369v4.732H45.128z"/>
21
- <path fill="#6699CC" d="M17.361,5h-0.05c-0.483,0-0.85,0.392-0.85,0.875s0.417,0.875,0.9,0.875c0.483,0,0.875-0.392,0.875-0.875
22
- S17.845,5,17.361,5z"/>
23
- <path fill="#6699CC" d="M20.898,5h-0.086c-0.483,0-0.832,0.392-0.832,0.875s0.435,0.875,0.918,0.875s0.875-0.392,0.875-0.875
24
- S21.382,5,20.898,5z"/>
25
- <path fill="#6699CC" d="M24.398,5h-0.05c-0.483,0-0.85,0.392-0.85,0.875s0.417,0.875,0.9,0.875s0.875-0.392,0.875-0.875
26
- S24.882,5,24.398,5z"/>
27
- <path fill="#6699CC" d="M37.626,59.27c0,5.621,4.574,10.195,10.196,10.195c5.623,0,10.197-4.574,10.197-10.195
28
- c0-5.623-4.574-10.197-10.197-10.197C42.2,49.07,37.626,53.646,37.626,59.27z M56.27,59.27c0,4.656-3.789,8.445-8.446,8.445
29
- s-8.446-3.789-8.446-8.445c0-4.658,3.789-8.447,8.446-8.447C52.48,50.82,56.27,54.609,56.27,59.27z"/>
30
- <path fill="#6699CC" d="M42.833,64.257c0.171,0.171,0.396,0.257,0.619,0.257c0.223,0,0.448-0.086,0.618-0.257l3.753-3.752
31
- l3.752,3.752c0.171,0.171,0.396,0.257,0.618,0.257c0.224,0,0.449-0.086,0.619-0.257c0.342-0.342,0.342-0.896,0-1.237l-3.752-3.752
32
- l3.752-3.752c0.342-0.343,0.342-0.896,0-1.238s-0.896-0.342-1.237,0l-3.752,3.752l-3.753-3.752c-0.342-0.342-0.896-0.342-1.237,0
33
- c-0.341,0.342-0.341,0.896,0,1.238l3.752,3.752l-3.752,3.752C42.492,63.361,42.492,63.915,42.833,64.257z"/>
34
- <path fill="#6699CC" d="M62.77,13.878c-0.041-0.079-0.082-0.158-0.148-0.225L50.535,1.569c-0.004-0.003-0.01-0.004-0.012-0.008
35
- c-0.08-0.076-0.17-0.138-0.272-0.181c-0.106-0.044-0.222-0.067-0.335-0.067H14.812c-1.585,0-2.875,1.29-2.875,2.875v66.625
36
- c0,1.586,1.29,2.875,2.875,2.875h45.377c1.584,0,2.875-1.289,2.875-2.875v-56.29C63.063,14.265,62.947,14.039,62.77,13.878z
37
- M50.791,4.3l9.348,9.348h-8.223c-0.62,0-1.125-0.505-1.125-1.125V4.3z M13.687,4.188c0-0.621,0.504-1.125,1.125-1.125h34.229
38
- v6.126H13.687V4.188z M61.313,70.813c0,0.621-0.504,1.125-1.125,1.125H14.812c-0.62,0-1.125-0.504-1.125-1.125V10.938h35.354v1.584
39
- c0,1.585,1.29,2.875,2.875,2.875h9.396V70.813z"/>
40
- </g>
41
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/purge-500.svg DELETED
@@ -1,46 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M24.2,29.932c-0.686,0-1.381,0.061-2.071,0.18l0.333-3.945h5.769c0.138,0,0.25-0.112,0.25-0.25v-1.569
8
- c0-0.138-0.112-0.25-0.25-0.25h-7.455c-0.13,0-0.239,0.1-0.249,0.23l-0.564,7.014c-0.008,0.092,0.037,0.181,0.114,0.23l0.882,0.563
9
- c0.053,0.034,0.118,0.047,0.179,0.036c1.071-0.194,1.932-0.293,2.56-0.293c2.419,0,3.595,0.944,3.595,2.888
10
- c0,1.005-0.298,1.748-0.912,2.271c-0.617,0.525-1.506,0.791-2.643,0.791c-0.667,0-1.354-0.085-2.042-0.253
11
- c-0.683-0.168-1.258-0.4-1.708-0.691c-0.078-0.051-0.174-0.053-0.255-0.01c-0.081,0.044-0.13,0.128-0.13,0.22v1.641
12
- c0,0.087,0.045,0.168,0.12,0.214c0.923,0.562,2.268,0.847,3.996,0.847c1.791,0,3.221-0.466,4.252-1.386
13
- c1.039-0.928,1.565-2.219,1.565-3.837c0-1.43-0.486-2.576-1.445-3.404C27.143,30.347,25.834,29.932,24.2,29.932z"/>
14
- <path fill="#6699CC" d="M40.443,37.76c0.839-1.313,1.264-3.31,1.264-5.938c0-2.539-0.439-4.513-1.305-5.867
15
- c-0.891-1.389-2.209-2.094-3.918-2.094c-1.751,0-3.074,0.677-3.933,2.011c-0.836,1.3-1.26,3.301-1.26,5.95
16
- c0,2.566,0.438,4.548,1.301,5.892c0.886,1.379,2.195,2.079,3.892,2.079C38.248,39.793,39.58,39.109,40.443,37.76z M36.484,37.826
17
- c-1.029,0-1.758-0.443-2.229-1.356c-0.492-0.955-0.741-2.519-0.741-4.648c0-2.131,0.25-3.691,0.741-4.638
18
- c0.47-0.906,1.199-1.347,2.229-1.347c1.042,0,1.776,0.447,2.243,1.365c0.489,0.961,0.737,2.515,0.737,4.619
19
- c0,2.103-0.248,3.661-0.738,4.629C38.259,37.376,37.526,37.826,36.484,37.826z"/>
20
- <path fill="#6699CC" d="M48.491,23.861c-1.752,0-3.074,0.677-3.932,2.011c-0.837,1.299-1.261,3.3-1.261,5.95
21
- c0,2.567,0.438,4.55,1.302,5.892c0.884,1.38,2.193,2.079,3.891,2.079c1.765,0,3.097-0.685,3.959-2.033
22
- c0.839-1.313,1.265-3.311,1.265-5.938c0-2.538-0.439-4.512-1.306-5.867C51.52,24.566,50.201,23.861,48.491,23.861z M48.491,37.826
23
- c-1.029,0-1.759-0.443-2.229-1.356c-0.491-0.953-0.741-2.517-0.741-4.648c0-2.132,0.249-3.692,0.741-4.638
24
- c0.47-0.906,1.198-1.346,2.229-1.346c1.042,0,1.775,0.447,2.243,1.365c0.488,0.96,0.736,2.514,0.736,4.619
25
- c0,2.104-0.248,3.662-0.736,4.629C50.266,37.376,49.532,37.826,48.491,37.826z"/>
26
- <path fill="#6699CC" d="M17.361,5h-0.05c-0.483,0-0.85,0.392-0.85,0.875s0.417,0.875,0.9,0.875c0.483,0,0.875-0.392,0.875-0.875
27
- S17.845,5,17.361,5z"/>
28
- <path fill="#6699CC" d="M20.898,5h-0.086c-0.483,0-0.832,0.392-0.832,0.875s0.435,0.875,0.918,0.875s0.875-0.392,0.875-0.875
29
- S21.382,5,20.898,5z"/>
30
- <path fill="#6699CC" d="M24.398,5h-0.05c-0.483,0-0.85,0.392-0.85,0.875s0.417,0.875,0.9,0.875s0.875-0.392,0.875-0.875
31
- S24.882,5,24.398,5z"/>
32
- <path fill="#6699CC" d="M37.626,59.27c0,5.621,4.574,10.195,10.196,10.195c5.623,0,10.197-4.574,10.197-10.195
33
- c0-5.623-4.574-10.197-10.197-10.197C42.2,49.07,37.626,53.646,37.626,59.27z M56.27,59.27c0,4.656-3.789,8.445-8.446,8.445
34
- s-8.446-3.789-8.446-8.445c0-4.658,3.789-8.447,8.446-8.447C52.48,50.82,56.27,54.609,56.27,59.27z"/>
35
- <path fill="#6699CC" d="M42.833,64.257c0.171,0.171,0.396,0.257,0.619,0.257c0.223,0,0.448-0.086,0.618-0.257l3.753-3.752
36
- l3.752,3.752c0.171,0.171,0.396,0.257,0.618,0.257c0.224,0,0.449-0.086,0.619-0.257c0.342-0.342,0.342-0.896,0-1.237l-3.752-3.752
37
- l3.752-3.752c0.342-0.343,0.342-0.896,0-1.238s-0.896-0.342-1.237,0l-3.752,3.752l-3.753-3.752c-0.342-0.342-0.896-0.342-1.237,0
38
- c-0.341,0.342-0.341,0.896,0,1.238l3.752,3.752l-3.752,3.752C42.492,63.361,42.492,63.915,42.833,64.257z"/>
39
- <path fill="#6699CC" d="M62.77,13.878c-0.041-0.079-0.082-0.158-0.148-0.225L50.535,1.569c-0.004-0.003-0.01-0.004-0.012-0.008
40
- c-0.08-0.076-0.17-0.138-0.272-0.181c-0.106-0.044-0.222-0.067-0.335-0.067H14.812c-1.585,0-2.875,1.29-2.875,2.875v66.625
41
- c0,1.586,1.29,2.875,2.875,2.875h45.377c1.584,0,2.875-1.289,2.875-2.875v-56.29C63.063,14.265,62.947,14.039,62.77,13.878z
42
- M50.791,4.3l9.348,9.348h-8.223c-0.62,0-1.125-0.505-1.125-1.125V4.3z M13.687,4.188c0-0.621,0.504-1.125,1.125-1.125h34.229
43
- v6.126H13.687V4.188z M61.313,70.813c0,0.621-0.504,1.125-1.125,1.125H14.812c-0.62,0-1.125-0.504-1.125-1.125V10.938h35.354v1.584
44
- c0,1.585,1.29,2.875,2.875,2.875h9.396V70.813z"/>
45
- </g>
46
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/purge-all.svg DELETED
@@ -1,46 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M50.955,23.981l-17.298-7.355c-0.446-0.19-0.959,0.018-1.147,0.463c-0.189,0.445,0.018,0.958,0.463,1.147
8
- l17.296,7.355c0.112,0.047,0.229,0.07,0.344,0.07c0.34,0,0.664-0.2,0.806-0.533C51.605,24.684,51.398,24.17,50.955,23.981z"/>
9
- <path fill="#6699CC" d="M37.581,23.984l-5.931-2.612c-0.443-0.195-0.959,0.006-1.153,0.448c-0.195,0.442,0.006,0.958,0.448,1.153
10
- l5.931,2.612c0.115,0.05,0.234,0.074,0.352,0.074c0.336,0,0.657-0.195,0.801-0.522C38.225,24.695,38.023,24.179,37.581,23.984z"/>
11
- <path fill="#6699CC" d="M56.841,27.021h-0.973l2.483-5.843c0.545-1.285-0.057-2.775-1.34-3.322l-2.213-0.94l1.564-5.533
12
- c0.379-1.344-0.406-2.746-1.75-3.125l-24.202-6.84c-1.341-0.379-2.748,0.405-3.127,1.75l-3.206,11.346
13
- c-0.021,0.075-0.016,0.149-0.017,0.224l-0.817-0.103c-0.67-0.085-1.336,0.098-1.87,0.513c-0.535,0.416-0.875,1.014-0.958,1.685
14
- l-1.28,10.189H18.16c-1.549,0-2.809,1.26-2.809,2.809c0,0.034,0.002,0.068,0.006,0.103l4.831,40.993
15
- c0.03,1.523,1.278,2.753,2.808,2.753h29.007c1.53,0,2.778-1.229,2.808-2.753l4.834-40.993c0.004-0.034,0.006-0.068,0.006-0.103
16
- C59.648,28.281,58.391,27.021,56.841,27.021z M56.328,19.466c0.396,0.169,0.581,0.631,0.412,1.028l-2.555,6.01
17
- c-0.072,0.171-0.07,0.348-0.035,0.517H24.933l7.222-16.982c0.082-0.192,0.233-0.341,0.427-0.419c0.195-0.079,0.408-0.077,0.6,0.005
18
- l20.276,8.621c0.019,0.006,0.03,0.021,0.05,0.026c0.006,0.001,0.012,0.001,0.016,0.002L56.328,19.466z M28.969,3.642
19
- c0.118-0.416,0.549-0.659,0.968-0.541L54.139,9.94c0.416,0.118,0.658,0.552,0.543,0.967l-1.505,5.318l-19.311-8.21
20
- c-0.624-0.265-1.312-0.271-1.939-0.018c-0.628,0.253-1.119,0.736-1.383,1.358l-2.517,5.918c-0.062-0.023-0.12-0.054-0.188-0.063
21
- l-2.065-0.259L28.969,3.642z M22.152,17.049c0.026-0.208,0.131-0.393,0.296-0.521c0.166-0.128,0.374-0.185,0.579-0.159l4.304,0.54
22
- l-4.037,9.495c-0.087,0.205-0.082,0.421-0.017,0.617H20.9L22.152,17.049z M53.066,70.768c-0.004,0.034-0.006,0.068-0.006,0.104
23
- c0,0.584-0.475,1.059-1.059,1.059H22.996c-0.583,0-1.059-0.475-1.059-1.059c0-0.034-0.002-0.068-0.006-0.104l-4.829-40.98
24
- c0.023-0.563,0.489-1.015,1.058-1.015h38.681c0.569,0,1.034,0.451,1.058,1.015L53.066,70.768z"/>
25
- <path fill="#6699CC" d="M28.884,63.443c-0.48,0.055-0.826,0.486-0.772,0.968l0.326,2.907c0.05,0.447,0.429,0.777,0.869,0.777
26
- c0.032,0,0.065-0.002,0.099-0.006c0.48-0.054,0.826-0.486,0.772-0.967l-0.326-2.908C29.797,63.734,29.364,63.382,28.884,63.443z"/>
27
- <path fill="#6699CC" d="M26.532,42.486c0.48-0.055,0.826-0.486,0.772-0.967l-0.759-6.771c-0.054-0.479-0.479-0.819-0.967-0.772
28
- c-0.48,0.054-0.826,0.487-0.772,0.967l0.759,6.771c0.05,0.447,0.429,0.777,0.869,0.777C26.466,42.492,26.499,42.49,26.532,42.486z"
29
- />
30
- <path fill="#6699CC" d="M46.116,63.445c-0.485-0.057-0.914,0.291-0.968,0.771l-0.325,2.906c-0.056,0.48,0.29,0.913,0.771,0.967
31
- c0.033,0.004,0.066,0.006,0.1,0.006c0.438,0,0.818-0.33,0.867-0.777l0.326-2.905C46.941,63.934,46.598,63.5,46.116,63.445z"/>
32
- <path fill="#6699CC" d="M49.421,33.976c-0.487-0.052-0.913,0.292-0.967,0.772l-0.731,6.525c-0.056,0.479,0.291,0.912,0.771,0.967
33
- c0.032,0.004,0.065,0.006,0.099,0.006c0.439,0,0.818-0.33,0.868-0.777l0.731-6.525C50.247,34.463,49.9,34.03,49.421,33.976z"/>
34
- <path fill="#6699CC" d="M37.306,64.895c-0.483,0-0.875,0.392-0.875,0.875v1.453c0,0.482,0.392,0.875,0.875,0.875
35
- s0.875-0.393,0.875-0.875V65.77C38.182,65.285,37.789,64.895,37.306,64.895z"/>
36
- <path fill="#6699CC" d="M37.306,37.75c0.483,0,0.875-0.392,0.875-0.875v-2.029c0-0.483-0.393-0.875-0.875-0.875
37
- s-0.875,0.392-0.875,0.875v2.029C36.431,37.358,36.822,37.75,37.306,37.75z"/>
38
- <path fill="#6699CC" d="M37.5,40.496c-6.108,0-11.078,4.97-11.078,11.079c0,6.108,4.97,11.077,11.078,11.077
39
- c6.109,0,11.079-4.969,11.079-11.077C48.578,45.466,43.607,40.496,37.5,40.496z M37.5,60.902c-5.144,0-9.328-4.185-9.328-9.327
40
- c0-5.146,4.185-9.329,9.328-9.329c5.145,0,9.329,4.186,9.329,9.329C46.828,56.719,42.645,60.902,37.5,60.902z"/>
41
- <path fill="#6699CC" d="M38.74,51.574l4.164-4.165c0.341-0.343,0.341-0.896,0-1.238c-0.342-0.342-0.896-0.342-1.238,0L37.5,50.336
42
- l-4.166-4.165c-0.342-0.342-0.896-0.342-1.237,0c-0.341,0.343-0.342,0.896,0,1.238l4.165,4.165l-4.165,4.165
43
- c-0.342,0.342-0.342,0.896,0,1.237c0.171,0.172,0.395,0.256,0.619,0.256c0.224,0,0.448-0.084,0.619-0.256l4.166-4.164l4.166,4.164
44
- c0.171,0.172,0.396,0.256,0.619,0.256c0.223,0,0.448-0.084,0.618-0.256c0.342-0.342,0.342-0.896,0-1.237L38.74,51.574z"/>
45
- </g>
46
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/purge-cssjs.svg DELETED
@@ -1,50 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M47.673,48.495c-5.733,0-10.4,4.666-10.4,10.401c0,5.733,4.667,10.398,10.4,10.398
8
- c5.735,0,10.401-4.665,10.401-10.398C58.074,53.161,53.408,48.495,47.673,48.495z M47.673,67.546c-4.771,0-8.649-3.88-8.649-8.649
9
- c0-4.771,3.881-8.65,8.649-8.65c4.771,0,8.651,3.881,8.651,8.65S52.443,67.546,47.673,67.546z"/>
10
- <path fill="#6699CC" d="M52.758,53.811c-0.34-0.343-0.896-0.341-1.236,0l-3.848,3.848l-3.847-3.848
11
- c-0.343-0.343-0.897-0.343-1.237,0c-0.342,0.342-0.343,0.896-0.001,1.236l3.849,3.85l-3.849,3.849
12
- c-0.342,0.341-0.341,0.896,0.001,1.237c0.17,0.17,0.395,0.256,0.618,0.256s0.448-0.086,0.619-0.256l3.847-3.849l3.848,3.849
13
- c0.17,0.17,0.396,0.256,0.619,0.256c0.223,0,0.447-0.086,0.617-0.256c0.342-0.342,0.344-0.896,0.001-1.237l-3.848-3.849l3.848-3.85
14
- C53.102,54.706,53.1,54.15,52.758,53.811z"/>
15
- <path fill="#6699CC" d="M64.165,17.493c-0.044-0.117-0.108-0.228-0.205-0.32l-9.576-9.197c-0.03-0.029-0.067-0.041-0.102-0.064
16
- c-0.058-0.042-0.111-0.087-0.179-0.114c-0.076-0.031-0.156-0.04-0.236-0.048c-0.031-0.003-0.059-0.018-0.09-0.018h-0.015
17
- c-0.003,0-0.005,0-0.007,0h-3.189c-0.029-0.041-0.047-0.088-0.086-0.124l-5.531-5.314c-0.03-0.029-0.067-0.04-0.102-0.064
18
- c-0.058-0.042-0.111-0.087-0.18-0.114c-0.072-0.03-0.148-0.037-0.227-0.046c-0.034-0.004-0.064-0.02-0.101-0.02h-0.016
19
- c-0.001,0-0.002,0-0.004,0H12.917c-1.451,0-2.632,1.18-2.632,2.631v59.231c0,1.449,1.181,2.631,2.632,2.631h4.382v4.909
20
- c0,1.479,1.205,2.685,2.685,2.685h41.583c1.479,0,2.684-1.203,2.684-2.685V17.857C64.25,17.726,64.217,17.604,64.165,17.493z
21
- M54.652,10.661l6.574,6.314l-6.574-0.023V10.661z M45.218,4.979l2.866,2.753h-2.866V4.979z M12.917,64.793
22
- c-0.486,0-0.882-0.396-0.882-0.881V4.681c0-0.486,0.396-0.881,0.882-0.881h30.551v3.932H19.984c-1.48,0-2.685,1.205-2.685,2.686
23
- v54.375H12.917z M62.5,71.452c0,0.516-0.419,0.935-0.934,0.935H19.984c-0.516,0-0.935-0.419-0.935-0.935V10.417
24
- c0-0.516,0.419-0.936,0.935-0.936h32.918v7.469c0,0.982,0.798,1.781,1.779,1.781H62.5V71.452z"/>
25
- <path fill="#6699CC" d="M28.199,23.273c-0.715,0.622-1.073,1.868-1.073,3.739v3.275c0,1.27-0.229,2.15-0.686,2.641
26
- c-0.457,0.491-1.287,0.736-2.488,0.736h-0.774v1.333h0.774c1.202,0,2.031,0.246,2.488,0.736c0.457,0.49,0.686,1.371,0.686,2.641
27
- v3.274c0,1.871,0.357,3.119,1.073,3.746c0.716,0.625,2.126,0.938,4.234,0.938h0.787V45h-0.863c-1.193,0-1.972-0.188-2.336-0.559
28
- c-0.364-0.373-0.546-1.155-0.546-2.35V38.45c0-1.329-0.208-2.277-0.622-2.844s-1.181-0.995-2.298-1.282
29
- c1.1-0.254,1.862-0.668,2.285-1.244s0.635-1.532,0.635-2.869v-3.644c0-1.193,0.182-1.976,0.546-2.349s1.143-0.559,2.336-0.559
30
- h0.863v-1.32h-0.787C30.326,22.34,28.915,22.651,28.199,23.273z"/>
31
- <path fill="#6699CC" d="M38.425,43.136c0.091,0,0.181-0.024,0.263-0.073c1.3-0.803,2.289-1.768,2.94-2.869
32
- c0.653-1.102,1.021-2.433,1.092-3.958c0.007-0.136-0.043-0.27-0.138-0.369c-0.094-0.099-0.225-0.155-0.361-0.155H39.72
33
- c-0.276,0-0.5,0.224-0.5,0.5v0.47c0,1.045-0.172,1.941-0.511,2.662c-0.335,0.713-0.873,1.342-1.596,1.873
34
- c-0.118,0.088-0.191,0.221-0.203,0.365c-0.012,0.145,0.042,0.288,0.145,0.393l1.016,1.016
35
- C38.168,43.086,38.296,43.136,38.425,43.136z M39.614,39.77c0.398-0.848,0.603-1.875,0.605-3.058h1.464
36
- c-0.113,1.14-0.422,2.138-0.916,2.972c-0.513,0.867-1.276,1.646-2.273,2.313l-0.336-0.335
37
- C38.794,41.109,39.282,40.475,39.614,39.77z"/>
38
- <path fill="#6699CC" d="M40.914,31.685c0.609,0,1.132-0.214,1.553-0.635c0.422-0.421,0.637-0.944,0.637-1.554
39
- c0-0.6-0.213-1.119-0.634-1.544c-0.842-0.853-2.264-0.854-3.108-0.009c-0.422,0.422-0.635,0.944-0.635,1.553
40
- s0.213,1.131,0.635,1.554C39.782,31.471,40.307,31.685,40.914,31.685z M40.066,28.65c0.233-0.234,0.504-0.343,0.848-0.343
41
- c0.338,0,0.613,0.113,0.844,0.347c0.231,0.235,0.346,0.51,0.346,0.842c0,0.344-0.108,0.612-0.344,0.846
42
- c-0.464,0.464-1.229,0.464-1.691,0c-0.229-0.23-0.342-0.507-0.342-0.846S39.838,28.88,40.066,28.65z"/>
43
- <path fill="#6699CC" d="M54.563,27.012c0-1.871-0.354-3.117-1.062-3.739c-0.706-0.622-2.113-0.933-4.221-0.933h-0.8v1.32h0.889
44
- c1.185,0,1.957,0.184,2.316,0.552s0.539,1.153,0.539,2.355v3.644c0,1.337,0.209,2.293,0.629,2.869
45
- c0.418,0.576,1.179,0.99,2.278,1.244c-1.108,0.288-1.871,0.715-2.284,1.282c-0.416,0.567-0.623,1.515-0.623,2.844v3.644
46
- c0,1.202-0.18,1.986-0.539,2.355c-0.359,0.367-1.133,0.552-2.316,0.552H48.48v1.333h0.8c2.106,0,3.515-0.313,4.221-0.939
47
- c0.707-0.625,1.062-1.875,1.062-3.744v-3.275c0-1.27,0.229-2.15,0.686-2.641c0.457-0.491,1.286-0.736,2.488-0.736h0.787v-1.333
48
- h-0.787c-1.202,0-2.031-0.246-2.488-0.736c-0.457-0.49-0.686-1.371-0.686-2.641V27.012z"/>
49
- </g>
50
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/purge-front.svg DELETED
@@ -1,31 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#21A0DF" d="M63.657,12.237c-0.045-0.116-0.109-0.227-0.205-0.318L52.954,1.835c-0.028-0.027-0.065-0.039-0.097-0.062
8
- c-0.059-0.043-0.115-0.089-0.185-0.117c-0.069-0.027-0.142-0.034-0.215-0.043c-0.037-0.005-0.071-0.022-0.11-0.022H52.33h-0.001
9
- H14.114c-1.577,0-2.86,1.283-2.86,2.859v66.923c0,1.577,1.283,2.859,2.86,2.859h46.772c1.576,0,2.859-1.282,2.859-2.859V12.608
10
- C63.746,12.474,63.711,12.351,63.657,12.237z M53.223,4.52l7.51,7.213h-7.395c-0.064,0-0.115-0.052-0.115-0.118V4.52z
11
- M61.996,71.373c0,0.611-0.498,1.109-1.109,1.109H14.114c-0.612,0-1.11-0.498-1.11-1.109V4.45c0-0.612,0.498-1.109,1.11-1.109
12
- h37.358v8.274c0,1.03,0.837,1.868,1.865,1.868h8.658V71.373z"/>
13
- <path fill="#21A0DF" d="M45.429,44.487c-6.656,0-12.071,5.416-12.071,12.072s5.415,12.071,12.071,12.071
14
- s12.072-5.415,12.072-12.071S52.085,44.487,45.429,44.487z M45.429,66.881c-5.691,0-10.321-4.63-10.321-10.321
15
- s4.63-10.322,10.321-10.322s10.322,4.631,10.322,10.322S51.12,66.881,45.429,66.881z"/>
16
- <path fill="#21A0DF" d="M51.299,50.689c-0.342-0.342-0.896-0.342-1.238,0L45.43,55.32l-4.631-4.631
17
- c-0.342-0.342-0.896-0.342-1.238,0c-0.341,0.342-0.341,0.896,0,1.238l4.631,4.631l-4.631,4.631c-0.341,0.342-0.341,0.896,0,1.238
18
- c0.171,0.171,0.396,0.256,0.619,0.256s0.448-0.085,0.619-0.256l4.631-4.631l4.631,4.631c0.171,0.171,0.396,0.256,0.619,0.256
19
- s0.448-0.085,0.619-0.256c0.341-0.342,0.341-0.896,0-1.238l-4.631-4.631l4.631-4.631C51.64,51.586,51.64,51.031,51.299,50.689z"/>
20
- <path fill="#21A0DF" d="M19.826,18.879c0,0.483,0.392,0.875,0.875,0.875h33.598c0.483,0,0.875-0.392,0.875-0.875
21
- s-0.392-0.875-0.875-0.875H20.701C20.218,18.004,19.826,18.396,19.826,18.879z"/>
22
- <path fill="#21A0DF" d="M20.701,29.511h33.598c0.483,0,0.875-0.392,0.875-0.875s-0.392-0.875-0.875-0.875H20.701
23
- c-0.483,0-0.875,0.392-0.875,0.875S20.218,29.511,20.701,29.511z"/>
24
- <path fill="#21A0DF" d="M20.701,39.269h33.598c0.483,0,0.875-0.392,0.875-0.875s-0.392-0.875-0.875-0.875H20.701
25
- c-0.483,0-0.875,0.392-0.875,0.875S20.218,39.269,20.701,39.269z"/>
26
- <path fill="#21A0DF" d="M30.125,47.276h-9.423c-0.483,0-0.875,0.392-0.875,0.875s0.392,0.875,0.875,0.875h9.423
27
- c0.483,0,0.875-0.392,0.875-0.875S30.608,47.276,30.125,47.276z"/>
28
- <path fill="#21A0DF" d="M27.75,57.034h-7.049c-0.483,0-0.875,0.392-0.875,0.875s0.392,0.875,0.875,0.875h7.049
29
- c0.483,0,0.875-0.392,0.875-0.875S28.233,57.034,27.75,57.034z"/>
30
- </g>
31
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/purge-pages.svg DELETED
@@ -1,41 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M47.423,47.475c-6.108,0-11.078,4.971-11.078,11.08c0,6.107,4.969,11.077,11.078,11.077
8
- c6.109,0,11.079-4.97,11.079-11.077C58.502,52.443,53.532,47.475,47.423,47.475z M47.423,67.882c-5.144,0-9.327-4.185-9.327-9.327
9
- c0-5.146,4.184-9.33,9.327-9.33c5.146,0,9.329,4.186,9.329,9.33C56.752,63.697,52.566,67.882,47.423,67.882z"/>
10
- <path fill="#6699CC" d="M52.827,53.148c-0.343-0.342-0.896-0.342-1.238,0l-4.165,4.166l-4.165-4.166
11
- c-0.342-0.342-0.896-0.342-1.237,0c-0.342,0.343-0.342,0.896,0,1.238l4.164,4.165l-4.164,4.165c-0.342,0.342-0.342,0.896,0,1.238
12
- c0.17,0.171,0.396,0.256,0.619,0.256c0.223,0,0.447-0.085,0.618-0.256l4.165-4.165l4.165,4.165
13
- c0.171,0.171,0.396,0.256,0.619,0.256s0.448-0.085,0.619-0.256c0.341-0.342,0.341-0.896,0-1.238l-4.165-4.165l4.165-4.165
14
- C53.168,54.046,53.168,53.491,52.827,53.148z"/>
15
- <path fill="#6699CC" d="M64.166,21.332c-0.045-0.116-0.109-0.225-0.205-0.316l-8.912-8.56c-0.029-0.028-0.066-0.04-0.1-0.063
16
- c-0.059-0.042-0.113-0.087-0.182-0.115c-0.072-0.029-0.147-0.036-0.225-0.045c-0.035-0.004-0.064-0.021-0.102-0.021h-0.018
17
- c-0.001,0-0.002,0-0.003,0h-2.938c-0.023-0.032-0.037-0.07-0.067-0.099l-5.149-4.946c-0.031-0.031-0.072-0.044-0.107-0.069
18
- c-0.057-0.04-0.107-0.083-0.172-0.109c-0.071-0.029-0.146-0.036-0.223-0.045c-0.035-0.004-0.066-0.021-0.104-0.021h-0.018
19
- c0,0,0,0-0.002,0h-2.832c-0.045-0.119-0.108-0.232-0.207-0.326L36.901,1.12c0,0-0.001,0-0.001-0.001l-0.012-0.012
20
- c-0.027-0.026-0.061-0.036-0.09-0.057c-0.061-0.046-0.12-0.093-0.191-0.122c-0.064-0.026-0.132-0.03-0.2-0.04
21
- c-0.042-0.006-0.081-0.025-0.125-0.025H10.139c-1.364,0-2.474,1.11-2.474,2.474V57.23c0,1.362,1.11,2.473,2.474,2.473h3.38
22
- c0.139,0,0.266-0.039,0.383-0.098v4.953c0,1.385,1.126,2.51,2.51,2.51h4.018v4.509c0,1.411,1.148,2.56,2.56,2.56h38.701
23
- c1.41,0,2.559-1.147,2.559-2.56V21.695C64.25,21.564,64.217,21.443,64.166,21.332z M55.316,15.14l5.924,5.689l-5.924,0.023V15.14z
24
- M46.536,9.852l2.457,2.36h-2.457V9.852z M37.157,3.792l3.26,3.131h-3.26V3.792z M13.902,9.432v48.619
25
- c-0.117-0.059-0.244-0.098-0.383-0.098h-3.38c-0.399,0-0.724-0.324-0.724-0.723V3.337c0-0.399,0.325-0.724,0.724-0.724h25.268v4.31
26
- H16.413C15.028,6.923,13.902,8.048,13.902,9.432z M16.413,65.318c-0.419,0-0.76-0.34-0.76-0.76V9.432
27
- c0-0.418,0.341-0.759,0.76-0.759h28.374v3.539H22.99c-1.411,0-2.56,1.148-2.56,2.56V65.32h-4.017V65.318z M62.5,71.577
28
- c0,0.446-0.361,0.81-0.809,0.81H22.99c-0.446,0-0.81-0.363-0.81-0.81V14.771c0-0.446,0.363-0.81,0.81-0.81h30.576v6.891
29
- c0,0.947,0.771,1.718,1.718,1.718H62.5V71.577z"/>
30
- <path fill="#6699CC" d="M27.498,28.501h26.625c0.482,0,0.875-0.392,0.875-0.875s-0.393-0.875-0.875-0.875H27.498
31
- c-0.483,0-0.875,0.392-0.875,0.875S27.015,28.501,27.498,28.501z"/>
32
- <path fill="#6699CC" d="M27.498,36.757h26.625c0.482,0,0.875-0.392,0.875-0.875c0-0.483-0.393-0.875-0.875-0.875H27.498
33
- c-0.483,0-0.875,0.392-0.875,0.875C26.623,36.365,27.015,36.757,27.498,36.757z"/>
34
- <path fill="#6699CC" d="M27.498,45.014h26.625c0.482,0,0.875-0.393,0.875-0.875c0-0.484-0.393-0.875-0.875-0.875H27.498
35
- c-0.483,0-0.875,0.391-0.875,0.875C26.623,44.621,27.015,45.014,27.498,45.014z"/>
36
- <path fill="#6699CC" d="M32.999,51.52h-5.501c-0.483,0-0.875,0.393-0.875,0.875c0,0.483,0.392,0.875,0.875,0.875h5.501
37
- c0.483,0,0.875-0.392,0.875-0.875C33.874,51.912,33.482,51.52,32.999,51.52z"/>
38
- <path fill="#6699CC" d="M31.124,59.775h-3.626c-0.483,0-0.875,0.392-0.875,0.875c0,0.482,0.392,0.875,0.875,0.875h3.626
39
- c0.483,0,0.875-0.393,0.875-0.875C31.999,60.167,31.607,59.775,31.124,59.775z"/>
40
- </g>
41
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/revision.svg DELETED
@@ -1,64 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M60.912,72.441H14.087c-1.493,0-2.708-1.214-2.708-2.708V5.266c0-1.493,1.215-2.708,2.708-2.708h46.827
8
- c1.492,0,2.708,1.215,2.708,2.708v64.468C63.62,71.228,62.406,72.441,60.912,72.441z M14.087,4.206c-0.584,0-1.06,0.476-1.06,1.06
9
- v64.468c0,0.584,0.476,1.061,1.06,1.061h46.827c0.583,0,1.06-0.477,1.06-1.061V5.266c0-0.583-0.477-1.06-1.06-1.06H14.087z"/>
10
- </g>
11
- <g>
12
- <path fill="#6699CC" d="M53.625,16.858h-32.25c-0.483,0-0.875-0.392-0.875-0.875s0.392-0.875,0.875-0.875h32.25
13
- c0.482,0,0.875,0.392,0.875,0.875S54.107,16.858,53.625,16.858z"/>
14
- </g>
15
- <g>
16
- <path fill="#6699CC" d="M53.625,27.617h-32.25c-0.483,0-0.875-0.392-0.875-0.875c0-0.483,0.392-0.875,0.875-0.875h32.25
17
- c0.482,0,0.875,0.392,0.875,0.875C54.5,27.225,54.107,27.617,53.625,27.617z"/>
18
- </g>
19
- <g>
20
- <path fill="#6699CC" d="M53.625,38.375h-32.25c-0.483,0-0.875-0.392-0.875-0.875s0.392-0.875,0.875-0.875h32.25
21
- c0.482,0,0.875,0.392,0.875,0.875S54.107,38.375,53.625,38.375z"/>
22
- </g>
23
- <g>
24
- <path fill="#6699CC" d="M29.373,49.133h-7.998c-0.483,0-0.875-0.392-0.875-0.875c0-0.482,0.392-0.875,0.875-0.875h7.998
25
- c0.483,0,0.875,0.393,0.875,0.875C30.248,48.741,29.856,49.133,29.373,49.133z"/>
26
- </g>
27
- <g>
28
- <path fill="#6699CC" d="M27.763,59.893h-6.388c-0.483,0-0.875-0.392-0.875-0.875c0-0.482,0.392-0.875,0.875-0.875h6.388
29
- c0.483,0,0.875,0.393,0.875,0.875C28.638,59.501,28.247,59.893,27.763,59.893z"/>
30
- </g>
31
- <g>
32
- <path fill="#6699CC" d="M35.727,49.516"/>
33
- </g>
34
- <g>
35
- <path fill="#6699CC" d="M50.613,64.8"/>
36
- </g>
37
- <g>
38
- <g>
39
- <path fill="#6699CC" d="M44.561,67.521c-6.457,0-11.709-5.254-11.709-11.711c0-0.719,0.066-1.438,0.195-2.141l1.721,0.318
40
- c-0.11,0.597-0.166,1.21-0.166,1.822c0,5.491,4.467,9.959,9.959,9.959c1.992,0,3.916-0.586,5.563-1.696l0.979,1.45
41
- C49.165,66.831,46.902,67.521,44.561,67.521z"/>
42
- </g>
43
- <g>
44
- <g>
45
- <polygon fill="#6699CC" points="30.879,53.666 35.572,49.759 36.61,55.777 "/>
46
- </g>
47
- </g>
48
- </g>
49
- <g>
50
- <g>
51
- <path fill="#6699CC" d="M56.075,57.952l-1.722-0.316c0.11-0.6,0.166-1.214,0.166-1.823c0-5.492-4.468-9.961-9.959-9.961
52
- c-1.994,0-3.918,0.588-5.564,1.698l-0.979-1.45c1.937-1.308,4.198-1.998,6.543-1.998c6.457,0,11.709,5.254,11.709,11.711
53
- C56.271,56.527,56.205,57.248,56.075,57.952z"/>
54
- </g>
55
- <g>
56
- <g>
57
- <polygon fill="#6699CC" points="58.242,57.958 53.548,61.865 52.512,55.848 "/>
58
- </g>
59
- </g>
60
- </g>
61
- <g>
62
- <path fill="#6699CC" d="M38.507,46.824"/>
63
- </g>
64
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/spam_comment.svg DELETED
@@ -1,38 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M65.631,35.152c-0.053-0.112-0.125-0.216-0.227-0.3l-3.545-2.941l2.103-1.267
8
- c0.263-0.157,0.422-0.438,0.425-0.743c0.002-0.304-0.154-0.588-0.412-0.749l-3.882-2.417l1.966-3.417
9
- c0.799-1.297,0.395-3.003-0.92-3.815L36.428,5.109c-1.296-0.803-3.003-0.4-3.815,0.913L21.069,25.613
10
- c-0.146,0.025-0.288,0.074-0.41,0.175l-11.062,9.19c-0.031,0.026-0.046,0.062-0.073,0.09c-0.958,0.463-1.625,1.436-1.625,2.569
11
- v33.007c0,1.578,1.284,2.862,2.862,2.862h53.477c1.578,0,2.861-1.284,2.861-2.862V37.637
12
- C67.102,36.567,66.504,35.643,65.631,35.152z M33.131,55.07L9.671,70.753c-0.004-0.037-0.022-0.069-0.022-0.106V37.637
13
- c0-0.21,0.075-0.396,0.177-0.565c-0.004,0.271,0.101,0.539,0.333,0.714L33.131,55.07z M35.793,55.396
14
- c0.047-0.032,0.092-0.068,0.132-0.109c0.876-0.875,2.404-0.875,3.277,0c0.041,0.041,0.086,0.078,0.134,0.109L63.87,71.758H11.317
15
- L35.793,55.396z M65.331,70.63L41.773,54.92l23.502-17.647c0.041,0.115,0.074,0.235,0.074,0.365v33.008v0.002
16
- C65.343,70.645,65.339,70.635,65.331,70.63z M60.342,32.925l3.71,3.079l-17.312,13l7.267-12.359l6.281-3.786
17
- C60.309,32.879,60.318,32.906,60.342,32.925z M34.111,6.927c0.295-0.476,0.922-0.623,1.416-0.318l24.709,14.395
18
- c0.477,0.294,0.625,0.921,0.318,1.42l-2.4,4.171c-0.234,0.409-0.104,0.93,0.296,1.179l3.386,2.108l-8.922,5.377
19
- c-0.125,0.075-0.229,0.181-0.303,0.306L43.25,51.488c-0.034,0.059-0.044,0.121-0.063,0.185l-2.944,2.21
20
- c-1.532-1.338-4.009-1.313-5.489,0.104l-0.081,0.055L15.049,39.275L34.111,6.927z M13.642,38.217l-2.431-1.829
21
- c-0.118-0.089-0.252-0.132-0.389-0.153l7.812-6.489L13.642,38.217z"/>
22
- <path fill="#6699CC" d="M28.153,46.658c1.823,1.126,3.914,1.721,6.046,1.721c4.031,0,7.701-2.045,9.814-5.47
23
- c1.617-2.619,2.119-5.711,1.411-8.707s-2.54-5.537-5.159-7.154c-1.822-1.126-3.914-1.721-6.045-1.721
24
- c-4.03,0-7.699,2.045-9.814,5.47C21.066,36.201,22.747,43.316,28.153,46.658z M42.523,41.989c-1.793,2.905-4.905,4.64-8.325,4.64
25
- c-1.808,0-3.58-0.505-5.126-1.459c-2.025-1.252-3.431-3.129-4.129-5.229l18.938-4.476C44.21,37.732,43.742,40.02,42.523,41.989z
26
- M25.894,31.716c1.794-2.905,4.907-4.64,8.326-4.64c1.807,0,3.58,0.505,5.125,1.46c1.973,1.217,3.413,3.053,4.135,5.227
27
- l-18.938,4.473C24.226,36.048,24.643,33.741,25.894,31.716z"/>
28
- <path fill="#6699CC" d="M32.743,20.526c0.139,0.082,0.292,0.121,0.442,0.121c0.3,0,0.592-0.154,0.755-0.432l3.168-5.388
29
- c0.245-0.417,0.105-0.953-0.311-1.198c-0.417-0.247-0.954-0.105-1.198,0.311l-3.168,5.388
30
- C32.188,19.745,32.327,20.281,32.743,20.526z"/>
31
- <path fill="#6699CC" d="M42.586,23.268c0.141,0.082,0.292,0.121,0.441,0.121c0.301,0,0.593-0.154,0.756-0.432l1.838-3.125
32
- c0.245-0.417,0.105-0.953-0.311-1.198c-0.416-0.244-0.953-0.106-1.197,0.311l-1.838,3.125
33
- C42.029,22.487,42.169,23.023,42.586,23.268z"/>
34
- <path fill="#6699CC" d="M49.389,31.182c0.139,0.082,0.291,0.121,0.441,0.121c0.3,0,0.592-0.154,0.755-0.432l3.548-6.034
35
- c0.245-0.417,0.105-0.953-0.311-1.198c-0.418-0.246-0.953-0.105-1.197,0.311l-3.548,6.034
36
- C48.832,30.401,48.971,30.937,49.389,31.182z"/>
37
- </g>
38
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/success_icon.svg DELETED
@@ -1,42 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
6
- <g id="Layer_1_1_" display="none">
7
- <path display="inline" fill="#E8AE4A" d="M10,0C4.477,0,0,4.478,0,10c0,5.521,4.477,10,10,10c5.521,0,10-4.479,10-10
8
- C20,4.478,15.521,0,10,0z M11.329,16.83c-0.362,0.361-0.804,0.545-1.313,0.545s-0.949-0.184-1.312-0.545
9
- c-0.361-0.362-0.544-0.805-0.544-1.313c0-0.509,0.18-0.951,0.537-1.316c0.357-0.363,0.802-0.551,1.318-0.551
10
- c0.512,0,0.953,0.184,1.313,0.543c0.359,0.361,0.542,0.808,0.542,1.324C11.871,16.027,11.688,16.468,11.329,16.83z M11.389,7.468
11
- l-0.535,2.207c-0.185,0.771-0.322,1.7-0.409,2.763c-0.01,0.111-0.104,0.198-0.216,0.198H9.783c-0.114,0-0.209-0.089-0.216-0.202
12
- c-0.046-0.754-0.201-1.683-0.46-2.759L8.58,7.467C8.257,6.115,8.099,5.169,8.099,4.572c0-0.576,0.177-1.049,0.527-1.406
13
- c0.351-0.358,0.813-0.541,1.37-0.541c0.543,0,1.004,0.183,1.363,0.544c0.358,0.36,0.541,0.822,0.541,1.373
14
- C11.9,5.077,11.734,6.033,11.389,7.468z"/>
15
- </g>
16
- <g id="Layer_1_copy_3" display="none">
17
- <path display="inline" fill="#4675B8" d="M10,0C4.477,0,0,4.478,0,10c0,5.521,4.477,10,10,10c5.521,0,10-4.479,10-10
18
- C20,4.478,15.521,0,10,0z M11.329,16.83c-0.362,0.361-0.804,0.545-1.313,0.545s-0.949-0.184-1.312-0.545
19
- c-0.361-0.362-0.544-0.805-0.544-1.313c0-0.509,0.18-0.951,0.537-1.316c0.357-0.363,0.802-0.551,1.318-0.551
20
- c0.512,0,0.953,0.184,1.313,0.543c0.359,0.361,0.542,0.808,0.542,1.324C11.871,16.027,11.688,16.468,11.329,16.83z M11.389,7.468
21
- l-0.535,2.207c-0.185,0.771-0.322,1.7-0.409,2.763c-0.01,0.111-0.104,0.198-0.216,0.198H9.783c-0.114,0-0.209-0.089-0.216-0.202
22
- c-0.046-0.754-0.201-1.683-0.46-2.759L8.58,7.467C8.257,6.115,8.099,5.169,8.099,4.572c0-0.576,0.177-1.049,0.527-1.406
23
- c0.351-0.358,0.813-0.541,1.37-0.541c0.543,0,1.004,0.183,1.363,0.544c0.358,0.36,0.541,0.822,0.541,1.373
24
- C11.9,5.077,11.734,6.033,11.389,7.468z"/>
25
- </g>
26
- <g id="Layer_1_copy" display="none">
27
- <path display="inline" fill="#A32430" d="M10,0C4.477,0,0,4.478,0,10c0,5.521,4.477,10,10,10c5.521,0,10-4.479,10-10
28
- C20,4.478,15.521,0,10,0z M15.159,13.764c0.187,0.188,0.288,0.437,0.288,0.697c0,0.262-0.102,0.51-0.288,0.695
29
- c-0.185,0.184-0.438,0.289-0.698,0.289c-0.262,0-0.518-0.105-0.697-0.291L10,11.393l-3.764,3.765c-0.361,0.36-1.033,0.36-1.393,0
30
- c-0.187-0.185-0.29-0.433-0.29-0.695s0.103-0.512,0.289-0.696l3.764-3.767L4.842,6.234c-0.385-0.384-0.385-1.01,0-1.394
31
- c0.359-0.361,1.032-0.361,1.394,0L10,8.604l3.766-3.765c0.356-0.359,1.033-0.361,1.395,0c0.188,0.185,0.288,0.433,0.288,0.697
32
- c0.001,0.264-0.103,0.511-0.288,0.697l-3.766,3.764L15.159,13.764z"/>
33
- </g>
34
- <g id="Layer_1_copy_2">
35
- <path fill="#3ABFBF" d="M10,0C4.477,0,0,4.478,0,10c0,5.521,4.477,10,10,10c5.521,0,10-4.479,10-10C20,4.478,15.521,0,10,0z
36
- M15.458,6.018l-5.944,9.089c-0.031,0.048-0.07,0.088-0.115,0.121l-0.088,0.063c-0.03,0.021-0.063,0.04-0.097,0.053l-0.189,0.075
37
- c-0.048,0.019-0.1,0.03-0.152,0.032l-0.146,0.004c-0.005,0-0.009,0-0.014,0c-0.026,0-0.052-0.003-0.078-0.008l-0.309-0.096
38
- c-0.058-0.022-0.11-0.058-0.154-0.101c-0.025-0.017-0.077-0.056-0.099-0.074l-3.381-3.133c-0.185-0.171-0.295-0.405-0.307-0.661
39
- c-0.01-0.256,0.079-0.497,0.251-0.683c0.357-0.378,0.974-0.398,1.349-0.054l2.597,2.399l5.277-8.069
40
- c0.277-0.426,0.895-0.558,1.322-0.276c0.211,0.137,0.357,0.352,0.41,0.602C15.645,5.554,15.596,5.807,15.458,6.018z"/>
41
- </g>
42
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/trackback-pingback.svg DELETED
@@ -1,30 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M13.333,10.792c-0.483,0-0.875,0.392-0.875,0.875v2.167c0,0.483,0.392,0.875,0.875,0.875
8
- s0.875-0.392,0.875-0.875v-2.167C14.208,11.183,13.817,10.792,13.333,10.792z"/>
9
- <path fill="#6699CC" d="M34.926,34.313V11.001c0-0.167-0.059-0.314-0.141-0.447c-0.044-0.108-0.109-0.21-0.198-0.297l-6.291-6.118
10
- C28.267,4.111,28.23,4.1,28.199,4.077c-0.161-0.181-0.388-0.301-0.649-0.301H11.926c-1.034,0-1.875,0.841-1.875,1.875v28.662
11
- c0,1.034,0.841,1.875,1.875,1.875h21.125C34.084,36.188,34.926,35.346,34.926,34.313z M28.425,6.706l3.517,3.42H28.55
12
- c-0.069,0-0.125-0.056-0.125-0.125V6.706z M11.801,34.313V5.65c0-0.069,0.056-0.125,0.125-0.125h14.749v4.476
13
- c0,1.034,0.841,1.875,1.875,1.875h4.626v22.437c0,0.069-0.056,0.125-0.125,0.125H11.926C11.857,34.438,11.801,34.381,11.801,34.313
14
- z"/>
15
- <path fill="#6699CC" d="M64.809,45.588c-0.045-0.105-0.109-0.207-0.197-0.293l-6.291-6.119c-0.028-0.027-0.064-0.039-0.096-0.062
16
- c-0.16-0.183-0.389-0.302-0.649-0.302H41.949c-1.034,0-1.875,0.84-1.875,1.875V69.35c0,1.034,0.841,1.875,1.875,1.875h21.125
17
- c1.033,0,1.875-0.841,1.875-1.875V46.037C64.949,45.869,64.891,45.723,64.809,45.588z M58.449,41.743l3.515,3.419h-3.39
18
- c-0.069,0-0.125-0.057-0.125-0.125V41.743z M63.199,69.35c0,0.069-0.057,0.125-0.125,0.125H41.949
19
- c-0.069,0-0.125-0.056-0.125-0.125V40.688c0-0.068,0.056-0.125,0.125-0.125h14.75v4.476c0,1.034,0.841,1.875,1.875,1.875h4.625
20
- V69.35z"/>
21
- <path fill="#6699CC" d="M44.533,44.016c-0.483,0-0.875,0.393-0.875,0.875v2.168c0,0.482,0.392,0.875,0.875,0.875
22
- c0.482,0,0.875-0.393,0.875-0.875v-2.168C45.408,44.407,45.018,44.016,44.533,44.016z"/>
23
- <path fill="#6699CC" d="M47.535,44.016c-0.483,0-0.875,0.393-0.875,0.875v2.168c0,0.482,0.392,0.875,0.875,0.875
24
- c0.482,0,0.875-0.393,0.875-0.875v-2.168C48.41,44.407,48.02,44.016,47.535,44.016z"/>
25
- <polygon fill="#6699CC" points="31.548,44.113 25.648,42.532 27.229,48.432 28.769,46.893 34.5,52.622 35.737,51.384
26
- 30.007,45.652 "/>
27
- <polygon fill="#6699CC" points="43.452,30.886 49.352,32.467 47.771,26.567 46.23,28.108 40.501,22.378 39.264,23.616
28
- 44.992,29.346 "/>
29
- </g>
30
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/trash_comment.svg DELETED
@@ -1,64 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M62.324,17.893l2.085-2.085c0.366-0.367,0.569-0.855,0.569-1.374s-0.203-1.007-0.568-1.374L53.094,1.743
8
- c-0.365-0.367-0.854-0.57-1.373-0.57c-0.519,0-1.007,0.202-1.373,0.569l-7.883,7.882c-0.064-0.08-0.141-0.154-0.234-0.21
9
- l-7.519-4.431c-0.447-0.264-0.969-0.338-1.472-0.208c-0.503,0.13-0.924,0.448-1.188,0.896l-3.12,5.293l-1.2-2.208
10
- c-0.249-0.457-0.66-0.789-1.159-0.936c-0.497-0.146-1.023-0.09-1.476,0.157L11.034,15.62c-0.938,0.511-1.287,1.692-0.778,2.634
11
- l4.606,8.477c-1.289,0.254-2.264,1.391-2.264,2.753c0,0.034,0.002,0.068,0.006,0.103l4.831,40.993
12
- c0.03,1.523,1.278,2.753,2.808,2.753H49.25c1.529,0,2.777-1.229,2.809-2.753l4.832-40.993c0.004-0.034,0.006-0.068,0.006-0.103
13
- c0-1.549-1.26-2.809-2.81-2.809h-0.544l2.629-2.629l8.118-2.356c0.297-0.086,0.526-0.323,0.604-0.623
14
- c0.076-0.3-0.011-0.618-0.229-0.836L62.324,17.893z M33.561,6.558c0.034-0.057,0.083-0.08,0.118-0.089
15
- c0.033-0.01,0.087-0.013,0.145,0.021l7.408,4.367l-9.371,9.371c-0.757,0.757-0.756,1.99,0,2.747l3.7,3.701h-3.046l0.714-1.211
16
- c0.245-0.417,0.106-0.953-0.31-1.198c-0.417-0.245-0.953-0.106-1.198,0.31l-1.163,1.973c-0.024,0.041-0.027,0.085-0.044,0.127
17
- h-3.032L35.366,13.3c0.245-0.417,0.107-0.953-0.31-1.198s-0.953-0.107-1.198,0.31l-8.307,14.094
18
- c-0.032,0.054-0.04,0.113-0.059,0.17h-3.789L33.561,6.558z M11.871,17.157l14.066-7.644c0.056-0.031,0.109-0.026,0.144-0.015
19
- c0.035,0.011,0.083,0.035,0.115,0.093l1.266,2.328c0.138,0.254,0.386,0.397,0.653,0.434l-2.13,3.613l-0.291-0.535
20
- c-0.23-0.424-0.763-0.582-1.187-0.351c-0.424,0.231-0.582,0.762-0.351,1.187l0.388,0.713c0.127,0.234,0.346,0.381,0.588,0.433
21
- l-1.715,2.908L21.884,17.5c-0.23-0.424-0.762-0.582-1.187-0.351c-0.424,0.23-0.582,0.762-0.351,1.187l1.535,2.824
22
- c0.158,0.292,0.459,0.457,0.77,0.457c0.001,0,0.002,0,0.003,0l-1.833,3.109c-0.017-0.077-0.03-0.155-0.07-0.228l-2.677-4.926
23
- c-0.231-0.424-0.763-0.582-1.187-0.351c-0.424,0.231-0.582,0.762-0.351,1.187l2.677,4.926c0.159,0.292,0.459,0.457,0.77,0.457
24
- c0.084,0,0.165-0.038,0.248-0.063l-0.269,0.457c-0.091,0.155-0.113,0.325-0.104,0.492h-3.034l-5.03-9.255
25
- C11.743,17.326,11.778,17.208,11.871,17.157z M55.145,29.44l-4.83,40.981c-0.004,0.034-0.006,0.068-0.006,0.103
26
- c0,0.584-0.475,1.06-1.059,1.06H20.243c-0.583,0-1.059-0.476-1.059-1.06c0-0.033-0.002-0.067-0.006-0.103l-4.83-40.981
27
- c0.023-0.563,0.489-1.015,1.058-1.015h38.681C54.656,28.425,55.121,28.876,55.145,29.44z M55.468,22.428
28
- c-0.142,0.041-0.271,0.117-0.375,0.222l-4.024,4.025h-3.877l10.588-10.586c0.341-0.342,0.341-0.896,0-1.237
29
- c-0.342-0.342-0.896-0.342-1.238,0l-11.57,11.569c-0.076,0.075-0.128,0.163-0.17,0.254h-6.765l-4.937-4.938
30
- c-0.075-0.075-0.075-0.197,0-0.272L51.585,2.979c0.047-0.046,0.101-0.056,0.136-0.056c0.036,0,0.088,0.01,0.135,0.057
31
- l11.317,11.318c0.048,0.046,0.058,0.1,0.058,0.136c0,0.036-0.01,0.089-0.059,0.136l-2.704,2.705
32
- c-0.163,0.164-0.256,0.387-0.256,0.619s0.093,0.455,0.257,0.619l1.911,1.911L55.468,22.428z"/>
33
- <path fill="#6699CC" d="M51.648,8.721c-0.342-0.342-0.896-0.342-1.238,0L38.84,20.289c-0.341,0.341-0.341,0.896,0,1.237
34
- c0.172,0.171,0.396,0.256,0.619,0.256s0.448-0.085,0.619-0.256l11.57-11.568C51.988,9.617,51.99,9.063,51.648,8.721z"/>
35
- <path fill="#6699CC" d="M53.475,11.787L41.906,23.356c-0.342,0.342-0.342,0.896,0,1.237c0.171,0.171,0.396,0.256,0.619,0.256
36
- c0.223,0,0.447-0.085,0.619-0.256l11.566-11.569c0.342-0.342,0.341-0.896,0-1.237C54.37,11.445,53.814,11.445,53.475,11.787z"/>
37
- <path fill="#6699CC" d="M26.256,54.037l1.131,0.652l0.001-4.361l-3.779,2.18l1.131,0.653l-0.326,0.565
38
- c-0.896,1.549-1.013,3.057-0.329,4.242s2.047,1.84,3.838,1.84h4.415c0.483,0,0.875-0.393,0.875-0.875
39
- c0-0.483-0.392-0.875-0.875-0.875h-4.415c-1.123,0-1.969-0.353-2.323-0.965c-0.354-0.611-0.234-1.521,0.328-2.492L26.256,54.037z"
40
- />
41
- <path fill="#6699CC" d="M29.08,47.398c0.138,0.08,0.289,0.117,0.437,0.117c0.302,0,0.596-0.156,0.758-0.438l2.221-3.844
42
- c0.371-0.641,0.817-1.09,1.325-1.336c0.454-0.221,0.896-0.222,1.35,0.002c0.506,0.244,0.95,0.692,1.322,1.336l0.366,0.632
43
- l-1.131,0.653l3.779,2.18l-0.003-4.362l-1.13,0.653l-0.366-0.633c-0.55-0.95-1.248-1.635-2.073-2.034
44
- c-0.926-0.449-1.946-0.45-2.875-0.003c-0.83,0.402-1.529,1.088-2.078,2.037l-2.221,3.844C28.519,46.622,28.662,47.157,29.08,47.398
45
- z"/>
46
- <path fill="#6699CC" d="M36.654,58.934l3.778,2.183v-1.308h0.637c1.791,0,3.154-0.652,3.84-1.84
47
- c0.684-1.187,0.566-2.693-0.33-4.242l-2.25-3.895c-0.241-0.419-0.776-0.561-1.195-0.32c-0.419,0.242-0.563,0.777-0.32,1.195
48
- l2.252,3.896c0.562,0.971,0.682,1.879,0.328,2.492c-0.354,0.611-1.199,0.963-2.322,0.963h-0.637v-1.307L36.654,58.934z"/>
49
- <path fill="#6699CC" d="M26.13,63.1c-0.48,0.053-0.826,0.485-0.772,0.967l0.327,2.906c0.05,0.447,0.429,0.777,0.869,0.777
50
- c0.033,0,0.065-0.002,0.099-0.006c0.48-0.055,0.826-0.486,0.772-0.967l-0.327-2.907C27.043,63.391,26.613,63.048,26.13,63.1z"/>
51
- <path fill="#6699CC" d="M24.216,46.914c0.032,0,0.065-0.002,0.099-0.006c0.48-0.055,0.826-0.486,0.772-0.967l-1.294-11.54
52
- c-0.054-0.479-0.481-0.822-0.967-0.772c-0.48,0.054-0.826,0.487-0.772,0.967l1.294,11.539
53
- C23.397,46.584,23.776,46.914,24.216,46.914z"/>
54
- <path fill="#6699CC" d="M43.361,63.1c-0.489-0.06-0.912,0.291-0.967,0.771l-0.326,2.906c-0.055,0.479,0.291,0.912,0.771,0.967
55
- c0.033,0.004,0.066,0.006,0.1,0.006c0.438,0,0.817-0.33,0.867-0.777l0.326-2.906C44.188,63.586,43.843,63.152,43.361,63.1z"/>
56
- <path fill="#6699CC" d="M45.176,46.932c0.033,0.004,0.066,0.006,0.1,0.006c0.438,0,0.817-0.33,0.867-0.776l1.297-11.563
57
- c0.056-0.48-0.291-0.914-0.771-0.967c-0.487-0.049-0.913,0.292-0.967,0.772l-1.298,11.563
58
- C44.35,46.445,44.695,46.878,45.176,46.932z"/>
59
- <path fill="#6699CC" d="M34.552,63.125c-0.483,0-0.875,0.393-0.875,0.875v2.875c0,0.482,0.392,0.875,0.875,0.875
60
- c0.483,0,0.875-0.393,0.875-0.875V64C35.427,63.518,35.036,63.125,34.552,63.125z"/>
61
- <path fill="#6699CC" d="M34.552,37.187c0.483,0,0.875-0.392,0.875-0.875V34.5c0-0.483-0.392-0.875-0.875-0.875
62
- c-0.483,0-0.875,0.392-0.875,0.875v1.812C33.677,36.795,34.069,37.187,34.552,37.187z"/>
63
- </g>
64
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icons/trash_post.svg DELETED
@@ -1,48 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
6
- <g>
7
- <path fill="#6699CC" d="M48.201,23.882l-17.297-7.355c-0.446-0.188-0.959,0.018-1.147,0.463c-0.189,0.445,0.018,0.958,0.463,1.147
8
- l17.295,7.355c0.112,0.047,0.229,0.07,0.344,0.07c0.34,0,0.664-0.2,0.806-0.533C48.854,24.585,48.646,24.071,48.201,23.882z"/>
9
- <path fill="#6699CC" d="M34.828,23.886l-5.931-2.612c-0.445-0.195-0.959,0.006-1.153,0.448c-0.195,0.442,0.006,0.958,0.448,1.153
10
- l5.931,2.612c0.115,0.05,0.234,0.074,0.352,0.074c0.336,0,0.657-0.195,0.801-0.522C35.471,24.597,35.271,24.081,34.828,23.886z"/>
11
- <path fill="#6699CC" d="M54.087,26.923h-0.974l2.484-5.843c0.545-1.285-0.057-2.775-1.341-3.322l-2.211-0.94l1.563-5.534
12
- c0.379-1.344-0.405-2.746-1.75-3.125l-24.201-6.84c-1.35-0.379-2.748,0.405-3.127,1.75l-3.207,11.346
13
- c-0.021,0.075-0.016,0.149-0.017,0.224l-0.816-0.103c-1.38-0.168-2.655,0.812-2.83,2.198l-1.28,10.189h-0.976
14
- c-1.549,0-2.809,1.26-2.809,2.809c0,0.034,0.002,0.068,0.006,0.103l4.831,40.993c0.03,1.523,1.278,2.753,2.808,2.753H49.25
15
- c1.529,0,2.777-1.229,2.809-2.753l4.832-40.993c0.004-0.034,0.006-0.068,0.006-0.103C56.896,28.183,55.637,26.923,54.087,26.923z
16
- M53.986,20.396l-2.555,6.01c-0.072,0.171-0.07,0.348-0.035,0.517H22.179L29.4,9.941c0.169-0.397,0.63-0.584,1.028-0.415
17
- l20.28,8.623c0.017,0.006,0.028,0.019,0.046,0.024c0.005,0.001,0.01,0,0.016,0.002l2.804,1.192
18
- C53.971,19.537,54.156,19.999,53.986,20.396z M26.216,3.543c0.118-0.416,0.549-0.661,0.968-0.541l24.201,6.839
19
- c0.416,0.118,0.659,0.552,0.543,0.967l-1.504,5.318l-19.311-8.21c-1.285-0.547-2.776,0.055-3.323,1.34l-2.517,5.918
20
- c-0.063-0.023-0.12-0.054-0.188-0.063l-2.065-0.259L26.216,3.543z M19.399,16.952c0.054-0.429,0.439-0.733,0.875-0.68l4.303,0.54
21
- l-4.037,9.495c-0.087,0.205-0.082,0.421-0.017,0.617h-2.377L19.399,16.952z M50.314,70.669c-0.004,0.034-0.006,0.067-0.006,0.103
22
- c0,0.584-0.476,1.06-1.06,1.06H20.243c-0.583,0-1.059-0.476-1.059-1.06c0-0.033-0.002-0.067-0.006-0.103l-4.83-40.981
23
- c0.023-0.563,0.489-1.015,1.058-1.015h38.68c0.568,0,1.034,0.451,1.059,1.015L50.314,70.669z"/>
24
- <path fill="#6699CC" d="M32.34,58.307h-4.416c-1.123,0-1.969-0.352-2.322-0.964s-0.234-1.521,0.328-2.491l0.327-0.565l1.131,0.653
25
- l0.001-4.362l-3.779,2.18l1.131,0.653l-0.326,0.564c-0.896,1.551-1.013,3.058-0.329,4.242c0.685,1.188,2.048,1.84,3.838,1.84h4.416
26
- c0.483,0,0.875-0.392,0.875-0.875C33.215,58.699,32.824,58.307,32.34,58.307z"/>
27
- <path fill="#6699CC" d="M39.508,46.949l-0.003-4.362l-1.13,0.653l-0.365-0.631c-0.549-0.951-1.248-1.637-2.074-2.035
28
- c-0.927-0.45-1.947-0.451-2.874-0.004c-0.831,0.402-1.53,1.088-2.079,2.037l-2.222,3.843c-0.242,0.419-0.099,0.954,0.319,1.196
29
- c0.138,0.078,0.289,0.117,0.437,0.117c0.302,0,0.596-0.156,0.758-0.438l2.222-3.844c0.371-0.642,0.816-1.092,1.325-1.336
30
- c0.448-0.217,0.902-0.217,1.35,0.002c0.506,0.244,0.951,0.692,1.322,1.336l0.365,0.631l-1.131,0.654L39.508,46.949z"/>
31
- <path fill="#6699CC" d="M42.328,50.08c-0.241-0.419-0.776-0.561-1.195-0.32c-0.419,0.242-0.563,0.777-0.32,1.195l2.252,3.896
32
- c0.562,0.971,0.682,1.879,0.328,2.49c-0.354,0.613-1.199,0.965-2.322,0.965h-0.637V57l-3.779,2.182l3.779,2.183v-1.308h0.637
33
- c1.791,0,3.154-0.652,3.839-1.841c0.684-1.187,0.565-2.692-0.33-4.241L42.328,50.08z"/>
34
- <path fill="#6699CC" d="M26.13,63.346c-0.48,0.055-0.826,0.486-0.772,0.967l0.327,2.908c0.05,0.447,0.429,0.777,0.869,0.777
35
- c0.033,0,0.065-0.002,0.099-0.006c0.48-0.055,0.826-0.486,0.772-0.967l-0.327-2.908C27.043,63.637,26.613,63.294,26.13,63.346z"/>
36
- <path fill="#6699CC" d="M24.216,47.162c0.032,0,0.065-0.002,0.099-0.006c0.48-0.055,0.826-0.486,0.772-0.967l-1.294-11.541
37
- c-0.054-0.48-0.482-0.826-0.967-0.772c-0.48,0.054-0.826,0.487-0.772,0.967l1.294,11.54C23.398,46.832,23.777,47.162,24.216,47.162
38
- z"/>
39
- <path fill="#6699CC" d="M43.361,63.348c-0.489-0.058-0.912,0.291-0.967,0.771l-0.326,2.906c-0.055,0.479,0.291,0.912,0.771,0.967
40
- c0.033,0.004,0.066,0.006,0.1,0.006c0.438,0,0.817-0.33,0.867-0.777l0.326-2.906C44.188,63.834,43.843,63.4,43.361,63.348z"/>
41
- <path fill="#6699CC" d="M46.668,33.877c-0.486-0.053-0.913,0.292-0.967,0.772l-1.297,11.563c-0.055,0.479,0.291,0.913,0.771,0.968
42
- c0.033,0.004,0.066,0.006,0.099,0.006c0.439,0,0.818-0.33,0.869-0.777l1.297-11.563C47.494,34.364,47.148,33.931,46.668,33.877z"/>
43
- <path fill="#6699CC" d="M34.553,63.373c-0.483,0-0.875,0.393-0.875,0.875v2.875c0,0.482,0.392,0.875,0.875,0.875
44
- c0.483,0,0.875-0.393,0.875-0.875v-2.875C35.428,63.766,35.037,63.373,34.553,63.373z"/>
45
- <path fill="#6699CC" d="M34.553,37.435c0.483,0,0.875-0.392,0.875-0.875v-1.813c0-0.483-0.392-0.875-0.875-0.875
46
- c-0.483,0-0.875,0.392-0.875,0.875v1.813C33.678,37.043,34.07,37.435,34.553,37.435z"/>
47
- </g>
48
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/data.class.php DELETED
@@ -1,177 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The class to store and manage litespeed db data.
5
- *
6
- * @since 1.3.1
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/includes
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- class LiteSpeed_Cache_Data
13
- {
14
- private static $_instance ;
15
-
16
- const TB_OPTIMIZER = 'litespeed_optimizer' ;
17
-
18
- private $_charset_collate ;
19
- private $_tb_optm ;
20
-
21
- /**
22
- * Init
23
- *
24
- * @since 1.3.1
25
- * @access private
26
- */
27
- private function __construct()
28
- {
29
- LiteSpeed_Cache_Log::debug2( 'Data init' ) ;
30
- global $wpdb ;
31
-
32
- $this->_charset_collate = $wpdb->get_charset_collate() ;
33
-
34
- $this->_tb_optm = $wpdb->base_prefix . self::TB_OPTIMIZER ;
35
-
36
- $this->_optm_sync() ;
37
- }
38
-
39
- /**
40
- * save optimizer src to db
41
- *
42
- * @since 1.3.1
43
- * @access public
44
- */
45
- public static function optm_save_src( $filename, $src )
46
- {
47
- $instance = self::get_instance() ;
48
- return $instance->_optm_save_src( $filename, $src ) ;
49
- }
50
- private function _optm_save_src( $filename, $src )
51
- {
52
- global $wpdb ;
53
-
54
- $src = serialize( $src ) ;
55
- $f = array(
56
- 'hash_name' => $filename,
57
- 'src' => $src,
58
- 'dateline' => time(),
59
- 'refer' => ! empty( $SERVER[ 'SCRIPT_URI' ] ) ? $SERVER[ 'SCRIPT_URI' ] : '',
60
- ) ;
61
-
62
- $res = $wpdb->replace( $this->_tb_optm, $f ) ;
63
-
64
- return $res ;
65
- }
66
-
67
- /**
68
- * Get src set from hash in optimizer
69
- *
70
- * @since 1.3.1
71
- * @access public
72
- */
73
- public static function optm_hash2src( $filename )
74
- {
75
- $instance = self::get_instance() ;
76
- return $instance->_optm_hash2src( $filename ) ;
77
- }
78
- private function _optm_hash2src( $filename )
79
- {
80
- global $wpdb ;
81
-
82
- $s = $wpdb->prepare( 'SELECT src FROM `' . $this->_tb_optm . '` WHERE `hash_name` = %s', $filename ) ;
83
-
84
- $res = $wpdb->get_var( $s ) ;
85
-
86
- LiteSpeed_Cache_Log::debug2( 'Data: Loaded hash2src ' . $res ) ;
87
-
88
- $res = unserialize( $res ) ;
89
-
90
- return $res ;
91
- }
92
-
93
- /**
94
- * Create optimizer table
95
- *
96
- * @since 1.3.1
97
- * @access private
98
- */
99
- private function _optm_sync()
100
- {
101
- if ( defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
102
- return ;
103
- }
104
- define( 'LITESPEED_DID_' . __FUNCTION__, true ) ;
105
-
106
- // if ( get_option( $this->_tb_optm ) ) {
107
- // return ;
108
- // }
109
-
110
- global $wpdb ;
111
-
112
- LiteSpeed_Cache_Log::debug2( 'Data: Checking optm table' ) ;
113
-
114
- // Check if table exists first
115
- $res = $wpdb->get_var( "SHOW TABLES LIKE '$this->_tb_optm'" ) ;
116
- if ( $res ) {
117
- LiteSpeed_Cache_Log::debug2( 'Data: Existed' ) ;
118
-
119
- return ;
120
- }
121
-
122
- LiteSpeed_Cache_Log::debug( 'Data: Creating optm table' ) ;
123
-
124
- $s = sprintf(
125
- 'CREATE TABLE IF NOT EXISTS `%1$s` (
126
- `id` int(11) NOT NULL AUTO_INCREMENT,
127
- `hash_name` varchar(60) NOT NULL COMMENT "hash.filetype",
128
- `src` text NOT NULL COMMENT "full url array set",
129
- `dateline` int(11) NOT NULL,
130
- `refer` varchar(255) NOT NULL COMMENT "The container page url",
131
- PRIMARY KEY (`id`),
132
- UNIQUE KEY `hash_name` (`hash_name`),
133
- KEY `dateline` (`dateline`)
134
- ) %2$s;',
135
- $this->_tb_optm,
136
- $this->_charset_collate
137
- ) ;
138
-
139
- $wpdb->query( $s ) ;
140
-
141
- // Move data from wp_options to here
142
- $hashes = get_option( 'litespeed-cache-optimized' ) ;
143
- if ( $hashes ) {
144
- foreach ( $hashes as $k => $v ) {
145
- $f = array(
146
- 'hash_name' => $k,
147
- 'src' => serialize( $v ),
148
- 'dateline' => time(),
149
- 'refer' => '',
150
- ) ;
151
- $wpdb->replace( $this->_tb_optm, $f ) ;
152
- }
153
- }
154
- delete_option( 'litespeed-cache-optimized' ) ;
155
-
156
- // Record tb version
157
- update_option( $this->_tb_optm, LiteSpeed_Cache::PLUGIN_VERSION ) ;
158
-
159
- }
160
-
161
- /**
162
- * Get the current instance object.
163
- *
164
- * @since 1.3.1
165
- * @access public
166
- * @return Current class instance.
167
- */
168
- public static function get_instance()
169
- {
170
- if ( ! isset( self::$_instance ) ) {
171
- self::$_instance = new self() ;
172
- }
173
-
174
- return self::$_instance ;
175
- }
176
-
177
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-litespeed-cache-config.php ADDED
@@ -0,0 +1,677 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The core plugin config class.
5
+ *
6
+ * This maintains all the options and settings for this plugin.
7
+ *
8
+ * @since 1.0.0
9
+ * @package LiteSpeed_Cache
10
+ * @subpackage LiteSpeed_Cache/includes
11
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
12
+ */
13
+ class LiteSpeed_Cache_Config
14
+ {
15
+
16
+ const OPTION_NAME = 'litespeed-cache-conf' ;
17
+ const LOG_LEVEL_NONE = 0 ;
18
+ const LOG_LEVEL_ERROR = 1 ;
19
+ const LOG_LEVEL_NOTICE = 2 ;
20
+ const LOG_LEVEL_INFO = 3 ;
21
+ const LOG_LEVEL_DEBUG = 4 ;
22
+ const OPID_VERSION = 'version' ;
23
+ const OPID_ENABLED = 'enabled' ;
24
+ const OPID_ENABLED_RADIO = 'radio_select';
25
+ const OPID_ENABLED_DISABLE = 0;
26
+ const OPID_ENABLED_ENABLE = 1;
27
+ const OPID_ENABLED_NOTSET = 2;
28
+ const OPID_PURGE_ON_UPGRADE = 'purge_upgrade';
29
+ const OPID_CACHE_COMMENTERS = 'cache_commenters';
30
+ const OPID_CACHE_LOGIN = 'cache_login';
31
+ const OPID_CACHE_FAVICON = 'cache_favicon';
32
+ const OPID_CACHE_RES = 'cache_resources';
33
+ const OPID_MOBILEVIEW_ENABLED = 'mobileview_enabled';
34
+ const OPID_LOGIN_COOKIE = 'login_cookie';
35
+ const OPID_TAG_PREFIX = 'tag_prefix';
36
+ const OPID_CHECK_ADVANCEDCACHE = 'check_advancedcache';
37
+ // do NOT set default options for these three, it is used for admin.
38
+ const ID_MOBILEVIEW_LIST = 'mobileview_rules';
39
+ const ID_NOCACHE_COOKIES = 'nocache_cookies' ;
40
+ const ID_NOCACHE_USERAGENTS = 'nocache_useragents' ;
41
+ const OPID_DEBUG = 'debug' ;
42
+ const OPID_ADMIN_IPS = 'admin_ips' ;
43
+ const OPID_PUBLIC_TTL = 'public_ttl' ;
44
+ const OPID_FRONT_PAGE_TTL = 'front_page_ttl';
45
+ const OPID_FEED_TTL = 'feed_ttl';
46
+ const OPID_403_TTL = '403_ttl';
47
+ const OPID_404_TTL = '404_ttl';
48
+ const OPID_500_TTL = '500_ttl';
49
+ const OPID_PURGE_BY_POST = 'purge_by_post' ;
50
+ const OPID_TEST_IPS = 'test_ips' ;
51
+ const PURGE_ALL_PAGES = '-' ;
52
+ const PURGE_FRONT_PAGE = 'F' ;
53
+ const PURGE_HOME_PAGE = 'H' ;
54
+ const PURGE_PAGES = 'PGS' ;
55
+ const PURGE_PAGES_WITH_RECENT_POSTS = 'PGSRP' ;
56
+ const PURGE_AUTHOR = 'A' ;
57
+ const PURGE_YEAR = 'Y' ;
58
+ const PURGE_MONTH = 'M' ;
59
+ const PURGE_DATE = 'D' ;
60
+ const PURGE_TERM = 'T' ; // include category|tag|tax
61
+ const PURGE_POST_TYPE = 'PT' ;
62
+ const OPID_EXCLUDES_URI = 'excludes_uri' ;
63
+ const OPID_EXCLUDES_CAT = 'excludes_cat' ;
64
+ const OPID_EXCLUDES_TAG = 'excludes_tag' ;
65
+
66
+ const NETWORK_OPID_ENABLED = 'network_enabled';
67
+ const NETWORK_OPID_USE_PRIMARY = 'use_primary_settings';
68
+
69
+ protected $options ;
70
+ protected $purge_options ;
71
+ protected $debug_tag = 'LiteSpeed_Cache' ;
72
+
73
+ /**
74
+ * Initialize the class and set its properties.
75
+ *
76
+ * @since 1.0.0
77
+ */
78
+ public function __construct()
79
+ {
80
+ if ( is_multisite()) {
81
+ $options = $this->construct_multisite_options();
82
+ }
83
+ else {
84
+ $options = get_option(self::OPTION_NAME,
85
+ $this->get_default_options());
86
+ }
87
+ $this->options = $options ;
88
+ $this->purge_options = explode('.', $options[self::OPID_PURGE_BY_POST]) ;
89
+
90
+ if ((isset($options[self::OPID_CHECK_ADVANCEDCACHE]))
91
+ && ($options[self::OPID_CHECK_ADVANCEDCACHE] === false)
92
+ && (!defined('LSCACHE_ADV_CACHE'))) {
93
+ define('LSCACHE_ADV_CACHE', true);
94
+ }
95
+
96
+ if ( true === WP_DEBUG /* && $this->options[self::OPID_DEBUG] */ ) {
97
+ $msec = microtime() ;
98
+ $msec1 = substr($msec, 2, strpos($msec, ' ') - 2) ;
99
+ if ( array_key_exists('REMOTE_ADDR', $_SERVER) && array_key_exists('REMOTE_PORT', $_SERVER) ) {
100
+ $this->debug_tag .= ' [' . $_SERVER['REMOTE_ADDR'] . ':' . $_SERVER['REMOTE_PORT'] . ':' . $msec1 . '] ' ;
101
+ }
102
+ }
103
+ }
104
+
105
+ /**
106
+ * For multisite installations, the single site options need to be updated
107
+ * with the network wide options.
108
+ *
109
+ * @since 1.0.13
110
+ * @access private
111
+ * @return array The updated options.
112
+ */
113
+ private function construct_multisite_options()
114
+ {
115
+ $site_options = get_site_option(self::OPTION_NAME);
116
+
117
+ if (!function_exists('is_plugin_active_for_network') ) {
118
+ require_once(ABSPATH . '/wp-admin/includes/plugin.php');
119
+ }
120
+
121
+ if ((!$site_options) || (!is_array($site_options))
122
+ || (!is_plugin_active_for_network('litespeed-cache/litespeed-cache.php'))) {
123
+ $options = get_option(self::OPTION_NAME,
124
+ $this->get_default_options());
125
+ if ($options[self::OPID_ENABLED_RADIO] == self::OPID_ENABLED_NOTSET) {
126
+ $options[self::OPID_ENABLED] = true;
127
+ }
128
+ return $options;
129
+ }
130
+ if ((isset($site_options[self::NETWORK_OPID_USE_PRIMARY]))
131
+ && ($site_options[self::NETWORK_OPID_USE_PRIMARY])) {
132
+ $main_id = BLOG_ID_CURRENT_SITE;
133
+ $options = get_blog_option($main_id,
134
+ LiteSpeed_Cache_Config::OPTION_NAME, array());
135
+ }
136
+ else {
137
+ $options = get_option(self::OPTION_NAME,
138
+ $this->get_default_options());
139
+ }
140
+ $options[self::NETWORK_OPID_ENABLED] = $site_options[self::NETWORK_OPID_ENABLED];
141
+ if ($options[self::OPID_ENABLED_RADIO] == self::OPID_ENABLED_NOTSET) {
142
+ $options[self::OPID_ENABLED] = $options[self::NETWORK_OPID_ENABLED];
143
+ }
144
+ $options[self::OPID_PURGE_ON_UPGRADE]
145
+ = $site_options[self::OPID_PURGE_ON_UPGRADE];
146
+ $options[self::OPID_MOBILEVIEW_ENABLED]
147
+ = $site_options[self::OPID_MOBILEVIEW_ENABLED];
148
+ $options[self::ID_MOBILEVIEW_LIST]
149
+ = $site_options[self::ID_MOBILEVIEW_LIST];
150
+ $options[self::OPID_LOGIN_COOKIE]
151
+ = $site_options[self::OPID_LOGIN_COOKIE];
152
+ $options[self::OPID_TAG_PREFIX]
153
+ = $site_options[self::OPID_TAG_PREFIX];
154
+ return $options;
155
+ }
156
+
157
+ /**
158
+ * Get the list of configured options for the blog.
159
+ *
160
+ * @since 1.0.0
161
+ * @access public
162
+ * @return array The list of configured options.
163
+ */
164
+ public function get_options()
165
+ {
166
+ return $this->options ;
167
+ }
168
+
169
+ /**
170
+ * Get the selected configuration option.
171
+ *
172
+ * @since 1.0.0
173
+ * @access public
174
+ * @param string $id Configuration ID.
175
+ * @return mixed Selected option if set, NULL if not.
176
+ */
177
+ public function get_option($id)
178
+ {
179
+ if (isset($this->options[$id])) {
180
+ return $this->options[$id];
181
+ }
182
+ if (defined('LSCWP_LOG')) {
183
+ LiteSpeed_Cache::debug_log('Invalid option ID ' . $id);
184
+ }
185
+ return NULL;
186
+ }
187
+
188
+ /**
189
+ * Get the configured purge options.
190
+ *
191
+ * @since 1.0.0
192
+ * @access public
193
+ * @return array The list of purge options.
194
+ */
195
+ public function get_purge_options()
196
+ {
197
+ return $this->purge_options ;
198
+ }
199
+
200
+ /**
201
+ * Check if the flag type of posts should be purged on updates.
202
+ *
203
+ * @since 1.0.0
204
+ * @access public
205
+ * @param string $flag Post type. Refer to LiteSpeed_Cache_Config::PURGE_*
206
+ * @return boolean True if the post type should be purged, false otherwise.
207
+ */
208
+ public function purge_by_post( $flag )
209
+ {
210
+ return in_array($flag, $this->purge_options) ;
211
+ }
212
+
213
+ /**
214
+ * Gets the default single site options
215
+ *
216
+ * @since 1.0.0
217
+ * @access public
218
+ * @param bool $include_thirdparty Whether to include the thirdparty options.
219
+ * @return array An array of the default options.
220
+ */
221
+ public function get_default_options($include_thirdparty = true)
222
+ {
223
+ $default_purge_options = array(
224
+ self::PURGE_FRONT_PAGE,
225
+ self::PURGE_HOME_PAGE,
226
+ self::PURGE_PAGES,
227
+ self::PURGE_PAGES_WITH_RECENT_POSTS,
228
+ self::PURGE_AUTHOR,
229
+ self::PURGE_MONTH,
230
+ self::PURGE_TERM,
231
+ self::PURGE_POST_TYPE
232
+ ) ;
233
+ sort($default_purge_options) ;
234
+
235
+ //For multi site, default is 2 (Use Network Admin Settings). For single site, default is 1 (Enabled).
236
+ if ( is_multisite()) {
237
+ $default_enabled = false;
238
+ $default_radio = self::OPID_ENABLED_NOTSET;
239
+ }
240
+ else {
241
+ $default_enabled = true;
242
+ $default_radio = self::OPID_ENABLED_ENABLE;
243
+ }
244
+
245
+ $default_options = array(
246
+ self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
247
+ self::OPID_ENABLED => $default_enabled,
248
+ self::OPID_ENABLED_RADIO => $default_radio,
249
+ self::OPID_PURGE_ON_UPGRADE => true,
250
+ self::OPID_CACHE_COMMENTERS => true,
251
+ self::OPID_CACHE_LOGIN => true,
252
+ self::OPID_CACHE_FAVICON => true,
253
+ self::OPID_CACHE_RES => true,
254
+ self::OPID_MOBILEVIEW_ENABLED => false,
255
+ self::ID_MOBILEVIEW_LIST => false,
256
+ self::OPID_LOGIN_COOKIE => '',
257
+ self::OPID_TAG_PREFIX => '',
258
+ self::OPID_CHECK_ADVANCEDCACHE => true,
259
+ self::OPID_DEBUG => self::LOG_LEVEL_NONE,
260
+ self::OPID_ADMIN_IPS => '127.0.0.1',
261
+ self::OPID_TEST_IPS => '',
262
+ self::OPID_PUBLIC_TTL => 604800,
263
+ self::OPID_FRONT_PAGE_TTL => 604800,
264
+ self::OPID_FEED_TTL => 0,
265
+ self::OPID_403_TTL => 3600,
266
+ self::OPID_404_TTL => 3600,
267
+ self::OPID_500_TTL => 3600,
268
+ self::OPID_PURGE_BY_POST => implode('.', $default_purge_options),
269
+ self::OPID_EXCLUDES_URI => '',
270
+ self::OPID_EXCLUDES_CAT => '',
271
+ self::OPID_EXCLUDES_TAG => '',
272
+ self::ID_NOCACHE_COOKIES => '',
273
+ self::ID_NOCACHE_USERAGENTS => '',
274
+ ) ;
275
+
276
+ if (is_multisite()) {
277
+ $default_options[self::NETWORK_OPID_ENABLED] = false;
278
+ }
279
+
280
+ if (!$include_thirdparty) {
281
+ return $default_options;
282
+ }
283
+
284
+ $tp_options = $this->get_thirdparty_options($default_options);
285
+ if ((!isset($tp_options)) || (!is_array($tp_options))) {
286
+ return $default_options;
287
+ }
288
+ return array_merge($default_options, $tp_options);
289
+ }
290
+
291
+ /**
292
+ * Gets the default network options
293
+ *
294
+ * @since 1.0.11
295
+ * @access protected
296
+ * @return array An array of the default options.
297
+ */
298
+ protected function get_default_site_options()
299
+ {
300
+ $default_site_options = array(
301
+ self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
302
+ self::NETWORK_OPID_ENABLED => false,
303
+ self::NETWORK_OPID_USE_PRIMARY => false,
304
+ self::OPID_PURGE_ON_UPGRADE => true,
305
+ self::OPID_CACHE_FAVICON => true,
306
+ self::OPID_CACHE_RES => true,
307
+ self::OPID_MOBILEVIEW_ENABLED => 0,
308
+ self::ID_MOBILEVIEW_LIST => false,
309
+ self::OPID_LOGIN_COOKIE => '',
310
+ self::OPID_TAG_PREFIX => '',
311
+ self::OPID_CHECK_ADVANCEDCACHE => true,
312
+ self::ID_NOCACHE_COOKIES => '',
313
+ self::ID_NOCACHE_USERAGENTS => '',
314
+ );
315
+ return $default_site_options;
316
+ }
317
+
318
+ /**
319
+ * When the .htaccess files need to be reset, use this array to denote
320
+ * everything off.
321
+ *
322
+ * @since 1.0.12
323
+ * @access public
324
+ * @return array The list of options to reset.
325
+ */
326
+ public static function get_rule_reset_options()
327
+ {
328
+ $reset = array(
329
+ LiteSpeed_Cache_Config::OPID_MOBILEVIEW_ENABLED => false,
330
+ LiteSpeed_Cache_Config::OPID_CACHE_FAVICON => false,
331
+ LiteSpeed_Cache_Config::OPID_CACHE_RES => false,
332
+ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST => false,
333
+ LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES => '',
334
+ LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS => '',
335
+ LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE => ''
336
+ );
337
+ return $reset;
338
+ }
339
+
340
+ /**
341
+ * Get the plugin's site wide options.
342
+ *
343
+ * If the site wide options are not set yet, set it to default.
344
+ *
345
+ * @since 1.0.2
346
+ * @access public
347
+ * @return array Returns the current site options.
348
+ */
349
+ public function get_site_options()
350
+ {
351
+ if (!is_multisite()) {
352
+ return null;
353
+ }
354
+ $site_options = get_site_option(self::OPTION_NAME);
355
+ if (isset($site_options) && is_array($site_options)) {
356
+ return $site_options;
357
+ }
358
+ elseif (isset($site_options) && is_string($site_options)) {
359
+ return $site_options;
360
+ }
361
+ $default_site_options = $this->get_default_site_options();
362
+ add_site_option(self::OPTION_NAME, $default_site_options);
363
+ return $default_site_options;
364
+ }
365
+
366
+ /**
367
+ * Gets the third party options.
368
+ * Will also strip the options that are actually normal options.
369
+ *
370
+ * @access public
371
+ * @since 1.0.9
372
+ * @param array $options Optional. The default options to compare against.
373
+ * @return mixed boolean on failure, array of keys on success.
374
+ */
375
+ public function get_thirdparty_options($options = null)
376
+ {
377
+ $tp_options = apply_filters('litespeed_cache_get_options', array());
378
+ if (empty($tp_options)) {
379
+ return false;
380
+ }
381
+ if (!isset($options)) {
382
+ $options = $this->get_default_options(false);
383
+ }
384
+ return array_diff_key($tp_options, $options);
385
+ }
386
+
387
+ /**
388
+ * Helper function to convert the options to replicate the input format.
389
+ *
390
+ * The only difference is the checkboxes.
391
+ *
392
+ * @access public
393
+ * @since 1.0.15
394
+ * @param array $options The options array to port to input format.
395
+ */
396
+ public static function convert_options_to_input(&$options)
397
+ {
398
+ $checkboxes =
399
+ array(
400
+ LiteSpeed_Cache_Config::OPID_MOBILEVIEW_ENABLED,
401
+ LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE,
402
+ LiteSpeed_Cache_Config::OPID_CACHE_COMMENTERS,
403
+ LiteSpeed_Cache_Config::OPID_CACHE_LOGIN,
404
+ LiteSpeed_Cache_Config::OPID_CACHE_FAVICON,
405
+ LiteSpeed_Cache_Config::OPID_CACHE_RES,
406
+ LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE,
407
+ );
408
+
409
+ if (isset($options[self::OPID_PURGE_BY_POST])) {
410
+ $purge_opts = explode('.', $options[self::OPID_PURGE_BY_POST]);
411
+
412
+ foreach ($purge_opts as $purge_opt) {
413
+ $options['purge_' . $purge_opt] = $purge_opt;
414
+ }
415
+ }
416
+
417
+ foreach ($checkboxes as $checkbox) {
418
+ if ((isset($options[$checkbox])) && ($options[$checkbox])) {
419
+ $options['lscwp_' . $checkbox] = $checkbox;
420
+ }
421
+ }
422
+
423
+ }
424
+
425
+ /**
426
+ * Get the difference between the current options and the default options.
427
+ *
428
+ * @since 1.0.11
429
+ * @access public
430
+ * @param array $default_options The default options.
431
+ * @param array $options The current options.
432
+ */
433
+ public static function option_diff($default_options, &$options)
434
+ {
435
+ $dkeys = array_keys($default_options);
436
+ $keys = array_keys($options);
437
+ $newkeys = array_diff($dkeys, $keys);
438
+ $log = '' ;
439
+ if ( ! empty($newkeys) ) {
440
+ foreach ( $newkeys as $newkey ) {
441
+ $options[$newkey] = $default_options[$newkey] ;
442
+ $log .= ' Added ' . $newkey . ' = ' . $default_options[$newkey] ;
443
+ }
444
+ }
445
+ $retiredkeys = array_diff($keys, $dkeys) ;
446
+ if ( ! empty($retiredkeys) ) {
447
+ foreach ( $retiredkeys as $retired ) {
448
+ unset($options[$retired]) ;
449
+ $log .= 'Removed ' . $retired ;
450
+ }
451
+ }
452
+ $options[self::OPID_VERSION] = LiteSpeed_Cache::PLUGIN_VERSION;
453
+
454
+ if ($options[self::OPID_MOBILEVIEW_ENABLED] === false) {
455
+ $options[self::ID_MOBILEVIEW_LIST] = false;
456
+ }
457
+ }
458
+
459
+ /**
460
+ * Verify that the options are still valid.
461
+ *
462
+ * This is used only when upgrading the plugin versions.
463
+ *
464
+ * @since 1.0.0
465
+ * @access public
466
+ */
467
+ public function plugin_upgrade()
468
+ {
469
+ $default_options = $this->get_default_options() ;
470
+
471
+ if (($this->options[self::OPID_VERSION] == $default_options[self::OPID_VERSION])
472
+ && (count($default_options) == count($this->options))) {
473
+ return;
474
+ }
475
+
476
+ self::option_diff($default_options, $this->options);
477
+
478
+ // if ((!is_multisite()) || (is_network_admin())) {
479
+ // $this->options[self::OPID_LOGIN_COOKIE]
480
+ // = LiteSpeed_Cache_Admin_Rules::get_instance()->scan_upgrade();
481
+ // }
482
+
483
+ $res = update_option(self::OPTION_NAME, $this->options) ;
484
+ if (defined('LSCWP_LOG')) {
485
+ LiteSpeed_Cache::debug_log(
486
+ "plugin_upgrade option changed = $res\n");
487
+ }
488
+ }
489
+
490
+ /**
491
+ * Upgrade network options when the plugin is upgraded.
492
+ *
493
+ * @since 1.0.11
494
+ * @access public
495
+ */
496
+ public function plugin_site_upgrade()
497
+ {
498
+ $default_options = $this->get_default_site_options();
499
+ $options = $this->get_site_options();
500
+
501
+ if (($options[self::OPID_VERSION] == $default_options[self::OPID_VERSION])
502
+ && (count($default_options) == count($options))) {
503
+ return;
504
+ }
505
+
506
+ self::option_diff($default_options, $options);
507
+
508
+ $res = update_site_option(self::OPTION_NAME, $options);
509
+
510
+ if (defined('LSCWP_LOG')) {
511
+ LiteSpeed_Cache::debug_log("plugin_upgrade option changed = $res\n");
512
+ }
513
+
514
+ }
515
+
516
+ /**
517
+ * Update the WP_CACHE variable in the wp-config.php file.
518
+ *
519
+ * If enabling, check if the variable is defined, and if not, define it.
520
+ * Vice versa for disabling.
521
+ *
522
+ * @since 1.0.0
523
+ * @access public
524
+ * @param boolean $enable True if enabling, false if disabling.
525
+ * @return boolean True if the variable is the correct value, false if something went wrong.
526
+ */
527
+ public static function wp_cache_var_setter( $enable )
528
+ {
529
+ if ( $enable ) {
530
+ if ( defined('WP_CACHE') && constant('WP_CACHE') == true ) {
531
+ return true ;
532
+ }
533
+ }
534
+ elseif (! defined('WP_CACHE') || (defined('WP_CACHE') && constant('WP_CACHE') == false) ) {
535
+ return true;
536
+ }
537
+ $file = ABSPATH . 'wp-config.php' ;
538
+ if ( !is_writeable($file) ) {
539
+ $file = dirname(ABSPATH) . '/wp-config.php';
540
+ if ( !is_writeable($file) ) {
541
+ error_log('wp-config file not writeable for \'WP_CACHE\'');
542
+ return LiteSpeed_Cache_Admin_Error::E_CONF_WRITE;
543
+ }
544
+ }
545
+ $file_content = file_get_contents($file) ;
546
+
547
+ if ( $enable ) {
548
+ $count = 0 ;
549
+
550
+ $new_file_content = preg_replace('/[\/]*define\(.*\'WP_CACHE\'.+;/',
551
+ "define('WP_CACHE', true);", $file_content, -1, $count) ;
552
+ if ( $count == 0 ) {
553
+ $new_file_content = preg_replace('/(\$table_prefix)/',
554
+ "define('WP_CACHE', true);\n$1", $file_content) ;
555
+ if ( $count == 0 ) {
556
+ $new_file_content = preg_replace('/(\<\?php)/',
557
+ "$1\ndefine('WP_CACHE', true);", $file_content, -1, $count) ;
558
+ }
559
+
560
+ if ($count == 0) {
561
+ error_log('wp-config file did not find a place to insert define.');
562
+ return LiteSpeed_Cache_Admin_Error::E_CONF_FIND;
563
+ }
564
+ }
565
+ }
566
+ else {
567
+ $new_file_content = preg_replace('/define\(.*\'WP_CACHE\'.+;/',
568
+ "define('WP_CACHE', false);", $file_content) ;
569
+ }
570
+
571
+ file_put_contents($file, $new_file_content) ;
572
+ return true ;
573
+ }
574
+
575
+ /**
576
+ * On plugin activation, load the default options.
577
+ *
578
+ * @since 1.0.0
579
+ * @access public
580
+ * @param int $count In multisite, the number of blogs active.
581
+ */
582
+ public function plugin_activation($count)
583
+ {
584
+ $errors = array();
585
+ $rules = LiteSpeed_Cache_Admin_Rules::get_instance();
586
+ $default = $this->get_default_options();
587
+ $res = add_option(self::OPTION_NAME, $default);
588
+ if (defined('LSCWP_LOG')) {
589
+ LiteSpeed_Cache::debug_log("plugin_activation update option = $res");
590
+ }
591
+ if (is_multisite()) {
592
+ if (!is_network_admin()) {
593
+ if ($count === 1) {
594
+ $rules->validate_common_rewrites(array(), $errors);
595
+ }
596
+ return;
597
+ }
598
+ $options = $this->get_site_options();
599
+ if (isset($options) && (is_string($options))) {
600
+ $options = unserialize($options);
601
+ update_site_option(self::OPTION_NAME, $options);
602
+ }
603
+ if (($res == true)
604
+ || (($options[self::NETWORK_OPID_ENABLED] == false))) {
605
+ return;
606
+ }
607
+ }
608
+ elseif (($res == false)
609
+ && (($this->get_option(self::OPID_ENABLED) == false))) {
610
+ return;
611
+ }
612
+ else {
613
+ $options = $this->get_options();
614
+ }
615
+
616
+ $default = self::get_rule_reset_options();
617
+
618
+ if ($options[self::OPID_CACHE_FAVICON]) {
619
+ $options['lscwp_' . self::OPID_CACHE_FAVICON]
620
+ = self::OPID_CACHE_FAVICON;
621
+ }
622
+ if ($options[self::OPID_CACHE_RES]) {
623
+ $options['lscwp_' . self::OPID_CACHE_RES] = self::OPID_CACHE_RES;
624
+ }
625
+ if ($options[self::OPID_MOBILEVIEW_ENABLED]) {
626
+ $options['lscwp_' . self::OPID_MOBILEVIEW_ENABLED]
627
+ = self::OPID_MOBILEVIEW_ENABLED;
628
+ }
629
+
630
+ $diff = $rules->check_input($default, $options, $errors);
631
+
632
+ if (!empty($diff)) {
633
+ $rules->validate_common_rewrites($diff, $errors);
634
+ }
635
+
636
+ if (!empty($errors)) {
637
+ exit(implode("\n", $errors));
638
+ }
639
+
640
+ }
641
+
642
+ /**
643
+ * Checks if caching is allowed via server variable.
644
+ *
645
+ * @since 1.0.0
646
+ * @access public
647
+ * @return boolean True if allowed, false otherwise.
648
+ */
649
+ public function is_caching_allowed()
650
+ {
651
+ if (((isset($_SERVER['X-LSCACHE'])) && ($_SERVER['X-LSCACHE'])) //lsws
652
+ || (is_webadc())) {
653
+ return true;
654
+ }
655
+ return false;
656
+ }
657
+
658
+ /**
659
+ * Checks if caching is allowed, then if the plugin is enabled in configs.
660
+ *
661
+ * @since 1.0.0
662
+ * @access public
663
+ * @return boolean True if enabled, false otherwise.
664
+ */
665
+ public function is_plugin_enabled()
666
+ {
667
+ if (!$this->is_caching_allowed()) {
668
+ return false;
669
+ }
670
+ elseif ((is_multisite()) && (is_network_admin())
671
+ && (current_user_can('manage_network_options'))) {
672
+ return $this->options[self::NETWORK_OPID_ENABLED];
673
+ }
674
+ return $this->options[self::OPID_ENABLED];
675
+ }
676
+
677
+ }
includes/class-litespeed-cache-tags.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * The LiteSpeed Web Server response header tags.
6
+ *
7
+ * The constants listed here are used by the web server to determine actions
8
+ * that need to take place.
9
+ *
10
+ * The TYPE_* constants are used to tag a cache entry with site-wide page types.
11
+ *
12
+ * The HEADER_* constants are used to notify the web server to do some action.
13
+ *
14
+ * @since 1.0.5
15
+ * @package LiteSpeed_Cache
16
+ * @subpackage LiteSpeed_Cache/includes
17
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
18
+ */
19
+ class LiteSpeed_Cache_Tags
20
+ {
21
+ // G P C E tags reserved for litemage.
22
+
23
+ const TYPE_FEED = 'FD';
24
+ const TYPE_FRONTPAGE = 'F' ;
25
+ const TYPE_HOME = 'H' ;
26
+ const TYPE_PAGES = 'PGS';
27
+ const TYPE_PAGES_WITH_RECENT_POSTS = 'PGSRP';
28
+ const TYPE_ERROR = 'ERR.';
29
+ const TYPE_POST = 'Po.' ; // Post. Cannot use P, reserved for litemage.
30
+ const TYPE_ARCHIVE_POSTTYPE = 'PT.' ;
31
+ const TYPE_ARCHIVE_TERM = 'T.' ; //for is_category|is_tag|is_tax
32
+ const TYPE_AUTHOR = 'A.' ;
33
+ const TYPE_ARCHIVE_DATE = 'D.' ;
34
+ const TYPE_BLOG = 'B.' ;
35
+ const TYPE_LOGIN = 'L';
36
+ const TYPE_URL = 'URL.';
37
+ const HEADER_PURGE = 'X-LiteSpeed-Purge' ;
38
+ const HEADER_CACHE_CONTROL = 'X-LiteSpeed-Cache-Control' ;
39
+ const HEADER_CACHE_TAG = 'X-LiteSpeed-Tag' ;
40
+ const HEADER_CACHE_VARY = 'X-LiteSpeed-Vary' ;
41
+ const HEADER_DEBUG = 'X-LiteSpeed-Debug' ;
42
+
43
+ static $thirdparty_purge_tags = array();
44
+ static $thirdparty_cache_tags = array();
45
+ static $thirdparty_vary_cookies = array(); // vary header only!
46
+ static $thirdparty_noncacheable = false;
47
+ static $thirdparty_mobile = false;
48
+ static $thirdparty_use_front_ttl = false;
49
+
50
+ /**
51
+ * Gets cache tags that are already added for the current page.
52
+ *
53
+ * @since 1.0.5
54
+ * @access public
55
+ * @return array An array of all cache tags currently added.
56
+ */
57
+ public static function get_cache_tags()
58
+ {
59
+ if (empty(self::$thirdparty_cache_tags)) {
60
+ return self::$thirdparty_cache_tags;
61
+ }
62
+ return array_unique(self::$thirdparty_cache_tags);
63
+ }
64
+
65
+ /**
66
+ * Adds cache tags to the list of cache tags for the current page.
67
+ *
68
+ * @since 1.0.5
69
+ * @access public
70
+ * @param mixed $tag A string or array of cache tags to add to the current list.
71
+ */
72
+ public static function add_cache_tag($tag)
73
+ {
74
+ if (is_array($tag)) {
75
+ self::$thirdparty_cache_tags = array_merge(self::$thirdparty_cache_tags, $tag);
76
+ }
77
+ else {
78
+ self::$thirdparty_cache_tags[] = $tag;
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Gets purge tags that are already added for the current page.
84
+ *
85
+ * @since 1.0.5
86
+ * @access public
87
+ * @return array An array of all purge tags currently added.
88
+ */
89
+ public static function get_purge_tags()
90
+ {
91
+ if (empty(self::$thirdparty_purge_tags)) {
92
+ return self::$thirdparty_purge_tags;
93
+ }
94
+ return array_unique(self::$thirdparty_purge_tags);
95
+ }
96
+
97
+ /**
98
+ * Adds purge tags to the list of purge tags for the current page.
99
+ *
100
+ * @since 1.0.5
101
+ * @access public
102
+ * @param mixed $tag A string or array of purge tags to add to the current list.
103
+ */
104
+ public static function add_purge_tag($tag)
105
+ {
106
+ if (is_array($tag)) {
107
+ self::$thirdparty_purge_tags = array_merge(self::$thirdparty_purge_tags, $tag);
108
+ }
109
+ else {
110
+ self::$thirdparty_purge_tags[] = $tag;
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Gets vary cookies that are already added for the current page.
116
+ *
117
+ * @since 1.0.13
118
+ * @access public
119
+ * @return array An array of all vary cookies currently added.
120
+ */
121
+ public static function get_vary_cookies()
122
+ {
123
+ if (empty(self::$thirdparty_vary_cookies)) {
124
+ return self::$thirdparty_vary_cookies;
125
+ }
126
+ $cookies = array_unique(self::$thirdparty_vary_cookies);
127
+ if (empty($cookies)) {
128
+ return $cookies;
129
+ }
130
+ foreach ($cookies as $key => $val) {
131
+ $cookies[$key] = 'cookie=' . $val;
132
+ }
133
+ return $cookies;
134
+ }
135
+
136
+ /**
137
+ * Adds vary cookie(s) to the list of vary cookies for the current page.
138
+ *
139
+ * @since 1.0.13
140
+ * @access public
141
+ * @param mixed $cookie A string or array of vary cookies to add to the
142
+ * current list.
143
+ */
144
+ public static function add_vary_cookie($cookie)
145
+ {
146
+ if (is_array($cookie)) {
147
+ self::$thirdparty_vary_cookies =
148
+ array_merge(self::$thirdparty_vary_cookies, $cookie);
149
+ }
150
+ else {
151
+ self::$thirdparty_vary_cookies[] = $cookie;
152
+ }
153
+ }
154
+
155
+ /**
156
+ * Gets whether any plugins determined that the current page is
157
+ * non-cacheable.
158
+ *
159
+ * @return boolean True if the current page was deemed non-cacheable,
160
+ * false otherwise.
161
+ */
162
+ public static function is_noncacheable()
163
+ {
164
+ return self::$thirdparty_noncacheable;
165
+ }
166
+
167
+ /**
168
+ * Mark the current page as non cacheable. This may be useful for
169
+ * if the litespeed_cache_is_cacheable hook point triggers too soon
170
+ * for the third party plugin to know if the page is cacheable.
171
+ *
172
+ * Must be called before the shutdown hook point.
173
+ *
174
+ * @since 1.0.7
175
+ * @access public
176
+ */
177
+ public static function set_noncacheable()
178
+ {
179
+ if (defined('LSCWP_LOG')) {
180
+ $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
181
+ LiteSpeed_Cache::debug_log('Thirdparty called set_noncacheable(): '
182
+ . $trace[1]['class']);
183
+ }
184
+ self::$thirdparty_noncacheable = true;
185
+ }
186
+
187
+ /**
188
+ * Gets whether any plugins determined that the current page is
189
+ * mobile.
190
+ *
191
+ * @return boolean True if the current page was deemed mobile,
192
+ * false otherwise.
193
+ */
194
+ public static function is_mobile()
195
+ {
196
+ return self::$thirdparty_mobile;
197
+ }
198
+
199
+ /**
200
+ * Mark the current page as mobile. This may be useful for
201
+ * if the plugin does not override wp_is_mobile.
202
+ *
203
+ * Must be called before the shutdown hook point.
204
+ *
205
+ * @since 1.0.7
206
+ * @access public
207
+ */
208
+ public static function set_mobile()
209
+ {
210
+ self::$thirdparty_mobile = true;
211
+ }
212
+
213
+ /**
214
+ * Gets whether any plugins determined that the current page should use
215
+ * the front page TTL setting.
216
+ *
217
+ * @since 1.0.9
218
+ * @access public
219
+ * @return boolean True if use front page TTL, false otherwise.
220
+ */
221
+ public static function get_use_frontpage_ttl()
222
+ {
223
+ return self::$thirdparty_use_front_ttl;
224
+ }
225
+
226
+ /**
227
+ * Mark the current page to use the front page ttl.
228
+ *
229
+ * @since 1.0.9
230
+ * @access public
231
+ */
232
+ public static function set_use_frontpage_ttl()
233
+ {
234
+ self::$thirdparty_use_front_ttl = true;
235
+ }
236
+
237
+ }
includes/class-litespeed-cache.php ADDED
@@ -0,0 +1,2630 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * The core plugin class.
6
+ *
7
+ * This is used to define internationalization, admin-specific hooks, and
8
+ * public-facing site hooks.
9
+ *
10
+ * Also maintains the unique identifier of this plugin as well as the current
11
+ * version of the plugin.
12
+ *
13
+ * @since 1.0.0
14
+ * @package LiteSpeed_Cache
15
+ * @subpackage LiteSpeed_Cache/includes
16
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
17
+ */
18
+ class LiteSpeed_Cache
19
+ {
20
+
21
+ private static $instance ;
22
+ private static $log_path = '';
23
+
24
+ const PLUGIN_NAME = 'litespeed-cache' ;
25
+ const PLUGIN_VERSION = '1.0.15' ;
26
+
27
+ const LSCOOKIE_VARY_NAME = 'LSCACHE_VARY_COOKIE' ;
28
+ const LSCOOKIE_DEFAULT_VARY = '_lscache_vary' ;
29
+ const LSCOOKIE_VARY_LOGGED_IN = 1;
30
+ const LSCOOKIE_VARY_COMMENTER = 2;
31
+
32
+ const ADMINQS_KEY = 'LSCWP_CTRL';
33
+ const ADMINQS_DISMISS = 'DISMISS';
34
+ const ADMINQS_PURGE = 'PURGE';
35
+ const ADMINQS_PURGEBY = 'PURGEBY';
36
+ const ADMINQS_PURGEALL = 'PURGEALL';
37
+ const ADMINQS_PURGESINGLE = 'PURGESINGLE';
38
+ const ADMINQS_SHOWHEADERS = 'SHOWHEADERS';
39
+
40
+ const ADMINNONCE_PURGEALL = 'litespeed-purgeall';
41
+ const ADMINNONCE_PURGENETWORKALL = 'litespeed-purgeall-network';
42
+ const ADMINNONCE_PURGEBY = 'litespeed-purgeby';
43
+ const ADMINNONCE_DISMISS = 'litespeed-dismiss';
44
+
45
+ const CACHECTRL_NOCACHE = 0;
46
+ const CACHECTRL_CACHE = 1;
47
+ const CACHECTRL_PURGE = 2;
48
+ const CACHECTRL_PURGESINGLE = 3;
49
+
50
+ const CACHECTRL_SHOWHEADERS = 128; // (1<<7)
51
+ const CACHECTRL_STALE = 64; // (1<<6)
52
+
53
+ const WHM_TRANSIENT = 'lscwp_whm_install';
54
+ const WHM_TRANSIENT_VAL = 'whm_install';
55
+ const NETWORK_TRANSIENT_COUNT = 'lscwp_network_count';
56
+
57
+ protected $plugin_dir ;
58
+ protected $config ;
59
+ protected $current_vary;
60
+ protected $cachectrl = self::CACHECTRL_NOCACHE;
61
+ protected $pub_purge_tags = array();
62
+ protected $error_status = false;
63
+
64
+ /**
65
+ * Define the core functionality of the plugin.
66
+ *
67
+ * Set the plugin name and the plugin version that can be used throughout the plugin.
68
+ * Load the dependencies, define the locale, and set the hooks for the admin area and
69
+ * the public-facing side of the site.
70
+ *
71
+ * @since 1.0.0
72
+ */
73
+ private function __construct()
74
+ {
75
+ $cur_dir = dirname(__FILE__) ;
76
+ require_once $cur_dir . '/class-litespeed-cache-config.php' ;
77
+ include_once $cur_dir . '/class-litespeed-cache-tags.php';
78
+ // Load third party detection.
79
+ include_once $cur_dir . '/../thirdparty/litespeed-cache-thirdparty-registry.php';
80
+
81
+ $theme_root = get_theme_root();
82
+ $content_dir = dirname($theme_root);
83
+
84
+ $should_debug = LiteSpeed_Cache_Config::OPID_ENABLED_DISABLE;
85
+ self::$log_path = $content_dir . '/debug.log';
86
+ $this->config = new LiteSpeed_Cache_Config() ;
87
+ if ($this->config->get_option(LiteSpeed_Cache_Config::OPID_ENABLED)) {
88
+ $should_debug = intval($this->config->get_option(
89
+ LiteSpeed_Cache_Config::OPID_DEBUG));
90
+ }
91
+
92
+ switch ($should_debug) {
93
+ // NOTSET is used as check admin IP here.
94
+ case LiteSpeed_Cache_Config::OPID_ENABLED_NOTSET:
95
+ $ips = $this->config->get_option(LiteSpeed_Cache_Config::OPID_ADMIN_IPS);
96
+ if (strpos($ips, $_SERVER['REMOTE_ADDR']) === false) {
97
+ break;
98
+ }
99
+ // fall through
100
+ case LiteSpeed_Cache_Config::OPID_ENABLED_ENABLE:
101
+ define ('LSCWP_LOG', true);
102
+ break;
103
+ case LiteSpeed_Cache_Config::OPID_ENABLED_DISABLE:
104
+ break;
105
+ default:
106
+ break;
107
+ }
108
+
109
+ $this->plugin_dir = plugin_dir_path($cur_dir) ;
110
+ $plugin_file = $this->plugin_dir . 'litespeed-cache.php' ;
111
+ register_activation_hook($plugin_file, array( $this, 'register_activation' )) ;
112
+ register_deactivation_hook($plugin_file, array( $this, 'register_deactivation' )) ;
113
+
114
+ add_action('after_setup_theme', array( $this, 'init' )) ;
115
+ }
116
+
117
+ /**
118
+ * The entry point for LiteSpeed Cache.
119
+ *
120
+ * @since 1.0.0
121
+ * @access public
122
+ */
123
+ public static function run()
124
+ {
125
+ if ( ! isset(self::$instance) ) {
126
+ self::$instance = new LiteSpeed_Cache() ;
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Get the LiteSpeed_Cache object.
132
+ *
133
+ * @since 1.0.0
134
+ * @access public
135
+ * @return LiteSpeed_Cache Static instance of the LiteSpeed_Cache class.
136
+ */
137
+ public static function plugin()
138
+ {
139
+ return self::$instance ;
140
+ }
141
+
142
+ /**
143
+ * Get the LiteSpeed_Cache_Config object. Can be called outside of a
144
+ * LiteSpeed_Cache object.
145
+ *
146
+ * @since 1.0.0
147
+ * @access public
148
+ * @param string $opt_id An option ID if getting an option.
149
+ * @return LiteSpeed_Cache_Config The configurations for the accessed page.
150
+ */
151
+ public static function config($opt_id = '')
152
+ {
153
+ $conf = self::$instance->config;
154
+ if ((empty($opt_id)) || (!is_string($opt_id))) {
155
+ return $conf;
156
+ }
157
+ return $conf->get_option($opt_id);
158
+ }
159
+
160
+ /**
161
+ * Sets up the log tag and creates initial log messages.
162
+ *
163
+ * @since 1.0.12
164
+ * @access private
165
+ */
166
+ private static function setup_debug_log()
167
+ {
168
+ if (!defined('LSCWP_LOG_TAG')) {
169
+ define('LSCWP_LOG_TAG',
170
+ 'LSCACHE_WP_blogid_' . get_current_blog_id());
171
+ }
172
+ self::log_request();
173
+
174
+ }
175
+
176
+ /**
177
+ * Formats the log message with a consistent prefix.
178
+ *
179
+ * @since 1.0.12
180
+ * @access private
181
+ * @param string $mesg The log message to write.
182
+ * @return string The formatted log message.
183
+ */
184
+ private static function format_message($mesg)
185
+ {
186
+ $tag = defined('LSCWP_LOG_TAG') ? constant('LSCWP_LOG_TAG') : 'LSCACHE_WP';
187
+ $formatted = sprintf("%s [%s:%s] [%s] %s\n", date('r'),
188
+ $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_PORT'],
189
+ $tag, $mesg);
190
+ return $formatted;
191
+ }
192
+
193
+ /**
194
+ * Logs a debug message.
195
+ *
196
+ * @since 1.0.0
197
+ * @access public
198
+ * @param string $mesg The debug message.
199
+ */
200
+ public static function debug_log($mesg)
201
+ {
202
+ $formatted = self::format_message($mesg);
203
+ file_put_contents(self::$log_path, $formatted, FILE_APPEND);
204
+ }
205
+
206
+ /**
207
+ * Create the initial log messages with the request parameters.
208
+ *
209
+ * @since 1.0.12
210
+ * @access private
211
+ */
212
+ private static function log_request()
213
+ {
214
+ $SERVERVARS = array(
215
+ 'Query String' => '',
216
+ 'HTTP_USER_AGENT' => '',
217
+ 'HTTP_ACCEPT_ENCODING' => '',
218
+ 'HTTP_COOKIE' => '',
219
+ 'X-LSCACHE' => '',
220
+ 'LSCACHE_VARY_COOKIE' => '',
221
+ 'LSCACHE_VARY_VALUE' => ''
222
+ );
223
+ $SERVER = array_merge($SERVERVARS, $_SERVER);
224
+ $params = array(
225
+ sprintf('%s %s %s', $SERVER['REQUEST_METHOD'],
226
+ $SERVER['SERVER_PROTOCOL'],
227
+ strtok($SERVER['REQUEST_URI'], '?')),
228
+ 'Query String: ' . $SERVER['QUERY_STRING'],
229
+ 'User Agent: ' . $SERVER['HTTP_USER_AGENT'],
230
+ 'Accept Encoding: ' . $SERVER['HTTP_ACCEPT_ENCODING'],
231
+ 'Cookie: ' . $SERVER['HTTP_COOKIE'],
232
+ 'X-LSCACHE: ' . ($SERVER['X-LSCACHE'] ? 'true' : 'false'),
233
+ 'LSCACHE_VARY_COOKIE: ' . $SERVER['LSCACHE_VARY_COOKIE'],
234
+ 'LSCACHE_VARY_VALUE: ' . $SERVER['LSCACHE_VARY_VALUE'],
235
+ );
236
+
237
+ $request = array_map('self::format_message', $params);
238
+ file_put_contents(self::$log_path, $request, FILE_APPEND);
239
+ }
240
+
241
+ /**
242
+ * The activation hook callback.
243
+ *
244
+ * Attempts to set up the advanced cache file. If it fails for any reason,
245
+ * the plugin will not activate.
246
+ *
247
+ * @since 1.0.0
248
+ * @access public
249
+ */
250
+ public function register_activation()
251
+ {
252
+ $count = 0;
253
+ if (!defined('LSCWP_LOG_TAG')) {
254
+ define('LSCWP_LOG_TAG',
255
+ 'LSCACHE_WP_activate_' . get_current_blog_id());
256
+ }
257
+ $this->try_copy_advanced_cache();
258
+ LiteSpeed_Cache_Config::wp_cache_var_setter(true);
259
+
260
+ include_once $this->plugin_dir . '/admin/class-litespeed-cache-admin.php';
261
+ require_once $this->plugin_dir . '/admin/class-litespeed-cache-admin-display.php';
262
+ require_once $this->plugin_dir . '/admin/class-litespeed-cache-admin-rules.php';
263
+ if (is_multisite()) {
264
+ $count = $this->get_network_count();
265
+ if ($count !== false) {
266
+ $count = intval($count) + 1;
267
+ set_site_transient(self::NETWORK_TRANSIENT_COUNT, $count,
268
+ DAY_IN_SECONDS);
269
+ }
270
+ }
271
+ do_action('litespeed_cache_detect_thirdparty');
272
+ $this->config->plugin_activation($count);
273
+ self::generate_environment_report();
274
+
275
+ if (defined('LSCWP_PLUGIN_NAME')) {
276
+ set_transient(self::WHM_TRANSIENT, self::WHM_TRANSIENT_VAL);
277
+ }
278
+ }
279
+
280
+ /**
281
+ * Get the blog ids for the network. Accepts function arguments.
282
+ *
283
+ * Will use wp_get_sites for WP versions less than 4.6
284
+ *
285
+ * @since 1.0.12
286
+ * @access private
287
+ * @param array $args Arguments to pass into get_sites/wp_get_sites.
288
+ * @return array The array of blog ids.
289
+ */
290
+ private static function get_network_ids($args = array())
291
+ {
292
+ global $wp_version;
293
+ if (version_compare($wp_version, '4.6', '<')) {
294
+ $blogs = wp_get_sites($args);
295
+ if (!empty($blogs)) {
296
+ foreach ($blogs as $key => $blog) {
297
+ $blogs[$key] = $blog['blog_id'];
298
+ }
299
+ }
300
+ }
301
+ else {
302
+ $args['fields'] = 'ids';
303
+ $blogs = get_sites($args);
304
+ }
305
+ return $blogs;
306
+ }
307
+
308
+ /**
309
+ * Gets the count of active litespeed cache plugins on multisite.
310
+ *
311
+ * @since 1.0.12
312
+ * @access private
313
+ * @return mixed The count on success, false on failure.
314
+ */
315
+ private function get_network_count()
316
+ {
317
+ $count = get_site_transient(self::NETWORK_TRANSIENT_COUNT);
318
+ if ($count !== false) {
319
+ return intval($count);
320
+ }
321
+ // need to update
322
+ $basename = plugin_basename($this->plugin_dir . 'litespeed-cache.php');
323
+ $default = array();
324
+ $count = 0;
325
+
326
+ $sites = self::get_network_ids(array('deleted' => 0));
327
+ if (empty($sites)) {
328
+ return false;
329
+ }
330
+
331
+ foreach ($sites as $site) {
332
+ $plugins = get_blog_option($site->blog_id, 'active_plugins',
333
+ $default);
334
+ if (in_array($basename, $plugins, true)) {
335
+ $count++;
336
+ }
337
+ }
338
+ if (is_plugin_active_for_network($basename)) {
339
+ $count++;
340
+ }
341
+ return $count;
342
+ }
343
+
344
+ /**
345
+ * Is this deactivate call the last active installation on the multisite
346
+ * network?
347
+ *
348
+ * @since 1.0.12
349
+ * @access private
350
+ * @return bool True if yes, false otherwise.
351
+ */
352
+ private function is_deactivate_last()
353
+ {
354
+ $count = $this->get_network_count();
355
+ if ($count === false) {
356
+ return false;
357
+ }
358
+ if ($count !== 1) {
359
+ // Not deactivating the last one.
360
+ $count--;
361
+ set_site_transient(self::NETWORK_TRANSIENT_COUNT, $count,
362
+ DAY_IN_SECONDS);
363
+ return false;
364
+ }
365
+
366
+ delete_site_transient(self::NETWORK_TRANSIENT_COUNT);
367
+ return true;
368
+ }
369
+
370
+ /**
371
+ * The deactivation hook callback.
372
+ *
373
+ * Initializes all clean up functionalities.
374
+ *
375
+ * @since 1.0.0
376
+ * @access public
377
+ */
378
+ public function register_deactivation()
379
+ {
380
+ require_once $this->plugin_dir
381
+ . '/admin/class-litespeed-cache-admin-display.php';
382
+ require_once $this->plugin_dir
383
+ . '/admin/class-litespeed-cache-admin-rules.php';
384
+ if (!defined('LSCWP_LOG_TAG')) {
385
+ define('LSCWP_LOG_TAG',
386
+ 'LSCACHE_WP_deactivate_' . get_current_blog_id());
387
+ }
388
+ $this->purge_all();
389
+
390
+ if (is_multisite()) {
391
+ if (is_network_admin()) {
392
+ $options = get_site_option(
393
+ LiteSpeed_Cache_Config::OPTION_NAME);
394
+ if ((isset($options)) && (is_array($options))) {
395
+ $opt_str = serialize($options);
396
+ update_site_option(LiteSpeed_Cache_Config::OPTION_NAME,
397
+ $opt_str);
398
+ }
399
+ }
400
+ if (!$this->is_deactivate_last()) {
401
+ if ((is_network_admin()) && (isset($opt_str))
402
+ && ($options[LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED])) {
403
+ $reset = LiteSpeed_Cache_Config::get_rule_reset_options();
404
+ $errors = array();
405
+ LiteSpeed_Cache_Admin_Rules::get_instance()
406
+ ->validate_common_rewrites($reset, $errors);
407
+ }
408
+ return;
409
+ }
410
+ }
411
+
412
+ $adv_cache_path = dirname(self::$log_path) . '/advanced-cache.php';
413
+ if (file_exists($adv_cache_path) && is_writable($adv_cache_path) &&
414
+ ((LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE) && defined('LSCACHE_ADV_CACHE') )
415
+ || strpos(file_get_contents($adv_cache_path), 'LSCACHE_ADV_CACHE') !== false ) ) {
416
+ unlink($adv_cache_path) ;
417
+ }
418
+ else {
419
+ error_log('Failed to remove advanced-cache.php, file does not exist or is not writable!') ;
420
+ }
421
+
422
+ if (!LiteSpeed_Cache_Config::wp_cache_var_setter(false)) {
423
+ error_log('In wp-config.php: WP_CACHE could not be set to false during deactivation!') ;
424
+ }
425
+ LiteSpeed_Cache_Admin_Rules::clear_rules();
426
+ // delete in case it's not deleted prior to deactivation.
427
+ delete_transient(self::WHM_TRANSIENT);
428
+ }
429
+
430
+ /**
431
+ * The plugin initializer.
432
+ *
433
+ * This function checks if the cache is enabled and ready to use, then
434
+ * determines what actions need to be set up based on the type of user
435
+ * and page accessed. Output is buffered if the cache is enabled.
436
+ *
437
+ * @since 1.0.0
438
+ * @access public
439
+ */
440
+ public function init()
441
+ {
442
+ $module_enabled = $this->config->is_plugin_enabled();
443
+ $is_ajax = (defined('DOING_AJAX') && DOING_AJAX);
444
+
445
+ if (defined('LSCWP_LOG')) {
446
+ self::setup_debug_log();
447
+ }
448
+
449
+ if ( is_admin() ) {
450
+ $this->load_admin_actions($module_enabled, $is_ajax);
451
+ }
452
+ else {
453
+ $this->load_nonadmin_actions($module_enabled);
454
+ }
455
+
456
+ if ((!$module_enabled) || (!defined('LSCACHE_ADV_CACHE'))
457
+ || (constant('LSCACHE_ADV_CACHE') === false)) {
458
+ return;
459
+ }
460
+
461
+ define('LITESPEED_CACHE_ENABLED', true);
462
+ ob_start();
463
+ //TODO: Uncomment this when esi is implemented.
464
+ // add_action('init', array($this, 'check_admin_bar'), 0);
465
+ // $this->add_actions_esi();
466
+
467
+ $bad_cookies = $this->setup_cookies();
468
+
469
+ if ( $this->check_esi_page()) {
470
+ return;
471
+ }
472
+
473
+ if (($bad_cookies) || ($this->check_user_logged_in())
474
+ || ($this->check_cookies())) {
475
+ $this->load_logged_in_actions() ;
476
+ }
477
+ else {
478
+ $this->load_logged_out_actions();
479
+ }
480
+
481
+ $this->load_public_actions() ;
482
+ if ($is_ajax) {
483
+ add_action('init', array($this, 'detect'), 4);
484
+ }
485
+ elseif ((is_admin()) || (is_network_admin())) {
486
+ add_action('admin_init', array($this, 'detect'), 0);
487
+ }
488
+ else {
489
+ add_action('wp', array($this, 'detect'), 4);
490
+ }
491
+ }
492
+
493
+ /**
494
+ * Callback used to call the detect third party action.
495
+ *
496
+ * The detect action is used by third party plugin integration classes
497
+ * to determine if they should add the rest of their hooks.
498
+ *
499
+ * @since 1.0.5
500
+ * @access public
501
+ */
502
+ public function detect()
503
+ {
504
+ do_action('litespeed_cache_detect_thirdparty');
505
+ }
506
+
507
+ /**
508
+ * Get the LiteSpeed_Cache_Config object.
509
+ *
510
+ * @since 1.0.0
511
+ * @access public
512
+ * @return LiteSpeed_Cache_Config The configurations for the accessed page.
513
+ */
514
+ public function get_config()
515
+ {
516
+ return $this->config ;
517
+ }
518
+
519
+ /**
520
+ * Try to copy our advanced-cache.php file to the wordpress directory.
521
+ *
522
+ * @since 1.0.11
523
+ * @access public
524
+ * @return boolean True on success, false on failure.
525
+ */
526
+ public function try_copy_advanced_cache()
527
+ {
528
+ $adv_cache_path = dirname(self::$log_path) . '/advanced-cache.php';
529
+ if ((file_exists($adv_cache_path))
530
+ && ((filesize($adv_cache_path) !== 0)
531
+ || (!is_writable($adv_cache_path)))) {
532
+ return false;
533
+ }
534
+ copy($this->plugin_dir . '/includes/advanced-cache.php',
535
+ $adv_cache_path);
536
+ include($adv_cache_path);
537
+ $ret = defined('LSCACHE_ADV_CACHE');
538
+ return $ret;
539
+ }
540
+ /**
541
+ * Define the locale for this plugin for internationalization.
542
+ *
543
+ * Uses the LiteSpeed_Cache_i18n class in order to set the domain and to register the hook
544
+ * with WordPress.
545
+ *
546
+ * @since 1.0.0
547
+ * @access private
548
+ */
549
+ private function set_locale()
550
+ {
551
+ load_plugin_textdomain(self::PLUGIN_NAME, false,
552
+ dirname(dirname(plugin_basename(__FILE__))) . '/languages/') ;
553
+ }
554
+
555
+ /**
556
+ * Register all of the hooks related to the admin area functionality
557
+ * of the plugin.
558
+ *
559
+ * @since 1.0.0
560
+ * @access private
561
+ * @param boolean $module_enabled Whether the module is enabled or not.
562
+ * @param boolean $is_ajax Whether the request is an ajax request or not.
563
+ */
564
+ private function load_admin_actions( $module_enabled, $is_ajax )
565
+ {
566
+ /**
567
+ * The class responsible for defining all actions that occur in the admin area.
568
+ */
569
+ require_once $this->plugin_dir . 'admin/class-litespeed-cache-admin.php' ;
570
+ require_once $this->plugin_dir . 'admin/class-litespeed-cache-admin-display.php' ;
571
+ require_once $this->plugin_dir . 'admin/class-litespeed-cache-admin-rules.php' ;
572
+
573
+ $admin = new LiteSpeed_Cache_Admin(self::PLUGIN_NAME, self::PLUGIN_VERSION) ;
574
+
575
+ add_action('load-litespeed-cache_page_lscache-edit-htaccess',
576
+ 'LiteSpeed_Cache_Admin_Rules::htaccess_editor_save');
577
+ add_action('load-litespeed-cache_page_lscache-settings',
578
+ array($admin, 'validate_network_settings'));
579
+ if (is_multisite()) {
580
+ add_action('update_site_option_' . LiteSpeed_Cache_Config::OPTION_NAME,
581
+ 'LiteSpeed_Cache::update_environment_report', 10, 2);
582
+ }
583
+ else {
584
+ add_action('update_option_' . LiteSpeed_Cache_Config::OPTION_NAME,
585
+ 'LiteSpeed_Cache::update_environment_report', 10, 2);
586
+ }
587
+ $this->set_locale() ;
588
+ if (!$module_enabled) {
589
+ return;
590
+ }
591
+
592
+ if ((is_multisite()) && (is_network_admin())) {
593
+ $manage = 'manage_network_options';
594
+ }
595
+ else {
596
+ $manage = 'manage_options';
597
+ }
598
+
599
+ //register purge_all actions
600
+ $purge_all_events = array(
601
+ 'switch_theme',
602
+ 'wp_create_nav_menu', 'wp_update_nav_menu', 'wp_delete_nav_menu',
603
+ 'create_term', 'edit_terms', 'delete_term',
604
+ 'add_link', 'edit_link', 'delete_link'
605
+ );
606
+ foreach ( $purge_all_events as $event ) {
607
+ add_action($event, array( $this, 'purge_all' ));
608
+ }
609
+ global $pagenow;
610
+ if ($pagenow === 'plugins.php') {
611
+ add_action('wp_default_scripts',
612
+ array($admin, 'set_update_text'), 0);
613
+ add_action('wp_default_scripts',
614
+ array($admin, 'unset_update_text'), 20);
615
+
616
+ }
617
+ if ($is_ajax) {
618
+ add_action('wp_ajax_lscache_cli', array($this, 'check_admin_ip'));
619
+ add_action('wp_ajax_nopriv_lscache_cli',
620
+ array($this, 'check_admin_ip'));
621
+ add_action('wp_ajax_lscache_dismiss_whm', array($this, 'check_admin_ip'));
622
+ add_action('wp_ajax_nopriv_lscache_dismiss_whm',
623
+ array($this, 'check_admin_ip'));
624
+ }
625
+ else {
626
+ add_action('admin_init', array($this, 'check_admin_ip'), 6);
627
+ }
628
+ if ($this->config->get_option(LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE)) {
629
+ add_action('upgrader_process_complete', array($this, 'purge_all'));
630
+ }
631
+
632
+ //Checks if WP_CACHE is defined and true in the wp-config.php file.
633
+ if (!current_user_can($manage)) {
634
+ return;
635
+ }
636
+ add_action('wp_before_admin_bar_render',
637
+ array($admin, 'add_quick_purge'));
638
+
639
+ if ((defined('WP_CACHE')) && (constant('WP_CACHE') == true)) {
640
+ return;
641
+ }
642
+ $add_var = LiteSpeed_Cache_Config::wp_cache_var_setter(true);
643
+ if ($add_var !== true) {
644
+ LiteSpeed_Cache_Admin_Error::add_error($add_var);
645
+ }
646
+ }
647
+
648
+ /**
649
+ * Register all of the hooks for non admin pages.
650
+ * of the plugin.
651
+ *
652
+ * @since 1.0.7
653
+ * @access private
654
+ * @param boolean $module_enabled Whether the module is enabled or not.
655
+ */
656
+ private function load_nonadmin_actions( $module_enabled )
657
+ {
658
+ if ($module_enabled) {
659
+ add_action('wp', array($this, 'check_admin_ip'), 6);
660
+ }
661
+ }
662
+
663
+ /**
664
+ * Register all the hooks for logged in users.
665
+ *
666
+ * @since 1.0.0
667
+ * @access private
668
+ */
669
+ private function load_logged_in_actions()
670
+ {
671
+ }
672
+
673
+ /**
674
+ * Register all the hooks for non-logged in users.
675
+ *
676
+ * @since 1.0.0
677
+ * @access private
678
+ */
679
+ private function load_logged_out_actions()
680
+ {
681
+ // user is not logged in
682
+ add_action('wp', array( $this, 'check_cacheable' ), 5) ;
683
+ add_action('login_init', array( $this, 'check_login_cacheable' ), 5) ;
684
+ add_filter('status_header', array($this, 'check_error_codes'), 10, 2);
685
+
686
+ $cache_res = $this->config->get_option(
687
+ LiteSpeed_Cache_Config::OPID_CACHE_RES);
688
+ if ($cache_res) {
689
+ require_once $this->plugin_dir . 'admin/class-litespeed-cache-admin-rules.php';
690
+ $uri = esc_url($_SERVER["REQUEST_URI"]);
691
+ $pattern = '!' . LiteSpeed_Cache_Admin_Rules::$RW_PATTERN_RES . '!';
692
+ if (preg_match($pattern, $uri)) {
693
+ add_action('wp_loaded', array( $this, 'check_cacheable' ), 5) ;
694
+ }
695
+ }
696
+ }
697
+
698
+ /**
699
+ * Register all of the hooks related to the all users
700
+ * of the plugin.
701
+ *
702
+ * @since 1.0.0
703
+ * @access private
704
+ */
705
+ private function load_public_actions()
706
+ {
707
+ //register purge actions
708
+ $purge_post_events = array(
709
+ 'edit_post',
710
+ 'save_post',
711
+ 'deleted_post',
712
+ 'trashed_post',
713
+ 'delete_attachment',
714
+ ) ;
715
+ foreach ( $purge_post_events as $event ) {
716
+ // this will purge all related tags
717
+ add_action($event, array( $this, 'purge_post' ), 10, 2) ;
718
+ }
719
+
720
+ add_action('wp_update_comment_count',
721
+ array($this, 'purge_feeds'));
722
+
723
+ add_action('shutdown', array($this, 'send_headers'), 0);
724
+ // purge_single_post will only purge that post by tag
725
+ add_action('lscwp_purge_single_post', array($this, 'purge_single_post'));
726
+
727
+ // register recent posts widget tag before theme renders it to make it work
728
+ add_filter('widget_posts_args', array($this, 'register_tag_widget_recent_posts'));
729
+
730
+ // TODO: private purge?
731
+ // TODO: purge by category, tag?
732
+ }
733
+
734
+ /**
735
+ * Register purge tag for pages with recent posts widget
736
+ * of the plugin.
737
+ *
738
+ * @since 1.0.15
739
+ * @access public
740
+ * @param array $params [wordpress params for widget_posts_args]
741
+ */
742
+ public function register_tag_widget_recent_posts($params){
743
+ LiteSpeed_Cache_Tags::add_cache_tag(LiteSpeed_Cache_Tags::TYPE_PAGES_WITH_RECENT_POSTS);
744
+ return $params;
745
+ }
746
+
747
+ /**
748
+ * Adds the actions used for setting up cookies on log in/out.
749
+ *
750
+ * Also checks if the database matches the rewrite rule.
751
+ *
752
+ * @since 1.0.4
753
+ * @access private
754
+ * @return boolean True if cookies are bad, false otherwise.
755
+ */
756
+ private function setup_cookies()
757
+ {
758
+ $ret = false;
759
+ // Set vary cookie for logging in user, unset for logging out.
760
+ add_action('set_logged_in_cookie', array( $this, 'set_user_cookie'), 10, 5);
761
+ add_action('clear_auth_cookie', array( $this, 'set_user_cookie'), 10, 5);
762
+
763
+ if (!$this->config->get_option(LiteSpeed_Cache_Config::OPID_CACHE_COMMENTERS)) {
764
+ // Set vary cookie for commenter.
765
+ add_action('set_comment_cookies', array( $this, 'set_comment_cookie'), 10, 2);
766
+ }
767
+ if (is_multisite()) {
768
+ $options = $this->get_config()->get_site_options();
769
+ if (is_array($options)) {
770
+ $db_cookie = $options[
771
+ LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE];
772
+ }
773
+ }
774
+ else {
775
+ $db_cookie = $this->get_config()
776
+ ->get_option(LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE);
777
+ }
778
+
779
+ if (!isset($_SERVER[self::LSCOOKIE_VARY_NAME])) {
780
+ if (!empty($db_cookie)) {
781
+ $ret = true;
782
+ if (is_multisite() ? is_network_admin() : is_admin()) {
783
+ LiteSpeed_Cache_Admin_Display::show_error_cookie();
784
+ }
785
+ }
786
+ $this->current_vary = self::LSCOOKIE_DEFAULT_VARY;
787
+ return $ret;
788
+ }
789
+ elseif (empty($db_cookie)) {
790
+ $this->current_vary = self::LSCOOKIE_DEFAULT_VARY;
791
+ return $ret;
792
+ }
793
+ // beyond this point, need to do more processing.
794
+ $vary_arr = explode(',', $_SERVER[self::LSCOOKIE_VARY_NAME]);
795
+
796
+ if (in_array($db_cookie, $vary_arr)) {
797
+ $this->current_vary = $db_cookie;
798
+ return $ret;
799
+ }
800
+ elseif ((is_multisite() ? is_network_admin() : is_admin())) {
801
+ LiteSpeed_Cache_Admin_Display::show_error_cookie();
802
+ }
803
+ $ret = true;
804
+ $this->current_vary = self::LSCOOKIE_DEFAULT_VARY;
805
+ return $ret;
806
+ }
807
+
808
+ /**
809
+ * Do the action of setting the vary cookie.
810
+ *
811
+ * Since we are using bitwise operations, if the resulting cookie has
812
+ * value zero, we need to set the expire time appropriately.
813
+ *
814
+ * @since 1.0.4
815
+ * @access private
816
+ * @param integer $update_val The value to update.
817
+ * @param integer $expire Expire time.
818
+ * @param boolean $ssl True if ssl connection, false otherwise.
819
+ * @param boolean $httponly True if the cookie is for http requests only, false otherwise.
820
+ */
821
+ private function do_set_cookie($update_val, $expire, $ssl = false, $httponly = false)
822
+ {
823
+ $curval = 0;
824
+ if (isset($_COOKIE[$this->current_vary]))
825
+ {
826
+ $curval = intval($_COOKIE[$this->current_vary]);
827
+ }
828
+
829
+ // not, remove from curval.
830
+ if ($update_val < 0) {
831
+ // If cookie will no longer exist, delete the cookie.
832
+ if (($curval == 0) || ($curval == (~$update_val))) {
833
+ // Use a year in case of bad local clock.
834
+ $expire = time() - 31536001;
835
+ }
836
+ $curval &= $update_val;
837
+ }
838
+ else { // add to curval.
839
+ $curval |= $update_val;
840
+ }
841
+ setcookie($this->current_vary, $curval, $expire, COOKIEPATH,
842
+ COOKIE_DOMAIN, $ssl, $httponly);
843
+ }
844
+
845
+ /**
846
+ * Sets cookie denoting logged in/logged out.
847
+ *
848
+ * This will notify the server on next page request not to serve from cache.
849
+ *
850
+ * @since 1.0.1
851
+ * @access public
852
+ * @param mixed $logged_in_cookie
853
+ * @param string $expire Expire time.
854
+ * @param integer $expiration Expire time.
855
+ * @param integer $user_id The user's id.
856
+ * @param string $action Whether the user is logging in or logging out.
857
+ */
858
+ public function set_user_cookie($logged_in_cookie = false, $expire = ' ',
859
+ $expiration = 0, $user_id = 0, $action = 'logged_out')
860
+ {
861
+ if ($action == 'logged_in') {
862
+ $this->do_set_cookie(self::LSCOOKIE_VARY_LOGGED_IN, $expire, is_ssl(), true);
863
+ }
864
+ else {
865
+ $this->do_set_cookie(~self::LSCOOKIE_VARY_LOGGED_IN,
866
+ time() + apply_filters( 'comment_cookie_lifetime', 30000000 ));
867
+ }
868
+ }
869
+
870
+ /**
871
+ * Sets a cookie that marks the user as a commenter.
872
+ *
873
+ * This will notify the server on next page request not to serve
874
+ * from cache if that setting is enabled.
875
+ *
876
+ * @since 1.0.4
877
+ * @access public
878
+ * @param mixed $comment Comment object
879
+ * @param mixed $user The visiting user object.
880
+ */
881
+ public function set_comment_cookie($comment, $user)
882
+ {
883
+ if ( $user->exists() ) {
884
+ return;
885
+ }
886
+ $comment_cookie_lifetime = time() + apply_filters( 'comment_cookie_lifetime', 30000000 );
887
+ $this->do_set_cookie(self::LSCOOKIE_VARY_COMMENTER, $comment_cookie_lifetime);
888
+ }
889
+
890
+ /**
891
+ * Adds new purge tags to the array of purge tags for the request.
892
+ *
893
+ * @since 1.0.1
894
+ * @access private
895
+ * @param mixed $tags Tags to add to the list.
896
+ * @param boolean $is_public Whether to add public or private purge tags.
897
+ */
898
+ private function add_purge_tags($tags, $is_public = true)
899
+ {
900
+ //TODO: implement private tag add
901
+ if (is_array($tags)) {
902
+ $this->pub_purge_tags = array_merge($this->pub_purge_tags, $tags);
903
+ }
904
+ else {
905
+ $this->pub_purge_tags[] = $tags;
906
+ }
907
+ $this->pub_purge_tags = array_unique($this->pub_purge_tags);
908
+ }
909
+
910
+ /**
911
+ * Alerts LiteSpeed Web Server to purge all pages.
912
+ *
913
+ * For multisite installs, if this is called by a site admin (not network admin),
914
+ * it will only purge all posts associated with that site.
915
+ *
916
+ * @since 1.0.0
917
+ * @access public
918
+ */
919
+ public function purge_all()
920
+ {
921
+ $this->add_purge_tags('*');
922
+ }
923
+
924
+ /**
925
+ * Alerts LiteSpeed Web Server to purge the front page.
926
+ *
927
+ * @since 1.0.3
928
+ * @access public
929
+ */
930
+ public function purge_front()
931
+ {
932
+ $this->add_purge_tags(LiteSpeed_Cache_Tags::TYPE_FRONTPAGE);
933
+ }
934
+
935
+ /**
936
+ * Alerts LiteSpeed Web Server to purge pages.
937
+ *
938
+ * @since 1.0.15
939
+ * @access public
940
+ */
941
+ public function purge_pages()
942
+ {
943
+ $this->add_purge_tags(LiteSpeed_Cache_Tags::TYPE_PAGES);
944
+ }
945
+
946
+ /**
947
+ * Alerts LiteSpeed Web Server to purge error pages.
948
+ *
949
+ * @since 1.0.14
950
+ * @access public
951
+ */
952
+ public function purge_errors()
953
+ {
954
+ $this->add_purge_tags(LiteSpeed_Cache_Tags::TYPE_ERROR);
955
+ if (!isset($_POST[LiteSpeed_Cache_Config::OPTION_NAME])) {
956
+ return;
957
+ }
958
+ $input = $_POST[LiteSpeed_Cache_Config::OPTION_NAME];
959
+ if (isset($input['include_403'])) {
960
+ $this->add_purge_tags(LiteSpeed_Cache_Tags::TYPE_ERROR . '403');
961
+ }
962
+ if (isset($input['include_404'])) {
963
+ $this->add_purge_tags(LiteSpeed_Cache_Tags::TYPE_ERROR . '404');
964
+ }
965
+ if (isset($input['include_500'])) {
966
+ $this->add_purge_tags(LiteSpeed_Cache_Tags::TYPE_ERROR . '500');
967
+ }
968
+ }
969
+
970
+ /**
971
+ * The purge by callback used to purge a list of tags.
972
+ *
973
+ * @access public
974
+ * @since 1.0.15
975
+ * @param string $tags A comma delimited list of tags.
976
+ */
977
+ public function purgeby_cb($tags)
978
+ {
979
+ $tag_arr = explode(',', $tags);
980
+ self::add_purge_tags($tag_arr);
981
+ }
982
+
983
+ /**
984
+ * Callback to add purge tags if admin selects to purge selected category pages.
985
+ *
986
+ * @since 1.0.7
987
+ * @access public
988
+ * @param string $value The category slug.
989
+ * @param string $key Unused.
990
+ */
991
+ public function purgeby_cat_cb($value, $key)
992
+ {
993
+ $val = trim($value);
994
+ if (empty($val)) {
995
+ return;
996
+ }
997
+ if (preg_match('/^[a-zA-Z0-9-]+$/', $val) == 0) {
998
+ LiteSpeed_Cache_Admin_Error::add_error(
999
+ LiteSpeed_Cache_Admin_Error::E_PURGEBY_CAT_INV
1000
+ );
1001
+ return;
1002
+ }
1003
+ $cat = get_category_by_slug($val);
1004
+ if ($cat == false) {
1005
+ LiteSpeed_Cache_Admin_Error::add_error(
1006
+ LiteSpeed_Cache_Admin_Error::E_PURGEBY_CAT_DNE, $val);
1007
+ return;
1008
+ }
1009
+
1010
+ LiteSpeed_Cache_Admin_Display::get_instance()->add_notice(
1011
+ LiteSpeed_Cache_Admin_Display::NOTICE_GREEN,
1012
+ sprintf(__('Purge category %s', 'litespeed-cache'), $val));
1013
+
1014
+ LiteSpeed_Cache_Tags::add_purge_tag(
1015
+ LiteSpeed_Cache_Tags::TYPE_ARCHIVE_TERM . $cat->term_id);
1016
+ }
1017
+
1018
+ /**
1019
+ * Callback to add purge tags if admin selects to purge selected post IDs.
1020
+ *
1021
+ * @since 1.0.7
1022
+ * @access public
1023
+ * @param string $value The post ID.
1024
+ * @param string $key Unused.
1025
+ */
1026
+ public function purgeby_pid_cb($value, $key)
1027
+ {
1028
+ $val = trim($value);
1029
+ if (empty($val)) {
1030
+ return;
1031
+ }
1032
+ if (!is_numeric($val)) {
1033
+ LiteSpeed_Cache_Admin_Error::add_error(
1034
+ LiteSpeed_Cache_Admin_Error::E_PURGEBY_PID_NUM, $val
1035
+ );
1036
+ return;
1037
+ }
1038
+ elseif (get_post_status($val) !== 'publish') {
1039
+ LiteSpeed_Cache_Admin_Error::add_error(
1040
+ LiteSpeed_Cache_Admin_Error::E_PURGEBY_PID_DNE, $val
1041
+ );
1042
+ return;
1043
+ }
1044
+ LiteSpeed_Cache_Admin_Display::get_instance()->add_notice(
1045
+ LiteSpeed_Cache_Admin_Display::NOTICE_GREEN,
1046
+ sprintf(__('Purge Post ID %s', 'litespeed-cache'), $val));
1047
+
1048
+ LiteSpeed_Cache_Tags::add_purge_tag(
1049
+ LiteSpeed_Cache_Tags::TYPE_POST . $val);
1050
+ }
1051
+
1052
+ /**
1053
+ * Callback to add purge tags if admin selects to purge selected tag pages.
1054
+ *
1055
+ * @since 1.0.7
1056
+ * @access public
1057
+ * @param string $value The tag slug.
1058
+ * @param string $key Unused.
1059
+ */
1060
+ public function purgeby_tag_cb($value, $key)
1061
+ {
1062
+ $val = trim($value);
1063
+ if (empty($val)) {
1064
+ return;
1065
+ }
1066
+ if (preg_match('/^[a-zA-Z0-9-]+$/', $val) == 0) {
1067
+ LiteSpeed_Cache_Admin_Error::add_error(
1068
+ LiteSpeed_Cache_Admin_Error::E_PURGEBY_TAG_INV
1069
+ );
1070
+ return;
1071
+ }
1072
+ $term = get_term_by('slug', $val, 'post_tag');
1073
+ if ($term == 0) {
1074
+ LiteSpeed_Cache_Admin_Error::add_error(
1075
+ LiteSpeed_Cache_Admin_Error::E_PURGEBY_TAG_DNE, $val
1076
+ );
1077
+ return;
1078
+ }
1079
+
1080
+ LiteSpeed_Cache_Admin_Display::get_instance()->add_notice(
1081
+ LiteSpeed_Cache_Admin_Display::NOTICE_GREEN,
1082
+ sprintf(__('Purge tag %s', 'litespeed-cache'), $val));
1083
+
1084
+ LiteSpeed_Cache_Tags::add_purge_tag(
1085
+ LiteSpeed_Cache_Tags::TYPE_ARCHIVE_TERM . $term->term_id);
1086
+ }
1087
+
1088
+ /**
1089
+ * Callback to add purge tags if admin selects to purge selected urls.
1090
+ *
1091
+ * @since 1.0.7
1092
+ * @access public
1093
+ * @param string $value A url to purge.
1094
+ * @param string $key Unused.
1095
+ */
1096
+ public function purgeby_url_cb($value, $key)
1097
+ {
1098
+ $val = trim($value);
1099
+ if (empty($val)) {
1100
+ return;
1101
+ }
1102
+
1103
+ if (strpos($val, '<') !== false) {
1104
+ LiteSpeed_Cache_Admin_Error::add_error(
1105
+ LiteSpeed_Cache_Admin_Error::E_PURGEBY_URL_BAD
1106
+ );
1107
+ return;
1108
+ }
1109
+
1110
+ $hash = self::get_uri_hash($val);
1111
+
1112
+ if ($hash === false) {
1113
+ LiteSpeed_Cache_Admin_Error::add_error(
1114
+ LiteSpeed_Cache_Admin_Error::E_PURGEBY_URL_INV,
1115
+ $val
1116
+ );
1117
+ return;
1118
+ }
1119
+
1120
+ LiteSpeed_Cache_Admin_Display::get_instance()->add_notice(
1121
+ LiteSpeed_Cache_Admin_Display::NOTICE_GREEN,
1122
+ sprintf(__('Purge url %s', 'litespeed-cache'), $val));
1123
+
1124
+ LiteSpeed_Cache_Tags::add_purge_tag(
1125
+ LiteSpeed_Cache_Tags::TYPE_URL . $hash);
1126
+ return;
1127
+ }
1128
+
1129
+ /**
1130
+ * Purge a list of pages when selected by admin. This method will
1131
+ * look at the post arguments to determine how and what to purge.
1132
+ *
1133
+ * @since 1.0.7
1134
+ * @access public
1135
+ */
1136
+ public function purge_list()
1137
+ {
1138
+ if (!isset($_POST[LiteSpeed_Cache_Config::OPTION_NAME])) {
1139
+ LiteSpeed_Cache_Admin_Error::add_error(
1140
+ LiteSpeed_Cache_Admin_Error::E_PURGE_FORM
1141
+ );
1142
+ return;
1143
+ }
1144
+ $conf = $_POST[LiteSpeed_Cache_Config::OPTION_NAME];
1145
+ $sel = $conf[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT];
1146
+ $list_buf = $conf[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_LIST];
1147
+ if (empty($list_buf)) {
1148
+ LiteSpeed_Cache_Admin_Error::add_error(
1149
+ LiteSpeed_Cache_Admin_Error::E_PURGEBY_EMPTY
1150
+ );
1151
+ return;
1152
+ }
1153
+ $list = explode("\n", $list_buf);
1154
+ switch($sel) {
1155
+ case LiteSpeed_Cache_Admin_Display::PURGEBY_CAT:
1156
+ $cb = 'purgeby_cat_cb';
1157
+ break;
1158
+ case LiteSpeed_Cache_Admin_Display::PURGEBY_PID:
1159
+ $cb = 'purgeby_pid_cb';
1160
+ break;
1161
+ case LiteSpeed_Cache_Admin_Display::PURGEBY_TAG:
1162
+ $cb = 'purgeby_tag_cb';
1163
+ break;
1164
+ case LiteSpeed_Cache_Admin_Display::PURGEBY_URL:
1165
+ $cb = 'purgeby_url_cb';
1166
+ break;
1167
+ default:
1168
+ LiteSpeed_Cache_Admin_Error::add_error(
1169
+ LiteSpeed_Cache_Admin_Error::E_PURGEBY_BAD
1170
+ );
1171
+ return;
1172
+ }
1173
+ array_walk($list, Array($this, $cb));
1174
+ }
1175
+
1176
+ /**
1177
+ * Purges a post on update.
1178
+ *
1179
+ * This function will get the relevant purge tags to add to the response
1180
+ * as well.
1181
+ *
1182
+ * @since 1.0.0
1183
+ * @access public
1184
+ * @param integer $id The post id to purge.
1185
+ */
1186
+ public function purge_post( $id )
1187
+ {
1188
+ $post_id = intval($id);
1189
+ // ignore the status we don't care
1190
+ if ( ! in_array(get_post_status($post_id), array( 'publish', 'trash', 'private' )) ) {
1191
+ return ;
1192
+ }
1193
+
1194
+ $purge_tags = $this->get_purge_tags($post_id) ;
1195
+ if ( empty($purge_tags) ) {
1196
+ return;
1197
+ }
1198
+ if ( in_array('*', $purge_tags) ) {
1199
+ $this->add_purge_tags('*');
1200
+ }
1201
+ else {
1202
+ $this->add_purge_tags($purge_tags);
1203
+ }
1204
+ $this->cachectrl |= self::CACHECTRL_STALE;
1205
+ // $this->send_purge_headers();
1206
+ }
1207
+
1208
+ /**
1209
+ * Purge a single post.
1210
+ *
1211
+ * If a third party plugin needs to purge a single post, it can send
1212
+ * a purge tag using this function.
1213
+ *
1214
+ * @since 1.0.1
1215
+ * @access public
1216
+ * @param integer $id The post id to purge.
1217
+ */
1218
+ public function purge_single_post($id)
1219
+ {
1220
+ $post_id = intval($id);
1221
+ if ( ! in_array(get_post_status($post_id), array( 'publish', 'trash' )) ) {
1222
+ return ;
1223
+ }
1224
+ $this->add_purge_tags(LiteSpeed_Cache_Tags::TYPE_POST . $post_id);
1225
+ // $this->send_purge_headers();
1226
+ }
1227
+
1228
+ /**
1229
+ * Purges feeds on comment count update.
1230
+ *
1231
+ * @since 1.0.9
1232
+ * @access public
1233
+ */
1234
+ public function purge_feeds()
1235
+ {
1236
+ if ($this->config->get_option(LiteSpeed_Cache_Config::OPID_FEED_TTL) > 0) {
1237
+ $this->add_purge_tags(LiteSpeed_Cache_Tags::TYPE_FEED);
1238
+ }
1239
+ }
1240
+
1241
+ /**
1242
+ * Checks if the user is logged in. If the user is logged in, does an
1243
+ * additional check to make sure it's using the correct login cookie.
1244
+ *
1245
+ * @return boolean True if logged in, false otherwise.
1246
+ */
1247
+ private function check_user_logged_in()
1248
+ {
1249
+ if (!is_user_logged_in()) {
1250
+ // If the cookie is set, unset it.
1251
+ if ((isset($_COOKIE)) && (isset($_COOKIE[$this->current_vary]))
1252
+ && (intval($_COOKIE[$this->current_vary])
1253
+ & self::LSCOOKIE_VARY_LOGGED_IN)) {
1254
+ $this->do_set_cookie(~self::LSCOOKIE_VARY_LOGGED_IN,
1255
+ time() + apply_filters( 'comment_cookie_lifetime', 30000000 ));
1256
+ $_COOKIE[$this->current_vary] &= ~self::LSCOOKIE_VARY_LOGGED_IN;
1257
+ }
1258
+ return false;
1259
+ }
1260
+ elseif (!isset($_COOKIE[$this->current_vary])) {
1261
+ $this->do_set_cookie(self::LSCOOKIE_VARY_LOGGED_IN,
1262
+ time() + 2 * DAY_IN_SECONDS, is_ssl(), true);
1263
+ }
1264
+ return true;
1265
+ }
1266
+
1267
+ /**
1268
+ * Check if the user accessing the page has the commenter cookie.
1269
+ *
1270
+ * If the user does not want to cache commenters, just check if user is commenter.
1271
+ * Otherwise if the vary cookie is set, unset it. This is so that when
1272
+ * the page is cached, the page will appear as if the user was a normal user.
1273
+ * Normal user is defined as not a logged in user and not a commenter.
1274
+ *
1275
+ * @since 1.0.4
1276
+ * @access private
1277
+ * @return boolean True if do not cache for commenters and user is a commenter. False otherwise.
1278
+ */
1279
+ private function check_cookies()
1280
+ {
1281
+ if (!$this->config->get_option(LiteSpeed_Cache_Config::OPID_CACHE_COMMENTERS))
1282
+ {
1283
+ // If do not cache commenters, check cookie for commenter value.
1284
+ if ((isset($_COOKIE[$this->current_vary]))
1285
+ && ($_COOKIE[$this->current_vary] & self::LSCOOKIE_VARY_COMMENTER)) {
1286
+ return true;
1287
+ }
1288
+ // If wp commenter cookie exists, need to set vary and do not cache.
1289
+ foreach($_COOKIE as $cookie_name => $cookie_value) {
1290
+ if ((strlen($cookie_name) >= 15)
1291
+ && (strncmp($cookie_name, 'comment_author_', 15) == 0)) {
1292
+ $user = wp_get_current_user();
1293
+ $this->set_comment_cookie(NULL, $user);
1294
+ return true;
1295
+ }
1296
+ }
1297
+ return false;
1298
+ }
1299
+
1300
+ // If vary cookie is set, need to change the value.
1301
+ if (isset($_COOKIE[$this->current_vary])) {
1302
+ $this->do_set_cookie(~self::LSCOOKIE_VARY_COMMENTER, 14 * DAY_IN_SECONDS);
1303
+ unset($_COOKIE[$this->current_vary]);
1304
+ }
1305
+
1306
+ // If cache commenters, unset comment cookies for caching.
1307
+ foreach($_COOKIE as $cookie_name => $cookie_value) {
1308
+ if ((strlen($cookie_name) >= 15)
1309
+ && (strncmp($cookie_name, 'comment_author_', 15) == 0)) {
1310
+ unset($_COOKIE[$cookie_name]);
1311
+ }
1312
+ }
1313
+ return false;
1314
+ }
1315
+
1316
+ /**
1317
+ * Check admin configuration to see if the uri accessed is excluded from cache.
1318
+ *
1319
+ * @since 1.0.1
1320
+ * @access private
1321
+ * @param array $excludes_list List of excluded URIs
1322
+ * @return boolean True if excluded, false otherwise.
1323
+ */
1324
+ private function is_uri_excluded($excludes_list)
1325
+ {
1326
+ $uri = esc_url($_SERVER["REQUEST_URI"]);
1327
+ $uri_len = strlen( $uri ) ;
1328
+ if (is_multisite()) {
1329
+ $blog_details = get_blog_details(get_current_blog_id());
1330
+ $blog_path = $blog_details->path;
1331
+ $blog_path_len = strlen($blog_path);
1332
+ if (($uri_len >= $blog_path_len)
1333
+ && (strncmp($uri, $blog_path, $blog_path_len) == 0)) {
1334
+ $uri = substr($uri, $blog_path_len - 1);
1335
+ $uri_len = strlen( $uri ) ;
1336
+ }
1337
+ }
1338
+ foreach( $excludes_list as $excludes_rule )
1339
+ {
1340
+ $rule_len = strlen( $excludes_rule );
1341
+ if (($excludes_rule[$rule_len - 1] == '$')) {
1342
+ if ($uri_len != (--$rule_len)) {
1343
+ continue;
1344
+ }
1345
+ }
1346
+ elseif ( $uri_len < $rule_len ) {
1347
+ continue;
1348
+ }
1349
+
1350
+ if ( strncmp( $uri, $excludes_rule, $rule_len ) == 0 ){
1351
+ return true ;
1352
+ }
1353
+ }
1354
+ return false;
1355
+ }
1356
+
1357
+ /**
1358
+ * Check if a page is cacheable.
1359
+ *
1360
+ * This will check what we consider not cacheable as well as what
1361
+ * third party plugins consider not cacheable.
1362
+ *
1363
+ * @since 1.0.0
1364
+ * @access private
1365
+ * @return boolean True if cacheable, false otherwise.
1366
+ */
1367
+ private function is_cacheable()
1368
+ {
1369
+ // logged_in users already excluded, no hook added
1370
+ $method = $_SERVER["REQUEST_METHOD"] ;
1371
+ $conf = $this->config;
1372
+
1373
+ if ( 'GET' !== $method ) {
1374
+ return $this->no_cache_for('not GET method') ;
1375
+ }
1376
+
1377
+ if (($conf->get_option(LiteSpeed_Cache_Config::OPID_FEED_TTL) === 0)
1378
+ && (is_feed())) {
1379
+ return $this->no_cache_for('feed') ;
1380
+ }
1381
+
1382
+ if ( is_trackback() ) {
1383
+ return $this->no_cache_for('trackback') ;
1384
+ }
1385
+
1386
+ if (($conf->get_option(LiteSpeed_Cache_Config::OPID_404_TTL) === 0)
1387
+ && (is_404())) {
1388
+ return $this->no_cache_for('404 pages') ;
1389
+ }
1390
+
1391
+ if ( is_search() ) {
1392
+ return $this->no_cache_for('search') ;
1393
+ }
1394
+
1395
+ // if ( !defined('WP_USE_THEMES') || !WP_USE_THEMES ) {
1396
+ // return $this->no_cache_for('no theme used') ;
1397
+ // }
1398
+
1399
+ $cacheable = apply_filters('litespeed_cache_is_cacheable', true);
1400
+ if (!$cacheable) {
1401
+ global $wp_filter;
1402
+ if ((!defined('LSCWP_LOG'))
1403
+ || (empty($wp_filter['litespeed_cache_is_cacheable']))) {
1404
+ return $this->no_cache_for(
1405
+ 'Third Party Plugin determined not cacheable.');
1406
+ }
1407
+ $funcs = array();
1408
+ foreach ($wp_filter['litespeed_cache_is_cacheable'] as $hook_level) {
1409
+ foreach ($hook_level as $func=>$params) {
1410
+ $funcs[] = $func;
1411
+ }
1412
+ }
1413
+ $this->no_cache_for('One of the following functions '
1414
+ . "determined that this page is not cacheable:\n\t\t"
1415
+ . implode("\n\t\t", $funcs));
1416
+ return false;
1417
+ }
1418
+
1419
+ $excludes = $conf->get_option(LiteSpeed_Cache_Config::OPID_EXCLUDES_URI);
1420
+ if (( ! empty($excludes))
1421
+ && ( $this->is_uri_excluded(explode("\n", $excludes))))
1422
+ {
1423
+ return $this->no_cache_for('Admin configured URI Do not cache: '
1424
+ . $_SERVER['REQUEST_URI']);
1425
+ }
1426
+
1427
+ $excludes = $conf->get_option(LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT);
1428
+ if (( ! empty($excludes))
1429
+ && (has_category(explode(',', $excludes)))) {
1430
+ return $this->no_cache_for('Admin configured Category Do not cache.');
1431
+ }
1432
+
1433
+ $excludes = $conf->get_option(LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG);
1434
+ if (( ! empty($excludes))
1435
+ && (has_tag(explode(',', $excludes)))) {
1436
+ return $this->no_cache_for('Admin configured Tag Do not cache.');
1437
+ }
1438
+
1439
+ $excludes = $conf->get_option(LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES);
1440
+ if ((!empty($excludes)) && (!empty($_COOKIE))) {
1441
+ $exclude_list = explode('|', $excludes);
1442
+
1443
+ foreach( $_COOKIE as $key=>$val) {
1444
+ if (in_array($key, $exclude_list)) {
1445
+ return $this->no_cache_for('Admin configured Cookie Do not cache.');
1446
+ }
1447
+ }
1448
+ }
1449
+
1450
+ $excludes = $conf->get_option(LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS);
1451
+ if ((!empty($excludes)) && (isset($_SERVER['HTTP_USER_AGENT']))) {
1452
+ $pattern = '/' . $excludes . '/';
1453
+ $nummatches = preg_match($pattern, $_SERVER['HTTP_USER_AGENT']);
1454
+ if ($nummatches) {
1455
+ return $this->no_cache_for('Admin configured User Agent Do not cache.');
1456
+ }
1457
+ }
1458
+
1459
+ return true;
1460
+ }
1461
+
1462
+ /**
1463
+ * Check if the page returns 403 and 500 errors.
1464
+ *
1465
+ * @since 1.0.13.1
1466
+ * @access public
1467
+ * @param $header, $code.
1468
+ * @return $eeror_status.
1469
+ */
1470
+ public function check_error_codes($header, $code)
1471
+ {
1472
+ $ttl_403 = $this->config->get_option(LiteSpeed_Cache_Config::OPID_403_TTL);
1473
+ $ttl_500 = $this->config->get_option(LiteSpeed_Cache_Config::OPID_500_TTL);
1474
+ if ($code == 403) {
1475
+ if ($ttl_403 <= 30) {
1476
+ LiteSpeed_Cache_Tags::set_noncacheable();
1477
+ }
1478
+ else {
1479
+ $this->error_status = $code;
1480
+ }
1481
+ }
1482
+ elseif ($code >= 500 && $code < 600) {
1483
+ if ($ttl_500 <= 30) {
1484
+ LiteSpeed_Cache_Tags::set_noncacheable();
1485
+ }
1486
+ }
1487
+ elseif ($code > 400) {
1488
+ $this->error_status = $code;
1489
+ }
1490
+ return $this->error_status;
1491
+ }
1492
+
1493
+ /**
1494
+ * Write a debug message for if a page is not cacheable.
1495
+ *
1496
+ * @since 1.0.0
1497
+ * @access private
1498
+ * @param string $reason An explanation for why the page is not cacheable.
1499
+ * @return boolean Return false.
1500
+ */
1501
+ private function no_cache_for( $reason )
1502
+ {
1503
+ if (defined('LSCWP_LOG')) {
1504
+ $this->debug_log('Do not cache - ' . $reason);
1505
+ }
1506
+ return false ;
1507
+ }
1508
+
1509
+ /**
1510
+ * Check if the post is cacheable. If so, set the cacheable member variable.
1511
+ *
1512
+ * @since 1.0.0
1513
+ * @access public
1514
+ */
1515
+ public function check_cacheable()
1516
+ {
1517
+ if ((LiteSpeed_Cache_Tags::is_noncacheable() == false)
1518
+ && ($this->is_cacheable())) {
1519
+ $this->cachectrl = self::CACHECTRL_CACHE;
1520
+ }
1521
+ }
1522
+
1523
+ /**
1524
+ * Check if the login page is cacheable.
1525
+ * If not, unset the cacheable member variable.
1526
+ *
1527
+ * @since 1.0.0
1528
+ * @access public
1529
+ */
1530
+ public function check_login_cacheable()
1531
+ {
1532
+ if ($this->config->get_option(LiteSpeed_Cache_Config::OPID_CACHE_LOGIN)
1533
+ === false) {
1534
+ return;
1535
+ }
1536
+ $this->check_cacheable();
1537
+ if ($this->cachectrl !== self::CACHECTRL_CACHE) {
1538
+ return;
1539
+ }
1540
+ if (!empty($_GET)) {
1541
+
1542
+ if (defined('LSCWP_LOG')) {
1543
+ $this->no_cache_for('Not a get request');
1544
+ }
1545
+ $this->cachectrl = self::CACHECTRL_NOCACHE;
1546
+ return;
1547
+ }
1548
+
1549
+ LiteSpeed_Cache_Tags::add_cache_tag(LiteSpeed_Cache_Tags::TYPE_LOGIN);
1550
+
1551
+ $list = headers_list();
1552
+ if (empty($list)) {
1553
+ return;
1554
+ }
1555
+ foreach ($list as $hdr) {
1556
+ if (strncasecmp($hdr, 'set-cookie:', 11) == 0) {
1557
+ $cookie = substr($hdr, 12);
1558
+ @header('lsc-cookie: ' . $cookie, false);
1559
+ }
1560
+ }
1561
+ return;
1562
+ }
1563
+
1564
+ /**
1565
+ * After a LSCWP_CTRL action, need to redirect back to the same page
1566
+ * without the nonce and action in the query string.
1567
+ *
1568
+ * @since 1.0.12
1569
+ * @access private
1570
+ * @global string $pagenow
1571
+ */
1572
+ private function admin_ctrl_redirect()
1573
+ {
1574
+ global $pagenow;
1575
+ $qs = '';
1576
+
1577
+ if (!empty($_GET)) {
1578
+ if (isset($_GET['LSCWP_CTRL'])) {
1579
+ unset($_GET['LSCWP_CTRL']);
1580
+ }
1581
+ if (isset($_GET['_wpnonce'])) {
1582
+ unset($_GET['_wpnonce']);
1583
+ }
1584
+ if (!empty($_GET)) {
1585
+ $qs = '?' . http_build_query($_GET);
1586
+ }
1587
+ }
1588
+ if (is_network_admin()) {
1589
+ $url = network_admin_url($pagenow . $qs);
1590
+ }
1591
+ else {
1592
+ $url = admin_url($pagenow . $qs);
1593
+ }
1594
+ wp_redirect($url);
1595
+ exit();
1596
+ }
1597
+
1598
+ /**
1599
+ * On admin cache actions, verify the nonce to make sure the request is valid.
1600
+ *
1601
+ * @access private
1602
+ * @since 1.0.15
1603
+ * @param string $nonce The nonce used by the request.
1604
+ * @return bool True if the nonce is valid, false otherwise.
1605
+ */
1606
+ private static function verify_admin_nonce($nonce)
1607
+ {
1608
+ $valid_nonces = array(
1609
+ self::ADMINNONCE_PURGEALL,
1610
+ self::ADMINNONCE_PURGENETWORKALL,
1611
+ self::ADMINNONCE_PURGEBY,
1612
+ self::ADMINNONCE_DISMISS
1613
+ );
1614
+
1615
+ foreach ($valid_nonces as $valid_nonce) {
1616
+ if (wp_verify_nonce($nonce, $valid_nonce)) {
1617
+ return true;
1618
+ }
1619
+ }
1620
+ return false;
1621
+ }
1622
+
1623
+ /**
1624
+ * Check the query string to see if it contains a LSCWP_CTRL.
1625
+ * Also will compare IPs to see if it is a valid command.
1626
+ *
1627
+ * @since 1.0.7
1628
+ * @access public
1629
+ */
1630
+ public function check_admin_ip()
1631
+ {
1632
+ // Not set, ignore.
1633
+ if (!isset($_GET[self::ADMINQS_KEY])) {
1634
+ return;
1635
+ }
1636
+ $action = $_GET[self::ADMINQS_KEY];
1637
+ if ((is_admin()) || (is_network_admin())) {
1638
+ if ((empty($_GET)) || (empty($_GET['_wpnonce']))
1639
+ || (self::verify_admin_nonce($_GET['_wpnonce']) === false)) {
1640
+ return;
1641
+ }
1642
+ }
1643
+ elseif (!defined('DOING_AJAX')) {
1644
+ $ips = $this->config->get_option(LiteSpeed_Cache_Config::OPID_ADMIN_IPS);
1645
+
1646
+ if (strpos($ips, $_SERVER['REMOTE_ADDR']) === false) {
1647
+ if (defined('LSCWP_LOG')) {
1648
+ $this->no_cache_for('LSCWP_CTRL query string - did not match admin IP');
1649
+ }
1650
+ $this->cachectrl = self::CACHECTRL_NOCACHE;
1651
+ return;
1652
+ }
1653
+ }
1654
+
1655
+ if (defined('LSCWP_LOG')) {
1656
+ self::debug_log('LSCWP_CTRL query string action is ' . $action);
1657
+ }
1658
+
1659
+ switch ($action[0]) {
1660
+ case 'P':
1661
+ if ($action == self::ADMINQS_PURGE) {
1662
+ $this->cachectrl = self::CACHECTRL_PURGE;
1663
+ }
1664
+ elseif ($action == self::ADMINQS_PURGESINGLE) {
1665
+ $this->cachectrl = self::CACHECTRL_PURGESINGLE;
1666
+ }
1667
+ elseif ($action == self::ADMINQS_PURGEALL) {
1668
+ $this->cachectrl = self::CACHECTRL_NOCACHE;
1669
+ $this->purge_all();
1670
+ }
1671
+ elseif (($action == self::ADMINQS_PURGEBY)
1672
+ && (isset($_GET['purge_tags']))) {
1673
+ $this->cachectrl = self::CACHECTRL_NOCACHE;
1674
+ $this->purgeby_cb($_GET['purge_tags']);
1675
+ }
1676
+ else {
1677
+ break;
1678
+ }
1679
+ if (((!is_admin()) && (!is_network_admin()))
1680
+ || ((defined('DOING_AJAX') && DOING_AJAX))) {
1681
+ return;
1682
+ }
1683
+ $this->admin_ctrl_redirect();
1684
+ return;
1685
+ case 'S':
1686
+ if ($action == self::ADMINQS_SHOWHEADERS) {
1687
+ $this->cachectrl |= self::CACHECTRL_SHOWHEADERS;
1688
+ return;
1689
+ }
1690
+ break;
1691
+ case 'D':
1692
+ if ($action == self::ADMINQS_DISMISS) {
1693
+ delete_transient(self::WHM_TRANSIENT);
1694
+ $this->admin_ctrl_redirect();
1695
+ }
1696
+ break;
1697
+ default:
1698
+ break;
1699
+ }
1700
+
1701
+ if (defined('LSCWP_LOG')) {
1702
+ $this->no_cache_for('LSCWP_CTRL query string should not cache.');
1703
+ }
1704
+ $this->cachectrl = self::CACHECTRL_NOCACHE;
1705
+ }
1706
+
1707
+ /**
1708
+ * Gathers all the purge headers.
1709
+ *
1710
+ * This will collect all site wide purge tags as well as
1711
+ * third party plugin defined purge tags.
1712
+ *
1713
+ * @since 1.0.1
1714
+ * @access private
1715
+ * @param boolean $stale Whether to add header as a stale header or not.
1716
+ * @return string The purge header
1717
+ */
1718
+ private function build_purge_headers($stale)
1719
+ {
1720
+ $cache_purge_header = LiteSpeed_Cache_Tags::HEADER_PURGE . ': ';
1721
+ $purge_tags = array_merge($this->pub_purge_tags,
1722
+ LiteSpeed_Cache_Tags::get_purge_tags());
1723
+ $purge_tags = array_unique($purge_tags);
1724
+
1725
+ if (empty($purge_tags)) {
1726
+ return '';
1727
+ }
1728
+
1729
+ $prefix = $this->config->get_option(
1730
+ LiteSpeed_Cache_Config::OPID_TAG_PREFIX);
1731
+ if (empty($prefix)) {
1732
+ $prefix = '';
1733
+ }
1734
+
1735
+ if (!in_array('*', $purge_tags )) {
1736
+ $tags = array_map(array($this,'prefix_apply'), $purge_tags);
1737
+ }
1738
+ elseif (isset($_POST['clearcache'])) {
1739
+ $tags = array('*');
1740
+ }
1741
+ // Would only use multisite and network admin except is_network_admin
1742
+ // is false for ajax calls, which is used by wordpress updates v4.6+
1743
+ elseif ((is_multisite()) && ((is_network_admin())
1744
+ || ((defined('DOING_AJAX'))
1745
+ && ((check_ajax_referer('updates', false, false))
1746
+ || (check_ajax_referer('litespeed-purgeall-network',
1747
+ false, false)))))) {
1748
+ $blogs = self::get_network_ids();
1749
+ if (empty($blogs)) {
1750
+ if (defined('LSCWP_LOG')) {
1751
+ self::debug_log('blog list is empty');
1752
+ }
1753
+ return '';
1754
+ }
1755
+ $tags = array();
1756
+ foreach ($blogs as $blog_id) {
1757
+ $tags[] = sprintf('%sB%s_', $prefix, $blog_id);
1758
+ }
1759
+ }
1760
+ else {
1761
+ $tags = array($prefix . 'B' . get_current_blog_id() . '_');
1762
+ }
1763
+
1764
+ if ($stale) {
1765
+ $cache_purge_header .= 'stale,';
1766
+ }
1767
+
1768
+ $cache_purge_header .= 'tag=' . implode(',', $tags);
1769
+ return $cache_purge_header;
1770
+ // TODO: private cache headers
1771
+ // $cache_purge_header = LiteSpeed_Cache_Tags::HEADER_PURGE
1772
+ // . ': private,tag=' . implode(',', $this->ext_purge_private_tags);
1773
+ // @header($cache_purge_header, false);
1774
+ }
1775
+
1776
+ /**
1777
+ * Builds the vary header.
1778
+ *
1779
+ * Currently, this only checks post passwords.
1780
+ *
1781
+ * @since 1.0.13
1782
+ * @access private
1783
+ * @global $post
1784
+ * @return mixed false if the user has the postpass cookie. Empty string
1785
+ * if the post is not password protected. Vary header otherwise.
1786
+ */
1787
+ private function build_vary_headers()
1788
+ {
1789
+ global $post;
1790
+ $tp_cookies = LiteSpeed_Cache_Tags::get_vary_cookies();
1791
+ if (!empty($post->post_password)) {
1792
+ if (isset($_COOKIE['wp-postpass_' . COOKIEHASH])) {
1793
+ // If user has password cookie, do not cache
1794
+ return false;
1795
+ }
1796
+ else {
1797
+ $tp_cookies[] = 'cookie=wp-postpass_' . COOKIEHASH;
1798
+ }
1799
+ }
1800
+
1801
+ if (empty($tp_cookies)) {
1802
+ return '';
1803
+ }
1804
+ return LiteSpeed_Cache_Tags::HEADER_CACHE_VARY
1805
+ . ': ' . implode(',', $tp_cookies);
1806
+ }
1807
+
1808
+ /**
1809
+ * The mode determines if the page is cacheable. This function filters
1810
+ * out the possible show header admin control.
1811
+ *
1812
+ * @since 1.0.7
1813
+ * @access private
1814
+ * @param boolean $showhdr Whether the show header command was selected.
1815
+ * @param boolean $stale Whether to make the purge headers stale.
1816
+ * @return integer The integer corresponding to the selected
1817
+ * cache control value.
1818
+ */
1819
+ private function validate_mode(&$showhdr, &$stale)
1820
+ {
1821
+ $mode = $this->cachectrl;
1822
+ if ($mode & self::CACHECTRL_SHOWHEADERS) {
1823
+ $showhdr = true;
1824
+ $mode &= ~self::CACHECTRL_SHOWHEADERS;
1825
+ }
1826
+
1827
+ if ($mode & self::CACHECTRL_STALE) {
1828
+ $stale = true;
1829
+ $mode &= ~self::CACHECTRL_STALE;
1830
+ }
1831
+
1832
+ if ($mode != self::CACHECTRL_CACHE) {
1833
+ return $mode;
1834
+ }
1835
+ elseif ((is_admin()) || (is_network_admin())) {
1836
+ return self::CACHECTRL_NOCACHE;
1837
+ }
1838
+
1839
+ if (((defined('LSCACHE_NO_CACHE')) && (constant('LSCACHE_NO_CACHE')))
1840
+ || (LiteSpeed_Cache_Tags::is_noncacheable())) {
1841
+ return self::CACHECTRL_NOCACHE;
1842
+ }
1843
+
1844
+ if ($this->config->get_option(
1845
+ LiteSpeed_Cache_Config::OPID_MOBILEVIEW_ENABLED) == false) {
1846
+ return (LiteSpeed_Cache_Tags::is_mobile() ? self::CACHECTRL_NOCACHE
1847
+ : $mode);
1848
+ }
1849
+
1850
+ if ((isset($_SERVER['LSCACHE_VARY_VALUE']))
1851
+ && ($_SERVER['LSCACHE_VARY_VALUE'] === 'ismobile')) {
1852
+ if ((!wp_is_mobile()) && (!LiteSpeed_Cache_Tags::is_mobile())) {
1853
+ return self::CACHECTRL_NOCACHE;
1854
+ }
1855
+ }
1856
+ elseif ((wp_is_mobile()) || (LiteSpeed_Cache_Tags::is_mobile())) {
1857
+ return self::CACHECTRL_NOCACHE;
1858
+ }
1859
+
1860
+ return $mode;
1861
+ }
1862
+
1863
+ /**
1864
+ * Send out the LiteSpeed Cache headers. If show headers is true,
1865
+ * will send out debug header.
1866
+ *
1867
+ * @since 1.0.7
1868
+ * @access private
1869
+ * @param boolean $showhdr True to show debug header, false if real headers.
1870
+ * @param string $cache_ctrl The cache control header to send out.
1871
+ * @param string $purge_hdr The purge tag header to send out.
1872
+ * @param string $cache_hdr The cache tag header to send out.
1873
+ * @param string $vary_hdr The cache vary header to send out.
1874
+ */
1875
+ private function header_out($showhdr, $cache_ctrl, $purge_hdr,
1876
+ $cache_hdr = '', $vary_hdr = '')
1877
+ {
1878
+ $hdr_content = array();
1879
+ if ((!is_null($cache_ctrl)) && (!empty($cache_ctrl))) {
1880
+ $hdr_content[] = $cache_ctrl;
1881
+ }
1882
+ if ((!is_null($purge_hdr)) && (!empty($purge_hdr))) {
1883
+ $hdr_content[] = $purge_hdr;
1884
+ }
1885
+ if ((!is_null($cache_hdr)) && (!empty($cache_hdr))) {
1886
+ $hdr_content[] = $cache_hdr;
1887
+ }
1888
+ if ((!is_null($vary_hdr)) && (!empty($vary_hdr))) {
1889
+ $hdr_content[] = $vary_hdr;
1890
+ }
1891
+
1892
+ if (!empty($hdr_content)) {
1893
+ if ($showhdr) {
1894
+ @header(LiteSpeed_Cache_Tags::HEADER_DEBUG . ': '
1895
+ . implode('; ', $hdr_content));
1896
+ }
1897
+ else {
1898
+ foreach($hdr_content as $hdr) {
1899
+ @header($hdr);
1900
+ }
1901
+ }
1902
+ }
1903
+
1904
+ if (defined('LSCWP_LOG')) {
1905
+ if(!defined('DOING_AJAX')){
1906
+ echo '<!-- Page generated by LiteSpeed Cache on '.date('Y-m-d H:i:s').' -->';
1907
+ }
1908
+ if($cache_hdr){
1909
+ $this->debug_log($cache_hdr);
1910
+ if(!defined('DOING_AJAX')){
1911
+ echo "\n<!-- ".$cache_hdr." -->";
1912
+ }
1913
+ }
1914
+ if($cache_ctrl) {
1915
+ $this->debug_log($cache_ctrl);
1916
+ if(!defined('DOING_AJAX')){
1917
+ echo "\n<!-- ".$cache_ctrl." -->";
1918
+ }
1919
+ }
1920
+ if($purge_hdr) {
1921
+ $this->debug_log($purge_hdr);
1922
+ if(!defined('DOING_AJAX')){
1923
+ echo "\n<!-- ".$purge_hdr." -->";
1924
+ }
1925
+ }
1926
+ $this->debug_log("End response.\n");
1927
+ }
1928
+ }
1929
+
1930
+ /**
1931
+ * Sends the headers out at the end of processing the request.
1932
+ *
1933
+ * This will send out all LiteSpeed Cache related response headers
1934
+ * needed for the post.
1935
+ *
1936
+ * @since 1.0.5
1937
+ * @access public
1938
+ */
1939
+ public function send_headers()
1940
+ {
1941
+ global $GLOBALS;
1942
+ global $wpforo;
1943
+ $zz = $GLOBALS['wpforo'];
1944
+ $cache_control_header = '';
1945
+ $cache_tag_header = '';
1946
+ $vary_headers = '';
1947
+ $cache_tags = null;
1948
+ $showhdr = false;
1949
+ $stale = false;
1950
+ do_action('litespeed_cache_add_purge_tags');
1951
+
1952
+ $mode = $this->validate_mode($showhdr, $stale);
1953
+
1954
+ if ($mode != self::CACHECTRL_NOCACHE) {
1955
+ do_action('litespeed_cache_add_cache_tags');
1956
+ $vary_headers = $this->build_vary_headers();
1957
+ $cache_tags = $this->get_cache_tags();
1958
+ if ($mode === self::CACHECTRL_CACHE) {
1959
+ $cache_tags[] = ''; //add blank entry to add blog tag.
1960
+ }
1961
+ }
1962
+
1963
+ if (empty($cache_tags) || ($vary_headers === false)) {
1964
+ $cache_control_header =
1965
+ LiteSpeed_Cache_Tags::HEADER_CACHE_CONTROL . ': no-cache' /*. ',esi=on'*/ ;
1966
+ $purge_headers = $this->build_purge_headers($stale);
1967
+ $this->header_out($showhdr, $cache_control_header, $purge_headers);
1968
+ return;
1969
+ }
1970
+ $prefix_tags = array_map(array($this,'prefix_apply'), $cache_tags);
1971
+
1972
+ switch ($mode) {
1973
+ case self::CACHECTRL_CACHE:
1974
+ $feed_ttl = $this->config->get_option(LiteSpeed_Cache_Config::OPID_FEED_TTL);
1975
+ $ttl_403 = $this->config->get_option(LiteSpeed_Cache_Config::OPID_403_TTL);
1976
+ $ttl_404 = $this->config->get_option(LiteSpeed_Cache_Config::OPID_404_TTL);
1977
+ $ttl_500 = $this->config->get_option(LiteSpeed_Cache_Config::OPID_500_TTL);
1978
+ if ((LiteSpeed_Cache_Tags::get_use_frontpage_ttl())
1979
+ || (is_front_page())){
1980
+ $ttl = $this->config->get_option(LiteSpeed_Cache_Config::OPID_FRONT_PAGE_TTL);
1981
+ }
1982
+ elseif ((is_feed()) && ($feed_ttl > 0)) {
1983
+ $ttl = $feed_ttl;
1984
+ }
1985
+ elseif ((is_404()) && ($ttl_404 > 0)) {
1986
+ $ttl = $ttl_404;
1987
+ }
1988
+ elseif ($this->error_status === 403) {
1989
+ $ttl = $ttl_403;
1990
+ }
1991
+ elseif ($this->error_status >= 500) {
1992
+ $ttl = $ttl_500;
1993
+ }
1994
+ else {
1995
+ $ttl = $this->config->get_option(LiteSpeed_Cache_Config::OPID_PUBLIC_TTL) ;
1996
+ }
1997
+ $cache_control_header = LiteSpeed_Cache_Tags::HEADER_CACHE_CONTROL
1998
+ . ': public,max-age=' . $ttl /*. ',esi=on'*/ ;
1999
+ $cache_tag_header = LiteSpeed_Cache_Tags::HEADER_CACHE_TAG
2000
+ . ': ' . implode(',', $prefix_tags) ;
2001
+ break;
2002
+ case self::CACHECTRL_PURGESINGLE:
2003
+ $cache_tags = $cache_tags[0];
2004
+ // fall through
2005
+ case self::CACHECTRL_PURGE:
2006
+ $cache_control_header =
2007
+ LiteSpeed_Cache_Tags::HEADER_CACHE_CONTROL . ': no-cache' /*. ',esi=on'*/ ;
2008
+ LiteSpeed_Cache_Tags::add_purge_tag($cache_tags);
2009
+ break;
2010
+
2011
+ }
2012
+ $purge_headers = $this->build_purge_headers($stale);
2013
+ $this->header_out($showhdr, $cache_control_header, $purge_headers,
2014
+ $cache_tag_header, $vary_headers);
2015
+ }
2016
+
2017
+ /**
2018
+ * Callback function that applies a prefix to cache/purge tags.
2019
+ *
2020
+ * The first call to this method will build the prefix. Subsequent calls
2021
+ * will use the already set prefix.
2022
+ *
2023
+ * @since 1.0.9
2024
+ * @access private
2025
+ * @staticvar string $prefix The prefix to use for each tag.
2026
+ * @param string $tag The tag to prefix.
2027
+ * @return string The amended tag.
2028
+ */
2029
+ private function prefix_apply($tag)
2030
+ {
2031
+ static $prefix = null;
2032
+ if (is_null($prefix)) {
2033
+ $prefix = $this->config->get_option(
2034
+ LiteSpeed_Cache_Config::OPID_TAG_PREFIX);
2035
+ if (empty($prefix)) {
2036
+ $prefix = '';
2037
+ }
2038
+ $prefix .= 'B' . get_current_blog_id() . '_';
2039
+ }
2040
+ return $prefix . $tag;
2041
+ }
2042
+
2043
+ /**
2044
+ * Gets the cache tags to set for the page.
2045
+ *
2046
+ * This includes site wide post types (e.g. front page) as well as
2047
+ * any third party plugin specific cache tags.
2048
+ *
2049
+ * @since 1.0.0
2050
+ * @access private
2051
+ * @return array The list of cache tags to set.
2052
+ */
2053
+ private function get_cache_tags()
2054
+ {
2055
+ global $post ;
2056
+ global $wp_query ;
2057
+
2058
+ $queried_obj_id = get_queried_object_id() ;
2059
+ $cache_tags = array();
2060
+
2061
+ $hash = self::get_uri_hash(urldecode($_SERVER['REQUEST_URI']));
2062
+
2063
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_URL . $hash;
2064
+
2065
+ if ( is_front_page() ) {
2066
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_FRONTPAGE ;
2067
+ }
2068
+ elseif ( is_home() ) {
2069
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_HOME ;
2070
+ }
2071
+
2072
+ if ($this->error_status !== false) {
2073
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_ERROR . $this->error_status;
2074
+ }
2075
+
2076
+ if ( is_archive() ) {
2077
+ //An Archive is a Category, Tag, Author, Date, Custom Post Type or Custom Taxonomy based pages.
2078
+
2079
+ if ( is_category() || is_tag() || is_tax() ) {
2080
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_ARCHIVE_TERM . $queried_obj_id ;
2081
+ }
2082
+ elseif ( is_post_type_archive() ) {
2083
+ $post_type = $wp_query->get('post_type') ;
2084
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_ARCHIVE_POSTTYPE . $post_type ;
2085
+ }
2086
+ elseif ( is_author() ) {
2087
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_AUTHOR . $queried_obj_id ;
2088
+ }
2089
+ elseif ( is_date() ) {
2090
+ $date = $post->post_date ;
2091
+ $date = strtotime($date) ;
2092
+ if ( is_day() ) {
2093
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_ARCHIVE_DATE . date('Ymd', $date) ;
2094
+ }
2095
+ elseif ( is_month() ) {
2096
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_ARCHIVE_DATE . date('Ym', $date) ;
2097
+ }
2098
+ elseif ( is_year() ) {
2099
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_ARCHIVE_DATE . date('Y', $date) ;
2100
+ }
2101
+ }
2102
+ }
2103
+ elseif ( is_singular() ) {
2104
+ //$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
2105
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_POST . $queried_obj_id ;
2106
+
2107
+ if ( is_page() ) {
2108
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_PAGES;
2109
+ }
2110
+ }
2111
+ elseif ( is_feed() ) {
2112
+ $cache_tags[] = LiteSpeed_Cache_Tags::TYPE_FEED;
2113
+ }
2114
+
2115
+ return array_merge($cache_tags, LiteSpeed_Cache_Tags::get_cache_tags());
2116
+ }
2117
+
2118
+ /**
2119
+ * Gets all the purge tags correlated with the post about to be purged.
2120
+ *
2121
+ * If the purge all pages configuration is set, all pages will be purged.
2122
+ *
2123
+ * This includes site wide post types (e.g. front page) as well as
2124
+ * any third party plugin specific post tags.
2125
+ *
2126
+ * @since 1.0.0
2127
+ * @access private
2128
+ * @param integer $post_id The id of the post about to be purged.
2129
+ * @return array The list of purge tags correlated with the post.
2130
+ */
2131
+ private function get_purge_tags( $post_id )
2132
+ {
2133
+ // If this is a valid post we want to purge the post, the home page and any associated tags & cats
2134
+ // If not, purge everything on the site.
2135
+
2136
+ $purge_tags = array() ;
2137
+ $config = $this->config() ;
2138
+
2139
+ if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_ALL_PAGES) ) {
2140
+ // ignore the rest if purge all
2141
+ return array( '*' ) ;
2142
+ }
2143
+
2144
+ do_action('litespeed_cache_on_purge_post', $post_id);
2145
+
2146
+ // post
2147
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_POST . $post_id ;
2148
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_URL
2149
+ . self::get_uri_hash(wp_make_link_relative(get_post_permalink($post_id)));
2150
+
2151
+ // for archive of categories|tags|custom tax
2152
+ global $post;
2153
+ $post = get_post($post_id) ;
2154
+ $post_type = $post->post_type ;
2155
+
2156
+ // get adjacent posts id as related post tag
2157
+ if($post_type == 'post'){
2158
+ $prev_post = get_previous_post();
2159
+ $next_post = get_next_post();
2160
+ if(!empty($prev_post->ID)) {
2161
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_POST . $prev_post->ID;
2162
+ if(defined('LSCWP_LOG')){
2163
+ self::debug_log('--------purge_tags prev is: '.$prev_post->ID);
2164
+ }
2165
+ }
2166
+ if(!empty($next_post->ID)) {
2167
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_POST . $next_post->ID;
2168
+ if(defined('LSCWP_LOG')){
2169
+ self::debug_log('--------purge_tags next is: '.$next_post->ID);
2170
+ }
2171
+ }
2172
+ }
2173
+
2174
+ if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_TERM) ) {
2175
+ $taxonomies = get_object_taxonomies($post_type) ;
2176
+ //$this->debug_log('purge by post, check tax = ' . print_r($taxonomies, true)) ;
2177
+ foreach ( $taxonomies as $tax ) {
2178
+ $terms = get_the_terms($post_id, $tax) ;
2179
+ if ( ! empty($terms) ) {
2180
+ foreach ( $terms as $term ) {
2181
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_ARCHIVE_TERM . $term->term_id ;
2182
+ }
2183
+ }
2184
+ }
2185
+ }
2186
+
2187
+ if ($config->get_option(LiteSpeed_Cache_Config::OPID_FEED_TTL) > 0) {
2188
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_FEED;
2189
+ }
2190
+
2191
+ // author, for author posts and feed list
2192
+ if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_AUTHOR) ) {
2193
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_AUTHOR . get_post_field('post_author', $post_id) ;
2194
+ }
2195
+
2196
+ // archive and feed of post type
2197
+ // todo: check if type contains space
2198
+ if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_POST_TYPE) ) {
2199
+ if ( get_post_type_archive_link($post_type) ) {
2200
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_ARCHIVE_POSTTYPE . $post_type ;
2201
+ }
2202
+ }
2203
+
2204
+ if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_FRONT_PAGE) ) {
2205
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_FRONTPAGE ;
2206
+ }
2207
+
2208
+ if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_HOME_PAGE) ) {
2209
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_HOME ;
2210
+ }
2211
+
2212
+ if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_PAGES) ) {
2213
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_PAGES ;
2214
+ }
2215
+
2216
+ if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_PAGES_WITH_RECENT_POSTS) ) {
2217
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_PAGES_WITH_RECENT_POSTS ;
2218
+ }
2219
+
2220
+ // if configured to have archived by date
2221
+ $date = $post->post_date ;
2222
+ $date = strtotime($date) ;
2223
+
2224
+ if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_DATE) ) {
2225
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_ARCHIVE_DATE . date('Ymd', $date) ;
2226
+ }
2227
+
2228
+ if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_MONTH) ) {
2229
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_ARCHIVE_DATE . date('Ym', $date) ;
2230
+ }
2231
+
2232
+ if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_YEAR) ) {
2233
+ $purge_tags[] = LiteSpeed_Cache_Tags::TYPE_ARCHIVE_DATE . date('Y', $date) ;
2234
+ }
2235
+
2236
+ return array_unique($purge_tags) ;
2237
+ }
2238
+
2239
+ /**
2240
+ * Will get a hash of the URI. Removes query string and appends a '/' if
2241
+ * it is missing.
2242
+ *
2243
+ * @since 1.0.12
2244
+ * @access private
2245
+ * @param string $uri The uri to get the hash of.
2246
+ * @return bool|string False on input error, hash otherwise.
2247
+ */
2248
+ private static function get_uri_hash($uri)
2249
+ {
2250
+ $no_qs = strtok($uri, '?');
2251
+ if (empty($no_qs)) {
2252
+ return false;
2253
+ }
2254
+ $slashed = trailingslashit($no_qs);
2255
+ return md5($slashed);
2256
+ }
2257
+
2258
+ /**
2259
+ * Creates a part of the environment report based on a section header
2260
+ * and an array for the section parameters.
2261
+ *
2262
+ * @since 1.0.12
2263
+ * @access private
2264
+ * @param string $section_header The section heading
2265
+ * @param array $section An array of information to output
2266
+ * @return string The created report block.
2267
+ */
2268
+ private static function format_report_section($section_header, $section)
2269
+ {
2270
+ $tab = ' '; // four spaces
2271
+ $nl = "\n";
2272
+
2273
+ if (empty($section)) {
2274
+ return 'No matching ' . $section_header . $nl . $nl;
2275
+ }
2276
+ $buf = $section_header;
2277
+ foreach ($section as $key=>$val) {
2278
+ $buf .= $nl . $tab;
2279
+ if (!is_numeric($key)) {
2280
+ $buf .= $key . ' = ';
2281
+ }
2282
+ if (!is_string($val)) {
2283
+ $buf .= print_r($val, true);
2284
+ }
2285
+ else {
2286
+ $buf .= $val;
2287
+ }
2288
+ }
2289
+ return $buf . $nl . $nl;
2290
+ }
2291
+
2292
+ /**
2293
+ * Builds the environment report buffer with the given parameters
2294
+ *
2295
+ * @param array $server - server variables
2296
+ * @param array $options - cms options
2297
+ * @param array $extras - cms specific attributes
2298
+ * @param array $htaccess_paths - htaccess paths to check.
2299
+ * @return string The Environment Report buffer.
2300
+ */
2301
+ public static function build_environment_report($server, $options,
2302
+ $extras = array(), $htaccess_paths = array())
2303
+ {
2304
+ $server_keys = array(
2305
+ 'DOCUMENT_ROOT'=>'',
2306
+ 'SERVER_SOFTWARE'=>'',
2307
+ 'X-LSCACHE'=>'',
2308
+ 'HTTP_X_LSCACHE'=>''
2309
+ );
2310
+ $server_vars = array_intersect_key($server, $server_keys);
2311
+ $buf = self::format_report_section('Server Variables', $server_vars);
2312
+
2313
+ $buf .= self::format_report_section('LSCache Plugin Options',
2314
+ $options);
2315
+
2316
+ $buf .= self::format_report_section('Wordpress Specific Extras',
2317
+ $extras);
2318
+
2319
+ if (empty($htaccess_paths)) {
2320
+ return $buf;
2321
+ }
2322
+
2323
+ foreach ($htaccess_paths as $path) {
2324
+ if ((!file_exists($path)) || (!is_readable($path))) {
2325
+ $buf .= $path . " does not exist or is not readable.\n";
2326
+ continue;
2327
+ }
2328
+ $content = file_get_contents($path);
2329
+ if ($content === false) {
2330
+ $buf .= $path . " returned false for file_get_contents.\n";
2331
+ continue;
2332
+ }
2333
+ $buf .= $path . " contents:\n" . $content . "\n\n";
2334
+ }
2335
+ return $buf;
2336
+ }
2337
+
2338
+ /**
2339
+ * Write the environment report to the report location.
2340
+ *
2341
+ * @since 1.0.12
2342
+ * @access public
2343
+ * @param string $content What to write to the environment report.
2344
+ */
2345
+ public function write_environment_report($content)
2346
+ {
2347
+ $content = "<"."?php die();?".">\n\n".$content;
2348
+
2349
+ $ret = LiteSpeed_Cache_Admin_Rules::file_save($content, false,
2350
+ untrailingslashit($this->plugin_dir) . '/environment_report.php', false);
2351
+ if (($ret !== true) && (defined('LSCWP_LOG'))) {
2352
+ self::debug_log('LSCache wordpress plugin attempted to write '
2353
+ . 'env report but did not have permissions.');
2354
+ }
2355
+ }
2356
+
2357
+ /**
2358
+ * Gathers the environment details and creates the report.
2359
+ * Will write to the environment report file.
2360
+ *
2361
+ * @since 1.0.12
2362
+ * @access public
2363
+ * @param mixed $options Array of options to output. If null, will skip
2364
+ * the options section.
2365
+ * @return string The built report.
2366
+ */
2367
+ public static function generate_environment_report($options = null)
2368
+ {
2369
+ global $wp_version, $_SERVER;
2370
+ $home = LiteSpeed_Cache_Admin_Rules::get_home_path();
2371
+ $site = LiteSpeed_Cache_Admin_Rules::get_site_path();
2372
+ $paths = array($home);
2373
+ if ($home != $site) {
2374
+ $paths[] = $site;
2375
+ }
2376
+
2377
+ if (is_multisite()) {
2378
+ $active_plugins = get_site_option('active_sitewide_plugins');
2379
+ if (!empty($active_plugins)) {
2380
+ $active_plugins = array_keys($active_plugins);
2381
+ }
2382
+ }
2383
+ else {
2384
+ $active_plugins = get_option('active_plugins');
2385
+ }
2386
+
2387
+ if (function_exists('wp_get_theme')) {
2388
+ $theme_obj = wp_get_theme();
2389
+ $active_theme = $theme_obj->get('Name');
2390
+ }
2391
+ else {
2392
+ $active_theme = get_current_theme();
2393
+ }
2394
+
2395
+ $extras = array(
2396
+ 'wordpress version' => $wp_version,
2397
+ 'locale' => get_locale(),
2398
+ 'active theme' => $active_theme,
2399
+ 'active plugins' => $active_plugins,
2400
+
2401
+ );
2402
+ if (is_null($options)) {
2403
+ $options = self::config()->get_options();
2404
+ }
2405
+
2406
+ if ((!is_null($options)) && (is_multisite())) {
2407
+ $blogs = self::get_network_ids();
2408
+ if (!empty($blogs)) {
2409
+ foreach ($blogs as $blog_id) {
2410
+ $opts = get_blog_option($blog_id,
2411
+ LiteSpeed_Cache_Config::OPTION_NAME, array());
2412
+ if (isset($opts[LiteSpeed_Cache_Config::OPID_ENABLED_RADIO])) {
2413
+ $options['blog ' . $blog_id . ' radio select']
2414
+ = $opts[LiteSpeed_Cache_Config::OPID_ENABLED_RADIO];
2415
+ }
2416
+ }
2417
+ }
2418
+ }
2419
+
2420
+ $report = self::build_environment_report($_SERVER, $options, $extras,
2421
+ $paths);
2422
+ self::plugin()->write_environment_report($report);
2423
+ return $report;
2424
+ }
2425
+
2426
+ /**
2427
+ * Hooked to the update options/site options actions. Whenever our options
2428
+ * are updated, update the environment report with the new options.
2429
+ *
2430
+ * @since 1.0.12
2431
+ * @access public
2432
+ * @param $unused
2433
+ * @param mixed $options The updated options. May be array or string.
2434
+ */
2435
+ public static function update_environment_report($unused, $options)
2436
+ {
2437
+ if (is_array($options)) {
2438
+ self::generate_environment_report($options);
2439
+ }
2440
+ }
2441
+
2442
+
2443
+
2444
+ /* BEGIN ESI CODE, not fully implemented for now */
2445
+ /**
2446
+ *
2447
+ *
2448
+ * @since 1.0.1
2449
+ */
2450
+ public function esi_admin_bar_render()
2451
+ {
2452
+ echo '<!-- lscwp admin esi start -->'
2453
+ . '<esi:include src="/lscwp_admin_bar.php" onerror=\"continue\"/>'
2454
+ . '<!-- lscwp admin esi end -->';
2455
+ }
2456
+
2457
+ /**
2458
+ *
2459
+ *
2460
+ * @since 1.0.1
2461
+ */
2462
+ public function check_admin_bar()
2463
+ {
2464
+ if (is_admin_bar_showing()) {
2465
+ remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
2466
+ remove_action( 'in_admin_header', 'wp_admin_bar_render', 0 );
2467
+ add_action('wp_footer', array($this, 'esi_admin_bar_render'), 1000);
2468
+ }
2469
+ }
2470
+
2471
+ /**
2472
+ *
2473
+ *
2474
+ * @since 1.0.1
2475
+ */
2476
+ public function check_storefront_cart()
2477
+ {
2478
+ if (has_action('storefront_header', 'storefront_header_cart')) {
2479
+ remove_action('storefront_header', 'storefront_header_cart', 60);
2480
+ echo '<!-- lscwp cart esi start -->'
2481
+ . '<esi:include src="/lscwp_cart.php" onerror=\"continue\"/>'
2482
+ . '<!-- lscwp cart esi end -->';
2483
+ }
2484
+ }
2485
+
2486
+ /**
2487
+ *
2488
+ *
2489
+ * @since 1.0.1
2490
+ */
2491
+ public function check_sidebar()
2492
+ {
2493
+ if (has_action('storefront_sidebar', 'storefront_get_sidebar')) {
2494
+ remove_action('storefront_sidebar', 'storefront_get_sidebar', 10);
2495
+ echo '<!-- lscwp sidebar esi start -->'
2496
+ . '<esi:include src="/lscwp_sidebar.php" onerror=\"continue\"/>'
2497
+ . '<!-- lscwp sidebar esi end -->';
2498
+ }
2499
+ }
2500
+
2501
+ /**
2502
+ *
2503
+ *
2504
+ * @since 1.0.1
2505
+ */
2506
+ private function add_actions_esi()
2507
+ {
2508
+ add_action('storefront_header',
2509
+ array($this, 'check_storefront_cart'), 59);
2510
+ add_action('storefront_sidebar', array($this, 'check_sidebar'), 0);
2511
+ }
2512
+
2513
+ /**
2514
+ *
2515
+ *
2516
+ * @since 1.0.1
2517
+ */
2518
+ public function send_esi()
2519
+ {
2520
+ status_header(200);
2521
+ die();
2522
+ }
2523
+
2524
+ /**
2525
+ *
2526
+ *
2527
+ * @since 1.0.1
2528
+ */
2529
+ private function is_esi_admin_bar($uri, $urilen)
2530
+ {
2531
+ $admin = 'admin_bar.php';
2532
+ $adminlen = strlen($admin);
2533
+
2534
+ if (($urilen != $adminlen)
2535
+ || (strncmp($uri, $admin, $adminlen) != 0)) {
2536
+ return false;
2537
+ }
2538
+ add_action( 'init', '_wp_admin_bar_init', 0 );
2539
+ add_action( 'init', 'wp_admin_bar_render', 0 );
2540
+ add_action('init', array($this, 'send_esi'), 0);
2541
+ return true;
2542
+ }
2543
+
2544
+ /**
2545
+ *
2546
+ *
2547
+ * @since 1.0.1
2548
+ */
2549
+ private function is_esi_cart($uri, $urilen)
2550
+ {
2551
+ $cart = 'cart.php';
2552
+ $cartlen = strlen($cart);
2553
+
2554
+ if (($urilen != $cartlen)
2555
+ || (strncmp($uri, $cart, $cartlen) != 0)) {
2556
+ return false;
2557
+ }
2558
+ register_widget( 'WC_Widget_Cart' );
2559
+ add_action('init', 'storefront_cart_link_fragment', 0);
2560
+ add_action('init', 'storefront_header_cart', 0);
2561
+ add_action('init', array($this, 'send_esi'), 0);
2562
+ return true;
2563
+ }
2564
+
2565
+ /**
2566
+ *
2567
+ *
2568
+ * @since 1.0.1
2569
+ */
2570
+ public function load_sidebar_widgets()
2571
+ {
2572
+ do_action('widgets_init');
2573
+ do_action('register_sidebar');
2574
+ do_action('wp_register_sidebar_widget');
2575
+ }
2576
+
2577
+ /**
2578
+ *
2579
+ *
2580
+ * @since 1.0.1
2581
+ */
2582
+ private function is_esi_sidebar($uri, $urilen)
2583
+ {
2584
+ $sidebar = 'sidebar.php';
2585
+ $sidebarlen = strlen($sidebar);
2586
+
2587
+ if (($urilen != $sidebarlen)
2588
+ || (strncmp($uri, $sidebar, $sidebarlen) != 0)) {
2589
+ return false;
2590
+ }
2591
+ add_action('widgets_init', 'storefront_widgets_init', 10);
2592
+ add_action('wp_loaded', array($this, 'load_sidebar_widgets'), 0);
2593
+ add_action('wp_loaded', 'storefront_get_sidebar', 0);
2594
+ add_action('wp_loaded', array($this, 'send_esi'), 0);
2595
+ return true;
2596
+ }
2597
+
2598
+ /**
2599
+ *
2600
+ *
2601
+ * @since 1.0.1
2602
+ */
2603
+ private function check_esi_page()
2604
+ {
2605
+ $prefix = '/lscwp_';
2606
+ $prefixlen = 7;
2607
+ $uri = esc_url($_SERVER['REQUEST_URI']);
2608
+ $urilen = strlen($uri);
2609
+
2610
+ if (($urilen <= $prefixlen) || (strncmp($uri, $prefix, $prefixlen) != 0 )) {
2611
+ return false;
2612
+ }
2613
+
2614
+ $uri = substr($uri, $prefixlen);
2615
+ $urilen -= $prefixlen;
2616
+
2617
+ switch ($uri[0]) {
2618
+ case 'a':
2619
+ return $this->is_esi_admin_bar($uri, $urilen);
2620
+ case 'c':
2621
+ return $this->is_esi_cart($uri, $urilen);
2622
+ case 's':
2623
+ return $this->is_esi_sidebar($uri, $urilen);
2624
+ default:
2625
+ break;
2626
+ }
2627
+ return false;
2628
+ }
2629
+ /*END ESI CODE*/
2630
+ }
includes/deprecated-litespeed-cache-tags.class.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Deprecated Class for API backward compatibility to v1.1.2.2
5
- */
6
- class LiteSpeed_Cache_Tags
7
- {
8
- public static function add_purge_tag( $tag )
9
- {
10
- LiteSpeed_Cache_API::purge( $tag ) ;
11
- }
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-activation.class.php DELETED
@@ -1,235 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin activation class.
4
- *
5
- * @since 1.1.0
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/includes
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
- class LiteSpeed_Cache_Activation
11
- {
12
- const NETWORK_TRANSIENT_COUNT = 'lscwp_network_count' ;
13
-
14
- /**
15
- * The activation hook callback.
16
- *
17
- * Attempts to set up the advanced cache file. If it fails for any reason,
18
- * the plugin will not activate.
19
- *
20
- * @since 1.0.0
21
- * @access public
22
- */
23
- public static function register_activation()
24
- {
25
- $count = 0 ;
26
- ! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', 'Activate_' . get_current_blog_id() ) ;
27
-
28
- self::try_copy_advanced_cache() ;
29
- LiteSpeed_Cache_Config::wp_cache_var_setter( true ) ;
30
-
31
- if ( is_multisite() ) {
32
- $count = self::get_network_count() ;
33
- if ( $count !== false ) {
34
- $count = intval( $count ) + 1 ;
35
- set_site_transient( self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS ) ;
36
- }
37
- }
38
- do_action( 'litespeed_cache_api_load_thirdparty' ) ;
39
- LiteSpeed_Cache_Config::get_instance()->plugin_activation( $count ) ;
40
- LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report() ;
41
-
42
- if ( defined( 'LSCWP_PLUGIN_NAME' ) ) {
43
- set_transient( LiteSpeed_Cache::WHM_TRANSIENT, LiteSpeed_Cache::WHM_TRANSIENT_VAL ) ;
44
- }
45
-
46
- // Register crawler cron task
47
- LiteSpeed_Cache_Task::update() ;
48
- }
49
-
50
- /**
51
- * Uninstall plugin
52
- * @since 1.1.0
53
- */
54
- public static function uninstall_litespeed_cache()
55
- {
56
- LiteSpeed_Cache_Task::clear() ;
57
- LiteSpeed_Cache_Admin_Rules::get_instance()->clear_rules( true ) ;
58
- delete_option( LiteSpeed_Cache_Config::OPTION_NAME ) ;
59
- if ( is_multisite() ) {
60
- delete_site_option( LiteSpeed_Cache_Config::OPTION_NAME ) ;
61
- }
62
- }
63
-
64
- /**
65
- * Get the blog ids for the network. Accepts function arguments.
66
- *
67
- * Will use wp_get_sites for WP versions less than 4.6
68
- *
69
- * @since 1.0.12
70
- * @access public
71
- * @param array $args Arguments to pass into get_sites/wp_get_sites.
72
- * @return array The array of blog ids.
73
- */
74
- public static function get_network_ids( $args = array() )
75
- {
76
- global $wp_version ;
77
- if ( version_compare( $wp_version, '4.6', '<' ) ) {
78
- $blogs = wp_get_sites( $args ) ;
79
- if ( ! empty( $blogs ) ) {
80
- foreach ( $blogs as $key => $blog ) {
81
- $blogs[ $key ] = $blog[ 'blog_id' ] ;
82
- }
83
- }
84
- }
85
- else {
86
- $args[ 'fields' ] = 'ids' ;
87
- $blogs = get_sites( $args ) ;
88
- }
89
- return $blogs ;
90
- }
91
-
92
- /**
93
- * Gets the count of active litespeed cache plugins on multisite.
94
- *
95
- * @since 1.0.12
96
- * @access private
97
- * @return mixed The count on success, false on failure.
98
- */
99
- private static function get_network_count()
100
- {
101
- $count = get_site_transient( self::NETWORK_TRANSIENT_COUNT ) ;
102
- if ( $count !== false ) {
103
- return intval( $count ) ;
104
- }
105
- // need to update
106
- $default = array() ;
107
- $count = 0 ;
108
-
109
- $sites = self::get_network_ids( array( 'deleted' => 0 ) ) ;
110
- if ( empty( $sites ) ) {
111
- return false ;
112
- }
113
-
114
- foreach ( $sites as $site ) {
115
- $bid = is_object( $site ) && property_exists( $site, 'blog_id' ) ? $site->blog_id : $site ;
116
- $plugins = get_blog_option( $bid , 'active_plugins', $default ) ;
117
- if ( in_array( LSWCP_BASENAME, $plugins, true ) ) {
118
- $count++ ;
119
- }
120
- }
121
- if ( is_plugin_active_for_network( LSWCP_BASENAME ) ) {
122
- $count++ ;
123
- }
124
- return $count ;
125
- }
126
-
127
- /**
128
- * Is this deactivate call the last active installation on the multisite
129
- * network?
130
- *
131
- * @since 1.0.12
132
- * @access private
133
- * @return bool True if yes, false otherwise.
134
- */
135
- private static function is_deactivate_last()
136
- {
137
- $count = self::get_network_count() ;
138
- if ( $count === false ) {
139
- return false ;
140
- }
141
- if ( $count !== 1 ) {
142
- // Not deactivating the last one.
143
- $count-- ;
144
- set_site_transient( self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS ) ;
145
- return false ;
146
- }
147
-
148
- delete_site_transient( self::NETWORK_TRANSIENT_COUNT ) ;
149
- return true ;
150
- }
151
-
152
- /**
153
- * The deactivation hook callback.
154
- *
155
- * Initializes all clean up functionalities.
156
- *
157
- * @since 1.0.0
158
- * @access public
159
- */
160
- public static function register_deactivation()
161
- {
162
- LiteSpeed_Cache_Task::clear() ;
163
-
164
- ! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', 'Deactivate_' . get_current_blog_id() ) ;
165
-
166
- LiteSpeed_Cache_Purge::purge_all() ;
167
-
168
- if ( is_multisite() ) {
169
-
170
- if ( ! self::is_deactivate_last() ) {
171
- if ( is_network_admin() ) {
172
- // Still other activated subsite left, set .htaccess with only CacheLookUp
173
- LiteSpeed_Cache_Admin_Rules::get_instance()->insert_wrapper() ;
174
- }
175
- return ;
176
- }
177
- }
178
-
179
- $adv_cache_path = LSWCP_CONTENT_DIR . '/advanced-cache.php' ;
180
- // this file can be generated by other cache plugin like w3tc, we only delete our own file
181
- if ( file_exists( $adv_cache_path ) && is_writable( $adv_cache_path ) ) {
182
- if ( strpos( file_get_contents( $adv_cache_path ), 'LSCACHE_ADV_CACHE' ) !== false ) {
183
- unlink( $adv_cache_path ) ;
184
- }
185
- else {
186
- error_log(' Keep advanced-cache.php as it belongs to other plugins' ) ;
187
- }
188
- }
189
- else {
190
- error_log( 'Failed to remove advanced-cache.php, file does not exist or is not writable!' ) ;
191
- }
192
-
193
- if ( ! LiteSpeed_Cache_Config::wp_cache_var_setter( false ) ) {
194
- error_log('In wp-config.php: WP_CACHE could not be set to false during deactivation!') ;
195
- }
196
-
197
- LiteSpeed_Cache_Admin_Rules::get_instance()->clear_rules( true ) ;
198
-
199
- // delete in case it's not deleted prior to deactivation.
200
- self::dismiss_whm() ;
201
- }
202
-
203
- /**
204
- * Try to copy our advanced-cache.php file to the wordpress directory.
205
- *
206
- * @since 1.0.11
207
- * @access public
208
- * @return boolean True on success, false on failure.
209
- */
210
- public static function try_copy_advanced_cache()
211
- {
212
- $adv_cache_path = LSWCP_CONTENT_DIR . '/advanced-cache.php' ;
213
- if ( file_exists( $adv_cache_path ) && ( filesize( $adv_cache_path ) !== 0 || ! is_writable( $adv_cache_path ) ) ) {
214
- return false ;
215
- }
216
-
217
- copy( LSWCP_DIR . 'includes/advanced-cache.php', $adv_cache_path ) ;
218
- include( $adv_cache_path ) ;
219
- $ret = defined( 'LSCACHE_ADV_CACHE' ) ;
220
- return $ret ;
221
- }
222
-
223
- /**
224
- * Delete whm transient msg tag
225
- *
226
- * @since 1.1.1
227
- * @access public
228
- */
229
- public static function dismiss_whm()
230
- {
231
- delete_transient( LiteSpeed_Cache::WHM_TRANSIENT ) ;
232
- }
233
-
234
-
235
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-api.class.php DELETED
@@ -1,427 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The plugin API class.
5
- *
6
- * @since 1.1.3
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/includes
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
- class LiteSpeed_Cache_API
12
- {
13
- const VERSION = LiteSpeed_Cache::PLUGIN_VERSION ;
14
-
15
- const TYPE_FEED = LiteSpeed_Cache_Tag::TYPE_FEED ;
16
- const TYPE_FRONTPAGE = LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ;
17
- const TYPE_HOME = LiteSpeed_Cache_Tag::TYPE_HOME ;
18
- const TYPE_PAGES = LiteSpeed_Cache_Tag::TYPE_PAGES ;
19
- const TYPE_PAGES_WITH_RECENT_POSTS = LiteSpeed_Cache_Tag::TYPE_PAGES_WITH_RECENT_POSTS ;
20
- const TYPE_ERROR = LiteSpeed_Cache_Tag::TYPE_ERROR ;
21
- const TYPE_POST = LiteSpeed_Cache_Tag::TYPE_POST ;
22
- const TYPE_ARCHIVE_POSTTYPE = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_POSTTYPE ;
23
- const TYPE_ARCHIVE_TERM = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM ;
24
- const TYPE_AUTHOR = LiteSpeed_Cache_Tag::TYPE_AUTHOR ;
25
- const TYPE_ARCHIVE_DATE = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE ;
26
- const TYPE_BLOG = LiteSpeed_Cache_Tag::TYPE_BLOG ;
27
- const TYPE_LOGIN = LiteSpeed_Cache_Tag::TYPE_LOGIN ;
28
- const TYPE_URL = LiteSpeed_Cache_Tag::TYPE_URL ;
29
- const TYPE_WIDGET = LiteSpeed_Cache_Tag::TYPE_WIDGET ;
30
-
31
- const PARAM_NAME = LiteSpeed_Cache_ESI::PARAM_NAME ;
32
- const WIDGET_OPID_ESIENABLE = LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ;
33
- const WIDGET_OPID_TTL = LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ;
34
-
35
- const VAL_OFF = LiteSpeed_Cache_Config::VAL_OFF ;
36
- const VAL_ON = LiteSpeed_Cache_Config::VAL_ON ;
37
- const VAL_ON2 = LiteSpeed_Cache_Config::VAL_ON2 ;
38
-
39
- /**
40
- * Compare version
41
- *
42
- * @since 1.3
43
- * @access public
44
- */
45
- public static function v( $v )
46
- {
47
- return version_compare( self::VERSION, $v, '>=' ) ;
48
- }
49
-
50
- /**
51
- * Set mobile
52
- *
53
- * @since 1.1.3
54
- * @access public
55
- */
56
- public static function set_mobile()
57
- {
58
- LiteSpeed_Cache_Control::set_mobile() ;
59
- }
60
-
61
- /**
62
- * Set cache status to not cacheable
63
- *
64
- * @since 1.1.3
65
- * @access public
66
- */
67
- public static function set_cache_private()
68
- {
69
- LiteSpeed_Cache_Control::set_private() ;
70
- }
71
-
72
- /**
73
- * Set cache status to no vary
74
- *
75
- * @since 1.2.0
76
- * @access public
77
- */
78
- public static function set_cache_no_vary()
79
- {
80
- LiteSpeed_Cache_Control::set_no_vary() ;
81
- }
82
-
83
- /**
84
- * Set cache status to not cacheable
85
- *
86
- * @since 1.1.3
87
- * @access public
88
- */
89
- public static function set_nocache( $reason = false )
90
- {
91
- LiteSpeed_Cache_Control::set_nocache( $reason ?: 'api' ) ;
92
- }
93
-
94
- /**
95
- * Get current not cacheable status
96
- *
97
- * @since 1.1.3
98
- * @access public
99
- */
100
- public static function not_cacheable()
101
- {
102
- return ! LiteSpeed_Cache_Control::is_cacheable() ;
103
- }
104
-
105
- /**
106
- * Set cache control ttl to use frontpage ttl
107
- *
108
- * @since 1.1.3
109
- * @access public
110
- */
111
- public static function set_use_frontpage_ttl()
112
- {
113
- LiteSpeed_Cache_Control::set_custom_ttl(self::config(LiteSpeed_Cache_Config::OPID_FRONT_PAGE_TTL)) ;
114
- }
115
-
116
- /**
117
- * Set cache control ttl
118
- *
119
- * @since 1.1.5
120
- * @access public
121
- */
122
- public static function set_ttl( $val )
123
- {
124
- LiteSpeed_Cache_Control::set_custom_ttl( $val ) ;
125
- }
126
-
127
- /**
128
- * Get current cache control ttl
129
- *
130
- * @since 1.1.5
131
- * @access public
132
- */
133
- public static function get_ttl()
134
- {
135
- return LiteSpeed_Cache_Control::get_ttl() ;
136
- }
137
-
138
- /**
139
- * Add public tag to cache
140
- *
141
- * @since 1.1.3
142
- * @access public
143
- */
144
- public static function tag_add($tags)
145
- {
146
- LiteSpeed_Cache_Tag::add($tags) ;
147
- }
148
-
149
- /**
150
- * Add vary
151
- *
152
- * @since 1.1.3
153
- * @access public
154
- */
155
- public static function vary_add($vary)
156
- {
157
- LiteSpeed_Cache_Vary::add($vary) ;
158
- }
159
-
160
- /**
161
- * Purge all action
162
- *
163
- * @since 1.1.3
164
- * @access public
165
- */
166
- public static function purge_all()
167
- {
168
- LiteSpeed_Cache_Purge::purge_all() ;
169
- }
170
-
171
- /**
172
- * Purge single action
173
- *
174
- * @since 1.3
175
- * @access public
176
- * @param int $pid The ID of a post
177
- */
178
- public static function purge_post( $pid )
179
- {
180
- LiteSpeed_Cache_Purge::purge_post( $pid ) ;
181
- }
182
-
183
- /**
184
- * Add purge tags
185
- *
186
- * @since 1.1.3
187
- * @access public
188
- */
189
- public static function purge($tags)
190
- {
191
- LiteSpeed_Cache_Purge::add($tags) ;
192
- }
193
-
194
- /**
195
- * Build a switch div html snippet
196
- *
197
- * @since 1.1.3
198
- * @access public
199
- * @param string $id
200
- * @param boolean $disabled Disable this field
201
- * @param boolean $return Return the html or echo it
202
- */
203
- public static function build_switch($id, $disabled = false, $return = false)
204
- {
205
- return LiteSpeed_Cache_Admin_Display::get_instance()->build_switch($id, $disabled, $return) ;
206
- }
207
-
208
- /**
209
- * Filter the value for checkbox via input and id (enabled/disabled)
210
- *
211
- * @since 1.1.6
212
- * @access public
213
- * @param int $input The whole input array
214
- * @param string $id The ID of the option
215
- * @return bool Filtered value
216
- */
217
- public static function parse_onoff( $input, $id )
218
- {
219
- return LiteSpeed_Cache_Admin_Settings::parse_onoff( $input, $id ) ;
220
- }
221
-
222
-
223
- /**
224
- * Hook cacheable check to cache control
225
- *
226
- * @since 1.1.3
227
- * @access public
228
- */
229
- public static function hook_control($hook)
230
- {
231
- add_action('litespeed_cache_api_control', $hook) ;
232
- }
233
-
234
- /**
235
- * Hook tag appending to tag
236
- *
237
- * @since 1.1.3
238
- * @access public
239
- */
240
- public static function hook_tag($hook)
241
- {
242
- add_action('litespeed_cache_api_tag', $hook) ;
243
- }
244
-
245
- /**
246
- * Hook vary appending to vary
247
- *
248
- * NOTE: This will add vary to rewrite rule
249
- *
250
- * @since 1.1.3
251
- * @access public
252
- */
253
- public static function hook_vary($hook)
254
- {
255
- add_action('litespeed_cache_api_vary', $hook) ;
256
- }
257
-
258
- /**
259
- * Hook purge tags appending to purge
260
- *
261
- * @since 1.1.3
262
- * @access public
263
- */
264
- public static function hook_purge($hook)
265
- {
266
- add_action('litespeed_cache_api_purge', $hook) ;
267
- }
268
-
269
- /**
270
- * Hook purge post action to purge
271
- *
272
- * @since 1.1.3
273
- * @access public
274
- */
275
- public static function hook_purge_post($hook)
276
- {
277
- add_action('litespeed_cache_api_purge_post', $hook) ;
278
- }
279
-
280
- /**
281
- * Hook not ESI template
282
- *
283
- * @since 1.1.3
284
- * @access public
285
- */
286
- public static function hook_tpl_not_esi($hook)
287
- {
288
- add_action('litespeed_cache_is_not_esi_template', $hook) ;
289
- }
290
-
291
- /**
292
- * Hook ESI template block
293
- *
294
- * @since 1.1.3
295
- * @access public
296
- */
297
- public static function hook_tpl_esi($block, $hook)
298
- {
299
- add_action('litespeed_cache_load_esi_block-' . $block, $hook) ;
300
- }
301
-
302
- /**
303
- * Hook ESI params
304
- *
305
- * @since 1.1.3
306
- * @access public
307
- */
308
- public static function hook_esi_param($block, $hook)
309
- {
310
- add_filter('litespeed_cache_sub_esi_params-' . $block, $hook) ;
311
- }
312
-
313
- /**
314
- * Hook setting tab
315
- *
316
- * @since 1.1.3
317
- * @access public
318
- */
319
- public static function hook_setting_tab($hook, $priority = 10, $args = 1)
320
- {
321
- add_filter('litespeed_cache_add_config_tab', $hook, $priority, $args) ;
322
- }
323
-
324
- /**
325
- * Hook setting saving
326
- *
327
- * @since 1.1.3
328
- * @access public
329
- */
330
- public static function hook_setting_save($hook, $priority = 10, $args = 1)
331
- {
332
- add_filter('litespeed_cache_save_options', $hook, $priority, $args) ;
333
- }
334
-
335
- /**
336
- * Hook widget default settings value
337
- *
338
- * @since 1.1.3
339
- * @access public
340
- */
341
- public static function hook_widget_default_options($hook, $priority = 10, $args = 1)
342
- {
343
- add_filter('litespeed_cache_widget_default_options', $hook, $priority, $args) ;
344
- }
345
-
346
- /**
347
- * Hook get options value
348
- *
349
- * @since 1.1.3
350
- * @access public
351
- */
352
- public static function hook_get_options($hook)
353
- {
354
- add_filter('litespeed_cache_get_options', $hook) ;
355
- }
356
-
357
- /**
358
- * Generate ESI block url
359
- *
360
- * @since 1.1.3
361
- * @access public
362
- * @param string $control Cache control tag
363
- */
364
- public static function esi_url( $block_id, $wrapper, $params = array(), $control = 'default', $silence = false )
365
- {
366
- if ( $control === 'default' ) {
367
- $control = 'private,no-vary' ;
368
- }
369
- return LiteSpeed_Cache_ESI::sub_esi_block( $block_id, $wrapper, $params, $control, $silence ) ;
370
- }
371
-
372
- /**
373
- * Log debug info
374
- *
375
- * @since 1.1.3
376
- * @access public
377
- */
378
- public static function debug($info)
379
- {
380
- LiteSpeed_Cache_Log::debug($info) ;
381
- }
382
-
383
- /**
384
- * Get ESI enable setting value
385
- *
386
- * @since 1.2.0
387
- * @access public
388
- */
389
- public static function esi_enabled()
390
- {
391
- return LiteSpeed_Cache_Router::esi_enabled() ;
392
- }
393
-
394
- /**
395
- * Get cache enable setting value
396
- *
397
- * @since 1.3
398
- * @access public
399
- */
400
- public static function cache_enabled()
401
- {
402
- return defined( 'LITESPEED_ON' ) ;
403
- }
404
-
405
- /**
406
- * Get cfg setting value
407
- *
408
- * @since 1.1.3
409
- * @access public
410
- */
411
- public static function config($id)
412
- {
413
- return LiteSpeed_Cache::config($id) ;
414
- }
415
-
416
- /**
417
- * register 3rd party detect hooks
418
- *
419
- * @since 1.1.3
420
- * @access public
421
- */
422
- public static function register($cls)
423
- {
424
- add_action('litespeed_cache_api_load_thirdparty', $cls . '::detect') ;
425
- }
426
-
427
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-cdn.class.php DELETED
@@ -1,400 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The CDN class.
5
- *
6
- * @since 1.2.3
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/includes
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- class LiteSpeed_Cache_CDN
13
- {
14
- private static $_instance ;
15
-
16
- const BYPASS = 'LITESPEED_BYPASS_CDN' ;
17
-
18
- private $content ;
19
-
20
- private $cfg_cdn ;
21
- private $cfg_url_ori ;
22
- private $cfg_cdn_url ;
23
- private $cfg_cdn_inc_img ;
24
- private $cfg_cdn_inc_css ;
25
- private $cfg_cdn_inc_js ;
26
- private $cfg_cdn_filetype ;
27
- private $cfg_cdn_exclude ;
28
-
29
- /**
30
- * Init
31
- *
32
- * @since 1.2.3
33
- * @access private
34
- */
35
- private function __construct()
36
- {
37
- LiteSpeed_Cache_Log::debug2( 'CDN init' ) ;
38
-
39
- if ( ! $this->can_cdn() ) {
40
- if ( ! defined( self::BYPASS ) ) {
41
- define( self::BYPASS, true ) ;
42
- }
43
- return ;
44
- }
45
-
46
- $this->cfg_cdn = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN ) ;
47
- if ( ! $this->cfg_cdn ) {
48
- if ( ! defined( self::BYPASS ) ) {
49
- define( self::BYPASS, true ) ;
50
- }
51
- return ;
52
- }
53
-
54
- $this->cfg_url_ori = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_ORI ) ;
55
- $this->cfg_cdn_url = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_URL ) ;
56
- if ( ! $this->cfg_url_ori || ! $this->cfg_cdn_url ) {
57
- if ( ! defined( self::BYPASS ) ) {
58
- define( self::BYPASS, true ) ;
59
- }
60
- return ;
61
- }
62
-
63
- $this->cfg_cdn_inc_img = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_INC_IMG ) ;
64
- $this->cfg_cdn_inc_css = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_INC_CSS ) ;
65
- $this->cfg_cdn_inc_js = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_INC_JS ) ;
66
- $this->cfg_cdn_filetype = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_FILETYPE ) ;
67
- if ( ! $this->cfg_cdn_inc_img && ! $this->cfg_cdn_inc_css && ! $this->cfg_cdn_inc_js && ! $this->cfg_cdn_filetype ) {
68
- if ( ! defined( self::BYPASS ) ) {
69
- define( self::BYPASS, true ) ;
70
- }
71
- return ;
72
- }
73
-
74
- $this->cfg_cdn_filetype = explode( "\n", $this->cfg_cdn_filetype ) ;
75
-
76
- $this->cfg_cdn_exclude = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_EXCLUDE ) ;
77
- $this->cfg_cdn_exclude = explode( "\n", $this->cfg_cdn_exclude ) ;
78
-
79
- if ( $this->cfg_cdn_inc_img ) {
80
- // Hook to srcset
81
- if ( function_exists( 'wp_calculate_image_srcset' ) ) {
82
- add_filter( 'wp_calculate_image_srcset', __CLASS__ . '::srcset', 999 ) ;
83
- }
84
- // Hook to mime icon
85
- add_filter( 'wp_get_attachment_image_src', __CLASS__ . '::attach_img_src', 999 ) ;
86
- add_filter( 'wp_get_attachment_url', __CLASS__ . '::url', 999 ) ;
87
- }
88
-
89
- if ( $this->cfg_cdn_inc_css ) {
90
- add_filter( 'style_loader_src', __CLASS__ . '::url', 999 ) ;
91
- }
92
-
93
- if ( $this->cfg_cdn_inc_js ) {
94
- add_filter( 'script_loader_src', __CLASS__ . '::url', 999 ) ;
95
- }
96
-
97
- }
98
-
99
- /**
100
- * Check if the host is the CDN internal host
101
- *
102
- * @since 1.2.3
103
- *
104
- */
105
- public static function internal( $host )
106
- {
107
- if ( defined( self::BYPASS ) ) {
108
- return false ;
109
- }
110
-
111
- if ( ! defined( 'LITESPEED_CDN_HOST' ) ) {
112
- $instance = self::get_instance() ;
113
- define( 'LITESPEED_CDN_HOST', parse_url( $instance->cfg_cdn_url, PHP_URL_HOST ) ) ;
114
- }
115
-
116
- return $host === LITESPEED_CDN_HOST ;
117
- }
118
-
119
- /**
120
- * Run CDN process
121
- * NOTE: As this is after cache finalized, can NOT set any cache control anymore
122
- *
123
- * @since 1.2.3
124
- * @access public
125
- * @return string The content that is after optimization
126
- */
127
- public static function run( $content )
128
- {
129
- $instance = self::get_instance() ;
130
- $instance->content = $content ;
131
-
132
- $instance->_process() ;
133
- return $instance->content ;
134
- }
135
-
136
- /**
137
- * Check if it can use CDN replacement
138
- *
139
- * @since 1.2.3
140
- * @access public
141
- */
142
- public function can_cdn()
143
- {
144
- if ( is_admin() ) {
145
- return false ;
146
- }
147
-
148
- if ( is_feed() ) {
149
- return false ;
150
- }
151
-
152
- if ( is_preview() ) {
153
- return false ;
154
- }
155
-
156
- return true ;
157
- }
158
-
159
- /**
160
- * Replace CDN url
161
- *
162
- * @since 1.2.3
163
- * @access private
164
- */
165
- private function _process()
166
- {
167
- if ( defined( self::BYPASS ) ) {
168
- LiteSpeed_Cache_Log::debug2( 'CDN bypass' ) ;
169
- return ;
170
- }
171
-
172
- LiteSpeed_Cache_Log::debug( 'CDN _process' ) ;
173
-
174
- // Start replacing img src
175
- if ( $this->cfg_cdn_inc_img ) {
176
- $this->_replace_img() ;
177
- $this->_replace_inline_css() ;
178
- }
179
-
180
- if ( $this->cfg_cdn_filetype ) {
181
- $this->_replace_file_types() ;
182
- }
183
-
184
- }
185
-
186
- /**
187
- * Parse all file types
188
- *
189
- * @since 1.2.3
190
- * @access private
191
- */
192
- private function _replace_file_types()
193
- {
194
- preg_match_all( '#(src|data-src|href)\s*=\s*[\'"]([^\'"]+)[\'"]#i', $this->content, $matches ) ;
195
- if ( empty( $matches[ 2 ] ) ) {
196
- return ;
197
- }
198
- foreach ( $matches[ 2 ] as $k => $url ) {
199
- $url_parsed = parse_url( $url ) ;
200
- if ( empty( $url_parsed[ 'path' ] ) ) {
201
- continue ;
202
- }
203
- $postfix = substr( $url_parsed[ 'path' ], strrpos( $url_parsed[ 'path' ], '.' ) ) ;
204
- if ( ! in_array( $postfix, $this->cfg_cdn_filetype ) ) {
205
- continue ;
206
- }
207
-
208
- LiteSpeed_Cache_Log::debug2( 'CDN matched file_type ' . $postfix . ' : ' . $url ) ;
209
-
210
- if( ! $url2 = $this->rewrite( $url ) ) {
211
- continue ;
212
- }
213
-
214
- $attr = str_replace( $url, $url2, $matches[ 0 ][ $k ] ) ;
215
- $this->content = str_replace( $matches[ 0 ][ $k ], $attr, $this->content ) ;
216
- }
217
- }
218
-
219
- /**
220
- * Parse all images
221
- *
222
- * @since 1.2.3
223
- * @access private
224
- */
225
- private function _replace_img()
226
- {
227
- preg_match_all( '#<img([^>]+?)src=([\'"\\\]*)([^\'"\s\\\>]+)([\'"\\\]*)([^>]*)>#i', $this->content, $matches ) ;
228
- foreach ( $matches[ 3 ] as $k => $url ) {
229
- // Check if is a DATA-URI
230
- if ( strpos( $url, 'data:image' ) !== false ) {
231
- continue ;
232
- }
233
-
234
- if ( ! $url2 = $this->rewrite( $url ) ) {
235
- continue ;
236
- }
237
-
238
- $html_snippet = sprintf(
239
- '<img %1$s src=%2$s %3$s>',
240
- $matches[ 1 ][ $k ],
241
- $matches[ 2 ][ $k ] . $url2 . $matches[ 4 ][ $k ],
242
- $matches[ 5 ][ $k ]
243
- ) ;
244
- $this->content = str_replace( $matches[ 0 ][ $k ], $html_snippet, $this->content ) ;
245
- }
246
- }
247
-
248
- /**
249
- * Parse and replace all inline styles containing url()
250
- *
251
- * @since 1.2.3
252
- * @access private
253
- */
254
- private function _replace_inline_css()
255
- {
256
- // preg_match_all( '/url\s*\(\s*(?!["\']?data:)(?![\'|\"]?[\#|\%|])([^)]+)\s*\)([^;},\s]*)/i', $this->content, $matches ) ;
257
- preg_match_all( '#url\((?![\'"]?data)[\'"]?([^\)\'"]+)[\'"]?\)#i', $this->content, $matches ) ;
258
- foreach ( $matches[ 1 ] as $k => $url ) {
259
- $url = str_replace( array( ' ', '\t', '\n', '\r', '\0', '\x0B', '"', "'", '&quot;', '&#039;' ), '', $url ) ;
260
-
261
- if ( ! $url2 = $this->rewrite( $url ) ) {
262
- continue ;
263
- }
264
- $attr = str_replace( $matches[ 1 ][ $k ], $url2, $matches[ 0 ][ $k ] ) ;
265
- $this->content = str_replace( $matches[ 0 ][ $k ], $attr, $this->content ) ;
266
- }
267
- }
268
-
269
- /**
270
- * Hook to wp_get_attachment_image_src
271
- *
272
- * @since 1.2.3
273
- * @access public
274
- * @param array $img The URL of the attachment image src, the width, the height
275
- * @return array
276
- */
277
- public static function attach_img_src( $img )
278
- {
279
- $instance = self::get_instance() ;
280
- if ( $img && $url = $instance->rewrite( $img[ 0 ] ) ) {
281
- $img[ 0 ] = $url ;
282
- }
283
- return $img ;
284
- }
285
-
286
- /**
287
- * Try to rewrite one URL with CDN
288
- *
289
- * @since 1.2.3
290
- * @access public
291
- * @param string $url
292
- * @return string
293
- */
294
- public static function url( $url )
295
- {
296
- $instance = self::get_instance() ;
297
- if ( $url && $url2 = $instance->rewrite( $url ) ) {
298
- $url = $url2 ;
299
- }
300
- return $url ;
301
- }
302
-
303
- /**
304
- * Hook to replace WP responsive images
305
- *
306
- * @since 1.2.3
307
- * @access public
308
- * @param array $srcs
309
- * @return array
310
- */
311
- public static function srcset( $srcs )
312
- {
313
- if ( $srcs ) {
314
- $instance = self::get_instance() ;
315
- foreach ( $srcs as $w => $data ) {
316
- if( ! $url = $instance->rewrite( $data[ 'url' ] ) ) {
317
- continue ;
318
- }
319
- $srcs[ $w ][ 'url' ] = $url ;
320
- }
321
- }
322
- return $srcs ;
323
- }
324
-
325
- /**
326
- * Replace URL to CDN URL
327
- *
328
- * @since 1.2.3
329
- * @access public
330
- * @param string $url
331
- * @return string Replaced URL
332
- */
333
- public function rewrite( $url )
334
- {
335
- LiteSpeed_Cache_Log::debug2( 'CDN: try rewriting ' . $url ) ;
336
- $url_parsed = parse_url( $url ) ;
337
-
338
- // Only images under wp-cotnent/wp-includes can be replaced
339
- if ( stripos( $url_parsed[ 'path' ], LSWCP_CONTENT_FOLDER ) === false && stripos( $url_parsed[ 'path' ], 'wp-includes' ) === false && stripos( $url_parsed[ 'path' ], '/min/' ) === false ) {
340
- if ( defined( 'UPLOADS' ) && stripos( $url_parsed[ 'path' ], UPLOADS ) === false ) {
341
- LiteSpeed_Cache_Log::debug2( 'CDN: rewriting failed: path not match ' ) ;
342
- return false ;
343
- }
344
- }
345
-
346
- // Check if is external url
347
- if ( ! empty( $url_parsed[ 'host' ] ) && ! LiteSpeed_Cache_Utility::internal( $url_parsed[ 'host' ] ) ) {
348
- LiteSpeed_Cache_Log::debug2( 'CDN: rewriting failed: host not internal' ) ;
349
- return false ;
350
- }
351
-
352
- if ( $this->cfg_cdn_exclude ) {
353
- foreach ( $this->cfg_cdn_exclude as $exclude ) {
354
- if ( stripos( $url, $exclude ) !== false ) {
355
- LiteSpeed_Cache_Log::debug2( 'CDN: Abort excludes ' . $exclude ) ;
356
- return false ;
357
- }
358
- }
359
- }
360
-
361
- // Fill full url before replacement
362
- if ( empty( $url_parsed[ 'host' ] ) ) {
363
- $url = LiteSpeed_Cache_Utility::uri2url( $url ) ;
364
- LiteSpeed_Cache_Log::debug2( 'CDN: fill before rewritten: ' . $url ) ;
365
-
366
- $url_parsed = parse_url( $url ) ;
367
- }
368
-
369
- $scheme = ! empty( $url_parsed[ 'scheme' ] ) ? $url_parsed[ 'scheme' ] . ':' : '' ;
370
- if ( $scheme ) {
371
- LiteSpeed_Cache_Log::debug2( 'CDN: scheme from url: ' . $scheme ) ;
372
- }
373
-
374
- // Now lets replace CDN url
375
- $url = str_replace( $scheme . $this->cfg_url_ori, $this->cfg_cdn_url, $url ) ;
376
- LiteSpeed_Cache_Log::debug2( 'CDN: after rewritten: ' . $url ) ;
377
-
378
- return $url ;
379
- }
380
-
381
- /**
382
- * Get the current instance object.
383
- *
384
- * @since 1.2.3
385
- * @access public
386
- * @return Current class instance.
387
- */
388
- public static function get_instance()
389
- {
390
- if ( ! isset(self::$_instance) ) {
391
- self::$_instance = new self() ;
392
- }
393
-
394
- return self::$_instance ;
395
- }
396
-
397
- }
398
-
399
-
400
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-config.class.php DELETED
@@ -1,819 +0,0 @@
1
- <?php
2
- /**
3
- * The core plugin config class.
4
- *
5
- * This maintains all the options and settings for this plugin.
6
- *
7
- * @since 1.0.0
8
- * @package LiteSpeed_Cache
9
- * @subpackage LiteSpeed_Cache/includes
10
- * @author LiteSpeed Technologies <info@litespeedtech.com>
11
- */
12
- class LiteSpeed_Cache_Config
13
- {
14
- private static $_instance ;
15
-
16
- const OPTION_NAME = 'litespeed-cache-conf' ;
17
- const VARY_GROUP = 'litespeed-cache-vary-group' ;
18
- const ITEM_OPTM_CSS = 'litespeed-optm-css' ;// separate critical css that should be stored in option table
19
- const VAL_OFF = 0 ;
20
- const VAL_ON = 1 ;
21
- const VAL_ON2 = 2 ;
22
-
23
- const LOG_LEVEL_NONE = 0 ;
24
- const LOG_LEVEL_ERROR = 1 ;
25
- const LOG_LEVEL_NOTICE = 2 ;
26
- const LOG_LEVEL_INFO = 3 ;
27
- const LOG_LEVEL_DEBUG = 4 ;
28
- const OPID_VERSION = 'version' ;
29
- const OPID_ENABLED_RADIO = 'radio_select' ;
30
-
31
- const OPID_CACHE_PRIV = 'cache_priv' ;
32
- const OPID_CACHE_COMMENTER = 'cache_commenter' ;
33
- const OPID_CACHE_REST = 'cache_rest' ;
34
- const OPID_CACHE_PAGE_LOGIN = 'cache_page_login' ;
35
- const OPID_CACHE_FAVICON = 'cache_favicon' ;
36
- const OPID_CACHE_RES = 'cache_resources' ;
37
- const OPID_CACHE_MOBILE = 'mobileview_enabled' ;
38
- const ID_MOBILEVIEW_LIST = 'mobileview_rules' ;
39
- const OPID_CACHE_URI_PRIV = 'cache_uri_priv' ;
40
- const OPID_CACHE_BROWSER = 'cache_browser' ;
41
-
42
- const OPID_PURGE_ON_UPGRADE = 'purge_upgrade' ;
43
- const OPID_TIMED_URLS = 'timed_urls' ;
44
- const OPID_TIMED_URLS_TIME = 'timed_urls_time' ;
45
-
46
- const OPID_LOGIN_COOKIE = 'login_cookie' ;
47
- const OPID_CHECK_ADVANCEDCACHE = 'check_advancedcache' ;
48
- // do NOT set default options for these three, it is used for admin.
49
- const ID_NOCACHE_COOKIES = 'nocache_cookies' ;
50
- const ID_NOCACHE_USERAGENTS = 'nocache_useragents' ;
51
- const OPID_DEBUG = 'debug' ;
52
- const OPID_ADMIN_IPS = 'admin_ips' ;
53
- const OPID_DEBUG_LEVEL = 'debug_level' ;
54
- const OPID_LOG_FILE_SIZE = 'log_file_size' ;
55
- const OPID_HEARTBEAT = 'heartbeat' ;
56
- const OPID_DEBUG_COOKIE = 'debug_cookie' ;
57
- const OPID_COLLAPS_QS = 'collaps_qs' ;
58
- const OPID_LOG_FILTERS = 'log_filters' ;
59
- const OPID_LOG_IGNORE_FILTERS = 'log_ignore_filters' ;
60
- const OPID_LOG_IGNORE_PART_FILTERS = 'log_ignore_part_filters' ;
61
-
62
- const OPID_PUBLIC_TTL = 'public_ttl' ;
63
- const OPID_PRIVATE_TTL = 'private_ttl' ;
64
- const OPID_FRONT_PAGE_TTL = 'front_page_ttl' ;
65
- const OPID_FEED_TTL = 'feed_ttl' ;
66
- const OPID_403_TTL = '403_ttl' ;
67
- const OPID_404_TTL = '404_ttl' ;
68
- const OPID_500_TTL = '500_ttl' ;
69
- const OPID_PURGE_BY_POST = 'purge_by_post' ;
70
- const OPID_ESI_ENABLE = 'esi_enabled' ;
71
- const OPID_ESI_CACHE_ADMBAR = 'esi_cached_admbar' ;
72
- const OPID_ESI_CACHE_COMMFORM = 'esi_cached_commform' ;
73
- const PURGE_ALL_PAGES = '-' ;
74
- const PURGE_FRONT_PAGE = 'F' ;
75
- const PURGE_HOME_PAGE = 'H' ;
76
- const PURGE_PAGES = 'PGS' ;
77
- const PURGE_PAGES_WITH_RECENT_POSTS = 'PGSRP' ;
78
- const PURGE_AUTHOR = 'A' ;
79
- const PURGE_YEAR = 'Y' ;
80
- const PURGE_MONTH = 'M' ;
81
- const PURGE_DATE = 'D' ;
82
- const PURGE_TERM = 'T' ; // include category|tag|tax
83
- const PURGE_POST_TYPE = 'PT' ;
84
- const OPID_EXCLUDES_URI = 'excludes_uri' ;
85
- const OPID_EXCLUDES_QS = 'excludes_qs' ;
86
- const OPID_EXCLUDES_CAT = 'excludes_cat' ;
87
- const OPID_EXCLUDES_TAG = 'excludes_tag' ;
88
-
89
- const OPID_CSS_MINIFY = 'css_minify' ;
90
- const OPID_CSS_COMBINE = 'css_combine' ;
91
- const OPID_CSS_HTTP2 = 'css_http2' ;
92
- const OPID_CSS_EXCLUDES = 'css_exclude' ;
93
- const OPID_JS_MINIFY = 'js_minify' ;
94
- const OPID_JS_COMBINE = 'js_combine' ;
95
- const OPID_JS_HTTP2 = 'js_http2' ;
96
- const OPID_JS_EXCLUDES = 'js_exclude' ;
97
- const OPID_OPTIMIZE_TTL = 'optimize_ttl' ;
98
- const OPID_HTML_MINIFY = 'html_minify' ;
99
- const OPID_OPTM_QS_RM = 'optm_qs_rm' ;
100
- const OPID_OPTM_GGFONTS_RM = 'optm_ggfonts_rm' ;
101
- const OPID_OPTM_CSS_ASYNC = 'optm_css_async' ;
102
- const OPID_OPTM_JS_DEFER = 'optm_js_defer' ;
103
- const OPID_OPTM_EMOJI_RM = 'optm_emoji_rm' ;
104
-
105
- const OPID_CDN = 'cdn' ;
106
- const OPID_CDN_ORI = 'cdn_ori' ;
107
- const OPID_CDN_URL = 'cdn_url' ;
108
- const OPID_CDN_INC_IMG = 'cdn_inc_img' ;
109
- const OPID_CDN_INC_CSS = 'cdn_inc_css' ;
110
- const OPID_CDN_INC_JS = 'cdn_inc_js' ;
111
- const OPID_CDN_FILETYPE = 'cdn_filetype' ;
112
- const OPID_CDN_EXCLUDE = 'cdn_exclude' ;
113
-
114
- const HASH = 'hash' ;
115
-
116
- const NETWORK_OPID_ENABLED = 'network_enabled' ;
117
- const NETWORK_OPID_USE_PRIMARY = 'use_primary_settings' ;
118
-
119
- const CRWL_POSTS = 'crawler_include_posts' ;
120
- const CRWL_PAGES = 'crawler_include_pages' ;
121
- const CRWL_CATS = 'crawler_include_cats' ;
122
- const CRWL_TAGS = 'crawler_include_tags' ;
123
- const CRWL_EXCLUDES_CPT = 'crawler_excludes_cpt' ;
124
- const CRWL_ORDER_LINKS = 'crawler_order_links' ;
125
- const CRWL_USLEEP = 'crawler_usleep' ;
126
- const CRWL_RUN_DURATION = 'crawler_run_duration' ;
127
- const CRWL_RUN_INTERVAL = 'crawler_run_interval' ;
128
- const CRWL_CRAWL_INTERVAL = 'crawler_crawl_interval' ;
129
- const CRWL_THREADS = 'crawler_threads' ;
130
- const CRWL_LOAD_LIMIT = 'crawler_load_limit' ;
131
- const CRWL_DOMAIN_IP = 'crawler_domain_ip' ;
132
- const CRWL_CUSTOM_SITEMAP = 'crawler_custom_sitemap' ;
133
-
134
- const CRWL_CRON_ACTIVE = 'crawler_cron_active' ;
135
-
136
- const CRWL_DATE_DESC = 'date_desc' ;
137
- const CRWL_DATE_ASC = 'date_asc' ;
138
- const CRWL_ALPHA_DESC = 'alpha_desc' ;
139
- const CRWL_ALPHA_ASC = 'alpha_asc' ;
140
-
141
- protected $options ;
142
- protected $vary_groups ;
143
- protected $purge_options ;
144
-
145
- /**
146
- * Initialize the class and set its properties.
147
- *
148
- * @since 1.0.0
149
- * @access private
150
- */
151
- private function __construct()
152
- {
153
- if ( is_multisite() ) {
154
- $options = $this->construct_multisite_options() ;
155
- }
156
- else {
157
- $options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
158
- }
159
-
160
- $this->options = $options ;
161
- $this->purge_options = explode('.', $options[ self::OPID_PURGE_BY_POST ] ) ;
162
-
163
- // Init global const cache on set
164
- if ( $this->options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON
165
- // || ( is_multisite() && is_network_admin() && current_user_can( 'manage_network_options' ) && $this->options[ LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ] ) todo: need to check when primary is off and network is on, if can manage
166
- ) {
167
- defined( 'LITESPEED_ALLOWED' ) && ! defined( 'LITESPEED_ON' ) && define( 'LITESPEED_ON', true ) ;
168
- }
169
-
170
- // Check advanced_cache set
171
- if ( isset( $this->options[ self::OPID_CHECK_ADVANCEDCACHE ] ) && $this->options[ self::OPID_CHECK_ADVANCEDCACHE ] === false && ! defined( 'LSCACHE_ADV_CACHE' ) ) {
172
- define( 'LSCACHE_ADV_CACHE', true ) ;
173
- }
174
-
175
- // Vary group settings
176
- $this->vary_groups = (array) get_option( self::VARY_GROUP ) ;
177
-
178
- // Set security key if not initialized yet
179
- if ( isset( $this->options[ self::HASH ] ) && empty( $this->options[ self::HASH ] ) ) {
180
- $this->update_options( array( self::HASH => Litespeed_String::rrand( 32 ) ) ) ;
181
- }
182
-
183
- }
184
-
185
- /**
186
- * For multisite installations, the single site options need to be updated with the network wide options.
187
- *
188
- * @since 1.0.13
189
- * @access private
190
- * @return array The updated options.
191
- */
192
- private function construct_multisite_options()
193
- {
194
- $site_options = get_site_option( self::OPTION_NAME ) ;
195
-
196
- if ( ! function_exists('is_plugin_active_for_network') ) { // todo: check if needed
197
- require_once(ABSPATH . '/wp-admin/includes/plugin.php') ;
198
- }
199
-
200
- $options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
201
-
202
- // If don't have site options
203
- if ( ! $site_options || ! is_array( $site_options ) || ! is_plugin_active_for_network( 'litespeed-cache/litespeed-cache.php' ) ) {
204
- if ( $options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON2 ) { // Default to cache on
205
- defined( 'LITESPEED_ALLOWED' ) && ! defined( 'LITESPEED_ON' ) && define( 'LITESPEED_ON', true ) ;
206
- }
207
- return $options ;
208
- }
209
-
210
- // If network set to use primary setting
211
- if ( ! empty ( $site_options[ self::NETWORK_OPID_USE_PRIMARY ] ) ) {
212
-
213
- // save temparary cron setting
214
- $CRWL_CRON_ACTIVE = $options[ self::CRWL_CRON_ACTIVE ] ;
215
-
216
- // Get the primary site settings
217
- $options = get_blog_option( BLOG_ID_CURRENT_SITE, LiteSpeed_Cache_Config::OPTION_NAME, array() ) ;
218
-
219
- // crawler cron activation is separated
220
- $options[ self::CRWL_CRON_ACTIVE ] = $CRWL_CRON_ACTIVE ;
221
- }
222
-
223
- // If use network setting
224
- if ( $options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON2 && $site_options[ self::NETWORK_OPID_ENABLED ] ) {
225
- defined( 'LITESPEED_ALLOWED' ) && ! defined( 'LITESPEED_ON' ) && define( 'LITESPEED_ON', true ) ;
226
- }
227
- // Set network eanble to on
228
- if ( $site_options[ self::NETWORK_OPID_ENABLED ] ) {
229
- ! defined( 'LITESPEED_NETWORK_ON' ) && define( 'LITESPEED_NETWORK_ON', true ) ;
230
- }
231
-
232
- // These two are not for single blog options
233
- unset( $site_options[ self::NETWORK_OPID_ENABLED ] ) ;
234
- unset( $site_options[ self::NETWORK_OPID_USE_PRIMARY ] ) ;
235
-
236
- // Append site options to single blog options
237
- $options = array_merge( $options, $site_options ) ;
238
-
239
- return $options ;
240
- }
241
-
242
- /**
243
- * Get the list of configured options for the blog.
244
- *
245
- * @since 1.0.0
246
- * @access public
247
- * @return array The list of configured options.
248
- */
249
- public function get_options()
250
- {
251
- return $this->options ;
252
- }
253
-
254
- /**
255
- * Get the selected configuration option.
256
- *
257
- * @since 1.0.0
258
- * @access public
259
- * @param string $id Configuration ID.
260
- * @return mixed Selected option if set, NULL if not.
261
- */
262
- public function get_option( $id )
263
- {
264
- if ( isset( $this->options[$id] ) ) {
265
- return $this->options[$id] ;
266
- }
267
- if ( LiteSpeed_Cache_Log::initialized() ) {
268
- LiteSpeed_Cache_Log::debug( 'Invalid option ID ' . $id ) ;
269
- }
270
- return NULL ;
271
- }
272
-
273
- /**
274
- * Set the configured options.
275
- *
276
- * NOTE: No validation here. Do validate before use this function with LiteSpeed_Cache_Admin_Settings->validate_plugin_settings().
277
- *
278
- * @since 1.1.3
279
- * @access public
280
- * @param array $new_cfg The new settings to update, which will be update $this->options too.
281
- * @return array The result of update.
282
- */
283
- public function update_options( $new_cfg = array() )
284
- {
285
- if ( ! empty( $new_cfg ) ) {
286
- $this->options = array_merge( $this->options, $new_cfg ) ;
287
- }
288
- return update_option( self::OPTION_NAME, $this->options ) ;
289
- }
290
-
291
- /**
292
- * Save frontend url to private cached uri/no cache uri
293
- *
294
- * @since 1.3
295
- * @access public
296
- */
297
- public static function frontend_save()
298
- {
299
- if ( empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
300
- exit( 'no referer' ) ;
301
- }
302
-
303
- if ( empty( $_GET[ 'type' ] ) ) {
304
- exit( 'no type' ) ;
305
- }
306
-
307
- $id = $_GET[ 'type' ] == 'nocache' ? self::OPID_EXCLUDES_URI : self::OPID_CACHE_URI_PRIV ;
308
- $instance = self::get_instance() ;
309
- $list = $instance->get_option( $id ) ;
310
-
311
- $list = explode( "\n", $list ) ;
312
- $list[] = $_SERVER[ 'HTTP_REFERER' ] ;
313
- $list = array_map( 'LiteSpeed_Cache_Utility::make_relative', $list ) ;// Remove domain
314
- $list = array_unique( $list ) ;
315
- $list = array_filter( $list ) ;
316
- $list = implode( "\n", $list ) ;
317
-
318
- $instance->update_options( array( $id => $list ) ) ;
319
-
320
- // Purge this page & redirect
321
- LiteSpeed_Cache_Purge::frontend_purge() ;
322
- exit() ;
323
- }
324
-
325
- /**
326
- * Check if one user role is in vary group settings
327
- *
328
- * @since 1.2.0
329
- * @access public
330
- * @param string $role The user role
331
- * @return int The set value if already set
332
- */
333
- public function in_vary_group( $role )
334
- {
335
- $group = 0 ;
336
- if ( array_key_exists( $role, $this->vary_groups ) ) {
337
- $group = $this->vary_groups[ $role ] ;
338
- }
339
- elseif ( $role === 'administrator' ) {
340
- $group = 99 ;
341
- }
342
-
343
- return $group ;
344
- }
345
-
346
- /**
347
- * Get the configured purge options.
348
- *
349
- * @since 1.0.0
350
- * @access public
351
- * @return array The list of purge options.
352
- */
353
- public function get_purge_options()
354
- {
355
- return $this->purge_options ;
356
- }
357
-
358
- /**
359
- * Check if the flag type of posts should be purged on updates.
360
- *
361
- * @since 1.0.0
362
- * @access public
363
- * @param string $flag Post type. Refer to LiteSpeed_Cache_Config::PURGE_*
364
- * @return boolean True if the post type should be purged, false otherwise.
365
- */
366
- public function purge_by_post( $flag )
367
- {
368
- return in_array( $flag, $this->purge_options ) ;
369
- }
370
-
371
- /**
372
- * Gets the default single site options
373
- *
374
- * @since 1.0.0
375
- * @access public
376
- * @param bool $include_thirdparty Whether to include the thirdparty options.
377
- * @return array An array of the default options.
378
- */
379
- public function get_default_options($include_thirdparty = true)
380
- {
381
- $default_purge_options = array(
382
- self::PURGE_FRONT_PAGE,
383
- self::PURGE_HOME_PAGE,
384
- self::PURGE_PAGES,
385
- self::PURGE_PAGES_WITH_RECENT_POSTS,
386
- self::PURGE_AUTHOR,
387
- self::PURGE_MONTH,
388
- self::PURGE_TERM,
389
- self::PURGE_POST_TYPE
390
- ) ;
391
- sort($default_purge_options) ;
392
-
393
- //For multi site, default is 2 (Use Network Admin Settings). For single site, default is 1 (Enabled).
394
- if ( is_multisite() ) {
395
- $default_radio = 2 ;
396
- }
397
- else {
398
- $default_radio = 1 ;
399
- }
400
-
401
- $default_options = array(
402
- self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
403
- self::OPID_ENABLED_RADIO => $default_radio,
404
- self::OPID_PURGE_ON_UPGRADE => true,
405
- self::OPID_CACHE_PRIV => true,
406
- self::OPID_CACHE_COMMENTER => true,
407
- self::OPID_CACHE_REST => true,
408
- self::OPID_CACHE_PAGE_LOGIN => true,
409
- self::OPID_TIMED_URLS => '',
410
- self::OPID_TIMED_URLS_TIME => '',
411
- self::OPID_CACHE_FAVICON => true,
412
- self::OPID_CACHE_RES => true,
413
- self::OPID_CACHE_MOBILE => false,
414
- self::ID_MOBILEVIEW_LIST => false,
415
- self::OPID_CACHE_URI_PRIV => '',
416
- self::OPID_CACHE_BROWSER => false,
417
-
418
- self::OPID_LOGIN_COOKIE => '',
419
- self::OPID_CHECK_ADVANCEDCACHE => true,
420
- self::OPID_DEBUG => self::LOG_LEVEL_NONE,
421
- self::OPID_ADMIN_IPS => '127.0.0.1',
422
- self::OPID_DEBUG_LEVEL => false,
423
- self::OPID_LOG_FILE_SIZE => 30,
424
- self::OPID_HEARTBEAT => true,
425
- self::OPID_DEBUG_COOKIE => false,
426
- self::OPID_COLLAPS_QS => false,
427
- self::OPID_LOG_FILTERS => false,
428
- self::OPID_LOG_IGNORE_FILTERS => "gettext\ngettext_with_context\nget_the_terms\nget_term",
429
- self::OPID_LOG_IGNORE_PART_FILTERS => "i18n\nlocale\nsettings\noption",
430
- self::OPID_PUBLIC_TTL => 604800,
431
- self::OPID_PRIVATE_TTL => 1800,
432
- self::OPID_FRONT_PAGE_TTL => 604800,
433
- self::OPID_FEED_TTL => 0,
434
- self::OPID_403_TTL => 3600,
435
- self::OPID_404_TTL => 3600,
436
- self::OPID_500_TTL => 3600,
437
- self::OPID_PURGE_BY_POST => implode('.', $default_purge_options),
438
- self::OPID_EXCLUDES_URI => '',
439
- self::OPID_EXCLUDES_QS => '',
440
- self::OPID_EXCLUDES_CAT => '',
441
- self::OPID_EXCLUDES_TAG => '',
442
-
443
- self::OPID_CSS_MINIFY => false,
444
- self::OPID_CSS_COMBINE => false,
445
- self::OPID_CSS_HTTP2 => false,
446
- self::OPID_CSS_EXCLUDES => '',
447
- self::OPID_JS_MINIFY => false,
448
- self::OPID_JS_COMBINE => false,
449
- self::OPID_JS_HTTP2 => false,
450
- self::OPID_JS_EXCLUDES => '',
451
- self::OPID_OPTIMIZE_TTL => 604800,
452
- self::OPID_HTML_MINIFY => false,
453
- self::OPID_OPTM_QS_RM => false,
454
- self::OPID_OPTM_GGFONTS_RM => false,
455
- self::OPID_OPTM_CSS_ASYNC => false,
456
- self::OPID_OPTM_JS_DEFER => false,
457
- self::OPID_OPTM_EMOJI_RM => false,
458
-
459
- self::OPID_CDN => false,
460
- self::OPID_CDN_ORI => '',
461
- self::OPID_CDN_URL => '',
462
- self::OPID_CDN_INC_IMG => false,
463
- self::OPID_CDN_INC_CSS => false,
464
- self::OPID_CDN_INC_JS => false,
465
- self::OPID_CDN_FILETYPE => ".aac\n.css\n.eot\n.gif\n.jpeg\n.js\n.jpg\n.less\n.mp3\n.mp4\n.ogg\n.otf\n.pdf\n.png\n.svg\n.ttf\n.woff",
466
- self::OPID_CDN_EXCLUDE => '',
467
-
468
- self::HASH => '',
469
-
470
- self::ID_NOCACHE_COOKIES => '',
471
- self::ID_NOCACHE_USERAGENTS => '',
472
- self::CRWL_POSTS => true,
473
- self::CRWL_PAGES => true,
474
- self::CRWL_CATS => true,
475
- self::CRWL_TAGS => true,
476
- self::CRWL_EXCLUDES_CPT => '',
477
- self::CRWL_ORDER_LINKS => self::CRWL_DATE_DESC,
478
- self::CRWL_USLEEP => 500,
479
- self::CRWL_RUN_DURATION => 400,
480
- self::CRWL_RUN_INTERVAL => 600,
481
- self::CRWL_CRAWL_INTERVAL => 302400,
482
- self::CRWL_THREADS => 3,
483
- self::CRWL_LOAD_LIMIT => 1,
484
- self::CRWL_DOMAIN_IP => '',
485
- self::CRWL_CUSTOM_SITEMAP => '',
486
- self::CRWL_CRON_ACTIVE => false,
487
- ) ;
488
-
489
- if ( LSWCP_ESI_SUPPORT ) {
490
- $default_options[self::OPID_ESI_ENABLE] = false ;
491
- $default_options[self::OPID_ESI_CACHE_ADMBAR] = true ;
492
- $default_options[self::OPID_ESI_CACHE_COMMFORM] = true ;
493
- }
494
-
495
- if ( ! $include_thirdparty ) {
496
- return $default_options ;
497
- }
498
-
499
- $tp_options = $this->get_thirdparty_options($default_options) ;
500
- if ( ! isset($tp_options) || ! is_array($tp_options) ) {
501
- return $default_options ;
502
- }
503
- return array_merge($default_options, $tp_options) ;
504
- }
505
-
506
- /**
507
- * Gets the default network options
508
- *
509
- * @since 1.0.11
510
- * @access protected
511
- * @return array An array of the default options.
512
- */
513
- protected function get_default_site_options()
514
- {
515
- $default_site_options = array(
516
- self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
517
- self::NETWORK_OPID_ENABLED => false,
518
- self::NETWORK_OPID_USE_PRIMARY => false,
519
- self::OPID_PURGE_ON_UPGRADE => true,
520
- self::OPID_CACHE_FAVICON => true,
521
- self::OPID_CACHE_RES => true,
522
- self::OPID_CACHE_MOBILE => 0, // todo: why not false
523
- self::ID_MOBILEVIEW_LIST => false,
524
- self::OPID_CACHE_BROWSER => false,
525
- self::OPID_LOGIN_COOKIE => '',
526
- self::OPID_CHECK_ADVANCEDCACHE => true,
527
- self::ID_NOCACHE_COOKIES => '',
528
- self::ID_NOCACHE_USERAGENTS => '',
529
- ) ;
530
- return $default_site_options ;
531
- }
532
-
533
- /**
534
- * Get the plugin's site wide options.
535
- *
536
- * If the site wide options are not set yet, set it to default.
537
- *
538
- * @since 1.0.2
539
- * @access public
540
- * @return array Returns the current site options.
541
- */
542
- public function get_site_options()
543
- {
544
- if ( ! is_multisite() ) {
545
- return null ;
546
- }
547
- $site_options = get_site_option( self::OPTION_NAME ) ;
548
-
549
- if ( isset( $site_options ) && is_array( $site_options ) ) {
550
- return $site_options ;
551
- }
552
-
553
- $default_site_options = $this->get_default_site_options() ;
554
- add_site_option( self::OPTION_NAME, $default_site_options ) ;
555
-
556
- return $default_site_options ;
557
- }
558
-
559
- /**
560
- * Gets the third party options.
561
- * Will also strip the options that are actually normal options.
562
- *
563
- * @access public
564
- * @since 1.0.9
565
- * @param array $options Optional. The default options to compare against.
566
- * @return mixed boolean on failure, array of keys on success.
567
- */
568
- public function get_thirdparty_options($options = null)
569
- {
570
- $tp_options = apply_filters('litespeed_cache_get_options', array()) ;
571
- if ( empty($tp_options) ) {
572
- return false ;
573
- }
574
- if ( ! isset($options) ) {
575
- $options = $this->get_default_options(false) ;
576
- }
577
- return array_diff_key($tp_options, $options) ;
578
- }
579
-
580
- /**
581
- * Helper function to convert the options to replicate the input format.
582
- *
583
- * The only difference is the checkboxes.
584
- *
585
- * @since 1.0.15
586
- * @access public
587
- * @param array $options The options array to port to input format.
588
- * @return array $options The options array with input format.
589
- */
590
- public static function convert_options_to_input($options)
591
- {
592
- foreach ( $options as $key => $val ) {
593
- if ( $val === true ) {
594
- $options[$key] = self::VAL_ON ;
595
- }
596
- elseif ( $val === false ) {
597
- $options[$key] = self::VAL_OFF ;
598
- }
599
- }
600
- if ( isset($options[self::OPID_PURGE_BY_POST]) ) {
601
- $purge_opts = explode('.', $options[self::OPID_PURGE_BY_POST]) ;
602
-
603
- foreach ($purge_opts as $purge_opt) {
604
- $options['purge_' . $purge_opt] = self::VAL_ON ;
605
- }
606
- }
607
-
608
- return $options ;
609
- }
610
-
611
- /**
612
- * Get the difference between the current options and the default options.
613
- *
614
- * @since 1.0.11
615
- * @access public
616
- * @param array $default_options The default options.
617
- * @param array $options The current options.
618
- * @return array New options.
619
- */
620
- public static function option_diff($default_options, $options)
621
- {
622
- $dkeys = array_keys($default_options) ;
623
- $keys = array_keys($options) ;
624
- $newkeys = array_diff($dkeys, $keys) ;
625
- $log = '' ;//todo: useless
626
- if ( ! empty($newkeys) ) {
627
- foreach ( $newkeys as $newkey ) {
628
- $options[$newkey] = $default_options[$newkey] ;
629
- $log .= ' Added ' . $newkey . ' = ' . $default_options[$newkey] ;
630
- }
631
- }
632
- $retiredkeys = array_diff($keys, $dkeys) ;
633
- if ( ! empty($retiredkeys) ) {
634
- foreach ( $retiredkeys as $retired ) {
635
- unset($options[$retired]) ;
636
- $log .= 'Removed ' . $retired ;
637
- }
638
- }
639
- $options[self::OPID_VERSION] = LiteSpeed_Cache::PLUGIN_VERSION ;
640
-
641
- return $options ;
642
- }
643
-
644
- /**
645
- * Verify that the options are still valid.
646
- *
647
- * This is used only when upgrading the plugin versions.
648
- *
649
- * @since 1.0.0
650
- * @access public
651
- */
652
- public function plugin_upgrade()
653
- {
654
- $default_options = $this->get_default_options() ;
655
-
656
- if ( $this->options[ self::OPID_VERSION ] == $default_options[ self::OPID_VERSION ] && count( $default_options ) == count( $this->options ) ) {
657
- return ;
658
- }
659
-
660
- $this->options = self::option_diff( $default_options, $this->options ) ;
661
-
662
- $res = $this->update_options() ;
663
- define( 'LSWCP_EMPTYCACHE', true ) ;// clear all sites caches
664
- LiteSpeed_Cache_Purge::purge_all() ;
665
- LiteSpeed_Cache_Log::debug( "plugin_upgrade option changed = $res\n" ) ;
666
- }
667
-
668
- /**
669
- * Upgrade network options when the plugin is upgraded.
670
- *
671
- * @since 1.0.11
672
- * @access public
673
- */
674
- public function plugin_site_upgrade()
675
- {
676
- $default_options = $this->get_default_site_options() ;
677
- $options = $this->get_site_options() ;
678
-
679
- if ( $options[ self::OPID_VERSION ] == $default_options[ self::OPID_VERSION ] && count( $default_options ) == count( $options ) ) {
680
- return ;
681
- }
682
-
683
- $options = self::option_diff( $default_options, $options ) ;
684
-
685
- $res = update_site_option( self::OPTION_NAME, $options ) ;
686
-
687
- LiteSpeed_Cache_Log::debug( "plugin_upgrade option changed = $res\n" ) ;
688
- }
689
-
690
- /**
691
- * Update the WP_CACHE variable in the wp-config.php file.
692
- *
693
- * If enabling, check if the variable is defined, and if not, define it.
694
- * Vice versa for disabling.
695
- *
696
- * @since 1.0.0
697
- * @access public
698
- * @param boolean $enable True if enabling, false if disabling.
699
- * @return boolean True if the variable is the correct value, false if something went wrong.
700
- */
701
- public static function wp_cache_var_setter( $enable )
702
- {
703
- if ( $enable ) {
704
- if ( defined( 'WP_CACHE' ) && WP_CACHE ) {
705
- return true ;
706
- }
707
- }
708
- elseif ( ! defined( 'WP_CACHE' ) || ( defined( 'WP_CACHE' ) && ! WP_CACHE ) ) {
709
- return true ;
710
- }
711
-
712
- $file = ABSPATH . 'wp-config.php' ;
713
-
714
- if ( ! is_writeable( $file ) ) {
715
- $file = dirname( ABSPATH ) . '/wp-config.php' ; // todo: is the path correct?
716
- if ( ! is_writeable( $file ) ) {
717
- error_log( 'wp-config file not writable for \'WP_CACHE\'' ) ;
718
- return LiteSpeed_Cache_Admin_Error::E_CONF_WRITE ;
719
- }
720
- }
721
-
722
- $file_content = file_get_contents( $file ) ;
723
-
724
- if ( $enable ) {
725
- $count = 0 ;
726
-
727
- $new_file_content = preg_replace( '/[\/]*define\(.*\'WP_CACHE\'.+;/', "define('WP_CACHE', true);", $file_content, -1, $count ) ;
728
- if ( $count == 0 ) {
729
- $new_file_content = preg_replace( '/(\$table_prefix)/', "define('WP_CACHE', true);\n$1", $file_content ) ;
730
- if ( $count == 0 ) {
731
- $new_file_content = preg_replace( '/(\<\?php)/', "$1\ndefine('WP_CACHE', true);", $file_content, -1, $count ) ;
732
- }
733
-
734
- if ( $count == 0 ) {
735
- error_log( 'wp-config file did not find a place to insert define.' ) ;
736
- return LiteSpeed_Cache_Admin_Error::E_CONF_FIND ;
737
- }
738
- }
739
- }
740
- else {
741
- $new_file_content = preg_replace( '/define\(.*\'WP_CACHE\'.+;/', "define('WP_CACHE', false);", $file_content ) ;
742
- }
743
-
744
- file_put_contents( $file, $new_file_content ) ;
745
- return true ;
746
- }
747
-
748
- /**
749
- * On plugin activation, load the default options.
750
- *
751
- * @since 1.0.0
752
- * @access public
753
- * @param int $count The count of blogs active in multisite.
754
- */
755
- public function plugin_activation( $count )
756
- {
757
- $errors = array() ;
758
-
759
- $res = add_option( self::OPTION_NAME, $this->get_default_options() ) ;
760
-
761
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
762
- LiteSpeed_Cache_Log::push( "plugin_activation update option = " . var_export( $res, true ) ) ;
763
- }
764
-
765
- if ( is_multisite() ) {
766
-
767
- if ( ! is_network_admin() ) {
768
- if ( $count === 1 ) {
769
- // Only itself is activated, set .htaccess with only CacheLookUp
770
- LiteSpeed_Cache_Admin_Rules::get_instance()->insert_wrapper() ;
771
- }
772
- return ;
773
- }
774
- else {
775
- // Network admin should make a wapper to avoid subblogs cache not work
776
- LiteSpeed_Cache_Admin_Rules::get_instance()->insert_wrapper() ;
777
- }
778
-
779
- $options = $this->get_site_options() ;
780
-
781
- if ( $res == true || $options[ self::NETWORK_OPID_ENABLED ] == false ) {
782
- return ;
783
- }
784
-
785
- }
786
- elseif ( $res == false && ! defined( 'LITESPEED_ON' ) ) {// todo: why do this
787
- return ;
788
- }
789
- else {
790
- $options = $this->get_options() ;
791
- }
792
-
793
- $res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $options ) ;
794
-
795
- if ( $res !== true ) {
796
- if ( ! is_array( $res ) ) {
797
- exit( $res ) ;
798
- }
799
- exit( implode( "\n", $res ) ) ;
800
- }
801
-
802
- }
803
-
804
- /**
805
- * Get the current instance object.
806
- *
807
- * @since 1.1.0
808
- * @access public
809
- * @return Current class instance.
810
- */
811
- public static function get_instance()
812
- {
813
- if ( ! isset( self::$_instance ) ) {
814
- self::$_instance = new self() ;
815
- }
816
-
817
- return self::$_instance ;
818
- }
819
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-control.class.php DELETED
@@ -1,610 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin cache-control class for X-Litespeed-Cache-Control
4
- *
5
- * @since 1.1.3
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/includes
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
- class LiteSpeed_Cache_Control
11
- {
12
- private static $_instance ;
13
-
14
- const BM_CACHEABLE = 1 ;
15
- const BM_PRIVATE = 2 ;
16
- const BM_SHARED = 4 ;
17
- const BM_NO_VARY = 8 ;
18
- const BM_STALE = 128 ;
19
- const BM_NOTCACHEABLE = 256 ;
20
-
21
- const X_HEADER = 'X-LiteSpeed-Cache-Control' ;
22
-
23
- protected static $_control = 0 ;
24
- protected static $_custom_ttl = 0 ;
25
- private static $_mobile = false ;
26
-
27
- /**
28
- * 1. Initialize cacheable status for `wp` hook
29
- * 2. Hook error page tags for cacheable pages
30
- *
31
- * @since 1.1.3
32
- * @access public
33
- */
34
- public static function init_cacheable()
35
- {
36
- // Hook `wp` to mark default cacheable status
37
- // NOTE: Any process that does NOT run into `wp` hook will not get cacheable by default
38
- add_action( 'wp', 'LiteSpeed_Cache_Control::set_cacheable', 5 ) ;
39
-
40
- // Hook WP REST to be cacheable
41
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_REST ) ) {
42
- add_action( 'rest_api_init', 'LiteSpeed_Cache_Control::set_cacheable', 5 ) ;
43
- }
44
-
45
- // Cache resources
46
- // NOTE: If any strange resource doesn't use normal WP logic `wp_loaded` hook, rewrite rule can handle it
47
- $cache_res = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_RES ) ;
48
- if ( $cache_res ) {
49
- $uri = esc_url( $_SERVER["REQUEST_URI"] ) ;
50
- $pattern = '!' . LSWCP_CONTENT_FOLDER . LiteSpeed_Cache_Admin_Rules::RW_PATTERN_RES . '!' ;
51
- if ( preg_match( $pattern, $uri ) ) {
52
- add_action( 'wp_loaded', 'LiteSpeed_Cache_Control::set_cacheable', 5 ) ;
53
- }
54
- }
55
-
56
- // Check error page
57
- add_filter( 'status_header', 'LiteSpeed_Cache_Tag::check_error_codes', 10, 2 ) ;
58
- }
59
-
60
- /**
61
- * Set no vary setting
62
- *
63
- * @access public
64
- * @since 1.1.3
65
- */
66
- public static function set_no_vary()
67
- {
68
- if ( self::is_no_vary() ) {
69
- return ;
70
- }
71
- self::$_control |= self::BM_NO_VARY ;
72
- LiteSpeed_Cache_Log::debug('X Cache_control -> no-vary') ;
73
- }
74
-
75
- /**
76
- * Get no vary setting
77
- *
78
- * @access public
79
- * @since 1.1.3
80
- */
81
- public static function is_no_vary()
82
- {
83
- return self::$_control & self::BM_NO_VARY ;
84
- }
85
-
86
- /**
87
- * Set stale
88
- *
89
- * @access public
90
- * @since 1.1.3
91
- */
92
- public static function set_stale()
93
- {
94
- if ( self::is_stale() ) {
95
- return ;
96
- }
97
- self::$_control |= self::BM_STALE ;
98
- LiteSpeed_Cache_Log::debug('X Cache_control -> stale') ;
99
- }
100
-
101
- /**
102
- * Get stale
103
- *
104
- * @access public
105
- * @since 1.1.3
106
- */
107
- public static function is_stale()
108
- {
109
- return self::$_control & self::BM_STALE ;
110
- }
111
-
112
- /**
113
- * Set cache control to shared private
114
- *
115
- * @access public
116
- * @since 1.1.3
117
- * @param string $reason The reason to no cache
118
- */
119
- public static function set_shared( $reason = false )
120
- {
121
- if ( self::is_shared() ) {
122
- return ;
123
- }
124
- self::$_control |= self::BM_SHARED ;
125
- self::set_private() ;
126
- if ( $reason ) {
127
- $reason = "( $reason )" ;
128
- }
129
- LiteSpeed_Cache_Log::debug( 'X Cache_control -> shared ' . $reason ) ;
130
- }
131
-
132
- /**
133
- * Check if is shared private
134
- *
135
- * @access public
136
- * @since 1.1.3
137
- */
138
- public static function is_shared()
139
- {
140
- return (self::$_control & self::BM_SHARED) && self::is_private() ;
141
- }
142
-
143
- /**
144
- * Set cache control to private
145
- *
146
- * @access public
147
- * @since 1.1.3
148
- * @param string $reason The reason to no cache
149
- */
150
- public static function set_private( $reason = false )
151
- {
152
- if ( self::is_private() ) {
153
- return ;
154
- }
155
- self::$_control |= self::BM_PRIVATE ;
156
- if ( $reason ) {
157
- $reason = "( $reason )" ;
158
- }
159
- LiteSpeed_Cache_Log::debug( 'X Cache_control -> private ' . $reason) ;
160
- }
161
-
162
- /**
163
- * Check if is private
164
- *
165
- * @access public
166
- * @since 1.1.3
167
- */
168
- public static function is_private()
169
- {
170
- return self::$_control & self::BM_PRIVATE ;
171
- }
172
-
173
- /**
174
- * Initialize cacheable status in `wp` hook, if not call this, by default it will be non-cacheable
175
- *
176
- * @access public
177
- * @since 1.1.3
178
- */
179
- public static function set_cacheable()
180
- {
181
- self::$_control |= self::BM_CACHEABLE ;
182
- LiteSpeed_Cache_Log::debug( 'X Cache_control init on' ) ;
183
- }
184
-
185
- /**
186
- * Switch to nocacheable status
187
- *
188
- * @access public
189
- * @since 1.1.3
190
- * @param string $reason The reason to no cache
191
- */
192
- public static function set_nocache( $reason = false )
193
- {
194
- self::$_control |= self::BM_NOTCACHEABLE ;
195
- if ( $reason ) {
196
- $reason = "( $reason )" ;
197
- }
198
- LiteSpeed_Cache_Log::debug( 'X Cache_control -> no Cache ' . $reason, 2 ) ;
199
- }
200
-
201
- /**
202
- * Check current notcacheable bit set
203
- *
204
- * @access public
205
- * @since 1.1.3
206
- * @return bool True if notcacheable bit is set, otherwise false.
207
- */
208
- public static function isset_notcacheable()
209
- {
210
- return self::$_control & self::BM_NOTCACHEABLE ;
211
- }
212
-
213
- /**
214
- * Check current cacheable status
215
- *
216
- * @access public
217
- * @since 1.1.3
218
- * @return bool True if is still cacheable, otherwise false.
219
- */
220
- public static function is_cacheable()
221
- {
222
- return ! self::isset_notcacheable() && self::$_control & self::BM_CACHEABLE ;
223
- }
224
-
225
-
226
-
227
-
228
- /**
229
- * Set a custom TTL to use with the request if needed.
230
- *
231
- * @access public
232
- * @since 1.1.3
233
- * @param mixed $ttl An integer or string to use as the TTL. Must be numeric.
234
- */
235
- public static function set_custom_ttl($ttl)
236
- {
237
- if ( is_numeric($ttl) ) {
238
- self::$_custom_ttl = $ttl ;
239
- LiteSpeed_Cache_Log::debug('X Cache_control TTL -> ' . $ttl) ;
240
- }
241
- }
242
-
243
- /**
244
- * Generate final TTL.
245
- *
246
- * @access public
247
- * @since 1.1.3
248
- * @return int $ttl An integer to use as the TTL.
249
- */
250
- public static function get_ttl()
251
- {
252
- if ( self::$_custom_ttl != 0 ) {
253
- return self::$_custom_ttl ;
254
- }
255
-
256
- // Check if is in timed url list or not
257
- $timed_urls = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_TIMED_URLS ) ;
258
- $timed_urls_time = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_TIMED_URLS_TIME ) ;
259
- if ( $timed_urls && $timed_urls_time ) {
260
- $timed_urls = explode( "\n", $timed_urls ) ;
261
- $current_url = LiteSpeed_Cache_Tag::build_uri_tag( true ) ;
262
- if ( in_array( $current_url, $timed_urls ) ) {
263
- // Use time limit ttl
264
- $scheduled_time = strtotime( $timed_urls_time ) ;
265
- $ttl = $scheduled_time - time() ;
266
- if ( $ttl < 0 ) {
267
- $ttl += 86400 ;// add one day
268
- }
269
- LiteSpeed_Cache_Log::debug( 'X Cache_control TTL is limited to ' . $ttl ) ;
270
- return $ttl ;
271
- }
272
- }
273
-
274
- // Private cache uses private ttl setting
275
- if ( self::is_private() ) {
276
- return LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_PRIVATE_TTL ) ;
277
- }
278
-
279
- if ( is_front_page() ){
280
- return LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_FRONT_PAGE_TTL ) ;
281
- }
282
-
283
- $feed_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_FEED_TTL ) ;
284
- if ( is_feed() && $feed_ttl > 0 ) {
285
- return $feed_ttl ;
286
- }
287
-
288
- $ttl_404 = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_404_TTL ) ;
289
- if ( is_404() && $ttl_404 > 0 ) {
290
- return $ttl_404 ;
291
- }
292
-
293
- if ( LiteSpeed_Cache_Tag::get_error_code() === 403 ) {
294
- $ttl_403 = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_403_TTL ) ;
295
- return $ttl_403 ;
296
- }
297
-
298
- $ttl_500 = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_500_TTL ) ;
299
- if ( LiteSpeed_Cache_Tag::get_error_code() >= 500 ) {
300
- return $ttl_500 ;
301
- }
302
-
303
- return LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_PUBLIC_TTL ) ;
304
- }
305
-
306
- /**
307
- * Check if need to set no cache status for redirection or not
308
- *
309
- * @access public
310
- * @since 1.1.3
311
- */
312
- public static function check_redirect( $location, $status )
313
- {
314
- if ( ! empty( $_SERVER[ 'SCRIPT_URI' ] ) ) { // dont check $status == '301' anymore
315
- LiteSpeed_Cache_Log::debug( "301 from " . $_SERVER[ 'SCRIPT_URI' ] ) ;
316
- LiteSpeed_Cache_Log::debug( "301 to $location" ) ;
317
- if ( parse_url( $_SERVER[ 'SCRIPT_URI' ], PHP_URL_PATH ) == parse_url( $location, PHP_URL_PATH ) ) {
318
- self::set_nocache( '301 to same url' ) ;
319
- }
320
- }
321
- return $location ;
322
- }
323
-
324
- /**
325
- * Sets up the Cache Control header.
326
- *
327
- * @since 1.1.3
328
- * @access public
329
- * @return string empty string if empty, otherwise the cache control header.
330
- */
331
- public static function output()
332
- {
333
- $esi_hdr = '' ;
334
- if ( LSWCP_ESI_SUPPORT && LiteSpeed_Cache_ESI::has_esi() ) {
335
- $esi_hdr = ',esi=on' ;
336
- }
337
-
338
- $hdr = self::X_HEADER . ': ' ;
339
-
340
- if ( ! self::is_cacheable() ) {
341
- $hdr .= 'no-cache' . $esi_hdr ;
342
- return $hdr ;
343
- }
344
-
345
- if ( self::is_shared() ) {
346
- $hdr .= 'shared,private' ;
347
- }
348
- elseif ( self::is_private() ) {
349
- $hdr .= 'private' ;
350
- }
351
- else {
352
- $hdr .= 'public' ;
353
- }
354
-
355
- if ( self::is_no_vary() ) {
356
- $hdr .= ',no-vary' ;
357
- }
358
-
359
- $hdr .= ',max-age=' . self::get_ttl() . $esi_hdr ;
360
- return $hdr ;
361
- }
362
-
363
- /**
364
- * Generate all `control` tags before output
365
- *
366
- * @access public
367
- * @since 1.1.3
368
- */
369
- public static function finalize()
370
- {
371
- // if is not cacheable, terminate check
372
- // Even no need to run 3rd party hook
373
- if ( ! self::is_cacheable() ) {
374
- LiteSpeed_Cache_Log::debug( 'not cacheable before ctrl finalize' ) ;
375
- return ;
376
- }
377
-
378
- if ( defined('LSCACHE_NO_CACHE') && LSCACHE_NO_CACHE ) {
379
- self::set_nocache('LSCACHE_NO_CACHE constant defined') ;
380
- return ;
381
- }
382
-
383
- $instance = self::get_instance() ;
384
-
385
- // Apply 3rd party filter
386
- // Parse ESI block id
387
- $esi_id = false ;
388
- if ( defined( 'LSCACHE_IS_ESI' ) ) {
389
- $params = LiteSpeed_Cache_ESI::parse_esi_param() ;
390
- if ( $params !== false ) {
391
- $esi_id = $params[LiteSpeed_Cache_ESI::PARAM_BLOCK_ID] ;
392
- }
393
- }
394
- // NOTE: Hook always needs to run asap because some 3rd party set is_mobile in this hook
395
- do_action('litespeed_cache_api_control', $esi_id) ;
396
-
397
- // if is not cacheable, terminate check
398
- if ( ! self::is_cacheable() ) {
399
- LiteSpeed_Cache_Log::debug( 'not cacheable after api_control' ) ;
400
- return ;
401
- }
402
-
403
- if ( is_preview() ) {
404
- self::set_nocache( 'preview page' ) ;
405
- return ;
406
- }
407
-
408
- // Check litespeed setting to set cacheable status
409
- if ( ! $instance->_setting_cacheable() ) {
410
- self::set_nocache() ;
411
- return ;
412
- }
413
-
414
- // If user has password cookie, do not cache (moved from vary)
415
- global $post ;
416
- if ( ! empty($post->post_password) && isset($_COOKIE['wp-postpass_' . COOKIEHASH]) ) {
417
- // If user has password cookie, do not cache
418
- self::set_nocache('pswd cookie') ;
419
- return ;
420
- }
421
-
422
- // The following check to the end is ONLY for mobile
423
- if ( ! LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_CACHE_MOBILE) ) {
424
- if ( self::is_mobile() ) {
425
- self::set_nocache('mobile') ;
426
- }
427
- return ;
428
- }
429
-
430
- if ( isset($_SERVER['LSCACHE_VARY_VALUE']) && $_SERVER['LSCACHE_VARY_VALUE'] === 'ismobile' ) {
431
- if ( ! wp_is_mobile() && ! self::is_mobile() ) {
432
- self::set_nocache( 'is not mobile' ) ;
433
- return ;
434
- }
435
- }
436
- elseif ( wp_is_mobile() || self::is_mobile() ) {
437
- self::set_nocache( 'is mobile' ) ;
438
- return ;
439
- }
440
-
441
- }
442
-
443
- /**
444
- * Check if a page is cacheable based on litespeed setting.
445
- *
446
- * @since 1.0.0
447
- * @access private
448
- * @return boolean True if cacheable, false otherwise.
449
- */
450
- private function _setting_cacheable()
451
- {
452
- // logged_in users already excluded, no hook added
453
-
454
- if( ! empty( $_REQUEST[ LiteSpeed_Cache::ACTION_KEY ] ) ) {
455
- return $this->_no_cache_for( 'Query String Action' ) ;
456
- }
457
-
458
- if ( $_SERVER["REQUEST_METHOD"] !== 'GET' ) {
459
- return $this->_no_cache_for('not GET method:' . $_SERVER["REQUEST_METHOD"]) ;
460
- }
461
-
462
- if ( is_feed() && LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_FEED_TTL ) == 0 ) {
463
- return $this->_no_cache_for('feed') ;
464
- }
465
-
466
- if ( is_trackback() ) {
467
- return $this->_no_cache_for('trackback') ;
468
- }
469
-
470
- if ( is_404() && LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_404_TTL ) == 0 ) {
471
- return $this->_no_cache_for('404 pages') ;
472
- }
473
-
474
- if ( is_search() ) {
475
- return $this->_no_cache_for('search') ;
476
- }
477
-
478
- // if ( !defined('WP_USE_THEMES') || !WP_USE_THEMES ) {
479
- // return $this->_no_cache_for('no theme used') ;
480
- // }
481
-
482
- // Check private cache URI setting
483
- $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_URI_PRIV ) ;
484
- if ( ! empty( $excludes ) ) {
485
- $uri = esc_url( $_SERVER[ 'REQUEST_URI' ] ) ;
486
- $result = LiteSpeed_Cache_Utility::str_hit_array( $uri, explode( "\n", $excludes ) ) ;
487
- if ( $result ) {
488
- self::set_private( 'Admin cfg Private Cached URI: ' . $result ) ;
489
- }
490
- }
491
-
492
- // Check if URI is excluded from cache
493
- $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_URI ) ;
494
- if ( ! empty( $excludes ) ) {
495
- $uri = esc_url( $_SERVER[ 'REQUEST_URI' ] ) ;
496
- $result = LiteSpeed_Cache_Utility::str_hit_array( $uri, explode( "\n", $excludes ) ) ;
497
- if ( $result ) {
498
- return $this->_no_cache_for( 'Admin configured URI Do not cache: ' . $result ) ;
499
- }
500
- }
501
-
502
- // Check QS excluded setting
503
- $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_QS ) ;
504
- if ( ! empty( $excludes ) && $qs = $this->_is_qs_excluded( explode( "\n", $excludes ) ) ) {
505
- return $this->_no_cache_for( 'Admin configured QS Do not cache: ' . $qs ) ;
506
- }
507
-
508
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT) ;
509
- if ( ! empty($excludes) && has_category(explode(',', $excludes)) ) {
510
- return $this->_no_cache_for('Admin configured Category Do not cache.') ;
511
- }
512
-
513
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG) ;
514
- if ( ! empty($excludes) && has_tag(explode(',', $excludes)) ) {
515
- return $this->_no_cache_for('Admin configured Tag Do not cache.') ;
516
- }
517
-
518
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES) ;
519
- if ( ! empty($excludes) && ! empty($_COOKIE) ) {
520
- $exclude_list = explode('|', $excludes) ;
521
-
522
- foreach( $_COOKIE as $key=>$val) {
523
- if ( in_array($key, $exclude_list) ) {
524
- return $this->_no_cache_for('Admin configured Cookie Do not cache.') ;
525
- }
526
- }
527
- }
528
-
529
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS) ;
530
- if ( ! empty($excludes) && isset($_SERVER['HTTP_USER_AGENT']) ) {
531
- $pattern = '/' . $excludes . '/' ;
532
- $nummatches = preg_match($pattern, $_SERVER['HTTP_USER_AGENT']) ;
533
- if ( $nummatches ) {
534
- return $this->_no_cache_for('Admin configured User Agent Do not cache.') ;
535
- }
536
- }
537
-
538
- return true ;
539
- }
540
-
541
- /**
542
- * Write a debug message for if a page is not cacheable.
543
- *
544
- * @since 1.0.0
545
- * @access private
546
- * @param string $reason An explanation for why the page is not cacheable.
547
- * @return boolean Return false.
548
- */
549
- private function _no_cache_for( $reason )
550
- {
551
- LiteSpeed_Cache_Log::debug('X Cache_control off - ' . $reason) ;
552
- return false ;
553
- }
554
-
555
- /**
556
- * Check if current request has qs excluded setting
557
- *
558
- * @since 1.3
559
- * @access private
560
- * @param array $excludes QS excludes setting
561
- * @return boolean|string False if not excluded, otherwise the hit qs list
562
- */
563
- private function _is_qs_excluded( $excludes )
564
- {
565
- if ( ! empty( $_GET ) && $intersect = array_intersect( array_keys( $_GET ), $excludes ) ) {
566
- return implode( ',', $intersect ) ;
567
- }
568
- return false ;
569
- }
570
-
571
- /**
572
- * Gets whether any plugins determined that the current page is mobile.
573
- *
574
- * @access public
575
- * @return boolean True if the current page was deemed mobile, false otherwise.
576
- */
577
- public static function is_mobile()
578
- {
579
- return self::$_mobile ;
580
- }
581
-
582
- /**
583
- * Mark the current page as mobile. This may be useful for if the plugin does not override wp_is_mobile.
584
- *
585
- * Must be called before the shutdown hook point.
586
- *
587
- * @since 1.0.7
588
- * @access public
589
- */
590
- public static function set_mobile()
591
- {
592
- self::$_mobile = true ;
593
- }
594
-
595
- /**
596
- * Get the current instance object.
597
- *
598
- * @since 1.3
599
- * @access public
600
- * @return Current class instance.
601
- */
602
- public static function get_instance()
603
- {
604
- if ( ! isset( self::$_instance ) ) {
605
- self::$_instance = new self() ;
606
- }
607
-
608
- return self::$_instance ;
609
- }
610
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-crawler-sitemap.class.php DELETED
@@ -1,155 +0,0 @@
1
- <?php
2
- /**
3
- * The Crawler Sitemap Class
4
- *
5
- *
6
- * @since 1.1.0
7
- * @package LiteSpeed_Cache_Crawler_Sitemap
8
- * @subpackage LiteSpeed_Cache/includes
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- class LiteSpeed_Cache_Crawler_Sitemap
13
- {
14
- private static $_instance ;
15
- private $home_url ;// Used to simplify urls
16
-
17
- protected $_urls = array() ;
18
-
19
- /**
20
- * Instantiate the class
21
- *
22
- * @since 1.1.0
23
- * @access private
24
- */
25
- private function __construct()
26
- {
27
- if ( is_multisite() ) {
28
- $this->home_url = get_home_url( get_current_blog_id() ) ;
29
- }
30
- else{
31
- $this->home_url = get_home_url() ;
32
- }
33
- }
34
-
35
- /**
36
- * Generate all urls
37
- *
38
- * @since 1.1.0
39
- * @access public
40
- */
41
- public function generate_data($blacklist = array())
42
- {
43
- global $wpdb ;
44
-
45
- $options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
46
-
47
- $optionOrderBy = $options[LiteSpeed_Cache_Config::CRWL_ORDER_LINKS] ;
48
-
49
- $show_pages = $options[LiteSpeed_Cache_Config::CRWL_PAGES] ;
50
-
51
- $show_posts = $options[LiteSpeed_Cache_Config::CRWL_POSTS] ;
52
-
53
- $show_cats = $options[LiteSpeed_Cache_Config::CRWL_CATS] ;
54
-
55
- $show_tags = $options[LiteSpeed_Cache_Config::CRWL_TAGS] ;
56
-
57
- switch ( $optionOrderBy ) {
58
- case 'date_asc':
59
- $orderBy = " ORDER BY post_date ASC" ;
60
- break ;
61
-
62
- case 'alpha_desc':
63
- $orderBy = " ORDER BY post_title DESC" ;
64
- break ;
65
-
66
- case 'alpha_asc':
67
- $orderBy = " ORDER BY post_title ASC" ;
68
- break ;
69
-
70
- case 'date_desc':
71
- default:
72
- $orderBy = " ORDER BY post_date DESC" ;
73
- break ;
74
- }
75
-
76
- $post_type_array = array() ;
77
- if ( isset($show_pages) && $show_pages == 1 ) {
78
- $post_type_array[] = 'page' ;
79
- }
80
-
81
- if ( isset($show_posts) && $show_posts == 1 ) {
82
- $post_type_array[] = 'post' ;
83
- }
84
-
85
- $id = LiteSpeed_Cache_Config::CRWL_EXCLUDES_CPT ;
86
- if ( isset($options[$id]) ) {
87
- $excludeCptArr = explode(',', $options[$id]) ;
88
- $excludeCptArr = array_map('trim', $excludeCptArr) ;
89
- $cptArr = get_post_types() ;
90
- $cptArr = array_diff($cptArr, array('post', 'page')) ;
91
- $cptArr = array_diff($cptArr, $excludeCptArr) ;
92
- $post_type_array = array_merge($post_type_array, $cptArr) ;
93
- }
94
-
95
- if ( ! empty($post_type_array) ) {
96
- $post_type = implode("','", $post_type_array) ;
97
-
98
- LiteSpeed_Cache_Log::debug("Crawler sitemap log: post_type is '$post_type'") ;
99
-
100
- $query = "SELECT ID, post_date FROM ".$wpdb->prefix."posts where post_type IN ('".$post_type."') AND post_status='publish' ".$orderBy ;
101
- $results = $wpdb->get_results($query) ;
102
-
103
- foreach ( $results as $result ){
104
- $slug = str_replace($this->home_url, '', get_permalink($result->ID)) ;
105
- if ( ! in_array($slug, $blacklist) ) {
106
- $this->_urls[] = $slug ;
107
- }
108
- }
109
- }
110
-
111
- //Generate Categories Link if option checked
112
- if ( isset($show_cats) && $show_cats == 1 ) {
113
- $cats = get_terms("category", array("hide_empty"=>true, "hierarchical"=>false)) ;
114
- if ( $cats && is_array($cats) && count($cats) > 0 ) {
115
- foreach ( $cats as $cat ) {
116
- $slug = str_replace($this->home_url, '', get_category_link($cat->term_id)) ;
117
- if ( ! in_array($slug, $blacklist) ){
118
- $this->_urls[] = $slug ;//var_dump($slug);exit;//todo: check permalink
119
- }
120
- }
121
- }
122
- }
123
-
124
- //Generate tags Link if option checked
125
- if ( isset($show_tags) && $show_tags == 1 ) {
126
- $tags = get_terms("post_tag", array("hide_empty"=>true, "hierarchical"=>false)) ;
127
- if ( $tags && is_array($tags) && count($tags) > 0 ) {
128
- foreach ( $tags as $tag ) {
129
- $slug = str_replace($this->home_url, '', get_tag_link($tag->term_id)) ;
130
- if ( ! in_array($slug, $blacklist) ) {
131
- $this->_urls[] = $slug ;
132
- }
133
- }
134
- }
135
- }
136
-
137
- return apply_filters('litespeed_crawler_sitemap', $this->_urls) ;
138
- }
139
-
140
- /**
141
- * Get the current instance object.
142
- *
143
- * @since 1.1.0
144
- * @access public
145
- * @return Current class instance.
146
- */
147
- public static function get_instance()
148
- {
149
- if ( ! isset(self::$_instance) ) {
150
- self::$_instance = new self() ;
151
- }
152
-
153
- return self::$_instance ;
154
- }
155
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-crawler.class.php DELETED
@@ -1,450 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The crawler class
5
- *
6
- *
7
- * @since 1.1.0
8
- * @package LiteSpeed_Cache
9
- * @subpackage LiteSpeed_Cache/includes
10
- * @author LiteSpeed Technologies <info@litespeedtech.com>
11
- */
12
- class LiteSpeed_Cache_Crawler
13
- {
14
- private static $_instance;
15
- private $_sitemap_file ;
16
- private $_blacklist_file ;
17
- private $_home_url ;
18
- const CRWL_BLACKLIST = 'crawler_blacklist' ;
19
-
20
- /**
21
- * Initialize crawler, assign sitemap path
22
- *
23
- * @since 1.1.0
24
- * @access private
25
- */
26
- private function __construct()
27
- {
28
- $sitemapPath = LSWCP_DIR . 'var' ;
29
- if ( is_multisite() ) {
30
- $blogID = get_current_blog_id() ;
31
- $this->_sitemap_file = $sitemapPath . '/crawlermap-' . $blogID . '.data' ;
32
- $this->_home_url = get_home_url( $blogID ) ;
33
- }
34
- else{
35
- $this->_sitemap_file = $sitemapPath . '/crawlermap.data' ;
36
- $this->_home_url = get_home_url() ;
37
- }
38
- $this->_blacklist_file = $this->_sitemap_file . '.blacklist' ;
39
-
40
- LiteSpeed_Cache_Log::debug('Crawler log: Initialized') ;
41
- }
42
-
43
- /**
44
- * Return crawler meta file
45
- *
46
- * @since 1.1.0
47
- * @access public
48
- * @return string Json data file path
49
- */
50
- public function get_crawler_json_path()
51
- {
52
- if ( ! file_exists($this->_sitemap_file . '.meta') ) {
53
- return false ;
54
- }
55
- $metaUrl = implode('/', array_slice(explode('/', $this->_sitemap_file . '.meta'), -5)) ;
56
- return $this->_home_url . '/' . $metaUrl ;
57
- }
58
-
59
- /**
60
- * Return crawler meta info
61
- *
62
- * @since 1.1.0
63
- * @access public
64
- * @return array Meta array
65
- */
66
- public function get_meta()
67
- {
68
- if ( ! file_exists($this->_sitemap_file . '.meta') || ! $meta = Litespeed_File::read($this->_sitemap_file . '.meta') ) {
69
- return false ;
70
- }
71
- return json_decode($meta) ;
72
- }
73
-
74
- /**
75
- * Return blacklist content
76
- *
77
- * @since 1.1.0
78
- * @access public
79
- * @return string
80
- */
81
- public function get_blacklist()
82
- {
83
- return Litespeed_File::read($this->_blacklist_file) ;
84
- }
85
-
86
- /**
87
- * Return blacklist count
88
- *
89
- * @since 1.1.0
90
- * @access public
91
- * @return string
92
- */
93
- public function count_blacklist()
94
- {
95
- return Litespeed_File::count_lines($this->_blacklist_file) ;
96
- }
97
-
98
- /**
99
- * Save blacklist to file
100
- *
101
- * @since 1.1.0
102
- * @access public
103
- * @return bool If saved successfully
104
- */
105
- public function save_blacklist()
106
- {
107
- if ( ! isset( $_POST[ self::CRWL_BLACKLIST ] ) ) {
108
- $msg = __( 'Can not find any form data for blacklist', 'litespeed-cache' ) ;
109
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_RED, $msg ) ;
110
- return false ;
111
- }
112
- $content = $_POST[ self::CRWL_BLACKLIST ] ;
113
- $content = array_map( 'trim', explode( "\n", $content ) ) ;// remove space
114
- $content = implode( "\n", array_filter( $content ) ) ;
115
-
116
- // save blacklist file
117
- $ret = Litespeed_File::save( $this->_blacklist_file, $content, true, false, false ) ;
118
- if ( $ret !== true ) {
119
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_RED, $ret ) ;
120
- }
121
- else {
122
- $msg = sprintf(
123
- __( 'File saved successfully: %s', 'litespeed-cache' ),
124
- $this->_blacklist_file
125
- ) ;
126
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg ) ;
127
- }
128
-
129
- return true ;
130
- }
131
-
132
- /**
133
- * Append urls to current list
134
- *
135
- * @since 1.1.0
136
- * @access public
137
- * @param array $list The url list needs to be appended
138
- */
139
- public function append_blacklist( $list )
140
- {
141
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
142
- LiteSpeed_Cache_Log::push( 'Crawler log: append blacklist ' . count( $list ) ) ;
143
- }
144
- $ori_list = Litespeed_File::read( $this->_blacklist_file ) ;
145
- $ori_list = explode( "\n", $ori_list ) ;
146
- $ori_list = array_merge( $ori_list, $list ) ;
147
- $ori_list = array_map( 'trim', $ori_list ) ;
148
- $ori_list = array_filter( $ori_list ) ;
149
- $content = implode( "\n", $ori_list ) ;
150
-
151
- // save blacklist
152
- $ret = Litespeed_File::save( $this->_blacklist_file, $content, true, false, false ) ;
153
- if ( $ret !== true ) {
154
- LiteSpeed_Cache_Log::debug( 'Crawler log: append blacklist failed: ' . $ret ) ;
155
- return false ;
156
- }
157
-
158
- return true ;
159
- }
160
-
161
- /**
162
- * Generate sitemap
163
- *
164
- * @since 1.1.0
165
- * @access public
166
- */
167
- public function generate_sitemap()
168
- {
169
- $ret = $this->_generate_sitemap() ;
170
- if ( $ret !== true ) {
171
- LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_RED, $ret) ;
172
- }
173
- else {
174
- $msg = sprintf(
175
- __('File created successfully: %s', 'litespeed-cache'),
176
- $this->_sitemap_file
177
- ) ;
178
- LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg) ;
179
- }
180
- }
181
-
182
- /**
183
- * Parse custom sitemap and return urls
184
- *
185
- * @since 1.1.1
186
- * @access public
187
- * @param string $sitemap The url set map address
188
- * @param boolean $return_detail If return url list
189
- * @return bollean|array Url list or if is a sitemap
190
- */
191
- public function parse_custom_sitemap($sitemap, $return_detail = true)
192
- {
193
- if ( ! file_get_contents($sitemap) ) {
194
- return LiteSpeed_Cache_Admin_Error::E_SETTING_CUSTOM_SITEMAP_READ ;
195
- }
196
- $xml_object = simplexml_load_file($sitemap) ;
197
- if ( ! $xml_object ) {
198
- return LiteSpeed_Cache_Admin_Error::E_SETTING_CUSTOM_SITEMAP_PARSE ;
199
- }
200
- if ( ! $return_detail ) {
201
- return true ;
202
- }
203
- // start parsing
204
- $_urls = array() ;
205
-
206
- $xml_array = (array)$xml_object ;
207
- if ( !empty($xml_array['sitemap']) ) {// parse sitemap set
208
- if ( is_object($xml_array['sitemap']) ) {
209
- $xml_array['sitemap'] = (array)$xml_array['sitemap'] ;
210
- }
211
- if ( !empty($xml_array['sitemap']['loc']) ) {// is single sitemap
212
- $urls = $this->parse_custom_sitemap($xml_array['sitemap']['loc']) ;
213
- if ( is_array($urls) && !empty($urls) ) {
214
- $_urls = array_merge($_urls, $urls) ;
215
- }
216
- }
217
- else {
218
- // parse multiple sitemaps
219
- foreach ($xml_array['sitemap'] as $val) {
220
- $val = (array)$val ;
221
- if ( !empty($val['loc']) ) {
222
- $urls = $this->parse_custom_sitemap($val['loc']) ;// recursive parse sitemap
223
- if ( is_array($urls) && !empty($urls) ) {
224
- $_urls = array_merge($_urls, $urls) ;
225
- }
226
- }
227
- }
228
- }
229
- }
230
- elseif ( !empty($xml_array['url']) ) {// parse url set
231
- if ( is_object($xml_array['url']) ) {
232
- $xml_array['url'] = (array)$xml_array['url'] ;
233
- }
234
- // if only 1 element
235
- if ( !empty($xml_array['url']['loc']) ) {
236
- $_urls[] = $xml_array['url']['loc'] ;
237
- }
238
- else {
239
- foreach ($xml_array['url'] as $val) {
240
- $val = (array)$val ;
241
- if ( !empty($val['loc']) ) {
242
- $_urls[] = $val['loc'] ;
243
- }
244
- }
245
- }
246
- }
247
-
248
- return $_urls ;
249
- }
250
-
251
- /**
252
- * Generate the sitemap
253
- *
254
- * @since 1.1.0
255
- * @access protected
256
- * @return string|true
257
- */
258
- protected function _generate_sitemap()
259
- {
260
- // use custom sitemap
261
- if ( $sitemap = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CUSTOM_SITEMAP ) ) {
262
- $sitemap_urls = $this->parse_custom_sitemap( $sitemap ) ;
263
- $urls = array() ;
264
- $offset = strlen( $this->_home_url ) ;
265
- if ( is_array( $sitemap_urls ) && ! empty( $sitemap_urls ) ) {
266
- foreach ( $sitemap_urls as $val ) {
267
- if ( stripos( $val, $this->_home_url ) === 0 ) {
268
- $urls[] = substr( $val, $offset ) ;
269
- }
270
- }
271
- }
272
- }
273
- else {
274
- $urls = LiteSpeed_Cache_Crawler_Sitemap::get_instance()->generate_data() ;
275
- }
276
-
277
- // filter urls
278
- $blacklist = Litespeed_File::read( $this->_blacklist_file ) ;
279
- $blacklist = explode( "\n", $blacklist ) ;
280
- $urls = array_diff( $urls, $blacklist ) ;
281
- LiteSpeed_Cache_Log::debug( 'Crawler log: Generate sitemap' ) ;
282
-
283
- $ret = Litespeed_File::save( $this->_sitemap_file, implode( "\n", $urls ), true, false, false ) ;
284
-
285
- // refresh list size in meta
286
- $crawler = new Litespeed_Crawler( $this->_sitemap_file ) ;
287
- $crawler->refresh_list_size() ;
288
-
289
- return $ret ;
290
- }
291
-
292
- /**
293
- * Get sitemap file info
294
- *
295
- * @since 1.1.0
296
- * @access public
297
- */
298
- public function sitemap_time()
299
- {
300
- if ( ! file_exists($this->_sitemap_file) ) {
301
- return false ;
302
- }
303
-
304
- $filetime = date('m/d/Y H:i:s', filemtime($this->_sitemap_file) + LITESPEED_TIME_OFFSET ) ;
305
-
306
- return $filetime ;
307
- }
308
-
309
- /**
310
- * Create reset pos file
311
- *
312
- * @since 1.1.0
313
- * @access public
314
- * @return mixed True or error message
315
- */
316
- public function reset_pos()
317
- {
318
- $crawler = new Litespeed_Crawler($this->_sitemap_file) ;
319
- $ret = $crawler->reset_pos() ;
320
- $log = 'Crawler log: Reset pos. ' ;
321
- if ( $ret !== true ) {
322
- $log .= "Error: $ret" ;
323
- $msg = sprintf(__('Failed to send position reset notification: %s', 'litespeed-cache'), $ret) ;
324
- LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_RED, $msg) ;
325
- }
326
- else {
327
- $msg = __('Position reset notification sent successfully', 'litespeed-cache') ;
328
- LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg) ;
329
- }
330
- LiteSpeed_Cache_Log::debug($log) ;
331
- }
332
-
333
- /**
334
- * Proceed crawling
335
- *
336
- * @since 1.1.0
337
- * @access public
338
- * @param bool $force If ignore whole crawling interval
339
- */
340
- public static function crawl_data($force = false)
341
- {
342
- if ( ! LiteSpeed_Cache_Router::can_crawl() ) {
343
- LiteSpeed_Cache_Log::debug('Crawler log: ......crawler is NOT allowed by the server admin......') ;
344
- return false;
345
- }
346
- if ( $force ) {
347
- LiteSpeed_Cache_Log::debug('Crawler log: ......crawler manually ran......') ;
348
- }
349
- return self::get_instance()->_crawl_data($force) ;
350
- }
351
-
352
- /**
353
- * Crawling start
354
- *
355
- * @since 1.1.0
356
- * @access protected
357
- * @param bool $force If ignore whole crawling interval
358
- */
359
- protected function _crawl_data($force)
360
- {
361
- LiteSpeed_Cache_Log::debug('Crawler log: ......crawler started......') ;
362
- // for the first time running
363
- if ( ! file_exists($this->_sitemap_file) ) {
364
- $ret = $this->_generate_sitemap() ;
365
- if ( $ret !== true ) {
366
- LiteSpeed_Cache_Log::debug('Crawler log: ' . $ret) ;
367
- return $this->output($ret) ;
368
- }
369
- }
370
-
371
- $options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
372
-
373
- $crawler = new Litespeed_Crawler($this->_sitemap_file) ;
374
- // if finished last time, regenerate sitemap
375
- if ( $last_fnished_at = $crawler->get_done_status() ) {
376
- // check whole crawling interval
377
- if ( ! $force && time() - $last_fnished_at < $options[LiteSpeed_Cache_Config::CRWL_CRAWL_INTERVAL] ) {
378
- LiteSpeed_Cache_Log::debug('Crawler log: Cron abort: cache warmed already.') ;
379
- // if not reach whole crawling interval, exit
380
- return;
381
- }
382
- $this->_generate_sitemap() ;
383
- }
384
- $crawler->set_base_url($this->_home_url) ;
385
- $crawler->set_run_duration($options[LiteSpeed_Cache_Config::CRWL_RUN_DURATION]) ;
386
- $crawler->set_run_delay($options[LiteSpeed_Cache_Config::CRWL_USLEEP]) ;
387
- $crawler->set_threads_limit($options[LiteSpeed_Cache_Config::CRWL_THREADS]) ;
388
- $crawler->set_load_limit($options[LiteSpeed_Cache_Config::CRWL_LOAD_LIMIT]) ;
389
- if ( $options[LiteSpeed_Cache_Config::CRWL_DOMAIN_IP] ) {
390
- $crawler->set_domain_ip($options[LiteSpeed_Cache_Config::CRWL_DOMAIN_IP]) ;
391
- }
392
- $ret = $crawler->engine_start() ;
393
-
394
- // merge blacklist
395
- if ( $ret['blacklist'] ) {
396
- $this->append_blacklist($ret['blacklist']) ;
397
- }
398
-
399
- if ( ! empty($ret['crawled']) && LiteSpeed_Cache_Log::get_enabled() ) {
400
- LiteSpeed_Cache_Log::push('Crawler log: Last crawled ' . $ret['crawled'] . ' item(s)') ;
401
- }
402
-
403
- // return error
404
- if ( $ret['error'] !== false ) {
405
- LiteSpeed_Cache_Log::debug('Crawler log: ' . $ret['error']) ;
406
- return $this->output($ret['error']) ;
407
- }
408
- else {
409
- $msg = 'Reached end of sitemap file. Crawling completed.' ;
410
- $msg_t = __('Reached end of sitemap file. Crawling completed.', 'litespeed-cache') ;
411
- LiteSpeed_Cache_Log::debug('Crawler log: ' . $msg) ;
412
- return $this->output($msg_t) ;
413
- }
414
- }
415
-
416
- /**
417
- * Output info and exit
418
- *
419
- * @since 1.1.0
420
- * @access protected
421
- * @param string $error Error info
422
- */
423
- protected function output($msg)
424
- {
425
- if ( defined('DOING_CRON') ) {
426
- echo $msg ;
427
- // exit();
428
- }
429
- else {
430
- echo "<script>alert('" . htmlspecialchars($msg) . "');</script>" ;
431
- // exit;
432
- }
433
- }
434
-
435
- /**
436
- * Get the current instance object.
437
- *
438
- * @since 1.1.0
439
- * @access public
440
- * @return Current class instance.
441
- */
442
- public static function get_instance()
443
- {
444
- if ( ! isset(self::$_instance) ) {
445
- self::$_instance = new self() ;
446
- }
447
-
448
- return self::$_instance ;
449
- }
450
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-esi-dummy.tpl.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is a dummy template file.
5
- *
6
- * It is meant to be used to skip comment processing on the main request
7
- * when using esi comments.
8
- */
9
-
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-esi.class.php DELETED
@@ -1,569 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The esi class.
5
- *
6
- * This is used to define all esi related functions.
7
- *
8
- * @since 1.1.3
9
- * @package LiteSpeed_Cache
10
- * @subpackage LiteSpeed_Cache/includes
11
- * @author LiteSpeed Technologies <info@litespeedtech.com>
12
- */
13
- class LiteSpeed_Cache_ESI
14
- {
15
- private static $_instance ;
16
-
17
- private static $has_esi = false ;
18
- private $esi_args = null ;
19
-
20
- const QS_ACTION = 'lsesi' ;
21
- const POSTTYPE = 'lswcp' ;
22
- const QS_PARAMS = 'esi' ;
23
-
24
- const PARAM_ARGS = 'args' ;
25
- const PARAM_BLOCK_ID = 'block_id' ;
26
- const PARAM_ID = 'id' ;
27
- const PARAM_INSTANCE = 'instance' ;
28
- const PARAM_NAME = 'name' ;
29
-
30
- const WIDGET_OPID_ESIENABLE = 'widget_esi_enable' ;
31
- const WIDGET_OPID_TTL = 'widget_ttl' ;
32
-
33
- /**
34
- * Constructor of ESI
35
- *
36
- * @since 1.2.0
37
- * @access private
38
- */
39
- private function __construct()
40
- {
41
- add_action( 'template_include', 'LiteSpeed_Cache_ESI::esi_template', 100 ) ;
42
- add_action( 'load-widgets.php', 'LiteSpeed_Cache_Purge::purge_widget' ) ;
43
- add_action( 'wp_update_comment_count', 'LiteSpeed_Cache_Purge::purge_comment_widget' ) ;
44
- }
45
-
46
- /**
47
- * Check if the requested page has esi elements. If so, return esi on
48
- * header.
49
- *
50
- * @since 1.1.3
51
- * @access public
52
- * @return string Esi On header if request has esi, empty string otherwise.
53
- */
54
- public static function has_esi()
55
- {
56
- return self::$has_esi ;
57
- }
58
-
59
- /**
60
- * Sets that the requested page has esi elements.
61
- *
62
- * @since 1.1.3
63
- * @access public
64
- */
65
- public static function set_has_esi()
66
- {
67
- self::$has_esi = true ;
68
- }
69
-
70
- /**
71
- * Hooked to the template_include action.
72
- * Selects the esi template file when the post type is a LiteSpeed ESI page.
73
- *
74
- * @since 1.1.3
75
- * @access public
76
- * @param string $template The template path filtered.
77
- * @return string The new template path.
78
- */
79
- public static function esi_template($template)
80
- {
81
- // Add comment forum esi for logged-in user or commenter
82
- if ( ! LiteSpeed_Cache_Router::is_ajax() && LiteSpeed_Cache_Vary::has_vary() ) {
83
- add_filter( 'comment_form_defaults', array( self::get_instance(), 'register_comment_form_actions' ) ) ;
84
- }
85
-
86
- // Check if is an ESI request
87
- if ( ! empty( $_GET[ LiteSpeed_Cache_ESI::QS_ACTION ] ) && $_GET[ LiteSpeed_Cache_ESI::QS_ACTION ] == LiteSpeed_Cache_ESI::POSTTYPE ) {
88
- define('LSCACHE_IS_ESI', true) ;
89
-
90
- self::get_instance()->register_esi_actions() ;
91
-
92
- return LSWCP_DIR . 'includes/litespeed-cache-esi.tpl.php' ;
93
- }
94
- self::get_instance()->register_not_esi_actions() ;
95
- return $template ;
96
- }
97
-
98
- /**
99
- * Register all of the hooks related to the esi logic of the plugin.
100
- * Specifically when the page IS an esi page.
101
- *
102
- * @since 1.1.3
103
- * @access public
104
- */
105
- public function register_esi_actions()
106
- {
107
- add_action('litespeed_cache_load_esi_block-widget', array($this, 'load_widget_block')) ;
108
- add_action('litespeed_cache_load_esi_block-admin-bar', array($this, 'load_admin_bar_block')) ;
109
- add_action('litespeed_cache_load_esi_block-comment-form', array($this, 'load_comment_form_block')) ;
110
- }
111
-
112
- /**
113
- * Register all of the hooks related to the esi logic of the plugin.
114
- * Specifically when the page is NOT an esi page.
115
- *
116
- * @since 1.1.3
117
- * @access public
118
- */
119
- public function register_not_esi_actions()
120
- {
121
- do_action('litespeed_cache_is_not_esi_template') ;
122
-
123
- if ( LiteSpeed_Cache_Router::is_ajax() ) {
124
- return ;
125
- }
126
-
127
- add_filter('widget_display_callback', array($this, 'sub_widget_block'), 0, 3) ;
128
-
129
- // Add admin_bar esi
130
- if ( LiteSpeed_Cache_Router::is_logged_in() ) {
131
- remove_action('wp_footer', 'wp_admin_bar_render', 1000) ;
132
- add_action('wp_footer', array($this, 'sub_admin_bar_block'), 1000) ;
133
- }
134
-
135
- }
136
-
137
- /**
138
- * Hooked to the comment_form_defaults filter.
139
- * Stores the default comment form settings.
140
- * This method initializes an output buffer and adds two hook functions to the WP process.
141
- * If comment_form_sub_cancel is triggered, the output buffer is flushed because there is no need to make the comment form ESI.
142
- * Else if sub_comment_form_block is triggered, the output buffer is cleared and an esi block is added. The remaining comment form is also buffered and cleared.
143
- *
144
- * @since 1.1.3
145
- * @access public
146
- * @param array $defaults The default comment form settings.
147
- * @return array The default comment form settings.
148
- */
149
- public function register_comment_form_actions($defaults)
150
- {
151
- $this->esi_args = $defaults ;
152
- ob_start() ;
153
- add_action('comment_form_must_log_in_after', array($this, 'comment_form_sub_cancel')) ;
154
- add_action('comment_form_comments_closed', array($this, 'comment_form_sub_cancel')) ;
155
- add_filter('comment_form_submit_button', array($this, 'sub_comment_form_block'), 1000, 2) ;
156
- return $defaults ;
157
- }
158
-
159
- /**
160
- * Build the esi url. This method will build the html comment wrapper as well as serialize and encode the parameter array.
161
- *
162
- * The block_id parameter should contain alphanumeric and '-_' only.
163
- *
164
- * @since 1.1.3
165
- * @access private
166
- * @param string $block_id The id to use to display the correct esi block.
167
- * @param string $wrapper The wrapper for the esi comments.
168
- * @param array $params The esi parameters.
169
- * @param string $control The cache control attribute if any.
170
- * @param bool $silence If generate wrapper comment or not
171
- * @return bool|string False on error, the output otherwise.
172
- */
173
- public static function sub_esi_block( $block_id, $wrapper, $params = array(), $control = 'private,no-vary', $silence = false )
174
- {
175
- if ( empty($block_id) || ! is_array($params) || preg_match('/[^\w-]/', $block_id) ) {
176
- return false ;
177
- }
178
-
179
- $params[ self::PARAM_BLOCK_ID ] = $block_id ;
180
- if ( $silence ) {
181
- // Don't add comment to esi block ( orignal for nonce used in tag property data-nonce='esi_block' )
182
- $params[ '_ls_silence' ] = true ;
183
- }
184
-
185
- $params = apply_filters('litespeed_cache_sub_esi_params-' . $block_id, $params) ;
186
- $control = apply_filters('litespeed_cache_sub_esi_control-' . $block_id, $control) ;
187
- if ( !is_array($params) || !is_string($control) ) {
188
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
189
- LiteSpeed_Cache_Log::push("Sub esi hooks returned Params: \n"
190
- . var_export($params, true) . "\ncache control: \n"
191
- . var_export($control, true)) ;
192
- }
193
- return false ;
194
- }
195
-
196
- $url = trailingslashit( wp_make_link_relative( home_url() ) ) . '?' . self::QS_ACTION . '=' . self::POSTTYPE . '&' . self::QS_PARAMS . '=' . urlencode(base64_encode(serialize($params))) ;
197
- $output = "<esi:include src='$url'" ;
198
- if ( ! empty( $control ) ) {
199
- $output .= " cache-control='$control'" ;
200
- }
201
- $output .= " />" ;
202
-
203
- if ( ! $silence ) {
204
- $output = "<!-- lscwp $wrapper -->$output<!-- lscwp $wrapper esi end -->" ;
205
- }
206
-
207
- LiteSpeed_Cache_Log::debug( "ESI block ID:$block_id; $wrapper; $control" ) ;
208
-
209
- self::set_has_esi() ;
210
- return $output ;
211
- }
212
-
213
- /**
214
- * Parses the request parameters on an ESI request
215
- *
216
- * @since 1.1.3
217
- * @access public
218
- */
219
- public static function parse_esi_param()
220
- {
221
- if ( ! isset($_REQUEST[self::QS_PARAMS]) ) {
222
- return false ;
223
- }
224
- $req_params = $_REQUEST[self::QS_PARAMS] ;
225
- $unencrypted = base64_decode($req_params) ;
226
- if ( $unencrypted === false ) {
227
- return false ;
228
- }
229
- $unencoded = urldecode($unencrypted) ;
230
- $params = unserialize($unencoded) ;
231
- if ( $params === false || ! isset($params[self::PARAM_BLOCK_ID]) ) {
232
- return false ;
233
- }
234
-
235
- return $params ;
236
- }
237
-
238
- /**
239
- * Select the correct esi output based on the parameters in an ESI request.
240
- *
241
- * @since 1.1.3
242
- * @access public
243
- */
244
- public static function load_esi_block()
245
- {
246
- $params = self::parse_esi_param() ;
247
- if ( $params === false ) {
248
- return ;
249
- }
250
- $esi_id = $params[ self::PARAM_BLOCK_ID ] ;
251
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
252
- $logInfo = '------- ESI ------- ' ;
253
- if( ! empty( $params[ self::PARAM_NAME ] ) ) {
254
- $logInfo .= ' Name: ' . $params[ self::PARAM_NAME ] . ' ----- ' ;
255
- }
256
- $logInfo .= $esi_id . ' -------' ;
257
- LiteSpeed_Cache_Log::push( $logInfo ) ;
258
- }
259
-
260
- if ( ! empty( $params[ '_ls_silence' ] ) ) {
261
- define( 'LSCACHE_ESI_SILENCE', true ) ;
262
- }
263
-
264
- $orig = $_SERVER[ 'REQUEST_URI' ] ;
265
- $_SERVER[ 'REQUEST_URI' ] = !empty( $_SERVER[ 'ESI_REFERER' ] ) ? $_SERVER[ 'ESI_REFERER' ] : false ;
266
-
267
- LiteSpeed_Cache_Tag::add( rtrim( LiteSpeed_Cache_Tag::TYPE_ESI, '.' ) ) ;
268
- LiteSpeed_Cache_Tag::add( LiteSpeed_Cache_Tag::TYPE_ESI . $esi_id ) ;
269
-
270
- // LiteSpeed_Cache_Log::debug(var_export($params, true ));
271
-
272
- do_action('litespeed_cache_load_esi_block-' . $esi_id, $params) ;
273
-
274
- $_SERVER[ 'REQUEST_URI' ] = $orig ;
275
- }
276
-
277
- // BEGIN helper functions
278
- // The *_sub_* functions are helpers for the sub_* functions.
279
- // The *_load_* functions are helpers for the load_* functions.
280
-
281
- /**
282
- * Get the configuration option for the current widget.
283
- *
284
- * @since 1.1.3
285
- * @access public
286
- * @param WP_Widget $widget The widget to get the options for.
287
- * @return mixed null if not found, an array of the options otherwise.
288
- */
289
- public static function widget_load_get_options($widget)
290
- {
291
- add_filter('litespeed_cache_widget_default_options', 'LiteSpeed_Cache_ESI::widget_default_options', 10, 2) ;
292
-
293
- if ( ! is_numeric($widget->number) ) {
294
- return null ;
295
- }
296
-
297
- if ( $widget->updated ) {
298
- $settings = get_option($widget->option_name) ;
299
- }
300
- else {
301
- $settings = $widget->get_settings() ;
302
- }
303
-
304
- if ( ! isset($settings) ) {
305
- return null ;
306
- }
307
-
308
- $instance = $settings[$widget->number] ;
309
-
310
- if ( ! isset($instance) || ! isset($instance[LiteSpeed_Cache_Config::OPTION_NAME]) ) {
311
- return null;
312
- }
313
-
314
- return $instance[LiteSpeed_Cache_Config::OPTION_NAME] ;
315
- }
316
-
317
- /**
318
- * Loads the default options for default WordPress widgets.
319
- *
320
- * @since 1.1.3
321
- * @access public
322
- * @param array $options The current options selected.
323
- * @param WP_Widget $widget The widget to be configured.
324
- * @return array The updated options.
325
- */
326
- public static function widget_default_options($options, $widget)
327
- {
328
- if ( ! is_array($options) ) {
329
- return $options ;
330
- }
331
-
332
- $widget_name = get_class($widget) ;
333
- switch ($widget_name) {
334
- case 'WP_Widget_Recent_Posts' :
335
- case 'WP_Widget_Recent_Comments' :
336
- $options[self::WIDGET_OPID_ESIENABLE] = LiteSpeed_Cache_Config::VAL_OFF ;
337
- $options[self::WIDGET_OPID_TTL] = 86400 ;
338
- break ;
339
- default :
340
- break ;
341
- }
342
- return $options ;
343
- }
344
-
345
- /**
346
- * Hooked to the comment_form_must_log_in_after and
347
- * comment_form_comments_closed actions.
348
- *
349
- * @since 1.1.3
350
- * @access public
351
- */
352
- public function comment_form_sub_cancel()
353
- {
354
- ob_flush() ;
355
- }
356
-
357
- /**
358
- * Hooked to the comment_form_after action.
359
- * Cleans up the remaining comment form output.
360
- *
361
- * @since 1.1.3
362
- * @access public
363
- */
364
- public function comment_form_sub_clean()
365
- {
366
- ob_clean() ;
367
- }
368
-
369
- // END helper functions.
370
-
371
- /**
372
- * Hooked to the widget_display_callback filter.
373
- * If the admin configured the widget to display via esi, this function
374
- * will set up the esi request and cancel the widget display.
375
- *
376
- * @since 1.1.3
377
- * @access public
378
- * @param array $instance Parameter used to build the widget.
379
- * @param WP_Widget $widget The widget to build.
380
- * @param array $args Parameter used to build the widget.
381
- * @return mixed Return false if display through esi, instance otherwise.
382
- */
383
- public function sub_widget_block( array $instance, WP_Widget $widget, array $args )
384
- {
385
- $name = get_class( $widget ) ;
386
- if ( ! isset( $instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ) {
387
- return $instance ;
388
- }
389
- $options = $instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ;
390
- if ( ! isset( $options ) || ! $options[ self::WIDGET_OPID_ESIENABLE ] ) {
391
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
392
- LiteSpeed_Cache_Log::push( 'ESI 0 ' . $name . ': '. ( ! isset( $options ) ? 'not set' : 'set off' ) ) ;
393
- }
394
- return $instance ;
395
- }
396
-
397
- $esi_private = $options[ self::WIDGET_OPID_ESIENABLE ] === LiteSpeed_Cache_Config::VAL_ON2 ? 'private,' : '' ;
398
-
399
- $params = array(
400
- self::PARAM_NAME => $name,
401
- self::PARAM_ID => $widget->id,
402
- self::PARAM_INSTANCE => $instance,
403
- self::PARAM_ARGS => $args
404
- ) ;
405
-
406
- echo self::sub_esi_block( 'widget', 'widget ' . $name, $params, $esi_private . 'no-vary' ) ;
407
- return false ;
408
- }
409
-
410
- /**
411
- * Hooked to the wp_footer action.
412
- * Sets up the ESI request for the admin bar.
413
- *
414
- * @access public
415
- * @since 1.1.3
416
- * @global type $wp_admin_bar
417
- */
418
- public function sub_admin_bar_block()
419
- {
420
- global $wp_admin_bar ;
421
-
422
- if ( ! is_admin_bar_showing() || ! is_object($wp_admin_bar) ) {
423
- return ;
424
- }
425
-
426
- echo self::sub_esi_block('admin-bar', 'adminbar') ;
427
- }
428
-
429
- /**
430
- * Hooked to the comment_form_submit_button filter.
431
- *
432
- * This method will compare the used comment form args against the default args. The difference will be passed to the esi request.
433
- *
434
- * @access public
435
- * @since 1.1.3
436
- * @global type $post
437
- * @param $unused
438
- * @param array $args The used comment form args.
439
- * @return unused.
440
- */
441
- public function sub_comment_form_block($unused, $args)
442
- {
443
- if ( empty($args) || empty($this->esi_args) ) {
444
- LiteSpeed_Cache_Log::debug('comment form args empty?') ;
445
- return $unused ;
446
- }
447
- $esi_args = array() ;
448
-
449
- foreach ($args as $key => $val) {
450
- if ( ! isset($this->esi_args[$key]) ) {
451
- $esi_args[$key] = $val ;
452
- }
453
- elseif ( is_array($val) ) {
454
- $diff = array_diff_assoc($val, $this->esi_args[$key]) ;
455
- if ( ! empty($diff) ) {
456
- $esi_args[$key] = $diff ;
457
- }
458
- }
459
- elseif ( $val !== $this->esi_args[$key] ) {
460
- $esi_args[$key] = $val ;
461
- }
462
- }
463
-
464
- ob_clean() ;
465
- global $post ;
466
- $params = array(
467
- self::PARAM_ID => $post->ID,
468
- self::PARAM_ARGS => $esi_args,
469
- ) ;
470
-
471
- echo self::sub_esi_block('comment-form', 'comment form', $params) ;
472
- ob_start() ;
473
- add_action('comment_form_after', array($this, 'comment_form_sub_clean')) ;
474
- return $unused ;
475
- }
476
-
477
- /**
478
- * Parses the esi input parameters and generates the widget for esi display.
479
- *
480
- * @access public
481
- * @since 1.1.3
482
- * @global $wp_widget_factory
483
- * @param array $params Input parameters needed to correctly display widget
484
- */
485
- public function load_widget_block( $params )
486
- {
487
- global $wp_widget_factory ;
488
- $widget = $wp_widget_factory->widgets[ $params[ self::PARAM_NAME ] ] ;
489
- $option = self::widget_load_get_options( $widget ) ;
490
- // Since we only reach here via esi, safe to assume setting exists.
491
- $ttl = $option[ self::WIDGET_OPID_TTL ] ;
492
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
493
- LiteSpeed_Cache_Log::push( 'ESI widget render: name ' . $params[ self::PARAM_NAME ] . ', id ' . $params[ self::PARAM_ID ] . ', ttl ' . $ttl ) ;
494
- }
495
- if ( $ttl == 0 ) {
496
- LiteSpeed_Cache_Control::set_nocache( 'ESI Widget time to live set to 0' ) ;
497
- }
498
- else {
499
- LiteSpeed_Cache_Control::set_custom_ttl( $ttl ) ;
500
-
501
- if ( $option[ self::WIDGET_OPID_ESIENABLE ] === LiteSpeed_Cache_Config::VAL_ON2 ) {
502
- LiteSpeed_Cache_Control::set_private() ;
503
- }
504
- LiteSpeed_Cache_Control::set_no_vary() ;
505
- LiteSpeed_Cache_Tag::add( LiteSpeed_Cache_Tag::TYPE_WIDGET . $params[ self::PARAM_ID ] ) ;
506
- }
507
- the_widget( $params[ self::PARAM_NAME ], $params[ self::PARAM_INSTANCE ], $params[ self::PARAM_ARGS ] ) ;
508
- }
509
-
510
- /**
511
- * Generates the admin bar for esi display.
512
- *
513
- * @access public
514
- * @since 1.1.3
515
- */
516
- public function load_admin_bar_block()
517
- {
518
- wp_admin_bar_render() ;
519
- if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_ESI_CACHE_ADMBAR ) ) {
520
- LiteSpeed_Cache_Control::set_nocache( 'build-in set to not cacheable' ) ;
521
- }
522
- else {
523
- LiteSpeed_Cache_Control::set_private() ;
524
- LiteSpeed_Cache_Control::set_no_vary() ;
525
- }
526
- }
527
-
528
-
529
- /**
530
- * Parses the esi input parameters and generates the comment form for esi display.
531
- *
532
- * @access public
533
- * @since 1.1.3
534
- * @param array $params Input parameters needed to correctly display comment form
535
- */
536
- public function load_comment_form_block($params)
537
- {
538
- remove_filter('comment_form_defaults', array($this, 'register_comment_form_actions')) ;
539
- comment_form($params[self::PARAM_ARGS], $params[self::PARAM_ID]) ;
540
-
541
- if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_ESI_CACHE_COMMFORM ) ) {
542
- LiteSpeed_Cache_Control::set_nocache( 'build-in set to not cacheable' ) ;
543
- }
544
- else {
545
- // by default comment form is public
546
- if ( LiteSpeed_Cache_Vary::has_vary() ) {
547
- LiteSpeed_Cache_Control::set_private() ;
548
- LiteSpeed_Cache_Control::set_no_vary() ;
549
- }
550
- }
551
-
552
- }
553
-
554
- /**
555
- * Get the current instance object.
556
- *
557
- * @since 1.1.3
558
- * @access public
559
- * @return Current class instance.
560
- */
561
- public static function get_instance()
562
- {
563
- if ( ! isset(self::$_instance) ) {
564
- self::$_instance = new self() ;
565
- }
566
-
567
- return self::$_instance ;
568
- }
569
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-esi.tpl.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- if ( ! defined('ABSPATH') ) {
4
- die() ;
5
- }
6
-
7
- LiteSpeed_Cache_ESI::load_esi_block() ;
8
-
9
-
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-gui.class.php DELETED
@@ -1,116 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The frontend GUI class.
5
- *
6
- * @since 1.3
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/includes
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- class LiteSpeed_Cache_GUI
13
- {
14
- private static $_instance ;
15
-
16
- /**
17
- * Init
18
- *
19
- * @since 1.3
20
- * @access private
21
- */
22
- private function __construct()
23
- {
24
- if ( ! is_admin() && is_admin_bar_showing() && current_user_can( 'manage_options' ) ) {
25
- LiteSpeed_Cache_Log::debug( 'GUI init' ) ;
26
- add_action( 'wp_enqueue_scripts', array( $this, 'frontend_enqueue_style' ) ) ;
27
- add_action( 'admin_bar_menu', array( $this, 'frontend_shortcut' ), 95 ) ;
28
- }
29
- }
30
-
31
- /**
32
- * Load frontend menu shortcut
33
- *
34
- * @since 1.3
35
- * @access private
36
- */
37
- public function frontend_enqueue_style()
38
- {
39
- wp_enqueue_style( LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'css/litespeed.css', array(), LiteSpeed_Cache::PLUGIN_VERSION, 'all' ) ;
40
- }
41
-
42
- /**
43
- * Load frontend menu shortcut
44
- *
45
- * @since 1.3
46
- * @access private
47
- */
48
- public function frontend_shortcut()
49
- {
50
-
51
- global $wp_admin_bar ;
52
- $wp_admin_bar->add_menu( array(
53
- 'id' => 'litespeed-menu',
54
- 'title' => '<span class="ab-icon"></span>',
55
- 'href' => get_admin_url( null, 'admin.php?page=lscache-settings' ),
56
- 'meta' => array( 'tabindex' => 0, 'class' => 'litespeed-top-toolbar' ),
57
- ) ) ;
58
-
59
- $wp_admin_bar->add_menu( array(
60
- 'parent' => 'litespeed-menu',
61
- 'id' => 'litespeed-purge-single',
62
- 'title' => __( 'Purge this page', 'litespeed-cache' ),
63
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_PURGE, false, false, true ),
64
- 'meta' => array( 'tabindex' => '0' ),
65
- ) );
66
-
67
- $wp_admin_bar->add_menu( array(
68
- 'parent' => 'litespeed-menu',
69
- 'id' => 'litespeed-single-action',
70
- 'title' => __( 'Mark this page as ', 'litespeed-cache' ),
71
- 'meta' => array( 'tabindex' => '0' ),
72
- ) );
73
-
74
- $wp_admin_bar->add_menu( array(
75
- 'parent' => 'litespeed-single-action',
76
- 'id' => 'litespeed-single-noncache',
77
- 'title' => __( 'Non cacheable', 'litespeed-cache' ),
78
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, false, 'type=nocache', true ),
79
- ) );
80
-
81
- $wp_admin_bar->add_menu( array(
82
- 'parent' => 'litespeed-single-action',
83
- 'id' => 'litespeed-single-private',
84
- 'title' => __( 'Private cache', 'litespeed-cache' ),
85
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, false, 'type=private', true ),
86
- ) );
87
-
88
- $wp_admin_bar->add_menu( array(
89
- 'parent' => 'litespeed-single-action',
90
- 'id' => 'litespeed-single-more',
91
- 'title' => __( 'More settings', 'litespeed-cache' ),
92
- 'href' => get_admin_url( null, 'admin.php?page=lscache-settings#excludes' ),
93
- ) );
94
-
95
-
96
- }
97
-
98
- /**
99
- * Get the current instance object.
100
- *
101
- * @since 1.3
102
- * @access public
103
- * @return Current class instance.
104
- */
105
- public static function get_instance()
106
- {
107
- if ( ! isset( self::$_instance ) ) {
108
- self::$_instance = new self() ;
109
- }
110
-
111
- return self::$_instance ;
112
- }
113
-
114
- }
115
-
116
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-log.class.php DELETED
@@ -1,321 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin logging class.
4
- *
5
- * This generate the valid action.
6
- *
7
- * @since 1.1.0
8
- * @package LiteSpeed_Cache
9
- * @subpackage LiteSpeed_Cache/includes
10
- * @author LiteSpeed Technologies <info@litespeedtech.com>
11
- */
12
- class LiteSpeed_Cache_Log
13
- {
14
- private static $_instance ;
15
- private static $_debug ;
16
- private static $log_path ;
17
- private static $_prefix ;
18
- private static $_enabled = false ;
19
-
20
- /**
21
- * Log class Constructor
22
- *
23
- * NOTE: in this process, until last step ( self::$_debug = true ), any usage to WP filter should not be used to prevent infinite loop with log_filters()
24
- *
25
- * @since 1.1.2
26
- * @access public
27
- */
28
- private function __construct()
29
- {
30
- self::$log_path = LSWCP_CONTENT_DIR . '/debug.log' ;
31
- if ( ! empty( $_SERVER[ 'HTTP_USER_AGENT' ] ) && $_SERVER[ 'HTTP_USER_AGENT' ] === Litespeed_Crawler::FAST_USER_AGENT ) {
32
- self::$log_path = LSWCP_CONTENT_DIR . '/crawler.log' ;
33
- }
34
- if ( ! defined( 'LSCWP_LOG_TAG' ) ) {
35
- define( 'LSCWP_LOG_TAG', get_current_blog_id() ) ;
36
- }
37
-
38
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL ) ) {
39
- define( 'LSCWP_LOG_MORE', true ) ;
40
- }
41
-
42
- $this->_init_request() ;
43
- self::$_debug = true ;
44
- }
45
-
46
- /**
47
- * Heartbeat control
48
- *
49
- * @since 1.1.5
50
- * @access public
51
- */
52
- public static function disable_heartbeat()
53
- {
54
- wp_deregister_script( 'heartbeat' ) ;
55
- }
56
-
57
- /**
58
- * Check if log class finished initialized
59
- *
60
- * @since 1.1.3
61
- * @access public
62
- */
63
- public static function initialized()
64
- {
65
- return isset( self::$_debug ) ;
66
- }
67
-
68
- /**
69
- * Enable debug log
70
- *
71
- * @since 1.1.0
72
- * @access public
73
- */
74
- public static function set_enabled()
75
- {
76
- self::$_enabled = true ;
77
-
78
- if ( ! isset( self::$_debug ) ) {// If not initialized, do it now
79
- self::get_instance() ;
80
- }
81
-
82
- // Check if hook filters
83
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_LOG_FILTERS ) ) {
84
- add_action( 'all', 'LiteSpeed_Cache_Log::log_filters' ) ;
85
- }
86
- }
87
-
88
- /**
89
- * Log all filters and action hooks
90
- *
91
- * @since 1.1.5
92
- * @access public
93
- */
94
- public static function log_filters()
95
- {
96
- $action = current_filter() ;
97
- if ( $ignore_filters = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_LOG_IGNORE_FILTERS ) ) {
98
- $ignore_filters = explode( "\n", $ignore_filters ) ;
99
- if ( in_array( $action, $ignore_filters ) ) {
100
- return ;
101
- }
102
- }
103
-
104
- if ( $ignore_part_filters = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_LOG_IGNORE_PART_FILTERS ) ) {
105
- $ignore_part_filters = explode( "\n", $ignore_part_filters ) ;
106
- foreach ( $ignore_part_filters as $val ) {
107
- if ( stripos( $action, $val ) !== false ) {
108
- return ;
109
- }
110
- }
111
- }
112
-
113
- self::debug( "===log filter: $action" ) ;
114
- }
115
-
116
- /**
117
- * Get debug log status
118
- *
119
- * @since 1.1.0
120
- * @access public
121
- */
122
- public static function get_enabled()
123
- {
124
- return self::$_enabled ;
125
- }
126
-
127
- /**
128
- * Formats the log message with a consistent prefix.
129
- *
130
- * @since 1.0.12
131
- * @access private
132
- * @param string $msg The log message to write.
133
- * @return string The formatted log message.
134
- */
135
- private static function format_message( $msg )
136
- {
137
- // If call here without calling get_enabled() first, improve compatibility
138
- if ( ! defined( 'LSCWP_LOG_TAG' ) ) {
139
- return $msg . "\n" ;
140
- }
141
-
142
- if ( ! isset( self::$_prefix ) ) {
143
- // address
144
- if ( PHP_SAPI == 'cli' ) {
145
- $addr = '=CLI=' ;
146
- if ( isset( $_SERVER[ 'USER' ] ) ) {
147
- $addr .= $_SERVER[ 'USER' ] ;
148
- }
149
- elseif ( $_SERVER[ 'HTTP_X_FORWARDED_FOR' ] ) {
150
- $addr .= $_SERVER[ 'HTTP_X_FORWARDED_FOR' ] ;
151
- }
152
- }
153
- else {
154
- $addr = $_SERVER[ 'REMOTE_ADDR' ] . ':' . $_SERVER[ 'REMOTE_PORT' ] ;
155
- }
156
-
157
- // Generate a unique string per request
158
- self::$_prefix = sprintf( " [%s %s %s] ", $addr, LSCWP_LOG_TAG, Litespeed_String::rrand( 3 ) ) ;
159
- }
160
- list( $usec, $sec ) = explode(' ', microtime() ) ;
161
- return date( 'm/d/y H:i:s', $sec + LITESPEED_TIME_OFFSET ) . substr( $usec, 1, 4 ) . self::$_prefix . $msg . "\n" ;
162
- }
163
-
164
- /**
165
- * Direct call to log a debug message.
166
- *
167
- * @since 1.1.3
168
- * @access public
169
- * @param string $msg The debug message.
170
- * @param int $backtrace_limit Backtrace depth.
171
- */
172
- public static function debug( $msg, $backtrace_limit = false )
173
- {
174
- if ( self::get_enabled() ) {
175
- self::push( $msg, $backtrace_limit !== false ? $backtrace_limit+1 : false ) ;
176
- }
177
- }
178
-
179
- /**
180
- * Direct call to log an advanced debug message.
181
- *
182
- * @since 1.2.0
183
- * @access public
184
- * @param string $msg The debug message.
185
- * @param int $backtrace_limit Backtrace depth.
186
- */
187
- public static function debug2( $msg, $backtrace_limit = false )
188
- {
189
- if ( ! defined( 'LSCWP_LOG_MORE' ) ) {
190
- return ;
191
- }
192
- if ( self::get_enabled() ) {
193
- self::push( $msg, $backtrace_limit !== false ? $backtrace_limit+1 : false ) ;
194
- }
195
- }
196
-
197
- /**
198
- * Logs a debug message.
199
- *
200
- * @since 1.1.0
201
- * @access public
202
- * @param string $msg The debug message.
203
- * @param int $backtrace_limit Backtrace depth.
204
- */
205
- public static function push( $msg, $backtrace_limit = false )
206
- {
207
- // backtrace handler
208
- if ( defined( 'LSCWP_LOG_MORE' ) && $backtrace_limit !== false ) {
209
- $trace = version_compare( PHP_VERSION, '5.4.0', '<' ) ? debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ) : debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, $backtrace_limit + 2 ) ;
210
- for ( $i=1 ; $i <= $backtrace_limit + 1 ; $i++ ) {// the 0st item is push()
211
- if ( empty( $trace[$i]['class'] ) ) {
212
- break ;
213
- }
214
- if ( $trace[$i]['class'] == 'LiteSpeed_Cache_Log' ) {
215
- continue ;
216
- }
217
- $log = str_replace('LiteSpeed_Cache', 'LSC', $trace[$i]['class']) . $trace[$i]['type'] . $trace[$i]['function'] . '()' ;
218
- if ( ! empty( $trace[$i-1]['line'] ) ) {
219
- $log .= '@' . $trace[$i-1]['line'] ;
220
- }
221
- $msg .= " \ $log" ;
222
- }
223
-
224
- }
225
-
226
- Litespeed_File::append( self::$log_path, self::format_message( $msg ) ) ;
227
- }
228
-
229
- /**
230
- * Create the initial log messages with the request parameters.
231
- *
232
- * @since 1.0.12
233
- * @access private
234
- */
235
- private function _init_request()
236
- {
237
- // Check log file size
238
- $log_file_size = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_LOG_FILE_SIZE ) ;
239
- if ( file_exists( self::$log_path ) && filesize( self::$log_path ) > $log_file_size*1000000 ) {
240
- Litespeed_File::save( self::$log_path, '' ) ;
241
- }
242
-
243
- // For more than 2s's requests, add more break
244
- if ( file_exists( self::$log_path ) && time() - filemtime( self::$log_path ) > 2 ) {
245
- Litespeed_File::append( self::$log_path, "\n\n\n\n" ) ;
246
- }
247
-
248
- if ( PHP_SAPI == 'cli' ) {
249
- return ;
250
- }
251
-
252
- $SERVERVARS = array(
253
- 'Query String' => '',
254
- 'HTTP_USER_AGENT' => '',
255
- 'HTTP_ACCEPT_ENCODING' => '',
256
- 'HTTP_COOKIE' => '',
257
- 'X-LSCACHE' => '',
258
- 'LSCACHE_VARY_COOKIE' => '',
259
- 'LSCACHE_VARY_VALUE' => ''
260
- ) ;
261
- $SERVER = array_merge( $SERVERVARS, $_SERVER ) ;
262
- $params = array() ;
263
-
264
- $param = sprintf( '%s %s %s', $SERVER['REQUEST_METHOD'], $SERVER['SERVER_PROTOCOL'], strtok( $SERVER['REQUEST_URI'], '?' ) ) ;
265
-
266
- $qs = ! empty( $SERVER['QUERY_STRING'] ) ? $SERVER['QUERY_STRING'] : '' ;
267
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_COLLAPS_QS ) ) {
268
- if ( strlen( $qs ) > 53 ) {
269
- $qs = substr( $qs, 0, 53 ) . '...' ;
270
- }
271
- if ( $qs ) {
272
- $param .= ' ? ' . $qs ;
273
- }
274
- $params[] = $param ;
275
- }
276
- else {
277
- $params[] = $param ;
278
- $params[] = 'Query String: ' . $qs ;
279
- }
280
-
281
- if ( defined( 'LSCWP_LOG_MORE' ) ) {
282
- $params[] = 'User Agent: ' . $SERVER[ 'HTTP_USER_AGENT' ] ;
283
- $params[] = 'Accept Encoding: ' . $SERVER['HTTP_ACCEPT_ENCODING'] ;
284
- }
285
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE ) ) {
286
- $params[] = 'Cookie: ' . $SERVER['HTTP_COOKIE'] ;
287
- }
288
- if ( isset( $_COOKIE[ '_lscache_vary' ] ) ) {
289
- $params[] = 'Cookie _lscache_vary: ' . $_COOKIE[ '_lscache_vary' ] ;
290
- }
291
- if ( defined( 'LSCWP_LOG_MORE' ) ) {
292
- $params[] = 'X-LSCACHE: ' . ( $SERVER[ 'X-LSCACHE' ] ? 'true' : 'false' ) ;
293
- }
294
- if( $SERVER['LSCACHE_VARY_COOKIE'] ) {
295
- $params[] = 'LSCACHE_VARY_COOKIE: ' . $SERVER['LSCACHE_VARY_COOKIE'] ;
296
- }
297
- if( $SERVER['LSCACHE_VARY_VALUE'] ) {
298
- $params[] = 'LSCACHE_VARY_VALUE: ' . $SERVER['LSCACHE_VARY_VALUE'] ;
299
- }
300
-
301
- $request = array_map( 'self::format_message', $params ) ;
302
-
303
- Litespeed_File::append( self::$log_path, $request ) ;
304
- }
305
-
306
- /**
307
- * Get the current instance object.
308
- *
309
- * @since 1.1.0
310
- * @access public
311
- * @return Current class instance.
312
- */
313
- public static function get_instance()
314
- {
315
- if ( ! isset( self::$_instance ) ) {
316
- self::$_instance = new self() ;
317
- }
318
-
319
- return self::$_instance ;
320
- }
321
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-optimize.class.php DELETED
@@ -1,1002 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The optimize class.
5
- *
6
- * @since 1.2.2
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/includes
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- class LiteSpeed_Cache_Optimize
13
- {
14
- private static $_instance ;
15
-
16
- const DIR_MIN = '/min' ;
17
- const CSS_ASYNC_LIB = '/min/css_async.js' ;
18
-
19
- private $content ;
20
- private $http2_headers = array() ;
21
-
22
- private $cfg_http2_css ;
23
- private $cfg_http2_js ;
24
- private $cfg_css_minify ;
25
- private $cfg_css_combine ;
26
- private $cfg_js_minify ;
27
- private $cfg_js_combine ;
28
- private $cfg_html_minify ;
29
- private $cfg_css_async ;
30
- private $cfg_js_defer ;
31
- private $cfg_qs_rm ;
32
-
33
-
34
- private $html_foot = '' ; // The html info append to <body>
35
- private $html_head = '' ; // The html info prepend to <body>
36
- private $css_to_be_removed = array() ;
37
-
38
- private $minify_cache ;
39
- private $minify_minify ;
40
- private $minify_env ;
41
- private $minify_sourceFactory ;
42
- private $minify_controller ;
43
- private $minify_options ;
44
-
45
- /**
46
- * Init optimizer
47
- *
48
- * @since 1.2.2
49
- * @access private
50
- */
51
- private function __construct()
52
- {
53
- $this->cfg_http2_css = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_HTTP2 ) ;
54
- $this->cfg_http2_js = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_HTTP2 ) ;
55
- $this->cfg_css_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_MINIFY ) ;
56
- $this->cfg_css_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_COMBINE ) ;
57
- $this->cfg_js_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_MINIFY ) ;
58
- $this->cfg_js_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ;
59
- $this->cfg_html_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_HTML_MINIFY ) ;
60
- $this->cfg_css_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC ) ;
61
- $this->cfg_js_defer = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ;
62
- $this->cfg_qs_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ;
63
-
64
- $this->_static_request_check() ;
65
-
66
- if ( ! $this->_can_optm() ) {
67
- return ;
68
- }
69
-
70
- // To remove emoji from WP
71
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM ) ) {
72
- add_action( 'init', array( $this, 'emoji_rm' ) ) ;
73
- }
74
-
75
- if ( $this->cfg_qs_rm ) {
76
- add_filter( 'style_loader_src', array( $this, 'remove_query_strings' ), 999 ) ;
77
- add_filter( 'script_loader_src', array( $this, 'remove_query_strings' ), 999 ) ;
78
- }
79
-
80
- // Check if there is any critical css rules setting
81
- if ( $this->cfg_css_async ) {
82
- add_action( 'wp_head', array( $this, 'prepend_critical_css' ), 1 ) ;
83
- }
84
- }
85
-
86
- /**
87
- * Remove emoji from WP
88
- *
89
- * @since 1.4
90
- * @access public
91
- */
92
- public function emoji_rm()
93
- {
94
- remove_action( 'wp_head' , 'print_emoji_detection_script', 7 ) ;
95
- remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' ) ;
96
- remove_filter( 'the_content_feed' , 'wp_staticize_emoji' ) ;
97
- remove_filter( 'comment_text_rss' , 'wp_staticize_emoji' ) ;
98
- }
99
-
100
- /**
101
- * Output critical css
102
- *
103
- * @since 1.3
104
- * @access public
105
- * @return string The static file content
106
- */
107
- public function prepend_critical_css()
108
- {
109
-
110
- $rules = get_option( LiteSpeed_Cache_Config::ITEM_OPTM_CSS ) ;
111
- if ( ! $rules ) {
112
- return ;
113
- }
114
-
115
- echo '<style id="litespeed-optm-css-rules">' . $rules . '</style>' ;
116
- }
117
-
118
- /**
119
- * Check if the request is for static file
120
- *
121
- * @since 1.2.2
122
- * @access private
123
- * @return string The static file content
124
- */
125
- private function _static_request_check()
126
- {
127
- // This request is for js/css_async.js
128
- if ( $this->cfg_css_async && strpos( $_SERVER[ 'REQUEST_URI' ], self::CSS_ASYNC_LIB ) !== false ) {
129
- LiteSpeed_Cache_Log::debug( 'Optimizer start serving static file' ) ;
130
-
131
- LiteSpeed_Cache_Control::set_cacheable() ;
132
- LiteSpeed_Cache_Control::set_no_vary() ;
133
- LiteSpeed_Cache_Control::set_custom_ttl( 8640000 ) ;
134
- LiteSpeed_Cache_Tag::add( LiteSpeed_Cache_Tag::TYPE_MIN . '_CSS_ASYNC' ) ;
135
-
136
- $file = LSWCP_DIR . 'js/css_async.js' ;
137
-
138
- header( 'Content-Length: ' . filesize( $file ) ) ;
139
- header( 'Content-Type: application/x-javascript; charset=utf-8' ) ;
140
-
141
- echo file_get_contents( $file ) ;
142
- exit ;
143
- }
144
-
145
- // If not turn on min files
146
- if ( ! $this->cfg_css_minify && ! $this->cfg_css_combine && ! $this->cfg_js_minify && ! $this->cfg_js_combine ) {
147
- return ;
148
- }
149
-
150
- if ( empty( $_SERVER[ 'REQUEST_URI' ] ) || strpos( $_SERVER[ 'REQUEST_URI' ], self::DIR_MIN . '/' ) === false ) {
151
- return ;
152
- }
153
-
154
- // try to match `http://home_url/min/xx.css
155
- if ( ! preg_match( '#' . self::DIR_MIN . '/(\w+\.(css|js))#U', $_SERVER[ 'REQUEST_URI' ], $match ) ) {
156
- return ;
157
- }
158
-
159
- LiteSpeed_Cache_Log::debug( 'Optimizer start minifying file' ) ;
160
-
161
- // Proceed css/js file generation
162
- define( 'LITESPEED_MIN_FILE', true ) ;
163
-
164
- $result = $this->_minify( $match[ 1 ] ) ;
165
-
166
- if ( ! $result ) {
167
- LiteSpeed_Cache_Control::set_nocache( 'Empty content from optimizer' ) ;
168
- exit ;
169
- }
170
-
171
- foreach ( $result[ 'headers' ] as $key => $val ) {
172
- if ( in_array( $key, array( 'Content-Length', 'Content-Type' ) ) ) {
173
- header( $key . ': ' . $val ) ;
174
- }
175
- }
176
-
177
- LiteSpeed_Cache_Control::set_cacheable() ;
178
- LiteSpeed_Cache_Control::set_no_vary() ;
179
- LiteSpeed_Cache_Control::set_custom_ttl( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ) ) ;
180
- LiteSpeed_Cache_Tag::add( LiteSpeed_Cache_Tag::TYPE_MIN ) ;
181
-
182
- echo $result[ 'content' ] ;
183
- exit ;
184
- }
185
-
186
- /**
187
- * Remove QS
188
- *
189
- * @since 1.3
190
- * @access public
191
- */
192
- public function remove_query_strings( $src )
193
- {
194
- if ( strpos( $src, 'ver=' ) !== false ) {
195
- $src = preg_replace( '#[&\?]+(ver=([\w\-\.]+))#i', '', $src ) ;
196
- }
197
- return $src ;
198
- }
199
-
200
- /**
201
- * Check if can run optimize
202
- *
203
- * @since 1.3
204
- * @access private
205
- */
206
- private function _can_optm()
207
- {
208
- if ( is_admin() ) {
209
- return false ;
210
- }
211
-
212
- if ( is_feed() ) {
213
- return false ;
214
- }
215
-
216
- if ( is_preview() ) {
217
- return false ;
218
- }
219
-
220
- if ( LiteSpeed_Cache_Router::is_ajax() ) {
221
- return false ;
222
- }
223
-
224
- return true ;
225
- }
226
-
227
- /**
228
- * Run optimize process
229
- * NOTE: As this is after cache finalized, can NOT set any cache control anymore
230
- *
231
- * @since 1.2.2
232
- * @access public
233
- * @return string The content that is after optimization
234
- */
235
- public static function run( $content )
236
- {
237
- if ( defined( 'LITESPEED_MIN_FILE' ) ) {// Must have this to avoid css/js from optimization again
238
- return $content ;
239
- }
240
-
241
- if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
242
- LiteSpeed_Cache_Log::debug( 'Optimizer bypass: Not frontend HTML type' ) ;
243
- return $content ;
244
- }
245
-
246
- LiteSpeed_Cache_Log::debug( 'Optimizer start' ) ;
247
-
248
- $instance = self::get_instance() ;
249
- $instance->content = $content ;
250
-
251
- $instance->_optimize() ;
252
- return $instance->content ;
253
- }
254
-
255
- /**
256
- * Optimize css src
257
- *
258
- * @since 1.2.2
259
- * @access private
260
- */
261
- private function _optimize()
262
- {
263
- if ( ! $this->_can_optm() ) {
264
- LiteSpeed_Cache_Log::debug( 'Optimizer bypass: admin/feed/preview' ) ;
265
- return ;
266
- }
267
-
268
- do_action( 'litespeed_optm' ) ;
269
-
270
- // Parse css from content
271
- $ggfonts_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ;
272
- if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css || $ggfonts_rm || $this->cfg_css_async ) {
273
- // To remove google fonts
274
- if ( $ggfonts_rm ) {
275
- $this->css_to_be_removed[] = 'fonts.googleapis.com' ;
276
- }
277
- list( $src_list, $html_list ) = $this->_handle_css() ;
278
- }
279
-
280
- // css optimizer
281
- if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css ) {
282
-
283
- if ( $src_list ) {
284
- // Analyze local file
285
- list( $ignored_html, $src_queue_list, $file_size_list ) = $this->_analyse_links( $src_list, $html_list ) ;
286
-
287
- // IF combine
288
- if ( $this->cfg_css_combine ) {
289
- $urls = $this->_limit_size_build_hash_url( $src_queue_list, $file_size_list ) ;
290
-
291
- $snippet = '' ;
292
- foreach ( $urls as $url ) {
293
- $snippet .= "<link data-minified='1' rel='stylesheet' href='$url' />" ;
294
- }
295
-
296
- // Handle css async load
297
- if ( $this->cfg_css_async ) {
298
- // Only ignored html snippet needs async
299
- list( $noscript, $ignored_html_async ) = $this->_async_css_list( $ignored_html ) ;
300
-
301
- $noscript .= $snippet ;
302
- $snippet = '' ;
303
- foreach ( $urls as $url ) {
304
- $snippet .= "<link rel='preload' data-preload='1' data-minified='1' as='style' onload='this.rel=\"stylesheet\"' href='$url' />" ;
305
- }
306
-
307
- $this->html_head .= implode( '', $ignored_html_async ) . $snippet ;
308
- $this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
309
- }
310
- else {
311
- $this->html_head .= implode( '', $ignored_html ) . $snippet ;
312
- }
313
-
314
- // Move all css to top
315
- $this->content = str_replace( $html_list, '', $this->content ) ;
316
-
317
- // Add to HTTP2
318
- foreach ( $urls as $url ) {
319
- $this->append_http2( $url ) ;
320
- }
321
-
322
- }
323
- // Only minify
324
- elseif ( $this->cfg_css_minify ) {
325
- // will handle async css load inside
326
- $this->_src_queue_handler( $src_queue_list, $html_list ) ;
327
- }
328
- // Only HTTP2 push
329
- else {
330
- foreach ( $src_queue_list as $val ) {
331
- $this->append_http2( $val ) ;
332
- }
333
- }
334
- }
335
- }
336
-
337
- // Handle css lazy load if not handled async loaded yet
338
- if ( $this->cfg_css_async && ! $this->cfg_css_minify && ! $this->cfg_css_combine ) {
339
- // async html
340
- list( $noscript, $html_list_async ) = $this->_async_css_list( $html_list ) ;
341
-
342
- // add noscript
343
- $this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
344
-
345
- // Replace async css
346
- $this->content = str_replace( $html_list, $html_list_async, $this->content ) ;
347
-
348
- }
349
-
350
- // Parse js from buffer as needed
351
- if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js || $this->cfg_js_defer ) {
352
- list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
353
- }
354
-
355
- // js optimizer
356
- if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js ) {
357
-
358
- if ( $src_list ) {
359
- list( $ignored_html, $src_queue_list, $file_size_list ) = $this->_analyse_links( $src_list, $html_list, 'js' ) ;
360
-
361
- // IF combine
362
- if ( $this->cfg_js_combine ) {
363
- // separate head/foot js/raw html
364
- $head_js = array() ;
365
- $head_ignored_html = array() ;
366
- $foot_js = array() ;
367
- $foot_ignored_html = array() ;
368
- foreach ( $src_queue_list as $k => $src ) {
369
- if ( in_array( $src, $head_src_list ) ) {
370
- $head_js[ $k ] = $src ;
371
- }
372
- else {
373
- $foot_js[ $k ] = $src ;
374
- }
375
- }
376
- foreach ( $ignored_html as $src => $html ) {
377
- if ( in_array( $src, $head_src_list ) ) {
378
- $head_ignored_html[] = $html ;
379
- }
380
- else {
381
- $foot_ignored_html[] = $html ;
382
- }
383
- }
384
-
385
- $snippet = '' ;
386
- if ( $head_js ) {
387
- $urls = $this->_limit_size_build_hash_url( $head_js, $file_size_list, 'js' ) ;
388
- foreach ( $urls as $url ) {
389
- $snippet .= "<script data-minified='1' src='$url' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;
390
-
391
- // Add to HTTP2
392
- $this->append_http2( $url, 'js' ) ;
393
- }
394
- }
395
- if ( $this->cfg_js_defer ) {
396
- $head_ignored_html = $this->_js_defer( $head_ignored_html ) ;
397
- }
398
- $this->html_head .= implode( '', $head_ignored_html ) . $snippet ;
399
-
400
- $snippet = '' ;
401
- if ( $foot_js ) {
402
- $urls = $this->_limit_size_build_hash_url( $foot_js, $file_size_list, 'js' ) ;
403
- foreach ( $urls as $url ) {
404
- $snippet .= "<script data-minified='1' src='$url' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;
405
-
406
- // Add to HTTP2
407
- $this->append_http2( $url, 'js' ) ;
408
- }
409
- }
410
- if ( $this->cfg_js_defer ) {
411
- $foot_ignored_html = $this->_js_defer( $foot_ignored_html ) ;
412
- }
413
- $this->html_foot .= implode( '', $foot_ignored_html ) . $snippet ;
414
-
415
- // Will move all js to top/bottom
416
- $this->content = str_replace( $html_list, '', $this->content ) ;
417
-
418
- }
419
- // Only minify
420
- elseif ( $this->cfg_js_minify ) {
421
- // Will handle js defer inside
422
- $this->_src_queue_handler( $src_queue_list, $html_list, 'js' ) ;
423
- }
424
- // Only HTTP2 push
425
- else {
426
- foreach ( $src_queue_list as $val ) {
427
- $this->append_http2( $val, 'js' ) ;
428
- }
429
- }
430
- }
431
- }
432
-
433
- // Handle js defer if not handled defer yet
434
- if ( $this->cfg_js_defer && ! $this->cfg_js_minify && ! $this->cfg_js_combine ) {
435
- // defer html
436
- $html_list2 = $this->_js_defer( $html_list ) ;
437
-
438
- // Replace async js
439
- $this->content = str_replace( $html_list, $html_list2, $this->content ) ;
440
- }
441
-
442
-
443
- // Append async compatibility lib to head
444
- if ( $this->cfg_css_async ) {
445
- $css_async_lib_url = LiteSpeed_Cache_Utility::get_permalink_url( self::CSS_ASYNC_LIB ) ;
446
- $this->html_head .= "<script src='" . $css_async_lib_url . "' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;
447
- $this->append_http2( $css_async_lib_url, 'js' ) ; // async lib will be http/2 pushed always
448
- }
449
-
450
- // Replace html head part
451
- $this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head ) ;
452
- if ( $this->html_head ) {
453
- $this->content = preg_replace( '#<head([^>]*)>#isU', '<head$1>' . $this->html_head , $this->content, 1 ) ;
454
- }
455
-
456
- // Replace html foot part
457
- $this->html_foot = apply_filters( 'litespeed_optm_html_foot', $this->html_foot ) ;
458
- if ( $this->html_foot ) {
459
- $this->content = str_replace( '</body>', $this->html_foot . '</body>' , $this->content ) ;
460
- }
461
-
462
- // HTML minify
463
- if ( $this->cfg_html_minify ) {
464
- $ori = $this->content ;
465
-
466
- set_error_handler( 'litespeed_exception_handler' ) ;
467
- try {
468
- litespeed_load_vendor() ;
469
- $this->content = Minify_HTML::minify( $this->content ) ;
470
- $this->content .= '<!-- Page minified by LiteSpeed Cache on '.date('Y-m-d H:i:s').' -->' ;
471
-
472
- } catch ( ErrorException $e ) {
473
- LiteSpeed_Cache_Control::debug( 'Error when optimizing HTML: ' . $e->getMessage() ) ;
474
- error_log( 'LiteSpeed Optimizer optimizing HTML Error: ' . $e->getMessage() ) ;
475
- // If failed to minify HTML, restore original content
476
- $this->content = $ori ;
477
- }
478
- restore_error_handler() ;
479
-
480
- }
481
-
482
- if ( $this->http2_headers ) {
483
- @header( 'Link: ' . implode( ',', $this->http2_headers ), false ) ;
484
- }
485
-
486
- }
487
-
488
- /**
489
- * Limit combined filesize when build hash url
490
- *
491
- * @since 1.3
492
- * @access private
493
- */
494
- private function _limit_size_build_hash_url( $src_queue_list, $file_size_list, $file_type = 'css' )
495
- {
496
- $total = 0 ;
497
- $i = 0 ;
498
- $src_arr = array() ;
499
- foreach ( $src_queue_list as $k => $v ) {
500
-
501
- empty( $src_arr[ $i ] ) && $src_arr[ $i ] = array() ;
502
-
503
- $src_arr[ $i ][] = $v ;
504
-
505
- $total += $file_size_list[ $k ] ;
506
-
507
- if ( $total > 1000000 ) { // If larger than 1M, separate them
508
- $total = 0;
509
- $i ++ ;
510
- }
511
- }
512
- if ( count( $src_arr ) > 1 ) {
513
- LiteSpeed_Cache_Log::debug( 'Optimizer: separate ' . $file_type . ' to ' . count( $src_arr ) ) ;
514
- }
515
-
516
- // group build
517
- $hashed_arr = array() ;
518
- foreach ( $src_arr as $v ) {
519
- $hashed_arr[] = $this->_build_hash_url( $v, $file_type ) ;
520
- }
521
-
522
- return $hashed_arr ;
523
- }
524
-
525
- /**
526
- * Run minify with src queue list
527
- *
528
- * @since 1.2.2
529
- * @access private
530
- */
531
- private function _src_queue_handler( $src_queue_list, $html_list, $file_type = 'css' )
532
- {
533
- $noscript = '' ;
534
- $html_list_ori = $html_list ;
535
-
536
- $tag = $file_type === 'css' ? 'link' : 'script' ;
537
- foreach ( $src_queue_list as $key => $src ) {
538
- $url = $this->_build_hash_url( $src, $file_type ) ;
539
- $snippet = str_replace( $src, $url, $html_list[ $key ] ) ;
540
- $snippet = str_replace( "<$tag ", "<$tag data-minified='1' ", $snippet ) ;
541
-
542
- $html_list[ $key ] = $snippet ;
543
-
544
- // Add to HTTP2
545
- $this->append_http2( $url, $file_type ) ;
546
- }
547
-
548
- // Handle css async load
549
- if ( $file_type === 'css' && $this->cfg_css_async ) {
550
- list( $noscript, $html_list ) = $this->_async_css_list( $html_list ) ;
551
- $this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
552
- }
553
-
554
- // Handle js defer
555
- if ( $file_type === 'js' && $this->cfg_js_defer ) {
556
- $html_list = $this->_js_defer( $html_list ) ;
557
- }
558
-
559
- $this->content = str_replace( $html_list_ori, $html_list, $this->content ) ;
560
- }
561
-
562
- /**
563
- * Check if links are internal or external
564
- *
565
- * @since 1.2.2
566
- * @access private
567
- * @return array Array(Ignored raw html, src needed to be handled list, filesize for param 2nd )
568
- */
569
- private function _analyse_links( $src_list, $html_list, $file_type = 'css' )
570
- {
571
- if ( $file_type == 'css' ) {
572
- $excludes = apply_filters( 'litespeed_cache_optimize_css_excludes', LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_EXCLUDES ) ) ;
573
- }
574
- else {
575
- $excludes = apply_filters( 'litespeed_cache_optimize_js_excludes', LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_EXCLUDES ) ) ;
576
- }
577
- if ( $excludes ) {
578
- $excludes = explode( "\n", $excludes ) ;
579
- }
580
-
581
- $ignored_html = array() ;
582
- $src_queue_list = array() ;
583
- $file_size_list = array() ;
584
-
585
- // Analyse links
586
- foreach ( $src_list as $key => $src ) {
587
- LiteSpeed_Cache_Log::debug2( 'Optm: ' . $src ) ;
588
-
589
- if ( $excludes ) {
590
- foreach ( $excludes as $exclude ) {
591
- if ( stripos( $src, $exclude ) !== false ) {
592
- $ignored_html[] = $html_list[ $key ] ;
593
- LiteSpeed_Cache_Log::debug2( 'Optm: Abort excludes ' . $exclude ) ;
594
- continue 2 ;
595
- }
596
- }
597
- }
598
-
599
- // Check if is external URL
600
- $url_parsed = parse_url( $src ) ;
601
- if ( ! $file_info = $this->_is_file_url( $src ) ) {
602
- $ignored_html[ $src ] = $html_list[ $key ] ;
603
- LiteSpeed_Cache_Log::debug2( 'Optm: Abort external/non-exist ' ) ;
604
- continue ;
605
- }
606
-
607
- $src_queue_list[ $key ] = $src ;
608
- $file_size_list[ $key ] = $file_info[ 1 ] ;
609
- }
610
-
611
- return array( $ignored_html, $src_queue_list, $file_size_list ) ;
612
- }
613
-
614
- /**
615
- * Check if an URL is a internal existing file
616
- *
617
- * @since 1.2.2
618
- * @access private
619
- * @return string|bool The real path of file OR false
620
- */
621
- private function _is_file_url( $url )
622
- {
623
- $url_parsed = parse_url( $url ) ;
624
- if ( isset( $url_parsed[ 'host' ] ) && ! LiteSpeed_Cache_Utility::internal( $url_parsed[ 'host' ] ) ) {
625
- // Check if is cdn path
626
- if ( ! LiteSpeed_Cache_CDN::internal( $url_parsed[ 'host' ] ) ) {
627
- return false ;
628
- }
629
- }
630
-
631
- if ( empty( $url_parsed[ 'path' ] ) ) {
632
- return false ;
633
- }
634
-
635
- // Need to replace child blog path for assets, ref: .htaccess
636
- if ( is_multisite() && defined( 'PATH_CURRENT_SITE' ) ) {
637
- $pattern = '#^' . PATH_CURRENT_SITE . '([_0-9a-zA-Z-]+/)(wp-(content|admin|includes))#U' ;
638
- $replacement = PATH_CURRENT_SITE . '$2' ;
639
- $url_parsed[ 'path' ] = preg_replace( $pattern, $replacement, $url_parsed[ 'path' ] ) ;
640
- // $current_blog = (int) get_current_blog_id() ;
641
- // $main_blog_id = (int) get_network()->site_id ;
642
- // if ( $current_blog === $main_blog_id ) {
643
- // define( 'LITESPEED_IS_MAIN_BLOG', true ) ;
644
- // }
645
- // else {
646
- // define( 'LITESPEED_IS_MAIN_BLOG', false ) ;
647
- // }
648
- }
649
-
650
- // Parse file path
651
- if ( substr( $url_parsed[ 'path' ], 0, 1 ) === '/' ) {
652
- $file_path = $_SERVER[ 'DOCUMENT_ROOT' ] . $url_parsed[ 'path' ] ;
653
- }
654
- else {
655
- $file_path = LiteSpeed_Cache_Router::frontend_path() . '/' . $url_parsed[ 'path' ] ;
656
- }
657
- $file_path = realpath( $file_path ) ;
658
- if ( ! is_file( $file_path ) ) {
659
- return false ;
660
- }
661
-
662
- return array( $file_path, filesize( $file_path ) ) ;
663
- }
664
-
665
- /**
666
- * Run minify process and return final content
667
- *
668
- * @since 1.2.2
669
- * @access private
670
- * @return string The final content
671
- */
672
- private function _minify( $filename )
673
- {
674
- // Search filename in db for src URLs
675
- $urls = LiteSpeed_Cache_Data::optm_hash2src( $filename ) ;
676
- if ( ! $urls || ! is_array( $urls ) ) {
677
- return false;
678
- }
679
-
680
- $file_type = substr( $filename, strrpos( $filename, '.' ) + 1 ) ;
681
-
682
- // Parse real file path
683
- $real_files = array() ;
684
- foreach ( $urls as $url ) {
685
- $real_file = $this->_is_file_url( $url ) ;
686
- if ( ! $real_file ) {
687
- continue ;
688
- }
689
- $real_files[] = $real_file[ 0 ] ;
690
- }
691
-
692
- if ( ! $real_files ) {
693
- return false;
694
- }
695
-
696
- // Request to minify
697
- $result = $this->_minify_serve( $real_files, $file_type ) ;
698
-
699
- if ( empty( $result[ 'success' ] ) ) {
700
- LiteSpeed_Cache_Log::debug( 'Optm: Lib serve failed ' . $result[ 'statusCode' ] ) ;
701
- return false ;
702
- }
703
-
704
- LiteSpeed_Cache_Log::debug( 'Optm: Generated content' ) ;
705
-
706
- return $result ;
707
- }
708
-
709
- /**
710
- * Generate full URL path with hash for a list of src
711
- *
712
- * @since 1.2.2
713
- * @access private
714
- * @return string The final URL
715
- */
716
- private function _build_hash_url( $src, $file_type = 'css' )
717
- {
718
- if ( ! $src ) {
719
- return false ;
720
- }
721
-
722
- if ( ! is_array( $src ) ) {
723
- $src = array( $src ) ;
724
- }
725
- $src = array_values( $src ) ;
726
-
727
- $hash = md5( serialize( $src ) ) ;
728
-
729
- $short = substr( $hash, -5 ) ;
730
-
731
- $filename = $short ;
732
-
733
- // Need to check conflicts
734
- // If short hash exists
735
- if ( $urls = LiteSpeed_Cache_Data::optm_hash2src( $short . '.' . $file_type ) ) {
736
- // If conflicts
737
- if ( $urls !== $src ) {
738
- LiteSpeed_Cache_Data::optm_save_src( $hash . '.' . $file_type, $src ) ;
739
- $filename = $hash ;
740
- }
741
- }
742
- else {
743
- // Short hash is safe now
744
- LiteSpeed_Cache_Data::optm_save_src( $short . '.' . $file_type, $src ) ;
745
- }
746
-
747
- $file_to_save = self::DIR_MIN . '/' . $filename . '.' . $file_type ;
748
-
749
- return LiteSpeed_Cache_Utility::get_permalink_url( $file_to_save ) ;
750
- }
751
-
752
- /**
753
- * Parse js src
754
- *
755
- * @since 1.2.2
756
- * @access private
757
- * @return array All the src & related raw html list
758
- */
759
- private function _parse_js()
760
- {
761
- $src_list = array() ;
762
- $html_list = array() ;
763
- $head_src_list = array() ;
764
-
765
- $content = preg_replace( '#<!--.*-->#sU', '', $this->content ) ;
766
- preg_match_all( '#<script\s+([^>]+)>\s*</script>|</head>#isU', $content, $matches, PREG_SET_ORDER ) ;
767
- $i = 0;
768
- $is_head = true ;
769
- foreach ( $matches as $match ) {
770
- if ( $match[ 0 ] === '</head>' ) {
771
- $is_head = false ;
772
- continue ;
773
- }
774
- $attrs = $this->_parse_attr( $match[ 1 ] ) ;
775
-
776
- if ( ! empty( $attrs[ 'data-minified' ] ) ) {
777
- continue ;
778
- }
779
- if ( empty( $attrs[ 'src' ] ) ) {
780
- continue ;
781
- }
782
-
783
- $src_list[] = $attrs[ 'src' ] ;
784
- $html_list[] = $match[ 0 ] ;
785
-
786
- if ( $is_head ) {
787
- $head_src_list[] = $attrs[ 'src' ] ;
788
- }
789
- }
790
-
791
- return array( $src_list, $html_list, $head_src_list ) ;
792
- }
793
-
794
- /**
795
- * Parse css src and remove to-be-removed css
796
- *
797
- * @since 1.2.2
798
- * @access private
799
- * @return array All the src & related raw html list
800
- */
801
- private function _handle_css()
802
- {
803
- $this->css_to_be_removed = apply_filters( 'litespeed_optm_css_to_be_removed', $this->css_to_be_removed ) ;
804
-
805
- $src_list = array() ;
806
- $html_list = array() ;
807
-
808
- // $dom = new PHPHtmlParser\Dom ;
809
- // $dom->load( $content ) ;return $val;
810
- // $items = $dom->find( 'link' ) ;
811
-
812
- $content = preg_replace( '#<!--.*-->#sU', '', $this->content ) ;
813
- preg_match_all( '#<link\s+([^>]+)/?>#isU', $content, $matches, PREG_SET_ORDER ) ;
814
- $i = 0;
815
- foreach ( $matches as $match ) {
816
- $attrs = $this->_parse_attr( $match[ 1 ] ) ;
817
-
818
- if ( empty( $attrs[ 'rel' ] ) || $attrs[ 'rel' ] !== 'stylesheet' ) {
819
- continue ;
820
- }
821
- if ( ! empty( $attrs[ 'data-minified' ] ) ) {
822
- continue ;
823
- }
824
- if ( ! empty( $attrs[ 'media' ] ) && strpos( $attrs[ 'media' ], 'print' ) !== false ) {
825
- continue ;
826
- }
827
- if ( empty( $attrs[ 'href' ] ) ) {
828
- continue ;
829
- }
830
-
831
- // Check if need to remove this css
832
- if ( $this->css_to_be_removed && LiteSpeed_Cache_Utility::str_hit_array( $attrs[ 'href' ], $this->css_to_be_removed ) ) {
833
- LiteSpeed_Cache_Log::debug( 'Optm: rm css snippet ' . $attrs[ 'href' ] ) ;
834
- // Delete this css snippet from orig html
835
- $this->content = str_replace( $match[ 0 ], '', $this->content ) ;
836
- continue ;
837
- }
838
-
839
- $src_list[] = $attrs[ 'href' ] ;
840
- $html_list[] = $match[ 0 ] ;
841
- }
842
-
843
- return array( $src_list, $html_list ) ;
844
- }
845
-
846
- /**
847
- * Replace css to async loaded css
848
- *
849
- * @since 1.3
850
- * @access private
851
- * @param array $html_list Orignal css array
852
- * @return array array( (string)noscript, (array)css_async_list )
853
- */
854
- private function _async_css_list( $html_list )
855
- {
856
- $noscript = '' ;
857
- foreach ( $html_list as $k => $ori ) {
858
- // Append to noscript content
859
- $noscript .= $ori ;
860
- // async replacement
861
- $v = str_replace( 'stylesheet', 'preload', $ori ) ;
862
- $v = str_replace( '<link', "<link data-preload='1' as='style' onload='this.rel=\"stylesheet\"' ", $v ) ;
863
- $html_list[ $k ] = $v ;
864
- }
865
- return array( $noscript, $html_list ) ;
866
- }
867
-
868
- /**
869
- * Add defer to js
870
- *
871
- * @since 1.3
872
- * @access private
873
- */
874
- private function _js_defer( $html_list )
875
- {
876
- foreach ( $html_list as $k => $v ) {
877
- if ( strpos( $v, 'async' ) !== false ) {
878
- continue ;
879
- }
880
- if ( strpos( $v, 'defer' ) !== false ) {
881
- continue ;
882
- }
883
- if ( strpos( $v, 'data-defer' ) !== false ) {
884
- continue ;
885
- }
886
-
887
- $html_list[ $k ] = str_replace( '></script>', ' defer></script>', $v ) ;
888
- }
889
-
890
- return $html_list ;
891
- }
892
-
893
- /**
894
- * Parse attributes from string
895
- *
896
- * @since 1.2.2
897
- * @access private
898
- * @param string $str
899
- * @return array All the attributes
900
- */
901
- private function _parse_attr( $str )
902
- {
903
- $attrs = array() ;
904
- preg_match_all( '#(\w+)=["\']([^"\']*)["\']#isU', $str, $matches, PREG_SET_ORDER ) ;
905
- foreach ( $matches as $match ) {
906
- $attrs[ $match[ 1 ] ] = trim( $match[ 2 ] ) ;
907
- }
908
- return $attrs ;
909
- }
910
-
911
- /**
912
- * Append to HTTP2 header
913
- *
914
- * @since 1.2.2
915
- * @access private
916
- */
917
- private function append_http2( $url, $file_type = 'css' )
918
- {
919
- if ( ! ( $file_type === 'css' ? $this->cfg_http2_css : $this->cfg_http2_js ) ) {
920
- return ;
921
- }
922
-
923
- $uri = LiteSpeed_Cache_Utility::url2uri( $url ) ;
924
-
925
- if ( ! $uri ) {
926
- return ;
927
- }
928
-
929
- $this->http2_headers[] = '<' . $uri . '>; rel=preload; as=' . ( $file_type === 'css' ? 'style' : 'script' ) ;
930
- }
931
-
932
- /**
933
- * Run minify serve
934
- *
935
- * @since 1.2.2
936
- * @access private
937
- * @param array|string $files The file(s) to minify/combine
938
- * @return string The string after effect
939
- */
940
- private function _minify_serve( $files, $file_type )
941
- {
942
- set_error_handler( 'litespeed_exception_handler' ) ;
943
- try {
944
- litespeed_load_vendor() ;
945
- if ( ! isset( $this->minify_cache ) ) {
946
- $this->minify_cache = new Minify_Cache_File() ;
947
- }
948
- if ( ! isset( $this->minify_minify ) ) {
949
- $this->minify_minify = new Minify( $this->minify_cache ) ;
950
- }
951
- if ( ! isset( $this->minify_env ) ) {
952
- $this->minify_env = new Minify_Env() ;
953
- }
954
- if ( ! isset( $this->minify_sourceFactory ) ) {
955
- $this->minify_sourceFactory = new Minify_Source_Factory( $this->minify_env, array(), $this->minify_cache ) ;
956
- }
957
- if ( ! isset( $this->minify_controller ) ) {
958
- $this->minify_controller = new Minify_Controller_Files( $this->minify_env, $this->minify_sourceFactory ) ;
959
- }
960
- if ( ! isset( $this->minify_options ) ) {
961
- $this->minify_options = array(
962
- 'encodeOutput' => false,
963
- 'quiet' => true,
964
- ) ;
965
- }
966
-
967
- $this->minify_options[ 'concatOnly' ] = ! ( $file_type === 'css' ? $this->cfg_css_minify : $this->cfg_js_minify ) ;
968
-
969
- $this->minify_options[ 'files' ] = $files ;
970
-
971
- $content = $this->minify_minify->serve( $this->minify_controller, $this->minify_options ) ;
972
-
973
- } catch ( ErrorException $e ) {
974
- LiteSpeed_Cache_Control::debug( 'Error when serving from optimizer: ' . $e->getMessage() ) ;
975
- error_log( 'LiteSpeed Optimizer serving Error: ' . $e->getMessage() ) ;
976
- return false ;
977
- }
978
- restore_error_handler() ;
979
-
980
- return $content ;
981
- }
982
-
983
- /**
984
- * Get the current instance object.
985
- *
986
- * @since 1.2.2
987
- * @access public
988
- * @return Current class instance.
989
- */
990
- public static function get_instance()
991
- {
992
- if ( ! isset(self::$_instance) ) {
993
- self::$_instance = new self() ;
994
- }
995
-
996
- return self::$_instance ;
997
- }
998
-
999
- }
1000
-
1001
-
1002
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-purge.class.php DELETED
@@ -1,753 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin purge class for X-LiteSpeed-Purge
4
- *
5
- * @since 1.1.3
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/includes
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
- class LiteSpeed_Cache_Purge
11
- {
12
- private static $_instance ;
13
- protected static $_pub_purge = array() ;
14
- protected static $_priv_purge = array() ;
15
- protected static $_purge_related = false ;
16
- protected static $_purge_single = false ;
17
-
18
- const X_HEADER = 'X-LiteSpeed-Purge' ;
19
- const PURGE_QUEUE = 'litespeed-cache-purge-queue' ;
20
-
21
- /**
22
- * Adds new public purge tags to the array of purge tags for the request.
23
- *
24
- * @since 1.1.3
25
- * @access public
26
- * @param mixed $tags Tags to add to the list.
27
- */
28
- public static function add( $tags )
29
- {
30
- if ( ! is_array( $tags ) ) {
31
- $tags = array( $tags ) ;
32
- }
33
- if ( ! array_diff( $tags, self::$_pub_purge ) ) {
34
- return ;
35
- }
36
-
37
- self::$_pub_purge = array_merge( self::$_pub_purge, $tags ) ;
38
-
39
- // Send purge header immediately
40
- $curr_built = self::_build() ;
41
- if ( defined( 'LITESPEED_DID_send_headers' ) ) {
42
- // Can't send, already has output, need to save and wait for next run
43
- update_option( self::PURGE_QUEUE, $curr_built ) ;
44
- LiteSpeed_Cache_Log::debug( 'Output existed, Purge queue stored: ' . $curr_built ) ;
45
- }
46
- else {
47
- @header( $curr_built ) ;
48
- LiteSpeed_Cache_Log::debug( $curr_built ) ;
49
- }
50
- }
51
-
52
- /**
53
- * Adds new private purge tags to the array of purge tags for the request.
54
- *
55
- * @since 1.1.3
56
- * @access public
57
- * @param mixed $tags Tags to add to the list.
58
- */
59
- public static function add_private( $tags )
60
- {
61
- if ( ! is_array( $tags ) ) {
62
- $tags = array( $tags ) ;
63
- }
64
- if ( ! array_diff( $tags, self::$_priv_purge ) ) {
65
- return ;
66
- }
67
-
68
- self::$_priv_purge = array_merge( self::$_priv_purge, $tags ) ;
69
-
70
- // Send purge header immediately
71
- @header( self::_build() ) ;
72
- }
73
-
74
- /**
75
- * Activate `purge related tags` for Admin QS.
76
- *
77
- * @since 1.1.3
78
- * @access public
79
- */
80
- public static function set_purge_related()
81
- {
82
- self::$_purge_related = true ;
83
- }
84
-
85
- /**
86
- * Activate `purge single url tag` for Admin QS.
87
- *
88
- * @since 1.1.3
89
- * @access public
90
- */
91
- public static function set_purge_single()
92
- {
93
- self::$_purge_single = true ;
94
- }
95
-
96
- /**
97
- * Check qs purge status
98
- *
99
- * @since 1.1.3
100
- * @access public
101
- */
102
- public static function get_qs_purge()
103
- {
104
- return self::$_purge_single || self::$_purge_related ;
105
- }
106
-
107
- /**
108
- * Alerts LiteSpeed Web Server to purge all pages.
109
- *
110
- * For multisite installs, if this is called by a site admin (not network admin),
111
- * it will only purge all posts associated with that site.
112
- *
113
- * @since 1.0.0
114
- * @access public
115
- */
116
- public static function purge_all()
117
- {
118
- self::add( '*' ) ;
119
-
120
- // check if need to reset crawler
121
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) ) {
122
- LiteSpeed_Cache_Crawler::get_instance()->reset_pos() ;
123
- }
124
- }
125
-
126
- /**
127
- * Alerts LiteSpeed Web Server to purge the front page.
128
- *
129
- * @since 1.0.3
130
- * @access public
131
- */
132
- public static function purge_front()
133
- {
134
- self::add( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
135
- if ( LITESPEED_SERVER_TYPE !== 'LITESPEED_SERVER_OLS' ) {
136
- self::add_private( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
137
- }
138
- }
139
-
140
- /**
141
- * Alerts LiteSpeed Web Server to purge pages.
142
- *
143
- * @since 1.0.15
144
- * @access public
145
- */
146
- public static function purge_pages()
147
- {
148
- self::add( LiteSpeed_Cache_Tag::TYPE_PAGES ) ;
149
- }
150
-
151
- /**
152
- * Alerts LiteSpeed Web Server to purge pages.
153
- *
154
- * @since 1.2.2
155
- * @access public
156
- */
157
- public static function purge_cssjs()
158
- {
159
- self::add( LiteSpeed_Cache_Tag::TYPE_MIN ) ;
160
- }
161
-
162
- /**
163
- * Alerts LiteSpeed Web Server to purge error pages.
164
- *
165
- * @since 1.0.14
166
- * @access public
167
- */
168
- public static function purge_errors()
169
- {
170
- self::add( LiteSpeed_Cache_Tag::TYPE_ERROR ) ;
171
- if ( ! isset( $_GET[ 'lserr' ] ) || ! in_array( $_GET[ 'lserr' ], array( '403', '404', '500' ) ) ) {
172
- return ;
173
- }
174
-
175
- self::add( LiteSpeed_Cache_Tag::TYPE_ERROR . $_GET[ 'lserr' ] ) ;
176
- }
177
-
178
- /**
179
- * Callback to add purge tags if admin selects to purge selected category pages.
180
- *
181
- * @since 1.0.7
182
- * @access public
183
- * @param string $value The category slug.
184
- * @param string $key Unused.
185
- */
186
- public function purgeby_cat_cb( $value, $key )
187
- {
188
- $val = trim( $value ) ;
189
- if ( empty( $val ) ) {
190
- return ;
191
- }
192
- if ( preg_match( '/^[a-zA-Z0-9-]+$/', $val ) == 0 ) {
193
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_CAT_INV ) ;
194
- return ;
195
- }
196
- $cat = get_category_by_slug( $val ) ;
197
- if ( $cat == false ) {
198
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_CAT_DNE, $val ) ;
199
- return ;
200
- }
201
-
202
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge category %s', 'litespeed-cache' ), $val ) ) ;
203
-
204
- self::add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $cat->term_id ) ;
205
- }
206
-
207
- /**
208
- * Callback to add purge tags if admin selects to purge selected post IDs.
209
- *
210
- * @since 1.0.7
211
- * @access public
212
- * @param string $value The post ID.
213
- * @param string $key Unused.
214
- */
215
- public function purgeby_pid_cb( $value, $key )
216
- {
217
- $val = trim( $value ) ;
218
- if ( empty( $val ) ) {
219
- return ;
220
- }
221
- if ( ! is_numeric( $val ) ) {
222
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_PID_NUM, $val ) ;
223
- return ;
224
- }
225
- elseif ( get_post_status( $val ) !== 'publish' ) {
226
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_PID_DNE, $val ) ;
227
- return ;
228
- }
229
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge Post ID %s', 'litespeed-cache' ), $val ) ) ;
230
-
231
- self::add( LiteSpeed_Cache_Tag::TYPE_POST . $val ) ;
232
- }
233
-
234
- /**
235
- * Callback to add purge tags if admin selects to purge selected tag pages.
236
- *
237
- * @since 1.0.7
238
- * @access public
239
- * @param string $value The tag slug.
240
- * @param string $key Unused.
241
- */
242
- public function purgeby_tag_cb( $value, $key )
243
- {
244
- $val = trim( $value ) ;
245
- if ( empty( $val ) ) {
246
- return ;
247
- }
248
- if ( preg_match( '/^[a-zA-Z0-9-]+$/', $val ) == 0 ) {
249
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_TAG_INV ) ;
250
- return ;
251
- }
252
- $term = get_term_by( 'slug', $val, 'post_tag' ) ;
253
- if ( $term == 0 ) {
254
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_TAG_DNE, $val ) ;
255
- return ;
256
- }
257
-
258
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge tag %s', 'litespeed-cache' ), $val ) ) ;
259
-
260
- self::add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $term->term_id ) ;
261
- }
262
-
263
- /**
264
- * Callback to add purge tags if admin selects to purge selected urls.
265
- *
266
- * @since 1.0.7
267
- * @access public
268
- * @param string $value A url to purge.
269
- * @param string $key Unused.
270
- */
271
- public function purgeby_url_cb( $value, $key = false )
272
- {
273
- $val = trim( $value ) ;
274
- if ( empty( $val ) ) {
275
- return ;
276
- }
277
-
278
- if ( strpos( $val, '<' ) !== false ) {
279
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_URL_BAD ) ;
280
- return ;
281
- }
282
-
283
- $val = LiteSpeed_Cache_Utility::make_relative( $val ) ;
284
-
285
- $hash = LiteSpeed_Cache_Tag::get_uri_tag( $val ) ;
286
-
287
- if ( $hash === false ) {
288
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_URL_INV, $val ) ;
289
- return ;
290
- }
291
-
292
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, sprintf( __( 'Purge url %s', 'litespeed-cache' ), $val ) ) ;
293
-
294
- self::add( $hash ) ;
295
- return ;
296
- }
297
-
298
- /**
299
- * Purge a list of pages when selected by admin. This method will
300
- * look at the post arguments to determine how and what to purge.
301
- *
302
- * @since 1.0.7
303
- * @access public
304
- */
305
- public function purge_list()
306
- {
307
- if ( ! isset($_REQUEST[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT]) || ! isset($_REQUEST[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_LIST]) ) {
308
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_PURGE_FORM) ;
309
- return ;
310
- }
311
- $sel = $_REQUEST[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT] ;
312
- $list_buf = $_REQUEST[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_LIST] ;
313
- if ( empty($list_buf) ) {
314
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_PURGEBY_EMPTY) ;
315
- return ;
316
- }
317
- $list_buf = str_replace(",", "\n", $list_buf) ;// for cli
318
- $list = explode("\n", $list_buf) ;
319
- switch($sel) {
320
- case LiteSpeed_Cache_Admin_Display::PURGEBY_CAT:
321
- $cb = 'purgeby_cat_cb' ;
322
- break ;
323
- case LiteSpeed_Cache_Admin_Display::PURGEBY_PID:
324
- $cb = 'purgeby_pid_cb' ;
325
- break ;
326
- case LiteSpeed_Cache_Admin_Display::PURGEBY_TAG:
327
- $cb = 'purgeby_tag_cb' ;
328
- break ;
329
- case LiteSpeed_Cache_Admin_Display::PURGEBY_URL:
330
- $cb = 'purgeby_url_cb' ;
331
- break ;
332
- default:
333
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_PURGEBY_BAD) ;
334
- return ;
335
- }
336
- array_walk($list, Array($this, $cb)) ;
337
-
338
- // for redirection
339
- $_GET[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT] = $sel ;
340
- }
341
-
342
- /**
343
- * Purge frontend url
344
- *
345
- * @since 1.3
346
- * @access public
347
- */
348
- public static function frontend_purge()
349
- {
350
- if ( empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
351
- exit( 'no referer' ) ;
352
- }
353
- $instance = self::get_instance() ;
354
-
355
- $instance->purgeby_url_cb( $_SERVER[ 'HTTP_REFERER' ] ) ;
356
-
357
- wp_redirect( $_SERVER[ 'HTTP_REFERER' ] ) ;
358
- exit() ;
359
- }
360
-
361
- /**
362
- * Purge a post on update.
363
- *
364
- * This function will get the relevant purge tags to add to the response
365
- * as well.
366
- *
367
- * @since 1.0.0
368
- * @access public
369
- * @param integer $id The post id to purge.
370
- */
371
- public static function purge_post( $id )
372
- {
373
- $post_id = intval($id) ;
374
- // ignore the status we don't care
375
- if ( ! in_array(get_post_status($post_id), array( 'publish', 'trash', 'private', 'draft' )) ) {
376
- return ;
377
- }
378
-
379
- $purge_tags = self::get_purge_tags_by_post($post_id) ;
380
- if ( empty($purge_tags) ) {
381
- return ;
382
- }
383
- if ( in_array( '*', $purge_tags ) ) {
384
- self::purge_all() ;
385
- }
386
- else {
387
- self::add( $purge_tags ) ;
388
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_REST ) ) {
389
- self::add( LiteSpeed_Cache_Tag::TYPE_REST ) ;
390
- }
391
- }
392
- LiteSpeed_Cache_Control::set_stale() ;
393
- }
394
-
395
- /**
396
- * Hooked to the load-widgets.php action.
397
- * Attempts to purge a single widget from cache.
398
- * If no widget id is passed in, the method will attempt to find the widget id.
399
- *
400
- * @since 1.1.3
401
- * @access public
402
- * @param type $widget_id The id of the widget to purge.
403
- */
404
- public static function purge_widget($widget_id = null)
405
- {
406
- if ( is_null($widget_id) ) {
407
- $widget_id = $_POST['widget-id'] ;
408
- if ( is_null($widget_id) ) {
409
- return ;
410
- }
411
- }
412
- self::add(LiteSpeed_Cache_Tag::TYPE_WIDGET . $widget_id) ;
413
- self::add_private(LiteSpeed_Cache_Tag::TYPE_WIDGET . $widget_id) ;
414
- }
415
-
416
- /**
417
- * Hooked to the wp_update_comment_count action.
418
- * Purges the comment widget when the count is updated.
419
- *
420
- * @access public
421
- * @since 1.1.3
422
- * @global type $wp_widget_factory
423
- */
424
- public static function purge_comment_widget()
425
- {
426
- global $wp_widget_factory ;
427
- $recent_comments = $wp_widget_factory->widgets['WP_Widget_Recent_Comments'] ;
428
- if ( !is_null($recent_comments) ) {
429
- self::add(LiteSpeed_Cache_Tag::TYPE_WIDGET . $recent_comments->id) ;
430
- self::add_private(LiteSpeed_Cache_Tag::TYPE_WIDGET . $recent_comments->id) ;
431
- }
432
- }
433
-
434
- /**
435
- * Purges feeds on comment count update.
436
- *
437
- * @since 1.0.9
438
- * @access public
439
- */
440
- public static function purge_feeds()
441
- {
442
- if ( LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_FEED_TTL) > 0 ) {
443
- self::add(LiteSpeed_Cache_Tag::TYPE_FEED) ;
444
- }
445
- }
446
-
447
- /**
448
- * Purges all private cache entries when the user logs out.
449
- *
450
- * @access public
451
- * @since 1.1.3
452
- */
453
- public static function purge_on_logout()
454
- {
455
- self::add_private('*') ;
456
- }
457
-
458
- /**
459
- * Generate all purge tags before output
460
- *
461
- * @access private
462
- * @since 1.1.3
463
- */
464
- private static function _finalize()
465
- {
466
- // Make sure header output only run once
467
- if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
468
- define( 'LITESPEED_DID_' . __FUNCTION__, true ) ;
469
- }
470
- else {
471
- return ;
472
- }
473
-
474
- do_action('litespeed_cache_api_purge') ;
475
-
476
- // Append unique uri purge tags if Admin QS is `PURGESINGLE`
477
- if ( self::$_purge_single ) {
478
- self::$_pub_purge[] = LiteSpeed_Cache_Tag::build_uri_tag() ; // TODO: add private tag too
479
- }
480
- // Append related purge tags if Admin QS is `PURGE`
481
- if ( self::$_purge_related ) {
482
- // Before this, tags need to be finalized
483
- $tags_related = LiteSpeed_Cache_Tag::output_tags() ;
484
- // NOTE: need to remove the empty item `B1_` to avoid purging all
485
- $tags_related = array_filter($tags_related) ;
486
- if ( $tags_related ) {
487
- self::$_pub_purge = array_merge(self::$_pub_purge, $tags_related) ;
488
- }
489
- }
490
-
491
- if ( ! empty(self::$_pub_purge) ) {
492
- self::$_pub_purge = array_unique(self::$_pub_purge) ;
493
- }
494
-
495
- if ( ! empty(self::$_priv_purge) ) {
496
- self::$_priv_purge = array_unique(self::$_priv_purge) ;
497
- }
498
- }
499
-
500
- /**
501
- * Gathers all the purge headers.
502
- *
503
- * This will collect all site wide purge tags as well as third party plugin defined purge tags.
504
- *
505
- * @since 1.1.0
506
- * @access public
507
- * @return string the built purge header
508
- */
509
- public static function output()
510
- {
511
- self::_finalize() ;
512
-
513
- return self::_build() ;
514
- }
515
-
516
- /**
517
- * Build the current purge headers.
518
- *
519
- * @since 1.1.5
520
- * @access private
521
- * @return string the built purge header
522
- */
523
- private static function _build()
524
- {
525
- if ( empty( self::$_pub_purge ) && empty( self::$_priv_purge ) ) {
526
- return ;
527
- }
528
-
529
- $purge_header = '' ;
530
- $private_prefix = self::X_HEADER . ': private,' ;
531
-
532
- if ( ! empty( self::$_pub_purge ) ) {
533
- $public_tags = self::_append_prefix( self::$_pub_purge ) ;
534
- if ( empty( $public_tags ) ) {
535
- // If this ends up empty, private will also end up empty
536
- return ;
537
- }
538
- $purge_header = self::X_HEADER . ': public,' ;
539
- if ( LiteSpeed_Cache_Control::is_stale() ) {
540
- $purge_header .= 'stale,' ;
541
- }
542
- $purge_header .= implode( ',', $public_tags ) ;
543
- $private_prefix = ';private,' ;
544
- }
545
-
546
- // Handle priv purge tags
547
- if ( ! empty( self::$_priv_purge ) ) {
548
- $private_tags = self::_append_prefix( self::$_priv_purge, true ) ;
549
- $purge_header .= $private_prefix . implode( ',', $private_tags ) ;
550
- }
551
-
552
- return $purge_header ;
553
- }
554
-
555
- /**
556
- * Append prefix to an array of purge headers
557
- *
558
- * @since 1.1.0
559
- * @access private
560
- * @param array $purge_tags The purge tags to apply the prefix to.
561
- * @param boolean $is_private If is private tags or not.
562
- * @return array The array of built purge tags.
563
- */
564
- private static function _append_prefix( $purge_tags, $is_private = false )
565
- {
566
- $curr_bid = get_current_blog_id() ;
567
-
568
- if ( ! in_array('*', $purge_tags) ) {
569
- $tags = array() ;
570
- foreach ($purge_tags as $val) {
571
- $tags[] = LSWCP_TAG_PREFIX . $curr_bid . '_' . $val ;
572
- }
573
- return $tags ;
574
- }
575
-
576
- if ( defined('LSWCP_EMPTYCACHE') || $is_private ) {
577
- return array('*') ;
578
- }
579
-
580
- // Would only use multisite and network admin except is_network_admin
581
- // is false for ajax calls, which is used by wordpress updates v4.6+
582
- if ( is_multisite() && (is_network_admin() || (
583
- LiteSpeed_Cache_Router::is_ajax() && (check_ajax_referer('updates', false, false) || check_ajax_referer('litespeed-purgeall-network', false, false))
584
- )) ) {
585
- $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
586
- if ( empty($blogs) ) {
587
- LiteSpeed_Cache_Log::debug('build_purge_headers: blog list is empty') ;
588
- return '' ;
589
- }
590
- $tags = array() ;
591
- foreach ($blogs as $blog_id) {
592
- $tags[] = LSWCP_TAG_PREFIX . $blog_id . '_' ;
593
- }
594
- return $tags ;
595
- }
596
- else {
597
- return array(LSWCP_TAG_PREFIX . $curr_bid . '_') ;
598
- }
599
- }
600
-
601
- /**
602
- * Gets all the purge tags correlated with the post about to be purged.
603
- *
604
- * If the purge all pages configuration is set, all pages will be purged.
605
- *
606
- * This includes site wide post types (e.g. front page) as well as
607
- * any third party plugin specific post tags.
608
- *
609
- * @since 1.0.0
610
- * @access public
611
- * @param integer $post_id The id of the post about to be purged.
612
- * @return array The list of purge tags correlated with the post.
613
- */
614
- public static function get_purge_tags_by_post( $post_id )
615
- {
616
- // If this is a valid post we want to purge the post, the home page and any associated tags & cats
617
- // If not, purge everything on the site.
618
-
619
- $purge_tags = array() ;
620
- $config = LiteSpeed_Cache_Config::get_instance() ;
621
-
622
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_ALL_PAGES) ) {
623
- // ignore the rest if purge all
624
- return array( '*' ) ;
625
- }
626
-
627
- // now do API hook action for post purge
628
- do_action('litespeed_cache_api_purge_post', $post_id) ;
629
-
630
- // post
631
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_POST . $post_id ;
632
- $purge_tags[] = LiteSpeed_Cache_Tag::get_uri_tag(wp_make_link_relative(get_permalink($post_id))) ;
633
-
634
- // for archive of categories|tags|custom tax
635
- global $post ;
636
- $post = get_post($post_id) ;
637
- $post_type = $post->post_type ;
638
-
639
- global $wp_widget_factory ;
640
- $recent_posts = $wp_widget_factory->widgets['WP_Widget_Recent_Posts'] ;
641
- if ( ! is_null($recent_posts) ) {
642
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_WIDGET . $recent_posts->id ;
643
- }
644
-
645
- // get adjacent posts id as related post tag
646
- if( $post_type == 'post' ){
647
- $prev_post = get_previous_post() ;
648
- $next_post = get_next_post() ;
649
- if( ! empty($prev_post->ID) ) {
650
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_POST . $prev_post->ID ;
651
- LiteSpeed_Cache_Log::debug('--------purge_tags prev is: '.$prev_post->ID) ;
652
- }
653
- if( ! empty($next_post->ID) ) {
654
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_POST . $next_post->ID ;
655
- LiteSpeed_Cache_Log::debug('--------purge_tags next is: '.$next_post->ID) ;
656
- }
657
- }
658
-
659
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_TERM) ) {
660
- $taxonomies = get_object_taxonomies($post_type) ;
661
- //LiteSpeed_Cache_Log::push('purge by post, check tax = ' . var_export($taxonomies, true)) ;
662
- foreach ( $taxonomies as $tax ) {
663
- $terms = get_the_terms($post_id, $tax) ;
664
- if ( ! empty($terms) ) {
665
- foreach ( $terms as $term ) {
666
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $term->term_id ;
667
- }
668
- }
669
- }
670
- }
671
-
672
- if ( $config->get_option(LiteSpeed_Cache_Config::OPID_FEED_TTL) > 0 ) {
673
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_FEED ;
674
- }
675
-
676
- // author, for author posts and feed list
677
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_AUTHOR) ) {
678
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_AUTHOR . get_post_field('post_author', $post_id) ;
679
- }
680
-
681
- // archive and feed of post type
682
- // todo: check if type contains space
683
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_POST_TYPE) ) {
684
- if ( get_post_type_archive_link($post_type) ) {
685
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_POSTTYPE . $post_type ;
686
- }
687
- }
688
-
689
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_FRONT_PAGE) ) {
690
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ;
691
- }
692
-
693
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_HOME_PAGE) ) {
694
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_HOME ;
695
- }
696
-
697
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_PAGES) ) {
698
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_PAGES ;
699
- }
700
-
701
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_PAGES_WITH_RECENT_POSTS) ) {
702
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_PAGES_WITH_RECENT_POSTS ;
703
- }
704
-
705
- // if configured to have archived by date
706
- $date = $post->post_date ;
707
- $date = strtotime($date) ;
708
-
709
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_DATE) ) {
710
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE . date('Ymd', $date) ;
711
- }
712
-
713
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_MONTH) ) {
714
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE . date('Ym', $date) ;
715
- }
716
-
717
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_YEAR) ) {
718
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE . date('Y', $date) ;
719
- }
720
-
721
- return array_unique($purge_tags) ;
722
- }
723
-
724
- /**
725
- * The dummy filter for purge all
726
- *
727
- * @since 1.1.5
728
- * @access public
729
- * @param string $val The filter value
730
- * @return string The filter value
731
- */
732
- public static function filter_with_purge_all( $val )
733
- {
734
- self::purge_all() ;
735
- return $val ;
736
- }
737
-
738
- /**
739
- * Get the current instance object.
740
- *
741
- * @since 1.1.3
742
- * @access public
743
- * @return Current class instance.
744
- */
745
- public static function get_instance()
746
- {
747
- if ( ! isset(self::$_instance) ) {
748
- self::$_instance = new self() ;
749
- }
750
-
751
- return self::$_instance ;
752
- }
753
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-router.class.php DELETED
@@ -1,397 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The core plugin router class.
5
- *
6
- * This generate the valid action.
7
- *
8
- * @since 1.1.0
9
- * @package LiteSpeed_Cache
10
- * @subpackage LiteSpeed_Cache/includes
11
- * @author LiteSpeed Technologies <info@litespeedtech.com>
12
- */
13
- class LiteSpeed_Cache_Router
14
- {
15
- private static $_instance ;
16
- private static $_esi_enabled ;
17
- private static $_is_ajax ;
18
- private static $_is_logged_in ;
19
- private static $_can_crawl ;
20
- private static $_ip ;
21
- private static $_action ;
22
- private static $_is_admin_ip ;
23
- private static $_has_whm_msg ;
24
- private static $_has_msg_ruleconflict ;
25
- private static $_frontend_path ;
26
-
27
- /**
28
- * Get frontend path
29
- *
30
- * @since 1.2.2
31
- * @access public
32
- * @return boolean
33
- */
34
- public static function frontend_path()
35
- {
36
- if ( ! isset( self::$_frontend_path ) ) {
37
- $frontend = rtrim( ABSPATH, '/' ) ; // /home/user/public_html/frontend
38
- // get home path failed. Trac ticket #37668 (e.g. frontend:/blog backend:/wordpress)
39
- if ( ! $frontend ) {
40
- $frontend = parse_url( get_option( 'home' ) ) ;
41
- $frontend = ! empty( $frontend[ 'path' ] ) ? $frontend[ 'path' ] : '' ;
42
- $frontend = $_SERVER[ 'DOCUMENT_ROOT' ] . $frontend ;
43
- }
44
- $frontend = realpath( $frontend ) ;
45
-
46
- self::$_frontend_path = $frontend ;
47
- }
48
- return self::$_frontend_path ;
49
- }
50
-
51
- /**
52
- * Check if ESI is enabled or not
53
- *
54
- * @since 1.2.0
55
- * @access public
56
- * @return boolean
57
- */
58
- public static function esi_enabled()
59
- {
60
- if ( ! isset( self::$_esi_enabled ) ) {
61
- self::$_esi_enabled = LSWCP_ESI_SUPPORT && defined( 'LITESPEED_ON' ) && LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_ESI_ENABLE ) ;
62
- }
63
- return self::$_esi_enabled ;
64
- }
65
-
66
- /**
67
- * Check if has rule conflict notice
68
- *
69
- * @since 1.1.5
70
- * @access public
71
- * @return boolean
72
- */
73
- public static function has_msg_ruleconflict()
74
- {
75
- if ( ! isset( self::$_has_msg_ruleconflict ) ) {
76
- self::$_has_msg_ruleconflict = get_option( LiteSpeed_Cache_Admin_Display::DISMISS_MSG ) == LiteSpeed_Cache_Admin_Display::RULECONFLICT_ON ;
77
- }
78
- return self::$_has_msg_ruleconflict ;
79
- }
80
-
81
- /**
82
- * Check if has whm notice
83
- *
84
- * @since 1.1.1
85
- * @access public
86
- * @return boolean
87
- */
88
- public static function has_whm_msg()
89
- {
90
- if ( ! isset( self::$_has_whm_msg ) ) {
91
- self::$_has_whm_msg = get_transient( LiteSpeed_Cache::WHM_TRANSIENT ) == LiteSpeed_Cache::WHM_TRANSIENT_VAL ;
92
- }
93
- return self::$_has_whm_msg ;
94
- }
95
-
96
- /**
97
- * Check if crawler is enabled on server level
98
- *
99
- * @since 1.1.1
100
- * @access public
101
- * @return boolean
102
- */
103
- public static function can_crawl()
104
- {
105
- if ( ! isset( self::$_can_crawl ) ) {
106
- self::$_can_crawl = false ;
107
- if ( isset( $_SERVER['X-LSCACHE'] ) && strpos( $_SERVER['X-LSCACHE'], 'crawler' ) !== false ) {
108
- self::$_can_crawl = true ;
109
- }
110
- // CLI will bypass this check as crawler library can always do the 428 check
111
- if ( defined( 'LITESPEED_CLI' ) ) {
112
- self::$_can_crawl = true ;
113
- }
114
- }
115
- return self::$_can_crawl ;
116
- }
117
-
118
- /**
119
- * Check action
120
- *
121
- * @since 1.1.0
122
- * @access public
123
- * @return string
124
- */
125
- public static function get_action()
126
- {
127
- if ( ! isset( self::$_action ) ) {
128
- self::$_action = false;
129
- self::get_instance()->verify_action() ;
130
- if ( self::$_action && LiteSpeed_Cache_Log::get_enabled() ) {
131
- LiteSpeed_Cache_Log::push( 'LSCWP_CTRL verified: ' . var_export( self::$_action, true ) ) ;
132
- }
133
-
134
- }
135
- return self::$_action ;
136
- }
137
-
138
- /**
139
- * Check if is logged in
140
- *
141
- * @since 1.1.3
142
- * @access public
143
- * @return boolean
144
- */
145
- public static function is_logged_in()
146
- {
147
- if ( ! isset( self::$_is_logged_in ) ) {
148
- self::$_is_logged_in = is_user_logged_in() ;
149
- }
150
- return self::$_is_logged_in ;
151
- }
152
-
153
- /**
154
- * Check if is ajax call
155
- *
156
- * @since 1.1.0
157
- * @access public
158
- * @return boolean
159
- */
160
- public static function is_ajax()
161
- {
162
- if ( ! isset( self::$_is_ajax ) ) {
163
- self::$_is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ;
164
- }
165
- return self::$_is_ajax ;
166
- }
167
-
168
- /**
169
- * Check if is admin ip
170
- *
171
- * @since 1.1.0
172
- * @access public
173
- * @return boolean
174
- */
175
- public static function is_admin_ip()
176
- {
177
- if ( ! isset( self::$_is_admin_ip ) ) {
178
- $ips = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_ADMIN_IPS ) ;
179
-
180
- self::$_is_admin_ip = self::get_instance()->ip_access( $ips ) ;
181
- }
182
- return self::$_is_admin_ip ;
183
- }
184
-
185
- /**
186
- * Check privilege and nonce for the action
187
- *
188
- * @since 1.1.0
189
- * @access private
190
- */
191
- private function verify_action()
192
- {
193
- if( empty( $_REQUEST[LiteSpeed_Cache::ACTION_KEY] ) ) {
194
- return ;
195
- }
196
-
197
- $action = $_REQUEST[LiteSpeed_Cache::ACTION_KEY] ;
198
- $_is_public_action = false ;
199
-
200
- // Each action must have a valid nonce unless its from admin ip and is public action
201
- // Validate requests nonce (from admin logged in page or cli)
202
- if ( ! $this->verify_nonce( $action ) ) {
203
- // check if it is from admin ip
204
- if ( ! $this->is_admin_ip() ) {
205
- LiteSpeed_Cache_Log::debug( 'LSCWP_CTRL query string - did not match admin IP: ' . $action ) ;
206
- return ;
207
- }
208
-
209
- // check if it is public action
210
- if ( ! in_array( $action, array(
211
- LiteSpeed_Cache::ACTION_QS_NOCACHE,
212
- LiteSpeed_Cache::ACTION_QS_PURGE,
213
- LiteSpeed_Cache::ACTION_QS_PURGE_SINGLE,
214
- LiteSpeed_Cache::ACTION_QS_SHOW_HEADERS,
215
- LiteSpeed_Cache::ACTION_QS_PURGE_ALL,
216
- LiteSpeed_Cache::ACTION_QS_PURGE_EMPTYCACHE,
217
- ) ) ) {
218
- LiteSpeed_Cache_Log::debug( 'LSCWP_CTRL query string - did not match admin IP Actions: ' . $action ) ;
219
- return ;
220
- }
221
-
222
- $_is_public_action = true ;
223
- }
224
-
225
- /* Now it is a valid action, lets log and check the permission */
226
- LiteSpeed_Cache_Log::debug( 'LSCWP_CTRL: ' . $action ) ;
227
-
228
- // OK, as we want to do something magic, lets check if its allowed
229
- $_is_multisite = is_multisite() ;
230
- $_is_network_admin = $_is_multisite && is_network_admin() ;
231
- $_can_network_option = $_is_network_admin && current_user_can( 'manage_network_options' ) ;
232
- $_can_option = current_user_can( 'manage_options' ) ;
233
-
234
- switch ( $action ) {
235
- // Save htaccess
236
- case LiteSpeed_Cache::ACTION_SAVE_HTACCESS:
237
- if ( ( ! $_is_multisite && $_can_option ) || $_can_network_option ) {
238
- self::$_action = $action ;
239
- }
240
- return ;
241
-
242
- // Save network settings
243
- case LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK:
244
- if ( $_can_network_option ) {
245
- self::$_action = $action ;
246
- }
247
- return ;
248
-
249
- case LiteSpeed_Cache::ACTION_PURGE_FRONT:
250
- case LiteSpeed_Cache::ACTION_PURGE_PAGES:
251
- case LiteSpeed_Cache::ACTION_PURGE_CSSJS:
252
- case LiteSpeed_Cache::ACTION_PURGE_ERRORS:
253
- case LiteSpeed_Cache::ACTION_PURGE_ALL:
254
- case LiteSpeed_Cache::ACTION_PURGE_BY:
255
- case LiteSpeed_Cache::ACTION_FRONT_PURGE:
256
- case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
257
- if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || $_can_option || self::is_ajax() ) ) {//here may need more security
258
- self::$_action = $action ;
259
- }
260
- return ;
261
-
262
- case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
263
- if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || $_can_option ) ) {
264
- self::$_action = $action ;
265
- }
266
- return ;
267
-
268
- case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:
269
- if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || ( ! $_is_multisite && $_can_option ) ) ) {
270
- self::$_action = $action ;
271
- }
272
- return ;
273
-
274
- case LiteSpeed_Cache::ACTION_QS_NOCACHE:
275
- case LiteSpeed_Cache::ACTION_QS_PURGE:
276
- case LiteSpeed_Cache::ACTION_QS_PURGE_SINGLE:
277
- case LiteSpeed_Cache::ACTION_QS_SHOW_HEADERS:
278
- case LiteSpeed_Cache::ACTION_QS_PURGE_ALL:
279
- case LiteSpeed_Cache::ACTION_QS_PURGE_EMPTYCACHE:
280
- if ( defined( 'LITESPEED_ON' ) && ( $_is_public_action || self::is_ajax() ) ) {
281
- self::$_action = $action ;
282
- }
283
- return ;
284
-
285
- case LiteSpeed_Cache::ACTION_CRAWLER_GENERATE_FILE:
286
- case LiteSpeed_Cache::ACTION_CRAWLER_RESET_POS:
287
- case LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE:
288
- case LiteSpeed_Cache::ACTION_DO_CRAWL:
289
- case LiteSpeed_Cache::ACTION_BLACKLIST_SAVE:
290
- if ( defined( 'LITESPEED_ON' ) && $_can_option && ! $_is_network_admin ) {
291
- self::$_action = $action ;
292
- }
293
- return ;
294
-
295
- case LiteSpeed_Cache::ACTION_DISMISS_WHM:
296
- case LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT:
297
- if ( self::is_ajax() ) {
298
- self::$_action = $action ;
299
- }
300
- return ;
301
-
302
- default:
303
- LiteSpeed_Cache_Log::debug( 'LSCWP_CTRL match falied: ' . $action ) ;
304
- return ;
305
- }
306
-
307
- }
308
-
309
- /**
310
- * Verify nonce
311
- *
312
- * @since 1.1.0
313
- * @access private
314
- * @param string $action
315
- * @return bool
316
- */
317
- private function verify_nonce( $action )
318
- {
319
- if ( ! isset( $_REQUEST[LiteSpeed_Cache::NONCE_NAME] ) || ! wp_verify_nonce( $_REQUEST[LiteSpeed_Cache::NONCE_NAME], $action ) ) {
320
- return false ;
321
- }
322
- else{
323
- return true ;
324
- }
325
- }
326
-
327
- /**
328
- * Check if the ip is in the range
329
- *
330
- * @since 1.1.0
331
- * @access private
332
- * @param string $ip_list IP list
333
- * @return bool
334
- */
335
- private function ip_access( $ip_list )
336
- {
337
- if ( ! $ip_list ) {
338
- return false ;
339
- }
340
- if ( ! isset( self::$_ip ) ) {
341
- self::$_ip = $this->get_ip() ;
342
- }
343
- // $uip = explode('.', $_ip) ;
344
- // if(empty($uip) || count($uip) != 4) Return false ;
345
- if ( ! is_array( $ip_list ) ) {
346
- $ip_list = explode( "\n", $ip_list ) ;
347
- }
348
- // foreach($ip_list as $key => $ip) $ip_list[$key] = explode('.', trim($ip)) ;
349
- // foreach($ip_list as $key => $ip) {
350
- // if(count($ip) != 4) continue ;
351
- // for($i = 0 ; $i <= 3 ; $i++) if($ip[$i] == '*') $ip_list[$key][$i] = $uip[$i] ;
352
- // }
353
- return in_array( self::$_ip, $ip_list ) ;
354
- }
355
-
356
- /**
357
- * Get client ip
358
- *
359
- * @since 1.1.0
360
- * @access private
361
- * @return string
362
- */
363
- private function get_ip()
364
- {
365
- $_ip = '' ;
366
- if ( function_exists( 'apache_request_headers' ) ) {
367
- $apache_headers = apache_request_headers() ;
368
- $_ip = ! empty( $apache_headers['True-Client-IP'] ) ? $apache_headers['True-Client-IP'] : false ;
369
- if ( ! $_ip ) {
370
- $_ip = ! empty( $apache_headers['X-Forwarded-For'] ) ? $apache_headers['X-Forwarded-For'] : false ;
371
- $_ip = explode( ", ", $_ip ) ;
372
- $_ip = array_shift( $_ip ) ;
373
- }
374
-
375
- if ( ! $_ip ) {
376
- $_ip = ! empty( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : false ;
377
- }
378
- }
379
- return $_ip ;
380
- }
381
-
382
- /**
383
- * Get the current instance object.
384
- *
385
- * @since 1.1.0
386
- * @access public
387
- * @return Current class instance.
388
- */
389
- public static function get_instance()
390
- {
391
- if ( ! isset( self::$_instance ) ) {
392
- self::$_instance = new self() ;
393
- }
394
-
395
- return self::$_instance ;
396
- }
397
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-tag.class.php DELETED
@@ -1,367 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin cache-tag class for X-LiteSpeed-Tag
4
- *
5
- * @since 1.1.3
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/includes
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
- class LiteSpeed_Cache_Tag
11
- {
12
- // private static $_instance ;
13
-
14
- const TYPE_FEED = 'FD' ;
15
- const TYPE_FRONTPAGE = 'F' ;
16
- const TYPE_HOME = 'H' ;
17
- const TYPE_PAGES = 'PGS' ;
18
- const TYPE_PAGES_WITH_RECENT_POSTS = 'PGSRP' ;
19
- const TYPE_ERROR = 'ERR.' ;
20
- const TYPE_POST = 'Po.' ; // Post. Cannot use P, reserved for litemage.
21
- const TYPE_ARCHIVE_POSTTYPE = 'PT.' ;
22
- const TYPE_ARCHIVE_TERM = 'T.' ; //for is_category|is_tag|is_tax
23
- const TYPE_AUTHOR = 'A.' ;
24
- const TYPE_ARCHIVE_DATE = 'D.' ;
25
- const TYPE_BLOG = 'B.' ;
26
- const TYPE_LOGIN = 'L' ;
27
- const TYPE_URL = 'URL.' ;
28
- const TYPE_WIDGET = 'W.' ;
29
- const TYPE_ESI = 'ESI.' ;
30
- const TYPE_REST = 'REST' ;
31
- const TYPE_LIST = 'LIST' ;
32
- const TYPE_MIN = 'MIN' ;
33
-
34
- const X_HEADER = 'X-LiteSpeed-Tag' ;
35
-
36
- private static $_tags = array() ;
37
- private static $_tags_priv = array( 'tag_priv' ) ;
38
- protected static $_error_status = false ;
39
-
40
- /**
41
- * Check if the login page is cacheable.
42
- * If not, unset the cacheable member variable.
43
- *
44
- * NOTE: This is checked separately because login page doesn't go through WP logic.
45
- *
46
- * @since 1.0.0
47
- * @access public
48
- */
49
- public static function check_login_cacheable()
50
- {
51
- if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_PAGE_LOGIN ) ) {
52
- return ;
53
- }
54
- if ( LiteSpeed_Cache_Control::isset_notcacheable() ) {
55
- return ;
56
- }
57
-
58
- if ( ! empty( $_GET ) ) {
59
- LiteSpeed_Cache_Control::set_nocache( 'has GET request' ) ;
60
- return ;
61
- }
62
-
63
- LiteSpeed_Cache_Control::set_cacheable() ;
64
-
65
- self::add( self::TYPE_LOGIN ) ;
66
-
67
- // we need to send lsc-cookie manually to make it be sent to all other users when is cacheable
68
- $list = headers_list() ;
69
- if ( empty( $list ) ) {
70
- return ;
71
- }
72
- foreach ( $list as $hdr ) {
73
- if ( strncasecmp( $hdr, 'set-cookie:', 11 ) == 0 ) {
74
- $cookie = substr( $hdr, 12 ) ;
75
- @header( 'lsc-cookie: ' . $cookie, false ) ;
76
- }
77
- }
78
- }
79
-
80
- /**
81
- * Check if the page returns 403 and 500 errors.
82
- *
83
- * @since 1.0.13.1
84
- * @access public
85
- * @param $header
86
- * @param $code
87
- * @return $eror_status
88
- */
89
- public static function check_error_codes( $header, $code )
90
- {
91
- $ttl_403 = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_403_TTL ) ;
92
- $ttl_500 = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_500_TTL ) ;
93
- if ( $code == 403 ) {
94
- if ( $ttl_403 <= 30 && LiteSpeed_Cache_Control::is_cacheable() ) {
95
- LiteSpeed_Cache_Control::set_nocache( '403 TTL is less than 30s' ) ;
96
- }
97
- else {
98
- self::$_error_status = $code ;
99
- }
100
- }
101
- elseif ( $code >= 500 && $code < 600 ) {
102
- if ( $ttl_500 <= 30 && LiteSpeed_Cache_Control::is_cacheable() ) {
103
- LiteSpeed_Cache_Control::set_nocache( 'TTL is less than 30s' ) ;
104
- }
105
- }
106
- elseif ( $code > 400 ) {
107
- self::$_error_status = $code ;
108
- }
109
- return self::$_error_status ;
110
- }
111
-
112
- /**
113
- * Get error code.
114
- *
115
- * @since 1.1.3
116
- * @access public
117
- */
118
- public static function get_error_code()
119
- {
120
- return self::$_error_status ;
121
- }
122
-
123
- /**
124
- * Register purge tag for pages with recent posts widget
125
- * of the plugin.
126
- *
127
- * @since 1.0.15
128
- * @access public
129
- * @param array $params [wordpress params for widget_posts_args]
130
- */
131
- public static function add_widget_recent_posts( $params )
132
- {
133
- self::add( self::TYPE_PAGES_WITH_RECENT_POSTS ) ;
134
- return $params ;
135
- }
136
-
137
- /**
138
- * Adds cache tags to the list of cache tags for the current page.
139
- *
140
- * @since 1.0.5
141
- * @access public
142
- * @param mixed $tags A string or array of cache tags to add to the current list.
143
- */
144
- public static function add( $tags )
145
- {
146
- if ( ! is_array( $tags ) ) {
147
- $tags = array( $tags ) ;
148
- }
149
-
150
- self::$_tags = array_merge( self::$_tags, $tags ) ;
151
- }
152
-
153
- /**
154
- * Return tags for Admin QS
155
- *
156
- * @since 1.1.3
157
- * @access public
158
- */
159
- public static function output_tags()
160
- {
161
- return self::$_tags ;
162
- }
163
-
164
- /**
165
- * Will get a hash of the URI. Removes query string and appends a '/' if it is missing.
166
- *
167
- * @since 1.0.12
168
- * @access public
169
- * @param string $uri The uri to get the hash of.
170
- * @param boolean $ori Return the original url or not
171
- * @return bool|string False on input error, hash otherwise.
172
- */
173
- public static function get_uri_tag( $uri, $ori = false )
174
- {
175
- $no_qs = strtok( $uri, '?' ) ;
176
- if ( empty( $no_qs ) ) {
177
- return false ;
178
- }
179
- $slashed = trailingslashit( $no_qs ) ;
180
-
181
- // If only needs uri tag
182
- if ( $ori ) {
183
- return $slashed ;
184
- }
185
- // return self::TYPE_URL . ( $slashed ) ;
186
- return self::TYPE_URL . md5( $slashed ) ;
187
- }
188
-
189
- /**
190
- * Get the unique tag based on self url.
191
- *
192
- * @since 1.1.3
193
- * @access public
194
- * @param boolean $ori Return the original url or not
195
- */
196
- public static function build_uri_tag( $ori = false )
197
- {
198
- return self::get_uri_tag( urldecode( $_SERVER['REQUEST_URI'] ), $ori ) ;
199
- }
200
-
201
- /**
202
- * Gets the cache tags to set for the page.
203
- *
204
- * This includes site wide post types (e.g. front page) as well as
205
- * any third party plugin specific cache tags.
206
- *
207
- * @since 1.0.0
208
- * @access private
209
- * @return array The list of cache tags to set.
210
- */
211
- private static function _build_type_tags()
212
- {
213
- $tags = array() ;
214
-
215
- $tags[] = self::build_uri_tag() ;
216
-
217
- if ( is_front_page() ) {
218
- $tags[] = self::TYPE_FRONTPAGE ;
219
- }
220
- elseif ( is_home() ) {
221
- $tags[] = self::TYPE_HOME ;
222
- }
223
-
224
- $err = self::get_error_code() ;
225
- if ( $err !== false ) {
226
- $tags[] = self::TYPE_ERROR . $err ;
227
- }
228
-
229
- $queried_obj_id = get_queried_object_id() ;
230
- if ( is_archive() ) {
231
- //An Archive is a Category, Tag, Author, Date, Custom Post Type or Custom Taxonomy based pages.
232
- if ( is_category() || is_tag() || is_tax() ) {
233
- $tags[] = self::TYPE_ARCHIVE_TERM . $queried_obj_id ;
234
- }
235
- elseif ( is_post_type_archive() ) {
236
- global $wp_query ;
237
- $post_type = $wp_query->get( 'post_type' ) ;
238
- $tags[] = self::TYPE_ARCHIVE_POSTTYPE . $post_type ;
239
- }
240
- elseif ( is_author() ) {
241
- $tags[] = self::TYPE_AUTHOR . $queried_obj_id ;
242
- }
243
- elseif ( is_date() ) {
244
- global $post ;
245
- $date = $post->post_date ;
246
- $date = strtotime( $date ) ;
247
- if ( is_day() ) {
248
- $tags[] = self::TYPE_ARCHIVE_DATE . date( 'Ymd', $date ) ;
249
- }
250
- elseif ( is_month() ) {
251
- $tags[] = self::TYPE_ARCHIVE_DATE . date( 'Ym', $date ) ;
252
- }
253
- elseif ( is_year() ) {
254
- $tags[] = self::TYPE_ARCHIVE_DATE . date( 'Y', $date ) ;
255
- }
256
- }
257
- }
258
- elseif ( is_singular() ) {
259
- //$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
260
- $tags[] = self::TYPE_POST . $queried_obj_id ;
261
-
262
- if ( is_page() ) {
263
- $tags[] = self::TYPE_PAGES ;
264
- }
265
- }
266
- elseif ( is_feed() ) {
267
- $tags[] = self::TYPE_FEED ;
268
- }
269
-
270
- // Check REST API
271
- if ( defined( 'REST_REQUEST' ) ) {
272
- $tags[] = self::TYPE_REST ;
273
-
274
- $path = ! empty( $_SERVER[ 'SCRIPT_URL' ] ) ? $_SERVER[ 'SCRIPT_URL' ] : false ;
275
- if ( $path ) {
276
- // posts collections tag
277
- if ( substr( $path, -6 ) == '/posts' ) {
278
- $tags[] = self::TYPE_LIST ;// Not used for purge yet
279
- }
280
-
281
- // single post tag
282
- global $post;
283
- if ( ! empty( $post->ID ) && substr( $path, - strlen( $post->ID ) - 1 ) === '/' . $post->ID ) {
284
- $tags[] = self::TYPE_POST . $post->ID ;
285
- }
286
-
287
- // pages collections & single page tag
288
- if ( stripos( $path, '/pages' ) !== false ) {
289
- $tags[] = self::TYPE_PAGES ;
290
- }
291
- }
292
-
293
- }
294
-
295
- return $tags ;
296
- }
297
-
298
- /**
299
- * Generate all cache tags before output
300
- *
301
- * @access private
302
- * @since 1.1.3
303
- */
304
- private static function _finalize()
305
- {
306
- // run 3rdparty hooks to tag
307
- do_action( 'litespeed_cache_api_tag' ) ;
308
- // generate wp tags
309
- if ( ! defined( 'LSCACHE_IS_ESI' ) ) {
310
- $type_tags = self::_build_type_tags() ;
311
- self::$_tags = array_merge( self::$_tags, $type_tags ) ;
312
- }
313
- // append blog main tag
314
- self::$_tags[] = '' ;
315
- // removed duplicates
316
- self::$_tags = array_unique( self::$_tags ) ;
317
- }
318
-
319
- /**
320
- * Sets up the Cache Tags header.
321
- * ONLY need to run this if is cacheable
322
- *
323
- * @since 1.1.3
324
- * @access public
325
- * @return string empty string if empty, otherwise the cache tags header.
326
- */
327
- public static function output()
328
- {
329
- self::_finalize() ;
330
-
331
- $prefix_tags = array() ;
332
- $prefix = LSWCP_TAG_PREFIX . get_current_blog_id() . '_' ;
333
-
334
- // If is_private and has private tags, append them first, then specify prefix to `public` for public tags
335
- if ( LiteSpeed_Cache_Control::is_private() ) {
336
- foreach ( self::$_tags_priv as $priv_tag ) {
337
- $prefix_tags[] = $prefix . $priv_tag ;
338
- }
339
- $prefix = 'public:' . $prefix ;
340
- }
341
-
342
- foreach ( self::$_tags as $tag ) {
343
- $prefix_tags[] = $prefix . $tag ;
344
- }
345
-
346
- $hdr = self::X_HEADER . ': ' . implode( ',', $prefix_tags ) ;
347
-
348
- return $hdr ;
349
- }
350
-
351
- /**
352
- * Get the current instance object.
353
- *
354
- * @since 1.1.3
355
- * @access public
356
- * @return Current class instance.
357
- */
358
- // public static function get_instance()
359
- // {
360
- // if ( ! isset(self::$_instance) ) {
361
- // self::$_instance = new self() ;
362
- // }
363
-
364
- // return self::$_instance ;
365
- // }
366
-
367
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-task.class.php DELETED
@@ -1,128 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The cron task class.
5
- *
6
- * @since 1.1.3
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/includes
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
- class LiteSpeed_Cache_Task
12
- {
13
- const CRON_ACTION_HOOK = 'litespeed_crawl_trigger' ;
14
- const CRON_FITLER = 'litespeed_crawl_filter' ;
15
-
16
- /**
17
- * Enable/Disable cron task
18
- *
19
- * @since 1.1.0
20
- * @access public
21
- */
22
- public static function enable()
23
- {
24
- $id = LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ;
25
-
26
- // get new setting
27
- $is_enabled = ! LiteSpeed_Cache::config( $id ) ;
28
-
29
- // log
30
- LiteSpeed_Cache_Log::debug( 'Crawler log: Crawler is ' . ( $is_enabled ? 'enabled' : 'disabled' ) ) ;
31
-
32
- // update config
33
- LiteSpeed_Cache_Config::get_instance()->update_options( array( $id => $is_enabled ) ) ;
34
-
35
- self::update() ;
36
-
37
- echo json_encode( array( 'enable' => $is_enabled ) ) ;
38
- wp_die() ;
39
- }
40
-
41
- /**
42
- * Update cron status
43
- *
44
- * @since 1.1.0
45
- * @access public
46
- * @param array $options The options to check if cron should be enabled
47
- */
48
- public static function update( $options = false )
49
- {
50
- $id = LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ;
51
- if ( $options && isset( $options[ $id ] ) ) {
52
- $is_active = $options[$id] ;
53
- }
54
- else {
55
- $is_active = LiteSpeed_Cache::config( $id ) ;
56
- }
57
-
58
- // If cron setting is on, check cache status
59
- if ( $is_active ) {
60
- if ( defined( 'LITESPEED_NEW_OFF' ) ) {
61
- $is_active = false ;
62
- }
63
- elseif ( ! defined( 'LITESPEED_ON' ) && ! defined( 'LITESPEED_NEW_ON' ) ) {
64
- $is_active = false ;
65
- }
66
- }
67
-
68
- if ( $is_active ) {
69
- self::schedule_filter() ;
70
- }
71
- else {
72
- self::clear() ;
73
- }
74
-
75
- }
76
-
77
- /**
78
- * Schedule cron
79
- *
80
- * @since 1.1.0
81
- * @access public
82
- */
83
- public static function schedule_filter()
84
- {
85
- add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter' ) ;
86
-
87
- // Schedule event here to see if it can lost again or not
88
- if( ! wp_next_scheduled( self::CRON_ACTION_HOOK ) ) {
89
- LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook register......' ) ;
90
- wp_schedule_event( time(), self::CRON_FITLER, self::CRON_ACTION_HOOK ) ;
91
- }
92
- }
93
-
94
- /**
95
- * Register cron interval
96
- *
97
- * @since 1.1.0
98
- * @access public
99
- * @param array $schedules WP Hook
100
- */
101
- public static function lscache_cron_filter( $schedules )
102
- {
103
- $interval = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL ) ;
104
- // $wp_schedules = wp_get_schedules() ;
105
- if ( ! array_key_exists( self::CRON_FITLER, $schedules ) ) {
106
- // if ( LiteSpeed_Cache_Log::get_enabled() ) {
107
- // LiteSpeed_Cache_Log::push('Crawler cron log: ......cron filter '.$interval.' added......') ;
108
- // }
109
- $schedules[self::CRON_FITLER] = array(
110
- 'interval' => $interval,
111
- 'display' => __( 'LiteSpeed Cache Custom Cron', 'litespeed-cache' ),
112
- ) ;
113
- }
114
- return $schedules ;
115
- }
116
-
117
- /**
118
- * Clear cron
119
- *
120
- * @since 1.1.0
121
- * @access public
122
- */
123
- public static function clear()
124
- {
125
- LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook cleared......' ) ;
126
- wp_clear_scheduled_hook( self::CRON_ACTION_HOOK ) ;
127
- }
128
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-utility.class.php DELETED
@@ -1,254 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * The utility class.
5
- *
6
- * @since 1.1.5
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/includes
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
- class LiteSpeed_Cache_Utility
12
- {
13
-
14
- /**
15
- * Get url based on permalink setting
16
- *
17
- * @since 1.3
18
- * @access public
19
- * @return string
20
- */
21
- public static function get_permalink_url( $relative_url )
22
- {
23
- return $GLOBALS[ 'wp_rewrite' ]->using_permalinks() ? home_url( $relative_url ) : home_url() . '/?' . $relative_url ;
24
- }
25
-
26
- /**
27
- * Check if an array has a string
28
- *
29
- * Support $ exact match
30
- *
31
- * @since 1.3
32
- * @access private
33
- * @param string $needle The string to search with
34
- * @param array $haystack
35
- * @return bool|string False if not found, otherwise return the matched string in haystack.
36
- */
37
- public static function str_hit_array( $needle, $haystack )
38
- {
39
- foreach( $haystack as $item ) {
40
- // do exact match
41
- if ( substr( $item, -1 ) === '$' ) {
42
- if ( $needle === substr( $item, 1 ) ) {
43
- return $item ;
44
- }
45
- }
46
- else {
47
- if ( strpos( $needle, $item ) !== false ) {
48
- return $item ;
49
- }
50
- }
51
- }
52
-
53
- return false ;
54
- }
55
-
56
- /**
57
- * Improve compatibility to PHP old versions
58
- *
59
- * @since 1.2.2
60
- *
61
- */
62
- public static function compatibility()
63
- {
64
- require_once LSWCP_DIR . 'lib/litespeed-php-compatibility.func.php' ;
65
- }
66
-
67
- /**
68
- * Check if the host is the internal host
69
- *
70
- * @since 1.2.3
71
- *
72
- */
73
- public static function internal( $host )
74
- {
75
- if ( ! defined( 'LITESPEED_FRONTEND_HOST' ) ) {
76
- define( 'LITESPEED_FRONTEND_HOST', parse_url( get_option( 'home' ), PHP_URL_HOST ) ) ;
77
- }
78
-
79
- return $host === LITESPEED_FRONTEND_HOST ;
80
- }
81
-
82
- /**
83
- * Convert URI to URL
84
- *
85
- * @since 1.3
86
- * @access public
87
- * @param string $uri `xx/xx.html` or `/subfolder/xx/xx.html`
88
- * @return string http://www.example.com/subfolder/xx/xx.html
89
- */
90
- public static function uri2url( $uri )
91
- {
92
- if ( substr( $uri, 0, 1 ) === '/' ) {
93
- self::domain_const() ;
94
- $url = LSCWP_DOMAIN . $uri ;
95
- }
96
- else {
97
- $url = home_url( '/' ) . $uri ;
98
- }
99
-
100
- return $url ;
101
- }
102
-
103
- /**
104
- * Convert URL to URI
105
- *
106
- * @since 1.2.2
107
- * @access public
108
- */
109
- public static function url2uri( $url )
110
- {
111
- $url = trim( $url ) ;
112
- $uri = @parse_url( $url, PHP_URL_PATH ) ;
113
- return $uri ;
114
- }
115
-
116
- /**
117
- * Make URL to be relative
118
- *
119
- * NOTE: for subfolder home_url, need to strip subfolder part (strip anything but scheme and host)
120
- *
121
- * @param string $url
122
- * @return string Relative URL, start with /
123
- */
124
- public static function make_relative( $url )
125
- {
126
- // replace home_url if the url is full url
127
- self::domain_const() ;
128
- if ( strpos( $url, LSCWP_DOMAIN ) === 0 ) {
129
- $url = substr( $url, strlen( LSCWP_DOMAIN ) ) ;
130
- }
131
- return trim( $url ) ;
132
- }
133
-
134
- /**
135
- * Generate domain const
136
- *
137
- * This will generate http://www.example.com even there is a subfolder in home_url setting
138
- *
139
- * Const LSCWP_DOMAIN has NO trailing /
140
- *
141
- * @since 1.3
142
- * @access public
143
- */
144
- public static function domain_const()
145
- {
146
- if ( defined( 'LSCWP_DOMAIN' ) ) {
147
- return ;
148
- }
149
-
150
- $home_url = get_home_url( is_multisite() ? get_current_blog_id() : null ) ;
151
-
152
- self::compatibility() ;
153
- $domain = http_build_url( $home_url, array(), HTTP_URL_STRIP_ALL ) ;
154
-
155
- define( 'LSCWP_DOMAIN', $domain ) ;
156
- }
157
-
158
- /**
159
- * Array map one textarea to sanitize the url
160
- *
161
- * @since 1.3
162
- * @access public
163
- * @param string $content
164
- * @param bool $type String handler type
165
- * @return string
166
- */
167
- public static function sanitize_lines( $content, $type = null )
168
- {
169
- if ( ! $content ) {
170
- return $content ;
171
- }
172
-
173
- $arr = explode( "\n", $content ) ;
174
- if ( $type === 'uri' ) {
175
- $arr = array_map( 'LiteSpeed_Cache_Utility::url2uri', $arr ) ;
176
- }
177
- if ( $type === 'relative' ) {
178
- $arr = array_map( 'LiteSpeed_Cache_Utility::make_relative', $arr ) ;// Remove domain
179
- }
180
- $arr = array_map( 'trim', $arr ) ;
181
- $arr = array_unique( $arr ) ;
182
- $arr = array_filter( $arr ) ;
183
- return implode( "\n", $arr ) ;
184
- }
185
-
186
- /**
187
- * Builds an url with an action and a nonce.
188
- *
189
- * Assumes user capabilities are already checked.
190
- *
191
- * @access public
192
- * @param string $action The LSCWP_CTRL action to do in the url.
193
- * @param string $ajax_action AJAX call's action
194
- * @param string $append_str The appending string to url
195
- * @return string The built url.
196
- */
197
- public static function build_url( $action, $ajax_action = false, $append_str = false, $page = null )
198
- {
199
- $prefix = '?' ;
200
-
201
- if ( $ajax_action === false ) {
202
- if ( $page ) {
203
- // If use admin url
204
- if ( $page === true ) {
205
- $page = 'admin.php' ;
206
- }
207
- else {
208
- if ( strpos( $page, '?' ) !== false ) {
209
- $prefix = '&' ;
210
- }
211
- }
212
- $combined = $page . $prefix . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
213
- }
214
- else {
215
- // Current page rebuild URL
216
- $params = $_GET ;
217
-
218
- if ( ! empty( $params ) ) {
219
- if ( isset( $params[ 'LSCWP_CTRL' ] ) ) {
220
- unset( $params[ 'LSCWP_CTRL' ] ) ;
221
- }
222
- if ( isset( $params[ '_wpnonce' ] ) ) {
223
- unset( $params[ '_wpnonce' ] ) ;
224
- }
225
- if ( ! empty( $params ) ) {
226
- $prefix .= http_build_query( $params ) . '&' ;
227
- }
228
- }
229
- global $pagenow ;
230
- $combined = $pagenow . $prefix . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
231
- }
232
- }
233
- else {
234
- $combined = 'admin-ajax.php?action=' . $ajax_action . '&' . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
235
- }
236
-
237
- if ( is_network_admin() ) {
238
- $prenonce = network_admin_url( $combined ) ;
239
- }
240
- else {
241
- $prenonce = admin_url( $combined ) ;
242
- }
243
- $url = wp_nonce_url( $prenonce, $action, LiteSpeed_Cache::NONCE_NAME ) ;
244
-
245
- if ( $append_str ) {
246
- $url .= '&' . $append_str ;
247
- }
248
-
249
- return $url ;
250
- }
251
- }
252
-
253
-
254
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-vary.class.php DELETED
@@ -1,465 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin vary class to manage X-LiteSpeed-Vary
4
- *
5
- * @since 1.1.3
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/includes
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
- class LiteSpeed_Cache_Vary
11
- {
12
- private static $_instance ;
13
-
14
- const X_HEADER = 'X-LiteSpeed-Vary' ;
15
-
16
- private static $_vary_name = '_lscache_vary' ; // this default vary cookie is used for logged in status check
17
- private static $_vary_cookies = array() ; // vary header only!
18
-
19
- /**
20
- * Adds the actions used for setting up cookies on log in/out.
21
- *
22
- * Also checks if the database matches the rewrite rule.
23
- *
24
- * @since 1.0.4
25
- */
26
- private function __construct()
27
- {
28
- // logged in user
29
- if ( LiteSpeed_Cache_Router::is_logged_in() ) {
30
- // Make sure the cookie value is corrent
31
- self::add_logged_in() ;
32
-
33
- // If not esi, check cache logged-in user setting
34
- if ( ! LiteSpeed_Cache_Router::esi_enabled() ) {
35
- // If cache logged-in, then init cacheable to private
36
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_PRIV ) ) {
37
- add_action( 'wp_logout', 'LiteSpeed_Cache_Purge::purge_on_logout' ) ;
38
-
39
- LiteSpeed_Cache_Control::init_cacheable() ;
40
- LiteSpeed_Cache_Control::set_private( 'logged in user' ) ;
41
- }
42
- // No cache for logged-in user
43
- else {
44
- LiteSpeed_Cache_Control::set_nocache( 'logged in user' ) ;
45
- }
46
- }
47
- // ESI is on, can be public cache
48
- else {
49
- // Need to make sure vary is using group id
50
- LiteSpeed_Cache_Control::init_cacheable() ;
51
- }
52
-
53
- // register logout hook to clear login status
54
- add_action( 'clear_auth_cookie', 'LiteSpeed_Cache_Vary::remove_logged_in' ) ;
55
-
56
- }
57
- else {
58
- // Make sure the cookie value is corrent
59
- self::remove_logged_in() ;
60
-
61
- // Set vary cookie for logging in user, otherwise the user will hit public with vary=0 (guest version)
62
- add_action( 'set_logged_in_cookie', 'LiteSpeed_Cache_Vary::add_logged_in', 10, 4 ) ;
63
- add_action( 'wp_login', 'LiteSpeed_Cache_Purge::purge_on_logout' ) ;
64
-
65
- LiteSpeed_Cache_Control::init_cacheable() ;
66
-
67
- // Check `login page` cacheable setting because they don't go through main WP logic
68
- add_action( 'login_init', 'LiteSpeed_Cache_Tag::check_login_cacheable', 5 ) ;
69
-
70
- }
71
-
72
- // Add comment list ESI
73
- add_filter('comments_array', array( $this, 'check_commenter' ) ) ;
74
-
75
- // Set vary cookie for commenter.
76
- add_action('set_comment_cookies', array( $this, 'append_commenter' ) ) ;
77
-
78
- /******** Below to the end is only for cookie name setting check ********/
79
- // Get specific cookie name
80
- $db_cookie = false ;
81
- if ( is_multisite() ) {
82
- $options = LiteSpeed_Cache_Config::get_instance()->get_site_options() ;
83
- $db_cookie = $options[ LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ] ;
84
- }
85
- else {
86
- $db_cookie = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE) ;
87
- }
88
-
89
- // If no vary set in rewrite rule
90
- if ( ! isset($_SERVER['LSCACHE_VARY_COOKIE']) ) {
91
- if ( $db_cookie ) {
92
- // Display cookie error msg to admin
93
- if ( is_multisite() ? is_network_admin() : is_admin() ) {
94
- LiteSpeed_Cache_Admin_Display::show_error_cookie() ;
95
- }
96
- LiteSpeed_Cache_Control::set_nocache('vary cookie setting error') ;
97
- return ;
98
- }
99
- return ;
100
- }
101
- // If db setting does not exist, skip checking db value
102
- if ( ! $db_cookie ) {
103
- return ;
104
- }
105
-
106
- // beyond this point, need to make sure db vary setting is in $_SERVER env.
107
- $vary_arr = explode(',', $_SERVER['LSCACHE_VARY_COOKIE']) ;
108
-
109
- if ( in_array($db_cookie, $vary_arr) ) {
110
- self::$_vary_name = $db_cookie ;
111
- return ;
112
- }
113
-
114
- if ( is_multisite() ? is_network_admin() : is_admin() ) {
115
- LiteSpeed_Cache_Admin_Display::show_error_cookie() ;
116
- }
117
- LiteSpeed_Cache_Control::set_nocache('vary cookie setting lost error') ;
118
- }
119
-
120
- /**
121
- * Hooked to the comments_array filter.
122
- *
123
- * Check if the user accessing the page has the commenter cookie.
124
- *
125
- * If the user does not want to cache commenters, just check if user is commenter.
126
- * Otherwise if the vary cookie is set, unset it. This is so that when the page is cached, the page will appear as if the user was a normal user.
127
- * Normal user is defined as not a logged in user and not a commenter.
128
- *
129
- * @since 1.0.4
130
- * @access public
131
- * @global type $post
132
- * @param array $comments The current comments to output
133
- * @return array The comments to output.
134
- */
135
- public function check_commenter( $comments )
136
- {
137
- $pending = false ;
138
- foreach ( $comments as $comment ) {
139
- if ( ! $comment->comment_approved ) {// current user has pending comment
140
- $pending = true ;
141
- break ;
142
- }
143
- }
144
-
145
- // No pending comments, don't need to add private cache
146
- if ( ! $pending ) {
147
- $this->remove_commenter() ;
148
-
149
- // Remove commenter prefilled info if exists, for public cache
150
- foreach( $_COOKIE as $cookie_name => $cookie_value ) {
151
- if ( strlen( $cookie_name ) >= 15 && strncmp( $cookie_name, 'comment_author_', 15 ) == 0 ) {
152
- unset( $_COOKIE[ $cookie_name ] ) ;
153
- }
154
- }
155
-
156
- return $comments ;
157
- }
158
-
159
- // Current user/visitor has pending comments
160
- // set vary=2 for next time vary lookup
161
- $this->add_commenter() ;
162
-
163
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_COMMENTER ) ) {
164
- LiteSpeed_Cache_Control::set_private( 'existing commenter' ) ;
165
- }
166
- else {
167
- LiteSpeed_Cache_Control::set_nocache( 'existing commenter' ) ;
168
- }
169
-
170
- return $comments ;
171
- }
172
-
173
- /**
174
- * Check if default vary has a value
175
- *
176
- * @since 1.1.3
177
- * @access public
178
- */
179
- public static function has_vary()
180
- {
181
- if ( empty( $_COOKIE[ self::$_vary_name ] ) ) {
182
- return false ;
183
- }
184
- return $_COOKIE[ self::$_vary_name ] ;
185
- }
186
-
187
- /**
188
- * Append user status with logged in
189
- *
190
- * @since 1.1.3
191
- * @access public
192
- */
193
- public static function add_logged_in( $logged_in_cookie = false, $expire = false, $expiration = false, $user_id = false )
194
- {
195
- // If the cookie is lost somehow, set it
196
- $vary = self::generate_vary( $user_id ) ;
197
- $current_vary = self::has_vary() ;
198
- if ( $current_vary !== $vary && $current_vary !== 'commenter' ) {
199
- // $_COOKIE[ self::$_vary_name ] = $vary ; // not needed
200
-
201
- // save it
202
- if ( ! $expire ) {
203
- $expire = time() + 2 * DAY_IN_SECONDS ;
204
- }
205
- self::_cookie( $vary, $expire ) ;
206
- LiteSpeed_Cache_Control::set_nocache( 'adding logged in status' ) ;
207
- }
208
- }
209
-
210
- /**
211
- * Remove user logged in status
212
- *
213
- * @since 1.1.3
214
- * @access public
215
- */
216
- public static function remove_logged_in()
217
- {
218
- // If the cookie is set and not commenter, unset it.
219
- $current_vary = self::has_vary() ;
220
- if ( $current_vary && $current_vary !== 'commenter' ) {
221
- // remove logged in status from global var
222
- // unset( $_COOKIE[ self::$_vary_name ] ) ; // not needed
223
-
224
- // save it
225
- self::_cookie() ;
226
- LiteSpeed_Cache_Control::set_nocache( 'removing logged in status' ) ;
227
- }
228
- }
229
-
230
- /**
231
- * Get user vary tag based on admin_bar & role
232
- *
233
- * @since 1.2.0
234
- * @access public
235
- */
236
- public static function generate_vary( $user_id )
237
- {
238
- if ( ! $user_id ) {
239
- $user = wp_get_current_user() ;
240
- $user_id = $user->ID ;
241
- LiteSpeed_Cache_Log::debug2( 'getting user_id: ' . $user_id ) ;
242
- }
243
- $vary = array( 'logged-in' => 1 ) ;
244
- // get user's group id
245
- $user = get_userdata( $user_id ) ;
246
- if ( empty( $user->roles[ 0 ] ) ) {
247
- // Guest user
248
- LiteSpeed_Cache_Log::debug( 'Vary role id: failed, guest' ) ;
249
- return false ;
250
- }
251
-
252
- // parge role group from settings
253
- $gid = $user->roles[ 0 ] ?: 0 ;
254
- if ( $role_group = LiteSpeed_Cache_Config::get_instance()->in_vary_group( $gid ) ) {
255
- $vary[ 'role' ] = $role_group ;
256
- LiteSpeed_Cache_Log::debug2( 'Vary role group: ' . $gid ) ;
257
- }
258
-
259
- // Get admin bar set
260
- // see @_get_admin_bar_pref()
261
- $pref = get_user_option( 'show_admin_bar_front', $user_id ) ;
262
- LiteSpeed_Cache_Log::debug2( 'Vary show_admin_bar_front: ' . $pref ) ;
263
- $admin_bar = $pref === false || $pref === 'true' ;
264
-
265
- if ( $admin_bar ) {
266
- $vary[ 'admin_bar' ] = 1 ;
267
- LiteSpeed_Cache_Log::debug2( 'Vary admin bar : true' ) ;
268
- }
269
-
270
- ksort( $vary ) ;
271
- $res = array() ;
272
- foreach ( $vary as $key => $val ) {
273
- $res[] = $key . ':' . $val ;
274
- }
275
-
276
- if ( ! $res ) {
277
- return false ;
278
- }
279
-
280
- $res = implode( ';', $res ) ;
281
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
282
- return $res ;
283
- }
284
- // Encrypt in production
285
- return md5( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::HASH ) . $res ) ;
286
- }
287
-
288
- /**
289
- * Append user status with commenter
290
- *
291
- * This is ONLY used when submit a comment
292
- *
293
- * @since 1.1.6
294
- * @access public
295
- */
296
- public function append_commenter()
297
- {
298
- $this->add_commenter( true ) ;
299
- }
300
-
301
- /**
302
- * Correct user status with commenter
303
- *
304
- * @since 1.1.3
305
- * @access private
306
- * @param boolean $from_redirect If the request is from redirect page or not
307
- */
308
- private function add_commenter( $from_redirect = false )
309
- {
310
- // If the cookie is lost somehow, set it
311
- if ( self::has_vary() !== 'commenter' ) {
312
- // $_COOKIE[ self::$_vary_name ] = 'commenter' ; // not needed
313
-
314
- // save it
315
- // only set commenter status for current domain path
316
- self::_cookie( 'commenter', time() + apply_filters( 'comment_cookie_lifetime', 30000000 ), self::_relative_path( $from_redirect ) ) ;
317
- LiteSpeed_Cache_Control::set_nocache( 'adding commenter status' ) ;
318
- }
319
- }
320
-
321
- /**
322
- * Remove user commenter status
323
- *
324
- * @since 1.1.3
325
- * @access private
326
- */
327
- private function remove_commenter()
328
- {
329
- if ( self::has_vary() === 'commenter' ) {
330
- // remove logged in status from global var
331
- // unset( $_COOKIE[ self::$_vary_name ] ) ; // not needed
332
-
333
- // save it
334
- self::_cookie( false, false, self::_relative_path() ) ;
335
- LiteSpeed_Cache_Control::set_nocache( 'removing commenter status' ) ;
336
- }
337
- }
338
-
339
- /**
340
- * Generate relative path for cookie
341
- *
342
- * @since 1.1.3
343
- * @access private
344
- * @param boolean $from_redirect If the request is from redirect page or not
345
- */
346
- private static function _relative_path( $from_redirect = false )
347
- {
348
- $path = false ;
349
- $tag = $from_redirect ? 'HTTP_REFERER' : 'SCRIPT_URL' ;
350
- if ( ! empty( $_SERVER[ $tag ] ) ) {
351
- $path = parse_url( $_SERVER[ $tag ] ) ;
352
- $path = ! empty( $path[ 'path' ] ) ? $path[ 'path' ] : false ;
353
- LiteSpeed_Cache_Log::debug( 'Cookie Vary path: ' . $path ) ;
354
- }
355
- return $path ;
356
- }
357
-
358
- /**
359
- * Gets vary cookies that are already added for the current page.
360
- *
361
- * @since 1.0.13
362
- * @access private
363
- * @return array An array of all vary cookies currently added.
364
- */
365
- private static function _format_vary_cookies()
366
- {
367
- if ( empty(self::$_vary_cookies) ) {
368
- return false ;
369
- }
370
- $cookies = array_filter(array_unique(self::$_vary_cookies)) ;
371
- if ( empty($cookies) ) {
372
- return false ;
373
- }
374
- foreach ($cookies as $key => $val) {
375
- $cookies[$key] = 'cookie=' . $val ;
376
- }
377
- return $cookies ;
378
- }
379
-
380
- /**
381
- * Builds the vary header.
382
- *
383
- * Currently, this only checks post passwords.
384
- *
385
- * @since 1.0.13
386
- * @access public
387
- * @global $post
388
- * @return mixed false if the user has the postpass cookie. Empty string
389
- * if the post is not password protected. Vary header otherwise.
390
- */
391
- public static function output()
392
- {
393
- if ( ! LiteSpeed_Cache_Control::is_cacheable() ) {
394
- return ;
395
- }
396
- $tp_cookies = self::_format_vary_cookies() ;
397
- global $post ;
398
- if ( ! empty($post->post_password) ) {
399
- if ( isset($_COOKIE['wp-postpass_' . COOKIEHASH]) ) {
400
- // If user has password cookie, do not cache
401
- LiteSpeed_Cache_Control::set_nocache('password protected vary') ;
402
- return ;
403
- }
404
-
405
- $tp_cookies[] = 'cookie=wp-postpass_' . COOKIEHASH ;
406
- }
407
-
408
- if ( empty($tp_cookies) ) {
409
- return ;
410
- }
411
- return self::X_HEADER . ': ' . implode(',', $tp_cookies) ;
412
- }
413
-
414
- /**
415
- * Adds vary to the list of vary cookies for the current page.
416
- *
417
- * @since 1.0.13
418
- * @access public
419
- * @param mixed $vary A string or array of vary cookies to add to the current list.
420
- */
421
- public static function add($vary)
422
- {
423
- if ( ! is_array($vary) ) {
424
- $vary = array($vary) ;
425
- }
426
-
427
- self::$_vary_cookies = array_merge(self::$_vary_cookies, $vary) ;
428
- }
429
-
430
- /**
431
- * Set the vary cookie.
432
- *
433
- * If vary cookie changed, must set non cacheable.
434
- *
435
- * @since 1.0.4
436
- * @access private
437
- * @param integer $val The value to update.
438
- * @param integer $expire Expire time.
439
- * @param boolean $path False if use wp root path as cookie path
440
- */
441
- private static function _cookie($val = false, $expire = false, $path = false)
442
- {
443
- if ( ! $val ) {
444
- $expire = 1 ;
445
- }
446
-
447
- setcookie(self::$_vary_name, $val, $expire, $path?: COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true) ;
448
- }
449
-
450
- /**
451
- * Get the current instance object.
452
- *
453
- * @since 1.1.3
454
- * @access public
455
- * @return Current class instance.
456
- */
457
- public static function get_instance()
458
- {
459
- if ( ! isset(self::$_instance) ) {
460
- self::$_instance = new self() ;
461
- }
462
-
463
- return self::$_instance ;
464
- }
465
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache.class.php DELETED
@@ -1,594 +0,0 @@
1
- <?php
2
- /**
3
- * The core plugin class.
4
- *
5
- * This is used to define internationalization, admin-specific hooks, and
6
- * public-facing site hooks.
7
- *
8
- * Also maintains the unique identifier of this plugin as well as the current
9
- * version of the plugin.
10
- *
11
- * @since 1.0.0
12
- * @package LiteSpeed_Cache
13
- * @subpackage LiteSpeed_Cache/includes
14
- * @author LiteSpeed Technologies <info@litespeedtech.com>
15
- */
16
- class LiteSpeed_Cache
17
- {
18
- private static $_instance ;
19
-
20
- const PLUGIN_NAME = 'litespeed-cache' ;
21
- const PLUGIN_VERSION = '1.3.1.1' ;
22
-
23
- const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
24
-
25
- const NONCE_NAME = 'LSCWP_NONCE' ;
26
- const ACTION_KEY = 'LSCWP_CTRL' ;
27
- const ACTION_DISMISS_WHM = 'dismiss-whm' ;
28
- const ACTION_DISMISS_EXPIRESDEFAULT = 'dismiss-ExpiresDefault' ;
29
- const ACTION_SAVE_HTACCESS = 'save-htaccess' ;
30
- const ACTION_SAVE_SETTINGS = 'save-settings' ;
31
- const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network' ;
32
- const ACTION_PURGE_ERRORS = 'PURGE_ERRORS' ;
33
- const ACTION_PURGE_PAGES = 'PURGE_PAGES' ;
34
- const ACTION_PURGE_CSSJS = 'PURGE_CSSJS' ;
35
- const ACTION_PURGE_BY = 'PURGE_BY' ;
36
- const ACTION_PURGE_FRONT = 'PURGE_FRONT' ;
37
- const ACTION_PURGE_ALL = 'PURGE_ALL' ;
38
- const ACTION_PURGE_EMPTYCACHE = 'PURGE_EMPTYCACHE' ;
39
- const ACTION_QS_PURGE = 'PURGE' ;
40
- const ACTION_QS_PURGE_SINGLE = 'PURGESINGLE' ;
41
- const ACTION_QS_SHOW_HEADERS = 'SHOWHEADERS' ;
42
- const ACTION_QS_PURGE_ALL = 'purge_all' ;
43
- const ACTION_QS_PURGE_EMPTYCACHE = 'empty_all' ;
44
- const ACTION_QS_NOCACHE = 'NOCACHE' ;
45
- const ACTION_CRAWLER_GENERATE_FILE = 'crawler-generate-file' ;
46
- const ACTION_CRAWLER_RESET_POS = 'crawler-reset-pos' ;
47
- const ACTION_CRAWLER_CRON_ENABLE = 'crawler-cron-enable' ;
48
- const ACTION_DO_CRAWL = 'do-crawl' ;
49
- const ACTION_BLACKLIST_SAVE = 'blacklist-save' ;
50
-
51
- const ACTION_FRONT_PURGE = 'front-purge' ;
52
- const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
53
-
54
- const ACTION_DB_OPTIMIZE = 'db_optimize' ;
55
-
56
- const WHM_TRANSIENT = 'lscwp_whm_install' ;
57
- const WHM_TRANSIENT_VAL = 'whm_install' ;
58
-
59
- const HEADER_DEBUG = 'X-LiteSpeed-Debug' ;
60
-
61
- protected static $_debug_show_header = false ;
62
-
63
- /**
64
- * Define the core functionality of the plugin.
65
- *
66
- * Set the plugin name and the plugin version that can be used throughout the plugin.
67
- * Load the dependencies, define the locale, and set the hooks for the admin area and
68
- * the public-facing side of the site.
69
- *
70
- * @since 1.0.0
71
- */
72
- private function __construct()
73
- {
74
- LiteSpeed_Cache_Config::get_instance() ;
75
- // Check if debug is on
76
- if ( defined( 'LITESPEED_ON' ) ) {
77
- $should_debug = intval(self::config(LiteSpeed_Cache_Config::OPID_DEBUG)) ;
78
- if ( $should_debug == LiteSpeed_Cache_Config::VAL_ON || ($should_debug == LiteSpeed_Cache_Config::VAL_ON2 && LiteSpeed_Cache_Router::is_admin_ip()) ) {
79
- LiteSpeed_Cache_Log::set_enabled() ;
80
- }
81
-
82
- // Load third party detection if lscache enabled.
83
- include_once LSWCP_DIR . 'thirdparty/lscwp-registry-3rd.php' ;
84
- }
85
-
86
- // Register plugin activate/deactivate/uninstall hooks
87
- // NOTE: this can't be moved under after_setup_theme, otherwise activation will be bypassed somehow
88
- if( is_admin() || defined( 'LITESPEED_CLI' ) ) {
89
- $plugin_file = LSWCP_DIR . 'litespeed-cache.php' ;
90
- register_activation_hook($plugin_file, array('LiteSpeed_Cache_Activation', 'register_activation' )) ;
91
- register_deactivation_hook($plugin_file, array('LiteSpeed_Cache_Activation', 'register_deactivation' )) ;
92
- register_uninstall_hook($plugin_file, 'LiteSpeed_Cache_Activation::uninstall_litespeed_cache') ;
93
- }
94
-
95
- add_action( 'after_setup_theme', array( $this, 'init' ) ) ;
96
-
97
- // Check if there is a purge request in queue
98
- if ( $purge_queue = get_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ) {
99
- @header( $purge_queue ) ;
100
- LiteSpeed_Cache_Log::debug( 'Purge Queue found&sent: ' . $purge_queue ) ;
101
- delete_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ;
102
- }
103
- }
104
-
105
- /**
106
- * The plugin initializer.
107
- *
108
- * This function checks if the cache is enabled and ready to use, then
109
- * determines what actions need to be set up based on the type of user
110
- * and page accessed. Output is buffered if the cache is enabled.
111
- *
112
- * @since 1.0.0
113
- * @access public
114
- */
115
- public function init()
116
- {
117
- if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
118
- add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
119
- }
120
-
121
- if( is_admin() ) {
122
- LiteSpeed_Cache_Admin::get_instance() ;
123
- }
124
-
125
- if ( ! defined( 'LITESPEED_ON' ) || ! defined( 'LSCACHE_ADV_CACHE' ) || ! LSCACHE_ADV_CACHE ) {
126
- return ;
127
- }
128
-
129
- ob_start( array( $this, 'send_headers_force' ) ) ;
130
- add_action( 'shutdown', array( $this, 'send_headers' ), 0 ) ;
131
- add_action( 'wp_footer', 'LiteSpeed_Cache::footer_hook' ) ;
132
-
133
- // Check minify file request in the very beginning
134
- LiteSpeed_Cache_Optimize::get_instance() ;
135
-
136
- // 1. Init vary
137
- // 2. Init cacheable status
138
- LiteSpeed_Cache_Vary::get_instance() ;
139
-
140
- // Hook cdn for attachements
141
- LiteSpeed_Cache_CDN::get_instance() ;
142
-
143
- // Load public hooks
144
- $this->load_public_actions() ;
145
-
146
- // load cron task for crawler
147
- if ( self::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) && LiteSpeed_Cache_Router::can_crawl() ) {
148
- // keep cron intval filter
149
- LiteSpeed_Cache_Task::schedule_filter() ;
150
-
151
- // cron hook
152
- add_action( LiteSpeed_Cache_Task::CRON_ACTION_HOOK, 'LiteSpeed_Cache_Crawler::crawl_data' ) ;
153
- }
154
-
155
- // Load 3rd party hooks
156
- add_action( 'wp_loaded', array( $this, 'load_thirdparty' ), 2 ) ;
157
-
158
- // load litespeed actions
159
- if ( $action = LiteSpeed_Cache_Router::get_action() ) {
160
- $this->proceed_action( $action ) ;
161
- }
162
-
163
- // Load frontend GUI
164
- LiteSpeed_Cache_GUI::get_instance() ;
165
-
166
- }
167
-
168
- /**
169
- * Run frontend actions
170
- *
171
- * @since 1.1.0
172
- * @access public
173
- */
174
- public function proceed_action( $action )
175
- {
176
- $msg = false ;
177
- // handle actions
178
- switch ( $action ) {
179
- case LiteSpeed_Cache::ACTION_QS_PURGE:
180
- LiteSpeed_Cache_Purge::set_purge_related() ;
181
- break;
182
-
183
- case self::ACTION_QS_SHOW_HEADERS:
184
- self::$_debug_show_header = true ;
185
- break;
186
-
187
- case LiteSpeed_Cache::ACTION_QS_PURGE_SINGLE:
188
- LiteSpeed_Cache_Purge::set_purge_single() ;
189
- break;
190
-
191
- case LiteSpeed_Cache::ACTION_CRAWLER_GENERATE_FILE:
192
- LiteSpeed_Cache_Crawler::get_instance()->generate_sitemap() ;
193
- LiteSpeed_Cache_Admin::redirect() ;
194
- break;
195
-
196
- case LiteSpeed_Cache::ACTION_CRAWLER_RESET_POS:
197
- LiteSpeed_Cache_Crawler::get_instance()->reset_pos() ;
198
- LiteSpeed_Cache_Admin::redirect() ;
199
- break;
200
-
201
- case LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE:
202
- LiteSpeed_Cache_Task::enable() ;
203
- break;
204
-
205
- // Handle the ajax request to proceed crawler manually by admin
206
- case LiteSpeed_Cache::ACTION_DO_CRAWL:
207
- LiteSpeed_Cache_Crawler::crawl_data( true ) ;
208
- break ;
209
-
210
- case LiteSpeed_Cache::ACTION_BLACKLIST_SAVE:
211
- LiteSpeed_Cache_Crawler::get_instance()->save_blacklist() ;
212
- $msg = __( 'Crawler blacklist is saved.', 'litespeed-cache' ) ;
213
- break ;
214
-
215
- case LiteSpeed_Cache::ACTION_PURGE_FRONT:
216
- LiteSpeed_Cache_Purge::purge_front() ;
217
- $msg = __( 'Notified LiteSpeed Web Server to purge the front page.', 'litespeed-cache' ) ;
218
- break ;
219
-
220
- case LiteSpeed_Cache::ACTION_PURGE_PAGES:
221
- LiteSpeed_Cache_Purge::purge_pages() ;
222
- $msg = __( 'Notified LiteSpeed Web Server to purge pages.', 'litespeed-cache' ) ;
223
- break ;
224
-
225
- case LiteSpeed_Cache::ACTION_PURGE_CSSJS:
226
- LiteSpeed_Cache_Purge::purge_cssjs() ;
227
- $msg = __( 'Notified LiteSpeed Web Server to purge CSS/JS entries.', 'litespeed-cache' ) ;
228
- break ;
229
-
230
- case LiteSpeed_Cache::ACTION_PURGE_ERRORS:
231
- LiteSpeed_Cache_Purge::purge_errors() ;
232
- $msg = __( 'Notified LiteSpeed Web Server to purge error pages.', 'litespeed-cache' ) ;
233
- break ;
234
-
235
- case LiteSpeed_Cache::ACTION_PURGE_ALL:
236
- case LiteSpeed_Cache::ACTION_QS_PURGE_ALL:
237
- LiteSpeed_Cache_Purge::purge_all() ;
238
- $msg = __( 'Notified LiteSpeed Web Server to purge all caches.', 'litespeed-cache' ) ;
239
- break;
240
-
241
- case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:
242
- case LiteSpeed_Cache::ACTION_QS_PURGE_EMPTYCACHE:
243
- define( 'LSWCP_EMPTYCACHE', true ) ;// clear all sites caches
244
- LiteSpeed_Cache_Purge::purge_all() ;
245
- $msg = __( 'Notified LiteSpeed Web Server to purge everything.', 'litespeed-cache' ) ;
246
- break;
247
-
248
- case LiteSpeed_Cache::ACTION_FRONT_PURGE:
249
- // redirect inside
250
- LiteSpeed_Cache_Purge::frontend_purge() ;
251
- break ;
252
-
253
- case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
254
- // redirect inside
255
- LiteSpeed_Cache_Config::frontend_save() ;
256
- break ;
257
-
258
- case LiteSpeed_Cache::ACTION_PURGE_BY:
259
- LiteSpeed_Cache_Purge::get_instance()->purge_list() ;
260
- $msg = __( 'Notified LiteSpeed Web Server to purge the list.', 'litespeed-cache' ) ;
261
- break;
262
-
263
- case LiteSpeed_Cache::ACTION_DISMISS_WHM:// Even its from ajax, we don't need to register wp ajax callback function but directly use our action
264
- LiteSpeed_Cache_Activation::dismiss_whm() ;
265
- break ;
266
-
267
- case LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT:
268
- update_option( LiteSpeed_Cache_Admin_Display::DISMISS_MSG, LiteSpeed_Cache_Admin_Display::RULECONFLICT_DISMISSED ) ;
269
- break ;
270
-
271
- case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
272
- $msg = LiteSpeed_Cache_Admin_Optimize::run_db_clean() ;
273
- break ;
274
-
275
- default:
276
- break ;
277
- }
278
- if ( $msg && ! LiteSpeed_Cache_Router::is_ajax() ) {
279
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg ) ;
280
- LiteSpeed_Cache_Admin::redirect() ;
281
- return ;
282
- }
283
- }
284
-
285
- /**
286
- * Callback used to call the detect third party action.
287
- *
288
- * The detect action is used by third party plugin integration classes to determine if they should add the rest of their hooks.
289
- *
290
- * @since 1.0.5
291
- * @access public
292
- */
293
- public function load_thirdparty()
294
- {
295
- do_action( 'litespeed_cache_api_load_thirdparty' ) ;
296
- }
297
-
298
- /**
299
- * Register all of the hooks related to the all users
300
- * of the plugin.
301
- *
302
- * @since 1.0.0
303
- * @access private
304
- */
305
- private function load_public_actions()
306
- {
307
- //register purge actions
308
- $purge_post_events = array(
309
- 'edit_post',
310
- 'save_post',
311
- 'deleted_post',
312
- 'trashed_post',
313
- 'delete_attachment',
314
- // 'clean_post_cache', // This will disable wc's not purge product when stock status not change setting
315
- ) ;
316
- foreach ( $purge_post_events as $event ) {
317
- // this will purge all related tags
318
- add_action( $event, 'LiteSpeed_Cache_Purge::purge_post', 10, 2 ) ;
319
- }
320
-
321
- // The ESI functionality is an enterprise feature.
322
- // Removing the openlitespeed check will simply break the page.
323
- if ( ! LiteSpeed_Cache_Router::is_ajax() && LiteSpeed_Cache_Router::esi_enabled() ) {
324
- LiteSpeed_Cache_ESI::get_instance() ;
325
- }
326
-
327
- add_action( 'wp_update_comment_count', 'LiteSpeed_Cache_Purge::purge_feeds' ) ;
328
-
329
- // register recent posts widget tag before theme renders it to make it work
330
- add_filter( 'widget_posts_args', 'LiteSpeed_Cache_Tag::add_widget_recent_posts' ) ;
331
-
332
- // 301 redirect hook
333
- add_filter( 'wp_redirect', 'LiteSpeed_Cache_Control::check_redirect', 10, 2 ) ;
334
- }
335
-
336
- /**
337
- * A shortcut to get the LiteSpeed_Cache_Config config value
338
- *
339
- * @since 1.0.0
340
- * @access public
341
- * @param string $opt_id An option ID if getting an option.
342
- * @return the option value
343
- */
344
- public static function config( $opt_id )
345
- {
346
- return LiteSpeed_Cache_Config::get_instance()->get_option( $opt_id ) ;
347
- }
348
-
349
- /**
350
- * Mark wp_footer called
351
- *
352
- * @since 1.3
353
- * @access public
354
- */
355
- public static function footer_hook()
356
- {
357
- if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
358
- define( 'LITESPEED_FOOTER_CALLED', true ) ;
359
- }
360
- }
361
-
362
- /**
363
- * Tigger coment info display hook
364
- *
365
- * @since 1.3
366
- * @access private
367
- */
368
- private function _check_is_html( $buffer = null )
369
- {
370
- if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
371
- return ;
372
- }
373
-
374
- if ( defined( 'DOING_AJAX' ) ) {
375
- return ;
376
- }
377
-
378
- if ( defined( 'DOING_CRON' ) ) {
379
- return ;
380
- }
381
-
382
- if ( $buffer === null ) {
383
- $buffer = ob_get_contents() ;
384
- }
385
-
386
- // double check to make sure it is a html file
387
- if ( strlen( $buffer ) > 300 ) {
388
- $buffer = substr( $buffer, 0, 300 ) ;
389
- }
390
- if ( strstr( $buffer, '<!--' ) !== false ) {
391
- $buffer = preg_replace( '|<!--.*?-->|s', '', $buffer ) ;
392
- }
393
- $buffer = trim( $buffer ) ;
394
- $is_html = stripos( $buffer, '<html' ) === 0 || stripos( $buffer, '<!DOCTYPE' ) === 0 ;
395
-
396
- if ( ! $is_html ) {
397
- LiteSpeed_Cache_Log::debug( 'Footer check failed: ' . ob_get_level() . '-' . substr( $buffer, 0, 100 ) ) ;
398
- return ;
399
- }
400
-
401
- if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
402
- define( 'LITESPEED_IS_HTML', true ) ;
403
- }
404
- }
405
-
406
- /**
407
- * For compatibility with those plugins have 'Bad' logic that forced all buffer output even it is NOT their buffer :(
408
- *
409
- * Usually this is called after send_headers() if following orignal WP process
410
- *
411
- * @since 1.1.5
412
- * @access public
413
- * @param string $buffer
414
- * @return string
415
- */
416
- public function send_headers_force( $buffer )
417
- {
418
- $this->_check_is_html( $buffer ) ;
419
-
420
- $buffer = LiteSpeed_Cache_Optimize::run( $buffer ) ;
421
-
422
- $buffer = LiteSpeed_Cache_CDN::run( $buffer ) ;
423
-
424
- $buffer .= $this->send_headers( true ) ;
425
-
426
- LiteSpeed_Cache_Log::debug( "End response\n--------------------------------------------------------------------------------\n" ) ;
427
-
428
- return $buffer ;
429
- }
430
-
431
- /**
432
- * Sends the headers out at the end of processing the request.
433
- *
434
- * This will send out all LiteSpeed Cache related response headers needed for the post.
435
- *
436
- * @since 1.0.5
437
- * @access public
438
- * @param boolean $is_forced If the header is sent following our normal finalizing logic
439
- */
440
- public function send_headers( $is_forced = false )
441
- {
442
- // Make sure header output only run once
443
- if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
444
- define( 'LITESPEED_DID_' . __FUNCTION__, true ) ;
445
- }
446
- else {
447
- return ;
448
- }
449
-
450
- $this->_check_is_html() ;
451
-
452
- // NOTE: cache ctrl output needs to be done first, as currently some varies are added in 3rd party hook `litespeed_cache_api_control`.
453
- LiteSpeed_Cache_Control::finalize() ;
454
-
455
- $vary_header = LiteSpeed_Cache_Vary::output() ;
456
-
457
- // If is not cacheable but Admin QS is `purge` or `purgesingle`, `tag` still needs to be generated
458
- $tag_header = LiteSpeed_Cache_Tag::output() ;
459
- if ( LiteSpeed_Cache_Control::is_cacheable() && ! $tag_header ) {
460
- LiteSpeed_Cache_Control::set_nocache( 'empty tag header' ) ;
461
- }
462
-
463
- // NOTE: `purge` output needs to be after `tag` output as Admin QS may need to send `tag` header
464
- $purge_header = LiteSpeed_Cache_Purge::output() ;
465
-
466
- // generate `control` header in the end in case control status is changed by other headers.
467
- $control_header = LiteSpeed_Cache_Control::output() ;
468
-
469
- // Init comment info
470
- $running_info_showing = defined( 'LITESPEED_IS_HTML' ) || defined( 'LSCACHE_IS_ESI' ) ;
471
- if ( defined( 'LSCACHE_ESI_SILENCE' ) ) {
472
- $running_info_showing = false ;
473
- LiteSpeed_Cache_Log::debug( 'ESI silence' ) ;
474
- }
475
-
476
- $comment = '' ;
477
- if ( $running_info_showing ) {
478
- $comment .= sprintf(
479
- '<!-- %1$s %2$s by LiteSpeed Cache on %3$s -->',
480
- defined( 'LSCACHE_IS_ESI' ) ? 'Block' : 'Page',
481
- LiteSpeed_Cache_Control::is_cacheable() ? 'generated' : 'uncached',
482
- date( 'Y-m-d H:i:s', time() + LITESPEED_TIME_OFFSET )
483
- ) ;
484
- }
485
-
486
- // send Control header
487
- if ( $control_header ) {
488
- @header( $control_header ) ;
489
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
490
- LiteSpeed_Cache_Log::push( $control_header ) ;
491
- if ( $running_info_showing ) {
492
- $comment .= "\n<!-- " . $control_header . " -->" ;
493
- }
494
- }
495
- }
496
- // send PURGE header
497
- if ( $purge_header ) {
498
- @header( $purge_header ) ;
499
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
500
- LiteSpeed_Cache_Log::push( $purge_header ) ;
501
- if ( $running_info_showing ) {
502
- $comment .= "\n<!-- " . $purge_header . " -->" ;
503
- }
504
- }
505
- }
506
- // send Vary header
507
- if ( $vary_header ) {
508
- @header( $vary_header ) ;
509
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
510
- LiteSpeed_Cache_Log::push( $vary_header ) ;
511
- if ( $running_info_showing ) {
512
- $comment .= "\n<!-- " . $vary_header . " -->" ;
513
- }
514
- }
515
- }
516
-
517
- // Admin QS show header action
518
- if ( self::$_debug_show_header ) {
519
- $debug_header = self::HEADER_DEBUG . ': ' ;
520
- if ( $control_header ) {
521
- $debug_header .= $control_header . '; ' ;
522
- }
523
- if ( $purge_header ) {
524
- $debug_header .= $purge_header . '; ' ;
525
- }
526
- if ( $tag_header ) {
527
- $debug_header .= $tag_header . '; ' ;
528
- }
529
- if ( $vary_header ) {
530
- $debug_header .= $vary_header . '; ' ;
531
- }
532
- @header( $debug_header ) ;
533
- LiteSpeed_Cache_Log::debug( $debug_header ) ;
534
- }
535
- else {
536
- // Control header
537
- if ( LiteSpeed_Cache_Control::is_cacheable() && $tag_header ) {
538
- @header( $tag_header ) ;
539
- if ( LiteSpeed_Cache_Log::get_enabled() ) {
540
- LiteSpeed_Cache_Log::push( $tag_header ) ;
541
- if ( $running_info_showing ) {
542
- $comment .= "\n<!-- " . $tag_header . " -->" ;
543
- }
544
- }
545
- }
546
- }
547
-
548
- if ( $is_forced ) {
549
- LiteSpeed_Cache_Log::debug( '--forced--' ) ;
550
- }
551
-
552
- if ( $comment ) {
553
- if ( $is_forced ) {
554
- return $comment ;
555
- }
556
- else {
557
- echo $comment ;
558
- }
559
- }
560
- }
561
-
562
- /**
563
- * Deprecated calls for backward compatibility to v1.1.2.2
564
- */
565
- public function purge_post( $id )
566
- {
567
- litespeed_purge_single_post( $id ) ;
568
- }
569
-
570
- /**
571
- * Deprecated calls for backward compatibility to v1.1.2.2
572
- */
573
- public function purge_all()
574
- {
575
- LiteSpeed_Cache_API::purge_all() ;
576
- }
577
-
578
- /**
579
- * Get the current instance object.
580
- *
581
- * @since 1.1.0
582
- * @access public
583
- * @return Current class instance.
584
- */
585
- public static function get_instance()
586
- {
587
- if ( ! isset(self::$_instance) ) {
588
- self::$_instance = new self() ;
589
- }
590
-
591
- return self::$_instance ;
592
- }
593
-
594
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed.autoload.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
- /**
3
- * Auto registration for LiteSpeed classes
4
- *
5
- * @since 1.1.0
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/includes
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
-
11
- if ( ! defined('WPINC') ) {
12
- die ;
13
- }
14
-
15
- if ( !function_exists('_litespeed_autoload') ) {
16
- function _litespeed_autoload($cls)
17
- {
18
- $class2fileArr = array(
19
- 'LiteSpeed' => 'lib/litespeed/litespeed.class.php',
20
- 'Litespeed_Crawler' => 'lib/litespeed/litespeed-crawler.class.php',
21
- 'Litespeed_File' => 'lib/litespeed/litespeed-file.class.php',
22
- 'Litespeed_String' => 'lib/litespeed/litespeed-string.class.php',
23
-
24
- 'LiteSpeed_Cache' => 'includes/litespeed-cache.class.php',
25
- 'LiteSpeed_Cache_Activation' => 'includes/litespeed-cache-activation.class.php',
26
- 'LiteSpeed_Cache_API' => 'includes/litespeed-cache-api.class.php',
27
- 'LiteSpeed_Cache_CDN' => 'includes/litespeed-cache-cdn.class.php',
28
- 'LiteSpeed_Cache_Config' => 'includes/litespeed-cache-config.class.php',
29
- 'LiteSpeed_Cache_Control' => 'includes/litespeed-cache-control.class.php',
30
- 'LiteSpeed_Cache_Crawler' => 'includes/litespeed-cache-crawler.class.php',
31
- 'LiteSpeed_Cache_Crawler_Sitemap' => 'includes/litespeed-cache-crawler-sitemap.class.php',
32
- 'LiteSpeed_Cache_Data' => 'inc/data.class.php',
33
- 'LiteSpeed_Cache_ESI' => 'includes/litespeed-cache-esi.class.php',
34
- 'LiteSpeed_Cache_GUI' => 'includes/litespeed-cache-gui.class.php',
35
- 'LiteSpeed_Cache_Log' => 'includes/litespeed-cache-log.class.php',
36
- 'LiteSpeed_Cache_Optimize' => 'includes/litespeed-cache-optimize.class.php',
37
- 'LiteSpeed_Cache_Purge' => 'includes/litespeed-cache-purge.class.php',
38
- 'LiteSpeed_Cache_Router' => 'includes/litespeed-cache-router.class.php',
39
- 'LiteSpeed_Cache_Tag' => 'includes/litespeed-cache-tag.class.php',
40
- 'LiteSpeed_Cache_Task' => 'includes/litespeed-cache-task.class.php',
41
- 'LiteSpeed_Cache_Vary' => 'includes/litespeed-cache-vary.class.php',
42
- 'LiteSpeed_Cache_Utility' => 'includes/litespeed-cache-utility.class.php',
43
-
44
- 'LiteSpeed_Cache_Admin' => 'admin/litespeed-cache-admin.class.php',
45
- 'LiteSpeed_Cache_Admin_Display' => 'admin/litespeed-cache-admin-display.class.php',
46
- 'LiteSpeed_Cache_Admin_Error' => 'admin/litespeed-cache-admin-error.class.php',
47
- 'LiteSpeed_Cache_Admin_Optimize' => 'admin/litespeed-cache-admin-optimize.class.php',
48
- 'LiteSpeed_Cache_Admin_Report' => 'admin/litespeed-cache-admin-report.class.php',
49
- 'LiteSpeed_Cache_Admin_Rules' => 'admin/litespeed-cache-admin-rules.class.php',
50
- 'LiteSpeed_Cache_Admin_Settings' => 'admin/litespeed-cache-admin-settings.class.php',
51
-
52
- 'LiteSpeed_Cache_Cli_Admin' => 'cli/litespeed-cache-cli-admin.class.php',
53
- 'LiteSpeed_Cache_Cli_Purge' => 'cli/litespeed-cache-cli-purge.class.php',
54
-
55
- 'LiteSpeed_Cache_Tags' => 'includes/deprecated-litespeed-cache-tags.class.php',
56
- );
57
- if( array_key_exists($cls, $class2fileArr) && file_exists(LSWCP_DIR . $class2fileArr[$cls]) ) {
58
- require_once LSWCP_DIR . $class2fileArr[$cls];
59
- }
60
- }
61
- }
62
-
63
- spl_autoload_register('_litespeed_autoload');
64
-
65
- /**
66
- * Load vendor loader
67
- *
68
- * @since 1.2.2
69
- */
70
- if ( !function_exists('litespeed_load_vendor') ) {
71
- function litespeed_load_vendor()
72
- {
73
- require_once LSWCP_DIR.'lib/vendor/autoload.php';
74
- }
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/css_async.js DELETED
@@ -1,4 +0,0 @@
1
- /*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
2
- !function(a){"use strict";var b=function(b,c,d){function e(a){return h.body?a():void setTimeout(function(){e(a)})}function f(){i.addEventListener&&i.removeEventListener("load",f),i.media=d||"all"}var g,h=a.document,i=h.createElement("link");if(c)g=c;else{var j=(h.body||h.getElementsByTagName("head")[0]).childNodes;g=j[j.length-1]}var k=h.styleSheets;i.rel="stylesheet",i.href=b,i.media="only x",e(function(){g.parentNode.insertBefore(i,c?g:g.nextSibling)});var l=function(a){for(var b=i.href,c=k.length;c--;)if(k[c].href===b)return a();setTimeout(function(){l(a)})};return i.addEventListener&&i.addEventListener("load",f),i.onloadcssdefined=l,l(f),i};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
3
- /*! loadCSS rel=preload polyfill. [c]2017 Filament Group, Inc. MIT License */
4
- !function(a){if(a.loadCSS){var b=loadCSS.relpreload={};if(b.support=function(){try{return a.document.createElement("link").relList.supports("preload")}catch(b){return!1}},b.poly=function(){for(var b=a.document.getElementsByTagName("link"),c=0;c<b.length;c++){var d=b[c];"preload"===d.rel&&"style"===d.getAttribute("as")&&(a.loadCSS(d.href,d,d.getAttribute("media")),d.rel=null)}},!b.support()){b.poly();var c=a.setInterval(b.poly,300);a.addEventListener&&a.addEventListener("load",function(){b.poly(),a.clearInterval(c)}),a.attachEvent&&a.attachEvent("onload",function(){a.clearInterval(c)})}}}(this);
 
 
 
 
js/litespeed-cache-admin.js DELETED
@@ -1,385 +0,0 @@
1
- var _litespeed_meta ;
2
- var _litespeed_shell_interval = 3 ;// seconds
3
- var _litespeed_shell_interval_range = [3, 60] ;
4
- var _litespeed_shell_handle ;
5
- var _litespeed_shell_display_handle ;
6
- var _litespeed_crawler_url ;
7
- var _litespeed_dots ;
8
-
9
- (function ($) {
10
- 'use strict' ;
11
-
12
- /**
13
- * All of the code for your public-facing JavaScript source
14
- * should reside in this file.
15
- *
16
- * Note: It has been assumed you will write jQuery code here, so the
17
- * $ function reference has been prepared for usage within the scope
18
- * of this function.
19
- *
20
- * This enables you to define handlers, for when the DOM is ready:
21
- *
22
- * $(function() {
23
- *
24
- * }) ;
25
- *
26
- * When the window is loaded:
27
- *
28
- * $( window ).load(function() {
29
- *
30
- * }) ;
31
- *
32
- * ...and/or other possibilities.
33
- *
34
- * Ideally, it is not considered best practise to attach more than a
35
- * single DOM-ready or window-load handler for a particular page.
36
- * Although scripts in the WordPress core, Plugins and Themes may be
37
- * practising this, we should strive to set a better example in our own work.
38
- */
39
-
40
- jQuery(document).ready(function () {
41
- /************** Common LiteSpeed JS **************/
42
- // Arrow transform
43
- $('.litespeed-down, .litespeed-up').click(function(event) {
44
- $(this).toggleClass('litespeed-up litespeed-down') ;
45
- }) ;
46
-
47
- // Link confirm
48
- $('[data-litespeed-cfm]').click(function(event) {
49
- if(confirm($.trim($(this).data('litespeed-cfm')).replace(/\\n/g,"\n"))) {
50
- return true ;
51
- }
52
- event.preventDefault() ;
53
- event.stopImmediatePropagation() ;
54
- return false ;
55
- }) ;
56
-
57
- /************** LSWCP JS ****************/
58
- // FAQ show and hide
59
- $('.litespeed-answer').hide() ;
60
- $('.litespeed-question').click(function(event) {
61
- $(this).next('.litespeed-answer').slideToggle('fast') ;
62
- }) ;
63
- $('[data-litespeed-expend-all]').click(function(event) {
64
- var range = $(this).data('litespeed-expend-all') ;
65
- if($(this).html() == '+'){
66
- $(this).html('-') ;
67
- $('[data-litespeed-layout="'+range+'"] .litespeed-answer').slideDown('fast') ;
68
- $('[data-litespeed-layout="'+range+'"] .litespeed-question').addClass('litespeed-up').removeClass('litespeed-down') ;
69
- }else{
70
- $(this).html('+') ;
71
- $('[data-litespeed-layout="'+range+'"] .litespeed-answer').slideUp('fast') ;
72
- $('[data-litespeed-layout="'+range+'"] .litespeed-question').addClass('litespeed-down').removeClass('litespeed-up') ;
73
- }
74
- }) ;
75
-
76
- // page tab switch functionality
77
- if($('[data-litespeed-tab]').length > 0){
78
- // display default tab
79
- var litespeed_tab_current = document.cookie.replace(/(?:(?:^|.*;\s*)litespeed_tab\s*\=\s*([^;]*).*$)|^.*$/, "$1") ;
80
- if(window.location.hash.substr(1)) {
81
- litespeed_tab_current = window.location.hash.substr(1) ;
82
- }
83
- if(!litespeed_tab_current || !$('[data-litespeed-tab="'+litespeed_tab_current+'"]').length) {
84
- litespeed_tab_current = $('[data-litespeed-tab]').first().data('litespeed-tab') ;
85
- }
86
- litespeed_display_tab(litespeed_tab_current) ;
87
- // tab switch
88
- $('[data-litespeed-tab]').click(function(event) {
89
- litespeed_display_tab($(this).data('litespeed-tab')) ;
90
- document.cookie = 'litespeed_tab='+$(this).data('litespeed-tab') ;
91
- $(this).blur() ;
92
- }) ;
93
- }
94
-
95
- // Manage page -> purge by
96
- $('[name=purgeby]').change(function(event) {
97
- $('[data-purgeby]').hide() ;
98
- $('[data-purgeby='+this.value+']').show() ;
99
- }) ;
100
-
101
- // Select All and Copy to Clipboard
102
- $("#litespeed_cache_report_copy").click(function() {
103
- $('#litespeed-report').select() ;
104
- document.execCommand('copy') ;
105
- $('#copy_select_all_span').fadeIn('slow').delay(1000).fadeOut('slow') ;
106
- }) ;
107
-
108
- // Settings->General->Enable mobile view
109
- $('#conf_mobileview_enabled_1').click(function() {
110
- if($(this).is(':checked')){
111
- if(!$('#litespeed-mobileview-rules').val()){
112
- $('#litespeed-mobileview-rules').val($('#litespeed-mobileview-rules-default').val()) ;
113
- }
114
- $('#litespeed-mobileview-rules').prop('readonly', false) ;
115
- }
116
- }) ;
117
- $('#conf_mobileview_enabled_0').click(function() {
118
- if($(this).is(':checked')){
119
- // $('#litespeed-mobileview-rules').val('') ;
120
- $('#litespeed-mobileview-rules').prop('readonly', true) ;
121
- }
122
- }) ;
123
-
124
- /*************** crawler ******************/
125
- $('#litespeed-crawl-url-btn').click(function () {
126
- if( ! $(this).data('url') ){
127
- return false ;
128
- }
129
- $('.litespeed-shell').css('display','block') ;
130
- _litespeed_dots = window.setInterval(_litespeed_loading_dots, 300) ;
131
- _litespeed_crawler_url = $(this).data('url') ;
132
- litespeed_fetch_meta() ;
133
- $(this).hide() ;
134
- }) ;
135
-
136
- $('#litespeed_manual_trigger').click(function(event) {
137
- $('#litespeed-loading-dot').before('<li>Manually Started</li>') ;
138
- _litespeed_shell_interval = _litespeed_shell_interval_range[0] ;
139
- litespeed_fetch_meta() ;
140
- }) ;
141
-
142
- $('#litespeed_crawler_cron_enable').click(function(event) {
143
- var that = this ;
144
- $.getJSON( $(that).data('url'), function(json){
145
- $(that).prop('checked', json.enable) ;
146
- } ) ;
147
- }) ;
148
-
149
- $('#litespeed_custom_sitemap').keyup(function(event) {
150
- $('[data-litespeed-selfsitemap]').toggle(!$(this).val()) ;
151
- }) ;
152
-
153
- $('[data-litespeed-selfsitemap]').toggle(!$('#litespeed_custom_sitemap').val()) ;
154
-
155
- /******************** Clear whm msg ********************/
156
- $(document).on('click', '.lscwp-whm-notice .notice-dismiss', function () {
157
- $.get(litespeed_data.ajax_url_dismiss_whm) ;
158
- });
159
- /******************** Clear rule conflict msg ********************/
160
- $(document).on('click', '.lscwp-notice-ruleconflict .notice-dismiss', function () {
161
- $.get(litespeed_data.ajax_url_dismiss_ruleconflict) ;
162
- });
163
-
164
- /** Accesskey **/
165
- $( '[litespeed-accesskey]' ).map( function() {
166
- var thiskey = $( this ).attr( 'litespeed-accesskey' ) ;
167
- $( this ).attr( 'title', 'Shortcut : ' + thiskey.toLocaleUpperCase() ) ;
168
- var that = this ;
169
- $( document ).on( 'keydown', function( e ) {
170
- if( $(":input:focus").length > 0 ) return ;
171
- if( event.metaKey ) return ;
172
- if( event.ctrlKey ) return ;
173
- if( event.altKey ) return ;
174
- if( event.shiftKey ) return ;
175
- if( litespeed_keycode( thiskey.charCodeAt( 0 ) ) ) $( that )[ 0 ].click() ;
176
- });
177
- });
178
-
179
- /** Lets copy one more submit button **/
180
- if ( $( '#litespeed_form_options' ).length > 0 ) {
181
- $( '#litespeed_form_options [type="submit"]' ).clone().addClass( 'litespeed-float-submit' ).prependTo( '#litespeed_form_options' ) ;
182
- }
183
- }) ;
184
- })(jQuery) ;
185
-
186
- function litespeed_keycode( num ) {
187
- var num = num || 13 ;
188
- var code = window.event ? event.keyCode : event.which ;
189
- if( num == code ) return true ;
190
- return false ;
191
- }
192
-
193
- function litespeed_display_tab(tab) {
194
- // setting page -> display submit button
195
- if ( jQuery('#litespeed-submit').length > 0 ){
196
- jQuery('#litespeed-submit').toggle(tab != 'compatibilities') ;
197
- }
198
- jQuery('[data-litespeed-tab]').removeClass('litespeed-tab-active') ;
199
- jQuery('[data-litespeed-tab="'+tab+'"]').addClass('litespeed-tab-active') ;
200
- jQuery('[data-litespeed-layout]').hide() ;
201
- jQuery('[data-litespeed-layout="'+tab+'"]').show() ;
202
- }
203
-
204
- function lscwpEsiEnabled(the_checkbox, esi_ids) {
205
- var rdonly = the_checkbox.checked ? false : true;
206
- var len = esi_ids.length;
207
- for (var i = 0; i < len; i++) {
208
- var node_id = 'saved_' + esi_ids[i].getAttribute('id');
209
- var node_val = esi_ids[i].getAttribute('value');
210
- var prev = document.getElementById(node_id);
211
- if (rdonly === false) {
212
- esi_ids[i].removeAttribute('disabled');
213
- if (prev) {
214
- esi_ids[i].removeChild(prev);
215
- }
216
- continue;
217
- }
218
- esi_ids[i].setAttribute('disabled', true);
219
- if (prev !== null) {
220
- if (esi_ids[i].checked) {
221
- prev.setAttribute("value", node_val);
222
- }
223
- else {
224
- esi_ids[i].removeChild(prev);
225
- }
226
- continue;
227
- }
228
- else if (esi_ids[i].checked === false) {
229
- continue;
230
- }
231
- var hid = document.createElement("INPUT");
232
- hid.setAttribute("type", "hidden");
233
- hid.setAttribute("name", esi_ids[i].getAttribute('name'));
234
- hid.setAttribute("value", node_val);
235
- hid.setAttribute("id", node_id);
236
- esi_ids[i].appendChild(hid);
237
- }
238
- }
239
-
240
- // Append params to uri
241
- function litespeed_append_param(uri, key, val) {
242
- var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i") ;
243
- var separator = uri.indexOf('?') !== -1 ? "&" : "?" ;
244
- if (uri.match(re)) {
245
- return uri.replace(re, '$1' + key + "=" + val + '$2') ;
246
- }
247
- else {
248
- return uri + separator + key + "=" + val ;
249
- }
250
- }
251
-
252
- function litespeed_pulse() {
253
- jQuery('#litespeed-shell-icon').animate({
254
- width: 27, height: 34,
255
- opacity: 1
256
- }, 700, function() {
257
- jQuery('#litespeed-shell-icon').animate({
258
- width: 23, height: 29,
259
- opacity: 0.5
260
- }, 700) ;
261
- }) ;
262
- }
263
-
264
- function litespeed_fetch_meta() {
265
- window.clearTimeout(_litespeed_shell_handle) ;
266
- jQuery('#litespeed-loading-dot').text('') ;
267
- jQuery.ajaxSetup({ cache: false }) ;
268
- jQuery.getJSON(_litespeed_crawler_url, function( meta ) {
269
- litespeed_pulse() ;
270
- var changed = false ;
271
- if ( meta && 'list_size' in meta ) {
272
- new_meta = meta.list_size + ' ' + meta.file_time + ' ' + meta.last_pos + ' ' + meta.last_count + ' ' + meta.last_start_time + ' ' + meta.is_running ;
273
- if ( new_meta != _litespeed_meta ) {
274
- _litespeed_meta = new_meta ;
275
- changed = true ;
276
- string = _litespeed_build_meta(meta);
277
- jQuery('#litespeed-loading-dot').before(string) ;
278
- // remove first log elements
279
- log_length = jQuery('.litespeed-shell-body li').length;
280
- if ( log_length > 50) {
281
- jQuery('.litespeed-shell-body li:lt(' + (log_length - 50) + ')').remove();
282
- }
283
- // scroll to end
284
- jQuery('.litespeed-shell-body').stop().animate({
285
- scrollTop: jQuery('.litespeed-shell-body')[0].scrollHeight
286
- }, 800) ;
287
- }
288
-
289
- // dynamic adjust the interval length
290
- _litespeed_adjust_interval(changed) ;
291
- }
292
- // display interval counting
293
- litespeed_display_interval_reset() ;
294
- _litespeed_shell_handle = window.setTimeout(_litespeed_dynamic_timeout, _litespeed_shell_interval*1000) ;
295
- }) ;
296
- }
297
-
298
- /**
299
- * Dynamic adjust interval
300
- */
301
- function _litespeed_adjust_interval(changed) {
302
- if ( changed ) {
303
- _litespeed_shell_interval -= Math.ceil(_litespeed_shell_interval/2) ;
304
- }
305
- else{
306
- _litespeed_shell_interval ++ ;
307
- }
308
-
309
- if(_litespeed_shell_interval < _litespeed_shell_interval_range[0]) {
310
- _litespeed_shell_interval = _litespeed_shell_interval_range[0] ;
311
- }
312
- if(_litespeed_shell_interval > _litespeed_shell_interval_range[1]) {
313
- _litespeed_shell_interval = _litespeed_shell_interval_range[1] ;
314
- }
315
- }
316
-
317
- function _litespeed_build_meta(meta) {
318
- var string = '<li>' + litespeed_date(meta.last_update_time) +
319
- '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Size: ' + meta.list_size +
320
- '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Position: ' + (meta.last_pos*1+1) +
321
- '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Threads: ' + meta.last_count +
322
- '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Status: '
323
- ;
324
- if ( meta.is_running ) {
325
- string += 'crawling, ' + meta.last_status;
326
- }
327
- else{
328
- string += meta.end_reason ? meta.end_reason : '-' ;
329
- }
330
- string += '</li>' ;
331
- return string;
332
- }
333
-
334
- function _litespeed_dynamic_timeout() {
335
- litespeed_fetch_meta() ;
336
- }
337
-
338
- function litespeed_display_interval_reset() {
339
- window.clearInterval(_litespeed_shell_display_handle) ;
340
- jQuery('.litespeed-shell-header-bar').data('num', _litespeed_shell_interval) ;
341
- _litespeed_shell_display_handle = window.setInterval(_litespeed_display_interval, 1000) ;
342
-
343
- jQuery('.litespeed-shell-header-bar').stop().animate({width: '100%'}, 500, function(){
344
- jQuery('.litespeed-shell-header-bar').css('width', '0%') ;
345
- }) ;
346
- }
347
-
348
- function _litespeed_display_interval() {
349
- var num = jQuery('.litespeed-shell-header-bar').data('num') ;
350
- jQuery('.litespeed-shell-header-bar').stop().animate({width: litespeed_get_percent(num, _litespeed_shell_interval) + '%'}, 1000) ;
351
- if(num > 0) num-- ;
352
- if(num < 0) num = 0 ;
353
- jQuery('.litespeed-shell-header-bar').data('num', num) ;
354
- }
355
-
356
- function litespeed_get_percent(num1, num2){
357
- num1 = num1 * 1;
358
- num2 = num2 * 1;
359
- num = (num2 - num1) / num2;
360
- return num * 100;
361
- }
362
-
363
- function _litespeed_loading_dots() {
364
- jQuery('#litespeed-loading-dot').append('.') ;
365
- }
366
-
367
- function litespeed_date(timestamp) {
368
- var a = new Date(timestamp * 1000) ;
369
- var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] ;
370
- var year = a.getFullYear() ;
371
- var month = months[a.getMonth()] ;
372
- var date = litespeed_add_zero(a.getDate()) ;
373
- var hour = litespeed_add_zero(a.getHours()) ;
374
- var min = litespeed_add_zero(a.getMinutes()) ;
375
- var sec = litespeed_add_zero(a.getSeconds()) ;
376
- var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
377
- return time ;
378
- }
379
-
380
- function litespeed_add_zero(i) {
381
- if (i < 10) {
382
- i = "0" + i;
383
- }
384
- return i;
385
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/litespeed-cache.pot CHANGED
@@ -1,3228 +1,2139 @@
1
- # Copyright (C) 2017 LiteSpeed Cache
2
- # This file is distributed under the same license as the LiteSpeed Cache package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: LiteSpeed Cache 1.3.1\n"
6
- "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
- "POT-Creation-Date: 2017-10-05 19:11:47+00:00\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
 
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
 
 
 
 
14
 
15
- #: admin/litespeed-cache-admin-display.class.php:140
16
- msgid "Manage"
17
- msgstr ""
18
-
19
- #: admin/litespeed-cache-admin-display.class.php:142
20
- #: admin/litespeed-cache-admin-display.class.php:225
21
- msgid "Settings"
22
- msgstr ""
23
-
24
- #: admin/litespeed-cache-admin-display.class.php:145
25
- msgid "Edit .htaccess"
26
- msgstr ""
27
-
28
- #: admin/litespeed-cache-admin-display.class.php:148
29
- msgid "Information"
30
- msgstr ""
31
-
32
- #: admin/litespeed-cache-admin-display.class.php:150
33
- msgid "Environment Report"
34
- msgstr ""
35
-
36
- #: admin/litespeed-cache-admin-display.class.php:154 admin/tpl/info.php:10
37
- #: admin/tpl/settings.php:27
38
- msgid "Crawler"
39
- msgstr ""
40
-
41
- #: admin/litespeed-cache-admin-display.class.php:158
42
- #: admin/tpl/settings_debug.php:10
43
- msgid "Debug Log"
44
- msgstr ""
45
-
46
- #: admin/litespeed-cache-admin-display.class.php:245
47
- msgid ""
48
- "It is recommended that LiteSpeed Cache be purged after updating a plugin."
49
- msgstr ""
50
-
51
- #: admin/litespeed-cache-admin-display.class.php:285
52
- msgid "LiteSpeed Cache Purge All"
53
- msgstr ""
54
-
55
- #: admin/litespeed-cache-admin-display.class.php:770
56
- msgid "ON"
57
- msgstr ""
58
-
59
- #: admin/litespeed-cache-admin-display.class.php:774
60
- msgid "OFF"
61
- msgstr ""
62
-
63
- #: admin/litespeed-cache-admin-display.class.php:807
64
- msgid "Recommended value: %s"
65
- msgstr ""
66
-
67
- #: admin/litespeed-cache-admin-error.class.php:87
68
- msgid "The installed PHP version is too old for the LiteSpeed Cache Plugin."
69
- msgstr ""
70
-
71
- #: admin/litespeed-cache-admin-error.class.php:89
72
- msgid "The LiteSpeed Cache Plugin requires at least PHP %s."
73
- msgstr ""
74
-
75
- #: admin/litespeed-cache-admin-error.class.php:91
76
- msgid ""
77
- "The currently installed version is PHP %s, which is out-dated and insecure."
78
- msgstr ""
79
-
80
- #: admin/litespeed-cache-admin-error.class.php:93
81
- #: admin/litespeed-cache-admin-error.class.php:102
82
- msgid ""
83
- "Please upgrade or go to <a href=\"%s\">active plugins</a> and deactivate the "
84
- "LiteSpeed Cache plugin to hide this message."
85
- msgstr ""
86
-
87
- #: admin/litespeed-cache-admin-error.class.php:98
88
- msgid ""
89
- "The installed WordPress version is too old for the LiteSpeed Cache Plugin."
90
- msgstr ""
91
-
92
- #: admin/litespeed-cache-admin-error.class.php:100
93
- msgid "The LiteSpeed Cache Plugin requires at least WordPress %s."
94
- msgstr ""
95
-
96
- #: admin/litespeed-cache-admin-error.class.php:107
97
- msgid "Something went wrong with the form! Please try again."
98
- msgstr ""
99
-
100
- #: admin/litespeed-cache-admin-error.class.php:110
101
- msgid "Tried to purge list with empty list."
102
- msgstr ""
103
-
104
- #: admin/litespeed-cache-admin-error.class.php:113
105
- msgid "Bad Purge By selected value."
106
- msgstr ""
107
-
108
- #: admin/litespeed-cache-admin-error.class.php:116
109
- msgid "Failed to purge by category, invalid category slug."
110
- msgstr ""
111
-
112
- #: admin/litespeed-cache-admin-error.class.php:119
113
- msgid "Failed to purge by tag, invalid tag slug."
114
- msgstr ""
115
-
116
- #: admin/litespeed-cache-admin-error.class.php:122
117
- msgid "Failed to purge by url, contained \"<\"."
118
- msgstr ""
119
-
120
- #: admin/litespeed-cache-admin-error.class.php:126
121
- msgid "Failed to purge by Post ID, given ID is not numeric: %s"
122
- msgstr ""
123
-
124
- #: admin/litespeed-cache-admin-error.class.php:129
125
- msgid ""
126
- "Failed to purge by Post ID, given ID does not exist or is not published: %s"
127
- msgstr ""
128
-
129
- #: admin/litespeed-cache-admin-error.class.php:133
130
- msgid "Failed to purge by url, invalid input: %s."
131
- msgstr ""
132
-
133
- #: admin/litespeed-cache-admin-error.class.php:136
134
- msgid "Failed to purge by category, does not exist: %s"
135
- msgstr ""
136
-
137
- #: admin/litespeed-cache-admin-error.class.php:139
138
- msgid "Failed to purge by tag, does not exist: %s"
139
- msgstr ""
140
-
141
- #: admin/litespeed-cache-admin-error.class.php:143
142
- msgid "Invalid data in Admin IPs."
143
- msgstr ""
144
-
145
- #: admin/litespeed-cache-admin-error.class.php:146
146
- msgid "Invalid data in Test IPs."
147
- msgstr ""
148
-
149
- #: admin/litespeed-cache-admin-error.class.php:149
150
- msgid "Invalid Site IP: %s"
151
- msgstr ""
152
-
153
- #: admin/litespeed-cache-admin-error.class.php:152
154
- msgid "Can not fetch Custom Sitemap: %s"
155
- msgstr ""
156
-
157
- #: admin/litespeed-cache-admin-error.class.php:155
158
- msgid "Can not parse custom sitemap xml file: %s."
159
- msgstr ""
160
-
161
- #: admin/litespeed-cache-admin-error.class.php:156
162
- msgid ""
163
- "Please make sure the file is xml format and the %s extension is installed on "
164
- "the server."
165
- msgstr ""
166
-
167
- #: admin/litespeed-cache-admin-error.class.php:161
168
- msgid "%1$s must be an integer between %2$d and %3$d"
169
- msgstr ""
170
-
171
- #: admin/litespeed-cache-admin-error.class.php:166
172
- msgid "Removed category \"%s\" from list, ID does not exist."
173
- msgstr ""
174
-
175
- #: admin/litespeed-cache-admin-error.class.php:171
176
- msgid "Removed tag \"%s\" from list, ID does not exist."
177
- msgstr ""
178
-
179
- #: admin/litespeed-cache-admin-error.class.php:175
180
- msgid "Invalid login cookie. Invalid characters found: %s"
181
- msgstr ""
182
-
183
- #: admin/litespeed-cache-admin-error.class.php:179
184
- msgid "Invalid Rewrite List."
185
- msgstr ""
186
-
187
- #: admin/litespeed-cache-admin-error.class.php:180
188
- msgid "Empty or invalid rule."
189
- msgstr ""
190
-
191
- #: admin/litespeed-cache-admin-error.class.php:181
192
- msgid "Rule: %1$s, list: %2$s"
193
- msgstr ""
194
-
195
- #: admin/litespeed-cache-admin-error.class.php:185
196
- msgid "Tried to parse for existing login cookie."
197
- msgstr ""
198
-
199
- #: admin/litespeed-cache-admin-error.class.php:186
200
- msgid "%s file not valid. Please verify contents."
201
- msgstr ""
202
-
203
- #: admin/litespeed-cache-admin-error.class.php:190
204
- msgid "Could not find %s."
205
- msgstr ""
206
-
207
- #: admin/litespeed-cache-admin-error.class.php:194
208
- msgid "This site is a subdirectory install."
209
- msgstr ""
210
-
211
- #: admin/litespeed-cache-admin-error.class.php:195
212
- msgid "Login cookies do not match."
213
- msgstr ""
214
-
215
- #: admin/litespeed-cache-admin-error.class.php:196
216
- msgid ""
217
- "Please remove both and set the login cookie in LiteSpeed Cache advanced "
218
- "settings."
219
- msgstr ""
220
-
221
- #: admin/litespeed-cache-admin-error.class.php:200
222
- msgid ""
223
- "Notice: This plugin requires a LiteSpeed Server with the LSCache Module "
224
- "enabled."
225
- msgstr ""
226
-
227
- #: admin/litespeed-cache-admin-error.class.php:201
228
  msgid ""
229
- "If you are unable to change your server stack, please contact your hosting "
230
- "provider to request the required changes."
231
- msgstr ""
232
-
233
- #: admin/litespeed-cache-admin-error.class.php:202
234
- msgid "This plugin will NOT work properly."
235
- msgstr ""
236
-
237
- #: admin/litespeed-cache-admin-error.class.php:205
238
- #: admin/litespeed-cache-admin-error.class.php:243
239
- msgid "LiteSpeed Cache was unable to write to the wp-config.php file."
240
- msgstr ""
241
-
242
- #: admin/litespeed-cache-admin-error.class.php:206
243
- #: admin/litespeed-cache-admin-error.class.php:244
244
- msgid "Please add the following to the wp-config.php file: %s"
245
- msgstr ""
246
-
247
- #: admin/litespeed-cache-admin-error.class.php:210
248
- msgid "Failed to back up file, aborted changes."
249
- msgstr ""
250
-
251
- #: admin/litespeed-cache-admin-error.class.php:213
252
- msgid "Failed to put contents into %s"
253
- msgstr ""
254
-
255
- #: admin/litespeed-cache-admin-error.class.php:216
256
- msgid "Failed to get %s file contents."
257
- msgstr ""
258
-
259
- #: admin/litespeed-cache-admin-error.class.php:219
260
- msgid "%s file not readable or not writable."
261
- msgstr ""
262
-
263
- #: admin/litespeed-cache-admin-error.class.php:222
264
- msgid "%s file not readable."
265
- msgstr ""
266
-
267
- #: admin/litespeed-cache-admin-error.class.php:225
268
- msgid "%s file not writable."
269
- msgstr ""
270
-
271
- #: admin/litespeed-cache-admin-error.class.php:228
272
- msgid "Failed to overwrite %s."
273
- msgstr ""
274
-
275
- #: admin/litespeed-cache-admin-error.class.php:232
276
- msgid "The %1$s file not writable for %2$s"
277
- msgstr ""
278
-
279
- #: admin/litespeed-cache-admin-error.class.php:236
280
- msgid "%s file did not find a place to insert define."
281
- msgstr ""
282
-
283
- #: admin/litespeed-cache-admin-optimize.class.php:139
284
- msgid "Clean all successfully."
285
- msgstr ""
286
-
287
- #: admin/litespeed-cache-admin-optimize.class.php:146
288
- msgid "Clean post revisions successfully."
289
- msgstr ""
290
-
291
- #: admin/litespeed-cache-admin-optimize.class.php:150
292
- msgid "Clean auto drafts successfully."
293
- msgstr ""
294
-
295
- #: admin/litespeed-cache-admin-optimize.class.php:154
296
- msgid "Clean trashed posts and pages successfully."
297
- msgstr ""
298
-
299
- #: admin/litespeed-cache-admin-optimize.class.php:158
300
- msgid "Clean spam comments successfully."
301
- msgstr ""
302
-
303
- #: admin/litespeed-cache-admin-optimize.class.php:162
304
- msgid "Clean trashed comments successfully."
305
- msgstr ""
306
-
307
- #: admin/litespeed-cache-admin-optimize.class.php:166
308
- msgid "Clean trackbacks and pingbacks successfully."
309
- msgstr ""
310
-
311
- #: admin/litespeed-cache-admin-optimize.class.php:170
312
- msgid "Clean expired transients successfully."
313
- msgstr ""
314
-
315
- #: admin/litespeed-cache-admin-optimize.class.php:174
316
- msgid "Clean all transients successfully."
317
- msgstr ""
318
-
319
- #: admin/litespeed-cache-admin-optimize.class.php:184
320
- msgid "Optimized all tables."
321
  msgstr ""
322
 
323
- #: admin/litespeed-cache-admin-rules.class.php:629
 
324
  msgid ""
325
- "<p>Please add/replace the following codes into the beginning of %1$s:</p> "
326
- "%2$s"
327
- msgstr ""
328
-
329
- #: admin/litespeed-cache-admin-rules.class.php:827
330
- msgid "File Saved."
331
- msgstr ""
332
-
333
- #: admin/litespeed-cache-admin-settings.class.php:50
334
- msgid "'Use primary site settings' set by Network Administrator."
335
- msgstr ""
336
-
337
- #: admin/litespeed-cache-admin-settings.class.php:217
338
- msgid "Site options saved."
339
- msgstr ""
340
-
341
- #: admin/litespeed-cache-admin-settings.class.php:256
342
- msgid "Default Public Cache"
343
- msgstr ""
344
-
345
- #: admin/litespeed-cache-admin-settings.class.php:257
346
- msgid "Default Private Cache"
347
  msgstr ""
348
 
349
- #: admin/litespeed-cache-admin-settings.class.php:258
350
- msgid "Default Front Page"
351
- msgstr ""
352
-
353
- #: admin/litespeed-cache-admin-settings.class.php:259
354
- msgid "Feed"
355
- msgstr ""
356
-
357
- #: admin/litespeed-cache-admin-settings.class.php:260
358
- msgid "404"
359
- msgstr ""
360
-
361
- #: admin/litespeed-cache-admin-settings.class.php:261
362
- msgid "403"
363
- msgstr ""
364
-
365
- #: admin/litespeed-cache-admin-settings.class.php:262
366
- msgid "500"
367
- msgstr ""
368
-
369
- #: admin/litespeed-cache-admin-settings.class.php:543
370
- #: admin/tpl/settings_debug.php:75
371
- msgid "Log File Size Limit"
372
- msgstr ""
373
-
374
- #: admin/litespeed-cache-admin-settings.class.php:609
375
- #: admin/tpl/settings_crawler.php:10
376
- msgid "Delay"
377
- msgstr ""
378
-
379
- #: admin/litespeed-cache-admin-settings.class.php:610
380
- #: admin/tpl/settings_crawler.php:22
381
- msgid "Run Duration"
382
- msgstr ""
383
-
384
- #: admin/litespeed-cache-admin-settings.class.php:611
385
- msgid "Cron Interval"
386
- msgstr ""
387
-
388
- #: admin/litespeed-cache-admin-settings.class.php:612
389
- msgid "Whole Interval"
390
- msgstr ""
391
-
392
- #: admin/litespeed-cache-admin-settings.class.php:613
393
- #: admin/tpl/settings_crawler.php:58
394
- msgid "Threads"
395
- msgstr ""
396
-
397
- #: admin/litespeed-cache-admin.class.php:203
398
- msgid ""
399
- "For this scenario only, the network admin may uncheck \"Check Advanced Cache"
400
- "\" in LiteSpeed Cache settings."
401
  msgstr ""
402
 
403
- #: admin/litespeed-cache-admin.class.php:205
404
- msgid ""
405
- "For this scenario only, please uncheck \"Check Advanced Cache\" in LiteSpeed "
406
- "Cache settings."
407
- msgstr ""
408
-
409
- #: admin/litespeed-cache-admin.class.php:207
410
- msgid ""
411
- "Please disable/deactivate any other Full Page Cache solutions that are "
412
- "currently being used."
413
- msgstr ""
414
-
415
- #: admin/litespeed-cache-admin.class.php:208
416
- msgid ""
417
- "LiteSpeed Cache does work with other cache solutions, but only their non-"
418
- "page caching offerings—such as minifying css/js files."
419
- msgstr ""
420
-
421
- #: admin/tpl/admin_footer.php:5
422
- msgid ""
423
- "Rate <strong>LiteSpeed Cache</strong> with %s on WordPress.org if you like "
424
- "us!"
425
- msgstr ""
426
-
427
- #: admin/tpl/admin_footer.php:8
428
- msgid ""
429
- "If there are any questions that are not answered in the <a %s>FAQs</a>, do "
430
- "not hesitate to ask them on the <a %s>support forum</a>."
431
- msgstr ""
432
-
433
- #: admin/tpl/crawler.php:14 admin/tpl/crawler.php:80
434
- msgid "LiteSpeed Cache Crawler"
435
- msgstr ""
436
-
437
- #: admin/tpl/crawler.php:22
438
- msgid "Crawler File"
439
- msgstr ""
440
-
441
- #: admin/tpl/crawler.php:24
442
- msgid "Generate Crawler File"
443
- msgstr ""
444
-
445
- #: admin/tpl/crawler.php:29
446
- msgid "Generated at %s"
447
- msgstr ""
448
-
449
- #: admin/tpl/crawler.php:33
450
- msgid ""
451
- "On click, this will create a crawler sitemap file in plugin directory %s."
452
- msgstr ""
453
-
454
- #: admin/tpl/crawler.php:43
455
- msgid "%d hours"
456
- msgstr ""
457
-
458
- #: admin/tpl/crawler.php:46
459
- msgid "%d hour"
460
- msgstr ""
461
-
462
- #: admin/tpl/crawler.php:53
463
- msgid "%d minutes"
464
- msgstr ""
465
-
466
- #: admin/tpl/crawler.php:56
467
- msgid "%d minute"
468
- msgstr ""
469
-
470
- #: admin/tpl/crawler.php:60
471
- msgid "Crawler Cron"
472
- msgstr ""
473
-
474
- #: admin/tpl/crawler.php:63 admin/tpl/settings.php:114
475
- msgid "WARNING"
476
- msgstr ""
477
-
478
- #: admin/tpl/crawler.php:64
479
- msgid ""
480
- "The crawler feature is not enabled on the LiteSpeed server. Please consult "
481
- "your server admin."
482
- msgstr ""
483
-
484
- #: admin/tpl/crawler.php:65
485
- msgid ""
486
- "See <a %s>Introduction for Enabling the Crawler</a> for detailed infomation."
487
- msgstr ""
488
-
489
- #: admin/tpl/crawler.php:70
490
- msgid "Cron Name"
491
- msgstr ""
492
-
493
- #: admin/tpl/crawler.php:71
494
- msgid "Run Frequency"
495
- msgstr ""
496
-
497
- #: admin/tpl/crawler.php:72
498
- msgid "Last Status"
499
- msgstr ""
500
-
501
- #: admin/tpl/crawler.php:73
502
- msgid "Activation"
503
- msgstr ""
504
-
505
- #: admin/tpl/crawler.php:74
506
- msgid "Actions"
507
- msgstr ""
508
-
509
- #: admin/tpl/crawler.php:88 admin/tpl/crawler.php:93
510
- msgid "The current sitemap crawl started at %s"
511
- msgstr ""
512
-
513
- #: admin/tpl/crawler.php:96
514
- msgid "The next complete sitemap crawl will start at %s"
515
- msgstr ""
516
-
517
- #: admin/tpl/crawler.php:110
518
- msgid "The last complete run cost %s seconds"
519
- msgstr ""
520
-
521
- #: admin/tpl/crawler.php:120
522
- msgid "Is running"
523
- msgstr ""
524
-
525
- #: admin/tpl/crawler.php:136 admin/tpl/settings_general.php:30
526
- msgid "Enable"
527
- msgstr ""
528
-
529
- #: admin/tpl/crawler.php:136 admin/tpl/esi_widget_edit.php:58
530
- #: admin/tpl/settings_general.php:24
531
- msgid "Disable"
532
- msgstr ""
533
-
534
- #: admin/tpl/crawler.php:143
535
- msgid "Reset position"
536
- msgstr ""
537
-
538
- #: admin/tpl/crawler.php:146
539
- msgid "Manually run"
540
- msgstr ""
541
-
542
- #: admin/tpl/crawler.php:150
543
- msgid "<b>Last interval:</b> %s"
544
- msgstr ""
545
-
546
- #: admin/tpl/crawler.php:156
547
- msgid "<b>Ended reason:</b> %s"
548
- msgstr ""
549
-
550
- #: admin/tpl/crawler.php:162
551
- msgid "<b>Last crawled:</b> %s item(s)"
552
- msgstr ""
553
-
554
- #: admin/tpl/crawler.php:170
555
- msgid "Run frequency is set by the Interval Between Runs setting."
556
- msgstr ""
557
-
558
- #: admin/tpl/crawler.php:171
559
- msgid "Only one crawler can run concurrently."
560
- msgstr ""
561
-
562
- #: admin/tpl/crawler.php:172
563
- msgid ""
564
- "If both the cron and manual run start at a similar time, the first one to "
565
- "start will run."
566
- msgstr ""
567
-
568
- #: admin/tpl/crawler.php:173
569
- msgid ""
570
- "Please follow <a %s>Hooking WP-Cron Into the System Task Scheduler</a> to "
571
- "create the system cron task."
572
- msgstr ""
573
-
574
- #: admin/tpl/crawler.php:178
575
- msgid "Watch Crawler Status"
576
- msgstr ""
577
-
578
- #: admin/tpl/crawler.php:185
579
- msgid "Show crawler status"
580
- msgstr ""
581
-
582
- #: admin/tpl/crawler.php:203
583
- msgid "No crawler meta file generated yet"
584
- msgstr ""
585
-
586
- #: admin/tpl/crawler.php:208
587
- msgid "Sitemap Generation Blacklist"
588
- msgstr ""
589
-
590
- #: admin/tpl/crawler.php:217 admin/tpl/edit_htaccess.php:68
591
- msgid "Save"
592
- msgstr ""
593
-
594
- #: admin/tpl/crawler.php:221
595
- msgid "Current blacklist has %s item(s)."
596
- msgstr ""
597
-
598
- #: admin/tpl/crawler.php:222
599
- msgid ""
600
- "All Urls which returned no-cache tags will be added here, after the initial "
601
- "crawling."
602
- msgstr ""
603
-
604
- #: admin/tpl/debug_log.php:9
605
- msgid "LiteSpeed Cache Debug Log Viewer"
606
- msgstr ""
607
-
608
- #: admin/tpl/edit_htaccess.php:31
609
- msgid "LiteSpeed Cache Edit .htaccess"
610
- msgstr ""
611
-
612
- #: admin/tpl/edit_htaccess.php:40
613
- msgid "WARNING: This page is meant for advanced users."
614
- msgstr ""
615
-
616
- #: admin/tpl/edit_htaccess.php:42
617
- msgid "Any changes made to the .htaccess file may break the site."
618
- msgstr ""
619
-
620
- #: admin/tpl/edit_htaccess.php:43
621
- msgid "Please consult the host/server admin before making any changes."
622
- msgstr ""
623
-
624
- #: admin/tpl/edit_htaccess.php:48
625
- msgid "File editing is disabled in configuration."
626
- msgstr ""
627
-
628
- #: admin/tpl/edit_htaccess.php:58
629
- msgid "Current %s Contents"
630
- msgstr ""
631
-
632
- #: admin/tpl/edit_htaccess.php:60
633
- msgid "DO NOT EDIT ANYTHING WITHIN %s"
634
- msgstr ""
635
-
636
- #: admin/tpl/edit_htaccess.php:62
637
- msgid ""
638
- "These are added by the LS Cache plugin and may cause problems if they are "
639
- "changed."
640
- msgstr ""
641
-
642
- #: admin/tpl/esi_widget_edit.php:30 admin/tpl/settings_esi.php:35
643
- msgid "Enable ESI"
644
- msgstr ""
645
-
646
- #: admin/tpl/esi_widget_edit.php:40
647
- msgid "Public"
648
- msgstr ""
649
-
650
- #: admin/tpl/esi_widget_edit.php:49
651
- msgid "Private"
652
- msgstr ""
653
-
654
- #: admin/tpl/esi_widget_edit.php:69
655
- msgid "Widget Cache TTL:"
656
- msgstr ""
657
-
658
- #: admin/tpl/esi_widget_edit.php:72 admin/tpl/settings_crawler.php:25
659
- #: admin/tpl/settings_crawler.php:37 admin/tpl/settings_crawler.php:49
660
- #: admin/tpl/settings_general.php:59 admin/tpl/settings_general.php:71
661
- #: admin/tpl/settings_general.php:83 admin/tpl/settings_general.php:95
662
- #: admin/tpl/settings_general.php:108 admin/tpl/settings_general.php:121
663
- #: admin/tpl/settings_general.php:134 admin/tpl/settings_optimize.php:100
664
- msgid "seconds"
665
- msgstr ""
666
-
667
- #: admin/tpl/esi_widget_edit.php:75
668
- msgid "Recommended value: 28800 seconds (8 hours)."
669
- msgstr ""
670
-
671
- #: admin/tpl/esi_widget_edit.php:76
672
- msgid "A TTL of 0 indicates do not cache."
673
- msgstr ""
674
-
675
- #: admin/tpl/help_tabs.php:7
676
- msgid "Overview"
677
- msgstr ""
678
-
679
- #: admin/tpl/help_tabs.php:9
680
- msgid "LiteSpeed Cache is a page cache built into LiteSpeed Web Server."
681
- msgstr ""
682
-
683
- #: admin/tpl/help_tabs.php:10
684
- msgid ""
685
- "This plugin communicates with LiteSpeed Web Server to let it know which "
686
- "pages are cacheable and when to purge them."
687
- msgstr ""
688
-
689
- #: admin/tpl/help_tabs.php:11
690
- msgid ""
691
- "A LiteSpeed server (OLS, LSWS, WebADC) and its LSCache module must be "
692
- "installed and enabled."
693
- msgstr ""
694
-
695
- #: admin/tpl/help_tabs.php:22
696
- msgid "For more information:"
697
- msgstr ""
698
-
699
- #: admin/tpl/help_tabs.php:24
700
- msgid "Support Forum"
701
- msgstr ""
702
-
703
- #: admin/tpl/info.php:5
704
- msgid "FAQs"
705
- msgstr ""
706
-
707
- #: admin/tpl/info.php:6
708
- msgid "Configuration"
709
- msgstr ""
710
-
711
- #: admin/tpl/info.php:7
712
- msgid "Plugin Compatibilities"
713
- msgstr ""
714
-
715
- #: admin/tpl/info.php:8
716
- msgid "Common Rewrite Rules"
717
- msgstr ""
718
-
719
- #: admin/tpl/info.php:9
720
- msgid "Admin IP Commands"
721
- msgstr ""
722
-
723
- #: admin/tpl/info.php:16
724
- msgid "LiteSpeed Cache Information"
725
- msgstr ""
726
-
727
- #: admin/tpl/info_admin_ip.php:5
728
- msgid "This is used to display a page without caching it."
729
- msgstr ""
730
-
731
- #: admin/tpl/info_admin_ip.php:6
732
- msgid ""
733
- "An example use case is to compare a cached version of a page with an "
734
- "uncached version."
735
- msgstr ""
736
-
737
- #: admin/tpl/info_admin_ip.php:9
738
- msgid "This is used to purge most cache tags associated with the page."
739
- msgstr ""
740
-
741
- #: admin/tpl/info_admin_ip.php:10
742
- msgid "The lone exception is the blog ID tag."
743
- msgstr ""
744
-
745
- #: admin/tpl/info_admin_ip.php:11
746
- msgid ""
747
- "Note that this means that pages with the same cache tag will be purged as "
748
- "well."
749
- msgstr ""
750
-
751
- #: admin/tpl/info_admin_ip.php:14
752
- msgid "This is used to show all the cache headers associated with a page."
753
- msgstr ""
754
-
755
- #: admin/tpl/info_admin_ip.php:15
756
- msgid "This may be useful for debugging purposes."
757
- msgstr ""
758
-
759
- #: admin/tpl/info_admin_ip.php:19
760
- msgid "Admin IP Query String Actions"
761
- msgstr ""
762
-
763
- #: admin/tpl/info_admin_ip.php:21
764
- msgid ""
765
- "The following commands are available to the admin and do not require log-in, "
766
- "providing quick access to actions on the various pages."
767
- msgstr ""
768
-
769
- #: admin/tpl/info_admin_ip.php:23
770
- msgid "Action List:"
771
- msgstr ""
772
-
773
- #: admin/tpl/info_admin_ip.php:28
774
- msgid "This is used to purge the first cache tag associated with the page."
775
- msgstr ""
776
-
777
- #: admin/tpl/info_admin_ip.php:32
778
- msgid ""
779
- "To trigger the action for a page, access the page with the query string %s"
780
- msgstr ""
781
-
782
- #: admin/tpl/info_common_rewrite.php:8 admin/tpl/settings_excludes.php:57
783
- #: admin/tpl/settings_excludes.php:95
784
- #: admin/tpl/settings_inc.cache_browser.php:12
785
- #: admin/tpl/settings_inc.cache_favicon.php:14
786
- #: admin/tpl/settings_inc.cache_mobile.php:18
787
- #: admin/tpl/settings_inc.cache_resources.php:15
788
- #: admin/tpl/settings_inc.exclude_cookies.php:22
789
- #: admin/tpl/settings_inc.exclude_useragent.php:21
790
- msgid "NOTE:"
791
- msgstr ""
792
-
793
- #: admin/tpl/info_common_rewrite.php:10
794
- msgid "The following configuration can only be changed by the network admin."
795
- msgstr ""
796
-
797
- #: admin/tpl/info_common_rewrite.php:11
798
- msgid "Please contact the network admin to make any changes."
799
- msgstr ""
800
-
801
- #: admin/tpl/info_common_rewrite.php:14 admin/tpl/settings_advanced.php:6
802
- #: admin/tpl/settings_optimize.php:10
803
- msgid "NOTICE:"
804
- msgstr ""
805
-
806
- #: admin/tpl/info_common_rewrite.php:17
807
- msgid ""
808
- "The following rewrite rules can be configured in the LiteSpeed Cache "
809
- "settings page."
810
- msgstr ""
811
-
812
- #: admin/tpl/info_common_rewrite.php:18
813
- msgid "Please make any needed changes on that page."
814
- msgstr ""
815
-
816
- #: admin/tpl/info_common_rewrite.php:19
817
- msgid "It will automatically generate the correct rules in the htaccess file."
818
- msgstr ""
819
-
820
- #: admin/tpl/info_common_rewrite.php:24
821
- msgid "LiteSpeed Cache Common Rewrite Rules"
822
- msgstr ""
823
-
824
- #: admin/tpl/info_common_rewrite.php:31
825
- msgid "Mobile Views:"
826
- msgstr ""
827
-
828
- #: admin/tpl/info_common_rewrite.php:34
829
- msgid ""
830
- "Some sites have adaptive views, meaning the page sent will adapt to the "
831
- "browser type (desktop vs mobile)."
832
- msgstr ""
833
-
834
- #: admin/tpl/info_common_rewrite.php:35
835
- msgid ""
836
- "This rewrite rule is used for sites that load a different page for each type."
837
- msgstr ""
838
-
839
- #: admin/tpl/info_common_rewrite.php:38
840
- msgid ""
841
- "This configuration can be added on the settings page in the General tab."
842
- msgstr ""
843
-
844
- #: admin/tpl/info_common_rewrite.php:44
845
- msgid "Do Not Cache Cookies:"
846
- msgstr ""
847
-
848
- #: admin/tpl/info_common_rewrite.php:46
849
- msgid ""
850
- "Another common rewrite rule is to notify the cache not to cache when it sees "
851
- "a specified cookie name."
852
- msgstr ""
853
-
854
- #: admin/tpl/info_common_rewrite.php:47 admin/tpl/info_common_rewrite.php:55
855
- msgid ""
856
- "This configuration can be added on the settings page in the Do Not Cache tab."
857
- msgstr ""
858
-
859
- #: admin/tpl/info_common_rewrite.php:52
860
- msgid "Do Not Cache User Agent:"
861
- msgstr ""
862
-
863
- #: admin/tpl/info_common_rewrite.php:54
864
- msgid ""
865
- "A not so commonly used rewrite rule is to notify the cache not to cache when "
866
- "it sees a specified User Agent."
867
- msgstr ""
868
-
869
- #: admin/tpl/info_compatibility.php:27
870
- msgid "LiteSpeed Cache Plugin Compatibility"
871
- msgstr ""
872
-
873
- #: admin/tpl/info_compatibility.php:29
874
- msgid "Link Here"
875
- msgstr ""
876
-
877
- #: admin/tpl/info_compatibility.php:31
878
- msgid ""
879
- "Please add a comment listing the plugins that you are using and how they are "
880
- "functioning on the support thread."
881
- msgstr ""
882
-
883
- #: admin/tpl/info_compatibility.php:32
884
- msgid "With your help, we can provide the best WordPress caching solution."
885
- msgstr ""
886
-
887
- #: admin/tpl/info_compatibility.php:35
888
- msgid ""
889
- "This is a list of plugins that are confirmed to be compatible with LiteSpeed "
890
- "Cache Plugin:"
891
- msgstr ""
892
-
893
- #: admin/tpl/info_compatibility.php:44
894
- msgid "This is a list of known UNSUPPORTED plugins:"
895
- msgstr ""
896
-
897
- #: admin/tpl/info_config.php:4
898
- msgid "LiteSpeed Cache Configuration"
899
- msgstr ""
900
-
901
- #: admin/tpl/info_config.php:7
902
- msgid "Instructions for LiteSpeed Web Server Enterprise"
903
- msgstr ""
904
-
905
- #: admin/tpl/info_config.php:9
906
- msgid "Make sure that the server license has the LSCache module enabled."
907
- msgstr ""
908
-
909
- #: admin/tpl/info_config.php:10
910
- msgid ""
911
- "A <a %s>2-CPU trial license with LSCache module</a> is available for free "
912
- "for %d days."
913
- msgstr ""
914
-
915
- #: admin/tpl/info_config.php:14
916
- msgid "The server must be configured to have caching enabled."
917
- msgstr ""
918
-
919
- #: admin/tpl/info_config.php:15
920
- msgid "If you are the server admin, <a %s>click here.</a>"
921
- msgstr ""
922
-
923
- #: admin/tpl/info_config.php:17
924
- msgid ""
925
- "Otherwise request that the server admin configure the cache root for the "
926
- "server."
927
- msgstr ""
928
-
929
- #: admin/tpl/info_config.php:20
930
- msgid ""
931
- "In the .htaccess file for the WordPress installation, add the following:"
932
- msgstr ""
933
-
934
- #: admin/tpl/info_config.php:27
935
- msgid "Instructions for OpenLiteSpeed"
936
- msgstr ""
937
-
938
- #: admin/tpl/info_config.php:28
939
- msgid "This integration utilizes OLS's cache module."
940
- msgstr ""
941
-
942
- #: admin/tpl/info_config.php:30
943
- msgid ""
944
- "If it is a fresh OLS installation, the easiest way to integrate is to use <a "
945
- "%s>ols1clk.</a>"
946
- msgstr ""
947
-
948
- #: admin/tpl/info_config.php:32
949
- msgid "If using an existing WordPress installation, use the %s parameter."
950
- msgstr ""
951
-
952
- #: admin/tpl/info_config.php:33
953
- msgid ""
954
- "Else if OLS and WordPress are already installed, please follow the "
955
- "instructions <a %s>here.</a>"
956
- msgstr ""
957
-
958
- #: admin/tpl/info_config.php:38
959
- msgid "How to test the plugin"
960
- msgstr ""
961
-
962
- #: admin/tpl/info_config.php:39
963
- msgid ""
964
- "The LiteSpeed Cache Plugin utilizes LiteSpeed specific response headers."
965
- msgstr ""
966
-
967
- #: admin/tpl/info_config.php:41
968
- msgid ""
969
- "Visiting a page for the first time should result in a %s or %s response "
970
- "header for the page."
971
- msgstr ""
972
-
973
- #: admin/tpl/info_config.php:46
974
- msgid ""
975
- "Subsequent requests should have the %s response header until the page is "
976
- "updated, expired, or purged."
977
- msgstr ""
978
-
979
- #: admin/tpl/info_config.php:49
980
- msgid "Please visit <a %s>this page</a> for more information."
981
- msgstr ""
982
-
983
- #: admin/tpl/info_config.php:53
984
- msgid "Cache tag prefix setting"
985
- msgstr ""
986
-
987
- #: admin/tpl/info_config.php:56
988
- msgid ""
989
- "The value of this wordpress cache tag prefix is %1$s. If you want to change "
990
- "the value to avoid conflicts with multiple sites, please add %2$s to %3$s."
991
- msgstr ""
992
-
993
- #: admin/tpl/info_crawler.php:7
994
- msgid "Crawler Introduction"
995
- msgstr ""
996
-
997
- #: admin/tpl/info_crawler.php:11
998
- msgid "How Does the Crawler Work?"
999
- msgstr ""
1000
-
1001
- #: admin/tpl/info_crawler.php:13
1002
- msgid ""
1003
- "Using a sitemap as a guide, LSCache’s crawler, travels its way throughout "
1004
- "the backend, refreshing pages that have expired in the cache. The purpose is "
1005
- "to keep the cache as fresh as possible while minimizing visitor exposure to "
1006
- "uncached content."
1007
- msgstr ""
1008
-
1009
- #: admin/tpl/info_crawler.php:15
1010
- msgid ""
1011
- "The sitemap can be generated by the crawler, or you can provide your own "
1012
- "custom map."
1013
- msgstr ""
1014
-
1015
- #: admin/tpl/info_crawler.php:17
1016
- msgid ""
1017
- "To learn more about each of the crawler settings, see <a %s>our wiki - "
1018
- "Crawler Settings</a>."
1019
- msgstr ""
1020
-
1021
- #: admin/tpl/info_crawler.php:21
1022
- msgid "Should I Enable the Crawler?"
1023
- msgstr ""
1024
-
1025
- #: admin/tpl/info_crawler.php:23
1026
- msgid "Not every site needs a crawler."
1027
- msgstr ""
1028
-
1029
- #: admin/tpl/info_crawler.php:25
1030
- msgid ""
1031
- "In WordPress, the first visitor to an uncached page waits for the page to "
1032
- "be dynamically-generated and served, and the page is then cached for "
1033
- "subsequent visitors."
1034
- msgstr ""
1035
-
1036
- #: admin/tpl/info_crawler.php:27
1037
- msgid ""
1038
- "The LSCache crawler makes the first visitor’s experience better by "
1039
- "essentially becoming the first visitor. The crawler caches the page, and the "
1040
- "visitor who would have been first is spared the wait. As such, the crawler "
1041
- "realistically only benefits the first out of the many users who visit that "
1042
- "page before it expires. If you have a small user base, then crawling impacts "
1043
- "a greater percentage of your visitors than it would on a site that draws a "
1044
- "large crowd."
1045
- msgstr ""
1046
-
1047
- #: admin/tpl/info_crawler.php:29
1048
- msgid ""
1049
- "You should weigh this benefit against your server’s resources. If resources "
1050
- "are plentiful, then the crawler is a nice thing to have."
1051
- msgstr ""
1052
-
1053
- #: admin/tpl/info_crawler.php:31
1054
- msgid ""
1055
- "If your site is busy, you’ll find that commonly-visited pages are quickly re-"
1056
- "cached by new visitors, without the aid of a crawler. An extra crawler task "
1057
- "would compete for server resources while delivering minimal benefits."
1058
- msgstr ""
1059
-
1060
- #: admin/tpl/info_crawler.php:33
1061
- msgid ""
1062
- "The decision to use a crawler depends on the busy-ness of the site and the "
1063
- "availability of server resources. Ultimately, it is the hosting provider who "
1064
- "can best make this call."
1065
- msgstr ""
1066
-
1067
- #: admin/tpl/info_crawler.php:38
1068
- msgid "Enabling the Crawler"
1069
- msgstr ""
1070
-
1071
- #: admin/tpl/info_crawler.php:40
1072
- msgid ""
1073
- "Due to the potential of the crawler to consume considerable resources, we "
1074
- "have put the on/off switch in the hands of the server administrators. The "
1075
- "crawler is disabled by default and can only be enabled by an admin."
1076
- msgstr ""
1077
-
1078
- #: admin/tpl/info_crawler.php:42
1079
- msgid ""
1080
- "Instructions for enabling the crawler can be found in <a %s>our wiki - "
1081
- "Enabling the Crawler</a>. If you do not have access to server configuration "
1082
- "files or virtual host include files, you will need to ask your web host for "
1083
- "assistance."
1084
- msgstr ""
1085
-
1086
- #: admin/tpl/info_crawler.php:47
1087
- msgid "Testing the Crawler"
1088
- msgstr ""
1089
-
1090
- #: admin/tpl/info_crawler.php:49
1091
- msgid ""
1092
- "To determine whether the crawler is working as expected, you can test it "
1093
- "with a single URL."
1094
- msgstr ""
1095
-
1096
- #: admin/tpl/info_crawler.php:53
1097
- msgid "Pick a URL from your sitemap and purge it:"
1098
- msgstr ""
1099
-
1100
- #: admin/tpl/info_crawler.php:54
1101
- msgid ""
1102
- "Navigate to <b>LiteSpeed Cache > Manage > Purge By… > URL</b> and enter the "
1103
- "full URL in the text box."
1104
- msgstr ""
1105
-
1106
- #: admin/tpl/info_crawler.php:57
1107
- msgid "Manually run the crawler:"
1108
- msgstr ""
1109
-
1110
- #: admin/tpl/info_crawler.php:58
1111
- msgid ""
1112
- "Navigate to <b>LiteSpeed Cache > Crawler</b>, make sure <b>Activation</b> is "
1113
- "set to Enable, and press the <b>Manually run</b> button. Wait for it to "
1114
- "finish."
1115
- msgstr ""
1116
-
1117
- #: admin/tpl/info_crawler.php:61
1118
- msgid "See if the purged URL was cached during the crawl:"
1119
- msgstr ""
1120
-
1121
- #: admin/tpl/info_crawler.php:62
1122
- msgid ""
1123
- "Turn on your browser’s Developer Tool/Inspector. Visit the URL that should "
1124
- "have been crawled. Select the <b>Network</b> tab in the inspector, select "
1125
- "the page request (the URL we just visited - it should be the first entry in "
1126
- "the list), and select the <b>Header</b> tab. If the URL was crawled "
1127
- "correctly, you will see the response header X-LiteSpeed-Cache: hit."
1128
- msgstr ""
1129
-
1130
- #: admin/tpl/info_crawler.php:67
1131
- msgid ""
1132
- "If you don’t see X-LiteSpeed-Cache: hit, and you can’t figure out why the "
1133
- "crawler didn’t cache the purged URL, you can visit <a %s>our support forum</"
1134
- "a> for help."
1135
- msgstr ""
1136
-
1137
- #: admin/tpl/info_faqs.php:5
1138
- msgid "LiteSpeed Cache FAQs"
1139
- msgstr ""
1140
-
1141
- #: admin/tpl/info_faqs.php:9
1142
- msgid "Is the LiteSpeed Cache Plugin for WordPress free?"
1143
- msgstr ""
1144
-
1145
- #: admin/tpl/info_faqs.php:12
1146
- msgid "Yes, the plugin itself will remain free and open source."
1147
- msgstr ""
1148
-
1149
- #: admin/tpl/info_faqs.php:13
1150
- msgid "That said, a LiteSpeed server is required (see question 2)"
1151
- msgstr ""
1152
-
1153
- #: admin/tpl/info_faqs.php:17
1154
- msgid "What server software is required for this plugin?"
1155
- msgstr ""
1156
-
1157
- #: admin/tpl/info_faqs.php:19
1158
- msgid "A LiteSpeed server is required in order to use this plugin."
1159
- msgstr ""
1160
-
1161
- #: admin/tpl/info_faqs.php:25
1162
- msgid "Any single server or cluster including a LiteSpeed server will work."
1163
- msgstr ""
1164
-
1165
- #: admin/tpl/info_faqs.php:28
1166
- msgid "Does this plugin work in a clustered environment?"
1167
- msgstr ""
1168
-
1169
- #: admin/tpl/info_faqs.php:31
1170
- msgid "The cache entries are stored at the litespeed server level."
1171
- msgstr ""
1172
-
1173
- #: admin/tpl/info_faqs.php:32
1174
- msgid ""
1175
- "The simplest solution is to use LiteSpeed WebADC, as the cache entries will "
1176
- "be cached at that level."
1177
- msgstr ""
1178
-
1179
- #: admin/tpl/info_faqs.php:35
1180
- msgid ""
1181
- "If using another load balancer, the cache entries will only be stored at the "
1182
- "backend nodes, not at the load balancer."
1183
- msgstr ""
1184
-
1185
- #: admin/tpl/info_faqs.php:36
1186
- msgid ""
1187
- "The purges will also not be synchronized across the nodes, so this is not "
1188
- "recommended."
1189
  msgstr ""
1190
 
1191
- #: admin/tpl/info_faqs.php:39
1192
- msgid "If a customized solution is required, please contact %s at %s"
1193
  msgstr ""
1194
 
1195
- #: admin/tpl/info_faqs.php:42
1196
  msgid ""
1197
- "NOTICE: The rewrite rules created by this plugin must be copied to the WebADC"
 
1198
  msgstr ""
1199
 
1200
- #: admin/tpl/info_faqs.php:45
1201
- msgid "Where are the cache entries stored?"
1202
  msgstr ""
1203
 
1204
- #: admin/tpl/info_faqs.php:47
1205
- msgid ""
1206
- "The actual cached pages are stored and managed by LiteSpeed Servers. Nothing "
1207
- "is stored on the PHP side."
1208
  msgstr ""
1209
 
1210
- #: admin/tpl/info_faqs.php:50
1211
- msgid "Is WooCommerce supported?"
1212
  msgstr ""
1213
 
1214
- #: admin/tpl/info_faqs.php:53
1215
- msgid "In short, yes."
1216
  msgstr ""
1217
 
1218
- #: admin/tpl/info_faqs.php:54
1219
  msgid ""
1220
- "However, for some woocommerce themes, the cart may not be updated correctly."
 
1221
  msgstr ""
1222
 
1223
- #: admin/tpl/info_faqs.php:56
1224
- msgid "To test the cart:"
1225
  msgstr ""
1226
 
1227
- #: admin/tpl/info_faqs.php:58
1228
- msgid ""
1229
- "On a non-logged-in browser, visit and cache a page, then visit and cache a "
1230
- "product page."
1231
  msgstr ""
1232
 
1233
- #: admin/tpl/info_faqs.php:59
1234
- msgid ""
1235
- "The first page should be accessible from the product page (e.g. the shop)."
1236
  msgstr ""
1237
 
1238
- #: admin/tpl/info_faqs.php:60
1239
- msgid "Once both pages are confirmed cached, add the product to the cart."
1240
  msgstr ""
1241
 
1242
- #: admin/tpl/info_faqs.php:61
1243
- msgid "After adding to the cart, visit the first page."
1244
  msgstr ""
1245
 
1246
- #: admin/tpl/info_faqs.php:62
1247
- msgid "The page should still be cached, and the cart should be up to date."
 
 
 
 
1248
  msgstr ""
1249
 
1250
- #: admin/tpl/info_faqs.php:63
1251
  msgid ""
1252
- "If that is not the case, please add woocommerce_items_in_cart to the do not "
1253
- "cache cookie list."
1254
  msgstr ""
1255
 
1256
- #: admin/tpl/info_faqs.php:66
1257
  msgid ""
1258
- "Some themes like Storefront and Shop Isle are built such that the cart works "
1259
- "without the rule."
1260
  msgstr ""
1261
 
1262
- #: admin/tpl/info_faqs.php:67
 
1263
  msgid ""
1264
- "However, other themes like the E-Commerce theme, do not, so please verify "
1265
- "the theme used."
1266
  msgstr ""
1267
 
1268
- #: admin/tpl/info_faqs.php:71
1269
- msgid "Are my images optimized?"
1270
  msgstr ""
1271
 
1272
- #: admin/tpl/info_faqs.php:74
1273
- msgid "The cache plugin does not do anything with the images themselves."
1274
  msgstr ""
1275
 
1276
- #: admin/tpl/info_faqs.php:75
1277
- msgid ""
1278
- "We recommend you trying an image optimization plugin like %s to optimize "
1279
- "your images."
1280
  msgstr ""
1281
 
1282
- #: admin/tpl/info_faqs.php:77
1283
- msgid "It can reduce your site's images up to 90%."
 
1284
  msgstr ""
1285
 
1286
- #: admin/tpl/info_faqs.php:81
1287
- msgid "How do I get WP-PostViews to display an updating view count?"
1288
  msgstr ""
1289
 
1290
- #: admin/tpl/info_faqs.php:84
1291
- msgid "Use %1$s to replace %2$s"
1292
  msgstr ""
1293
 
1294
- #: admin/tpl/info_faqs.php:88
1295
- msgid ""
1296
- "NOTE: The id can be changed, but the div id and the ajax function must match."
1297
  msgstr ""
1298
 
1299
- #: admin/tpl/info_faqs.php:91
1300
- msgid "Replace the ajax query in %1$s with %2$s"
1301
  msgstr ""
1302
 
1303
- #: admin/tpl/info_faqs.php:106
1304
- msgid "Purge the cache to use the updated pages."
1305
  msgstr ""
1306
 
1307
- #: admin/tpl/manage.php:7 admin/tpl/manage_purge.php:75
1308
- #: admin/tpl/network_settings.php:7 admin/tpl/settings.php:9
1309
- msgid "Purge"
1310
  msgstr ""
1311
 
1312
- #: admin/tpl/manage.php:8
1313
- msgid "DB Optimizer"
1314
  msgstr ""
1315
 
1316
- #: admin/tpl/manage.php:17
1317
- msgid "LiteSpeed Cache Network Management"
1318
  msgstr ""
1319
 
1320
- #: admin/tpl/manage.php:20
1321
- msgid "LiteSpeed Cache Management"
1322
  msgstr ""
1323
 
1324
- #: admin/tpl/manage.php:42
1325
- msgid ""
1326
- "WARNING: LiteSpeed cache is disabled. The functionalities here can not work."
1327
  msgstr ""
1328
 
1329
- #: admin/tpl/manage_db.php:6
1330
- msgid "Clean All"
1331
  msgstr ""
1332
 
1333
- #: admin/tpl/manage_db.php:10
1334
- msgid "Post Revisions"
1335
  msgstr ""
1336
 
1337
- #: admin/tpl/manage_db.php:11
1338
- msgid "Clean all post revisions"
1339
  msgstr ""
1340
 
1341
- #: admin/tpl/manage_db.php:14
1342
- msgid "Auto Drafts"
1343
  msgstr ""
1344
 
1345
- #: admin/tpl/manage_db.php:15
1346
- msgid "Clean all auto saved drafts"
1347
  msgstr ""
1348
 
1349
- #: admin/tpl/manage_db.php:18
1350
- msgid "Trashed Posts"
1351
  msgstr ""
1352
 
1353
- #: admin/tpl/manage_db.php:19
1354
- msgid "Clean all trashed posts and pages"
1355
  msgstr ""
1356
 
1357
- #: admin/tpl/manage_db.php:22
1358
- msgid "Spam Comments"
1359
  msgstr ""
1360
 
1361
- #: admin/tpl/manage_db.php:23
1362
- msgid "Clean all spam comments"
1363
  msgstr ""
1364
 
1365
- #: admin/tpl/manage_db.php:26
1366
- msgid "Trashed Comments"
1367
  msgstr ""
1368
 
1369
- #: admin/tpl/manage_db.php:27
1370
- msgid "Clean all trashed comments"
1371
  msgstr ""
1372
 
1373
- #: admin/tpl/manage_db.php:30
1374
- msgid "Trackbacks/Pingbacks"
1375
  msgstr ""
1376
 
1377
- #: admin/tpl/manage_db.php:31
1378
- msgid "Clean all trackbacks and pingbacks"
1379
  msgstr ""
1380
 
1381
- #: admin/tpl/manage_db.php:34
1382
- msgid "Expired Transients"
1383
  msgstr ""
1384
 
1385
- #: admin/tpl/manage_db.php:35
1386
- msgid "Clean expired transient options"
1387
  msgstr ""
1388
 
1389
- #: admin/tpl/manage_db.php:38
1390
- msgid "All Transients"
 
1391
  msgstr ""
1392
 
1393
- #: admin/tpl/manage_db.php:39
1394
- msgid "Clean all transient options"
1395
  msgstr ""
1396
 
1397
- #: admin/tpl/manage_db.php:42
1398
- msgid "Optimize Tables"
 
 
1399
  msgstr ""
1400
 
1401
- #: admin/tpl/manage_db.php:43
1402
- msgid "Optimize all tables in your database"
 
1403
  msgstr ""
1404
 
1405
- #: admin/tpl/manage_db.php:62
1406
- msgid "Database Optimizer"
 
1407
  msgstr ""
1408
 
1409
- #: admin/tpl/manage_purge.php:7
1410
- msgid "Purge Front Page"
 
 
1411
  msgstr ""
1412
 
1413
- #: admin/tpl/manage_purge.php:8
1414
- msgid "This will Purge Front Page only"
 
1415
  msgstr ""
1416
 
1417
- #: admin/tpl/manage_purge.php:13
1418
- msgid "Purge Pages"
1419
  msgstr ""
1420
 
1421
- #: admin/tpl/manage_purge.php:14
1422
- msgid "This will Purge Pages only"
 
1423
  msgstr ""
1424
 
1425
- #: admin/tpl/manage_purge.php:19
1426
- msgid "Purge CSS/JS Cache"
1427
  msgstr ""
1428
 
1429
- #: admin/tpl/manage_purge.php:20
1430
- msgid "This will purge all minified/combined CSS/JS entries only"
1431
  msgstr ""
1432
 
1433
- #: admin/tpl/manage_purge.php:25
1434
- msgid "Purge 403 Error"
1435
  msgstr ""
1436
 
1437
- #: admin/tpl/manage_purge.php:26
1438
- msgid "Purge error pages, including 403 pages"
1439
  msgstr ""
1440
 
1441
- #: admin/tpl/manage_purge.php:32
1442
- msgid "Purge 404 Error"
1443
  msgstr ""
1444
 
1445
- #: admin/tpl/manage_purge.php:33
1446
- msgid "Purge error pages, including 404 pages"
 
 
1447
  msgstr ""
1448
 
1449
- #: admin/tpl/manage_purge.php:39
1450
- msgid "Purge 500 Error"
1451
  msgstr ""
1452
 
1453
- #: admin/tpl/manage_purge.php:40
1454
- msgid "Purge error pages, including 500 pages"
 
 
1455
  msgstr ""
1456
 
1457
- #: admin/tpl/manage_purge.php:46
1458
- msgid "Purge All"
 
 
1459
  msgstr ""
1460
 
1461
- #: admin/tpl/manage_purge.php:47
1462
- msgid "Purge the cache entries created by this plugin"
 
1463
  msgstr ""
1464
 
1465
- #: admin/tpl/manage_purge.php:52
1466
- msgid "This will purge everything for all blogs."
1467
  msgstr ""
1468
 
1469
- #: admin/tpl/manage_purge.php:53 admin/tpl/manage_purge.php:55
1470
- msgid "Are you sure you want to purge all?"
1471
  msgstr ""
1472
 
1473
- #: admin/tpl/manage_purge.php:61
1474
- msgid "Empty Entire Cache"
1475
  msgstr ""
1476
 
1477
- #: admin/tpl/manage_purge.php:62
1478
  msgid ""
1479
- "Clears all cache entries related to this site, <i>including other web "
1480
- "applications</i>."
1481
  msgstr ""
1482
 
1483
- #: admin/tpl/manage_purge.php:63
1484
- msgid "This action should only be used if things are cached incorrectly."
1485
  msgstr ""
1486
 
1487
- #: admin/tpl/manage_purge.php:67
1488
- msgid "This will clear EVERYTHING inside the cache."
1489
  msgstr ""
1490
 
1491
- #: admin/tpl/manage_purge.php:68
1492
- msgid "This may cause heavy load on the server."
1493
  msgstr ""
1494
 
1495
- #: admin/tpl/manage_purge.php:69
1496
- msgid "If only the WordPress site should be purged, use purge all."
1497
  msgstr ""
1498
 
1499
- #: admin/tpl/manage_purge.php:102
1500
- msgid "Purge By..."
1501
  msgstr ""
1502
 
1503
- #: admin/tpl/manage_purge.php:104
1504
- msgid "Select below for \"Purge by\" options."
 
1505
  msgstr ""
1506
 
1507
- #: admin/tpl/manage_purge.php:105
1508
- msgid "Please enter one per line."
1509
  msgstr ""
1510
 
1511
- #: admin/tpl/manage_purge.php:132
1512
- msgid "Category"
1513
  msgstr ""
1514
 
1515
- #: admin/tpl/manage_purge.php:138
1516
- msgid "Post ID"
1517
  msgstr ""
1518
 
1519
- #: admin/tpl/manage_purge.php:144
1520
- msgid "Tag"
1521
  msgstr ""
1522
 
1523
- #: admin/tpl/manage_purge.php:150
1524
- msgid "URL"
1525
  msgstr ""
1526
 
1527
- #: admin/tpl/manage_purge.php:156
1528
- msgid ""
1529
- "Purge pages by category name - e.g. %2$s should be used for the URL %1$s."
1530
  msgstr ""
1531
 
1532
- #: admin/tpl/manage_purge.php:161
1533
- msgid "Purge pages by post ID."
 
1534
  msgstr ""
1535
 
1536
- #: admin/tpl/manage_purge.php:165
1537
- msgid "Purge pages by tag name - e.g. %2$s should be used for the URL %1$s."
 
 
1538
  msgstr ""
1539
 
1540
- #: admin/tpl/manage_purge.php:170
1541
- msgid "Purge pages by relative or full URL."
1542
  msgstr ""
1543
 
1544
- #: admin/tpl/manage_purge.php:171
1545
- msgid "e.g. Use %s or %s."
 
 
 
1546
  msgstr ""
1547
 
1548
- #: admin/tpl/manage_purge.php:184
1549
- msgid "Purge List"
1550
  msgstr ""
1551
 
1552
- #: admin/tpl/network_settings.php:5 admin/tpl/settings.php:7
1553
- #: admin/tpl/settings_general.php:5
1554
- msgid "General"
 
 
1555
  msgstr ""
1556
 
1557
- #: admin/tpl/network_settings.php:6 admin/tpl/settings.php:8
1558
- msgid "Cache"
 
 
1559
  msgstr ""
1560
 
1561
- #: admin/tpl/network_settings.php:8 admin/tpl/settings.php:10
1562
- msgid "Excludes"
1563
  msgstr ""
1564
 
1565
- #: admin/tpl/network_settings.php:9 admin/tpl/settings.php:18
1566
- #: admin/tpl/settings_debug.php:65
1567
- msgid "Advanced"
 
 
1568
  msgstr ""
1569
 
1570
- #: admin/tpl/network_settings.php:19
1571
- msgid "LiteSpeed Cache Network Settings"
 
1572
  msgstr ""
1573
 
1574
- #: admin/tpl/network_settings_cache.php:4
1575
- msgid "Cache Control Network Settings"
 
 
 
1576
  msgstr ""
1577
 
1578
- #: admin/tpl/network_settings_cache.php:7
 
1579
  msgid ""
1580
- "Separate Mobile Views should be enabled if any of the network enabled themes "
1581
- "require a different view for mobile devices."
1582
  msgstr ""
1583
 
1584
- #: admin/tpl/network_settings_cache.php:8
1585
- msgid "Responsive themes can handle this part automatically."
 
 
 
1586
  msgstr ""
1587
 
1588
- #: admin/tpl/network_settings_excludes.php:5
1589
- msgid "Network Do Not Cache Rules"
1590
  msgstr ""
1591
 
1592
- #: admin/tpl/network_settings_general.php:5
1593
- msgid "General Network Configuration"
1594
  msgstr ""
1595
 
1596
- #: admin/tpl/network_settings_general.php:7
1597
- msgid "These configuration are only available network wide."
1598
  msgstr ""
1599
 
1600
- #: admin/tpl/network_settings_general.php:11
1601
- msgid "Network Enable Cache"
1602
  msgstr ""
1603
 
1604
- #: admin/tpl/network_settings_general.php:15
1605
- msgid ""
1606
- "Enabling LiteSpeed Cache for WordPress here enables the cache for the "
1607
- "network."
1608
  msgstr ""
1609
 
1610
- #: admin/tpl/network_settings_general.php:16
1611
- msgid ""
1612
- "It is <b>STRONGLY</b> recommend that the compatibility with other plugins on "
1613
- "a single/few sites is tested first."
1614
  msgstr ""
1615
 
1616
- #: admin/tpl/network_settings_general.php:17
1617
- msgid ""
1618
- "This is to ensure compatibility prior to enabling the cache for all sites."
1619
  msgstr ""
1620
 
1621
- #: admin/tpl/network_settings_general.php:23
1622
- msgid "Use Primary Site Configuration"
 
1623
  msgstr ""
1624
 
1625
- #: admin/tpl/network_settings_general.php:27
1626
- msgid ""
1627
- "Check this option to use the primary site's configuration for all subsites."
1628
  msgstr ""
1629
 
1630
- #: admin/tpl/network_settings_general.php:28
1631
- msgid "This will disable the settings page on all subsites."
1632
  msgstr ""
1633
 
1634
- #: admin/tpl/network_settings_purge.php:4
1635
- msgid "Purge Network Settings"
 
1636
  msgstr ""
1637
 
1638
- #: admin/tpl/report.php:10
1639
- msgid "LiteSpeed Cache Report"
 
 
 
1640
  msgstr ""
1641
 
1642
- #: admin/tpl/report.php:19
1643
  msgid ""
1644
  "The environment report contains detailed information about the WordPress "
1645
  "configuration."
1646
  msgstr ""
1647
 
1648
- #: admin/tpl/report.php:20
1649
  msgid ""
1650
  "If you run into any issues, please include the contents of this text area in "
1651
  "your support message."
1652
  msgstr ""
1653
 
1654
- #: admin/tpl/report.php:21
1655
  msgid ""
1656
  "To easily grab the content, click the <b>Select All and Copy to Clipboard</"
1657
  "b> button, to select and copy to clipboard."
1658
  msgstr ""
1659
 
1660
- #: admin/tpl/report.php:23
 
1661
  msgid "Alternatively, this information is also saved in %s."
1662
  msgstr ""
1663
 
1664
- #: admin/tpl/report.php:28
1665
  msgid "The text area below contains the following content:"
1666
  msgstr ""
1667
 
1668
- #: admin/tpl/report.php:32
1669
  msgid ""
1670
  "Server Variables, Plugin Options, WordPress information (version, locale, "
1671
  "active plugins, etc.), and .htaccess file content."
1672
  msgstr ""
1673
 
1674
- #: admin/tpl/report.php:37
1675
  msgid "Select All and Copy to Clipboard"
1676
  msgstr ""
1677
 
1678
- #: admin/tpl/report.php:40
1679
  msgid "Environment Report copied to Clipboard!"
1680
  msgstr ""
1681
 
1682
- #: admin/tpl/settings.php:11
1683
- msgid "Optimize"
1684
- msgstr ""
1685
-
1686
- #: admin/tpl/settings.php:12
1687
- msgid "CDN"
1688
- msgstr ""
1689
-
1690
- #: admin/tpl/settings.php:15
1691
- msgid "ESI"
1692
- msgstr ""
1693
-
1694
- #: admin/tpl/settings.php:21
1695
- msgid "Debug"
1696
- msgstr ""
1697
-
1698
- #: admin/tpl/settings.php:24
1699
- msgid "Compatibilities"
1700
- msgstr ""
1701
-
1702
- #: admin/tpl/settings.php:64
1703
- msgid "WARNING: Third party tab input invalid."
1704
- msgstr ""
1705
-
1706
- #: admin/tpl/settings.php:71
1707
- msgid "WARNING: Third party config slug contains invalid characters."
1708
- msgstr ""
1709
-
1710
- #: admin/tpl/settings.php:86
1711
- msgid "LiteSpeed Cache Settings"
1712
- msgstr ""
1713
-
1714
- #: admin/tpl/settings.php:116
1715
- msgid "The network admin selected use primary site configs for all subsites."
1716
- msgstr ""
1717
-
1718
- #: admin/tpl/settings.php:117
1719
- msgid ""
1720
- "The following options are selected, but are not editable in this settings "
1721
- "page."
1722
- msgstr ""
1723
-
1724
- #: admin/tpl/settings.php:139 admin/tpl/settings.php:142
1725
- msgid "Save Changes"
1726
- msgstr ""
1727
-
1728
- #: admin/tpl/settings_advanced.php:8
1729
- msgid "These settings are meant for ADVANCED USERS ONLY."
1730
- msgstr ""
1731
-
1732
- #: admin/tpl/settings_advanced.php:9
1733
- msgid "Please take great care when changing any of these settings."
1734
- msgstr ""
1735
-
1736
- #: admin/tpl/settings_advanced.php:10
1737
- msgid "If there are any questions, do not hesitate to submit a support thread."
1738
- msgstr ""
1739
-
1740
- #: admin/tpl/settings_advanced.php:14
1741
- msgid "Check Advanced Cache"
1742
- msgstr ""
1743
-
1744
- #: admin/tpl/settings_advanced.php:17
1745
- msgid "Include advanced-cache.php"
1746
- msgstr ""
1747
-
1748
- #: admin/tpl/settings_advanced.php:20
1749
- msgid ""
1750
- "The advanced-cache.php file is used by many caching plugins to signal that a "
1751
- "cache is active."
1752
- msgstr ""
1753
-
1754
- #: admin/tpl/settings_advanced.php:21
1755
- msgid ""
1756
- "When this option is checked and this file is detected as belonging to "
1757
- "another plugin, LiteSpeed Cache will not cache."
1758
  msgstr ""
1759
 
1760
- #: admin/tpl/settings_advanced.php:24
1761
- msgid ""
1762
- "Uncheck this option only if the other plugin is used for non-caching "
1763
- "purposes, such as minifying css/js files."
1764
  msgstr ""
1765
 
1766
- #: admin/tpl/settings_advanced.php:27
1767
- msgid "Login Cookie"
1768
  msgstr ""
1769
 
1770
- #: admin/tpl/settings_advanced.php:30
1771
- msgid "SYNTAX: alphanumeric and \"_\"."
1772
  msgstr ""
1773
 
1774
- #: admin/tpl/settings_advanced.php:31
1775
- msgid "No spaces and case sensitive."
1776
  msgstr ""
1777
 
1778
- #: admin/tpl/settings_advanced.php:32
1779
- msgid "MUST BE UNIQUE FROM OTHER WEB APPLICATIONS."
1780
  msgstr ""
1781
 
1782
- #: admin/tpl/settings_advanced.php:35
1783
- msgid "The default login cookie is %s."
1784
  msgstr ""
1785
 
1786
- #: admin/tpl/settings_advanced.php:36
1787
- msgid ""
1788
- "The server will determine if the user is logged in based on the existance of "
1789
- "this cookie."
1790
  msgstr ""
1791
 
1792
- #: admin/tpl/settings_advanced.php:37
1793
  msgid ""
1794
- "This setting is useful for those that have multiple web applications for the "
1795
- "same domain."
1796
  msgstr ""
1797
 
1798
- #: admin/tpl/settings_advanced.php:38
1799
  msgid ""
1800
- "If every web application uses the same cookie, the server may confuse "
1801
- "whether a user is logged in or not."
1802
  msgstr ""
1803
 
1804
- #: admin/tpl/settings_advanced.php:39
1805
- msgid "The cookie set here will be used for this WordPress installation."
1806
  msgstr ""
1807
 
1808
- #: admin/tpl/settings_advanced.php:42
1809
- msgid "Example use case:"
1810
  msgstr ""
1811
 
1812
- #: admin/tpl/settings_advanced.php:44
1813
- msgid "There is a WordPress installed for %s."
1814
  msgstr ""
1815
 
1816
- #: admin/tpl/settings_advanced.php:46
1817
- msgid "Then another WordPress is installed (NOT MULTISITE) at %s"
 
 
 
1818
  msgstr ""
1819
 
1820
- #: admin/tpl/settings_advanced.php:47
1821
- msgid ""
1822
- "The cache needs to distinguish who is logged into which WordPress site in "
1823
- "order to cache correctly."
1824
  msgstr ""
1825
 
1826
- #: admin/tpl/settings_advanced.php:53
1827
- msgid "Error: invalid login cookie. Please check the %s file"
 
1828
  msgstr ""
1829
 
1830
- #: admin/tpl/settings_advanced.php:62
1831
- msgid "Error getting current rules from %s: %s"
1832
  msgstr ""
1833
 
1834
- #: admin/tpl/settings_advanced.php:70
1835
- msgid ""
1836
- "WARNING: The .htaccess login cookie and Database login cookie do not match."
1837
  msgstr ""
1838
 
1839
- #: admin/tpl/settings_cache.php:4
1840
- msgid "Cache Control Settings"
 
 
 
 
 
1841
  msgstr ""
1842
 
1843
- #: admin/tpl/settings_cache.php:8
1844
- msgid "Cache Logged-in Users"
1845
  msgstr ""
1846
 
1847
- #: admin/tpl/settings_cache.php:12
1848
- msgid "Privately cache frontend pages for logged-in users. (LSWS %s required)"
 
1849
  msgstr ""
1850
 
1851
- #: admin/tpl/settings_cache.php:18
1852
- msgid "Cache Commenters"
1853
  msgstr ""
1854
 
1855
- #: admin/tpl/settings_cache.php:22
1856
  msgid ""
1857
- "Privately cache commenters that have pending comments. Disabling this option "
1858
- "will serve non-cacheable pages to commenters. (LSWS %s required)"
1859
  msgstr ""
1860
 
1861
- #: admin/tpl/settings_cache.php:28
1862
- msgid "Cache REST API"
1863
  msgstr ""
1864
 
1865
- #: admin/tpl/settings_cache.php:32
1866
- msgid "Cache requests made by WordPress REST API calls."
1867
  msgstr ""
1868
 
1869
- #: admin/tpl/settings_cache.php:38
1870
- msgid "Cache Login Page"
1871
  msgstr ""
1872
 
1873
- #: admin/tpl/settings_cache.php:42
1874
- msgid "Disabling this option may negatively affect performance."
1875
  msgstr ""
1876
 
1877
- #: admin/tpl/settings_cache.php:56
1878
- msgid "Private Cached URIs"
1879
  msgstr ""
1880
 
1881
- #: admin/tpl/settings_cache.php:60
1882
- msgid "URI Paths containing these strings will NOT be cached as public."
1883
  msgstr ""
1884
 
1885
- #: admin/tpl/settings_cache.php:61 admin/tpl/settings_excludes.php:13
1886
- msgid "The URLs will be compared to the REQUEST_URI server variable."
1887
  msgstr ""
1888
 
1889
- #: admin/tpl/settings_cache.php:64 admin/tpl/settings_excludes.php:16
1890
- msgid "To do an exact match, add %s to the end of the URL."
 
 
1891
  msgstr ""
1892
 
1893
- #: admin/tpl/settings_cache.php:65 admin/tpl/settings_excludes.php:17
1894
- #: admin/tpl/settings_excludes.php:30 admin/tpl/settings_excludes.php:53
1895
- #: admin/tpl/settings_excludes.php:91
1896
- #: admin/tpl/settings_inc.exclude_cookies.php:19
1897
- msgid "One per line."
1898
  msgstr ""
1899
 
1900
- #: admin/tpl/settings_cdn.php:11
1901
- msgid "CDN Settings"
 
 
1902
  msgstr ""
1903
 
1904
- #: admin/tpl/settings_cdn.php:15
1905
- msgid "Enable CDN"
1906
  msgstr ""
1907
 
1908
- #: admin/tpl/settings_cdn.php:19
1909
- msgid "Enable Content Delivery Network use."
 
 
1910
  msgstr ""
1911
 
1912
- #: admin/tpl/settings_cdn.php:25
1913
- msgid "CDN URL"
1914
  msgstr ""
1915
 
1916
- #: admin/tpl/settings_cdn.php:29
1917
- msgid "CDN URL to be used. For example, %s"
1918
  msgstr ""
1919
 
1920
- #: admin/tpl/settings_cdn.php:35
1921
- msgid "Original URL"
1922
  msgstr ""
1923
 
1924
- #: admin/tpl/settings_cdn.php:39
1925
- msgid ""
1926
- "Site URL to be served through the CDN. Beginning with %1$s. For example, %2$s"
1927
  msgstr ""
1928
 
1929
- #: admin/tpl/settings_cdn.php:45
1930
- msgid "Include Images"
1931
  msgstr ""
1932
 
1933
- #: admin/tpl/settings_cdn.php:49
1934
- msgid ""
1935
- "Serve all image files through the CDN. This will affect all attachments, "
1936
- "HTML %s tags, and CSS %s attributes."
1937
  msgstr ""
1938
 
1939
- #: admin/tpl/settings_cdn.php:55
1940
- msgid "Include CSS"
1941
  msgstr ""
1942
 
1943
- #: admin/tpl/settings_cdn.php:59
1944
- msgid ""
1945
- "Serve all CSS files through the CDN. This will affect all enqueued WP CSS "
1946
- "files."
1947
  msgstr ""
1948
 
1949
- #: admin/tpl/settings_cdn.php:65
1950
- msgid "Include JS"
1951
  msgstr ""
1952
 
1953
- #: admin/tpl/settings_cdn.php:69
1954
- msgid ""
1955
- "Serve all JavaScript files through the CDN. This will affect all enqueued WP "
1956
- "JavaScript files."
1957
  msgstr ""
1958
 
1959
- #: admin/tpl/settings_cdn.php:75
1960
- msgid "Include File Types"
1961
  msgstr ""
1962
 
1963
- #: admin/tpl/settings_cdn.php:81
1964
- msgid "Static file type links to be replaced by CDN links. One per line."
1965
  msgstr ""
1966
 
1967
- #: admin/tpl/settings_cdn.php:82
1968
- msgid "This will affect all tags containing attributes: %s %s %s."
1969
  msgstr ""
1970
 
1971
- #: admin/tpl/settings_cdn.php:94
1972
- msgid "Exclude Path"
1973
  msgstr ""
1974
 
1975
- #: admin/tpl/settings_cdn.php:99
1976
- msgid "Paths containing these strings will not be served from the CDN."
1977
  msgstr ""
1978
 
1979
- #: admin/tpl/settings_compatibilities.php:7
1980
- msgid "Compatibility with WP-PostViews"
 
 
 
1981
  msgstr ""
1982
 
1983
- #: admin/tpl/settings_compatibilities.php:9
1984
- msgid "To make LiteSpeed Cache compatible with WP-PostViews:"
1985
  msgstr ""
1986
 
1987
- #: admin/tpl/settings_compatibilities.php:13
1988
- msgid ""
1989
- "Replace the following calls in the active theme's template files with a div "
1990
- "or span with a unique ID."
1991
  msgstr ""
1992
 
1993
- #: admin/tpl/settings_compatibilities.php:14
1994
- msgid "e.g. Replace <br> <pre>%1$s</pre> with<br> <pre>%2$s</pre>"
1995
  msgstr ""
1996
 
1997
- #: admin/tpl/settings_compatibilities.php:21
1998
- msgid "Update the ajax request to output the results to that div."
 
 
 
1999
  msgstr ""
2000
 
2001
- #: admin/tpl/settings_compatibilities.php:22
2002
- msgid "Example:"
 
2003
  msgstr ""
2004
 
2005
- #: admin/tpl/settings_compatibilities.php:34
2006
- msgid "The ajax code can be found at"
2007
  msgstr ""
2008
 
2009
- #: admin/tpl/settings_compatibilities.php:37
2010
- msgid "After purging the cache, the view count should be updating."
 
 
2011
  msgstr ""
2012
 
2013
- #: admin/tpl/settings_crawler.php:6
2014
- msgid "Crawler Settings"
2015
  msgstr ""
2016
 
2017
- #: admin/tpl/settings_crawler.php:13
2018
- msgid "microseconds"
2019
  msgstr ""
2020
 
2021
- #: admin/tpl/settings_crawler.php:15
2022
  msgid ""
2023
- "Specify time in microseconds for the delay between requests during a crawl."
 
2024
  msgstr ""
2025
 
2026
- #: admin/tpl/settings_crawler.php:27
2027
- msgid "Specify time in seconds for the duration of the crawl interval."
2028
  msgstr ""
2029
 
2030
- #: admin/tpl/settings_crawler.php:34
2031
- msgid "Interval Between Runs"
2032
  msgstr ""
2033
 
2034
- #: admin/tpl/settings_crawler.php:39
2035
- msgid ""
2036
- "Specify time in seconds for the time between each run interval. Must be "
2037
- "greater than 60."
2038
  msgstr ""
2039
 
2040
- #: admin/tpl/settings_crawler.php:46
2041
- msgid "Crawl Interval"
2042
  msgstr ""
2043
 
2044
- #: admin/tpl/settings_crawler.php:51
2045
- msgid ""
2046
- "Specify how long in seconds before the crawler should initiate crawling the "
2047
- "entire sitemap again."
2048
  msgstr ""
2049
 
2050
- #: admin/tpl/settings_crawler.php:63
2051
- msgid "Specify Number of Threads to use while crawling."
2052
  msgstr ""
2053
 
2054
- #: admin/tpl/settings_crawler.php:70
2055
- msgid "Server Load Limit"
2056
  msgstr ""
2057
 
2058
- #: admin/tpl/settings_crawler.php:75
2059
- msgid ""
2060
- "The maximum average server load allowed while crawling. The number of "
2061
- "crawler threads in use will be actively reduced until average server load "
2062
- "falls under this limit. If this cannot be achieved with a single thread, the "
2063
- "current crawler run will be terminated."
2064
  msgstr ""
2065
 
2066
- #: admin/tpl/settings_crawler.php:83
2067
- msgid "Site IP"
 
2068
  msgstr ""
2069
 
2070
- #: admin/tpl/settings_crawler.php:88
2071
- msgid ""
2072
- "Enter this site's IP address to crawl by IP instead of domain name. This "
2073
- "eliminates the overhead of DNS and CDN lookups. (optional)"
2074
  msgstr ""
2075
 
2076
- #: admin/tpl/settings_crawler.php:94
2077
- msgid "Custom Sitemap"
 
2078
  msgstr ""
2079
 
2080
- #: admin/tpl/settings_crawler.php:99
2081
- msgid ""
2082
- "The crawler can use your Google XML Sitemap instead of its own. Enter the "
2083
- "full URL to your sitemap here."
2084
  msgstr ""
2085
 
2086
- #: admin/tpl/settings_crawler.php:105
2087
- msgid "Include Posts"
 
 
 
2088
  msgstr ""
2089
 
2090
- #: admin/tpl/settings_crawler.php:109
2091
- msgid "Include Posts in crawler sitemap generation."
 
 
 
2092
  msgstr ""
2093
 
2094
- #: admin/tpl/settings_crawler.php:115
2095
- msgid "Include Pages"
 
 
 
2096
  msgstr ""
2097
 
2098
- #: admin/tpl/settings_crawler.php:119
2099
- msgid "Include Pages in crawler sitemap generation."
 
 
2100
  msgstr ""
2101
 
2102
- #: admin/tpl/settings_crawler.php:125
2103
- msgid "Include Categories"
 
2104
  msgstr ""
2105
 
2106
- #: admin/tpl/settings_crawler.php:129
2107
- msgid "Include Categories pages in crawler sitemap generation."
 
 
2108
  msgstr ""
2109
 
2110
- #: admin/tpl/settings_crawler.php:135
2111
- msgid "Include Tags"
2112
  msgstr ""
2113
 
2114
- #: admin/tpl/settings_crawler.php:139
2115
- msgid "Include Tags pages in crawler sitemap generation."
2116
  msgstr ""
2117
 
2118
- #: admin/tpl/settings_crawler.php:145
2119
- msgid "Exclude Custom Post Types"
2120
  msgstr ""
2121
 
2122
- #: admin/tpl/settings_crawler.php:150
2123
  msgid ""
2124
- "If you want to exclude certain Custom Post Types in sitemap, add the Custom "
2125
- "Post Types in the box, one per line."
2126
- msgstr ""
2127
-
2128
- #: admin/tpl/settings_crawler.php:154
2129
- msgid "Available Custom Post Type"
2130
  msgstr ""
2131
 
2132
- #: admin/tpl/settings_crawler.php:163
2133
- msgid "Order links by"
 
 
2134
  msgstr ""
2135
 
2136
- #: admin/tpl/settings_crawler.php:169
2137
- msgid "Date, descending (Default)"
2138
  msgstr ""
2139
 
2140
- #: admin/tpl/settings_crawler.php:175
2141
- msgid "Date, ascending"
 
 
2142
  msgstr ""
2143
 
2144
- #: admin/tpl/settings_crawler.php:181
2145
- msgid "Alphabetical, descending"
2146
  msgstr ""
2147
 
2148
- #: admin/tpl/settings_crawler.php:187
2149
- msgid "Alphabetical, ascending"
2150
  msgstr ""
2151
 
2152
- #: admin/tpl/settings_crawler.php:191
2153
  msgid ""
2154
- "Please choose one of the above options to set the order in which the sitemap "
2155
- "will be parsed."
2156
  msgstr ""
2157
 
2158
- #: admin/tpl/settings_debug.php:6
2159
- msgid "Developer Testing"
2160
  msgstr ""
2161
 
2162
- #: admin/tpl/settings_debug.php:16
2163
- msgid "Off"
2164
  msgstr ""
2165
 
2166
- #: admin/tpl/settings_debug.php:22
2167
- msgid "On"
 
 
2168
  msgstr ""
2169
 
2170
- #: admin/tpl/settings_debug.php:28
2171
- msgid "Admin IP only"
 
 
 
2172
  msgstr ""
2173
 
2174
- #: admin/tpl/settings_debug.php:32
2175
  msgid "Outputs to WordPress debug log."
2176
  msgstr ""
2177
 
2178
- #: admin/tpl/settings_debug.php:33
2179
  msgid ""
2180
  "This should be set to off once everything is working to prevent filling the "
2181
  "disk."
2182
  msgstr ""
2183
 
2184
- #: admin/tpl/settings_debug.php:34
2185
  msgid ""
2186
  "The Admin IP option will only output log messages on requests from admin IPs."
2187
  msgstr ""
2188
 
2189
- #: admin/tpl/settings_debug.php:35
2190
- msgid "The logs will be outputted to %s."
 
2191
  msgstr ""
2192
 
2193
- #: admin/tpl/settings_debug.php:41
2194
  msgid "Admin IPs"
2195
  msgstr ""
2196
 
2197
- #: admin/tpl/settings_debug.php:45
2198
- msgid ""
2199
- "Allows listed IPs (one per line) to perform certain actions from their "
2200
- "browsers."
2201
  msgstr ""
2202
 
2203
- #: admin/tpl/settings_debug.php:46
2204
- msgid ""
2205
- "More information about the available commands can be found <a href=\"%s"
2206
- "\">here</a>."
2207
  msgstr ""
2208
 
2209
- #: admin/tpl/settings_debug.php:53
2210
- msgid "Debug Level"
2211
  msgstr ""
2212
 
2213
- #: admin/tpl/settings_debug.php:59
2214
- msgid "Basic"
2215
  msgstr ""
2216
 
2217
- #: admin/tpl/settings_debug.php:69
2218
- msgid "Advanced level will log more details."
2219
  msgstr ""
2220
 
2221
- #: admin/tpl/settings_de
1
+ # Translation template for the LiteSpeed Cache WordPress Plugin.
2
+ # Copyright (C) 2015-2017 LiteSpeed Technologies, Inc.
3
+ # This file is distributed under the same license as the LiteSpeed_Cache package.
4
+ # LiteSpeed Technologies <info@litespeedtech.com>, 2017.
5
+ #
6
+ #
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: 1.0.15\n"
10
+ "Report-Msgid-Bugs-To: info@litespeedtech.com\n"
11
+ "POT-Creation-Date: 2017-04-20 10:10-0500\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=CHARSET\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
 
20
+ #: admin/class-litespeed-cache-admin-display.php:69
21
+ #, php-format
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  msgid ""
23
+ "Rate <strong>LiteSpeed Cache</strong> with %s on WordPress.org if you like "
24
+ "us!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  msgstr ""
26
 
27
+ #: admin/class-litespeed-cache-admin-display.php:76
28
+ #, php-format
29
  msgid ""
30
+ "If there are any questions that are not answered in the <a href=\"%s\">FAQs</"
31
+ "a>, do not hesitate to ask them on the <a href=\"%s\" rel=\"%s\" target=\"%s"
32
+ "\">support forum</a>."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  msgstr ""
34
 
35
+ #: admin/class-litespeed-cache-admin-display.php:133
36
+ msgid "LiteSpeed Cache is a page cache built into LiteSpeed Web Server."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  msgstr ""
38
 
39
+ #: admin/class-litespeed-cache-admin-display.php:134
40
+ msgid ""
41
+ "This plugin communicates with LiteSpeed Web Server to let it know which "
42
+ "pages are cache-able and when to purge them."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  msgstr ""
44
 
45
+ #: admin/class-litespeed-cache-admin-display.php:140
46
+ msgid "Overview"
47
  msgstr ""
48
 
49
+ #: admin/class-litespeed-cache-admin-display.php:142
50
  msgid ""
51
+ "A LiteSpeed server (OLS, LSWS, WebADC) and its LSCache module must be "
52
+ "installed and enabled."
53
  msgstr ""
54
 
55
+ #: admin/class-litespeed-cache-admin-display.php:153
56
+ msgid "For more information:"
57
  msgstr ""
58
 
59
+ #: admin/class-litespeed-cache-admin-display.php:155
60
+ msgid "Support Forum"
 
 
61
  msgstr ""
62
 
63
+ #: admin/class-litespeed-cache-admin-display.php:324
64
+ msgid "Expand All"
65
  msgstr ""
66
 
67
+ #: admin/class-litespeed-cache-admin-display.php:325
68
+ msgid "Collapse All"
69
  msgstr ""
70
 
71
+ #: admin/class-litespeed-cache-admin-display.php:448
72
  msgid ""
73
+ "From this screen, one can inform the server to purge the selected cached "
74
+ "pages or empty the entire cache."
75
  msgstr ""
76
 
77
+ #: admin/class-litespeed-cache-admin-display.php:450
78
+ msgid "This will purge everything for all blogs."
79
  msgstr ""
80
 
81
+ #: admin/class-litespeed-cache-admin-display.php:451
82
+ #: admin/class-litespeed-cache-admin-display.php:594
83
+ msgid "Are you sure you want to purge all?"
 
84
  msgstr ""
85
 
86
+ #: admin/class-litespeed-cache-admin-display.php:454
87
+ msgid "Select dropdown below for \"Purge by\" options."
 
88
  msgstr ""
89
 
90
+ #: admin/class-litespeed-cache-admin-display.php:455
91
+ msgid "Please enter one per line."
92
  msgstr ""
93
 
94
+ #: admin/class-litespeed-cache-admin-display.php:458
95
+ msgid "This will clear EVERYTHING inside the cache."
96
  msgstr ""
97
 
98
+ #: admin/class-litespeed-cache-admin-display.php:459
99
+ msgid "This may cause heavy load on the server."
100
+ msgstr ""
101
+
102
+ #: admin/class-litespeed-cache-admin-display.php:460
103
+ msgid "If only the WordPress site should be purged, use purge all."
104
  msgstr ""
105
 
106
+ #: admin/class-litespeed-cache-admin-display.php:463
107
  msgid ""
108
+ "Clears all cache entries related to this site, <i>including other web "
109
+ "applications</i>."
110
  msgstr ""
111
 
112
+ #: admin/class-litespeed-cache-admin-display.php:465
113
  msgid ""
114
+ "<b>This action should only be used if things are cached incorrectly.</b>"
 
115
  msgstr ""
116
 
117
+ #: admin/class-litespeed-cache-admin-display.php:470
118
+ #, php-format
119
  msgid ""
120
+ "Purge pages by category name - e.g. %2$s should be used for the URL %1$s."
 
121
  msgstr ""
122
 
123
+ #: admin/class-litespeed-cache-admin-display.php:474
124
+ msgid "Purge pages by relative URL."
125
  msgstr ""
126
 
127
+ #: admin/class-litespeed-cache-admin-display.php:475
128
+ msgid "Must be exact match."
129
  msgstr ""
130
 
131
+ #: admin/class-litespeed-cache-admin-display.php:476
132
+ #, php-format
133
+ msgid "e.g. Use %s for %s."
 
134
  msgstr ""
135
 
136
+ #: admin/class-litespeed-cache-admin-display.php:482
137
+ #, php-format
138
+ msgid "Purge pages by tag name - e.g. %2$s should be used for the URL %1$s."
139
  msgstr ""
140
 
141
+ #: admin/class-litespeed-cache-admin-display.php:490
142
+ msgid "Category"
143
  msgstr ""
144
 
145
+ #: admin/class-litespeed-cache-admin-display.php:491
146
+ msgid "Post ID"
147
  msgstr ""
148
 
149
+ #: admin/class-litespeed-cache-admin-display.php:492
150
+ msgid "Tag"
 
151
  msgstr ""
152
 
153
+ #: admin/class-litespeed-cache-admin-display.php:493
154
+ msgid "URL"
155
  msgstr ""
156
 
157
+ #: admin/class-litespeed-cache-admin-display.php:498
158
+ msgid "LiteSpeed Cache Management"
159
  msgstr ""
160
 
161
+ #: admin/class-litespeed-cache-admin-display.php:508
162
+ msgid "Purge Front Page"
 
163
  msgstr ""
164
 
165
+ #: admin/class-litespeed-cache-admin-display.php:511
166
+ msgid "Purge Pages"
167
  msgstr ""
168
 
169
+ #: admin/class-litespeed-cache-admin-display.php:517
170
+ msgid "Purge All"
171
  msgstr ""
172
 
173
+ #: admin/class-litespeed-cache-admin-display.php:523
174
+ msgid "Purge Error Pages"
175
  msgstr ""
176
 
177
+ #: admin/class-litespeed-cache-admin-display.php:527
178
+ msgid "Include 403"
 
179
  msgstr ""
180
 
181
+ #: admin/class-litespeed-cache-admin-display.php:530
182
+ msgid "Include 404"
183
  msgstr ""
184
 
185
+ #: admin/class-litespeed-cache-admin-display.php:533
186
+ msgid "Include 500s"
187
  msgstr ""
188
 
189
+ #: admin/class-litespeed-cache-admin-display.php:539
190
+ msgid "Purge the Front Page."
191
  msgstr ""
192
 
193
+ #: admin/class-litespeed-cache-admin-display.php:542
194
+ msgid "This will Purge Front Page only"
195
  msgstr ""
196
 
197
+ #: admin/class-litespeed-cache-admin-display.php:546
198
+ msgid "Purge Pages."
199
  msgstr ""
200
 
201
+ #: admin/class-litespeed-cache-admin-display.php:549
202
+ msgid "This will Purge Pages only"
203
  msgstr ""
204
 
205
+ #: admin/class-litespeed-cache-admin-display.php:553
206
+ msgid "Purge all WordPress pages."
207
  msgstr ""
208
 
209
+ #: admin/class-litespeed-cache-admin-display.php:556
210
+ msgid "Purge the cache entries created by this plugin."
211
  msgstr ""
212
 
213
+ #: admin/class-litespeed-cache-admin-display.php:560
214
+ msgid "Purge the error pages."
215
  msgstr ""
216
 
217
+ #: admin/class-litespeed-cache-admin-display.php:563
218
+ msgid "Purges the error page cache entries created by this plugin."
219
  msgstr ""
220
 
221
+ #: admin/class-litespeed-cache-admin-display.php:571
222
+ msgid "Clear all cache entries."
223
  msgstr ""
224
 
225
+ #: admin/class-litespeed-cache-admin-display.php:576
226
+ msgid "Empty Entire Cache"
227
  msgstr ""
228
 
229
+ #: admin/class-litespeed-cache-admin-display.php:598
230
+ msgid "Purge By..."
231
  msgstr ""
232
 
233
+ #: admin/class-litespeed-cache-admin-display.php:617
234
+ msgid "Purge pages by post ID."
235
  msgstr ""
236
 
237
+ #: admin/class-litespeed-cache-admin-display.php:623
238
+ msgid "Purge List"
239
  msgstr ""
240
 
241
+ #: admin/class-litespeed-cache-admin-display.php:675
242
+ #: admin/class-litespeed-cache-admin-display.php:842
243
+ msgid "LiteSpeed Cache Settings"
244
  msgstr ""
245
 
246
+ #: admin/class-litespeed-cache-admin-display.php:681
247
+ msgid "The network admin selected use primary site configs for all subsites."
248
  msgstr ""
249
 
250
+ #: admin/class-litespeed-cache-admin-display.php:682
251
+ msgid ""
252
+ "The following options are selected, but are not editable in this settings "
253
+ "page."
254
  msgstr ""
255
 
256
+ #: admin/class-litespeed-cache-admin-display.php:700
257
+ #: admin/class-litespeed-cache-admin-display.php:1105
258
+ msgid "Plugin Compatibilities"
259
  msgstr ""
260
 
261
+ #: admin/class-litespeed-cache-admin-display.php:711
262
+ #: admin/class-litespeed-cache-admin-display.php:1738
263
+ msgid "Advanced Settings"
264
  msgstr ""
265
 
266
+ #: admin/class-litespeed-cache-admin-display.php:729
267
+ #: admin/class-litespeed-cache-admin-display.php:855
268
+ #: admin/class-litespeed-cache-admin-display.php:1234
269
+ msgid "General"
270
  msgstr ""
271
 
272
+ #: admin/class-litespeed-cache-admin-display.php:730
273
+ #: admin/class-litespeed-cache-admin-display.php:1356
274
+ msgid "Specific Pages"
275
  msgstr ""
276
 
277
+ #: admin/class-litespeed-cache-admin-display.php:731
278
+ msgid "Purge Rules"
279
  msgstr ""
280
 
281
+ #: admin/class-litespeed-cache-admin-display.php:732
282
+ #: admin/class-litespeed-cache-admin-display.php:856
283
+ msgid "Do Not Cache Rules"
284
  msgstr ""
285
 
286
+ #: admin/class-litespeed-cache-admin-display.php:734
287
+ msgid "Debug"
288
  msgstr ""
289
 
290
+ #: admin/class-litespeed-cache-admin-display.php:746
291
+ msgid "WARNING: Third party tab input invalid."
292
  msgstr ""
293
 
294
+ #: admin/class-litespeed-cache-admin-display.php:755
295
+ msgid "WARNING: Third party config slug contains invalid characters."
296
  msgstr ""
297
 
298
+ #: admin/class-litespeed-cache-admin-display.php:801
299
+ msgid "Save Changes"
300
  msgstr ""
301
 
302
+ #: admin/class-litespeed-cache-admin-display.php:822
303
+ msgid "These configurations are only available network wide."
304
  msgstr ""
305
 
306
+ #: admin/class-litespeed-cache-admin-display.php:825
307
+ msgid ""
308
+ "Separate Mobile Views should be enabled if any of the network enabled themes "
309
+ "require a different view for mobile devices."
310
  msgstr ""
311
 
312
+ #: admin/class-litespeed-cache-admin-display.php:826
313
+ msgid "Responsive themes can handle this part automatically."
314
  msgstr ""
315
 
316
+ #: admin/class-litespeed-cache-admin-display.php:828
317
+ msgid ""
318
+ "Enabling LiteSpeed Cache for WordPress here enables the cache for the "
319
+ "network."
320
  msgstr ""
321
 
322
+ #: admin/class-litespeed-cache-admin-display.php:830
323
+ msgid ""
324
+ "It is <b>STRONGLY</b> recommend that the compatibility with other plugins on "
325
+ "a single/few sites is tested first."
326
  msgstr ""
327
 
328
+ #: admin/class-litespeed-cache-admin-display.php:832
329
+ msgid ""
330
+ "This is to ensure compatibility prior to enabling the cache for all sites."
331
  msgstr ""
332
 
333
+ #: admin/class-litespeed-cache-admin-display.php:857
334
+ msgid "Advanced"
335
  msgstr ""
336
 
337
+ #: admin/class-litespeed-cache-admin-display.php:861
338
+ msgid "General Network Configurations"
339
  msgstr ""
340
 
341
+ #: admin/class-litespeed-cache-admin-display.php:870
342
+ msgid "Network Enable Cache"
343
  msgstr ""
344
 
345
+ #: admin/class-litespeed-cache-admin-display.php:878
346
  msgid ""
347
+ "Check this option to use the primary site's configurations for all subsites."
 
348
  msgstr ""
349
 
350
+ #: admin/class-litespeed-cache-admin-display.php:880
351
+ msgid "This will disable the settings page on all subsites."
352
  msgstr ""
353
 
354
+ #: admin/class-litespeed-cache-admin-display.php:884
355
+ msgid "Use Primary Site Configurations"
356
  msgstr ""
357
 
358
+ #: admin/class-litespeed-cache-admin-display.php:898
359
+ msgid "Network Do Not Cache Rules"
360
  msgstr ""
361
 
362
+ #: admin/class-litespeed-cache-admin-display.php:903
363
+ msgid "Do Not Cache User Agents"
364
  msgstr ""
365
 
366
+ #: admin/class-litespeed-cache-admin-display.php:912
367
+ msgid "Do Not Cache Cookies"
368
  msgstr ""
369
 
370
+ #: admin/class-litespeed-cache-admin-display.php:924
371
+ #: admin/class-litespeed-cache-admin-display.php:997
372
+ msgid "Save"
373
  msgstr ""
374
 
375
+ #: admin/class-litespeed-cache-admin-display.php:941
376
+ msgid "Any changes made to the .htaccess file may break the site."
377
  msgstr ""
378
 
379
+ #: admin/class-litespeed-cache-admin-display.php:942
380
+ msgid "Please consult the host/server admin before making any changes."
381
  msgstr ""
382
 
383
+ #: admin/class-litespeed-cache-admin-display.php:944
384
+ msgid "LiteSpeed Cache Edit .htaccess"
385
  msgstr ""
386
 
387
+ #: admin/class-litespeed-cache-admin-display.php:950
388
+ msgid "File editing is disabled in configuration."
389
  msgstr ""
390
 
391
+ #: admin/class-litespeed-cache-admin-display.php:966
392
+ msgid "WARNING: This page is meant for advanced users."
393
  msgstr ""
394
 
395
+ #: admin/class-litespeed-cache-admin-display.php:978
396
+ #, php-format
397
+ msgid "Current %s contents:"
398
  msgstr ""
399
 
400
+ #: admin/class-litespeed-cache-admin-display.php:981
401
+ #, php-format
402
+ msgid "DO NOT EDIT ANYTHING WITHIN %s"
403
  msgstr ""
404
 
405
+ #: admin/class-litespeed-cache-admin-display.php:984
406
+ msgid ""
407
+ "These are added by the LS Cache plugin and may cause problems if they are "
408
+ "changed."
409
  msgstr ""
410
 
411
+ #: admin/class-litespeed-cache-admin-display.php:1017
412
+ msgid "Make sure that the server license has the LSCache module enabled."
413
  msgstr ""
414
 
415
+ #: admin/class-litespeed-cache-admin-display.php:1019
416
+ #, php-format
417
+ msgid ""
418
+ "A <a href=\"%1$s\" rel=\"%2$s\" target=\"%3$s\">2-CPU trial license with "
419
+ "LSCache module</a> is available for free for %4$d days."
420
  msgstr ""
421
 
422
+ #: admin/class-litespeed-cache-admin-display.php:1032
423
+ msgid "The server must be configured to have caching enabled."
424
  msgstr ""
425
 
426
+ #: admin/class-litespeed-cache-admin-display.php:1034
427
+ #, php-format
428
+ msgid ""
429
+ "If you are the server admin, <a href=\"%s\" rel=\"%s\" target=\"%s\">click "
430
+ "here.</a>"
431
  msgstr ""
432
 
433
+ #: admin/class-litespeed-cache-admin-display.php:1044
434
+ msgid ""
435
+ "Otherwise request that the server admin configure the cache root for the "
436
+ "server."
437
  msgstr ""
438
 
439
+ #: admin/class-litespeed-cache-admin-display.php:1050
440
+ msgid "This integration utilizes OLS's cache module."
441
  msgstr ""
442
 
443
+ #: admin/class-litespeed-cache-admin-display.php:1053
444
+ #, php-format
445
+ msgid ""
446
+ "If it is a fresh OLS installation, the easiest way to integrate is to use <a "
447
+ "href=\"%s\" rel=\"%s\" target=\"%s\">ols1clk.</a>"
448
  msgstr ""
449
 
450
+ #: admin/class-litespeed-cache-admin-display.php:1063
451
+ #, php-format
452
+ msgid "If using an existing WordPress installation, use the %s parameter."
453
  msgstr ""
454
 
455
+ #: admin/class-litespeed-cache-admin-display.php:1067
456
+ #, php-format
457
+ msgid ""
458
+ "Else if OLS and WordPress are already installed, please follow the "
459
+ "instructions <a href=\"%s\" rel=\"%s\" target=\"%s\">here.</a>"
460
  msgstr ""
461
 
462
+ #: admin/class-litespeed-cache-admin-display.php:1082
463
+ #, php-format
464
  msgid ""
465
+ "Subsequent requests should have the %s response header until the page is "
466
+ "updated, expired, or purged."
467
  msgstr ""
468
 
469
+ #: admin/class-litespeed-cache-admin-display.php:1085
470
+ #, php-format
471
+ msgid ""
472
+ "Please visit <a href=\"%s\" rel=\"%s\" target=\"%s\">this page</a> for more "
473
+ "information."
474
  msgstr ""
475
 
476
+ #: admin/class-litespeed-cache-admin-display.php:1099
477
+ msgid "LiteSpeed Cache Information"
478
  msgstr ""
479
 
480
+ #: admin/class-litespeed-cache-admin-display.php:1103
481
+ msgid "FAQs"
482
  msgstr ""
483
 
484
+ #: admin/class-litespeed-cache-admin-display.php:1104
485
+ msgid "Configurations"
486
  msgstr ""
487
 
488
+ #: admin/class-litespeed-cache-admin-display.php:1106
489
+ msgid "Common Rewrite Rules"
490
  msgstr ""
491
 
492
+ #: admin/class-litespeed-cache-admin-display.php:1107
493
+ msgid "Admin IP Commands"
 
 
494
  msgstr ""
495
 
496
+ #: admin/class-litespeed-cache-admin-display.php:1116
497
+ msgid "LiteSpeed Cache Configurations"
 
 
498
  msgstr ""
499
 
500
+ #: admin/class-litespeed-cache-admin-display.php:1117
501
+ msgid "Instructions for LiteSpeed Web Server Enterprise"
 
502
  msgstr ""
503
 
504
+ #: admin/class-litespeed-cache-admin-display.php:1124
505
+ msgid ""
506
+ "In the .htaccess file for the WordPress installation, add the following:"
507
  msgstr ""
508
 
509
+ #: admin/class-litespeed-cache-admin-display.php:1132
510
+ msgid "Instructions for OpenLiteSpeed"
 
511
  msgstr ""
512
 
513
+ #: admin/class-litespeed-cache-admin-display.php:1135
514
+ msgid "How to test the plugin"
515
  msgstr ""
516
 
517
+ #: admin/class-litespeed-cache-admin-display.php:1136
518
+ msgid ""
519
+ "The LiteSpeed Cache Plugin utilizes LiteSpeed specific response headers."
520
  msgstr ""
521
 
522
+ #: admin/class-litespeed-cache-admin-display.php:1138
523
+ #, php-format
524
+ msgid ""
525
+ "Visiting a page for the first time should result in a %s or %s response "
526
+ "header for the page."
527
  msgstr ""
528
 
529
+ #: admin/class-litespeed-cache-admin-display.php:1176
530
  msgid ""
531
  "The environment report contains detailed information about the WordPress "
532
  "configuration."
533
  msgstr ""
534
 
535
+ #: admin/class-litespeed-cache-admin-display.php:1177
536
  msgid ""
537
  "If you run into any issues, please include the contents of this text area in "
538
  "your support message."
539
  msgstr ""
540
 
541
+ #: admin/class-litespeed-cache-admin-display.php:1179
542
  msgid ""
543
  "To easily grab the content, click the <b>Select All and Copy to Clipboard</"
544
  "b> button, to select and copy to clipboard."
545
  msgstr ""
546
 
547
+ #: admin/class-litespeed-cache-admin-display.php:1181
548
+ #, php-format
549
  msgid "Alternatively, this information is also saved in %s."
550
  msgstr ""
551
 
552
+ #: admin/class-litespeed-cache-admin-display.php:1186
553
  msgid "The text area below contains the following content:"
554
  msgstr ""
555
 
556
+ #: admin/class-litespeed-cache-admin-display.php:1188
557
  msgid ""
558
  "Server Variables, Plugin Options, WordPress information (version, locale, "
559
  "active plugins, etc.), and .htaccess file content."
560
  msgstr ""
561
 
562
+ #: admin/class-litespeed-cache-admin-display.php:1194
563
  msgid "Select All and Copy to Clipboard"
564
  msgstr ""
565
 
566
+ #: admin/class-litespeed-cache-admin-display.php:1195
567
  msgid "Environment Report copied to Clipboard!"
568
  msgstr ""
569
 
570
+ #: admin/class-litespeed-cache-admin-display.php:1215
571
+ msgid "Specify how long, in seconds, feeds are cached."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
572
  msgstr ""
573
 
574
+ #: admin/class-litespeed-cache-admin-display.php:1216
575
+ msgid "If this is set to a number less than 30, feeds will not be cached."
 
 
576
  msgstr ""
577
 
578
+ #: admin/class-litespeed-cache-admin-display.php:1219
579
+ msgid "Specify how long, in seconds, 404 pages are cached."
580
  msgstr ""
581
 
582
+ #: admin/class-litespeed-cache-admin-display.php:1220
583
+ msgid "If this is set to a number less than 30, 404 pages will not be cached."
584
  msgstr ""
585
 
586
+ #: admin/class-litespeed-cache-admin-display.php:1223
587
+ msgid "Specify how long, in seconds, 403 pages are cached."
588
  msgstr ""
589
 
590
+ #: admin/class-litespeed-cache-admin-display.php:1224
591
+ msgid "If this is set to a number less than 30, 403 pages will not be cached."
592
  msgstr ""
593
 
594
+ #: admin/class-litespeed-cache-admin-display.php:1227
595
+ msgid "Specify how long, in seconds, 500 pages are cached."
596
  msgstr ""
597
 
598
+ #: admin/class-litespeed-cache-admin-display.php:1228
599
+ msgid "If this is set to a number less than 30, 500 pages will not be cached."
 
 
600
  msgstr ""
601
 
602
+ #: admin/class-litespeed-cache-admin-display.php:1231
603
  msgid ""
604
+ "When checked, commenters will not be able to see their comments awaiting "
605
+ "moderation."
606
  msgstr ""
607
 
608
+ #: admin/class-litespeed-cache-admin-display.php:1232
609
  msgid ""
610
+ "Disabling this option will display those types of comments, but the cache "
611
+ "will not perform as well."
612
  msgstr ""
613
 
614
+ #: admin/class-litespeed-cache-admin-display.php:1239
615
+ msgid "Enable"
616
  msgstr ""
617
 
618
+ #: admin/class-litespeed-cache-admin-display.php:1240
619
+ msgid "Disable"
620
  msgstr ""
621
 
622
+ #: admin/class-litespeed-cache-admin-display.php:1247
623
+ msgid "Use Network Admin Setting"
624
  msgstr ""
625
 
626
+ #: admin/class-litespeed-cache-admin-display.php:1254
627
+ #, php-format
628
+ msgid ""
629
+ "Please visit the <a href=\"%sadmin.php?page=lscache-info\">information</a> "
630
+ "page on how to test the cache."
631
  msgstr ""
632
 
633
+ #: admin/class-litespeed-cache-admin-display.php:1261
634
+ #: admin/class-litespeed-cache-admin-display.php:1722
635
+ msgid "NOTICE"
 
636
  msgstr ""
637
 
638
+ #: admin/class-litespeed-cache-admin-display.php:1262
639
+ msgid ""
640
+ "When disabling the cache, all cached entries for this blog will be purged."
641
  msgstr ""
642
 
643
+ #: admin/class-litespeed-cache-admin-display.php:1266
644
+ msgid "The network admin setting can be overridden here."
645
  msgstr ""
646
 
647
+ #: admin/class-litespeed-cache-admin-display.php:1270
648
+ msgid "Enable LiteSpeed Cache"
 
649
  msgstr ""
650
 
651
+ #: admin/class-litespeed-cache-admin-display.php:1275
652
+ #: admin/class-litespeed-cache-admin-display.php:1285
653
+ #: admin/class-litespeed-cache-admin-display.php:1294
654
+ #: admin/class-litespeed-cache-admin-display.php:1303
655
+ #: admin/class-litespeed-cache-admin-display.php:1312
656
+ #: admin/class-litespeed-cache-admin-display.php:1321
657
+ msgid "seconds"
658
  msgstr ""
659
 
660
+ #: admin/class-litespeed-cache-admin-display.php:1278
661
+ msgid "Default Public Cache TTL"
662
  msgstr ""
663
 
664
+ #: admin/class-litespeed-cache-admin-display.php:1280
665
+ msgid ""
666
+ "Specify how long, in seconds, public pages are cached. Minimum is 30 seconds."
667
  msgstr ""
668
 
669
+ #: admin/class-litespeed-cache-admin-display.php:1287
670
+ msgid "Default Front Page TTL"
671
  msgstr ""
672
 
673
+ #: admin/class-litespeed-cache-admin-display.php:1289
674
  msgid ""
675
+ "Specify how long, in seconds, the front page is cached. Minimum is 30 "
676
+ "seconds."
677
  msgstr ""
678
 
679
+ #: admin/class-litespeed-cache-admin-display.php:1296
680
+ msgid "Default Feed TTL"
681
  msgstr ""
682
 
683
+ #: admin/class-litespeed-cache-admin-display.php:1305
684
+ msgid "Default 404 Page TTL"
685
  msgstr ""
686
 
687
+ #: admin/class-litespeed-cache-admin-display.php:1314
688
+ msgid "Default 403 Page TTL"
689
  msgstr ""
690
 
691
+ #: admin/class-litespeed-cache-admin-display.php:1323
692
+ msgid "Default 500 Page TTL"
693
  msgstr ""
694
 
695
+ #: admin/class-litespeed-cache-admin-display.php:1331
696
+ msgid "Enable Cache for Commenters"
697
  msgstr ""
698
 
699
+ #: admin/class-litespeed-cache-admin-display.php:1361
700
+ msgid "Enable Cache for Login Page"
701
  msgstr ""
702
 
703
+ #: admin/class-litespeed-cache-admin-display.php:1363
704
+ msgid "Unchecking this option may negatively affect performance."
705
  msgstr ""
706
 
707
+ #: admin/class-litespeed-cache-admin-display.php:1389
708
+ msgid ""
709
+ "Select \"All\" if there are dynamic widgets linked to posts on pages other "
710
+ "than the front or home pages."
711
  msgstr ""
712
 
713
+ #: admin/class-litespeed-cache-admin-display.php:1390
714
+ msgid "Other checkboxes will be ignored."
 
 
 
715
  msgstr ""
716
 
717
+ #: admin/class-litespeed-cache-admin-display.php:1391
718
+ msgid ""
719
+ "Select only the archive types that are currently used, the others can be "
720
+ "left unchecked."
721
  msgstr ""
722
 
723
+ #: admin/class-litespeed-cache-admin-display.php:1397
724
+ msgid "Auto Purge Rules For Publish/Update"
725
  msgstr ""
726
 
727
+ #: admin/class-litespeed-cache-admin-display.php:1398
728
+ msgid ""
729
+ "Select which pages will be automatically purged when posts are published/"
730
+ "updated."
731
  msgstr ""
732
 
733
+ #: admin/class-litespeed-cache-admin-display.php:1400
734
+ msgid "Note:"
735
  msgstr ""
736
 
737
+ #: admin/class-litespeed-cache-admin-display.php:1412
738
+ msgid "All pages"
739
  msgstr ""
740
 
741
+ #: admin/class-litespeed-cache-admin-display.php:1419
742
+ msgid "Front page"
743
  msgstr ""
744
 
745
+ #: admin/class-litespeed-cache-admin-display.php:1426
746
+ msgid "Home page"
 
747
  msgstr ""
748
 
749
+ #: admin/class-litespeed-cache-admin-display.php:1432
750
+ msgid "Pages"
751
  msgstr ""
752
 
753
+ #: admin/class-litespeed-cache-admin-display.php:1439
754
+ msgid "All pages with Recent Posts Widget"
 
 
755
  msgstr ""
756
 
757
+ #: admin/class-litespeed-cache-admin-display.php:1446
758
+ msgid "Author archive"
759
  msgstr ""
760
 
761
+ #: admin/class-litespeed-cache-admin-display.php:1453
762
+ msgid "Post type archive"
 
 
763
  msgstr ""
764
 
765
+ #: admin/class-litespeed-cache-admin-display.php:1460
766
+ msgid "Yearly archive"
767
  msgstr ""
768
 
769
+ #: admin/class-litespeed-cache-admin-display.php:1467
770
+ msgid "Monthly archive"
 
 
771
  msgstr ""
772
 
773
+ #: admin/class-litespeed-cache-admin-display.php:1474
774
+ msgid "Daily archive"
775
  msgstr ""
776
 
777
+ #: admin/class-litespeed-cache-admin-display.php:1481
778
+ msgid "Term archive (include category, tag, and tax)"
779
  msgstr ""
780
 
781
+ #: admin/class-litespeed-cache-admin-display.php:1503
782
+ msgid "Enter a list of urls that should not be cached."
783
  msgstr ""
784
 
785
+ #: admin/class-litespeed-cache-admin-display.php:1504
786
+ msgid "The urls will be compared to the REQUEST_URI server variable."
787
  msgstr ""
788
 
789
+ #: admin/class-litespeed-cache-admin-display.php:1505
790
+ msgid "There should only be one url per line."
791
  msgstr ""
792
 
793
+ #: admin/class-litespeed-cache-admin-display.php:1510
794
+ #: admin/class-litespeed-cache-admin-display.php:1537
795
+ #: admin/class-litespeed-cache-admin-display.php:1560
796
+ #: thirdparty/class-litespeed-cache-thirdparty-woocommerce.php:381
797
+ msgid "NOTE:"
798
  msgstr ""
799
 
800
+ #: admin/class-litespeed-cache-admin-display.php:1513
801
+ msgid "URLs must start with a '/' to be correctly matched."
802
  msgstr ""
803
 
804
+ #: admin/class-litespeed-cache-admin-display.php:1514
805
+ msgid "To do an exact match, add '$' to the end of the URL."
 
 
806
  msgstr ""
807
 
808
+ #: admin/class-litespeed-cache-admin-display.php:1515
809
+ msgid "Any surrounding whitespaces will be trimmed."
810
  msgstr ""
811
 
812
+ #: admin/class-litespeed-cache-admin-display.php:1516
813
+ #: admin/class-litespeed-cache-admin-display.php:1541
814
+ #: admin/class-litespeed-cache-admin-display.php:1565
815
+ #, php-format
816
+ msgid "e.g. to exclude %1$s, insert %2$s"
817
  msgstr ""
818
 
819
+ #: admin/class-litespeed-cache-admin-display.php:1519
820
+ #, php-format
821
+ msgid "Similarly, to exclude %1$s(accessed with the /blog), insert %2$s"
822
  msgstr ""
823
 
824
+ #: admin/class-litespeed-cache-admin-display.php:1530
825
+ msgid "All categories are cached by default."
826
  msgstr ""
827
 
828
+ #: admin/class-litespeed-cache-admin-display.php:1532
829
+ msgid ""
830
+ "To prevent a category from being cached, enter it in the text area below, "
831
+ "one per line."
832
  msgstr ""
833
 
834
+ #: admin/class-litespeed-cache-admin-display.php:1540
835
+ msgid "If the Category ID is not found, the name will be removed on save."
836
  msgstr ""
837
 
838
+ #: admin/class-litespeed-cache-admin-display.php:1553
839
+ msgid "All tags are cached by default."
840
  msgstr ""
841
 
842
+ #: admin/class-litespeed-cache-admin-display.php:1555
843
  msgid ""
844
+ "To prevent tags from being cached, enter the tag in the text area below, one "
845
+ "per line."
846
  msgstr ""
847
 
848
+ #: admin/class-litespeed-cache-admin-display.php:1564
849
+ msgid "If the Tag ID is not found, the name will be removed on save."
850
  msgstr ""
851
 
852
+ #: admin/class-litespeed-cache-admin-display.php:1577
853
+ msgid "URI List"
854
  msgstr ""
855
 
856
+ #: admin/class-litespeed-cache-admin-display.php:1586
857
+ msgid "SYNTAX: URLs must start with a '/' to be correctly matched."
 
 
858
  msgstr ""
859
 
860
+ #: admin/class-litespeed-cache-admin-display.php:1588
861
+ msgid "To do an exact match, add '$' to the end of the URL. One URL per line."
862
  msgstr ""
863
 
864
+ #: admin/class-litespeed-cache-admin-display.php:1604
865
+ msgid "Category List"
 
 
866
  msgstr ""
867
 
868
+ #: admin/class-litespeed-cache-admin-display.php:1613
869
+ msgid "SYNTAX: One category id per line."
870
  msgstr ""
871
 
872
+ #: admin/class-litespeed-cache-admin-display.php:1636
873
+ msgid "Tag List"
874
  msgstr ""
875
 
876
+ #: admin/class-litespeed-cache-admin-display.php:1645
877
+ msgid "SYNTAX: One tag id per line."
 
 
 
 
878
  msgstr ""
879
 
880
+ #: admin/class-litespeed-cache-admin-display.php:1662
881
+ #: admin/class-litespeed-cache-admin-display.php:1981
882
+ msgid "SYNTAX: Cookies should be listed one per line."
883
  msgstr ""
884
 
885
+ #: admin/class-litespeed-cache-admin-display.php:1663
886
+ #: admin/class-litespeed-cache-admin-display.php:1982
887
+ #, php-format
888
+ msgid "Spaces should have a backslash in front of them, %s"
889
  msgstr ""
890
 
891
+ #: admin/class-litespeed-cache-admin-display.php:1666
892
+ #: admin/class-litespeed-cache-admin-display.php:1987
893
+ msgid "Cookie List"
894
  msgstr ""
895
 
896
+ #: admin/class-litespeed-cache-admin-display.php:1667
897
+ #: admin/class-litespeed-cache-admin-display.php:1988
898
+ msgid "To prevent cookies from being cached, enter it in the text area below."
 
899
  msgstr ""
900
 
901
+ #: admin/class-litespeed-cache-admin-display.php:1668
902
+ #: admin/class-litespeed-cache-admin-display.php:1908
903
+ #: admin/class-litespeed-cache-admin-display.php:1990
904
+ #: admin/class-litespeed-cache-admin-display.php:2031
905
+ msgid "NOTICE:"
906
  msgstr ""
907
 
908
+ #: admin/class-litespeed-cache-admin-display.php:1669
909
+ #: admin/class-litespeed-cache-admin-display.php:1909
910
+ #: admin/class-litespeed-cache-admin-display.php:1991
911
+ #: admin/class-litespeed-cache-admin-display.php:2032
912
+ msgid "This setting will edit the .htaccess file."
913
  msgstr ""
914
 
915
+ #: admin/class-litespeed-cache-admin-display.php:1687
916
+ #, php-format
917
+ msgid ""
918
+ "SYNTAX: Separate each user agent with a bar, <style=\"font-style:normal\">"
919
+ "%s</style>."
920
  msgstr ""
921
 
922
+ #: admin/class-litespeed-cache-admin-display.php:1688
923
+ #: admin/class-litespeed-cache-admin-display.php:2023
924
+ #, php-format
925
+ msgid "Spaces should have a backslash in front of them, %s."
926
  msgstr ""
927
 
928
+ #: admin/class-litespeed-cache-admin-display.php:1691
929
+ #: admin/class-litespeed-cache-admin-display.php:2028
930
+ msgid "User Agent List"
931
  msgstr ""
932
 
933
+ #: admin/class-litespeed-cache-admin-display.php:1692
934
+ #: admin/class-litespeed-cache-admin-display.php:2029
935
+ msgid ""
936
+ "To prevent user agents from being cached, enter it in the text field below."
937
  msgstr ""
938
 
939
+ #: admin/class-litespeed-cache-admin-display.php:1723
940
+ msgid "These settings are meant for ADVANCED USERS ONLY."
941
  msgstr ""
942
 
943
+ #: admin/class-litespeed-cache-admin-display.php:1724
944
+ msgid "Please take great care when changing any of these settings."
945
  msgstr ""
946
 
947
+ #: admin/class-litespeed-cache-admin-display.php:1725
948
+ msgid "If there are any questions, do not hesitate to submit a support thread."
949
  msgstr ""
950
 
951
+ #: admin/class-litespeed-cache-admin-display.php:1729
952
  msgid ""
953
+ "The advanced-cache.php file is used by many caching plugins to signal that a "
954
+ "cache is active."
 
 
 
 
955
  msgstr ""
956
 
957
+ #: admin/class-litespeed-cache-admin-display.php:1730
958
+ msgid ""
959
+ "When this option is checked and this file is detected as belonging to "
960
+ "another plugin, LiteSpeed Cache will not cache."
961
  msgstr ""
962
 
963
+ #: admin/class-litespeed-cache-admin-display.php:1734
964
+ msgid "Add an alpha-numeric prefix to cache and purge tags."
965
  msgstr ""
966
 
967
+ #: admin/class-litespeed-cache-admin-display.php:1735
968
+ msgid ""
969
+ "This can be used to prevent issues when using multiple LiteSpeed caching "
970
+ "extensions on the same server."
971
  msgstr ""
972
 
973
+ #: admin/class-litespeed-cache-admin-display.php:1746
974
+ msgid "Check advanced-cache.php"
975
  msgstr ""
976
 
977
+ #: admin/class-litespeed-cache-admin-display.php:1747
978
+ msgid "Check this option to include advanced-cache.php"
979
  msgstr ""
980
 
981
+ #: admin/class-litespeed-cache-admin-display.php:1751
982
  msgid ""
983
+ "<i>Uncheck this option only if the other plugin is used for non-caching "
984
+ "purposes, such as minifying css/js files.</i>"
985
  msgstr ""
986
 
987
+ #: admin/class-litespeed-cache-admin-display.php:1761
988
+ msgid "Cache Tag Prefix"
989
  msgstr ""
990
 
991
+ #: admin/class-litespeed-cache-admin-display.php:1788
992
+ msgid "Developer Testing"
993
  msgstr ""
994
 
995
+ #: admin/class-litespeed-cache-admin-display.php:1791
996
+ msgid ""
997
+ "Allows listed IPs (space or comma separated) to perform certain actions from "
998
+ "their browsers."
999
  msgstr ""
1000
 
1001
+ #: admin/class-litespeed-cache-admin-display.php:1794
1002
+ #, php-format
1003
+ msgid ""
1004
+ "More information about the available commands can be found <a href=\"%s"
1005
+ "\">here</a>."
1006
  msgstr ""
1007
 
1008
+ #: admin/class-litespeed-cache-admin-display.php:1800
1009
  msgid "Outputs to WordPress debug log."
1010
  msgstr ""
1011
 
1012
+ #: admin/class-litespeed-cache-admin-display.php:1801
1013
  msgid ""
1014
  "This should be set to off once everything is working to prevent filling the "
1015
  "disk."
1016
  msgstr ""
1017
 
1018
+ #: admin/class-litespeed-cache-admin-display.php:1802
1019
  msgid ""
1020
  "The Admin IP option will only output log messages on requests from admin IPs."
1021
  msgstr ""
1022
 
1023
+ #: admin/class-litespeed-cache-admin-display.php:1803
1024
+ msgid ""
1025
+ "The logs will be outputted to the debug.log in the wp-content directory."
1026
  msgstr ""
1027
 
1028
+ #: admin/class-litespeed-cache-admin-display.php:1810
1029
  msgid "Admin IPs"
1030
  msgstr ""
1031
 
1032
+ #: admin/class-litespeed-cache-admin-display.php:1817
1033
+ msgid "Off"
 
 
1034
  msgstr ""
1035
 
1036
+ #: admin/class-litespeed-cache-admin-display.php:1818
1037
+ msgid "On"
 
 
1038
  msgstr ""
1039
 
1040
+ #: admin/class-litespeed-cache-admin-display.php:1819
1041
+ msgid "Admin IP only"
1042
  msgstr ""
1043
 
1044
+ #: admin/class-litespeed-cache-admin-display.php:1823
1045
+ msgid "Debug Log"
1046
  msgstr ""
1047
 
1048
+ #: admin/class-litespeed-cache-admin-display.php:1872
1049
+ msgid "When checked, mobile views will be cached separately."
1050
  msgstr ""
1051