From 2b55e30467f5ccdf9324b0377c419c5681f4c215 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Sat, 8 Apr 2006 05:58:05 +0000 Subject: This update includes a full rewrite of the Localplay code, only update to this version if you don't care about losing a lot of functionality while I am still finishing it up. Also the only working localplay method is currently MPD. UPDATE AT YOUR OWN RISK! --- admin/modules.php | 53 +++++++ admin/orphan.php | 71 --------- config/ampache.cfg.php.dist | 83 +++-------- docs/CHANGELOG | 3 + images/localplay/next.gif | Bin 0 -> 1005 bytes images/localplay/pause.gif | Bin 0 -> 1006 bytes images/localplay/play.gif | Bin 0 -> 989 bytes images/localplay/prev.gif | Bin 0 -> 1014 bytes images/localplay/stop.gif | Bin 0 -> 1005 bytes lib/class/localplay.class.php | 119 +++++++++++++++- lib/class/stream.class.php | 32 ++--- lib/class/update.class.php | 123 ++++++++++++++++ lib/class/user.class.php | 16 +-- lib/localplay.lib.php | 238 +++++++++++++++++++++++++++++++ lib/mpd.php | 142 ------------------ lib/preferences.php | 73 +++++++--- lib/ui.lib.php | 46 ++---- login.php | 4 +- modules/init.php | 30 ++-- modules/kajax/ajax.js | 4 +- modules/kajax/driver.php | 13 -- modules/localplay/mpd.controller.php | 61 +++++++- modules/vauth/session.lib.php | 2 +- server/ajax.server.php | 220 ++++++++-------------------- song.php | 2 +- templates/footer.inc | 2 + templates/header.inc | 6 + templates/show_localplay_control.inc.php | 63 ++++++++ templates/show_modules.inc.php | 55 +++++++ templates/show_preference_box.inc.php | 6 +- templates/show_preferences.inc | 4 +- templates/sidebar.inc.php | 24 ++-- test.php | 3 + 33 files changed, 909 insertions(+), 589 deletions(-) create mode 100644 admin/modules.php delete mode 100644 admin/orphan.php create mode 100755 images/localplay/next.gif create mode 100755 images/localplay/pause.gif create mode 100755 images/localplay/play.gif create mode 100755 images/localplay/prev.gif create mode 100755 images/localplay/stop.gif create mode 100644 lib/localplay.lib.php delete mode 100644 lib/mpd.php delete mode 100755 modules/kajax/driver.php create mode 100644 templates/show_localplay_control.inc.php create mode 100644 templates/show_modules.inc.php diff --git a/admin/modules.php b/admin/modules.php new file mode 100644 index 00000000..ea2fb6f0 --- /dev/null +++ b/admin/modules.php @@ -0,0 +1,53 @@ +has_access(100)) { + access_denied(); + exit(); +} + + +$action = scrub_in($_REQUEST['action']); + +/* Always show the header */ +show_template('header'); + +switch ($action) { + case 'insert_localplay_preferences': + $type = scrub_in($_REQUEST['type']); + insert_localplay_preferences($type); + $url = conf('web_path') . '/admin/modules.php'; + $title = _('Module Activated'); + $body = ''; + show_confirmation($title,$body,$url); + break; + default: + require_once (conf('prefix') . '/templates/show_modules.inc.php'); + break; +} // end switch + +show_footer(); + + +?> diff --git a/admin/orphan.php b/admin/orphan.php deleted file mode 100644 index 500b6dbf..00000000 --- a/admin/orphan.php +++ /dev/null @@ -1,71 +0,0 @@ -has_access(100)) { - header("Location: " . conf('web_path') . "/index.php?access=denied"); - exit(); -} - - -if ( $type and $action == 'show_songs' ) { - print("

Orphaned Songs with missing $type information

"); - - $song_ids = get_orphan_songs($type); - show_songs($song_ids); -} - -show_template('header'); - -show_menu_items('Admin'); -show_admin_menu('Catalog'); - -if ( $action == 'show_orphan_songs' ) { - print("

Orphaned songs with no artist

"); - - $song_ids = get_orphan_songs(); - show_songs($song_ids); -} -elseif ( $action == 'show_orphan_albums' ) { - print("

Orphaned albums with no name

