File manager - Edit - /home/autoph/public_html/data03252025consolidation/api/sms/sms.php
Back
<?php include_once("../../cfg/db.php"); include_once("../controllers/utility.php"); include_once("../../app/sms/sms_start.php"); include_once("../controllers/sms.php"); $sms = new SMSS(); //from controller $sms_class = new SMS(); //from app $utility = new Utility(); $server_method = isset($_SERVER["REQUEST_METHOD"]) ? $_SERVER["REQUEST_METHOD"] : false; // if(isset($argv[1])){ // parse_str($argv[1], $params); // if(isset($params['apiKey']) && $params['apiKey'] === '7728455798904120'){ if (isset($_REQUEST['apiKey']) || isset($argv[1])) { if (isset($argv[1])) { parse_str($argv[1], $params); if (isset($params['apiKey'])) { $apiKey = $params['apiKey']; } } else if (isset($_REQUEST['apiKey'])) { $apiKey = $_REQUEST['apiKey']; } else { $apiKey = ""; } if ($apiKey === '3553379094510847') { //Read Company List if (!isset($_SESSION['user']['id'])) { echo "Session Expired."; exit; } $json_data = isset($_REQUEST['json_data']) ? ($_REQUEST['json_data']) : '[]'; $json_data = str_replace('\n', '\\\n', $json_data); $filtered_array = array_filter(json_decode($json_data, true)); $sms->update_sc_reminder_status(json_encode($filtered_array), $db); $myfile = fopen("sms_sc_reminder.json", "w") or die("Unable to open file!"); fwrite($myfile, $json_data); fclose($myfile); } else if ($apiKey === '8779525176267196') { if (!isset($_SESSION['user']['id'])) { echo "Session Expired."; exit; } echo $sms->get_sc_reminder($utility, $db); } else if ($apiKey === '3090921140511093') { if (filesize('sms_sc_reminder.json') != 0) { $storeVar = file_get_contents("sms_sc_reminder.json"); if ($utility->isJson($storeVar)) { $json_arr = json_decode($storeVar, true); if (isset($json_arr['status']) && $json_arr['status']) { foreach ($json_arr as $key => $value) { if (strpos($key, 'date_time_') !== false) { $week_day_id = str_replace('date_time_', 'week_day_', $key); //check if selected day and time is not empty if (isset($json_arr[$week_day_id]) && $utility->isNotEmpty($json_arr[$week_day_id]) && $utility->isNotEmpty($json_arr[$key])) { //check if selected days are valid json if ($utility->isJson($json_arr[$week_day_id])) { //json to array and get it into word if not empty by iterate in loop $decoded_week_day = json_decode($json_arr[$week_day_id]); if (count($decoded_week_day) > 0) { foreach ($decoded_week_day as $day) { // change day index to 3 letters word day // 0m 1t 2w 3th 4f 5sat 6sun $day_string = ""; switch (intval($day)) { case 0: $day_string = "Mon"; break; case 1: $day_string = "Tue"; break; case 2: $day_string = "Wed"; break; case 3: $day_string = "Thu"; break; case 4: $day_string = "Fri"; break; case 5: $day_string = "Sat"; break; case 6: $day_string = "Sun"; break; } // $day_now = date('D'); awit // $time_now = date('h:i A'); test lang $t = date('Y-m-dH:i:s'); $day_now = date("D", strtotime($t)); $time_now = date("h:i A", strtotime($t)); //check if exact day and time now is equal in current selected day & time in this foreach loop if ($day_now == $day_string && $time_now == $value) { //testmode // if(true){ // same date & time lets get all fckin data from the outside world! curl :P // get the list of clients from data con with incomplete data $site_link = $variable['site_link'] . 'api/compliance/compliance.php'; $site_link = str_replace("https", "http", $site_link); $has_incomplete_sc = $utility->curl_me( $site_link, // change status to dynamic if magkaron ng data filter, example reminder for complete status/commission status etc.. array('apiKey' => '4683843345322827', 'status' => '0', 'asa_only' => '1'), "POST" ); $has_incomplete_sc_arr = json_decode($has_incomplete_sc, true); if (count($has_incomplete_sc_arr['rows']) > 0) { //store every asa_id of sc that has incomplete data $asa_ids = array(); foreach ($has_incomplete_sc_arr['rows'] as $dat) { if (intval($dat['incomplete']) > 0) { $asa_ids[] = $dat['asa_id']; } } // get all information of asa user (sc) from collected asa ids $incomplete_sc_data = $utility->curl_me( 'https://www.autohub.ph/connect/LOAD_SALES_PERSON.php', array('apiKey' => '3892635489643867', 'ids' => json_encode($asa_ids)), "POST" ); $incomplete_sc_data_arr = json_decode($incomplete_sc_data, true); //create log date $fp = fopen('data.txt', 'a'); //opens file in append mode fwrite($fp, "\n\n" . $t . "\n"); fclose($fp); foreach ($incomplete_sc_data_arr['rows'] as $row_dat) { $uid = $row_dat['u_id']; $fname = $row_dat['u_fname']; $lname = $row_dat['u_lname']; $mbile = $utility->fix_mobile_format($utility->remove_non_numeric($row_dat['usr_mobile'])); $email = $utility->isValidEmail($row_dat['email']); // get the row index from has_incomplete_sc_arr using uid from this loop to get other needed data $has_incomplete_sc_arr_id = array_search($uid, array_column($has_incomplete_sc_arr['rows'], 'asa_id')); $complete_count = $has_incomplete_sc_arr['rows'][$has_incomplete_sc_arr_id]['complete']; $incomplete_count = $has_incomplete_sc_arr['rows'][$has_incomplete_sc_arr_id]['incomplete']; // replace params, dirty sol. :/ // $final_template = str_replace('[firstname]',$fname,$json_arr['template']); // $final_template = str_replace('[lastname]',$lname,$final_template); // $final_template = str_replace('[mobile]',$mbile,$final_template); // $final_template = str_replace('[email]',$email,$final_template); // $final_template = str_replace('[incomplete]',$incomplete_count,$final_template); // replace params, quick sol. $final_template = $json_arr['template']; $replace_parameter = array( '[firstname]' => $fname, '[lastname]' => $lname, '[mobile]' => $mbile, '[email]' => $email, '[incomplete]' => $incomplete_count ); $final_template = strtr($final_template, $replace_parameter); // echo "\n".$fname."\n".$lname."\n".$mbile."\n".$email."\n".$complete_count."\n".$incomplete_count."\n\n".str_replace("\\n","\n",$final_template)."\n--------------------\n";//testmode $txtmo_status = -1; $txtmo_status = $sms_class->sendSMS($mbile, str_replace("\\n", "\n", $final_template), $variable); $fp = fopen('data.txt', 'a'); //opens file in append mode fwrite($fp, $txtmo_status . ' - ' . $incomplete_count . ' - ' . $mbile . ' - ' . $fname . "\n"); fclose($fp); //add delay to rest sleep(3); } } } } } } } } } } }; } } else if ($apiKey === '9184024462372227') { $return_arr["module_status"] = $sms->read_module_status(1, $db); //orcr/plate $return_arr["orcr_template"] = $sms->read_module_template(1, $db); //orcr $return_arr["plate_template"] = $sms->read_module_template(2, $db); //plate $return_arr["orcrplate_template"] = $sms->read_module_template(3, $db); //orcrplate echo json_encode($return_arr); } else if ($apiKey === '3168325945108656') { $sms->update_module_status(1, 'orcr_plate', $_REQUEST['orcr_status'], $db); //orcr/plate $sms->update_module_template(1, 1, $db->escape($_REQUEST['orcr_template']), $db); //orcr $sms->update_module_template(2, 1, $db->escape($_REQUEST['orcr_plate_template']), $db); //plate $sms->update_module_template(3, 1, $db->escape($_REQUEST['orcrplate_template']), $db); //plate $return_arr["message"] = ""; $return_arr["status"] = 1; echo json_encode($return_arr); } else { $return_arr["message"] = " You are not allowed to do this action."; echo $return_arr["message"]; return; } } else { $return_arr["message"] = " You are not allowed to do this action."; echo $return_arr["message"]; return; }
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings