Well, I ended up getting pretty bored today, so I decided to look for a job. Foregoing the manual approach, I pulled this together. Some of it is my work, some of it is not.
1. Create a database called "resume"
2. Create a table called "jobs" with "id"(int auto_increment), "link"(varchar), "title"(varchar again), and "email"(varchar once more)
3. Create "resume.doc" in the same folder
4. Edit code below to fit
resume.php
<?php
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
mysql_connect("", "", "");
mysql_select_db("resume");
$result = mysql_query("TRUNCATE TABLE `jobs`;");
if(!$result){
echo("Cannot truncate<br>");
exit();
}
if(!isset($min) or $min == ""){
$min = 0;
}
if(!isset($max) or $max == ""){
$max = 10;
}
if(!isset($inc) or $inc == ""){
$inc = $max;
}
echo("Fetching links...<br>");
echo($min."-".$max);
$min2=0;
$max2=$min;
if($max<100){
$url = "http://fortcollins.craigslist.org/jjj/index0.html";
$input = file_get_contents($url);
if(!$input){
echo("Could not get URL: ".$url."<br>");
}
if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)){
foreach($matches as $match) {
$pos = strrpos($match[2], ".html");
if($pos !== false){
$min2++;
if($min2>$min){
$match[3] = mysql_real_escape_string($match[3]);
$result = mysql_query("INSERT INTO `jobs`(link, title) VALUES(
'".$match[2]."',
'".$match[3]."');");
if(!$result){
echo("Cannot get job link ".$match[2]." with title ".$match[3]."<br>");
}
$max2++;
if($max2 == $max){
echo('<form action="resume2.php" method="post" id="redir">');
echo('<input type="hidden" name="min" value="'.$min.'">');
echo('<input type="hidden" name="max" value="'.$max.'">');
echo('<input type="hidden" name="inc" value="'.$inc.'">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
<?
exit();
}
}
}
}
}
}else{
for($i=$min;$i<$max;$i+=100){
$url = "http://fortcollins.craigslist.org/jjj/index".$i.".html";
$input = file_get_contents($url);
if(!$input){
echo("Could not get URL: ".$url."<br>");
}
if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)){
foreach($matches as $match) {
$pos = strrpos($match[2], ".html");
if($pos !== false){
$min2++;
if($min2>$min){
$match[3] = mysql_real_escape_string($match[3]);
$result = mysql_query("INSERT INTO `jobs`(link, title) VALUES(
'".$match[2]."',
'".$match[3]."');");
if(!$result){
echo("Cannot get job link ".$match[2]." with title ".$match[3]."<br>");
}
$max2++;
if($max2 == $max){
echo('<form action="resume2.php" method="post" id="redir">');
echo('<input type="hidden" name="min" value="'.$min.'">');
echo('<input type="hidden" name="max" value="'.$max.'">');
echo('<input type="hidden" name="inc" value="'.$inc.'">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
<?
exit();
}
}
}
}
}
}
}
echo('<form action="resume2.php" method="post" id="redir">');
echo('<input type="hidden" name="min" value="'.$min.'">');
echo('<input type="hidden" name="max" value="'.$max.'">');
echo('<input type="hidden" name="inc" value="'.$inc.'">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
resume2.php
<?php
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
mysql_connect("", "", "");
mysql_select_db("resume");
$result = mysql_query("SELECT * FROM `jobs`");
if(!$result){
echo("Cannot get data<br>");
exit();
}
if(!isset($min) or $min == ""){
echo('<form action="resume.php" method="post" id="redir">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
<?
}
if(!isset($max) or $max == ""){
echo('<form action="resume.php" method="post" id="redir">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
<?
}
if(!isset($inc) or $inc == ""){
echo('<form action="resume.php" method="post" id="redir">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
<?
}
echo("Getting e-mails...<br>");
while($row = mysql_fetch_array($result)){
$url = $row["link"];
$input = file_get_contents($url);
if(!$input){
echo("Could not get URL: ".$url."<br>");
}
if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)){
foreach($matches as $match) {
if(preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $match[3])){
$match[3] = mysql_real_escape_string($match[3]);
$result2 = mysql_query("UPDATE `jobs` SET `email`='".$match[3]."' WHERE `id`=".$row["id"].";");
if(!$result2){
echo("Cannot submit ".$match[3]."<br>");
}
}
}
}
}
echo('<form action="resume3.php" method="post" id="redir">');
echo('<input type="hidden" name="min" value="'.$min.'">');
echo('<input type="hidden" name="max" value="'.$max.'">');
echo('<input type="hidden" name="inc" value="'.$inc.'">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
resume3.php
<?php
$attachment = chunk_split(base64_encode(file_get_contents("resume.doc")));
mysql_connect("", "", "");
mysql_select_db("resume");
$result = mysql_query("SELECT * FROM `jobs`");
if(!$result){
echo("Cannot get e-mails<br>");
exit();
}
if(!isset($min) or $min == ""){
echo('<form action="resume.php" method="post" id="redir">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
<?
}
if(!isset($max) or $max == ""){
echo('<form action="resume.php" method="post" id="redir">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
<?
}
if(!isset($inc) or $inc == ""){
echo('<form action="resume.php" method="post" id="redir">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>
<?
}
echo("Sending e-mails...<br>");
while($row = mysql_fetch_array($result)){
if(isset($row["email"]) and $row["email"] != ""){
$to = $row["email"];
$subject = "Replying to ".$row["title"];
$random_hash = md5(date('r', time()));
$headers = "From: you@yoursite.com\r\nReply-To: you@yoursite.com";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$output = "
--PHP-mixed-$random_hash;
Content-Type: multipart/alternative; boundary='PHP-alt-$random_hash'
--PHP-alt-$random_hash
Content-Type: text/html; charset='iso-8859-1'
Content-Transfer-Encoding: 7bit
--PHP-alt-$random_hash--
--PHP-mixed-$random_hash
Content-Type: application/msword; name=resume.doc
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--PHP-mixed-$random_hash--";
if(!mail($to, $subject, $output, $headers)){
echo("Mail could not be sent to ".$to);
}
}
}
echo("Done. Waiting 20 seconds for flood interval...<br>");
sleep(20);
$min += $inc;
$max += $inc;
echo('<form action="resume.php" method="post" id="redir">');
echo('<input type="hidden" name="min" value="'.$min.'">');
echo('<input type="hidden" name="max" value="'.$max.'">');
echo('<input type="hidden" name="inc" value="'.$inc.'">');
?>
</form>
<script language="JavaScript" type="text/javascript">
<!--
document.getElementById('redir').submit();
//-->
</script>