All pastes #804439 Raw Edit

filetype output

public php v1 · immutable
·published 2007-12-03 14:10 UTC
rendered paste body
<?php// fileinfo$title = "myFileTester v0.1";echo "<html>\n";echo "<head>\n<title>$title</title>\n</head>";echo "<body>\n";if ($_GET['name']) {	$file = $_POST['name'];	$filehandleinfo = finfo_open(FILEINFO_MIME);	$fileinfo = chop(finfo_file($filehandleinfo, $file));	if (preg_match("/^text\/.*/i", $fileinfo)) {		// печатаем текст...		$filecontents = file($file);		if ($fileinfo = "text/html") {			foreach ($filecontents as $line) {				echo htmlspecialchars($line) . "\n";			}		} else {			echo "<pre>\n"			foreach ($filecontents as $line) {				echo $line . "\n";			}			echo "</pre>\n"		}	} elseif (preg_match("/^image\/.*/i", $fileinfo)) {		// показываем картинку...	} else {		// выводим hex...	}}$space = "  ";echo "$space<form id=\"file_main\" name=\"file\" method=\"POST\">\n";echo "<input id=\"file_name\" name=\"name\" type=\"text\" width=\"30\">\n";echo "<input id=\"ok\" name=\"okbtn\" type=\"submit\" width=\"30\">\n";echo "$space</form>\n";echo "</body>\n";echo "</html>\n";?>