| Server IP : 10.200.247.200 / Your IP : 216.73.217.19 Web Server : Apache System : Linux synergy-usa-sites 6.8.0-138-generic #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026 x86_64 User : jeremy ( 1001) PHP Version : 8.4.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/hans_sites/froyo2me.com/functions/ |
Upload File : |
<?php
session_start();
require_once($_SERVER['DOCUMENT_ROOT'].'/php/mysql.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/php/txtwire_yogurtland_texts.php');
//Send texts to people that have just ordered
$res = $db->get_results("SELECT id,cc_phone,latitude,longitude FROM yogurtland_delivers.orders
WHERE DATE(delivery_time)=CURDATE()
AND delivery_time <= '".date('Y-m-d H:i:s',strtotime('+55 minutes',strtotime('+1 hours')))."'
AND date_delivered='0000-00-00 00:00:00'
AND sent_geo_text=0
");
if(!empty($res)) {
foreach($res as $r) {
$db->query("UPDATE yogurtland_delivers.orders SET sent_geo_text=1 WHERE id='".$db->clean($r->id)."'");
if(date('H')*1>=21) {
continue;
}
$geo = $db->get_results("SELECT (SQRT((".$db->clean($r->latitude)." - latitude) * (".$db->clean($r->latitude)."- latitude) + (".$db->clean($r->longitude)." - longitude) * (".$db->clean($r->longitude)." - longitude)))*69 as distance,o.full_address,o.cc_first_name,o.cc_last_name,o.cc_phone,o.ts as date_ordered
FROM yogurtland_delivers.orders o
WHERE curbside_delivery=0
AND (SQRT((".$db->clean($r->latitude)." - latitude) * (".$db->clean($r->latitude)."- latitude) + (".$db->clean($r->longitude)." - longitude) * (".$db->clean($r->longitude)." - longitude)))*69 <= 0.5
AND o.cc_phone<>'".$db->clean($r->cc_phone)."'
AND o.cc_phone NOT IN (SELECT phone FROM yogurtland_texts.do_not_call)
AND o.cc_phone NOT IN (SELECT phone FROM yogurtland_texts.do_not_call_geo)
AND cc_phone NOT IN (SELECT phone_sent_to FROM yogurtland_texts.geo_texts WHERE ts >= '".$db->clean(date('Y-m-d',strtotime('-8 day')))."')
GROUP BY cc_phone
HAVING distance>0
ORDER BY distance ASC");
if(!empty($geo)) {
$new_promo_code = substr(md5(uniqid(mt_rand(), true)), 0, 12);
$db->query("INSERT INTO yogurtland_delivers.promo_codes
(
promo_code
,min_price
,discount_type
,amount_off
,max_amount_off
,start_date
,end_date
,max_uses
,total_uses
) VALUES (
'".$db->clean($new_promo_code)."'
,'6'
,'dollars_off'
,'3.75'
,'0'
,'".date('Y-m-d H:i:s')."'
,'".$db->clean(date('Y-m-d H:i:s',strtotime('+30 minute')))."'
,'0'
,'0'
)");
$db->query("INSERT INTO yogurtland_delivers.promo_codes
(
promo_code
,min_price
,discount_type
,amount_off
,max_amount_off
,start_date
,end_date
,max_uses
,total_uses
) VALUES (
'".$db->clean($new_promo_code)."'
,'6'
,'dollars_off'
,'1.50'
,'0'
,'".$db->clean(date('Y-m-d H:i:s',strtotime('+30 minute')))."'
,'".$db->clean(date('Y-m-d',strtotime('+14 day')))." 23:59:59'
,'0'
,'0'
)");
foreach($geo as $g) {
send_text($g->cc_phone,'Great News! Someone in your neighborhood just ordered Yogurtland. Use this link in the next 20 minutes and get 7 oz of FREE Yogurt with a $6 purchase! Don\'t want YL right now? Use the same link until '.date('m/d/y',strtotime('+14 day')).' for $1.50 off each order! (to stop receiving these discounts reply "NoThanks")');
send_text($g->cc_phone,'https://froyo2me.com/free/'.$new_promo_code);
$db->query("INSERT INTO yogurtland_texts.geo_texts
(
order_id_from
,promo_code_created
,phone_sent_to
,distance_from_order
,did_order
,opt_out
,ts
) VALUES (
'".$db->clean($r->id)."'
,'".$db->clean($new_promo_code)."'
,'".$db->clean($g->cc_phone)."'
,'".$db->clean($g->distance)."'
,'0'
,'0'
,NOW()
)");
}
}
}
}
$res = $db->query("SELECT COUNT(*) as c FROM yogurtland_delivers.orders WHERE DATE(delivery_time)=CURDATE() AND delivery_time <= '".date('Y-m-d H:i:s',strtotime('+55 minutes',strtotime('+1 hours')))."' AND date_delivered='0000-00-00 00:00:00' AND date_printed='0000-00-00 00:00:00'");
$res2 = $db->query("SELECT SUM(tip) as tips FROM yogurtland_delivers.orders WHERE tip_paid=0 AND (date_yogurt_created<>'0000-00-00 00:00:00' OR delivery_time='0000-00-00 00:00:00')");
echo json_encode(array('new_orders'=>$res[0]['c'],'tips'=>number_format($res2[0]['tips'],2)));
?>