diff --git a/composer.json b/composer.json index 964b96c..e737829 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,8 @@ "optimize-autoloader": true }, "require": { - "michelf/php-markdown": "1.4.*@dev", - "suin/php-rss-writer": ">=1.0", + "michelf/php-markdown": "~1.4", + "suin/php-rss-writer": "~1", "kanti/hub-updater": "~0.3" }, "autoload": { diff --git a/composer.lock b/composer.lock index e62ec1b..cf4e011 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "fd413dc0819094cfb73068fa24dc1cf0", + "hash": "93444ef16e9607df09bdc196135e9946", "packages": [ { "name": "kanti/hub-updater", - "version": "v0.3.0", + "version": "v0.3.1", "source": { "type": "git", "url": "https://github.com/Kanti/hub-updater.git", - "reference": "c520b71d9e836932e67bae7177b9a8bc49dda032" + "reference": "105bf291983b1323c5916092cc4e170bf987b00c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Kanti/hub-updater/zipball/c520b71d9e836932e67bae7177b9a8bc49dda032", - "reference": "c520b71d9e836932e67bae7177b9a8bc49dda032", + "url": "https://api.github.com/repos/Kanti/hub-updater/zipball/105bf291983b1323c5916092cc4e170bf987b00c", + "reference": "105bf291983b1323c5916092cc4e170bf987b00c", "shasum": "" }, "require": { @@ -42,20 +42,20 @@ } ], "description": "Simple Github Updater for Web Projects", - "time": "2014-12-12 17:28:13" + "time": "2014-12-27 13:59:09" }, { "name": "michelf/php-markdown", - "version": "dev-lib", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/michelf/php-markdown.git", - "reference": "1b5a30e13974b490964a1610bab5958e83cd4b69" + "reference": "de9a19c7bf352d41cc99ed86c3c0ef17e87394b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/michelf/php-markdown/zipball/1b5a30e13974b490964a1610bab5958e83cd4b69", - "reference": "1b5a30e13974b490964a1610bab5958e83cd4b69", + "url": "https://api.github.com/repos/michelf/php-markdown/zipball/de9a19c7bf352d41cc99ed86c3c0ef17e87394b6", + "reference": "de9a19c7bf352d41cc99ed86c3c0ef17e87394b6", "shasum": "" }, "require": { @@ -93,7 +93,7 @@ "keywords": [ "markdown" ], - "time": "2014-12-08 02:09:55" + "time": "2014-05-05 02:43:50" }, { "name": "suin/php-rss-writer", @@ -144,9 +144,7 @@ "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "michelf/php-markdown": 20 - }, + "stability-flags": [], "prefer-stable": false, "platform": [], "platform-dev": [] diff --git a/system/admin/views/config.html.php b/system/admin/views/config.html.php new file mode 100644 index 0000000..cb1f9ab --- /dev/null +++ b/system/admin/views/config.html.php @@ -0,0 +1,44 @@ +

Your Settings:

+

+ hint: Use Ctrl/CMD⌘ + F to search for your config key or value. +

+
+ + + + + + + + "hallo", + ]; + if (file_exists($config_file)) { + $array = parse_ini_file($config_file, true); + } + function valueMaker($value) + { + if (is_string($value)) + return htmlspecialchars($value); + + if ($value === true) + return "true"; + if ($value === false) + return "false"; + + if ($value == false) + return "0"; + return (string)$value; + } + foreach ($array as $key => $value) { + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
+ +
diff --git a/system/admin/views/updated-to.html.php b/system/admin/views/updated-to.html.php index 737e6d7..4bdf41a 100644 --- a/system/admin/views/updated-to.html.php +++ b/system/admin/views/updated-to.html.php @@ -1,6 +1,6 @@

Updated to

[]

-

+

head_contents('Config - ' . blog_title(), blog_description(), site_url()), + 'bodyclass' => 'config', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Config' + )); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + + +// Config page +post('/admin/config', function () { + error_reporting(E_ALL); + ini_set("display_errors", 1); + + $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); + if (login() && $proper) { + $newKey = from($_REQUEST, 'newKey'); + $newValue = from($_REQUEST, 'newValue'); + + $new_config = array(); + $new_Keys = array(); + if(!empty($newKey)){ + $new_Keys[$newKey] = $newValue; + } + foreach($_POST as $name => $value){ + if(substr($name,0,8) == "-config-"){ + $name = str_replace("_", ".",substr($name,8)); + $new_config[$name] = $value; + } + } + save_config($new_config, $new_Keys); + $login = site_url() . 'admin/config'; + header("location: $login"); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + // Backup page get('/admin/backup', function () { if (login()) { diff --git a/system/includes/dispatch.php b/system/includes/dispatch.php index 2b45b03..ceb4d4e 100644 --- a/system/includes/dispatch.php +++ b/system/includes/dispatch.php @@ -52,6 +52,24 @@ function config($key, $value = null) $_config[$key] = $value; } +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); + $string = preg_replace("/^" . $word . " = .+$/m", $word . ' = "' . $value . '"', $string); + } + $string = rtrim($string); + foreach ($new as $word => $value) { + $value = str_replace('"','\"',$value); + $string .= "\n" . $word . ' = "' . $value . '"' . "\n"; + } + $string = rtrim($string); + return file_put_contents($config_file, $string); +} + function to_b64($str) { $str = base64_encode($str); diff --git a/system/includes/functions.php b/system/includes/functions.php index 33b952b..2595456 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -1662,10 +1662,11 @@ EOF; echo '
  • Edit profile
  • '; echo '
  • Import
  • '; echo '
  • Backup
  • '; + echo '
  • Config
  • '; echo '
  • Clear cache
  • '; if ($updater->able()) { $info = $updater->getNewestInfo(); - echo '
  • Update to ' . $info['tag_name'] . '
  • '; + echo '
  • Update to ' . $info['tag_name'] . '
  • '; } echo '
  • Logout
  • '; diff --git a/system/vendor/autoload.php b/system/vendor/autoload.php index 2dd86a2..2677d4a 100644 --- a/system/vendor/autoload.php +++ b/system/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit4e8efbd787f4b484a9c0ae0966c85f83::getLoader(); +return ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1::getLoader(); diff --git a/system/vendor/composer/ClassLoader.php b/system/vendor/composer/ClassLoader.php index 4433649..70d78bc 100644 --- a/system/vendor/composer/ClassLoader.php +++ b/system/vendor/composer/ClassLoader.php @@ -56,7 +56,11 @@ class ClassLoader public function getPrefixes() { - return call_user_func_array('array_merge', $this->prefixesPsr0); + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); } public function getPrefixesPsr4() diff --git a/system/vendor/composer/autoload_real.php b/system/vendor/composer/autoload_real.php index a3f15bf..7593687 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 ComposerAutoloaderInit4e8efbd787f4b484a9c0ae0966c85f83 +class ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1 { private static $loader; @@ -19,9 +19,9 @@ class ComposerAutoloaderInit4e8efbd787f4b484a9c0ae0966c85f83 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit4e8efbd787f4b484a9c0ae0966c85f83', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit4e8efbd787f4b484a9c0ae0966c85f83', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1', 'loadClassLoader')); $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -42,14 +42,14 @@ class ComposerAutoloaderInit4e8efbd787f4b484a9c0ae0966c85f83 $includeFiles = require __DIR__ . '/autoload_files.php'; foreach ($includeFiles as $file) { - composerRequire4e8efbd787f4b484a9c0ae0966c85f83($file); + composerRequire202d771b98d07410d9e52c5a90cbc9e1($file); } return $loader; } } -function composerRequire4e8efbd787f4b484a9c0ae0966c85f83($file) +function composerRequire202d771b98d07410d9e52c5a90cbc9e1($file) { require $file; } diff --git a/system/vendor/composer/installed.json b/system/vendor/composer/installed.json index 2c6fc78..6a4582f 100644 --- a/system/vendor/composer/installed.json +++ b/system/vendor/composer/installed.json @@ -1,57 +1,4 @@ [ - { - "name": "michelf/php-markdown", - "version": "dev-lib", - "version_normalized": "dev-lib", - "source": { - "type": "git", - "url": "https://github.com/michelf/php-markdown.git", - "reference": "1b5a30e13974b490964a1610bab5958e83cd4b69" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/michelf/php-markdown/zipball/1b5a30e13974b490964a1610bab5958e83cd4b69", - "reference": "1b5a30e13974b490964a1610bab5958e83cd4b69", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2014-12-08 02:09:55", - "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": "suin/php-rss-writer", "version": "1.3", @@ -101,25 +48,25 @@ }, { "name": "kanti/hub-updater", - "version": "v0.3.0", - "version_normalized": "0.3.0.0", + "version": "v0.3.1", + "version_normalized": "0.3.1.0", "source": { "type": "git", "url": "https://github.com/Kanti/hub-updater.git", - "reference": "c520b71d9e836932e67bae7177b9a8bc49dda032" + "reference": "105bf291983b1323c5916092cc4e170bf987b00c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Kanti/hub-updater/zipball/c520b71d9e836932e67bae7177b9a8bc49dda032", - "reference": "c520b71d9e836932e67bae7177b9a8bc49dda032", + "url": "https://api.github.com/repos/Kanti/hub-updater/zipball/105bf291983b1323c5916092cc4e170bf987b00c", + "reference": "105bf291983b1323c5916092cc4e170bf987b00c", "shasum": "" }, "require": { "php": ">=5.3.0" }, - "time": "2014-12-12 17:28:13", + "time": "2014-12-27 13:59:09", "type": "library", - "installation-source": "source", + "installation-source": "dist", "autoload": { "psr-4": { "Kanti\\": "" @@ -138,5 +85,58 @@ } ], "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" + ] } ] diff --git a/system/vendor/kanti/hub-updater/HubUpdater.php b/system/vendor/kanti/hub-updater/HubUpdater.php index 878851a..0e33e30 100644 --- a/system/vendor/kanti/hub-updater/HubUpdater.php +++ b/system/vendor/kanti/hub-updater/HubUpdater.php @@ -17,8 +17,8 @@ class HubUpdater "cache" => "cache/", "save" => "", "prerelease" => false, - - "exceptions" => false, + + "exceptions" => false, ); protected $allRelease = array(); @@ -26,9 +26,9 @@ class HubUpdater public function __construct($option) { - //options + //options if (is_array($option)) { - if (! isset($option['name'])) { + if (!isset($option['name'])) { throw new \Exception('No Name in Option Set'); } $this->options = $option + $this->options; @@ -52,15 +52,15 @@ class HubUpdater mkdir($this->options['cache']); } } - $caBundleDir = dirname(__FILE__); - if (HelperClass::isInPhar()) { - $caBundleDir = dirname($_SERVER["SCRIPT_FILENAME"]) . "/" . $this->options['cache']; - if (! HelperClass::fileExists($this->options['cache'] . "ca_bundle.crt")) { - copy(dirname(__FILE__) . "/ca_bundle.crt",$caBundleDir . "ca_bundle.crt"); + $caBundleDir = dirname(__FILE__); + if (HelperClass::isInPhar()) { + $caBundleDir = dirname($_SERVER["SCRIPT_FILENAME"]) . "/" . $this->options['cache']; + if (!HelperClass::fileExists($this->options['cache'] . "ca_bundle.crt")) { + copy(dirname(__FILE__) . "/ca_bundle.crt", $caBundleDir . "ca_bundle.crt"); } - } + } - $this->cachedInfo = new CacheOneFile(dirname($_SERVER["SCRIPT_FILENAME"]) . "/" . $this->options['cache'] . $this->options['cacheFile'],$this->options['holdTime']); + $this->cachedInfo = new CacheOneFile(dirname($_SERVER["SCRIPT_FILENAME"]) . "/" . $this->options['cache'] . $this->options['cacheFile'], $this->options['holdTime']); $this->streamContext = stream_context_create( array( @@ -89,35 +89,39 @@ class HubUpdater protected function getRemoteInfos() { - $path = "https://api.github.com/repos/" . $this->options['name'] ."/releases"; + $path = "https://api.github.com/repos/" . $this->options['name'] . "/releases"; if ($this->cachedInfo->is()) { $fileContent = $this->cachedInfo->get(); } else { if (!in_array('https', stream_get_wrappers())) { - if($this->options["exceptions"]){ - throw new \Exception("No HTTPS Wrapper Exception"); - } else { - return array(); - } + if ($this->options["exceptions"]) { + throw new \Exception("No HTTPS Wrapper Exception"); + } else { + return array(); + } } $fileContent = @file_get_contents($path, false, $this->streamContext); if ($fileContent === false) { - if($this->options["exceptions"]){ - throw new \Exception("No Internet Exception"); - } else { - return array(); - } + if ($this->options["exceptions"]) { + throw new \Exception("No Internet Exception"); + } else { + return array(); + } } $json = json_decode($fileContent, true); if (isset($json['message'])) { - if($this->options["exceptions"]){ - throw new \Exception("API Exception[" . $json['message'] . "]"); - } else { - $json = array(); - } + if ($this->options["exceptions"]) { + throw new \Exception("API Exception[" . $json['message'] . "]"); + } else { + $json = array(); + } + } + if (defined("JSON_PRETTY_PRINT")) { + $fileContent = json_encode($json, JSON_PRETTY_PRINT); + } else { + $fileContent = json_encode($json); } - $fileContent = json_encode($json, JSON_PRETTY_PRINT); $this->cachedInfo->set($fileContent); return $json; @@ -134,8 +138,8 @@ class HubUpdater if (empty($this->allRelease)) { return false; } - - $this->getNewestInfo(); + + $this->getNewestInfo(); if (HelperClass::fileExists($this->options['cache'] . $this->options['versionFile'])) { $fileContent = file_get_contents($this->options['cache'] . $this->options['versionFile']); @@ -154,15 +158,22 @@ class HubUpdater public function update() { - $newestRelease = $this->getNewestInfo(); + $newestRelease = $this->getNewestInfo(); if ($this->able()) { if ($this->download($newestRelease['zipball_url'])) { if ($this->unZip()) { unlink($this->options['cache'] . $this->options['zipFile']); - file_put_contents($this->options['cache'] . $this->options['versionFile'], json_encode(array( - "id" => $newestRelease['id'], - "tag_name" => $newestRelease['tag_name'] - ), JSON_PRETTY_PRINT)); + if (defined("JSON_PRETTY_PRINT")) { + file_put_contents($this->options['cache'] . $this->options['versionFile'], json_encode(array( + "id" => $newestRelease['id'], + "tag_name" => $newestRelease['tag_name'] + ), JSON_PRETTY_PRINT)); + } else { + file_put_contents($this->options['cache'] . $this->options['versionFile'], json_encode(array( + "id" => $newestRelease['id'], + "tag_name" => $newestRelease['tag_name'] + ))); + } return true; } @@ -176,11 +187,11 @@ class HubUpdater { $file = @fopen($url, 'r', false, $this->streamContext2); if ($file == false) { - if($this->options["exceptions"]){ - throw new \Exception("Download faild Exception"); - } else { - return false; - } + if ($this->options["exceptions"]) { + throw new \Exception("Download faild Exception"); + } else { + return false; + } } file_put_contents( dirname($_SERVER['SCRIPT_FILENAME']) . "/" . $this->options['cache'] . $this->options['zipFile'], @@ -197,7 +208,7 @@ class HubUpdater $updateIgnore = array(); if (HelperClass::fileExists($this->options['updateignore'])) { $updateIgnore = file($this->options['updateignore']); - foreach($updateIgnore as &$ignore) { + foreach ($updateIgnore as &$ignore) { $ignore = $this->options['save'] . trim($ignore); } } @@ -207,16 +218,16 @@ class HubUpdater $cutLength = strlen($zip->getNameIndex(0)); for ($i = 1; $i < $zip->numFiles; $i++) {//iterate throw the Zip $name = $this->options['save'] . substr($zip->getNameIndex($i), $cutLength); - + $do = true; - - foreach($updateIgnore as $ignore) { + + foreach ($updateIgnore as $ignore) { if (substr($name, 0, strlen($ignore)) == $ignore) { $do = false; break; } } - + if ($do) { $stat = $zip->statIndex($i); if ($stat["crc"] == 0) { @@ -235,38 +246,38 @@ class HubUpdater return false; } } - - public function getCurrentInfo() - { - if(isset($this->currentInfo)) { - return $this->currentInfo; - } - - $this->currentInfo = null; + + public function getCurrentInfo() + { + if (isset($this->currentInfo)) { + return $this->currentInfo; + } + + $this->currentInfo = null; if (HelperClass::fileExists($this->options['cache'] . $this->options['versionFile'])) { - $fileContent = file_get_contents($this->options['cache'] . $this->options['versionFile']); - $current = json_decode($fileContent, true); - - foreach ($this->allRelease as $release) { - if (isset($current['id']) && $current['id'] == $release['id']) { - $this->currentInfo = $release; - break; - } - if (isset($current['tag_name']) && $current['tag_name'] == $release['tag_name']) { - $this->currentInfo = $release; - break; - } - } - } - return $this->currentInfo; - } - - public function getNewestInfo() - { - if(isset($this->newestInfo)) { - return $this->newestInfo; - } - + $fileContent = file_get_contents($this->options['cache'] . $this->options['versionFile']); + $current = json_decode($fileContent, true); + + foreach ($this->allRelease as $release) { + if (isset($current['id']) && $current['id'] == $release['id']) { + $this->currentInfo = $release; + break; + } + if (isset($current['tag_name']) && $current['tag_name'] == $release['tag_name']) { + $this->currentInfo = $release; + break; + } + } + } + return $this->currentInfo; + } + + public function getNewestInfo() + { + if (isset($this->newestInfo)) { + return $this->newestInfo; + } + foreach ($this->allRelease as $release) { if (!$this->options['prerelease'] && $release['prerelease']) { continue; @@ -277,6 +288,6 @@ class HubUpdater $this->newestInfo = $release; break; } - return $this->newestInfo; - } + return $this->newestInfo; + } } diff --git a/system/vendor/michelf/php-markdown/Michelf/Markdown.php b/system/vendor/michelf/php-markdown/Michelf/Markdown.php index c8ced89..0d37012 100644 --- a/system/vendor/michelf/php-markdown/Michelf/Markdown.php +++ b/system/vendor/michelf/php-markdown/Michelf/Markdown.php @@ -59,9 +59,6 @@ class Markdown implements MarkdownInterface { public $predef_urls = array(); public $predef_titles = array(); - # Optional filter function for URLs - public $url_filter_func = null; - ### Parser Implementation ### @@ -596,7 +593,7 @@ class Markdown implements MarkdownInterface { if (isset($this->urls[$link_id])) { $url = $this->urls[$link_id]; - $url = $this->encodeURLAttribute($url); + $url = $this->encodeAttribute($url); $result = "titles[$link_id] ) ) { @@ -626,7 +623,7 @@ class Markdown implements MarkdownInterface { if ($unhashed != $url) $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); - $url = $this->encodeURLAttribute($url); + $url = $this->encodeAttribute($url); $result = "encodeAttribute($alt_text); if (isset($this->urls[$link_id])) { - $url = $this->encodeURLAttribute($this->urls[$link_id]); + $url = $this->encodeAttribute($this->urls[$link_id]); $result = "\"$alt_text\"";titles[$link_id])) { $title = $this->titles[$link_id]; @@ -731,7 +728,7 @@ class Markdown implements MarkdownInterface { $title =& $matches[7]; $alt_text = $this->encodeAttribute($alt_text); - $url = $this->encodeURLAttribute($url); + $url = $this->encodeAttribute($url); $result = "\"$alt_text\"";encodeAttribute($title); @@ -1263,33 +1260,6 @@ class Markdown implements MarkdownInterface { $text = str_replace('"', '"', $text); return $text; } - - - protected function encodeURLAttribute($url, &$text = null) { - # - # Encode text for a double-quoted HTML attribute containing a URL, - # applying the URL filter if set. Also generates the textual - # representation for the URL (removing mailto: or tel:) storing it in $text. - # This function is *not* suitable for attributes enclosed in single quotes. - # - if ($this->url_filter_func) - $url = call_user_func($this->url_filter_func, $url); - - if (preg_match('{^mailto:}i', $url)) - $url = $this->encodeEntityObfuscatedAttribute($url, $text, 7); - else if (preg_match('{^tel:}i', $url)) - { - $url = $this->encodeAttribute($url); - $text = substr($url, 4); - } - else - { - $url = $this->encodeAttribute($url); - $text = $url; - } - - return $url; - } protected function encodeAmpsAndAngles($text) { @@ -1314,7 +1284,7 @@ class Markdown implements MarkdownInterface { protected function doAutoLinks($text) { - $text = preg_replace_callback('{<((https?|ftp|dict|tel):[^\'">\s]+)>}i', + $text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}i', array($this, '_doAutoLinks_url_callback'), $text); # Email addresses: @@ -1337,46 +1307,48 @@ class Markdown implements MarkdownInterface { > }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->encodeURLAttribute($matches[1], $text); - $link = "$text"; + $url = $this->encodeAttribute($matches[1]); + $link = "$url"; return $this->hashPart($link); } protected function _doAutoLinks_email_callback($matches) { - $addr = $matches[1]; - $url = $this->encodeURLAttribute("mailto:$addr", $text); - $link = "$text"; + $address = $matches[1]; + $link = $this->encodeEmailAddress($address); return $this->hashPart($link); } - protected function encodeEntityObfuscatedAttribute($text, &$tail = null, $head_length = 0) { + protected function encodeEmailAddress($addr) { # - # Input: some text to obfuscate, e.g. "mailto:foo@example.com" + # Input: an email address, e.g. "foo@example.com" # - # Output: the same text but with most characters encoded as either a - # decimal or hex entity, in the hopes of foiling most address - # harvesting spam bots. E.g.: + # 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.: # - # mailto:foo + #

    foo@exampl + # e.com

    # # Based by a filter by Matthew Wickline, posted to BBEdit-Talk. - # With some optimizations by Milian Wolff. Forced encoding of HTML - # attribute special characters by Allan Odgaard. + # With some optimizations by Milian Wolff. # - if ($text == "") return $tail = ""; - - $chars = preg_split('/(? $char) { $ord = ord($char); # Ignore non-ascii chars. @@ -1384,17 +1356,18 @@ class Markdown implements MarkdownInterface { $r = ($seed * (1 + $key)) % 100; # Pseudo-random function. # roughly 10% raw, 45% hex, 45% dec # '@' *must* be encoded. I insist. - # '"' and '>' have to be encoded inside the attribute - if ($r > 90 && strpos('@"&>', $char) === false) /* do nothing */; + # '"' 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"; - $text = implode('', $chars); - $tail = $head_length ? implode('', array_slice($chars, $head_length)) : $text; - - return $text; + return $addr; } @@ -1678,9 +1651,9 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown { ### Extra Attribute Parser ### # Expression to use to catch attributes (includes the braces) - protected $id_class_attr_catch_re = '\{((?:[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,})[ ]*\}'; + 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-z][-_:a-zA-Z0-9=]+){1,}[ ]*\}'; + protected $id_class_attr_nocatch_re = '\{(?:[ ]*[#.][-_:a-zA-Z0-9]+){1,}[ ]*\}'; protected function doExtraAttributes($tag_name, $attr) { # @@ -1692,21 +1665,17 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown { if (empty($attr)) return ""; # Split on components - preg_match_all('/[#.a-z][-_:a-zA-Z0-9=]+/', $attr, $matches); + preg_match_all('/[#.][-_:a-zA-Z0-9]+/', $attr, $matches); $elements = $matches[0]; # handle classes and ids (only first id taken into account) $classes = array(); - $attributes = 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); - } else if (strpos($element, '=') > 0) { - $parts = explode('=', $element, 2); - $attributes[] = $parts[0] . '="' . $parts[1] . '"'; } } @@ -1718,9 +1687,6 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown { if (!empty($classes)) { $attr_str .= ' class="'.implode(" ", $classes).'"'; } - if (!$this->no_markup && !empty($attributes)) { - $attr_str .= ' '.implode(" ", $attributes); - } return $attr_str; } @@ -2330,7 +2296,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown { if (isset($this->urls[$link_id])) { $url = $this->urls[$link_id]; - $url = $this->encodeURLAttribute($url); + $url = $this->encodeAttribute($url); $result = "titles[$link_id] ) ) { @@ -2363,7 +2329,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown { if ($unhashed != $url) $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); - $url = $this->encodeURLAttribute($url); + $url = $this->encodeAttribute($url); $result = "encodeAttribute($alt_text); if (isset($this->urls[$link_id])) { - $url = $this->encodeURLAttribute($this->urls[$link_id]); + $url = $this->encodeAttribute($this->urls[$link_id]); $result = "\"$alt_text\"";titles[$link_id])) { $title = $this->titles[$link_id]; @@ -2473,7 +2439,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown { $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]); $alt_text = $this->encodeAttribute($alt_text); - $url = $this->encodeURLAttribute($url); + $url = $this->encodeAttribute($url); $result = "\"$alt_text\"";encodeAttribute($title); diff --git a/system/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php b/system/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php index e4c2931..f8367ed 100644 --- a/system/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php +++ b/system/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php @@ -32,3 +32,6 @@ interface MarkdownInterface { 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 index 80504c2..0bccd69 100644 --- a/system/vendor/michelf/php-markdown/Readme.md +++ b/system/vendor/michelf/php-markdown/Readme.md @@ -174,16 +174,6 @@ PHP Markdown, please visit [michelf.ca/donate] or send Bitcoin to Version History --------------- -Unreleased - -* Added the ability to insert custom HTML attributes everywhere an extra - attribute block is allowed (links, images, headers). Credits to - Peter Droogmans for providing the implementation. - -* Added a `url_filter_func` configuration variable which takes a function - that can rewrite any link or image URL to something different. - - PHP Markdown Lib 1.4.1 (4 May 2014) * The HTML block parser will now treat `
    ` as a block-level element diff --git a/themes/default/css/toolbar.css b/themes/default/css/toolbar.css index a7d13f9..5813c6d 100644 --- a/themes/default/css/toolbar.css +++ b/themes/default/css/toolbar.css @@ -1 +1 @@ -body{ padding-top:30px;}#toolbar {background: #666666;box-shadow: 0 5px 15px #000000;color: #CCCCCC;font-family: Georgia, sans-serif;left: 0;margin: 0 -20px;padding: 0 25px;position: fixed;right: 0;top: 0;z-index: 600;border: 0 none;font-size: 15px;text-align: left;vertical-align: baseline;min-height:30px;}#toolbar ul {margin:0;padding-top:5px;padding-bottom:5px;padding-left:30px;float:left;}#toolbar ul li, #toolbar ul li a {float: left;list-style: none outside none;margin:0;}#toolbar a {color: #FFFFFF;font-size: 0.846em;text-decoration: none;border-radius: 10px;padding: 0 10px;line-height:1.6;} @media all and (max-width: 550px) {body{ padding-top:60px;}} \ No newline at end of file +body{padding-top:30px}#toolbar{background:#666;box-shadow:0 5px 15px #000;color:#CCC;font-family:Georgia,sans-serif;left:0;margin:0 -20px;padding:0 25px;position:fixed;right:0;top:0;z-index:600;border:0;font-size:15px;text-align:left;vertical-align:baseline;min-height:30px}#toolbar ul{margin:0;padding-top:5px;padding-bottom:5px;padding-left:30px;float:left}#toolbar ul li,#toolbar ul li a{float:left;list-style:none;margin:0}#toolbar a{color:#FFF;font-size:.846em;text-decoration:none;border-radius:10px;padding:0 10px;line-height:1.6}@media all and (max-width:550px){body{padding-top:60px}}table#config td:first-child{width:30%}table#config td:last-child{width:70%}table#config input{width:100%;box-sizing:border-box}table#config tr:last-child td{border-bottom:none} \ No newline at end of file