ANTICHAT

ANTICHAT (https://forum.antichat.io/index.php)
-   PHP (https://forum.antichat.io/forumdisplay.php?f=37)
-   -   Трабла с дешифровкой (https://forum.antichat.io/showthread.php?t=127508)

sNt 29.06.2009 20:08

Трабла с дешифровкой
 
Есть шифровщик символов. Но, дешифровщик выдает пустую страницу, если скормить ему <[любой символ]>. Помогите, пожалуйста.

Кодировщик символов:

PHP код:

<?php

if($_POST['string']) {

$str=preg_replace("/q/i", "%11", $_POST['string']);
$str=preg_replace("/w/i", "%12", $str);
$str=preg_replace("/e/i", "%13", $str);
$str=preg_replace("/r/i", "%14", $str);
$str=preg_replace("/t/i", "%15", $str);
$str=preg_replace("/y/i", "%16", $str);
$str=preg_replace("/u/i", "%17", $str);
$str=preg_replace("/i/i", "%18", $str);
$str=preg_replace("/o/i", "%19", $str);
$str=preg_replace("/p/i", "%20", $str);
$str=preg_replace("/a/i", "%21", $str);
$str=preg_replace("/s/i", "%22", $str);
$str=preg_replace("/d/i", "%23", $str);
$str=preg_replace("/f/i", "%24", $str);
$str=preg_replace("/g/i", "%25", $str);
$str=preg_replace("/h/i", "%26", $str);
$str=preg_replace("/j/i", "%27", $str);
$str=preg_replace("/k/i", "%28", $str);
$str=preg_replace("/l/i", "%29", $str);
$str=preg_replace("/z/i", "%30", $str);
$str=preg_replace("/x/i", "%31", $str);
$str=preg_replace("/c/i", "%32", $str);
$str=preg_replace("/v/i", "%33", $str);
$str=preg_replace("/b/i", "%34", $str);
$str=preg_replace("/n/i", "%35", $str);
$str=preg_replace("/m/i", "%36", $str);
$str=preg_replace("/,/i", "%37", $str);
$str=preg_replace("/'/i", "%38", $str);
$str=str_replace('"', "%39", $str);
$str=str_replace("/", "%40", $str);
$str=str_replace(".", "%41", $str);
$str=str_replace(";", "%42", $str);
$str=str_replace(":", "%43", $str);
$str=str_replace("<", "%44", $str);
$str=str_replace(">", "%45", $str);
$str=str_replace("\%", "%", $str);

echo 
$str;

} else {
echo 
"<form action='index.php' method='POST'>";
echo 
"<tr><td align='right'>Строка: </td><td><input type='text' name='string' size=20></td></tr>";
echo 
"<tr><td></td><td><input type='submit' value='Обработать'></td></tr>";
}

?>

Дешифровщик:

PHP код:

<?php

if($_POST['string']) {

$str=preg_replace("/%11/i", "q", $_POST['string']);
$str=preg_replace("/%12/i", "w", $str);
$str=preg_replace("/%13/i", "e", $str);
$str=preg_replace("/%14/i", "r", $str);
$str=preg_replace("/%15/i", "t", $str);
$str=preg_replace("/%16/i", "y", $str);
$str=preg_replace("/%17/i", "u", $str);
$str=preg_replace("/%18/i", "i", $str);
$str=preg_replace("/%19/i", "o", $str);
$str=preg_replace("/%20/i", "p", $str);
$str=preg_replace("/%21/i", "a", $str);
$str=preg_replace("/%22/i", "s", $str);
$str=preg_replace("/%23/i", "d", $str);
$str=preg_replace("/%24/i", "f", $str);
$str=preg_replace("/%25/i", "g", $str);
$str=preg_replace("/%26/i", "h", $str);
$str=preg_replace("/%27/i", "j", $str);
$str=preg_replace("/%28/i", "k", $str);
$str=preg_replace("/%29/i", "l", $str);
$str=preg_replace("/%30/i", "z", $str);
$str=preg_replace("/%31/i", "x", $str);
$str=preg_replace("/%32/i", "c", $str);
$str=preg_replace("/%33/i", "v", $str);
$str=preg_replace("/%34/i", "b", $str);
$str=preg_replace("/%35/i", "n", $str);
$str=preg_replace("/%36/i", "m", $str);
$str=preg_replace("/%37/i", ",", $str);
$str=preg_replace("/%38/i", "'", $str);
$str=str_replace("%39", '"', $str);
$str=str_replace("%40", "/", $str);
$str=str_replace("%41", ".", $str);
$str=str_replace("%42", ";", $str);
$str=str_replace("%43", ":", $str);
$str=preg_replace("/%44/i", "<", $str);
$str=preg_replace("/%45/i", ">", $str);

echo 
$str;

} else {
echo 
"<form action='test.php' method='POST'>";
echo 
"<tr><td align='right'>Строка для расшифровки: </td><td><input type='text' name='string' size=20></td></tr>";
echo 
"<tr><td></td><td><input type='submit' value='Обработать'></td></tr>";
}

?>


Pashkela 29.06.2009 21:07

PHP код:

<?php

$submit 
= $_POST['submit'];
$string = $_POST['string'];


if(isset(
$submit) && !empty($string)) { 

     
$str=str_replace("%11", "q", $string); 
     
$str=str_replace("%12", "w", $str); 
     
$str=str_replace("%13", "e", $str); 
     
$str=str_replace("%14", "r", $str); 
     
$str=str_replace("%15", "t", $str); 
     
$str=str_replace("%16", "y", $str); 
     
$str=str_replace("%17", "u", $str); 
     
$str=str_replace("%18", "i", $str); 
     
$str=str_replace("%19", "o", $str); 
     
$str=str_replace("%20", "p", $str); 
     
$str=str_replace("%21", "a", $str); 
     
$str=str_replace("%22", "s", $str); 
     
$str=str_replace("%23", "d", $str); 
     
$str=str_replace("%24", "f", $str); 
     
$str=str_replace("%25", "g", $str); 
     
$str=str_replace("%26", "h", $str); 
     
$str=str_replace("%27", "j", $str); 
     
$str=str_replace("%28", "k", $str); 
     
$str=str_replace("%29", "l", $str); 
     
$str=str_replace("%30", "z", $str); 
     
$str=str_replace("%31", "x", $str); 
     
$str=str_replace("%32", "c", $str); 
     
$str=str_replace("%33", "v", $str); 
     
$str=str_replace("%34", "b", $str); 
     
$str=str_replace("%35", "n", $str); 
     
$str=str_replace("%36", "m", $str); 
     
$str=str_replace("%37", ",", $str); 
     
$str=str_replace("%38", "'", $str); 
     
$str=str_replace("%39", '"', $str); 
     
$str=str_replace("%40", "/", $str); 
     
$str=str_replace("%41", ".", $str); 
     
$str=str_replace("%42", ";", $str); 
     
$str=str_replace("%43", ":", $str); 
     
$str=str_replace("%44", "<", $str); 
     
$str=str_replace("%45", ">", $str); 

  echo 
$str; 

} else { 
    echo 
"<form method='POST'>"; 
    echo 
"<tr><td align='right'>String: </td><td><input type='text' name='string' size=20></td></tr>"; 
    echo 
"<tr><td></td><td><input type='submit' name = 'submit' value='Go'></td></tr></form>"; 
} 
 
?>

Изменения не только в str_replace, смотри весь код

ЗЫЖ А вообще ппц, конечно:)

sNt 29.06.2009 21:15

Хм, у меня ничего не изменилось. Он, короче, в теги преобразует <blabla>. И как его заставить мыслить иначе - я не знаю...

Pashkela 29.06.2009 21:19

Дык если в Опере тестил только что - потесть в мозиле, или в IE:)))) КЭШ

sNt 29.06.2009 21:29

Все пашет, спс ))


Время: 06:53