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 {
|
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 $_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 $_access = array();
|
||||||
protected $_headers = array();
|
protected $_headers = array();
|
||||||
protected $_siteControl = '';
|
protected $_siteControl = '';
|
||||||
|
|
||||||
protected $_cache = '';
|
protected $_cache = '';
|
||||||
|
|
||||||
protected $_cacheValid = false;
|
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') {
|
public function setSiteControl($permittedCrossDomainPolicies = 'all') {
|
||||||
if (!$this->validateSiteControl($permittedCrossDomainPolicies)) {
|
if (!$this->validateSiteControl($permittedCrossDomainPolicies)) {
|
||||||
throw new \UnexpectedValueException('Invalid site control set');
|
throw new \UnexpectedValueException('Invalid site control set');
|
||||||
@ -77,6 +81,12 @@ class FlashPolicyComponent implements MessageComponentInterface {
|
|||||||
$this->_siteControl = $permittedCrossDomainPolicies;
|
$this->_siteControl = $permittedCrossDomainPolicies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* renderPolicy function.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function renderPolicy() {
|
public function renderPolicy() {
|
||||||
|
|
||||||
$policy = new \SimpleXMLElement($this->_policy);
|
$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) {
|
public function addAllowedAccess($domain, $ports = '*', $secure = false) {
|
||||||
|
|
||||||
if (!$this->validateDomain($domain)) {
|
if (!$this->validateDomain($domain)) {
|
||||||
@ -127,6 +146,15 @@ class FlashPolicyComponent implements MessageComponentInterface {
|
|||||||
$this->_cacheValid = false;
|
$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) {
|
public function addAllowedHTTPRequestHeaders($domain, $headers, $secure = true) {
|
||||||
|
|
||||||
if (!$this->validateDomain($domain)) {
|
if (!$this->validateDomain($domain)) {
|
||||||
@ -139,12 +167,25 @@ class FlashPolicyComponent implements MessageComponentInterface {
|
|||||||
$this->_cacheValid = false;
|
$this->_cacheValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* validateSiteControl function.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed $permittedCrossDomainPolicies
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function validateSiteControl($permittedCrossDomainPolicies) {
|
public function validateSiteControl($permittedCrossDomainPolicies) {
|
||||||
|
|
||||||
return (bool)in_array($permittedCrossDomainPolicies, array('none', 'master-only', 'by-content-type', 'all'));
|
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) {
|
public function validateDomain($domain) {
|
||||||
|
|
||||||
if ($domain == '*') {
|
if ($domain == '*') {
|
||||||
@ -155,7 +196,6 @@ class FlashPolicyComponent implements MessageComponentInterface {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$d = parse_url($domain);
|
$d = parse_url($domain);
|
||||||
if (!isset($d['scheme']) || empty($d['scheme'])) {
|
if (!isset($d['scheme']) || empty($d['scheme'])) {
|
||||||
$domain = 'http://' . $domain;
|
$domain = 'http://' . $domain;
|
||||||
@ -177,6 +217,13 @@ class FlashPolicyComponent implements MessageComponentInterface {
|
|||||||
return (bool)filter_var(str_replace(array('*.', '.*'), '123', $domain), FILTER_VALIDATE_URL);
|
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) {
|
public function validatePorts($port) {
|
||||||
|
|
||||||
if ($port == '*') {
|
if ($port == '*') {
|
||||||
@ -208,6 +255,13 @@ class FlashPolicyComponent implements MessageComponentInterface {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* validateHeaders function.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed $headers
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function validateHeaders($headers) {
|
public function validateHeaders($headers) {
|
||||||
|
|
||||||
if ($headers == '*') {
|
if ($headers == '*') {
|
||||||
@ -229,6 +283,13 @@ class FlashPolicyComponent implements MessageComponentInterface {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* validateSecure function.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed $secure
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function validateSecure($secure) {
|
public function validateSecure($secure) {
|
||||||
|
|
||||||
return is_bool($secure);
|
return is_bool($secure);
|
||||||
|
Loading…
Reference in New Issue
Block a user