Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(0);
- require_once('class.db.php');
- $db = new db();
- $db->__connect();
- if((!$_GET['pub_id'])||(!$_GET['product_id'])||(!$_GET['mail_id'])){
- echo "Need pub id,product id and mail id. Quitting.";
- exit;
- }
- //get the product
- $db->changeDb('DTMS_Tracking'); // The db can be changed here.
- $product_id = $_GET['product_id'];
- $sql = "select * from master_product_table where product_id = $product_id";
- $result = $db->fetchQuery($sql);
- if(!$result)
- {
- echo "Product id invalid. Quitting.";
- exit;
- }
- foreach($result as $key => $val)
- {
- $product = $val;
- }
- //get the publisher
- $db->changeDb('emailer_queue'); // The db can be changed here.
- $pub_id = $_GET['pub_id'];
- $sql = "select * from publishers where id = $pub_id";
- $result = $db->fetchQuery($sql);
- if(!$result)
- {
- echo "Publisher id invalid. Quitting.";
- exit;
- }
- foreach($result as $key => $val)
- {
- $publisher = $val;
- }
- //get the mail template
- $db->changeDb('emailer_queue'); // The db can be changed here.
- $mail_id = $_GET['mail_id'];
- $sql = "select * from prebuilt_emails where id = $mail_id";
- $result = $db->fetchQuery($sql);
- if(!$result)
- {
- echo "Mail id invalid. Quitting.";
- exit;
- }
- foreach($result as $key => $val)
- {
- $mail_template = $val;
- }
- $user_where = "";
- $user_id = $_GET['user_id'];
- if($user_id)
- {
- $user_where = " AND user_id in ($user_id) ";
- }
- $sp_database = $product['product_database'];
- $query = "SELECT * FROM $sp_database.users where user_id not in(select user_id from DTMS_Tracking.emails_sent) $user_where";
- $email_subject = $mail_template['email_subject'];
- $email_body = $mail_template['email_body'];
- $email_from_name = $product['product_label'];
- $product_email_label = $product['product_email_label'];
- $email_from_address = "no-reply@$product_email_label";
- $site_db = $sp_database;
- //next time
- //$query = "SELECT * FROM users where user_id not in (select user_id from users_sent)";
- //for test
- //$query = "SELECT * FROM users where ssn = 1000";
- //
- $res = $db->fetchQuery($query);
- //$email_from_name = "IDWarden";
- //$email_from_address = "no-reply@idwarden.com";
- //$email_subject = "Your ID Theft Program Update";
- //$email_body = file_get_contents('1.html');
- $rate[0]['eph'] = 1000;
- $eph = $rate[0]['eph'];
- $epm = ($eph / 60);
- if($_GET['email'])
- {
- $specific_email_body = str_replace(array('%%firstname%%','%%username%%','%%password%%'),array($firstname,$username,$password), $email_body);
- $headers = "Mine-Version: 1.0"."\r\nContent-type: text/html; charset=iso-8859-1\r\n".
- "To:".$_GET['email']." <".$_GET['email'].">"."\r\n".
- "From:".$email_from_name." <".$email_from_address.">"."\r\n".
- "X-Mailer: PHP / ".phpversion();
- if($_GET['f_name']&&$_GET['l_name'])
- {
- //update DB firstly.
- $name = $_GET['f_name'].' '.$_GET['l_name'];
- $email = $_GET['email'];
- $sql = "insert into $sp_database.users(name,email) values('$name','$email')";
- $db->query($sql);
- //
- }
- $response = mail('', $email_subject, $specific_email_body, $headers);
- if($response){
- $user_id = $val['user_id'];
- $query = "insert into emails_sent(site_db,pub_id,product_id,mail_id,user_id) values('$site_db',$pub_id,$product_id,$mail_id,$user_id)";
- $db->query($query);
- }
- echo "finished";
- exit;
- }
- exit;
- $total = 0;
- $stime = time();
- foreach($res as $key=>$val){
- if($total == $epm)
- {
- $etime = time();
- $sleep_time = $stime + 60 - $etime;
- if($sleep_time > 0)sleep($sleep_time);
- $stime = $stime + 60;
- $total = 0;
- }
- $firstname = $val['first_name'];
- $username = $val['phone_number'];
- $password = $val['zip'];
- $specific_email_body = str_replace(array('%%firstname%%','%%username%%','%%password%%'),array($firstname,$username,$password), $email_body);
- $headers = "Mine-Version: 1.0"."\r\nContent-type: text/html; charset=iso-8859-1\r\n".
- "To:".$val['first_name']." <".$val['email_address'].">"."\r\n".
- "From:".$email_from_name." <".$email_from_address.">"."\r\n".
- "X-Mailer: PHP / ".phpversion();
- $response = mail('', $email_subject, $specific_email_body, $headers);
- if($response){
- $user_id = $val['user_id'];
- $query = "insert into emails_sent(site_db,pub_id,product_id,mail_id,user_id) values('$site_db',$pub_id,$product_id,$mail_id,$user_id)";
- $db->query($query);
- }
- $total++;
- }
- echo "finished";
- exit;
- ?>
Add Comment
Please, Sign In to add comment