From b46e8f7441d5a1b93aa8aeb957ebc6c8536053c4 Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Thu, 10 May 2007 13:52:32 +0000 Subject: [PATCH] ~ Fixed problems with apostrophes and ampersands in paths/names. Still need to sort out international characters. + Tracks in an album are now sorted by tracknumber. + Added config file. --- config/config.inc.php | 13 +++++++++++++ index.php | 4 ++-- lib/actions.php | 2 +- lib/global.php | 18 ++++++++++++++---- lib/page.php | 20 ++++++++++++++++---- templates/default/browse.html | 2 +- templates/default/browselist_item.html | 4 ++-- 7 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 config/config.inc.php diff --git a/config/config.inc.php b/config/config.inc.php new file mode 100644 index 0000000..bd9bd6c --- /dev/null +++ b/config/config.inc.php @@ -0,0 +1,13 @@ + diff --git a/index.php b/index.php index 7a2ca61..6bff8ea 100644 --- a/index.php +++ b/index.php @@ -11,6 +11,6 @@ require("lib/page.php"); /* output the template */ - $smarty->display('default/index.html'); + $smarty->display($_CONFIG['template'] . '/index.html'); -?> \ No newline at end of file +?> diff --git a/lib/actions.php b/lib/actions.php index b1bd4cf..c366e24 100644 --- a/lib/actions.php +++ b/lib/actions.php @@ -94,4 +94,4 @@ header("Location: index.php"); break; } -?> \ No newline at end of file +?> diff --git a/lib/global.php b/lib/global.php index 46f7df1..9830c94 100644 --- a/lib/global.php +++ b/lib/global.php @@ -1,5 +1,7 @@ connected) { echo "

Problem connecting to MPD!

"; exit; + } + + /* track number sorting function */ + + function track_sort($a, $b) { + return $a['Track'] - $b['Track']; } /* setup some global vars */ @@ -43,10 +51,12 @@ /* do the same with the current browse position */ if ($_GET['browse']) { $browse = $_GET['browse']; - setcookie('browse', $browse); + setcookie('browse', stripslashes($browse)); } else { $browse = $_COOKIE['browse']; - } + } + + $browse = stripslashes($browse); -?> \ No newline at end of file +?> diff --git a/lib/page.php b/lib/page.php index 25023ee..92ffd84 100644 --- a/lib/page.php +++ b/lib/page.php @@ -25,7 +25,9 @@ $browse = ''; } - $browse_list = explode('/', $browse); + $browse_list = explode('/', $browse); + + //print_r($browse); if ($browse) { @@ -40,8 +42,18 @@ if (!$browselist) { $browselist = $mympd->GetDir($browse); - } - + } + + if ($_CONFIG['sort_by_tracknumber']) { + usort($browselist, "track_sort"); + } + + /* + echo '
';
+			print_r($browselist);
+			echo '
'; + //*/ + foreach ($browselist as $key => $browselist_item) { @@ -73,4 +85,4 @@ break; } -?> \ No newline at end of file +?> diff --git a/templates/default/browse.html b/templates/default/browse.html index 482e476..b4d7041 100644 --- a/templates/default/browse.html +++ b/templates/default/browse.html @@ -3,7 +3,7 @@
  • Home
  • {foreach from=$dir_list item=dir_list_item} -
  • {$dir_list_item.name}
  • +
  • {$dir_list_item.name|escape:'html'}
  • {/foreach} diff --git a/templates/default/browselist_item.html b/templates/default/browselist_item.html index a7e2111..c9f3849 100644 --- a/templates/default/browselist_item.html +++ b/templates/default/browselist_item.html @@ -1,10 +1,10 @@ {if $browselist_item.directory} -
  • {$browselist_item.directory_name}
  • +
  • {$browselist_item.directory_name|escape:'html'}
  • {else} - {if $browselist_item.in_playlist}
  • {else}
  • {/if}AddPlay {if $browselist_item.Title}{$browselist_item.Title}
    {$browselist_item.Artist} ({$browselist_item.Album}){else}{$browselist_item.file}{/if}
  • + {if $browselist_item.in_playlist}
  • {else}
  • {/if}AddPlay {if $browselist_item.Title|escape:'html'}{$browselist_item.Title|escape:'html'}
    {$browselist_item.Artist|escape:'html'} ({$browselist_item.Album|escape:'html'}){else}{$browselist_item.file|escape:'html'}{/if}
  • {/if}