diff --git a/system/admin/admin.php b/system/admin/admin.php
index 665d77c..7fa1bfb 100644
--- a/system/admin/admin.php
+++ b/system/admin/admin.php
@@ -451,9 +451,13 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ
if ($old_url != $post_url) {
if (file_exists($viewsFile)) {
- $views = json_decode(file_get_contents($viewsFile), true);
- $arr = replace_key($views, 'post_' . $old_url, 'post_' . $post_url);
- save_json_pretty($viewsFile, $arr);
+ $views = json_decode(file_get_data($viewsFile), true);
+ $oKey = 'post_' . $old_url;
+ $nKey = 'post_' . $post_url;
+ if (isset($views[$oKey])) {
+ $arr = replace_key($views, $oKey, $nKey);
+ save_json_pretty($viewsFile, $arr);
+ }
}
}
@@ -695,9 +699,13 @@ function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft,
if ($old_url != $pu) {
if (file_exists($viewsFile)) {
- $views = json_decode(file_get_contents($viewsFile), true);
- $arr = replace_key($views, 'subpage_' . $static .'.'. $old_url, 'subpage_' . $static .'.'. $pu);
- save_json_pretty($viewsFile, $arr);
+ $views = json_decode(file_get_data($viewsFile), true);
+ $oKey = 'subpage_' . $static . '.' . $old_url;
+ $nKey = 'subpage_' . $static . '.' . $pu;
+ if (isset($views[$oKey])) {
+ $arr = replace_key($views, $oKey, $nKey);
+ save_json_pretty($viewsFile, $arr);
+ }
}
}
@@ -706,18 +714,26 @@ function edit_page($title, $url, $content, $oldfile, $revertPage, $publishDraft,
if ($old_url != $pu) {
if (file_exists($viewsFile)) {
- $views = json_decode(file_get_contents($viewsFile), true);
- $arr = replace_key($views, 'page_' . $old_url, 'page_' . $pu);
- save_json_pretty($viewsFile, $arr);
+ $views = json_decode(file_get_data($viewsFile), true);
+ $oKey = 'page_' . $old_url;
+ $nKey = 'page_' . $pu;
+ if (isset($views[$oKey])) {
+ $arr = replace_key($views, $oKey, $nKey);
+ save_json_pretty($viewsFile, $arr);
+ }
}
$sPage = find_subpage($pu);
if (!empty($sPage)) {
foreach ($sPage as $sp) {
if (file_exists($viewsFile)) {
- $views = json_decode(file_get_contents($viewsFile), true);
- $arr = replace_key($views, 'subpage_' . $old_url . '.' . $sp->slug, 'subpage_' . $pu . '.' . $sp->slug);
- save_json_pretty($viewsFile, $arr);
+ $views = json_decode(file_get_data($viewsFile), true);
+ $oKey = 'subpage_' . $old_url . '.' . $sp->slug;
+ $nKey = 'subpage_' . $pu . '.' . $sp->slug;
+ if (isset($views[$soKey])) {
+ $arr = replace_key($views, $oKey, $nKey);
+ save_json_pretty($viewsFile, $arr);
+ }
}
}
}
@@ -1532,7 +1548,6 @@ function reorder_pages($pages = null)
$i = 1;
$arr = array();
$dir = 'content/static/';
- $viewsFile = "content/data/views.json";
foreach ($pages as $p) {
$fn = pathinfo($p, PATHINFO_FILENAME);
$num = str_pad($i, 2, 0, STR_PAD_LEFT);
@@ -1560,7 +1575,6 @@ function reorder_subpages($subpages = null)
$i = 1;
$arr = array();
$dir = 'content/static/';
- $viewsFile = "content/data/views.json";
foreach ($subpages as $sp) {
$dn = $dir . pathinfo($sp, PATHINFO_DIRNAME) . '/';
$fn = pathinfo($sp, PATHINFO_FILENAME);
diff --git a/system/includes/dispatch.php b/system/includes/dispatch.php
index 006a181..32b978a 100644
--- a/system/includes/dispatch.php
+++ b/system/includes/dispatch.php
@@ -432,6 +432,19 @@ function save_json_pretty($filename, $arr)
}
}
+function file_get_data($filename)
+{
+ $thisFile = fopen($filename, 'r');
+ if (flock($thisFile, LOCK_SH)) {
+ $fileData = file_get_contents($filename);
+ flock($thisFile, LOCK_UN);
+ } else {
+ $fileData = json_encode(array('flock_fail' => 'reading'));
+ }
+ fclose($thisFile);
+ return $fileData;
+}
+
function condition()
{
static $cb_map = array();
diff --git a/system/includes/functions.php b/system/includes/functions.php
index 10ec935..a8afe37 100644
--- a/system/includes/functions.php
+++ b/system/includes/functions.php
@@ -2677,8 +2677,8 @@ function not_found($request = null)
}
if (isset($views[$request])) {
unset($views[$request]);
+ save_json_pretty($filename, $views);
}
- save_json_pretty($filename, $views);
}
}
@@ -3253,14 +3253,19 @@ function add_view($page)
$filename = "content/data/views.json";
$views = array();
if (file_exists($filename)) {
- $views = json_decode(file_get_contents($filename), true);
+ $views = json_decode(file_get_data($filename), true);
}
if (isset($views[$page])) {
$views[$page]++;
+ save_json_pretty($filename, $views);
} else {
- $views[$page] = 1;
+ if (isset($views['flock_fail'])) {
+ return;
+ } else {
+ $views[$page] = 1;
+ save_json_pretty($filename, $views);
+ }
}
- save_json_pretty($filename, $views);
}
// Get the page views count
@@ -3271,6 +3276,7 @@ function get_views($page, $oldID = null)
if (file_exists($filename)) {
$_views = json_decode(file_get_contents($filename), true);
}
+
if (!is_null($oldID)) {
if (isset($_views[$oldID])) {
$arr = replace_key($_views, $oldID, $page);
diff --git a/themes/doks/css/style.css b/themes/doks/css/style.css
index ebbea07..fda6a10 100644
--- a/themes/doks/css/style.css
+++ b/themes/doks/css/style.css
@@ -3402,16 +3402,16 @@ body.dark .docs-links .nav > li.active li.active > a, body.dark .docs-links .n
}
#toc .h3-toc {
- text-indent: .25in;
+ margin-left: .25in;
}
#toc .h4-toc {
- text-indent: .50in;
+ margin-left: .50in;
}
#toc .h5-toc {
- text-indent: .75in;
+ margin-left: .75in;
}
#toc .h6-toc {
- text-indent: 1in;
+ margin-left: 1in;
}
#toc > div {
diff --git a/themes/doks/main.html.php b/themes/doks/main.html.php
index 9304ed4..ca299d8 100644
--- a/themes/doks/main.html.php
+++ b/themes/doks/main.html.php
@@ -70,13 +70,16 @@
image)) {?>
- video)) {?>
-
- audio)) {?>
-
+
+ video)):?>
+
+
+ audio)):?>
+
+
quote)):?>
- audio)) {?>
-