1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 01:39:28 +02:00

Fix Scrutinizer reported errors

This commit is contained in:
Afterster 2014-07-09 23:27:14 +02:00
parent 4a2d7b97f6
commit 80cd08ed04
29 changed files with 117 additions and 92 deletions

View file

@ -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':

View file

@ -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;

View file

@ -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

View file

@ -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 */

View file

@ -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)

View file

@ -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':

View file

@ -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');

View file

@ -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

View file

@ -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] .= "<br />\n" . $message;
$_SESSION['errors'][$name] .= "<br />\n" . $message;
}

View file

@ -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)) {

View file

@ -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

View file

@ -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);
}
}
}

View file

@ -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);

View file

@ -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()

View file

@ -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;

View file

@ -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 = '<a href="' . $this->link . '" title="' . $this->f_name . '">' . $this->f_name . '</a>';
$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);
}
}
}

View file

@ -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;
}

View file

@ -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 = '<a href="' . $this->link . '" title="' . $tvshow->f_name . ' - ' . $this->f_name . '">' . $this->f_name . '</a>';
$this->_get_extra_info($this->catalog_id);
$this->_get_extra_info();
return true;
}

View file

@ -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;
}
/**

View file

@ -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');

View file

@ -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];
}
}
}
}

View file

@ -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 = '';
/**

View file

@ -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'];

View file

@ -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</$key>\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</$key>\n";
} else {
if ($key == "key") {

View file

@ -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;

View file

@ -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)) {

View file

@ -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';

View file

@ -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();

View file

@ -25,6 +25,8 @@ $rootMediaItems[] = Upnp_Api::_videoMetadata('');
exit;
}
$items = array();
$responseType = "u:Error";
switch ($upnpRequest['action']) {
case 'search':
$responseType = 'u:SearchResponse';