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.
+
+
diff --git a/system/htmly.php b/system/htmly.php
index 0258390..8241bfd 100644
--- a/system/htmly.php
+++ b/system/htmly.php
@@ -4,7 +4,8 @@
date_default_timezone_set('Asia/Jakarta');
// Load the configuration file
-config('source', 'config/config.ini');
+$config_file = 'config/config.ini';
+config('source', $config_file);
if(config('timezone')) {
date_default_timezone_set(config('timezone'));
}
@@ -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' => '' . 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/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