Giorno, ho un problema con questo script, questo è l'originale:
Codice PHP:
<?php
    
/*
        -------------------------------------------------------------------
        NFO Viewer v1.1 by Richard Davey, Core PHP (rich@corephp.co.uk)

        Released 3rd May 2007
        Updated 5th January 2008

        Includes base font from the Damn NFO Viewer
        -------------------------------------------------------------------
        You are free to use this in any product, or on any web site.
        I'd appreciate it if you email and tell me where you use it, thanks.
        Latest builds at: [url]http://nfo.corephp.co.uk[/url]
        -------------------------------------------------------------------
        
        This script accepts the following $_REQUEST parameters:
        
        bg              optional        The background colour of the image (default black)
        filename        required        The NFO file to load and display
        colour          required        The font to use when rendering
    */

    //  This should be set to the top level directory where the NFO files exist.
    //  For example if the NFO files live in: /usr/corephp/www/nfo
    //  then that is what baredir should point to.
    
$basedir '';

    
//    PHP Version sanity check // AGGIUNTO
    
if (version_compare('4.0.6'phpversion()) == 1)
    {
        echo 
'This version of PHP is not fully supported. You need 4.0.6 or above.';
        exit();
    }

    
//    GD check
    
if (extension_loaded('gd') == false && !dl('gd.so'))
    {
        echo 
'You are missing the GD extension for PHP, sorry but I cannot continue.';
        exit();
    }

    
//    bgc (the background colour used, defaults to black if not given)
    
if (isset($_REQUEST['bg']) == false)
    {
        
$red 0;
        
$green 0;
        
$blue 0;
    }
    else
    {
        
//    Extract the hex colour
        
$hex_bgc $_REQUEST['bg'];
        
        
//    Does it start with a hash? If so then strip it
        
$hex_bgc str_replace('#'''$hex_bgc);
        
        switch (
strlen($hex_bgc))
        {
            case 
6:
                
$red hexdec(substr($hex_bgc02));
                
$green hexdec(substr($hex_bgc22));
                
$blue hexdec(substr($hex_bgc42));
                break;
                
            case 
3:
                
$red substr($hex_bgc01);
                
$green substr($hex_bgc11);
                
$blue substr($hex_bgc21);
                
$red hexdec($red $red);
                
$green hexdec($green $green);
                
$blue hexdec($blue $blue);
                break;
                
            default:
                
//    Wrong values passed, default to black
                
$red 0;
                
$green 0;
                
$blue 0;
        }
    }
    
    if (isset(
$_REQUEST['nfo']))
    {
        
$filename $_REQUEST['nfo'];
        
$filename str_replace('..'''$filename);
    }
    else
    {
        echo 
"Aborting, no nfo parameter given.";
        exit();
    }

    if (isset(
$_REQUEST['colour']))
    {
        
$colour = (int) $_REQUEST['colour'];
        
$colour abs($colour);
    }
    else
    {
        
$colour 0;
    }
    
    if (
file_exists("nfo/$filename"))
    {
        
$nfo file("nfo/$filename");
    }
    else
    {
        echo 
"Aborting, cannot find or read from $basedir/$filename - is the path correct?";
        exit();
    }
    
    
$fontpath dirname(__FILE__);
    
    if (
file_exists("$fontpath/nfogen.png"))
    {
        
$fontset imagecreatefrompng("$fontpath/nfogen.png");
    }
    else
    {
        echo 
"Aborting, cannot find the required fontset nfogen.png in path: $fontpath";
        exit();
    }

    
$x 0;
    
$y 0;
    
$fontx 5;
    
$fonty 12;
    
$colour $colour $fonty;
    
    
//    Calculate max width and height of image needed - height is easy, do first:
    
$image_height count($nfo) * 12;
    
$image_width 0;

    
//    Width needs a loop through the text
    
for ($c 0$c count($nfo); $c++)
    {
        
$line $nfo[$c];
        
$temp_len strlen($line);
        if (
$temp_len $image_width)
        {
            
$image_width $temp_len;
        }
    }

    
$image_width $image_width $fontx;
    
    
//    Sanity Checks
    
if ($image_width 1600)
    {
        
$image_width 1600;
    }

    
$im imagecreatetruecolor($image_width$image_height);
    
$bgc imagecolorallocate($im$red$green$blue);
    
imagefill($im00$bgc);
    
    for (
$c 0$c count($nfo); $c++)
    {
        
$x $fontx;
        
$line $nfo[$c];

        for (
$i 0$i strlen($line); $i++)
        {
            
$current_char substr($line$i1);
            if (
$current_char !== "\r" && $current_char !== "\n")
            {
                
$offset ord($current_char) * 5;
                
imagecopy($im$fontset$x$y$offset$colour$fontx$fonty);
                
$x += $fontx;
            }
        }

        
$y += $fonty;
    }

    
header("Content-type: image/png");
    
imagepng($im);
    
imagedestroy($im);
?>
Tramite un form si può scegliere un file NFO caricato su server per trasformarlo in immagine, volevo aggiungere uno pezzo che permetta di caricare un file NFO e che lo converta automaticamente in immagine, ma quando aggiungo, lo script non funziona più..
Se potete darmi una mano e spiegare dove o sbagliato ve ne sarei grato

