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-mme.php
<?php
require_once('../../../../wp-load.php');

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

//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
);

//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;

require_once 'formr/class.formr.php';
require "libs/HTML_Object.php";
$form = new Formr();
$tid = $form->get('tid');


#header("Content-Encoding: UTF-8");
header('content-type: image/png');
header("Cache-Control: no-store, no-cache");  
header('Content-Disposition: attachment; filename="MME_'.$tid.'.png"');

$url = "https://ws.followmystaff.com/api/v3/transactions/$tid/image"; 
$ch = curl_init($url);
#curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt ( $ch, CURLOPT_HTTPHEADER, array ('x-access-token:'.$apiToken) ); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


$result = curl_exec($ch);



#echo '<img src="data:image/jpeg;base64,'.base64_decode($result).'"/>';
#echo base64_decode($result);
#echo base64_encode($image);

echo '<img src="data:image/png;base64,' . base64_encode($result) . '">';

#$objHTMLDocument->body()
#        ->content($body);
#$objHTMLDocument->display();


?>