From 484279620435be0a59d32044f0e484ebb5962958 Mon Sep 17 00:00:00 2001 From: Kanti Date: Sun, 29 Mar 2015 16:18:16 +0200 Subject: [PATCH 1/3] [TASK] fix for PHP 5.4 since pullRequest #140 --- system/admin/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/admin/admin.php b/system/admin/admin.php index d428b38..3f17051 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -68,7 +68,7 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $post_title = $title; $post_fi = $fi; - $post_vid = str_replace(["http://", "https://", "www.", "youtube", ".com", "/watch?v=", "/embed/"], "", $vid); + $post_vid = str_replace(array("http://", "https://", "www.", "youtube", ".com", "/watch?v=", "/embed/"), "", $vid); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { @@ -161,7 +161,7 @@ function add_post($title, $tag, $url, $content, $user, $description = null, $fi, $post_date = date('Y-m-d-H-i-s'); $post_title = $title; $post_fi = $fi; - $post_vid = str_replace(["http://", "https://", "www.", "youtube", ".com", "/watch?v=", "/embed/"], "", $vid); + $post_vid = str_replace(array("http://", "https://", "www.", "youtube", ".com", "/watch?v=", "/embed/"), "", $vid); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { From 3c6936349fdc90c114d6311fd53083edffd0012c Mon Sep 17 00:00:00 2001 From: Kanti Date: Sun, 29 Mar 2015 16:20:51 +0200 Subject: [PATCH 2/3] [TASK] better password storing (password_verify API) --- composer.json | 3 +- composer.lock | 45 ++- system/admin/admin.php | 47 ++- system/vendor/composer/ClassLoader.php | 26 ++ system/vendor/composer/autoload_classmap.php | 14 - system/vendor/composer/autoload_files.php | 1 + system/vendor/composer/installed.json | 44 +++ system/vendor/ircmaxell/password-compat/LICENSE.md | 7 + .../vendor/ircmaxell/password-compat/composer.json | 20 ++ .../ircmaxell/password-compat/lib/password.php | 314 +++++++++++++++++++++ .../ircmaxell/password-compat/version-test.php | 6 + 11 files changed, 501 insertions(+), 26 deletions(-) create mode 100644 system/vendor/ircmaxell/password-compat/LICENSE.md create mode 100644 system/vendor/ircmaxell/password-compat/composer.json create mode 100644 system/vendor/ircmaxell/password-compat/lib/password.php create mode 100644 system/vendor/ircmaxell/password-compat/version-test.php diff --git a/composer.json b/composer.json index e737829..93a8990 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "require": { "michelf/php-markdown": "~1.4", "suin/php-rss-writer": "~1", - "kanti/hub-updater": "~0.3" + "kanti/hub-updater": "~0.3", + "ircmaxell/password-compat": "~1.0" }, "autoload": { "files": [ diff --git a/composer.lock b/composer.lock index cf4e011..7c1527a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,50 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "93444ef16e9607df09bdc196135e9946", + "hash": "18445c7fcb4587c445b0f715332b8ded", "packages": [ + { + "name": "ircmaxell/password-compat", + "version": "v1.0.4", + "source": { + "type": "git", + "url": "https://github.com/ircmaxell/password_compat.git", + "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c", + "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c", + "shasum": "" + }, + "require-dev": { + "phpunit/phpunit": "4.*" + }, + "type": "library", + "autoload": { + "files": [ + "lib/password.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anthony Ferrara", + "email": "ircmaxell@php.net", + "homepage": "http://blog.ircmaxell.com" + } + ], + "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", + "homepage": "https://github.com/ircmaxell/password_compat", + "keywords": [ + "hashing", + "password" + ], + "time": "2014-11-20 16:49:30" + }, { "name": "kanti/hub-updater", "version": "v0.3.1", @@ -146,6 +188,7 @@ "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, + "prefer-lowest": false, "platform": [], "platform-dev": [] } diff --git a/system/admin/admin.php b/system/admin/admin.php index 3f17051..4e037da 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -13,15 +13,27 @@ function user($key, $user = null) } } -function create_user($userName, $password) +function update_user($userName, $password, $role) +{ + $file = 'config/users/' . $userName . '.ini'; + if (file_exists($file)) { + file_put_contents($file, "password = " . password_hash($password, PASSWORD_DEFAULT) . "\n" . + "encryption = password_hash\n" . + "role = " . $role . "\n"); + return true; + } + return false; +} + +function create_user($userName, $password, $role = "user") { $file = 'config/users/' . $userName . '.ini'; if (file_exists($file)) { return false; } else { - file_put_contents($file, "password = " . hash("sha512", $password) . "\n" . - "encryption = sha512\n" . - "role = user\n"); + file_put_contents($file, "password = " . password_hash($password, PASSWORD_DEFAULT) . "\n" . + "encryption = password_hash\n" . + "role = " . $role . "\n"); return true; } } @@ -30,22 +42,37 @@ function create_user($userName, $password) function session($user, $pass) { $user_file = 'config/users/' . $user . '.ini'; + if (!file_exists($user_file)) { + return $str = '
  • Username not found in our record.
  • '; + } + $user_enc = user('encryption', $user); $user_pass = user('password', $user); - $password = (strlen($user_enc) > 0 && $user_enc !== 'clear' && $user_enc !== 'none') ? hash($user_enc, $pass) : $pass; + $user_role = user('role', $user); - if (file_exists($user_file)) { - if ($password === $user_pass) { + if ($user_enc == "password_hash") { + if (password_verify($pass, $user_pass)) { + if (password_needs_rehash($user_pass, PASSWORD_DEFAULT)) { + update_user($user, $pass, $user_role); + } $_SESSION[config("site.url")]['user'] = $user; header('location: admin'); - } else { - return $str = '
  • Your username and password mismatch.
  • '; } + } else if (old_password_verify($pass, $user_enc, $user_pass)) { + update_user($user, $pass, $user_role); + $_SESSION[config("site.url")]['user'] = $user; + header('location: admin'); } else { - return $str = '
  • Username not found in our record.
  • '; + return $str = '
  • Your username and password mismatch.
  • '; } } +function old_password_verify($pass, $user_enc, $user_pass) +{ + $password = (strlen($user_enc) > 0 && $user_enc !== 'clear' && $user_enc !== 'none') ? hash($user_enc, $pass) : $pass; + return ($password === $user_pass); +} + // Clean URLs function remove_accent($str) { diff --git a/system/vendor/composer/ClassLoader.php b/system/vendor/composer/ClassLoader.php index 70d78bc..5e1469e 100644 --- a/system/vendor/composer/ClassLoader.php +++ b/system/vendor/composer/ClassLoader.php @@ -54,6 +54,8 @@ class ClassLoader private $useIncludePath = false; private $classMap = array(); + private $classMapAuthoritative = false; + public function getPrefixes() { if (!empty($this->prefixesPsr0)) { @@ -248,6 +250,27 @@ class ClassLoader return $this->useIncludePath; } + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + /** * Registers this instance as an autoloader. * @@ -299,6 +322,9 @@ class ClassLoader if (isset($this->classMap[$class])) { return $this->classMap[$class]; } + if ($this->classMapAuthoritative) { + return false; + } $file = $this->findFileWithExtension($class, '.php'); diff --git a/system/vendor/composer/autoload_classmap.php b/system/vendor/composer/autoload_classmap.php index 48954d2..71dd9c1 100644 --- a/system/vendor/composer/autoload_classmap.php +++ b/system/vendor/composer/autoload_classmap.php @@ -6,18 +6,4 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname(dirname($vendorDir)); return array( - 'Kanti\\CacheOneFile' => $vendorDir . '/kanti/hub-updater/CacheOneFile.php', - 'Kanti\\HelperClass' => $vendorDir . '/kanti/hub-updater/HelperClass.php', - 'Kanti\\HubUpdater' => $vendorDir . '/kanti/hub-updater/HubUpdater.php', - 'Michelf\\Markdown' => $vendorDir . '/michelf/php-markdown/Michelf/Markdown.php', - 'Michelf\\MarkdownExtra' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownExtra.php', - 'Michelf\\MarkdownInterface' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownInterface.php', - 'Michelf\\_MarkdownExtra_TmpImpl' => $vendorDir . '/michelf/php-markdown/Michelf/Markdown.php', - 'Suin\\RSSWriter\\Channel' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/Channel.php', - 'Suin\\RSSWriter\\ChannelInterface' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/ChannelInterface.php', - 'Suin\\RSSWriter\\Feed' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/Feed.php', - 'Suin\\RSSWriter\\FeedInterface' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/FeedInterface.php', - 'Suin\\RSSWriter\\Item' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/Item.php', - 'Suin\\RSSWriter\\ItemInterface' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/ItemInterface.php', - 'Suin\\RSSWriter\\SimpleXMLElement' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/SimpleXMLElement.php', ); diff --git a/system/vendor/composer/autoload_files.php b/system/vendor/composer/autoload_files.php index 029e617..a582309 100644 --- a/system/vendor/composer/autoload_files.php +++ b/system/vendor/composer/autoload_files.php @@ -6,6 +6,7 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname(dirname($vendorDir)); return array( + $vendorDir . '/ircmaxell/password-compat/lib/password.php', $baseDir . '/system/includes/dispatch.php', $baseDir . '/system/includes/functions.php', $baseDir . '/system/admin/admin.php', diff --git a/system/vendor/composer/installed.json b/system/vendor/composer/installed.json index 6a4582f..b219f2f 100644 --- a/system/vendor/composer/installed.json +++ b/system/vendor/composer/installed.json @@ -138,5 +138,49 @@ "keywords": [ "markdown" ] + }, + { + "name": "ircmaxell/password-compat", + "version": "v1.0.4", + "version_normalized": "1.0.4.0", + "source": { + "type": "git", + "url": "https://github.com/ircmaxell/password_compat.git", + "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c", + "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c", + "shasum": "" + }, + "require-dev": { + "phpunit/phpunit": "4.*" + }, + "time": "2014-11-20 16:49:30", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "lib/password.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anthony Ferrara", + "email": "ircmaxell@php.net", + "homepage": "http://blog.ircmaxell.com" + } + ], + "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", + "homepage": "https://github.com/ircmaxell/password_compat", + "keywords": [ + "hashing", + "password" + ] } ] diff --git a/system/vendor/ircmaxell/password-compat/LICENSE.md b/system/vendor/ircmaxell/password-compat/LICENSE.md new file mode 100644 index 0000000..1efc565 --- /dev/null +++ b/system/vendor/ircmaxell/password-compat/LICENSE.md @@ -0,0 +1,7 @@ +Copyright (c) 2012 Anthony Ferrara + +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 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. \ No newline at end of file diff --git a/system/vendor/ircmaxell/password-compat/composer.json b/system/vendor/ircmaxell/password-compat/composer.json new file mode 100644 index 0000000..822fd1f --- /dev/null +++ b/system/vendor/ircmaxell/password-compat/composer.json @@ -0,0 +1,20 @@ +{ + "name": "ircmaxell/password-compat", + "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", + "keywords": ["password", "hashing"], + "homepage": "https://github.com/ircmaxell/password_compat", + "license": "MIT", + "authors": [ + { + "name": "Anthony Ferrara", + "email": "ircmaxell@php.net", + "homepage": "http://blog.ircmaxell.com" + } + ], + "require-dev": { + "phpunit/phpunit": "4.*" + }, + "autoload": { + "files": ["lib/password.php"] + } +} diff --git a/system/vendor/ircmaxell/password-compat/lib/password.php b/system/vendor/ircmaxell/password-compat/lib/password.php new file mode 100644 index 0000000..cc6896c --- /dev/null +++ b/system/vendor/ircmaxell/password-compat/lib/password.php @@ -0,0 +1,314 @@ + + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @copyright 2012 The Authors + */ + +namespace { + + if (!defined('PASSWORD_BCRYPT')) { + /** + * PHPUnit Process isolation caches constants, but not function declarations. + * So we need to check if the constants are defined separately from + * the functions to enable supporting process isolation in userland + * code. + */ + define('PASSWORD_BCRYPT', 1); + define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); + define('PASSWORD_BCRYPT_DEFAULT_COST', 10); + } + + if (!function_exists('password_hash')) { + + /** + * Hash the password using the specified algorithm + * + * @param string $password The password to hash + * @param int $algo The algorithm to use (Defined by PASSWORD_* constants) + * @param array $options The options for the algorithm to use + * + * @return string|false The hashed password, or false on error. + */ + function password_hash($password, $algo, array $options = array()) { + if (!function_exists('crypt')) { + trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING); + return null; + } + if (is_null($password) || is_int($password)) { + $password = (string) $password; + } + if (!is_string($password)) { + trigger_error("password_hash(): Password must be a string", E_USER_WARNING); + return null; + } + if (!is_int($algo)) { + trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING); + return null; + } + $resultLength = 0; + switch ($algo) { + case PASSWORD_BCRYPT: + $cost = PASSWORD_BCRYPT_DEFAULT_COST; + if (isset($options['cost'])) { + $cost = $options['cost']; + if ($cost < 4 || $cost > 31) { + trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); + return null; + } + } + // The length of salt to generate + $raw_salt_len = 16; + // The length required in the final serialization + $required_salt_len = 22; + $hash_format = sprintf("$2y$%02d$", $cost); + // The expected length of the final crypt() output + $resultLength = 60; + break; + default: + trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); + return null; + } + $salt_requires_encoding = false; + if (isset($options['salt'])) { + switch (gettype($options['salt'])) { + case 'NULL': + case 'boolean': + case 'integer': + case 'double': + case 'string': + $salt = (string) $options['salt']; + break; + case 'object': + if (method_exists($options['salt'], '__tostring')) { + $salt = (string) $options['salt']; + break; + } + case 'array': + case 'resource': + default: + trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); + return null; + } + if (PasswordCompat\binary\_strlen($salt) < $required_salt_len) { + trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", PasswordCompat\binary\_strlen($salt), $required_salt_len), E_USER_WARNING); + return null; + } elseif (0 == preg_match('#^[a-zA-Z0-9./]+$#D', $salt)) { + $salt_requires_encoding = true; + } + } else { + $buffer = ''; + $buffer_valid = false; + if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { + $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM); + if ($buffer) { + $buffer_valid = true; + } + } + if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { + $buffer = openssl_random_pseudo_bytes($raw_salt_len); + if ($buffer) { + $buffer_valid = true; + } + } + if (!$buffer_valid && @is_readable('/dev/urandom')) { + $f = fopen('/dev/urandom', 'r'); + $read = PasswordCompat\binary\_strlen($buffer); + while ($read < $raw_salt_len) { + $buffer .= fread($f, $raw_salt_len - $read); + $read = PasswordCompat\binary\_strlen($buffer); + } + fclose($f); + if ($read >= $raw_salt_len) { + $buffer_valid = true; + } + } + if (!$buffer_valid || PasswordCompat\binary\_strlen($buffer) < $raw_salt_len) { + $bl = PasswordCompat\binary\_strlen($buffer); + for ($i = 0; $i < $raw_salt_len; $i++) { + if ($i < $bl) { + $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); + } else { + $buffer .= chr(mt_rand(0, 255)); + } + } + } + $salt = $buffer; + $salt_requires_encoding = true; + } + if ($salt_requires_encoding) { + // encode string with the Base64 variant used by crypt + $base64_digits = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + $bcrypt64_digits = + './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + + $base64_string = base64_encode($salt); + $salt = strtr(rtrim($base64_string, '='), $base64_digits, $bcrypt64_digits); + } + $salt = PasswordCompat\binary\_substr($salt, 0, $required_salt_len); + + $hash = $hash_format . $salt; + + $ret = crypt($password, $hash); + + if (!is_string($ret) || PasswordCompat\binary\_strlen($ret) != $resultLength) { + return false; + } + + return $ret; + } + + /** + * Get information about the password hash. Returns an array of the information + * that was used to generate the password hash. + * + * array( + * 'algo' => 1, + * 'algoName' => 'bcrypt', + * 'options' => array( + * 'cost' => PASSWORD_BCRYPT_DEFAULT_COST, + * ), + * ) + * + * @param string $hash The password hash to extract info from + * + * @return array The array of information about the hash. + */ + function password_get_info($hash) { + $return = array( + 'algo' => 0, + 'algoName' => 'unknown', + 'options' => array(), + ); + if (PasswordCompat\binary\_substr($hash, 0, 4) == '$2y$' && PasswordCompat\binary\_strlen($hash) == 60) { + $return['algo'] = PASSWORD_BCRYPT; + $return['algoName'] = 'bcrypt'; + list($cost) = sscanf($hash, "$2y$%d$"); + $return['options']['cost'] = $cost; + } + return $return; + } + + /** + * Determine if the password hash needs to be rehashed according to the options provided + * + * If the answer is true, after validating the password using password_verify, rehash it. + * + * @param string $hash The hash to test + * @param int $algo The algorithm used for new password hashes + * @param array $options The options array passed to password_hash + * + * @return boolean True if the password needs to be rehashed. + */ + function password_needs_rehash($hash, $algo, array $options = array()) { + $info = password_get_info($hash); + if ($info['algo'] != $algo) { + return true; + } + switch ($algo) { + case PASSWORD_BCRYPT: + $cost = isset($options['cost']) ? $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST; + if ($cost != $info['options']['cost']) { + return true; + } + break; + } + return false; + } + + /** + * Verify a password against a hash using a timing attack resistant approach + * + * @param string $password The password to verify + * @param string $hash The hash to verify against + * + * @return boolean If the password matches the hash + */ + function password_verify($password, $hash) { + if (!function_exists('crypt')) { + trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING); + return false; + } + $ret = crypt($password, $hash); + if (!is_string($ret) || PasswordCompat\binary\_strlen($ret) != PasswordCompat\binary\_strlen($hash) || PasswordCompat\binary\_strlen($ret) <= 13) { + return false; + } + + $status = 0; + for ($i = 0; $i < PasswordCompat\binary\_strlen($ret); $i++) { + $status |= (ord($ret[$i]) ^ ord($hash[$i])); + } + + return $status === 0; + } + } + +} + +namespace PasswordCompat\binary { + + if (!function_exists('PasswordCompat\\binary\\_strlen')) { + + /** + * Count the number of bytes in a string + * + * We cannot simply use strlen() for this, because it might be overwritten by the mbstring extension. + * In this case, strlen() will count the number of *characters* based on the internal encoding. A + * sequence of bytes might be regarded as a single multibyte character. + * + * @param string $binary_string The input string + * + * @internal + * @return int The number of bytes + */ + function _strlen($binary_string) { + if (function_exists('mb_strlen')) { + return mb_strlen($binary_string, '8bit'); + } + return strlen($binary_string); + } + + /** + * Get a substring based on byte limits + * + * @see _strlen() + * + * @param string $binary_string The input string + * @param int $start + * @param int $length + * + * @internal + * @return string The substring + */ + function _substr($binary_string, $start, $length) { + if (function_exists('mb_substr')) { + return mb_substr($binary_string, $start, $length, '8bit'); + } + return substr($binary_string, $start, $length); + } + + /** + * Check if current PHP version is compatible with the library + * + * @return boolean the check result + */ + function check() { + static $pass = NULL; + + if (is_null($pass)) { + if (function_exists('crypt')) { + $hash = '$2y$04$usesomesillystringfore7hnbRJHxXVLeakoG8K30oukPsA.ztMG'; + $test = crypt("password", $hash); + $pass = $test == $hash; + } else { + $pass = false; + } + } + return $pass; + } + + } +} \ No newline at end of file diff --git a/system/vendor/ircmaxell/password-compat/version-test.php b/system/vendor/ircmaxell/password-compat/version-test.php new file mode 100644 index 0000000..96f60ca --- /dev/null +++ b/system/vendor/ircmaxell/password-compat/version-test.php @@ -0,0 +1,6 @@ + Date: Mon, 30 Mar 2015 19:06:21 +0200 Subject: [PATCH 3/3] [TASK] update composer --- cache/installedVersion.json | 4 +- composer.json | 38 +- composer.lock | 47 +- system/admin/editor/css/editor.css | 148 +- system/admin/editor/js/Markdown.Converter.js | 648 ++-- system/admin/editor/js/Markdown.Editor.js | 124 +- system/admin/editor/js/Markdown.Sanitizer.js | 2 +- system/admin/editor/js/local/Markdown.local.fr.js | 4 +- system/admin/editor/package.json | 27 +- system/admin/views/404.html.php | 25 +- system/admin/views/add-page.html.php | 57 +- system/admin/views/add-post.html.php | 73 +- system/admin/views/backup-start.html.php | 23 +- system/admin/views/backup.html.php | 24 +- system/admin/views/clear-cache.html.php | 8 +- system/admin/views/config.html.php | 1 + system/admin/views/delete-page.html.php | 30 +- system/admin/views/delete-post.html.php | 68 +- system/admin/views/edit-page.html.php | 96 +- system/admin/views/edit-post.html.php | 139 +- system/admin/views/edit-profile.html.php | 75 +- system/admin/views/import.html.php | 16 +- system/admin/views/layout.html.php | 98 +- system/admin/views/login.html.php | 40 +- system/admin/views/main.html.php | 4 +- system/admin/views/posts-list.html.php | 88 +- system/admin/views/updated-to.html.php | 8 +- system/admin/views/user-posts.html.php | 85 +- system/htmly.php | 38 +- system/includes/dispatch.php | 7 +- system/includes/functions.php | 2 +- system/includes/opml.php | 1 + system/includes/session.php | 10 +- system/plugins/lightbox/css/lightbox.css | 233 +- system/plugins/lightbox/js/lightbox-2.6.min.js | 268 +- system/resources/htmly.js | 12 +- system/vendor/autoload.php | 2 +- system/vendor/composer/autoload_classmap.php | 13 + system/vendor/composer/autoload_psr4.php | 2 +- system/vendor/composer/autoload_real.php | 10 +- system/vendor/composer/installed.json | 135 +- system/vendor/ircmaxell/password-compat/LICENSE.md | 7 - .../vendor/ircmaxell/password-compat/composer.json | 20 - .../ircmaxell/password-compat/lib/password.php | 314 -- .../ircmaxell/password-compat/version-test.php | 6 - system/vendor/kanti/hub-updater/.gitattributes | 7 + system/vendor/kanti/hub-updater/.updateignore | 1 + system/vendor/kanti/hub-updater/CacheOneFile.php | 39 - system/vendor/kanti/hub-updater/HelperClass.php | 12 - system/vendor/kanti/hub-updater/README.md | 122 + system/vendor/kanti/hub-updater/composer.json | 22 +- system/vendor/kanti/hub-updater/composer.lock | 974 ++++++ system/vendor/kanti/hub-updater/example.php | 5 + system/vendor/kanti/hub-updater/example2.php | 29 + .../vendor/kanti/hub-updater/src/CacheOneFile.php | 58 + .../vendor/kanti/hub-updater/src/HelperClass.php | 28 + .../kanti/hub-updater/{ => src}/HubUpdater.php | 15 +- .../kanti/hub-updater/{ => src}/ca_bundle.crt | 0 .../kanti/hub-updater/tests/CacheOneFileTest.php | 73 + .../kanti/hub-updater/tests/HelperClassTest.php | 54 + .../kanti/hub-updater/tests/asserts/testfile.txt | 1 + .../vendor/kanti/hub-updater/tests/bootstrap.php | 9 + system/vendor/kanti/hub-updater/tests/phpunit.xml | 29 + system/vendor/michelf/php-markdown/License.md | 36 - .../michelf/php-markdown/Michelf/Markdown.inc.php | 10 - .../michelf/php-markdown/Michelf/Markdown.php | 3117 -------------------- .../php-markdown/Michelf/MarkdownExtra.inc.php | 11 - .../michelf/php-markdown/Michelf/MarkdownExtra.php | 38 - .../php-markdown/Michelf/MarkdownInterface.inc.php | 9 - .../php-markdown/Michelf/MarkdownInterface.php | 37 - system/vendor/michelf/php-markdown/Readme.md | 305 -- system/vendor/michelf/php-markdown/Readme.php | 31 - system/vendor/michelf/php-markdown/composer.json | 31 - system/vendor/suin/php-rss-writer/.travis.yml | 11 - system/vendor/suin/php-rss-writer/README.md | 96 - .../Source/Suin/RSSWriter/Channel.php | 189 -- .../Source/Suin/RSSWriter/ChannelInterface.php | 91 - .../php-rss-writer/Source/Suin/RSSWriter/Feed.php | 54 - .../Source/Suin/RSSWriter/FeedInterface.php | 27 - .../php-rss-writer/Source/Suin/RSSWriter/Item.php | 169 -- .../Source/Suin/RSSWriter/ItemInterface.php | 75 - .../Source/Suin/RSSWriter/SimpleXMLElement.php | 16 - .../vendor/suin/php-rss-writer/Tests/Bootstrap.php | 8 - system/vendor/suin/php-rss-writer/Tests/README.md | 28 - .../Tests/Suin/RSSWriter/ChannelTest.php | 252 -- .../Tests/Suin/RSSWriter/FeedTest.php | 96 - .../Tests/Suin/RSSWriter/ItemTest.php | 200 -- .../vendor/suin/php-rss-writer/Tests/composer.json | 12 - .../suin/php-rss-writer/Tests/phpunit.xml.dist | 42 - system/vendor/suin/php-rss-writer/composer.json | 20 - system/vendor/suin/php-rss-writer/example.php | 35 - themes/clean/404-search.html.php | 31 +- themes/clean/404.html.php | 25 +- themes/clean/css/style.css | 996 ++++--- themes/clean/layout.html.php | 71 +- themes/clean/main.html.php | 119 +- themes/clean/post.html.php | 121 +- themes/clean/profile.html.php | 84 +- themes/clean/static.html.php | 20 +- themes/default/404-search.html.php | 31 +- themes/default/404.html.php | 25 +- themes/default/css/style.css | 409 +-- themes/default/css/toolbar.css | 69 +- themes/default/layout.html.php | 131 +- themes/default/main.html.php | 119 +- themes/default/post.html.php | 121 +- themes/default/profile.html.php | 84 +- themes/default/static.html.php | 20 +- themes/logs/404-search.html.php | 33 +- themes/logs/404.html.php | 27 +- themes/logs/css/style.css | 372 +-- themes/logs/layout.html.php | 148 +- themes/logs/main.html.php | 119 +- themes/logs/post.html.php | 121 +- themes/logs/profile.html.php | 84 +- themes/logs/static.html.php | 20 +- 116 files changed, 4837 insertions(+), 8167 deletions(-) delete mode 100644 system/vendor/ircmaxell/password-compat/LICENSE.md delete mode 100644 system/vendor/ircmaxell/password-compat/composer.json delete mode 100644 system/vendor/ircmaxell/password-compat/lib/password.php delete mode 100644 system/vendor/ircmaxell/password-compat/version-test.php create mode 100644 system/vendor/kanti/hub-updater/.gitattributes create mode 100644 system/vendor/kanti/hub-updater/.updateignore delete mode 100644 system/vendor/kanti/hub-updater/CacheOneFile.php delete mode 100644 system/vendor/kanti/hub-updater/HelperClass.php create mode 100644 system/vendor/kanti/hub-updater/README.md create mode 100644 system/vendor/kanti/hub-updater/composer.lock create mode 100644 system/vendor/kanti/hub-updater/example.php create mode 100644 system/vendor/kanti/hub-updater/example2.php create mode 100644 system/vendor/kanti/hub-updater/src/CacheOneFile.php create mode 100644 system/vendor/kanti/hub-updater/src/HelperClass.php rename system/vendor/kanti/hub-updater/{ => src}/HubUpdater.php (95%) rename system/vendor/kanti/hub-updater/{ => src}/ca_bundle.crt (100%) create mode 100644 system/vendor/kanti/hub-updater/tests/CacheOneFileTest.php create mode 100644 system/vendor/kanti/hub-updater/tests/HelperClassTest.php create mode 100644 system/vendor/kanti/hub-updater/tests/asserts/testfile.txt create mode 100644 system/vendor/kanti/hub-updater/tests/bootstrap.php create mode 100644 system/vendor/kanti/hub-updater/tests/phpunit.xml delete mode 100644 system/vendor/michelf/php-markdown/License.md delete mode 100644 system/vendor/michelf/php-markdown/Michelf/Markdown.inc.php delete mode 100644 system/vendor/michelf/php-markdown/Michelf/Markdown.php delete mode 100644 system/vendor/michelf/php-markdown/Michelf/MarkdownExtra.inc.php delete mode 100644 system/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php delete mode 100644 system/vendor/michelf/php-markdown/Michelf/MarkdownInterface.inc.php delete mode 100644 system/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php delete mode 100644 system/vendor/michelf/php-markdown/Readme.md delete mode 100644 system/vendor/michelf/php-markdown/Readme.php delete mode 100644 system/vendor/michelf/php-markdown/composer.json delete mode 100644 system/vendor/suin/php-rss-writer/.travis.yml delete mode 100644 system/vendor/suin/php-rss-writer/README.md delete mode 100644 system/vendor/suin/php-rss-writer/Source/Suin/RSSWriter/Channel.php delete mode 100644 system/vendor/suin/php-rss-writer/Source/Suin/RSSWriter/ChannelInterface.php delete mode 100644 system/vendor/suin/php-rss-writer/Source/Suin/RSSWriter/Feed.php delete mode 100644 system/vendor/suin/php-rss-writer/Source/Suin/RSSWriter/FeedInterface.php delete mode 100644 system/vendor/suin/php-rss-writer/Source/Suin/RSSWriter/Item.php delete mode 100644 system/vendor/suin/php-rss-writer/Source/Suin/RSSWriter/ItemInterface.php delete mode 100644 system/vendor/suin/php-rss-writer/Source/Suin/RSSWriter/SimpleXMLElement.php delete mode 100644 system/vendor/suin/php-rss-writer/Tests/Bootstrap.php delete mode 100644 system/vendor/suin/php-rss-writer/Tests/README.md delete mode 100644 system/vendor/suin/php-rss-writer/Tests/Suin/RSSWriter/ChannelTest.php delete mode 100644 system/vendor/suin/php-rss-writer/Tests/Suin/RSSWriter/FeedTest.php delete mode 100644 system/vendor/suin/php-rss-writer/Tests/Suin/RSSWriter/ItemTest.php delete mode 100644 system/vendor/suin/php-rss-writer/Tests/composer.json delete mode 100644 system/vendor/suin/php-rss-writer/Tests/phpunit.xml.dist delete mode 100644 system/vendor/suin/php-rss-writer/composer.json delete mode 100644 system/vendor/suin/php-rss-writer/example.php diff --git a/cache/installedVersion.json b/cache/installedVersion.json index 4ddcec4..c89ef82 100644 --- a/cache/installedVersion.json +++ b/cache/installedVersion.json @@ -1,4 +1,4 @@ { - "id": 782014, - "tag_name": "v2.5.1" + "id": 782014, + "tag_name": "v2.5.1" } diff --git a/composer.json b/composer.json index 93a8990..9f8af0b 100644 --- a/composer.json +++ b/composer.json @@ -1,21 +1,21 @@ { - "config": { - "vendor-dir": "system/vendor/", - "optimize-autoloader": true - }, - "require": { - "michelf/php-markdown": "~1.4", - "suin/php-rss-writer": "~1", - "kanti/hub-updater": "~0.3", - "ircmaxell/password-compat": "~1.0" - }, - "autoload": { - "files": [ - "system/includes/dispatch.php", - "system/includes/functions.php", - "system/admin/admin.php", - "system/includes/session.php", - "system/includes/opml.php" - ] - } + "config": { + "vendor-dir": "system/vendor/", + "optimize-autoloader": true + }, + "require": { + "michelf/php-markdown": "~1.4", + "suin/php-rss-writer": "~1", + "kanti/hub-updater": "~0.3", + "ircmaxell/password-compat": "~1.0" + }, + "autoload": { + "files": [ + "system/includes/dispatch.php", + "system/includes/functions.php", + "system/admin/admin.php", + "system/includes/session.php", + "system/includes/opml.php" + ] + } } diff --git a/composer.lock b/composer.lock index 7c1527a..dd3b4b4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "18445c7fcb4587c445b0f715332b8ded", + "hash": "3e80d2a8e4920ba6151c05a19f1f8b9e", "packages": [ { "name": "ircmaxell/password-compat", @@ -29,7 +29,7 @@ "lib/password.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -50,28 +50,31 @@ }, { "name": "kanti/hub-updater", - "version": "v0.3.1", + "version": "v0.4", "source": { "type": "git", "url": "https://github.com/Kanti/hub-updater.git", - "reference": "105bf291983b1323c5916092cc4e170bf987b00c" + "reference": "81dae71f2b3ccd0e3425579ac932a8c6b7b58c5d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Kanti/hub-updater/zipball/105bf291983b1323c5916092cc4e170bf987b00c", - "reference": "105bf291983b1323c5916092cc4e170bf987b00c", + "url": "https://api.github.com/repos/Kanti/hub-updater/zipball/81dae71f2b3ccd0e3425579ac932a8c6b7b58c5d", + "reference": "81dae71f2b3ccd0e3425579ac932a8c6b7b58c5d", "shasum": "" }, "require": { "php": ">=5.3.0" }, + "require-dev": { + "phpunit/phpunit": "~4.6@dev" + }, "type": "library", "autoload": { "psr-4": { - "Kanti\\": "" + "Kanti\\": "src" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "GPL-2.0" ], @@ -84,20 +87,20 @@ } ], "description": "Simple Github Updater for Web Projects", - "time": "2014-12-27 13:59:09" + "time": "2015-02-03 09:53:58" }, { "name": "michelf/php-markdown", - "version": "1.4.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/michelf/php-markdown.git", - "reference": "de9a19c7bf352d41cc99ed86c3c0ef17e87394b6" + "reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/michelf/php-markdown/zipball/de9a19c7bf352d41cc99ed86c3c0ef17e87394b6", - "reference": "de9a19c7bf352d41cc99ed86c3c0ef17e87394b6", + "url": "https://api.github.com/repos/michelf/php-markdown/zipball/e1aabe18173231ebcefc90e615565742fc1c7fd9", + "reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9", "shasum": "" }, "require": { @@ -114,28 +117,28 @@ "Michelf": "" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "BSD-3-Clause" ], "authors": [ + { + "name": "John Gruber", + "homepage": "http://daringfireball.net/" + }, { "name": "Michel Fortin", "email": "michel.fortin@michelf.ca", - "homepage": "http://michelf.ca/", + "homepage": "https://michelf.ca/", "role": "Developer" - }, - { - "name": "John Gruber", - "homepage": "http://daringfireball.net/" } ], "description": "PHP Markdown", - "homepage": "http://michelf.ca/projects/php-markdown/", + "homepage": "https://michelf.ca/projects/php-markdown/", "keywords": [ "markdown" ], - "time": "2014-05-05 02:43:50" + "time": "2015-03-01 12:03:08" }, { "name": "suin/php-rss-writer", @@ -160,7 +163,7 @@ "Suin\\RSSWriter": "Source" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], diff --git a/system/admin/editor/css/editor.css b/system/admin/editor/css/editor.css index 7e19ab8..52a09ca 100644 --- a/system/admin/editor/css/editor.css +++ b/system/admin/editor/css/editor.css @@ -1,59 +1,59 @@ -body { +body { font-family: Georgia, sans-serif; } blockquote { - border-left: 2px dotted #888; - padding-left: 5px; - background: #F6F7F9; + border-left: 2px dotted #888; + padding-left: 5px; + background: #F6F7F9; } -.wmd-panel{ - width: 44%; - float:left; - padding-right:20px; +.wmd-panel { + width: 44%; + float: left; + padding-right: 20px; } .wmd-button-bar { - background-color: #F6F7F9; - padding: 5px 0; - margin-bottom:10px; - width: 100%; - border: 1px solid #CFDAE5; - display:block; - float:left; + background-color: #F6F7F9; + padding: 5px 0; + margin-bottom: 10px; + width: 100%; + border: 1px solid #CFDAE5; + display: block; + float: left; } .wmd-button-bar:hover { - border: 1px solid #CCCCCC; + border: 1px solid #CCCCCC; } -.wmd-input { - min-height: 300px; - width: 96%; - padding: 2%; +.wmd-input { + min-height: 300px; + width: 96%; + padding: 2%; } -.wmd-preview { - background-color: #E4EBF1; - width: 46%; - float:left; - padding:2%; +.wmd-preview { + background-color: #E4EBF1; + width: 46%; + float: left; + padding: 2%; } .wmd-button-row { - position: relative; - margin: 0px; - padding: 0px; + position: relative; + margin: 0px; + padding: 0px; } -.wmd-spacer{ - width: 1px; - height: 20px; - background-color: Silver; - list-style: none; - float:left; - margin: 0.25em 5px; +.wmd-spacer { + width: 1px; + height: 20px; + background-color: Silver; + list-style: none; + float: left; + margin: 0.25em 5px; } .wmd-button { @@ -63,7 +63,7 @@ blockquote { padding-right: 5px; list-style: none; cursor: pointer; - float:left; + float: left; } .wmd-button > span { @@ -75,74 +75,74 @@ blockquote { display: inline-block; } -.wmd-spacer1{ +.wmd-spacer1 { left: 50px; } -.wmd-spacer2{ +.wmd-spacer2 { left: 175px; } -.wmd-spacer3{ + +.wmd-spacer3 { left: 300px; } -.wmd-prompt-background{ - background-color: Black; +.wmd-prompt-background { + background-color: Black; } -.wmd-prompt-dialog{ - border: 1px solid #999999; - background-color: #F5F5F5; +.wmd-prompt-dialog { + border: 1px solid #999999; + background-color: #F5F5F5; } .wmd-prompt-dialog > div { - font-size: 0.8em; - font-family: arial, helvetica, sans-serif; + font-size: 0.8em; + font-family: arial, helvetica, sans-serif; } - .wmd-prompt-dialog > form > input[type="text"] { - border: 1px solid #999999; - color: black; + border: 1px solid #999999; + color: black; } -.wmd-prompt-dialog > form > input[type="button"]{ - border: 1px solid #888888; - font-family: trebuchet MS, helvetica, sans-serif; - font-size: 0.8em; - font-weight: bold; +.wmd-prompt-dialog > form > input[type="button"] { + border: 1px solid #888888; + font-family: trebuchet MS, helvetica, sans-serif; + font-size: 0.8em; + font-weight: bold; } pre { - margin: 1em 0; - overflow: auto; - background: #F1F1FF; + margin: 1em 0; + overflow: auto; + background: #F1F1FF; } pre code { color: #333333; display: block; - font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; + font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif; font-size: 14px; padding: 5px 10px; } @media all and (max-width: 980px) { - .nav { - width: 100%; - padding: 2%; - } - - .wmd-panel, .wmd-preview { - width: 96%; - float:left; - padding:2%; - } - - pre { - white-space: pre-wrap; - word-wrap:break-word; - } - + .nav { + width: 100%; + padding: 2%; + } + + .wmd-panel, .wmd-preview { + width: 96%; + float: left; + padding: 2%; + } + + pre { + white-space: pre-wrap; + word-wrap: break-word; + } + } \ No newline at end of file diff --git a/system/admin/editor/js/Markdown.Converter.js b/system/admin/editor/js/Markdown.Converter.js index 4ef9907..60e0bb5 100644 --- a/system/admin/editor/js/Markdown.Converter.js +++ b/system/admin/editor/js/Markdown.Converter.js @@ -4,7 +4,7 @@ if (typeof exports === "object" && typeof require === "function") // we're in a Markdown = exports; else Markdown = {}; - + // The following text is included for historical reasons, but should // be taken with a pinch of salt; it's not all true anymore. @@ -52,10 +52,16 @@ else (function () { - function identity(x) { return x; } - function returnFalse(x) { return false; } + function identity(x) { + return x; + } + + function returnFalse(x) { + return false; + } - function HookCollection() { } + function HookCollection() { + } HookCollection.prototype = { @@ -95,7 +101,9 @@ else // http://meta.stackoverflow.com/questions/64655/strange-wmd-bug // (granted, switching from Array() to Object() alone would have left only __proto__ // to be a problem) - function SaveHash() { } + function SaveHash() { + } + SaveHash.prototype = { set: function (key, value) { this["s_" + key] = value; @@ -107,26 +115,26 @@ else Markdown.Converter = function () { var pluginHooks = this.hooks = new HookCollection(); - + // given a URL that was encountered by itself (without markup), should return the link text that's to be given to this link pluginHooks.addNoop("plainLinkText"); - + // called with the orignal text as given to makeHtml. The result of this plugin hook is the actual markdown source that will be cooked pluginHooks.addNoop("preConversion"); - + // called with the text once all normalizations have been completed (tabs to spaces, line endings, etc.), but before any conversions have pluginHooks.addNoop("postNormalization"); - + // Called with the text before / after creating block elements like code blocks and lists. Note that this is called recursively // with inner content, e.g. it's called with the full text, and then only with the content of a blockquote. The inner // call will receive outdented text. pluginHooks.addNoop("preBlockGamut"); pluginHooks.addNoop("postBlockGamut"); - + // called with the text of a single block element before / after the span-level conversions (bold, code spans, etc.) have been made pluginHooks.addNoop("preSpanGamut"); pluginHooks.addNoop("postSpanGamut"); - + // called with the final cooked HTML code. The result of this plugin hook is the actual output of makeHtml pluginHooks.addNoop("postConversion"); @@ -156,7 +164,7 @@ else // Don't do that. if (g_urls) throw new Error("Recursive call to converter.makeHtml"); - + // Create the private state objects. g_urls = new SaveHash(); g_titles = new SaveHash(); @@ -191,7 +199,7 @@ else // match consecutive blank lines with /\n+/ instead of something // contorted like /[ \t]*\n+/ . text = text.replace(/^[ \t]+$/mg, ""); - + text = pluginHooks.postNormalization(text); // Turn block-level HTML blocks into hash entries @@ -226,27 +234,27 @@ else // Link defs are in the form: ^[id]: url "optional title" /* - text = text.replace(/ - ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1 - [ \t]* - \n? // maybe *one* newline - [ \t]* - ? // url = $2 - (?=\s|$) // lookahead for whitespace instead of the lookbehind removed below - [ \t]* - \n? // maybe one newline - [ \t]* - ( // (potential) title = $3 - (\n*) // any lines skipped = $4 attacklab: lookbehind removed - [ \t]+ - ["(] - (.+?) // title = $5 - [")] - [ \t]* - )? // title is optional - (?:\n+|$) - /gm, function(){...}); - */ + text = text.replace(/ + ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1 + [ \t]* + \n? // maybe *one* newline + [ \t]* + ? // url = $2 + (?=\s|$) // lookahead for whitespace instead of the lookbehind removed below + [ \t]* + \n? // maybe one newline + [ \t]* + ( // (potential) title = $3 + (\n*) // any lines skipped = $4 attacklab: lookbehind removed + [ \t]+ + ["(] + (.+?) // title = $5 + [")] + [ \t]* + )? // title is optional + (?:\n+|$) + /gm, function(){...}); + */ text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?(?=\s|$)[ \t]*\n?[ \t]*((\n*)["(](.+?)[")][ \t]*)?(?:\n+)/gm, function (wholeMatch, m1, m2, m3, m4, m5) { @@ -294,19 +302,19 @@ else // attacklab: This regex can be expensive when it fails. /* - text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_a) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*?\n // any number of lines, minimally matching - // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ + text = text.replace(/ + ( // save in $1 + ^ // start of line (with /m) + <($block_tags_a) // start tag = $2 + \b // word break + // attacklab: hack around khtml/pcre bug... + [^\r]*?\n // any number of lines, minimally matching + // the matching end tag + [ \t]* // trailing spaces/tabs + (?=\n+) // followed by a newline + ) // attacklab: there are sentinel newlines at end of document + /gm,function(){...}}; + */ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm, hashElement); // @@ -314,76 +322,76 @@ else // /* - text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_b) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*? // any number of lines, minimally matching - .* // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ + text = text.replace(/ + ( // save in $1 + ^ // start of line (with /m) + <($block_tags_b) // start tag = $2 + \b // word break + // attacklab: hack around khtml/pcre bug... + [^\r]*? // any number of lines, minimally matching + .* // the matching end tag + [ \t]* // trailing spaces/tabs + (?=\n+) // followed by a newline + ) // attacklab: there are sentinel newlines at end of document + /gm,function(){...}}; + */ text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm, hashElement); // Special case just for
    . It was easier to make a special case than // to make the other regex more complicated. /* - text = text.replace(/ - \n // Starting after a blank line - [ ]{0,3} - ( // save in $1 - (<(hr) // start tag = $2 - \b // word break - ([^<>])*? - \/?>) // the matching end tag - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ + text = text.replace(/ + \n // Starting after a blank line + [ ]{0,3} + ( // save in $1 + (<(hr) // start tag = $2 + \b // word break + ([^<>])*? + \/?>) // the matching end tag + [ \t]* + (?=\n{2,}) // followed by a blank line + ) + /g,hashElement); + */ text = text.replace(/\n[ ]{0,3}((<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g, hashElement); // Special case for standalone HTML comments: /* - text = text.replace(/ - \n\n // Starting after a blank line - [ ]{0,3} // attacklab: g_tab_width - 1 - ( // save in $1 - -]|-[^>])(?:[^-]|-[^-])*)--) // see http://www.w3.org/TR/html-markup/syntax.html#comments and http://meta.stackoverflow.com/q/95256 - > - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ + text = text.replace(/ + \n\n // Starting after a blank line + [ ]{0,3} // attacklab: g_tab_width - 1 + ( // save in $1 + -]|-[^>])(?:[^-]|-[^-])*)--) // see http://www.w3.org/TR/html-markup/syntax.html#comments and http://meta.stackoverflow.com/q/95256 + > + [ \t]* + (?=\n{2,}) // followed by a blank line + ) + /g,hashElement); + */ text = text.replace(/\n\n[ ]{0,3}(-]|-[^>])(?:[^-]|-[^-])*)--)>[ \t]*(?=\n{2,}))/g, hashElement); // PHP and ASP-style processor instructions ( and <%...%>) /* - text = text.replace(/ - (?: - \n\n // Starting after a blank line - ) - ( // save in $1 - [ ]{0,3} // attacklab: g_tab_width - 1 - (?: - <([?%]) // $2 - [^\r]*? - \2> - ) - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ + text = text.replace(/ + (?: + \n\n // Starting after a blank line + ) + ( // save in $1 + [ ]{0,3} // attacklab: g_tab_width - 1 + (?: + <([?%]) // $2 + [^\r]*? + \2> + ) + [ \t]* + (?=\n{2,}) // followed by a blank line + ) + /g,hashElement); + */ text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g, hashElement); return text; @@ -403,17 +411,19 @@ else return blockText; } - - var blockGamutHookCallback = function (t) { return _RunBlockGamut(t); } + + var blockGamutHookCallback = function (t) { + return _RunBlockGamut(t); + } function _RunBlockGamut(text, doNotUnhash) { // // These are all the transformations that form block-level // tags like paragraphs, headers, and list items. // - + text = pluginHooks.preBlockGamut(text, blockGamutHookCallback); - + text = _DoHeaders(text); // Do Horizontal Rules: @@ -425,7 +435,7 @@ else text = _DoLists(text); text = _DoCodeBlocks(text); text = _DoBlockQuotes(text); - + text = pluginHooks.postBlockGamut(text, blockGamutHookCallback); // We already ran _HashHTMLBlocks() before, in Markdown(), but that @@ -445,7 +455,7 @@ else // text = pluginHooks.preSpanGamut(text); - + text = _DoCodeSpans(text); text = _EscapeSpecialCharsWithinTagAttributes(text); text = _EncodeBackslashEscapes(text); @@ -459,15 +469,15 @@ else // Must come after _DoAnchors(), because you can use < and > // delimiters in inline links like [this](). text = _DoAutoLinks(text); - + text = text.replace(/~P/g, "://"); // put in place to prevent autolinking; reset now - + text = _EncodeAmpsAndAngles(text); text = _DoItalicsAndBold(text); // Do hard breaks: text = text.replace(/ +\n/g, "
    \n"); - + text = pluginHooks.postSpanGamut(text); return text; @@ -504,28 +514,28 @@ else // /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[] // or anything else - )* - ) - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - ) - ()()()() // pad remaining backreferences - /g, writeAnchorTag); - */ + text = text.replace(/ + ( // wrap whole match in $1 + \[ + ( + (?: + \[[^\]]*\] // allow brackets nested one level + | + [^\[] // or anything else + )* + ) + \] + + [ ]? // one optional space + (?:\n[ ]*)? // one optional newline followed by spaces + + \[ + (.*?) // id = $3 + \] + ) + ()()()() // pad remaining backreferences + /g, writeAnchorTag); + */ text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeAnchorTag); // @@ -533,38 +543,38 @@ else // /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[\]] // or anything else - )* - ) - \] - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // Title = $7 - \6 // matching quote - [ \t]* // ignore any spaces/tabs between closing quote and ) - )? // title is optional - \) - ) - /g, writeAnchorTag); - */ + text = text.replace(/ + ( // wrap whole match in $1 + \[ + ( + (?: + \[[^\]]*\] // allow brackets nested one level + | + [^\[\]] // or anything else + )* + ) + \] + \( // literal paren + [ \t]* + () // no id, so leave $3 empty + ? + [ \t]* + ( // $5 + (['"]) // quote char = $6 + (.*?) // Title = $7 + \6 // matching quote + [ \t]* // ignore any spaces/tabs between closing quote and ) + )? // title is optional + \) + ) + /g, writeAnchorTag); + */ text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeAnchorTag); @@ -575,15 +585,15 @@ else // /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ([^\[\]]+) // link text = $2; can't contain '[' or ']' - \] - ) - ()()()()() // pad rest of backreferences - /g, writeAnchorTag); - */ + text = text.replace(/ + ( // wrap whole match in $1 + \[ + ([^\[\]]+) // link text = $2; can't contain '[' or ']' + \] + ) + ()()()()() // pad rest of backreferences + /g, writeAnchorTag); + */ text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag); return text; @@ -644,22 +654,22 @@ else // /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - ) - ()()()() // pad rest of backreferences - /g, writeImageTag); - */ + text = text.replace(/ + ( // wrap whole match in $1 + !\[ + (.*?) // alt text = $2 + \] + + [ ]? // one optional space + (?:\n[ ]*)? // one optional newline followed by spaces + + \[ + (.*?) // id = $3 + \] + ) + ()()()() // pad rest of backreferences + /g, writeImageTag); + */ text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeImageTag); // @@ -667,32 +677,32 @@ else // Don't forget: encode * and _ /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - \s? // One optional whitespace character - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? // src url = $4 - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // title = $7 - \6 // matching quote - [ \t]* - )? // title is optional - \) - ) - /g, writeImageTag); - */ + text = text.replace(/ + ( // wrap whole match in $1 + !\[ + (.*?) // alt text = $2 + \] + \s? // One optional whitespace character + \( // literal paren + [ \t]* + () // no id, so leave $3 empty + ? // src url = $4 + [ \t]* + ( // $5 + (['"]) // quote char = $6 + (.*?) // title = $7 + \6 // matching quote + [ \t]* + )? // title is optional + \) + ) + /g, writeImageTag); + */ text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeImageTag); return text; } - + function attributeEncode(text) { // unconditionally replace angle brackets here -- what ends up in an attribute (e.g. alt or title) // never makes sense to have verbatim HTML in it (and the sanitizer would totally break it) @@ -725,7 +735,7 @@ else return whole_match; } } - + alt_text = escapeCharacters(attributeEncode(alt_text), "*_[]()"); url = escapeCharacters(url, "*_"); var result = "\""" + _RunSpanGamut(m1) + "\n\n"; } + function (wholeMatch, m1) { + return "

    " + _RunSpanGamut(m1) + "

    \n\n"; + } ); text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, - function (matchFound, m1) { return "

    " + _RunSpanGamut(m1) + "

    \n\n"; } + function (matchFound, m1) { + return "

    " + _RunSpanGamut(m1) + "

    \n\n"; + } ); // atx-style headers: @@ -770,15 +784,15 @@ else // /* - text = text.replace(/ - ^(\#{1,6}) // $1 = string of #'s - [ \t]* - (.+?) // $2 = Header text - [ \t]* - \#* // optional closing #'s (not counted) - \n+ - /gm, function() {...}); - */ + text = text.replace(/ + ^(\#{1,6}) // $1 = string of #'s + [ \t]* + (.+?) // $2 = Header text + [ \t]* + \#* // optional closing #'s (not counted) + \n+ + /gm, function() {...}); + */ text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, function (wholeMatch, m1, m2) { @@ -802,27 +816,27 @@ else // Re-usable pattern to match any entirel ul or ol list: /* - var whole_list = / - ( // $1 = whole list - ( // $2 - [ ]{0,3} // attacklab: g_tab_width - 1 - ([*+-]|\d+[.]) // $3 = first list item marker - [ \t]+ - ) - [^\r]+? - ( // $4 - ~0 // sentinel for workaround; should be $ - | - \n{2,} - (?=\S) - (?! // Negative lookahead for another list item marker - [ \t]* - (?:[*+-]|\d+[.])[ \t]+ - ) - ) - ) - /g - */ + var whole_list = / + ( // $1 = whole list + ( // $2 + [ ]{0,3} // attacklab: g_tab_width - 1 + ([*+-]|\d+[.]) // $3 = first list item marker + [ \t]+ + ) + [^\r]+? + ( // $4 + ~0 // sentinel for workaround; should be $ + | + \n{2,} + (?=\S) + (?! // Negative lookahead for another list item marker + [ \t]* + (?:[*+-]|\d+[.])[ \t]+ + ) + ) + ) + /g + */ var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm; if (g_list_level) { @@ -859,7 +873,7 @@ else return text; } - var _listItemMarkers = { ol: "\\d+[.]", ul: "[*+-]" }; + var _listItemMarkers = {ol: "\\d+[.]", ul: "[*+-]"}; function _ProcessListItems(list_str, list_type, isInsideParagraphlessListItem) { // @@ -908,19 +922,19 @@ else // // We changed this to behave identical to MarkdownSharp. This is the constructed RegEx, // with {MARKER} being one of \d+[.] or [*+-], depending on list_type: - + /* - list_str = list_str.replace(/ - (^[ \t]*) // leading whitespace = $1 - ({MARKER}) [ \t]+ // list marker = $2 - ([^\r]+? // list item text = $3 - (\n+) - ) - (?= - (~0 | \2 ({MARKER}) [ \t]+) - ) - /gm, function(){...}); - */ + list_str = list_str.replace(/ + (^[ \t]*) // leading whitespace = $1 + ({MARKER}) [ \t]+ // list marker = $2 + ([^\r]+? // list item text = $3 + (\n+) + ) + (?= + (~0 | \2 ({MARKER}) [ \t]+) + ) + /gm, function(){...}); + */ var marker = _listItemMarkers[list_type]; var re = new RegExp("(^[ \\t]*)(" + marker + ")[ \\t]+([^\\r]+?(\\n+))(?=(~0|\\1(" + marker + ")[ \\t]+))", "gm"); @@ -960,17 +974,17 @@ else // /* - text = text.replace(/ - (?:\n\n|^) - ( // $1 = the code block -- one or more lines, starting with a space/tab - (?: - (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width - .*\n+ - )+ - ) - (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width - /g ,function(){...}); - */ + text = text.replace(/ + (?:\n\n|^) + ( // $1 = the code block -- one or more lines, starting with a space/tab + (?: + (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width + .*\n+ + )+ + ) + (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width + /g ,function(){...}); + */ // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug text += "~0"; @@ -1029,17 +1043,17 @@ else // /* - text = text.replace(/ - (^|[^\\]) // Character before opening ` can't be a backslash - (`+) // $2 = Opening run of ` - ( // $3 = The code block - [^\r]*? - [^`] // attacklab: work around lack of lookbehind - ) - \2 // Matching closer - (?!`) - /gm, function(){...}); - */ + text = text.replace(/ + (^|[^\\]) // Character before opening ` can't be a backslash + (`+) // $2 = Opening run of ` + ( // $3 = The code block + [^\r]*? + [^`] // attacklab: work around lack of lookbehind + ) + \2 // Matching closer + (?!`) + /gm, function(){...}); + */ text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, function (wholeMatch, m1, m2, m3, m4) { @@ -1089,10 +1103,10 @@ else // must go first: text = text.replace(/([\W_]|^)(\*\*|__)(?=\S)([^\r]*?\S[\*_]*)\2([\W_]|$)/g, - "$1$3$4"); + "$1$3$4"); text = text.replace(/([\W_]|^)(\*|_)(?=\S)([^\r\*_]*?\S)\2([\W_]|$)/g, - "$1$3$4"); + "$1$3$4"); return text; } @@ -1100,17 +1114,17 @@ else function _DoBlockQuotes(text) { /* - text = text.replace(/ - ( // Wrap whole match in $1 - ( - ^[ \t]*>[ \t]? // '>' at the start of a line - .+\n // rest of the first line - (.+\n)* // subsequent consecutive lines - \n* // blanks - )+ - ) - /gm, function(){...}); - */ + text = text.replace(/ + ( // Wrap whole match in $1 + ( + ^[ \t]*>[ \t]? // '>' at the start of a line + .+\n // rest of the first line + (.+\n)* // subsequent consecutive lines + \n* // blanks + )+ + ) + /gm, function(){...}); + */ text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm, function (wholeMatch, m1) { @@ -1130,7 +1144,7 @@ else bq = bq.replace(/(^|\n)/g, "$1 "); // These leading spaces screw with
     content, so we need to fix that:
                         bq = bq.replace(
    -                            /(\s*
    [^\r]+?<\/pre>)/gm,
    +                        /(\s*
    [^\r]+?<\/pre>)/gm,
                             function (wholeMatch, m1) {
                                 var pre = m1;
                                 // attacklab: hack around Konqueror 3.5.4 bug:
    @@ -1157,7 +1171,7 @@ else
     
                 var grafs = text.split(/\n{2,}/g);
                 var grafsOut = [];
    -            
    +
                 var markerRe = /~K(\d+)K/;
     
                 //
    @@ -1272,7 +1286,7 @@ else
                 }
                 return "<" + protocol + link + ">" + tail;
             }
    -        
    +
             function _DoAutoLinks(text) {
     
                 // note that at this point, all other URL in the text are already hyperlinked as 
    @@ -1285,31 +1299,33 @@ else
                 text = text.replace(autoLinkRegex, handleTrailingParens);
     
                 //  autolink anything like 
    -            
    -            var replacer = function (wholematch, m1) { return "" + pluginHooks.plainLinkText(m1) + ""; }
    +
    +            var replacer = function (wholematch, m1) {
    +                return "" + pluginHooks.plainLinkText(m1) + "";
    +            }
                 text = text.replace(/<((https?|ftp):[^'">\s]+)>/gi, replacer);
     
                 // Email addresses: 
                 /*
    -            text = text.replace(/
    -                <
    -                (?:mailto:)?
    -                (
    -                    [-.\w]+
    -                    \@
    -                    [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
    -                )
    -                >
    -            /gi, _DoAutoLinks_callback());
    -            */
    +             text = text.replace(/
    +             <
    +             (?:mailto:)?
    +             (
    +             [-.\w]+
    +             \@
    +             [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
    +             )
    +             >
    +             /gi, _DoAutoLinks_callback());
    +             */
     
                 /* disabling email autolinking, since we don't do that on the server, either
    -            text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
    -                function(wholeMatch,m1) {
    -                    return _EncodeEmailAddress( _UnescapeSpecialChars(m1) );
    -                }
    -            );
    -            */
    +             text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,
    +             function(wholeMatch,m1) {
    +             return _EncodeEmailAddress( _UnescapeSpecialChars(m1) );
    +             }
    +             );
    +             */
                 return text;
             }
     
    @@ -1347,8 +1363,8 @@ else
                     return text;
     
                 var spaces = ["    ", "   ", "  ", " "],
    -            skew = 0,
    -            v;
    +                skew = 0,
    +                v;
     
                 return text.replace(/[\n\t]/g, function (match, offset) {
                     if (match === "\n") {
    diff --git a/system/admin/editor/js/Markdown.Editor.js b/system/admin/editor/js/Markdown.Editor.js
    index c181675..86b6c79 100644
    --- a/system/admin/editor/js/Markdown.Editor.js
    +++ b/system/admin/editor/js/Markdown.Editor.js
    @@ -8,7 +8,7 @@
             doc = window.document,
             re = window.RegExp,
             nav = window.navigator,
    -        SETTINGS = { lineLength: 72 },
    +        SETTINGS = {lineLength: 72},
     
         // Used to work around some browser bugs where we can't use feature testing.
             uaSniffed = {
    @@ -90,29 +90,34 @@
         // - run() actually starts the editor; should be called after all necessary plugins are registered. Calling this more than once is a no-op.
         // - refreshPreview() forces the preview to be updated. This method is only available after run() was called.
         Markdown.Editor = function (markdownConverter, idPostfix, options) {
    -        
    +
             options = options || {};
     
             if (typeof options.handler === "function") { //backwards compatible behavior
    -            options = { helpButton: options };
    +            options = {helpButton: options};
             }
             options.strings = options.strings || {};
             if (options.helpButton) {
                 options.strings.help = options.strings.help || options.helpButton.title;
             }
    -        var getString = function (identifier) { return options.strings[identifier] || defaultsStrings[identifier]; }
    +        var getString = function (identifier) {
    +            return options.strings[identifier] || defaultsStrings[identifier];
    +        }
     
             idPostfix = idPostfix || "";
     
             var hooks = this.hooks = new Markdown.HookCollection();
             hooks.addNoop("onPreviewRefresh");       // called with no arguments after the preview has been refreshed
             hooks.addNoop("postBlockquoteCreation"); // called with the user's selection *after* the blockquote was created; should return the actual to-be-inserted text
    -        hooks.addFalse("insertImageDialog");     /* called with one parameter: a callback to be called with the URL of the image. If the application creates
    -                                                  * its own image insertion dialog, this hook should return true, and the callback should be called with the chosen
    -                                                  * image url (or null if the user cancelled). If this hook returns false, the default dialog will be used.
    -                                                  */
    +        hooks.addFalse("insertImageDialog");
    +        /* called with one parameter: a callback to be called with the URL of the image. If the application creates
    +         * its own image insertion dialog, this hook should return true, and the callback should be called with the chosen
    +         * image url (or null if the user cancelled). If this hook returns false, the default dialog will be used.
    +         */
     
    -        this.getConverter = function () { return markdownConverter; }
    +        this.getConverter = function () {
    +            return markdownConverter;
    +        }
     
             var that = this,
                 panels;
    @@ -123,7 +128,9 @@
     
                 panels = new PanelCollection(idPostfix);
                 var commandManager = new CommandManager(hooks, getString);
    -            var previewManager = new PreviewManager(markdownConverter, panels, function () { hooks.onPreviewRefresh(); });
    +            var previewManager = new PreviewManager(markdownConverter, panels, function () {
    +                hooks.onPreviewRefresh();
    +            });
                 var undoManager, uiManager;
     
                 if (!/\?noundo/.test(doc.location.href)) {
    @@ -142,7 +149,9 @@
                 uiManager = new UIManager(idPostfix, panels, undoManager, previewManager, commandManager, options.helpButton, getString);
                 uiManager.setUndoRedoButtonStates();
     
    -            var forceRefresh = that.refreshPreview = function () { previewManager.refresh(true); };
    +            var forceRefresh = that.refreshPreview = function () {
    +                previewManager.refresh(true);
    +            };
     
                 forceRefresh();
             };
    @@ -151,7 +160,8 @@
     
         // before: contains all the text in the input box BEFORE the selection.
         // after: contains all the text in the input box AFTER the selection.
    -    function Chunks() { }
    +    function Chunks() {
    +    }
     
         // startRegex: a regular expression to find the start tag
         // endRegex: a regular expresssion to find the end tag
    @@ -208,8 +218,14 @@
             if (remove) {
                 beforeReplacer = afterReplacer = "";
             } else {
    -            beforeReplacer = function (s) { that.before += s; return ""; }
    -            afterReplacer = function (s) { that.after = s + that.after; return ""; }
    +            beforeReplacer = function (s) {
    +                that.before += s;
    +                return "";
    +            }
    +            afterReplacer = function (s) {
    +                that.after = s + that.after;
    +                return "";
    +            }
             }
     
             this.selection = this.selection.replace(/^(\s*)/, beforeReplacer).replace(/(\s*)$/, afterReplacer);
    @@ -847,14 +863,12 @@
                 if (window.innerHeight) {
                     result = window.pageYOffset;
                 }
    -            else
    -                if (doc.documentElement && doc.documentElement.scrollTop) {
    -                    result = doc.documentElement.scrollTop;
    -                }
    -                else
    -                    if (doc.body) {
    -                        result = doc.body.scrollTop;
    -                    }
    +            else if (doc.documentElement && doc.documentElement.scrollTop) {
    +                result = doc.documentElement.scrollTop;
    +            }
    +            else if (doc.body) {
    +                result = doc.body.scrollTop;
    +            }
     
                 return result;
             };
    @@ -1023,9 +1037,9 @@
     
             var background = doc.createElement("div"),
                 style = background.style;
    -        
    +
             background.className = "wmd-prompt-background";
    -        
    +
             style.position = "absolute";
             style.top = "0";
     
    @@ -1107,7 +1121,6 @@
             };
     
     
    -
             // Create the text input box form/window.
             var createDialog = function () {
     
    @@ -1128,7 +1141,9 @@
                 // The web form container for the text box and buttons.
                 var form = doc.createElement("form"),
                     style = form.style;
    -            form.onsubmit = function () { return close(false); };
    +            form.onsubmit = function () {
    +                return close(false);
    +            };
                 style.padding = "0";
                 style.margin = "0";
                 style.cssFloat = "left";
    @@ -1150,7 +1165,9 @@
                 // The ok button
                 var okButton = doc.createElement("input");
                 okButton.type = "button";
    -            okButton.onclick = function () { return close(false); };
    +            okButton.onclick = function () {
    +                return close(false);
    +            };
                 okButton.value = "OK";
                 style = okButton.style;
                 style.margin = "10px";
    @@ -1161,7 +1178,9 @@
                 // The cancel button
                 var cancelButton = doc.createElement("input");
                 cancelButton.type = "button";
    -            cancelButton.onclick = function () { return close(true); };
    +            cancelButton.onclick = function () {
    +                return close(true);
    +            };
                 cancelButton.value = "Cancel";
                 style = cancelButton.style;
                 style.margin = "10px";
    @@ -1415,14 +1434,17 @@
                 }
                 else {
                     image.style.backgroundPosition = button.XShift + " " + disabledYShift;
    -                button.onmouseover = button.onmouseout = button.onclick = function () { };
    +                button.onmouseover = button.onmouseout = button.onclick = function () {
    +                };
                 }
             }
     
             function bindCommand(method) {
                 if (typeof method === "string")
                     method = commandManager[method];
    -            return function () { method.apply(commandManager, arguments); }
    +            return function () {
    +                method.apply(commandManager, arguments);
    +            }
             }
     
             function makeSpritedButtonRow() {
    @@ -1484,14 +1506,18 @@
                 buttons.hr = makeButton("wmd-hr-button", getString("hr"), "-180px", bindCommand("doHorizontalRule"));
                 makeSpacer(3);
                 buttons.undo = makeButton("wmd-undo-button", getString("undo"), "-200px", null);
    -            buttons.undo.execute = function (manager) { if (manager) manager.undo(); };
    +            buttons.undo.execute = function (manager) {
    +                if (manager) manager.undo();
    +            };
     
                 var redoTitle = /win/.test(nav.platform.toLowerCase()) ?
                     getString("redo") :
                     getString("redomac"); // mac and other non-Windows platforms
     
                 buttons.redo = makeButton("wmd-redo-button", redoTitle, "-220px", null);
    -            buttons.redo.execute = function (manager) { if (manager) manager.redo(); };
    +            buttons.redo.execute = function (manager) {
    +                if (manager) manager.redo();
    +            };
     
                 if (helpOptions) {
                     var helpButton = document.createElement("li");
    @@ -1716,7 +1742,7 @@
     
             }
             else {
    -            
    +
                 // We're moving start and end tag back into the selection, since (as we're in the else block) we're not
                 // *removing* a link, but *adding* one, so whatever findTags() found is now back to being part of the
                 // link text. linkEnteredCallback takes care of escaping any brackets.
    @@ -1754,7 +1780,7 @@
                         // would mean a zero-width match at the start. Since zero-width matches advance the string position,
                         // the first bracket could then not act as the "not a backslash" for the second.
                         chunk.selection = (" " + chunk.selection).replace(/([^\\](?:\\\\)*)(?=[[\]])/g, "$1\\").substr(1);
    -                    
    +
                         var linkDef = " [999]: " + properlyEncoded(link);
     
                         var num = that.addLinkDef(chunk, linkDef);
    @@ -1796,7 +1822,7 @@
             chunk.before = chunk.before.replace(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]*\n$/, "\n\n");
             chunk.before = chunk.before.replace(/(\n|^)[ ]{0,3}>[ \t]*\n$/, "\n\n");
             chunk.before = chunk.before.replace(/(\n|^)[ \t]+\n$/, "\n\n");
    -        
    +
             // There's no selection, end the cursor wasn't at the end of the line:
             // The user wants to split the current list item / code line / blockquote line
             // (for the latter it doesn't really matter) in two. Temporarily select the
    @@ -1824,7 +1850,7 @@
                     commandMgr.doCode(chunk);
                 }
             }
    -        
    +
             if (fakeSelection) {
                 chunk.after = chunk.selection + chunk.after;
                 chunk.selection = "";
    @@ -1853,15 +1879,15 @@
             // text *directly before* the selection already was a blockquote:
     
             /*
    -        if (chunk.before) {
    -        chunk.before = chunk.before.replace(/\n?$/, "\n");
    -        }
    -        chunk.before = chunk.before.replace(/(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*$)/,
    -        function (totalMatch) {
    -        chunk.startTag = totalMatch;
    -        return "";
    -        });
    -        */
    +         if (chunk.before) {
    +         chunk.before = chunk.before.replace(/\n?$/, "\n");
    +         }
    +         chunk.before = chunk.before.replace(/(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*$)/,
    +         function (totalMatch) {
    +         chunk.startTag = totalMatch;
    +         return "";
    +         });
    +         */
     
             // This comes down to:
             // Go backwards as many lines a possible, such that each line
    @@ -1968,10 +1994,10 @@
     
             if (!/\n/.test(chunk.selection)) {
                 chunk.selection = chunk.selection.replace(/^(> *)/,
    -            function (wholeMatch, blanks) {
    -                chunk.startTag += blanks;
    -                return "";
    -            });
    +                function (wholeMatch, blanks) {
    +                    chunk.startTag += blanks;
    +                    return "";
    +                });
             }
         };
     
    diff --git a/system/admin/editor/js/Markdown.Sanitizer.js b/system/admin/editor/js/Markdown.Sanitizer.js
    index cc5826f..bfced16 100644
    --- a/system/admin/editor/js/Markdown.Sanitizer.js
    +++ b/system/admin/editor/js/Markdown.Sanitizer.js
    @@ -7,7 +7,7 @@
             output = window.Markdown;
             Converter = output.Converter;
         }
    -        
    +
         output.getSanitizingConverter = function () {
             var converter = new Converter();
             converter.hooks.chain("postConversion", sanitizeHtml);
    diff --git a/system/admin/editor/js/local/Markdown.local.fr.js b/system/admin/editor/js/local/Markdown.local.fr.js
    index db1a373..febd080 100644
    --- a/system/admin/editor/js/local/Markdown.local.fr.js
    +++ b/system/admin/editor/js/local/Markdown.local.fr.js
    @@ -3,8 +3,8 @@
     // var myConverter = new Markdown.Editor(myConverter, null, { strings: Markdown.local.fr });
     
     (function () {
    -        Markdown.local = Markdown.local || {};
    -        Markdown.local.fr = {
    +    Markdown.local = Markdown.local || {};
    +    Markdown.local.fr = {
             bold: "Gras  Ctrl+B",
             boldexample: "texte en gras",
     
    diff --git a/system/admin/editor/package.json b/system/admin/editor/package.json
    index aedd3c1..57b0689 100644
    --- a/system/admin/editor/package.json
    +++ b/system/admin/editor/package.json
    @@ -1,12 +1,19 @@
     {
    -    "name": "pagedown",
    -    "version": "1.1.0",
    -    "description": "markdown converter, based on showdown",
    -    "repository": { "type": "hg", "url": "https://code.google.com/p/pagedown/" },
    -    "keywords": ["markdown"],
    -    "license": "MIT",
    -    "files": ["Markdown.Converter.js", "Markdown.Sanitizer.js", "node-pagedown.js"],
    -    "main": "node-pagedown.js",
    -    "bugs": "http://code.google.com/p/pagedown/issues/list",
    -    "homepage": "http://code.google.com/p/pagedown/wiki/PageDown"
    +  "name": "pagedown",
    +  "version": "1.1.0",
    +  "description": "markdown converter, based on showdown",
    +  "repository": {
    +    "type": "hg",
    +    "url": "https://code.google.com/p/pagedown/"
    +  },
    +  "keywords": ["markdown"],
    +  "license": "MIT",
    +  "files": [
    +    "Markdown.Converter.js",
    +    "Markdown.Sanitizer.js",
    +    "node-pagedown.js"
    +  ],
    +  "main": "node-pagedown.js",
    +  "bugs": "http://code.google.com/p/pagedown/issues/list",
    +  "homepage": "http://code.google.com/p/pagedown/wiki/PageDown"
     }
    diff --git a/system/admin/views/404.html.php b/system/admin/views/404.html.php
    index 96439e7..8367291 100644
    --- a/system/admin/views/404.html.php
    +++ b/system/admin/views/404.html.php
    @@ -1,19 +1,20 @@
     
     
     
    -	
    -	
    -	
    -	
    -	404 Not Found - <?php echo blog_title() ?>
    -	
    -	
    -	
    +    
    +    
    +    
    +    
    +    404 Not Found - <?php echo blog_title() ?>
    +    
    +    
    +    
     
     
    -	
    -

    This page doesn't exist!

    -

    Would you like to try our homepage instead?

    -
    +
    +

    This page doesn't exist!

    + +

    Would you like to try our homepage instead?

    +
    \ No newline at end of file diff --git a/system/admin/views/add-page.html.php b/system/admin/views/add-page.html.php index c7c89cf..16b0253 100644 --- a/system/admin/views/add-page.html.php +++ b/system/admin/views/add-page.html.php @@ -1,30 +1,47 @@ - + -
    - +
    +
    -
    - Title *


    - Url (optional)

    - If the url leave empty we will use the page title.

    - Meta Description (optional)
    -
    -
    -
    - - -
    +
    + Title *


    + Url (optional)

    + If the url leave empty we will use the page title.

    + Meta Description (optional)
    +
    + +
    +
    + + +
    \ No newline at end of file diff --git a/system/admin/views/add-post.html.php b/system/admin/views/add-post.html.php index ee686b5..c99142f 100644 --- a/system/admin/views/add-post.html.php +++ b/system/admin/views/add-post.html.php @@ -1,33 +1,60 @@ - + -
    - +
    +
    -
    - Title *


    - Tag *


    - Url (optional)

    - If the url leave empty we will use the post title.

    - Meta Description (optional)
    -

    - Featured Image (optional)


    - Embed Youtube Video (optional)


    -
    -
    - - -
    +
    + Title *


    + Tag *


    + Url (optional)

    + If the url leave empty we will use the post title.

    + Meta Description (optional)
    +

    + Featured Image (optional)


    + Embed Youtube Video (optional)


    + +
    +
    + + +
    diff --git a/system/admin/views/backup-start.html.php b/system/admin/views/backup-start.html.php index 4141b80..86b5903 100644 --- a/system/admin/views/backup-start.html.php +++ b/system/admin/views/backup-start.html.php @@ -2,23 +2,22 @@ $title = config('blog.title'); $name = preg_replace('/[^A-Za-z0-9 ,.-]/u', '', strtolower($title)); -$name = str_replace(' ', '-',$name); -$name = str_replace('--', '-',$name); -$name = str_replace('--', '-',$name); +$name = str_replace(' ', '-', $name); +$name = str_replace('--', '-', $name); +$name = str_replace('--', '-', $name); $name = rtrim(ltrim($name, ' \,\.\-'), ' \,\.\-'); $timestamp = date('Y-m-d-H-i-s'); $dir = 'backup'; -if(is_dir($dir)) { - Zip('content/', 'backup/' . $name . '_' . $timestamp . '.zip', true); -} -else { - mkdir($dir, 0777, true); - Zip('content/', 'backup/' . $name . '_' . $timestamp . '.zip', true); +if (is_dir($dir)) { + Zip('content/', 'backup/' . $name . '_' . $timestamp . '.zip', true); +} else { + mkdir($dir, 0777, true); + Zip('content/', 'backup/' . $name . '_' . $timestamp . '.zip', true); } $redirect = site_url() . 'admin/backup'; -header("Location: $redirect"); - - ?> \ No newline at end of file +header("Location: $redirect"); + +?> \ No newline at end of file diff --git a/system/admin/views/backup.html.php b/system/admin/views/backup.html.php index eb30b4a..0d2f001 100644 --- a/system/admin/views/backup.html.php +++ b/system/admin/views/backup.html.php @@ -1,15 +1,15 @@ - -Create backup -

    Your backups

    + Create backup +

    Your backups

    \ No newline at end of file diff --git a/system/admin/views/clear-cache.html.php b/system/admin/views/clear-cache.html.php index 408ebbd..2070ab5 100644 --- a/system/admin/views/clear-cache.html.php +++ b/system/admin/views/clear-cache.html.php @@ -2,11 +2,11 @@ rebuilt_cache('all'); -foreach(glob('cache/page/*.cache', GLOB_NOSORT) as $file) { - unlink($file); +foreach (glob('cache/page/*.cache', GLOB_NOSORT) as $file) { + unlink($file); } echo 'All cache has been deleted!'; - - ?> \ No newline at end of file + +?> \ No newline at end of file diff --git a/system/admin/views/config.html.php b/system/admin/views/config.html.php index cb1f9ab..28cbfa5 100644 --- a/system/admin/views/config.html.php +++ b/system/admin/views/config.html.php @@ -32,6 +32,7 @@ return "0"; return (string)$value; } + foreach ($array as $key => $value) { echo ''; echo ''; diff --git a/system/admin/views/delete-page.html.php b/system/admin/views/delete-page.html.php index 3a25687..6e0d237 100644 --- a/system/admin/views/delete-page.html.php +++ b/system/admin/views/delete-page.html.php @@ -1,25 +1,25 @@ file; +if (isset($_GET['destination'])) { + $destination = $_GET['destination']; +} +$url = $p->file; - $dir = substr($url, 0, strrpos($url, '/')); - $oldurl = str_replace($dir . '/', '', $url); - $oldmd = str_replace('.md', '', $oldurl); +$dir = substr($url, 0, strrpos($url, '/')); +$oldurl = str_replace($dir . '/', '', $url); +$oldmd = str_replace('.md', '', $oldurl); - $post = $p->url; +$post = $p->url; - if (isset($destination)) { +if (isset($destination)) { - if ($destination == 'post') { - $back = $post; - } else { - $back = site_url() . $destination; - } + if ($destination == 'post') { + $back = $post; } else { - $back = site_url(); + $back = site_url() . $destination; } +} else { + $back = site_url(); +} ?>

    Are you sure want to delete title; ?>?

    diff --git a/system/admin/views/delete-post.html.php b/system/admin/views/delete-post.html.php index 63989cf..1a05e30 100644 --- a/system/admin/views/delete-post.html.php +++ b/system/admin/views/delete-post.html.php @@ -1,40 +1,38 @@ file; - $oldurl = explode('_', $url); - $oldtag = $oldurl[1]; - $oldmd = str_replace('.md','',$oldurl[2]); +if (isset($_GET['destination'])) { + $destination = $_GET['destination']; +} +$url = $p->file; +$oldurl = explode('_', $url); +$oldtag = $oldurl[1]; +$oldmd = str_replace('.md', '', $oldurl[2]); + +$replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; +$dt = str_replace($replaced, '', $oldurl[0]); +$t = str_replace('-', '', $dt); +$time = new DateTime($t); +$timestamp = $time->format("Y-m-d"); +// The post date +$postdate = strtotime($timestamp); +// The post URL +$post = site_url() . date('Y/m', $postdate) . '/' . $oldmd; + +if (isset($destination)) { + + if ($destination == 'post') { + $back = $post; + } else { + $back = site_url() . $destination; + } +} else { + $back = site_url(); +} - $replaced = substr($oldurl[0], 0,strrpos($oldurl[0], '/')) . '/'; - $dt = str_replace($replaced,'',$oldurl[0]); - $t = str_replace('-','',$dt); - $time = new DateTime($t); - $timestamp= $time->format("Y-m-d"); - // The post date - $postdate = strtotime($timestamp); - // The post URL - $post = site_url().date('Y/m', $postdate).'/'.$oldmd; - - if(isset($destination)) { - - if($destination == 'post') { - $back = $post; - } - else { - $back = site_url() . $destination; - } - } - else { - $back = site_url(); - } - ?> -Are you sure want to delete ' . $p->title . '?

    ';?> +Are you sure want to delete ' . $p->title . '?

    '; ?> -
    - - - Cancel +
    + + + Cancel
    \ No newline at end of file diff --git a/system/admin/views/edit-page.html.php b/system/admin/views/edit-page.html.php index 4dd5e09..6cde183 100644 --- a/system/admin/views/edit-page.html.php +++ b/system/admin/views/edit-page.html.php @@ -1,56 +1,66 @@ file)) { - $url = $p->file; - } - else { - $url = $oldfile; - } - $content = file_get_contents($url); - $oldtitle = get_content_tag('t',$content,'Untitled'); - $oldcontent = remove_html_comments($content); - - if(isset($_GET['destination'])) { - $destination = $_GET['destination']; - } - else { - $destination = 'admin'; - } - $dir = substr($url, 0, strrpos($url, '/')); - $oldurl = str_replace($dir . '/','',$url); - $oldmd = str_replace('.md','',$oldurl); - - $delete = $p->url . '/delete?destination=' . $destination; - +if (isset($p->file)) { + $url = $p->file; +} else { + $url = $oldfile; +} +$content = file_get_contents($url); +$oldtitle = get_content_tag('t', $content, 'Untitled'); +$oldcontent = remove_html_comments($content); + +if (isset($_GET['destination'])) { + $destination = $_GET['destination']; +} else { + $destination = 'admin'; +} +$dir = substr($url, 0, strrpos($url, '/')); +$oldurl = str_replace($dir . '/', '', $url); +$oldmd = str_replace('.md', '', $oldurl); + +$delete = $p->url . '/delete?destination=' . $destination; + ?> - + -
    - +
    +
    -
    - Title *


    - Url (optional)

    - If the url leave empty we will use the page title.

    - Meta Description (optional)
    -

    -
    -
    - - - Delete -
    +
    + Title *


    + Url (optional)

    + If the url leave empty we will use the page title.

    + Meta Description (optional)
    +

    + +
    +
    + + + Delete +
    \ No newline at end of file diff --git a/system/admin/views/edit-post.html.php b/system/admin/views/edit-post.html.php index 8fe7e76..b971c05 100644 --- a/system/admin/views/edit-post.html.php +++ b/system/admin/views/edit-post.html.php @@ -1,75 +1,90 @@ file)) { - $url = $p->file; - } - else { - $url = $oldfile; - } +if (isset($p->file)) { + $url = $p->file; +} else { + $url = $oldfile; +} + +$content = file_get_contents($url); +$oldtitle = get_content_tag('t', $content, 'Untitled'); +$oldfi = get_content_tag('fi', $content); +$oldvid = get_content_tag('vid', $content); +$oldcontent = remove_html_comments($content); + +$dir = substr($url, 0, strrpos($url, '/')); + +$oldurl = explode('_', $url); + +$oldtag = $oldurl[1]; + +$oldmd = str_replace('.md', '', $oldurl[2]); + +if (isset($_GET['destination'])) { + $destination = $_GET['destination']; +} else { + $destination = 'admin'; +} +$replaced = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/'; +$dt = str_replace($replaced, '', $oldurl[0]); +$t = str_replace('-', '', $dt); +$time = new DateTime($t); +$timestamp = $time->format("Y-m-d"); +// The post date +$postdate = strtotime($timestamp); +// The post URL +$delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destination=' . $destination; + - $content = file_get_contents($url); - $oldtitle = get_content_tag('t',$content,'Untitled'); - $oldfi = get_content_tag('fi',$content); - $oldvid = get_content_tag('vid',$content); - $oldcontent = remove_html_comments($content); - - $dir = substr($url, 0, strrpos($url, '/')); - - $oldurl = explode('_', $url); - - $oldtag = $oldurl[1]; - - $oldmd = str_replace('.md','',$oldurl[2]); - - if(isset($_GET['destination'])) { - $destination = $_GET['destination']; - } - else { - $destination = 'admin'; - } - $replaced = substr($oldurl[0], 0,strrpos($oldurl[0], '/')) . '/'; - $dt = str_replace($replaced,'',$oldurl[0]); - $t = str_replace('-','',$dt); - $time = new DateTime($t); - $timestamp= $time->format("Y-m-d"); - // The post date - $postdate = strtotime($timestamp); - // The post URL - $delete= site_url().date('Y/m', $postdate).'/'.$oldmd . '/delete?destination=' . $destination; - - ?> - + -
    - +
    +
    -
    - Title *


    - Tag *


    - Url (optional)

    - If the url leave empty we will use the post title.

    - Date Time



    - Meta Description (optional)
    -

    - Featured Image (optional)


    - Embed Youtube Video (optional)


    -
    -
    - - - Delete -
    +
    + Title *


    + Tag *


    + Url (optional)

    + If the url leave empty we will use the post title.

    + Date Time



    + Meta Description (optional)
    +

    + Featured Image (optional)


    + Embed Youtube Video (optional)


    + +
    +
    + + + Delete +
    diff --git a/system/admin/views/edit-profile.html.php b/system/admin/views/edit-profile.html.php index 1736c62..f85d286 100644 --- a/system/admin/views/edit-profile.html.php +++ b/system/admin/views/edit-profile.html.php @@ -1,47 +1,56 @@ - + -
    - +
    +
    -
    - Title *


    -
    -
    -
    - - -
    +
    + Title *


    +
    + +
    +
    + + +
    \ No newline at end of file diff --git a/system/admin/views/import.html.php b/system/admin/views/import.html.php index b402de1..cdf4835 100644 --- a/system/admin/views/import.html.php +++ b/system/admin/views/import.html.php @@ -1,11 +1,15 @@ -
    - +
    +

    Import RSS Feed 2.0

    By using this importer you are agree if the feed is yours, or at least you have the authority to publish it.

    - Feed Url *


    - Add source link (optional)

    - - + Feed Url *


    + Add source link (optional)

    + +
    \ No newline at end of file diff --git a/system/admin/views/layout.html.php b/system/admin/views/layout.html.php index ebecbb5..c52a7aa 100644 --- a/system/admin/views/layout.html.php +++ b/system/admin/views/layout.html.php @@ -1,54 +1,58 @@ - - - - - + + + + + + -
    - - -
    - -
    - -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    - -
    - +
    + + +
    + +
    + +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    + +
    + \ No newline at end of file diff --git a/system/admin/views/login.html.php b/system/admin/views/login.html.php index 916e9b7..2681245 100644 --- a/system/admin/views/login.html.php +++ b/system/admin/views/login.html.php @@ -1,19 +1,29 @@ -
    - - -

    Login

    -
    - User *
    -

    - Password *
    -

    - - +
    + + +

    Login

    + + User *
    +

    + Password *
    +

    + +
    ">

    - - -
    - \ No newline at end of file + + + + \ No newline at end of file diff --git a/system/admin/views/main.html.php b/system/admin/views/main.html.php index 90403f0..89829fa 100644 --- a/system/admin/views/main.html.php +++ b/system/admin/views/main.html.php @@ -1,5 +1,5 @@ -Your recent posts'; -get_recent_posts(); +get_recent_posts(); echo '

    Static pages

    '; get_recent_pages(); ?> \ No newline at end of file diff --git a/system/admin/views/posts-list.html.php b/system/admin/views/posts-list.html.php index 9457c3e..a9a6035 100644 --- a/system/admin/views/posts-list.html.php +++ b/system/admin/views/posts-list.html.php @@ -1,39 +1,49 @@ -

    - - - - - - - - - - - - - - - -
    TitlePublishedViewsAuthorTagOperations
    title ?>date) ?>views ?>author ?>tag ?>Edit Delete
    - -
    - - - - - - -
    - - \ No newline at end of file +

    + + + + + + + + + + + + + + + + + + + + + + + +
    TitlePublishedViewsAuthorTagOperations
    title ?>date) ?>views ?>author ?>tag ?>Edit Delete
    + +
    + + + + + + +
    + + \ No newline at end of file diff --git a/system/admin/views/updated-to.html.php b/system/admin/views/updated-to.html.php index 4bdf41a..16c3997 100644 --- a/system/admin/views/updated-to.html.php +++ b/system/admin/views/updated-to.html.php @@ -1,6 +1,8 @@ -

    Updated to

    -

    []

    -

    +

    Updated to +

    +

    []

    + +

    - - - - - - - - - - - - - - -
    TitlePublishedViewsTagOperations
    title ?>date) ?>views ?>tag ?>Edit Delete
    - -
    - - - - - - -
    - - \ No newline at end of file +

    + + + + + + + + + + + + + + + + + + + + + +
    TitlePublishedViewsTagOperations
    title ?>date) ?>views ?>tag ?>Edit Delete
    + +
    + + + + + + +
    + + \ No newline at end of file diff --git a/system/htmly.php b/system/htmly.php index 122d68b..2b79512 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -5,7 +5,7 @@ date_default_timezone_set('Asia/Jakarta'); // Load the configuration file config('source', $config_file); -if(config('timezone')) { +if (config('timezone')) { date_default_timezone_set(config('timezone')); } @@ -18,7 +18,7 @@ get('/index', function () { } $page = from($_GET, 'page'); - $page = $page ? (int) $page : 1; + $page = $page ? (int)$page : 1; $perpage = config('posts.perpage'); $posts = get_posts(null, $page, $perpage); @@ -89,7 +89,7 @@ post('/login', function () { if (!$proper) { $message['error'] .= '
  • CSRF Token not correct.
  • '; } - if(!$captcha) { + if (!$captcha) { $message['error'] .= '
  • reCaptcha not correct.
  • '; } @@ -344,12 +344,12 @@ post('/:year/:month/:name/edit', function () { $date = from($_REQUEST, 'date'); $time = from($_REQUEST, 'time'); $dateTime = null; - if($date !== null && $time !== null) { + if ($date !== null && $time !== null) { $dateTime = $date . ' ' . $time; } if ($proper && !empty($title) && !empty($tag) && !empty($content)) { - if(empty($url)) { + if (empty($url)) { $url = $title; } edit_post($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $fi, $vid); @@ -442,7 +442,7 @@ get('/author/:profile', function ($profile) { } $page = from($_GET, 'page'); - $page = $page ? (int) $page : 1; + $page = $page ? (int)$page : 1; $perpage = config('profile.perpage'); $posts = get_profile($profile, $page, $perpage); @@ -545,7 +545,7 @@ get('/admin/posts', function () { config('views.root', 'system/admin/views'); $page = from($_GET, 'page'); - $page = $page ? (int) $page : 1; + $page = $page ? (int)$page : 1; $perpage = 20; $posts = get_posts(null, $page, $perpage); @@ -603,7 +603,7 @@ get('/admin/mine', function () { $profile = $_SESSION[config("site.url")]['user']; $page = from($_GET, 'page'); - $page = $page ? (int) $page : 1; + $page = $page ? (int)$page : 1; $perpage = config('profile.perpage'); $posts = get_profile($profile, $page, $perpage); @@ -1087,12 +1087,12 @@ post('/admin/config', function () { $new_config = array(); $new_Keys = array(); - if(!empty($newKey)){ + if (!empty($newKey)) { $new_Keys[$newKey] = $newValue; } - foreach($_POST as $name => $value){ - if(substr($name,0,8) == "-config-"){ - $name = str_replace("_", ".",substr($name,8)); + foreach ($_POST as $name => $value) { + if (substr($name, 0, 8) == "-config-") { + $name = str_replace("_", ".", substr($name, 8)); $new_config[$name] = $value; } } @@ -1163,7 +1163,7 @@ get('/tag/:tag', function ($tag) { } $page = from($_GET, 'page'); - $page = $page ? (int) $page : 1; + $page = $page ? (int)$page : 1; $perpage = config('tag.perpage'); $posts = get_tag($tag, $page, $perpage, false); @@ -1193,7 +1193,7 @@ get('/archive/:req', function ($req) { } $page = from($_GET, 'page'); - $page = $page ? (int) $page : 1; + $page = $page ? (int)$page : 1; $perpage = config('archive.perpage'); $posts = get_archive($req, $page, $perpage); @@ -1239,7 +1239,7 @@ get('/search/:keyword', function ($keyword) { } $page = from($_GET, 'page'); - $page = $page ? (int) $page : 1; + $page = $page ? (int)$page : 1; $perpage = config('search.perpage'); $posts = get_keyword($keyword, $page, $perpage); @@ -1268,7 +1268,7 @@ get('/api/json', function () { header('Content-type: application/json'); $page = from($_GET, 'page'); - $page = $page ? (int) $page : 1; + $page = $page ? (int)$page : 1; $perpage = config('json.count'); echo generate_json(get_posts(null, $page, $perpage)); @@ -1296,9 +1296,9 @@ get('/admin/update/now/:csrf', function ($CSRF) { $proper = is_csrf_proper($CSRF); $updater = new \Kanti\HubUpdater(array( - 'name' => 'danpros/htmly', - 'prerelease' => !!config("prerelease"), - )); + 'name' => 'danpros/htmly', + 'prerelease' => !!config("prerelease"), + )); if (login() && $proper && $updater->able()) { $updater->update(); config('views.root', 'system/admin/views'); diff --git a/system/includes/dispatch.php b/system/includes/dispatch.php index ceb4d4e..09906be 100644 --- a/system/includes/dispatch.php +++ b/system/includes/dispatch.php @@ -52,18 +52,19 @@ function config($key, $value = null) $_config[$key] = $value; } -function save_config($data = array(),$new = array()){ +function save_config($data = array(), $new = array()) +{ global $config_file; $string = file_get_contents($config_file) . "\n"; foreach ($data as $word => $value) { - $value = str_replace('"','\"',$value); + $value = str_replace('"', '\"', $value); $string = preg_replace("/^" . $word . " = .+$/m", $word . ' = "' . $value . '"', $string); } $string = rtrim($string); foreach ($new as $word => $value) { - $value = str_replace('"','\"',$value); + $value = str_replace('"', '\"', $value); $string .= "\n" . $word . ' = "' . $value . '"' . "\n"; } $string = rtrim($string); diff --git a/system/includes/functions.php b/system/includes/functions.php index c495e7a..1e57b3b 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -244,7 +244,7 @@ function get_posts($posts, $page = 1, $perpage = 0) // Extract the title and body $post->title = get_content_tag('t', $content, 'Untitled: ' . date('l jS \of F Y', $post->date)); $post->feature = get_content_tag('fi', $content); - $post->video = get_content_tag('vid', $content); + $post->video = get_content_tag('vid', $content); // Get the contents and convert it to HTML $post->body = MarkdownExtra::defaultTransform(remove_html_comments($content)); diff --git a/system/includes/opml.php b/system/includes/opml.php index 8cb57a8..dd1acf2 100644 --- a/system/includes/opml.php +++ b/system/includes/opml.php @@ -1,4 +1,5 @@ .nav { - left: 0; + left: 0; } /* line 74, ../sass/lightbox.sass */ .lb-nav a { - outline: none; + outline: none; } /* line 77, ../sass/lightbox.sass */ .lb-prev, .lb-next { - width: 49%; - height: 100%; - cursor: pointer; - /* Trick IE into showing hover */ - display: block; + width: 49%; + height: 100%; + cursor: pointer; + /* Trick IE into showing hover */ + display: block; } /* line 84, ../sass/lightbox.sass */ .lb-prev { - left: 0; - float: left; + left: 0; + float: left; } + /* line 87, ../sass/lightbox.sass */ .lb-prev:hover { - background: url(../img/prev.png) left 48% no-repeat; + background: url(../img/prev.png) left 48% no-repeat; } /* line 90, ../sass/lightbox.sass */ .lb-next { - right: 0; - float: right; + right: 0; + float: right; } + /* line 93, ../sass/lightbox.sass */ .lb-next:hover { - background: url(../img/next.png) right 48% no-repeat; + background: url(../img/next.png) right 48% no-repeat; } /* line 96, ../sass/lightbox.sass */ .lb-dataContainer { - margin: 0 auto; - padding-top: 5px; - *zoom: 1; - width: 100%; - -moz-border-radius-bottomleft: 4px; - -webkit-border-bottom-left-radius: 4px; - border-bottom-left-radius: 4px; - -moz-border-radius-bottomright: 4px; - -webkit-border-bottom-right-radius: 4px; - border-bottom-right-radius: 4px; + margin: 0 auto; + padding-top: 5px; + *zoom: 1; + width: 100%; + -moz-border-radius-bottomleft: 4px; + -webkit-border-bottom-left-radius: 4px; + border-bottom-left-radius: 4px; + -moz-border-radius-bottomright: 4px; + -webkit-border-bottom-right-radius: 4px; + border-bottom-right-radius: 4px; } + /* line 38, ../../../../.rvm/gems/ruby-1.9.3-p392/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.scss */ .lb-dataContainer:after { - content: ""; - display: table; - clear: both; + content: ""; + display: table; + clear: both; } /* line 103, ../sass/lightbox.sass */ .lb-data { - padding: 0 4px; - color: #bbbbbb; + padding: 0 4px; + color: #bbbbbb; } + /* line 106, ../sass/lightbox.sass */ .lb-data .lb-details { - width: 85%; - float: left; - text-align: left; - line-height: 1.1em; + width: 85%; + float: left; + text-align: left; + line-height: 1.1em; } + /* line 111, ../sass/lightbox.sass */ .lb-data .lb-caption { - font-size: 13px; - font-weight: bold; - line-height: 1em; + font-size: 13px; + font-weight: bold; + line-height: 1em; } + /* line 115, ../sass/lightbox.sass */ .lb-data .lb-number { - display: block; - clear: left; - padding-bottom: 1em; - font-size: 12px; - color: #999999; + display: block; + clear: left; + padding-bottom: 1em; + font-size: 12px; + color: #999999; } + /* line 121, ../sass/lightbox.sass */ .lb-data .lb-close { - display: block; - float: right; - width: 30px; - height: 30px; - background: url(../img/close.png) top right no-repeat; - text-align: right; - outline: none; - filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=70); - opacity: 0.7; + display: block; + float: right; + width: 30px; + height: 30px; + background: url(../img/close.png) top right no-repeat; + text-align: right; + outline: none; + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=70); + opacity: 0.7; } + /* line 130, ../sass/lightbox.sass */ .lb-data .lb-close:hover { - cursor: pointer; - filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100); - opacity: 1; + cursor: pointer; + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100); + opacity: 1; } /* fix image preview */ .lb-image { - max-width: inherit!important; + max-width: inherit !important; } \ No newline at end of file diff --git a/system/plugins/lightbox/js/lightbox-2.6.min.js b/system/plugins/lightbox/js/lightbox-2.6.min.js index fe7360a..8be4135 100644 --- a/system/plugins/lightbox/js/lightbox-2.6.min.js +++ b/system/plugins/lightbox/js/lightbox-2.6.min.js @@ -1 +1,267 @@ -(function(){var b,d,c;b=jQuery;c=(function(){function b(){this.fadeDuration=500;this.fitImagesInViewport=true;this.resizeDuration=700;this.showImageNumberLabel=true;this.wrapAround=false}b.prototype.albumLabel=function(b,c){return"Image "+b+" of "+c};return b})();d=(function(){function c(b){this.options=b;this.album=[];this.currentImageIndex=void 0;this.init()}c.prototype.init=function(){this.enable();return this.build()};c.prototype.enable=function(){var c=this;return b('body').on('click','a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]',function(d){c.start(b(d.currentTarget));return false})};c.prototype.build=function(){var c=this;b("
    ").appendTo(b('body'));this.$lightbox=b('#lightbox');this.$overlay=b('#lightboxOverlay');this.$outerContainer=this.$lightbox.find('.lb-outerContainer');this.$container=this.$lightbox.find('.lb-container');this.containerTopPadding=parseInt(this.$container.css('padding-top'),10);this.containerRightPadding=parseInt(this.$container.css('padding-right'),10);this.containerBottomPadding=parseInt(this.$container.css('padding-bottom'),10);this.containerLeftPadding=parseInt(this.$container.css('padding-left'),10);this.$overlay.hide().on('click',function(){c.end();return false});this.$lightbox.hide().on('click',function(d){if(b(d.target).attr('id')==='lightbox'){c.end()}return false});this.$outerContainer.on('click',function(d){if(b(d.target).attr('id')==='lightbox'){c.end()}return false});this.$lightbox.find('.lb-prev').on('click',function(){if(c.currentImageIndex===0){c.changeImage(c.album.length-1)}else{c.changeImage(c.currentImageIndex-1)}return false});this.$lightbox.find('.lb-next').on('click',function(){if(c.currentImageIndex===c.album.length-1){c.changeImage(0)}else{c.changeImage(c.currentImageIndex+1)}return false});return this.$lightbox.find('.lb-loader, .lb-close').on('click',function(){c.end();return false})};c.prototype.start=function(c){var f,e,j,d,g,n,o,k,l,m,p,h,i;b(window).on("resize",this.sizeOverlay);b('select, object, embed').css({visibility:"hidden"});this.$overlay.width(b(document).width()).height(b(document).height()).fadeIn(this.options.fadeDuration);this.album=[];g=0;j=c.attr('data-lightbox');if(j){h=b(c.prop("tagName")+'[data-lightbox="'+j+'"]');for(d=k=0,m=h.length;kj)||(c.height>i)){if((c.width/j)>(c.height/i)){h=j;g=parseInt(c.height/(c.width/h),10);d.width(h);d.height(g)}else{g=i;h=parseInt(c.width/(c.height/g),10);d.width(h);d.height(g)}}}return e.sizeContainer(d.width(),d.height())};c.src=this.album[f].link;this.currentImageIndex=f};c.prototype.sizeOverlay=function(){return b('#lightboxOverlay').width(b(document).width()).height(b(document).height())};c.prototype.sizeContainer=function(f,g){var b,d,e,h,c=this;h=this.$outerContainer.outerWidth();e=this.$outerContainer.outerHeight();d=f+this.containerLeftPadding+this.containerRightPadding;b=g+this.containerTopPadding+this.containerBottomPadding;this.$outerContainer.animate({width:d,height:b},this.options.resizeDuration,'swing');setTimeout(function(){c.$lightbox.find('.lb-dataContainer').width(d);c.$lightbox.find('.lb-prevLink').height(b);c.$lightbox.find('.lb-nextLink').height(b);c.showImage()},this.options.resizeDuration)};c.prototype.showImage=function(){this.$lightbox.find('.lb-loader').hide();this.$lightbox.find('.lb-image').fadeIn('slow');this.updateNav();this.updateDetails();this.preloadNeighboringImages();this.enableKeyboardNav()};c.prototype.updateNav=function(){this.$lightbox.find('.lb-nav').show();if(this.album.length>1){if(this.options.wrapAround){this.$lightbox.find('.lb-prev, .lb-next').show()}else{if(this.currentImageIndex>0){this.$lightbox.find('.lb-prev').show()}if(this.currentImageIndex1&&this.options.showImageNumberLabel){this.$lightbox.find('.lb-number').text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn('fast')}else{this.$lightbox.find('.lb-number').hide()}this.$outerContainer.removeClass('animating');this.$lightbox.find('.lb-dataContainer').fadeIn(this.resizeDuration,function(){return b.sizeOverlay()})};c.prototype.preloadNeighboringImages=function(){var c,b;if(this.album.length>this.currentImageIndex+1){c=new Image();c.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){b=new Image();b.src=this.album[this.currentImageIndex-1].link}};c.prototype.enableKeyboardNav=function(){b(document).on('keyup.keyboard',b.proxy(this.keyboardAction,this))};c.prototype.disableKeyboardNav=function(){b(document).off('.keyboard')};c.prototype.keyboardAction=function(g){var d,e,f,c,b;d=27;e=37;f=39;b=g.keyCode;c=String.fromCharCode(b).toLowerCase();if(b===d||c.match(/x|o|c/)){this.end()}else if(c==='p'||b===e){if(this.currentImageIndex!==0){this.changeImage(this.currentImageIndex-1)}}else if(c==='n'||b===f){if(this.currentImageIndex!==this.album.length-1){this.changeImage(this.currentImageIndex+1)}}};c.prototype.end=function(){this.disableKeyboardNav();b(window).off("resize",this.sizeOverlay);this.$lightbox.fadeOut(this.options.fadeDuration);this.$overlay.fadeOut(this.options.fadeDuration);return b('select, object, embed').css({visibility:"visible"})};return c})();b(function(){var e,b;b=new c();return e=new d(b)})}).call(this); \ No newline at end of file +(function () { + var b, d, c; + b = jQuery; + c = (function () { + function b() { + this.fadeDuration = 500; + this.fitImagesInViewport = true; + this.resizeDuration = 700; + this.showImageNumberLabel = true; + this.wrapAround = false + } + + b.prototype.albumLabel = function (b, c) { + return "Image " + b + " of " + c + }; + return b + })(); + d = (function () { + function c(b) { + this.options = b; + this.album = []; + this.currentImageIndex = void 0; + this.init() + } + + c.prototype.init = function () { + this.enable(); + return this.build() + }; + c.prototype.enable = function () { + var c = this; + return b('body').on('click', 'a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]', function (d) { + c.start(b(d.currentTarget)); + return false + }) + }; + c.prototype.build = function () { + var c = this; + b("
    ").appendTo(b('body')); + this.$lightbox = b('#lightbox'); + this.$overlay = b('#lightboxOverlay'); + this.$outerContainer = this.$lightbox.find('.lb-outerContainer'); + this.$container = this.$lightbox.find('.lb-container'); + this.containerTopPadding = parseInt(this.$container.css('padding-top'), 10); + this.containerRightPadding = parseInt(this.$container.css('padding-right'), 10); + this.containerBottomPadding = parseInt(this.$container.css('padding-bottom'), 10); + this.containerLeftPadding = parseInt(this.$container.css('padding-left'), 10); + this.$overlay.hide().on('click', function () { + c.end(); + return false + }); + this.$lightbox.hide().on('click', function (d) { + if (b(d.target).attr('id') === 'lightbox') { + c.end() + } + return false + }); + this.$outerContainer.on('click', function (d) { + if (b(d.target).attr('id') === 'lightbox') { + c.end() + } + return false + }); + this.$lightbox.find('.lb-prev').on('click', function () { + if (c.currentImageIndex === 0) { + c.changeImage(c.album.length - 1) + } else { + c.changeImage(c.currentImageIndex - 1) + } + return false + }); + this.$lightbox.find('.lb-next').on('click', function () { + if (c.currentImageIndex === c.album.length - 1) { + c.changeImage(0) + } else { + c.changeImage(c.currentImageIndex + 1) + } + return false + }); + return this.$lightbox.find('.lb-loader, .lb-close').on('click', function () { + c.end(); + return false + }) + }; + c.prototype.start = function (c) { + var f, e, j, d, g, n, o, k, l, m, p, h, i; + b(window).on("resize", this.sizeOverlay); + b('select, object, embed').css({visibility: "hidden"}); + this.$overlay.width(b(document).width()).height(b(document).height()).fadeIn(this.options.fadeDuration); + this.album = []; + g = 0; + j = c.attr('data-lightbox'); + if (j) { + h = b(c.prop("tagName") + '[data-lightbox="' + j + '"]'); + for (d = k = 0, m = h.length; k < m; d = ++k) { + e = h[d]; + this.album.push({link: b(e).attr('href'), title: b(e).attr('title')}); + if (b(e).attr('href') === c.attr('href')) { + g = d + } + } + } else { + if (c.attr('rel') === 'lightbox') { + this.album.push({link: c.attr('href'), title: c.attr('title')}) + } else { + i = b(c.prop("tagName") + '[rel="' + c.attr('rel') + '"]'); + for (d = l = 0, p = i.length; l < p; d = ++l) { + e = i[d]; + this.album.push({link: b(e).attr('href'), title: b(e).attr('title')}); + if (b(e).attr('href') === c.attr('href')) { + g = d + } + } + } + } + f = b(window); + o = f.scrollTop() + f.height() / 10; + n = f.scrollLeft(); + this.$lightbox.css({top: o + 'px', left: n + 'px'}).fadeIn(this.options.fadeDuration); + this.changeImage(g) + }; + c.prototype.changeImage = function (f) { + var d, c, e = this; + this.disableKeyboardNav(); + d = this.$lightbox.find('.lb-image'); + this.sizeOverlay(); + this.$overlay.fadeIn(this.options.fadeDuration); + b('.lb-loader').fadeIn('slow'); + this.$lightbox.find('.lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption').hide(); + this.$outerContainer.addClass('animating'); + c = new Image(); + c.onload = function () { + var m, g, h, i, j, k, l; + d.attr('src', e.album[f].link); + m = b(c); + d.width(c.width); + d.height(c.height); + if (e.options.fitImagesInViewport) { + l = b(window).width(); + k = b(window).height(); + j = l - e.containerLeftPadding - e.containerRightPadding - 20; + i = k - e.containerTopPadding - e.containerBottomPadding - 110; + if ((c.width > j) || (c.height > i)) { + if ((c.width / j) > (c.height / i)) { + h = j; + g = parseInt(c.height / (c.width / h), 10); + d.width(h); + d.height(g) + } else { + g = i; + h = parseInt(c.width / (c.height / g), 10); + d.width(h); + d.height(g) + } + } + } + return e.sizeContainer(d.width(), d.height()) + }; + c.src = this.album[f].link; + this.currentImageIndex = f + }; + c.prototype.sizeOverlay = function () { + return b('#lightboxOverlay').width(b(document).width()).height(b(document).height()) + }; + c.prototype.sizeContainer = function (f, g) { + var b, d, e, h, c = this; + h = this.$outerContainer.outerWidth(); + e = this.$outerContainer.outerHeight(); + d = f + this.containerLeftPadding + this.containerRightPadding; + b = g + this.containerTopPadding + this.containerBottomPadding; + this.$outerContainer.animate({width: d, height: b}, this.options.resizeDuration, 'swing'); + setTimeout(function () { + c.$lightbox.find('.lb-dataContainer').width(d); + c.$lightbox.find('.lb-prevLink').height(b); + c.$lightbox.find('.lb-nextLink').height(b); + c.showImage() + }, this.options.resizeDuration) + }; + c.prototype.showImage = function () { + this.$lightbox.find('.lb-loader').hide(); + this.$lightbox.find('.lb-image').fadeIn('slow'); + this.updateNav(); + this.updateDetails(); + this.preloadNeighboringImages(); + this.enableKeyboardNav() + }; + c.prototype.updateNav = function () { + this.$lightbox.find('.lb-nav').show(); + if (this.album.length > 1) { + if (this.options.wrapAround) { + this.$lightbox.find('.lb-prev, .lb-next').show() + } else { + if (this.currentImageIndex > 0) { + this.$lightbox.find('.lb-prev').show() + } + if (this.currentImageIndex < this.album.length - 1) { + this.$lightbox.find('.lb-next').show() + } + } + } + }; + c.prototype.updateDetails = function () { + var b = this; + if (typeof this.album[this.currentImageIndex].title !== 'undefined' && this.album[this.currentImageIndex].title !== "") { + this.$lightbox.find('.lb-caption').html(this.album[this.currentImageIndex].title).fadeIn('fast') + } + if (this.album.length > 1 && this.options.showImageNumberLabel) { + this.$lightbox.find('.lb-number').text(this.options.albumLabel(this.currentImageIndex + 1, this.album.length)).fadeIn('fast') + } else { + this.$lightbox.find('.lb-number').hide() + } + this.$outerContainer.removeClass('animating'); + this.$lightbox.find('.lb-dataContainer').fadeIn(this.resizeDuration, function () { + return b.sizeOverlay() + }) + }; + c.prototype.preloadNeighboringImages = function () { + var c, b; + if (this.album.length > this.currentImageIndex + 1) { + c = new Image(); + c.src = this.album[this.currentImageIndex + 1].link + } + if (this.currentImageIndex > 0) { + b = new Image(); + b.src = this.album[this.currentImageIndex - 1].link + } + }; + c.prototype.enableKeyboardNav = function () { + b(document).on('keyup.keyboard', b.proxy(this.keyboardAction, this)) + }; + c.prototype.disableKeyboardNav = function () { + b(document).off('.keyboard') + }; + c.prototype.keyboardAction = function (g) { + var d, e, f, c, b; + d = 27; + e = 37; + f = 39; + b = g.keyCode; + c = String.fromCharCode(b).toLowerCase(); + if (b === d || c.match(/x|o|c/)) { + this.end() + } else if (c === 'p' || b === e) { + if (this.currentImageIndex !== 0) { + this.changeImage(this.currentImageIndex - 1) + } + } else if (c === 'n' || b === f) { + if (this.currentImageIndex !== this.album.length - 1) { + this.changeImage(this.currentImageIndex + 1) + } + } + }; + c.prototype.end = function () { + this.disableKeyboardNav(); + b(window).off("resize", this.sizeOverlay); + this.$lightbox.fadeOut(this.options.fadeDuration); + this.$overlay.fadeOut(this.options.fadeDuration); + return b('select, object, embed').css({visibility: "visible"}) + }; + return c + })(); + b(function () { + var e, b; + b = new c(); + return e = new d(b) + }) +}).call(this); \ No newline at end of file diff --git a/system/resources/htmly.js b/system/resources/htmly.js index d1d8c6a..f17c066 100644 --- a/system/resources/htmly.js +++ b/system/resources/htmly.js @@ -1,10 +1,10 @@ (function ($) { - $(document).ready(function() { - $('.teaser-body img, .post-body img').each(function() { - var currentImage = $(this); - currentImage.wrap(""); - }); - }); + $(document).ready(function () { + $('.teaser-body img, .post-body img').each(function () { + var currentImage = $(this); + currentImage.wrap(""); + }); + }); })(jQuery); diff --git a/system/vendor/autoload.php b/system/vendor/autoload.php index 2677d4a..8f05b25 100644 --- a/system/vendor/autoload.php +++ b/system/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1::getLoader(); +return ComposerAutoloaderInitf198a7e8b1b11fe318ca9933d34f115b::getLoader(); diff --git a/system/vendor/composer/autoload_classmap.php b/system/vendor/composer/autoload_classmap.php index 71dd9c1..21cdb84 100644 --- a/system/vendor/composer/autoload_classmap.php +++ b/system/vendor/composer/autoload_classmap.php @@ -6,4 +6,17 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname(dirname($vendorDir)); return array( + 'Kanti\\CacheOneFile' => $vendorDir . '/kanti/hub-updater/src/CacheOneFile.php', + 'Kanti\\HelperClass' => $vendorDir . '/kanti/hub-updater/src/HelperClass.php', + 'Kanti\\HubUpdater' => $vendorDir . '/kanti/hub-updater/src/HubUpdater.php', + 'Michelf\\Markdown' => $vendorDir . '/michelf/php-markdown/Michelf/Markdown.php', + 'Michelf\\MarkdownExtra' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownExtra.php', + 'Michelf\\MarkdownInterface' => $vendorDir . '/michelf/php-markdown/Michelf/MarkdownInterface.php', + 'Suin\\RSSWriter\\Channel' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/Channel.php', + 'Suin\\RSSWriter\\ChannelInterface' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/ChannelInterface.php', + 'Suin\\RSSWriter\\Feed' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/Feed.php', + 'Suin\\RSSWriter\\FeedInterface' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/FeedInterface.php', + 'Suin\\RSSWriter\\Item' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/Item.php', + 'Suin\\RSSWriter\\ItemInterface' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/ItemInterface.php', + 'Suin\\RSSWriter\\SimpleXMLElement' => $vendorDir . '/suin/php-rss-writer/Source/Suin/RSSWriter/SimpleXMLElement.php', ); diff --git a/system/vendor/composer/autoload_psr4.php b/system/vendor/composer/autoload_psr4.php index 3f2650b..7e43120 100644 --- a/system/vendor/composer/autoload_psr4.php +++ b/system/vendor/composer/autoload_psr4.php @@ -6,5 +6,5 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname(dirname($vendorDir)); return array( - 'Kanti\\' => array($vendorDir . '/kanti/hub-updater'), + 'Kanti\\' => array($vendorDir . '/kanti/hub-updater/src'), ); diff --git a/system/vendor/composer/autoload_real.php b/system/vendor/composer/autoload_real.php index 7593687..7cff397 100644 --- a/system/vendor/composer/autoload_real.php +++ b/system/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1 +class ComposerAutoloaderInitf198a7e8b1b11fe318ca9933d34f115b { private static $loader; @@ -19,9 +19,9 @@ class ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitf198a7e8b1b11fe318ca9933d34f115b', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitf198a7e8b1b11fe318ca9933d34f115b', 'loadClassLoader')); $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -42,14 +42,14 @@ class ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1 $includeFiles = require __DIR__ . '/autoload_files.php'; foreach ($includeFiles as $file) { - composerRequire202d771b98d07410d9e52c5a90cbc9e1($file); + composerRequiref198a7e8b1b11fe318ca9933d34f115b($file); } return $loader; } } -function composerRequire202d771b98d07410d9e52c5a90cbc9e1($file) +function composerRequiref198a7e8b1b11fe318ca9933d34f115b($file) { require $file; } diff --git a/system/vendor/composer/installed.json b/system/vendor/composer/installed.json index b219f2f..f26e4e7 100644 --- a/system/vendor/composer/installed.json +++ b/system/vendor/composer/installed.json @@ -1,4 +1,57 @@ [ + { + "name": "michelf/php-markdown", + "version": "1.5.0", + "version_normalized": "1.5.0.0", + "source": { + "type": "git", + "url": "https://github.com/michelf/php-markdown.git", + "reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/michelf/php-markdown/zipball/e1aabe18173231ebcefc90e615565742fc1c7fd9", + "reference": "e1aabe18173231ebcefc90e615565742fc1c7fd9", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2015-03-01 12:03:08", + "type": "library", + "extra": { + "branch-alias": { + "dev-lib": "1.4.x-dev" + } + }, + "installation-source": "source", + "autoload": { + "psr-0": { + "Michelf": "" + } + }, + "notification-url": "http://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "John Gruber", + "homepage": "http://daringfireball.net/" + }, + { + "name": "Michel Fortin", + "email": "michel.fortin@michelf.ca", + "homepage": "https://michelf.ca/", + "role": "Developer" + } + ], + "description": "PHP Markdown", + "homepage": "https://michelf.ca/projects/php-markdown/", + "keywords": [ + "markdown" + ] + }, { "name": "suin/php-rss-writer", "version": "1.3", @@ -19,13 +72,13 @@ }, "time": "2014-03-12 06:05:28", "type": "library", - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-0": { "Suin\\RSSWriter": "Source" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], @@ -48,31 +101,34 @@ }, { "name": "kanti/hub-updater", - "version": "v0.3.1", - "version_normalized": "0.3.1.0", + "version": "v0.4", + "version_normalized": "0.4.0.0", "source": { "type": "git", "url": "https://github.com/Kanti/hub-updater.git", - "reference": "105bf291983b1323c5916092cc4e170bf987b00c" + "reference": "81dae71f2b3ccd0e3425579ac932a8c6b7b58c5d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Kanti/hub-updater/zipball/105bf291983b1323c5916092cc4e170bf987b00c", - "reference": "105bf291983b1323c5916092cc4e170bf987b00c", + "url": "https://api.github.com/repos/Kanti/hub-updater/zipball/81dae71f2b3ccd0e3425579ac932a8c6b7b58c5d", + "reference": "81dae71f2b3ccd0e3425579ac932a8c6b7b58c5d", "shasum": "" }, "require": { "php": ">=5.3.0" }, - "time": "2014-12-27 13:59:09", + "require-dev": { + "phpunit/phpunit": "~4.6@dev" + }, + "time": "2015-02-03 09:53:58", "type": "library", - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-4": { - "Kanti\\": "" + "Kanti\\": "src" } }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "GPL-2.0" ], @@ -86,59 +142,6 @@ ], "description": "Simple Github Updater for Web Projects" }, - { - "name": "michelf/php-markdown", - "version": "1.4.1", - "version_normalized": "1.4.1.0", - "source": { - "type": "git", - "url": "https://github.com/michelf/php-markdown.git", - "reference": "de9a19c7bf352d41cc99ed86c3c0ef17e87394b6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/michelf/php-markdown/zipball/de9a19c7bf352d41cc99ed86c3c0ef17e87394b6", - "reference": "de9a19c7bf352d41cc99ed86c3c0ef17e87394b6", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2014-05-05 02:43:50", - "type": "library", - "extra": { - "branch-alias": { - "dev-lib": "1.4.x-dev" - } - }, - "installation-source": "source", - "autoload": { - "psr-0": { - "Michelf": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Michel Fortin", - "email": "michel.fortin@michelf.ca", - "homepage": "http://michelf.ca/", - "role": "Developer" - }, - { - "name": "John Gruber", - "homepage": "http://daringfireball.net/" - } - ], - "description": "PHP Markdown", - "homepage": "http://michelf.ca/projects/php-markdown/", - "keywords": [ - "markdown" - ] - }, { "name": "ircmaxell/password-compat", "version": "v1.0.4", @@ -159,13 +162,13 @@ }, "time": "2014-11-20 16:49:30", "type": "library", - "installation-source": "dist", + "installation-source": "source", "autoload": { "files": [ "lib/password.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "notification-url": "http://packagist.org/downloads/", "license": [ "MIT" ], diff --git a/system/vendor/ircmaxell/password-compat/LICENSE.md b/system/vendor/ircmaxell/password-compat/LICENSE.md deleted file mode 100644 index 1efc565..0000000 --- a/system/vendor/ircmaxell/password-compat/LICENSE.md +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2012 Anthony Ferrara - -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 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. \ No newline at end of file diff --git a/system/vendor/ircmaxell/password-compat/composer.json b/system/vendor/ircmaxell/password-compat/composer.json deleted file mode 100644 index 822fd1f..0000000 --- a/system/vendor/ircmaxell/password-compat/composer.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "ircmaxell/password-compat", - "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", - "keywords": ["password", "hashing"], - "homepage": "https://github.com/ircmaxell/password_compat", - "license": "MIT", - "authors": [ - { - "name": "Anthony Ferrara", - "email": "ircmaxell@php.net", - "homepage": "http://blog.ircmaxell.com" - } - ], - "require-dev": { - "phpunit/phpunit": "4.*" - }, - "autoload": { - "files": ["lib/password.php"] - } -} diff --git a/system/vendor/ircmaxell/password-compat/lib/password.php b/system/vendor/ircmaxell/password-compat/lib/password.php deleted file mode 100644 index cc6896c..0000000 --- a/system/vendor/ircmaxell/password-compat/lib/password.php +++ /dev/null @@ -1,314 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @copyright 2012 The Authors - */ - -namespace { - - if (!defined('PASSWORD_BCRYPT')) { - /** - * PHPUnit Process isolation caches constants, but not function declarations. - * So we need to check if the constants are defined separately from - * the functions to enable supporting process isolation in userland - * code. - */ - define('PASSWORD_BCRYPT', 1); - define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); - define('PASSWORD_BCRYPT_DEFAULT_COST', 10); - } - - if (!function_exists('password_hash')) { - - /** - * Hash the password using the specified algorithm - * - * @param string $password The password to hash - * @param int $algo The algorithm to use (Defined by PASSWORD_* constants) - * @param array $options The options for the algorithm to use - * - * @return string|false The hashed password, or false on error. - */ - function password_hash($password, $algo, array $options = array()) { - if (!function_exists('crypt')) { - trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING); - return null; - } - if (is_null($password) || is_int($password)) { - $password = (string) $password; - } - if (!is_string($password)) { - trigger_error("password_hash(): Password must be a string", E_USER_WARNING); - return null; - } - if (!is_int($algo)) { - trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING); - return null; - } - $resultLength = 0; - switch ($algo) { - case PASSWORD_BCRYPT: - $cost = PASSWORD_BCRYPT_DEFAULT_COST; - if (isset($options['cost'])) { - $cost = $options['cost']; - if ($cost < 4 || $cost > 31) { - trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); - return null; - } - } - // The length of salt to generate - $raw_salt_len = 16; - // The length required in the final serialization - $required_salt_len = 22; - $hash_format = sprintf("$2y$%02d$", $cost); - // The expected length of the final crypt() output - $resultLength = 60; - break; - default: - trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); - return null; - } - $salt_requires_encoding = false; - if (isset($options['salt'])) { - switch (gettype($options['salt'])) { - case 'NULL': - case 'boolean': - case 'integer': - case 'double': - case 'string': - $salt = (string) $options['salt']; - break; - case 'object': - if (method_exists($options['salt'], '__tostring')) { - $salt = (string) $options['salt']; - break; - } - case 'array': - case 'resource': - default: - trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); - return null; - } - if (PasswordCompat\binary\_strlen($salt) < $required_salt_len) { - trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", PasswordCompat\binary\_strlen($salt), $required_salt_len), E_USER_WARNING); - return null; - } elseif (0 == preg_match('#^[a-zA-Z0-9./]+$#D', $salt)) { - $salt_requires_encoding = true; - } - } else { - $buffer = ''; - $buffer_valid = false; - if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { - $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM); - if ($buffer) { - $buffer_valid = true; - } - } - if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { - $buffer = openssl_random_pseudo_bytes($raw_salt_len); - if ($buffer) { - $buffer_valid = true; - } - } - if (!$buffer_valid && @is_readable('/dev/urandom')) { - $f = fopen('/dev/urandom', 'r'); - $read = PasswordCompat\binary\_strlen($buffer); - while ($read < $raw_salt_len) { - $buffer .= fread($f, $raw_salt_len - $read); - $read = PasswordCompat\binary\_strlen($buffer); - } - fclose($f); - if ($read >= $raw_salt_len) { - $buffer_valid = true; - } - } - if (!$buffer_valid || PasswordCompat\binary\_strlen($buffer) < $raw_salt_len) { - $bl = PasswordCompat\binary\_strlen($buffer); - for ($i = 0; $i < $raw_salt_len; $i++) { - if ($i < $bl) { - $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); - } else { - $buffer .= chr(mt_rand(0, 255)); - } - } - } - $salt = $buffer; - $salt_requires_encoding = true; - } - if ($salt_requires_encoding) { - // encode string with the Base64 variant used by crypt - $base64_digits = - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - $bcrypt64_digits = - './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - - $base64_string = base64_encode($salt); - $salt = strtr(rtrim($base64_string, '='), $base64_digits, $bcrypt64_digits); - } - $salt = PasswordCompat\binary\_substr($salt, 0, $required_salt_len); - - $hash = $hash_format . $salt; - - $ret = crypt($password, $hash); - - if (!is_string($ret) || PasswordCompat\binary\_strlen($ret) != $resultLength) { - return false; - } - - return $ret; - } - - /** - * Get information about the password hash. Returns an array of the information - * that was used to generate the password hash. - * - * array( - * 'algo' => 1, - * 'algoName' => 'bcrypt', - * 'options' => array( - * 'cost' => PASSWORD_BCRYPT_DEFAULT_COST, - * ), - * ) - * - * @param string $hash The password hash to extract info from - * - * @return array The array of information about the hash. - */ - function password_get_info($hash) { - $return = array( - 'algo' => 0, - 'algoName' => 'unknown', - 'options' => array(), - ); - if (PasswordCompat\binary\_substr($hash, 0, 4) == '$2y$' && PasswordCompat\binary\_strlen($hash) == 60) { - $return['algo'] = PASSWORD_BCRYPT; - $return['algoName'] = 'bcrypt'; - list($cost) = sscanf($hash, "$2y$%d$"); - $return['options']['cost'] = $cost; - } - return $return; - } - - /** - * Determine if the password hash needs to be rehashed according to the options provided - * - * If the answer is true, after validating the password using password_verify, rehash it. - * - * @param string $hash The hash to test - * @param int $algo The algorithm used for new password hashes - * @param array $options The options array passed to password_hash - * - * @return boolean True if the password needs to be rehashed. - */ - function password_needs_rehash($hash, $algo, array $options = array()) { - $info = password_get_info($hash); - if ($info['algo'] != $algo) { - return true; - } - switch ($algo) { - case PASSWORD_BCRYPT: - $cost = isset($options['cost']) ? $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST; - if ($cost != $info['options']['cost']) { - return true; - } - break; - } - return false; - } - - /** - * Verify a password against a hash using a timing attack resistant approach - * - * @param string $password The password to verify - * @param string $hash The hash to verify against - * - * @return boolean If the password matches the hash - */ - function password_verify($password, $hash) { - if (!function_exists('crypt')) { - trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING); - return false; - } - $ret = crypt($password, $hash); - if (!is_string($ret) || PasswordCompat\binary\_strlen($ret) != PasswordCompat\binary\_strlen($hash) || PasswordCompat\binary\_strlen($ret) <= 13) { - return false; - } - - $status = 0; - for ($i = 0; $i < PasswordCompat\binary\_strlen($ret); $i++) { - $status |= (ord($ret[$i]) ^ ord($hash[$i])); - } - - return $status === 0; - } - } - -} - -namespace PasswordCompat\binary { - - if (!function_exists('PasswordCompat\\binary\\_strlen')) { - - /** - * Count the number of bytes in a string - * - * We cannot simply use strlen() for this, because it might be overwritten by the mbstring extension. - * In this case, strlen() will count the number of *characters* based on the internal encoding. A - * sequence of bytes might be regarded as a single multibyte character. - * - * @param string $binary_string The input string - * - * @internal - * @return int The number of bytes - */ - function _strlen($binary_string) { - if (function_exists('mb_strlen')) { - return mb_strlen($binary_string, '8bit'); - } - return strlen($binary_string); - } - - /** - * Get a substring based on byte limits - * - * @see _strlen() - * - * @param string $binary_string The input string - * @param int $start - * @param int $length - * - * @internal - * @return string The substring - */ - function _substr($binary_string, $start, $length) { - if (function_exists('mb_substr')) { - return mb_substr($binary_string, $start, $length, '8bit'); - } - return substr($binary_string, $start, $length); - } - - /** - * Check if current PHP version is compatible with the library - * - * @return boolean the check result - */ - function check() { - static $pass = NULL; - - if (is_null($pass)) { - if (function_exists('crypt')) { - $hash = '$2y$04$usesomesillystringfore7hnbRJHxXVLeakoG8K30oukPsA.ztMG'; - $test = crypt("password", $hash); - $pass = $test == $hash; - } else { - $pass = false; - } - } - return $pass; - } - - } -} \ No newline at end of file diff --git a/system/vendor/ircmaxell/password-compat/version-test.php b/system/vendor/ircmaxell/password-compat/version-test.php deleted file mode 100644 index 96f60ca..0000000 --- a/system/vendor/ircmaxell/password-compat/version-test.php +++ /dev/null @@ -1,6 +0,0 @@ -fileName = $fileName; - $this->holdTime = $holdTime; - } - - public function is() - { - if (! HelperClass::fileExists($this->fileName)) { - return false; - } - if (filemtime($this->fileName) < ( time() - $this->holdTime )) { - unlink($this->fileName); - - return false; - } - - return true; - } - - public function get() - { - return file_get_contents($this->fileName); - } - - public function set($content) - { - file_put_contents($this->fileName, $content); - } -} diff --git a/system/vendor/kanti/hub-updater/HelperClass.php b/system/vendor/kanti/hub-updater/HelperClass.php deleted file mode 100644 index f55e12c..0000000 --- a/system/vendor/kanti/hub-updater/HelperClass.php +++ /dev/null @@ -1,12 +0,0 @@ -update(); +``` + +## how to provide an update? + +- Go to your Repository on github.com ‣‣ +- click on the ``releases`` tab ‣‣ +- click on ``Draft a new release`` ‣‣ +- Enter your release details ‣‣ +- click on ``Publish release`` ‣‣ +- now you can use HubUpdater to update to the newest version. +- _note: The timestamp of the release is used. NOT the version number!!_ + + +## install via composer + +The recommended way to install hub-updater is through +[Composer](http://getcomposer.org). + +```bash +# Install Composer +curl -sS https://getcomposer.org/installer | php +``` + +Next, run the Composer command to install the latest stable version of HubUpdater: + +```bash +composer require kanti/hub-updater ~0.3 +``` + +After installing, you need to require Composer's autoloader: + +```php + 'value', +); +new \Kanti\HubUpdater($settings); +``` +|setting|description|default| +|---|---|---| +|name|the name your Repository has |**must be set**| +|branch|the branch you like to watch. |``master``| +|cache|the directory you like to put the cache stuff |``./cache/``| +|save|the directory you like to put the content of the zip |``./``| +|prerelease|would you like to download the prereleases? |``false``| +|cacheFile|name of the InformationCacheFile(in cacheDir)|``downloadInfo.json``| +|holdTime|time(seconds) the Cached-Information will be used|``43200``| +|versionFile|name of the InstalledVersionInformation is safed(in cacheDir)|``installedVersion.json``| +|zipFile|name of the temporary zip file(in cacheDir)|``tmpZipFile.zip``| +|updateignore|name of the updateignore file(in root of project)|``.updateignore``| +|exceptions|if true, will ``throw new \Exception`` on failure|``false``| + +## Check for an update [complete] +```php + "downloadInfo.json",//name of the InformationCacheFile(in cacheDir) + "holdTime" => 43200,//time(seconds) the Cached-Information will be used + + "versionFile" => "installedVersion.json",//name of the InstalledVersionInformation is safed(in cacheDir) + "zipFile" => "tmpZipFile.zip",//name of the temporary zip file(in cacheDir) + "updateignore" => ".updateignore",//name of the updateignore file(in root of project) + + "name" => 'kanti/test',//Repository to watch + "branch" => 'master',//wich branch to watch + "cache" => 'cache/',//were to put the caching stuff + "save" => 'save/',//there to put the downloaded Version[default ./] + "prerelease" => true,//accept prereleases? + + "exceptions" => true,//if true, will throw new \Exception on failure +)); +if ($updater->able()) { + if (isset($_GET['update'])) { + $updater->update(); + echo '

    updated :)

    '; + } else { + echo 'Update Me'; //only update if they klick this link + } +} else { + echo '

    uptodate :)

    '; +} + +``` +## the .updateignore file +### syntax: +put a file in one line and it will not be updated. _note put the .updateignore in your projects root directory_ +``` +.htaccess +favicon.ico +there/the/config.ini/is.ini +``` + + +## Thanks: +- ca_bundle.crt form [bagder/ca-bundle](https://github.com/bagder/ca-bundle) diff --git a/system/vendor/kanti/hub-updater/composer.json b/system/vendor/kanti/hub-updater/composer.json index 6a915b5..9c30166 100644 --- a/system/vendor/kanti/hub-updater/composer.json +++ b/system/vendor/kanti/hub-updater/composer.json @@ -13,15 +13,23 @@ "support": { "forum": "https://github.com/Kanti/hub-updater/issues", "issues": "https://github.com/Kanti/hub-updater/issues", - "source": "https://github.com/Kanti/hub-updater" + "source": "https://github.com/Kanti/hub-updater" }, "minimum-stability": "dev", "require": { - "php": ">=5.3.0" - }, - "autoload": { - "psr-4": { - "Kanti\\": "" - } + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.6@dev" + }, + "autoload": { + "psr-4": { + "Kanti\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Kanti\\Test\\": "tests" + } } } diff --git a/system/vendor/kanti/hub-updater/composer.lock b/system/vendor/kanti/hub-updater/composer.lock new file mode 100644 index 0000000..0cb4142 --- /dev/null +++ b/system/vendor/kanti/hub-updater/composer.lock @@ -0,0 +1,974 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "b8e4efa9ea29bd0bab50ed2191d4b9cb", + "packages": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "3d9669e597439e8d205baf315efb757038fb4dea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/3d9669e597439e8d205baf315efb757038fb4dea", + "reference": "3d9669e597439e8d205baf315efb757038fb4dea", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-01-16 19:29:51" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "fd0ac2007401505fb596fdfb859ec4e103d69e55" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/fd0ac2007401505fb596fdfb859ec4e103d69e55", + "reference": "fd0ac2007401505fb596fdfb859ec4e103d69e55", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2014-09-02 14:26:20" + }, + { + "name": "phpspec/prophecy", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "d647e27524f9f7edc37baf63a114b52f5975808f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/d647e27524f9f7edc37baf63a114b52f5975808f", + "reference": "d647e27524f9f7edc37baf63a114b52f5975808f", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2015-01-26 10:50:16" + }, + { + "name": "phpunit/php-code-coverage", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "34cc484af1ca149188d0d9e91412191e398e0b67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/34cc484af1ca149188d0d9e91412191e398e0b67", + "reference": "34cc484af1ca149188d0d9e91412191e398e0b67", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-01-24 10:06:35" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2013-10-10 15:34:57" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/db32c18eba00b121c145575fcbcd4d4d24e6db74", + "reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-01-17 09:51:32" + }, + { + "name": "phpunit/phpunit", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "e85198bbce24ea11075ce8bdfc2cfffb818aae8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e85198bbce24ea11075ce8bdfc2cfffb818aae8c", + "reference": "e85198bbce24ea11075ce8bdfc2cfffb818aae8c", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "~1.3.1", + "phpunit/php-code-coverage": "~2.0", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.1", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.2", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.1|~3.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.6.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2015-01-27 07:32:25" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "b752b41e3fead4feee99f3a2f2972cef517abb8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/b752b41e3fead4feee99f3a2f2972cef517abb8b", + "reference": "b752b41e3fead4feee99f3a2f2972cef517abb8b", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "4.4.*@dev" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-01-18 10:44:19" + }, + { + "name": "sebastian/comparator", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "6a1e846331bb3cc1a305168125d047fb86260e3d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/6a1e846331bb3cc1a305168125d047fb86260e3d", + "reference": "6a1e846331bb3cc1a305168125d047fb86260e3d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.1", + "sebastian/exporter": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-01-05 16:29:00" + }, + { + "name": "sebastian/diff", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "6dc90302a4cdf8486c221a0ad3a4da53859fcfa5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/6dc90302a4cdf8486c221a0ad3a4da53859fcfa5", + "reference": "6dc90302a4cdf8486c221a0ad3a4da53859fcfa5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-01-01 09:20:29" + }, + { + "name": "sebastian/environment", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5a8c7d31914337b69923db26c4221b81ff5a196e", + "reference": "5a8c7d31914337b69923db26c4221b81ff5a196e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2015-01-01 10:01:08" + }, + { + "name": "sebastian/exporter", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "84839970d05254c73cde183a721c7af13aede943" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", + "reference": "84839970d05254c73cde183a721c7af13aede943", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-01-27 07:23:06" + }, + { + "name": "sebastian/global-state", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "007c441df427cf0e175372fcbb9d196bce7eb743" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/007c441df427cf0e175372fcbb9d196bce7eb743", + "reference": "007c441df427cf0e175372fcbb9d196bce7eb743", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2015-01-20 04:09:31" + }, + { + "name": "sebastian/recursion-context", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-01-24 09:48:32" + }, + { + "name": "sebastian/version", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "a77d9123f8e809db3fbdea15038c27a95da4058b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/a77d9123f8e809db3fbdea15038c27a95da4058b", + "reference": "a77d9123f8e809db3fbdea15038c27a95da4058b", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2014-12-15 14:25:24" + }, + { + "name": "symfony/yaml", + "version": "dev-master", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "13ef40ee1437582f86fa805445363d0c694dae3a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/13ef40ee1437582f86fa805445363d0c694dae3a", + "reference": "13ef40ee1437582f86fa805445363d0c694dae3a", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com", + "time": "2015-01-25 04:42:01" + } + ], + "aliases": [], + "minimum-stability": "dev", + "stability-flags": { + "phpunit/phpunit": 20 + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.3.0" + }, + "platform-dev": [] +} diff --git a/system/vendor/kanti/hub-updater/example.php b/system/vendor/kanti/hub-updater/example.php new file mode 100644 index 0000000..a9fa297 --- /dev/null +++ b/system/vendor/kanti/hub-updater/example.php @@ -0,0 +1,5 @@ +update(); diff --git a/system/vendor/kanti/hub-updater/example2.php b/system/vendor/kanti/hub-updater/example2.php new file mode 100644 index 0000000..ab6d31c --- /dev/null +++ b/system/vendor/kanti/hub-updater/example2.php @@ -0,0 +1,29 @@ + "downloadInfo.json",//name of the InformationCacheFile(in cacheDir) + "holdTime" => 43200,//time(seconds) the Cached-Information will be used + + "versionFile" => "installedVersion.json",//name of the InstalledVersionInformation is safed(in cacheDir) + "zipFile" => "tmpZipFile.zip",//name of the temporary zip file(in cacheDir) + "updateignore" => ".updateignore",//name of the updateignore file(in root of project) + + "name" => 'kanti/test',//Repository to watch + "branch" => 'master',//wich branch to watch + "cache" => 'cache/',//were to put the caching stuff + "save" => 'save/',//there to put the downloaded Version[default ./] + "prerelease" => true,//accept prereleases? + + "exceptions" => true,//if true, will throw new \Exception on failure +)); +if ($updater->able()) { + if (isset($_GET['update'])) { + $updater->update(); + echo '

    updated :)

    '; + } else { + echo 'Update Me'; //only update if they klick this link + } +} else { + echo '

    uptodate :)

    '; +} diff --git a/system/vendor/kanti/hub-updater/src/CacheOneFile.php b/system/vendor/kanti/hub-updater/src/CacheOneFile.php new file mode 100644 index 0000000..5c0751f --- /dev/null +++ b/system/vendor/kanti/hub-updater/src/CacheOneFile.php @@ -0,0 +1,58 @@ +fileName = $fileName; + $this->holdTime = $holdTime; + } + + public function is() + { + if (!HelperClass::fileExists($this->fileName)) { + return false; + } + clearstatcache(); + + if (filemtime($this->fileName) < (time() - $this->holdTime)) { + unlink($this->fileName); + + return false; + } + + return true; + } + + protected function file_force_contents() + { + $args = func_get_args(); + $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $args[0]); + $parts = explode(DIRECTORY_SEPARATOR, $path); + array_pop($parts); + $directory = ''; + foreach ($parts as $part): + $check_path = $directory . $part; + if (is_dir($check_path . DIRECTORY_SEPARATOR) === FALSE) { + mkdir($check_path, 0755); + } + $directory = $check_path . DIRECTORY_SEPARATOR; + endforeach; + call_user_func_array('file_put_contents', $args); + } + + public function get() + { + return file_get_contents($this->fileName); + } + + public function set($content) + { + $this->file_force_contents($this->fileName, $content); + } +} diff --git a/system/vendor/kanti/hub-updater/src/HelperClass.php b/system/vendor/kanti/hub-updater/src/HelperClass.php new file mode 100644 index 0000000..04e5726 --- /dev/null +++ b/system/vendor/kanti/hub-updater/src/HelperClass.php @@ -0,0 +1,28 @@ + 3 && ctype_alpha($path[0]) && $path[1] == ':' && + ('\\' == $path[2] || '/' == $path[2]))); + } + + public static function fileExists($file) + { + if (is_bool($file) || is_array($file)) { + throw new \InvalidArgumentException; + } + if(strlen($file) >= 3 && static::isAbsolutePath($file)){ + return file_exists($file); + } + return file_exists(dirname($_SERVER["SCRIPT_FILENAME"]) . "/" . $file); + } + + static public function isInPhar() + { + return substr(__FILE__, 0, 7) === "phar://"; + } +} \ No newline at end of file diff --git a/system/vendor/kanti/hub-updater/HubUpdater.php b/system/vendor/kanti/hub-updater/src/HubUpdater.php similarity index 95% rename from system/vendor/kanti/hub-updater/HubUpdater.php rename to system/vendor/kanti/hub-updater/src/HubUpdater.php index 0e33e30..8ca819a 100644 --- a/system/vendor/kanti/hub-updater/HubUpdater.php +++ b/system/vendor/kanti/hub-updater/src/HubUpdater.php @@ -28,11 +28,14 @@ class HubUpdater { //options if (is_array($option)) { - if (!isset($option['name'])) { + if (!isset($option['name']) || empty($option['name'])) { throw new \Exception('No Name in Option Set'); } $this->options = $option + $this->options; } elseif (is_string($option)) { + if(empty($option)){ + throw new \Exception('No Name Set'); + } $this->options['name'] = $option; } else { throw new \Exception('No Option Set'); @@ -65,7 +68,8 @@ class HubUpdater $this->streamContext = stream_context_create( array( 'http' => array( - 'header' => "User-Agent: Awesome-Update-My-Self-" . $this->options['name'] . "\r\nAccept: application/vnd.github.v3+json\r\n", + 'header' => "User-Agent: Awesome-Update-My-Self-" . $this->options['name'] . "\r\n" + . "Accept: application/vnd.github.v3+json\r\n", ), 'ssl' => array( 'cafile' => $caBundleDir . '/ca_bundle.crt', @@ -288,6 +292,13 @@ class HubUpdater $this->newestInfo = $release; break; } + if (!isset($this->newestInfo)) { + if ($this->options["exceptions"]) { + throw new \Exception("no suitable release found"); + } else { + return array(); + } + } return $this->newestInfo; } } diff --git a/system/vendor/kanti/hub-updater/ca_bundle.crt b/system/vendor/kanti/hub-updater/src/ca_bundle.crt similarity index 100% rename from system/vendor/kanti/hub-updater/ca_bundle.crt rename to system/vendor/kanti/hub-updater/src/ca_bundle.crt diff --git a/system/vendor/kanti/hub-updater/tests/CacheOneFileTest.php b/system/vendor/kanti/hub-updater/tests/CacheOneFileTest.php new file mode 100644 index 0000000..0a868d7 --- /dev/null +++ b/system/vendor/kanti/hub-updater/tests/CacheOneFileTest.php @@ -0,0 +1,73 @@ +is()){ + $this->fail("is not set"); + } + + touch($fileName); + if(! $cache->is()){ + $this->fail("could not set"); + } + touch($fileName,0); + if($cache->is()){ + $this->fail("does not reset"); + } + } + + public function testGet(){ + $fileName = __DIR__ . "/asserts/testfile.txt"; + $time = 60*60;//1h + $cache = new CacheOneFile($fileName,$time); + + foreach ($this->validContent as $value) { + $cache->set($value); + if($cache->get() !== (string)$value){ + $this->fail("get set dosen't match for value{" . print_r($value,true) . "}"); + } + } + unlink($fileName); + foreach ($this->invalidContent as $value) { + $cache->set($value); + if($cache->get() === $value){ + $this->fail("get set does match for value{" . print_r($value,true) . "}"); + } + } + } +} + \ No newline at end of file diff --git a/system/vendor/kanti/hub-updater/tests/HelperClassTest.php b/system/vendor/kanti/hub-updater/tests/HelperClassTest.php new file mode 100644 index 0000000..7c00a16 --- /dev/null +++ b/system/vendor/kanti/hub-updater/tests/HelperClassTest.php @@ -0,0 +1,54 @@ +invalidFileNames as $value) { + try { + HelperClass::fileExists($value); + } catch (\InvalidArgumentException $e) { + // Good, we got an exception! + continue; + } + $this->fail('Expected exception not raised on value: "' . $value . '".'); + } + + foreach ($this->validFileNames as $value) { + HelperClass::fileExists($value); + } + } + + public function testIsInPhar(){ + if(HelperClass::isInPhar()){ + $this->fail("unit test is in phar?"); + } + } +} + \ No newline at end of file diff --git a/system/vendor/kanti/hub-updater/tests/asserts/testfile.txt b/system/vendor/kanti/hub-updater/tests/asserts/testfile.txt new file mode 100644 index 0000000..6b584e8 --- /dev/null +++ b/system/vendor/kanti/hub-updater/tests/asserts/testfile.txt @@ -0,0 +1 @@ +content \ No newline at end of file diff --git a/system/vendor/kanti/hub-updater/tests/bootstrap.php b/system/vendor/kanti/hub-updater/tests/bootstrap.php new file mode 100644 index 0000000..a8f3a11 --- /dev/null +++ b/system/vendor/kanti/hub-updater/tests/bootstrap.php @@ -0,0 +1,9 @@ + + + + + ./ + + + + + ../src/ + + + + + + + + + + diff --git a/system/vendor/michelf/php-markdown/License.md b/system/vendor/michelf/php-markdown/License.md deleted file mode 100644 index 8a5b854..0000000 --- a/system/vendor/michelf/php-markdown/License.md +++ /dev/null @@ -1,36 +0,0 @@ -PHP Markdown Lib -Copyright (c) 2004-2014 Michel Fortin - -All rights reserved. - -Based on Markdown -Copyright (c) 2003-2006 John Gruber - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -* Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -* Neither the name "Markdown" nor the names of its contributors may - be used to endorse or promote products derived from this software - without specific prior written permission. - -This software is provided by the copyright holders and contributors "as -is" and any express or implied warranties, including, but not limited -to, the implied warranties of merchantability and fitness for a -particular purpose are disclaimed. In no event shall the copyright owner -or contributors be liable for any direct, indirect, incidental, special, -exemplary, or consequential damages (including, but not limited to, -procurement of substitute goods or services; loss of use, data, or -profits; or business interruption) however caused and on any theory of -liability, whether in contract, strict liability, or tort (including -negligence or otherwise) arising in any way out of the use of this -software, even if advised of the possibility of such damage. diff --git a/system/vendor/michelf/php-markdown/Michelf/Markdown.inc.php b/system/vendor/michelf/php-markdown/Michelf/Markdown.inc.php deleted file mode 100644 index 8c28109..0000000 --- a/system/vendor/michelf/php-markdown/Michelf/Markdown.inc.php +++ /dev/null @@ -1,10 +0,0 @@ - -# -# Original Markdown -# Copyright (c) 2004-2006 John Gruber -# -# -namespace Michelf; - - -# -# Markdown Parser Class -# - -class Markdown implements MarkdownInterface { - - ### Version ### - - const MARKDOWNLIB_VERSION = "1.4.1"; - - ### Simple Function Interface ### - - public static function defaultTransform($text) { - # - # Initialize the parser and return the result of its transform method. - # This will work fine for derived classes too. - # - # Take parser class on which this function was called. - $parser_class = \get_called_class(); - - # try to take parser from the static parser list - static $parser_list; - $parser =& $parser_list[$parser_class]; - - # create the parser it not already set - if (!$parser) - $parser = new $parser_class; - - # Transform text using parser. - return $parser->transform($text); - } - - ### Configuration Variables ### - - # Change to ">" for HTML output. - public $empty_element_suffix = " />"; - public $tab_width = 4; - - # Change to `true` to disallow markup or entities. - public $no_markup = false; - public $no_entities = false; - - # Predefined urls and titles for reference links and images. - public $predef_urls = array(); - public $predef_titles = array(); - - - ### Parser Implementation ### - - # Regex to match balanced [brackets]. - # Needed to insert a maximum bracked depth while converting to PHP. - protected $nested_brackets_depth = 6; - protected $nested_brackets_re; - - protected $nested_url_parenthesis_depth = 4; - protected $nested_url_parenthesis_re; - - # Table of hash values for escaped characters: - protected $escape_chars = '\`*_{}[]()>#+-.!'; - protected $escape_chars_re; - - - public function __construct() { - # - # Constructor function. Initialize appropriate member variables. - # - $this->_initDetab(); - $this->prepareItalicsAndBold(); - - $this->nested_brackets_re = - str_repeat('(?>[^\[\]]+|\[', $this->nested_brackets_depth). - str_repeat('\])*', $this->nested_brackets_depth); - - $this->nested_url_parenthesis_re = - str_repeat('(?>[^()\s]+|\(', $this->nested_url_parenthesis_depth). - str_repeat('(?>\)))*', $this->nested_url_parenthesis_depth); - - $this->escape_chars_re = '['.preg_quote($this->escape_chars).']'; - - # Sort document, block, and span gamut in ascendent priority order. - asort($this->document_gamut); - asort($this->block_gamut); - asort($this->span_gamut); - } - - - # Internal hashes used during transformation. - protected $urls = array(); - protected $titles = array(); - protected $html_hashes = array(); - - # Status flag to avoid invalid nesting. - protected $in_anchor = false; - - - protected function setup() { - # - # Called before the transformation process starts to setup parser - # states. - # - # Clear global hashes. - $this->urls = $this->predef_urls; - $this->titles = $this->predef_titles; - $this->html_hashes = array(); - - $this->in_anchor = false; - } - - protected function teardown() { - # - # Called after the transformation process to clear any variable - # which may be taking up memory unnecessarly. - # - $this->urls = array(); - $this->titles = array(); - $this->html_hashes = array(); - } - - - public function transform($text) { - # - # Main function. Performs some preprocessing on the input text - # and pass it through the document gamut. - # - $this->setup(); - - # Remove UTF-8 BOM and marker character in input, if present. - $text = preg_replace('{^\xEF\xBB\xBF|\x1A}', '', $text); - - # Standardize line endings: - # DOS to Unix and Mac to Unix - $text = preg_replace('{\r\n?}', "\n", $text); - - # Make sure $text ends with a couple of newlines: - $text .= "\n\n"; - - # Convert all tabs to spaces. - $text = $this->detab($text); - - # Turn block-level HTML blocks into hash entries - $text = $this->hashHTMLBlocks($text); - - # Strip any lines consisting only of spaces and tabs. - # This makes subsequent regexen easier to write, because we can - # match consecutive blank lines with /\n+/ instead of something - # contorted like /[ ]*\n+/ . - $text = preg_replace('/^[ ]+$/m', '', $text); - - # Run document gamut methods. - foreach ($this->document_gamut as $method => $priority) { - $text = $this->$method($text); - } - - $this->teardown(); - - return $text . "\n"; - } - - protected $document_gamut = array( - # Strip link definitions, store in hashes. - "stripLinkDefinitions" => 20, - - "runBasicBlockGamut" => 30, - ); - - - protected function stripLinkDefinitions($text) { - # - # Strips link definitions from text, stores the URLs and titles in - # hash references. - # - $less_than_tab = $this->tab_width - 1; - - # Link defs are in the form: ^[id]: url "optional title" - $text = preg_replace_callback('{ - ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 - [ ]* - \n? # maybe *one* newline - [ ]* - (?: - <(.+?)> # url = $2 - | - (\S+?) # url = $3 - ) - [ ]* - \n? # maybe one newline - [ ]* - (?: - (?<=\s) # lookbehind for whitespace - ["(] - (.*?) # title = $4 - [")] - [ ]* - )? # title is optional - (?:\n+|\Z) - }xm', - array($this, '_stripLinkDefinitions_callback'), - $text); - return $text; - } - protected function _stripLinkDefinitions_callback($matches) { - $link_id = strtolower($matches[1]); - $url = $matches[2] == '' ? $matches[3] : $matches[2]; - $this->urls[$link_id] = $url; - $this->titles[$link_id] =& $matches[4]; - return ''; # String that will replace the block - } - - - protected function hashHTMLBlocks($text) { - if ($this->no_markup) return $text; - - $less_than_tab = $this->tab_width - 1; - - # Hashify HTML blocks: - # We only want to do this for block-level HTML tags, such as headers, - # lists, and tables. That's because we still want to wrap

    s around - # "paragraphs" that are wrapped in non-block-level tags, such as anchors, - # phrase emphasis, and spans. The list of tags we're looking for is - # hard-coded: - # - # * List "a" is made of tags which can be both inline or block-level. - # These will be treated block-level when the start tag is alone on - # its line, otherwise they're not matched here and will be taken as - # inline later. - # * List "b" is made of tags which are always block-level; - # - $block_tags_a_re = 'ins|del'; - $block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'. - 'script|noscript|style|form|fieldset|iframe|math|svg|'. - 'article|section|nav|aside|hgroup|header|footer|'. - 'figure'; - - # Regular expression for the content of a block tag. - $nested_tags_level = 4; - $attr = ' - (?> # optional tag attributes - \s # starts with whitespace - (?> - [^>"/]+ # text outside quotes - | - /+(?!>) # slash not followed by ">" - | - "[^"]*" # text inside double quotes (tolerate ">") - | - \'[^\']*\' # text inside single quotes (tolerate ">") - )* - )? - '; - $content = - str_repeat(' - (?> - [^<]+ # content without tag - | - <\2 # nested opening tag - '.$attr.' # attributes - (?> - /> - | - >', $nested_tags_level). # end of opening tag - '.*?'. # last level nested tag content - str_repeat(' - # closing nested tag - ) - | - <(?!/\2\s*> # other tags with a different name - ) - )*', - $nested_tags_level); - $content2 = str_replace('\2', '\3', $content); - - # First, look for nested blocks, e.g.: - #

    - #
    - # tags for inner block must be indented. - #
    - #
    - # - # The outermost tags must start at the left margin for this to match, and - # the inner nested divs must be indented. - # We need to do this before the next, more liberal match, because the next - # match will start at the first `
    ` and stop at the first `
    `. - $text = preg_replace_callback('{(?> - (?> - (?<=\n) # Starting on its own line - | # or - \A\n? # the at beginning of the doc - ) - ( # save in $1 - - # Match from `\n` to `\n`, handling nested tags - # in between. - - [ ]{0,'.$less_than_tab.'} - <('.$block_tags_b_re.')# start tag = $2 - '.$attr.'> # attributes followed by > and \n - '.$content.' # content, support nesting - # the matching end tag - [ ]* # trailing spaces/tabs - (?=\n+|\Z) # followed by a newline or end of document - - | # Special version for tags of group a. - - [ ]{0,'.$less_than_tab.'} - <('.$block_tags_a_re.')# start tag = $3 - '.$attr.'>[ ]*\n # attributes followed by > - '.$content2.' # content, support nesting - # the matching end tag - [ ]* # trailing spaces/tabs - (?=\n+|\Z) # followed by a newline or end of document - - | # Special case just for
    . It was easier to make a special - # case than to make the other regex more complicated. - - [ ]{0,'.$less_than_tab.'} - <(hr) # start tag = $2 - '.$attr.' # attributes - /?> # the matching end tag - [ ]* - (?=\n{2,}|\Z) # followed by a blank line or end of document - - | # Special case for standalone HTML comments: - - [ ]{0,'.$less_than_tab.'} - (?s: - - ) - [ ]* - (?=\n{2,}|\Z) # followed by a blank line or end of document - - | # PHP and ASP-style processor instructions ( - ) - [ ]* - (?=\n{2,}|\Z) # followed by a blank line or end of document - - ) - )}Sxmi', - array($this, '_hashHTMLBlocks_callback'), - $text); - - return $text; - } - protected function _hashHTMLBlocks_callback($matches) { - $text = $matches[1]; - $key = $this->hashBlock($text); - return "\n\n$key\n\n"; - } - - - protected function hashPart($text, $boundary = 'X') { - # - # Called whenever a tag must be hashed when a function insert an atomic - # element in the text stream. Passing $text to through this function gives - # a unique text-token which will be reverted back when calling unhash. - # - # The $boundary argument specify what character should be used to surround - # the token. By convension, "B" is used for block elements that needs not - # to be wrapped into paragraph tags at the end, ":" is used for elements - # that are word separators and "X" is used in the general case. - # - # Swap back any tag hash found in $text so we do not have to `unhash` - # multiple times at the end. - $text = $this->unhash($text); - - # Then hash the block. - static $i = 0; - $key = "$boundary\x1A" . ++$i . $boundary; - $this->html_hashes[$key] = $text; - return $key; # String that will replace the tag. - } - - - protected function hashBlock($text) { - # - # Shortcut function for hashPart with block-level boundaries. - # - return $this->hashPart($text, 'B'); - } - - - protected $block_gamut = array( - # - # These are all the transformations that form block-level - # tags like paragraphs, headers, and list items. - # - "doHeaders" => 10, - "doHorizontalRules" => 20, - - "doLists" => 40, - "doCodeBlocks" => 50, - "doBlockQuotes" => 60, - ); - - protected function runBlockGamut($text) { - # - # Run block gamut tranformations. - # - # We need to escape raw HTML in Markdown source before doing anything - # else. This need to be done for each block, and not only at the - # begining in the Markdown function since hashed blocks can be part of - # list items and could have been indented. Indented blocks would have - # been seen as a code block in a previous pass of hashHTMLBlocks. - $text = $this->hashHTMLBlocks($text); - - return $this->runBasicBlockGamut($text); - } - - protected function runBasicBlockGamut($text) { - # - # Run block gamut tranformations, without hashing HTML blocks. This is - # useful when HTML blocks are known to be already hashed, like in the first - # whole-document pass. - # - foreach ($this->block_gamut as $method => $priority) { - $text = $this->$method($text); - } - - # Finally form paragraph and restore hashed blocks. - $text = $this->formParagraphs($text); - - return $text; - } - - - protected function doHorizontalRules($text) { - # Do Horizontal Rules: - return preg_replace( - '{ - ^[ ]{0,3} # Leading space - ([-*_]) # $1: First marker - (?> # Repeated marker group - [ ]{0,2} # Zero, one, or two spaces. - \1 # Marker character - ){2,} # Group repeated at least twice - [ ]* # Tailing spaces - $ # End of line. - }mx', - "\n".$this->hashBlock("empty_element_suffix")."\n", - $text); - } - - - protected $span_gamut = array( - # - # These are all the transformations that occur *within* block-level - # tags like paragraphs, headers, and list items. - # - # Process character escapes, code spans, and inline HTML - # in one shot. - "parseSpan" => -30, - - # Process anchor and image tags. Images must come first, - # because ![foo][f] looks like an anchor. - "doImages" => 10, - "doAnchors" => 20, - - # Make links out of things like `` - # Must come after doAnchors, because you can use < and > - # delimiters in inline links like [this](). - "doAutoLinks" => 30, - "encodeAmpsAndAngles" => 40, - - "doItalicsAndBold" => 50, - "doHardBreaks" => 60, - ); - - protected function runSpanGamut($text) { - # - # Run span gamut tranformations. - # - foreach ($this->span_gamut as $method => $priority) { - $text = $this->$method($text); - } - - return $text; - } - - - protected function doHardBreaks($text) { - # Do hard breaks: - return preg_replace_callback('/ {2,}\n/', - array($this, '_doHardBreaks_callback'), $text); - } - protected function _doHardBreaks_callback($matches) { - return $this->hashPart("empty_element_suffix\n"); - } - - - protected function doAnchors($text) { - # - # Turn Markdown link shortcuts into XHTML tags. - # - if ($this->in_anchor) return $text; - $this->in_anchor = true; - - # - # First, handle reference-style links: [link text] [id] - # - $text = preg_replace_callback('{ - ( # wrap whole match in $1 - \[ - ('.$this->nested_brackets_re.') # link text = $2 - \] - - [ ]? # one optional space - (?:\n[ ]*)? # one optional newline followed by spaces - - \[ - (.*?) # id = $3 - \] - ) - }xs', - array($this, '_doAnchors_reference_callback'), $text); - - # - # Next, inline-style links: [link text](url "optional title") - # - $text = preg_replace_callback('{ - ( # wrap whole match in $1 - \[ - ('.$this->nested_brackets_re.') # link text = $2 - \] - \( # literal paren - [ \n]* - (?: - <(.+?)> # href = $3 - | - ('.$this->nested_url_parenthesis_re.') # href = $4 - ) - [ \n]* - ( # $5 - ([\'"]) # quote char = $6 - (.*?) # Title = $7 - \6 # matching quote - [ \n]* # ignore any spaces/tabs between closing quote and ) - )? # title is optional - \) - ) - }xs', - array($this, '_doAnchors_inline_callback'), $text); - - # - # Last, handle reference-style shortcuts: [link text] - # These must come last in case you've also got [link text][1] - # or [link text](/foo) - # - $text = preg_replace_callback('{ - ( # wrap whole match in $1 - \[ - ([^\[\]]+) # link text = $2; can\'t contain [ or ] - \] - ) - }xs', - array($this, '_doAnchors_reference_callback'), $text); - - $this->in_anchor = false; - return $text; - } - protected function _doAnchors_reference_callback($matches) { - $whole_match = $matches[1]; - $link_text = $matches[2]; - $link_id =& $matches[3]; - - if ($link_id == "") { - # for shortcut links like [this][] or [this]. - $link_id = $link_text; - } - - # lower-case and turn embedded newlines into spaces - $link_id = strtolower($link_id); - $link_id = preg_replace('{[ ]?\n}', ' ', $link_id); - - if (isset($this->urls[$link_id])) { - $url = $this->urls[$link_id]; - $url = $this->encodeAttribute($url); - - $result = "titles[$link_id] ) ) { - $title = $this->titles[$link_id]; - $title = $this->encodeAttribute($title); - $result .= " title=\"$title\""; - } - - $link_text = $this->runSpanGamut($link_text); - $result .= ">$link_text"; - $result = $this->hashPart($result); - } - else { - $result = $whole_match; - } - return $result; - } - protected function _doAnchors_inline_callback($matches) { - $whole_match = $matches[1]; - $link_text = $this->runSpanGamut($matches[2]); - $url = $matches[3] == '' ? $matches[4] : $matches[3]; - $title =& $matches[7]; - - // if the URL was of the form it got caught by the HTML - // tag parser and hashed. Need to reverse the process before using the URL. - $unhashed = $this->unhash($url); - if ($unhashed != $url) - $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); - - $url = $this->encodeAttribute($url); - - $result = "encodeAttribute($title); - $result .= " title=\"$title\""; - } - - $link_text = $this->runSpanGamut($link_text); - $result .= ">$link_text"; - - return $this->hashPart($result); - } - - - protected function doImages($text) { - # - # Turn Markdown image shortcuts into tags. - # - # - # First, handle reference-style labeled images: ![alt text][id] - # - $text = preg_replace_callback('{ - ( # wrap whole match in $1 - !\[ - ('.$this->nested_brackets_re.') # alt text = $2 - \] - - [ ]? # one optional space - (?:\n[ ]*)? # one optional newline followed by spaces - - \[ - (.*?) # id = $3 - \] - - ) - }xs', - array($this, '_doImages_reference_callback'), $text); - - # - # Next, handle inline images: ![alt text](url "optional title") - # Don't forget: encode * and _ - # - $text = preg_replace_callback('{ - ( # wrap whole match in $1 - !\[ - ('.$this->nested_brackets_re.') # alt text = $2 - \] - \s? # One optional whitespace character - \( # literal paren - [ \n]* - (?: - <(\S*)> # src url = $3 - | - ('.$this->nested_url_parenthesis_re.') # src url = $4 - ) - [ \n]* - ( # $5 - ([\'"]) # quote char = $6 - (.*?) # title = $7 - \6 # matching quote - [ \n]* - )? # title is optional - \) - ) - }xs', - array($this, '_doImages_inline_callback'), $text); - - return $text; - } - protected function _doImages_reference_callback($matches) { - $whole_match = $matches[1]; - $alt_text = $matches[2]; - $link_id = strtolower($matches[3]); - - if ($link_id == "") { - $link_id = strtolower($alt_text); # for shortcut links like ![this][]. - } - - $alt_text = $this->encodeAttribute($alt_text); - if (isset($this->urls[$link_id])) { - $url = $this->encodeAttribute($this->urls[$link_id]); - $result = "\"$alt_text\"";titles[$link_id])) { - $title = $this->titles[$link_id]; - $title = $this->encodeAttribute($title); - $result .= " title=\"$title\""; - } - $result .= $this->empty_element_suffix; - $result = $this->hashPart($result); - } - else { - # If there's no such link ID, leave intact: - $result = $whole_match; - } - - return $result; - } - protected function _doImages_inline_callback($matches) { - $whole_match = $matches[1]; - $alt_text = $matches[2]; - $url = $matches[3] == '' ? $matches[4] : $matches[3]; - $title =& $matches[7]; - - $alt_text = $this->encodeAttribute($alt_text); - $url = $this->encodeAttribute($url); - $result = "\"$alt_text\"";encodeAttribute($title); - $result .= " title=\"$title\""; # $title already quoted - } - $result .= $this->empty_element_suffix; - - return $this->hashPart($result); - } - - - protected function doHeaders($text) { - # Setext-style headers: - # Header 1 - # ======== - # - # Header 2 - # -------- - # - $text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx', - array($this, '_doHeaders_callback_setext'), $text); - - # atx-style headers: - # # Header 1 - # ## Header 2 - # ## Header 2 with closing hashes ## - # ... - # ###### Header 6 - # - $text = preg_replace_callback('{ - ^(\#{1,6}) # $1 = string of #\'s - [ ]* - (.+?) # $2 = Header text - [ ]* - \#* # optional closing #\'s (not counted) - \n+ - }xm', - array($this, '_doHeaders_callback_atx'), $text); - - return $text; - } - protected function _doHeaders_callback_setext($matches) { - # Terrible hack to check we haven't found an empty list item. - if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1])) - return $matches[0]; - - $level = $matches[2]{0} == '=' ? 1 : 2; - $block = "".$this->runSpanGamut($matches[1]).""; - return "\n" . $this->hashBlock($block) . "\n\n"; - } - protected function _doHeaders_callback_atx($matches) { - $level = strlen($matches[1]); - $block = "".$this->runSpanGamut($matches[2]).""; - return "\n" . $this->hashBlock($block) . "\n\n"; - } - - - protected function doLists($text) { - # - # Form HTML ordered (numbered) and unordered (bulleted) lists. - # - $less_than_tab = $this->tab_width - 1; - - # Re-usable patterns to match list item bullets and number markers: - $marker_ul_re = '[*+-]'; - $marker_ol_re = '\d+[\.]'; - - $markers_relist = array( - $marker_ul_re => $marker_ol_re, - $marker_ol_re => $marker_ul_re, - ); - - foreach ($markers_relist as $marker_re => $other_marker_re) { - # Re-usable pattern to match any entirel ul or ol list: - $whole_list_re = ' - ( # $1 = whole list - ( # $2 - ([ ]{0,'.$less_than_tab.'}) # $3 = number of spaces - ('.$marker_re.') # $4 = first list item marker - [ ]+ - ) - (?s:.+?) - ( # $5 - \z - | - \n{2,} - (?=\S) - (?! # Negative lookahead for another list item marker - [ ]* - '.$marker_re.'[ ]+ - ) - | - (?= # Lookahead for another kind of list - \n - \3 # Must have the same indentation - '.$other_marker_re.'[ ]+ - ) - ) - ) - '; // mx - - # We use a different prefix before nested lists than top-level lists. - # See extended comment in _ProcessListItems(). - - if ($this->list_level) { - $text = preg_replace_callback('{ - ^ - '.$whole_list_re.' - }mx', - array($this, '_doLists_callback'), $text); - } - else { - $text = preg_replace_callback('{ - (?:(?<=\n)\n|\A\n?) # Must eat the newline - '.$whole_list_re.' - }mx', - array($this, '_doLists_callback'), $text); - } - } - - return $text; - } - protected function _doLists_callback($matches) { - # Re-usable patterns to match list item bullets and number markers: - $marker_ul_re = '[*+-]'; - $marker_ol_re = '\d+[\.]'; - $marker_any_re = "(?:$marker_ul_re|$marker_ol_re)"; - - $list = $matches[1]; - $list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol"; - - $marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re ); - - $list .= "\n"; - $result = $this->processListItems($list, $marker_any_re); - - $result = $this->hashBlock("<$list_type>\n" . $result . ""); - return "\n". $result ."\n\n"; - } - - protected $list_level = 0; - - protected function processListItems($list_str, $marker_any_re) { - # - # Process the contents of a single ordered or unordered list, splitting it - # into individual list items. - # - # The $this->list_level global keeps track of when we're inside a list. - # Each time we enter a list, we increment it; when we leave a list, - # we decrement. If it's zero, we're not in a list anymore. - # - # We do this because when we're not inside a list, we want to treat - # something like this: - # - # I recommend upgrading to version - # 8. Oops, now this line is treated - # as a sub-list. - # - # As a single paragraph, despite the fact that the second line starts - # with a digit-period-space sequence. - # - # Whereas when we're inside a list (or sub-list), that line will be - # treated as the start of a sub-list. What a kludge, huh? This is - # an aspect of Markdown's syntax that's hard to parse perfectly - # without resorting to mind-reading. Perhaps the solution is to - # change the syntax rules such that sub-lists must start with a - # starting cardinal number; e.g. "1." or "a.". - - $this->list_level++; - - # trim trailing blank lines: - $list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str); - - $list_str = preg_replace_callback('{ - (\n)? # leading line = $1 - (^[ ]*) # leading whitespace = $2 - ('.$marker_any_re.' # list marker and space = $3 - (?:[ ]+|(?=\n)) # space only required if item is not empty - ) - ((?s:.*?)) # list item text = $4 - (?:(\n+(?=\n))|\n) # tailing blank line = $5 - (?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n)))) - }xm', - array($this, '_processListItems_callback'), $list_str); - - $this->list_level--; - return $list_str; - } - protected function _processListItems_callback($matches) { - $item = $matches[4]; - $leading_line =& $matches[1]; - $leading_space =& $matches[2]; - $marker_space = $matches[3]; - $tailing_blank_line =& $matches[5]; - - if ($leading_line || $tailing_blank_line || - preg_match('/\n{2,}/', $item)) - { - # Replace marker with the appropriate whitespace indentation - $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item; - $item = $this->runBlockGamut($this->outdent($item)."\n"); - } - else { - # Recursion for sub-lists: - $item = $this->doLists($this->outdent($item)); - $item = preg_replace('/\n+$/', '', $item); - $item = $this->runSpanGamut($item); - } - - return "
  • " . $item . "
  • \n"; - } - - - protected function doCodeBlocks($text) { - # - # Process Markdown `
    ` blocks.
    -	#
    -		$text = preg_replace_callback('{
    -				(?:\n\n|\A\n?)
    -				(	            # $1 = the code block -- one or more lines, starting with a space/tab
    -				  (?>
    -					[ ]{'.$this->tab_width.'}  # Lines must start with a tab or a tab-width of spaces
    -					.*\n+
    -				  )+
    -				)
    -				((?=^[ ]{0,'.$this->tab_width.'}\S)|\Z)	# Lookahead for non-space at line-start, or end of doc
    -			}xm',
    -			array($this, '_doCodeBlocks_callback'), $text);
    -
    -		return $text;
    -	}
    -	protected function _doCodeBlocks_callback($matches) {
    -		$codeblock = $matches[1];
    -
    -		$codeblock = $this->outdent($codeblock);
    -		$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
    -
    -		# trim leading newlines and trailing newlines
    -		$codeblock = preg_replace('/\A\n+|\n+\z/', '', $codeblock);
    -
    -		$codeblock = "
    $codeblock\n
    "; - return "\n\n".$this->hashBlock($codeblock)."\n\n"; - } - - - protected function makeCodeSpan($code) { - # - # Create a code span markup for $code. Called from handleSpanToken. - # - $code = htmlspecialchars(trim($code), ENT_NOQUOTES); - return $this->hashPart("$code"); - } - - - protected $em_relist = array( - '' => '(?:(? '(? '(? '(?:(? '(? '(? '(?:(? '(? '(?em_relist as $em => $em_re) { - foreach ($this->strong_relist as $strong => $strong_re) { - # Construct list of allowed token expressions. - $token_relist = array(); - if (isset($this->em_strong_relist["$em$strong"])) { - $token_relist[] = $this->em_strong_relist["$em$strong"]; - } - $token_relist[] = $em_re; - $token_relist[] = $strong_re; - - # Construct master expression from list. - $token_re = '{('. implode('|', $token_relist) .')}'; - $this->em_strong_prepared_relist["$em$strong"] = $token_re; - } - } - } - - protected function doItalicsAndBold($text) { - $token_stack = array(''); - $text_stack = array(''); - $em = ''; - $strong = ''; - $tree_char_em = false; - - while (1) { - # - # Get prepared regular expression for seraching emphasis tokens - # in current context. - # - $token_re = $this->em_strong_prepared_relist["$em$strong"]; - - # - # Each loop iteration search for the next emphasis token. - # Each token is then passed to handleSpanToken. - # - $parts = preg_split($token_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE); - $text_stack[0] .= $parts[0]; - $token =& $parts[1]; - $text =& $parts[2]; - - if (empty($token)) { - # Reached end of text span: empty stack without emitting. - # any more emphasis. - while ($token_stack[0]) { - $text_stack[1] .= array_shift($token_stack); - $text_stack[0] .= array_shift($text_stack); - } - break; - } - - $token_len = strlen($token); - if ($tree_char_em) { - # Reached closing marker while inside a three-char emphasis. - if ($token_len == 3) { - # Three-char closing marker, close em and strong. - array_shift($token_stack); - $span = array_shift($text_stack); - $span = $this->runSpanGamut($span); - $span = "$span"; - $text_stack[0] .= $this->hashPart($span); - $em = ''; - $strong = ''; - } else { - # Other closing marker: close one em or strong and - # change current token state to match the other - $token_stack[0] = str_repeat($token{0}, 3-$token_len); - $tag = $token_len == 2 ? "strong" : "em"; - $span = $text_stack[0]; - $span = $this->runSpanGamut($span); - $span = "<$tag>$span"; - $text_stack[0] = $this->hashPart($span); - $$tag = ''; # $$tag stands for $em or $strong - } - $tree_char_em = false; - } else if ($token_len == 3) { - if ($em) { - # Reached closing marker for both em and strong. - # Closing strong marker: - for ($i = 0; $i < 2; ++$i) { - $shifted_token = array_shift($token_stack); - $tag = strlen($shifted_token) == 2 ? "strong" : "em"; - $span = array_shift($text_stack); - $span = $this->runSpanGamut($span); - $span = "<$tag>$span"; - $text_stack[0] .= $this->hashPart($span); - $$tag = ''; # $$tag stands for $em or $strong - } - } else { - # Reached opening three-char emphasis marker. Push on token - # stack; will be handled by the special condition above. - $em = $token{0}; - $strong = "$em$em"; - array_unshift($token_stack, $token); - array_unshift($text_stack, ''); - $tree_char_em = true; - } - } else if ($token_len == 2) { - if ($strong) { - # Unwind any dangling emphasis marker: - if (strlen($token_stack[0]) == 1) { - $text_stack[1] .= array_shift($token_stack); - $text_stack[0] .= array_shift($text_stack); - } - # Closing strong marker: - array_shift($token_stack); - $span = array_shift($text_stack); - $span = $this->runSpanGamut($span); - $span = "$span"; - $text_stack[0] .= $this->hashPart($span); - $strong = ''; - } else { - array_unshift($token_stack, $token); - array_unshift($text_stack, ''); - $strong = $token; - } - } else { - # Here $token_len == 1 - if ($em) { - if (strlen($token_stack[0]) == 1) { - # Closing emphasis marker: - array_shift($token_stack); - $span = array_shift($text_stack); - $span = $this->runSpanGamut($span); - $span = "$span"; - $text_stack[0] .= $this->hashPart($span); - $em = ''; - } else { - $text_stack[0] .= $token; - } - } else { - array_unshift($token_stack, $token); - array_unshift($text_stack, ''); - $em = $token; - } - } - } - return $text_stack[0]; - } - - - protected function doBlockQuotes($text) { - $text = preg_replace_callback('/ - ( # Wrap whole match in $1 - (?> - ^[ ]*>[ ]? # ">" at the start of a line - .+\n # rest of the first line - (.+\n)* # subsequent consecutive lines - \n* # blanks - )+ - ) - /xm', - array($this, '_doBlockQuotes_callback'), $text); - - return $text; - } - protected function _doBlockQuotes_callback($matches) { - $bq = $matches[1]; - # trim one level of quoting - trim whitespace-only lines - $bq = preg_replace('/^[ ]*>[ ]?|^[ ]+$/m', '', $bq); - $bq = $this->runBlockGamut($bq); # recurse - - $bq = preg_replace('/^/m', " ", $bq); - # These leading spaces cause problem with
     content, 
    -		# so we need to fix that:
    -		$bq = preg_replace_callback('{(\s*
    .+?
    )}sx', - array($this, '_doBlockQuotes_callback2'), $bq); - - return "\n". $this->hashBlock("
    \n$bq\n
    ")."\n\n"; - } - protected function _doBlockQuotes_callback2($matches) { - $pre = $matches[1]; - $pre = preg_replace('/^ /m', '', $pre); - return $pre; - } - - - protected function formParagraphs($text) { - # - # Params: - # $text - string to process with html

    tags - # - # Strip leading and trailing lines: - $text = preg_replace('/\A\n+|\n+\z/', '', $text); - - $grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY); - - # - # Wrap

    tags and unhashify HTML blocks - # - foreach ($grafs as $key => $value) { - if (!preg_match('/^B\x1A[0-9]+B$/', $value)) { - # Is a paragraph. - $value = $this->runSpanGamut($value); - $value = preg_replace('/^([ ]*)/', "

    ", $value); - $value .= "

    "; - $grafs[$key] = $this->unhash($value); - } - else { - # Is a block. - # Modify elements of @grafs in-place... - $graf = $value; - $block = $this->html_hashes[$graf]; - $graf = $block; -// if (preg_match('{ -// \A -// ( # $1 =
    tag -//
    ]* -// \b -// markdown\s*=\s* ([\'"]) # $2 = attr quote char -// 1 -// \2 -// [^>]* -// > -// ) -// ( # $3 = contents -// .* -// ) -// (
    ) # $4 = closing tag -// \z -// }xs', $block, $matches)) -// { -// list(, $div_open, , $div_content, $div_close) = $matches; -// -// # We can't call Markdown(), because that resets the hash; -// # that initialization code should be pulled into its own sub, though. -// $div_content = $this->hashHTMLBlocks($div_content); -// -// # Run document gamut methods on the content. -// foreach ($this->document_gamut as $method => $priority) { -// $div_content = $this->$method($div_content); -// } -// -// $div_open = preg_replace( -// '{\smarkdown\s*=\s*([\'"]).+?\1}', '', $div_open); -// -// $graf = $div_open . "\n" . $div_content . "\n" . $div_close; -// } - $grafs[$key] = $graf; - } - } - - return implode("\n\n", $grafs); - } - - - protected function encodeAttribute($text) { - # - # Encode text for a double-quoted HTML attribute. This function - # is *not* suitable for attributes enclosed in single quotes. - # - $text = $this->encodeAmpsAndAngles($text); - $text = str_replace('"', '"', $text); - return $text; - } - - - protected function encodeAmpsAndAngles($text) { - # - # Smart processing for ampersands and angle brackets that need to - # be encoded. Valid character entities are left alone unless the - # no-entities mode is set. - # - if ($this->no_entities) { - $text = str_replace('&', '&', $text); - } else { - # Ampersand-encoding based entirely on Nat Irons's Amputator - # MT plugin: - $text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/', - '&', $text); - } - # Encode remaining <'s - $text = str_replace('<', '<', $text); - - return $text; - } - - - protected function doAutoLinks($text) { - $text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}i', - array($this, '_doAutoLinks_url_callback'), $text); - - # Email addresses: - $text = preg_replace_callback('{ - < - (?:mailto:)? - ( - (?: - [-!#$%&\'*+/=?^_`.{|}~\w\x80-\xFF]+ - | - ".*?" - ) - \@ - (?: - [-a-z0-9\x80-\xFF]+(\.[-a-z0-9\x80-\xFF]+)*\.[a-z]+ - | - \[[\d.a-fA-F:]+\] # IPv4 & IPv6 - ) - ) - > - }xi', - array($this, '_doAutoLinks_email_callback'), $text); - $text = preg_replace_callback('{<(tel:([^\'">\s]+))>}i',array($this, '_doAutoLinks_tel_callback'), $text); - - return $text; - } - protected function _doAutoLinks_tel_callback($matches) { - $url = $this->encodeAttribute($matches[1]); - $tel = $this->encodeAttribute($matches[2]); - $link = "$tel"; - return $this->hashPart($link); - } - protected function _doAutoLinks_url_callback($matches) { - $url = $this->encodeAttribute($matches[1]); - $link = "$url"; - return $this->hashPart($link); - } - protected function _doAutoLinks_email_callback($matches) { - $address = $matches[1]; - $link = $this->encodeEmailAddress($address); - return $this->hashPart($link); - } - - - protected function encodeEmailAddress($addr) { - # - # Input: an email address, e.g. "foo@example.com" - # - # Output: the email address as a mailto link, with each character - # of the address encoded as either a decimal or hex entity, in - # the hopes of foiling most address harvesting spam bots. E.g.: - # - #

    foo@exampl - # e.com

    - # - # Based by a filter by Matthew Wickline, posted to BBEdit-Talk. - # With some optimizations by Milian Wolff. - # - $addr = "mailto:" . $addr; - $chars = preg_split('/(? $char) { - $ord = ord($char); - # Ignore non-ascii chars. - if ($ord < 128) { - $r = ($seed * (1 + $key)) % 100; # Pseudo-random function. - # roughly 10% raw, 45% hex, 45% dec - # '@' *must* be encoded. I insist. - # '"' has to be encoded inside the attribute - if ($r > 90 && $char != '@' && $char != '"') /* do nothing */; - else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';'; - else $chars[$key] = '&#'.$ord.';'; - } - } - - $addr = implode('', $chars); - $text = implode('', array_slice($chars, 7)); # text without `mailto:` - $addr = "$text"; - - return $addr; - } - - - protected function parseSpan($str) { - # - # Take the string $str and parse it into tokens, hashing embeded HTML, - # escaped characters and handling code spans. - # - $output = ''; - - $span_re = '{ - ( - \\\\'.$this->escape_chars_re.' - | - (?no_markup ? '' : ' - | - # comment - | - <\?.*?\?> | <%.*?%> # processing instruction - | - <[!$]?[-a-zA-Z0-9:_]+ # regular tags - (?> - \s - (?>[^"\'>]+|"[^"]*"|\'[^\']*\')* - )? - > - | - <[-a-zA-Z0-9:_]+\s*/> # xml-style empty tag - | - # closing tag - ').' - ) - }xs'; - - while (1) { - # - # Each loop iteration seach for either the next tag, the next - # openning code span marker, or the next escaped character. - # Each token is then passed to handleSpanToken. - # - $parts = preg_split($span_re, $str, 2, PREG_SPLIT_DELIM_CAPTURE); - - # Create token from text preceding tag. - if ($parts[0] != "") { - $output .= $parts[0]; - } - - # Check if we reach the end. - if (isset($parts[1])) { - $output .= $this->handleSpanToken($parts[1], $parts[2]); - $str = $parts[2]; - } - else { - break; - } - } - - return $output; - } - - - protected function handleSpanToken($token, &$str) { - # - # Handle $token provided by parseSpan by determining its nature and - # returning the corresponding value that should replace it. - # - switch ($token{0}) { - case "\\": - return $this->hashPart("&#". ord($token{1}). ";"); - case "`": - # Search for end marker in remaining text. - if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm', - $str, $matches)) - { - $str = $matches[2]; - $codespan = $this->makeCodeSpan($matches[1]); - return $this->hashPart($codespan); - } - return $token; // return as text since no ending marker found. - default: - return $this->hashPart($token); - } - } - - - protected function outdent($text) { - # - # Remove one level of line-leading tabs or spaces - # - return preg_replace('/^(\t|[ ]{1,'.$this->tab_width.'})/m', '', $text); - } - - - # String length function for detab. `_initDetab` will create a function to - # hanlde UTF-8 if the default function does not exist. - protected $utf8_strlen = 'mb_strlen'; - - protected function detab($text) { - # - # Replace tabs with the appropriate amount of space. - # - # For each line we separate the line in blocks delemited by - # tab characters. Then we reconstruct every line by adding the - # appropriate number of space between each blocks. - - $text = preg_replace_callback('/^.*\t.*$/m', - array($this, '_detab_callback'), $text); - - return $text; - } - protected function _detab_callback($matches) { - $line = $matches[0]; - $strlen = $this->utf8_strlen; # strlen function for UTF-8. - - # Split in blocks. - $blocks = explode("\t", $line); - # Add each blocks to the line. - $line = $blocks[0]; - unset($blocks[0]); # Do not add first block twice. - foreach ($blocks as $block) { - # Calculate amount of space, insert spaces, insert block. - $amount = $this->tab_width - - $strlen($line, 'UTF-8') % $this->tab_width; - $line .= str_repeat(" ", $amount) . $block; - } - return $line; - } - protected function _initDetab() { - # - # Check for the availability of the function in the `utf8_strlen` property - # (initially `mb_strlen`). If the function is not available, create a - # function that will loosely count the number of UTF-8 characters with a - # regular expression. - # - if (function_exists($this->utf8_strlen)) return; - $this->utf8_strlen = create_function('$text', 'return preg_match_all( - "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", - $text, $m);'); - } - - - protected function unhash($text) { - # - # Swap back in all the tags hashed by _HashHTMLBlocks. - # - return preg_replace_callback('/(.)\x1A[0-9]+\1/', - array($this, '_unhash_callback'), $text); - } - protected function _unhash_callback($matches) { - return $this->html_hashes[$matches[0]]; - } - -} - - -# -# Temporary Markdown Extra Parser Implementation Class -# -# NOTE: DON'T USE THIS CLASS -# Currently the implementation of of Extra resides here in this temporary class. -# This makes it easier to propagate the changes between the three different -# packaging styles of PHP Markdown. When this issue is resolved, this -# MarkdownExtra_TmpImpl class here will disappear and \Michelf\MarkdownExtra -# will contain the code. So please use \Michelf\MarkdownExtra and ignore this -# one. -# - -abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown { - - ### Configuration Variables ### - - # Prefix for footnote ids. - public $fn_id_prefix = ""; - - # Optional title attribute for footnote links and backlinks. - public $fn_link_title = ""; - public $fn_backlink_title = ""; - - # Optional class attribute for footnote links and backlinks. - public $fn_link_class = "footnote-ref"; - public $fn_backlink_class = "footnote-backref"; - - # Class name for table cell alignment (%% replaced left/center/right) - # For instance: 'go-%%' becomes 'go-left' or 'go-right' or 'go-center' - # If empty, the align attribute is used instead of a class name. - public $table_align_class_tmpl = ''; - - # Optional class prefix for fenced code block. - public $code_class_prefix = ""; - # Class attribute for code blocks goes on the `code` tag; - # setting this to true will put attributes on the `pre` tag instead. - public $code_attr_on_pre = false; - - # Predefined abbreviations. - public $predef_abbr = array(); - - - ### Parser Implementation ### - - public function __construct() { - # - # Constructor function. Initialize the parser object. - # - # Add extra escapable characters before parent constructor - # initialize the table. - $this->escape_chars .= ':|'; - - # Insert extra document, block, and span transformations. - # Parent constructor will do the sorting. - $this->document_gamut += array( - "doFencedCodeBlocks" => 5, - "stripFootnotes" => 15, - "stripAbbreviations" => 25, - "appendFootnotes" => 50, - ); - $this->block_gamut += array( - "doFencedCodeBlocks" => 5, - "doTables" => 15, - "doDefLists" => 45, - ); - $this->span_gamut += array( - "doFootnotes" => 5, - "doAbbreviations" => 70, - ); - - parent::__construct(); - } - - - # Extra variables used during extra transformations. - protected $footnotes = array(); - protected $footnotes_ordered = array(); - protected $footnotes_ref_count = array(); - protected $footnotes_numbers = array(); - protected $abbr_desciptions = array(); - protected $abbr_word_re = ''; - - # Give the current footnote number. - protected $footnote_counter = 1; - - - protected function setup() { - # - # Setting up Extra-specific variables. - # - parent::setup(); - - $this->footnotes = array(); - $this->footnotes_ordered = array(); - $this->footnotes_ref_count = array(); - $this->footnotes_numbers = array(); - $this->abbr_desciptions = array(); - $this->abbr_word_re = ''; - $this->footnote_counter = 1; - - foreach ($this->predef_abbr as $abbr_word => $abbr_desc) { - if ($this->abbr_word_re) - $this->abbr_word_re .= '|'; - $this->abbr_word_re .= preg_quote($abbr_word); - $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); - } - } - - protected function teardown() { - # - # Clearing Extra-specific variables. - # - $this->footnotes = array(); - $this->footnotes_ordered = array(); - $this->footnotes_ref_count = array(); - $this->footnotes_numbers = array(); - $this->abbr_desciptions = array(); - $this->abbr_word_re = ''; - - parent::teardown(); - } - - - ### Extra Attribute Parser ### - - # Expression to use to catch attributes (includes the braces) - protected $id_class_attr_catch_re = '\{((?:[ ]*[#.][-_:a-zA-Z0-9]+){1,})[ ]*\}'; - # Expression to use when parsing in a context when no capture is desired - protected $id_class_attr_nocatch_re = '\{(?:[ ]*[#.][-_:a-zA-Z0-9]+){1,}[ ]*\}'; - - protected function doExtraAttributes($tag_name, $attr) { - # - # Parse attributes caught by the $this->id_class_attr_catch_re expression - # and return the HTML-formatted list of attributes. - # - # Currently supported attributes are .class and #id. - # - if (empty($attr)) return ""; - - # Split on components - preg_match_all('/[#.][-_:a-zA-Z0-9]+/', $attr, $matches); - $elements = $matches[0]; - - # handle classes and ids (only first id taken into account) - $classes = array(); - $id = false; - foreach ($elements as $element) { - if ($element{0} == '.') { - $classes[] = substr($element, 1); - } else if ($element{0} == '#') { - if ($id === false) $id = substr($element, 1); - } - } - - # compose attributes as string - $attr_str = ""; - if (!empty($id)) { - $attr_str .= ' id="'.$id.'"'; - } - if (!empty($classes)) { - $attr_str .= ' class="'.implode(" ", $classes).'"'; - } - return $attr_str; - } - - - protected function stripLinkDefinitions($text) { - # - # Strips link definitions from text, stores the URLs and titles in - # hash references. - # - $less_than_tab = $this->tab_width - 1; - - # Link defs are in the form: ^[id]: url "optional title" - $text = preg_replace_callback('{ - ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1 - [ ]* - \n? # maybe *one* newline - [ ]* - (?: - <(.+?)> # url = $2 - | - (\S+?) # url = $3 - ) - [ ]* - \n? # maybe one newline - [ ]* - (?: - (?<=\s) # lookbehind for whitespace - ["(] - (.*?) # title = $4 - [")] - [ ]* - )? # title is optional - (?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr - (?:\n+|\Z) - }xm', - array($this, '_stripLinkDefinitions_callback'), - $text); - return $text; - } - protected function _stripLinkDefinitions_callback($matches) { - $link_id = strtolower($matches[1]); - $url = $matches[2] == '' ? $matches[3] : $matches[2]; - $this->urls[$link_id] = $url; - $this->titles[$link_id] =& $matches[4]; - $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]); - return ''; # String that will replace the block - } - - - ### HTML Block Parser ### - - # Tags that are always treated as block tags: - protected $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|figure'; - - # Tags treated as block tags only if the opening tag is alone on its line: - protected $context_block_tags_re = 'script|noscript|style|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video'; - - # Tags where markdown="1" default to span mode: - protected $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address'; - - # Tags which must not have their contents modified, no matter where - # they appear: - protected $clean_tags_re = 'script|style|math|svg'; - - # Tags that do not need to be closed. - protected $auto_close_tags_re = 'hr|img|param|source|track'; - - - protected function hashHTMLBlocks($text) { - # - # Hashify HTML Blocks and "clean tags". - # - # We only want to do this for block-level HTML tags, such as headers, - # lists, and tables. That's because we still want to wrap

    s around - # "paragraphs" that are wrapped in non-block-level tags, such as anchors, - # phrase emphasis, and spans. The list of tags we're looking for is - # hard-coded. - # - # This works by calling _HashHTMLBlocks_InMarkdown, which then calls - # _HashHTMLBlocks_InHTML when it encounter block tags. When the markdown="1" - # attribute is found within a tag, _HashHTMLBlocks_InHTML calls back - # _HashHTMLBlocks_InMarkdown to handle the Markdown syntax within the tag. - # These two functions are calling each other. It's recursive! - # - if ($this->no_markup) return $text; - - # - # Call the HTML-in-Markdown hasher. - # - list($text, ) = $this->_hashHTMLBlocks_inMarkdown($text); - - return $text; - } - protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0, - $enclosing_tag_re = '', $span = false) - { - # - # Parse markdown text, calling _HashHTMLBlocks_InHTML for block tags. - # - # * $indent is the number of space to be ignored when checking for code - # blocks. This is important because if we don't take the indent into - # account, something like this (which looks right) won't work as expected: - # - #

    - #
    - # Hello World. <-- Is this a Markdown code block or text? - #
    <-- Is this a Markdown code block or a real tag? - #
    - # - # If you don't like this, just don't indent the tag on which - # you apply the markdown="1" attribute. - # - # * If $enclosing_tag_re is not empty, stops at the first unmatched closing - # tag with that name. Nested tags supported. - # - # * If $span is true, text inside must treated as span. So any double - # newline will be replaced by a single newline so that it does not create - # paragraphs. - # - # Returns an array of that form: ( processed text , remaining text ) - # - if ($text === '') return array('', ''); - - # Regex to check for the presense of newlines around a block tag. - $newline_before_re = '/(?:^\n?|\n\n)*$/'; - $newline_after_re = - '{ - ^ # Start of text following the tag. - (?>[ ]*)? # Optional comment. - [ ]*\n # Must be followed by newline. - }xs'; - - # Regex to match any tag. - $block_tag_re = - '{ - ( # $2: Capture whole tag. - # Tag name. - '.$this->block_tags_re.' | - '.$this->context_block_tags_re.' | - '.$this->clean_tags_re.' | - (?!\s)'.$enclosing_tag_re.' - ) - (?: - (?=[\s"\'/a-zA-Z0-9]) # Allowed characters after tag name. - (?> - ".*?" | # Double quotes (can contain `>`) - \'.*?\' | # Single quotes (can contain `>`) - .+? # Anything but quotes and `>`. - )*? - )? - > # End of tag. - | - # HTML Comment - | - <\?.*?\?> | <%.*?%> # Processing instruction - | - # CData Block - '. ( !$span ? ' # If not in span. - | - # Indented code block - (?: ^[ ]*\n | ^ | \n[ ]*\n ) - [ ]{'.($indent+4).'}[^\n]* \n - (?> - (?: [ ]{'.($indent+4).'}[^\n]* | [ ]* ) \n - )* - | - # Fenced code block marker - (?<= ^ | \n ) - [ ]{0,'.($indent+3).'}(?:~{3,}|`{3,}) - [ ]* - (?: - \.?[-_:a-zA-Z0-9]+ # standalone class name - | - '.$this->id_class_attr_nocatch_re.' # extra attributes - )? - [ ]* - (?= \n ) - ' : '' ). ' # End (if not is span). - | - # Code span marker - # Note, this regex needs to go after backtick fenced - # code blocks but it should also be kept outside of the - # "if not in span" condition adding backticks to the parser - `+ - ) - }xs'; - - - $depth = 0; # Current depth inside the tag tree. - $parsed = ""; # Parsed text that will be returned. - - # - # Loop through every tag until we find the closing tag of the parent - # or loop until reaching the end of text if no parent tag specified. - # - do { - # - # Split the text using the first $tag_match pattern found. - # Text before pattern will be first in the array, text after - # pattern will be at the end, and between will be any catches made - # by the pattern. - # - $parts = preg_split($block_tag_re, $text, 2, - PREG_SPLIT_DELIM_CAPTURE); - - # If in Markdown span mode, add a empty-string span-level hash - # after each newline to prevent triggering any block element. - if ($span) { - $void = $this->hashPart("", ':'); - $newline = "$void\n"; - $parts[0] = $void . str_replace("\n", $newline, $parts[0]) . $void; - } - - $parsed .= $parts[0]; # Text before current tag. - - # If end of $text has been reached. Stop loop. - if (count($parts) < 3) { - $text = ""; - break; - } - - $tag = $parts[1]; # Tag to handle. - $text = $parts[2]; # Remaining text after current tag. - $tag_re = preg_quote($tag); # For use in a regular expression. - - # - # Check for: Fenced code block marker. - # Note: need to recheck the whole tag to disambiguate backtick - # fences from code spans - # - if (preg_match('{^\n?([ ]{0,'.($indent+3).'})(~{3,}|`{3,})[ ]*(?:\.?[-_:a-zA-Z0-9]+|'.$this->id_class_attr_nocatch_re.')?[ ]*\n?$}', $tag, $capture)) { - # Fenced code block marker: find matching end marker. - $fence_indent = strlen($capture[1]); # use captured indent in re - $fence_re = $capture[2]; # use captured fence in re - if (preg_match('{^(?>.*\n)*?[ ]{'.($fence_indent).'}'.$fence_re.'[ ]*(?:\n|$)}', $text, - $matches)) - { - # End marker found: pass text unchanged until marker. - $parsed .= $tag . $matches[0]; - $text = substr($text, strlen($matches[0])); - } - else { - # No end marker: just skip it. - $parsed .= $tag; - } - } - # - # Check for: Indented code block. - # - else if ($tag{0} == "\n" || $tag{0} == " ") { - # Indented code block: pass it unchanged, will be handled - # later. - $parsed .= $tag; - } - # - # Check for: Code span marker - # Note: need to check this after backtick fenced code blocks - # - else if ($tag{0} == "`") { - # Find corresponding end marker. - $tag_re = preg_quote($tag); - if (preg_match('{^(?>.+?|\n(?!\n))*?(?block_tags_re.')\b}', $tag) || - ( preg_match('{^<(?:'.$this->context_block_tags_re.')\b}', $tag) && - preg_match($newline_before_re, $parsed) && - preg_match($newline_after_re, $text) ) - ) - { - # Need to parse tag and following text using the HTML parser. - list($block_text, $text) = - $this->_hashHTMLBlocks_inHTML($tag . $text, "hashBlock", true); - - # Make sure it stays outside of any paragraph by adding newlines. - $parsed .= "\n\n$block_text\n\n"; - } - # - # Check for: Clean tag (like script, math) - # HTML Comments, processing instructions. - # - else if (preg_match('{^<(?:'.$this->clean_tags_re.')\b}', $tag) || - $tag{1} == '!' || $tag{1} == '?') - { - # Need to parse tag and following text using the HTML parser. - # (don't check for markdown attribute) - list($block_text, $text) = - $this->_hashHTMLBlocks_inHTML($tag . $text, "hashClean", false); - - $parsed .= $block_text; - } - # - # Check for: Tag with same name as enclosing tag. - # - else if ($enclosing_tag_re !== '' && - # Same name as enclosing tag. - preg_match('{^= 0); - - return array($parsed, $text); - } - protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) { - # - # Parse HTML, calling _HashHTMLBlocks_InMarkdown for block tags. - # - # * Calls $hash_method to convert any blocks. - # * Stops when the first opening tag closes. - # * $md_attr indicate if the use of the `markdown="1"` attribute is allowed. - # (it is not inside clean tags) - # - # Returns an array of that form: ( processed text , remaining text ) - # - if ($text === '') return array('', ''); - - # Regex to match `markdown` attribute inside of a tag. - $markdown_attr_re = ' - { - \s* # Eat whitespace before the `markdown` attribute - markdown - \s*=\s* - (?> - (["\']) # $1: quote delimiter - (.*?) # $2: attribute value - \1 # matching delimiter - | - ([^\s>]*) # $3: unquoted attribute value - ) - () # $4: make $3 always defined (avoid warnings) - }xs'; - - # Regex to match any tag. - $tag_re = '{ - ( # $2: Capture whole tag. - - ".*?" | # Double quotes (can contain `>`) - \'.*?\' | # Single quotes (can contain `>`) - .+? # Anything but quotes and `>`. - )*? - )? - > # End of tag. - | - # HTML Comment - | - <\?.*?\?> | <%.*?%> # Processing instruction - | - # CData Block - ) - }xs'; - - $original_text = $text; # Save original text in case of faliure. - - $depth = 0; # Current depth inside the tag tree. - $block_text = ""; # Temporary text holder for current text. - $parsed = ""; # Parsed text that will be returned. - - # - # Get the name of the starting tag. - # (This pattern makes $base_tag_name_re safe without quoting.) - # - if (preg_match('/^<([\w:$]*)\b/', $text, $matches)) - $base_tag_name_re = $matches[1]; - - # - # Loop through every tag until we find the corresponding closing tag. - # - do { - # - # Split the text using the first $tag_match pattern found. - # Text before pattern will be first in the array, text after - # pattern will be at the end, and between will be any catches made - # by the pattern. - # - $parts = preg_split($tag_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE); - - if (count($parts) < 3) { - # - # End of $text reached with unbalenced tag(s). - # In that case, we return original text unchanged and pass the - # first character as filtered to prevent an infinite loop in the - # parent function. - # - return array($original_text{0}, substr($original_text, 1)); - } - - $block_text .= $parts[0]; # Text before current tag. - $tag = $parts[1]; # Tag to handle. - $text = $parts[2]; # Remaining text after current tag. - - # - # Check for: Auto-close tag (like
    ) - # Comments and Processing Instructions. - # - if (preg_match('{^auto_close_tags_re.')\b}', $tag) || - $tag{1} == '!' || $tag{1} == '?') - { - # Just add the tag to the block as if it was text. - $block_text .= $tag; - } - else { - # - # Increase/decrease nested tag count. Only do so if - # the tag's name match base tag's. - # - if (preg_match('{^mode = $attr_m[2] . $attr_m[3]; - $span_mode = $this->mode == 'span' || $this->mode != 'block' && - preg_match('{^<(?:'.$this->contain_span_tags_re.')\b}', $tag); - - # Calculate indent before tag. - if (preg_match('/(?:^|\n)( *?)(?! ).*?$/', $block_text, $matches)) { - $strlen = $this->utf8_strlen; - $indent = $strlen($matches[1], 'UTF-8'); - } else { - $indent = 0; - } - - # End preceding block with this tag. - $block_text .= $tag; - $parsed .= $this->$hash_method($block_text); - - # Get enclosing tag name for the ParseMarkdown function. - # (This pattern makes $tag_name_re safe without quoting.) - preg_match('/^<([\w:$]*)\b/', $tag, $matches); - $tag_name_re = $matches[1]; - - # Parse the content using the HTML-in-Markdown parser. - list ($block_text, $text) - = $this->_hashHTMLBlocks_inMarkdown($text, $indent, - $tag_name_re, $span_mode); - - # Outdent markdown text. - if ($indent > 0) { - $block_text = preg_replace("/^[ ]{1,$indent}/m", "", - $block_text); - } - - # Append tag content to parsed text. - if (!$span_mode) $parsed .= "\n\n$block_text\n\n"; - else $parsed .= "$block_text"; - - # Start over with a new block. - $block_text = ""; - } - else $block_text .= $tag; - } - - } while ($depth > 0); - - # - # Hash last block text that wasn't processed inside the loop. - # - $parsed .= $this->$hash_method($block_text); - - return array($parsed, $text); - } - - - protected function hashClean($text) { - # - # Called whenever a tag must be hashed when a function inserts a "clean" tag - # in $text, it passes through this function and is automaticaly escaped, - # blocking invalid nested overlap. - # - return $this->hashPart($text, 'C'); - } - - - protected function doAnchors($text) { - # - # Turn Markdown link shortcuts into XHTML tags. - # - if ($this->in_anchor) return $text; - $this->in_anchor = true; - - # - # First, handle reference-style links: [link text] [id] - # - $text = preg_replace_callback('{ - ( # wrap whole match in $1 - \[ - ('.$this->nested_brackets_re.') # link text = $2 - \] - - [ ]? # one optional space - (?:\n[ ]*)? # one optional newline followed by spaces - - \[ - (.*?) # id = $3 - \] - ) - }xs', - array($this, '_doAnchors_reference_callback'), $text); - - # - # Next, inline-style links: [link text](url "optional title") - # - $text = preg_replace_callback('{ - ( # wrap whole match in $1 - \[ - ('.$this->nested_brackets_re.') # link text = $2 - \] - \( # literal paren - [ \n]* - (?: - <(.+?)> # href = $3 - | - ('.$this->nested_url_parenthesis_re.') # href = $4 - ) - [ \n]* - ( # $5 - ([\'"]) # quote char = $6 - (.*?) # Title = $7 - \6 # matching quote - [ \n]* # ignore any spaces/tabs between closing quote and ) - )? # title is optional - \) - (?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes - ) - }xs', - array($this, '_doAnchors_inline_callback'), $text); - - # - # Last, handle reference-style shortcuts: [link text] - # These must come last in case you've also got [link text][1] - # or [link text](/foo) - # - $text = preg_replace_callback('{ - ( # wrap whole match in $1 - \[ - ([^\[\]]+) # link text = $2; can\'t contain [ or ] - \] - ) - }xs', - array($this, '_doAnchors_reference_callback'), $text); - - $this->in_anchor = false; - return $text; - } - protected function _doAnchors_reference_callback($matches) { - $whole_match = $matches[1]; - $link_text = $matches[2]; - $link_id =& $matches[3]; - - if ($link_id == "") { - # for shortcut links like [this][] or [this]. - $link_id = $link_text; - } - - # lower-case and turn embedded newlines into spaces - $link_id = strtolower($link_id); - $link_id = preg_replace('{[ ]?\n}', ' ', $link_id); - - if (isset($this->urls[$link_id])) { - $url = $this->urls[$link_id]; - $url = $this->encodeAttribute($url); - - $result = "titles[$link_id] ) ) { - $title = $this->titles[$link_id]; - $title = $this->encodeAttribute($title); - $result .= " title=\"$title\""; - } - if (isset($this->ref_attr[$link_id])) - $result .= $this->ref_attr[$link_id]; - - $link_text = $this->runSpanGamut($link_text); - $result .= ">$link_text"; - $result = $this->hashPart($result); - } - else { - $result = $whole_match; - } - return $result; - } - protected function _doAnchors_inline_callback($matches) { - $whole_match = $matches[1]; - $link_text = $this->runSpanGamut($matches[2]); - $url = $matches[3] == '' ? $matches[4] : $matches[3]; - $title =& $matches[7]; - $attr = $this->doExtraAttributes("a", $dummy =& $matches[8]); - - // if the URL was of the form it got caught by the HTML - // tag parser and hashed. Need to reverse the process before using the URL. - $unhashed = $this->unhash($url); - if ($unhashed != $url) - $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); - - $url = $this->encodeAttribute($url); - - $result = "encodeAttribute($title); - $result .= " title=\"$title\""; - } - $result .= $attr; - - $link_text = $this->runSpanGamut($link_text); - $result .= ">$link_text"; - - return $this->hashPart($result); - } - - - protected function doImages($text) { - # - # Turn Markdown image shortcuts into tags. - # - # - # First, handle reference-style labeled images: ![alt text][id] - # - $text = preg_replace_callback('{ - ( # wrap whole match in $1 - !\[ - ('.$this->nested_brackets_re.') # alt text = $2 - \] - - [ ]? # one optional space - (?:\n[ ]*)? # one optional newline followed by spaces - - \[ - (.*?) # id = $3 - \] - - ) - }xs', - array($this, '_doImages_reference_callback'), $text); - - # - # Next, handle inline images: ![alt text](url "optional title") - # Don't forget: encode * and _ - # - $text = preg_replace_callback('{ - ( # wrap whole match in $1 - !\[ - ('.$this->nested_brackets_re.') # alt text = $2 - \] - \s? # One optional whitespace character - \( # literal paren - [ \n]* - (?: - <(\S*)> # src url = $3 - | - ('.$this->nested_url_parenthesis_re.') # src url = $4 - ) - [ \n]* - ( # $5 - ([\'"]) # quote char = $6 - (.*?) # title = $7 - \6 # matching quote - [ \n]* - )? # title is optional - \) - (?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes - ) - }xs', - array($this, '_doImages_inline_callback'), $text); - - return $text; - } - protected function _doImages_reference_callback($matches) { - $whole_match = $matches[1]; - $alt_text = $matches[2]; - $link_id = strtolower($matches[3]); - - if ($link_id == "") { - $link_id = strtolower($alt_text); # for shortcut links like ![this][]. - } - - $alt_text = $this->encodeAttribute($alt_text); - if (isset($this->urls[$link_id])) { - $url = $this->encodeAttribute($this->urls[$link_id]); - $result = "\"$alt_text\"";titles[$link_id])) { - $title = $this->titles[$link_id]; - $title = $this->encodeAttribute($title); - $result .= " title=\"$title\""; - } - if (isset($this->ref_attr[$link_id])) - $result .= $this->ref_attr[$link_id]; - $result .= $this->empty_element_suffix; - $result = $this->hashPart($result); - } - else { - # If there's no such link ID, leave intact: - $result = $whole_match; - } - - return $result; - } - protected function _doImages_inline_callback($matches) { - $whole_match = $matches[1]; - $alt_text = $matches[2]; - $url = $matches[3] == '' ? $matches[4] : $matches[3]; - $title =& $matches[7]; - $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]); - - $alt_text = $this->encodeAttribute($alt_text); - $url = $this->encodeAttribute($url); - $result = "\"$alt_text\"";encodeAttribute($title); - $result .= " title=\"$title\""; # $title already quoted - } - $result .= $attr; - $result .= $this->empty_element_suffix; - - return $this->hashPart($result); - } - - - protected function doHeaders($text) { - # - # Redefined to add id and class attribute support. - # - # Setext-style headers: - # Header 1 {#header1} - # ======== - # - # Header 2 {#header2 .class1 .class2} - # -------- - # - $text = preg_replace_callback( - '{ - (^.+?) # $1: Header text - (?:[ ]+ '.$this->id_class_attr_catch_re.' )? # $3 = id/class attributes - [ ]*\n(=+|-+)[ ]*\n+ # $3: Header footer - }mx', - array($this, '_doHeaders_callback_setext'), $text); - - # atx-style headers: - # # Header 1 {#header1} - # ## Header 2 {#header2} - # ## Header 2 with closing hashes ## {#header3.class1.class2} - # ... - # ###### Header 6 {.class2} - # - $text = preg_replace_callback('{ - ^(\#{1,6}) # $1 = string of #\'s - [ ]* - (.+?) # $2 = Header text - [ ]* - \#* # optional closing #\'s (not counted) - (?:[ ]+ '.$this->id_class_attr_catch_re.' )? # $3 = id/class attributes - [ ]* - \n+ - }xm', - array($this, '_doHeaders_callback_atx'), $text); - - return $text; - } - protected function _doHeaders_callback_setext($matches) { - if ($matches[3] == '-' && preg_match('{^- }', $matches[1])) - return $matches[0]; - $level = $matches[3]{0} == '=' ? 1 : 2; - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[2]); - $block = "".$this->runSpanGamut($matches[1]).""; - return "\n" . $this->hashBlock($block) . "\n\n"; - } - protected function _doHeaders_callback_atx($matches) { - $level = strlen($matches[1]); - $attr = $this->doExtraAttributes("h$level", $dummy =& $matches[3]); - $block = "".$this->runSpanGamut($matches[2]).""; - return "\n" . $this->hashBlock($block) . "\n\n"; - } - - - protected function doTables($text) { - # - # Form HTML tables. - # - $less_than_tab = $this->tab_width - 1; - # - # Find tables with leading pipe. - # - # | Header 1 | Header 2 - # | -------- | -------- - # | Cell 1 | Cell 2 - # | Cell 3 | Cell 4 - # - $text = preg_replace_callback(' - { - ^ # Start of a line - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. - [|] # Optional leading pipe (present) - (.+) \n # $1: Header row (at least one pipe) - - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. - [|] ([ ]*[-:]+[-| :]*) \n # $2: Header underline - - ( # $3: Cells - (?> - [ ]* # Allowed whitespace. - [|] .* \n # Row content. - )* - ) - (?=\n|\Z) # Stop at final double newline. - }xm', - array($this, '_doTable_leadingPipe_callback'), $text); - - # - # Find tables without leading pipe. - # - # Header 1 | Header 2 - # -------- | -------- - # Cell 1 | Cell 2 - # Cell 3 | Cell 4 - # - $text = preg_replace_callback(' - { - ^ # Start of a line - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. - (\S.*[|].*) \n # $1: Header row (at least one pipe) - - [ ]{0,'.$less_than_tab.'} # Allowed whitespace. - ([-:]+[ ]*[|][-| :]*) \n # $2: Header underline - - ( # $3: Cells - (?> - .* [|] .* \n # Row content - )* - ) - (?=\n|\Z) # Stop at final double newline. - }xm', - array($this, '_DoTable_callback'), $text); - - return $text; - } - protected function _doTable_leadingPipe_callback($matches) { - $head = $matches[1]; - $underline = $matches[2]; - $content = $matches[3]; - - # Remove leading pipe for each row. - $content = preg_replace('/^ *[|]/m', '', $content); - - return $this->_doTable_callback(array($matches[0], $head, $underline, $content)); - } - protected function _doTable_makeAlignAttr($alignname) - { - if (empty($this->table_align_class_tmpl)) - return " align=\"$alignname\""; - - $classname = str_replace('%%', $alignname, $this->table_align_class_tmpl); - return " class=\"$classname\""; - } - protected function _doTable_callback($matches) { - $head = $matches[1]; - $underline = $matches[2]; - $content = $matches[3]; - - # Remove any tailing pipes for each line. - $head = preg_replace('/[|] *$/m', '', $head); - $underline = preg_replace('/[|] *$/m', '', $underline); - $content = preg_replace('/[|] *$/m', '', $content); - - # Reading alignement from header underline. - $separators = preg_split('/ *[|] */', $underline); - foreach ($separators as $n => $s) { - if (preg_match('/^ *-+: *$/', $s)) - $attr[$n] = $this->_doTable_makeAlignAttr('right'); - else if (preg_match('/^ *:-+: *$/', $s)) - $attr[$n] = $this->_doTable_makeAlignAttr('center'); - else if (preg_match('/^ *:-+ *$/', $s)) - $attr[$n] = $this->_doTable_makeAlignAttr('left'); - else - $attr[$n] = ''; - } - - # Parsing span elements, including code spans, character escapes, - # and inline HTML tags, so that pipes inside those gets ignored. - $head = $this->parseSpan($head); - $headers = preg_split('/ *[|] */', $head); - $col_count = count($headers); - $attr = array_pad($attr, $col_count, ''); - - # Write column headers. - $text = "\n"; - $text .= "\n"; - $text .= "\n"; - foreach ($headers as $n => $header) - $text .= " ".$this->runSpanGamut(trim($header))."\n"; - $text .= "\n"; - $text .= "\n"; - - # Split content by row. - $rows = explode("\n", trim($content, "\n")); - - $text .= "\n"; - foreach ($rows as $row) { - # Parsing span elements, including code spans, character escapes, - # and inline HTML tags, so that pipes inside those gets ignored. - $row = $this->parseSpan($row); - - # Split row by cell. - $row_cells = preg_split('/ *[|] */', $row, $col_count); - $row_cells = array_pad($row_cells, $col_count, ''); - - $text .= "\n"; - foreach ($row_cells as $n => $cell) - $text .= " ".$this->runSpanGamut(trim($cell))."\n"; - $text .= "\n"; - } - $text .= "\n"; - $text .= "
    "; - - return $this->hashBlock($text) . "\n"; - } - - - protected function doDefLists($text) { - # - # Form HTML definition lists. - # - $less_than_tab = $this->tab_width - 1; - - # Re-usable pattern to match any entire dl list: - $whole_list_re = '(?> - ( # $1 = whole list - ( # $2 - [ ]{0,'.$less_than_tab.'} - ((?>.*\S.*\n)+) # $3 = defined term - \n? - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition - ) - (?s:.+?) - ( # $4 - \z - | - \n{2,} - (?=\S) - (?! # Negative lookahead for another term - [ ]{0,'.$less_than_tab.'} - (?: \S.*\n )+? # defined term - \n? - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition - ) - (?! # Negative lookahead for another definition - [ ]{0,'.$less_than_tab.'}:[ ]+ # colon starting definition - ) - ) - ) - )'; // mx - - $text = preg_replace_callback('{ - (?>\A\n?|(?<=\n\n)) - '.$whole_list_re.' - }mx', - array($this, '_doDefLists_callback'), $text); - - return $text; - } - protected function _doDefLists_callback($matches) { - # Re-usable patterns to match list item bullets and number markers: - $list = $matches[1]; - - # Turn double returns into triple returns, so that we can make a - # paragraph for the last item in a list, if necessary: - $result = trim($this->processDefListItems($list)); - $result = "
    \n" . $result . "\n
    "; - return $this->hashBlock($result) . "\n\n"; - } - - - protected function processDefListItems($list_str) { - # - # Process the contents of a single definition list, splitting it - # into individual term and definition list items. - # - $less_than_tab = $this->tab_width - 1; - - # trim trailing blank lines: - $list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str); - - # Process definition terms. - $list_str = preg_replace_callback('{ - (?>\A\n?|\n\n+) # leading line - ( # definition terms = $1 - [ ]{0,'.$less_than_tab.'} # leading whitespace - (?!\:[ ]|[ ]) # negative lookahead for a definition - # mark (colon) or more whitespace. - (?> \S.* \n)+? # actual term (not whitespace). - ) - (?=\n?[ ]{0,3}:[ ]) # lookahead for following line feed - # with a definition mark. - }xm', - array($this, '_processDefListItems_callback_dt'), $list_str); - - # Process actual definitions. - $list_str = preg_replace_callback('{ - \n(\n+)? # leading line = $1 - ( # marker space = $2 - [ ]{0,'.$less_than_tab.'} # whitespace before colon - \:[ ]+ # definition mark (colon) - ) - ((?s:.+?)) # definition text = $3 - (?= \n+ # stop at next definition mark, - (?: # next term or end of text - [ ]{0,'.$less_than_tab.'} \:[ ] | -
    | \z - ) - ) - }xm', - array($this, '_processDefListItems_callback_dd'), $list_str); - - return $list_str; - } - protected function _processDefListItems_callback_dt($matches) { - $terms = explode("\n", trim($matches[1])); - $text = ''; - foreach ($terms as $term) { - $term = $this->runSpanGamut(trim($term)); - $text .= "\n
    " . $term . "
    "; - } - return $text . "\n"; - } - protected function _processDefListItems_callback_dd($matches) { - $leading_line = $matches[1]; - $marker_space = $matches[2]; - $def = $matches[3]; - - if ($leading_line || preg_match('/\n{2,}/', $def)) { - # Replace marker with the appropriate whitespace indentation - $def = str_repeat(' ', strlen($marker_space)) . $def; - $def = $this->runBlockGamut($this->outdent($def . "\n\n")); - $def = "\n". $def ."\n"; - } - else { - $def = rtrim($def); - $def = $this->runSpanGamut($this->outdent($def)); - } - - return "\n
    " . $def . "
    \n"; - } - - - protected function doFencedCodeBlocks($text) { - # - # Adding the fenced code block syntax to regular Markdown: - # - # ~~~ - # Code block - # ~~~ - # - $less_than_tab = $this->tab_width; - - $text = preg_replace_callback('{ - (?:\n|\A) - # 1: Opening marker - ( - (?:~{3,}|`{3,}) # 3 or more tildes/backticks. - ) - [ ]* - (?: - \.?([-_:a-zA-Z0-9]+) # 2: standalone class name - | - '.$this->id_class_attr_catch_re.' # 3: Extra attributes - )? - [ ]* \n # Whitespace and newline following marker. - - # 4: Content - ( - (?> - (?!\1 [ ]* \n) # Not a closing marker. - .*\n+ - )+ - ) - - # Closing marker. - \1 [ ]* (?= \n ) - }xm', - array($this, '_doFencedCodeBlocks_callback'), $text); - - return $text; - } - protected function _doFencedCodeBlocks_callback($matches) { - $classname =& $matches[2]; - $attrs =& $matches[3]; - $codeblock = $matches[4]; - $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES); - $codeblock = preg_replace_callback('/^\n+/', - array($this, '_doFencedCodeBlocks_newlines'), $codeblock); - - if ($classname != "") { - if ($classname{0} == '.') - $classname = substr($classname, 1); - $attr_str = ' class="'.$this->code_class_prefix.$classname.'"'; - } else { - $attr_str = $this->doExtraAttributes($this->code_attr_on_pre ? "pre" : "code", $attrs); - } - $pre_attr_str = $this->code_attr_on_pre ? $attr_str : ''; - $code_attr_str = $this->code_attr_on_pre ? '' : $attr_str; - $codeblock = "$codeblock
    "; - - return "\n\n".$this->hashBlock($codeblock)."\n\n"; - } - protected function _doFencedCodeBlocks_newlines($matches) { - return str_repeat("empty_element_suffix", - strlen($matches[0])); - } - - - # - # Redefining emphasis markers so that emphasis by underscore does not - # work in the middle of a word. - # - protected $em_relist = array( - '' => '(?:(? '(? '(? '(?:(? '(? '(? '(?:(? '(? '(? tags - # - # Strip leading and trailing lines: - $text = preg_replace('/\A\n+|\n+\z/', '', $text); - - $grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY); - - # - # Wrap

    tags and unhashify HTML blocks - # - foreach ($grafs as $key => $value) { - $value = trim($this->runSpanGamut($value)); - - # Check if this should be enclosed in a paragraph. - # Clean tag hashes & block tag hashes are left alone. - $is_p = !preg_match('/^B\x1A[0-9]+B|^C\x1A[0-9]+C$/', $value); - - if ($is_p) { - $value = "

    $value

    "; - } - $grafs[$key] = $value; - } - - # Join grafs in one text, then unhash HTML tags. - $text = implode("\n\n", $grafs); - - # Finish by removing any tag hashes still present in $text. - $text = $this->unhash($text); - - return $text; - } - - - ### Footnotes - - protected function stripFootnotes($text) { - # - # Strips link definitions from text, stores the URLs and titles in - # hash references. - # - $less_than_tab = $this->tab_width - 1; - - # Link defs are in the form: [^id]: url "optional title" - $text = preg_replace_callback('{ - ^[ ]{0,'.$less_than_tab.'}\[\^(.+?)\][ ]?: # note_id = $1 - [ ]* - \n? # maybe *one* newline - ( # text = $2 (no blank lines allowed) - (?: - .+ # actual text - | - \n # newlines but - (?!\[.+?\][ ]?:\s)# negative lookahead for footnote or link definition marker. - (?!\n+[ ]{0,3}\S)# ensure line is not blank and followed - # by non-indented content - )* - ) - }xm', - array($this, '_stripFootnotes_callback'), - $text); - return $text; - } - protected function _stripFootnotes_callback($matches) { - $note_id = $this->fn_id_prefix . $matches[1]; - $this->footnotes[$note_id] = $this->outdent($matches[2]); - return ''; # String that will replace the block - } - - - protected function doFootnotes($text) { - # - # Replace footnote references in $text [^id] with a special text-token - # which will be replaced by the actual footnote marker in appendFootnotes. - # - if (!$this->in_anchor) { - $text = preg_replace('{\[\^(.+?)\]}', "F\x1Afn:\\1\x1A:", $text); - } - return $text; - } - - - protected function appendFootnotes($text) { - # - # Append footnote list to text. - # - $text = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}', - array($this, '_appendFootnotes_callback'), $text); - - if (!empty($this->footnotes_ordered)) { - $text .= "\n\n"; - $text .= "
    \n"; - $text .= "empty_element_suffix ."\n"; - $text .= "
      \n\n"; - - $attr = ""; - if ($this->fn_backlink_class != "") { - $class = $this->fn_backlink_class; - $class = $this->encodeAttribute($class); - $attr .= " class=\"$class\""; - } - if ($this->fn_backlink_title != "") { - $title = $this->fn_backlink_title; - $title = $this->encodeAttribute($title); - $attr .= " title=\"$title\""; - } - $num = 0; - - while (!empty($this->footnotes_ordered)) { - $footnote = reset($this->footnotes_ordered); - $note_id = key($this->footnotes_ordered); - unset($this->footnotes_ordered[$note_id]); - $ref_count = $this->footnotes_ref_count[$note_id]; - unset($this->footnotes_ref_count[$note_id]); - unset($this->footnotes[$note_id]); - - $footnote .= "\n"; # Need to append newline before parsing. - $footnote = $this->runBlockGamut("$footnote\n"); - $footnote = preg_replace_callback('{F\x1Afn:(.*?)\x1A:}', - array($this, '_appendFootnotes_callback'), $footnote); - - $attr = str_replace("%%", ++$num, $attr); - $note_id = $this->encodeAttribute($note_id); - - # Prepare backlink, multiple backlinks if multiple references - $backlink = ""; - for ($ref_num = 2; $ref_num <= $ref_count; ++$ref_num) { - $backlink .= " "; - } - # Add backlink to last paragraph; create new paragraph if needed. - if (preg_match('{

      $}', $footnote)) { - $footnote = substr($footnote, 0, -4) . " $backlink

      "; - } else { - $footnote .= "\n\n

      $backlink

      "; - } - - $text .= "
    1. \n"; - $text .= $footnote . "\n"; - $text .= "
    2. \n\n"; - } - - $text .= "
    \n"; - $text .= "
    "; - } - return $text; - } - protected function _appendFootnotes_callback($matches) { - $node_id = $this->fn_id_prefix . $matches[1]; - - # Create footnote marker only if it has a corresponding footnote *and* - # the footnote hasn't been used by another marker. - if (isset($this->footnotes[$node_id])) { - $num =& $this->footnotes_numbers[$node_id]; - if (!isset($num)) { - # Transfer footnote content to the ordered list and give it its - # number - $this->footnotes_ordered[$node_id] = $this->footnotes[$node_id]; - $this->footnotes_ref_count[$node_id] = 1; - $num = $this->footnote_counter++; - $ref_count_mark = ''; - } else { - $ref_count_mark = $this->footnotes_ref_count[$node_id] += 1; - } - - $attr = ""; - if ($this->fn_link_class != "") { - $class = $this->fn_link_class; - $class = $this->encodeAttribute($class); - $attr .= " class=\"$class\""; - } - if ($this->fn_link_title != "") { - $title = $this->fn_link_title; - $title = $this->encodeAttribute($title); - $attr .= " title=\"$title\""; - } - - $attr = str_replace("%%", $num, $attr); - $node_id = $this->encodeAttribute($node_id); - - return - "". - "$num". - ""; - } - - return "[^".$matches[1]."]"; - } - - - ### Abbreviations ### - - protected function stripAbbreviations($text) { - # - # Strips abbreviations from text, stores titles in hash references. - # - $less_than_tab = $this->tab_width - 1; - - # Link defs are in the form: [id]*: url "optional title" - $text = preg_replace_callback('{ - ^[ ]{0,'.$less_than_tab.'}\*\[(.+?)\][ ]?: # abbr_id = $1 - (.*) # text = $2 (no blank lines allowed) - }xm', - array($this, '_stripAbbreviations_callback'), - $text); - return $text; - } - protected function _stripAbbreviations_callback($matches) { - $abbr_word = $matches[1]; - $abbr_desc = $matches[2]; - if ($this->abbr_word_re) - $this->abbr_word_re .= '|'; - $this->abbr_word_re .= preg_quote($abbr_word); - $this->abbr_desciptions[$abbr_word] = trim($abbr_desc); - return ''; # String that will replace the block - } - - - protected function doAbbreviations($text) { - # - # Find defined abbreviations in text and wrap them in elements. - # - if ($this->abbr_word_re) { - // cannot use the /x modifier because abbr_word_re may - // contain significant spaces: - $text = preg_replace_callback('{'. - '(?abbr_word_re.')'. - '(?![\w\x1A])'. - '}', - array($this, '_doAbbreviations_callback'), $text); - } - return $text; - } - protected function _doAbbreviations_callback($matches) { - $abbr = $matches[0]; - if (isset($this->abbr_desciptions[$abbr])) { - $desc = $this->abbr_desciptions[$abbr]; - if (empty($desc)) { - return $this->hashPart("$abbr"); - } else { - $desc = $this->encodeAttribute($desc); - return $this->hashPart("$abbr"); - } - } else { - return $matches[0]; - } - } - -} diff --git a/system/vendor/michelf/php-markdown/Michelf/MarkdownExtra.inc.php b/system/vendor/michelf/php-markdown/Michelf/MarkdownExtra.inc.php deleted file mode 100644 index e11b1ef..0000000 --- a/system/vendor/michelf/php-markdown/Michelf/MarkdownExtra.inc.php +++ /dev/null @@ -1,11 +0,0 @@ - -# -# Original Markdown -# Copyright (c) 2004-2006 John Gruber -# -# -namespace Michelf; - - -# Just force Michelf/Markdown.php to load. This is needed to load -# the temporary implementation class. See below for details. -\Michelf\Markdown::MARKDOWNLIB_VERSION; - -# -# Markdown Extra Parser Class -# -# Note: Currently the implementation resides in the temporary class -# \Michelf\MarkdownExtra_TmpImpl (in the same file as \Michelf\Markdown). -# This makes it easier to propagate the changes between the three different -# packaging styles of PHP Markdown. Once this issue is resolved, the -# _MarkdownExtra_TmpImpl will disappear and this one will contain the code. -# - -class MarkdownExtra extends \Michelf\_MarkdownExtra_TmpImpl { - - ### Parser Implementation ### - - # Temporarily, the implemenation is in the _MarkdownExtra_TmpImpl class. - # See note above. - -} - diff --git a/system/vendor/michelf/php-markdown/Michelf/MarkdownInterface.inc.php b/system/vendor/michelf/php-markdown/Michelf/MarkdownInterface.inc.php deleted file mode 100644 index a023ed4..0000000 --- a/system/vendor/michelf/php-markdown/Michelf/MarkdownInterface.inc.php +++ /dev/null @@ -1,9 +0,0 @@ - -# -# Original Markdown -# Copyright (c) 2004-2006 John Gruber -# -# -namespace Michelf; - - -# -# Markdown Parser Interface -# - -interface MarkdownInterface { - - # - # Initialize the parser and return the result of its transform method. - # This will work fine for derived classes too. - # - public static function defaultTransform($text); - - # - # Main function. Performs some preprocessing on the input text - # and pass it through the document gamut. - # - public function transform($text); - -} - - -?> \ No newline at end of file diff --git a/system/vendor/michelf/php-markdown/Readme.md b/system/vendor/michelf/php-markdown/Readme.md deleted file mode 100644 index 0bccd69..0000000 --- a/system/vendor/michelf/php-markdown/Readme.md +++ /dev/null @@ -1,305 +0,0 @@ -PHP Markdown -============ - -PHP Markdown Lib 1.4.1 - 4 May 2013 - -by Michel Fortin - - -based on Markdown by John Gruber - - - -Introduction ------------- - -This is a library package that includes the PHP Markdown parser and its -sibling PHP Markdown Extra with additional features. - -Markdown is a text-to-HTML conversion tool for web writers. Markdown -allows you to write using an easy-to-read, easy-to-write plain text -format, then convert it to structurally valid XHTML (or HTML). - -"Markdown" is actually two things: a plain text markup syntax, and a -software tool, originally written in Perl, that converts the plain text -markup to HTML. PHP Markdown is a port to PHP of the original Markdown -program by John Gruber. - -* [Full documentation of the Markdown syntax]() - - Daring Fireball (John Gruber) -* [Markdown Extra syntax additions]() - - Michel Fortin - - -Requirement ------------ - -This library package requires PHP 5.3 or later. - -Note: The older plugin/library hybrid package for PHP Markdown and -PHP Markdown Extra is still maintained and will work with PHP 4.0.5 and later. - -Before PHP 5.3.7, pcre.backtrack_limit defaults to 100 000, which is too small -in many situations. You might need to set it to higher values. Later PHP -releases defaults to 1 000 000, which is usually fine. - - -Usage ------ - -This library package is meant to be used with class autoloading. For autoloading -to work, your project needs have setup a PSR-0-compatible autoloader. See the -included Readme.php file for a minimal autoloader setup. (If you cannot use -autoloading, see below.) - -With class autoloading in place, putting the 'Michelf' folder in your -include path should be enough for this to work: - - use \Michelf\Markdown; - $my_html = Markdown::defaultTransform($my_text); - -Markdown Extra syntax is also available the same way: - - use \Michelf\MarkdownExtra; - $my_html = MarkdownExtra::defaultTransform($my_text); - -If you wish to use PHP Markdown with another text filter function -built to parse HTML, you should filter the text *after* the `transform` -function call. This is an example with [PHP SmartyPants][psp]: - - use \Michelf\Markdown, \Michelf\SmartyPants; - $my_html = Markdown::defaultTransform($my_text); - $my_html = SmartyPants::defaultTransform($my_html); - -All these examples are using the static `defaultTransform` static function -found inside the parser class. If you want to customize the parser -configuration, you can also instantiate it directly and change some -configuration variables: - - use \Michelf\MarkdownExtra; - $parser = new MarkdownExtra; - $parser->fn_id_prefix = "post22-"; - $my_html = $parser->transform($my_text); - -To learn more, see the full list of [configuration variables]. - - [configuration variables]: http://michelf.ca/projects/php-markdown/configuration/ - - -### Usage without an autoloader - -If you cannot use class autoloading, you can still use `include` or `require` -to access the parser. To load the `\Michelf\Markdown` parser, do it this way: - - require_once 'Michelf/Markdown.inc.php'; - -Or, if you need the `\Michelf\MarkdownExtra` parser: - - require_once 'Michelf/MarkdownExtra.inc.php'; - -While the plain `.php` files depend on autoloading to work correctly, using the -`.inc.php` files instead will eagerly load the dependencies that would be -loaded on demand if you were using autoloading. - - -Public API and Versioning Policy ---------------------------------- - -Version numbers are of the form *major*.*minor*.*patch*. - -The public API of PHP Markdown consist of the two parser classes `Markdown` -and `MarkdownExtra`, their constructors, the `transform` and `defaultTransform` -functions and their configuration variables. The public API is stable for -a given major version number. It might get additions when the minor version -number increments. - -**Protected members are not considered public API.** This is unconventional -and deserves an explanation. Incrementing the major version number every time -the underlying implementation of something changes is going to give -nonessential version numbers for the vast majority of people who just use the -parser. Protected members are meant to create parser subclasses that behave in -different ways. Very few people create parser subclasses. I don't want to -discourage it by making everything private, but at the same time I can't -guarantee any stable hook between versions if you use protected members. - -**Syntax changes** will increment the minor number for new features, and the -patch number for small corrections. A *new feature* is something that needs a -change in the syntax documentation. Note that since PHP Markdown Lib includes -two parsers, a syntax change for either of them will increment the minor -number. Also note that there is nothing perfectly backward-compatible with the -Markdown syntax: all inputs are always valid, so new features always replace -something that was previously legal, although generally nonsensical to do. - - -Bugs ----- - -To file bug reports please send email to: - - -Please include with your report: (1) the example input; (2) the output you -expected; (3) the output PHP Markdown actually produced. - -If you have a problem where Markdown gives you an empty result, first check -that the backtrack limit is not too low by running `php --info | grep pcre`. -See Installation and Requirement above for details. - - -Development and Testing ------------------------ - -Pull requests for fixing bugs are welcome. Proposed new features are -going meticulously reviewed -- taking into account backward compatibility, -potential side effects, and future extensibility -- before deciding on -acceptance or rejection. - -If you make a pull request that includes changes to the parser please add -tests for what is being changed to [MDTest][] and make a pull request there -too. - - [MDTest]: https://github.com/michelf/mdtest/ - - -Donations ---------- - -If you wish to make a donation that will help me devote more time to -PHP Markdown, please visit [michelf.ca/donate] or send Bitcoin to -[1HiuX34czvVPPdhXbUAsAu7pZcesniDCGH]. - - [michelf.ca/donate]: https://michelf.ca/donate/#!Thanks%20for%20PHP%20Markdown - [1HiuX34czvVPPdhXbUAsAu7pZcesniDCGH]: bitcoin:1HiuX34czvVPPdhXbUAsAu7pZcesniDCGH - - -Version History ---------------- - -PHP Markdown Lib 1.4.1 (4 May 2014) - -* The HTML block parser will now treat `
    ` as a block-level element - (as it should) and no longer wrap it in `

    ` or parse it's content with - the as Markdown syntax (although with Extra you can use `markdown="1"` - if you wish to use the Markdown syntax inside it). - -* The content of `