File manager - Edit - /home/autoph/public_html/data03252025consolidation/app/cron/cron_pdc_send.php
Back
<?php include_once("../../cfg/db.php"); include_once("../sms/sms_start.php"); include_once("../../api/controllers/utility.php"); ini_set('max_execution_time', '0'); set_time_limit(0); ini_set('memory_limit','-1'); //6735228158166740 $utility = new Utility(); if(isset($argv[1])){ parse_str($argv[1], $params); if(isset($params['apiKey']) && $params['apiKey'] === '6735228158166740'){ // prepare pdc message template $message_header = ""; $message_body = ""; $message_footer = ""; $message_query_list = $db->sql_query("SELECT message_header, message_body, message_footer FROM `auto_txt_blast` WHERE id = 4"); foreach($message_query_list AS $data){ $message_header = $db->escape($data['message_header']); $message_body = $db->escape($data['message_body']); $message_footer = $db->escape($data['message_footer']); } $pending_count = $db->select("SELECT COUNT(*) FROM `txtblast_pdc_reminder_record` WHERE `sms_response` = -1"); if($pending_count > 0){ // has pending status $send_sms = new SMS(); //call send message function $request_id = ""; $cust_id = ""; $mobile_number = ""; while($pending_count > 0){ $rows = $db->sql_query("SELECT `pdc_id`, `reminder_type` FROM txtblast_pdc_reminder_record WHERE `sms_response` = -1 LIMIT 1"); $pdc_id = ""; $mobile_number = ""; $reminder_type = ""; $message = ""; foreach($rows AS $row){ $pdc_id = $row['pdc_id']; $reminder_type = $row['reminder_type']; } // ----------------------------------------------------------------------------------- $count = " COUNT(*) "; $fields = " fp.id, fp.plate_cs_number1, fp.plate_cs_number2, fp.client_name, fsb.name AS brand, fscm.name AS model, fp.client_mobile, fp.client_email, fp.pdc_check_number, fp.company_id, fp.dealer_id, sc.name AS company_name, sd.name AS dealer_name, fp.check_date, DATE_FORMAT(fp.check_date, '%b %d, %Y') AS check_date_eng, fp.check_amount, fip.name AS insurance_company "; $query = "SELECT %s FROM finance_pdc fp INNER JOIN source_company sc ON sc.id = fp.company_id INNER JOIN source_dealer sd ON sd.id = fp.dealer_id INNER JOIN finance_source_brand fsb ON fsb.id = fp.brand_id INNER JOIN finance_source_car_model fscm ON fscm.id = fp.model_id INNER JOIN finance_ins_provider fip ON fip.id = fp.insurance_company_id WHERE fp.id = '$pdc_id' AND fp.status = 1"; // echo sprintf($query, $fields); exit; $result_count = $db->select(sprintf($query, $count)); if($result_count > 0){ $fetch_query = $db->sql_query(sprintf($query, $fields)); foreach($fetch_query AS $row){ $plate_cs_number = ""; $pdc_id = $row['id']; $pdc_check_number = $row['pdc_check_number']; $plate_cs_number_1 = $row['plate_cs_number1']; $plate_cs_number_2 = $row['plate_cs_number2']; if($plate_cs_number_1 != "" && $plate_cs_number_2 != ""){ $plate_cs_number = $plate_cs_number_1 . "/" . $plate_cs_number_2; } else if($plate_cs_number_1 != "" && $plate_cs_number_2 == ""){ $plate_cs_number = $plate_cs_number_1; } else if($plate_cs_number_1 == "" && $plate_cs_number_2 != ""){ $plate_cs_number = $plate_cs_number_2; } $brand = $row['brand']; $model = $row['model']; $client_name = $row['client_name']; $client_mobile = checkForValidNumber($row['client_mobile'], $utility); $client_email = $row['client_email']; $company_id = $row['company_id']; $dealer_id = $row['dealer_id']; $dealer_name = $row['dealer_name']; $check_date = $row['check_date']; $check_date_eng = $row['check_date_eng']; $check_amount = "P" . $row['check_amount']; $ins_company = $row['insurance_company']; $contact_count = $db->select("SELECT COUNT(*) FROM source_dealer_mobile_contact_finance WHERE dealer_id = '$dealer_id'"); $contact_message = ""; if($contact_count == 0){ $contact_message = ""; } else if($contact_count > 1){ $mob_num_arr = array(); $contact_name = ""; $contact_query = "SELECT mobile_number, contact_name FROM source_dealer_mobile_contact_finance WHERE dealer_id = '$dealer_id'"; $contact_query_list = $db->sql_query($contact_query); foreach($contact_query_list AS $row){ $mob_num = $row['mobile_number']; $contact_name = $row['contact_name']; array_push($mob_num_arr, $mob_num); } $contact_message = $contact_name . "\n" . $mob_num_arr[0] . " / " . $mob_num_arr[1]; } else if($contact_count == 1){ $mob_num = ""; $contact_name = ""; $contact_query = "SELECT mobile_number, contact_name FROM source_dealer_mobile_contact_finance WHERE dealer_id = '$dealer_id'"; $contact_query_list = $db->sql_query($contact_query); foreach($contact_query_list AS $row){ $mob_num = $row['mobile_number']; $contact_name = $row['contact_name']; } $contact_message = "\n" . $contact_name . "\n" . $mob_num; } $message_content = $message_header . "\n\n" . $message_body . "\n\n" . $message_footer; $replace = array( '[remaining days]'=>ucwords(strtolower($reminder_type)), '[vehicle description]'=>ucwords(strtolower($brand)) . " " . ucwords(strtolower($model)), '[check date]'=>ucwords(strtolower($check_date_eng)), '[pdc insurance company]'=>strtoupper($ins_company), '[check amount]'=>ucwords(strtolower($check_amount)), '[dealer]'=>ucwords(strtolower($dealer_name)), '[dealer contact]'=>ucwords(strtolower($contact_message)) ); $message_content = strtr($message_content, $replace); // $cleaned_message = str_replace("\r\n", "\n", $message); $isValid = substr($client_mobile, 0, 4); if($isValid == "+639" && strlen($client_mobile) == 13){ //valid number $sms_response = $send_sms->sendSMS($client_mobile, $message_content, $variable); // SEND TEXT ITXTMO $current_datetime = $db->select("SELECT NOW() AS now"); // $status = -2; //not activated (test live sent status) // echo $status; //set status $update_sms_response = "UPDATE `txtblast_pdc_reminder_record` SET `action_date` = '$current_datetime', `sms_response` = '$sms_response' WHERE pdc_id = '$pdc_id' AND reminder_type = '$reminder_type'"; $db->sql_query($update_sms_response); } else { // invalid number $current_datetime = $db->select("SELECT NOW() AS now"); // $cleaned_message = $db->escape($cleaned_message); // $cleaned_message = str_replace("\n", "\r\n", $cleaned_message); $db->sql_query("UPDATE `txtblast_pdc_reminder_record` SET `action_date` = '$current_datetime', `sms_response` = 1 WHERE pdc_id = '$pdc_id' AND reminder_type = '$reminder_type'"); } } } // ----------------------------------------------------------------------------------- $pending_count--; } } return; //always execute this } } echo "What are you doing? "; //this will appear if there's an error on param or code function checkForValidNumber($data, $utility){ $data_to_return = ""; if(strpos($data, '/') > 0){ $multi_mobile = array(); $multi_mobile = explode("/", $data); $multi_mobile[0] = $utility->fix_mobile_format(remove_non_numeric($multi_mobile[0])); $multi_mobile[1] = $utility->fix_mobile_format(remove_non_numeric($multi_mobile[1])); $isValid1 = isMobileValid($multi_mobile[0]); if($isValid1 == 1){ // mobile 1 is valid $data_to_return = $multi_mobile[0]; } else { // mobile 2 instead $isValid2 = isMobileValid($multi_mobile[1]); if($isValid2 == 1){ // mobile 1 is valid $data_to_return = $multi_mobile[1]; } else { // if mobile 2 is still not valid, return mobile 1, may lead to invalid mobile number $data_to_return = $multi_mobile[0]; } } } else { $data_to_return = $data; } return $data_to_return; } function isMobileValid($data){ if(substr($data, 0, 4 ) === "+639"){ if(strlen($data) == 13){ return 1; } else { return 0; } } else { return 0; } } function remove_non_numeric($data){ return preg_replace("/[^0-9\/s\/]/", "", $data); // return preg_replace("/[^0-9]/","",$data); } ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings