Codice PHP:
<?php
function isindb($sent_url = $_POST['sent_url']) {
/* STRUTTURA DEL DB - tabella "url"
#
# |---------------|-------------------|
# | titolo | md5mac |
|---------------|-------------------|
*/
/* AL momento di inserire una pagina nella tabella "URL"
calcolo il valore md5 (o hash) della pagina
*/
$load = file_get_contents($sent_url);
//Emulo il tuo codice
preg_match("/<title[^<>]*>([^<]*)</title>/is", $load, $matches);
$title = $matches[1];
eregi("<body([^>]*)>(.*)</body>", $load, $regs);
$bodyTAG = strip_tags($regs[2],'<img>');
$hash = md5($bodyTAG);
//Confronto le hash
$check = mysql_query("SELECT * FROM url WHERE md5mac = '" . $hash . "' LIMIT 1");
if(mysql_num_rows($check == 1)) return false;
//il link non è mai stato inserito...
mysql_query("INSERT INTO url (titolo, md5mac) VALUES ('" . $title . "', '" . $hash . "')");
return true;
}
?>
Questo?