Codice PHP:
<?php
    
/*
        -------------------------------------------------------------------
        NFO Viewer v1.1 by Richard Davey, Core PHP (rich@corephp.co.uk)

        Released 3rd May 2007
        Updated 5th January 2008

        Includes base font from the Damn NFO Viewer
        -------------------------------------------------------------------
        You are free to use this in any product, or on any web site.
        I'd appreciate it if you email and tell me where you use it, thanks.
        Latest builds at: [url]http://nfo.corephp.co.uk[/url]
        -------------------------------------------------------------------
        
        This script accepts the following $_REQUEST parameters:
        
        bg              optional        The background colour of the image (default black)
        filename        required        The NFO file to load and display
        colour          required        The font to use when rendering
    */

    //  This should be set to the top level directory where the NFO files exist.
    //  For example if the NFO files live in: /usr/corephp/www/nfo
    //  then that is what baredir should point to.
    
$basedir '';
    
$target "nfo/";
    
$target $target basename$_FILES['uploaded']['name']) ;
    
$ok=1;

    
    if(
move_uploaded_file($_FILES['nfo']['tmp_name'], $target))
    {
    echo 
"The file "basename$_FILES['uploadedfile']['name']). " has been uploaded";
    }
    else {
    echo 
"Sorry, there was a problem uploading your file.";
    }

    
//    PHP Version sanity check // AGGIUNTO
    
if (version_compare('4.0.6'phpversion()) == 1)
    {
        echo 
'This version of PHP is not fully supported. You need 4.0.6 or above.';
        exit();
    }

    
//    GD check
    
if (extension_loaded('gd') == false && !dl('gd.so'))
    {
        echo 
'You are missing the GD extension for PHP, sorry but I cannot continue.';
        exit();
    }

    
//    bgc (the background colour used, defaults to black if not given)
    
if (isset($_REQUEST['bg']) == false)
    {
        
$red 0;
        
$green 0;
        
$blue 0;
    }
    else
    {
        
//    Extract the hex colour
        
$hex_bgc $_REQUEST['bg'];
        
        
//    Does it start with a hash? If so then strip it
        
$hex_bgc str_replace('#'''$hex_bgc);
        
        switch (
strlen($hex_bgc))
        {
            case 
6:
                
$red hexdec(substr($hex_bgc02));
                
$green hexdec(substr($hex_bgc22));
                
$blue hexdec(substr($hex_bgc42));
                break;
                
            case 
3:
                
$red substr($hex_bgc01);
                
$green substr($hex_bgc11);
                
$blue substr($hex_bgc21);
                
$red hexdec($red $red);
                
$green hexdec($green $green);
                
$blue hexdec($blue $blue);
                break;
                
            default:
                
//    Wrong values passed, default to black
                
$red 0;
                
$green 0;
                
$blue 0;
        }
    }
    
    if (isset(
$_REQUEST['nfo']))
    {
        
$filename $_REQUEST['nfo'];
        
$filename str_replace('..'''$filename);
    }
    else
    {
        echo 
"Aborting, no nfo parameter given.";
        exit();
    }

    if (isset(
$_REQUEST['colour']))
    {
        
$colour = (int) $_REQUEST['colour'];
        
$colour abs($colour);
    }
    else
    {
        
$colour 0;
    }
    
    if (
file_exists("nfo/$filename"))
    {
        
$nfo file("nfo/$filename");
    }
    else
    {
        echo 
"Aborting, cannot find or read from $basedir/$filename - is the path correct?";
        exit();
    }
    
    
$fontpath dirname(__FILE__);
    
    if (
file_exists("$fontpath/nfogen.png"))
    {
        
$fontset imagecreatefrompng("$fontpath/nfogen.png");
    }
    else
    {
        echo 
"Aborting, cannot find the required fontset nfogen.png in path: $fontpath";
        exit();
    }

    
$x 0;
    
$y 0;
    
$fontx 5;
    
$fonty 12;
    
$colour $colour $fonty;
    
    
//    Calculate max width and height of image needed - height is easy, do first:
    
$image_height count($nfo) * 12;
    
$image_width 0;

    
//    Width needs a loop through the text
    
for ($c 0$c count($nfo); $c++)
    {
        
$line $nfo[$c];
        
$temp_len strlen($line);
        if (
$temp_len $image_width)
        {
            
$image_width $temp_len;
        }
    }

    
$image_width $image_width $fontx;
    
    
//    Sanity Checks
    
if ($image_width 1600)
    {
        
$image_width 1600;
    }

    
$im imagecreatetruecolor($image_width$image_height);
    
$bgc imagecolorallocate($im$red$green$blue);
    
imagefill($im00$bgc);
    
    for (
$c 0$c count($nfo); $c++)
    {
        
$x $fontx;
        
$line $nfo[$c];

        for (
$i 0$i strlen($line); $i++)
        {
            
$current_char substr($line$i1);
            if (
$current_char !== "\r" && $current_char !== "\n")
            {
                
$offset ord($current_char) * 5;
                
imagecopy($im$fontset$x$y$offset$colour$fontx$fonty);
                
$x += $fontx;
            }
        }

        
$y += $fonty;
    }

    
header("Content-type: image/png");
    
imagepng($im);
    
imagedestroy($im);
?>