fix rest api, need to change every variable to readable

This commit is contained in:
Ibnu Maksum
2024-04-01 13:01:21 +07:00
parent ee73621c85
commit 254fd4ccf7
4 changed files with 26 additions and 16 deletions

View File

@ -1,7 +1,7 @@
<?php
/**
* PHP Mikrotik Billing (https://github.com/SiberTech/)
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux
*
* This File is for API Access
@ -19,8 +19,6 @@ $isApi = true;
include "../init.php";
unset($_COOKIE['aid']);
// Dummy Class
$ui = new class($key)
{
@ -71,14 +69,14 @@ if (!empty($token)) {
} else {
# validate token
list($tipe, $uid, $time, $sha1) = explode('.', $token);
if (trim($sha1) != sha1($uid . '.' . $time . '.' . $db_password)) {
if (trim($sha1) != sha1($uid . '.' . $time . '.' . $api_secret)) {
showResult(false, Lang::T("Token is invalid"));
}
#cek token expiration
// 3 bulan
if ($time != 0 && time()-$time > 7776000) {
die("$time != ". (time()-$time));
if ($time != 0 && time() - $time > 7776000) {
die("$time != " . (time() - $time));
showResult(false, Lang::T("Token Expired"), [], ['login' => true]);
}
@ -109,6 +107,9 @@ if (!empty($token)) {
showResult(false, Lang::T("Token is invalid"));
}
}
}else{
unset($_COOKIE);
unset($_SESSION);
}
try {