HEX
Server: Apache/2.4.59 (Debian)
System: Linux keymana 4.19.0-21-cloud-amd64 #1 SMP Debian 4.19.249-2 (2022-06-30) x86_64
User: lijunjie (1003)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wp-content/themes/ormedia/qrpatrol/qrpatrol-api.php
<?php
require_once('../../../../wp-load.php');
// header('Content-Type: application/json');
/*
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
*/
require_once 'formr/class.formr.php';
require "libs/HTML_Object.php";

// get username and password
$u = $wpdb->get_row("SELECT * from keylab_qrpatrol where ID=1");


/*
$snapshotTypes = array(
''=>'ALL',
'START'=>'START',
'FINISH'=>'FINISH',
'TEST'=>'TEST',
'SCAN'=>'SCAN',
'NFCSCAN'=>'NFC SCAN',
'MISSEDSCAN'=>'MISSED SCAN',
'INMSG'=>'MME',
'CHECKPOINT SCAN'=>'CHECKPOINT SCAN',
'INCIDENT'=>'INCIDENT',
'MANDOWN'=>'MANDOWN',
'SOS'=>'SOS'
);
*/
//API Url
$url = 'https://ws.followmystaff.com/api/v3/getToken';
//Initiate cURL.
$ch = curl_init($url);
//The JSON data.
$jsonData = array(
    'username' => $u->un,
    'password' => $u->up
);

#var_dump($jsonData);
 
//Encode the array into JSON.
$jsonDataEncoded = json_encode($jsonData);
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
//Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Execute the request
$result = curl_exec($ch);
$resultArray = json_decode($result);
$apiToken = $resultArray->apiToken;

// convert POST captured dates to unix dates
$toDate = current_time("timestamp");
$fromDate = ($_REQUEST['fromDate']=="")?strtotime("1/1/2019"):$_REQUEST['fromDate'];

//API Url
$url2 = 'https://ws.followmystaff.com/api/v3/transactions?fromDate='.$fromDate.'&toDate='.$toDate.'&snapshot=["INMSG"]';

#$url2 = 'https://ws.followmystaff.com/api/v3/transactions?limit=5&fromDate=1565020800&toDate=1567699200';
#var_dump($url2);

$ch2 = curl_init($url2);
#curl_setopt($ch2, CURLOPT_POST, 1);

curl_setopt ($ch2, CURLOPT_HTTPHEADER, array ('x-access-token:'.$apiToken) ); 
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);

$result2 = curl_exec($ch2);
#var_dump($result2);
$data = json_decode($result2, true);
$result = array();

foreach ($data['rows'] as $d) {
	$r = new stdClass();
	foreach (array_keys($d) as $k) {
		$r->$k = $d[$k];				
	}	
	$r->mme = get_bloginfo("stylesheet_directory").'/qrpatrol/qrpatrol-mme.php?tid='.$r->ID.'&apiToken='.$apiToken;
	echo $r->mme.'<br />';
	array_push($result,$r);	 	
}

//echo json_encode($result,true);



?>