Browse Source

Fix error on some server

Fix error on some server
pull/31/merge
Danang Probo Sayekti 12 years ago
parent
commit
39b1ad8c3f
2 changed files with 59 additions and 44 deletions
  1. +6
    -0
      .htaccess
  2. +53
    -44
      system/includes/functions.php

+ 6
- 0
.htaccess View File

@ -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.
<IfModule mod_expires.c>


+ 53
- 44
system/includes/functions.php View File

@ -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('<!--t','',$arr[0]);
$post->body = $arr[1];
}
else {
$post->title = $static;
$post->body = $arr[0];
}
// Extract the title and body
$arr = explode('t-->', $content);
if(isset($arr[1])) {
$post->title = str_replace('<!--t','',$arr[0]);
$post->body = $arr[1];
}
else {
$post->title = $static;
$post->body = $arr[0];
}
$tmp[] = $post;
$tmp[] = $post;
}
}
}
return $tmp;
return $tmp;
}
}
// Return search page.
@ -854,22 +858,27 @@ function menu(){
function get_menu() {
$posts = get_static_pages();
krsort($posts);
echo '<ul>';
echo '<li><a href="' . site_url() . '">' .config('breadcrumb.home'). '</a></li>';
foreach($posts as $index => $v){
if(!empty($posts)) {
krsort($posts);
echo '<ul>';
echo '<li><a href="' . site_url() . '">' .config('breadcrumb.home'). '</a></li>';
foreach($posts as $index => $v){
// Replaced string
$replaced = substr($v, 0, strrpos($v, '/')) . '/';
// The static page URL
$title = str_replace($replaced,'',$v);
$url = site_url() . str_replace('.md','',$title);
echo '<li><a href="' . $url . '">' . ucfirst(str_replace('.md','',$title)) . '</a></li>';
}
echo '</ul>';
// Replaced string
$replaced = substr($v, 0, strrpos($v, '/')) . '/';
// The static page URL
$title = str_replace($replaced,'',$v);
$url = site_url() . str_replace('.md','',$title);
echo '<li><a href="' . $url . '">' . ucfirst(str_replace('.md','',$title)) . '</a></li>';
}
echo '</ul>';
}


Loading…
Cancel
Save