$v){ $_POST[$k] = stripslashes($v); } ini_set('magic_quotes_gpc', 0); } set_magic_quotes_runtime(0); $_POST['enc'] = (isset($_POST['enc']) and preg_match('`^[-\w]+$`', $_POST['enc'])) ? $_POST['enc'] : 'utf-8'; // token for anti-CSRF if(count($_POST)){ if((empty($_GET['pre']) and ((!empty($_POST['token']) and !empty($_SESSION['token']) and $_POST['token'] != $_SESSION['token']) or empty($_POST[$_sid]) or $_POST[$_sid] != session_id() or empty($_COOKIE[$_sid]) or $_COOKIE[$_sid] != session_id())) or ($_POST[$_sid] != session_id())){ $_POST = array('enc'=>'utf-8'); } } if(empty($_GET['pre'])){ $_SESSION['token'] = md5(uniqid(rand(), 1)); $token = $_SESSION['token']; session_regenerate_id(1); } // compress if(function_exists('gzencode') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('`gzip|deflate`i', $_SERVER['HTTP_ACCEPT_ENCODING']) && !ini_get('zlib.output_compression')){ ob_start('ob_gzhandler'); } // HTM for unprocessed if(isset($_POST['inputH'])){ echo '
Rendering of unprocessed input without an HTML doctype or charset declaration close window | htmLawed test page
';
$offset = 0;
$len = strlen($d);
for($i=$j=0; $i<$len; $i++)
{
// Convert to hexidecimal
$hexi .= sprintf("%02X ", ord($d[$i]));
// Replace non-viewable bytes with '.'
if(ord($d[$i]) >= 32){
$ascii .= htmlspecialchars($d[$i]);
}else{
$ascii .= '.';
}
// Add extra column spacing
if($j == 7){
$hexi .= ' ';
$ascii .= ' ';
}
// Add row
if(++$j == 16 || $i == $len-1){
// Join the hexi / ascii output
echo sprintf("%04X %-49s %s", $offset, $hexi, $ascii);
// Reset vars
$hexi = $ascii = '';
$offset += 16;
$j = 0;
// Add newline
if ($i !== $len-1){
echo "\n";
}
}
}
echo '';
$o = ob_get_contents();
ob_end_clean();
return $o;
}
?>