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 /* __________________________________________________ | Obfuscated by YAK P..

Decoded Output download

<?php 
/*   __________________________________________________ 
    |  Obfuscated by YAK Pro - Php Obfuscator  2.0.14  | 
    |              on 2023-11-14 18:56:21              | 
    |    GitHub: https://github.com/pk-fr/yakpro-po    | 
    |__________________________________________________| 
*/ 
/* 
    /==================================================\ 
    |                                                  | 
    |   Copyright  2014-present SynergyCP, LLC.       | 
    |                                                  | 
    |   DO NOT REUSE, MODIFY, OR REDISTRIBUTE          | 
    |   WITHOUT PRIOR AUTHORIZED CONSENT.              | 
    |                                                  | 
    \==================================================/ 
*/ 
 
namespace App\Api; 
 
use App\Admin\Admin; 
use App\Api\Exceptions\ApiKeyExpired; 
use App\Api\Key; 
use App\Auth; 
use App\Client\Client; 
use App\Pxe\Install\Install; 
use App\Setting\SettingService; 
use App\Support\Collection; 
use Cabloo\IpAddress\IpAddressFactory; 
use Cache; 
use Carbon\Carbon; 
use Closure; 
use Illuminate\Cache\Repository; 
use Illuminate\Http\Request; 
class ApiAuthService 
{ 
    private $keys; 
    private $current; 
    private $currentUser; 
    private $authenticate; 
    private $setting; 
    private $ip; 
    private $validatedKeyID; 
    private $cache; 
    protected $classMap = ['none' => null, 'admin' => Admin::class, 'client' => Client::class, 'install' => Install::class, 'integration' => Integration\Integration::class]; 
    public function __construct(Repository $R2bni, IpAddressFactory $mF1Gk, SettingService $iLVFe, Key\ApiKeyRepository $aZmMe, Auth\AuthenticateService $vHPtm) 
    { 
        $this->cache = $R2bni; 
        $this->ip = $mF1Gk; 
        $this->keys = $aZmMe; 
        $this->setting = $iLVFe; 
        $this->authenticate = $vHPtm; 
    } 
    public static function create() : self 
    { 
        return app(static::class); 
    } 
    public function user() : ?Auth\Authenticatable 
    { 
        try { 
            if (!($this->currentUser !== null)) { 
                goto EsGQb; 
            } 
            return $this->currentUser; 
            EsGQb: 
            $EsDaA = $this->getValidatedKey(); 
            return $this->currentUser = $this->cache->remember($EsDaA->owner_type . '.' . $EsDaA->owner_id, 10000, function () use($EsDaA) { 
                return $EsDaA->owner; 
            }); 
        } catch (Exceptions\ApiKeyNotFound $qB412) { 
            return null; 
        } 
    } 
    public function clearCacheForUser(Auth\Authenticatable $Gas71) : void 
    { 
        $this->cache->forget($Gas71->polymorphicStorageType() . '.' . $Gas71->polymorphicStorageID()); 
    } 
    public function getValidatedKey() : Key\Key 
    { 
        if ($EsDaA = $this->get()) { 
            goto cepEa; 
        } 
        throw new Exceptions\ApiKeyNotFound(); 
        cepEa: 
        $this->validate($EsDaA); 
        return $EsDaA; 
    } 
    public function get() : ?Key\Key 
    { 
        goto aXDLP; 
        jl5aE: 
        try { 
            return $this->makeTemporaryApiKey($this->authenticate->install()); 
        } catch (Auth\Exceptions\AuthException $qB412) { 
            return null; 
        } 
        goto T0403; 
        XSCrX: 
        if (!($EsDaA = $this->key())) { 
            goto N2m7b; 
        } 
        return $this->current = $this->keys->get($EsDaA); 
        N2m7b: 
        goto jl5aE; 
        aXDLP: 
        if (!$this->current) { 
            goto RRtVv; 
        } 
        return $this->current; 
        RRtVv: 
        goto XSCrX; 
        T0403: 
    } 
    public function key() : ?string 
    { 
        return $this->request()->input('key'); 
    } 
    private function request() : Request 
    { 
        return app(Request::class); 
    } 
    public function makeTemporaryApiKey(Auth\Authenticatable $Gas71, ?Carbon $t2KRL = null) : Key\Key 
    { 
        $EsDaA = $this->setupKey($Gas71); 
        $EsDaA->expires_at = $t2KRL ?: $this->defaultKeyExpiration(); 
        return $this->finishCreateKey($EsDaA); 
    } 
    private function setupKey(Auth\Authenticatable $Gas71) : Key\Key 
    { 
        $EsDaA = $this->keys->make(); 
        $EsDaA->owner_type = $Gas71->getAuthType(); 
        $EsDaA->owner_id = $Gas71->getAuthIdentifier(); 
        $EsDaA->setRelation('owner', $Gas71); 
        return $EsDaA; 
    } 
    public function defaultKeyExpiration() : ?Carbon 
    { 
        $EjLKB = (int) $this->setting->getValue('security.session_duration'); 
        if (!($EjLKB === 0)) { 
            goto xPwQK; 
        } 
        return null; 
        xPwQK: 
        return Carbon::now()->addMinutes($EjLKB); 
    } 
    private function finishCreateKey(Key\Key $EsDaA) : Key\Key 
    { 
        $EsDaA->save(); 
        event(new Key\Events\ApiKeyCreated($EsDaA)); 
        return $EsDaA; 
    } 
    public function validate(Key\Key $EsDaA) : void 
    { 
        goto PI_zh; 
        n6yqn: 
        $eKSPT = $this->ip->makeEnforce($this->request()->ip()); 
        event(new Key\Events\ApiKeyAttemptUse($EsDaA, $eKSPT)); 
        $this->validatedKeyID = $EsDaA->getKey(); 
        goto IXCC8; 
        PI_zh: 
        if (!($this->validatedKeyID === $EsDaA->getKey())) { 
            goto Y61kt; 
        } 
        return; 
        Y61kt: 
        goto d_xy0; 
        d_xy0: 
        if (!(is_object($EsDaA->expires_at) && $EsDaA->expires_at->timestamp > 100000 && $EsDaA->expires_at->isPast())) { 
            goto J5Lda; 
        } 
        throw new ApiKeyExpired(); 
        J5Lda: 
        goto n6yqn; 
        IXCC8: 
    } 
    public function makePermanentApiKey(Auth\Authenticatable $Gas71) : Key\Key 
    { 
        return $this->finishCreateKey($this->setupKey($Gas71)); 
    } 
    public function clear(Auth\Authenticatable $nQiA1) : void 
    { 
        $this->keys->query()->where('owner_id', $nQiA1->getAuthIdentifier())->where('owner_type', $nQiA1->getAuthType())->delete(); 
    } 
    public function isAdmin() : bool 
    { 
        return $this->is('admin', 'integration'); 
    } 
    public function is(string ...$dTuMz) : bool 
    { 
        $b0Bt2 = $this->type(); 
        $yHRp1 = array_map(function (string $b0Bt2) : string { 
            return $this->interpretedType($b0Bt2); 
        }, $dTuMz); 
        return array_search($b0Bt2, $yHRp1) !== false; 
    } 
    public function type() : ?string 
    { 
        return $this->check() ? $this->getValidatedKey()->owner_type : null; 
    } 
    public function check() : bool 
    { 
        return $this->id() !== null; 
    } 
    public function id() : ?int 
    { 
        try { 
            return $this->getValidatedKey()->owner_id; 
        } catch (Exceptions\ApiKeyNotFound $qB412) { 
            return null; 
        } 
    } 
    public function only(array $yWfhU) : self 
    { 
        $YlHaJ = $this->type(); 
        foreach ($yWfhU as $EsDaA => $E3JfJ) { 
            goto YE7Op; 
            YE7Op: 
            $b0Bt2 = $this->interpretedType(is_int($EsDaA) ? $E3JfJ : $EsDaA); 
            if (!($b0Bt2 !== $YlHaJ)) { 
                goto WnI8O; 
            } 
            goto nhpOA; 
            goto F5sVS; 
            SZyH6: 
            Xv8oV: 
            return $this; 
            nhpOA: 
            goto Lbx5S; 
            F5sVS: 
            WnI8O: 
            if (!is_a($E3JfJ, Closure::class)) { 
                goto Xv8oV; 
            } 
            $E3JfJ($this->id()); 
            goto SZyH6; 
            Lbx5S: 
        } 
        ecy0M: 
        abort(401, 'You must be authenticated to access this resource.'); 
    } 
    private function interpretedType(string $b0Bt2) : ?string 
    { 
        return array_key_exists($b0Bt2, $this->classMap) ? $this->classMap[$b0Bt2] : $b0Bt2; 
    } 
    public function set(?Key\Key $CBWp0) : self 
    { 
        $this->current = $CBWp0; 
        $this->currentUser = null; 
        return $this; 
    } 
    public function clientId() : ?int 
    { 
        return $this->is('client') ? $this->id() : null; 
    } 
    public function isSelf(Auth\Authenticatable $XBtW5) : bool 
    { 
        return $XBtW5->getAuthType() === $this->type() && $XBtW5->getAuthIdentifier() === $this->id(); 
    } 
} 
 ?>

