403Webshell
Server IP : 127.0.1.1  /  Your IP : 216.73.216.60
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux nepub 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.2.30
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : OFF
Directory :  /var/www/html/public_html/lib/pkp/classes/security/authorization/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /var/www/html/public_html/lib/pkp/classes/security/authorization/AllowedHostsPolicy.inc.php
<?php
/**
 * @file classes/security/authorization/AllowedHostsPolicy.inc.php
 *
 * Copyright (c) 2014-2022 Simon Fraser University
 * Copyright (c) 2000-2022 John Willinsky
 * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
 *
 * @class AllowedHostsPolicy
 * @ingroup security_authorization
 *
 * @brief Class to ensure allowed hosts, when configured, are respected. (pkp/pkp-lib#7649)
 */

import('lib.pkp.classes.security.authorization.AuthorizationPolicy');

class AllowedHostsPolicy extends AuthorizationPolicy {
	/** @var PKPRequest */
	var $_request;

	/**
	 * Constructor
	 *
	 * @param $request PKPRequest
	 */
	function __construct($request) {
		parent::__construct();
		$this->_request = $request;

		// Add advice
		$this->setAdvice(AUTHORIZATION_ADVICE_CALL_ON_DENY, [$this, 'callOnDeny', []]);
	}

	//
	// Implement template methods from AuthorizationPolicy
	//
	/**
	 * @see AuthorizationPolicy::applies()
	 */
	function applies() {
		return Config::getVar('general', 'allowed_hosts') != '';
	}

	/**
	 * @see AuthorizationPolicy::effect()
	 */
	function effect() {
		// The list of server hosts, when specified, is a JSON array. Decode it
		// and make it lowercase.
		$allowedHosts = Config::getVar('general', 'allowed_hosts');
		$allowedHosts = array_map('strtolower', json_decode($allowedHosts));
		$serverHost = $this->_request->getServerHost(null, false);
		return in_array(strtolower($serverHost), $allowedHosts) ? 
			AUTHORIZATION_PERMIT : AUTHORIZATION_DENY;
	}

	/**
	 * Handle a mismatch in the allowed hosts expectation.
	 */
	function callOnDeny() {
		http_response_code(400);
		error_log('Server host "' . $this->_request->getServerHost(null, false) . ' not allowed!');
                fatalError('400 Bad Request');
	}
}



Youez - 2016 - github.com/yon3zu
LinuXploit