From 39b1ad8c3fc4aa960f2a9c15f511bc50d0974a8d Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Thu, 30 Jan 2014 16:28:21 +0700 Subject: [PATCH] Fix error on some server Fix error on some server --- .htaccess | 6 +++ system/includes/functions.php | 97 +++++++++++++++++++++++-------------------- 2 files changed, 59 insertions(+), 44 deletions(-) diff --git a/.htaccess b/.htaccess index a899349..75ba2c0 100644 --- a/.htaccess +++ b/.htaccess @@ -1,3 +1,9 @@ +# Make HTMLy handle any 404 errors. +ErrorDocument 404 /index.php + +# Set the default handler. +DirectoryIndex index.php index.html index.htm + # Requires mod_expires to be enabled. diff --git a/system/includes/functions.php b/system/includes/functions.php index e3913e1..601f495 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -360,42 +360,46 @@ function get_static_post($static){ $posts = get_static_pages(); - $tmp = array(); + if(!empty($posts)) { - foreach($posts as $index => $v){ - if(strpos($v, $static.'.md') !== false){ - - $post = new stdClass; - - // Replaced string - $replaced = substr($v, 0, strrpos($v, '/')) . '/'; - - // The static page URL - $url = str_replace($replaced,'',$v); - $post->url = site_url() . str_replace('.md','',$url); - - $post->file = $v; + $tmp = array(); + + foreach($posts as $index => $v){ + if(strpos($v, $static.'.md') !== false){ - // Get the contents and convert it to HTML - $content = MarkdownExtra::defaultTransform(file_get_contents($v)); + $post = new stdClass; + + // Replaced string + $replaced = substr($v, 0, strrpos($v, '/')) . '/'; + + // The static page URL + $url = str_replace($replaced,'',$v); + $post->url = site_url() . str_replace('.md','',$url); + + $post->file = $v; + + // Get the contents and convert it to HTML + $content = MarkdownExtra::defaultTransform(file_get_contents($v)); - // Extract the title and body - $arr = explode('t-->', $content); - if(isset($arr[1])) { - $post->title = str_replace('', $content); + if(isset($arr[1])) { + $post->title = str_replace('