Browse Source

Merge pull request #135 from Kanti/master

[TASK] added Admin tab Config
pull/146/merge
Kanti 11 years ago
parent
commit
905c3d1369
16 changed files with 337 additions and 253 deletions
  1. +2
    -2
      composer.json
  2. +12
    -14
      composer.lock
  3. +44
    -0
      system/admin/views/config.html.php
  4. +1
    -1
      system/admin/views/updated-to.html.php
  5. +51
    -2
      system/htmly.php
  6. +18
    -0
      system/includes/dispatch.php
  7. +2
    -1
      system/includes/functions.php
  8. +1
    -1
      system/vendor/autoload.php
  9. +5
    -1
      system/vendor/composer/ClassLoader.php
  10. +5
    -5
      system/vendor/composer/autoload_real.php
  11. +60
    -60
      system/vendor/composer/installed.json
  12. +89
    -78
      system/vendor/kanti/hub-updater/HubUpdater.php
  13. +43
    -77
      system/vendor/michelf/php-markdown/Michelf/Markdown.php
  14. +3
    -0
      system/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php
  15. +0
    -10
      system/vendor/michelf/php-markdown/Readme.md
  16. +1
    -1
      themes/default/css/toolbar.css

+ 2
- 2
composer.json View File

@ -4,8 +4,8 @@
"optimize-autoloader": true "optimize-autoloader": true
}, },
"require": { "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" "kanti/hub-updater": "~0.3"
}, },
"autoload": { "autoload": {


+ 12
- 14
composer.lock View File

@ -4,20 +4,20 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "fd413dc0819094cfb73068fa24dc1cf0",
"hash": "93444ef16e9607df09bdc196135e9946",
"packages": [ "packages": [
{ {
"name": "kanti/hub-updater", "name": "kanti/hub-updater",
"version": "v0.3.0",
"version": "v0.3.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Kanti/hub-updater.git", "url": "https://github.com/Kanti/hub-updater.git",
"reference": "c520b71d9e836932e67bae7177b9a8bc49dda032"
"reference": "105bf291983b1323c5916092cc4e170bf987b00c"
}, },
"dist": { "dist": {
"type": "zip", "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": "" "shasum": ""
}, },
"require": { "require": {
@ -42,20 +42,20 @@
} }
], ],
"description": "Simple Github Updater for Web Projects", "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", "name": "michelf/php-markdown",
"version": "dev-lib",
"version": "1.4.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/michelf/php-markdown.git", "url": "https://github.com/michelf/php-markdown.git",
"reference": "1b5a30e13974b490964a1610bab5958e83cd4b69"
"reference": "de9a19c7bf352d41cc99ed86c3c0ef17e87394b6"
}, },
"dist": { "dist": {
"type": "zip", "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": "" "shasum": ""
}, },
"require": { "require": {
@ -93,7 +93,7 @@
"keywords": [ "keywords": [
"markdown" "markdown"
], ],
"time": "2014-12-08 02:09:55"
"time": "2014-05-05 02:43:50"
}, },
{ {
"name": "suin/php-rss-writer", "name": "suin/php-rss-writer",
@ -144,9 +144,7 @@
"packages-dev": [], "packages-dev": [],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": {
"michelf/php-markdown": 20
},
"stability-flags": [],
"prefer-stable": false, "prefer-stable": false,
"platform": [], "platform": [],
"platform-dev": [] "platform-dev": []


+ 44
- 0
system/admin/views/config.html.php View File

@ -0,0 +1,44 @@
<h2>Your Settings:</h2>
<p>
<u>hint:</u> Use <code>Ctrl</code>/<code>CMD⌘</code> + <code>F</code> to search for your config key or value.
</p>
<form method="POST">
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
<input type="submit">
<table id="config">
<tr>
<td><input type="text" name="newKey" placeholder="Your New Config Key"></td>
<td><input type="text" name="newValue" placeholder="Your New Value"></td>
</tr>
<?php
global $config_file;
$array = [
"google.wmt" => "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 '<tr>';
echo '<td><label for="' . $key . '">' . $key . '</label></td>';
echo '<td><input type="text" name="-config-' . $key . '" value="' . valueMaker($value) . '"></td>';
echo '</tr>';
}
?>
</table>
<input type="submit">
</form>

+ 1
- 1
system/admin/views/updated-to.html.php View File

@ -1,6 +1,6 @@
<h3>Updated to<h3> <h3>Updated to<h3>
<h2>[<?php echo $info['tag_name'];?>] <?php echo $info['name']; ?></h2> <h2>[<?php echo $info['tag_name'];?>] <?php echo $info['name']; ?></h2>
<p><?php echo $info['body'];?></p>
<p><?php echo \Michelf\MarkdownExtra::defaultTransform($info['body']);?></p>
<?php <?php
require_once "system/upgrade/run.php"; require_once "system/upgrade/run.php";

+ 51
- 2
system/htmly.php View File

@ -4,7 +4,8 @@
date_default_timezone_set('Asia/Jakarta'); date_default_timezone_set('Asia/Jakarta');
// Load the configuration file // Load the configuration file
config('source', 'config/config.ini');
$config_file = 'config/config.ini';
config('source', $config_file);
if(config('timezone')) { if(config('timezone')) {
date_default_timezone_set(config('timezone')); date_default_timezone_set(config('timezone'));
} }
@ -995,7 +996,7 @@ post('/admin/import', function () {
$url = from($_REQUEST, 'url'); $url = from($_REQUEST, 'url');
$credit = from($_REQUEST, 'credit'); $credit = from($_REQUEST, 'credit');
if (!empty($url)) {
if (login() && !empty($url) && $proper) {
get_feed($url, $credit); get_feed($url, $credit);
$log = get_feed($url, $credit); $log = get_feed($url, $credit);
@ -1032,6 +1033,54 @@ post('/admin/import', function () {
} }
}); });
// Config page
get('/admin/config', function () {
if (login()) {
config('views.root', 'system/admin/views');
render('config', array(
'head_contents' => head_contents('Config - ' . blog_title(), blog_description(), site_url()),
'bodyclass' => 'config',
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; 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 // Backup page
get('/admin/backup', function () { get('/admin/backup', function () {
if (login()) { if (login()) {


+ 18
- 0
system/includes/dispatch.php View File

@ -52,6 +52,24 @@ function config($key, $value = null)
$_config[$key] = $value; $_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) function to_b64($str)
{ {
$str = base64_encode($str); $str = base64_encode($str);


+ 2
- 1
system/includes/functions.php View File

@ -1662,10 +1662,11 @@ EOF;
echo '<li><a href="' . $base . 'edit/profile">Edit profile</a></li>'; echo '<li><a href="' . $base . 'edit/profile">Edit profile</a></li>';
echo '<li><a href="' . $base . 'admin/import">Import</a></li>'; echo '<li><a href="' . $base . 'admin/import">Import</a></li>';
echo '<li><a href="' . $base . 'admin/backup">Backup</a></li>'; echo '<li><a href="' . $base . 'admin/backup">Backup</a></li>';
echo '<li><a href="' . $base . 'admin/config">Config</a></li>';
echo '<li><a href="' . $base . 'admin/clear-cache">Clear cache</a></li>'; echo '<li><a href="' . $base . 'admin/clear-cache">Clear cache</a></li>';
if ($updater->able()) { if ($updater->able()) {
$info = $updater->getNewestInfo(); $info = $updater->getNewestInfo();
echo '<li><a href="' . $base . 'admin/update/now/' . $CSRF . '">Update to ' . $info['tag_name'] . '</a></li>';
echo '<li><a href="' . $base . 'admin/update/now/' . $CSRF . '" alt="' . $info['name'] . '">Update to ' . $info['tag_name'] . '</a></li>';
} }
echo '<li><a href="' . $base . 'logout">Logout</a></li>'; echo '<li><a href="' . $base . 'logout">Logout</a></li>';


+ 1
- 1
system/vendor/autoload.php View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php'; require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit4e8efbd787f4b484a9c0ae0966c85f83::getLoader();
return ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1::getLoader();

+ 5
- 1
system/vendor/composer/ClassLoader.php View File

@ -56,7 +56,11 @@ class ClassLoader
public function getPrefixes() 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() public function getPrefixesPsr4()


+ 5
- 5
system/vendor/composer/autoload_real.php View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInit4e8efbd787f4b484a9c0ae0966c85f83
class ComposerAutoloaderInit202d771b98d07410d9e52c5a90cbc9e1
{ {
private static $loader; private static $loader;
@ -19,9 +19,9 @@ class ComposerAutoloaderInit4e8efbd787f4b484a9c0ae0966c85f83
return self::$loader; 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(); 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'; $map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) { foreach ($map as $namespace => $path) {
@ -42,14 +42,14 @@ class ComposerAutoloaderInit4e8efbd787f4b484a9c0ae0966c85f83
$includeFiles = require __DIR__ . '/autoload_files.php'; $includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) { foreach ($includeFiles as $file) {
composerRequire4e8efbd787f4b484a9c0ae0966c85f83($file);
composerRequire202d771b98d07410d9e52c5a90cbc9e1($file);
} }
return $loader; return $loader;
} }
} }
function composerRequire4e8efbd787f4b484a9c0ae0966c85f83($file)
function composerRequire202d771b98d07410d9e52c5a90cbc9e1($file)
{ {
require $file; require $file;
} }

+ 60
- 60
system/vendor/composer/installed.json View File

@ -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", "name": "suin/php-rss-writer",
"version": "1.3", "version": "1.3",
@ -101,25 +48,25 @@
}, },
{ {
"name": "kanti/hub-updater", "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": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Kanti/hub-updater.git", "url": "https://github.com/Kanti/hub-updater.git",
"reference": "c520b71d9e836932e67bae7177b9a8bc49dda032"
"reference": "105bf291983b1323c5916092cc4e170bf987b00c"
}, },
"dist": { "dist": {
"type": "zip", "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": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.0" "php": ">=5.3.0"
}, },
"time": "2014-12-12 17:28:13",
"time": "2014-12-27 13:59:09",
"type": "library", "type": "library",
"installation-source": "source",
"installation-source": "dist",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Kanti\\": "" "Kanti\\": ""
@ -138,5 +85,58 @@
} }
], ],
"description": "Simple Github Updater for Web Projects" "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"
]
} }
] ]

