Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Drupal\rest_api_authentication; use Drupal\Component\Utility\Html;..
Decoded Output download
<?php
namespace Drupal\rest_api_authentication;
use Drupal\Component\Utility\Html;
use Drupal\user\Entity\User;
use Drupal\rest_api_authentication\DBQueries;
class API_Authentication_OAuth
{
static function validate_api_request($BB)
{
$DT = array();
$DT["user"] = null;
$kl = '';
if (!(!empty(\Drupal::config("rest_api_authentication.settings")->get("custom_header")) || \Drupal::config("rest_api_authentication.settings")->get("custom_header") != null)) {
goto Y2;
}
$kl = $BB->headers->get(\Drupal::config("rest_api_authentication.settings")->get("custom_header"));
Y2:
if (!($BB->headers->get("AUTHORIZATION") != null || $BB->headers->get("AUTHORISATION") != null)) {
goto lW;
}
$kl = $BB->headers->get("AUTHORIZATION") != null ? $BB->headers->get("AUTHORIZATION") : $BB->headers->get("AUTHORISATION");
lW:
$kl = trim(Html::escape($kl));
if (!(empty($kl) || $kl == '')) {
goto Mf;
}
$DT = array("status" => "error", "http_code" => "401", "error" => "MISSING_AUTHORIZATION_HEADER", "error_description" => "Authorization header not received.");
return $DT;
Mf:
if (preg_match("/\Bearer\b/", $kl)) {
goto XL;
}
$DT = array("status" => "error", "http_code" => "405", "error" => "INVALID_AUTHORIZATION_HEADER_TOKEN_TYPE", "error_description" => "Authorization header must be the type of Bearer Token.");
return $DT;
XL:
$lU = explode(" ", $kl);
$kl = $lU[1];
if ($kl != null) {
goto Nf;
}
$DT["status"] = "error";
$DT["http_code"] = "404";
$DT["error"] = "TOKEN_NOT_FOUND";
$DT["message"] = "Incomplete Request. Token Not found.";
goto gg;
Nf:
$user = DBQueries::get_user_id_from_access_token($kl);
if (!empty($user)) {
goto Hu;
}
$DT = array("status" => "error", "http_code" => "401", "error" => "INVALID_ACCESS_TOKEN", "error_description" => "Invalid Access Token.");
return $DT;
Hu:
$hx = time();
$gG = \Drupal::config("rest_api_authentication.settings")->get("token_expiry");
$gG = empty($gG) ? 3600 + $user["access_token_request_time"] : $user["access_token_request_time"] + $gG * 60;
if (!($hx - $gG >= 0)) {
goto mK;
}
$DT = array("status" => "error", "http_code" => "401", "error" => "TOKEN_EXPIRED", "error_description" => "Invalid request: Token Expired.");
return $DT;
mK:
$user = User::load($user["user_id_val"]);
$DT["status"] = "SUCCESS";
$DT["user"] = $user;
gg:
return $DT;
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Drupal\rest_api_authentication;
use Drupal\Component\Utility\Html;
use Drupal\user\Entity\User;
use Drupal\rest_api_authentication\DBQueries;
class API_Authentication_OAuth
{
static function validate_api_request($BB)
{
$DT = array();
$DT["\165\163\x65\162"] = null;
$kl = '';
if (!(!empty(\Drupal::config("\162\145\x73\164\x5f\x61\160\x69\x5f\x61\x75\164\x68\x65\156\164\151\x63\x61\164\x69\157\156\x2e\x73\145\x74\x74\x69\x6e\147\163")->get("\x63\165\x73\164\157\155\137\150\x65\141\144\x65\162")) || \Drupal::config("\x72\145\163\164\x5f\141\x70\x69\x5f\x61\x75\x74\x68\145\156\164\x69\143\x61\164\151\157\x6e\56\x73\145\x74\x74\x69\x6e\147\x73")->get("\143\x75\x73\x74\157\x6d\137\150\145\141\144\x65\x72") != null)) {
goto Y2;
}
$kl = $BB->headers->get(\Drupal::config("\162\x65\x73\x74\x5f\x61\x70\151\137\x61\x75\164\x68\x65\156\x74\x69\x63\x61\x74\151\x6f\x6e\56\163\145\164\x74\x69\156\x67\x73")->get("\143\x75\x73\164\157\x6d\137\x68\145\x61\x64\x65\162"));
Y2:
if (!($BB->headers->get("\x41\x55\124\110\117\x52\x49\x5a\x41\124\x49\117\x4e") != null || $BB->headers->get("\x41\125\x54\x48\117\122\x49\123\x41\x54\x49\x4f\116") != null)) {
goto lW;
}
$kl = $BB->headers->get("\x41\125\x54\110\117\x52\x49\132\x41\x54\111\117\116") != null ? $BB->headers->get("\x41\x55\124\110\x4f\122\x49\x5a\101\x54\111\x4f\x4e") : $BB->headers->get("\x41\x55\124\x48\117\122\x49\x53\101\124\x49\117\x4e");
lW:
$kl = trim(Html::escape($kl));
if (!(empty($kl) || $kl == '')) {
goto Mf;
}
$DT = array("\x73\x74\141\164\165\163" => "\145\x72\x72\x6f\162", "\150\164\164\x70\137\143\157\144\x65" => "\x34\60\61", "\145\x72\162\x6f\x72" => "\x4d\111\123\123\x49\116\107\x5f\x41\x55\124\110\117\x52\x49\x5a\101\x54\111\117\116\137\x48\x45\x41\x44\105\122", "\145\162\x72\157\162\137\144\x65\163\x63\x72\151\160\164\x69\157\156" => "\x41\165\164\150\157\162\151\172\x61\x74\151\157\x6e\40\x68\145\141\144\145\x72\40\156\x6f\164\40\x72\x65\143\x65\151\166\145\x64\x2e");
return $DT;
Mf:
if (preg_match("\57\x5c\102\145\x61\x72\x65\162\x5c\x62\57", $kl)) {
goto XL;
}
$DT = array("\x73\x74\141\x74\165\163" => "\145\x72\162\157\162", "\150\164\x74\160\x5f\x63\x6f\144\x65" => "\64\60\x35", "\145\x72\162\x6f\162" => "\111\116\x56\x41\114\111\x44\137\101\125\124\110\117\x52\x49\132\x41\124\x49\x4f\x4e\x5f\x48\105\101\104\x45\122\x5f\x54\117\113\105\x4e\x5f\x54\x59\120\105", "\x65\162\x72\x6f\162\137\144\x65\x73\143\162\x69\160\x74\x69\157\156" => "\101\x75\x74\x68\157\162\x69\172\141\164\x69\x6f\156\x20\x68\145\x61\x64\145\x72\x20\155\x75\x73\x74\x20\142\x65\40\164\x68\145\40\164\x79\160\x65\40\157\146\40\x42\145\141\x72\145\x72\x20\x54\x6f\153\145\156\56");
return $DT;
XL:
$lU = explode("\x20", $kl);
$kl = $lU[1];
if ($kl != null) {
goto Nf;
}
$DT["\163\164\141\164\x75\x73"] = "\145\162\x72\157\x72";
$DT["\x68\164\164\x70\137\143\x6f\144\145"] = "\x34\x30\x34";
$DT["\x65\162\162\x6f\x72"] = "\x54\117\x4b\105\116\x5f\x4e\117\x54\137\106\117\x55\x4e\104";
$DT["\x6d\x65\x73\163\x61\x67\x65"] = "\111\156\x63\157\155\x70\154\x65\164\145\40\122\x65\x71\165\x65\163\164\x2e\x20\124\157\153\145\156\x20\x4e\157\164\40\146\157\x75\156\144\x2e";
goto gg;
Nf:
$user = DBQueries::get_user_id_from_access_token($kl);
if (!empty($user)) {
goto Hu;
}
$DT = array("\163\164\141\164\165\x73" => "\x65\162\162\x6f\x72", "\150\164\164\160\137\x63\x6f\x64\145" => "\x34\x30\61", "\145\x72\162\x6f\162" => "\x49\x4e\126\101\114\111\x44\137\x41\103\x43\x45\x53\x53\x5f\x54\x4f\113\105\x4e", "\145\162\162\157\162\137\144\145\x73\143\162\151\x70\164\151\157\156" => "\111\156\166\x61\x6c\x69\x64\40\101\143\143\x65\163\x73\x20\x54\157\x6b\x65\x6e\56");
return $DT;
Hu:
$hx = time();
$gG = \Drupal::config("\x72\145\163\164\137\141\x70\x69\137\x61\165\164\x68\x65\156\x74\x69\143\x61\x74\x69\157\156\56\163\145\164\x74\x69\156\x67\163")->get("\x74\157\x6b\x65\156\x5f\x65\x78\160\x69\x72\x79");
$gG = empty($gG) ? 3600 + $user["\141\x63\143\145\163\x73\x5f\164\x6f\x6b\145\156\137\x72\x65\x71\x75\145\163\164\137\164\x69\155\x65"] : $user["\x61\143\143\x65\163\163\137\x74\x6f\153\145\156\x5f\162\145\x71\x75\145\x73\x74\137\164\x69\x6d\x65"] + $gG * 60;
if (!($hx - $gG >= 0)) {
goto mK;
}
$DT = array("\163\164\141\164\x75\163" => "\145\162\162\x6f\x72", "\150\164\x74\x70\137\143\x6f\144\x65" => "\64\x30\61", "\x65\x72\x72\x6f\162" => "\124\x4f\113\105\116\137\105\130\120\x49\x52\x45\x44", "\x65\162\162\x6f\x72\137\144\x65\163\x63\162\x69\160\x74\x69\x6f\x6e" => "\111\156\x76\x61\154\x69\144\40\162\x65\x71\x75\145\163\x74\x3a\x20\124\157\x6b\145\x6e\40\105\170\160\151\162\145\x64\56");
return $DT;
mK:
$user = User::load($user["\x75\163\145\x72\137\151\x64\x5f\166\x61\154"]);
$DT["\163\164\141\x74\165\163"] = "\x53\125\x43\x43\x45\123\123";
$DT["\165\x73\145\162"] = $user;
gg:
return $DT;
}
}
Function Calls
None |
Stats
MD5 | dcdcb54baee4a41d82a2175ee6bb3a76 |
Eval Count | 0 |
Decode Time | 90 ms |