File manager - Edit - /home/autoph/public_html/connectv1/api/notification/notifications.php
Back
<?php include_once("../../cfg/db.php"); if ($_SERVER["REQUEST_METHOD"] != "POST") { $return_arr["message"]=" You are not allowed to do this action."; echo $return_arr["message"]; return; } /** * http://connect.autohub.ph/api/notification/notifications.php * params * apiKey 7355825454556 * userID * * response * date_time * record_id * notification_type * description * report_link * total * * */ if(isset($_REQUEST['apiKey']) ){ $apiKey = $_REQUEST['apiKey']; if($apiKey === '7355825454556'){ if(isset($_REQUEST['userID']) ){ $asa_id = $_REQUEST['userID']; $employee_id = $db -> select("SELECT id FROM employee WHERE asa_id = '$asa_id' "); // echo $employee_id;exit; $notification_total_count = $db -> select("SELECT count(1) FROM `notification_list` WHERE `employee_id` = '$employee_id' AND `status` != '1'"); $notification_list = $db -> sql_query("SELECT nl.notification_type_id,nl.description,nt.link,nl.record_id,nl.employee_id,nl.generate_by_employee_id, DATE_FORMAT(`date_time`,'%M %d, %Y - %h:%m %p') as date_time FROM `notification_list` nl INNER JOIN notification_type nt ON nt.id = nl.`notification_type_id` WHERE nl.`employee_id` = '$employee_id' AND nl.status = 0 ORDER BY nl.date_time DESC"); $json_arr['notifications'] = array(); foreach($notification_list as $data){ if($notification_total_count < 1){ break; } $header_date_time = $data['date_time']; $header_record_id = $data['record_id']; $header_employee_id = $data['employee_id']; $header_generate_by_employee_id = $data['generate_by_employee_id']; $header_link = $data['link'].$db -> base64_url_encode( '{"record_id":"'.$header_record_id.'","generate_by_employee_id":"'.$header_generate_by_employee_id.'","employee_id":"'.$header_employee_id.'"}' ); $json_arr['notifications'] = array_merge($json_arr['notifications'] ,array( array( 'date_time'=>$data['date_time'], 'record_id'=>$data['record_id'], 'notification_type'=>$data['notification_type_id'], 'description'=>$data['description'], 'report_link'=> $variable['site_link'].$data['link'].$db -> base64_url_encode( '{"record_id":"'.$header_record_id.'","generate_by_employee_id":"'.$header_generate_by_employee_id.'","employee_id":"'.$header_employee_id.'"}' ), ))) ; } if($notification_total_count > 0 ){ $json_arr['found'] = $notification_total_count." Record".((intval($notification_total_count) < 2) ? '' : 's' )." Found"; }else{ $json_arr['found'] = "No Record Found"; } $json_arr['total'] = $notification_total_count; //total number of result echo json_encode($json_arr); return; }else{ $return_arr["message"]=" You are not allowed to do this action."; echo $return_arr["message"]; return; } }else if($apiKey === '2625558409416390'){ $_SESSION['user']['is_notification_icon_click'] = true; exit; $user_id = $_SESSION['user']['id']; $db -> sql_query("UPDATE `notification_list` SET status = 1 WHERE employee_id = '$user_id' "); }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