diff --git a/batch.php b/batch.php index 97485805..25b15287 100644 --- a/batch.php +++ b/batch.php @@ -39,18 +39,19 @@ $default_name = "Unknown.zip"; $name = $default_name; if (Core::is_playable_item($_REQUEST['action'])) { - $id = $_REQUEST['id']; - if (!is_array($id)) { - $id = array($id); - } - $media_ids = array(); - foreach ($id as $i) { - $libitem = new $_REQUEST['action']($i); - if ($libitem->id) { - $name = $libitem->get_fullname(); - $media_ids = array_merge($media_ids, $libitem->get_medias()); - } - } + $id = $_REQUEST['id']; + if (!is_array($id)) { + $id = array($id); + } + $media_ids = array(); + foreach ($id as $i) { + $libitem = new $_REQUEST['action']($i); + if ($libitem->id) { + $libitem->format(); + $name = $libitem->get_fullname(); + $media_ids = array_merge($media_ids, $libitem->get_medias()); + } + } } else { switch ($_REQUEST['action']) { case 'tmp_playlist': diff --git a/lib/class/album.class.php b/lib/class/album.class.php index f13f3f3d..62693817 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -468,7 +468,7 @@ class Album extends database_object implements library_item $keywords = array(); $keywords['artist'] = array('important' => true, 'label' => T_('Artist'), - 'value' => (($album->artist_count < 2) ? $this->f_artist_name : '')); + 'value' => (($this->artist_count < 2) ? $this->f_artist_name : '')); $keywords['album'] = array('important' => true, 'label' => T_('Album'), 'value' => $this->f_name); @@ -483,8 +483,8 @@ class Album extends database_object implements library_item public function get_parent() { - if ($album->artist_count == 1) { - return array('object_type' => 'artist', 'object_id' => $album->artist_id); + if ($this->artist_count == 1) { + return array('object_type' => 'artist', 'object_id' => $this->artist_id); } return null; diff --git a/lib/class/api.class.php b/lib/class/api.class.php index 87536163..5752b43b 100644 --- a/lib/class/api.class.php +++ b/lib/class/api.class.php @@ -429,12 +429,13 @@ class Api public static function tag_artists($input) { $artists = Tag::get_tag_objects('artist',$input['filter']); + if ($artists) { + XML_Data::set_offset($input['offset']); + XML_Data::set_limit($input['limit']); - XML_Data::set_offset($input['offset']); - XML_Data::set_limit($input['limit']); - - ob_end_clean(); - echo XML_Data::artists($artists); + ob_end_clean(); + echo XML_Data::artists($artists); + } } // tag_artists @@ -445,12 +446,13 @@ class Api public static function tag_albums($input) { $albums = Tag::get_tag_objects('album',$input['filter']); + if ($albums) { + XML_Data::set_offset($input['offset']); + XML_Data::set_limit($input['limit']); - XML_Data::set_offset($input['offset']); - XML_Data::set_limit($input['limit']); - - ob_end_clean(); - echo XML_Data::albums($albums); + ob_end_clean(); + echo XML_Data::albums($albums); + } } // tag_albums diff --git a/lib/class/art.class.php b/lib/class/art.class.php index 0acbd6bb..f4e043f7 100644 --- a/lib/class/art.class.php +++ b/lib/class/art.class.php @@ -451,10 +451,6 @@ class Art extends database_object // If it came from the database if (isset($data['db'])) { - // Repull it - $uid = Dba::escape($data['db']); - $type = Dba::escape($type); - $sql = "SELECT * FROM `image` WHERE `object_type` = ? AND `object_id` =? AND `size`='original'"; $db_results = Dba::read($sql, array($type, $data['db'])); $row = Dba::fetch_assoc($db_results); @@ -586,7 +582,7 @@ class Art extends database_object * gather * This tries to get the art in question */ - public function gather($options = array(), $limit = false, $gather_parent = false) + public function gather($options = array(), $limit = 0) { // Define vars $results = array(); @@ -1151,6 +1147,8 @@ class Art extends database_object public static function get_thumb_size($thumb) { + $size = array(); + switch ($thumb) { case '1': /* This is used by the now_playing / browse stuff */ diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index 3e35e7a1..a919cd40 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -266,7 +266,7 @@ class Artist extends database_object implements library_item * _get_extra info * This returns the extra information for the artist, this means totals etc */ - private function _get_extra_info($catalog=FALSE) + private function _get_extra_info($catalog=0) { // Try to find it in the cache and save ourselves the trouble if (parent::is_cached('artist_extra',$this->id) ) { @@ -367,6 +367,7 @@ class Artist extends database_object implements library_item public function get_childrens() { + $medias = array(); $albums = $this->get_albums(); foreach ($albums as $album_id) { $medias[] = array( @@ -374,7 +375,7 @@ class Artist extends database_object implements library_item 'object_id' => $album_id ); } - return array('album' => $this->get_albums()); + return array('album' => $medias); } public function get_medias($filter_type = null) diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index da90f835..62b03a5b 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -163,7 +163,7 @@ class Browse extends Query break; case 'artist': $box_title = T_('Artists') . $match; - Artist::build_cache($object_ids, 'extra'); + Artist::build_cache($object_ids, true); $box_req = AmpConfig::get('prefix') . '/templates/show_artists.inc.php'; break; case 'live_stream': diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 02d755db..7e5340f9 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -369,10 +369,12 @@ abstract class Catalog extends database_object return $results; } - public static function getLastUpdate() + public static function getLastUpdate($catalogs = null) { $last_update = 0; - $catalogs = self::get_catalogs(); + if ($catalogs == null || !is_array($catalogs)) { + $catalogs = self::get_catalogs(); + } foreach ($catalogs as $id) { $catalog = Catalog::create_from_id($id); if ($catalog->last_add > $last_update) { @@ -636,7 +638,7 @@ abstract class Catalog extends database_object if (!empty($type)) { $sql .= "JOIN `" . $type . "` ON `" . $type . "`.`id` = `video`.`id` "; } - if ($catalogs) { + if ($catalog_id) { $sql .= "WHERE `video`.`catalog` = `" . intval($catalog_id) . "`"; } $db_results = Dba::read($sql); @@ -680,7 +682,7 @@ abstract class Catalog extends database_object $results = array(); foreach ($catalogs as $catalog_id) { $catalog = Catalog::create_from_id($catalog_id); - $tvshow_ids = $catalog->get_tvshow_ids($type); + $tvshow_ids = $catalog->get_tvshow_ids(); foreach ($tvshow_ids as $tvshow_id) { $results[] = new TVShow($tvshow_id); } @@ -870,6 +872,13 @@ abstract class Catalog extends database_object if ($type == 'video' && AmpConfig::get('generate_video_preview')) { Video::generate_preview($id); } + + // Stupid little cutesie thing + $search_count++; + if (UI::check_ticker()) { + UI::update_text('count_art_' . $this->id, $search_count); + UI::update_text('read_art_' . $this->id, $libitem->get_fullname()); + } } /** @@ -921,13 +930,6 @@ abstract class Catalog extends database_object foreach ($searches as $key => $values) { foreach ($values as $id) { $this->gather_art_item($key, $id); - - // Stupid little cutesie thing - $search_count++; - if (UI::check_ticker()) { - UI::update_text('count_art_' . $this->id, $search_count); - UI::update_text('read_art_' . $this->id, scrub_out($album->name)); - } } } @@ -1648,7 +1650,7 @@ abstract class Catalog extends database_object $xml['dict']['Play Count'] = intval($song->played); $xml['dict']['Track Type'] = "URL"; $xml['dict']['Location'] = Song::play_url($song->id); - echo xoutput_from_array($xml, 1, 'itunes'); + echo xoutput_from_array($xml, true, 'itunes'); // flush output buffer } // while result echo xml_get_footer('itunes'); diff --git a/lib/class/channel.class.php b/lib/class/channel.class.php index 604f60d8..11b24bbc 100644 --- a/lib/class/channel.class.php +++ b/lib/class/channel.class.php @@ -100,10 +100,12 @@ class Channel extends database_object implements media, library_item { $tags = Tag::get_object_tags('channel', $this->id); $genre = ""; - foreach ($tags as $tag) { - $genre .= $tag['name'] . ' '; + if ($tags) { + foreach ($tags as $tag) { + $genre .= $tag['name'] . ' '; + } + $genre = trim($genre); } - $genre = trim($genre); return $genre; } @@ -447,4 +449,14 @@ class Channel extends database_object implements media, library_item // Do nothing } + public function get_transcode_settings($array, $callback = false, $type = '') + { + return false; + } + + public static function gc() + { + + } + } // end of channel class diff --git a/lib/class/error.class.php b/lib/class/error.class.php index d2ed8113..8e749e4e 100644 --- a/lib/class/error.class.php +++ b/lib/class/error.class.php @@ -64,18 +64,18 @@ class Error // Make sure its set first if (!isset(Error::$errors[$name])) { Error::$errors[$name] = $message; - Error::$state = 1; + Error::$state = true; $_SESSION['errors'][$name] = $message; } // They want us to clobber it elseif ($clobber) { - Error::$state = 1; + Error::$state = true; Error::$errors[$name] = $message; $_SESSION['errors'][$name] = $message; } // They want us to append the error, add a BR\n and then the message else { - Error::$state = 1; + Error::$state = true; Error::$errors[$name] .= "
\n" . $message; $_SESSION['errors'][$name] .= "
\n" . $message; } diff --git a/lib/class/preference.class.php b/lib/class/preference.class.php index 74d0a9e7..674ab05a 100644 --- a/lib/class/preference.class.php +++ b/lib/class/preference.class.php @@ -69,7 +69,7 @@ class Preference extends database_object * update * This updates a single preference from the given name or id */ - public static function update($preference,$user_id,$value,$applytoall='',$applytodefault='') + public static function update($preference,$user_id,$value,$applytoall=false,$applytodefault=false) { // First prepare if (!is_numeric($preference)) { diff --git a/lib/class/query.class.php b/lib/class/query.class.php index ccee071a..afc9408c 100644 --- a/lib/class/query.class.php +++ b/lib/class/query.class.php @@ -1015,7 +1015,7 @@ class Query */ private function get_select() { - $select_string = implode($this->_state['select'], ", "); + $select_string = implode(", ", $this->_state['select']); return $select_string; } // get_select diff --git a/lib/class/scrobbler_async.class.php b/lib/class/scrobbler_async.class.php index 15e7d5f6..859a2f4c 100644 --- a/lib/class/scrobbler_async.class.php +++ b/lib/class/scrobbler_async.class.php @@ -33,7 +33,7 @@ class scrobbler_async extends Thread spl_autoload_register(array('Core', 'autoload'), true, true); Requests::register_autoloader(); if ($this->song_info) { - User::save_songplay($this->user, $this->song_info); + User::save_mediaplay($this->user, $this->song_info); } } } diff --git a/lib/class/session.class.php b/lib/class/session.class.php index c8955ad1..401bd429 100644 --- a/lib/class/session.class.php +++ b/lib/class/session.class.php @@ -374,7 +374,7 @@ class Session // Set up the cookie prefs before we throw down, this is very important $cookie_life = AmpConfig::get('cookie_life'); $cookie_path = AmpConfig::get('cookie_path'); - $cookie_domain = false; + $cookie_domain = null; $cookie_secure = AmpConfig::get('cookie_secure'); session_set_cookie_params($cookie_life, $cookie_path, $cookie_domain, $cookie_secure); diff --git a/lib/class/song_preview.class.php b/lib/class/song_preview.class.php index 62e44580..05721b95 100644 --- a/lib/class/song_preview.class.php +++ b/lib/class/song_preview.class.php @@ -222,7 +222,7 @@ class Song_Preview extends database_object implements media, playable_item public function get_fullname() { - return $this->f_name; + return $this->f_title; } public function get_parent() diff --git a/lib/class/tag.class.php b/lib/class/tag.class.php index 6305cecd..92192b58 100644 --- a/lib/class/tag.class.php +++ b/lib/class/tag.class.php @@ -194,7 +194,7 @@ class Tag extends database_object implements library_item if ($data['select_tags']) { $merge_to = Tag::construct_from_name($data['select_tags']); if ($merge_to->id) { - $tag->merge($merge_to->id, ($data['merge_persist'] == '1')); + $this->merge($merge_to->id, ($data['merge_persist'] == '1')); } } @@ -241,9 +241,12 @@ class Tag extends database_object implements library_item $db_results = Dba::read($sql, array($this->id)); + $results = array(); while ($row = Dba::fetch_assoc($db_results)) { $results[$row['id']] = array('id'=>$row['id'], 'name'=>$row['name']); } + + return $results; } /** @@ -654,11 +657,13 @@ class Tag extends database_object implements library_item $medias = array(); if ($filter_type) { $ids = Tag::get_tag_objects($filter_type, $this->id); - foreach ($ids as $id) { - $medias[] = array( - 'object_type' => $filter_type, - 'object_id' => $id - ); + if ($ids) { + foreach ($ids as $id) { + $medias[] = array( + 'object_type' => $filter_type, + 'object_id' => $id + ); + } } } return $medias; diff --git a/lib/class/tvshow.class.php b/lib/class/tvshow.class.php index 0eb2b1ea..10b62f1b 100644 --- a/lib/class/tvshow.class.php +++ b/lib/class/tvshow.class.php @@ -177,7 +177,7 @@ class TVShow extends database_object implements library_item $this->link = AmpConfig::get('web_path') . '/tvshows.php?action=show&tvshow=' . $this->id; $this->f_link = '' . $this->f_name . ''; - $this->_get_extra_info($this->catalog_id); + $this->_get_extra_info(); $this->tags = Tag::get_top_tags('tvshow', $this->id); $this->f_tags = Tag::get_display($this->tags, true, 'tvshow'); @@ -343,10 +343,9 @@ class TVShow extends database_object implements library_item Tag::update_tag_list($tags_comma, 'tvshow', $current_id); if ($override_childs) { - $seasons = $this->get_albums(null, true); - foreach ($seasons as $season_id) { - $season = new TVShow_Season($season_id); - $season->update_tags($tags_comma, $override_childs); + $episodes = $this->get_episodes(); + foreach ($episodes as $ep_id) { + Tag::update_tag_list($data['edit_tags'], 'episode', $ep_id); } } } diff --git a/lib/class/tvshow_episode.class.php b/lib/class/tvshow_episode.class.php index b67996a7..4c2f5d8d 100644 --- a/lib/class/tvshow_episode.class.php +++ b/lib/class/tvshow_episode.class.php @@ -125,6 +125,8 @@ class TVShow_Episode extends Video $sql = "UPDATE `tvshow_episode` SET `original_name` = ?, `season` = ?, `episode_number` = ?, `summary` = ? WHERE `id` = ?"; Dba::write($sql, array($data['original_name'], $data['tvshow_season'], $data['tvshow_episode'], $data['summary'], $this->id)); + Tag::update_tag_list($data['edit_tags'], 'episode', $this->id); + return $this->id; } diff --git a/lib/class/tvshow_season.class.php b/lib/class/tvshow_season.class.php index f145e932..c850171b 100644 --- a/lib/class/tvshow_season.class.php +++ b/lib/class/tvshow_season.class.php @@ -138,7 +138,7 @@ class TVShow_Season extends database_object implements library_item $this->link = AmpConfig::get('web_path') . '/tvshow_seasons.php?action=show&season=' . $this->id; $this->f_link = '' . $this->f_name . ''; - $this->_get_extra_info($this->catalog_id); + $this->_get_extra_info(); return true; } diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 08784421..c66803f7 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -1867,7 +1867,7 @@ class Update $sql = "INSERT INTO `user_preference` VALUES (-1,?,'0')"; $retval = Dba::write($sql, array($id)) ? $retval : false; - return true; + return $retval; } /** @@ -1908,7 +1908,7 @@ class Update $sql = "INSERT INTO `user_preference` VALUES (-1,?,'1')"; $retval = Dba::write($sql, array($id)) ? $retval : false; - return true; + return $retval; } /** @@ -2158,7 +2158,7 @@ class Update $sql = "DELETE FROM `preference` WHERE `name` = 'tags_userlist'"; $retval = Dba::write($sql) ? $retval : false; - return true; + return $retval; } /** @@ -2550,7 +2550,7 @@ class Update $sql = "INSERT INTO `user_preference` VALUES (-1,?,'0')"; $retval = Dba::write($sql, array($id)) ? $retval : false; - return true; + return $retval; } /** diff --git a/lib/class/upnp_api.class.php b/lib/class/upnp_api.class.php index 3d6ca3d8..ff1196b2 100644 --- a/lib/class/upnp_api.class.php +++ b/lib/class/upnp_api.class.php @@ -95,6 +95,7 @@ class Upnp_Api public static function parseUPnPRequest($prmRequest) { + $retArr = array(); $reader = new XMLReader(); $reader->XML($prmRequest); while ($reader->read()) { @@ -559,8 +560,6 @@ class Upnp_Api break; default: - $counts = Catalog::count_medias(); - $mediaItems[] = self::_musicMetadata('artists'); $mediaItems[] = self::_musicMetadata('albums'); $mediaItems[] = self::_musicMetadata('songs'); diff --git a/lib/class/vainfo.class.php b/lib/class/vainfo.class.php index 3c382d2a..56f5ce30 100644 --- a/lib/class/vainfo.class.php +++ b/lib/class/vainfo.class.php @@ -39,7 +39,7 @@ class vainfo public $gather_types = array(); protected $_raw = array(); - protected $_getID3 = ''; + protected $_getID3 = null; protected $_forcedSize = 0; protected $_file_encoding = ''; @@ -169,7 +169,7 @@ class vainfo } if ($encoding != 'ASCII' && $encoding != '0') { - return $encoding; + return (string) $encoding; } else { return 'ISO-8859-1'; } @@ -897,10 +897,12 @@ class vainfo } else { // Or we assume each parent folder contains one missing information if (preg_match('/[\/\\\\]([^\/\\\\]*)[\/\\\\]Season (\d{1,2})[\/\\\\]((E|Ep|Episode)\s?(\d{1,2})[\/\\\\])?/i', $filename, $matches)) { - $results['tvshow'] = $this->fixSerieName($matches[1]); - $results['tvshow_season'] = $matches[2]; - if (isset($matches[5])) { - $results['tvshow_episode'] = $matches[5]; + if ($matches != null) { + $results['tvshow'] = $this->fixSerieName($matches[1]); + $results['tvshow_season'] = $matches[2]; + if (isset($matches[5])) { + $results['tvshow_episode'] = $matches[5]; + } } } } diff --git a/lib/class/xml_data.class.php b/lib/class/xml_data.class.php index 846f6e20..c96e77f3 100644 --- a/lib/class/xml_data.class.php +++ b/lib/class/xml_data.class.php @@ -31,8 +31,8 @@ class XML_Data { // This is added so that we don't pop any webservers - private static $limit = '5000'; - private static $offset = '0'; + private static $limit = 5000; + private static $offset = 0; private static $type = ''; /** diff --git a/lib/init.php b/lib/init.php index 9cb25ab9..caf3f3a2 100644 --- a/lib/init.php +++ b/lib/init.php @@ -189,7 +189,7 @@ if (!defined('NO_SESSION') && AmpConfig::get('use_auth')) { $GLOBALS['user'] = User::get_from_username($_SESSION['userdata']['username']); } else { $GLOBALS['user'] = new User($auth['username']); - $GLOBALS['user']->id = '-1'; + $GLOBALS['user']->id = -1; $GLOBALS['user']->username = $auth['username']; $GLOBALS['user']->fullname = $auth['fullname']; $GLOBALS['user']->access = $auth['access']; diff --git a/lib/ui.lib.php b/lib/ui.lib.php index dddf2f5b..961a4f13 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -185,7 +185,7 @@ function show_preference_box($preferences) * This displays a select of every album that we've got in Ampache (which can be * hella long). It's used by the Edit page and takes a $name and a $album_id */ -function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0) +function show_album_select($name='album',$album_id=0,$allow_add=false,$song_id=0) { static $album_id_cnt = 0; @@ -527,7 +527,7 @@ function xml_from_array($array, $callback = false, $type = '') case 'itunes': foreach ($array as $key=>$value) { if (is_array($value)) { - $value = xoutput_from_array($value,1,$type); + $value = xoutput_from_array($value, true, $type); $string .= "\t\t<$key>\n$value\t\t\n"; } else { if ($key == "key") { @@ -548,7 +548,7 @@ function xml_from_array($array, $callback = false, $type = '') case 'xspf': foreach ($array as $key=>$value) { if (is_array($value)) { - $value = xoutput_from_array($value,1,$type); + $value = xoutput_from_array($value, true, $type); $string .= "\t\t<$key>\n$value\t\t\n"; } else { if ($key == "key") { diff --git a/play/index.php b/play/index.php index 484ced00..e7555e6d 100644 --- a/play/index.php +++ b/play/index.php @@ -44,7 +44,7 @@ if (AmpConfig::get('transcode_player_customize')) { $transcode_to = null; $bitrate = 0; } -$share_id = scrub_in($_REQUEST['share_id']); +$share_id = intval($_REQUEST['share_id']); if (!$type) { $type = 'song'; @@ -82,7 +82,7 @@ if (empty($uid)) { } } -if (empty($share_id)) { +if (!$share_id) { $GLOBALS['user'] = new User($uid); Preference::init(); @@ -446,7 +446,7 @@ if ($range_values > 0 && ($start > 0 || $end > 0)) { if ($start > 0) { debug_event('play', 'Content-Range doesn\'t start from 0, stats should already be registered previously; not collecting stats', 5); } else { - if (empty($share_id)) { + if (!$share_id) { if ($_SERVER['REQUEST_METHOD'] != 'HEAD') { debug_event('play', 'Registering stats for {'.$media->get_stream_name() .'}...', '5'); $sessionkey = Stream::$session; diff --git a/playlist.php b/playlist.php index 16db955a..3280dec2 100644 --- a/playlist.php +++ b/playlist.php @@ -122,7 +122,7 @@ switch ($_REQUEST['action']) { break; } - $playlist->add_songs(array($_REQUEST['song_id']), 'ORDERED'); + $playlist->add_songs(array($_REQUEST['song_id']), true); break; case 'prune_empty': if (!$GLOBALS['user']->has_access(100)) { diff --git a/server/index.ajax.php b/server/index.ajax.php index a19d5475..fff6e3fa 100644 --- a/server/index.ajax.php +++ b/server/index.ajax.php @@ -38,7 +38,7 @@ switch ($_REQUEST['action']) { } break; case 'random_videos': - $videos = Video::get_random(6, true); + $videos = Video::get_random(6); if (count($videos) AND is_array($videos)) { ob_start(); require_once AmpConfig::get('prefix') . '/templates/show_random_videos.inc.php'; diff --git a/server/playlist.ajax.php b/server/playlist.ajax.php index 42fa51ff..1df17fb2 100644 --- a/server/playlist.ajax.php +++ b/server/playlist.ajax.php @@ -120,7 +120,7 @@ switch ($_REQUEST['action']) { if (count($songs) > 0) { Ajax::set_include_override(true); - $playlist->add_songs($songs, 'ORDERED'); + $playlist->add_songs($songs, true); /*$playlist->format(); $object_ids = $playlist->get_items(); diff --git a/upnp/control-reply.php b/upnp/control-reply.php index 5b796a8f..c98dcf83 100644 --- a/upnp/control-reply.php +++ b/upnp/control-reply.php @@ -25,6 +25,8 @@ $rootMediaItems[] = Upnp_Api::_videoMetadata(''); exit; } + $items = array(); + $responseType = "u:Error"; switch ($upnpRequest['action']) { case 'search': $responseType = 'u:SearchResponse';