Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Tastiera gaming MSI GK600 TKL: switch hot-swap, display LCD e tre modalità wireless
Tastiera gaming MSI GK600 TKL: switch hot-swap, display LCD e tre modalità wireless
MSI FORGE GK600 TKL WIRELESS: switch lineari hot-swap, tripla connettività, display LCD e 5 strati di fonoassorbimento. Ottima in gaming, a 79,99 euro
DJI Osmo Pocket 4: la gimbal camera tascabile cresce e ha nuovi controlli fisici
DJI Osmo Pocket 4: la gimbal camera tascabile cresce e ha nuovi controlli fisici
DJI porta un importante aggiornamento alla sua linea di gimbal camera tascabili con Osmo Pocket 4: sensore CMOS da 1 pollice rinnovato, gamma dinamica a 14 stop, profilo colore D-Log a 10 bit, slow motion a 4K/240fps e 107 GB di archiviazione integrata. Un prodotto pensato per i creator avanzati, ma che convince anche per l'uso quotidiano
Sony INZONE H6 Air: il primo headset open-back di Sony per giocatori
Sony INZONE H6 Air: il primo headset open-back di Sony per giocatori
Il primo headset open-back della linea INZONE arriva a 200 euro con driver derivati dalle cuffie da studio MDR-MV1 e un peso record di soli 199 grammi
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 17-06-2006, 17:41   #1
dottorkame
Senior Member
 
Iscritto dal: Jan 2003
Città: Monza
Messaggi: 769
[php] aiutatemi contro lo spam

Ciao ragazzi, mi sono fatto un semplice guestbook in php, il problema e' che ogni giorno ci trovo dentro un sacco di spam e devo sempre ripulire. Mi hanno detto che posso mettere anche dei controlli per evitarlo, qualcuno mi sa aiutare?

il codice e' questo:

Codice:
<?php

// This program writes the data to a file called guestbook.data
// Create a blank file with this name, put it in the same directory as this script, and then set the file to user read/write and group read/write, you may also have to set it to other read/write depending upon your hosting situation.

// set error to false
$error = false;

// the sign guestbook function
function signGuestbook(){
         // gain access to the global form variables
        global $name,$comments;

        // put a new guestbook entry together
        // urlencode it for easy storage
        $new_guestbook_entry = urlencode($name).",".urlencode($comments)."\n";

        // write the new guestbook entry to
        // the guestbook data file
        $fp=fopen("guestbook.data",a) or exit;
        fwrite($fp,$new_guestbook_entry);
        fclose($fp);

	// reset form variables
	$name="";
	$comments="";
}

// the read guestbook function
function readGuestbook(){

         // read the guestbook data
        $fp=fopen("guestbook.data",r) or exit;
        $rawdata=fread($fp,filesize("guestbook.data"));
        fclose($fp);

	// if guestbook is empty
	if($rawdata == ""){
		echo "<p><font face=\"sans-serif\">My Guestbook is empty</font></p>";
		return;
	}

        // put each guestbook entry into an array element
        $each_line = explode("\n",$rawdata);

	// sort from newest to oldest
	//  rsort($each_line);

	// if guestbook is not empty
	$entries = count($each_line)-1;
	echo "<p><font face=\"sans-serif\">Ci sono <b>$entries</b> messaggi</font></p>";

        // step through each guestbook entry
        for ($key = 0; $key < count($each_line)-1; $key++){

              // put each field in the current guestbook entry
              // into a temporary array
                $temp = explode(",",$each_line[$key]);

              // put each guestbook field into the guestbook multi-array
                $guestbook[$key]["name"] = $temp[0];
                $guestbook[$key]["comments"] = $temp[1];
        }

        // display the guestbook
        for($key = count($guestbook) - 1; $key >= 0; $key--){
                echo "<p><font face=\"sans-serif\"><b>Nome:</b> ";
                echo htmlspecialchars(urldecode($guestbook[$key]["name"]));
                echo "</a><br><b>Messaggio:</b> ";
                echo htmlspecialchars(urldecode($guestbook[$key]["comments"]));
                echo "</font></p>";
        }
}

// check for form values and sign guestbook if not empty
if ($sign_guestbook){
        if($name != "" && $comments != ""){
                signGuestbook();
        }else{
                $error = true;
        }
}

?>

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>The Wall  - guestbook -</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>

<body bgcolor="#000000" text="#CCCCCC">
<p><font face="sans-serif"><b>Lasciaci un messaggio</b></font></p>
<hr noshade size="1" color="#000000">

<?php if($error){ ?>
<p><font face="sans-serif" color="red">One or more fields have not been filled out, please fill them out before signing the guestbook.</font></p>
<?php } ?>

<form name=guestbook method="post" action="guestbook.php">
<div align="left">
    <table width="520" border="0" cellpadding="5" cellspacing="0">
      <!--DWLayoutTable-->
      <tr> 
        <td width="80" align="left" valign="top"><font face="sans-serif">Nome:</font></td>
        <td width="420" align="left" valign="top"><input type="text" name="name" size="70" value="<?php echo addslashes($name); ?>"></td>
      </tr>
      <tr> 
        <td height="61">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr> 
        <td rowspan="2" align="left" valign="top"><font face="sans-serif">Messaggio:</font></td>
        <td height="112" align="left" valign="top"><textarea rows="5" name="comments" cols="61" wrap=virtual><?php echo htmlspecialchars($comments); ?></textarea></td>
      </tr>
      <tr> 
        <td height="43" align="left" valign="top"><input type="hidden" name="sign_guestbook" value="true"> 
          <input type="submit" value="Submit"> <input type="reset" value="Reset"></td>
      </tr>
    </table>
</div>
</form>

<p>&nbsp;</p>
<p><b><font face="sans-serif" size="3">Leggi il nostro guestbook</font></b></p>
<hr noshade size="1" color="#000000">

<?php readGuestbook(); ?>

</body>
</html>
dottorkame è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Tastiera gaming MSI GK600 TKL: switch hot-swap, display LCD e tre modalità wireless Tastiera gaming MSI GK600 TKL: switch hot-swap, ...
DJI Osmo Pocket 4: la gimbal camera tascabile cresce e ha nuovi controlli fisici DJI Osmo Pocket 4: la gimbal camera tascabile cr...
Sony INZONE H6 Air: il primo headset open-back di Sony per giocatori Sony INZONE H6 Air: il primo headset open-back d...
Nutanix cambia pelle: dall’iperconvergenza alla piattaforma full stack per cloud ibrido e IA Nutanix cambia pelle: dall’iperconvergenza alla ...
Recensione Xiaomi Pad 8 Pro: potenza bruta e HyperOS 3 per sfidare la fascia alta Recensione Xiaomi Pad 8 Pro: potenza bruta e Hyp...
Annunciata la tuta di volo di Vast che s...
Vast presenta il nuovo Large Docking Ada...
Una denuncia getta ombre sulle batterie ...
DJI Avata 2 Fly Smart Combo a 526€: il d...
Alla guida della nuova auto elettrica ci...
GeForce RTX 3060 12 GB a giugno di nuovo...
Apple Music sarà sponsor ufficiale di Po...
The Mandalorian & Grogu: trailer fin...
Fedeltà record: Apple blinda gli utenti,...
Volkswagen ID.3 Neo: fino a 630 km di au...
GPU-Z mette i dati personali a rischio? ...
La PS6 potrebbe essere retrocompatibile ...
Amazfit Cheetah 2 Pro arriva in Italia: ...
Duolingo ammette l'errore dopo un anno: ...
Samsung Galaxy Tab S10 Lite a 249€: il t...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 06:03.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v