diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-08-31 15:39:40 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-08-31 15:39:40 +0000 |
commit | c1970f2f3984e557ff7d61c2e15905e2940b68a8 (patch) | |
tree | a2fa4cd2564e8f9283932384ec8f16d5e8b0d3b4 /lib/class | |
parent | 3435cfa2bfc3f35ed540fbf766a9cb4869726b46 (diff) | |
download | ampache-c1970f2f3984e557ff7d61c2e15905e2940b68a8.tar.gz ampache-c1970f2f3984e557ff7d61c2e15905e2940b68a8.tar.bz2 ampache-c1970f2f3984e557ff7d61c2e15905e2940b68a8.zip |
massivly simplify parse_url() and make it so random urls show up correctly in the localplay playlist
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/localplay.abstract.php | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/class/localplay.abstract.php b/lib/class/localplay.abstract.php index 49fc85db..39562fca 100644 --- a/lib/class/localplay.abstract.php +++ b/lib/class/localplay.abstract.php @@ -88,34 +88,28 @@ abstract class localplay_controller { /** * parse_url * This takes an Ampache URL and then returns the 'primary' part of it - * So that it's easier for localplay module sto return valid song information + * So that it's easier for localplay modules to return valid song information */ public function parse_url($url) { // Define possible 'primary' keys - $primary_array = array('song','demo_id'); + $primary_array = array('song','demo_id','random'); // Delete everything before the first ? $file = preg_replace("/.*\?(.+)/",'$1',$url); - // Split on & symbol - $data = explode("&",$file); + $variables = parse_url($url,PHP_URL_QUERY); + parse_str($variables,$data); - foreach ($data as $pair) { - $elements = explode("=",$pair); - $key = $elements['0']; - $value = $elements['1']; - $results[$key] = $value; - - if (in_array($key,$primary_array)) { - $primary = $key; - } + foreach ($primary_array as $pkey) { + if ($data[$pkey]) { + $data['primary_key'] = $pkey; + return $data; + } } // end foreach - $results['primary_key'] = $primary; - - return $results; + return $data; } // parse_url |