public static function wfFunc_view() { $localFile = ABSPATH . preg_replace('/^(?:\\.\\.|[\\/]+)/', '', sanitize_text_field($_GET['file'])); if (strpos($localFile, '..') !== false) { echo "Invalid file requested. (Relative paths not allowed)"; exit; } if (preg_match('/[\'\\"<>\\!\\{\\}\\(\\)\\&\\@\\%\\$\\*\\+\\[\\]\\?]+/', $localFile)) { echo "File contains illegal characters."; exit; } $cont = @file_get_contents($localFile); $isEmpty = false; if (!$cont) { if (file_exists($localFile) && filesize($localFile) === 0) { //There's a remote possibility that very large files on 32 bit systems will return 0 here, but it's about 1 in 2 billion $isEmpty = true; } else { $err = error_get_last(); echo "We could not open the requested file for reading. The error was: " . $err['message']; exit(0); } } $fileMTime = @filemtime($localFile); $fileMTime = date('l jS \\of F Y h:i:s A', $fileMTime); try { if (wfUtils::fileOver2Gigs($localFile)) { $fileSize = "Greater than 2 Gigs"; } else { $fileSize = @filesize($localFile); //Checked if over 2 gigs above $fileSize = number_format($fileSize, 0, '', ',') . ' bytes'; } } catch (Exception $e) { $fileSize = 'Unknown file size.'; } require 'wfViewResult.php'; exit(0); }
public static function wfFunc_view() { $localFile = ABSPATH . '/' . preg_replace('/^(?:\\.\\.|[\\/]+)/', '', $_GET['file']); if (strpos($localFile, '..') !== false) { echo "Invalid file requested. (Relative paths not allowed)"; exit; } $lang = false; $cont = @file_get_contents($localFile); $isEmpty = false; if (!$cont) { if (file_exists($localFile) && filesize($localFile) === 0) { //There's a remote possibility that very large files on 32 bit systems will return 0 here, but it's about 1 in 2 billion $isEmpty = true; } else { $err = error_get_last(); echo "We could not open the requested file for reading. The error was: " . $err['message']; exit(0); } } $fileMTime = @filemtime($localFile); $fileMTime = date('l jS \\of F Y h:i:s A', $fileMTime); if (wfUtils::fileOver2Gigs($localFile)) { $fileSize = "Greater than 2 Gigs"; } else { $fileSize = @filesize($localFile); //Checked if over 2 gigs above $fileSize = number_format($fileSize, 0, '', ',') . ' bytes'; } require 'wfViewResult.php'; exit(0); }