From b16958f44efadd9e44e89565fe01cfb89d00a5bc Mon Sep 17 00:00:00 2001 From: Afterster Date: Sun, 25 May 2014 22:54:04 +0200 Subject: [PATCH] Remove old code and fix old php errors --- admin/catalog.php | 1 - admin/export.php | 2 - admin/system.php | 1 - admin/users.php | 2 +- albums.php | 2 +- artists.php | 53 -------- batch.php | 6 +- broadcast.php | 6 +- channel.php | 12 +- channel/index.php | 6 + lib/class/access.class.php | 31 +---- lib/class/album.class.php | 12 +- lib/class/ampconfig.class.php | 1 - lib/class/art.class.php | 63 ++++----- lib/class/artist.class.php | 4 +- lib/class/auth.class.php | 1 + lib/class/broadcast.class.php | 2 +- lib/class/browse.class.php | 4 +- lib/class/catalog.class.php | 28 ++-- lib/class/channel.class.php | 7 +- lib/class/core.class.php | 2 +- lib/class/dba.class.php | 13 +- lib/class/democratic.class.php | 24 ++-- lib/class/localplay.class.php | 10 +- lib/class/localplay_controller.abstract.php | 16 ++- lib/class/mailer.class.php | 11 +- lib/class/openid.class.php | 5 +- lib/class/playlist.class.php | 33 ++--- lib/class/playlist_object.abstract.php | 6 +- lib/class/plex_api.class.php | 4 +- lib/class/plex_xml_data.class.php | 37 ++---- lib/class/plugin.class.php | 4 +- lib/class/preference.class.php | 20 +-- lib/class/query.class.php | 21 +-- lib/class/radio.class.php | 8 +- lib/class/random.class.php | 13 +- lib/class/rating.class.php | 4 +- lib/class/recommendation.class.php | 4 +- lib/class/search.class.php | 30 +++-- lib/class/session.class.php | 29 +---- lib/class/share.class.php | 24 +++- lib/class/shoutbox.class.php | 13 +- lib/class/song.class.php | 52 ++++---- lib/class/song_preview.class.php | 13 ++ lib/class/stats.class.php | 13 +- lib/class/stream.class.php | 14 +- lib/class/stream_playlist.class.php | 3 + lib/class/subsonic_api.class.php | 7 + lib/class/subsonic_xml_data.class.php | 4 +- lib/class/tag.class.php | 69 +++++----- lib/class/tmp_playlist.class.php | 27 ++-- lib/class/ui.class.php | 6 +- lib/class/update.class.php | 26 ++-- lib/class/user.class.php | 137 ++++++++------------ lib/class/userflag.class.php | 6 +- lib/class/vainfo.class.php | 35 ++--- lib/class/video.class.php | 14 ++ lib/class/wanted.class.php | 12 +- lib/class/waveform.class.php | 8 +- lib/class/webplayer.class.php | 5 +- lib/class/xml_data.class.php | 13 +- lib/general.lib.php | 1 + lib/init.php | 2 + lib/install.lib.php | 13 +- lib/login.php | 9 +- lib/preferences.php | 9 +- lib/rating.lib.php | 7 - lib/themes.php | 2 +- lib/ui.lib.php | 20 +-- locale/fr_FR/LC_MESSAGES/messages.mo | Bin 63417 -> 63407 bytes locale/fr_FR/LC_MESSAGES/messages.po | 4 +- localplay.php | 2 +- play/index.php | 17 ++- playlist.php | 18 --- preferences.php | 5 + random.php | 6 +- register.php | 2 +- search.php | 4 +- server/ajax.server.php | 35 ++--- server/browse.ajax.php | 6 +- server/democratic.ajax.php | 2 + server/index.ajax.php | 3 +- server/localplay.ajax.php | 1 + server/player.ajax.php | 2 +- server/playlist.ajax.php | 1 + server/random.ajax.php | 9 +- server/stream.ajax.php | 1 + server/tag.ajax.php | 2 +- share.php | 12 +- shout.php | 2 +- stream.php | 6 +- templates/show_rename_artist.inc.php | 40 ------ 92 files changed, 576 insertions(+), 706 deletions(-) delete mode 100644 templates/show_rename_artist.inc.php diff --git a/admin/catalog.php b/admin/catalog.php index 6a1cd729..0184926f 100644 --- a/admin/catalog.php +++ b/admin/catalog.php @@ -243,7 +243,6 @@ switch ($_REQUEST['action']) { $body = ''; show_confirmation($title, $body, $url); break; - default: case 'show_catalogs': require_once AmpConfig::get('prefix') . '/templates/show_manage_catalogs.inc.php'; break; diff --git a/admin/export.php b/admin/export.php index 3864714d..59e4f1af 100644 --- a/admin/export.php +++ b/admin/export.php @@ -64,8 +64,6 @@ switch ($_REQUEST['action']) { // We don't want the footer so we're done here exit; - - break; default: require_once AmpConfig::get('prefix') . '/templates/show_export.inc.php'; break; diff --git a/admin/system.php b/admin/system.php index c86bb1c0..d55f1089 100644 --- a/admin/system.php +++ b/admin/system.php @@ -42,7 +42,6 @@ switch ($_REQUEST['action']) { $browser->downloadHeaders('ampache.cfg.php','text/plain',false,filesize(AmpConfig::get('prefix') . '/config/ampache.cfg.php.dist')); echo $final; exit; - break; case 'reset_db_charset': Dba::reset_db_charset(); show_confirmation(T_('Database Charset Updated'), T_('Your Database and associated tables have been updated to match your currently configured charset'), AmpConfig::get('web_path').'/admin/system.php?action=show_debug'); diff --git a/admin/users.php b/admin/users.php index 4efc29ee..7068d4ba 100644 --- a/admin/users.php +++ b/admin/users.php @@ -40,7 +40,7 @@ switch ($_REQUEST['action']) { } /* Clean up the variables */ - $user_id = scrub_in($_POST['user_id']); + $user_id = intval($_POST['user_id']); $username = scrub_in($_POST['username']); $fullname = scrub_in($_POST['fullname']); $email = scrub_in($_POST['email']); diff --git a/albums.php b/albums.php index ac5c0dae..66479000 100644 --- a/albums.php +++ b/albums.php @@ -108,7 +108,7 @@ switch ($_REQUEST['action']) { $options['keyword'] = trim($artist . " " . $album_name); // Attempt to find the art. - $images = $art->gather($options,'6'); + $images = $art->gather($options); if (!empty($_REQUEST['cover'])) { $path_info = pathinfo($_REQUEST['cover']); diff --git a/artists.php b/artists.php index 3ad4825f..c6d86c8d 100644 --- a/artists.php +++ b/artists.php @@ -48,59 +48,6 @@ switch ($_REQUEST['action']) { $target_url = AmpConfig::get('web_path') . "/artists.php?action=show&artist=" . $object_id; require_once AmpConfig::get('prefix') . '/templates/show_update_items.inc.php'; break; - case 'rename': - //die if not enough permissions - if (!$user->has_access('100')) { UI::access_denied(); } - - /* Get the artist */ - $artist = new Artist($_REQUEST['artist']); - - //check if we've been given a target - if ((isset($_POST['artist_id']) && $_POST['artist_id'] != $artist->id ) || (isset($_POST['artist_name']) && $_POST['artist_name'] != "")) { - - //if we want to update id3 tags, then get the array of ids now, it's too late afterwards - if (make_bool($_POST['update_id3'])) - $songs = $artist->get_songs(); - - $ret = 0; - $newname = ""; - $newid = 0; - //the manual rename takes priority, but if they tested out the insert thing ignore - if ($_POST['artist_name'] != "" && $_POST['artist_name'] != $artist->name) { - //then just change the name of the artist in the db - $ret = $artist->rename($_POST['artist_name']); - $newid = $ret; - $newname = $_POST['artist_name']; - } - //new id? - elseif ($_POST['artist_id'] != $artist->id) { - //merge with other artist - $ret = $artist->merge($_POST['artist_id']); - $newid = $_POST['artist_id']; - $newname = $ret; - } // elseif different artist and id - //if no changes, no changes - - // show something other than a blank screen after this - if ($ret) { - show_confirmation ( - T_('Renamed artist'), - sprintf(T_('%1$s is now known as %2$s'), $artist->name, $newname), - AmpConfig::get('web_path') . "/artists.php?action=show&artist=" . $newid - ); - } - - } // if we've got the needed variables - - /* Else we've got an error! But be lenient, and just show the form again */ - else { - require AmpConfig::get('prefix') . '/templates/show_rename_artist.inc.php'; - } - break; - case 'show_rename': - $artist = new Artist($_REQUEST['artist']); - require AmpConfig::get('prefix') . '/templates/show_rename_artist.inc.php'; - break; case 'match': case 'Match': $match = scrub_in($_REQUEST['match']); diff --git a/batch.php b/batch.php index 5e25fd5a..d4a9d955 100644 --- a/batch.php +++ b/batch.php @@ -101,6 +101,8 @@ switch ($_REQUEST['action']) { // Take whatever we've got and send the zip $song_files = get_song_files($media_ids); -set_memory_limit($song_files['1']+32); -send_zip($name,$song_files['0']); +if (is_array($song_files['0'])) { + set_memory_limit($song_files['1']+32); + send_zip($name,$song_files['0']); +} exit; diff --git a/broadcast.php b/broadcast.php index ef1ffef4..2328216c 100644 --- a/broadcast.php +++ b/broadcast.php @@ -33,8 +33,7 @@ switch ($_REQUEST['action']) { $next_url = AmpConfig::get('web_path') . '/broadcast.php?action=delete&id=' . scrub_out($id); show_confirmation(T_('Broadcast Delete'), T_('Confirm Deletion Request'), $next_url, 1, 'delete_broadcast'); UI::show_footer(); - exit(); - break; + exit; case 'delete': if (AmpConfig::get('demo_mode')) { UI::access_denied(); @@ -49,8 +48,7 @@ switch ($_REQUEST['action']) { show_confirmation(T_('Broadcast Deleted'), T_('The Broadcast has been deleted'), $next_url); } UI::show_footer(); - exit(); - break; + exit; } // switch on the action UI::show_footer(); diff --git a/channel.php b/channel.php index 5643391c..c58854da 100644 --- a/channel.php +++ b/channel.php @@ -38,8 +38,7 @@ switch ($_REQUEST['action']) { } } UI::show_footer(); - exit(); - break; + exit; case 'create': if (AmpConfig::get('demo_mode')) { UI::access_denied(); @@ -61,8 +60,7 @@ switch ($_REQUEST['action']) { show_confirmation($title, $body, AmpConfig::get('web_path') . '/browse.php?action=channel'); } UI::show_footer(); - exit(); - break; + exit; case 'show_delete': UI::show_header(); $id = $_REQUEST['id']; @@ -70,8 +68,7 @@ switch ($_REQUEST['action']) { $next_url = AmpConfig::get('web_path') . '/channel.php?action=delete&id=' . scrub_out($id); show_confirmation(T_('Channel Delete'), T_('Confirm Deletion Request'), $next_url, 1, 'delete_channel'); UI::show_footer(); - exit(); - break; + exit; case 'delete': if (AmpConfig::get('demo_mode')) { UI::access_denied(); @@ -86,8 +83,7 @@ switch ($_REQUEST['action']) { show_confirmation(T_('Channel Deleted'), T_('The Channel has been deleted'), $next_url); } UI::show_footer(); - exit(); - break; + exit; } // switch on the action UI::show_footer(); diff --git a/channel/index.php b/channel/index.php index 2314eebd..84ca5e47 100644 --- a/channel/index.php +++ b/channel/index.php @@ -99,11 +99,17 @@ curl_setopt_array($ch, array( curl_exec($ch); curl_close($ch); +/** + * @SuppressWarnings("unused") + */ function progress($totaldownload, $downloaded, $us, $ud) { ob_flush(); } +/** + * @SuppressWarnings("unused") + */ function output_header($ch, $header) { $th = trim($header); diff --git a/lib/class/access.class.php b/lib/class/access.class.php index 402d7775..d2ef66b8 100644 --- a/lib/class/access.class.php +++ b/lib/class/access.class.php @@ -145,7 +145,7 @@ class Access $sql = 'UPDATE `access_list` SET `start` = ?, `end` = ?, `level` = ?, ' . '`user` = ?, `name` = ?, `type` = ?, `enabled` = ? WHERE `id` = ?'; - $db_results = Dba::write($sql, + Dba::write($sql, array($start, $end, $level, $user, $name, $type, $enabled, $this->id)); return true; @@ -180,7 +180,7 @@ class Access $sql = 'INSERT INTO `access_list` (`name`, `level`, `start`, `end`, ' . '`user`,`type`,`enabled`) VALUES (?, ?, ?, ?, ?, ?, ?)'; - $db_results = Dba::write($sql, array($name, $level, $start, $end, $user, $type, $enabled)); + Dba::write($sql, array($name, $level, $start, $end, $user, $type, $enabled)); return true; @@ -230,7 +230,6 @@ class Access switch ($type) { case 'download': return AmpConfig::get('download'); - break ; case 'batch_download': if (!function_exists('gzcompress')) { debug_event('access', 'ZLIB extension not loaded, batch download disabled', 3); @@ -242,7 +241,6 @@ class Access break; default: return false; - break; } } @@ -259,7 +257,6 @@ class Access case 'interface': case 'stream': return true; - break; default: return false; } @@ -283,7 +280,6 @@ class Access break; default: return false; - break; } // end switch on type $sql = 'SELECT `id` FROM `access_list` ' . @@ -333,24 +329,13 @@ class Access switch ($type) { case 'localplay': // Check their localplay_level - if (AmpConfig::get('localplay_level') >= $level - || $GLOBALS['user']->access >= 100) { - return true; - } else { - return false; - } - break; + return (AmpConfig::get('localplay_level') >= $level + || $GLOBALS['user']->access >= 100); case 'interface': // Check their standard user level - if ($GLOBALS['user']->access >= $level) { - return true; - } else { - return false; - } - break; + return ($GLOBALS['user']->access >= $level); default: return false; - break; } return false; @@ -369,10 +354,8 @@ class Access case 'interface': case 'network': return $type; - break; default: return 'stream'; - break; } } @@ -439,17 +422,13 @@ class Access switch ($this->type) { case 'rpc': return T_('API/RPC'); - break; case 'network': return T_('Local Network Definition'); - break; case 'interface': return T_('Web Interface'); - break; case 'stream': default: return T_('Stream Access'); - break; } } } diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 17133748..c5bd40ef 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -38,6 +38,7 @@ class Album extends database_object public $prefix; public $mbid; // MusicBrainz ID + public $song_count; public $artist_prefix; public $artist_name; public $artist_id; @@ -52,6 +53,7 @@ class Album extends database_object public $f_link_src; public $f_link; public $f_tags; + public $f_title; // cached information public $_fake; @@ -445,7 +447,7 @@ class Album extends database_object } $this->tags = Tag::get_top_tags('album', $this->id); - $this->f_tags = Tag::get_display($this->tags, $this->id, 'album'); + $this->f_tags = Tag::get_display($this->tags); } // format @@ -490,7 +492,7 @@ class Album extends database_object $current_id = $this->id; - $updated = 0; + $updated = false; $songs = null; if ($artist != $this->artist_id AND $artist) { // Update every song @@ -498,7 +500,7 @@ class Album extends database_object foreach ($songs as $song_id) { Song::update_artist($artist,$song_id); } - $updated = 1; + $updated = true; Artist::gc(); } @@ -510,11 +512,11 @@ class Album extends database_object Song::update_year($year,$song_id); } $current_id = $album_id; - $updated = 1; + $updated = true; self::gc(); } - if ($updated) { + if ($updated && is_array($songs)) { foreach ($songs as $song_id) { Song::update_utime($song_id); } // foreach song of album diff --git a/lib/class/ampconfig.class.php b/lib/class/ampconfig.class.php index 63b86805..665cfaf5 100644 --- a/lib/class/ampconfig.class.php +++ b/lib/class/ampconfig.class.php @@ -35,7 +35,6 @@ */ class AmpConfig { - private $_local = array(); private static $_global = array(); public function __construct() diff --git a/lib/class/art.class.php b/lib/class/art.class.php index 335ae6c7..80730771 100644 --- a/lib/class/art.class.php +++ b/lib/class/art.class.php @@ -135,10 +135,8 @@ class Art extends database_object case 'video': case 'user': return $type; - break; default: return 'album'; - break; } } // validate_type @@ -278,7 +276,7 @@ class Art extends database_object // Insert it! $sql = "INSERT INTO `image` (`image`, `mime`, `size`, `object_type`, `object_id`) VALUES('$image', '$mime', 'original', '$type', '$uid')"; - $db_results = Dba::write($sql); + Dba::write($sql); return true; @@ -291,8 +289,7 @@ class Art extends database_object public function reset() { $sql = "DELETE FROM `image` WHERE `object_id` = ? AND `object_type` = ?"; - $db_results = Dba::write($sql, array($this->uid, $this->type)); - + Dba::write($sql, array($this->uid, $this->type)); } // reset /** @@ -317,8 +314,7 @@ class Art extends database_object $db_results = Dba::write($sql); $sql = "INSERT INTO `image` (`image`, `mime`, `size`, `object_type`, `object_id`) VALUES('$source', '$mime', '$size', '$type', '$uid')"; - $db_results = Dba::write($sql); - + Dba::write($sql); } // save_thumb /** @@ -424,13 +420,17 @@ class Art extends database_object break; // Turn bmps into pngs case 'bmp': - $type = 'png'; case 'png': imagepng($thumbnail); $mime_type = image_type_to_mime_type(IMAGETYPE_PNG); break; } // resized + if (!isset($mime_type)) { + debug_event('Art', 'Eror: No mime type found.', 1); + return false; + } + $data = ob_get_contents(); ob_end_clean(); @@ -533,13 +533,9 @@ class Art extends database_object $row = parent::get_from_cache('art', $key . 'original'); $thumb_mime = $row['mime']; } - if (!$mime && !$thumb_mime) { - - $type = Dba::escape($type); - $uid = Dba::escape($uid); - - $sql = "SELECT `object_type`, `object_id`, `mime`, `size` FROM `image` WHERE `object_type`='$type' AND `object_id`='$uid'"; - $db_results = Dba::read($sql); + if (!isset($mime) && !isset($thumb_mime)) { + $sql = "SELECT `object_type`, `object_id`, `mime`, `size` FROM `image` WHERE `object_type` = ? AND `object_id` = ?"; + $db_results = Dba::read($sql, array($type, $uid)); while ($row = Dba::fetch_assoc($db_results)) { parent::add_to_cache('art', $key . $row['size'], $row); @@ -551,7 +547,7 @@ class Art extends database_object } } - $mime = $thumb_mime ? $thumb_mime : $mime; + $mime = isset($thumb_mime) ? $thumb_mime : $mime; $extension = self::extension($mime); $name = 'art.' . $extension; @@ -573,7 +569,7 @@ class Art extends database_object $type . "` ON `" . $type . "`.`id`=" . "`image`.`object_id` WHERE `object_type`='" . $type . "' AND `" . $type . "`.`id` IS NULL"; - $db_results = Dba::write($sql); + Dba::write($sql); } // foreach } @@ -591,10 +587,9 @@ class Art extends database_object $allowed_methods = array('db','lastfm','folder','amazon','google','musicbrainz','tags'); break; case 'artist': - $allowed_methods = array(); - break; case 'video': - $allowed_methods = array(); + default: + $allowed_methods = array(); break; } @@ -614,8 +609,6 @@ class Art extends database_object foreach ($config as $method) { - $data = array(); - if (!in_array($method, $allowed_methods)) { debug_event('Art', "$method not in allowed_methods, skipping", 3); continue; @@ -843,14 +836,20 @@ class Art extends database_object 'MediumImage', 'SmallImage' ); + + if ($this->type == 'album') { + $album = new Album($this->uid); + } else { + return $images; + } // Prevent the script from timing out set_time_limit(0); if (empty($keywords)) { - $keywords = $this->full_name; + $keywords = $album->full_name; /* If this isn't a various album combine with artist name */ - if ($this->artist_count == '1') { $keywords .= ' ' . $this->artist_name; } + if ($album->artist_count == '1') { $keywords .= ' ' . $album->artist_name; } } /* Attempt to retrieve the album art order */ @@ -879,11 +878,9 @@ class Art extends database_object /* Set up the needed variables */ $max_pages_to_search = max(AmpConfig::get('max_amazon_results_pages'),$amazon->_default_results_pages); - $pages_to_search = $max_pages_to_search; //init to max until we know better. // while we have pages to search do { - $raw_results = $amazon->search(array('artist'=>$artist,'album'=>$albumname,'keywords'=>$keywords)); - + $raw_results = $amazon->search(array('artist'=>'', 'album'=>'', 'keywords'=>$keywords)); $total = count($raw_results) + count($search_results); // If we've gotten more then we wanted @@ -922,9 +919,11 @@ class Art extends database_object /* Foreach through what we've found */ foreach ($final_results as $result) { + $key = ''; /* Recurse through the images found */ - foreach ($possible_keys as $key) { - if (strlen($result[$key])) { + foreach ($possible_keys as $k) { + if (strlen($result[$k])) { + $key = $k; break; } } // foreach @@ -941,6 +940,7 @@ class Art extends database_object continue; } + $data = array(); $data['url'] = $result[$key]; $data['mime'] = $mime; @@ -987,7 +987,6 @@ class Art extends database_object ); foreach ($songs as $song_id) { - $data = array(); $song = new Song($song_id); $dir = dirname($song->file); @@ -1165,6 +1164,7 @@ class Art extends database_object */ public function gather_lastfm($limit, $options = false) { + $data = array(); // Create the parser object $lastfm = new LastFMSearch(); @@ -1180,6 +1180,9 @@ class Art extends database_object $album = $media->full_name; } break; + default: + return $data; + break; } if (AmpConfig::get('proxy_host') AND AmpConfig::get('proxy_port')) { diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index dea76bb7..f474d04b 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -36,6 +36,8 @@ class Artist extends database_object public $catalog_id; public $time; + public $tags; + public $f_tags; public $object_cnt; public $f_name; public $f_full_name; @@ -330,7 +332,7 @@ class Artist extends database_object $this->f_time = ltrim($hours . ':' . $min . ':' . $sec,'0:'); $this->tags = Tag::get_top_tags('artist', $this->id); - $this->f_tags = Tag::get_display($this->tags, $this->id, 'artist'); + $this->f_tags = Tag::get_display($this->tags); $this->object_cnt = $extra_info['object_cnt']; diff --git a/lib/class/auth.class.php b/lib/class/auth.class.php index 4917603f..4baace22 100644 --- a/lib/class/auth.class.php +++ b/lib/class/auth.class.php @@ -84,6 +84,7 @@ class Auth */ public static function login($username, $password, $allow_ui = false) { + $results = array(); foreach (AmpConfig::get('auth_methods') as $method) { $function_name = $method . '_auth'; diff --git a/lib/class/broadcast.class.php b/lib/class/broadcast.class.php index b63f148c..a5ba0872 100644 --- a/lib/class/broadcast.class.php +++ b/lib/class/broadcast.class.php @@ -112,7 +112,7 @@ class Broadcast extends database_object $this->f_name = $this->name; $this->f_link = '' . scrub_out($this->f_name) . ''; $this->tags = Tag::get_top_tags('broadcast', $this->id); - $this->f_tags = Tag::get_display($this->tags, $this->id, 'broadcast'); + $this->f_tags = Tag::get_display($this->tags); } public static function get_broadcast_list_sql() diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index a2330fb5..0b8fb15c 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -243,12 +243,12 @@ class Browse extends Query } } - if ($box_req) { + if (isset($box_req)) { require $box_req; } if ($this->get_show_header()) { - if ($box_req) { + if (isset($box_req)) { UI::show_box_bottom(); } echo ' -name)); ?> -
- id, "artist_id", 4); ?> -
-
- - []
- print_error('artist_name'); ?> -  
-
-
-