diff options
32 files changed, 790 insertions, 470 deletions
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 @@ +<?php +/* + + Copyright (c) 2001 - 2006 Ampache.org + All rights reserved. + + 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. + + 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. + +*/ + +require('../modules/init.php'); + +if (!$GLOBALS['user']->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 @@ -<?php - -/* - - Copyright (c) 2001 - 2005 Ampache.org - All rights reserved. - - 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. - - 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. - -*/ - - -/*! - @header Orphaned Admin Page - View and edit orphan files - -*/ - -require('../modules/init.php'); - - -if (!$user->has_access(100)) { - header("Location: " . conf('web_path') . "/index.php?access=denied"); - exit(); -} - - -if ( $type and $action == 'show_songs' ) { - print("<p style=\"font-size: 12px; font-weight: bold;\"> Orphaned Songs with missing $type information </p>"); - - $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("<p style=\"font-size: 12px; font-weight: bold;\"> Orphaned songs with no artist </p>"); - - $song_ids = get_orphan_songs(); - show_songs($song_ids); -} -elseif ( $action == 'show_orphan_albums' ) { - print("<p style=\"font-size: 12px; font-weight: bold;\"> Orphaned albums with no name </p>"); - - $song_ids = get_orphan_albums(); - show_songs($song_ids); -} - -?> - - -<hr /> - -</body> -</html> 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 @@ ##<?php exit(); ?>## #################### -# 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 Binary files differnew file mode 100755 index 00000000..e7e6664f --- /dev/null +++ b/images/localplay/next.gif diff --git a/images/localplay/pause.gif b/images/localplay/pause.gif Binary files differnew file mode 100755 index 00000000..7f49b71f --- /dev/null +++ b/images/localplay/pause.gif diff --git a/images/localplay/play.gif b/images/localplay/play.gif Binary files differnew file mode 100755 index 00000000..a416b0d9 --- /dev/null +++ b/images/localplay/play.gif diff --git a/images/localplay/prev.gif b/images/localplay/prev.gif Binary files differnew file mode 100755 index 00000000..575e4692 --- /dev/null +++ b/images/localplay/prev.gif diff --git a/images/localplay/stop.gif b/images/localplay/stop.gif Binary files differnew file mode 100755 index 00000000..428c3279 --- /dev/null +++ b/images/localplay/stop.gif 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/mpd.php b/lib/localplay.lib.php index 26053267..c0ef6e32 100644 --- a/lib/mpd.php +++ b/lib/localplay.lib.php @@ -104,39 +104,135 @@ function mpd_redirect( $page = 'mpd.php' ) { } } // 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) { -/** - * 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 + /* 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 init_mpd() { +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()); - static $myMpd; + $temp_user = new User(); + $temp_user->fix_preferences('-1'); - if (!conf('allow_mpd_playback')) { return false; } + while ($r = mysql_fetch_assoc($db_results)) { + $temp_user->fix_preferences($r['username']); + } // end while - if (!is_object($myMpd)) { - $myMpd = new mpd(conf('mpd_host'),conf('mpd_port')); - } + return true; - if (!$myMpd->connected AND is_object($myMpd)) { - // Attempt to reconnect - $myMpd->Connect(); +} // 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'); } - 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); + $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; } - return false; - } + } // 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 $myMpd; + return $localplay; -} // function init_mpd() +} // function init_localplay ?> 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 "</select>\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 "<select name=\"$name\">\n"; - if (conf('allow_local_playback')) { - echo "\t<option value=\"local_play\" $is_local>" . _("Local") . "</option>\n"; - } if (conf('allow_stream_playback')) { - echo "\t<option value=\"stream\" $is_stream>" . _("Stream") . "</option>\n"; - } - if (conf('allow_icecast_playback')) { - echo "\t<option value=\"icecast2\" $is_ice>" . _("IceCast") . "</option>\n"; + echo "\t<option value=\"stream\" $is_stream>" . _('Stream') . "</option>\n"; } if (conf('allow_downsample_playback')) { - echo "\t<option value=\"downsample\" $is_down>" . _("Downsample") . "</option>\n"; - } - if (conf('allow_mpd_playback')) { - echo "\t<option value=\"mpd\" $is_mpd>" . _("Music Player Daemon") . "</option>\n"; - } - if (conf('allow_slim_playback')) { - echo "\t<option value=\"slim\" $is_slim>" . _("SlimServer") . "</option>\n"; + echo "\t<option value=\"downsample\" $is_down>" . _('Downsample') . "</option>\n"; } - + echo "\t<option value=\"localplay\" $is_local>" . _('Localplay') . "</option>\n"; echo "</select>\n"; break; case 'playlist_type': @@ -311,6 +296,25 @@ function create_preference_input($name,$value) { } // end foreach echo "</select>\n"; break; + case 'localplay_controller': + $controllers = get_localplay_controllers(); + echo "<select name=\"$name\">\n"; + foreach ($controllers as $controller) { + $is_selected = ''; + if ($value == $controller) { $is_selected = 'selected="selected"'; } + echo "\t<option value=\"" . $controller . "\" $is_selected>" . ucfirst($controller) . "</option>\n"; + } // end foreach + echo "</select>\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 "<select name=\"$name\">\n"; + echo "<option value=\"0\">" . _('Disabled') . "</option>\n"; + echo "<option value=\"1\" $is_global>" . _('Global') . "</option>\n"; + echo "<option value=\"2\" $is_full>" . _('Full') . "</option>\n"; + echo "</select>\n"; + break; case 'theme_name': $themes = get_themes(); echo "<select name=\"$name\">\n"; @@ -320,7 +324,7 @@ function create_preference_input($name,$value) { echo "\t<option value=\"" . $theme['path'] . "\" $is_selected>" . $theme['name'] . "</option>\n"; } // foreach themes echo "</select>\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 @@ -50,32 +50,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 :( * This grabs the preferences and then loads them into conf it should be run on page load @@ -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; @@ -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 @@ -<script type="text/javascript">
//var xmlDoc = null;
var http_request = false;
var IE = true;
@@ -38,8 +37,7 @@ function ajaxPut(url,getTerms,uid) {
makeRequest(url,getTerms);
- data = http_request.responseTXT;
+ data = http_request.responseText;
document.getElementById(uid).innerHTML = data;
}
-</script>
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 @@ -<?
- Copyright 2006 Kevin Riker
- All Rights Reserved
-
-$url = "query.php";
-$get = "search=hello";
-
-require_once('ajax.js');
-
-echo "<script type=\"text/javascript\">
- javascript:makeRequest(\"$url\",\"$get\");
-</script>";
-?>
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; @@ -164,6 +171,42 @@ class AmpacheMpd { /** + * 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 * The songs that MPD currently has in it's playlist. This must be @@ -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 @@ <?php -header('Content-Type: text/xml'); -header('Cache-control: no-cache'); -header('Pragma: no-cache'); -echo '<?xml version="1.0" encoding="UTF-8"?>'; - -$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 . '<error>'.$myMpd->errStr.'</error>'; } } -function volume() { global $result, $myMpd; - if ($GLOBALS['player'] == 'mpd') - { $result = $result . '<volume>'. $myMpd->volume. '</volume>'; } } -function state() { global $result, $myMpd; - if ($GLOBALS['player'] == 'mpd') - { $result = $result. '<state>'. $myMpd->state. '</state>'; } } - -function mpd_cur_track_pos () { - global $result, $myMpd; - if ($GLOBALS['player'] == 'mpd') { - $result = $result . '<mpd_cur_track_pos>'.$myMpd->current_track_position.'</mpd_cur_track_pos>'; - } -} - -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.'<now_playing>'. - '<songid>'.$myMpd->current_track_id.'</songid>'. - '<songtitle>'.htmlspecialchars($myMpd->playlist[$myMpd->current_track_id]['Title']).'</songtitle>'. - '<songartist>'.htmlspecialchars($myMpd->playlist[$myMpd->current_track_id]['Artist']).'</songartist>'. - '<songalbum>'.htmlspecialchars($myMpd->playlist[$myMpd->current_track_id]['Album']).'</songalbum>'. - '<songlength>'.htmlspecialchars($myMpd->playlist[($myMpd->current_track_id)]['Time']).'</songlength>'. - '</now_playing>'; - } //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.'<now_playing_display>'; - - if (count($results)) { - - foreach($results as $item) { - - $song = $item['song']; - $np_user = $item['user']; - - if (is_object($song)) { - - $result = $result.'<song>'; - - if (!$np_user->fullname) { $np_user->fullname = "Unknown User"; } - - if (conf('use_auth')) { - $result = $result.'<fullname>'.$np_user->fullname.'</fullname>'; - } else { - $result = $result.'<fullname></fullname>'; - } - - $result = $result.'<songid>'.$song->id.'</songid>'; - $result = $result.'<albumid>'.$song->album.'</albumid>'; - $result = $result.'<artistid>'.$song->artist.'</artistid>'; - $result = $result.'<songtitle>'.htmlspecialchars($song->f_title).'</songtitle>'; - $result = $result.'<songartist>'.htmlspecialchars($song->f_artist).'</songartist>'; - $result = $result.'<songalbum>'.htmlspecialchars($song->f_album).'</songalbum>'; - - $result = $result.'</song>'; - - } // if it's a song - } // foreach song - - } // if now playing - $result = $result.'</now_playing_display>'; - -} + 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 '<error>Inadequate access privileges!</error>'; return; }*/ - -switch ($action) { -case 'getvol' : - $result = '<volume>'. $myMpd->volume. '</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 = '<error>'.$myMpd->errStr.'</error>'; - $result = $result.'<volume>'. $myMpd->volume. '</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') { ?> + <span style="text-decoration:underline;cursor:pointer;" onclick="ajaxPut('<?php echo $ajax_url; ?>','action=change_play_type&type=<?php echo $_SESSION['data']['old_play_type'] . $required_info; ?>','play_type');return true;"> + <?php echo ucfirst($_SESSION['data']['old_play_type']) . ' ' . _('Mode'); ?> + </span> + <?php } else { ?> + <span style="text-decoration:underline;cursor:pointer;" onclick="ajaxPut('<?php echo $ajax_url; ?>','action=change_play_type&type=localplay<?php echo $required_info; ?>','play_type');return true;"> + <?php echo _('Localplay Mode'); ?> + </span> + <?php } break; -case 'adjvol' : - if ( is_null($myMpd->AdjustVolume($_GET['param1'])) ) $result = '<error>'.$myMpd->errStr.'</error>'; - volume(); - break; - case ' > ': - case "play": - if ( is_null($myMpd->Play()) ) $result = '<error>'.$myMpd->errStr.'</error>\n'; - mpd_cur_track_pos(); - state(); - now_playing(); - break; - case "stop": - case ' X ': - if ( is_null($myMpd->Stop()) ) $result = '<error>'.$myMpd->errStr.'</error>\n'; - $result = $result.'<state>'. $myMpd->state. '</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 '<properties>' . - '<action>' . $action .$player.'</action>' . - $result . -'</properties>'; + default: + echo "Default Action"; + break; +} // end switch action ?> @@ -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 @@ */ ?> +<!-- I really hate IE --> +</td></tr></table> </div> <!-- end id="content"--> </div> <!-- end id="maincontainer"--> </body> 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')) { ?> </head> <body> <script src="<?php echo $web_path; ?>/lib/general.js" language="javascript" type="text/javascript"></script> +<script src="<?php echo $web_path; ?>/modules/kajax/ajax.js" language="javascript" type="text/javascript"></script> <div id="maincontainer"> <div id="topbar"><!-- This is the topbar row --> <div id="topbarleft"> @@ -58,5 +59,10 @@ if (conf('use_rss')) { ?> </div><!-- End topbar --> <div id="sidebar"><!-- This is the sidebar --> <?php require_once(conf('prefix') . '/templates/sidebar.inc.php'); ?> + <?php if ($localplay = init_localplay()) { ?> + <?php require_once(conf('prefix') . '/templates/show_localplay_control.inc.php'); ?> + <?php } ?> </div><!-- End sidebar --> <div id="content"> +<!-- I hate IE... --> +<table><tr><td> 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 @@ +<?php +/* + + Copyright (c) 2001 - 2006 Ampache.org + All rights reserved. + + 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. + + 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. + +*/ + +$web_path = conf('web_path'); +$data = $localplay->status(); + +$required_info = "&user_id=" . $GLOBALS['user']->id . "&sessid=" . session_id(); +$ajax_url = $web_path . '/server/ajax.server.php'; + +?> +<?php if ($localplay->has_function('prev')) { ?> +<span id="prev_button" onclick="ajaxPut('<?php echo $ajax_url; ?>','action=localplay&cmd=prev<?php echo $required_info; ?>','localplay_state');return true;"> + <img src="<?php echo $web_path; ?>/images/localplay/prev.gif"> +</span> +<?php } ?> +<span id="stop_button" onclick="ajaxPut('<?php echo $ajax_url; ?>','action=localplay&cmd=stop<?php echo $required_info; ?>','localplay_state');return true;"> + <img src="<?php echo $web_path; ?>/images/localplay/stop.gif"> +</span> +<?php if ($localplay->has_function('pause')) { ?> +<span id="pause_button" onclick="ajaxPut('<?php echo $ajax_url; ?>','action=localplay&cmd=pause<?php echo $requird_info; ?>','localplay_state');return true;"> + <img src="<?Php echo $web_path; ?>/images/localplay/pause.gif"> +</span> +<?php } ?> +<span id="play_button" onclick="ajaxPut('<?php echo $ajax_url; ?>','action=localplay&cmd=play<?php echo $required_info; ?>','localplay_state');return true;"> + <img src="<?php echo $web_path; ?>/images/localplay/play.gif"> +</span> +<?php if ($localplay->has_function('next')) { ?> +<span id="next_button" onclick="ajaxPut('<?php echo $ajax_url; ?>','action=localplay&cmd=next<?php echo $required_info; ?>','localplay_state');return true;"> + <img src="<?php echo $web_path; ?>/images/localplay/next.gif"> +</span> +<?php } ?> +<br /> +Current State:<span id="localplay_state"><?php echo $data['state']; ?></span><br /> +<span id="play_type"> +<?php if (conf('play_type') == 'localplay' AND strlen($_SESSION['data']['old_play_type'])) { ?> +<span style="text-decoration:underline;cursor:pointer;" onclick="ajaxPut('<?php echo $ajax_url; ?>','action=change_play_type&type=<?php echo $_SESSION['data']['old_play_type'] . $required_info; ?>','play_type');return true;"> + <?php echo ucfirst($_SESSION['data']['old_play_type']) . ' ' . _('Mode'); ?> +</span> +<?php } else { ?> +<span style="text-decoration:underline;cursor:pointer;" onclick="ajaxPut('<?php echo $ajax_url; ?>','action=change_play_type&type=localplay<?php echo $required_info; ?>','play_type');return true;"> + <?php echo _('Localplay Mode'); ?> +</span> +<?php } ?> +</span><br /> 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 @@ +<?php +/* + + Copyright (c) 2001 - 2006 Ampache.org + All rights reserved. + + 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. + + 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. + +*/ + +/** + * for now we only have the localplay modules so this is going to be centered on them + * however the idea would be as module support is added more and more are put on this + * same page + */ + +/* Get Localplay Modules */ +$localplay_modules = get_localplay_controllers(); +$web_path = conf('web_path'); +?> +<table class="text-box"> +<tr class="table-header"> + <th><?php echo _('Module Name'); ?></th> + <th><?php echo _('Action'); ?></th> +</tr> +<?php +foreach ($localplay_modules as $module) { + $action = _('Active'); + if (!verify_localplay_preferences($module)) { + $action = "<a href=\"" . $web_path . "/admin/modules.php?action=insert_localplay_preferences&type=" . $module . "\">" . + _('Activate') . "</a>"; + } +?> +<tr> + <td><?php echo scrub_out($module); ?></td> + <td><?php echo $action; ?></td> +</tr> +<?php } if (!count($localplay_modules)) { ?> +<tr> + <td colspan="2"><span class="error"><?php echo _('No Records Found'); ?></span></td> +</tr> +<?php } ?> +</table> 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')) { <th colspan="3" class="header2" align="left"><?php echo $preferences['title']; ?></th> </tr> <tr class="table-header"> - <th><?php echo _("Preference"); ?></th> - <th><?php echo _("Value"); ?></th> + <th><?php echo _('Preference'); ?></th> + <th><?php echo _('Value'); ?></th> <?php if ($show_apply_to_all) { ?> - <th><?php echo _("Apply to All"); ?></th> + <th><?php echo _('Apply to All'); ?></th> <?php } ?> </tr> <?php diff --git a/templates/show_preferences.inc b/templates/show_preferences.inc index 9a96248a..701cb488 100644 --- a/templates/show_preferences.inc +++ b/templates/show_preferences.inc @@ -48,7 +48,7 @@ if (($GLOBALS['user']->has_access(100)) AND ($user_id == '-1' AND conf('use_auth } ?> <span class="header1"> -<?php echo _("Editing"); ?> <?php echo $fullname; ?> <?php echo _("preferences"); ?> +<?php echo _("Editing"); ?> <?php echo $fullname; ?> <?php echo _('preferences'); ?> <?php if ($GLOBALS['user']->has_access(100)) { ?> [<a href="<?php echo conf('web_path'); ?>/admin/preferences.php?action=fix_preferences&user_id=<?php echo $user_id; ?>"><?php echo _("Rebuild Preferences"); ?></a>] <?php } ?> @@ -79,7 +79,7 @@ if (($GLOBALS['user']->has_access(100)) AND ($user_id == '-1' AND conf('use_auth <?php } ?> </ul> </div> -<div class="text-box" style="width:35em;"> +<div class="text-box" style="width:45em;"> <form method="post" name="preferences" action="<?php echo conf('web_path'); ?><?php echo $target; ?>" enctype="multipart/form-data"> <?php if ($current_tab != 'account') { diff --git a/templates/sidebar.inc.php b/templates/sidebar.inc.php index e3117e4a..4d17dd31 100644 --- a/templates/sidebar.inc.php +++ b/templates/sidebar.inc.php @@ -26,11 +26,12 @@ * that have ['title'] ['url'] and ['active'] url assumes no conf('web_path') */ -$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'=>_('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'); </li> <?php if ($GLOBALS['user']->has_access(100)) { ?> <li<?php - if ($location['page'] == "admin/index.php" || - $location['page'] == "admin/users.php" || - $location['page'] == "admin/mail.php" || - $location['page'] == "admin/catalog.php" || - $location['page'] == "admin/preferences.php" || - $location['page'] == "admin/access.php" ){ + if ($location['page'] == 'admin/index.php' || + $location['page'] == 'admin/users.php' || + $location['page'] == 'admin/mail.php' || + $location['page'] == 'admin/catalog.php' || + $location['page'] == 'admin/preferences.php' || + $location['page'] == 'admin/modules.php' || + $location['page'] == 'admin/access.php' ){ echo " id=\"activetopmenu\" "; }?>> <a href="<?php echo $web_path; ?>/admin/index.php"><?php echo _("Admin"); ?></a> @@ -1,6 +1,9 @@ <?php /* + Copyright 2001 - 2006 Ampache.org + All Rights Reserved + 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 |