require_once("gettext.php"); //require_once("initDatabase.php"); session_start(); //set timezone to Central Time date_default_timezone_set("America/Chicago"); //error_reporting(E_ALL); // remove all session variables //session_unset(); // destroy the session //session_destroy(); define("REWARDS_GOAL", 8); function regTextPool($phone){ $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "SELECT * from textusers where phone ='$phone'"; if ($result=$link->query($query)) { if(mysqli_num_rows($result) == 0) { $balance=0; $rewarded=0; $query = "INSERT INTO textusers (phone,balance,usersince,lastvisit,rewarded,active) VALUES ('$phone', '$balance', NOW(), NOW(),'$rewarded', '1')"; $link->query($query); $txt = "Pooky's Famous Yogurt: Thank you for signing up for our promotional alerts. Msg & Data rates apply. You can opt out at any time by replying STOP."; sendSMS ($phone,$txt); $txt = "Pooky's: You are now entered in our drawings for Free Froyo. Good luck!"; sendSMS ($phone,$txt); } else sendSMS ($phone,"Already registered. Stop cheating!"); } else echo "Query Failed."; mysqli_close($link); //header('Location: http://www.aribellawebdesign.com/froyo/home.php', true, 301); } function sendText($phone,$txt) { sendSMS ($phone,$txt); } function email_application($info){ $email_message = "
Name: ".$info['name']."
Address: ".$info['address']."
Email: ".$info['email']."
Phone: ".$info['phone']."
DOB: ".$info['dob']."
Monday: ".$info['monav']."
Tuesday: ".$info['tueav']."
Wednesday: ".$info['wedav']."
Thursday: ".$info['thuav']."
Friday: ".$info['friav']."
Saturday: ".$info['satav']."
Sunday: ".$info['sunav']."
Weekly Hours: ".$info['hours']."
Hourly Rate: $".$info['rate']."
Start Date: ".$info['start']."
Position: ".$info['position']."
Last Job: ".$info['emphist']."
Comments: ".$info['message']."
"; $to = "contact@pookysyogurt.com, opmanager@pookysyogurt.com, manager@pookysyogurt.com"; $subject = 'New Applicant'; $headers = 'From: contact@pookysyogurt.com' . "\r\n" . 'Reply-To: contact@pookysyogurt.com' . "\r\n" . 'Content-type:text/html;charset=UTF-8' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $email_message, $headers); return true; } function getNumOfSubscribers(){ $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "SELECT * from textusers where active='1'"; if ($result=$link->query($query)) return mysqli_num_rows($result); else return 0; } function deductBucks($gc_num, $balance, $qty){ $newBalance = $balance - $qty; $newBalance = number_format($newBalance,2); $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "UPDATE giftcard SET balance='$newBalance' WHERE id ='$gc_num'"; $link->query($query); $query = "SELECT * from giftcard where id ='$gc_num' AND active ='1'"; if ($result=$link->query($query)) { if(mysqli_num_rows($result) > 0) { $row = $result->fetch_assoc(); $email = $row['to_email']; $name = $row['gc_to']; $expire = $row['expire']; } } mysqli_close($link); emailBalance($gc_num,$name,$email,$newBalance,$expire); } function emailBalance($gc_num,$name,$email,$newBalance,$expire){ $link_address = "http://pookysyogurt.com/placeOrder.php"; $email_message = "".$name.",
Thank you for your visit.
Your Froyo Bucks Info
Gift Card#: ".$gc_num."
Balance: $".$newBalance."
Expires: ".$expire."
Enjoy your Froyo Bucks,
Pooky's Famous Yogurt
12000 US 380 #102
Cross Roads, TX 76227
940-320-2331
Share the love. Click "."here"." to send Froyo Bucks to someone else.
"; $to = $email; $subject = 'Your Froyo Bucks Update'; $headers = 'From: contact@pookysyogurt.com' . "\r\n" . 'Reply-To: contact@pookysyogurt.com' . "\r\n" . 'Content-type:text/html;charset=UTF-8' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $email_message, $headers); } function getBucks($gc_num){ $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "SELECT * from giftcard where id ='$gc_num' AND active ='1'"; $ret=""; if ($result=$link->query($query)) { if(mysqli_num_rows($result) > 0) { $row = $result->fetch_assoc(); $ret = $row['balance']; } else $ret="NO"; } else $ret="NO"; mysqli_close($link); return $ret; } function getRefText($refId){ $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "SELECT * from referrals where refId ='$refId' AND active ='1'"; $ret=""; if ($result=$link->query($query)) { if(mysqli_num_rows($result) > 0) { $row = $result->fetch_assoc(); $ret = $row['org']; } } else echo "Query Failed."; mysqli_close($link); return $ret; } function saveGc(){ $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $n=count($_SESSION['cart']); $email = $_SESSION['sender_email']; $unique_id = $_SESSION['unique_id']; $refId = $_SESSION['refId']; $date = date('m-d-Y'); $tempDate = date('Y-m-d'); $expire = date('m-d-Y', strtotime($tempDate. ' + 90 days')); $i=0; while ($i<$n){ $pic = $_SESSION['cart'][$i]['pic']; $gc_from = $_SESSION['cart'][$i]['from']; $gc_to = $_SESSION['cart'][$i]['to']; $to_email = $_SESSION['cart'][$i]['rec_email1']; $message = $link->real_escape_string($_SESSION['cart'][$i]['message']); $start_amount = number_format ($_SESSION['cart'][$i]['amount'],2); $balance = $start_amount; $query = "INSERT INTO giftcard (gc_from,from_email,gc_to,to_email,message,start_amount,balance,active,date,expire,unique_id,pic) VALUES ('$gc_from','$email','$gc_to','$to_email','$message','$start_amount','$balance','0','$date','$expire','$unique_id','$pic')"; $link->query($query); $i++; } $amount = $_SESSION['amount']; $query = "INSERT INTO invoice (email,amount,paid,unique_id,refId) VALUES ('$email','$amount','0','$unique_id','$refId')"; $link->query($query); mysqli_close($link); } function saveGcAdmin(){ $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $n=count($_SESSION['cart']); $unique_id = $_SESSION['unique_id']; $refId = "admin"; $date = date('m-d-Y'); $tempDate = date('Y-m-d'); $expire = date('m-d-Y', strtotime($tempDate. ' + 90 days')); $i=0; while ($i<$n){ $start_amount = number_format ($_SESSION['cart'][$i]['amount'],2); $balance = $start_amount; $to_email = $_SESSION['cart'][$i]['email']; $query = "INSERT INTO giftcard (to_email,start_amount,balance,active,date,expire,unique_id) VALUES ('$to_email','$start_amount','$balance','1','$date','$expire','$unique_id')"; $link->query($query); $i++; } $amount = $_SESSION['amount']; $query = "INSERT INTO invoice (email, amount,paid,unique_id,refId) VALUES ('$to_email','$amount','1','$unique_id','$refId')"; $link->query($query); $query = "SELECT * from giftcard where unique_id ='$unique_id'"; $ret=""; if ($result=$link->query($query)) { if(mysqli_num_rows($result) > 0) { $row = $result->fetch_assoc(); $ret = $row; } else $ret="NO"; } else $ret="NO"; mysqli_close($link); email_froyoBucks($unique_id); return $ret; } function saveGcReal(){ $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $n=count($_SESSION['cart']); $unique_id = $_SESSION['unique_id']; $refId = "instore"; $date = date('m-d-Y'); $tempDate = date('Y-m-d'); $expire = date('m-d-Y', strtotime($tempDate. ' + 90 days')); $i=0; while ($i<$n){ $start_amount = number_format ($_SESSION['cart'][$i]['amount'],2); $balance = $start_amount; $query = "INSERT INTO giftcard (start_amount,balance,active,date,expire,unique_id) VALUES ('$start_amount','$balance','1','$date','$expire','$unique_id')"; $link->query($query); $i++; } $amount = $_SESSION['amount']; $query = "INSERT INTO invoice (amount,paid,unique_id,refId) VALUES ('$amount','1','$unique_id','$refId')"; $link->query($query); $query = "SELECT * from giftcard where unique_id ='$unique_id'"; $ret=""; if ($result=$link->query($query)) { if(mysqli_num_rows($result) > 0) { $row = $result->fetch_assoc(); $ret = $row; } else $ret="NO"; } else $ret="NO"; mysqli_close($link); return $ret; } function enableNumber($phone){ $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); if (strlen($phone) > 10) $phone = substr($phone, 2, 10); $query = "SELECT * from textusers where phone ='$phone'"; if ($result=$link->query($query)) { if(mysqli_num_rows($result) > 0) { $query = "UPDATE textusers SET active=1 where phone ='$phone'"; $link->query($query); } } else echo "Query Failed."; mysqli_close($link); } function disableNumber($phone){ $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); if (strlen($phone) > 10) $phone = substr($phone, 2, 10); $query = "SELECT * from textusers where phone ='$phone'"; if ($result=$link->query($query)) { if(mysqli_num_rows($result) > 0) { $query = "UPDATE textusers SET active=0 where phone ='$phone'"; $link->query($query); } } else echo "Query Failed."; mysqli_close($link); //header('Location: http://www.aribellawebdesign.com/froyo/home.php', true, 301); } function processPhone($phone){ $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "SELECT * from textusers where phone ='$phone'"; $curr_date=date("Y-m-d"); if ($result=$link->query($query)) { if(mysqli_num_rows($result) > 0) { $row = $result->fetch_assoc(); $lastVisitDate = date('Y-m-d',strtotime($row['lastvisit'])); if ($curr_date > $lastVisitDate) { updatePhone($row); } else { $_SESSION['dontMessage'] = true; } } else { insertPhone($phone); } } else echo "Query Failed."; mysqli_close($link); //header('Location: http://www.aribellawebdesign.com/froyo/home.php', true, 301); } function add_txt ($info){ $company = $info['company']; $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $message = $link->real_escape_string($info['message']); $query = "INSERT INTO txtchron (company,message,active) VALUES ('$company','$message','1')"; if ($link->query($query)) $ret = true; else $ret = false; mysqli_close($link); return $ret; }// end of add_txt function getMessage($company){ $ret=false; $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "SELECT * from txtchron WHERE company ='$company' AND active ='1'"; if ($result=$link->query($query)) { if(mysqli_num_rows($result) > 0) { $row = $result->fetch_assoc(); $ret = $row['message']; $query = "UPDATE txtchron SET active='0' WHERE company ='$company'"; $link->query($query); } } else echo "Query Failed."; mysqli_close($link); return $ret; } function send_txts($info){ $message = $info['message']; $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "SELECT * from textusers where active='1'"; if ($result=$link->query($query)) { $people = []; while($row = $result->fetch_assoc()) { //echo $row['phone']; $people[] = array( 'phone' => $row['phone'], ); } //print_r($people); sendSMSs ($people,$message); return true; } else echo "Query Failed."; mysqli_close($link); } function insertPhone ($phone) { $balance=1; $rewarded=0; $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "INSERT INTO textusers (phone,balance,usersince,lastvisit,rewarded,active) VALUES ('$phone', '$balance', NOW(), NOW(),'$rewarded', '1')"; //$query = $link->real_escape_string($query); $link->query($query); mysqli_close($link); $txt = "Pooky's Famous Yogurt: Thank you for signing up for our promotional alerts. Msg & Data rates apply. You can opt out at any time by replying STOP."; sendSMS ($phone,$txt); $txt = "Pooky's Famous Yogurt: Thank you. You now have 1/".REWARDS_GOAL." points. You're one step closer to your reward!"; sendSMS ($phone,$txt); } function updatePhone ($row) { $phone = $row['phone']; $rewarded = $row['rewarded']; $balance = $row['balance'] + 1; $txt = "Pooky's Famous Yogurt: Thank you. You now have ".$balance."/".REWARDS_GOAL." points. You're one step closer to your reward!"; if ($balance >= REWARDS_GOAL) { $rewarded = 1; $balance = 0; $tempDate = date('Y-m-d'); $expire = date('m-d-Y', strtotime($tempDate. ' + 7 days')); $txt = "Pooky's: You have earned your Free Froyo! Provide your cashier with this message at your next visit, to claim it. Expires: ".$expire; } $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "UPDATE textusers SET balance=$balance,rewarded=$rewarded, active=1 where phone ='$phone'"; //$query = $link->real_escape_string($query); $link->query($query); mysqli_close($link); sendSMS ($phone,$txt); } function froyoAddToCart($in){ $i=count($_SESSION['cart']); $_SESSION['cart'][$i]['from']= $in['from']; $_SESSION['cart'][$i]['to']= $in['to']; $_SESSION['cart'][$i]['message']= $in['message']; $_SESSION['cart'][$i]['rec_email1']= $in['rec_email1']; $_SESSION['cart'][$i]['amount']= $in['amount']; $_SESSION['cart'][$i]['pic']= $in['pic']; } function froyoAddToCartAdmin($in){ $i=count($_SESSION['cart']); $_SESSION['cart'][$i]['amount']= $in['amount']; $_SESSION['cart'][$i]['email']= $in['email']; } function froyoAddToCartReal($in){ $i=count($_SESSION['cart']); $_SESSION['cart'][$i]['amount']= $in['amount']; } function addBalance ($phone, $qty) { $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "SELECT * from textusers where phone ='$phone'"; if ($result=$link->query($query)) { if(mysqli_num_rows($result) > 0) { $row = $result->fetch_assoc(); } else { mysqli_close($link); return -1; } } else { mysqli_close($link); return -1; } $balance = $row['balance'] + $qty; $rewarded = $row['rewarded']; $txt = "Pooky's Famous Yogurt: Thank you. You now have ".$balance."/".REWARDS_GOAL." points. You're one step closer to your reward!"; if ($balance >= REWARDS_GOAL) { $rewarded = 1; $balance = $balance - REWARDS_GOAL; $txt = "Pooky's Famous Yogurt: Yay! You have earned your Reward! Provide your cashier with this phone number at your next visit, to claim it"; } $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "UPDATE textusers SET balance=$balance,rewarded=$rewarded, active=1 where phone ='$phone'"; //$query = $link->real_escape_string($query); $link->query($query); mysqli_close($link); sendSMS ($phone,$txt); } function getBalance($phone){ $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "SELECT * from textusers where phone ='$phone' AND active='1'"; if ($result=$link->query($query)) { if(mysqli_num_rows($result) > 0) { $row = $result->fetch_assoc(); return $row; } else return "NO"; } else echo "Query Failed."; mysqli_close($link); } function claimReward ($phone) { $link = mysqli_connect("127.0.0.1", "pookys", "@Pookysfamousyogurt2019", "pookys"); $query = "UPDATE textusers SET rewarded=0 where phone ='$phone'"; //$query = $link->real_escape_string($query); $link->query($query); mysqli_close($link); $txt = "Pooky's Famous Yogurt: You have claimed your reward. Thank you for your visit."; sendSMS ($phone,$txt); } //error_reporting(E_ALL); //redeemVoucher("promo1"); function sendEmail($info){ $name = $info['name']; $email = $info['email']; $message = "From: ".$name."\nEmail: ".$email."\n\n\n".$info['message']; $subject = "A New Message"; $to = "stojanbacev@yahoo.com"; $headers = ""; $headers .= "From: Dry Clean Delivery 380From: ".$from."
To: ".$to."
Message: ".$message."
Your Froyo Bucks Info
e-Card#: ".$gc_num."
Amount: $".$amount."
Expires: ".$expire."
Enjoy your Froyo Bucks,
Pooky's Famous Yogurt
12000 US 380 #102 #393
Cross Roads, TX 76227
940-320-2331
Share the love. Click "."here"." to send Froyo Bucks to someone else.
"; $to = $to_email; $subject = 'Froyo Bucks from '.$from; $headers = 'From: contact@pookysyogurt.com' . "\r\n" . 'Reply-To: contact@pookysyogurt.com' . "\r\n" . 'Bcc: contact@pookysyogurt.com' . "\r\n" . 'Content-type:text/html;charset=UTF-8' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $email_message, $headers); } //print_r($people); } mysqli_close($link); } ?>