diff --git a/image.php b/image.php index 08303a01fc..10d02fe5bd 100644 --- a/image.php +++ b/image.php @@ -81,45 +81,47 @@ break; } // define size based on thumbnail -switch ($_GET['type']) { - case 'popup': - require_once AmpConfig::get('prefix') . '/templates/show_big_art.inc.php'; - break; - // If we need to pull the data out of the session - case 'session': - Session::check(); - $filename = scrub_in($_REQUEST['image_index']); - $image = Art::get_from_source($_SESSION['form']['images'][$filename], 'album'); - $mime = $_SESSION['form']['images'][$filename]['mime']; - break; - default: - $media = new $type($_GET['id']); - $filename = $media->name; - - $art = new Art($media->id,$type); - $art->get_db(); +$image = ''; +$typeManaged = false; +if (isset($_GET['type'])) { + switch ($_GET['type']) { + case 'popup': + $typeManaged = true; + require_once AmpConfig::get('prefix') . '/templates/show_big_art.inc.php'; + break; + case 'session': + // If we need to pull the data out of the session + Session::check(); + $filename = scrub_in($_REQUEST['image_index']); + $image = Art::get_from_source($_SESSION['form']['images'][$filename], 'album'); + $mime = $_SESSION['form']['images'][$filename]['mime']; + $typeManaged = true; + break; + } +} +if (!$typeManaged) { + $media = new $type($_GET['id']); + $filename = $media->name; - if (!$art->raw_mime) { - $mime = 'image/jpeg'; - $image = file_get_contents(AmpConfig::get('prefix') . - AmpConfig::get('theme_path') . - '/images/blankalbum.jpg'); - } else { - if ($_GET['thumb']) { - $thumb_data = $art->get_thumb($size); - } + $art = new Art($media->id,$type); + $art->get_db(); - $mime = $thumb_data - ? $thumb_data['thumb_mime'] - : $art->raw_mime; - $image = $thumb_data - ? $thumb_data['thumb'] - : $art->raw; + if (!$art->raw_mime) { + $mime = 'image/jpeg'; + $image = file_get_contents(AmpConfig::get('prefix') . + AmpConfig::get('theme_path') . + '/images/blankalbum.jpg'); + } else { + if ($_GET['thumb']) { + $thumb_data = $art->get_thumb($size); } - break; -} // end switch type -if ($image) { + $mime = isset($thumb_data['thumb_mime']) ? $thumb_data['thumb_mime'] : $art->raw_mime; + $image = isset($thumb_data['thumb']) ? $thumb_data['thumb'] : $art->raw; + } +} + +if (!empty($image)) { $extension = Art::extension($mime); $filename = scrub_out($filename . '.' . $extension); diff --git a/index.php b/index.php index afcde79697..2efb28d753 100644 --- a/index.php +++ b/index.php @@ -32,7 +32,9 @@ $action = isset($_REQUEST['action']) ? scrub_in($_REQUEST['action']) : null; -session_start(); +if (session_status() == PHP_SESSION_NONE) { + session_start(); +} $_SESSION['catalog'] = 0; /** diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 7d9b67701f..6d6b2f753d 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -379,13 +379,13 @@ public function get_group_disks_ids() * get_album_suite * gets the album ids with the same musicbrainz identifier */ - public function get_album_suite() + public function get_album_suite($catalog = '') { $results = array(); $catalog_where = ""; $catalog_join = "LEFT JOIN `catalog` ON `catalog`.`id` = `song`.`catalog`"; - if ($catalog) { + if (!empty($catalog)) { $catalog_where .= " AND `catalog`.`id` = '$catalog'"; } if (AmpConfig::get('catalog_disable')) { diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index cabfa75cd3..3cb7e6ed49 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -72,9 +72,11 @@ public function add_supplemental_object($class, $uid) */ public function get_supplemental_objects() { - $objects = $_SESSION['browse']['supplemental'][$this->id]; + $objects = isset($_SESSION['browse']['supplemental'][$this->id]) ? $_SESSION['browse']['supplemental'][$this->id] : ''; - if (!is_array($objects)) { $objects = array(); } + if (!is_array($objects)) { + $objects = array(); + } return $objects; diff --git a/lib/class/preference.class.php b/lib/class/preference.class.php index be7b5b2e85..3b1b883ad2 100644 --- a/lib/class/preference.class.php +++ b/lib/class/preference.class.php @@ -387,7 +387,7 @@ public static function fix_preferences($results) */ public static function load_from_session($uid=-1) { - if (is_array($_SESSION['userdata']['preferences']) AND $_SESSION['userdata']['uid'] == $uid) { + if (isset($_SESSION['userdata']['preferences']) && is_array($_SESSION['userdata']['preferences']) AND $_SESSION['userdata']['uid'] == $uid) { AmpConfig::set_by_array($_SESSION['userdata']['preferences'], true); return true; } diff --git a/lib/class/query.class.php b/lib/class/query.class.php index b94275e7e0..69169119c3 100644 --- a/lib/class/query.class.php +++ b/lib/class/query.class.php @@ -1011,7 +1011,7 @@ private function get_limit_sql() */ private function get_join_sql() { - if (!is_array($this->_state['join'])) { + if (!isset($this->_state['join']) || !is_array($this->_state['join'])) { return ''; } @@ -1033,7 +1033,7 @@ private function get_join_sql() */ public function get_having_sql() { - $sql = $this->_state['having']; + $sql = isset($this->_state['having']) ? $this->_state['having'] : ''; return $sql; @@ -1049,7 +1049,7 @@ public function get_sql($limit = true) { $sql = $this->get_base_sql(); - if (!$this->_state['custom']) { + if (!isset($this->_state['custom']) || !$this->_state['custom']) { $filter_sql = $this->get_filter_sql(); $join_sql = $this->get_join_sql(); $having_sql = $this->get_having_sql(); @@ -1074,7 +1074,7 @@ public function get_sql($limit = true) */ private function post_process($data) { - $tags = $this->_state['filter']['tag']; + $tags = isset($this->_state['filter']['tag']) ? $this->_state['filter']['tag'] : ''; if (!is_array($tags) || sizeof($tags) < 2) { return $data; diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php index b62e4a0ccf..90c92772f7 100644 --- a/lib/class/rating.class.php +++ b/lib/class/rating.class.php @@ -122,14 +122,14 @@ public function get_user_rating($user_id = null) $user_id = $GLOBALS['user']->id; } - $key = 'rating_' . $type . '_user' . $user_id; + $key = 'rating_' . $this->type . '_user' . $user_id; if (parent::is_cached($key, $this->id)) { return parent::get_from_cache($key, $this->id); } $sql = "SELECT `rating` FROM `rating` WHERE `user` = ? ". "AND `object_id` = ? AND `object_type` = ?"; - $db_results = Dba::read($sql, array($user_id, $this->id, $type)); + $db_results = Dba::read($sql, array($user_id, $this->id, $this->type)); $rating = 0; @@ -149,8 +149,8 @@ public function get_user_rating($user_id = null) */ public function get_average_rating() { - if (parent::is_cached('rating_' . $type . '_all', $id)) { - return parent::get_from_cache('rating_' . $type . '_user', $id); + if (parent::is_cached('rating_' . $this->type . '_all', $this->id)) { + return parent::get_from_cache('rating_' . $this->type . '_user', $this->id); } $sql = "SELECT AVG(`rating`) as `rating` FROM `rating` WHERE " . @@ -159,7 +159,7 @@ public function get_average_rating() $results = Dba::fetch_assoc($db_results); - parent::add_to_cache('rating_' . $type . '_all', $id, $results['rating']); + parent::add_to_cache('rating_' . $this->type . '_all', $this->id, $results['rating']); return $results['rating']; } // get_average_rating @@ -264,7 +264,7 @@ public static function show($object_id, $type, $static=false) if (!AmpConfig::get('ratings')) { return false; } $rating = new Rating($object_id, $type); - + if ($static) { require AmpConfig::get('prefix') . '/templates/show_static_object_rating.inc.php'; } else { diff --git a/lib/class/session.class.php b/lib/class/session.class.php index 6fb19b9fdd..3b73b71acc 100644 --- a/lib/class/session.class.php +++ b/lib/class/session.class.php @@ -204,10 +204,16 @@ public static function create($data) break; } // end switch on data type - $username = $data['username']; + $username = ''; + if (isset($data['username'])) { + $username = $data['username']; + } $ip = $_SERVER['REMOTE_ADDR'] ? inet_pton($_SERVER['REMOTE_ADDR']) : '0'; $type = $data['type']; - $value = $data['value']; + $value = ''; + if (isset($data['value'])) { + $value = $data['value']; + } $agent = (!empty($data['agent'])) ? $data['agent'] : substr($_SERVER['HTTP_USER_AGENT'], 0, 254); if ($type == 'stream') { diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 9edafb5c06..b51b8f4230 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -185,6 +185,10 @@ public static function build_cache($song_ids) } $db_results = Dba::read($sql); + $artists = array(); + $albums = array(); + $tags = array(); + while ($row = Dba::fetch_assoc($db_results)) { if (AmpConfig::get('show_played_times')) { $row['object_cnt'] = Stats::get_object_count('song', $row['id']); @@ -200,7 +204,7 @@ public static function build_cache($song_ids) Artist::build_cache($artists); Album::build_cache($albums); Tag::build_cache($tags); - Tag::build_map_cache('song',$song_ids); + Tag::build_map_cache('song', $song_ids); Art::build_cache($albums); // If we're rating this then cache them as well @@ -824,8 +828,10 @@ public function format() $this->fill_ext_info(); // Format the filename - preg_match("/^.*\/(.*?)$/",$this->file, $short); - $this->f_file = htmlspecialchars($short[1]); + preg_match("/^.*\/(.*?)$/", $this->file, $short); + if (is_array($short) && isset($short[1])) { + $this->f_file = htmlspecialchars($short[1]); + } // Format the album name $this->f_album_full = $this->get_album_name(); diff --git a/lib/class/ui.class.php b/lib/class/ui.class.php index f372670bb8..b158c6f1f1 100644 --- a/lib/class/ui.class.php +++ b/lib/class/ui.class.php @@ -243,7 +243,7 @@ public static function get_icon($name, $title = null, $id = null) */ private static function _find_icon($name) { - if ($url = self::$_icon_cache[$name]) { + if (isset(self::$_icon_cache[$name]) && $url = self::$_icon_cache[$name]) { return $url; } diff --git a/lib/preferences.php b/lib/preferences.php index 082b24df38..cf6098d767 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -180,24 +180,42 @@ function create_preference_input($name,$value) case 'share_social': case 'broadcast_by_default': case 'album_group': - if ($value == '1') { $is_true = "selected=\"selected\""; } else { $is_false = "selected=\"selected\""; } + $is_true = ''; + $is_false = ''; + if ($value == '1') { + $is_true = "selected=\"selected\""; } + else { + $is_false = "selected=\"selected\""; + } echo "\n"; break; case 'play_type': - if ($value == 'localplay') { $is_local = 'selected="selected"'; } elseif ($value == 'democratic') { $is_vote = 'selected="selected"'; } elseif ($value == 'web_player') { $is_web_player = 'selected="selected"'; } else { $is_stream = "selected=\"selected\""; } + $is_localplay = ''; + $is_democratic = ''; + $is_web_player = ''; + $is_stream = ''; + if ($value == 'localplay') { + $is_localplay = 'selected="selected"'; + } elseif ($value == 'democratic') { + $is_democratic = 'selected="selected"'; + } elseif ($value == 'web_player') { + $is_web_player = 'selected="selected"'; + } else { + $is_stream = "selected=\"selected\""; + } echo "\n"; @@ -236,7 +254,18 @@ function create_preference_input($name,$value) echo "\n"; break; case 'localplay_level': - if ($value == '25') { $is_user = 'selected="selected"'; } elseif ($value == '100') { $is_admin = 'selected="selected"'; } elseif ($value == '50') { $is_manager = 'selected="selected"'; } + $is_user = ''; + $is_admin = ''; + $is_manager = ''; + if ($value == '25') { + $is_user = 'selected="selected"'; + } + elseif ($value == '100') { + $is_admin = 'selected="selected"'; + } + elseif ($value == '50') { + $is_manager = 'selected="selected"'; + } echo "\n"; break; case 'show_lyrics': - if ($value == '1') { $is_true = "selected=\"selected\""; } else { $is_false = "selected=\"selected\""; } + $is_true = ''; + $is_false = ''; + if ($value == '1') { + $is_true = "selected=\"selected\""; + } else { + $is_false = "selected=\"selected\""; + } echo "\n"; break; case 'album_sort': - if ($value == 'year_asc') { $is_sort_year_asc = 'selected="selected"'; } elseif ($value == 'year_desc') { $is_sort_year_desc = 'selected="selected"'; } elseif ($value == 'name_asc') { $is_sort_name_asc = 'selected="selected"'; } elseif ($value == 'name_desc') { $is_sort_name_desc = 'selected="selected"'; } else { $is_sort_default = 'selected="selected"'; } + $is_sort_year_asc = ''; + $is_sort_year_desc = ''; + $is_sort_name_asc = ''; + $is_sort_name_desc = ''; + $is_sort_default = ''; + if ($value == 'year_asc') { + $is_sort_year_asc = 'selected="selected"'; + } elseif ($value == 'year_desc') { + $is_sort_year_desc = 'selected="selected"'; + } elseif ($value == 'name_asc') { + $is_sort_name_asc = 'selected="selected"'; + } elseif ($value == 'name_desc') { + $is_sort_name_desc = 'selected="selected"'; + } else { + $is_sort_default = 'selected="selected"'; + } echo " - - - - -
- id . '&key=min_count&value=1', '')); ?> - - - -
- id . '&key=rated&value=1', '')); ?> - - - get_filter('unplayed') ? 'checked="checked"' : ''; ?>/> -
- - - get_filter('playlist_type') ? 'checked="checked"' : ''; ?>/> -
- id . '&key=playlist_type&value=1','')); ?> - - - get_filter('object_type'); ${$string} = 'selected="selected"'; ?> - /> -
- id . '&type=song','')); ?> - -
- id . '&type=album','')); ?> - -
- id . '&type=artist','')); ?> - +
  • +

    +
    + +
    + + +
    + + + +
    + id . '&key=min_count&value=1', '')); ?> + + + +
    + id . '&key=rated&value=1', '')); ?> + + + get_filter('unplayed') ? 'checked="checked"' : ''; ?>/> +
    + + + get_filter('playlist_type') ? 'checked="checked"' : ''; ?>/> +
    + id . '&key=playlist_type&value=1','')); ?> + + + get_filter('object_type'); ${$string} = 'selected="selected"'; ?> + /> +
    + id . '&type=song','')); ?> + +
    + id . '&type=album','')); ?> + +
    + id . '&type=artist','')); ?> + - -
    -
    - + + ' . $entries['name'] . ''; - } - ?> + foreach ($results as $entries) { + echo '
    - - -  /> - id, '')); ?> - -
    + + id,'catalog_select', 'catalog_choice')); ?> + + + +  /> + id, '')); ?> + +
  • diff --git a/templates/list_header.inc.php b/templates/list_header.inc.php index 5c8b957ba7..85268afda3 100644 --- a/templates/list_header.inc.php +++ b/templates/list_header.inc.php @@ -27,7 +27,7 @@ * to layout this page. */ - if ($is_header) { + if (isset($is_header) && $is_header) { $is_header = false; } else { $is_header = true; diff --git a/templates/show_album.inc.php b/templates/show_album.inc.php index 89a38c51b5..e228ceaf7d 100644 --- a/templates/show_album.inc.php +++ b/templates/show_album.inc.php @@ -125,10 +125,10 @@
  • - + - +
  • diff --git a/templates/show_html5_player.inc.php b/templates/show_html5_player.inc.php index 218c04f752..f39a413e07 100644 --- a/templates/show_html5_player.inc.php +++ b/templates/show_html5_player.inc.php @@ -177,7 +177,7 @@ function SwapSlideshow() echo "var lyricsobj = '" . T_('Show Lyrics') . "';"; echo "var actionsobj = '|';"; if (AmpConfig::get('sociable')) { - echo "actionsobj += ' " . UI::get_icon('comment', T_('Post Shout')) . "';"; + echo "actionsobj += ' " . UI::get_icon('comment', T_('Post Shout')) . " |';"; } echo "actionsobj += '
    ';"; if (AmpConfig::get('waveform')) { diff --git a/templates/show_playtype_switch.inc.php b/templates/show_playtype_switch.inc.php index 856505ee40..ae0c92e54e 100644 --- a/templates/show_playtype_switch.inc.php +++ b/templates/show_playtype_switch.inc.php @@ -30,19 +30,21 @@
    diff --git a/templates/show_recently_played.inc.php b/templates/show_recently_played.inc.php index 44623b3102..4c8708d094 100644 --- a/templates/show_recently_played.inc.php +++ b/templates/show_recently_played.inc.php @@ -125,7 +125,7 @@ - + diff --git a/templates/sidebar.inc.php b/templates/sidebar.inc.php index dbaaf758fa..97c4b96b8c 100644 --- a/templates/sidebar.inc.php +++ b/templates/sidebar.inc.php @@ -20,9 +20,10 @@ * */ -if (!$_SESSION['state']['sidebar_tab']) { $_SESSION['state']['sidebar_tab'] = 'home'; } +if (!$_SESSION['state']['sidebar_tab']) { + $_SESSION['state']['sidebar_tab'] = 'home'; +} $class_name = 'sidebar_' . $_SESSION['state']['sidebar_tab']; -${$class_name} = ' active'; // List of buttons ( id, title, icon, access level) $sidebar_items[] = array('id'=>'home', 'title' => T_('Home'), 'icon'=>'home', 'access'=>5); @@ -31,34 +32,36 @@ $sidebar_items[] = array('id'=>'modules','title' => T_('Modules'),'icon'=>'plugin','access'=>100); $sidebar_items[] = array('id'=>'admin', 'title' => T_('Admin'), 'icon'=>'admin', 'access'=>100); - $web_path = AmpConfig::get('web_path'); - ?> +