File manager - Edit - /home/autoph/public_html/tasks/system_cron_job.php.tar
Back
home/autoph/public_html/tasks/cron/system_cron_job.php 0000644 00000035146 15024752227 0017313 0 ustar 00 <?php include_once dirname(__FILE__) . '/../cfg/db_console.php'; // echo $db->select("SELECT REPLACE(UUID(), '-', '')");exit; //gen key if (isset($_REQUEST['key']) || isset($argv[1])) { if (isset($argv[1])) { parse_str($argv[1], $params); if (isset($params['key'])) { $apiKey = $params['key']; } } else if (isset($_REQUEST['key'])) { $apiKey = $_REQUEST['key']; } else { $apiKey = ""; } // INCLUDES include_once dirname(__FILE__) . '/../app/classes/user_class.php'; include_once dirname(__FILE__) . '/../app/classes/ticket_class.php'; include_once dirname(__FILE__) . '/../app/classes/sms_class.php'; // CLASSESS $user_class = new User(); $ticket_class = new Ticket(); $user_class = new User(); if ($apiKey === 'c037d27d6345487aa9969adde71d2684') { // asa_brand_model_to_system $json_asa_brand_model = $utility_class->curl_me( "https://autohub.ph/connect/api/v1/read_brand_model.php", array('key' => '64a7a46d6c3011eca72bfa163e06960f'), 'POST' ); $arr_asa_brand_model = json_decode($json_asa_brand_model, true); $previous_brand_id = ""; $system_brand_id = ""; foreach ($arr_asa_brand_model as $arr_asa_brand_model_row) { if ($previous_brand_id != $arr_asa_brand_model_row['b_id']) { $previous_brand_id = $arr_asa_brand_model_row['b_id']; //check brand source if exist using source id and source type $query = "SELECT * FROM `vehicle_brands` WHERE 1 AND status = 1 AND source = 1 AND source_id = '" . $arr_asa_brand_model_row['b_id'] . "'"; $existing_brand_data = $db->sql_query($query); $existing_brand_data_arr = array(); foreach ($existing_brand_data as $existing_brand_data_row) { $existing_brand_data_arr = $existing_brand_data_row; } if (count($existing_brand_data_arr) > 0) { //update if exist and diffrent name $system_brand_id = $existing_brand_data_arr['id']; if ($existing_brand_data_arr['name'] != $arr_asa_brand_model_row['b_name']) { $query_update = "UPDATE `vehicle_brands` SET `name`='" . $arr_asa_brand_model_row['b_name'] . "' WHERE 1 AND source_id = '" . $arr_asa_brand_model_row['b_id'] . "' "; $db->sql_query($query_update); } } else { //insert if not exist $query_insert = "INSERT IGNORE INTO `vehicle_brands`(`name`, `source`, `source_id`, `status`) VALUES ('" . $arr_asa_brand_model_row['b_name'] . "',1,NULLIF('" . $arr_asa_brand_model_row['b_id'] . "',''),1)"; $system_brand_id = $db->sql_query_id($query_insert); } //get the generated id } $query = "SELECT * FROM `vehicle_models` WHERE 1 AND status = 1 AND source = 1 AND source_id = '" . $arr_asa_brand_model_row['m_id'] . "' "; $existing_model_data = $db->sql_query($query); $existing_model_data_arr = array(); foreach ($existing_model_data as $existing_model_data_row) { $existing_model_data_arr = $existing_model_data_row; } if (count($existing_model_data_arr) > 0) { //update if exist and diffrent name if ($existing_model_data_arr['name'] != $arr_asa_brand_model_row['m_name']) { $query_update = "UPDATE `vehicle_models` SET `name`='" . $arr_asa_brand_model_row['m_name'] . "' WHERE 1 AND source_id = '" . $arr_asa_brand_model_row['m_id'] . "' "; $db->sql_query($query_update); } } else { //insert if not exist $query_insert = "INSERT IGNORE INTO `vehicle_models`(`name`, `brand_id`,`source`, `source_id`, `status`) VALUES ('" . $arr_asa_brand_model_row['m_name'] . "','$system_brand_id',1,NULLIF('" . $arr_asa_brand_model_row['m_id'] . "',''),1)"; $db->sql_query_id($query_insert); } } $return_arr["message"] = " Done fetching data."; echo $return_arr["message"]; exit; } else if ($apiKey === 'c2f00d9a772f11ec866200ff70631b9a') { // expert sms reminder if still open /*Logic -check if module is enabled reminder config has interval time and template settings -mag send lang pag On Hold at In progress ang case -get all On Hold at In progress ticket na may brand -get lastdate added sa expert remionder if wala get the ticket datetime creation -total = plus the lastdate to reminder hours config if(if total ay mataas sa current time){ exdecute reminder -get template from reminder config } */ $active_api_sql_obj = $user_class->read_active_api($utility_class, $db); $active_api_array = array(); foreach ($active_api_sql_obj as $row) { $active_api_array = $row; } if (count($active_api_array) > 0) { $notification_type_id = 5; //Send Notification to experts reminder open if ($user_class->read_notification_type_if_active($notification_type_id, $db)) { $description = $user_class->read_notification_template_by_id($notification_type_id, $utility_class, $db); $reminder_type = 5; $reminder_info_obj = $user_class->read_notification_reminder_by_type($reminder_type, $utility_class, $db); $reminder_info_arr = array(); foreach ($reminder_info_obj as $row) { $reminder_info_arr = $row; } if (!intval($reminder_info_arr['minutes']) && !intval($reminder_info_arr['hours']) && !intval($reminder_info_arr['days'])) { echo "Set the reminder time in settings."; exit; } // print_r($reminder_info_arr); // exit; $open_tickets_obj = $ticket_class->read_open_ticket_w_brand($utility_class, $db); foreach ($open_tickets_obj as $row) { $last_update_time = $row['last_reminder']; $date_format = 'Y-m-d H:i:s'; $minutes_to_add = $reminder_info_arr['minutes'] + ($reminder_info_arr['hours'] * 60) + ($reminder_info_arr['days'] * 24 * 60); $time = new DateTime($last_update_time); $time->add(new DateInterval('PT' . $minutes_to_add . 'M')); $total_reminder_date = strtotime($time->format($date_format)); $date_time_now = strtotime(date($date_format)); if ($total_reminder_date < $date_time_now) { $display_name = $row['firstname'] . ' ' . substr($row['lastname'], 0, 1); $display_name = ucwords(strtolower($display_name)); $replace_parameter = array( '<user>' => $display_name, '<ref_no>' => $row['reference_no'], '<title>' => $row['title'], // '<description>'=>$row['description'], //str_replace("\n"," ",$arr_data['description']), '<category>' => $row['sub_category'], '<priority>' => $row['priority_level'], '<brand>' => $row['brand'], '<model>' => $row['model'], '<variant>' => $row['model_variant'], ); $sms_description = strtr($description, $replace_parameter); $user_data_obj = $user_class->read_user_by_category_id_and_brand_id(2, $row['brand_id'], $db); foreach ($user_data_obj as $user_data_row) { $is_sms_sent = false; $message_will_be_sent = ""; $from_user_id = $row['user_id']; $ticket_id = $row['id']; $to_user_id = $user_data_row['id']; if ($from_user_id != $to_user_id) { // start create login token $token = $db->select('SELECT UUID()'); $user_class->create_user_login_token($to_user_id, $from_user_id, $ticket_id, $token, 1, $utility_class, $db); $url_params = array( 'token' => $token, 'type' => 1, 'id' => $ticket_id, ); $append_link = $global_system_settings['url'] . "token.php" . "?" . http_build_query($url_params); $append_link = urlencode($append_link); $append_link = $utility_class->curl_me( "https://s.autohub.ph/?url=$append_link&format=text", array(), 'GET' ); // echo $append_link;exit; $message_will_be_sent = $sms_description . "\n\nClick to view: " . $append_link; // end create login token // $replace_parameter = array( // '[no]' => '0' . $user_data_row['mobile'], // '[msg]' => addslashes($message_will_be_sent), // ); // $final_template = strtr($active_api_array['json_parameters'], $replace_parameter); // $final_template = preg_replace("/\\n/m", "\\n", $final_template); // $final_template = str_replace("\'", "'", $final_template); // $sms_status = $utility_class->curl_me( // $active_api_array['base_url'], // json_decode($final_template, true), // 'POST', // $active_api_array['headers'] // ); $array_data['mobile'] = '0' . $user_data_row['mobile']; $array_data['message'] = $message_will_be_sent; $array_data['data'] = $active_api_array; $sms_status = $sms_class->{$active_api_array['name']}($array_data); if ($sms_status == $active_api_array['sent_response']) { //send succcess echo "Sent to " . $user_data_row['mobile'] . " \n"; $is_sms_sent = true; } else { //send failed $is_sms_sent = false; } } } // if ($is_sms_sent) { $ticket_class->create_expert_reminder($ticket_id, $utility_class, $db); echo "Ticket " . $ticket_id . " Completed. \n"; // } } } } } } else if ($apiKey === '4252cd63823811ecb30d00ff70631b9a') { // asa_position_to_system $json_data = $utility_class->curl_me( "https://autohub.ph/connect/api/v1/read_positions.php", array('key' => 'a00b710a823711ecb30d00ff70631b9a'), 'POST' ); $arr_data = json_decode($json_data, true); foreach ($arr_data as $row) { //check brand source if exist using source id and source type $query = "SELECT * FROM `user_positions` WHERE 1 AND status = 1 AND source = 1 AND source_id = '" . $row['id'] . "'"; $existing_data = $db->sql_query($query); $existing_data_arr = array(); foreach ($existing_data as $existing_data_row) { $existing_data_arr = $existing_data_row; } if (count($existing_data_arr) > 0) { //update if exist and diffrent name $system_id = $existing_data_arr['id']; if ($existing_data_arr['name'] != $row['name']) { $query_update = "UPDATE `user_positions` SET `name`='" . $row['b_name'] . "' WHERE 1 AND source_id = '" . $row['id'] . "' "; $db->sql_query($query_update); } } else { //insert if not exist $query_insert = "INSERT IGNORE INTO `user_positions`(`name`, `rank`, `code`, `user_id`, `date_added`, `status`, source,`source_id`) VALUES ('" . $row['name'] . "',NULLIF('" . $row['rank'] . "',''),NULLIF('','') ,NULLIF('','') ,NOW(),1 ,1,'" . $row['id'] . "')"; $system_brand_id = $db->sql_query_id($query_insert); } } $return_arr["message"] = " Done fetching data."; echo $return_arr["message"]; exit; } else if ($apiKey === '3118718a856d11eca6ce00ff70631b9a') { // send viber notif for new vid $query = "SELECT * FROM `cnf_api_notifications` WHERE 1 AND api_type = 1 AND data_type = 1 AND status = 1"; $api_notif_obj = $db->sql_query($query); foreach ($api_notif_obj as $api_notif_row) { $db->sql_query("UPDATE `cnf_api_notifications` SET `status`=0 WHERE 1 AND id = " . $api_notif_row['id'] . ""); $utility_class->curl_me_async( $global_system_settings['url'] . "api/v1/viber/send_video_notification.php", array("json" => '{"target_id":"' . $api_notif_row['target_id'] . '","type":1,"target_json":' . $api_notif_row['target_json'] . '}'), 'POST' ); // echo '{"target_id":"'.$api_notif_row['target_id'].'","type":1,"target_json":'.$api_notif_row['target_json'].'} ....'; } $return_arr["message"] = " Done fetching data."; echo $return_arr["message"]; exit; } else { $return_arr["message"] = " You are not allowed to do this action."; echo $return_arr["message"]; exit; } } else { $return_arr["message"] = " You are not allowed to do this action."; echo $return_arr["message"]; exit; }
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings