/wp-content/plugins/really-simple-ssl/force-deactivate.txt

https://bitbucket.org/carloskikea/helpet · Plain Text · 131 lines · 95 code · 36 blank · 0 comment · 0 complexity · e9f62cada26b5fad5f2193a4a950700f MD5 · raw file

  1. <?php
  2. /*
  3. * Deactivation page to simple deactivate the plugin when backend is not accessible anymore
  4. * To deactivate:
  5. * 1) rename this file to force-deactivate.php
  6. * 2) Go in your browser to www.yourdomain.com/wp-content/plugins/really-simple-ssl/force-deactivate.php.
  7. * 3) IMPORTANT!!!! Rename this file back to .txt
  8. */
  9. ?>
  10. <html>
  11. <body>
  12. <?php
  13. # No need for the template engine
  14. define( 'WP_USE_THEMES', false );
  15. #find the base path
  16. define( 'BASE_PATH', find_wordpress_base_path()."/" );
  17. # Load WordPress Core
  18. require_once( BASE_PATH.'wp-load.php' );
  19. require_once(ABSPATH.'wp-admin/includes/plugin.php');
  20. $core_plugin = 'really-simple-ssl/rlrsssl-really-simple-ssl.php';
  21. if (!is_plugin_active($core_plugin) ) {
  22. echo "<h1>Really Simple SSL is already deactivated!</h1>";
  23. exit;
  24. }
  25. #Load plugin functionality
  26. require_once( dirname( __FILE__ ) . '/class-front-end.php' );
  27. require_once( dirname( __FILE__ ) . '/class-admin.php' );
  28. $really_simple_ssl = new rsssl_admin();
  29. if (is_multisite()) {
  30. require_once( dirname( __FILE__ ) . '/class-multisite.php' );
  31. $rsssl_multisite = new rsssl_multisite();
  32. }
  33. $step = 1;
  34. echo "<h1>Force deactivation of Really Simple SSL</h1>";
  35. echo $step.". Resetting options"."<br>";
  36. $networkwide = is_multisite();
  37. $really_simple_ssl->deactivate($networkwide);
  38. $step++;
  39. //add feedback on writable files.
  40. if (count($really_simple_ssl->errors)>0) {
  41. echo $step.". Errors occured while deactivating:<ul>";
  42. $step++;
  43. foreach($really_simple_ssl->errors as $errorname=>$error) {
  44. echo "<li>".$errorname."</li>";
  45. }
  46. echo "</ul>";
  47. echo "Errors while removing the Really Simple SSL lines from your wp-config.php and .htaccess files, which you can normally find in your webroot."."<br><br>";
  48. }
  49. echo $step.". Deactivating plugin"."<br>";
  50. rl_deactivate_plugin($really_simple_ssl->plugin_dir."/".$really_simple_ssl->plugin_filename);
  51. $step++;
  52. echo $step.". Completed with <b>".count($really_simple_ssl->errors)."</b> error(s)"."<br>";
  53. function rl_remove_plugin_from_array($plugin, $current) {
  54. $key = array_search( $plugin, $current );
  55. if ( false !== $key ) {
  56. $do_blog = true;
  57. unset( $current[ $key ] );
  58. }
  59. return $current;
  60. }
  61. function rl_deactivate_plugin( $plugin ) {
  62. $plugin = plugin_basename( trim( $plugin ) );
  63. if ( is_multisite() ) {
  64. $network_current = get_site_option( 'active_sitewide_plugins', array() );
  65. if ( is_plugin_active_for_network( $plugin ) ) { unset( $network_current[ $plugin ] );}
  66. update_site_option( 'active_sitewide_plugins', $network_current );
  67. //remove plugin one by one on each site
  68. $sites = wp_get_sites();
  69. foreach ( $sites as $site ) {
  70. switch_to_blog( $site[ 'blog_id' ] );
  71. $current = get_option( 'active_plugins', array() );
  72. $current = rl_remove_plugin_from_array($plugin, $current);
  73. update_option('active_plugins', $current);
  74. restore_current_blog(); //switches back to previous blog, not current, so we have to do it each loop
  75. }
  76. } else {
  77. $current = get_option( 'active_plugins', array() );
  78. $current = rl_remove_plugin_from_array($plugin, $current);
  79. update_option('active_plugins', $current);
  80. }
  81. update_option('active_plugins', $current);
  82. }
  83. function find_wordpress_base_path() {
  84. $dir = dirname(__FILE__);
  85. do {
  86. //it is possible to check for other files here
  87. if( file_exists($dir."/wp-config.php") ) {
  88. return $dir;
  89. }
  90. } while( $dir = realpath("$dir/..") );
  91. return null;
  92. }
  93. ?>
  94. </body>
  95. </html>