Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560
[2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85
[3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50
[4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13
[5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
403WebShell
403Webshell
Server IP : 94.177.8.99  /  Your IP : 216.73.217.165
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/patientapps_support/modules/loginGoogle/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/patientapps_support/modules/loginGoogle/main.php
<?php

namespace modules\loginGoogle;

use League\OAuth2\Client\Provider\Google;

class main extends \moduleMain {

	use \modules\input\traits {
			\modules\input\traits::__construct as __ConstructInput;
		}
	use \modules\database\traits {
			\modules\database\traits::__construct as __ConstructDatabase;
		}
	use \modules\output\traits {
			\modules\output\traits::__construct as __ConstructOutput;
		}

	public function __construct() {
		parent::__construct(__DIR__);
		$this->__ConstructInput();
		$this->__ConstructDatabase();
		$this->__ConstructOutput();
	}

	static function getHandle() {
		static $handle = NULL;
		if ($handle === NULL) {
			$handle = new static();
		}
		return $handle;
	}
	
	public function Activate() {
	// install hooks
		hook_add('auth.google.button', [$this, '__generate_button']);
		hook_add('auth.*.login', [$this, '__info']);	
		hook_add('auth.*.css', [$this, '__css']);	
		hook_add('auth.google.login', [$this, '__login_info']);		// information for login button / link /  generate auth field for user level to be used
		// add include items to template
		$this->css = $this->StaticUriModule(__DIR__) . '/google.css';
	}

	public function __css(&$results) {
		$results[] = $this->css;
	}

	public function __generate_button(&$html) {
		$html = hook_execute_late('html.button', '', 'Sign in with Google', 'fab fa-google', 'cc-blue');
	}

	public final function settings_help() {
		$view = $this->__loadView('google_help');
		$body = $view->text_info();
		return ['body' => $body];
	}

    // add to google credential Authorized redirect URIs:
    // https:// ... /~/logingoogle/authorize
    
	public final function authorize() {
		$this->_init();
		if (!isset($_GET['code'])) return;		// invalid

		if (!isset($_SESSION['loginGoogle'])) return;	// taken too long
		
		$token = $this->client->getAccessToken('authorization_code', [
			'code' => $_GET['code']
		]);		
			
		$_SESSION['google_access_token'] = $token;

		// get user info
		$userinfo = $this->client->getResourceOwner($token);		// $userinfo->getFirstName()		
		$values = $userinfo->toArray();
		$email_verified = $values['email_verified'];	// public method missing from class
		$source_id = $userinfo->getId();
		$email = $userinfo->getEmail();

		$session = $_SESSION['loginGoogle'];
		$existing_user = $session['user_id'];
		$params = new \StdClass;
		$params->user_id = $existing_user;
		$params->level = 1;
		$params->email = $email;
		$params->source = 'google';
		$params->source_id = $source_id;
		$params->verified = $email_verified;
		$params->name = $userinfo->getName();
		$params->picture = $userinfo->getAvatar();

        $newlevel = $this->settings['newuser'] ?? 0;
		if (!empty($session['auth'])) {	// A login should be created
			$level = hook_execute('nonce.verify', FALSE, 'loglevel', FALSE, $session['auth']);	// return $key, if key param is false
			if ($level === FALSE) return;		// auth data expired, or already used
			$params->level = $level;
			$user_info = hook_execute('login.create', NULL, $params);
		} else {		// user must exist in database
			$user_info = hook_execute('login.verify', NULL, $params);
		}
        if ($user_info === NULL && $email_verified) {
            if (!$newlevel) {       // creation of new users is disabled
                return [
                    'result' => 1593,
                    'message' => 'new users are not permitted at this time'
                ];
            }
			$params->level = $newlevel;
			$user_info = hook_execute('login.create', NULL, $params);
        }
        
		if ($user_info !== NULL) {
			hook_execute('login', 0, $user_info);			// log in as user $user_id
		}
		// Redirect to bounce url - may give permission denied error at that point

		$uri = $_SESSION['loginGoogle']['bounce'] ?? NULL;
		if(!is_null($uri)) {
			if (substr($uri, 0, 6) != '/login') {
				$this->Redirect($uri);
			} else {
				$this->Redirect('/');
				//die("\nCannot redirect to login\n");
			}
		}
	}
	
	private function _init() {
		if (empty($this->client)) {
			try {
				
				$uri = 'https://' . $this->hostname() . '/~/logingoogle/authorize';
				$this->client = new Google([
					'clientId'     => $this->settings['clientid'],
					'clientSecret' => $this->settings['secret'],
					'redirectUri'  => $uri,
				]);
			} catch(Exception $e) {
				var_dump($e);
				exit;
			}
		}
	}

/* 
	IN:
		$param = [
			'bounce' => url to visit once account has been verified (back from google login; or when email address is verified)
			'auth'	=> user level. If present this will allow new account to be created;  otherwise log in with existing creds
		]
	OUT: 
		$info = [
			'link'		=> link to login page (or create account page)
			'button'	=> caption for link
		]
		
		or 
		
		$info === FALSE -> incomplete settings, or module not enabled
*/

	public function __info(&$results, $param) {
		$res = [];
		$this->__login_info($res, $param);
		$results['google'] = $res;
	}
	
	private function _encode($x) {
		return str_replace(['+', '/', '='], ['-', '_', '~'], base64_encode($x));
	}
	private function _decode($x) {
		return base64_decode(str_replace(['+', '/', '='], ['-', '_', '~'], $x));
	}
	
	public function __login_info(&$info, $param) {
		if (empty($this->settings['clientid']) || empty($this->settings['secret'])) {
			$info = FALSE;
			return;		// insufficient config options specified.
		}
		$this->_init();

		$googleAuthUrl = $this->client->getAuthorizationUrl([
			'scope' => [
				'email', 'profile'
			],
		]);
		// save bounce and auth in session
		$_SESSION['loginGoogle'] = [
			'auth' => empty($param['auth']) ? '' : $param['auth'],
			'bounce' => $param['bounce'],
			'user_id' => empty($param['user_id']) ? 0 : $param['user_id'],
		];
		
		$html = <<<BLOCK
<div style="height:50px;width:240px;" class="abcRioButton abcRioButtonBlue"><div class="abcRioButtonContentWrapper"><div class="abcRioButtonIcon" style="padding:15px"><div style="width:18px;height:18px;" class="abcRioButtonSvgImageWithFallback abcRioButtonIconImage abcRioButtonIconImage18"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="18px" height="18px" viewBox="0 0 48 48" class="abcRioButtonSvg"><g><path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"></path><path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"></path><path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"></path><path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"></path><path fill="none" d="M0 0h48v48H0z"></path></g></svg></div></div><span style="font-size:16px;line-height:48px;" class="abcRioButtonContents"><span id="not_signed_inakcyjp4f0j9t">Sign in with Google</span><span id="connectedakcyjp4f0j9t" style="display:none">Signed in with Google</span></span></div></div>
BLOCK;
		$info = [
			'link' => $googleAuthUrl,
			'button' => $html,
			'css' => $this->css,
		];
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit