Code cleanup and start of some commenting
This commit is contained in:
		
							parent
							
								
									d0e471f4e0
								
							
						
					
					
						commit
						532323c497
					
				@ -17,14 +17,11 @@ use Ratchet\Resource\Command\CommandInterface;
 | 
			
		||||
class FlashPolicyComponent implements MessageComponentInterface {
 | 
			
		||||
 | 
			
		||||
    protected $_policy      = '<?xml version="1.0"?><!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"><cross-domain-policy></cross-domain-policy>';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    protected $_access      = array();
 | 
			
		||||
    protected $_headers     = array();
 | 
			
		||||
    protected $_siteControl = '';
 | 
			
		||||
 | 
			
		||||
    protected $_cache      = '';
 | 
			
		||||
 | 
			
		||||
    protected $_cacheValid = false;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -70,6 +67,13 @@ class FlashPolicyComponent implements MessageComponentInterface {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * setSiteControl function.
 | 
			
		||||
     * 
 | 
			
		||||
     * @access public
 | 
			
		||||
     * @param string $permittedCrossDomainPolicies (default: 'all')
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function setSiteControl($permittedCrossDomainPolicies = 'all') {
 | 
			
		||||
        if (!$this->validateSiteControl($permittedCrossDomainPolicies)) {
 | 
			
		||||
            throw new \UnexpectedValueException('Invalid site control set');
 | 
			
		||||
@ -77,6 +81,12 @@ class FlashPolicyComponent implements MessageComponentInterface {
 | 
			
		||||
        $this->_siteControl = $permittedCrossDomainPolicies;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * renderPolicy function.
 | 
			
		||||
     * 
 | 
			
		||||
     * @access public
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function renderPolicy() {
 | 
			
		||||
 | 
			
		||||
        $policy = new \SimpleXMLElement($this->_policy);
 | 
			
		||||
@ -113,6 +123,15 @@ class FlashPolicyComponent implements MessageComponentInterface {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * addAllowedAccess function.
 | 
			
		||||
     * 
 | 
			
		||||
     * @access public
 | 
			
		||||
     * @param mixed $domain
 | 
			
		||||
     * @param string $ports (default: '*')
 | 
			
		||||
     * @param bool $secure (default: false)
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function addAllowedAccess($domain, $ports = '*', $secure = false) {
 | 
			
		||||
 | 
			
		||||
        if (!$this->validateDomain($domain)) {
 | 
			
		||||
@ -127,6 +146,15 @@ class FlashPolicyComponent implements MessageComponentInterface {
 | 
			
		||||
        $this->_cacheValid = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * addAllowedHTTPRequestHeaders function.
 | 
			
		||||
     * 
 | 
			
		||||
     * @access public
 | 
			
		||||
     * @param mixed $domain
 | 
			
		||||
     * @param mixed $headers
 | 
			
		||||
     * @param bool $secure (default: true)
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function addAllowedHTTPRequestHeaders($domain, $headers, $secure = true) {
 | 
			
		||||
 | 
			
		||||
        if (!$this->validateDomain($domain)) {
 | 
			
		||||
@ -139,12 +167,25 @@ class FlashPolicyComponent implements MessageComponentInterface {
 | 
			
		||||
        $this->_cacheValid = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * validateSiteControl function.
 | 
			
		||||
     * 
 | 
			
		||||
     * @access public
 | 
			
		||||
     * @param mixed $permittedCrossDomainPolicies
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function validateSiteControl($permittedCrossDomainPolicies) {
 | 
			
		||||
 | 
			
		||||
        return (bool)in_array($permittedCrossDomainPolicies, array('none', 'master-only', 'by-content-type', 'all'));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * validateDomain function.
 | 
			
		||||
     * 
 | 
			
		||||
     * @access public
 | 
			
		||||
     * @param mixed $domain
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function validateDomain($domain) {
 | 
			
		||||
 | 
			
		||||
        if ($domain == '*') {
 | 
			
		||||
@ -155,7 +196,6 @@ class FlashPolicyComponent implements MessageComponentInterface {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        $d = parse_url($domain);
 | 
			
		||||
        if (!isset($d['scheme']) || empty($d['scheme'])) {
 | 
			
		||||
            $domain = 'http://' . $domain;
 | 
			
		||||
@ -177,6 +217,13 @@ class FlashPolicyComponent implements MessageComponentInterface {
 | 
			
		||||
        return (bool)filter_var(str_replace(array('*.', '.*'), '123', $domain), FILTER_VALIDATE_URL);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * validatePorts function.
 | 
			
		||||
     * 
 | 
			
		||||
     * @access public
 | 
			
		||||
     * @param mixed $port
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function validatePorts($port) {
 | 
			
		||||
 | 
			
		||||
        if ($port == '*') {
 | 
			
		||||
@ -208,6 +255,13 @@ class FlashPolicyComponent implements MessageComponentInterface {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * validateHeaders function.
 | 
			
		||||
     * 
 | 
			
		||||
     * @access public
 | 
			
		||||
     * @param mixed $headers
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function validateHeaders($headers) {
 | 
			
		||||
 | 
			
		||||
        if ($headers == '*') {
 | 
			
		||||
@ -229,6 +283,13 @@ class FlashPolicyComponent implements MessageComponentInterface {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * validateSecure function.
 | 
			
		||||
     * 
 | 
			
		||||
     * @access public
 | 
			
		||||
     * @param mixed $secure
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function validateSecure($secure) {
 | 
			
		||||
 | 
			
		||||
        return is_bool($secure);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user