Scriptul PHP din spatele acestui formular de upload:
Scriptul PHP de mai jos extrage adrese de email de pe o pagina web.
<?php
$url = "http:/www.genericwebsite.com/contact.php";
//getting the source-code of the web page
$sc = file_get_contents($url);
$sc = strtolower($sc);
$forbidden_symbols = array('?', '!', ',', ';', ':', '+', '=', '/', '\\', '"', '\'', '`', '’', '“', '”', '#', '$', '%', '^', '&', '*', '(', ')', '[', ']', '{', '}', '|', '<', '>');
//removing all symbols from the source-code less "@", "." and "_"
$sc = str_replace($forbidden_symbols, ' ', $sc);
//storing all words from the source-code into an array
$words_found = explode(' ', $sc);
//verifying each word from array if it is an email address
for ($i = 0; $i < count($words_found); $i++) {
//if the word contains the symbols "@" that means it is an email address
if (strpos($words_found[$i], '@')) {
//I make sure that the email address has no empty spaces in the beginning and in the and of it
$email_address = trim($words_found[$i]);
//I make sure that the email address has no symbols in the beginning and in the and of it
//I apply all these cleaning filters because the source-code can be pretty messy
$first_char = substr($email_address, 0, 1);
while (!ctype_alpha($first_char)) {
$email_address = substr($email_address, 1, strlen($email_address));
$first_char = substr($email_address, 0, 1);
}
$last_char = substr($email_address, strlen($email_address) - 1, 1);
while (!ctype_alpha($last_char)) {
$email_address = substr($email_address, 0, strlen($email_address) - 1);
$last_char = substr($email_address, strlen($email_address) - 1, 1);
}
//I make sure that the extracted string is really an email address
if (eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$", $email_address)) {
echo $email_address.'<br />';
}
}
}
?>