jjk2 Posted October 11, 2008 Share Posted October 11, 2008 i want to delay this from sending to quick. #!/usr/bin/php <?php $sql_server = 'localhost'; $sql_user = ''; $sql_pass = ''; $database = ''; $before_id = ''; //This is what you want to go b $after_id = ''; //This is what you want to go afte //$after _id = ''; This is what you want to go after $domain = 'yahoo.com'; //This is what you want after the @. //Just to show where things go for the addresses. <before_id><id><after_id>@<domain> $subject = 'Hi'; //Subject Line. $message = ' message goes here '; $db = mysql_connect($sql_server,$sql_user,$sql_pass); mysql_select_db($database); if ($argc < 2 || in_array($argv[1], array('--help', '-help', '-h', '-?', '--list'))) { if ($argv[1] == '--list') { $list = file_get_contents('searchlist.txt'); $list = explode(';',$list); foreach ($list as $ident) { print $ident.' '; } } else { print 'Usage: '.$argv[0].' <identifier> OR '.$argv[0].' --add <new-identifier> <newsearch> OR '.$argv[0].' --list <identifier> is a preset search you defined. <newsearch> is the search link you wish to add to the list. Example: '.$argv[0].' id1 OR '.$argv[0].' --add test http://chicago.craigslist.org/search/stp?query=m4m&minAsk=min&maxAsk=max If you want to list all current searches, use '.$argv[0].' --list ';} } else { $file = file_get_contents('searchlist.txt'); $identifer_temp = explode(';',$file); foreach ($identifer_temp as $identifer_temp2) { if (!empty($identifer_temp2)) { $temp = explode(' ',trim($identifer_temp2)); $identifer[trim($temp[0])] = trim($temp[1]); } } //print_r($identifer); if (in_array($argv[1],array('--add'))) { if ($argc < 3 ) { print 'You must specify an identifer and a search text. '; } else { if (empty($argv[3])) {print 'You must specify a search string.';} else { $write = fopen('searchlist.txt', 'w'); if (fwrite($write,$file.$argv[2].' '.$argv[3].';')) {print 'New search string added.';} else {print 'There was a problem adding the new search.';} fclose($write); } } } else { //Running the search. if ($identifer[$argv[1]]) { dl("php_curl.dll"); $base = 0; $connect = curl_init(); curl_setopt($connect, CURLOPT_URL,$identifer[$argv[1]]); curl_setopt($connect, CURLOPT_RETURNTRANSFER, 1); curl_setopt($connect, CURLOPT_FOLLOWLOCATION, 1); $result = curl_exec ($connect); while (preg_match_all("/\b[0-9]+.html/", $result ,$matches)) { foreach($matches[0] as $id) { $id = str_replace('.html','',trim($id)); $sql = "INSERT INTO craigslist_mail (id) VALUES ('".$id."')"; if (mysql_query($sql)) { $headers = 'From: '.$id.'@'.$domain."\r\n" . 'Reply-To: '.$id.'@'.$domain. "\r\n" . 'X-Mailer: PHP/' . phpversion(); $mailto = 'pers-'.$id.'@craigslist.org'; mail($mailto, $subject, $message, $headers, '-f'.$id.'@'.$domain.''); print $id.' - Message Sent ';} else {print $id.' - Already in the Database. ';} } $base += 100; $connect = curl_init(); if (explode('?',$identifer[$argv[1]])) { if ($arg = explode('&s=',$identifer[$argv[1]])) { print ' '; curl_setopt($connect, CURLOPT_URL,$arg[0].'&s='.$base); } else { curl_setopt($connect, CURLOPT_URL,$identifer[$argv[1]].'&s='.$base); } } else { curl_setopt($connect, CURLOPT_URL,$identifer[$argv[1]].'index'.$base.'.html'); } curl_setopt($connect, CURLOPT_RETURNTRANSFER, 1); curl_setopt($connect, CURLOPT_FOLLOWLOCATION, 1); $result = curl_exec ($connect); } //$result = explode('<table width="95%" summary="">',$result); //$result = explode('<div',$result[1]); //print $result[1]; } else {print 'Identify does not exist. Please try again.';} } } ?> Quote Link to comment Share on other sites More sharing options...
ratcateme Posted October 12, 2008 Share Posted October 12, 2008 i dont see how to quick could be a problem but you can use sleep($a_time_in_seconds); to delay your script for a while Scott. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.