: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
public function getParam() {
public function setParam($param) {
class wfLiveTrafficQueryException extends Exception {
class wfErrorLogHandler {
public static function getErrorLogs($deepSearch = false) {
static $errorLogs = null;
if ($errorLogs === null) {
$searchPaths = array(ABSPATH, ABSPATH . 'wp-admin', ABSPATH . 'wp-content');
$homePath = wfUtils::getHomePath();
if (!in_array($homePath, $searchPaths)) {
$searchPaths[] = $homePath;
$errorLogPath = ini_get('error_log');
if (!empty($errorLogPath) && !in_array($errorLogPath, $searchPaths)) {
$searchPaths[] = $errorLogPath;
foreach ($searchPaths as $s) {
$errorLogs = array_merge($errorLogs, self::_scanForLogs($s, $deepSearch));
private static function _scanForLogs($path, $deepSearch = false) {
static $processedFolders = array(); //Protection for endless loops caused by symlinks
if (preg_match('#(?:^php_errorlog$|error_log(\-\d+)?$|\.log$)#i', $file)) {
return array($path => is_readable($path));
$path = untrailingslashit($path);
$contents = @scandir($path);
if (!is_array($contents)) {
$processedFolders[$path] = true;
foreach ($contents as $name) {
if ($name == '.' || $name == '..') { continue; }
$testPath = $path . DIRECTORY_SEPARATOR . $name;
if (!array_key_exists($testPath, $processedFolders)) {
if ((is_dir($testPath) && $deepSearch) || !is_dir($testPath)) {
$errorLogs = array_merge($errorLogs, self::_scanForLogs($testPath, $deepSearch));
public static function outputErrorLog($path) {
$errorLogs = self::getErrorLogs();
if (!isset($errorLogs[$path])) { //Only allow error logs we've identified
$template = get_404_template();
if ($template && file_exists($template)) {
$fh = @fopen($path, 'r');
echo "503 Service Unavailable";
$headersOutputted = false;
$data = fread($fh, 1 * 1024 * 1024); //read 1 megs max per chunk
if ($data === false) { //Handle the error where the file was reported readable but we can't actually read it
echo "503 Service Unavailable";
if (!$headersOutputted) {
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename="' . basename($path));
$headersOutputted = true;