File manager - Edit - /home/autoph/public_html/connectv1/app/cron/new_import_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'); //6042867415061325 $utility = new Utility(); // if(isset($_REQUEST['apiKey'])){ if(isset($argv[1])){ parse_str($argv[1], $params); // $params['apiKey'] = $_REQUEST['apiKey']; // if(isset($argv[1])){ // parse_str($argv[1], $params); // if(isset($_REQUEST['apiKey'])) { // parse_str($argv[1], $params); // $params['apiKey'] = $_REQUEST['apiKey']; if(isset($params['apiKey']) && $params['apiKey'] === '6042867415061325'){ $count = $db->select("SELECT COUNT(*) FROM `cron_new_import_customer` WHERE 1"); if($count > 0){ //if table is not empty $request_id = ""; $cust_id = ""; $mobile_number = ""; while($count > 0){ $rows = $db->sql_query("SELECT cnic.cust_id, cnic.first_name, cnic.last_name, cnic.number, cnic.company_id, cnic.dealer_id, sd.name AS dealer_name, cnic.date_uploaded, cnic.token FROM cron_new_import_customer cnic INNER JOIN source_dealer sd ON cnic.dealer_id = sd.id WHERE 1 AND cnic.company_id !=30 LIMIT 1"); $first_name = ""; $last_name = ""; $mobile_number = ""; $cust_id = ""; $token = ""; foreach($rows AS $row){ $cust_id = $row['cust_id']; $first_name = $row['first_name']; $last_name = $row['last_name']; $company_id = $row['company_id']; $dealer_id = $row['dealer_id']; $dealer_name = $row['dealer_name']; $mobile_number = $row['number']; $date_uploaded = $row['date_uploaded']; $token = $row['token']; } $app_download_link = "https://play.google.com/store/apps/details?id=com.kezaratlas.autohub"; $app_download_link = urlencode($app_download_link); $app_download_link = $utility->curl_me( "https://s.autohub.ph/?url=$app_download_link&format=text", array(), 'GET'); $subscription_link = $variable['site_link'] . "subscription_ty.php?token=" . $token; $subscription_link = urlencode($subscription_link); $subscription_link = $utility->curl_me( "https://s.autohub.ph/?url=$subscription_link&format=text", array(), 'GET'); //get message content $message_content = ""; $message_header = ""; $message_body = ""; $message_footer = ""; $messages = $db->sql_query("SELECT message_header, message_body, message_footer FROM auto_txt_blast WHERE id = 3"); // newly imported customer foreach($messages AS $message){ $message_header = $message['message_header']; $message_body = $message['message_body']; $message_footer = $message['message_footer']; } $message_content = $message_header . "\n\n" . $message_body . "\n\n" . $message_footer; $replace = array( '[firstname]'=>ucwords(strtolower($first_name)), '[lastname]'=>ucwords(strtolower($last_name)), '[dealer]'=>ucwords(strtolower($dealer_name)), '[subscription link]'=>$subscription_link, '[app download link]'=>$app_download_link ); $message_content = strtr($message_content, $replace); $message_content = str_replace("\r\n", "\n", $message_content); $isValid = substr($mobile_number, 0, 4); $unsubscribed = $db->select("SELECT COUNT(id) FROM `txt_blast_subscription` WHERE `customer_id` = '$cust_id' AND `type` = 3"); if($unsubscribed > 0){ // recipient is unsubscribed, do nothing $db->sql_query("UPDATE `text_blast_new_import_record` SET `status` = 30 WHERE customer_id = '$cust_id'"); // status 30 means unsubscribed } else { if($isValid == "+639" && strlen($mobile_number) == 13){ //valid number $send_sms = new SMS(); //send message $status = $send_sms->sendSMS($mobile_number, $message_content, $variable); // SEND TEXT ITXTMO //set status $db->sql_query("UPDATE `text_blast_new_import_record` SET `status` = '$status' WHERE customer_id = '$cust_id'"); if($status == 0){ $db->sql_query("UPDATE `contact_validations` SET `valid_mobile_number` = 1 WHERE customer_id = '$cust_id'"); } else { $db->sql_query("UPDATE `contact_validations` SET `valid_mobile_number` = 0 WHERE customer_id = '$cust_id'"); } } else { // invalid number $db->sql_query("UPDATE `text_blast_new_import_record` SET `status` = 1 WHERE customer_id = '$cust_id'"); $db->sql_query("UPDATE `contact_validations` SET `valid_mobile_number` = 0 WHERE customer_id = '$cust_id'"); } } //delete record $deleted = $db->sql_query_num_inserted("DELETE FROM `cron_new_import_customer` WHERE cust_id = '$cust_id'"); sleep(2); // less count by 1 $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 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings