AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.216.192
Web Server : Apache
System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : lrsys ( 1015)
PHP Version : 5.6.40
Disable Function : exec,passthru,shell_exec,system
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/helpers/google/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/leo/application/plugins/module_imobles/helpers/google/Google.php
<?php

class Google {

    protected $access_token;
    protected $refresh_token;
    protected $scope;
    protected $client_id;
    protected $client_secret;
    protected $credentials_path = 'application/plugins/module_imobles/uploads/google/';
    protected $api_key = 'AIzaSyDV8EiKB-3-jeqoB9qGR7oeQb-y9kLHoCU';

    public function __construct() {
        $creds = $this->creds();
        $this->setCredentials($creds);
        $refresh = file_get_contents($this->credentials_path.'refresh_token');
        if ($refresh) {
            $this->refresh_token = $refresh;
            $this->access_token = $this->refresh();
        }
    }

    public function setScope($scope) {
        $this->scope = $scope;
        return $this->scope;
    }

    public function authorize() {
        $url =  'https://accounts.google.com/o/oauth2/v2/auth?'.
                'scope='.urlencode($this->scope) .
                '&access_type=offline&'.
                'include_granted_scopes=true&'.
                'response_type=code&'.
                'redirect_uri='.urlencode($this->redirect_uri) .
                '&client_id='.urlencode($this->client_id);
        return $url;
    }

    public function isAuthorized() {
        return !!file_get_contents($this->credentials_path .'authorization_token.txt');
    }

    public function saveAuthorizationToken($token) {
        if (!preg_match('/\//', $token)) { //if urlencoded
            $token = urldecode($token);
        }
        //do not overwrite if auth token exists and new one is null/empty
        $path = $this->credentials_path . 'authorization_token.txt';
        if (file_get_contents($path) && !$token) {
            return;
        }
        if (file_put_contents($path, $token)) {
            $this->is_authorized = true;
            $this->getAccessToken($token);
        }
    }

    protected function getAccessToken($authorization_code) {
        $this->saveAuthorizationToken($authorization_token);
        $auth_url = "https://oauth2.googleapis.com/token";

        if (!$this->is_authorized) {
            return false;
        }

        $request_payload = [
            "code" =>$authorization_code,
            "redirect_uri"=>$this->redirect_uri,
            "client_id"=>$this->client_id,
            "client_secret"=>$this->client_secret,
            "grant_type"=>"authorization_code"
        ];

        $request = curl_init($auth_url);

        curl_setopt($request, CURLOPT_POST, true);
        curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($request, CURLOPT_POSTFIELDS, $request_payload);
        $response = curl_exec($request);
        $access = json_decode($response);
        $this->access_token = $access->access_token;
        $this->refresh_token = $access->refresh_token;
        if (!file_get_contents($this->credentials_path.'refresh_token')) {
            file_put_contents($this->credentials_path.'refresh_token', $this->refresh_token);
        }
        file_put_contents($this->credentials_path . 'access.json', json_encode($response));
    }

    protected function setCredentials($creds) {
        $keys = ['access_token', 'refresh_token', 'client_id','client_secret'];
        $creds = (array) $creds;
        $creds = $creds['web'];

        foreach ($keys as $key) {
            $this->$key = $creds[$key];
        }

        $this->redirect_uri = $creds['redirect_uris'][0];
    }

    protected function refresh() {
        $url = 'https://oauth2.googleapis.com/token';

        $refresh_request = curl_init($url);

        $payload = [
            'client_id'=>$this->client_id,
            'client_secret'=>$this->client_secret,
            'grant_type'=>'refresh_token',
            'refresh_token'=>$this->refresh_token
        ];

        curl_setopt($refresh_request, CURLOPT_POST, true);
        curl_setopt($refresh_request, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($refresh_request, CURLOPT_POSTFIELDS, $payload);
        $response = curl_exec($refresh_request);
        $creds = json_decode($response);
        return $creds->access_token;
    }

    protected function requestHeaders() {
        $headers = array(
            'Authorization: Bearer '.$this->access_token,
            'Accept: application/json'
        );
        return $headers;
    }

    private function creds() {
        return [
            "web"=> [
                "client_id"=> "602959371766-bimh097g0ukpevc9d04oeel7mmrvm10e.apps.googleusercontent.com",
                "project_id"=> "imobles-drive",
                "auth_uri"=> "https://accounts.google.com/o/oauth2/auth",
                "token_uri"=> "https://oauth2.googleapis.com/token",
                "auth_provider_x509_cert_url"=> "https://www.googleapis.com/oauth2/v1/certs",
                "client_secret"=> "cm-ZwXH7dQynHgV-RlM-eBjr",
                "redirect_uris"=> [
                    "https://rocket.myside.com.br/?ng=module_imobles/googleAuthorization/auth/"
                ]
            ]
        ];
    }

}


Anon7 - 2022
AnonSec Team