"); - - $song_ids = get_orphan_albums(); - show_songs($song_ids); -} - -?> - - -
- - - diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist index e7ccbf8b..139b2101 100644 --- a/config/ampache.cfg.php.dist +++ b/config/ampache.cfg.php.dist @@ -1,10 +1,10 @@ #### #################### -# General Config +# General Config # #################### #################### -# Path Vars +# Path Vars # #################### # The path to your ampache install @@ -69,9 +69,9 @@ sess_cookielife = 0 # DEFAULT: 0 sess_cookiesecure = 0 -#################### -# The conf vars! # -#################### +###################### +# Program Settings # +###################### # Nuff Said # DEFAULT: Ampache :: For The Love of Music @@ -266,9 +266,8 @@ site_charset = iso-8859-1 # Default: cp1251 #lc_charset = cp1251 - ########################################################## -# Public Registration settings, defaults to disabled +# Public Registration settings, defaults to disabled # ########################################################## # This setting turns on/off public registration. It is @@ -308,9 +307,9 @@ site_charset = iso-8859-1 # User will need to accept the agreement before they can register #user_agreement = "false" -########################################################## -# These Option Control which playback methods are allowed -########################################################## +########################################################### +# These Option Control which playback methods are allowed # +########################################################### # Stream Playback # Disable this if you don't want to allow people to stream @@ -330,29 +329,11 @@ allow_stream_playback = true # DEFAULT: false #allow_local_playback = false -# MPD Playback -# Disable this if you don't want to allow people to push things -# to a MPD server as defined below -# DEFAULT: false -#allow_mpd_playback = false - -# Icecast Playback -# Disable this if you don't have an IceCast server to push -# music to -# DEFAULT: false -#allow_icecast_playback = false - -# Slim Server Playback -# Disable this if you don't have a SlimServer to push music -# to -# DEFAULT: false -#allow_slim_playback = false - -####################################################### -# These options control the dynamic down-sampling based -# on current usage -# *Note* Down-sampling must be enabled and working -####################################################### +######################################################### +# These options control the dynamic down-sampling based # +# on current usage # +# *Note* Down-sampling must be enabled and working # +######################################################### # Attempt to optimize bandwidth by dynamically down-sampling # all connections from users to fit within a maximum bandwidth. @@ -371,7 +352,7 @@ allow_stream_playback = true ####################################################### -# These options control how searching works +# These options control how searching works # ####################################################### # choices are: artist,album,song_title,song_genre,song_year,song_bitrate,song_min_bitrate,song_filename @@ -553,36 +534,6 @@ rss_main_language = nl ################### # MPD Settings # ################### -# These settings are for the MPD support -# built into Ampache. -##################################################### -# MPD Port -# This defines which port that ampache attempts to -# connect to MPD on. The standard port is 6600 -# DEFAULT: "" -#mpd_port = "6600" - -# MPD Hostname -# This is the hostname of the computer running MPD -# DEFAULT: "" -#mpd_host = "localhost" - -# MPD Password -# This is the password for the MPD server -# DEFAULT: "" -#mpd_pass = "" - -# MPD base directory -# this is the directory mpd.conf's music_directory points to, but -# it's the path on your Ampache server, not the mpd server -#mpd_dir = "" - -# MPD Method -# This is the method you want to use to pass your -# music to your MPD player. Possible values are -# file and url. I highly recommend using the URL -# method as it requires less configuration. -# POSSIBLE VALUES: file url -# DEFAULT: file -#mpd_method = "file" +# These settings have been moved into the database +# Defaults can be found in /modules/localplay/mpd.readme ##################################################### diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 4e1789d6..b431095a 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,9 @@ -------------------------------------------------------------------------- v.3.3.2-Beta3 + - Full re-write of Localplay, MPD controller added + - Tweaked Preferences once more + - Added Modules Page - Fixed a missing web_path reference on playlist edit page - Added Localplay API, check the wiki for more information https://ampache.bountysource.com/wiki/Localplay diff --git a/images/localplay/next.gif b/images/localplay/next.gif new file mode 100755 index 00000000..e7e6664f Binary files /dev/null and b/images/localplay/next.gif differ diff --git a/images/localplay/pause.gif b/images/localplay/pause.gif new file mode 100755 index 00000000..7f49b71f Binary files /dev/null and b/images/localplay/pause.gif differ diff --git a/images/localplay/play.gif b/images/localplay/play.gif new file mode 100755 index 00000000..a416b0d9 Binary files /dev/null and b/images/localplay/play.gif differ diff --git a/images/localplay/prev.gif b/images/localplay/prev.gif new file mode 100755 index 00000000..575e4692 Binary files /dev/null and b/images/localplay/prev.gif differ diff --git a/images/localplay/stop.gif b/images/localplay/stop.gif new file mode 100755 index 00000000..428c3279 Binary files /dev/null and b/images/localplay/stop.gif differ diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index 69b48cdf..232e9158 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -47,10 +47,6 @@ class Localplay { $this->_get_info(); - /* Test for a connection */ - $this->connect(); - - } // Localplay @@ -103,7 +99,7 @@ class Localplay { /* Check the function map, if it's got a value it must * be possible */ - if (strlen($this->_function_map) > 0) { return true; } + if (strlen($this->_function_map[$function_name]) > 0) { return true; } return false; @@ -120,15 +116,18 @@ class Localplay { * be function names that are called on the action in question */ function _map_functions($data) { - + /* Required Functions */ $this->_function_map['add'] = $data['add']; $this->_function_map['delete'] = $data['delete']; $this->_function_map['play'] = $data['play']; $this->_function_map['stop'] = $data['stop']; + $this->_function_map['get'] = $data['get']; $this->_function_map['connect'] = $data['connect']; /* Recommended Functions */ + $this->_function_map['status'] = $data['status']; + $this->_function_map['pause'] = $data['pause']; $this->_function_map['next'] = $data['next']; $this->_function_map['prev'] = $data['prev']; $this->_function_map['get_playlist'] = $data['get_playlist']; @@ -205,10 +204,118 @@ class Localplay { /* Call the Function Specified in the Function Map */ + $function = $this->_function_map['add']; + if (!$this->_player->$function($songs)) { + debug_event('localplay','Error Unable to add songs, check ' . $this->type . ' controller','1'); + return false; + } + + + return true; } // add + /** + * status + * This returns current information about the state of the player + * There is an expected array format + */ + function status() { + + $function = $this->_function_map['status']; + + $data = $this->_player->$function(); + + if (!count($data)) { + debug_event('localplay','Error Unable to get status, check ' . $this->type . ' controller','1'); + return false; + } + + return $data; + + } // status + + /** + * get + * This calls the get function of the player and then returns + * the array of current songs for display or whatever + */ + function get() { + + $function = $this->_function_map['get']; + + $data = $this->_player->$function(); + + if (!count($data)) { + debug_event('localplay','Error Unable to get song info, check ' . $this->type . ' controller','1'); + return false; + } + + return $data; + + } // get + + /** + * next + * This isn't a required function, it tells the daemon to go to the next + * song + */ + function next() { + + $function = $this->_function_map['next']; + + if (!$this->_player->$function()) { + debug_event('localplay','Error: Unable to skip to next song, check ' . $this->type . ' controller','1'); + return false; + } + + return true; + + } // next + + /** + * prev + * This isn't a required function, it tells the daemon to go the the previous + * song + */ + function prev() { + + $function = $this->_function_map['prev']; + + if (!$this->_player->$function()) { + debug_event('localplay','Error: Unable to skip to previous song, check ' . $this->type . ' controller','1'); + return false; + } + + return true; + + } // prev + + /** + * get_preferences + * This functions returns an array of the preferences that the localplay + * controller needs in order to actually work + */ + function get_preferences() { + + $preferences = $this->_player->preferences(); + + return $preferences; + + } // get_preferences + + /** + * delete + * This removes songs from the players playlist as defined get function + */ + function delete($songs) { + + + + } // delete + + } //end localplay class ?> diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 9bf5b7f1..f30c348d 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -232,25 +232,19 @@ class Stream { } // create_icecast2 - /*! - @function create_local_play - @discussion pushes out localplay mojo - */ - function create_local_play() { - - foreach($this->songs as $song_id) { - $song = new Song($song_id); - $song->format_song(); - $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type; - $url = escapeshellarg("$this->web_path/play/?song=$song_id&uid=$this->user_id&sid=$this->sess&name=" . rawurlencode($song_name)); - $localplay_add = conf('localplay_add'); - $localplay_add = str_replace("%URL%", $url, $localplay_add); - if (conf('debug')) { - log_event($_SESSION['userdata']['username'],"localplay","Exec: $localplay_add"); - } - exec($localplay_add); - header("Location: " . conf('web_path') . "/index.php"); - } + /** + * create_localplay + * This calls the Localplay API and attempts to + * add, and then start playback + */ + function create_localplay() { + + $localplay = init_localplay(); + $localplay->connect(); + $localplay->add($this->songs); + $localplay->play(); + + header("Location: " . return_referer()); } // create_localplay diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 318b9a9d..1fb90350 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -271,6 +271,11 @@ class Update { $version[] = array('version' => '332009','description' => $update_string); + $update_string = '- Reconfigure preferences to account for the new Localplay API, this also removes some preferences' . + ' from the web interface, see /test.php for any setting you may be missing'; + + $version[] = array('version' => '332010','description' => $update_string); + return $version; } // populate_version @@ -1466,5 +1471,123 @@ class Update { } // update_332009 + /** + * update_332010 + * This update changes the preferences table yet again... :( + */ + function update_332010() { + + /* Drop the Locked option */ + $sql = "ALTER TABLE `preferences` DROP `locked`"; + $db_results = mysql_query($sql, dbh()); + + /* Add the New catagory field */ + $sql = "ALTER TABLE `preferences` ADD `catagory` VARCHAR( 128 ) NOT NULL AFTER `type`"; + $db_results = mysql_query($sql, dbh()); + + /* Grab all of the Types and populate it into the catagory */ + $sql = "SELECT id,type FROM preferences"; + $db_results = mysql_query($sql, dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $key = $r['id']; + $results[$key] = $r['type']; + } + + foreach ($results as $key=>$catagory) { + + $sql = "UPDATE preferences SET catagory='" . $catagory . "' WHERE id='$key'"; + $db_results = mysql_query($sql, dbh()); + + } // foreach preferences + + /* Drop the Refresh Limit Option */ + $sql = "DELETE FROM preferences WHERE name='refresh_limit'"; + $db_results = mysql_query($sql, dbh()); + + /* Drop the Local Length */ + $sql = "DELETE FROM preferences WHERE name='local_length'"; + $db_results = mysql_query($sql, dbh()); + + /* Drop The cache limits */ + $sql = "DELETE FROM preferences WHERE name='album_cache_limit'"; + $db_results = mysql_query($sql, dbh()); + + $sql = "DELETE FROM preferences WHERE name='artist_cache_limit'"; + $db_results = mysql_query($sql, dbh()); + + $sql = "DELETE FROM preferences WHERE name='condPL'"; + $db_results = mysql_query($sql, dbh()); + + /* Insert the new Localplay Level */ + $sql = "INSERT INTO preferences (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + " VALUES ('localplay_level','0','Localplay Access Level','100','special','streaming')"; + $db_results = mysql_query($sql, dbh()); + + /* Inser the new Localplay Controller */ + $sql = "INSERT INTO preferences (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + " VALUES ('localplay_controller','0','Localplay Type','100','special','streaming')"; + $db_results = mysql_query($sql, dbh()); + + /* Set the Types for everything */ + $types['download'] = 'boolean'; + $types['upload'] = 'boolean'; + $types['quarantine'] = 'boolean'; + $types['popular_threshold'] = 'integer'; + $types['font'] = 'string'; + $types['bg_color1'] = 'string'; + $types['bg_color2'] = 'string'; + $types['base_color1'] = 'string'; + $types['base_color2'] = 'string'; + $types['font_color1'] = 'string'; + $types['font_color2'] = 'string'; + $types['font_color3'] = 'string'; + $types['row_color1'] = 'string'; + $types['row_color2'] = 'string'; + $types['row_color3'] = 'string'; + $types['error_color'] = 'string'; + $types['font_size'] = 'integer'; + $types['upload_dir'] = 'string'; + $types['sample_rate'] = 'string'; + $types['site_title'] = 'string'; + $types['lock_songs'] = 'boolean'; + $types['force_http_play'] = 'boolean'; + $types['http_port'] = 'integer'; + $types['catalog_echo_count'] = 'integer'; + $types['play_type'] = 'special'; + $types['direct_link'] = 'boolean'; + $types['lang'] = 'special'; + $types['playlist_type'] = 'special'; + $types['theme_name'] = 'special'; + $types['ellipse_threshold_album'] = 'integer'; + $types['ellipse_threshold_artist'] = 'integer'; + $types['ellipse_threshold_title'] = 'integer'; + $types['quarantine_dir'] = 'string'; + $types['localplay_level'] = 'special'; + $types['localplay_controller'] = 'special'; + + /* Now we need to insert this crap */ + foreach ($types as $key=>$type) { + + $sql = "UPDATE preferences SET type='$type' WHERE name='$key'"; + $db_results = mysql_query($sql, dbh()); + + } // foreach types + + /* Fix every users preferences */ + $sql = "SELECT * FROM user"; + $db_results = mysql_query($sql, dbh()); + + $user = new User(); + $user->fix_preferences('-1'); + + while ($r = mysql_fetch_assoc($db_results)) { + $user->fix_preferences($r['username']); + } // while results + + $this->set_version('db_version','332010'); + + } // update_332010 + } // end update class ?> diff --git a/lib/class/user.class.php b/lib/class/user.class.php index e4567ef0..5e28d2b5 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -98,21 +98,21 @@ class User { if (!conf('use_auth')) { $user_id = '-1'; } if ($user_id != '-1') { - $user_limit = "AND preferences.type != 'system'"; + $user_limit = "AND preferences.catagory != 'system'"; } if ($type != '0') { - $user_limit = "AND preferences.type = '" . sql_escape($type) . "'"; + $user_limit = "AND preferences.catagory = '" . sql_escape($type) . "'"; } - $sql = "SELECT preferences.name, preferences.description, preferences.type, user_preference.value FROM preferences,user_preference " . + $sql = "SELECT preferences.name, preferences.description, preferences.catagory, user_preference.value FROM preferences,user_preference " . "WHERE user_preference.user='$user_id' AND user_preference.preference=preferences.id $user_limit"; $db_results = mysql_query($sql, dbh()); /* Ok this is crapy, need to clean this up or improve the code FIXME */ while ($r = mysql_fetch_assoc($db_results)) { - $type = $r['type']; + $type = $r['catagory']; $admin = false; if ($type == 'system') { $admin = true; } $type_array[$type][] = array('name'=>$r['name'],'description'=>$r['description'],'value'=>$r['value']); @@ -131,7 +131,7 @@ class User { */ function set_preferences() { - $sql = "SELECT preferences.name,user_preference.value FROM preferences,user_preference WHERE user_preference.user='$this->username' " . + $sql = "SELECT preferences.name,user_preference.value FROM preferences,user_preference WHERE user_preference.user='$this->id' " . "AND user_preference.preference=preferences.id AND preferences.type != 'system'"; $db_results = mysql_query($sql, dbh()); @@ -274,7 +274,7 @@ class User { } // update_preference /** - * add_preference + * legacy_add_preference * adds a new preference * @package User * @catagory Class @@ -640,7 +640,7 @@ class User { */ if ($user_id != '-1') { $sql = "SELECT user_preference.preference,user_preference.value FROM user_preference,preferences " . - "WHERE user_preference.preference = preferences.id AND user_preference.user='-1' AND preferences.type !='system'"; + "WHERE user_preference.preference = preferences.id AND user_preference.user='-1' AND preferences.catagory !='system'"; $db_results = mysql_query($sql, dbh()); while ($r = mysql_fetch_object($db_results)) { $zero_results[$r->preference] = $r->value; @@ -650,7 +650,7 @@ class User { $sql = "SELECT * FROM preferences"; if ($user_id != '-1') { - $sql .= " WHERE type !='system'"; + $sql .= " WHERE catagory !='system'"; } $db_results = mysql_query($sql, dbh()); diff --git a/lib/localplay.lib.php b/lib/localplay.lib.php new file mode 100644 index 00000000..c0ef6e32 --- /dev/null +++ b/lib/localplay.lib.php @@ -0,0 +1,238 @@ +type == ".flac") { $song->type = ".ogg"; } + if ($GLOBALS['user']->prefs['play_type'] == 'downsample') { + $ds = $GLOBALS['user']->prefs['sample_rate']; + } + $song_url = conf('web_path') . "/play/index.php?song=$song_id&uid=" . $_SESSION['userdata']['username'] . "&sid=$sess_id&ds=$ds&name=." . $song->type; + if (is_null( $myMpd->PlAdd($song_url) ) ) { + $log_line = _("Error") . ": " . _("Could not add") . ": " . $song_url . " : " . $myMpd->errStr; + echo "$log_line
\n"; + if (conf('debug')) { log_event($GLOBALS['user']->username,'add',$log_line); } + } // if it's null + } // if we want urls + else { + $song = new Song( $song_id ); + $song_filename = $song->get_rel_path(); + if( is_null( $myMpd->PLAdd( $song_filename ) ) ) { + $log_line = _("Error") . ": " . _("Could not add") . ": " . $song_filename . " : " . $myMpd->errStr; + echo "$log_line
\n"; + if (conf('debug')) { log_event($_SESSION['userdata']['username'],'add',$log_line); } + } // end if it's null + // We still need to count if they use the file method + else { + $GLOBALS['user']->update_stats( $song_id ); + } // end else + + } // end else not url method + } // end foreach + +} // addToPlaylist + +/*! + @function show_mpd_control + @discussion shows the mpd controls +*/ +function show_mpd_control() { + + $_REQUEST['action'] = 'show_control'; + require (conf('prefix').'/amp-mpd.php'); + + +} // show_mpd_control + +/** + * show_mpd_pl + * Shows the MPD playlist + * @package Local Play + * @catagory MPD + */ +function show_mpd_pl() { + + $myMpd = init_mpd(); + + require (conf('prefix').'/templates/show_mpdpl.inc'); +} // show_mpd_pl + +/** + * mpd_redirect + * Redriect mojo + * @package Local Play + * @catagory MPD + * @param $page is the URL after conf('web_path') . '/' + */ +function mpd_redirect( $page = 'mpd.php' ) { + if (conf('localplay_menu')) { + header ("Location: " . conf('web_path') . '/' . $page); + } + else { + header ("Location: " . conf('web_path')); + } +} // mpd_redirect + +/** + * verify_localplay_prefrences + * This takes a type of localplay and then + * Verifys that the preferences have all been + * inserted into the database if they haven't been + * Then it returns false + */ +function verify_localplay_preferences($type) { + + /* Load the locaplay module of said type */ + $localplay = new Localplay($type); + + $preferences = $localplay->get_preferences(); + + foreach ($preferences as $preference) { + $name = 'localplay_' . $type . '_' . $preference['name']; + /* check for an existing record */ + $sql = "SELECT id FROM preferences WHERE name = '" . sql_escape($name) . "'"; + $db_results = mysql_query($sql, dbh()); + + if (!mysql_num_rows($db_results)) { return false; } + + } // end foreach preferences + + return true; + +} // verify_localplay_preferences + + +/** + * insert_locaplay_preferences + * This takes a controller type and inserts the preferences + * Into the database, it is able to handle existing preferences + * It checks before inserting... + */ +function insert_localplay_preferences($type) { + + /* We can't assume the connect so let's just + * create it then get the preferences + */ + $localplay = new Localplay($type); + + $preferences = $localplay->get_preferences(); + + foreach ($preferences as $preference) { + $name = 'localplay_' . $type . '_' . $preference['name']; + /* Check for an existing record */ + $sql = "SELECT id FROM preferences WHERE name = '" . sql_escape($name) . "'"; + $db_results = mysql_query($sql, dbh()); + + if (mysql_num_rows($db_results)) { continue; } + + insert_preference($name,$preference['description'],$preference['default'],'25',$preference['type'],'streaming'); + + } // end foreach preferences + + /* Fix everyones preferences */ + $sql = "SELECT * FROM user"; + $db_results = mysql_query($sql, dbh()); + + $temp_user = new User(); + $temp_user->fix_preferences('-1'); + + while ($r = mysql_fetch_assoc($db_results)) { + $temp_user->fix_preferences($r['username']); + } // end while + + return true; + +} // insert_localplay_preferences + + +/** + * get_localplay_controllers + * This returns an array of the localplay controllers filenames + * as well as a 'semi-cleaned' name + */ +function get_localplay_controllers() { + + /* First get a list of the files */ + $handle = opendir(conf('prefix') . '/modules/localplay'); + + if (!is_resource($handle)) { + debug_event('localplay','Error: Unable to read localplay controller directory','1'); + } + + $results = array(); + + while ($file = readdir($handle)) { + + if (substr($file,-14,14) != 'controller.php') { continue; } + + /* Make sure it isn't a subdir */ + if (!is_dir($file)) { + /* Get the base name, then get everything before .controller.php */ + $filename = basename($file,'.controller.php'); + $results[] = $filename; + } + } // end while + + return $results; + +} // get_localplay_controllers + + +/** + * This function stores the Localplay object + * It checks to see what access level you have + * and creates the localplay object based on that + * @package Local Play + */ +function init_localplay($reload=0) { + + static $localplay; + + if ($GLOBALS['user']->prefs['localplay_level'] == '0') { return false; } + + if ($GLOBALS['user']->prefs['localplay_level'] == '1' AND !is_object($localplay)) { + $localplay = new Localplay(conf('localplay_controller')); + $localplay->connect(); + } + + if ($GLOBALS['user']->prefs['localplay_level'] == '2' AND !is_object($localplay)) { + $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); + $localplay->connect(); + } + + return $localplay; + +} // function init_localplay + +?> diff --git a/lib/mpd.php b/lib/mpd.php deleted file mode 100644 index 26053267..00000000 --- a/lib/mpd.php +++ /dev/null @@ -1,142 +0,0 @@ -type == ".flac") { $song->type = ".ogg"; } - if ($GLOBALS['user']->prefs['play_type'] == 'downsample') { - $ds = $GLOBALS['user']->prefs['sample_rate']; - } - $song_url = conf('web_path') . "/play/index.php?song=$song_id&uid=" . $_SESSION['userdata']['username'] . "&sid=$sess_id&ds=$ds&name=." . $song->type; - if (is_null( $myMpd->PlAdd($song_url) ) ) { - $log_line = _("Error") . ": " . _("Could not add") . ": " . $song_url . " : " . $myMpd->errStr; - echo "$log_line
\n"; - if (conf('debug')) { log_event($GLOBALS['user']->username,'add',$log_line); } - } // if it's null - } // if we want urls - else { - $song = new Song( $song_id ); - $song_filename = $song->get_rel_path(); - if( is_null( $myMpd->PLAdd( $song_filename ) ) ) { - $log_line = _("Error") . ": " . _("Could not add") . ": " . $song_filename . " : " . $myMpd->errStr; - echo "$log_line
\n"; - if (conf('debug')) { log_event($_SESSION['userdata']['username'],'add',$log_line); } - } // end if it's null - // We still need to count if they use the file method - else { - $GLOBALS['user']->update_stats( $song_id ); - } // end else - - } // end else not url method - } // end foreach - -} // addToPlaylist - -/*! - @function show_mpd_control - @discussion shows the mpd controls -*/ -function show_mpd_control() { - - $_REQUEST['action'] = 'show_control'; - require (conf('prefix').'/amp-mpd.php'); - - -} // show_mpd_control - -/** - * show_mpd_pl - * Shows the MPD playlist - * @package Local Play - * @catagory MPD - */ -function show_mpd_pl() { - - $myMpd = init_mpd(); - - require (conf('prefix').'/templates/show_mpdpl.inc'); -} // show_mpd_pl - -/** - * mpd_redirect - * Redriect mojo - * @package Local Play - * @catagory MPD - * @param $page is the URL after conf('web_path') . '/' - */ -function mpd_redirect( $page = 'mpd.php' ) { - if (conf('localplay_menu')) { - header ("Location: " . conf('web_path') . '/' . $page); - } - else { - header ("Location: " . conf('web_path')); - } -} // mpd_redirect - - -/** - * Init MPD - This is originally from /amp-mpd.php - * This initializes MPD if it is the playback method. - * It checks to see if a global variable called myMpd is an object - * if it's not then it attempt to create one and return it - * @package Local Play - * @catagory MPD - */ -function init_mpd() { - - static $myMpd; - - if (!conf('allow_mpd_playback')) { return false; } - - if (!is_object($myMpd)) { - $myMpd = new mpd(conf('mpd_host'),conf('mpd_port')); - } - - if (!$myMpd->connected AND is_object($myMpd)) { - // Attempt to reconnect - $myMpd->Connect(); - } - - if (!$myMpd->connected) { - if (conf('debug')) { - log_event ($_SESSION['userdata']['username'],' connection_failed ',"Error: unable to connect to ". conf('mpd_host') . " on port " . conf('mpd_port') . " ".$myMpd->errStr); - } - return false; - } - - return $myMpd; - -} // function init_mpd() - -?> diff --git a/lib/preferences.php b/lib/preferences.php index 970a099f..66996e40 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -258,32 +258,17 @@ function create_preference_input($name,$value) { echo "\n"; break; case 'play_type': - if ($value == 'local_play') { $is_local = "selected=\"selected\""; } - elseif ($value == 'icecast2') { $is_ice = "selected=\"selected\""; } - elseif ($value == 'downsample') { $is_down = "selected=\"selected\""; } - elseif ($value == 'mpd') { $is_mpd = "selected=\"selected\""; } - elseif ($value == 'slim') { $is_slim = "selected=\"selected\""; } + if ($value == 'downsample') { $is_down = 'selected="selected"'; } + elseif ($value == 'localplay') { $is_local = 'selected="selected"'; } else { $is_stream = "selected=\"selected\""; } echo "\n"; break; case 'playlist_type': @@ -311,6 +296,25 @@ function create_preference_input($name,$value) { } // end foreach echo "\n"; break; + case 'localplay_controller': + $controllers = get_localplay_controllers(); + echo "\n"; + break; + case 'localplay_level': + if ($GLOBALS['user']->prefs['localplay_level'] == '2') { $is_full = 'selected="selected"'; } + elseif ($GLOBALS['user']->prefs['localplay_level'] == '1') { $is_global = 'selected="selected"'; } + echo "\n"; + break; case 'theme_name': $themes = get_themes(); echo "\n"; - break; + break; case 'quarantine_dir': case 'upload_dir': if (!$GLOBALS['user']->has_access(100)) { @@ -352,4 +356,31 @@ function get_preference_id($name) { } // get_preference_id +/** + * insert_preference + * This creates a new preference record in the + * preferences table this is used by the modules + */ +function insert_preference($name,$description,$default,$level,$type,$catagory) { + + /* Clean the incomming variables */ + $name = sql_escape($name); + $description = sql_escape($description); + $default = sql_escape($default); + $level = sql_escape($level); + $type = sql_escape($type); + $catagory = sql_escape($catagory); + + + /* Form the sql statement */ + $sql = "INSERT INTO preferences (`name`,`description`,`value`,`type`,`level`,`catagory`) VALUES " . + " ('$name','$description','$default','$type','$level','$catagory')"; + $db_results = mysql_query($sql, dbh()); + + if ($db_results) { return true; } + + return false; + +} // insert_preference + ?> diff --git a/lib/ui.lib.php b/lib/ui.lib.php index dec697ae..2bed47c6 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -49,32 +49,6 @@ function show_confirmation($title,$text,$next_url,$cancel=0) { } // show_confirmation -/** - * set_preferences - * legacy function... - * @todo Remove References - * @deprecated - */ -function set_preferences() { - - init_preferences(); - return true; - -} // set_preferences - -/** - * get_preferences - * WTF was I thinking, this should be set or ini not get.. it doesn't get anything.. sigh anyway I'll - * leave this be for now. - * @deprecated - */ -function get_preferences($username=0) { - - init_preferences(); - return true; - -} // get_preferences - /** * init_preferences * Third times the charm, why rename a function once when you can do it three times :( @@ -86,7 +60,7 @@ function init_preferences() { /* Get Global Preferences */ $sql = "SELECT preferences.name,user_preference.value FROM preferences,user_preference WHERE user_preference.user='-1' " . - " AND user_preference.preference = preferences.id AND preferences.type='system'"; + " AND user_preference.preference = preferences.id AND preferences.catagory='system'"; $db_results = mysql_query($sql, dbh()); while ($r = mysql_fetch_assoc($db_results)) { @@ -95,10 +69,13 @@ function init_preferences() { } // end while sys prefs /* Now we need to allow the user to override some stuff that's been set by the above */ - $username = $_SESSION['userdata']['username']; + $user_id = '-1'; + if ($GLOBALS['user']->username) { + $user_id = sql_escape($GLOBALS['user']->id); + } - $sql = "SELECT preferences.name,user_preference.value FROM preferences,user_preference WHERE user_preference.user='$username' " . - " AND user_preference.preference = preferences.id AND preferences.type != 'system'"; + $sql = "SELECT preferences.name,user_preference.value FROM preferences,user_preference WHERE user_preference.user='$user_id' " . + " AND user_preference.preference = preferences.id AND preferences.catagory != 'system'"; $db_results = mysql_query($sql, dbh()); while ($r = mysql_fetch_assoc($db_results)) { @@ -106,6 +83,11 @@ function init_preferences() { $results[$name] = $r['value']; } // end while + /* Set the Theme mojo */ + if (strlen($results['theme_name']) > 0) { + $results['theme_path'] = '/themes/' . $results['theme_name']; + } + conf($results,1); return true; @@ -444,7 +426,7 @@ function get_now_playing() { $np_user = new User($r['user']); $results[] = array('song'=>$song,'user'=>$np_user); } // end while - +/* $myMpd = init_mpd(); if (is_object($myMpd) AND conf('mpd_method') == 'file') { @@ -465,7 +447,7 @@ function get_now_playing() { } // end while } // end if we have a MPD object - +*/ return $results; diff --git a/login.php b/login.php index 7a370ed4..0311dc76 100644 --- a/login.php +++ b/login.php @@ -27,9 +27,9 @@ */ $no_session = true; -require_once("modules/init.php"); +require_once('modules/init.php'); vauth_session_cookie(); -set_site_preferences(); +init_preferences(); /* Check for posted username and password */ if ($_POST['username'] && $_POST['password']) { diff --git a/modules/init.php b/modules/init.php index 5e8257b4..63ce2c1d 100644 --- a/modules/init.php +++ b/modules/init.php @@ -80,9 +80,7 @@ if (!$results['allow_stream_playback']) { /** This is the version.... fluf nothing more... **/ -$results['version'] = '3.3.2-Beta3 (Build 002)'; - - +$results['version'] = '3.3.2-Beta3 (Build 003)'; $results['raw_web_path'] = $results['web_path']; $results['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['web_path']; @@ -145,33 +143,24 @@ require_once(conf('prefix') . '/lib/search.php'); require_once(conf('prefix') . '/lib/preferences.php'); require_once(conf('prefix') . '/lib/rss.php'); require_once(conf('prefix') . '/lib/log.lib.php'); -require_once(conf('prefix') . '/lib/mpd.php'); +require_once(conf('prefix') . '/lib/localplay.lib.php'); require_once(conf('prefix') . '/lib/ui.lib.php'); require_once(conf('prefix') . '/lib/gettext.php'); require_once(conf('prefix') . '/lib/batch.lib.php'); require_once(conf('prefix') . '/lib/themes.php'); require_once(conf('prefix') . '/lib/stream.lib.php'); require_once(conf('prefix') . '/lib/playlist.lib.php'); +require_once(conf('prefix') . '/lib/upload.php'); require_once(conf('prefix') . '/modules/lib.php'); require_once(conf('prefix') . '/modules/admin.php'); require_once(conf('prefix') . '/modules/catalog.php'); -require_once(conf('prefix') . '/lib/upload.php'); - -// Modules (These are conditionaly included depending upon config values) require_once(conf('prefix') . "/modules/id3/audioinfo.class.php"); require_once(conf('prefix') . "/modules/amazon/Snoopy.class.php"); require_once(conf('prefix') . "/modules/amazon/AmazonSearchEngine.class.php"); require_once(conf('prefix') . "/lib/xmlrpc.php"); require_once(conf('prefix') . "/modules/xmlrpc/xmlrpc.inc"); -if (conf('allow_slim_playback')) { - require_once(conf('prefix') . '/modules/slimserver/slim.class.php'); -} - -if (conf('allow_mpd_playback')) { - require_once(conf('prefix') . '/modules/mpd/mpd.class.php'); -} - +// Modules (These are conditionaly included depending upon config values) if (conf('ratings')) { require_once(conf('prefix') . '/lib/class/rating.class.php'); require_once(conf('prefix') . '/lib/rating.lib.php'); @@ -229,20 +218,17 @@ if (($gc_divisor / $gc_probability) > 5) { /* PHP5 Date problem solved.. ya'll GMT now! */ putenv("TZ=GMT"); -/* END Set PHP Vars */ - -/* Overwrite them with the DB preferences */ -set_site_preferences(); - /* Seed the random number */ srand((double) microtime() * 1000003); +/**** END Set PHP Vars ****/ + // If we don't want a session if (!isset($no_session) AND conf('use_auth')) { if (!vauth_check_session()) { logout(); exit(); } + $user = new User($_SESSION['userdata']['username']); init_preferences(); set_theme(); - $user = new User($_SESSION['userdata']['username']); $user->set_preferences(); $user->update_last_seen(); } @@ -283,6 +269,8 @@ flip_class(array('odd','even')); /* Setup the Error Class */ $error = new Error(); + +/* Set the Theme */ $theme = get_theme(conf('theme_name')); if (! preg_match('/update\.php/', $_SERVER['PHP_SELF'])) { diff --git a/modules/kajax/ajax.js b/modules/kajax/ajax.js index 9920f4d4..0ed70087 100755 --- a/modules/kajax/ajax.js +++ b/modules/kajax/ajax.js @@ -1,4 +1,3 @@ - diff --git a/modules/kajax/driver.php b/modules/kajax/driver.php deleted file mode 100755 index 5cb4edbb..00000000 --- a/modules/kajax/driver.php +++ /dev/null @@ -1,13 +0,0 @@ - - javascript:makeRequest(\"$url\",\"$get\"); -"; -?> diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php index 160e3e6e..f05447d0 100644 --- a/modules/localplay/mpd.controller.php +++ b/modules/localplay/mpd.controller.php @@ -56,12 +56,19 @@ class AmpacheMpd { $map = array(); + /* Required Functions */ $map['add'] = 'add_songs'; $map['delete'] = 'delete_songs'; $map['play'] = 'play'; $map['stop'] = 'stop'; $map['get'] = 'get_songs'; + $map['status'] = 'get_status'; $map['connect'] = 'connect'; + + /* Optional Functions */ + $map['next'] = 'next'; + $map['prev'] = 'prev'; + $map['pause'] = 'pause'; return $map; @@ -79,9 +86,9 @@ class AmpacheMpd { $preferences = array(); - $preferences[] = array('name'=>'hostname','default'=>'localhost','type'=>'string'); - $preferences[] = array('name'=>'port','default'=>'6600','type'=>'integer'); - $preferences[] = array('name'=>'password','default'=>'','type'=>'string'); + $preferences[] = array('name'=>'hostname','default'=>'localhost','type'=>'string','description'=>'MPD Hostname'); + $preferences[] = array('name'=>'port','default'=>'6600','type'=>'integer','description'=>'MPD Port'); + $preferences[] = array('name'=>'password','default'=>'','type'=>'string','description'=>'MPD Password'); return $preferences; @@ -163,6 +170,42 @@ class AmpacheMpd { } // stop + /** + * next + * This just tells MPD to skip to the next song + */ + function next() { + + if (is_null($this->_mpd->Next())) { return false; } + + return true; + + } // next + + /** + * prev + * This just tells MPD to skip to the prev song + */ + function prev() { + + if (is_null($this->_mpd->Previous())) { return false; } + + return true; + + } // prev + + /** + * pause + * This tells MPD to pause the current song + */ + function pause() { + + if (is_null($this->_mpd->Pause())) { return false; } + + return true; + + } // pause + /** * get_songs * This functions returns an array containing information about @@ -174,8 +217,7 @@ class AmpacheMpd { /* Get the Current Playlist */ $playlist = $this->_mpd->playlist; - foreach ($playlist as $key=>$entry) { - + foreach ($playlist as $entry) { $data = array(); /* Required Elements */ @@ -189,6 +231,8 @@ class AmpacheMpd { } // foreach playlist items + return $results; + } // get_songs /** @@ -198,8 +242,13 @@ class AmpacheMpd { */ function get_status() { + /* Construct the Array */ + $array['state'] = $this->_mpd->state; + $array['volume'] = $this->_mpd->volume; + $array['repeat'] = $this->_mpd->repeat; + $array['random'] = $this->_mpd->random; - + return $array; } // get_status diff --git a/modules/vauth/session.lib.php b/modules/vauth/session.lib.php index 18006dc1..9c30e1bc 100644 --- a/modules/vauth/session.lib.php +++ b/modules/vauth/session.lib.php @@ -66,7 +66,7 @@ function vauth_sess_close() { function vauth_sess_read($key) { $results = vauth_get_session($key); - if (!is_array($results)) { + if (isset($results['value']) AND strlen($results['value']) < 1) { vauth_error('Unable to read session data'); return ''; } diff --git a/server/ajax.server.php b/server/ajax.server.php index b5b149b5..394d4ce4 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -1,172 +1,70 @@ '; - -$no_session = true; -include ('../modules/init.php'); -$myMpd = init_mpd(); - -$action = $_GET['action']; -$player = $_GET['player']; -$result = ''; - - -function mpderr() { global $result, $myMpd; - if ($GLOBALS['player'] == 'mpd') - { $result = $result . ''.$myMpd->errStr.''; } } -function volume() { global $result, $myMpd; - if ($GLOBALS['player'] == 'mpd') - { $result = $result . ''. $myMpd->volume. ''; } } -function state() { global $result, $myMpd; - if ($GLOBALS['player'] == 'mpd') - { $result = $result. ''. $myMpd->state. ''; } } - -function mpd_cur_track_pos () { - global $result, $myMpd; - if ($GLOBALS['player'] == 'mpd') { - $result = $result . ''.$myMpd->current_track_position.''; - } -} - -function now_playing() { -global $result, $myMpd; - if ($GLOBALS['player'] == 'mpd') { - if (!$myMpd->playlist[($myMpd->current_track_id)]['Title']) { - list($tmp, $id, $tmp) = preg_split("/(song=|&)/", $myMpd->playlist[($myMpd->current_track_id)]['file']); - $r = new Song($id); - $myMpd->playlist[($myMpd->current_track_id)]['Title'] = $r->title; - $myMpd->playlist[($myMpd->current_track_id)]['Artist'] = $r->get_artist_name(); - $myMpd->playlist[($myMpd->current_track_id)]['Album'] = $r->get_album_name(); - } - $result = $result.''. - ''.$myMpd->current_track_id.''. - ''.htmlspecialchars($myMpd->playlist[$myMpd->current_track_id]['Title']).''. - ''.htmlspecialchars($myMpd->playlist[$myMpd->current_track_id]['Artist']).''. - ''.htmlspecialchars($myMpd->playlist[$myMpd->current_track_id]['Album']).''. - ''.htmlspecialchars($myMpd->playlist[($myMpd->current_track_id)]['Time']).''. - ''; - } //end if player == mpd -now_playing_display(); -} +/* + Copyright (c) 2001 - 2006 Ampache.org + All rights reserved. -function now_playing_display() { + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. - global $result; - $dbh = dbh(); - $results = get_now_playing(); - $result = $result.''; - - if (count($results)) { - - foreach($results as $item) { - - $song = $item['song']; - $np_user = $item['user']; - - if (is_object($song)) { - - $result = $result.''; - - if (!$np_user->fullname) { $np_user->fullname = "Unknown User"; } - - if (conf('use_auth')) { - $result = $result.''.$np_user->fullname.''; - } else { - $result = $result.''; - } - - $result = $result.''.$song->id.''; - $result = $result.''.$song->album.''; - $result = $result.''.$song->artist.''; - $result = $result.''.htmlspecialchars($song->f_title).''; - $result = $result.''.htmlspecialchars($song->f_artist).''; - $result = $result.''.htmlspecialchars($song->f_album).''; - - $result = $result.''; - - } // if it's a song - } // foreach song - - } // if now playing - $result = $result.''; - -} + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -/********************** -The below handles a request for action on the mpd player and/or the return of mpd -player state information. +*/ -It is grossly inefficient because everytime there is a request it loads init.php and does a full -instantiation of myMpd. Would be much faster if it only loaded limited info to start, then -just grabbed what it needed. (Prolly tougher to maintain abstraction.) -**********************/ +/* Because this is accessed via Ajax we are going to allow the session_id + * as part of the get request + */ -/*if (!$user->has_access(25)) { echo 'Inadequate access privileges!'; return; }*/ - -switch ($action) { -case 'getvol' : - $result = ''. $myMpd->volume. ''; +$no_session = true; +require_once('../modules/init.php'); + +/* Verify the existance of the Session they passed in */ +if (!session_exists($_REQUEST['sessid'])) { exit(); } + +$GLOBALS['user'] = new User($_REQUEST['user_id']); +$action = scrub_in($_REQUEST['action']); + +switch ($action) { + case 'localplay': + init_preferences(); + $localplay = init_localplay(); + $localplay->connect(); + $function = scrub_in($_GET['cmd']); + $localplay->$function(); + echo $function; break; -case 'setvol' : - if ( is_null($myMpd->SetVolume($_GET['param1'])) ) $result = ''.$myMpd->errStr.''; - $result = $result.''. $myMpd->volume. ''; + case 'change_play_type': + init_preferences(); + session_id(scrub_in($_REQUEST['sessid'])); + session_start(); + $_SESSION['data']['old_play_type'] = conf('play_type'); + $pref_id = get_preference_id('play_type'); + $GLOBALS['user']->update_preference($pref_id,$_GET['type']); + + /* Now Replace the text as you should */ + $ajax_url = conf('web_path') . '/server/ajax.server.php'; + $required_info = "&user_id=" . $GLOBALS['user']->id . "&sessid=" . session_id(); + if ($_GET['type'] == 'localplay') { ?> + + + + + + + + AdjustVolume($_GET['param1'])) ) $result = ''.$myMpd->errStr.''; - volume(); - break; - case ' > ': - case "play": - if ( is_null($myMpd->Play()) ) $result = ''.$myMpd->errStr.'\n'; - mpd_cur_track_pos(); - state(); - now_playing(); - break; - case "stop": - case ' X ': - if ( is_null($myMpd->Stop()) ) $result = ''.$myMpd->errStr.'\n'; - $result = $result.''. $myMpd->state. ''; - now_playing(); - break; - case ' | | ': - case ' = ': - case "pause": - if ( is_null($myMpd->Pause()) ) echo "ERROR: " .$myMpd->errStr."\n"; - mpd_cur_track_pos(); - state(); - now_playing(); - break; - case '|< ': - case "Prev": - if ( is_null($myMpd->Previous()) ) echo "ERROR: " . $myMpd->errStr."\n"; - mpd_cur_track_pos(); - state(); - now_playing(); - break; - case ' >|'; - case "Next": - if ( is_null($myMpd->Next()) ) echo "ERROR: " . $myMpd->errStr."\n"; - mpd_cur_track_pos(); - state(); - now_playing(); - break; - case 'now_playing' : - mpd_cur_track_pos(); - state(); - now_playing(); -// now_playing_display(); - break; - - -} //end switch - - -echo '' . - '' . $action .$player.'' . - $result . -''; + default: + echo "Default Action"; + break; +} // end switch action ?> diff --git a/song.php b/song.php index af6e9337..6905d71b 100644 --- a/song.php +++ b/song.php @@ -137,7 +137,7 @@ switch ($method) { $stream_type = conf('playlist_type'); if ($GLOBALS['user']->prefs['play_type'] != "stream" AND $GLOBALS['user']->prefs['play_type'] != "downsample") { - $stream_type = $user->prefs['play_type']; + $stream_type = $GLOBALS['user']->prefs['play_type']; } /* Start the Stream */ diff --git a/templates/footer.inc b/templates/footer.inc index 91332b3f..fc9752cb 100644 --- a/templates/footer.inc +++ b/templates/footer.inc @@ -20,6 +20,8 @@ */ ?> + + diff --git a/templates/header.inc b/templates/header.inc index 1277c4bc..b2839fec 100644 --- a/templates/header.inc +++ b/templates/header.inc @@ -38,6 +38,7 @@ if (conf('use_rss')) { ?> +
@@ -58,5 +59,10 @@ if (conf('use_rss')) { ?>
+ + - - + + - + has_access(100)) AND ($user_id == '-1' AND conf('use_auth } ?> - + has_access(100)) { ?> [] @@ -79,7 +79,7 @@ if (($GLOBALS['user']->has_access(100)) AND ($user_id == '-1' AND conf('use_auth -
+
_("Users"),'url'=>'admin/users.php','active'=>$location['page']); -$admin_items[] = array('title'=>_("Mail Users"),'url'=>'admin/mail.php','active'=>$location['page']); -$admin_items[] = array('title'=>_("Catalog"),'url'=>'admin/index.php','active'=>$location['page']); -$admin_items[] = array('title'=>_("Site Preferences"),'url'=>'admin/preferences.php','active'=>$location['page']); -$admin_items[] = array('title'=>_("Access List"),'url'=>'admin/access.php','active'=>$location['page']); +$admin_items[] = array('title'=>_('Users'),'url'=>'admin/users.php','active'=>$location['page']); +$admin_items[] = array('title'=>_('Mail Users'),'url'=>'admin/mail.php','active'=>$location['page']); +$admin_items[] = array('title'=>_('Catalog'),'url'=>'admin/index.php','active'=>$location['page']); +$admin_items[] = array('title'=>_('Site Preferences'),'url'=>'admin/preferences.php','active'=>$location['page']); +$admin_items[] = array('title'=>_('Access List'),'url'=>'admin/access.php','active'=>$location['page']); +$admin_items[] = array('title'=>_('Modules'),'url'=>'admin/modules.php','active'=>$location['page']); $browse_items[] = array('title'=>_("Albums"),'url'=>'albums.php','active'=>$location['page']); $browse_items[] = array('title'=>_("Artists"),'url'=>'artists.php','active'=>$location['page']); @@ -49,12 +50,13 @@ $web_path = conf('web_path'); has_access(100)) { ?> > diff --git a/test.php b/test.php index 69252751..d7949515 100644 --- a/test.php +++ b/test.php @@ -1,6 +1,9 @@
diff --git a/templates/show_localplay_control.inc.php b/templates/show_localplay_control.inc.php new file mode 100644 index 00000000..db771110 --- /dev/null +++ b/templates/show_localplay_control.inc.php @@ -0,0 +1,63 @@ +status(); + +$required_info = "&user_id=" . $GLOBALS['user']->id . "&sessid=" . session_id(); +$ajax_url = $web_path . '/server/ajax.server.php'; + +?> +has_function('prev')) { ?> + + + + + + + +has_function('pause')) { ?> + + + + + + + +has_function('next')) { ?> + + + + +
+Current State:
+ + + + + + + + + + +
diff --git a/templates/show_modules.inc.php b/templates/show_modules.inc.php new file mode 100644 index 00000000..23c1d593 --- /dev/null +++ b/templates/show_modules.inc.php @@ -0,0 +1,55 @@ + + + + + + +" . + _('Activate') . ""; + } +?> + + + + + + + + + +
diff --git a/templates/show_preference_box.inc.php b/templates/show_preference_box.inc.php index 4d2ffa67..f7298b05 100644 --- a/templates/show_preference_box.inc.php +++ b/templates/show_preference_box.inc.php @@ -40,10 +40,10 @@ if ($GLOBALS['user']->has_access(100) AND conf('use_auth')) {