* some changes

* moved some admin html code from php to twig templates (.html files)
* minimum PHP version required by installer is now 5.1.2, cause of spl_autoload_register functon.
* depracated Twig to version 1.20.0 cause of Autoloader
* removed unused admin stylish template
This commit is contained in:
slawkens
2017-08-28 10:02:49 +02:00
parent 603c2175e3
commit 15961f0c17
418 changed files with 15624 additions and 4322 deletions

View File

@@ -1,11 +1,19 @@
<?php
namespace Twig\Sandbox;
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class_exists('Twig_Sandbox_SecurityError');
if (\false) {
class SecurityError extends \Twig_Sandbox_SecurityError
{
}
/**
* Exception thrown when a security error occurs at runtime.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Twig_Sandbox_SecurityError extends Twig_Error
{
}

View File

@@ -1,11 +1,31 @@
<?php
namespace Twig\Sandbox;
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class_exists('Twig_Sandbox_SecurityNotAllowedFilterError');
/**
* Exception thrown when a not allowed filter is used in a template.
*
* @author Martin Hasoň <martin.hason@gmail.com>
*/
class Twig_Sandbox_SecurityNotAllowedFilterError extends Twig_Sandbox_SecurityError
{
private $filterName;
if (\false) {
class SecurityNotAllowedFilterError extends \Twig_Sandbox_SecurityNotAllowedFilterError
public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null)
{
parent::__construct($message, $lineno, $filename, $previous);
$this->filterName = $functionName;
}
public function getFilterName()
{
return $this->filterName;
}
}

View File

@@ -1,11 +1,31 @@
<?php
namespace Twig\Sandbox;
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class_exists('Twig_Sandbox_SecurityNotAllowedFunctionError');
/**
* Exception thrown when a not allowed function is used in a template.
*
* @author Martin Hasoň <martin.hason@gmail.com>
*/
class Twig_Sandbox_SecurityNotAllowedFunctionError extends Twig_Sandbox_SecurityError
{
private $functionName;
if (\false) {
class SecurityNotAllowedFunctionError extends \Twig_Sandbox_SecurityNotAllowedFunctionError
public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null)
{
parent::__construct($message, $lineno, $filename, $previous);
$this->functionName = $functionName;
}
public function getFunctionName()
{
return $this->functionName;
}
}

View File

@@ -1,11 +0,0 @@
<?php
namespace Twig\Sandbox;
class_exists('Twig_Sandbox_SecurityNotAllowedMethodError');
if (\false) {
class SecurityNotAllowedMethodError extends \Twig_Sandbox_SecurityNotAllowedMethodError
{
}
}

View File

@@ -1,11 +0,0 @@
<?php
namespace Twig\Sandbox;
class_exists('Twig_Sandbox_SecurityNotAllowedPropertyError');
if (\false) {
class SecurityNotAllowedPropertyError extends \Twig_Sandbox_SecurityNotAllowedPropertyError
{
}
}

View File

@@ -1,11 +1,31 @@
<?php
namespace Twig\Sandbox;
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class_exists('Twig_Sandbox_SecurityNotAllowedTagError');
/**
* Exception thrown when a not allowed tag is used in a template.
*
* @author Martin Hasoň <martin.hason@gmail.com>
*/
class Twig_Sandbox_SecurityNotAllowedTagError extends Twig_Sandbox_SecurityError
{
private $tagName;
if (\false) {
class SecurityNotAllowedTagError extends \Twig_Sandbox_SecurityNotAllowedTagError
public function __construct($message, $tagName, $lineno = -1, $filename = null, Exception $previous = null)
{
parent::__construct($message, $lineno, $filename, $previous);
$this->tagName = $tagName;
}
public function getTagName()
{
return $this->tagName;
}
}

View File

@@ -1,11 +1,119 @@
<?php
namespace Twig\Sandbox;
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class_exists('Twig_Sandbox_SecurityPolicy');
/**
* Represents a security policy which need to be enforced when sandbox mode is enabled.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterface
{
protected $allowedTags;
protected $allowedFilters;
protected $allowedMethods;
protected $allowedProperties;
protected $allowedFunctions;
if (\false) {
class SecurityPolicy extends \Twig_Sandbox_SecurityPolicy
public function __construct(array $allowedTags = array(), array $allowedFilters = array(), array $allowedMethods = array(), array $allowedProperties = array(), array $allowedFunctions = array())
{
$this->allowedTags = $allowedTags;
$this->allowedFilters = $allowedFilters;
$this->setAllowedMethods($allowedMethods);
$this->allowedProperties = $allowedProperties;
$this->allowedFunctions = $allowedFunctions;
}
public function setAllowedTags(array $tags)
{
$this->allowedTags = $tags;
}
public function setAllowedFilters(array $filters)
{
$this->allowedFilters = $filters;
}
public function setAllowedMethods(array $methods)
{
$this->allowedMethods = array();
foreach ($methods as $class => $m) {
$this->allowedMethods[$class] = array_map('strtolower', is_array($m) ? $m : array($m));
}
}
public function setAllowedProperties(array $properties)
{
$this->allowedProperties = $properties;
}
public function setAllowedFunctions(array $functions)
{
$this->allowedFunctions = $functions;
}
public function checkSecurity($tags, $filters, $functions)
{
foreach ($tags as $tag) {
if (!in_array($tag, $this->allowedTags)) {
throw new Twig_Sandbox_SecurityNotAllowedTagError(sprintf('Tag "%s" is not allowed.', $tag), $tag);
}
}
foreach ($filters as $filter) {
if (!in_array($filter, $this->allowedFilters)) {
throw new Twig_Sandbox_SecurityNotAllowedFilterError(sprintf('Filter "%s" is not allowed.', $filter), $filter);
}
}
foreach ($functions as $function) {
if (!in_array($function, $this->allowedFunctions)) {
throw new Twig_Sandbox_SecurityNotAllowedFunctionError(sprintf('Function "%s" is not allowed.', $function), $function);
}
}
}
public function checkMethodAllowed($obj, $method)
{
if ($obj instanceof Twig_TemplateInterface || $obj instanceof Twig_Markup) {
return true;
}
$allowed = false;
$method = strtolower($method);
foreach ($this->allowedMethods as $class => $methods) {
if ($obj instanceof $class) {
$allowed = in_array($method, $methods);
break;
}
}
if (!$allowed) {
throw new Twig_Sandbox_SecurityError(sprintf('Calling "%s" method on a "%s" object is not allowed.', $method, get_class($obj)));
}
}
public function checkPropertyAllowed($obj, $property)
{
$allowed = false;
foreach ($this->allowedProperties as $class => $properties) {
if ($obj instanceof $class) {
$allowed = in_array($property, is_array($properties) ? $properties : array($properties));
break;
}
}
if (!$allowed) {
throw new Twig_Sandbox_SecurityError(sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, get_class($obj)));
}
}
}

View File

@@ -1,11 +1,24 @@
<?php
namespace Twig\Sandbox;
/*
* This file is part of Twig.
*
* (c) 2009 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class_exists('Twig_Sandbox_SecurityPolicyInterface');
/**
* Interfaces that all security policy classes must implements.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface Twig_Sandbox_SecurityPolicyInterface
{
public function checkSecurity($tags, $filters, $functions);
if (\false) {
interface SecurityPolicyInterface extends \Twig_Sandbox_SecurityPolicyInterface
{
}
public function checkMethodAllowed($obj, $method);
public function checkPropertyAllowed($obj, $method);
}