<?php
/**
* @page encoder_decoder_url.php
* @brief Page d'encodage d'une URL
*
* @author hughes monget
* @see http://monget.com/
*/
$str_texte = '';
$str_code = '';
if (isset($_REQUEST['texte']) && is_string($_REQUEST['texte']) && strlen($_REQUEST['texte'])
&& isset($_REQUEST['bouton']) && is_string($_REQUEST['bouton']))
{
$str_texte = $_REQUEST['texte'];
if (get_magic_quotes_gpc())
{
$str_texte = stripslashes($str_texte);
}
switch ($_REQUEST['bouton'])
{
case 'Encoder':
$str_code = urlencode($str_texte);
break;
case 'Décoder':
$str_code = urldecode($str_texte);
break;
default: break;
}
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Encoder ou décoder des URL</title>
<style type="text/css">
<!--
body *
{
font-family: monospace;
font-size: 8pt;
}
input.texte
{
width: 600px;
}
form
{
margin: 0;
}
div
{
margin: 0 0 5px 0;
}
-->
</style>
<script type="text/javascript">
<!--;
function on_load()
{
if (document && document.getElementById)
{
var obj_input = document.getElementById('texte');
if (obj_input && obj_input.focus)
{
obj_input.focus();
}
}
}
//-->
</script>
</head>
<body onload="on_load();">
<form method="post" action="">
<div>
<input id="texte" name="texte" class="texte" value="<?php echo htmlspecialchars($str_texte, ENT_QUOTES); ?>" />
</div>
<div>
<input type="submit" class="submit" name="bouton" value="Encoder" />
<input type="submit" class="submit" name="bouton" value="Décoder" />
</div>
</form>
<?php
if ($str_code)
{
echo '<div><input type="text" class="texte" value="' ,htmlspecialchars($str_code, ENT_QUOTES),'" /></div>';
}
echo '<hr />';
highlight_file(__FILE__);
?>
</body>
</html>