From e207d427d7a7743e9c9ab13f676252c605eb3a52 Mon Sep 17 00:00:00 2001 From: kisselev Date: Fri, 26 Jul 2013 12:43:11 -0700 Subject: [PATCH 1/2] Added option to disable clean urls through config file for servers that cannot do url rewriting. --- README.md | 7 +++++++ docs/00_Getting_Started.md | 7 +++++++ libs/functions.php | 34 ++++++++++++++++++++++++++++------ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3cd1f32..ffbe208 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,13 @@ Set custom files and entire folders to ignore within your `/docs` folder. For fi } } +###Disabling clean URLs +By default, Daux.io will create clean url's that do not include index.php. On servers running Apache, uploading the included .htaccess file should be enough for them to work properly. On servers that are not running Apache or that do not allow custom .htaccess files, you may need to disable clean_urls: + + { + "clean_urls": false + } + ## Running Remotely Copy the files from the repo to a web server that can run PHP 5.3 or greater. diff --git a/docs/00_Getting_Started.md b/docs/00_Getting_Started.md index 3cd1f32..ffbe208 100644 --- a/docs/00_Getting_Started.md +++ b/docs/00_Getting_Started.md @@ -167,6 +167,13 @@ Set custom files and entire folders to ignore within your `/docs` folder. For fi } } +###Disabling clean URLs +By default, Daux.io will create clean url's that do not include index.php. On servers running Apache, uploading the included .htaccess file should be enough for them to work properly. On servers that are not running Apache or that do not allow custom .htaccess files, you may need to disable clean_urls: + + { + "clean_urls": false + } + ## Running Remotely Copy the files from the repo to a web server that can run PHP 5.3 or greater. diff --git a/libs/functions.php b/libs/functions.php index ab6b437..72f91d9 100644 --- a/libs/functions.php +++ b/libs/functions.php @@ -39,6 +39,7 @@ function get_options() { 'twitter' => array(), 'links' => array(), 'colors' => false, + 'clean_urls' => true, 'google_analytics' => false, 'piwik_analytics' => false, 'ignore' => array() @@ -228,8 +229,9 @@ function get_ignored() { return $all_ignored; } -function get_tree($path = '.', $clean_path = '', $title = ''){ - $tree = array(); +function get_tree($path = '.', $clean_path = '', $title = '', $first = true){ + $options = get_options(); + $tree = array(); $ignore = get_ignored(); $dh = @opendir($path); $index = 0; @@ -252,9 +254,29 @@ function get_tree($path = '.', $clean_path = '', $title = ''){ // Check that this file or folder is not to be ignored if(!in_array($file, $ignore)) { - $full_path = "$path/$file"; - $clean_sort = clean_sort($file); - $url = $clean_path . '/' . $clean_sort; + $full_path = "$path/$file"; + $clean_sort = clean_sort($file); + + // If clean_urls is set to false and this is the first branch of the tree, append index.php to the clean_path. + + print_r($options['clean_urls']); + + if($options['clean_urls'] == false) + { + if($first) + { + $url = $clean_path . '/index.php/' . $clean_sort; + } + else + { + $url = $clean_path . '/' . $clean_sort; + } + } + else + { + $url = $clean_path . '/' . $clean_sort; + } + $clean_name = clean_name($clean_sort); // Title @@ -273,7 +295,7 @@ function get_tree($path = '.', $clean_path = '', $title = ''){ 'path' => $full_path, 'clean' => $clean_sort, 'url' => $url, - 'tree'=> get_tree($full_path, $url, $full_title) + 'tree'=> get_tree($full_path, $url, $full_title, false) ); } else { // File From f532918681d9a5d5973c17147a4d3e09da810347 Mon Sep 17 00:00:00 2001 From: kisselev Date: Fri, 26 Jul 2013 13:30:51 -0700 Subject: [PATCH 2/2] Removed debug traces --- libs/functions.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/libs/functions.php b/libs/functions.php index 72f91d9..b2ada1a 100644 --- a/libs/functions.php +++ b/libs/functions.php @@ -258,9 +258,6 @@ function get_tree($path = '.', $clean_path = '', $title = '', $first = true){ $clean_sort = clean_sort($file); // If clean_urls is set to false and this is the first branch of the tree, append index.php to the clean_path. - - print_r($options['clean_urls']); - if($options['clean_urls'] == false) { if($first)