<?php
/*****************************************************************************
    * script.
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA,
 * or go to http://www.gnu.org/copyleft/gpl.html
 *
 * By Robert Sebille, 2004 - robert.sebille(at)cassiopea(dot)org
 *****************************************************************************/
 
?>
 
<h2>URL Encoder / Decoder</h2>

<form action="<?php echo $_SERVER['PHP_SELF'?>" method="POST">
<textarea name="texte" rows="15" cols="100"><?php echo $_POST["texte"?></textarea><br /> <br />
<input name="encode" value="Encoder URL" type="submit" />
<input name="decode" value="Decoder URL" type="submit" />
</form>

<hr />

<?php

$array_texte 
explode ('\n'$_POST["texte"]);
$i 0;
  
if (isset(
$_POST["decode"])) {
    echo 
"<h2>URL Decode</h2>";
    while (
$i count ($array_texte)) {
        echo 
htmlspecialchars(urldecode($array_texte[$i])), "<br  />\n";
        
$i++;
        }
    }

if (isset(
$_POST["encode"])) {
    echo 
"<h2>URL Encode</h2>";
    while (
$i count ($array_texte)) {
        echo 
htmlentities(urlencode($array_texte[$i])), "<br  />\n";
        
$i++;
        }
    }
    
?>