diff --git a/.gitignore b/.gitignore index 281515e9..57593edc 100644 --- a/.gitignore +++ b/.gitignore @@ -11,9 +11,6 @@ !/templates/*.html !/inc/config.php -# minify -/inc/lib/minify - # instance-config /inc/instance-config.php @@ -47,3 +44,5 @@ Thumbs.db #vichan custom favicon.ico /static/spoiler.png + +/vendor/ diff --git a/README.md b/README.md index 0e16e676..5499151a 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,11 @@ Installation development version with: git clone git://github.com/vichan-devel/vichan.git - -2. Navigate to ```install.php``` in your web browser and follow the + +2. run ```composer install``` inside the directory +3. Navigate to ```install.php``` in your web browser and follow the prompts. -3. vichan should now be installed. Log in to ```mod.php``` with the +4. vichan should now be installed. Log in to ```mod.php``` with the default username and password combination: **admin / password**. Please remember to change the administrator account password. diff --git a/banned.php b/banned.php index 1bee9115..dc079cf0 100644 --- a/banned.php +++ b/banned.php @@ -1,6 +1,5 @@
- * {{ post.published_at|date("m/d/Y") }}
- *
- *
- * @param Twig_Environment $env
- * @param DateTime|DateTimeInterface|DateInterval|string $date A date
- * @param string|null $format The target format, null to use the default
- * @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
- *
- * @return string The formatted date
- */
-function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $timezone = null)
-{
- if (null === $format) {
- $formats = $env->getExtension('Twig_Extension_Core')->getDateFormat();
- $format = $date instanceof DateInterval ? $formats[1] : $formats[0];
- }
-
- if ($date instanceof DateInterval) {
- return $date->format($format);
- }
-
- return twig_date_converter($env, $date, $timezone)->format($format);
-}
-
-/**
- * Returns a new date object modified.
- *
- *
- * {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
- *
- *
- * @param Twig_Environment $env
- * @param DateTime|string $date A date
- * @param string $modifier A modifier string
- *
- * @return DateTime A new date object
- */
-function twig_date_modify_filter(Twig_Environment $env, $date, $modifier)
-{
- $date = twig_date_converter($env, $date, false);
- $resultDate = $date->modify($modifier);
-
- // This is a hack to ensure PHP 5.2 support and support for DateTimeImmutable
- // DateTime::modify does not return the modified DateTime object < 5.3.0
- // and DateTimeImmutable does not modify $date.
- return null === $resultDate ? $date : $resultDate;
-}
-
-/**
- * Converts an input to a DateTime instance.
- *
- *
- * {% if date(user.created_at) < date('+2days') %}
- * {# do something #}
- * {% endif %}
- *
- *
- * @param Twig_Environment $env
- * @param DateTime|DateTimeInterface|string|null $date A date
- * @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
- *
- * @return DateTime A DateTime instance
- */
-function twig_date_converter(Twig_Environment $env, $date = null, $timezone = null)
-{
- // determine the timezone
- if (false !== $timezone) {
- if (null === $timezone) {
- $timezone = $env->getExtension('Twig_Extension_Core')->getTimezone();
- } elseif (!$timezone instanceof DateTimeZone) {
- $timezone = new DateTimeZone($timezone);
- }
- }
-
- // immutable dates
- if ($date instanceof DateTimeImmutable) {
- return false !== $timezone ? $date->setTimezone($timezone) : $date;
- }
-
- if ($date instanceof DateTime || $date instanceof DateTimeInterface) {
- $date = clone $date;
- if (false !== $timezone) {
- $date->setTimezone($timezone);
- }
-
- return $date;
- }
-
- if (null === $date || 'now' === $date) {
- return new DateTime($date, false !== $timezone ? $timezone : $env->getExtension('Twig_Extension_Core')->getTimezone());
- }
-
- $asString = (string) $date;
- if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) {
- $date = new DateTime('@'.$date);
- } else {
- $date = new DateTime($date, $env->getExtension('Twig_Extension_Core')->getTimezone());
- }
-
- if (false !== $timezone) {
- $date->setTimezone($timezone);
- }
-
- return $date;
-}
-
-/**
- * Replaces strings within a string.
- *
- * @param string $str String to replace in
- * @param array|Traversable $from Replace values
- * @param string|null $to Replace to, deprecated (@see https://secure.php.net/manual/en/function.strtr.php)
- *
- * @return string
- */
-function twig_replace_filter($str, $from, $to = null)
-{
- if ($from instanceof Traversable) {
- $from = iterator_to_array($from);
- } elseif (is_string($from) && is_string($to)) {
- @trigger_error('Using "replace" with character by character replacement is deprecated since version 1.22 and will be removed in Twig 2.0', E_USER_DEPRECATED);
-
- return strtr($str, $from, $to);
- } elseif (!is_array($from)) {
- throw new Twig_Error_Runtime(sprintf('The "replace" filter expects an array or "Traversable" as replace values, got "%s".', is_object($from) ? get_class($from) : gettype($from)));
- }
-
- return strtr($str, $from);
-}
-
-/**
- * Rounds a number.
- *
- * @param int|float $value The value to round
- * @param int|float $precision The rounding precision
- * @param string $method The method to use for rounding
- *
- * @return int|float The rounded number
- */
-function twig_round($value, $precision = 0, $method = 'common')
-{
- if ('common' == $method) {
- return round($value, $precision);
- }
-
- if ('ceil' != $method && 'floor' != $method) {
- throw new Twig_Error_Runtime('The round filter only supports the "common", "ceil", and "floor" methods.');
- }
-
- return $method($value * pow(10, $precision)) / pow(10, $precision);
-}
-
-/**
- * Number format filter.
- *
- * All of the formatting options can be left null, in that case the defaults will
- * be used. Supplying any of the parameters will override the defaults set in the
- * environment object.
- *
- * @param Twig_Environment $env
- * @param mixed $number A float/int/string of the number to format
- * @param int $decimal the number of decimal points to display
- * @param string $decimalPoint the character(s) to use for the decimal point
- * @param string $thousandSep the character(s) to use for the thousands separator
- *
- * @return string The formatted number
- */
-function twig_number_format_filter(Twig_Environment $env, $number, $decimal = null, $decimalPoint = null, $thousandSep = null)
-{
- $defaults = $env->getExtension('Twig_Extension_Core')->getNumberFormat();
- if (null === $decimal) {
- $decimal = $defaults[0];
- }
-
- if (null === $decimalPoint) {
- $decimalPoint = $defaults[1];
- }
-
- if (null === $thousandSep) {
- $thousandSep = $defaults[2];
- }
-
- return number_format((float) $number, $decimal, $decimalPoint, $thousandSep);
-}
-
-/**
- * URL encodes (RFC 3986) a string as a path segment or an array as a query string.
- *
- * @param string|array $url A URL or an array of query parameters
- *
- * @return string The URL encoded value
- */
-function twig_urlencode_filter($url)
-{
- if (is_array($url)) {
- if (defined('PHP_QUERY_RFC3986')) {
- return http_build_query($url, '', '&', PHP_QUERY_RFC3986);
- }
-
- return http_build_query($url, '', '&');
- }
-
- return rawurlencode($url);
-}
-
-if (PHP_VERSION_ID < 50300) {
- /**
- * JSON encodes a variable.
- *
- * @param mixed $value the value to encode
- * @param int $options Not used on PHP 5.2.x
- *
- * @return mixed The JSON encoded value
- */
- function twig_jsonencode_filter($value, $options = 0)
- {
- if ($value instanceof Twig_Markup) {
- $value = (string) $value;
- } elseif (is_array($value)) {
- array_walk_recursive($value, '_twig_markup2string');
- }
-
- return json_encode($value);
- }
-} else {
- /**
- * JSON encodes a variable.
- *
- * @param mixed $value the value to encode
- * @param int $options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT
- *
- * @return mixed The JSON encoded value
- */
- function twig_jsonencode_filter($value, $options = 0)
- {
- if ($value instanceof Twig_Markup) {
- $value = (string) $value;
- } elseif (is_array($value)) {
- array_walk_recursive($value, '_twig_markup2string');
- }
-
- return json_encode($value, $options);
- }
-}
-
-function _twig_markup2string(&$value)
-{
- if ($value instanceof Twig_Markup) {
- $value = (string) $value;
- }
-}
-
-/**
- * Merges an array with another one.
- *
- *
- * {% set items = { 'apple': 'fruit', 'orange': 'fruit' } %}
- *
- * {% set items = items|merge({ 'peugeot': 'car' }) %}
- *
- * {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car' } #}
- *
- *
- * @param array|Traversable $arr1 An array
- * @param array|Traversable $arr2 An array
- *
- * @return array The merged array
- */
-function twig_array_merge($arr1, $arr2)
-{
- if ($arr1 instanceof Traversable) {
- $arr1 = iterator_to_array($arr1);
- } elseif (!is_array($arr1)) {
- throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as first argument.', gettype($arr1)));
- }
-
- if ($arr2 instanceof Traversable) {
- $arr2 = iterator_to_array($arr2);
- } elseif (!is_array($arr2)) {
- throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as second argument.', gettype($arr2)));
- }
-
- return array_merge($arr1, $arr2);
-}
-
-/**
- * Slices a variable.
- *
- * @param Twig_Environment $env
- * @param mixed $item A variable
- * @param int $start Start of the slice
- * @param int $length Size of the slice
- * @param bool $preserveKeys Whether to preserve key or not (when the input is an array)
- *
- * @return mixed The sliced variable
- */
-function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false)
-{
- if ($item instanceof Traversable) {
- while ($item instanceof IteratorAggregate) {
- $item = $item->getIterator();
- }
-
- if ($start >= 0 && $length >= 0 && $item instanceof Iterator) {
- try {
- return iterator_to_array(new LimitIterator($item, $start, null === $length ? -1 : $length), $preserveKeys);
- } catch (OutOfBoundsException $exception) {
- return array();
- }
- }
-
- $item = iterator_to_array($item, $preserveKeys);
- }
-
- if (is_array($item)) {
- return array_slice($item, $start, $length, $preserveKeys);
- }
-
- $item = (string) $item;
-
- if (function_exists('mb_get_info') && null !== $charset = $env->getCharset()) {
- return (string) mb_substr($item, $start, null === $length ? mb_strlen($item, $charset) - $start : $length, $charset);
- }
-
- return (string) (null === $length ? substr($item, $start) : substr($item, $start, $length));
-}
-
-/**
- * Returns the first element of the item.
- *
- * @param Twig_Environment $env
- * @param mixed $item A variable
- *
- * @return mixed The first element of the item
- */
-function twig_first(Twig_Environment $env, $item)
-{
- $elements = twig_slice($env, $item, 0, 1, false);
-
- return is_string($elements) ? $elements : current($elements);
-}
-
-/**
- * Returns the last element of the item.
- *
- * @param Twig_Environment $env
- * @param mixed $item A variable
- *
- * @return mixed The last element of the item
- */
-function twig_last(Twig_Environment $env, $item)
-{
- $elements = twig_slice($env, $item, -1, 1, false);
-
- return is_string($elements) ? $elements : current($elements);
-}
-
-/**
- * Joins the values to a string.
- *
- * The separator between elements is an empty string per default, you can define it with the optional parameter.
- *
- *
- * {{ [1, 2, 3]|join('|') }}
- * {# returns 1|2|3 #}
- *
- * {{ [1, 2, 3]|join }}
- * {# returns 123 #}
- *
- *
- * @param array $value An array
- * @param string $glue The separator
- *
- * @return string The concatenated string
- */
-function twig_join_filter($value, $glue = '')
-{
- if ($value instanceof Traversable) {
- $value = iterator_to_array($value, false);
- }
-
- return implode($glue, (array) $value);
-}
-
-/**
- * Splits the string into an array.
- *
- *
- * {{ "one,two,three"|split(',') }}
- * {# returns [one, two, three] #}
- *
- * {{ "one,two,three,four,five"|split(',', 3) }}
- * {# returns [one, two, "three,four,five"] #}
- *
- * {{ "123"|split('') }}
- * {# returns [1, 2, 3] #}
- *
- * {{ "aabbcc"|split('', 2) }}
- * {# returns [aa, bb, cc] #}
- *
- *
- * @param Twig_Environment $env
- * @param string $value A string
- * @param string $delimiter The delimiter
- * @param int $limit The limit
- *
- * @return array The split string as an array
- */
-function twig_split_filter(Twig_Environment $env, $value, $delimiter, $limit = null)
-{
- if (!empty($delimiter)) {
- return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit);
- }
-
- if (!function_exists('mb_get_info') || null === $charset = $env->getCharset()) {
- return str_split($value, null === $limit ? 1 : $limit);
- }
-
- if ($limit <= 1) {
- return preg_split('/(?
- * {% for key in array|keys %}
- * {# ... #}
- * {% endfor %}
- *
- *
- * @param array $array An array
- *
- * @return array The keys
- */
-function twig_get_array_keys_filter($array)
-{
- if ($array instanceof Traversable) {
- while ($array instanceof IteratorAggregate) {
- $array = $array->getIterator();
- }
-
- if ($array instanceof Iterator) {
- $keys = array();
- $array->rewind();
- while ($array->valid()) {
- $keys[] = $array->key();
- $array->next();
- }
-
- return $keys;
- }
-
- $keys = array();
- foreach ($array as $key => $item) {
- $keys[] = $key;
- }
-
- return $keys;
- }
-
- if (!is_array($array)) {
- return array();
- }
-
- return array_keys($array);
-}
-
-/**
- * Reverses a variable.
- *
- * @param Twig_Environment $env
- * @param array|Traversable|string $item An array, a Traversable instance, or a string
- * @param bool $preserveKeys Whether to preserve key or not
- *
- * @return mixed The reversed input
- */
-function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false)
-{
- if ($item instanceof Traversable) {
- return array_reverse(iterator_to_array($item), $preserveKeys);
- }
-
- if (is_array($item)) {
- return array_reverse($item, $preserveKeys);
- }
-
- if (null !== $charset = $env->getCharset()) {
- $string = (string) $item;
-
- if ('UTF-8' !== $charset) {
- $item = twig_convert_encoding($string, 'UTF-8', $charset);
- }
-
- preg_match_all('/./us', $item, $matches);
-
- $string = implode('', array_reverse($matches[0]));
-
- if ('UTF-8' !== $charset) {
- $string = twig_convert_encoding($string, $charset, 'UTF-8');
- }
-
- return $string;
- }
-
- return strrev((string) $item);
-}
-
-/**
- * Sorts an array.
- *
- * @param array|Traversable $array
- *
- * @return array
- */
-function twig_sort_filter($array)
-{
- if ($array instanceof Traversable) {
- $array = iterator_to_array($array);
- } elseif (!is_array($array)) {
- throw new Twig_Error_Runtime(sprintf('The sort filter only works with arrays or "Traversable", got "%s".', gettype($array)));
- }
-
- asort($array);
-
- return $array;
-}
-
-/**
- * @internal
- */
-function twig_in_filter($value, $compare)
-{
- if (is_array($compare)) {
- return in_array($value, $compare, is_object($value) || is_resource($value));
- } elseif (is_string($compare) && (is_string($value) || is_int($value) || is_float($value))) {
- return '' === $value || false !== strpos($compare, (string) $value);
- } elseif ($compare instanceof Traversable) {
- if (is_object($value) || is_resource($value)) {
- foreach ($compare as $item) {
- if ($item === $value) {
- return true;
- }
- }
- } else {
- foreach ($compare as $item) {
- if ($item == $value) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- return false;
-}
-
-/**
- * Returns a trimmed string.
- *
- * @return string
- *
- * @throws Twig_Error_Runtime When an invalid trimming side is used (not a string or not 'left', 'right', or 'both')
- */
-function twig_trim_filter($string, $characterMask = null, $side = 'both')
-{
- if (null === $characterMask) {
- $characterMask = " \t\n\r\0\x0B";
- }
-
- switch ($side) {
- case 'both':
- return trim($string, $characterMask);
- case 'left':
- return ltrim($string, $characterMask);
- case 'right':
- return rtrim($string, $characterMask);
- default:
- throw new Twig_Error_Runtime('Trimming side must be "left", "right" or "both".');
- }
-}
-
-/**
- * Escapes a string.
- *
- * @param Twig_Environment $env
- * @param mixed $string The value to be escaped
- * @param string $strategy The escaping strategy
- * @param string $charset The charset
- * @param bool $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false)
- *
- * @return string
- */
-function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false)
-{
- if ($autoescape && $string instanceof Twig_Markup) {
- return $string;
- }
-
- if (!is_string($string)) {
- if (is_object($string) && method_exists($string, '__toString')) {
- $string = (string) $string;
- } elseif (in_array($strategy, array('html', 'js', 'css', 'html_attr', 'url'))) {
- return $string;
- }
- }
-
- if (null === $charset) {
- $charset = $env->getCharset();
- }
-
- switch ($strategy) {
- case 'html':
- // see https://secure.php.net/htmlspecialchars
-
- // Using a static variable to avoid initializing the array
- // each time the function is called. Moving the declaration on the
- // top of the function slow downs other escaping strategies.
- static $htmlspecialcharsCharsets = array(
- 'ISO-8859-1' => true, 'ISO8859-1' => true,
- 'ISO-8859-15' => true, 'ISO8859-15' => true,
- 'utf-8' => true, 'UTF-8' => true,
- 'CP866' => true, 'IBM866' => true, '866' => true,
- 'CP1251' => true, 'WINDOWS-1251' => true, 'WIN-1251' => true,
- '1251' => true,
- 'CP1252' => true, 'WINDOWS-1252' => true, '1252' => true,
- 'KOI8-R' => true, 'KOI8-RU' => true, 'KOI8R' => true,
- 'BIG5' => true, '950' => true,
- 'GB2312' => true, '936' => true,
- 'BIG5-HKSCS' => true,
- 'SHIFT_JIS' => true, 'SJIS' => true, '932' => true,
- 'EUC-JP' => true, 'EUCJP' => true,
- 'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true,
- );
-
- if (isset($htmlspecialcharsCharsets[$charset])) {
- return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
- }
-
- if (isset($htmlspecialcharsCharsets[strtoupper($charset)])) {
- // cache the lowercase variant for future iterations
- $htmlspecialcharsCharsets[$charset] = true;
-
- return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
- }
-
- $string = twig_convert_encoding($string, 'UTF-8', $charset);
- $string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
-
- return twig_convert_encoding($string, $charset, 'UTF-8');
-
- case 'js':
- // escape all non-alphanumeric characters
- // into their \x or \uHHHH representations
- if ('UTF-8' !== $charset) {
- $string = twig_convert_encoding($string, 'UTF-8', $charset);
- }
-
- if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
- throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
- }
-
- $string = preg_replace_callback('#[^a-zA-Z0-9,\._]#Su', '_twig_escape_js_callback', $string);
-
- if ('UTF-8' !== $charset) {
- $string = twig_convert_encoding($string, $charset, 'UTF-8');
- }
-
- return $string;
-
- case 'css':
- if ('UTF-8' !== $charset) {
- $string = twig_convert_encoding($string, 'UTF-8', $charset);
- }
-
- if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
- throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
- }
-
- $string = preg_replace_callback('#[^a-zA-Z0-9]#Su', '_twig_escape_css_callback', $string);
-
- if ('UTF-8' !== $charset) {
- $string = twig_convert_encoding($string, $charset, 'UTF-8');
- }
-
- return $string;
-
- case 'html_attr':
- if ('UTF-8' !== $charset) {
- $string = twig_convert_encoding($string, 'UTF-8', $charset);
- }
-
- if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
- throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
- }
-
- $string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_]#Su', '_twig_escape_html_attr_callback', $string);
-
- if ('UTF-8' !== $charset) {
- $string = twig_convert_encoding($string, $charset, 'UTF-8');
- }
-
- return $string;
-
- case 'url':
- if (PHP_VERSION_ID < 50300) {
- return str_replace('%7E', '~', rawurlencode($string));
- }
-
- return rawurlencode($string);
-
- default:
- static $escapers;
-
- if (null === $escapers) {
- $escapers = $env->getExtension('Twig_Extension_Core')->getEscapers();
- }
-
- if (isset($escapers[$strategy])) {
- return call_user_func($escapers[$strategy], $env, $string, $charset);
- }
-
- $validStrategies = implode(', ', array_merge(array('html', 'js', 'url', 'css', 'html_attr'), array_keys($escapers)));
-
- throw new Twig_Error_Runtime(sprintf('Invalid escaping strategy "%s" (valid ones: %s).', $strategy, $validStrategies));
- }
-}
-
-/**
- * @internal
- */
-function twig_escape_filter_is_safe(Twig_Node $filterArgs)
-{
- foreach ($filterArgs as $arg) {
- if ($arg instanceof Twig_Node_Expression_Constant) {
- return array($arg->getAttribute('value'));
- }
-
- return array();
- }
-
- return array('html');
-}
-
-if (function_exists('mb_convert_encoding')) {
- function twig_convert_encoding($string, $to, $from)
- {
- return mb_convert_encoding($string, $to, $from);
- }
-} elseif (function_exists('iconv')) {
- function twig_convert_encoding($string, $to, $from)
- {
- return iconv($from, $to, $string);
- }
-} else {
- function twig_convert_encoding($string, $to, $from)
- {
- throw new Twig_Error_Runtime('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).');
- }
-}
-
-function _twig_escape_js_callback($matches)
-{
- $char = $matches[0];
-
- /*
- * A few characters have short escape sequences in JSON and JavaScript.
- * Escape sequences supported only by JavaScript, not JSON, are ommitted.
- * \" is also supported but omitted, because the resulting string is not HTML safe.
- */
- static $shortMap = array(
- '\\' => '\\\\',
- '/' => '\\/',
- "\x08" => '\b',
- "\x0C" => '\f',
- "\x0A" => '\n',
- "\x0D" => '\r',
- "\x09" => '\t',
- );
-
- if (isset($shortMap[$char])) {
- return $shortMap[$char];
- }
-
- // \uHHHH
- $char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
- $char = strtoupper(bin2hex($char));
-
- if (4 >= strlen($char)) {
- return sprintf('\u%04s', $char);
- }
-
- return sprintf('\u%04s\u%04s', substr($char, 0, -4), substr($char, -4));
-}
-
-function _twig_escape_css_callback($matches)
-{
- $char = $matches[0];
-
- // \xHH
- if (!isset($char[1])) {
- $hex = ltrim(strtoupper(bin2hex($char)), '0');
- if (0 === strlen($hex)) {
- $hex = '0';
- }
-
- return '\\'.$hex.' ';
- }
-
- // \uHHHH
- $char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
-
- return '\\'.ltrim(strtoupper(bin2hex($char)), '0').' ';
-}
-
-/**
- * This function is adapted from code coming from Zend Framework.
- *
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (https://www.zend.com)
- * @license https://framework.zend.com/license/new-bsd New BSD License
- */
-function _twig_escape_html_attr_callback($matches)
-{
- /*
- * While HTML supports far more named entities, the lowest common denominator
- * has become HTML5's XML Serialisation which is restricted to the those named
- * entities that XML supports. Using HTML entities would result in this error:
- * XML Parsing Error: undefined entity
- */
- static $entityMap = array(
- 34 => 'quot', /* quotation mark */
- 38 => 'amp', /* ampersand */
- 60 => 'lt', /* less-than sign */
- 62 => 'gt', /* greater-than sign */
- );
-
- $chr = $matches[0];
- $ord = ord($chr);
-
- /*
- * The following replaces characters undefined in HTML with the
- * hex entity for the Unicode replacement character.
- */
- if (($ord <= 0x1f && "\t" != $chr && "\n" != $chr && "\r" != $chr) || ($ord >= 0x7f && $ord <= 0x9f)) {
- return '�';
- }
-
- /*
- * Check if the current character to escape has a name entity we should
- * replace it with while grabbing the hex value of the character.
- */
- if (1 == strlen($chr)) {
- $hex = strtoupper(substr('00'.bin2hex($chr), -2));
- } else {
- $chr = twig_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
- $hex = strtoupper(substr('0000'.bin2hex($chr), -4));
- }
-
- $int = hexdec($hex);
- if (array_key_exists($int, $entityMap)) {
- return sprintf('&%s;', $entityMap[$int]);
- }
-
- /*
- * Per OWASP recommendations, we'll use hex entities for any other
- * characters where a named entity does not exist.
- */
- return sprintf('%s;', $hex);
-}
-
-// add multibyte extensions if possible
-if (function_exists('mb_get_info')) {
- /**
- * Returns the length of a variable.
- *
- * @param Twig_Environment $env
- * @param mixed $thing A variable
- *
- * @return int The length of the value
- */
- function twig_length_filter(Twig_Environment $env, $thing)
- {
- if (null === $thing) {
- return 0;
- }
-
- if (is_scalar($thing)) {
- return mb_strlen($thing, $env->getCharset());
- }
-
- if ($thing instanceof \SimpleXMLElement) {
- return count($thing);
- }
-
- if (is_object($thing) && method_exists($thing, '__toString') && !$thing instanceof \Countable) {
- return mb_strlen((string) $thing, $env->getCharset());
- }
-
- if ($thing instanceof \Countable || is_array($thing)) {
- return count($thing);
- }
-
- if ($thing instanceof \IteratorAggregate) {
- return iterator_count($thing);
- }
-
- return 1;
- }
-
- /**
- * Converts a string to uppercase.
- *
- * @param Twig_Environment $env
- * @param string $string A string
- *
- * @return string The uppercased string
- */
- function twig_upper_filter(Twig_Environment $env, $string)
- {
- if (null !== $charset = $env->getCharset()) {
- return mb_strtoupper($string, $charset);
- }
-
- return strtoupper($string);
- }
-
- /**
- * Converts a string to lowercase.
- *
- * @param Twig_Environment $env
- * @param string $string A string
- *
- * @return string The lowercased string
- */
- function twig_lower_filter(Twig_Environment $env, $string)
- {
- if (null !== $charset = $env->getCharset()) {
- return mb_strtolower($string, $charset);
- }
-
- return strtolower($string);
- }
-
- /**
- * Returns a titlecased string.
- *
- * @param Twig_Environment $env
- * @param string $string A string
- *
- * @return string The titlecased string
- */
- function twig_title_string_filter(Twig_Environment $env, $string)
- {
- if (null !== $charset = $env->getCharset()) {
- return mb_convert_case($string, MB_CASE_TITLE, $charset);
- }
-
- return ucwords(strtolower($string));
- }
-
- /**
- * Returns a capitalized string.
- *
- * @param Twig_Environment $env
- * @param string $string A string
- *
- * @return string The capitalized string
- */
- function twig_capitalize_string_filter(Twig_Environment $env, $string)
- {
- if (null !== $charset = $env->getCharset()) {
- return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset).mb_strtolower(mb_substr($string, 1, mb_strlen($string, $charset), $charset), $charset);
- }
-
- return ucfirst(strtolower($string));
- }
-}
-// and byte fallback
-else {
- /**
- * Returns the length of a variable.
- *
- * @param Twig_Environment $env
- * @param mixed $thing A variable
- *
- * @return int The length of the value
- */
- function twig_length_filter(Twig_Environment $env, $thing)
- {
- if (null === $thing) {
- return 0;
- }
-
- if (is_scalar($thing)) {
- return strlen($thing);
- }
-
- if ($thing instanceof \SimpleXMLElement) {
- return count($thing);
- }
-
- if (is_object($thing) && method_exists($thing, '__toString') && !$thing instanceof \Countable) {
- return strlen((string) $thing);
- }
-
- if ($thing instanceof \Countable || is_array($thing)) {
- return count($thing);
- }
-
- if ($thing instanceof \IteratorAggregate) {
- return iterator_count($thing);
- }
-
- return 1;
- }
-
- /**
- * Returns a titlecased string.
- *
- * @param Twig_Environment $env
- * @param string $string A string
- *
- * @return string The titlecased string
- */
- function twig_title_string_filter(Twig_Environment $env, $string)
- {
- return ucwords(strtolower($string));
- }
-
- /**
- * Returns a capitalized string.
- *
- * @param Twig_Environment $env
- * @param string $string A string
- *
- * @return string The capitalized string
- */
- function twig_capitalize_string_filter(Twig_Environment $env, $string)
- {
- return ucfirst(strtolower($string));
- }
-}
-
-/**
- * @internal
- */
-function twig_ensure_traversable($seq)
-{
- if ($seq instanceof Traversable || is_array($seq)) {
- return $seq;
- }
-
- return array();
-}
-
-/**
- * Checks if a variable is empty.
- *
- *
- * {# evaluates to true if the foo variable is null, false, or the empty string #}
- * {% if foo is empty %}
- * {# ... #}
- * {% endif %}
- *
- *
- * @param mixed $value A variable
- *
- * @return bool true if the value is empty, false otherwise
- */
-function twig_test_empty($value)
-{
- if ($value instanceof Countable) {
- return 0 == count($value);
- }
-
- if (is_object($value) && method_exists($value, '__toString')) {
- return '' === (string) $value;
- }
-
- return '' === $value || false === $value || null === $value || array() === $value;
-}
-
-/**
- * Checks if a variable is traversable.
- *
- *
- * {# evaluates to true if the foo variable is an array or a traversable object #}
- * {% if foo is iterable %}
- * {# ... #}
- * {% endif %}
- *
- *
- * @param mixed $value A variable
- *
- * @return bool true if the value is traversable
- */
-function twig_test_iterable($value)
-{
- return $value instanceof Traversable || is_array($value);
-}
-
-/**
- * Renders a template.
- *
- * @param Twig_Environment $env
- * @param array $context
- * @param string|array $template The template to render or an array of templates to try consecutively
- * @param array $variables The variables to pass to the template
- * @param bool $withContext
- * @param bool $ignoreMissing Whether to ignore missing templates or not
- * @param bool $sandboxed Whether to sandbox the template or not
- *
- * @return string The rendered template
- */
-function twig_include(Twig_Environment $env, $context, $template, $variables = array(), $withContext = true, $ignoreMissing = false, $sandboxed = false)
-{
- $alreadySandboxed = false;
- $sandbox = null;
- if ($withContext) {
- $variables = array_merge($context, $variables);
- }
-
- if ($isSandboxed = $sandboxed && $env->hasExtension('Twig_Extension_Sandbox')) {
- $sandbox = $env->getExtension('Twig_Extension_Sandbox');
- if (!$alreadySandboxed = $sandbox->isSandboxed()) {
- $sandbox->enableSandbox();
- }
- }
-
- $result = null;
- try {
- $result = $env->resolveTemplate($template)->render($variables);
- } catch (Twig_Error_Loader $e) {
- if (!$ignoreMissing) {
- if ($isSandboxed && !$alreadySandboxed) {
- $sandbox->disableSandbox();
- }
-
- throw $e;
- }
- } catch (Throwable $e) {
- if ($isSandboxed && !$alreadySandboxed) {
- $sandbox->disableSandbox();
- }
-
- throw $e;
- } catch (Exception $e) {
- if ($isSandboxed && !$alreadySandboxed) {
- $sandbox->disableSandbox();
- }
-
- throw $e;
- }
-
- if ($isSandboxed && !$alreadySandboxed) {
- $sandbox->disableSandbox();
- }
-
- return $result;
-}
-
-/**
- * Returns a template content without rendering it.
- *
- * @param Twig_Environment $env
- * @param string $name The template name
- * @param bool $ignoreMissing Whether to ignore missing templates or not
- *
- * @return string The template source
- */
-function twig_source(Twig_Environment $env, $name, $ignoreMissing = false)
-{
- $loader = $env->getLoader();
- try {
- if (!$loader instanceof Twig_SourceContextLoaderInterface) {
- return $loader->getSource($name);
- } else {
- return $loader->getSourceContext($name)->getCode();
- }
- } catch (Twig_Error_Loader $e) {
- if (!$ignoreMissing) {
- throw $e;
- }
- }
-}
-
-/**
- * Provides the ability to get constants from instances as well as class/global constants.
- *
- * @param string $constant The name of the constant
- * @param null|object $object The object to get the constant from
- *
- * @return string
- */
-function twig_constant($constant, $object = null)
-{
- if (null !== $object) {
- $constant = get_class($object).'::'.$constant;
- }
-
- return constant($constant);
-}
-
-/**
- * Checks if a constant exists.
- *
- * @param string $constant The name of the constant
- * @param null|object $object The object to get the constant from
- *
- * @return bool
- */
-function twig_constant_is_defined($constant, $object = null)
-{
- if (null !== $object) {
- $constant = get_class($object).'::'.$constant;
- }
-
- return defined($constant);
-}
-
-/**
- * Batches item.
- *
- * @param array $items An array of items
- * @param int $size The size of the batch
- * @param mixed $fill A value used to fill missing items
- *
- * @return array
- */
-function twig_array_batch($items, $size, $fill = null)
-{
- if ($items instanceof Traversable) {
- $items = iterator_to_array($items, false);
- }
-
- $size = ceil($size);
-
- $result = array_chunk($items, $size, true);
-
- if (null !== $fill && !empty($result)) {
- $last = count($result) - 1;
- if ($fillCount = $size - count($result[$last])) {
- $result[$last] = array_merge(
- $result[$last],
- array_fill(0, $fillCount, $fill)
- );
- }
- }
-
- return $result;
-}
-
-class_alias('Twig_Extension_Core', 'Twig\Extension\CoreExtension', false);
diff --git a/inc/lib/Twig/Extension/Debug.php b/inc/lib/Twig/Extension/Debug.php
deleted file mode 100644
index d0cd1962..00000000
--- a/inc/lib/Twig/Extension/Debug.php
+++ /dev/null
@@ -1,67 +0,0 @@
- $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)),
- );
- }
-
- public function getName()
- {
- return 'debug';
- }
-}
-
-function twig_var_dump(Twig_Environment $env, $context)
-{
- if (!$env->isDebug()) {
- return;
- }
-
- ob_start();
-
- $count = func_num_args();
- if (2 === $count) {
- $vars = array();
- foreach ($context as $key => $value) {
- if (!$value instanceof Twig_Template) {
- $vars[$key] = $value;
- }
- }
-
- var_dump($vars);
- } else {
- for ($i = 2; $i < $count; ++$i) {
- var_dump(func_get_arg($i));
- }
- }
-
- return ob_get_clean();
-}
-
-class_alias('Twig_Extension_Debug', 'Twig\Extension\DebugExtension', false);
diff --git a/inc/lib/Twig/Extension/Escaper.php b/inc/lib/Twig/Extension/Escaper.php
deleted file mode 100644
index 46c2d84b..00000000
--- a/inc/lib/Twig/Extension/Escaper.php
+++ /dev/null
@@ -1,112 +0,0 @@
-setDefaultStrategy($defaultStrategy);
- }
-
- public function getTokenParsers()
- {
- return array(new Twig_TokenParser_AutoEscape());
- }
-
- public function getNodeVisitors()
- {
- return array(new Twig_NodeVisitor_Escaper());
- }
-
- public function getFilters()
- {
- return array(
- new Twig_SimpleFilter('raw', 'twig_raw_filter', array('is_safe' => array('all'))),
- );
- }
-
- /**
- * Sets the default strategy to use when not defined by the user.
- *
- * The strategy can be a valid PHP callback that takes the template
- * name as an argument and returns the strategy to use.
- *
- * @param string|false|callable $defaultStrategy An escaping strategy
- */
- public function setDefaultStrategy($defaultStrategy)
- {
- // for BC
- if (true === $defaultStrategy) {
- @trigger_error('Using "true" as the default strategy is deprecated since version 1.21. Use "html" instead.', E_USER_DEPRECATED);
-
- $defaultStrategy = 'html';
- }
-
- if ('filename' === $defaultStrategy) {
- @trigger_error('Using "filename" as the default strategy is deprecated since version 1.27. Use "name" instead.', E_USER_DEPRECATED);
-
- $defaultStrategy = 'name';
- }
-
- if ('name' === $defaultStrategy) {
- $defaultStrategy = array('Twig_FileExtensionEscapingStrategy', 'guess');
- }
-
- $this->defaultStrategy = $defaultStrategy;
- }
-
- /**
- * Gets the default strategy to use when not defined by the user.
- *
- * @param string $name The template name
- *
- * @return string|false The default strategy to use for the template
- */
- public function getDefaultStrategy($name)
- {
- // disable string callables to avoid calling a function named html or js,
- // or any other upcoming escaping strategy
- if (!is_string($this->defaultStrategy) && false !== $this->defaultStrategy) {
- return call_user_func($this->defaultStrategy, $name);
- }
-
- return $this->defaultStrategy;
- }
-
- public function getName()
- {
- return 'escaper';
- }
-}
-
-/**
- * Marks a variable as being safe.
- *
- * @param string $string A PHP variable
- *
- * @return string
- */
-function twig_raw_filter($string)
-{
- return $string;
-}
-
-class_alias('Twig_Extension_Escaper', 'Twig\Extension\EscaperExtension', false);
diff --git a/inc/lib/Twig/Extension/GlobalsInterface.php b/inc/lib/Twig/Extension/GlobalsInterface.php
deleted file mode 100644
index 922cd2c9..00000000
--- a/inc/lib/Twig/Extension/GlobalsInterface.php
+++ /dev/null
@@ -1,24 +0,0 @@
-
- */
-interface Twig_Extension_GlobalsInterface
-{
-}
-
-class_alias('Twig_Extension_GlobalsInterface', 'Twig\Extension\GlobalsInterface', false);
diff --git a/inc/lib/Twig/Extension/InitRuntimeInterface.php b/inc/lib/Twig/Extension/InitRuntimeInterface.php
deleted file mode 100644
index 1549862f..00000000
--- a/inc/lib/Twig/Extension/InitRuntimeInterface.php
+++ /dev/null
@@ -1,24 +0,0 @@
-
- */
-interface Twig_Extension_InitRuntimeInterface
-{
-}
-
-class_alias('Twig_Extension_InitRuntimeInterface', 'Twig\Extension\InitRuntimeInterface', false);
diff --git a/inc/lib/Twig/Extension/Optimizer.php b/inc/lib/Twig/Extension/Optimizer.php
deleted file mode 100644
index 6c62e3ef..00000000
--- a/inc/lib/Twig/Extension/Optimizer.php
+++ /dev/null
@@ -1,35 +0,0 @@
-optimizers = $optimizers;
- }
-
- public function getNodeVisitors()
- {
- return array(new Twig_NodeVisitor_Optimizer($this->optimizers));
- }
-
- public function getName()
- {
- return 'optimizer';
- }
-}
-
-class_alias('Twig_Extension_Optimizer', 'Twig\Extension\OptimizerExtension', false);
diff --git a/inc/lib/Twig/Extension/Profiler.php b/inc/lib/Twig/Extension/Profiler.php
deleted file mode 100644
index fcfc002b..00000000
--- a/inc/lib/Twig/Extension/Profiler.php
+++ /dev/null
@@ -1,49 +0,0 @@
-actives[] = $profile;
- }
-
- public function enter(Twig_Profiler_Profile $profile)
- {
- $this->actives[0]->addProfile($profile);
- array_unshift($this->actives, $profile);
- }
-
- public function leave(Twig_Profiler_Profile $profile)
- {
- $profile->leave();
- array_shift($this->actives);
-
- if (1 === count($this->actives)) {
- $this->actives[0]->leave();
- }
- }
-
- public function getNodeVisitors()
- {
- return array(new Twig_Profiler_NodeVisitor_Profiler(get_class($this)));
- }
-
- public function getName()
- {
- return 'profiler';
- }
-}
-
-class_alias('Twig_Extension_Profiler', 'Twig\Extension\ProfilerExtension', false);
-class_exists('Twig_Profiler_Profile');
diff --git a/inc/lib/Twig/Extension/Sandbox.php b/inc/lib/Twig/Extension/Sandbox.php
deleted file mode 100644
index 5cb80a71..00000000
--- a/inc/lib/Twig/Extension/Sandbox.php
+++ /dev/null
@@ -1,103 +0,0 @@
-policy = $policy;
- $this->sandboxedGlobally = $sandboxed;
- }
-
- public function getTokenParsers()
- {
- return array(new Twig_TokenParser_Sandbox());
- }
-
- public function getNodeVisitors()
- {
- return array(new Twig_NodeVisitor_Sandbox());
- }
-
- public function enableSandbox()
- {
- $this->sandboxed = true;
- }
-
- public function disableSandbox()
- {
- $this->sandboxed = false;
- }
-
- public function isSandboxed()
- {
- return $this->sandboxedGlobally || $this->sandboxed;
- }
-
- public function isSandboxedGlobally()
- {
- return $this->sandboxedGlobally;
- }
-
- public function setSecurityPolicy(Twig_Sandbox_SecurityPolicyInterface $policy)
- {
- $this->policy = $policy;
- }
-
- public function getSecurityPolicy()
- {
- return $this->policy;
- }
-
- public function checkSecurity($tags, $filters, $functions)
- {
- if ($this->isSandboxed()) {
- $this->policy->checkSecurity($tags, $filters, $functions);
- }
- }
-
- public function checkMethodAllowed($obj, $method)
- {
- if ($this->isSandboxed()) {
- $this->policy->checkMethodAllowed($obj, $method);
- }
- }
-
- public function checkPropertyAllowed($obj, $method)
- {
- if ($this->isSandboxed()) {
- $this->policy->checkPropertyAllowed($obj, $method);
- }
- }
-
- public function ensureToStringAllowed($obj)
- {
- if ($this->isSandboxed() && is_object($obj)) {
- $this->policy->checkMethodAllowed($obj, '__toString');
- }
-
- return $obj;
- }
-
- public function getName()
- {
- return 'sandbox';
- }
-}
-
-class_alias('Twig_Extension_Sandbox', 'Twig\Extension\SandboxExtension', false);
diff --git a/inc/lib/Twig/Extension/Staging.php b/inc/lib/Twig/Extension/Staging.php
deleted file mode 100644
index d3a0f9c9..00000000
--- a/inc/lib/Twig/Extension/Staging.php
+++ /dev/null
@@ -1,112 +0,0 @@
-
- *
- * @internal
- */
-class Twig_Extension_Staging extends Twig_Extension
-{
- protected $functions = array();
- protected $filters = array();
- protected $visitors = array();
- protected $tokenParsers = array();
- protected $globals = array();
- protected $tests = array();
-
- public function addFunction($name, $function)
- {
- if (isset($this->functions[$name])) {
- @trigger_error(sprintf('Overriding function "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
- }
-
- $this->functions[$name] = $function;
- }
-
- public function getFunctions()
- {
- return $this->functions;
- }
-
- public function addFilter($name, $filter)
- {
- if (isset($this->filters[$name])) {
- @trigger_error(sprintf('Overriding filter "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
- }
-
- $this->filters[$name] = $filter;
- }
-
- public function getFilters()
- {
- return $this->filters;
- }
-
- public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
- {
- $this->visitors[] = $visitor;
- }
-
- public function getNodeVisitors()
- {
- return $this->visitors;
- }
-
- public function addTokenParser(Twig_TokenParserInterface $parser)
- {
- if (isset($this->tokenParsers[$parser->getTag()])) {
- @trigger_error(sprintf('Overriding tag "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $parser->getTag()), E_USER_DEPRECATED);
- }
-
- $this->tokenParsers[$parser->getTag()] = $parser;
- }
-
- public function getTokenParsers()
- {
- return $this->tokenParsers;
- }
-
- public function addGlobal($name, $value)
- {
- $this->globals[$name] = $value;
- }
-
- public function getGlobals()
- {
- return $this->globals;
- }
-
- public function addTest($name, $test)
- {
- if (isset($this->tests[$name])) {
- @trigger_error(sprintf('Overriding test "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
- }
-
- $this->tests[$name] = $test;
- }
-
- public function getTests()
- {
- return $this->tests;
- }
-
- public function getName()
- {
- return 'staging';
- }
-}
-
-class_alias('Twig_Extension_Staging', 'Twig\Extension\StagingExtension', false);
diff --git a/inc/lib/Twig/Extension/StringLoader.php b/inc/lib/Twig/Extension/StringLoader.php
deleted file mode 100644
index 2ce3c992..00000000
--- a/inc/lib/Twig/Extension/StringLoader.php
+++ /dev/null
@@ -1,47 +0,0 @@
- true)),
- );
- }
-
- public function getName()
- {
- return 'string_loader';
- }
-}
-
-/**
- * Loads a template from a string.
- *
- *
- * {{ include(template_from_string("Hello {{ name }}")) }}
- *
- *
- * @param Twig_Environment $env A Twig_Environment instance
- * @param string $template A template as a string or object implementing __toString()
- *
- * @return Twig_Template
- */
-function twig_template_from_string(Twig_Environment $env, $template)
-{
- return $env->createTemplate((string) $template);
-}
-
-class_alias('Twig_Extension_StringLoader', 'Twig\Extension\StringLoaderExtension', false);
diff --git a/inc/lib/Twig/ExtensionInterface.php b/inc/lib/Twig/ExtensionInterface.php
deleted file mode 100644
index 946df500..00000000
--- a/inc/lib/Twig/ExtensionInterface.php
+++ /dev/null
@@ -1,90 +0,0 @@
-
- */
-interface Twig_ExtensionInterface
-{
- /**
- * Initializes the runtime environment.
- *
- * This is where you can load some file that contains filter functions for instance.
- *
- * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterface instead
- */
- public function initRuntime(Twig_Environment $environment);
-
- /**
- * Returns the token parser instances to add to the existing list.
- *
- * @return Twig_TokenParserInterface[]
- */
- public function getTokenParsers();
-
- /**
- * Returns the node visitor instances to add to the existing list.
- *
- * @return Twig_NodeVisitorInterface[]
- */
- public function getNodeVisitors();
-
- /**
- * Returns a list of filters to add to the existing list.
- *
- * @return Twig_SimpleFilter[]
- */
- public function getFilters();
-
- /**
- * Returns a list of tests to add to the existing list.
- *
- * @return Twig_SimpleTest[]
- */
- public function getTests();
-
- /**
- * Returns a list of functions to add to the existing list.
- *
- * @return Twig_SimpleFunction[]
- */
- public function getFunctions();
-
- /**
- * Returns a list of operators to add to the existing list.
- *
- * @return array'.parent::dump($profile).''; - } - - protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix) - { - return sprintf('%s└ %s', $prefix, self::$colors['template'], $profile->getTemplate()); - } - - protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix) - { - return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName()); - } - - protected function formatTime(Twig_Profiler_Profile $profile, $percent) - { - return sprintf('%.2fms/%.0f%%', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent); - } -} - -class_alias('Twig_Profiler_Dumper_Html', 'Twig\Profiler\Dumper\HtmlDumper', false); diff --git a/inc/lib/Twig/Profiler/Dumper/Text.php b/inc/lib/Twig/Profiler/Dumper/Text.php deleted file mode 100644 index 69d2c4bf..00000000 --- a/inc/lib/Twig/Profiler/Dumper/Text.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * @final - */ -class Twig_Profiler_Dumper_Text extends Twig_Profiler_Dumper_Base -{ - protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix) - { - return sprintf('%s└ %s', $prefix, $profile->getTemplate()); - } - - protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix) - { - return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), $profile->getName()); - } - - protected function formatTime(Twig_Profiler_Profile $profile, $percent) - { - return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent); - } -} - -class_alias('Twig_Profiler_Dumper_Text', 'Twig\Profiler\Dumper\TextDumper', false); diff --git a/inc/lib/Twig/Profiler/Node/EnterProfile.php b/inc/lib/Twig/Profiler/Node/EnterProfile.php deleted file mode 100644 index 69c8f797..00000000 --- a/inc/lib/Twig/Profiler/Node/EnterProfile.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -class Twig_Profiler_Node_EnterProfile extends Twig_Node -{ - public function __construct($extensionName, $type, $name, $varName) - { - parent::__construct(array(), array('extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName)); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->write(sprintf('$%s = $this->env->getExtension(', $this->getAttribute('var_name'))) - ->repr($this->getAttribute('extension_name')) - ->raw(");\n") - ->write(sprintf('$%s->enter($%s = new Twig_Profiler_Profile($this->getTemplateName(), ', $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof')) - ->repr($this->getAttribute('type')) - ->raw(', ') - ->repr($this->getAttribute('name')) - ->raw("));\n\n") - ; - } -} - -class_alias('Twig_Profiler_Node_EnterProfile', 'Twig\Profiler\Node\EnterProfileNode', false); diff --git a/inc/lib/Twig/Profiler/Node/LeaveProfile.php b/inc/lib/Twig/Profiler/Node/LeaveProfile.php deleted file mode 100644 index d1d6a7cc..00000000 --- a/inc/lib/Twig/Profiler/Node/LeaveProfile.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class Twig_Profiler_Node_LeaveProfile extends Twig_Node -{ - public function __construct($varName) - { - parent::__construct(array(), array('var_name' => $varName)); - } - - public function compile(Twig_Compiler $compiler) - { - $compiler - ->write("\n") - ->write(sprintf("\$%s->leave(\$%s);\n\n", $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof')) - ; - } -} - -class_alias('Twig_Profiler_Node_LeaveProfile', 'Twig\Profiler\Node\LeaveProfileNode', false); diff --git a/inc/lib/Twig/Profiler/NodeVisitor/Profiler.php b/inc/lib/Twig/Profiler/NodeVisitor/Profiler.php deleted file mode 100644 index 5db41fea..00000000 --- a/inc/lib/Twig/Profiler/NodeVisitor/Profiler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * @final - */ -class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor -{ - private $extensionName; - - public function __construct($extensionName) - { - $this->extensionName = $extensionName; - } - - protected function doEnterNode(Twig_Node $node, Twig_Environment $env) - { - return $node; - } - - protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) - { - if ($node instanceof Twig_Node_Module) { - $varName = $this->getVarName(); - $node->setNode('display_start', new Twig_Node(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start')))); - $node->setNode('display_end', new Twig_Node(array(new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end')))); - } elseif ($node instanceof Twig_Node_Block) { - $varName = $this->getVarName(); - $node->setNode('body', new Twig_Node_Body(array( - new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName), - $node->getNode('body'), - new Twig_Profiler_Node_LeaveProfile($varName), - ))); - } elseif ($node instanceof Twig_Node_Macro) { - $varName = $this->getVarName(); - $node->setNode('body', new Twig_Node_Body(array( - new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName), - $node->getNode('body'), - new Twig_Profiler_Node_LeaveProfile($varName), - ))); - } - - return $node; - } - - private function getVarName() - { - return sprintf('__internal_%s', hash('sha256', $this->extensionName)); - } - - public function getPriority() - { - return 0; - } -} - -class_alias('Twig_Profiler_NodeVisitor_Profiler', 'Twig\Profiler\NodeVisitor\ProfilerNodeVisitor', false); diff --git a/inc/lib/Twig/Profiler/Profile.php b/inc/lib/Twig/Profiler/Profile.php deleted file mode 100644 index 3fdc1a8a..00000000 --- a/inc/lib/Twig/Profiler/Profile.php +++ /dev/null @@ -1,170 +0,0 @@ - - * - * @final - */ -class Twig_Profiler_Profile implements IteratorAggregate, Serializable -{ - const ROOT = 'ROOT'; - const BLOCK = 'block'; - const TEMPLATE = 'template'; - const MACRO = 'macro'; - - private $template; - private $name; - private $type; - private $starts = array(); - private $ends = array(); - private $profiles = array(); - - public function __construct($template = 'main', $type = self::ROOT, $name = 'main') - { - $this->template = $template; - $this->type = $type; - $this->name = 0 === strpos($name, '__internal_') ? 'INTERNAL' : $name; - $this->enter(); - } - - public function getTemplate() - { - return $this->template; - } - - public function getType() - { - return $this->type; - } - - public function getName() - { - return $this->name; - } - - public function isRoot() - { - return self::ROOT === $this->type; - } - - public function isTemplate() - { - return self::TEMPLATE === $this->type; - } - - public function isBlock() - { - return self::BLOCK === $this->type; - } - - public function isMacro() - { - return self::MACRO === $this->type; - } - - public function getProfiles() - { - return $this->profiles; - } - - public function addProfile(Twig_Profiler_Profile $profile) - { - $this->profiles[] = $profile; - } - - /** - * Returns the duration in microseconds. - * - * @return int - */ - public function getDuration() - { - if ($this->isRoot() && $this->profiles) { - // for the root node with children, duration is the sum of all child durations - $duration = 0; - foreach ($this->profiles as $profile) { - $duration += $profile->getDuration(); - } - - return $duration; - } - - return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0; - } - - /** - * Returns the memory usage in bytes. - * - * @return int - */ - public function getMemoryUsage() - { - return isset($this->ends['mu']) && isset($this->starts['mu']) ? $this->ends['mu'] - $this->starts['mu'] : 0; - } - - /** - * Returns the peak memory usage in bytes. - * - * @return int - */ - public function getPeakMemoryUsage() - { - return isset($this->ends['pmu']) && isset($this->starts['pmu']) ? $this->ends['pmu'] - $this->starts['pmu'] : 0; - } - - /** - * Starts the profiling. - */ - public function enter() - { - $this->starts = array( - 'wt' => microtime(true), - 'mu' => memory_get_usage(), - 'pmu' => memory_get_peak_usage(), - ); - } - - /** - * Stops the profiling. - */ - public function leave() - { - $this->ends = array( - 'wt' => microtime(true), - 'mu' => memory_get_usage(), - 'pmu' => memory_get_peak_usage(), - ); - } - - public function reset() - { - $this->starts = $this->ends = $this->profiles = array(); - $this->enter(); - } - - public function getIterator() - { - return new ArrayIterator($this->profiles); - } - - public function serialize() - { - return serialize(array($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles)); - } - - public function unserialize($data) - { - list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = unserialize($data); - } -} - -class_alias('Twig_Profiler_Profile', 'Twig\Profiler\Profile', false); diff --git a/inc/lib/Twig/RuntimeLoaderInterface.php b/inc/lib/Twig/RuntimeLoaderInterface.php deleted file mode 100644 index f5eb14e0..00000000 --- a/inc/lib/Twig/RuntimeLoaderInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - */ -interface Twig_RuntimeLoaderInterface -{ - /** - * Creates the runtime implementation of a Twig element (filter/function/test). - * - * @param string $class A runtime class - * - * @return object|null The runtime instance or null if the loader does not know how to create the runtime for this class - */ - public function load($class); -} - -class_alias('Twig_RuntimeLoaderInterface', 'Twig\RuntimeLoader\RuntimeLoaderInterface', false); diff --git a/inc/lib/Twig/Sandbox/SecurityError.php b/inc/lib/Twig/Sandbox/SecurityError.php deleted file mode 100644 index b6707e38..00000000 --- a/inc/lib/Twig/Sandbox/SecurityError.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ -class Twig_Sandbox_SecurityError extends Twig_Error -{ -} - -class_alias('Twig_Sandbox_SecurityError', 'Twig\Sandbox\SecurityError', false); diff --git a/inc/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php b/inc/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php deleted file mode 100644 index 0ba33276..00000000 --- a/inc/lib/Twig/Sandbox/SecurityNotAllowedFilterError.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class Twig_Sandbox_SecurityNotAllowedFilterError extends Twig_Sandbox_SecurityError -{ - private $filterName; - - 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; - } -} - -class_alias('Twig_Sandbox_SecurityNotAllowedFilterError', 'Twig\Sandbox\SecurityNotAllowedFilterError', false); diff --git a/inc/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php b/inc/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php deleted file mode 100644 index aa391429..00000000 --- a/inc/lib/Twig/Sandbox/SecurityNotAllowedFunctionError.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class Twig_Sandbox_SecurityNotAllowedFunctionError extends Twig_Sandbox_SecurityError -{ - private $functionName; - - 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; - } -} - -class_alias('Twig_Sandbox_SecurityNotAllowedFunctionError', 'Twig\Sandbox\SecurityNotAllowedFunctionError', false); diff --git a/inc/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php b/inc/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php deleted file mode 100644 index 93012fe9..00000000 --- a/inc/lib/Twig/Sandbox/SecurityNotAllowedMethodError.php +++ /dev/null @@ -1,40 +0,0 @@ - - */ -class Twig_Sandbox_SecurityNotAllowedMethodError extends Twig_Sandbox_SecurityError -{ - private $className; - private $methodName; - - public function __construct($message, $className, $methodName, $lineno = -1, $filename = null, Exception $previous = null) - { - parent::__construct($message, $lineno, $filename, $previous); - $this->className = $className; - $this->methodName = $methodName; - } - - public function getClassName() - { - return $this->className; - } - - public function getMethodName() - { - return $this->methodName; - } -} - -class_alias('Twig_Sandbox_SecurityNotAllowedMethodError', 'Twig\Sandbox\SecurityNotAllowedMethodError', false); diff --git a/inc/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php b/inc/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php deleted file mode 100644 index f27969c1..00000000 --- a/inc/lib/Twig/Sandbox/SecurityNotAllowedPropertyError.php +++ /dev/null @@ -1,40 +0,0 @@ - - */ -class Twig_Sandbox_SecurityNotAllowedPropertyError extends Twig_Sandbox_SecurityError -{ - private $className; - private $propertyName; - - public function __construct($message, $className, $propertyName, $lineno = -1, $filename = null, Exception $previous = null) - { - parent::__construct($message, $lineno, $filename, $previous); - $this->className = $className; - $this->propertyName = $propertyName; - } - - public function getClassName() - { - return $this->className; - } - - public function getPropertyName() - { - return $this->propertyName; - } -} - -class_alias('Twig_Sandbox_SecurityNotAllowedPropertyError', 'Twig\Sandbox\SecurityNotAllowedPropertyError', false); diff --git a/inc/lib/Twig/Sandbox/SecurityNotAllowedTagError.php b/inc/lib/Twig/Sandbox/SecurityNotAllowedTagError.php deleted file mode 100644 index 4bbd2238..00000000 --- a/inc/lib/Twig/Sandbox/SecurityNotAllowedTagError.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class Twig_Sandbox_SecurityNotAllowedTagError extends Twig_Sandbox_SecurityError -{ - private $tagName; - - 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; - } -} - -class_alias('Twig_Sandbox_SecurityNotAllowedTagError', 'Twig\Sandbox\SecurityNotAllowedTagError', false); diff --git a/inc/lib/Twig/Sandbox/SecurityPolicy.php b/inc/lib/Twig/Sandbox/SecurityPolicy.php deleted file mode 100644 index dca0b82b..00000000 --- a/inc/lib/Twig/Sandbox/SecurityPolicy.php +++ /dev/null @@ -1,125 +0,0 @@ - - */ -class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterface -{ - protected $allowedTags; - protected $allowedFilters; - protected $allowedMethods; - protected $allowedProperties; - protected $allowedFunctions; - - 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) { - $class = get_class($obj); - throw new Twig_Sandbox_SecurityNotAllowedMethodError(sprintf('Calling "%s" method on a "%s" object is not allowed.', $method, $class), $class, $method); - } - } - - 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) { - $class = get_class($obj); - throw new Twig_Sandbox_SecurityNotAllowedPropertyError(sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, $class), $class, $property); - } - } -} - -class_alias('Twig_Sandbox_SecurityPolicy', 'Twig\Sandbox\SecurityPolicy', false); diff --git a/inc/lib/Twig/Sandbox/SecurityPolicyInterface.php b/inc/lib/Twig/Sandbox/SecurityPolicyInterface.php deleted file mode 100644 index 88f64447..00000000 --- a/inc/lib/Twig/Sandbox/SecurityPolicyInterface.php +++ /dev/null @@ -1,26 +0,0 @@ - - */ -interface Twig_Sandbox_SecurityPolicyInterface -{ - public function checkSecurity($tags, $filters, $functions); - - public function checkMethodAllowed($obj, $method); - - public function checkPropertyAllowed($obj, $method); -} - -class_alias('Twig_Sandbox_SecurityPolicyInterface', 'Twig\Sandbox\SecurityPolicyInterface', false); diff --git a/inc/lib/Twig/SimpleFilter.php b/inc/lib/Twig/SimpleFilter.php deleted file mode 100644 index ee4c0aeb..00000000 --- a/inc/lib/Twig/SimpleFilter.php +++ /dev/null @@ -1,121 +0,0 @@ - - */ -class Twig_SimpleFilter -{ - protected $name; - protected $callable; - protected $options; - protected $arguments = array(); - - public function __construct($name, $callable, array $options = array()) - { - $this->name = $name; - $this->callable = $callable; - $this->options = array_merge(array( - 'needs_environment' => false, - 'needs_context' => false, - 'is_variadic' => false, - 'is_safe' => null, - 'is_safe_callback' => null, - 'pre_escape' => null, - 'preserves_safety' => null, - 'node_class' => 'Twig_Node_Expression_Filter', - 'deprecated' => false, - 'alternative' => null, - ), $options); - } - - public function getName() - { - return $this->name; - } - - public function getCallable() - { - return $this->callable; - } - - public function getNodeClass() - { - return $this->options['node_class']; - } - - public function setArguments($arguments) - { - $this->arguments = $arguments; - } - - public function getArguments() - { - return $this->arguments; - } - - public function needsEnvironment() - { - return $this->options['needs_environment']; - } - - public function needsContext() - { - return $this->options['needs_context']; - } - - public function getSafe(Twig_Node $filterArgs) - { - if (null !== $this->options['is_safe']) { - return $this->options['is_safe']; - } - - if (null !== $this->options['is_safe_callback']) { - return call_user_func($this->options['is_safe_callback'], $filterArgs); - } - } - - public function getPreservesSafety() - { - return $this->options['preserves_safety']; - } - - public function getPreEscape() - { - return $this->options['pre_escape']; - } - - public function isVariadic() - { - return $this->options['is_variadic']; - } - - public function isDeprecated() - { - return (bool) $this->options['deprecated']; - } - - public function getDeprecatedVersion() - { - return $this->options['deprecated']; - } - - public function getAlternative() - { - return $this->options['alternative']; - } -} - -class_alias('Twig_SimpleFilter', 'Twig\TwigFilter', false); diff --git a/inc/lib/Twig/SimpleFunction.php b/inc/lib/Twig/SimpleFunction.php deleted file mode 100644 index a6aa7ca7..00000000 --- a/inc/lib/Twig/SimpleFunction.php +++ /dev/null @@ -1,111 +0,0 @@ - - */ -class Twig_SimpleFunction -{ - protected $name; - protected $callable; - protected $options; - protected $arguments = array(); - - public function __construct($name, $callable, array $options = array()) - { - $this->name = $name; - $this->callable = $callable; - $this->options = array_merge(array( - 'needs_environment' => false, - 'needs_context' => false, - 'is_variadic' => false, - 'is_safe' => null, - 'is_safe_callback' => null, - 'node_class' => 'Twig_Node_Expression_Function', - 'deprecated' => false, - 'alternative' => null, - ), $options); - } - - public function getName() - { - return $this->name; - } - - public function getCallable() - { - return $this->callable; - } - - public function getNodeClass() - { - return $this->options['node_class']; - } - - public function setArguments($arguments) - { - $this->arguments = $arguments; - } - - public function getArguments() - { - return $this->arguments; - } - - public function needsEnvironment() - { - return $this->options['needs_environment']; - } - - public function needsContext() - { - return $this->options['needs_context']; - } - - public function getSafe(Twig_Node $functionArgs) - { - if (null !== $this->options['is_safe']) { - return $this->options['is_safe']; - } - - if (null !== $this->options['is_safe_callback']) { - return call_user_func($this->options['is_safe_callback'], $functionArgs); - } - - return array(); - } - - public function isVariadic() - { - return $this->options['is_variadic']; - } - - public function isDeprecated() - { - return (bool) $this->options['deprecated']; - } - - public function getDeprecatedVersion() - { - return $this->options['deprecated']; - } - - public function getAlternative() - { - return $this->options['alternative']; - } -} - -class_alias('Twig_SimpleFunction', 'Twig\TwigFunction', false); diff --git a/inc/lib/Twig/SimpleTest.php b/inc/lib/Twig/SimpleTest.php deleted file mode 100644 index fee5778b..00000000 --- a/inc/lib/Twig/SimpleTest.php +++ /dev/null @@ -1,73 +0,0 @@ - - */ -class Twig_SimpleTest -{ - protected $name; - protected $callable; - protected $options; - - public function __construct($name, $callable, array $options = array()) - { - $this->name = $name; - $this->callable = $callable; - $this->options = array_merge(array( - 'is_variadic' => false, - 'node_class' => 'Twig_Node_Expression_Test', - 'deprecated' => false, - 'alternative' => null, - ), $options); - } - - public function getName() - { - return $this->name; - } - - public function getCallable() - { - return $this->callable; - } - - public function getNodeClass() - { - return $this->options['node_class']; - } - - public function isVariadic() - { - return $this->options['is_variadic']; - } - - public function isDeprecated() - { - return (bool) $this->options['deprecated']; - } - - public function getDeprecatedVersion() - { - return $this->options['deprecated']; - } - - public function getAlternative() - { - return $this->options['alternative']; - } -} - -class_alias('Twig_SimpleTest', 'Twig\TwigTest', false); diff --git a/inc/lib/Twig/Source.php b/inc/lib/Twig/Source.php deleted file mode 100644 index bd8d869f..00000000 --- a/inc/lib/Twig/Source.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ -class Twig_Source -{ - private $code; - private $name; - private $path; - - /** - * @param string $code The template source code - * @param string $name The template logical name - * @param string $path The filesystem path of the template if any - */ - public function __construct($code, $name, $path = '') - { - $this->code = $code; - $this->name = $name; - $this->path = $path; - } - - public function getCode() - { - return $this->code; - } - - public function getName() - { - return $this->name; - } - - public function getPath() - { - return $this->path; - } -} - -class_alias('Twig_Source', 'Twig\Source', false); diff --git a/inc/lib/Twig/SourceContextLoaderInterface.php b/inc/lib/Twig/SourceContextLoaderInterface.php deleted file mode 100644 index a6e8c425..00000000 --- a/inc/lib/Twig/SourceContextLoaderInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * @deprecated since 1.27 (to be removed in 3.0) - */ -interface Twig_SourceContextLoaderInterface -{ - /** - * Returns the source context for a given template logical name. - * - * @param string $name The template logical name - * - * @return Twig_Source - * - * @throws Twig_Error_Loader When $name is not found - */ - public function getSourceContext($name); -} - -class_alias('Twig_SourceContextLoaderInterface', 'Twig\Loader\SourceContextLoaderInterface', false); diff --git a/inc/lib/Twig/Template.php b/inc/lib/Twig/Template.php deleted file mode 100644 index c013b6a2..00000000 --- a/inc/lib/Twig/Template.php +++ /dev/null @@ -1,708 +0,0 @@ -load() - * instead, which returns an instance of Twig_TemplateWrapper. - * - * @author Fabien Potencier
- * HTTP_ConditionalGet::check($updateTime, true); // exits if client has cache
- * echo $content;
- *
- *
- * E.g. Content from DB with no update time:
- *
- * $content = getContentFromDB();
- * $cg = new HTTP_ConditionalGet(array(
- * 'contentHash' => md5($content)
- * ));
- * $cg->sendHeaders();
- * if ($cg->cacheIsValid) {
- * exit();
- * }
- * echo $content;
- *
- *
- * E.g. Static content with some static includes:
- *
- * // before content
- * $cg = new HTTP_ConditionalGet(array(
- * 'lastUpdateTime' => max(
- * filemtime(__FILE__)
- * ,filemtime('/path/to/header.inc')
- * ,filemtime('/path/to/footer.inc')
- * )
- * ));
- * $cg->sendHeaders();
- * if ($cg->cacheIsValid) {
- * exit();
- * }
- *
- * @package Minify
- * @subpackage HTTP
- * @author Stephen Clay
- * array(
- * 'Cache-Control' => 'max-age=0, public'
- * ,'ETag' => '"foobar"'
- * )
- *
- *
- * @return array
- */
- public function getHeaders()
- {
- return $this->_headers;
- }
-
- /**
- * Set the Content-Length header in bytes
- *
- * With most PHP configs, as long as you don't flush() output, this method
- * is not needed and PHP will buffer all output and set Content-Length for
- * you. Otherwise you'll want to call this to let the client know up front.
- *
- * @param int $bytes
- *
- * @return int copy of input $bytes
- */
- public function setContentLength($bytes)
- {
- return $this->_headers['Content-Length'] = $bytes;
- }
-
- /**
- * Send headers
- *
- * @see getHeaders()
- *
- * Note this doesn't "clear" the headers. Calling sendHeaders() will
- * call header() again (but probably have not effect) and getHeaders() will
- * still return the headers.
- *
- * @return null
- */
- public function sendHeaders()
- {
- $headers = $this->_headers;
- if (array_key_exists('_responseCode', $headers)) {
- // FastCGI environments require 3rd arg to header() to be set
- list(, $code) = explode(' ', $headers['_responseCode'], 3);
- header($headers['_responseCode'], true, $code);
- unset($headers['_responseCode']);
- }
- foreach ($headers as $name => $val) {
- header($name . ': ' . $val);
- }
- }
-
- /**
- * Exit if the client's cache is valid for this resource
- *
- * This is a convenience method for common use of the class
- *
- * @param int $lastModifiedTime if given, both ETag AND Last-Modified headers
- * will be sent with content. This is recommended.
- *
- * @param bool $isPublic (default false) if true, the Cache-Control header
- * will contain "public", allowing proxies to cache the content. Otherwise
- * "private" will be sent, allowing only browser caching.
- *
- * @param array $options (default empty) additional options for constructor
- */
- public static function check($lastModifiedTime = null, $isPublic = false, $options = array())
- {
- if (null !== $lastModifiedTime) {
- $options['lastModifiedTime'] = (int)$lastModifiedTime;
- }
- $options['isPublic'] = (bool)$isPublic;
- $cg = new HTTP_ConditionalGet($options);
- $cg->sendHeaders();
- if ($cg->cacheIsValid) {
- exit();
- }
- }
-
-
- /**
- * Get a GMT formatted date for use in HTTP headers
- *
- *
- * header('Expires: ' . HTTP_ConditionalGet::gmtdate($time));
- *
- *
- * @param int $time unix timestamp
- *
- * @return string
- */
- public static function gmtDate($time)
- {
- return gmdate('D, d M Y H:i:s \G\M\T', $time);
- }
-
- protected $_headers = array();
- protected $_lmTime = null;
- protected $_etag = null;
- protected $_stripEtag = false;
-
- /**
- * @param string $hash
- *
- * @param string $scope
- */
- protected function _setEtag($hash, $scope)
- {
- $this->_etag = '"' . substr($scope, 0, 3) . $hash . '"';
- $this->_headers['ETag'] = $this->_etag;
- }
-
- /**
- * @param int $time
- */
- protected function _setLastModified($time)
- {
- $this->_lmTime = (int)$time;
- $this->_headers['Last-Modified'] = self::gmtDate($time);
- }
-
- /**
- * Determine validity of client cache and queue 304 header if valid
- *
- * @return bool
- */
- protected function _isCacheValid()
- {
- if (null === $this->_etag) {
- // lmTime is copied to ETag, so this condition implies that the
- // server sent neither ETag nor Last-Modified, so the client can't
- // possibly has a valid cache.
- return false;
- }
- $isValid = ($this->resourceMatchedEtag() || $this->resourceNotModified());
- if ($isValid) {
- $this->_headers['_responseCode'] = 'HTTP/1.0 304 Not Modified';
- }
- return $isValid;
- }
-
- /**
- * @return bool
- */
- protected function resourceMatchedEtag()
- {
- if (!isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
- return false;
- }
- $clientEtagList = get_magic_quotes_gpc()
- ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])
- : $_SERVER['HTTP_IF_NONE_MATCH'];
- $clientEtags = explode(',', $clientEtagList);
-
- $compareTo = $this->normalizeEtag($this->_etag);
- foreach ($clientEtags as $clientEtag) {
- if ($this->normalizeEtag($clientEtag) === $compareTo) {
- // respond with the client's matched ETag, even if it's not what
- // we would've sent by default
- $this->_headers['ETag'] = trim($clientEtag);
- return true;
- }
- }
- return false;
- }
-
- /**
- * @param string $etag
- *
- * @return string
- */
- protected function normalizeEtag($etag) {
- $etag = trim($etag);
- return $this->_stripEtag
- ? preg_replace('/;\\w\\w"$/', '"', $etag)
- : $etag;
- }
-
- /**
- * @return bool
- */
- protected function resourceNotModified()
- {
- if (!isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
- return false;
- }
- // strip off IE's extra data (semicolon)
- list($ifModifiedSince) = explode(';', $_SERVER['HTTP_IF_MODIFIED_SINCE'], 2);
- if (strtotime($ifModifiedSince) >= $this->_lmTime) {
- // Apache 2.2's behavior. If there was no ETag match, send the
- // non-encoded version of the ETag value.
- $this->_headers['ETag'] = $this->normalizeEtag($this->_etag);
- return true;
- }
- return false;
- }
-}
diff --git a/inc/lib/minify/HTTP/Encoder.php b/inc/lib/minify/HTTP/Encoder.php
deleted file mode 100755
index 8f347793..00000000
--- a/inc/lib/minify/HTTP/Encoder.php
+++ /dev/null
@@ -1,335 +0,0 @@
-
- * // Send a CSS file, compressed if possible
- * $he = new HTTP_Encoder(array(
- * 'content' => file_get_contents($cssFile)
- * ,'type' => 'text/css'
- * ));
- * $he->encode();
- * $he->sendAll();
- *
- *
- *
- * // Shortcut to encoding output
- * header('Content-Type: text/css'); // needed if not HTML
- * HTTP_Encoder::output($css);
- *
- *
- *
- * // Just sniff for the accepted encoding
- * $encoding = HTTP_Encoder::getAcceptedEncoding();
- *
- *
- * For more control over headers, use getHeaders() and getData() and send your
- * own output.
- *
- * Note: If you don't need header mgmt, use PHP's native gzencode, gzdeflate,
- * and gzcompress functions for gzip, deflate, and compress-encoding
- * respectively.
- *
- * @package Minify
- * @subpackage HTTP
- * @author Stephen Clay
- * array(
- * 'Content-Length' => '615'
- * ,'Content-Encoding' => 'x-gzip'
- * ,'Vary' => 'Accept-Encoding'
- * )
- *
- *
- * @return array
- */
- public function getHeaders()
- {
- return $this->_headers;
- }
-
- /**
- * Send output headers
- *
- * You must call this before headers are sent and it probably cannot be
- * used in conjunction with zlib output buffering / mod_gzip. Errors are
- * not handled purposefully.
- *
- * @see getHeaders()
- */
- public function sendHeaders()
- {
- foreach ($this->_headers as $name => $val) {
- header($name . ': ' . $val);
- }
- }
-
- /**
- * Send output headers and content
- *
- * A shortcut for sendHeaders() and echo getContent()
- *
- * You must call this before headers are sent and it probably cannot be
- * used in conjunction with zlib output buffering / mod_gzip. Errors are
- * not handled purposefully.
- */
- public function sendAll()
- {
- $this->sendHeaders();
- echo $this->_content;
- }
-
- /**
- * Determine the client's best encoding method from the HTTP Accept-Encoding
- * header.
- *
- * If no Accept-Encoding header is set, or the browser is IE before v6 SP2,
- * this will return ('', ''), the "identity" encoding.
- *
- * A syntax-aware scan is done of the Accept-Encoding, so the method must
- * be non 0. The methods are favored in order of gzip, deflate, then
- * compress. Deflate is always smallest and generally faster, but is
- * rarely sent by servers, so client support could be buggier.
- *
- * @param bool $allowCompress allow the older compress encoding
- *
- * @param bool $allowDeflate allow the more recent deflate encoding
- *
- * @return array two values, 1st is the actual encoding method, 2nd is the
- * alias of that method to use in the Content-Encoding header (some browsers
- * call gzip "x-gzip" etc.)
- */
- public static function getAcceptedEncoding($allowCompress = true, $allowDeflate = true)
- {
- // @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
-
- if (! isset($_SERVER['HTTP_ACCEPT_ENCODING'])
- || self::isBuggyIe())
- {
- return array('', '');
- }
- $ae = $_SERVER['HTTP_ACCEPT_ENCODING'];
- // gzip checks (quick)
- if (0 === strpos($ae, 'gzip,') // most browsers
- || 0 === strpos($ae, 'deflate, gzip,') // opera
- ) {
- return array('gzip', 'gzip');
- }
- // gzip checks (slow)
- if (preg_match(
- '@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
- ,$ae
- ,$m)) {
- return array('gzip', $m[1]);
- }
- if ($allowDeflate) {
- // deflate checks
- $aeRev = strrev($ae);
- if (0 === strpos($aeRev, 'etalfed ,') // ie, webkit
- || 0 === strpos($aeRev, 'etalfed,') // gecko
- || 0 === strpos($ae, 'deflate,') // opera
- // slow parsing
- || preg_match(
- '@(?:^|,)\\s*deflate\\s*(?:$|,|;\\s*q=(?:0\\.|1))@', $ae)) {
- return array('deflate', 'deflate');
- }
- }
- if ($allowCompress && preg_match(
- '@(?:^|,)\\s*((?:x-)?compress)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
- ,$ae
- ,$m)) {
- return array('compress', $m[1]);
- }
- return array('', '');
- }
-
- /**
- * Encode (compress) the content
- *
- * If the encode method is '' (none) or compression level is 0, or the 'zlib'
- * extension isn't loaded, we return false.
- *
- * Then the appropriate gz_* function is called to compress the content. If
- * this fails, false is returned.
- *
- * The header "Vary: Accept-Encoding" is added. If encoding is successful,
- * the Content-Length header is updated, and Content-Encoding is also added.
- *
- * @param int $compressionLevel given to zlib functions. If not given, the
- * class default will be used.
- *
- * @return bool success true if the content was actually compressed
- */
- public function encode($compressionLevel = null)
- {
- if (! self::isBuggyIe()) {
- $this->_headers['Vary'] = 'Accept-Encoding';
- }
- if (null === $compressionLevel) {
- $compressionLevel = self::$compressionLevel;
- }
- if ('' === $this->_encodeMethod[0]
- || ($compressionLevel == 0)
- || !extension_loaded('zlib'))
- {
- return false;
- }
- if ($this->_encodeMethod[0] === 'deflate') {
- $encoded = gzdeflate($this->_content, $compressionLevel);
- } elseif ($this->_encodeMethod[0] === 'gzip') {
- $encoded = gzencode($this->_content, $compressionLevel);
- } else {
- $encoded = gzcompress($this->_content, $compressionLevel);
- }
- if (false === $encoded) {
- return false;
- }
- $this->_headers['Content-Length'] = $this->_useMbStrlen
- ? (string)mb_strlen($encoded, '8bit')
- : (string)strlen($encoded);
- $this->_headers['Content-Encoding'] = $this->_encodeMethod[1];
- $this->_content = $encoded;
- return true;
- }
-
- /**
- * Encode and send appropriate headers and content
- *
- * This is a convenience method for common use of the class
- *
- * @param string $content
- *
- * @param int $compressionLevel given to zlib functions. If not given, the
- * class default will be used.
- *
- * @return bool success true if the content was actually compressed
- */
- public static function output($content, $compressionLevel = null)
- {
- if (null === $compressionLevel) {
- $compressionLevel = self::$compressionLevel;
- }
- $he = new HTTP_Encoder(array('content' => $content));
- $ret = $he->encode($compressionLevel);
- $he->sendAll();
- return $ret;
- }
-
- /**
- * Is the browser an IE version earlier than 6 SP2?
- *
- * @return bool
- */
- public static function isBuggyIe()
- {
- if (empty($_SERVER['HTTP_USER_AGENT'])) {
- return false;
- }
- $ua = $_SERVER['HTTP_USER_AGENT'];
- // quick escape for non-IEs
- if (0 !== strpos($ua, 'Mozilla/4.0 (compatible; MSIE ')
- || false !== strpos($ua, 'Opera')) {
- return false;
- }
- // no regex = faaast
- $version = (float)substr($ua, 30);
- return self::$encodeToIe6
- ? ($version < 6 || ($version == 6 && false === strpos($ua, 'SV1')))
- : ($version < 7);
- }
-
- protected $_content = '';
- protected $_headers = array();
- protected $_encodeMethod = array('', '');
- protected $_useMbStrlen = false;
-}
diff --git a/inc/lib/minify/JSMin.php b/inc/lib/minify/JSMin.php
deleted file mode 100755
index 9840d8b3..00000000
--- a/inc/lib/minify/JSMin.php
+++ /dev/null
@@ -1,449 +0,0 @@
-
- * $minifiedJs = JSMin::minify($js);
- *
- *
- * This is a modified port of jsmin.c. Improvements:
- *
- * Does not choke on some regexp literals containing quote characters. E.g. /'/
- *
- * Spaces are preserved after some add/sub operators, so they are not mistakenly
- * converted to post-inc/dec. E.g. a + ++b -> a+ ++b
- *
- * Preserves multi-line comments that begin with /*!
- *
- * PHP 5 or higher is required.
- *
- * Permission is hereby granted to use this version of the library under the
- * same terms as jsmin.c, which has the following license:
- *
- * --
- * Copyright (c) 2002 Douglas Crockford (www.crockford.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is furnished to do
- * so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * The Software shall be used for Good, not Evil.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- * --
- *
- * @package JSMin
- * @author Ryan Grove
- * echo $b->uri('/site.js');
- * // outputs "/site.js?1678242"
- *
- * echo $b->uri('/scriptaculous.js?load=effects');
- * // outputs "/scriptaculous.js?load=effects&1678242"
- *
- *
- * @param string $uri
- * @param boolean $forceAmpersand (default = false) Force the use of ampersand to
- * append the timestamp to the URI.
- * @return string
- */
- public function uri($uri, $forceAmpersand = false) {
- $sep = ($forceAmpersand || strpos($uri, '?') !== false)
- ? self::$ampersand
- : '?';
- return "{$uri}{$sep}{$this->lastModified}";
- }
-
- /**
- * Create a build object
- *
- * @param array $sources array of Minify_Source objects and/or file paths
- *
- * @return null
- */
- public function __construct($sources)
- {
- $max = 0;
- foreach ((array)$sources as $source) {
- if ($source instanceof Minify_Source) {
- $max = max($max, $source->lastModified);
- } elseif (is_string($source)) {
- if (0 === strpos($source, '//')) {
- $source = $_SERVER['DOCUMENT_ROOT'] . substr($source, 1);
- }
- if (is_file($source)) {
- $max = max($max, filemtime($source));
- }
- }
- }
- $this->lastModified = $max;
- }
-}
diff --git a/inc/lib/minify/Minify/CSS.php b/inc/lib/minify/Minify/CSS.php
deleted file mode 100755
index 32414551..00000000
--- a/inc/lib/minify/Minify/CSS.php
+++ /dev/null
@@ -1,99 +0,0 @@
-
- * @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
- */
-class Minify_CSS {
-
- /**
- * Minify a CSS string
- *
- * @param string $css
- *
- * @param array $options available options:
- *
- * 'preserveComments': (default true) multi-line comments that begin
- * with "/*!" will be preserved with newlines before and after to
- * enhance readability.
- *
- * 'removeCharsets': (default true) remove all @charset at-rules
- *
- * 'prependRelativePath': (default null) if given, this string will be
- * prepended to all relative URIs in import/url declarations
- *
- * 'currentDir': (default null) if given, this is assumed to be the
- * directory of the current CSS file. Using this, minify will rewrite
- * all relative URIs in import/url declarations to correctly point to
- * the desired files. For this to work, the files *must* exist and be
- * visible by the PHP process.
- *
- * 'symlinks': (default = array()) If the CSS file is stored in
- * a symlink-ed directory, provide an array of link paths to
- * target paths, where the link paths are within the document root. Because
- * paths need to be normalized for this to work, use "//" to substitute
- * the doc root in the link paths (the array keys). E.g.:
- *
- * array('//symlink' => '/real/target/path') // unix
- * array('//static' => 'D:\\staticStorage') // Windows
- *
- *
- * 'docRoot': (default = $_SERVER['DOCUMENT_ROOT'])
- * see Minify_CSS_UriRewriter::rewrite
- *
- * @return string
- */
- public static function minify($css, $options = array())
- {
- $options = array_merge(array(
- 'compress' => true,
- 'removeCharsets' => true,
- 'preserveComments' => true,
- 'currentDir' => null,
- 'docRoot' => $_SERVER['DOCUMENT_ROOT'],
- 'prependRelativePath' => null,
- 'symlinks' => array(),
- ), $options);
-
- if ($options['removeCharsets']) {
- $css = preg_replace('/@charset[^;]+;\\s*/', '', $css);
- }
- if ($options['compress']) {
- if (! $options['preserveComments']) {
- $css = Minify_CSS_Compressor::process($css, $options);
- } else {
- $css = Minify_CommentPreserver::process(
- $css
- ,array('Minify_CSS_Compressor', 'process')
- ,array($options)
- );
- }
- }
- if (! $options['currentDir'] && ! $options['prependRelativePath']) {
- return $css;
- }
- if ($options['currentDir']) {
- return Minify_CSS_UriRewriter::rewrite(
- $css
- ,$options['currentDir']
- ,$options['docRoot']
- ,$options['symlinks']
- );
- } else {
- return Minify_CSS_UriRewriter::prepend(
- $css
- ,$options['prependRelativePath']
- );
- }
- }
-}
diff --git a/inc/lib/minify/Minify/CSS/Compressor.php b/inc/lib/minify/Minify/CSS/Compressor.php
deleted file mode 100755
index c6cdd8b7..00000000
--- a/inc/lib/minify/Minify/CSS/Compressor.php
+++ /dev/null
@@ -1,249 +0,0 @@
-
- * @author http://code.google.com/u/1stvamp/ (Issue 64 patch)
- */
-class Minify_CSS_Compressor {
-
- /**
- * Minify a CSS string
- *
- * @param string $css
- *
- * @param array $options (currently ignored)
- *
- * @return string
- */
- public static function process($css, $options = array())
- {
- $obj = new Minify_CSS_Compressor($options);
- return $obj->_process($css);
- }
-
- /**
- * @var array
- */
- protected $_options = null;
-
- /**
- * Are we "in" a hack? I.e. are some browsers targetted until the next comment?
- *
- * @var bool
- */
- protected $_inHack = false;
-
-
- /**
- * Constructor
- *
- * @param array $options (currently ignored)
- */
- private function __construct($options) {
- $this->_options = $options;
- }
-
- /**
- * Minify a CSS string
- *
- * @param string $css
- *
- * @return string
- */
- protected function _process($css)
- {
- $css = str_replace("\r\n", "\n", $css);
-
- // preserve empty comment after '>'
- // http://www.webdevout.net/css-hacks#in_css-selectors
- $css = preg_replace('@>/\\*\\s*\\*/@', '>/*keep*/', $css);
-
- // preserve empty comment between property and value
- // http://css-discuss.incutio.com/?page=BoxModelHack
- $css = preg_replace('@/\\*\\s*\\*/\\s*:@', '/*keep*/:', $css);
- $css = preg_replace('@:\\s*/\\*\\s*\\*/@', ':/*keep*/', $css);
-
- // apply callback to all valid comments (and strip out surrounding ws
- $css = preg_replace_callback('@\\s*/\\*([\\s\\S]*?)\\*/\\s*@'
- ,array($this, '_commentCB'), $css);
-
- // remove ws around { } and last semicolon in declaration block
- $css = preg_replace('/\\s*{\\s*/', '{', $css);
- $css = preg_replace('/;?\\s*}\\s*/', '}', $css);
-
- // remove ws surrounding semicolons
- $css = preg_replace('/\\s*;\\s*/', ';', $css);
-
- // remove ws around urls
- $css = preg_replace('/
- url\\( # url(
- \\s*
- ([^\\)]+?) # 1 = the URL (really just a bunch of non right parenthesis)
- \\s*
- \\) # )
- /x', 'url($1)', $css);
-
- // remove ws between rules and colons
- $css = preg_replace('/
- \\s*
- ([{;]) # 1 = beginning of block or rule separator
- \\s*
- ([\\*_]?[\\w\\-]+) # 2 = property (and maybe IE filter)
- \\s*
- :
- \\s*
- (\\b|[#\'"-]) # 3 = first character of a value
- /x', '$1$2:$3', $css);
-
- // remove ws in selectors
- $css = preg_replace_callback('/
- (?: # non-capture
- \\s*
- [^~>+,\\s]+ # selector part
- \\s*
- [,>+~] # combinators
- )+
- \\s*
- [^~>+,\\s]+ # selector part
- { # open declaration block
- /x'
- ,array($this, '_selectorsCB'), $css);
-
- // minimize hex colors
- $css = preg_replace('/([^=])#([a-f\\d])\\2([a-f\\d])\\3([a-f\\d])\\4([\\s;\\}])/i'
- , '$1#$2$3$4$5', $css);
-
- // remove spaces between font families
- $css = preg_replace_callback('/font-family:([^;}]+)([;}])/'
- ,array($this, '_fontFamilyCB'), $css);
-
- $css = preg_replace('/@import\\s+url/', '@import url', $css);
-
- // replace any ws involving newlines with a single newline
- $css = preg_replace('/[ \\t]*\\n+\\s*/', "\n", $css);
-
- // separate common descendent selectors w/ newlines (to limit line lengths)
- $css = preg_replace('/([\\w#\\.\\*]+)\\s+([\\w#\\.\\*]+){/', "$1\n$2{", $css);
-
- // Use newline after 1st numeric value (to limit line lengths).
- $css = preg_replace('/
- ((?:padding|margin|border|outline):\\d+(?:px|em)?) # 1 = prop : 1st numeric value
- \\s+
- /x'
- ,"$1\n", $css);
-
- // prevent triggering IE6 bug: http://www.crankygeek.com/ie6pebug/
- $css = preg_replace('/:first-l(etter|ine)\\{/', ':first-l$1 {', $css);
-
- return trim($css);
- }
-
- /**
- * Replace what looks like a set of selectors
- *
- * @param array $m regex matches
- *
- * @return string
- */
- protected function _selectorsCB($m)
- {
- // remove ws around the combinators
- return preg_replace('/\\s*([,>+~])\\s*/', '$1', $m[0]);
- }
-
- /**
- * Process a comment and return a replacement
- *
- * @param array $m regex matches
- *
- * @return string
- */
- protected function _commentCB($m)
- {
- $hasSurroundingWs = (trim($m[0]) !== $m[1]);
- $m = $m[1];
- // $m is the comment content w/o the surrounding tokens,
- // but the return value will replace the entire comment.
- if ($m === 'keep') {
- return '/**/';
- }
- if ($m === '" "') {
- // component of http://tantek.com/CSS/Examples/midpass.html
- return '/*" "*/';
- }
- if (preg_match('@";\\}\\s*\\}/\\*\\s+@', $m)) {
- // component of http://tantek.com/CSS/Examples/midpass.html
- return '/*";}}/* */';
- }
- if ($this->_inHack) {
- // inversion: feeding only to one browser
- if (preg_match('@
- ^/ # comment started like /*/
- \\s*
- (\\S[\\s\\S]+?) # has at least some non-ws content
- \\s*
- /\\* # ends like /*/ or /**/
- @x', $m, $n)) {
- // end hack mode after this comment, but preserve the hack and comment content
- $this->_inHack = false;
- return "/*/{$n[1]}/**/";
- }
- }
- if (substr($m, -1) === '\\') { // comment ends like \*/
- // begin hack mode and preserve hack
- $this->_inHack = true;
- return '/*\\*/';
- }
- if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */
- // begin hack mode and preserve hack
- $this->_inHack = true;
- return '/*/*/';
- }
- if ($this->_inHack) {
- // a regular comment ends hack mode but should be preserved
- $this->_inHack = false;
- return '/**/';
- }
- // Issue 107: if there's any surrounding whitespace, it may be important, so
- // replace the comment with a single space
- return $hasSurroundingWs // remove all other comments
- ? ' '
- : '';
- }
-
- /**
- * Process a font-family listing and return a replacement
- *
- * @param array $m regex matches
- *
- * @return string
- */
- protected function _fontFamilyCB($m)
- {
- // Issue 210: must not eliminate WS between words in unquoted families
- $pieces = preg_split('/(\'[^\']+\'|"[^"]+")/', $m[1], null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
- $out = 'font-family:';
- while (null !== ($piece = array_shift($pieces))) {
- if ($piece[0] !== '"' && $piece[0] !== "'") {
- $piece = preg_replace('/\\s+/', ' ', $piece);
- $piece = preg_replace('/\\s?,\\s?/', ',', $piece);
- }
- $out .= $piece;
- }
- return $out . $m[2];
- }
-}
diff --git a/inc/lib/minify/Minify/CSS/UriRewriter.php b/inc/lib/minify/Minify/CSS/UriRewriter.php
deleted file mode 100755
index 43cc2548..00000000
--- a/inc/lib/minify/Minify/CSS/UriRewriter.php
+++ /dev/null
@@ -1,307 +0,0 @@
-
- */
-class Minify_CSS_UriRewriter {
-
- /**
- * rewrite() and rewriteRelative() append debugging information here
- *
- * @var string
- */
- public static $debugText = '';
-
- /**
- * In CSS content, rewrite file relative URIs as root relative
- *
- * @param string $css
- *
- * @param string $currentDir The directory of the current CSS file.
- *
- * @param string $docRoot The document root of the web site in which
- * the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
- *
- * @param array $symlinks (default = array()) If the CSS file is stored in
- * a symlink-ed directory, provide an array of link paths to
- * target paths, where the link paths are within the document root. Because
- * paths need to be normalized for this to work, use "//" to substitute
- * the doc root in the link paths (the array keys). E.g.:
- *
- * array('//symlink' => '/real/target/path') // unix
- * array('//static' => 'D:\\staticStorage') // Windows
- *
- *
- * @return string
- */
- public static function rewrite($css, $currentDir, $docRoot = null, $symlinks = array())
- {
- self::$_docRoot = self::_realpath(
- $docRoot ? $docRoot : $_SERVER['DOCUMENT_ROOT']
- );
- self::$_currentDir = self::_realpath($currentDir);
- self::$_symlinks = array();
-
- // normalize symlinks
- foreach ($symlinks as $link => $target) {
- $link = ($link === '//')
- ? self::$_docRoot
- : str_replace('//', self::$_docRoot . '/', $link);
- $link = strtr($link, '/', DIRECTORY_SEPARATOR);
- self::$_symlinks[$link] = self::_realpath($target);
- }
-
- self::$debugText .= "docRoot : " . self::$_docRoot . "\n"
- . "currentDir : " . self::$_currentDir . "\n";
- if (self::$_symlinks) {
- self::$debugText .= "symlinks : " . var_export(self::$_symlinks, 1) . "\n";
- }
- self::$debugText .= "\n";
-
- $css = self::_trimUrls($css);
-
- // rewrite
- $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
- ,array(self::$className, '_processUriCB'), $css);
- $css = preg_replace_callback('/url\\(\\s*([\'"](.*?)[\'"]|[^\\)\\s]+)\\s*\\)/'
- ,array(self::$className, '_processUriCB'), $css);
-
- return $css;
- }
-
- /**
- * In CSS content, prepend a path to relative URIs
- *
- * @param string $css
- *
- * @param string $path The path to prepend.
- *
- * @return string
- */
- public static function prepend($css, $path)
- {
- self::$_prependPath = $path;
-
- $css = self::_trimUrls($css);
-
- // append
- $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
- ,array(self::$className, '_processUriCB'), $css);
- $css = preg_replace_callback('/url\\(\\s*([\'"](.*?)[\'"]|[^\\)\\s]+)\\s*\\)/'
- ,array(self::$className, '_processUriCB'), $css);
-
- self::$_prependPath = null;
- return $css;
- }
-
- /**
- * Get a root relative URI from a file relative URI
- *
- *
- * Minify_CSS_UriRewriter::rewriteRelative(
- * '../img/hello.gif'
- * , '/home/user/www/css' // path of CSS file
- * , '/home/user/www' // doc root
- * );
- * // returns '/img/hello.gif'
- *
- * // example where static files are stored in a symlinked directory
- * Minify_CSS_UriRewriter::rewriteRelative(
- * 'hello.gif'
- * , '/var/staticFiles/theme'
- * , '/home/user/www'
- * , array('/home/user/www/static' => '/var/staticFiles')
- * );
- * // returns '/static/theme/hello.gif'
- *
- *
- * @param string $uri file relative URI
- *
- * @param string $realCurrentDir realpath of the current file's directory.
- *
- * @param string $realDocRoot realpath of the site document root.
- *
- * @param array $symlinks (default = array()) If the file is stored in
- * a symlink-ed directory, provide an array of link paths to
- * real target paths, where the link paths "appear" to be within the document
- * root. E.g.:
- *
- * array('/home/foo/www/not/real/path' => '/real/target/path') // unix
- * array('C:\\htdocs\\not\\real' => 'D:\\real\\target\\path') // Windows
- *
- *
- * @return string
- */
- public static function rewriteRelative($uri, $realCurrentDir, $realDocRoot, $symlinks = array())
- {
- // prepend path with current dir separator (OS-independent)
- $path = strtr($realCurrentDir, '/', DIRECTORY_SEPARATOR)
- . DIRECTORY_SEPARATOR . strtr($uri, '/', DIRECTORY_SEPARATOR);
-
- self::$debugText .= "file-relative URI : {$uri}\n"
- . "path prepended : {$path}\n";
-
- // "unresolve" a symlink back to doc root
- foreach ($symlinks as $link => $target) {
- if (0 === strpos($path, $target)) {
- // replace $target with $link
- $path = $link . substr($path, strlen($target));
-
- self::$debugText .= "symlink unresolved : {$path}\n";
-
- break;
- }
- }
- // strip doc root
- $path = substr($path, strlen($realDocRoot));
-
- self::$debugText .= "docroot stripped : {$path}\n";
-
- // fix to root-relative URI
- $uri = strtr($path, '/\\', '//');
- $uri = self::removeDots($uri);
-
- self::$debugText .= "traversals removed : {$uri}\n\n";
-
- return $uri;
- }
-
- /**
- * Remove instances of "./" and "../" where possible from a root-relative URI
- *
- * @param string $uri
- *
- * @return string
- */
- public static function removeDots($uri)
- {
- $uri = str_replace('/./', '/', $uri);
- // inspired by patch from Oleg Cherniy
- do {
- $uri = preg_replace('@/[^/]+/\\.\\./@', '/', $uri, 1, $changed);
- } while ($changed);
- return $uri;
- }
-
- /**
- * Defines which class to call as part of callbacks, change this
- * if you extend Minify_CSS_UriRewriter
- *
- * @var string
- */
- protected static $className = 'Minify_CSS_UriRewriter';
-
- /**
- * Get realpath with any trailing slash removed. If realpath() fails,
- * just remove the trailing slash.
- *
- * @param string $path
- *
- * @return mixed path with no trailing slash
- */
- protected static function _realpath($path)
- {
- $realPath = realpath($path);
- if ($realPath !== false) {
- $path = $realPath;
- }
- return rtrim($path, '/\\');
- }
-
- /**
- * Directory of this stylesheet
- *
- * @var string
- */
- private static $_currentDir = '';
-
- /**
- * DOC_ROOT
- *
- * @var string
- */
- private static $_docRoot = '';
-
- /**
- * directory replacements to map symlink targets back to their
- * source (within the document root) E.g. '/var/www/symlink' => '/var/realpath'
- *
- * @var array
- */
- private static $_symlinks = array();
-
- /**
- * Path to prepend
- *
- * @var string
- */
- private static $_prependPath = null;
-
- /**
- * @param string $css
- *
- * @return string
- */
- private static function _trimUrls($css)
- {
- return preg_replace('/
- url\\( # url(
- \\s*
- ([^\\)]+?) # 1 = URI (assuming does not contain ")")
- \\s*
- \\) # )
- /x', 'url($1)', $css);
- }
-
- /**
- * @param array $m
- *
- * @return string
- */
- private static function _processUriCB($m)
- {
- // $m matched either '/@import\\s+([\'"])(.*?)[\'"]/' or '/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
- $isImport = ($m[0][0] === '@');
- // determine URI and the quote character (if any)
- if ($isImport) {
- $quoteChar = $m[1];
- $uri = $m[2];
- } else {
- // $m[1] is either quoted or not
- $quoteChar = ($m[1][0] === "'" || $m[1][0] === '"')
- ? $m[1][0]
- : '';
- $uri = ($quoteChar === '')
- ? $m[1]
- : substr($m[1], 1, strlen($m[1]) - 2);
- }
- // if not root/scheme relative and not starts with scheme
- if (!preg_match('~^(/|[a-z]+\:)~', $uri)) {
- // URI is file-relative: rewrite depending on options
- if (self::$_prependPath === null) {
- $uri = self::rewriteRelative($uri, self::$_currentDir, self::$_docRoot, self::$_symlinks);
- } else {
- $uri = self::$_prependPath . $uri;
- if ($uri[0] === '/') {
- $root = '';
- $rootRelative = $uri;
- $uri = $root . self::removeDots($rootRelative);
- } elseif (preg_match('@^((https?\:)?//([^/]+))/@', $uri, $m) && (false !== strpos($m[3], '.'))) {
- $root = $m[1];
- $rootRelative = substr($uri, strlen($root));
- $uri = $root . self::removeDots($rootRelative);
- }
- }
- }
- return $isImport
- ? "@import {$quoteChar}{$uri}{$quoteChar}"
- : "url({$quoteChar}{$uri}{$quoteChar})";
- }
-}
diff --git a/inc/lib/minify/Minify/Cache/APC.php b/inc/lib/minify/Minify/Cache/APC.php
deleted file mode 100755
index 24ab0462..00000000
--- a/inc/lib/minify/Minify/Cache/APC.php
+++ /dev/null
@@ -1,133 +0,0 @@
-
- * Minify::setCache(new Minify_Cache_APC());
- *
- *
- * @package Minify
- * @author Chris Edwards
- **/
-class Minify_Cache_APC {
-
- /**
- * Create a Minify_Cache_APC object, to be passed to
- * Minify::setCache().
- *
- *
- * @param int $expire seconds until expiration (default = 0
- * meaning the item will not get an expiration date)
- *
- * @return null
- */
- public function __construct($expire = 0)
- {
- $this->_exp = $expire;
- }
-
- /**
- * Write data to cache.
- *
- * @param string $id cache id
- *
- * @param string $data
- *
- * @return bool success
- */
- public function store($id, $data)
- {
- return apc_store($id, "{$_SERVER['REQUEST_TIME']}|{$data}", $this->_exp);
- }
-
- /**
- * Get the size of a cache entry
- *
- * @param string $id cache id
- *
- * @return int size in bytes
- */
- public function getSize($id)
- {
- if (! $this->_fetch($id)) {
- return false;
- }
- return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
- ? mb_strlen($this->_data, '8bit')
- : strlen($this->_data);
- }
-
- /**
- * Does a valid cache entry exist?
- *
- * @param string $id cache id
- *
- * @param int $srcMtime mtime of the original source file(s)
- *
- * @return bool exists
- */
- public function isValid($id, $srcMtime)
- {
- return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
- }
-
- /**
- * Send the cached content to output
- *
- * @param string $id cache id
- */
- public function display($id)
- {
- echo $this->_fetch($id)
- ? $this->_data
- : '';
- }
-
- /**
- * Fetch the cached content
- *
- * @param string $id cache id
- *
- * @return string
- */
- public function fetch($id)
- {
- return $this->_fetch($id)
- ? $this->_data
- : '';
- }
-
- private $_exp = null;
-
- // cache of most recently fetched id
- private $_lm = null;
- private $_data = null;
- private $_id = null;
-
- /**
- * Fetch data and timestamp from apc, store in instance
- *
- * @param string $id
- *
- * @return bool success
- */
- private function _fetch($id)
- {
- if ($this->_id === $id) {
- return true;
- }
- $ret = apc_fetch($id);
- if (false === $ret) {
- $this->_id = null;
- return false;
- }
- list($this->_lm, $this->_data) = explode('|', $ret, 2);
- $this->_id = $id;
- return true;
- }
-}
diff --git a/inc/lib/minify/Minify/Cache/File.php b/inc/lib/minify/Minify/Cache/File.php
deleted file mode 100755
index c228eb2b..00000000
--- a/inc/lib/minify/Minify/Cache/File.php
+++ /dev/null
@@ -1,197 +0,0 @@
-_locking = $fileLocking;
- $this->_path = $path;
- }
-
- /**
- * Write data to cache.
- *
- * @param string $id cache id (e.g. a filename)
- *
- * @param string $data
- *
- * @return bool success
- */
- public function store($id, $data)
- {
- $flag = $this->_locking
- ? LOCK_EX
- : null;
- $file = $this->_path . '/' . $id;
- if (! @file_put_contents($file, $data, $flag)) {
- $this->_log("Minify_Cache_File: Write failed to '$file'");
- }
- // write control
- if ($data !== $this->fetch($id)) {
- @unlink($file);
- $this->_log("Minify_Cache_File: Post-write read failed for '$file'");
- return false;
- }
- return true;
- }
-
- /**
- * Get the size of a cache entry
- *
- * @param string $id cache id (e.g. a filename)
- *
- * @return int size in bytes
- */
- public function getSize($id)
- {
- return filesize($this->_path . '/' . $id);
- }
-
- /**
- * Does a valid cache entry exist?
- *
- * @param string $id cache id (e.g. a filename)
- *
- * @param int $srcMtime mtime of the original source file(s)
- *
- * @return bool exists
- */
- public function isValid($id, $srcMtime)
- {
- $file = $this->_path . '/' . $id;
- return (is_file($file) && (filemtime($file) >= $srcMtime));
- }
-
- /**
- * Send the cached content to output
- *
- * @param string $id cache id (e.g. a filename)
- */
- public function display($id)
- {
- if ($this->_locking) {
- $fp = fopen($this->_path . '/' . $id, 'rb');
- flock($fp, LOCK_SH);
- fpassthru($fp);
- flock($fp, LOCK_UN);
- fclose($fp);
- } else {
- readfile($this->_path . '/' . $id);
- }
- }
-
- /**
- * Fetch the cached content
- *
- * @param string $id cache id (e.g. a filename)
- *
- * @return string
- */
- public function fetch($id)
- {
- if ($this->_locking) {
- $fp = fopen($this->_path . '/' . $id, 'rb');
- if (!$fp) {
- return false;
- }
- flock($fp, LOCK_SH);
- $ret = stream_get_contents($fp);
- flock($fp, LOCK_UN);
- fclose($fp);
- return $ret;
- } else {
- return file_get_contents($this->_path . '/' . $id);
- }
- }
-
- /**
- * Fetch the cache path used
- *
- * @return string
- */
- public function getPath()
- {
- return $this->_path;
- }
-
- /**
- * Get a usable temp directory
- *
- * Adapted from Solar/Dir.php
- * @author Paul M. Jones _reservePlace("