Salve,

Mi trovo davanti un problema incomprensibile, ho uno script per creare un captcha perfettamente funzionante se si trova sulla root del sito, ma non se lo metto in una cartella del sito.

Questo è lo script per generare il captcha:
Codice PHP:
function random_string($len)
{
   $string = "";
   $chars = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
               "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
               "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
               "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
               "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2",
               "3", "4", "5", "6", "7", "8", "9");
   for($i = 0; $i < $len; ++$i)
   {
      shuffle($chars);
      $string .= $chars[0];
   }
   
   return $string;
}


header("Content-type: image/png");
//header(”Content-type: image/png”);

$x = 200;
$y = 75;
$code = random_string(6);//substr($_GET['code'],0,9);
$space = $x / (strlen($code)+1);// Calcoliamo lo spazio che deve esserci tra un carattere e il successivo

$img = imagecreatetruecolor($x,$y);

$bg = imagecolorallocate($img,0,0,0);
$border = imagecolorallocate($img,0,0,0);
$colors[] = imagecolorallocate($img,128,64,192);
$colors[] = imagecolorallocate($img,216,147,54);
$colors[] = imagecolorallocate($img,108,192,64);

imagefilledrectangle($img,1,1,$x-2,$y-2,$bg);
imagerectangle($img,0,0,$x-1,$y-2,$border);

for ($i=0; $i< strlen($code); $i++)
{
$color = $colors[$i % count($colors)];
imagettftext($img,28+rand(0,8),-20+rand(0,40),($i+0.3)*$space,50+rand(0,10),$color,'xxx.otf',$code{$i});
}

for($i=0;$i<280;$i++)
{
$x1 = rand(3,$x-3);
$y1 = rand(3,$y-3);
$x2 = $x1-2-rand(0,8);
$y2 = $y1-2-rand(0,8);
imageline($img,$x1,$y1,$x2,$y2,$colors[rand(0,count($colors)-1)]);
}

?>
<?php imagepng($img); ?>
Poi il file che dovrebbe farlo vedere:
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Untitled Document</title>
</
head>

<
body>
[
img]1.php[/img]
</
body>
</
html
Se li sposto entrambe dalla root del sito in una delle cartelle del sito non funzionano più!!!

Qualcuno mi sa spiegare perché?