File manager - Edit - /home/autoph/public_html/data03252025consolidation/app/cron/greet_birthday.php
Back
<?php include_once("../../cfg/db.php"); include_once("../sms/sms_start.php"); include_once("../../api/controllers/utility.php"); //8842867415061325 $utility = new Utility(); if(isset($argv[1])){ parse_str($argv[1], $params); if(isset($params['apiKey']) && $params['apiKey'] === '8842867415061325'){ $send_sms = new SMS(); // $count = $db->select("SELECT COUNT(*) FROM `cron_birthday_queue` WHERE 1"); $count = $db->select("SELECT COUNT(1) FROM `text_blast_birthday_record` WHERE `sms_response` = -1"); if($count > 0){ $id = ""; $dealer_name = ""; $first_name = ""; $last_name = ""; $mobile = ""; $token = ""; $birthday_message_content = ""; $dealer = ""; while($count > 0){ $customers = $db->sql_query("SELECT c.first_name, c.last_name, cc.mobile_phone_1, tbbr.customer_id, sd.name AS dealer, tbbr.token FROM `text_blast_birthday_record` tbbr INNER JOIN customer c ON c.id = tbbr.customer_id INNER JOIN customer_contact cc ON cc.customer_id = tbbr.customer_id INNER JOIN customer_dms cdms ON cdms.customer_record_id = c.id INNER JOIN source_company_dealer scd ON scd.id = cdms.company_dealer_id INNER JOIN source_company sc ON sc.id = scd.company_id INNER JOIN source_dealer sd ON sd.id = scd.dealer_id WHERE tbbr.sms_response = -1 LIMIT 1"); $birthdays = $db->sql_query("SELECT message_header, message_body, message_footer FROM auto_txt_blast WHERE type = 'Birthday Greeting' LIMIT 1"); foreach($birthdays AS $birthday){ $message_header = $birthday['message_header']; $message_body = $birthday['message_body']; $message_footer = $birthday['message_footer']; $birthday_message_content = $message_header . "\n\n" . $message_body . "\n\n" . $message_footer; } foreach($customers AS $customer){ $id = $customer['customer_id']; $dealer_name = $customer['dealer']; $first_name = $customer['first_name']; $last_name = $customer['last_name']; $token = $customer['token']; $subscription_link = $variable['site_link'] . "subscription_bg.php?token=" . $token; $subscription_link = urlencode($subscription_link); $subscription_link = $utility->curl_me( "https://s.autohub.ph/?url=$subscription_link&format=text", array(), 'GET'); $replace = array( '[firstname]'=>ucwords(strtolower($first_name)), '[lastname]'=>ucwords(strtolower($last_name)), '[dealer]'=>ucwords(strtolower($dealer_name)), '[subscription link]'=>$subscription_link ); $birthday_message_content = strtr($birthday_message_content, $replace); // check if customer is subscribe to BG greetings $unsubscribed = $db->select("SELECT COUNT(id) FROM `txt_blast_subscription` WHERE `customer_id` = '$id' AND `type` = 1"); if($unsubscribed > 0){ // do nothing, means customer has unsubscribed $db->sql_query("UPDATE `text_blast_birthday_record` SET `sms_response` = 'unsubscribed' WHERE customer_id = '$id'"); // status 30 means unsubscribed } else { $mobile = $customer['mobile_phone_1']; $dealer = $customer['dealer']; $dealer = ucwords(strtolower($dealer)); $token = $customer['token']; $isValid = substr($mobile, 0, 4); if($isValid == "+639" && strlen($mobile) == 13){ //valid number $message = $birthday_message_content; $sms_response = $send_sms->sendSMS($mobile, $message, $variable); $current_date = $db->select("SELECT NOW() AS now"); $db->sql_query("UPDATE `text_blast_birthday_record` SET `date` = '$current_date' , `sms_response` = '$sms_response' WHERE customer_id = '$id'"); if($sms_response == 0){ // success $db->sql_query("UPDATE `contact_validations` SET `valid_mobile_number` = 1 WHERE customer_id = '$id'"); } else { $db->sql_query("UPDATE `contact_validations` SET `valid_mobile_number` = 0 WHERE customer_id = '$id'"); } } else { //not valid $db->sql_query("UPDATE `text_blast_birthday_record` SET `sms_response` = 1 WHERE customer_id = '$id'"); $db->sql_query("UPDATE `contact_validations` SET `valid_mobile_number` = 0 WHERE customer_id = '$id'"); } $first_name = ""; $last_name = ""; $dealer = ""; } // $deleted = $db->sql_query_num_inserted("DELETE FROM `cron_birthday_queue` WHERE cust_id = '$id'"); $count--; } } } return; //always execute this } } echo "What are you doing? "; //this will appear if there's an error on param or code ?>
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings