Sto provando a sistemare un codice PHP per il guestbook! Qualcuno mi può dare una mano?

Vi metto qua sotto tutto il codice con le varie suddivisioni di file:

admin.php:
Codice PHP:
<?php

/***********************************************\
* Bc - GuestBook!
* Bc Scripts (C) 2004
* Boris Carollo - [email]bc.scripts@lycos.com[/email]
* [url]http://bcscripts.zapto.org[/url]
\***********************************************/

// Includo le variabili importanti
include ("config.php");
include (
"vars.php");

// Conto i messaggi, un "</tr>" vale un messaggio
$cont implode ("",file($file));
$gets substr_count ($cont,"</tr>");

if (
$ssid == "") {
    
// Costruisco il codice HTML
    
echo ("
    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
    <html>
    <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />
    <title>
$site (Bc - GuestBook $vers)</title>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"
$dcss\" />
    </head>
    <body>
    
    

    <div align=\"center\">
    <form method=\"post\" action=\"admin.php?ssid=login\">
    <table cellspacing=\"1\" cellpadding=\"4\">
    <tr>
    <td class=\"bottd\" width=\"600\" colspan=\"2\">
    <div align=\"center\">
    [b]Login![/b]
    
 

    <input type=\"password\" name=\"pass\" size=\"30\" maxlength=\"15\">
    
 

    <input type=\"submit\" name=\"send\" value=\"invia\"> <input type=\"reset\" value=\"reset\">
    </div>
    </td>
    </tr>
    </table>
    </form>
    </div>
    

    
    </body>
    </html>
    "
);
}
elseif (
$ssid == "login") {
    if ((
$pass != $pwrd) || ($send == FALSE)) {
        echo (
"
        <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
        <html>
        <head>
        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />
        <title>
$site (Bc - GuestBook $vers)</title>
        <link rel=\"stylesheet\" type=\"text/css\" href=\"
$dcss\" />
        </head>
        <body>
        
        

        <div align=\"center\">
        <table cellspacing=\"1\" cellpadding=\"4\">
        <tr>
        <td class=\"bottd\" width=\"600\">
        <div align=\"center\">
        La password specificata &egrave; errata.
        
 

        <a href=\"javascript:history.back(-1)\">Indietro</a>
        </div>
        </td>
        </tr>
        </table>
        </div>
        

        
        </body>
        </html>
        "
);
    }
    else {
        echo (
"
        <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
        <html>
        <head>
        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />
        <meta http-equiv=\"Refresh\" content=\"2; url=admin.php?ssid=
$md5p\">
        <title>
$site (Bc - GuestBook $vers)</title>
        <link rel=\"stylesheet\" type=\"text/css\" href=\"
$dcss\" />
        </head>
        <body>
        
        

        <div align=\"center\">
        <table cellspacing=\"1\" cellpadding=\"4\">
        <tr>
        <td class=\"bottd\" width=\"600\">
        <div align=\"center\">
        Salve Admin!
        
 

        Sto effettuando il login...
        </div>
        </td>
        </tr>
        </table>
        </div>
        

        
        </body>
        </html>
        "
);
    }
}
elseif (
$ssid == $md5p) {
    echo (
"
    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
    <html>
    <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />
    <title>
$site (Bc - GuestBook $vers)</title>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"
$dcss\" />
    </head>
    <body>
    
    

    <div align=\"center\">
    <form method=\"post\" action=\"admin.php?ssid=apply\">
    <table cellspacing=\"1\" cellpadding=\"4\">
    <tr>
    <td class=\"toptd\" width=\"150\" height=\"20\">
    <img src=\"images/write.gif\" alt=\"\" border=\"0\" /> <a href=\"write.php\">Scrivi</a>
    </td>
    <td class=\"toptd\" width=\"450\" height=\"20\">
    Messaggi: [b]
$gets[/b]
    </td>
    </tr>
    <tr>
    <td class=\"bottd\" width=\"150\" height=\"20\">
    Password:
    </td>
    <td class=\"bottd\" width=\"450\" height=\"20\">
    <input type=\"text\" name=\"adps\" size=\"30\" value=\"
$pwrd\" maxlength=\"15\" />
    </td>
    </tr>
    <tr>
    <td class=\"bottd\" width=\"150\" height=\"20\">
    E-mail:
    </td>
    <td class=\"bottd\" width=\"450\" height=\"20\">
    <input type=\"text\" name=\"adml\" size=\"30\" value=\"
$mail\" maxlength=\"45\" />
    </td>
    </tr>
    <tr>
    <td class=\"bottd\" width=\"150\" height=\"20\">
    File:
    </td>
    <td class=\"bottd\" width=\"450\" height=\"20\">
    <input type=\"text\" name=\"adfl\" size=\"30\" value=\"
$file\" maxlength=\"15\" />
    </td>
    </tr>
    <tr>
    <td class=\"bottd\" width=\"150\" height=\"20\">
    Style:
    </td>
    <td class=\"bottd\" width=\"450\" height=\"20\">
    <input type=\"text\" name=\"adcs\" size=\"30\" value=\"
$dcss\" maxlength=\"15\" />
    </td>
    </tr>
    <tr>
    <td class=\"bottd\" width=\"150\" height=\"20\">
    Nome sito:
    </td>
    <td class=\"bottd\" width=\"450\" height=\"20\">
    <input type=\"text\" name=\"adst\" size=\"30\" value=\"
$site\" maxlength=\"15\" />
    </td>
    </tr>
    <tr>
    <td class=\"bottd\" width=\"150\" height=\"20\">
    
    </td>
    <td class=\"bottd\" width=\"450\" height=\"20\">
    <input type=\"submit\" name=\"send\" value=\"invia\" /> <input type=\"reset\" value=\"reset\" />
    </td>
    </tr>
    </table>
    </form>
    </div>
    

    
    </body>
    </html>
    "
);
}
elseif ((
$ssid == "apply") && ($send)) {
    
$open fopen ("config.php","w+");
    
$strg "<?php

/***********************************************\
* Bc - GuestBook!
* Bc Scripts (C) 2004
* Boris Carollo - [email]bc.scripts@lycos.com[/email]
* [url]http://bcscripts.zapto.org[/url]
\***********************************************/

// Configurazione
\$pwrd = "
."\"".$adps."\";
\$mail = "
."\"".$adml."\";
\$file = "
."\"".$adfl."\";
\$dcss = "
."\"".$adcs."\";
\$site = "
."\"".$adst."\";

?>"
;
    
$strg stripslashes ($strg);
    
fputs ($open,$strg);
    
fclose ($open);
    echo (
"
    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
    <html>
    <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />
    <meta http-equiv=\"Refresh\" content=\"2; url=admin.php?ssid=
$md5p\">
    <title>
$site (Bc - GuestBook $vers)</title>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"
$dcss\" />
    </head>
    <body>
    
    

    <div align=\"center\">
    <table cellspacing=\"1\" cellpadding=\"4\">
    <tr>
    <td class=\"bottd\" width=\"600\">
    <div align=\"center\">
    Configurazione salvata!
    
 

    <a href=\"admin.php?ssid=
$md5p\">Home</a>
    </div>
    </td>
    </tr>
    </table>
    </div>
    

    
    </body>
    </html>
    "
);
}
elseif (
$ssid != $md5p) {
    echo (
"
    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
    <html>
    <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />
    <meta http-equiv=\"Refresh\" content=\"2; url=admin.php\">
    <title>
$site (Bc - GuestBook $vers)</title>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"
$dcss\" />
    </head>
    <body>
    
    

    <div align=\"center\">
    <table cellspacing=\"1\" cellpadding=\"4\">
    <tr>
    <td class=\"bottd\" width=\"600\">
    <div align=\"center\">
    Password errata!
    
 

    Se hai cambiato la password devi rifare il <a href=\"admin.php\">login</a>.
    </div>
    </td>
    </tr>
    </table>
    </div>
    

    
    </body>
    </html>
    "
);
}

