diff --git a/config.json b/config.json
new file mode 100644
index 0000000..b4bbe3f
--- /dev/null
+++ b/config.json
@@ -0,0 +1 @@
+{"lang":"en","error_reporting":false,"show_hidden":false,"hide_Cols":false,"theme":"light"}
\ No newline at end of file
diff --git a/tinyfilemanager.php b/tinyfilemanager.php
index 6a29403..4324a75 100644
--- a/tinyfilemanager.php
+++ b/tinyfilemanager.php
@@ -1,7 +1,4 @@
data = array(
- 'lang' => 'en',
- 'error_reporting' => true,
- 'show_hidden' => true
- );
- $data = false;
- if (strlen($CONFIG)) {
- $data = fm_object_to_array(json_decode($CONFIG));
- } else {
+ $this->data = json_decode(@file_get_contents('config.json'), true);
+ if($this->data == "") {
$msg = 'Tiny File Manager
Error: Cannot load configuration';
- if (substr($fm_url, -1) == '/') {
+ if ($fm_url == '/' || $fm_url == "/index.php") {
$fm_url = rtrim($fm_url, '/');
$msg .= '
';
- $msg .= '
Seems like you have a trailing slash on the URL.';
- $msg .= '
Try this link: ' . $fm_url . '';
+ $msg .= '
Seems config.json does not exists or has no content.';
+ $msg .= '
Try create config.json with content: {"lang":"en","error_reporting":false,"show_hidden":false,"hide_Cols":false,"theme":"light"}';
}
die($msg);
}
- if (is_array($data) && count($data)) $this->data = $data;
- else $this->save();
}
function save()
{
- $fm_file = __FILE__;
- $var_name = '$CONFIG';
- $var_value = var_export(json_encode($this->data), true);
- $config_string = "data, JSON_PRETTY_PRINT);
+ $config_file = "config.json";
+ if (is_writable($config_file)) {
+ file_put_contents($config_file, $var_value);
}
}
}