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}