PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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?>
 11<html>
 12<body>
 13
 14<?php
 15  # No need for the template engine
 16  define( 'WP_USE_THEMES', false );
 17
 18  #find the base path
 19  define( 'BASE_PATH', find_wordpress_base_path()."/" );
 20
 21  # Load WordPress Core
 22  require_once( BASE_PATH.'wp-load.php' );
 23  require_once(ABSPATH.'wp-admin/includes/plugin.php');
 24  $core_plugin = 'really-simple-ssl/rlrsssl-really-simple-ssl.php';
 25
 26  if (!is_plugin_active($core_plugin) ) {
 27    echo "<h1>Really Simple SSL is already deactivated!</h1>";
 28    exit;
 29  }
 30
 31  #Load plugin functionality
 32  require_once( dirname( __FILE__ ) .  '/class-front-end.php' );
 33  require_once( dirname( __FILE__ ) .  '/class-admin.php' );
 34
 35  $really_simple_ssl = new rsssl_admin();
 36   if (is_multisite()) {
 37     require_once( dirname( __FILE__ ) .  '/class-multisite.php' );
 38     $rsssl_multisite = new rsssl_multisite();
 39   }
 40
 41   $step = 1;
 42   echo "<h1>Force deactivation of Really Simple SSL</h1>";
 43   echo $step.". Resetting options"."<br>";
 44   $networkwide = is_multisite();
 45   $really_simple_ssl->deactivate($networkwide);
 46   $step++;
 47
 48   //add feedback on writable files.
 49   if (count($really_simple_ssl->errors)>0) {
 50     echo $step.". Errors occured while deactivating:<ul>";
 51    $step++;
 52     foreach($really_simple_ssl->errors as $errorname=>$error) {
 53       echo "<li>".$errorname."</li>";
 54     }
 55     echo "</ul>";
 56     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>";
 57   }
 58
 59   echo $step.". Deactivating plugin"."<br>";
 60   rl_deactivate_plugin($really_simple_ssl->plugin_dir."/".$really_simple_ssl->plugin_filename);
 61
 62   $step++;
 63   echo $step.". Completed with <b>".count($really_simple_ssl->errors)."</b> error(s)"."<br>";
 64
 65
 66
 67
 68function rl_remove_plugin_from_array($plugin, $current) {
 69  $key = array_search( $plugin, $current );
 70  if ( false !== $key ) {
 71    $do_blog = true;
 72    unset( $current[ $key ] );
 73  }
 74  return $current;
 75}
 76
 77function rl_deactivate_plugin( $plugin ) {
 78  $plugin = plugin_basename( trim( $plugin ) );
 79
 80	if ( is_multisite() ) {
 81
 82		$network_current = get_site_option( 'active_sitewide_plugins', array() );
 83    if ( is_plugin_active_for_network( $plugin ) ) { unset( $network_current[ $plugin ] );}
 84    update_site_option( 'active_sitewide_plugins', $network_current );
 85
 86    //remove plugin one by one on each site
 87    $sites = wp_get_sites();
 88    foreach ( $sites as $site ) {
 89        switch_to_blog( $site[ 'blog_id' ] );
 90
 91        $current = get_option( 'active_plugins', array() );
 92        $current = rl_remove_plugin_from_array($plugin, $current);
 93        update_option('active_plugins', $current);
 94
 95        restore_current_blog(); //switches back to previous blog, not current, so we have to do it each loop
 96      }
 97
 98} else {
 99  $current = get_option( 'active_plugins', array() );
100  $current = rl_remove_plugin_from_array($plugin, $current);
101  update_option('active_plugins', $current);
102}
103
104
105
106
107
108
109
110
111
112	update_option('active_plugins', $current);
113
114
115
116}
117
118function find_wordpress_base_path() {
119  $dir = dirname(__FILE__);
120  do {
121      //it is possible to check for other files here
122      if( file_exists($dir."/wp-config.php") ) {
123          return $dir;
124      }
125  } while( $dir = realpath("$dir/..") );
126  return null;
127}
128
129?>
130</body>
131</html>