+ 89
- 78
system/vendor/kanti/hub-updater/HubUpdater.php View File

@ -17,8 +17,8 @@ class HubUpdater
"cache" => "cache/", "cache" => "cache/",
"save" => "", "save" => "",
"prerelease" => false, "prerelease" => false,
"exceptions" => false,
"exceptions" => false,
); );
protected $allRelease = array(); protected $allRelease = array();
@ -26,9 +26,9 @@ class HubUpdater
public function __construct($option) public function __construct($option)
{ {
//options
//options
if (is_array($option)) { if (is_array($option)) {
if (! isset($option['name'])) {
if (!isset($option['name'])) {
throw new \Exception('No Name in Option Set'); throw new \Exception('No Name in Option Set');
} }
$this->options = $option + $this->options; $this->options = $option + $this->options;
@ -52,15 +52,15 @@ class HubUpdater
mkdir($this->options['cache']); 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( $this->streamContext = stream_context_create(
array( array(
@ -89,35 +89,39 @@ class HubUpdater
protected function getRemoteInfos() 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()) { if ($this->cachedInfo->is()) {
$fileContent = $this->cachedInfo->get(); $fileContent = $this->cachedInfo->get();
} else { } else {
if (!in_array('https', stream_get_wrappers())) { 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); $fileContent = @file_get_contents($path, false, $this->streamContext);
if ($fileContent === false) { 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); $json = json_decode($fileContent, true);
if (isset($json['message'])) { 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); $this->cachedInfo->set($fileContent);
return $json; return $json;
@ -134,8 +138,8 @@ class HubUpdater
if (empty($this->allRelease)) { if (empty($this->allRelease)) {
return false; return false;
} }
$this->getNewestInfo();
$this->getNewestInfo();
if (HelperClass::fileExists($this->options['cache'] . $this->options['versionFile'])) { if (HelperClass::fileExists($this->options['cache'] . $this->options['versionFile'])) {
$fileContent = file_get_contents($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() public function update()
{ {
$newestRelease = $this->getNewestInfo();
$newestRelease = $this->getNewestInfo();
if ($this->able()) { if ($this->able()) {
if ($this->download($newestRelease['zipball_url'])) { if ($this->download($newestRelease['zipball_url'])) {
if ($this->unZip()) { if ($this->unZip()) {
unlink($this->options['cache'] . $this->options['zipFile']); 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; return true;
} }
@ -176,11 +187,11 @@ class HubUpdater
{ {
$file = @fopen($url, 'r', false, $this->streamContext2); $file = @fopen($url, 'r', false, $this->streamContext2);
if ($file == false) { 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( file_put_contents(
dirname($_SERVER['SCRIPT_FILENAME']) . "/" . $this->options['cache'] . $this->options['zipFile'], dirname($_SERVER['SCRIPT_FILENAME']) . "/" . $this->options['cache'] . $this->options['zipFile'],
@ -197,7 +208,7 @@ class HubUpdater
$updateIgnore = array(); $updateIgnore = array();
if (HelperClass::fileExists($this->options['updateignore'])) { if (HelperClass::fileExists($this->options['updateignore'])) {
$updateIgnore = file($this->options['updateignore']); $updateIgnore = file($this->options['updateignore']);
foreach($updateIgnore as &$ignore) {
foreach ($updateIgnore as &$ignore) {
$ignore = $this->options['save'] . trim($ignore); $ignore = $this->options['save'] . trim($ignore);
} }
} }
@ -207,16 +218,16 @@ class HubUpdater
$cutLength = strlen($zip->getNameIndex(0)); $cutLength = strlen($zip->getNameIndex(0));
for ($i = 1; $i < $zip->numFiles; $i++) {//iterate throw the Zip for ($i = 1; $i < $zip->numFiles; $i++) {//iterate throw the Zip
$name = $this->options['save'] . substr($zip->getNameIndex($i), $cutLength); $name = $this->options['save'] . substr($zip->getNameIndex($i), $cutLength);
$do = true; $do = true;
foreach($updateIgnore as $ignore) {
foreach ($updateIgnore as $ignore) {
if (substr($name, 0, strlen($ignore)) == $ignore) { if (substr($name, 0, strlen($ignore)) == $ignore) {
$do = false; $do = false;
break; break;
} }
} }
if ($do) { if ($do) {
$stat = $zip->statIndex($i); $stat = $zip->statIndex($i);
if ($stat["crc"] == 0) { if ($stat["crc"] == 0) {
@ -235,38 +246,38 @@ class HubUpdater
return false; 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'])) { 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) { foreach ($this->allRelease as $release) {
if (!$this->options['prerelease'] && $release['prerelease']) { if (!$this->options['prerelease'] && $release['prerelease']) {
continue; continue;
@ -277,6 +288,6 @@ class HubUpdater
$this->newestInfo = $release; $this->newestInfo = $release;
break; break;
} }
return $this->newestInfo;
}
return $this->newestInfo;
}
} }

+ 43
- 77
system/vendor/michelf/php-markdown/Michelf/Markdown.php View File

@ -59,9 +59,6 @@ class Markdown implements MarkdownInterface {
public $predef_urls = array(); public $predef_urls = array();
public $predef_titles = array(); public $predef_titles = array();
# Optional filter function for URLs
public $url_filter_func = null;
### Parser Implementation ### ### Parser Implementation ###
@ -596,7 +593,7 @@ class Markdown implements MarkdownInterface {
if (isset($this->urls[$link_id])) { if (isset($this->urls[$link_id])) {
$url = $this->urls[$link_id]; $url = $this->urls[$link_id];
$url = $this->encodeURLAttribute($url);
$url = $this->encodeAttribute($url);
$result = "<a href=\"$url\""; $result = "<a href=\"$url\"";
if ( isset( $this->titles[$link_id] ) ) { if ( isset( $this->titles[$link_id] ) ) {
@ -626,7 +623,7 @@ class Markdown implements MarkdownInterface {
if ($unhashed != $url) if ($unhashed != $url)
$url = preg_replace('/^<(.*)>$/', '\1', $unhashed); $url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
$url = $this->encodeURLAttribute($url);
$url = $this->encodeAttribute($url);
$result = "<a href=\"$url\""; $result = "<a href=\"$url\"";
if (isset($title)) { if (isset($title)) {
@ -707,7 +704,7 @@ class Markdown implements MarkdownInterface {
$alt_text = $this->encodeAttribute($alt_text); $alt_text = $this->encodeAttribute($alt_text);
if (isset($this->urls[$link_id])) { if (isset($this->urls[$link_id])) {
$url = $this->encodeURLAttribute($this->urls[$link_id]);
$url = $this->encodeAttribute($this->urls[$link_id]);
$result = "<img src=\"$url\" alt=\"$alt_text\""; $result = "<img src=\"$url\" alt=\"$alt_text\"";
if (isset($this->titles[$link_id])) { if (isset($this->titles[$link_id])) {
$title = $this->titles[$link_id]; $title = $this->titles[$link_id];
@ -731,7 +728,7 @@ class Markdown implements MarkdownInterface {
$title =& $matches[7]; $title =& $matches[7];
$alt_text = $this->encodeAttribute($alt_text); $alt_text = $this->encodeAttribute($alt_text);
$url = $this->encodeURLAttribute($url);
$url = $this->encodeAttribute($url);
$result = "<img src=\"$url\" alt=\"$alt_text\""; $result = "<img src=\"$url\" alt=\"$alt_text\"";
if (isset($title)) { if (isset($title)) {
$title = $this->encodeAttribute($title); $title = $this->encodeAttribute($title);
@ -1263,33 +1260,6 @@ class Markdown implements MarkdownInterface {
$text = str_replace('"', '&quot;', $text); $text = str_replace('"', '&quot;', $text);
return $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) { protected function encodeAmpsAndAngles($text) {
@ -1314,7 +1284,7 @@ class Markdown implements MarkdownInterface {
protected function doAutoLinks($text) { 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); array($this, '_doAutoLinks_url_callback'), $text);
# Email addresses: <address@domain.foo> # Email addresses: <address@domain.foo>
@ -1337,46 +1307,48 @@ class Markdown implements MarkdownInterface {
> >
}xi', }xi',
array($this, '_doAutoLinks_email_callback'), $text); array($this, '_doAutoLinks_email_callback'), $text);
$text = preg_replace_callback('{<(tel:([^\'">\s]+))>}i',array($this, '_doAutoLinks_tel_callback'), $text);
return $text; return $text;
} }
protected function _doAutoLinks_tel_callback($matches) {
$url = $this->encodeAttribute($matches[1]);
$tel = $this->encodeAttribute($matches[2]);
$link = "<a href=\"$url\">$tel</a>";
return $this->hashPart($link);
}
protected function _doAutoLinks_url_callback($matches) { protected function _doAutoLinks_url_callback($matches) {
$url = $this->encodeURLAttribute($matches[1], $text);
$link = "<a href=\"$url\">$text</a>";
$url = $this->encodeAttribute($matches[1]);
$link = "<a href=\"$url\">$url</a>";
return $this->hashPart($link); return $this->hashPart($link);
} }
protected function _doAutoLinks_email_callback($matches) { protected function _doAutoLinks_email_callback($matches) {
$addr = $matches[1];
$url = $this->encodeURLAttribute("mailto:$addr", $text);
$link = "<a href=\"$url\">$text</a>";
$address = $matches[1];
$link = $this->encodeEmailAddress($address);
return $this->hashPart($link); 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.:
# #
# &#109;&#x61;&#105;&#x6c;&#116;&#x6f;&#58;&#x66;o&#111;
# <p><a href="&#109;&#x61;&#105;&#x6c;&#116;&#x6f;&#58;&#x66;o&#111;
# &#x40;&#101;&#x78;&#97;&#x6d;&#112;&#x6c;&#101;&#46;&#x63;&#111; # &#x40;&#101;&#x78;&#97;&#x6d;&#112;&#x6c;&#101;&#46;&#x63;&#111;
# &#x6d;
#
# Note: the additional output $tail is assigned the same value as the
# ouput, minus the number of characters specified by $head_length.
# &#x6d;">&#x66;o&#111;&#x40;&#101;&#x78;&#97;&#x6d;&#112;&#x6c;
# &#101;&#46;&#x63;&#111;&#x6d;</a></p>
# #
# Based by a filter by Matthew Wickline, posted to BBEdit-Talk. # 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('/(?<!^)(?!$)/', $text);
$seed = (int)abs(crc32($text) / strlen($text)); # Deterministic seed.
$addr = "mailto:" . $addr;
$chars = preg_split('/(?<!^)(?!$)/', $addr);
$seed = (int)abs(crc32($addr) / strlen($addr)); # Deterministic seed.
foreach ($chars as $key => $char) { foreach ($chars as $key => $char) {
$ord = ord($char); $ord = ord($char);
# Ignore non-ascii chars. # Ignore non-ascii chars.
@ -1384,17 +1356,18 @@ class Markdown implements MarkdownInterface {
$r = ($seed * (1 + $key)) % 100; # Pseudo-random function. $r = ($seed * (1 + $key)) % 100; # Pseudo-random function.
# roughly 10% raw, 45% hex, 45% dec # roughly 10% raw, 45% hex, 45% dec
# '@' *must* be encoded. I insist. # '@' *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 if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';';
else $chars[$key] = '&#'.$ord.';'; else $chars[$key] = '&#'.$ord.';';
} }
} }
$addr = implode('', $chars);
$text = implode('', array_slice($chars, 7)); # text without `mailto:`
$addr = "<a href=\"$addr\">$text</a>";
$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 ### ### Extra Attribute Parser ###
# Expression to use to catch attributes (includes the braces) # 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 # 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) { protected function doExtraAttributes($tag_name, $attr) {
# #
@ -1692,21 +1665,17 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
if (empty($attr)) return ""; if (empty($attr)) return "";
# Split on components # 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]; $elements = $matches[0];
# handle classes and ids (only first id taken into account) # handle classes and ids (only first id taken into account)
$classes = array(); $classes = array();
$attributes = array();
$id = false; $id = false;
foreach ($elements as $element) { foreach ($elements as $element) {
if ($element{0} == '.') { if ($element{0} == '.') {
$classes[] = substr($element, 1); $classes[] = substr($element, 1);
} else if ($element{0} == '#') { } else if ($element{0} == '#') {
if ($id === false) $id = substr($element, 1); 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)) { if (!empty($classes)) {
$attr_str .= ' class="'.implode(" ", $classes).'"'; $attr_str .= ' class="'.implode(" ", $classes).'"';
} }
if (!$this->no_markup && !empty($attributes)) {
$attr_str .= ' '.implode(" ", $attributes);
}
return $attr_str; return $attr_str;
} }
@ -2330,7 +2296,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
if (isset($this->urls[$link_id])) { if (isset($this->urls[$link_id])) {
$url = $this->urls[$link_id]; $url = $this->urls[$link_id];
$url = $this->encodeURLAttribute($url);
$url = $this->encodeAttribute($url);
$result = "<a href=\"$url\""; $result = "<a href=\"$url\"";
if ( isset( $this->titles[$link_id] ) ) { if ( isset( $this->titles[$link_id] ) ) {
@ -2363,7 +2329,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
if ($unhashed != $url) if ($unhashed != $url)
$url = preg_replace('/^<(.*)>$/', '\1', $unhashed); $url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
$url = $this->encodeURLAttribute($url);
$url = $this->encodeAttribute($url);
$result = "<a href=\"$url\""; $result = "<a href=\"$url\"";
if (isset($title)) { if (isset($title)) {
@ -2446,7 +2412,7 @@ abstract class _MarkdownExtra_TmpImpl extends \Michelf\Markdown {
$alt_text = $this->encodeAttribute($alt_text); $alt_text = $this->encodeAttribute($alt_text);
if (isset($this->urls[$link_id])) { if (isset($this->urls[$link_id])) {
$url = $this->encodeURLAttribute($this->urls[$link_id]);
$url = $this->encodeAttribute($this->urls[$link_id]);
$result = "<img src=\"$url\" alt=\"$alt_text\""; $result = "<img src=\"$url\" alt=\"$alt_text\"";
if (isset($this->titles[$link_id])) { if (isset($this->titles[$link_id])) {
$title = $this->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]); $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]);
$alt_text = $this->encodeAttribute($alt_text); $alt_text = $this->encodeAttribute($alt_text);
$url = $this->encodeURLAttribute($url);
$url = $this->encodeAttribute($url);
$result = "<img src=\"$url\" alt=\"$alt_text\""; $result = "<img src=\"$url\" alt=\"$alt_text\"";
if (isset($title)) { if (isset($title)) {
$title = $this->encodeAttribute($title); $title = $this->encodeAttribute($title);


+ 3
- 0
system/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php View File

@ -32,3 +32,6 @@ interface MarkdownInterface {
public function transform($text); public function transform($text);
} }
?>

+ 0
- 10
system/vendor/michelf/php-markdown/Readme.md View File

@ -174,16 +174,6 @@ PHP Markdown, please visit [michelf.ca/donate] or send Bitcoin to
Version History 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) PHP Markdown Lib 1.4.1 (4 May 2014)
* The HTML block parser will now treat `<figure>` as a block-level element * The HTML block parser will now treat `<figure>` as a block-level element


+ 1
- 1
themes/default/css/toolbar.css View File

@ -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;}}
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}

Loading…
Cancel
Save