Fix API Structure
This commit is contained in:
parent
3a2e7c9192
commit
4bf6f9c0ac
15
init.php
15
init.php
@ -198,17 +198,13 @@ function _log($description, $type = '', $userid = '0')
|
||||
if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) //to check ip is pass from cloudflare tunnel
|
||||
{
|
||||
$d->ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
|
||||
}
|
||||
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
|
||||
{
|
||||
$d->ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
elseif (!empty($_SERVER['HTTP_CLIENT_IP'])) //to check ip from share internet
|
||||
} elseif (!empty($_SERVER['HTTP_CLIENT_IP'])) //to check ip from share internet
|
||||
{
|
||||
$d->ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$d->ip = $_SERVER["REMOTE_ADDR"];
|
||||
}
|
||||
$d->save();
|
||||
@ -224,6 +220,11 @@ function alphanumeric($str, $tambahan = "")
|
||||
return preg_replace("/[^a-zA-Z0-9" . $tambahan . "]+/", "", $str);
|
||||
}
|
||||
|
||||
function showResult($success, $message = '', $result = [], $meta = [])
|
||||
{
|
||||
header("Content-Type: Application/json; charset=utf-8");
|
||||
die(json_encode(array('success' => $success, 'message' => $message, 'result' => $result, 'meta' => $meta)));
|
||||
}
|
||||
|
||||
function sendTelegram($txt)
|
||||
{
|
||||
|
@ -47,9 +47,7 @@ $token = _get('token');
|
||||
$routes = explode('/', $req);
|
||||
$handler = $routes[0];
|
||||
|
||||
if(empty($token)){
|
||||
showResult(false, Lang::T("Token is invalid"));
|
||||
}
|
||||
if (!empty($token)) {
|
||||
|
||||
if ($token == $config['api_key']) {
|
||||
$admin = ORM::for_table('tbl_users')->where('user_type', 'SuperAdmin')->find_one($id);
|
||||
@ -88,11 +86,6 @@ if(!isset($handler) || empty($handler)){
|
||||
if ($handler == 'isValid') {
|
||||
showResult(true, Lang::T("Token is valid"));
|
||||
}
|
||||
|
||||
function showResult($success, $message = '', $result = [], $meta = [])
|
||||
{
|
||||
header("Content-Type: Application/json; charset=utf-8");
|
||||
die(json_encode(array('success' => $success, 'message' => $message, 'result' => $result, 'meta' => $meta)));
|
||||
}
|
||||
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user