// htmlentities()
set_magic_quotes_runtime(0);
$input = stripslashes($_GET['input']);
//$input = file_get_contents("/home/hendry/kai.txt");
$regex = stripslashes($_GET['regex']);
echo(htmlspecialchars($input));
printf("\nmd5: %s\nWord count: %d\n", md5($input), str_word_count($input));
echo("\nLiteral:\n");
// Don't understand this line:
$literal = addcslashes($input, "\0..\37!@\177..\377");
$literal = htmlspecialchars($literal);
?>
echo($regex);
printf("\nmd5: %s\n", md5($regex));
?>
// EREG POSIX
if(ereg($regex, $input)){
echo("ereg($regex, $literal)\nTrue\n");
}
else {
echo("ereg($regex, $literal)\nFalse\n");
}
// PREG_MATCH
echo("preg_match($regex, $literal, \$matches); \n");
preg_match($regex, $input, $matches);
if ($matches){
echo("\$matches:\n");
print_r($matches);
}
else
{
echo("NO \$matches\n");
}
// PREG_MATCH_ALL
echo("preg_match_all($regex, $literal, \$matches);\n");
preg_match_all($regex, $input, $matches);
if ($matches){
echo("\$matches:\n");
print_r($matches);
}
else
{
echo("NO \$matches\n");
}
// PREG_REPLACE
echo("\$output = preg_replace($regex, \"FOO\", $literal);\n");
$output = preg_replace($regex, "FOO", $input);
if ($output){
echo("\$output:\n");
print_r($output);
}
else
{
echo("NO \$output");
}
// STRSTR -- Find first occurrence of a string
echo("\n\$output = strstr($literal, $regex);\n");
$output = strstr($input, $regex);
if ($output){
echo("\$output:\n");
print_r($output);
}
else
{
echo("NO \$output");
}
// STRPOS
echo("\n\$output = strpos($literal, $regex);\n");
$output = strpos($input, $regex);
if ($output === false) {
echo("NO \$output\n");
}
else {
echo("\$output: ");
print_r($output);
}
?>
echo($_SERVER["SERVER_SOFTWARE"]); ?>