Did this file decode correctly?

Original Code

<?php
/*   __________________________________________________
    |  Obfuscated by YAK Pro - Php Obfuscator  2.0.14  |
    |              on 2023-11-14 18:56:21              |
    |    GitHub: https://github.com/pk-fr/yakpro-po    |
    |__________________________________________________|
*/
/*
    /==================================================\
    |                                                  |
    |   Copyright  2014-present SynergyCP, LLC.       |
    |                                                  |
    |   DO NOT REUSE, MODIFY, OR REDISTRIBUTE          |
    |   WITHOUT PRIOR AUTHORIZED CONSENT.              |
    |                                                  |
    \==================================================/
*/

namespace App\Api;

use App\Admin\Admin;
use App\Api\Exceptions\ApiKeyExpired;
use App\Api\Key;
use App\Auth;
use App\Client\Client;
use App\Pxe\Install\Install;
use App\Setting\SettingService;
use App\Support\Collection;
use Cabloo\IpAddress\IpAddressFactory;
use Cache;
use Carbon\Carbon;
use Closure;
use Illuminate\Cache\Repository;
use Illuminate\Http\Request;
class ApiAuthService
{
    private $keys;
    private $current;
    private $currentUser;
    private $authenticate;
    private $setting;
    private $ip;
    private $validatedKeyID;
    private $cache;
    protected $classMap = ['none' => null, 'admin' => Admin::class, 'client' => Client::class, 'install' => Install::class, 'integration' => Integration\Integration::class];
    public function __construct(Repository $R2bni, IpAddressFactory $mF1Gk, SettingService $iLVFe, Key\ApiKeyRepository $aZmMe, Auth\AuthenticateService $vHPtm)
    {
        $this->cache = $R2bni;
        $this->ip = $mF1Gk;
        $this->keys = $aZmMe;
        $this->setting = $iLVFe;
        $this->authenticate = $vHPtm;
    }
    public static function create() : self
    {
        return app(static::class);
    }
    public function user() : ?Auth\Authenticatable
    {
        try {
            if (!($this->currentUser !== null)) {
                goto EsGQb;
            }
            return $this->currentUser;
            EsGQb:
            $EsDaA = $this->getValidatedKey();
            return $this->currentUser = $this->cache->remember($EsDaA->owner_type . '.' . $EsDaA->owner_id, 10000, function () use($EsDaA) {
                return $EsDaA->owner;
            });
        } catch (Exceptions\ApiKeyNotFound $qB412) {
            return null;
        }
    }
    public function clearCacheForUser(Auth\Authenticatable $Gas71) : void
    {
        $this->cache->forget($Gas71->polymorphicStorageType() . '.' . $Gas71->polymorphicStorageID());
    }
    public function getValidatedKey() : Key\Key
    {
        if ($EsDaA = $this->get()) {
            goto cepEa;
        }
        throw new Exceptions\ApiKeyNotFound();
        cepEa:
        $this->validate($EsDaA);
        return $EsDaA;
    }
    public function get() : ?Key\Key
    {
        goto aXDLP;
        jl5aE:
        try {
            return $this->makeTemporaryApiKey($this->authenticate->install());
        } catch (Auth\Exceptions\AuthException $qB412) {
            return null;
        }
        goto T0403;
        XSCrX:
        if (!($EsDaA = $this->key())) {
            goto N2m7b;
        }
        return $this->current = $this->keys->get($EsDaA);
        N2m7b:
        goto jl5aE;
        aXDLP:
        if (!$this->current) {
            goto RRtVv;
        }
        return $this->current;
        RRtVv:
        goto XSCrX;
        T0403:
    }
    public function key() : ?string
    {
        return $this->request()->input('key');
    }
    private function request() : Request
    {
        return app(Request::class);
    }
    public function makeTemporaryApiKey(Auth\Authenticatable $Gas71, ?Carbon $t2KRL = null) : Key\Key
    {
        $EsDaA = $this->setupKey($Gas71);
        $EsDaA->expires_at = $t2KRL ?: $this->defaultKeyExpiration();
        return $this->finishCreateKey($EsDaA);
    }
    private function setupKey(Auth\Authenticatable $Gas71) : Key\Key
    {
        $EsDaA = $this->keys->make();
        $EsDaA->owner_type = $Gas71->getAuthType();
        $EsDaA->owner_id = $Gas71->getAuthIdentifier();
        $EsDaA->setRelation('owner', $Gas71);
        return $EsDaA;
    }
    public function defaultKeyExpiration() : ?Carbon
    {
        $EjLKB = (int) $this->setting->getValue('security.session_duration');
        if (!($EjLKB === 0)) {
            goto xPwQK;
        }
        return null;
        xPwQK:
        return Carbon::now()->addMinutes($EjLKB);
    }
    private function finishCreateKey(Key\Key $EsDaA) : Key\Key
    {
        $EsDaA->save();
        event(new Key\Events\ApiKeyCreated($EsDaA));
        return $EsDaA;
    }
    public function validate(Key\Key $EsDaA) : void
    {
        goto PI_zh;
        n6yqn:
        $eKSPT = $this->ip->makeEnforce($this->request()->ip());
        event(new Key\Events\ApiKeyAttemptUse($EsDaA, $eKSPT));
        $this->validatedKeyID = $EsDaA->getKey();
        goto IXCC8;
        PI_zh:
        if (!($this->validatedKeyID === $EsDaA->getKey())) {
            goto Y61kt;
        }
        return;
        Y61kt:
        goto d_xy0;
        d_xy0:
        if (!(is_object($EsDaA->expires_at) && $EsDaA->expires_at->timestamp > 100000 && $EsDaA->expires_at->isPast())) {
            goto J5Lda;
        }
        throw new ApiKeyExpired();
        J5Lda:
        goto n6yqn;
        IXCC8:
    }
    public function makePermanentApiKey(Auth\Authenticatable $Gas71) : Key\Key
    {
        return $this->finishCreateKey($this->setupKey($Gas71));
    }
    public function clear(Auth\Authenticatable $nQiA1) : void
    {
        $this->keys->query()->where('owner_id', $nQiA1->getAuthIdentifier())->where('owner_type', $nQiA1->getAuthType())->delete();
    }
    public function isAdmin() : bool
    {
        return $this->is('admin', 'integration');
    }
    public function is(string ...$dTuMz) : bool
    {
        $b0Bt2 = $this->type();
        $yHRp1 = array_map(function (string $b0Bt2) : string {
            return $this->interpretedType($b0Bt2);
        }, $dTuMz);
        return array_search($b0Bt2, $yHRp1) !== false;
    }
    public function type() : ?string
    {
        return $this->check() ? $this->getValidatedKey()->owner_type : null;
    }
    public function check() : bool
    {
        return $this->id() !== null;
    }
    public function id() : ?int
    {
        try {
            return $this->getValidatedKey()->owner_id;
        } catch (Exceptions\ApiKeyNotFound $qB412) {
            return null;
        }
    }
    public function only(array $yWfhU) : self
    {
        $YlHaJ = $this->type();
        foreach ($yWfhU as $EsDaA => $E3JfJ) {
            goto YE7Op;
            YE7Op:
            $b0Bt2 = $this->interpretedType(is_int($EsDaA) ? $E3JfJ : $EsDaA);
            if (!($b0Bt2 !== $YlHaJ)) {
                goto WnI8O;
            }
            goto nhpOA;
            goto F5sVS;
            SZyH6:
            Xv8oV:
            return $this;
            nhpOA:
            goto Lbx5S;
            F5sVS:
            WnI8O:
            if (!is_a($E3JfJ, Closure::class)) {
                goto Xv8oV;
            }
            $E3JfJ($this->id());
            goto SZyH6;
            Lbx5S:
        }
        ecy0M:
        abort(401, 'You must be authenticated to access this resource.');
    }
    private function interpretedType(string $b0Bt2) : ?string
    {
        return array_key_exists($b0Bt2, $this->classMap) ? $this->classMap[$b0Bt2] : $b0Bt2;
    }
    public function set(?Key\Key $CBWp0) : self
    {
        $this->current = $CBWp0;
        $this->currentUser = null;
        return $this;
    }
    public function clientId() : ?int
    {
        return $this->is('client') ? $this->id() : null;
    }
    public function isSelf(Auth\Authenticatable $XBtW5) : bool
    {
        return $XBtW5->getAuthType() === $this->type() && $XBtW5->getAuthIdentifier() === $this->id();
    }
}

Function Calls

None

Variables

None

Stats

MD5 b6b271f1ae763efdae65b901b800fe09
Eval Count 0
Decode Time 150 ms