first commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
PHP Class : /Controller/QZController
|
||||
Description : Koneksi QZ Printer
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : December 7th, 2008.
|
||||
Last Modified : August 9th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use flight\Engine;
|
||||
|
||||
class QZController {
|
||||
|
||||
protected Engine $app;
|
||||
|
||||
public function __construct(Engine $app) {
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
public function getCert() {
|
||||
$this->app->response()->header('Content-Type', 'text/plain');
|
||||
readfile(__DIR__ . '/../config/qz/cert.pem');
|
||||
}
|
||||
|
||||
public function getSign(string $req) {
|
||||
$privateKey = openssl_get_privatekey(file_get_contents(__DIR__ . '/../config/qz/key.pem'));
|
||||
$signature = null;
|
||||
openssl_sign($req, $signature, $privateKey);
|
||||
|
||||
$this->app->response()->header('Content-Type', 'text/plain');
|
||||
if ($signature) {
|
||||
echo base64_encode($signature);
|
||||
} else echo '<h1>Error signing message</h1>';
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user