?>
config.php:
Codice PHP:
<?php

/***********************************************\
* Bc - GuestBook!
* Bc Scripts (C) 2004
* Boris Carollo - [email]bc.scripts@lycos.com[/email]
* [url]http://bcscripts.zapto.org[/url]
\***********************************************/

// Configurazione
$pwrd "abcd";
$mail "mail";
$file "messages.txt";
$dcss "style.css";
$site "Bc Scripts";

?>
guestbook.php (iniziato con index.php):
Codice PHP:
<?php

/***********************************************\
* Bc - GuestBook!
* Bc Scripts (C) 2004
* Boris Carollo - [email]bc.scripts@lycos.com[/email]
* [url]http://bcscripts.zapto.org[/url]
\***********************************************/

// Includo le variabili importanti
include ("config.php");
include (
"vars.php");

// Conto i messaggi, un "</tr>" vale un messaggio
$cont implode ("",file($file));
$gets substr_count ($cont,"</tr>");

// Costruisco il codice HTML
echo ("
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />
<title>
$site (Bc - GuestBook $vers)</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"
$dcss\" />
</head>
<body>



<div align=\"center\">
<table cellspacing=\"1\" cellpadding=\"4\">
<tr>
<td class=\"toptd\" width=\"150\" height=\"20\">
<img src=\"images/write.gif\" alt=\"\" border=\"0\" /> <a href=\"write.php\">Scrivi</a>
</td>
<td class=\"toptd\" width=\"450\" height=\"20\">
Messaggi: [b]
$gets[/b]
</td>
</tr>
"
);

