Created
October 7, 2013 01:24
-
-
Save Mashpy/6861276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php include('header.php'); ?> | |
<?php | |
$the_url = isset($_REQUEST['url']) ? htmlspecialchars($_REQUEST['url']) : ''; | |
?> | |
<div class="hero-unit"> | |
<form method="post"> | |
Enter URL(http://):<br /> | |
<input type="text" name="url" size="30" value="<?php echo $the_url; ?>"/> | |
<br /> | |
<input type="submit" value="Parse Emails" /> | |
</form> | |
<?php | |
if (isset($_REQUEST['url']) && !empty($_REQUEST['url'])) { | |
// fetch data from specified url | |
$text = file_get_contents($_REQUEST['url']); | |
} | |
elseif (isset($_REQUEST['text']) && !empty($_REQUEST['text'])) { | |
// get text from text area | |
$text = $_REQUEST['text']; | |
} | |
// parse emails | |
if (!empty($text)) { | |
$res = preg_match_all( | |
"/[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i", | |
$text, | |
$matches | |
); | |
if ($res) { | |
foreach(array_unique($matches[0]) as $email) { | |
echo $email . "<br />"; | |
$dbhost='localhost'; | |
$dbuser='mashpy_sanjida'; | |
$dbpass='Mashpy#2134'; | |
$conn= mysql_connect($dbhost,$dbuser,$dbpass); | |
if(!conn) | |
{ | |
die('could not connect'.mysql_error()); | |
} | |
$sql="insert into crawler(metatag,links) values ('url','$email')"; | |
mysql_select_db(mashpy_sanjida); | |
$retravail=mysql_query($sql,$conn); | |
if(!$retravail) | |
{ | |
die('could not connect data'.mysql_error()); | |
} | |
echo ""; | |
mysql_close($conn); | |
} | |
} | |
else { | |
echo "No emails found."; | |
} | |
} | |
?></div> | |
<?php include('footer.php'); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment