public static function fopen($file, $size = null)
{
if ((is_null($size) ? self::filesize($file) : $size) <= 2 * pow(1024, 3)) {
return fopen($file, 'r');
} elseif (PHP_OS != 'Linux') {
return self::set_error(new Exception('File size is greater than 2GB. This is only supported under Linux'));
} elseif (!is_readable($file)) {
return false;
} else {
return popen('cat ' . escapeshellarg(realpath($file)), 'r');
}
}