mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. 
	
	Scuh a cdonition is arppoiatrely cllaed Typoglycemia.
/**/
$html = '';
$pa = isset($_POST['pa']) ? $_POST['pa'] : '';
$in_text = isset($_POST['in_text']) ? $_POST['in_text'] : '';
$out_paragraph = '';
switch (strtolower($pa)) {
    case 'process':
        $paragraphs = explode("\n", $in_text);
        foreach ($paragraphs as $paragraph) {
            $words = explode(' ', trim($paragraph));
            $out_words = '';
            foreach ($words as $word) {
                $out_words .= scramble($word) . ' ';
            }
            //END FOREACH
            $out_paragraph .= $out_words . " \n";
        }
        //END FOREACH
        $html .= '' . '<textarea cols="70" rows="20">' . $out_paragraph . '</textarea>' . '';
    default:
        $html = '' . '<form method="post">' . '<textarea cols="70" rows="20" name="in_text">' . $in_text . '</textarea> ' . '<textarea cols="70" rows="20">' . $out_paragraph . '</textarea>' . '<br /><input type="hidden" name="pa" value="process" />' . '<input type="submit" />' . '</form>' . '';
        break;
}
//END SWITCH
echo '<html><head><title>Typoglycemia</title></head><body>' . $html . '</body></html>';
function scramble($word)
{
    if (strlen($word) < 4) {
Ejemplo n.º 2
0
if ($upfile_type != "image/jpeg") {
    die("The image does not seem to be JPEG but of type '{$upfile_type}', please go back and select a JPEG image to upload.");
}
// load the file and get its size
$content = file_get_contents($upfile);
$size = $upfile_size;
// now store the original one
$fd = fopen("images/{$upfile_name}", "w") or die("The first fopen went wrong, e-mail webmaster Ben.");
fwrite($fd, $content, $size) or die("The first fwrite went wrong, e-mail webmaster Ben.");
fclose($fd);
// check the copied image
if (!imageCreateFromJPEG("images/{$upfile_name}")) {
    die("This JPEG is not valid, please go back and try another one.");
}
// create a folder to store the corrupted versions
@mkdir("images/{$upfile_name}-corrupted");
// corrupt it a few times
for ($c = 0, $r = 0; $c < $nCorrupts && $r < $nRetries; $r++) {
    // corrupt the file
    $corrupted = scramble($content, $size);
    // save it to disc
    $fd = fopen("images/{$upfile_name}-corrupted/{$c}.jpg", "w") or die("The fopen went wrong, e-mail webmaster Ben.");
    fwrite($fd, $corrupted, $size) or die("The fwrite went wrong, e-mail webmaster Ben.");
    fclose($fd);
    // count succeeded corrupts
    if (jpegIsValid("images/{$upfile_name}-corrupted/{$c}.jpg")) {
        $c++;
    }
}
// jippie! we're done! now go to the list of images...
Header("Location: index.php");