// Includo i messaggi
include ($file);

// Footer
echo ("
</table>
</div>



</body>
</html>
"
);

?>
post.php
Codice PHP:
<?php

/***********************************************\
* Bc - GuestBook!
* Bc Scripts (C) 2004
* Boris Carollo - [email]bc.scripts@lycos.com[/email]
* [url]http://bcscripts.zapto.org[/url]
\***********************************************/

// Includo le variabili importanti
include ("config.php");
include (
"vars.php");

// Conto i messaggi, un "</tr>" vale un messaggio
$cont implode ("",file($file));
$gets substr_count ($cont,"</tr>");

// Controllo se i campi sono stati inseriti
if (($name == "") || ($mess == "") || ($send == FALSE)) {
    echo (
"
    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
    <html>
    <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />
    <title>
$site (Bc - GuestBook $vers)</title>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"
$dcss\" />
    </head>
    <body>
    
    

    <div align=\"center\">
    <table cellspacing=\"1\" cellpadding=\"4\">
    <tr>
    <td class=\"bottd\" width=\"600\">
    <div align=\"center\">
    Tutti i campi sono obbligatori!
    
 

    <a href=\"javascript:history.back(-1)\">Indietro</a>
    </div>
    </td>
    </tr>
    </table>
    </div>
    

    
    </body>
    </html>
    "
);
}
else {
    
$join join ("",file($file));
    
$open fopen ($file,"w+");
    
$name stripslashes ($name);
    
$mess stripslashes ($mess);
    
$name eregi_replace ("<","&lt;",$name);
    
$mess eregi_replace ("<","&lt;",$mess);
    
$name eregi_replace ("'","'",$name);
    
$mess eregi_replace ("'","'",$mess);
    
$mess ereg_replace ("\n","
"
,$mess);
    
$mess wordwrap ($mess,45,"
"
,1);
    
$mess str_replace (":)","<img src=\"images/01.gif\" alt=\"\" border=\"0\" />",$mess);
    
$mess str_replace (":(","<img src=\"images/02.gif\" alt=\"\" border=\"0\" />",$mess);
    
$mess str_replace (":D","<img src=\"images/03.gif\" alt=\"\" border=\"0\" />",$mess);
    
$mess str_replace (":F","<img src=\"images/04.gif\" alt=\"\" border=\"0\" />",$mess);
    
$mess str_replace (";)","<img src=\"images/05.gif\" alt=\"\" border=\"0\" />",$mess);
    
$mess str_replace (";(","<img src=\"images/06.gif\" alt=\"\" border=\"0\" />",$mess);
    
$mess str_replace (":P","<img src=\"images/07.gif\" alt=\"\" border=\"0\" />",$mess);
    
$mess str_replace (":O","<img src=\"images/08.gif\" alt=\"\" border=\"0\" />",$mess);
    
flock ($open,2);
    
fputs ($open,"

<tr>
<td class=\"bottd\" width=\"150\" valign=\"top\">
[b]Name:[/b] 
$name


[b]Data:[/b] 
$date


[b]Ora:[/b] 
$time
</td>
<td class=\"bottd\" width=\"450\" valign=\"top\">
$mess
</td>
</tr>
$join
    "
);
    
flock ($open,3);
    
fclose ($open);
    
// Costruisco il codice HTML
    
echo ("
    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
    <html>
    <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />
    <meta http-equiv=\"Refresh\" content=\"2; url=index.php\" />
    <title>
$site (Bc - GuestBook $vers)</title>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"
$dcss\" />
    </head>
    <body>
    
    

    <div align=\"center\">
    <table cellspacing=\"1\" cellpadding=\"4\">
    <tr>
    <td class=\"bottd\" width=\"600\">
    <div align=\"center\">
    Messaggio inserito!
    
 

    <a href=\"guestbook.php\">Home</a>
    </div>
    </td>
    </tr>
    </table>
    </div>
    

    
    </body>
    </html>
    "
);
}

?>