diff options
author | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-03-14 06:10:27 +0000 |
---|---|---|
committer | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-03-14 06:10:27 +0000 |
commit | d78c207f76c8ae57744300611519f4c85c2c34c4 (patch) | |
tree | 7a29bf59f4c3c9fc5f9f654ba86e6cd3f065a74f | |
parent | 98c5c04643228731b1dcf0eb48fa3dbc77815ad6 (diff) | |
download | ampache-d78c207f76c8ae57744300611519f4c85c2c34c4.tar.gz ampache-d78c207f76c8ae57744300611519f4c85c2c34c4.tar.bz2 ampache-d78c207f76c8ae57744300611519f4c85c2c34c4.zip |
Cosmetics: use tabs for indentation, tweak some indentation/coding style.
28 files changed, 1365 insertions, 1365 deletions
diff --git a/lib/class/access.class.php b/lib/class/access.class.php index 558b8fc0..3652715d 100644 --- a/lib/class/access.class.php +++ b/lib/class/access.class.php @@ -94,24 +94,24 @@ class Access { */ public function update($data) { - /* We need to verify the incomming data a littlebit */ - $start = @inet_pton($data['start']); - $end = @inet_pton($data['end']); - - if (!$start AND $data['start'] != '0.0.0.0' AND $data['start'] != '::') { - Error::add('start',_('Invalid IPv4 / IPv6 Address Entered')); - return false; - } - if (!$end) { - Error::add('end',_('Invalid IPv4 / IPv6 Address Entered')); - return false; - } - - if (strlen(bin2hex($start)) != strlen(bin2hex($end))) { - Error::add('start',_('IP Address Version Mismatch')); - Error::add('end',_('IP Address Version Mismatch')); - return false; - } + /* We need to verify the incomming data a littlebit */ + $start = @inet_pton($data['start']); + $end = @inet_pton($data['end']); + + if (!$start AND $data['start'] != '0.0.0.0' AND $data['start'] != '::') { + Error::add('start',_('Invalid IPv4 / IPv6 Address Entered')); + return false; + } + if (!$end) { + Error::add('end',_('Invalid IPv4 / IPv6 Address Entered')); + return false; + } + + if (strlen(bin2hex($start)) != strlen(bin2hex($end))) { + Error::add('start',_('IP Address Version Mismatch')); + Error::add('end',_('IP Address Version Mismatch')); + return false; + } $name = Dba::escape($data['name']); $type = self::validate_type($data['type']); @@ -224,14 +224,14 @@ class Access { return Config::get('download'); break ; case 'batch_download': - if (!function_exists('gzcompress')) { - debug_event('gzcompress','ZLIB Extensions not loaded, batch download disabled','3'); - return false; - } - if (Config::get('allow_zip_download') AND $GLOBALS['user']->has_access('25')) { - return Config::get('download'); - } - break; + if (!function_exists('gzcompress')) { + debug_event('gzcompress','ZLIB Extensions not loaded, batch download disabled','3'); + return false; + } + if (Config::get('allow_zip_download') AND $GLOBALS['user']->has_access('25')) { + return Config::get('download'); + } + break; default: return false; break; diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php index 254bc6bf..5381f529 100644 --- a/lib/class/ajax.class.php +++ b/lib/class/ajax.class.php @@ -45,23 +45,23 @@ class Ajax { */ public static function observe($source,$method,$action,$post='') { - $non_quoted = array('document','window'); + $non_quoted = array('document','window'); - if (in_array($source,$non_quoted)) { - $source_txt = $source; - } - else { - $source_txt = "'$source'"; - } + if (in_array($source,$non_quoted)) { + $source_txt = $source; + } + else { + $source_txt = "'$source'"; + } // If it's a post then we need to stop events if ($post) { $action = 'Event.stop(e); ' . $action; } - $observe = "<script type=\"text/javascript\">"; - $observe .= "Event.observe($source_txt,'$method',function(e){" . $action . ";});"; - $observe .= "</script>"; + $observe = "<script type=\"text/javascript\">"; + $observe .= "Event.observe($source_txt,'$method',function(e){" . $action . ";});"; + $observe .= "</script>"; return $observe; @@ -76,15 +76,15 @@ class Ajax { $url = Config::get('ajax_url') . $action; - $non_quoted = array('document','window'); + $non_quoted = array('document','window'); + + if (in_array($source,$non_quoted)) { + $source_txt = $source; + } + else { + $source_txt = "'$source'"; + } - if (in_array($source,$non_quoted)) { - $source_txt = $source; - } - else { - $source_txt = "'$source'"; - } - if ($post) { $ajax_string = "ajaxPost('$url','$post',$source_txt)"; } @@ -106,7 +106,7 @@ class Ajax { // Get the correct action $ajax_string = self::action($action,$source,$post); - // If they passed a span class + // If they passed a span class if ($class) { $class_txt = ' class="' . $class . '"'; } @@ -114,7 +114,7 @@ class Ajax { $string = get_user_icon($icon,$alt); - // Generate a <a> so that it's more compliant with older browsers + // Generate a <a> so that it's more compliant with older browsers // (ie :hover actions) and also to unify linkbuttons (w/o ajax) display $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class_txt>".$string."</a>\n"; @@ -140,7 +140,7 @@ class Ajax { } // If we pass a source put it in the ID - $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class_txt>$text</a>\n"; + $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class_txt>$text</a>\n"; $string .= self::observe($source,'click',$ajax_string); diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 4f17db3d..144fcf4f 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -113,16 +113,16 @@ class Album extends database_object { if ($extra) { $sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,COUNT(song.id) AS song_count,artist.name AS artist_name" . ",artist.prefix AS artist_prefix,album_data.art AS has_art,album_data.thumb AS has_thumb, artist.id AS artist_id,`song`.`album`". - "FROM `song` " . - "INNER JOIN `artist` ON `artist`.`id`=`song`.`artist` " . - "LEFT JOIN `album_data` ON `album_data`.`album_id` = `song`.`album` " . - "WHERE `song`.`album` IN $idlist GROUP BY `song`.`album`"; + "FROM `song` " . + "INNER JOIN `artist` ON `artist`.`id`=`song`.`artist` " . + "LEFT JOIN `album_data` ON `album_data`.`album_id` = `song`.`album` " . + "WHERE `song`.`album` IN $idlist GROUP BY `song`.`album`"; $db_results = Dba::read($sql); while ($row = Dba::fetch_assoc($db_results)) { - $row['has_art'] = make_bool($row['has_art']); - $row['has_thumb'] = make_bool($row['has_thumb']); + $row['has_art'] = make_bool($row['has_art']); + $row['has_thumb'] = make_bool($row['has_thumb']); parent::add_to_cache('album_extra',$row['album'],$row); } // while rows } // if extra @@ -231,7 +231,7 @@ class Album extends database_object { */ public function format() { - $web_path = Config::get('web_path'); + $web_path = Config::get('web_path'); /* Pull the advanced information */ $data = $this->_get_extra_info(); @@ -251,7 +251,7 @@ class Album extends database_object { $this->f_title = $full_name; if ($this->artist_count == '1') { $artist = scrub_out(truncate_with_ellipsis(trim($this->artist_prefix . ' ' . $this->artist_name),Config::get('ellipse_threshold_artist'))); - $this->f_artist_link = "<a href=\"$web_path/artists.php?action=show&artist=" . $this->artist_id . "\" title=\"" . scrub_out($this->artist_name) . "\">" . $artist . "</a>"; + $this->f_artist_link = "<a href=\"$web_path/artists.php?action=show&artist=" . $this->artist_id . "\" title=\"" . scrub_out($this->artist_name) . "\">" . $artist . "</a>"; $this->f_artist = $artist; } else { @@ -312,7 +312,7 @@ class Album extends database_object { /* Attempt to retrive the album art order */ $config_value = Config::get('album_art_order'); - $class_methods = get_class_methods('Album'); + $class_methods = get_class_methods('Album'); /* If it's not set */ if (empty($config_value)) { @@ -465,7 +465,7 @@ class Album extends database_object { foreach ($this->_songs as $song_id) { $song = new Song($song_id); // If we find a good one, stop looking - $getID3 = new getID3(); + $getID3 = new getID3(); try { $id3 = $getID3->analyze($song->file); } catch (Exception $error) { debug_event('getid3',$error->message,'1'); @@ -520,15 +520,15 @@ class Album extends database_object { debug_event('folder_art',"Opening $dir and checking for Album Art",'3'); /* Open up the directory */ - $handle = @opendir($dir); + $handle = @opendir($dir); - if (!is_resource($handle)) { + if (!is_resource($handle)) { Error::add('general',_('Error: Unable to open') . ' ' . $dir); debug_event('read',"Error: Unable to open $dir for album art read",'2'); - } + } - /* Recurse through this dir and create the files array */ - while ( FALSE !== ($file = @readdir($handle)) ) { + /* Recurse through this dir and create the files array */ + while ( FALSE !== ($file = @readdir($handle)) ) { $extension = substr($file,strlen($file)-3,4); /* If it's an image file */ @@ -618,8 +618,8 @@ class Album extends database_object { */ public function get_musicbrainz_art($limit='') { $images = array(); - $num_found = 0; - $mbquery = new MusicBrainzQuery(); + $num_found = 0; + $mbquery = new MusicBrainzQuery(); if ($this->mbid) { debug_event('mbz-gatherart', "Album MBID: " . $this->mbid, '5'); @@ -674,60 +674,60 @@ class Album extends database_object { // The next bit is based directly on the MusicBrainz server code that displays cover art. // I'm leaving in the releaseuri info for the moment, though it's not going to be used. $coverartsites[] = array( - name => "CD Baby", - domain => "cdbaby.com", - regexp => '@http://cdbaby\.com/cd/(\w)(\w)(\w*)@', - imguri => 'http://cdbaby.name/$matches[1]/$matches[2]/$matches[1]$matches[2]$matches[3].jpg', - releaseuri => 'http://cdbaby.com/cd/$matches[1]$matches[2]$matches[3]/from/musicbrainz', + name => "CD Baby", + domain => "cdbaby.com", + regexp => '@http://cdbaby\.com/cd/(\w)(\w)(\w*)@', + imguri => 'http://cdbaby.name/$matches[1]/$matches[2]/$matches[1]$matches[2]$matches[3].jpg', + releaseuri => 'http://cdbaby.com/cd/$matches[1]$matches[2]$matches[3]/from/musicbrainz', ); $coverartsites[] = array( - name => "CD Baby", - domain => "cdbaby.name", - regexp => "@http://cdbaby\.name/([a-z0-9])/([a-z0-9])/([A-Za-z0-9]*).jpg@", - imguri => 'http://cdbaby.name/$matches[1]/$matches[2]/$matches[3].jpg', - releaseuri => 'http://cdbaby.com/cd/$matches[3]/from/musicbrainz', + name => "CD Baby", + domain => "cdbaby.name", + regexp => "@http://cdbaby\.name/([a-z0-9])/([a-z0-9])/([A-Za-z0-9]*).jpg@", + imguri => 'http://cdbaby.name/$matches[1]/$matches[2]/$matches[3].jpg', + releaseuri => 'http://cdbaby.com/cd/$matches[3]/from/musicbrainz', ); $coverartsites[] = array( - name => 'archive.org', - domain => 'archive.org', - regexp => '/^(.*\.(jpg|jpeg|png|gif))$/', - imguri => '$matches[1]', - releaseuri => '', + name => 'archive.org', + domain => 'archive.org', + regexp => '/^(.*\.(jpg|jpeg|png|gif))$/', + imguri => '$matches[1]', + releaseuri => '', ); $coverartsites[] = array( - name => "Jamendo", - domain => "www.jamendo.com", - regexp => '/http://www\.jamendo\.com/(\w\w/)?album/(\d+)/', - imguri => 'http://img.jamendo.com/albums/$matches[2]/covers/1.200.jpg', - releaseuri => 'http://www.jamendo.com/album/$matches[2]', + name => "Jamendo", + domain => "www.jamendo.com", + regexp => '/http://www\.jamendo\.com/(\w\w/)?album/(\d+)/', + imguri => 'http://img.jamendo.com/albums/$matches[2]/covers/1.200.jpg', + releaseuri => 'http://www.jamendo.com/album/$matches[2]', ); $coverartsites[] = array( - name => '8bitpeoples.com', - domain => '8bitpeoples.com', - regexp => '/^(.*)$/', - imguri => '$matches[1]', - releaseuri => '', + name => '8bitpeoples.com', + domain => '8bitpeoples.com', + regexp => '/^(.*)$/', + imguri => '$matches[1]', + releaseuri => '', ); $coverartsites[] = array( - name => 'Encyclopédisque', - domain => 'encyclopedisque.fr', - regexp => '/http://www.encyclopedisque.fr/images/imgdb/(thumb250|main)/(\d+).jpg/', - imguri => 'http://www.encyclopedisque.fr/images/imgdb/thumb250/$matches[2].jpg', - releaseuri => 'http://www.encyclopedisque.fr/', + name => 'Encyclopédisque', + domain => 'encyclopedisque.fr', + regexp => '/http://www.encyclopedisque.fr/images/imgdb/(thumb250|main)/(\d+).jpg/', + imguri => 'http://www.encyclopedisque.fr/images/imgdb/thumb250/$matches[2].jpg', + releaseuri => 'http://www.encyclopedisque.fr/', ); $coverartsites[] = array( - name => 'Thastrom', - domain => 'www.thastrom.se', - regexp => '/^(.*)$/', - imguri => '$matches[1]', - releaseuri => '', + name => 'Thastrom', + domain => 'www.thastrom.se', + regexp => '/^(.*)$/', + imguri => '$matches[1]', + releaseuri => '', ); $coverartsites[] = array( - name => 'Universal Poplab', - domain => 'www.universalpoplab.com', - regexp => '/^(.*)$/', - imguri => '$matches[1]', - releaseuri => '', + name => 'Universal Poplab', + domain => 'www.universalpoplab.com', + regexp => '/^(.*)$/', + imguri => '$matches[1]', + releaseuri => '', ); foreach ($release->getRelations($mbRelation->TO_URL) as $ar) { @@ -781,23 +781,23 @@ class Album extends database_object { /* Attempt to retrive the album art order */ $config_value = Config::get('amazon_base_urls'); - + /* If it's not set */ if (empty($config_value)) { $amazon_base_urls = array('http://webservices.amazon.com'); } elseif (!is_array($config_value)) { - array_push($amazon_base_urls,$config_value); + array_push($amazon_base_urls,$config_value); } else { $amazon_base_urls = array_merge($amazon_base_urls, Config::get('amazon_base_urls')); } - /* Foreach through the base urls that we should check */ - foreach ($amazon_base_urls AS $amazon_base) { + /* Foreach through the base urls that we should check */ + foreach ($amazon_base_urls AS $amazon_base) { - // Create the Search Object - $amazon = new AmazonSearch(Config::get('amazon_developer_public_key'), Config::get('amazon_developer_private_key'), $amazon_base); + // Create the Search Object + $amazon = new AmazonSearch(Config::get('amazon_developer_public_key'), Config::get('amazon_developer_private_key'), $amazon_base); if(Config::get('proxy_host') AND Config::get('proxy_port')) { $proxyhost = Config::get('proxy_host'); $proxyport = Config::get('proxy_port'); @@ -882,7 +882,7 @@ class Album extends database_object { continue; } - $data['url'] = $result[$key]; + $data['url'] = $result[$key]; $data['mime'] = $mime; $images[] = $data; @@ -893,7 +893,7 @@ class Album extends database_object { } } - } // if we've got something + } // if we've got something return $images; @@ -990,12 +990,12 @@ class Album extends database_object { */ if (Config::get('demo_mode')) { return false; } - // Check for PHP:GD and if we have it make sure this image is of some size - if (function_exists('ImageCreateFromString')) { + // Check for PHP:GD and if we have it make sure this image is of some size + if (function_exists('ImageCreateFromString')) { $im = ImageCreateFromString($image); if (imagesx($im) <= 5 || imagesy($im) <= 5 || !$im) { - return false; - } + return false; + } } // if we have PHP:GD elseif (strlen($image) < 5) { return false; @@ -1004,12 +1004,12 @@ class Album extends database_object { // Default to image/jpeg as a guess if there is no passed mime type $mime = $mime ? $mime : 'image/jpeg'; - // Push the image into the database - $sql = "REPLACE INTO `album_data` SET `art` = '" . Dba::escape($image) . "'," . - " `art_mime` = '" . Dba::escape($mime) . "'" . - ", `album_id` = '$this->id'," . + // Push the image into the database + $sql = "REPLACE INTO `album_data` SET `art` = '" . Dba::escape($image) . "'," . + " `art_mime` = '" . Dba::escape($mime) . "'" . + ", `album_id` = '$this->id'," . "`thumb` = NULL, `thumb_mime`=NULL"; - $db_results = Dba::write($sql); + $db_results = Dba::write($sql); return true; @@ -1042,33 +1042,33 @@ class Album extends database_object { */ public static function get_random_albums($count=6) { - $sql = 'SELECT `id` FROM `album` ORDER BY RAND() LIMIT ' . ($count*2); - $db_results = Dba::read($sql); + $sql = 'SELECT `id` FROM `album` ORDER BY RAND() LIMIT ' . ($count*2); + $db_results = Dba::read($sql); - $in_sql = '`album_id` IN ('; + $in_sql = '`album_id` IN ('; - while ($row = Dba::fetch_assoc($db_results)) { - $in_sql .= "'" . $row['id'] . "',"; - $total++; - } + while ($row = Dba::fetch_assoc($db_results)) { + $in_sql .= "'" . $row['id'] . "',"; + $total++; + } - if ($total < $count) { return false; } + if ($total < $count) { return false; } - $in_sql = rtrim($in_sql,',') . ')'; + $in_sql = rtrim($in_sql,',') . ')'; - $sql = "SELECT `album_id`,ISNULL(`art`) AS `no_art` FROM `album_data` WHERE $in_sql"; - $db_results = Dba::read($sql); - $results = array(); + $sql = "SELECT `album_id`,ISNULL(`art`) AS `no_art` FROM `album_data` WHERE $in_sql"; + $db_results = Dba::read($sql); + $results = array(); - while ($row = Dba::fetch_assoc($db_results)) { - $results[$row['album_id']] = $row['no_art']; - } // end for + while ($row = Dba::fetch_assoc($db_results)) { + $results[$row['album_id']] = $row['no_art']; + } // end for - asort($results); - $albums = array_keys($results); - $results = array_slice($albums,0,$count); + asort($results); + $albums = array_keys($results); + $results = array_slice($albums,0,$count); - return $results; + return $results; } // get_random_albums @@ -1077,66 +1077,66 @@ class Album extends database_object { * This gets an image for the album art from a source as * defined in the passed array. Because we don't know where * its comming from we are a passed an array that can look like - * ['url'] = URL *** OPTIONAL *** - * ['file'] = FILENAME *** OPTIONAL *** - * ['raw'] = Actual Image data, already captured + * ['url'] = URL *** OPTIONAL *** + * ['file'] = FILENAME *** OPTIONAL *** + * ['raw'] = Actual Image data, already captured */ public static function get_image_from_source($data) { - // Already have the data, this often comes from id3tags - if (isset($data['raw'])) { - return $data['raw']; - } - - // If it came from the database - if (isset($data['db'])) { - // Repull it - $album_id = Dba::escape($data['db']); - $sql = "SELECT * FROM `album_data` WHERE `album_id`='$album_id'"; - $db_results = Dba::read($sql); - $row = Dba::fetch_assoc($db_results); - return $row['art']; - } // came from the db - - // Check to see if it's a URL - if (isset($data['url'])) { - $snoopy = new Snoopy(); + // Already have the data, this often comes from id3tags + if (isset($data['raw'])) { + return $data['raw']; + } + + // If it came from the database + if (isset($data['db'])) { + // Repull it + $album_id = Dba::escape($data['db']); + $sql = "SELECT * FROM `album_data` WHERE `album_id`='$album_id'"; + $db_results = Dba::read($sql); + $row = Dba::fetch_assoc($db_results); + return $row['art']; + } // came from the db + + // Check to see if it's a URL + if (isset($data['url'])) { + $snoopy = new Snoopy(); if(Config::get('proxy_host') AND Config::get('proxy_port')) { $snoopy->proxy_user = Config::get('proxy_host'); $snoopy->proxy_port = Config::get('proxy_port'); $snoopy->proxy_user = Config::get('proxy_user'); $snoopy->proxy_pass = Config::get('proxy_pass'); } - $snoopy->fetch($data['url']); - return $snoopy->results; - } - - // Check to see if it's a FILE - if (isset($data['file'])) { - $handle = fopen($data['file'],'rb'); - $image_data = fread($handle,filesize($data['file'])); - fclose($handle); - return $image_data; - } + $snoopy->fetch($data['url']); + return $snoopy->results; + } + + // Check to see if it's a FILE + if (isset($data['file'])) { + $handle = fopen($data['file'],'rb'); + $image_data = fread($handle,filesize($data['file'])); + fclose($handle); + return $image_data; + } - // Check to see if it is embedded in id3 of a song - if (isset($data['song'])) { - // If we find a good one, stop looking - $getID3 = new getID3(); - $id3 = $getID3->analyze($data['song']); + // Check to see if it is embedded in id3 of a song + if (isset($data['song'])) { + // If we find a good one, stop looking + $getID3 = new getID3(); + $id3 = $getID3->analyze($data['song']); - if ($id3['format_name'] == "WMA") { - return $id3['asf']['extended_content_description_object']['content_descriptors']['13']['data']; - } - elseif (isset($id3['id3v2']['APIC'])) { - // Foreach incase they have more then one - foreach ($id3['id3v2']['APIC'] as $image) { - return $image['data']; - } - } - } // if data song - - return false; + if ($id3['format_name'] == "WMA") { + return $id3['asf']['extended_content_description_object']['content_descriptors']['13']['data']; + } + elseif (isset($id3['id3v2']['APIC'])) { + // Foreach incase they have more then one + foreach ($id3['id3v2']['APIC'] as $image) { + return $image['data']; + } + } + } // if data song + + return false; } // get_image_from_source diff --git a/lib/class/ampacherss.class.php b/lib/class/ampacherss.class.php index 68dfcced..8276bf77 100644 --- a/lib/class/ampacherss.class.php +++ b/lib/class/ampacherss.class.php @@ -184,29 +184,29 @@ class AmpacheRSS { $song->format(); $amount = intval(time() - $item['date']+2); $time_place = '0'; - while ($amount >= 1) { - $final = $amount; - $time_place++; - if ($time_place <= 2) { - $amount = floor($amount/60); - } - if ($time_place == '3') { - $amount = floor($amount/24); - } - if ($time_place == '4') { - $amount = floor($amount/7); - } - if ($time_place == '5') { - $amount = floor($amount/4); - } - if ($time_place == '6') { - $amount = floor ($amount/12); - } - if ($time_place > '6') { - $final = $amount . '+'; - break; + while ($amount >= 1) { + $final = $amount; + $time_place++; + if ($time_place <= 2) { + $amount = floor($amount/60); + } + if ($time_place == '3') { + $amount = floor($amount/24); + } + if ($time_place == '4') { + $amount = floor($amount/7); + } + if ($time_place == '5') { + $amount = floor($amount/4); + } + if ($time_place == '6') { + $amount = floor ($amount/12); + } + if ($time_place > '6') { + $final = $amount . '+'; + break; } - } // end while + } // end while $time_string = $final . ' ' . $time_unit[$time_place]; diff --git a/lib/class/api.class.php b/lib/class/api.class.php index 0d6a8fd1..fecab380 100644 --- a/lib/class/api.class.php +++ b/lib/class/api.class.php @@ -51,15 +51,15 @@ class Api { switch ($filter) { case 'add': - // Check for a range, if no range default to gt - if (strpos('/',$value)) { - $elements = explode('/',$value); - Browse::set_filter('add_lt',strtotime($elements['1'])); - Browse::set_filter('add_gt',strtotime($elements['0'])); - } - else { - Browse::set_filter('add_gt',strtotime($value)); - } + // Check for a range, if no range default to gt + if (strpos('/',$value)) { + $elements = explode('/',$value); + Browse::set_filter('add_lt',strtotime($elements['1'])); + Browse::set_filter('add_gt',strtotime($elements['0'])); + } + else { + Browse::set_filter('add_gt',strtotime($value)); + } break; case 'update': // Check for a range, if no range default to gt @@ -222,8 +222,8 @@ class Api { // Check and see if we should extend the api sessions (done if valid sess is passed) if (vauth::session_exists('api', $input['auth'])) { - vauth::session_extend($input['auth']); - $xmldata = array_merge(array('session_expire'=>date("r",time()+Config::get('session_length')-60)),$xmldata); + vauth::session_extend($input['auth']); + $xmldata = array_merge(array('session_expire'=>date("r",time()+Config::get('session_length')-60)),$xmldata); } debug_event('API','Ping Received from ' . $_SERVER['REMOTE_ADDR'] . ' :: ' . $input['auth'],'5'); @@ -545,9 +545,9 @@ class Api { $items = $playlist->get_items(); foreach ($items as $object) { - if ($object['type'] == 'song') { - $songs[] = $object['object_id']; - } + if ($object['type'] == 'song') { + $songs[] = $object['object_id']; + } } // end foreach xmlData::set_offset($input['offset']); @@ -625,18 +625,18 @@ class Api { $localplay->connect(); switch ($input['command']) { - case 'next': - case 'prev': - case 'play': - case 'stop': - $result_status = $localplay->$input['command'](); - $xml_array = array('localplay'=>array('command'=>array($input['command']=>make_bool($result_status)))); - echo xmlData::keyed_array($xml_array); - break; - default: - // They are doing it wrong - echo xmlData::error('405',_('Invalid Request')); - break; + case 'next': + case 'prev': + case 'play': + case 'stop': + $result_status = $localplay->$input['command'](); + $xml_array = array('localplay'=>array('command'=>array($input['command']=>make_bool($result_status)))); + echo xmlData::keyed_array($xml_array); + break; + default: + // They are doing it wrong + echo xmlData::error('405',_('Invalid Request')); + break; } // end switch on command } // localplay @@ -652,45 +652,45 @@ class Api { $democratic->set_parent(); switch ($input['method']) { - case 'vote': - $type = 'song'; - $media = new $type($input['oid']); - if (!$media->id) { - echo xmlData::error('400',_('Media Object Invalid or Not Specified')); - break; - } - $democratic->vote(array(array('song',$media->id))); - - // If everything was ok - $xml_array = array('action'=>$input['action'],'method'=>$input['method'],'result'=>true); - echo xmlData::keyed_array($xml_array); - break; - case 'devote': - $type = 'song'; - $media = new $type($input['oid']); - if (!$media->id) { - echo xmlData::error('400',_('Media Object Invalid or Not Specified')); - } - - $uid = $democratic->get_uid_from_object_id($media->id,$type); - $democratic->remove_vote($uid); - - // Everything was ok - $xml_array = array('action'=>$input['action'],'method'=>$input['method'],'result'=>true); - echo xmlData::keyed_array($xml_array); - break; - case 'playlist': - $objects = $democratic->get_items(); - Song::build_cache($democratic->object_ids); - Democratic::build_vote_cache($democratic->vote_ids); - xmlData::democratic($objects); - break; - case 'play': - $url = $democratic->play_url(); + case 'vote': + $type = 'song'; + $media = new $type($input['oid']); + if (!$media->id) { + echo xmlData::error('400',_('Media Object Invalid or Not Specified')); + break; + } + $democratic->vote(array(array('song',$media->id))); + + // If everything was ok + $xml_array = array('action'=>$input['action'],'method'=>$input['method'],'result'=>true); + echo xmlData::keyed_array($xml_array); + break; + case 'devote': + $type = 'song'; + $media = new $type($input['oid']); + if (!$media->id) { + echo xmlData::error('400',_('Media Object Invalid or Not Specified')); + } + + $uid = $democratic->get_uid_from_object_id($media->id,$type); + $democratic->remove_vote($uid); + + // Everything was ok + $xml_array = array('action'=>$input['action'],'method'=>$input['method'],'result'=>true); + echo xmlData::keyed_array($xml_array); + break; + case 'playlist': + $objects = $democratic->get_items(); + Song::build_cache($democratic->object_ids); + Democratic::build_vote_cache($democratic->vote_ids); + xmlData::democratic($objects); + break; + case 'play': + $url = $democratic->play_url(); $xml_array = array('url'=>$url); echo xmlData::keyed_array($xml_array); - break; - default: + break; + default: echo xmlData::error('405',_('Invalid Request')); break; } // switch on method diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index ad2b9f14..a0ca2ad3 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -93,9 +93,9 @@ class Artist extends database_object { // If we need to also pull the extra information, this is normally only used when we are doing the human display if ($extra) { - $sql = "SELECT `song`.`artist`, COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` " . - "WHERE `song`.`artist` IN $idlist GROUP BY `song`.`artist`"; - $db_results = Dba::read($sql); + $sql = "SELECT `song`.`artist`, COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` " . + "WHERE `song`.`artist` IN $idlist GROUP BY `song`.`artist`"; + $db_results = Dba::read($sql); while ($row = Dba::fetch_assoc($db_results)) { parent::add_to_cache('artist_extra',$row['artist'],$row); @@ -163,24 +163,24 @@ class Artist extends database_object { } // get_songs - /** - * get_random_songs + /** + * get_random_songs * Gets the songs from this artist in a random order - */ - public function get_random_songs() { + */ + public function get_random_songs() { - $results = array(); + $results = array(); - $sql = "SELECT `id` FROM `song` WHERE `artist`='$this->id' ORDER BY RAND()"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `song` WHERE `artist`='$this->id' ORDER BY RAND()"; + $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { - $results[] = $r['id']; - } + while ($r = Dba::fetch_assoc($db_results)) { + $results[] = $r['id']; + } - return $results; + return $results; - } // get_random_songs + } // get_random_songs /** * _get_extra info @@ -212,7 +212,7 @@ class Artist extends database_object { /** * format - * this function takes an array of artist + * this function takes an array of artist * information and reformats the relevent values * so they can be displayed in a table for example * it changes the title into a full link. @@ -220,14 +220,14 @@ class Artist extends database_object { public function format() { /* Combine prefix and name, trim then add ... if needed */ - $name = truncate_with_ellipsis(trim($this->prefix . " " . $this->name),Config::get('ellipse_threshold_artist')); + $name = truncate_with_ellipsis(trim($this->prefix . " " . $this->name),Config::get('ellipse_threshold_artist')); $this->f_name = $name; $this->f_full_name = trim($this->prefix . " " . $this->name); // If this is a fake object, we're done here if ($this->_fake) { return true; } - $this->f_name_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&artist=" . $this->id . "\" title=\"" . $this->full_name . "\">" . $name . "</a>"; + $this->f_name_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&artist=" . $this->id . "\" title=\"" . $this->full_name . "\">" . $name . "</a>"; $this->f_link = Config::get('web_path') . '/artists.php?action=show&artist=' . $this->id; // Get the counts diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index 8b145e48..8a176bb0 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -156,7 +156,7 @@ class Browse extends Query { } // Set the correct classes based on type - $class = "box browse_".self::$type; + $class = "box browse_".self::$type; Ajax::start_container('browse_content'); // Switch on the type of browsing we're doing @@ -263,22 +263,25 @@ class Browse extends Query { * //FIXME */ public static function set_filter_from_request($r) { - foreach ($r as $k=>$v) { - //reinterpret v as a list of int - $vl = explode(',', $v); - $ok = 1; - foreach($vl as $i) { - if (!is_numeric($i)) { - $ok = 0; - break; - } - } - if ($ok) - if (sizeof($vl) == 1) - self::set_filter($k, $vl[0]); - else - self::set_filter($k, $vl); - } + foreach($r as $k=>$v) { + //reinterpret v as a list of int + $vl = explode(',', $v); + $ok = 1; + foreach($vl as $i) { + if (!is_numeric($i)) { + $ok = 0; + break; + } + } + if ($ok) { + if (sizeof($vl) == 1) { + self::set_filter($k, $vl[0]); + } + } + else { + self::set_filter($k, $vl); + } + } } // set_filter_from_request } // browse diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 3c3b8b40..f9b3325b 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -208,15 +208,15 @@ class Catalog extends database_object { // presentation we do not care about less than 0.01 MB. // $sizeStr = (string)$results['size']; - if ( strlen( $sizeStr ) > 3 ) { + if ( strlen( $sizeStr ) > 3 ) { $size = (int)substr( $sizeStr, 0, -3 ); - } - else { + } + else { $size = 0; - } + } // Now go to MB's, applying a correction for KB first. - // - $size = ($size / 1.024) / 1024; + // + $size = ($size / 1.024) / 1024; $size = $results['size']/1048576; $days = floor($hours/24); @@ -348,11 +348,11 @@ class Catalog extends database_object { $this->get_album_art('',1); } - if ($options['parse_m3u'] AND count($this->_playlists)) { - foreach ($this->_playlists as $playlist_file) { - $result = $this->import_m3u($playlist_file); - } - } // if we need to do some m3u-age + if ($options['parse_m3u'] AND count($this->_playlists)) { + foreach ($this->_playlists as $playlist_file) { + $result = $this->import_m3u($playlist_file); + } + } // if we need to do some m3u-age return true; @@ -442,9 +442,9 @@ class Catalog extends database_object { $time = time(); $last_seen_time = $time - 1200; $sql = "SELECT count(DISTINCT s.username) FROM session AS s " . - "INNER JOIN user AS u ON s.username = u.username " . - "WHERE s.expire > " . $time . " " . - "AND u.last_seen > " . $last_seen_time; + "INNER JOIN user AS u ON s.username = u.username " . + "WHERE s.expire > " . $time . " " . + "AND u.last_seen > " . $last_seen_time; $db_results = Dba::read($sql); $data = Dba::fetch_row($db_results); @@ -831,7 +831,7 @@ class Catalog extends database_object { // Setup the base SQL $sql = "SELECT song.id AS song,artist.id AS artist,album.id AS album,title,COUNT(title) AS ctitle". - " FROM `song` LEFT JOIN `artist` ON `artist`.`id`=`song`.`artist` " . + " FROM `song` LEFT JOIN `artist` ON `artist`.`id`=`song`.`artist` " . " LEFT JOIN `album` ON `album`.`id`=`song`.`album` $where_sql GROUP BY `song`.`title`"; // Add any Additional constraints @@ -868,9 +868,9 @@ class Catalog extends database_object { public static function get_duplicate_info($item,$search_type) { // Build the SQL $sql = "SELECT `song`.`id`" . - " FROM song,artist,album". - " WHERE song.artist=artist.id AND song.album=album.id". - " AND song.title= '".Dba::escape($item['title'])."'"; + " FROM song,artist,album". + " WHERE song.artist=artist.id AND song.album=album.id". + " AND song.title= '".Dba::escape($item['title'])."'"; if ($search_type == "artist_title" || $search_type == "artist_album_title") { $sql .=" AND artist.id = '".Dba::escape($item['artist'])."'"; @@ -1128,46 +1128,46 @@ class Catalog extends database_object { } // update_video_from_tags - /** - * update_song_from_tags - * updates the song info based on tags, this is called from a bunch of different places + /** + * update_song_from_tags + * updates the song info based on tags, this is called from a bunch of different places * and passes in a full fledged song object, so it's a static function * FIXME: This is an ugly mess, this really needs to be consolidated and cleaned up */ - public static function update_song_from_tags($results,$song) { + public static function update_song_from_tags($results,$song) { - /* Setup the vars */ + /* Setup the vars */ $new_song = new Song(); - $new_song->file = $results['file']; - $new_song->title = $results['title']; - $new_song->year = $results['year']; - $new_song->comment = $results['comment']; + $new_song->file = $results['file']; + $new_song->title = $results['title']; + $new_song->year = $results['year']; + $new_song->comment = $results['comment']; $new_song->language = $results['language']; $new_song->lyrics = $results['lyrics']; - $new_song->bitrate = $results['bitrate']; - $new_song->rate = $results['rate']; - $new_song->mode = ($results['mode'] == 'cbr') ? 'cbr' : 'vbr'; - $new_song->size = $results['size']; - $new_song->time = $results['time']; + $new_song->bitrate = $results['bitrate']; + $new_song->rate = $results['rate']; + $new_song->mode = ($results['mode'] == 'cbr') ? 'cbr' : 'vbr'; + $new_song->size = $results['size']; + $new_song->time = $results['time']; $new_song->mime = $results['mime']; - $new_song->track = intval($results['track']); + $new_song->track = intval($results['track']); $new_song->mbid = $results['mb_trackid']; - $artist = $results['artist']; + $artist = $results['artist']; $artist_mbid = $results['mb_artistid']; - $album = $results['album']; + $album = $results['album']; $album_mbid = $results['mb_albumid']; $disk = $results['disk']; $tags = $results['genre']; // multiple genre support makes this an array - /* - * We have the artist/genre/album name need to check it in the tables - * If found then add & return id, else return id - */ - $new_song->artist = self::check_artist($artist,$artist_mbid); - $new_song->f_artist = $artist; - $new_song->album = self::check_album($album,$new_song->year,$disk,$album_mbid); - $new_song->f_album = $album . " - " . $new_song->year; - $new_song->title = self::check_title($new_song->title,$new_song->file); + /* + * We have the artist/genre/album name need to check it in the tables + * If found then add & return id, else return id + */ + $new_song->artist = self::check_artist($artist,$artist_mbid); + $new_song->f_artist = $artist; + $new_song->album = self::check_album($album,$new_song->year,$disk,$album_mbid); + $new_song->f_album = $album . " - " . $new_song->year; + $new_song->title = self::check_title($new_song->title,$new_song->file); // Nothing to assign here this is a multi-value doodly // multiple genre support @@ -1404,8 +1404,8 @@ class Catalog extends database_object { public function get_remote_album_images($client,$token,$path) { $encoded_key = new XML_RPC_Value($token,'string'); - $query_array = array($encoded_key); - $xmlrpc_message = new XML_RPC_Message('xmlrpcserver.get_album_images',$query_array); + $query_array = array($encoded_key); + $xmlrpc_message = new XML_RPC_Message('xmlrpcserver.get_album_images',$query_array); /* Depending upon the size of the target catalog this can be a very slow/long process */ set_time_limit(0); @@ -1683,11 +1683,11 @@ class Catalog extends database_object { $db_results = Dba::write($sql); $sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `album` ON `album`.`id`=`tag_map`.`object_id` " . - "WHERE `tag_map`.`object_type`='album' AND `album`.`id` IS NULL"; + "WHERE `tag_map`.`object_type`='album' AND `album`.`id` IS NULL"; $db_results = Dba::write($sql); $sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `artist` ON `artist`.`id`=`tag_map`.`object_id` " . - "WHERE `tag_map`.`object_type`='artist' AND `artist`.`id` IS NULL"; + "WHERE `tag_map`.`object_type`='artist' AND `artist`.`id` IS NULL"; $db_results = Dba::write($sql); $sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `video` ON `video`.`id`=`tag_map`.`object_id` " . @@ -1714,12 +1714,12 @@ class Catalog extends database_object { // Clean albums $sql = "DELETE FROM `user_shout` USING `user_shout` LEFT JOIN `album` ON `album`.`id`=`user_shout`.`object_id` " . - "WHERE `album`.`id` IS NULL AND `user_shout`.`object_type`='album'"; + "WHERE `album`.`id` IS NULL AND `user_shout`.`object_type`='album'"; $db_results = Dba::write($sql); // Clean artists $sql = "DELETE FROM `user_shout` USING `user_shout` LEFT JOIN `artist` ON `artist`.`id`=`user_shout`.`object_id` " . - "WHERE `artist`.`id` IS NULL AND `user_shout`.`object_type`='artist'"; + "WHERE `artist`.`id` IS NULL AND `user_shout`.`object_type`='artist'"; $db_results = Dba::write($sql); @@ -2021,7 +2021,7 @@ class Catalog extends database_object { $db_results = Dba::write($sql); $sql = "ANALYZE TABLE `song_data`,`song`,`rating`,`catalog`,`session`,`object_count`,`album`,`album_data`" . - ",`artist`,`ip_history`,`flagged`,`now_playing`,`user_preference`,`tag`,`tag_map`,`tmp_playlist`" . + ",`artist`,`ip_history`,`flagged`,`now_playing`,`user_preference`,`tag`,`tag_map`,`tmp_playlist`" . ",`tmp_playlist_data`,`playlist`,`playlist_data`,`session_stream`,`video`"; $db_results = Dba::write($sql); @@ -2093,8 +2093,8 @@ class Catalog extends database_object { $sql = "UPDATE `artist` SET `mbid`='$mbid' WHERE `id`='$artist_id'"; $db_results = Dba::write($sql); if (!$db_results) { - Error::add('general',"Updating Artist: $artist"); - } + Error::add('general',"Updating Artist: $artist"); + } } } unset($id_array); @@ -2352,9 +2352,9 @@ class Catalog extends database_object { */ public function insert_local_video($file,$filesize) { - /* Create the vainfo object and get info */ - $vainfo = new vainfo($file,'','','',$this->sort_pattern,$this->rename_pattern); - $vainfo->get_info(); + /* Create the vainfo object and get info */ + $vainfo = new vainfo($file,'','','',$this->sort_pattern,$this->rename_pattern); + $vainfo->get_info(); $tag_name = vainfo::get_tag_type($vainfo->tags); $results = vainfo::clean_tag_info($vainfo->tags,$tag_name,$file); @@ -2438,12 +2438,12 @@ class Catalog extends database_object { $client = new XML_RPC_Client($full_url,$server,$port,$proxy_host,$proxy_port,$proxy_user,$proxy_pass); /* encode the variables we need to send over */ - $encoded_key = new XML_RPC_Value($token,'string'); - $encoded_path = new XML_RPC_Value(Config::get('web_path'),'string'); - $song_id = new XML_RPC_Value($value,'int'); + $encoded_key = new XML_RPC_Value($token,'string'); + $encoded_path = new XML_RPC_Value(Config::get('web_path'),'string'); + $song_id = new XML_RPC_Value($value,'int'); - $xmlrpc_message = new XML_RPC_Message('xmlrpcserver.check_song', array($song_id,$encoded_key,$encoded_path)); - $response = $client->send($xmlrpc_message,30); + $xmlrpc_message = new XML_RPC_Message('xmlrpcserver.check_song', array($song_id,$encoded_key,$encoded_path)); + $response = $client->send($xmlrpc_message,30); if ($response->faultCode() ) { $error_msg = _("Error connecting to") . " " . $server . " " . _("Code") . ": " . $response->faultCode() . " " . _("Reason") . ": " . $response->faultString(); diff --git a/lib/class/database_object.abstract.php b/lib/class/database_object.abstract.php index e0ccc1bf..1bb368d6 100644 --- a/lib/class/database_object.abstract.php +++ b/lib/class/database_object.abstract.php @@ -119,14 +119,14 @@ abstract class database_object { } // remove_from_cache - /** - * _auto_init - * Load in the cache settings once so we can avoid function calls - */ - public static function _auto_init() { + /** + * _auto_init + * Load in the cache settings once so we can avoid function calls + */ + public static function _auto_init() { - self::$_enabled = Config::get('memory_cache'); + self::$_enabled = Config::get('memory_cache'); - } // _auto_init + } // _auto_init } // end database_object diff --git a/lib/class/democratic.class.php b/lib/class/democratic.class.php index e7efda0f..4d592b0b 100644 --- a/lib/class/democratic.class.php +++ b/lib/class/democratic.class.php @@ -208,11 +208,11 @@ class Democratic extends tmpPlaylist { } // get_current_playlist - /** - * get_items - * This returns an array of all object_ids currently in this tmpPlaylist. This - * has gotten a little more complicated because of type, the values are an array - * 0 being ID 1 being TYPE + /** + * get_items + * This returns an array of all object_ids currently in this tmpPlaylist. This + * has gotten a little more complicated because of type, the values are an array + * 0 being ID 1 being TYPE * FIXME: This is too complex, it makes my brain hurt * [VOTE COUNT] * [DATE OF NEWEST VOTE] @@ -223,25 +223,25 @@ class Democratic extends tmpPlaylist { * Sorting does the following * sort largest VOTE COUNT to top * sort smallest DATE OF NEWEST VOTE] - */ - public function get_items() { + */ + public function get_items() { - $order = "ORDER BY `user_vote`.`date` ASC, `tmp_playlist_data`.`track` ASC"; - $vote_join = "INNER JOIN `user_vote` ON `user_vote`.`object_id`=`tmp_playlist_data`.`id`"; + $order = "ORDER BY `user_vote`.`date` ASC, `tmp_playlist_data`.`track` ASC"; + $vote_join = "INNER JOIN `user_vote` ON `user_vote`.`object_id`=`tmp_playlist_data`.`id`"; - /* Select all objects from this playlist */ - $sql = "SELECT `user_vote`.`object_id` AS `vote_id`,`user_vote`.`user`,`tmp_playlist_data`.`id`,`tmp_playlist_data`.`object_type`, `user_vote`.`date`, `tmp_playlist_data`.`object_id` " . - "FROM `tmp_playlist_data` $vote_join " . - "WHERE `tmp_playlist_data`.`tmp_playlist`='" . Dba::escape($this->tmp_playlist) . "' $order"; - $db_results = Dba::read($sql); + /* Select all objects from this playlist */ + $sql = "SELECT `user_vote`.`object_id` AS `vote_id`,`user_vote`.`user`,`tmp_playlist_data`.`id`,`tmp_playlist_data`.`object_type`, `user_vote`.`date`, `tmp_playlist_data`.`object_id` " . + "FROM `tmp_playlist_data` $vote_join " . + "WHERE `tmp_playlist_data`.`tmp_playlist`='" . Dba::escape($this->tmp_playlist) . "' $order"; + $db_results = Dba::read($sql); - /* Define the array */ - $items = array(); + /* Define the array */ + $items = array(); $votes = array(); $object_ids = array(); // Itterate and build the sortable array - while ($results = Dba::fetch_assoc($db_results)) { + while ($results = Dba::fetch_assoc($db_results)) { // Extra set of data for caching! $this->object_ids[] = $results['object_id']; @@ -261,7 +261,7 @@ class Democratic extends tmpPlaylist { $primary_key = ${$name}; $secondary_key = $votes[$results['object_id']]; $items[$primary_key][$secondary_key][$results['id']] = array('object_id'=>$results['object_id'],'object_type'=>$results['object_type'],'id'=>$results['id']); - } // gather data + } // gather data // Sort highest voted stuff to the top krsort($items); @@ -278,30 +278,30 @@ class Democratic extends tmpPlaylist { } } - return $sorted_items; + return $sorted_items; - } // get_items + } // get_items - /** - * play_url - * This returns the special play URL for democratic play, only open to ADMINs - */ - public function play_url() { + /** + * play_url + * This returns the special play URL for democratic play, only open to ADMINs + */ + public function play_url() { - $link = Stream::get_base_url() . 'uid=' . scrub_out($GLOBALS['user']->id) . '&demo_id=' . scrub_out($this->id); + $link = Stream::get_base_url() . 'uid=' . scrub_out($GLOBALS['user']->id) . '&demo_id=' . scrub_out($this->id); - return $link; + return $link; - } // play_url + } // play_url - /** - * get_next_object - * This returns the next object in the tmp_playlist most of the time this - * will just be the top entry, but if there is a base_playlist and no - * items in the playlist then it returns a random entry from the base_playlist - */ - public function get_next_object($offset='') { - + /** + * get_next_object + * This returns the next object in the tmp_playlist most of the time this + * will just be the top entry, but if there is a base_playlist and no + * items in the playlist then it returns a random entry from the base_playlist + */ + public function get_next_object($offset='') { + $offset = $offset ? intval($offset) : '0'; // We have to get all because of the pysco sorting @@ -313,26 +313,26 @@ class Democratic extends tmpPlaylist { $results['object_id'] = $item['object_id']; } - /* If nothing was found and this is a voting playlist then get from base_playlist */ - if (!$results['object_id']) { + /* If nothing was found and this is a voting playlist then get from base_playlist */ + if (!$results['object_id']) { - /* Check for a playlist */ - if ($this->base_playlist) { - /* We need to pull a random one from the base_playlist */ - $base_playlist = new Playlist($this->base_playlist); + /* Check for a playlist */ + if ($this->base_playlist) { + /* We need to pull a random one from the base_playlist */ + $base_playlist = new Playlist($this->base_playlist); $data = $base_playlist->get_random_items(1); - $results['object_id'] = $data['0']['object_id']; - } - else { - $sql = "SELECT `id` as `object_id` FROM `song` WHERE `enabled`='1' ORDER BY RAND() LIMIT 1"; - $db_results = Dba::read($sql); - $results = Dba::fetch_assoc($db_results); - } - } + $results['object_id'] = $data['0']['object_id']; + } + else { + $sql = "SELECT `id` as `object_id` FROM `song` WHERE `enabled`='1' ORDER BY RAND() LIMIT 1"; + $db_results = Dba::read($sql); + $results = Dba::fetch_assoc($db_results); + } + } - return $results['object_id']; + return $results['object_id']; - } // get_next_object + } // get_next_object /** * get_uid_from_object_id @@ -371,108 +371,108 @@ class Democratic extends tmpPlaylist { } // get_cool_songs /** - * vote - * This function is called by users to vote on a system wide playlist - * This adds the specified objects to the tmp_playlist and adds a 'vote' - * by this user, naturally it checks to make sure that the user hasn't - * already voted on any of these objects - */ - public function vote($items) { - - /* Itterate through the objects if no vote, add to playlist and vote */ - foreach ($items as $element) { + * vote + * This function is called by users to vote on a system wide playlist + * This adds the specified objects to the tmp_playlist and adds a 'vote' + * by this user, naturally it checks to make sure that the user hasn't + * already voted on any of these objects + */ + public function vote($items) { + + /* Itterate through the objects if no vote, add to playlist and vote */ + foreach ($items as $element) { $type = array_shift($element); $object_id = array_shift($element); - if (!$this->has_vote($object_id,$type)) { - $this->add_vote($object_id,$type); - } - } // end foreach + if (!$this->has_vote($object_id,$type)) { + $this->add_vote($object_id,$type); + } + } // end foreach - } // vote + } // vote - /** - * has_vote - * This checks to see if the current user has already voted on this object - */ - public function has_vote($object_id,$type='') { + /** + * has_vote + * This checks to see if the current user has already voted on this object + */ + public function has_vote($object_id,$type='') { - $tmp_id = Dba::escape($this->tmp_playlist); + $tmp_id = Dba::escape($this->tmp_playlist); $object_id = Dba::escape($object_id); $type = $type ? Dba::escape($type) : 'song'; $user_id = Dba::escape($GLOBALS['user']->id); - /* Query vote table */ - $sql = "SELECT tmp_playlist_data.object_id FROM `user_vote` " . - "INNER JOIN tmp_playlist_data ON tmp_playlist_data.id=user_vote.object_id " . - "WHERE user_vote.user='$user_id' AND tmp_playlist_data.object_type='$type' " . - "AND tmp_playlist_data.object_id='$object_id' " . - "AND tmp_playlist_data.tmp_playlist='$tmp_id'"; - $db_results = Dba::read($sql); - - /* If we find row, they've voted!! */ - if (Dba::num_rows($db_results)) { - return true; - } - - return false; - - } // has_vote - - /** - * add_vote - * This takes a object id and user and actually inserts the row - */ - public function add_vote($object_id,$object_type='') { - - $object_id = Dba::escape($object_id); - $tmp_playlist = Dba::escape($this->tmp_playlist); + /* Query vote table */ + $sql = "SELECT tmp_playlist_data.object_id FROM `user_vote` " . + "INNER JOIN tmp_playlist_data ON tmp_playlist_data.id=user_vote.object_id " . + "WHERE user_vote.user='$user_id' AND tmp_playlist_data.object_type='$type' " . + "AND tmp_playlist_data.object_id='$object_id' " . + "AND tmp_playlist_data.tmp_playlist='$tmp_id'"; + $db_results = Dba::read($sql); + + /* If we find row, they've voted!! */ + if (Dba::num_rows($db_results)) { + return true; + } + + return false; + + } // has_vote + + /** + * add_vote + * This takes a object id and user and actually inserts the row + */ + public function add_vote($object_id,$object_type='') { + + $object_id = Dba::escape($object_id); + $tmp_playlist = Dba::escape($this->tmp_playlist); $object_type = $object_type ? Dba::escape($object_type) : 'song'; $media = new $object_type($object_id); $track = isset($media->track) ? "'" . intval($media->track) . "'" : "NULL"; - - /* If it's on the playlist just vote */ - $sql = "SELECT `id` FROM `tmp_playlist_data` " . - "WHERE `tmp_playlist_data`.`object_id`='$object_id' AND `tmp_playlist_data`.`tmp_playlist`='$tmp_playlist'"; - $db_results = Dba::write($sql); - - /* If it's not there, add it and pull ID */ - if (!$results = Dba::fetch_assoc($db_results)) { - $sql = "INSERT INTO `tmp_playlist_data` (`tmp_playlist`,`object_id`,`object_type`,`track`) " . - "VALUES ('$tmp_playlist','$object_id','$object_type',$track)"; - $db_results = Dba::write($sql); - $results['id'] = Dba::insert_id(); - } - - /* Vote! */ - $time = time(); - $sql = "INSERT INTO user_vote (`user`,`object_id`,`date`) " . - "VALUES ('" . Dba::escape($GLOBALS['user']->id) . "','" . $results['id'] . "','$time')"; - $db_results = Dba::write($sql); - - return true; - - } // add_vote - - /** - * remove_vote - * This is called to remove a vote by a user for an object, it uses the object_id - * As that's what we'll have most the time, no need to check if they've got an existing - * vote for this, just remove anything that is there - */ - public function remove_vote($row_id) { - - $object_id = Dba::escape($row_id); - $user_id = Dba::escape($GLOBALS['user']->id); + + /* If it's on the playlist just vote */ + $sql = "SELECT `id` FROM `tmp_playlist_data` " . + "WHERE `tmp_playlist_data`.`object_id`='$object_id' AND `tmp_playlist_data`.`tmp_playlist`='$tmp_playlist'"; + $db_results = Dba::write($sql); + + /* If it's not there, add it and pull ID */ + if (!$results = Dba::fetch_assoc($db_results)) { + $sql = "INSERT INTO `tmp_playlist_data` (`tmp_playlist`,`object_id`,`object_type`,`track`) " . + "VALUES ('$tmp_playlist','$object_id','$object_type',$track)"; + $db_results = Dba::write($sql); + $results['id'] = Dba::insert_id(); + } + + /* Vote! */ + $time = time(); + $sql = "INSERT INTO user_vote (`user`,`object_id`,`date`) " . + "VALUES ('" . Dba::escape($GLOBALS['user']->id) . "','" . $results['id'] . "','$time')"; + $db_results = Dba::write($sql); + + return true; + + } // add_vote + + /** + * remove_vote + * This is called to remove a vote by a user for an object, it uses the object_id + * As that's what we'll have most the time, no need to check if they've got an existing + * vote for this, just remove anything that is there + */ + public function remove_vote($row_id) { + + $object_id = Dba::escape($row_id); + $user_id = Dba::escape($GLOBALS['user']->id); $sql = "DELETE FROM `user_vote` WHERE `object_id`='$object_id' AND `user`='$user_id'"; - $db_results = Dba::write($sql); + $db_results = Dba::write($sql); - /* Clean up anything that has no votes */ - self::prune_tracks(); + /* Clean up anything that has no votes */ + self::prune_tracks(); - return true; + return true; - } // remove_vote + } // remove_vote /** * delete_votes @@ -564,41 +564,41 @@ class Democratic extends tmpPlaylist { */ public static function prune_tracks() { - // This deletes data without votes, if it's a voting democratic playlist - $sql = "DELETE FROM `tmp_playlist_data` USING `tmp_playlist_data` " . - "LEFT JOIN `user_vote` ON `tmp_playlist_data`.`id`=`user_vote`.`object_id` " . - "LEFT JOIN `tmp_playlist` ON `tmp_playlist`.`id`=`tmp_playlist_data`.`tmp_playlist` " . - "WHERE `user_vote`.`object_id` IS NULL AND `tmp_playlist`.`type` = 'vote'"; - $db_results = Dba::write($sql); + // This deletes data without votes, if it's a voting democratic playlist + $sql = "DELETE FROM `tmp_playlist_data` USING `tmp_playlist_data` " . + "LEFT JOIN `user_vote` ON `tmp_playlist_data`.`id`=`user_vote`.`object_id` " . + "LEFT JOIN `tmp_playlist` ON `tmp_playlist`.`id`=`tmp_playlist_data`.`tmp_playlist` " . + "WHERE `user_vote`.`object_id` IS NULL AND `tmp_playlist`.`type` = 'vote'"; + $db_results = Dba::write($sql); - return true; + return true; } // prune_tracks - /** - * clear - * This is really just a wrapper function, it clears the entire playlist - * including all votes etc. - */ - public function clear() { + /** + * clear + * This is really just a wrapper function, it clears the entire playlist + * including all votes etc. + */ + public function clear() { - $tmp_id = Dba::escape($this->tmp_playlist); + $tmp_id = Dba::escape($this->tmp_playlist); - /* Clear all votes then prune */ - $sql = "DELETE FROM `user_vote` USING `user_vote` " . - "LEFT JOIN `tmp_playlist_data` ON `user_vote`.`object_id` = `tmp_playlist_data`.`id` " . - "WHERE `tmp_playlist_data`.`tmp_playlist`='$tmp_id'"; - $db_results = Dba::write($sql); + /* Clear all votes then prune */ + $sql = "DELETE FROM `user_vote` USING `user_vote` " . + "LEFT JOIN `tmp_playlist_data` ON `user_vote`.`object_id` = `tmp_playlist_data`.`id` " . + "WHERE `tmp_playlist_data`.`tmp_playlist`='$tmp_id'"; + $db_results = Dba::write($sql); - // Prune! - self::prune_tracks(); + // Prune! + self::prune_tracks(); // Clean the votes self::clear_votes(); - return true; + return true; - } // clear_playlist + } // clear_playlist /** * clean_votes @@ -615,27 +615,27 @@ class Democratic extends tmpPlaylist { } // clear_votes - /** - * get_vote - * This returns the current count for a specific song on this tmp_playlist - */ - public function get_vote($object_id) { + /** + * get_vote + * This returns the current count for a specific song on this tmp_playlist + */ + public function get_vote($object_id) { if (parent::is_cached('democratic_vote',$object_id)) { return parent::get_from_cache('democratic_vote',$object_id); } - $object_id = Dba::escape($object_id); + $object_id = Dba::escape($object_id); - $sql = "SELECT COUNT(`user`) AS `count` FROM user_vote " . - "WHERE `object_id`='$object_id'"; - $db_results = Dba::read($sql); + $sql = "SELECT COUNT(`user`) AS `count` FROM user_vote " . + "WHERE `object_id`='$object_id'"; + $db_results = Dba::read($sql); - $results = Dba::fetch_assoc($db_results); + $results = Dba::fetch_assoc($db_results); - return $results['count']; + return $results['count']; - } // get_vote + } // get_vote /** * get_voters diff --git a/lib/class/flag.class.php b/lib/class/flag.class.php index 8ff27c1a..8105a247 100644 --- a/lib/class/flag.class.php +++ b/lib/class/flag.class.php @@ -370,42 +370,42 @@ class Flag extends database_object { */ public static function fill_tags( $tagWriter, $song, $type = 'comment' ) { - // Set all of the attributes for the tag to be written(All pulled from the song object) - // Use a function since ID3v1, ID3v2, and vorbis/flac/ape are different + // Set all of the attributes for the tag to be written(All pulled from the song object) + // Use a function since ID3v1, ID3v2, and vorbis/flac/ape are different switch ($type) { case 'comment': - $tagWriter->comments['title'] = $song->title; - $tagWriter->comments['date'] = $song->year; - $tagWriter->comments['year'] = $song->year; - $tagWriter->comments['comment'] = $song->comment; - $tagWriter->comments['size'] = $song->size; - $tagWriter->comments['time'] = $song->time; - $tagWriter->comments['album'] = $song->get_album_name(); - $tagWriter->comments['artist'] = $song->get_artist_name(); - $tagWriter->comments['genre'] = $song->get_genre_name(); - $tagWriter->comments['track'] = $song->track; + $tagWriter->comments['title'] = $song->title; + $tagWriter->comments['date'] = $song->year; + $tagWriter->comments['year'] = $song->year; + $tagWriter->comments['comment'] = $song->comment; + $tagWriter->comments['size'] = $song->size; + $tagWriter->comments['time'] = $song->time; + $tagWriter->comments['album'] = $song->get_album_name(); + $tagWriter->comments['artist'] = $song->get_artist_name(); + $tagWriter->comments['genre'] = $song->get_genre_name(); + $tagWriter->comments['track'] = $song->track; break; case 'id3v1': - $tagWriter->title = $song->title; - $tagWriter->year = $song->year; - $tagWriter->comment = $song->comment; - $tagWriter->artist = $song->get_artist_name(); - $tagWriter->album = $song->get_album_name(); - $tagWriter->genre = $song->get_genre_name(); - $tagWriter->track = $song->track; - unset($tagWriter->genre_id); + $tagWriter->title = $song->title; + $tagWriter->year = $song->year; + $tagWriter->comment = $song->comment; + $tagWriter->artist = $song->get_artist_name(); + $tagWriter->album = $song->get_album_name(); + $tagWriter->genre = $song->get_genre_name(); + $tagWriter->track = $song->track; + unset($tagWriter->genre_id); break; case 'id3v2': - $tagWriter->title = $song->title; - $tagWriter->year = $song->year; - $tagWriter->comment = $song->comment; - $tagWriter->artist = $song->get_artist_name(); - $tagWriter->album = $song->get_album_name(); - $tagWriter->genre = $song->get_genre_name(); - $tagWriter->track = $song->track; - unset($tagWriter->genre_id); + $tagWriter->title = $song->title; + $tagWriter->year = $song->year; + $tagWriter->comment = $song->comment; + $tagWriter->artist = $song->get_artist_name(); + $tagWriter->album = $song->get_album_name(); + $tagWriter->genre = $song->get_genre_name(); + $tagWriter->track = $song->track; + unset($tagWriter->genre_id); break; - } // end switch on type + } // end switch on type } // fill_tags diff --git a/lib/class/localplay.abstract.php b/lib/class/localplay.abstract.php index 02da3f63..6cc3d078 100644 --- a/lib/class/localplay.abstract.php +++ b/lib/class/localplay.abstract.php @@ -98,7 +98,7 @@ abstract class localplay_controller { return $data; } - } // end foreach + } // end foreach return $data; diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index 3da89c8b..186bea7e 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -488,21 +488,21 @@ class Localplay { } // prev - /** - * pause - * This isn't a required function, it tells the daemon to pause the - * song - */ - public function pause() { + /** + * pause + * This isn't a required function, it tells the daemon to pause the + * song + */ + public function pause() { - if (!$this->_player->pause()) { - debug_event('localplay','Error: Unable to pause song, check ' . $this->type . ' controller','1'); - return false; - } + if (!$this->_player->pause()) { + debug_event('localplay','Error: Unable to pause song, check ' . $this->type . ' controller','1'); + return false; + } - return true; + return true; - } // pause + } // pause /** * get_instances diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php index 5daa728e..8c4eb7f9 100644 --- a/lib/class/playlist.class.php +++ b/lib/class/playlist.class.php @@ -165,10 +165,10 @@ class Playlist extends database_object { while ($row = Dba::fetch_assoc($db_results)) { - $results[] = array('type'=>$row['object_type'],'object_id'=>$row['object_id']); - } // end while + $results[] = array('type'=>$row['object_type'],'object_id'=>$row['object_id']); + } // end while - return $results; + return $results; } // get_random_items @@ -385,38 +385,38 @@ class Playlist extends database_object { } // set_items - /** - * normalize_tracks - * this takes the crazy out of order tracks - * and numbers them in a liner fashion, not allowing for + /** + * normalize_tracks + * this takes the crazy out of order tracks + * and numbers them in a liner fashion, not allowing for * the same track # twice, this is an optional funcition */ - public function normalize_tracks() { + public function normalize_tracks() { - /* First get all of the songs in order of their tracks */ - $sql = "SELECT `id` FROM `playlist_data` WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY `track` ASC"; - $db_results = Dba::read($sql); + /* First get all of the songs in order of their tracks */ + $sql = "SELECT `id` FROM `playlist_data` WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY `track` ASC"; + $db_results = Dba::read($sql); - $i = 1; + $i = 1; $results = array(); - while ($r = Dba::fetch_assoc($db_results)) { - $new_data = array(); - $new_data['id'] = $r['id']; - $new_data['track'] = $i; - $results[] = $new_data; - $i++; - } // end while results - - foreach($results as $data) { - $sql = "UPDATE `playlist_data` SET `track`='" . $data['track'] . "' WHERE" . - " `id`='" . $data['id'] . "'"; - $db_results = Dba::write($sql); - } // foreach re-ordered results + while ($r = Dba::fetch_assoc($db_results)) { + $new_data = array(); + $new_data['id'] = $r['id']; + $new_data['track'] = $i; + $results[] = $new_data; + $i++; + } // end while results + + foreach($results as $data) { + $sql = "UPDATE `playlist_data` SET `track`='" . $data['track'] . "' WHERE" . + " `id`='" . $data['id'] . "'"; + $db_results = Dba::write($sql); + } // foreach re-ordered results - return true; + return true; - } // normalize_tracks + } // normalize_tracks /** * delete_track diff --git a/lib/class/preference.class.php b/lib/class/preference.class.php index e7780231..766859ea 100644 --- a/lib/class/preference.class.php +++ b/lib/class/preference.class.php @@ -83,13 +83,13 @@ class Preference { */ public static function update_level($preference,$level) { - // First prepare - if (!is_numeric($preference)) { - $preference_id = self::id_from_name($preference); - } - else { - $preference_id = $preference; - } + // First prepare + if (!is_numeric($preference)) { + $preference_id = self::id_from_name($preference); + } + else { + $preference_id = $preference; + } $preference_id = Dba::escape($preference_id); $level = Dba::escape($level); @@ -221,9 +221,9 @@ class Preference { $user_id = Dba::escape($user_id); - if ($user_id != '-1') { - $user_limit = "AND `preference`.`catagory` != 'system'"; - } + if ($user_id != '-1') { + $user_limit = "AND `preference`.`catagory` != 'system'"; + } $sql = "SELECT `preference`.`name`,`preference`.`description`,`user_preference`.`value` FROM `preference` " . " INNER JOIN `user_preference` ON `user_preference`.`preference`=`preference`.`id` " . @@ -272,15 +272,15 @@ class Preference { */ public static function delete($preference) { - // First prepare - if (!is_numeric($preference)) { + // First prepare + if (!is_numeric($preference)) { $name = Dba::escape($preference); $sql = "DELETE FROM `preference` WHERE `name`='$name'"; - } - else { + } + else { $id = Dba::escape($preference); $sql = "DELETE FROM `preference` WHERE `id`='$id'"; - } + } $db_results = Dba::write($sql); @@ -312,22 +312,22 @@ class Preference { */ public static function fix_preferences($results) { - $results['auth_methods'] = trim($results['auth_methods']) ? explode(",",$results['auth_methods']) : array(); - $results['tag_order'] = trim($results['tag_order']) ? explode(",",$results['tag_order']) : array(); - $results['album_art_order'] = trim($results['album_art_order']) ? explode(",",$results['album_art_order']) : array(); - if (isset($results['amazin_base_urls'])) - $results['amazon_base_urls'] = trim($results['amazin_base_urls']) ? explode(",",$results['amazon_base_urls']) : array(); - else + $results['auth_methods'] = trim($results['auth_methods']) ? explode(",",$results['auth_methods']) : array(); + $results['tag_order'] = trim($results['tag_order']) ? explode(",",$results['tag_order']) : array(); + $results['album_art_order'] = trim($results['album_art_order']) ? explode(",",$results['album_art_order']) : array(); + if (isset($results['amazin_base_urls'])) + $results['amazon_base_urls'] = trim($results['amazin_base_urls']) ? explode(",",$results['amazon_base_urls']) : array(); + else $results['amazon_base_urls']= array(); - foreach ($results as $key=>$data) { - if (!is_array($data)) { - if (strcasecmp($data,"true") == "0") { $results[$key] = 1; } - if (strcasecmp($data,"false") == "0") { $results[$key] = 0; } - } - } + foreach ($results as $key=>$data) { + if (!is_array($data)) { + if (strcasecmp($data,"true") == "0") { $results[$key] = 1; } + if (strcasecmp($data,"false") == "0") { $results[$key] = 0; } + } + } - return $results; + return $results; } // fix_preferences @@ -401,30 +401,30 @@ class Preference { return true; } - /* Get Global Preferences */ + /* Get Global Preferences */ $sql = "SELECT `preference`.`name`,`user_preference`.`value`,`syspref`.`value` AS `system_value` FROM `preference` " . "LEFT JOIN `user_preference` `syspref` ON `syspref`.`preference`=`preference`.`id` AND `syspref`.`user`='-1' AND `preference`.`catagory`='system' " . "LEFT JOIN `user_preference` ON `user_preference`.`preference`=`preference`.`id` AND `user_preference`.`user`='$user_id' AND `preference`.`catagory`!='system'"; - $db_results = Dba::read($sql); + $db_results = Dba::read($sql); - while ($row = Dba::fetch_assoc($db_results)) { + while ($row = Dba::fetch_assoc($db_results)) { $value = $row['system_value'] ? $row['system_value'] : $row['value']; - $name = $row['name']; - $results[$name] = $value; - } // end while sys prefs - - /* Set the Theme mojo */ - if (strlen($results['theme_name']) > 0) { - $results['theme_path'] = '/themes/' . $results['theme_name']; - } - // Default to the classic theme if we don't get anything from their - // preferenecs because we're going to want at least something otherwise - // the page is going to be really ugly - else { - $results['theme_path'] = '/themes/classic'; - } - - Config::set_by_array($results,1); + $name = $row['name']; + $results[$name] = $value; + } // end while sys prefs + + /* Set the Theme mojo */ + if (strlen($results['theme_name']) > 0) { + $results['theme_path'] = '/themes/' . $results['theme_name']; + } + // Default to the classic theme if we don't get anything from their + // preferenecs because we're going to want at least something otherwise + // the page is going to be really ugly + else { + $results['theme_path'] = '/themes/classic'; + } + + Config::set_by_array($results,1); $_SESSION['userdata']['preferences'] = $results; $_SESSION['userdata']['uid'] = $user_id; diff --git a/lib/class/query.class.php b/lib/class/query.class.php index 957838ed..057897e2 100644 --- a/lib/class/query.class.php +++ b/lib/class/query.class.php @@ -67,7 +67,7 @@ class Query { unset(self::$_state['filter'][self::$type][$key]); } else { - self::$_state['filter'][self::$type][$key] = 1; + self::$_state['filter'][self::$type][$key] = 1; } break; case 'tag': @@ -107,11 +107,11 @@ class Query { if (self::$_state['filter'][self::$type][$key] AND Access::check('interface','50')) { unset(self::$_state['filter'][self::$type][$key]); } else { self::$_state['filter'][self::$type][$key] = '1'; } break; - default: - // Rien a faire + default: + // Rien a faire return false; - break; - } // end switch + break; + } // end switch // If we've set a filter we need to reset the totals self::reset_total(); @@ -370,9 +370,9 @@ class Query { case 'video': $valid_array = array('title','resolution','length','codec'); break; - case 'user': - $valid_array = array('fullname','username','last_seen','create_date'); - break; + case 'user': + $valid_array = array('fullname','username','last_seen','create_date'); + break; } // end switch // If it's not in our list, smeg off! @@ -583,27 +583,27 @@ class Query { // Only allow it to be set once if (strlen(self::$_state['base'][self::$type])) { return true; } - switch (self::$type) { - case 'album': + switch (self::$type) { + case 'album': self::set_select("DISTINCT(`album`.`id`)"); - $sql = "SELECT %%SELECT%% FROM `album` "; - break; - case 'artist': + $sql = "SELECT %%SELECT%% FROM `album` "; + break; + case 'artist': self::set_select("DISTINCT(`artist`.`id`)"); - $sql = "SELECT %%SELECT%% FROM `artist` "; - break; - case 'user': + $sql = "SELECT %%SELECT%% FROM `artist` "; + break; + case 'user': self::set_select("`user`.`id`"); - $sql = "SELECT %%SELECT%% FROM `user` "; - break; - case 'live_stream': + $sql = "SELECT %%SELECT%% FROM `user` "; + break; + case 'live_stream': self::set_select("`live_stream`.`id`"); - $sql = "SELECT %%SELECT%% FROM `live_stream` "; - break; - case 'playlist': + $sql = "SELECT %%SELECT%% FROM `live_stream` "; + break; + case 'playlist': self::set_select("`playlist`.`id`"); - $sql = "SELECT %%SELECT%% FROM `playlist` "; - break; + $sql = "SELECT %%SELECT%% FROM `playlist` "; + break; case 'flagged': self::set_select("`flagged`.`id`"); $sql = "SELECT %%SELECT%% FROM `flagged` "; @@ -622,12 +622,12 @@ class Query { $sql = "SELECT %%SELECT%% FROM `tag` "; break; case 'playlist_song': - case 'song': - default: + case 'song': + default: self::set_select("DISTINCT(`song`.`id`)"); - $sql = "SELECT %%SELECT%% FROM `song` "; - break; - } // end base sql + $sql = "SELECT %%SELECT%% FROM `song` "; + break; + } // end base sql self::$_state['base'][self::$type] = $sql; @@ -838,7 +838,7 @@ class Query { case 'unplayed': $filter_sql = " `song`.`played`='0' AND "; break; - case 'album': + case 'album': $filter_sql = " `song`.`album` = '". Dba::escape($value) . "' AND "; break; case 'artist': @@ -877,7 +877,7 @@ class Query { case 'starts_with': $filter_sql = " `album`.`name` LIKE '" . Dba::escape($value) . "%' AND "; break; - case 'artist': + case 'artist': $filter_sql = " `artist`.`id` = '". Dba::escape($value) . "' AND "; break; case 'add_lt': @@ -964,21 +964,21 @@ class Query { } // end filter break; case 'tag': - switch ($filter) { - case 'alpha_match': - $filter_sql = " `tag`.`name` LIKE '%" . Dba::escape($value) . "%' AND "; - break; - case 'exact_match': - $filter_sql = " `tag`.`name` = '" . Dba::escape($value) . "' AND "; - break; + switch ($filter) { + case 'alpha_match': + $filter_sql = " `tag`.`name` LIKE '%" . Dba::escape($value) . "%' AND "; + break; + case 'exact_match': + $filter_sql = " `tag`.`name` = '" . Dba::escape($value) . "' AND "; + break; case 'tag': $filter_sql = " `tag`.`id` = '" . Dba::escape($value) . "' AND "; break; - default: - // Rien a faire - break; - } // end filter - break; + default: + // Rien a faire + break; + } // end filter + break; case 'video': switch ($filter) { case 'alpha_match': @@ -1106,22 +1106,22 @@ class Query { break; } // end switch break; - case 'user': - switch ($field) { - case 'username': - $sql = "`user`.`username`"; - break; - case 'fullname': - $sql = "`user`.`fullname`"; - break; - case 'last_seen': - $sql = "`user`.`last_seen`"; - break; - case 'create_date': - $sql = "`user`.`create_date`"; - break; - } // end switch - break; + case 'user': + switch ($field) { + case 'username': + $sql = "`user`.`username`"; + break; + case 'fullname': + $sql = "`user`.`fullname`"; + break; + case 'last_seen': + $sql = "`user`.`last_seen`"; + break; + case 'create_date': + $sql = "`user`.`create_date`"; + break; + } // end switch + break; case 'video': switch ($field) { case 'title': @@ -1186,14 +1186,14 @@ class Query { $order_sql = " ORDER BY "; - foreach (self::$_state['sort'][self::$type] as $key=>$value) { - $order_sql .= self::sql_sort($key,$value); - } - // Clean her up - $order_sql = rtrim($order_sql,"ORDER BY "); - $order_sql = rtrim($order_sql,","); + foreach (self::$_state['sort'][self::$type] as $key=>$value) { + $order_sql .= self::sql_sort($key,$value); + } + // Clean her up + $order_sql = rtrim($order_sql,"ORDER BY "); + $order_sql = rtrim($order_sql,","); - $sql = $sql . self::get_join_sql() . $where_sql . $order_sql; + $sql = $sql . self::get_join_sql() . $where_sql . $order_sql; } // if not simple $db_results = Dba::read($sql); @@ -1208,33 +1208,33 @@ class Query { } // resort_objects - /** - * save_objects - * This takes the full array of object ides, often passed into show and then - * if nessecary it saves them into the session - */ - public static function save_objects($object_ids) { - - // Saving these objects has two operations, one hold it in - // a local variable and then second hold it in a row in the tmp_browse - // table - self::$_cache['browse'][self::$type] = $object_ids; - - // Only do this if it's a not a simple browse - if (!self::is_simple()) { - $sid = Dba::escape(session_id()); - $data = Dba::escape(serialize($object_ids)); + /** + * save_objects + * This takes the full array of object ides, often passed into show and then + * if nessecary it saves them into the session + */ + public static function save_objects($object_ids) { + + // Saving these objects has two operations, one hold it in + // a local variable and then second hold it in a row in the tmp_browse + // table + self::$_cache['browse'][self::$type] = $object_ids; + + // Only do this if it's a not a simple browse + if (!self::is_simple()) { + $sid = Dba::escape(session_id()); + $data = Dba::escape(serialize($object_ids)); $type = Dba::escape(self::$type); - $sql = "REPLACE INTO `tmp_browse` SET `data`='$data', `sid`='$sid',`type`='$type'"; - $db_results = Dba::write($sql); + $sql = "REPLACE INTO `tmp_browse` SET `data`='$data', `sid`='$sid',`type`='$type'"; + $db_results = Dba::write($sql); - self::$total_objects = count($object_ids); - } // save it + self::$total_objects = count($object_ids); + } // save it - return true; + return true; - } // save_objects + } // save_objects /** * _auto_init diff --git a/lib/class/random.class.php b/lib/class/random.class.php index ca6bd6b0..eab6b3f9 100644 --- a/lib/class/random.class.php +++ b/lib/class/random.class.php @@ -246,51 +246,51 @@ class Random implements media { if ($data['genre'][0] != '-1') { $matchlist['genre'] = $data['genre']; } - + /* If they've passed -1 as limit then don't get everything */ - if ($data['random'] == "-1") { unset($data['random']); } - else { $limit_sql = "LIMIT " . Dba::escape($limit); } - - $where = "1=1 "; - if (is_array($matchlist)) { - foreach ($matchlist as $type => $value) { - if (is_array($value)) { - foreach ($value as $v) { + if ($data['random'] == "-1") { unset($data['random']); } + else { $limit_sql = "LIMIT " . Dba::escape($limit); } + + $where = "1=1 "; + if (is_array($matchlist)) { + foreach ($matchlist as $type => $value) { + if (is_array($value)) { + foreach ($value as $v) { if (!strlen($v)) { continue; } - $v = Dba::escape($v); - if ($v != $value[0]) { $where .= " OR $type='$v' "; } - else { $where .= " AND ( $type='$v'"; } - } + $v = Dba::escape($v); + if ($v != $value[0]) { $where .= " OR $type='$v' "; } + else { $where .= " AND ( $type='$v'"; } + } $where .= ")"; - } - elseif (strlen($value)) { - $value = Dba::escape($value); - $where .= " AND $type='$value' "; - } - } // end foreach + } + elseif (strlen($value)) { + $value = Dba::escape($value); + $where .= " AND $type='$value' "; + } + } // end foreach } // end if matchlist switch ($data['random_type']) { case 'full_album': - $query = "SELECT `album`.`id` FROM `song` INNER JOIN `album` ON `song`.`album`=`album`.`id` " . + $query = "SELECT `album`.`id` FROM `song` INNER JOIN `album` ON `song`.`album`=`album`.`id` " . "WHERE $where GROUP BY `song`.`album` ORDER BY RAND() $limit_sql"; - $db_results = Dba::read($query); - while ($row = Dba::fetch_assoc($db_results)) { - $albums_where .= " OR `song`.`album`=" . $row['id']; - } - $albums_where = ltrim($albums_where," OR"); - $sql = "SELECT `song`.`id`,`song`.`size`,`song`.`time` FROM `song` WHERE $albums_where ORDER BY `song`.`album`,`song`.`track` ASC"; + $db_results = Dba::read($query); + while ($row = Dba::fetch_assoc($db_results)) { + $albums_where .= " OR `song`.`album`=" . $row['id']; + } + $albums_where = ltrim($albums_where," OR"); + $sql = "SELECT `song`.`id`,`song`.`size`,`song`.`time` FROM `song` WHERE $albums_where ORDER BY `song`.`album`,`song`.`track` ASC"; break; case 'full_artist': - $query = "SELECT `artist`.`id` FROM `song` INNER JOIN `artist` ON `song`.`artist`=`artist`.`id` " . + $query = "SELECT `artist`.`id` FROM `song` INNER JOIN `artist` ON `song`.`artist`=`artist`.`id` " . "WHERE $where GROUP BY `song`.`artist` ORDER BY RAND() $limit_sql"; - $db_results = Dba::read($query); - while ($row = Dba::fetch_row($db_results)) { - $artists_where .= " OR song.artist=" . $row[0]; - } - $artists_where = ltrim($artists_where," OR"); - $sql = "SELECT song.id,song.size,song.time FROM song WHERE $artists_where ORDER BY RAND()"; - break; + $db_results = Dba::read($query); + while ($row = Dba::fetch_row($db_results)) { + $artists_where .= " OR song.artist=" . $row[0]; + } + $artists_where = ltrim($artists_where," OR"); + $sql = "SELECT song.id,song.size,song.time FROM song WHERE $artists_where ORDER BY RAND()"; + break; case 'unplayed': $uid = Dba::escape($GLOBALS['user']->id); $sql = "SELECT object_id,COUNT(`id`) AS `total` FROM `object_count` WHERE `user`='$uid' GROUP BY `object_id`"; @@ -481,18 +481,18 @@ class Random implements media { */ public static function validate_type($type) { - switch ($type) { + switch ($type) { case 'default': - case 'genre': - case 'album': - case 'artist': - case 'rated': + case 'genre': + case 'album': + case 'artist': + case 'rated': return $type; - break; - default: - return 'default'; - break; - } // end switch + break; + default: + return 'default'; + break; + } // end switch return $type; diff --git a/lib/class/registration.class.php b/lib/class/registration.class.php index a8865d33..30987011 100644 --- a/lib/class/registration.class.php +++ b/lib/class/registration.class.php @@ -127,19 +127,19 @@ E-mail: %s */ public static function show_agreement() { - $filename = Config::get('prefix') . '/config/registration_agreement.php'; + $filename = Config::get('prefix') . '/config/registration_agreement.php'; - if (!file_exists($filename)) { return false; } + if (!file_exists($filename)) { return false; } - /* Check for existance */ - $fp = fopen($filename,'r'); + /* Check for existance */ + $fp = fopen($filename,'r'); - if (!$fp) { return false; } + if (!$fp) { return false; } - $data = fread($fp,filesize($filename)); + $data = fread($fp,filesize($filename)); - /* Scrub and show */ - echo $data; + /* Scrub and show */ + echo $data; } // show_agreement diff --git a/lib/class/scrobbler.class.php b/lib/class/scrobbler.class.php index b2d223e0..ee1ae8a2 100644 --- a/lib/class/scrobbler.class.php +++ b/lib/class/scrobbler.class.php @@ -22,119 +22,119 @@ class scrobbler { - public $error_msg; - public $username; - public $password; - public $challenge; - public $submit_host; - public $submit_port; - public $submit_url; - public $queued_tracks; + public $error_msg; + public $username; + public $password; + public $challenge; + public $submit_host; + public $submit_port; + public $submit_url; + public $queued_tracks; public $reset_handshake = false; public $scrobble_host = 'post.audioscrobbler.com'; - /** - * Constructor - * This is the constructer it takes a username and password - */ - public function __construct($username, $password,$host='',$port='',$url='',$challenge='',$scrobble_host='') { + /** + * Constructor + * This is the constructer it takes a username and password + */ + public function __construct($username, $password,$host='',$port='',$url='',$challenge='',$scrobble_host='') { - $this->error_msg = ''; - $this->username = trim($username); - $this->password = trim($password); - $this->challenge = $challenge; + $this->error_msg = ''; + $this->username = trim($username); + $this->password = trim($password); + $this->challenge = $challenge; $this->submit_host = $host; $this->submit_port = $port; $this->submit_url = $url; - $this->queued_tracks = array(); + $this->queued_tracks = array(); if ($scrobble_host) { $this->scrobble_host = $scrobble_host; } - } // scrobbler + } // scrobbler - /** - * get_error_msg - */ - public function get_error_msg() { + /** + * get_error_msg + */ + public function get_error_msg() { - return $this->error_msg; + return $this->error_msg; - } // get_error_msg + } // get_error_msg - /** - * get_queue_count + /** + * get_queue_count */ - public function get_queue_count() { + public function get_queue_count() { - return count($this->queued_tracks); + return count($this->queued_tracks); - } // get_queue_count + } // get_queue_count - /** - * handshake - * This does a handshake with the audioscrobber server it doesn't pass the password, but + /** + * handshake + * This does a handshake with the audioscrobber server it doesn't pass the password, but * it does pass the username and has a 10 second timeout - */ - public function handshake() { + */ + public function handshake() { - $as_socket = fsockopen($this->scrobble_host, 80, $errno, $errstr, 2); - if(!$as_socket) { - $this->error_msg = $errstr; - return false; - } + $as_socket = fsockopen($this->scrobble_host, 80, $errno, $errstr, 2); + if(!$as_socket) { + $this->error_msg = $errstr; + return false; + } - $username = rawurlencode($this->username); + $username = rawurlencode($this->username); $timestamp = time(); $auth_token = rawurlencode(md5($this->password . $timestamp)); $get_string = "GET /?hs=true&p=1.2&c=apa&v=0.1&u=$username&t=$timestamp&a=$auth_token HTTP/1.1\r\n"; - + fwrite($as_socket, $get_string); - fwrite($as_socket, "Host: $this->scrobble_host\r\n"); - fwrite($as_socket, "Accept: */*\r\n\r\n"); - - $buffer = ''; - while(!feof($as_socket)) { - $buffer .= fread($as_socket, 4096); - } - fclose($as_socket); - $split_response = preg_split("/\r\n\r\n/", $buffer); - if(!isset($split_response[1])) { - $this->error_msg = 'Did not receive a valid response'; - return false; - } - $response = explode("\n", $split_response[1]); + fwrite($as_socket, "Host: $this->scrobble_host\r\n"); + fwrite($as_socket, "Accept: */*\r\n\r\n"); + + $buffer = ''; + while(!feof($as_socket)) { + $buffer .= fread($as_socket, 4096); + } + fclose($as_socket); + $split_response = preg_split("/\r\n\r\n/", $buffer); + if(!isset($split_response[1])) { + $this->error_msg = 'Did not receive a valid response'; + return false; + } + $response = explode("\n", $split_response[1]); if(substr($response[0], 0, 6) == 'FAILED') { - $this->error_msg = substr($response[0], 7); - return false; - } - if(substr($response[0], 0, 7) == 'BADUSER') { - $this->error_msg = 'Invalid Username'; - return false; - } + $this->error_msg = substr($response[0], 7); + return false; + } + if(substr($response[0], 0, 7) == 'BADUSER') { + $this->error_msg = 'Invalid Username'; + return false; + } if(substr($response[0],0,7) == 'BADTIME') { $this->error_msg = 'Your time is too far off from the server, or your PHP timezone is incorrect'; return false; } - if(substr($response[0], 0, 6) == 'UPDATE') { - $this->error_msg = 'You need to update your client: '.substr($response[0], 7); - return false; - } + if(substr($response[0], 0, 6) == 'UPDATE') { + $this->error_msg = 'You need to update your client: '.substr($response[0], 7); + return false; + } - if(preg_match('/http:\/\/([^\/]+)\/(.*)$/', $response[3], $matches)) { + if(preg_match('/http:\/\/([^\/]+)\/(.*)$/', $response[3], $matches)) { $host_parts = explode(":",$matches[1]); - $data['submit_host'] = $host_parts[0]; - $data['submit_port'] = $host_parts[1] ? $host_parts[1] : '80'; - $data['submit_url'] = '/' . $matches[2]; - } else { - $this->error_msg = "Invalid POST URL returned, unable to continue. Sent:\n$get_string\n----\nReceived:\n" . $buffer . + $data['submit_host'] = $host_parts[0]; + $data['submit_port'] = $host_parts[1] ? $host_parts[1] : '80'; + $data['submit_url'] = '/' . $matches[2]; + } else { + $this->error_msg = "Invalid POST URL returned, unable to continue. Sent:\n$get_string\n----\nReceived:\n" . $buffer . "\n---------\nExpeceted:" . print_r($response,1); - return false; - } + return false; + } - $data['challenge'] = $response[1]; - return $data; + $data['challenge'] = $response[1]; + return $data; - } // handshake + } // handshake /** * queue_track @@ -142,120 +142,120 @@ class scrobbler { * submit the track or talk to LastFM in anyway, kind of useless for our uses but its * here, and that's how it is. */ - public function queue_track($artist, $album, $title, $timestamp, $length,$track) { + public function queue_track($artist, $album, $title, $timestamp, $length,$track) { - if ($length < 30) { - debug_event('Scrobbler',"Not queuing track, too short",'5'); - return false; - } + if ($length < 30) { + debug_event('Scrobbler',"Not queuing track, too short",'5'); + return false; + } - $newtrack = array(); - $newtrack['artist'] = $artist; - $newtrack['album'] = $album; + $newtrack = array(); + $newtrack['artist'] = $artist; + $newtrack['album'] = $album; $newtrack['title'] = $title; - $newtrack['track'] = $track; - $newtrack['length'] = $length; - $newtrack['time'] = $timestamp; + $newtrack['track'] = $track; + $newtrack['length'] = $length; + $newtrack['time'] = $timestamp; - $this->queued_tracks[$timestamp] = $newtrack; - return true; + $this->queued_tracks[$timestamp] = $newtrack; + return true; - } // queue_track + } // queue_track /** * submit_tracks * This actually talks to LastFM submiting the tracks that are queued up. It * passed the md5'd password combinted with the challenge, which is then md5'd */ - public function submit_tracks() { + public function submit_tracks() { // Check and make sure that we've got some queued tracks - if(!count($this->queued_tracks)) { - $this->error_msg = "No tracks to submit"; - return false; - } + if(!count($this->queued_tracks)) { + $this->error_msg = "No tracks to submit"; + return false; + } //sort array by timestamp - ksort($this->queued_tracks); + ksort($this->queued_tracks); // build the query string - $query_str = 's='.rawurlencode($this->challenge).'&'; + $query_str = 's='.rawurlencode($this->challenge).'&'; - $i = 0; + $i = 0; - foreach($this->queued_tracks as $track) { - $query_str .= "a[$i]=".rawurlencode($track['artist'])."&t[$i]=".rawurlencode($track['title'])."&b[$i]=".rawurlencode($track['album'])."&"; - $query_str .= "m[$i]=&l[$i]=".rawurlencode($track['length'])."&i[$i]=".rawurlencode($track['time'])."&"; + foreach($this->queued_tracks as $track) { + $query_str .= "a[$i]=".rawurlencode($track['artist'])."&t[$i]=".rawurlencode($track['title'])."&b[$i]=".rawurlencode($track['album'])."&"; + $query_str .= "m[$i]=&l[$i]=".rawurlencode($track['length'])."&i[$i]=".rawurlencode($track['time'])."&"; $query_str .= "n[$i]=" . rawurlencode($track['track']) . "&o[$i]=P&r[$i]=&"; - $i++; - } + $i++; + } if (!trim($this->submit_host) || !$this->submit_port) { $this->reset_handshake = true; return false; } - $as_socket = fsockopen($this->submit_host, intval($this->submit_port), $errno, $errstr, 2); + $as_socket = fsockopen($this->submit_host, intval($this->submit_port), $errno, $errstr, 2); - if(!$as_socket) { - $this->error_msg = $errstr; + if(!$as_socket) { + $this->error_msg = $errstr; $this->reset_handshake = true; - return false; - } + return false; + } - $action = "POST ".$this->submit_url." HTTP/1.0\r\n"; - fwrite($as_socket, $action); - fwrite($as_socket, "Host: ".$this->submit_host."\r\n"); - fwrite($as_socket, "Accept: */*\r\n"); + $action = "POST ".$this->submit_url." HTTP/1.0\r\n"; + fwrite($as_socket, $action); + fwrite($as_socket, "Host: ".$this->submit_host."\r\n"); + fwrite($as_socket, "Accept: */*\r\n"); fwrite($as_socket, "User-Agent: Ampache/3.6\r\n"); - fwrite($as_socket, "Content-type: application/x-www-form-urlencoded\r\n"); - fwrite($as_socket, "Content-length: ".strlen($query_str)."\r\n\r\n"); + fwrite($as_socket, "Content-type: application/x-www-form-urlencoded\r\n"); + fwrite($as_socket, "Content-length: ".strlen($query_str)."\r\n\r\n"); - fwrite($as_socket, $query_str."\r\n\r\n"); - + fwrite($as_socket, $query_str."\r\n\r\n"); + $buffer = ''; - while(!feof($as_socket)) { - $buffer .= fread($as_socket, 8192); - } - fclose($as_socket); - - $split_response = preg_split("/\r\n\r\n/", $buffer); - if(!isset($split_response[1])) { - $this->error_msg = 'Did not receive a valid response'; + while(!feof($as_socket)) { + $buffer .= fread($as_socket, 8192); + } + fclose($as_socket); + + $split_response = preg_split("/\r\n\r\n/", $buffer); + if(!isset($split_response[1])) { + $this->error_msg = 'Did not receive a valid response'; $this->reset_handshake = true; - return false; - } - $response = explode("\n", $split_response[1]); - if(!isset($response[0])) { - $this->error_msg = 'Unknown error submitting tracks'. - "\nDebug output:\n".$buffer; + return false; + } + $response = explode("\n", $split_response[1]); + if(!isset($response[0])) { + $this->error_msg = 'Unknown error submitting tracks'. + "\nDebug output:\n".$buffer; $this->reset_handshake = true; - return false; - } - if(substr($response[0], 0, 6) == 'FAILED') { - $this->error_msg = $response[0]; + return false; + } + if(substr($response[0], 0, 6) == 'FAILED') { + $this->error_msg = $response[0]; $this->reset_handshake = true; - return false; - } - if(substr($response[0], 0, 7) == 'BADAUTH') { - $this->error_msg = 'Invalid username/password (' . $response[0] . ')'; - return false; - } + return false; + } + if(substr($response[0], 0, 7) == 'BADAUTH') { + $this->error_msg = 'Invalid username/password (' . $response[0] . ')'; + return false; + } if (substr($response[0],0,10) == 'BADSESSION') { $this->error_msg = 'Invalid Session passed (' . trim($response[0]) . ')'; $this->reset_handshake = true; return false; } - if(substr($response[0], 0, 2) != 'OK') { - $this->error_msg = 'Response Not ok, unknown error'. - "\nDebug output:\n".$buffer; + if(substr($response[0], 0, 2) != 'OK') { + $this->error_msg = 'Response Not ok, unknown error'. + "\nDebug output:\n".$buffer; $this->reset_handshake = true; - return false; - } + return false; + } - return true; + return true; - } // submit_tracks + } // submit_tracks } // end audioscrobbler class ?> diff --git a/lib/class/shoutbox.class.php b/lib/class/shoutbox.class.php index c5416d71..2de151d4 100644 --- a/lib/class/shoutbox.class.php +++ b/lib/class/shoutbox.class.php @@ -191,18 +191,15 @@ class shoutBox { } // create - /** - * format - * this function takes the object and reformats some values - */ + /** + * format + * this function takes the object and reformats some values + */ - public function format() { - - if ( $this->sticky == "0" ) { $this->sticky = "No"; } else { $this->sticky = "Yes"; } - - $this->date = date("m\/d\/Y - H:i",$this->date); - - return true; + public function format() { + $this->sticky = ($this->sticky == "0") ? 'No' : 'Yes'; + $this->date = date("m\/d\/Y - H:i", $this->date); + return true; } //format @@ -211,12 +208,12 @@ class shoutBox { * this function deletes a specific shoutbox entry */ - public function delete($shout_id) { + public function delete($shout_id) { - // Delete the shoutbox post + // Delete the shoutbox post $shout_id = Dba::escape($shout_id); - $sql = "DELETE FROM `user_shout` WHERE `id`='$shout_id'"; - $db_results = Dba::write($sql); + $sql = "DELETE FROM `user_shout` WHERE `id`='$shout_id'"; + $db_results = Dba::write($sql); } // delete diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 0820d159..df37d9f7 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -671,7 +671,7 @@ class Song extends database_object implements media { // Format the filename preg_match("/^.*\/(.*?)$/",$this->file, $short); $this->f_file = htmlspecialchars($short[1]); - + // Format the album name $this->f_album_full = $this->get_album_name(); $this->f_album = truncate_with_ellipsis($this->f_album_full,Config::get('ellipse_threshold_album')); @@ -719,7 +719,7 @@ class Song extends database_object implements media { * rename patterns */ public function format_pattern() { - + $extension = ltrim(substr($this->file,strlen($this->file)-4,4),"."); $catalog = new Catalog($this->catalog); @@ -731,23 +731,23 @@ class Song extends database_object implements media { return; } - /* Create the filename that this file should have */ - $album = $this->f_album_full; - $artist = $this->f_artist_full; - $track = $this->track; - $title = $this->title; - $year = $this->year; + /* Create the filename that this file should have */ + $album = $this->f_album_full; + $artist = $this->f_artist_full; + $track = $this->track; + $title = $this->title; + $year = $this->year; - /* Start replacing stuff */ - $replace_array = array('%a','%A','%t','%T','%y','/','\\'); - $content_array = array($artist,$album,$title,$track,$year,'-','-'); + /* Start replacing stuff */ + $replace_array = array('%a','%A','%t','%T','%y','/','\\'); + $content_array = array($artist,$album,$title,$track,$year,'-','-'); - $rename_pattern = str_replace($replace_array,$content_array,$catalog->rename_pattern); + $rename_pattern = str_replace($replace_array,$content_array,$catalog->rename_pattern); - $rename_pattern = preg_replace("[\-\:\!]","_",$rename_pattern); + $rename_pattern = preg_replace("[\-\:\!]","_",$rename_pattern); $this->f_pattern = $rename_pattern; - $this->f_file = $rename_pattern . "." . $extension; + $this->f_file = $rename_pattern . "." . $extension; } // format_pattern @@ -795,12 +795,12 @@ class Song extends database_object implements media { } // get_from_path /** - * @function get_rel_path - * @discussion returns the path of the song file stripped of the catalog path + * @function get_rel_path + * @discussion returns the path of the song file stripped of the catalog path * used for mpd playback */ public function get_rel_path($file_path=0,$catalog_id=0) { - + if (!$file_path) { $info = $this->_get_info(); $file_path = $info->file; @@ -808,12 +808,12 @@ class Song extends database_object implements media { if (!$catalog_id) { $catalog_id = $info->catalog; } - $catalog = new Catalog( $catalog_id ); - $info = $catalog->_get_info(); - $catalog_path = $info->path; + $catalog = new Catalog( $catalog_id ); + $info = $catalog->_get_info(); + $catalog_path = $info->path; $catalog_path = rtrim($catalog_path, "/"); - return( str_replace( $catalog_path . "/", "", $file_path ) ); - + return( str_replace( $catalog_path . "/", "", $file_path ) ); + } // get_rel_path @@ -853,9 +853,9 @@ class Song extends database_object implements media { */ function get_info_from_filename($file,$pattern,$tag) { - $preg_pattern = str_replace("$tag","(.+)",$pattern); - $preg_pattern = preg_replace("/\%\w/",".+",$preg_pattern); - $preg_pattern = "/" . str_replace("/","\/",$preg_pattern) . "\..+/"; + $preg_pattern = str_replace("$tag","(.+)",$pattern); + $preg_pattern = preg_replace("/\%\w/",".+",$preg_pattern); + $preg_pattern = "/" . str_replace("/","\/",$preg_pattern) . "\..+/"; preg_match($preg_pattern,$file,$matches); @@ -975,7 +975,7 @@ class Song extends database_object implements media { public function stream_cmd() { // Find the target for this transcode - $conf_type = 'transcode_' . $this->type . '_target'; + $conf_type = 'transcode_' . $this->type . '_target'; $stream_cmd = 'transcode_cmd_' . $this->type; $this->format_type(Config::get($conf_type)); diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 4fc8282a..3ae532e1 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -79,9 +79,9 @@ class Stream { $create_function = "create_" . $this->type; // If in the class, call it - if (in_array($create_function,$methods)) { - $this->{$create_function}(); - } + if (in_array($create_function,$methods)) { + $this->{$create_function}(); + } // Assume M3u incase they've pooched the type else { $this->create_m3u(); @@ -256,14 +256,14 @@ class Stream { */ public function create_m3u() { - // Send the client an m3u playlist - header("Cache-control: public"); - header("Content-Disposition: filename=ampache_playlist.m3u"); - header("Content-Type: audio/x-mpegurl;"); - echo "#EXTM3U\n"; + // Send the client an m3u playlist + header("Cache-control: public"); + header("Content-Disposition: filename=ampache_playlist.m3u"); + header("Content-Type: audio/x-mpegurl;"); + echo "#EXTM3U\n"; // Foreach the songs in this stream object - foreach ($this->media as $element) { + foreach ($this->media as $element) { $type = array_shift($element); $media = new $type(array_shift($element)); $media->format(); @@ -285,7 +285,7 @@ class Stream { break; } echo call_user_func(array($type,'play_url'),$media->id) . "\n"; - } // end foreach + } // end foreach /* Foreach URLS */ foreach ($this->urls as $url) { @@ -352,13 +352,13 @@ class Stream { */ public function create_asx() { - header("Cache-control: public"); - header("Content-Disposition: filename=ampache_playlist.asx"); + header("Cache-control: public"); + header("Content-Disposition: filename=ampache_playlist.asx"); header("Content-Type: video/x-ms-wmv;"); echo "<ASX version = \"3.0\" BANNERBAR=\"AUTO\">\n"; - echo "<TITLE>Ampache ASX Playlist</TITLE>"; - + echo "<TITLE>Ampache ASX Playlist</TITLE>"; + foreach ($this->media as $element) { $type = array_shift($element); $media = new $type(array_shift($element)); @@ -375,8 +375,8 @@ class Stream { } // end switch $url = call_user_func(array($type,'play_url'),$media->id); - echo "<ENTRY>\n"; - echo "<TITLE>$name</TITLE>\n"; + echo "<ENTRY>\n"; + echo "<TITLE>$name</TITLE>\n"; echo "<AUTHOR>$author</AUTHOR>\n"; echo "\t\t<COPYRIGHT>".$media->year."</COPYRIGHT>\n"; echo "\t\t<DURATION VALUE=\"00:00:".$media->time."\" />\n"; @@ -384,10 +384,10 @@ class Stream { echo "\t\t<PARAM NAME=\"Genre\" Value=\"".$media->get_genre_name()."\" />\n"; echo "\t\t<PARAM NAME=\"Composer\" Value=\"".$media->f_artist_full."\" />\n"; echo "\t\t<PARAM NAME=\"Prebuffer\" Value=\"false\" />\n"; - echo "<REF HREF = \"". $url . "\" />\n"; - echo "</ENTRY>\n"; + echo "<REF HREF = \"". $url . "\" />\n"; + echo "</ENTRY>\n"; - } // end foreach + } // end foreach /* Foreach urls */ foreach ($this->urls as $url) { @@ -398,7 +398,7 @@ class Stream { echo "</ENTRY>\n"; } // end foreach - echo "</ASX>\n"; + echo "</ASX>\n"; } // create_asx @@ -434,12 +434,12 @@ class Stream { $result .= xmlData::keyed_array($xml,1); - } // end foreach + } // end foreach xmlData::set_type('xspf'); - header("Cache-control: public"); - header("Content-Disposition: filename=ampache_playlist.xspf"); + header("Cache-control: public"); + header("Content-Disposition: filename=ampache_playlist.xspf"); header("Content-Type: application/xspf+xml; charset=utf-8"); echo xmlData::header(); echo $result; @@ -458,7 +458,7 @@ class Stream { /* Build the extra info we need to have it pass */ $play_info = "?action=show&tmpplaylist_id=" . $GLOBALS['user']->playlist->id; - // start ugly evil javascript code + // start ugly evil javascript code //FIXME: This needs to go in a template, here for now though //FIXME: This preference doesn't even exists, we'll eventually //FIXME: just make it the default @@ -466,30 +466,30 @@ class Stream { header("Location: ".Config::get('web_path')."/index.php?xspf&play_info=".$GLOBALS['user']->playlist->id); } else { - echo "<html><head>\n"; - echo "<title>" . Config::get('site_title') . "</title>\n"; - echo "<script language=\"javascript\" type=\"text/javascript\">\n"; - echo "<!-- begin\n"; - echo "function PlayerPopUp(URL) {\n"; - // We do a little check here to see if it's a Wii! - if (false !== stristr($_SERVER['HTTP_USER_AGENT'], 'Nintendo Wii')) { - echo "window.location=URL;\n"; - } - // Else go ahead and do the normal stuff - else { - echo "window.open(URL, 'XSPF_player', 'width=400,height=170,scrollbars=0,toolbar=0,location=0,directories=0,status=0,resizable=0');\n"; - echo "window.location = '" . return_referer() . "';\n"; - echo "return false;\n"; - } - echo "}\n"; - echo "// end -->\n"; - echo "</script>\n"; - echo "</head>\n"; - - echo "<body onLoad=\"javascript:PlayerPopUp('" . Config::get('web_path') . "/modules/flash/xspf_player.php" . $play_info . "')\">\n"; - echo "</body>\n"; - echo "</html>\n"; - } + echo "<html><head>\n"; + echo "<title>" . Config::get('site_title') . "</title>\n"; + echo "<script language=\"javascript\" type=\"text/javascript\">\n"; + echo "<!-- begin\n"; + echo "function PlayerPopUp(URL) {\n"; + // We do a little check here to see if it's a Wii! + if (false !== stristr($_SERVER['HTTP_USER_AGENT'], 'Nintendo Wii')) { + echo "window.location=URL;\n"; + } + // Else go ahead and do the normal stuff + else { + echo "window.open(URL, 'XSPF_player', 'width=400,height=170,scrollbars=0,toolbar=0,location=0,directories=0,status=0,resizable=0');\n"; + echo "window.location = '" . return_referer() . "';\n"; + echo "return false;\n"; + } + echo "}\n"; + echo "// end -->\n"; + echo "</script>\n"; + echo "</head>\n"; + + echo "<body onLoad=\"javascript:PlayerPopUp('" . Config::get('web_path') . "/modules/flash/xspf_player.php" . $play_info . "')\">\n"; + echo "</body>\n"; + echo "</html>\n"; + } } // create_xspf_player /** @@ -572,10 +572,10 @@ class Stream { */ public function create_ram() { - header("Cache-control: public"); - header("Content-Disposition: filename=ampache_playlist.ram"); - header("Content-Type: audio/x-pn-realaudio ram;"); - foreach ($this->media as $element) { + header("Cache-control: public"); + header("Content-Disposition: filename=ampache_playlist.ram"); + header("Content-Type: audio/x-pn-realaudio ram;"); + foreach ($this->media as $element) { $type = array_shift($element); echo $url = call_user_func(array($type,'play_url'),array_shift($element)) . "\n"; } // foreach songs @@ -590,105 +590,105 @@ class Stream { */ public static function start_downsample(&$song,$now_playing_id=0,$song_name=0,$start=0) { - /* Check to see if bitrates are set if so let's go ahead and optomize! */ - $max_bitrate = Config::get('max_bit_rate'); - $min_bitrate = Config::get('min_bit_rate'); - $time = time(); - $user_sample_rate = Config::get('sample_rate'); - $browser = new Browser(); - - if (!$song_name) { - $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type; - } - - if ($max_bitrate > 1 AND $min_bitrate < $max_bitrate AND $min_bitrate > 0) { - $last_seen_time = $time - 1200; //20 min. - - $sql = "SELECT COUNT(*) FROM now_playing, user_preference, preference " . - "WHERE preference.name = 'play_type' AND user_preference.preference = preference.id " . - "AND now_playing.user = user_preference.user AND user_preference.value='downsample'"; - $db_results = Dba::read($sql); - $results = Dba::fetch_row($db_results); - - // Current number of active streams (current is already in now playing, worst case make it 1) - $active_streams = intval($results[0]); + /* Check to see if bitrates are set if so let's go ahead and optomize! */ + $max_bitrate = Config::get('max_bit_rate'); + $min_bitrate = Config::get('min_bit_rate'); + $time = time(); + $user_sample_rate = Config::get('sample_rate'); + $browser = new Browser(); + + if (!$song_name) { + $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type; + } + + if ($max_bitrate > 1 AND $min_bitrate < $max_bitrate AND $min_bitrate > 0) { + $last_seen_time = $time - 1200; //20 min. + + $sql = "SELECT COUNT(*) FROM now_playing, user_preference, preference " . + "WHERE preference.name = 'play_type' AND user_preference.preference = preference.id " . + "AND now_playing.user = user_preference.user AND user_preference.value='downsample'"; + $db_results = Dba::read($sql); + $results = Dba::fetch_row($db_results); + + // Current number of active streams (current is already in now playing, worst case make it 1) + $active_streams = intval($results[0]); if (!$active_streams) { $active_streams = '1'; } - /* If only one user, they'll get all available. Otherwise split up equally. */ - $sample_rate = floor($max_bitrate/$active_streams); + /* If only one user, they'll get all available. Otherwise split up equally. */ + $sample_rate = floor($max_bitrate/$active_streams); - /* If min_bitrate is set, then we'll exit if the bandwidth would need to be split up smaller than the min. */ - if ($min_bitrate > 1 AND ($max_bitrate/$active_streams) < $min_bitrate) { + /* If min_bitrate is set, then we'll exit if the bandwidth would need to be split up smaller than the min. */ + if ($min_bitrate > 1 AND ($max_bitrate/$active_streams) < $min_bitrate) { - /* Log the failure */ - debug_event('downsample',"Error: Max bandwidith already allocated. $active_streams Active Streams",'2'); - echo "Maximum bandwidth already allocated. Try again later."; - exit(); + /* Log the failure */ + debug_event('downsample',"Error: Max bandwidith already allocated. $active_streams Active Streams",'2'); + echo "Maximum bandwidth already allocated. Try again later."; + exit(); - } - else { - $sample_rate = floor($max_bitrate/$active_streams); - } // end else + } + else { + $sample_rate = floor($max_bitrate/$active_streams); + } // end else - // Never go over the users sample rate - if ($sample_rate > $user_sample_rate) { $sample_rate = $user_sample_rate; } + // Never go over the users sample rate + if ($sample_rate > $user_sample_rate) { $sample_rate = $user_sample_rate; } - debug_event('downsample',"Downsampled: $active_streams current active streams, downsampling to $sample_rate",'2'); + debug_event('downsample',"Downsampled: $active_streams current active streams, downsampling to $sample_rate",'2'); - } // end if we've got bitrates + } // end if we've got bitrates - else { - $sample_rate = $user_sample_rate; - } + else { + $sample_rate = $user_sample_rate; + } - /* Validate the bitrate */ - $sample_rate = self::validate_bitrate($sample_rate); + /* Validate the bitrate */ + $sample_rate = self::validate_bitrate($sample_rate); - /* Never Upsample a song */ - if (($sample_rate*1000) > $song->bitrate) { - $sample_rate = self::validate_bitrate($song->bitrate/1000); - $sample_ratio = '1'; - } - else { - /* Set the Sample Ratio */ - $sample_ratio = $sample_rate/($song->bitrate/1000); - } - + /* Never Upsample a song */ + if (($sample_rate*1000) > $song->bitrate) { + $sample_rate = self::validate_bitrate($song->bitrate/1000); + $sample_ratio = '1'; + } + else { + /* Set the Sample Ratio */ + $sample_ratio = $sample_rate/($song->bitrate/1000); + } + // Set the new size for the song $song->size = floor($sample_ratio*$song->size); - /* Get Offset */ - $offset = ( $start*$song->time )/( $song->size ); - $offsetmm = floor($offset/60); - $offsetss = floor($offset-$offsetmm*60); - $offset = sprintf("%02d.%02d",$offsetmm,$offsetss); + /* Get Offset */ + $offset = ( $start*$song->time )/( $song->size ); + $offsetmm = floor($offset/60); + $offsetss = floor($offset-$offsetmm*60); + $offset = sprintf("%02d.%02d",$offsetmm,$offsetss); - /* Get EOF */ - $eofmm = floor($song->time/60); - $eofss = floor($song->time-$eofmm*60); - $eof = sprintf("%02d.%02d",$eofmm,$eofss); + /* Get EOF */ + $eofmm = floor($song->time/60); + $eofss = floor($song->time-$eofmm*60); + $eof = sprintf("%02d.%02d",$eofmm,$eofss); - $song_file = escapeshellarg($song->file); + $song_file = escapeshellarg($song->file); - /* Replace Variables */ - $downsample_command = Config::get($song->stream_cmd()); - $downsample_command = str_replace("%FILE%",$song_file,$downsample_command,$file_exists); - $downsample_command = str_replace("%OFFSET%",$offset,$downsample_command,$offset_exists); - $downsample_command = str_replace("%EOF%",$eof,$downsample_command,$eof_exists); - $downsample_command = str_replace("%SAMPLE%",$sample_rate,$downsample_command,$sample_exists); + /* Replace Variables */ + $downsample_command = Config::get($song->stream_cmd()); + $downsample_command = str_replace("%FILE%",$song_file,$downsample_command,$file_exists); + $downsample_command = str_replace("%OFFSET%",$offset,$downsample_command,$offset_exists); + $downsample_command = str_replace("%EOF%",$eof,$downsample_command,$eof_exists); + $downsample_command = str_replace("%SAMPLE%",$sample_rate,$downsample_command,$sample_exists); if (!$file_exists || !$offset_exists || !$eof_exists || !$sample_exists) { debug_event('downsample','Error: Downsample command missing a varaible values are File:' . $file_exists . ' Offset:' . $offset_exists . ' Eof:' . $eof_exists . ' Sample:' . $sample_exists,'1'); } - // If we are debugging log this event - $message = "Start Downsample: $downsample_command"; - debug_event('downsample',$message,'3'); + // If we are debugging log this event + $message = "Start Downsample: $downsample_command"; + debug_event('downsample',$message,'3'); - $fp = popen($downsample_command, 'rb'); + $fp = popen($downsample_command, 'rb'); // Return our new handle - return ($fp); + return ($fp); } // start_downsample @@ -698,8 +698,8 @@ class Stream { */ public static function validate_bitrate($bitrate) { - /* Round to standard bitrates */ - $sample_rate = 16*(floor($bitrate/16)); + /* Round to standard bitrates */ + $sample_rate = 16*(floor($bitrate/16)); return $sample_rate; @@ -713,11 +713,11 @@ class Stream { */ public static function gc_now_playing() { - // Remove any now playing entries for session_streams that have been GC'd - $sql = "DELETE FROM `now_playing` USING `now_playing` " . - "LEFT JOIN `session_stream` ON `session_stream`.`id`=`now_playing`.`id` " . - "WHERE `session_stream`.`id` IS NULL OR `now_playing`.`expire` < '" . time() . "'"; - $db_results = Dba::write($sql); + // Remove any now playing entries for session_streams that have been GC'd + $sql = "DELETE FROM `now_playing` USING `now_playing` " . + "LEFT JOIN `session_stream` ON `session_stream`.`id`=`now_playing`.`id` " . + "WHERE `session_stream`.`id` IS NULL OR `now_playing`.`expire` < '" . time() . "'"; + $db_results = Dba::write($sql); } // gc_now_playing @@ -729,14 +729,14 @@ class Stream { */ public static function insert_now_playing($oid,$uid,$length,$sid,$type) { - $time = intval(time()+$length); - $session_id = Dba::escape($sid); + $time = intval(time()+$length); + $session_id = Dba::escape($sid); $object_type = Dba::escape(strtolower($type)); - // Do a replace into ensuring that this client always only has a single row - $sql = "REPLACE INTO `now_playing` (`id`,`object_id`,`object_type`, `user`, `expire`)" . - " VALUES ('$session_id','$oid','$object_type', '$uid', '$time')"; - $db_result = Dba::write($sql); + // Do a replace into ensuring that this client always only has a single row + $sql = "REPLACE INTO `now_playing` (`id`,`object_id`,`object_type`, `user`, `expire`)" . + " VALUES ('$session_id','$oid','$object_type', '$uid', '$time')"; + $db_result = Dba::write($sql); } // insert_now_playing @@ -747,10 +747,10 @@ class Stream { */ public static function clear_now_playing() { - $sql = "TRUNCATE `now_playing`"; - $db_results = Dba::write($sql); + $sql = "TRUNCATE `now_playing`"; + $db_results = Dba::write($sql); - return true; + return true; } // clear_now_playing @@ -764,7 +764,7 @@ class Stream { "FROM `now_playing` " . "LEFT JOIN `session_stream` ON `session_stream`.`id`=`now_playing`.`id` " . "ORDER BY `now_playing`.`expire` DESC"; - $db_results = Dba::read($sql); + $db_results = Dba::read($sql); $results = array(); @@ -842,10 +842,10 @@ class Stream { } // end switch on method // Load our javascript - echo "<script type=\"text/javascript\">"; - //echo "reload_util();"; - echo "reload_util('".$_SESSION['iframe']['target']."');"; - echo "</script>"; + echo "<script type=\"text/javascript\">"; + //echo "reload_util();"; + echo "reload_util('".$_SESSION['iframe']['target']."');"; + echo "</script>"; } // run_playlist_method @@ -855,15 +855,15 @@ class Stream { */ public static function get_base_url() { - if (Config::get('require_session')) { - $session_string = 'ssid=' . Stream::get_session() . '&'; - } + if (Config::get('require_session')) { + $session_string = 'ssid=' . Stream::get_session() . '&'; + } - $web_path = Config::get('web_path'); + $web_path = Config::get('web_path'); - if (Config::get('force_http_play') OR !empty(self::$force_http)) { - $web_path = str_replace("https://", "http://",$web_path); - } + if (Config::get('force_http_play') OR !empty(self::$force_http)) { + $web_path = str_replace("https://", "http://",$web_path); + } if (Config::get('http_port') != '80') { if (preg_match("/:(\d+)/",$web_path,$matches)) { $web_path = str_replace(':' . $matches['1'],':' . Config::get('http_port'),$web_path); diff --git a/lib/class/tag.class.php b/lib/class/tag.class.php index dbac998e..1fa9b48b 100644 --- a/lib/class/tag.class.php +++ b/lib/class/tag.class.php @@ -153,11 +153,11 @@ class Tag extends database_object { if (!is_array($ids) OR !count($ids)) { return false; } - $type = self::validate_type($type); - $idlist = '(' . implode(',',$ids) . ')'; + $type = self::validate_type($type); + $idlist = '(' . implode(',',$ids) . ')'; - $sql = "SELECT `tag_map`.`id`,`tag_map`.`tag_id`,`tag_map`.`object_id`,`tag_map`.`user` FROM `tag_map` " . - "WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id` IN $idlist "; + $sql = "SELECT `tag_map`.`id`,`tag_map`.`tag_id`,`tag_map`.`object_id`,`tag_map`.`user` FROM `tag_map` " . + "WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id` IN $idlist "; $db_results = Dba::read($sql); $tags = array(); @@ -482,8 +482,8 @@ class Tag extends database_object { */ public static function filter_with_prefs($l) { - $colors = array('#0000FF', - '#00FF00', '#FFFF00', '#00FFFF','#FF00FF','#FF0000'); + $colors = array('#0000FF', + '#00FF00', '#FFFF00', '#00FFFF','#FF00FF','#FF0000'); $prefs = 'tag company'; // $prefs = Config::get('tags_userlist'); @@ -528,7 +528,7 @@ class Tag extends database_object { $i['color'] = $uids[$i['user']]; $i['username'] = $usernames[$i['user']]; $res[] = $i; - } + } } return $res; diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 426dffb3..f3ba888c 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -659,15 +659,15 @@ class Update { $sql = "ALTER TABLE `song_ext_data` ADD `label` VARCHAR ( 128 ) NULL, ADD `catalog_number` VARCHAR ( 128 ) NULL, ADD `language` VARCHAR ( 128 ) NULL"; $db_results = Dba::write($sql); - /* Fix every users preferences */ - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + /* Fix every users preferences */ + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while results + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while results self::set_version('db_version','340001'); @@ -769,27 +769,27 @@ class Update { $sql = "ALTER TABLE `rating` CHANGE `user_rating` `rating` ENUM( '-1', '0', '1', '2', '3', '4', '5' ) NOT NULL DEFAULT '0'"; $db_results = Dba::write($sql); - /* Add the rate_limit preference */ - $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES ('rate_limit','8192','Rate Limit','100','integer','streaming')"; - $db_results = Dba::write($sql); + /* Add the rate_limit preference */ + $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES ('rate_limit','8192','Rate Limit','100','integer','streaming')"; + $db_results = Dba::write($sql); - /* Add the playlist_method preference and remove it from the user table */ - $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES ('playlist_method','normal','Playlist Method','5','string','streaming')"; - $db_results = Dba::write($sql); + /* Add the playlist_method preference and remove it from the user table */ + $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES ('playlist_method','normal','Playlist Method','5','string','streaming')"; + $db_results = Dba::write($sql); $sql = "ALTER TABLE `update_info` ADD UNIQUE (`key`)"; $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } self::set_version('db_version','340003'); @@ -804,8 +804,8 @@ class Update { */ public static function update_340004() { - /* Alter the session.id so that it's 64 */ - $sql = "ALTER TABLE `session` CHANGE `id` `id` VARCHAR( 64 ) NOT NULL"; + /* Alter the session.id so that it's 64 */ + $sql = "ALTER TABLE `session` CHANGE `id` `id` VARCHAR( 64 ) NOT NULL"; $db_results = Dba::write($sql); /* Add Playlist Related Preferences */ @@ -848,14 +848,14 @@ class Update { $sql = "OPTIMIZE TABLE `album`"; $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // Update our database version now that we are all done self::set_version('db_version','340004'); @@ -885,24 +885,24 @@ class Update { $sql = "SELECT * FROM `preference` WHERE `name`='playlist_method'"; $db_results = Dba::read($sql); if (!Dba::num_rows($db_results)) { - /* Add the playlist_method preference and remove it from the user table */ - $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - "VALUES ('playlist_method','default','Playlist Method','5','string','playlist')"; - $db_results = Dba::write($sql); + /* Add the playlist_method preference and remove it from the user table */ + $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES ('playlist_method','default','Playlist Method','5','string','playlist')"; + $db_results = Dba::write($sql); } // Add in the object_type to the tmpplaylist data table so that we can have non-songs in there $sql = "ALTER TABLE `tmp_playlist_data` ADD `object_type` VARCHAR( 32 ) NULL AFTER `tmp_playlist`"; $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } self::set_version('db_version','340005'); @@ -934,18 +934,18 @@ class Update { $sql = "DELETE FROM `preference` WHERE `name`='random_method'"; $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } - self::set_version('db_version','340006'); + self::set_version('db_version','340006'); - return true; + return true; } // update_340006 @@ -1022,14 +1022,14 @@ class Update { $sql = "DROP TABLE IF EXISTS `ratings`"; $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } self::set_version('db_version','340008'); @@ -1089,15 +1089,15 @@ class Update { $sql = "UPDATE `preference` SET `description`='Localplay Config' WHERE `name`='localplay_level'"; $db_results = Dba::write($sql); - /* Fix every users preferences */ - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + /* Fix every users preferences */ + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while results + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while results self::set_version('db_version','340010'); @@ -1114,16 +1114,16 @@ class Update { public static function update_340011() { // First add the new table for the new session stuff - $sql = "CREATE TABLE `session_api` ( " . - "`id` VARCHAR( 64 ) NOT NULL , " . - "`user` INT( 11 ) UNSIGNED NOT NULL , " . - "`agent` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL , " . + $sql = "CREATE TABLE `session_api` ( " . + "`id` VARCHAR( 64 ) NOT NULL , " . + "`user` INT( 11 ) UNSIGNED NOT NULL , " . + "`agent` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL , " . "`level` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0', " . - "`expire` INT( 11 ) UNSIGNED NOT NULL , " . - "`ip` INT( 11 ) UNSIGNED NULL , " . - "PRIMARY KEY ( `id` ) " . - ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; - $db_results = Dba::write($sql); + "`expire` INT( 11 ) UNSIGNED NOT NULL , " . + "`ip` INT( 11 ) UNSIGNED NULL , " . + "PRIMARY KEY ( `id` ) " . + ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; + $db_results = Dba::write($sql); self::set_version('db_version','340011'); @@ -1179,14 +1179,14 @@ class Update { $sql = "UPDATE `access_list` SET `type`='rpc' WHERE `type`='xml-rpc'"; $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while we're fixing the useres stuff + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while we're fixing the useres stuff self::set_version('db_version','340013'); @@ -1357,9 +1357,9 @@ class Update { break; } // end mysql charset translation - // Alter the charset for the entire database - $sql = "ALTER DATABASE `" . Config::get('database_name') . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; - $db_results = Dba::write($sql); + // Alter the charset for the entire database + $sql = "ALTER DATABASE `" . Config::get('database_name') . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; + $db_results = Dba::write($sql); $sql = "SHOW TABLES"; $db_results = Dba::read($sql); @@ -1369,9 +1369,9 @@ class Update { $sql = "DESCRIBE `" . $row['0'] . "`"; $describe_results = Dba::read($sql); - // Change the tables default charset and colliation - $sql = "ALTER TABLE `" . $row['0'] . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; - $alter_table = Dba::write($sql); + // Change the tables default charset and colliation + $sql = "ALTER TABLE `" . $row['0'] . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; + $alter_table = Dba::write($sql); // Itterate through the columns of the table while ($table = Dba::fetch_assoc($describe_results)) { @@ -1641,14 +1641,14 @@ class Update { $sql = "INSERT INTO `user_preference` VALUES (1,69,'0')"; $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while we're fixing the useres stuff + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while we're fixing the useres stuff self::set_version('db_version','350006'); @@ -1751,8 +1751,8 @@ class Update { $sql = "ALTER TABLE `video` ADD INDEX (`update_time`)"; $db_results = Dba::write($sql); - $sql = "ALTER TABLE `artist_data` ADD INDEX ( `art_mime` )"; - $db_results = Dba::write($sql); + $sql = "ALTER TABLE `artist_data` ADD INDEX ( `art_mime` )"; + $db_results = Dba::write($sql); $sql = "ALTER TABLE `album_data` ADD INDEX ( `art_mime` )"; $db_results = Dba::write($sql); @@ -1793,14 +1793,14 @@ class Update { $sql = "DELETE FROM `preference` WHERE `name` LIKE 'rio_%'"; $db_results = Dba::write($sql); - $sql = "SELECT `id` FROM `user`"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::read($sql); - User::fix_preferences('-1'); + User::fix_preferences('-1'); - while ($r = Dba::fetch_assoc($db_results)) { - User::fix_preferences($r['id']); - } // while we're fixing the useres stuff + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while we're fixing the useres stuff self::set_version('db_version','360001'); diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 8e069753..4ba750d1 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -240,7 +240,7 @@ class User extends database_object { */ function get_favorites($type) { - $web_path = Config::get('web_path'); + $web_path = Config::get('web_path'); $results = Stats::get_user(Config::get('popular_threshold'),$type,$this->id,1); @@ -693,7 +693,7 @@ class User extends database_object { else { $this->f_last_seen = date("m\/d\/Y - H:i",$this->last_seen); } /* If they have a create date */ - if (!$this->create_date) { $this->f_create_date = _('Unknown'); } + if (!$this->create_date) { $this->f_create_date = _('Unknown'); } else { $this->f_create_date = date("m\/d\/Y - H:i",$this->create_date); } // Base link @@ -860,56 +860,56 @@ class User extends database_object { /* If we aren't the -1 user before we continue grab the -1 users values */ if ($user_id != '-1') { - $sql = "SELECT `user_preference`.`preference`,`user_preference`.`value` FROM `user_preference`,`preference` " . - "WHERE `user_preference`.`preference` = `preference`.`id` AND `user_preference`.`user`='-1' AND `preference`.`catagory` !='system'"; - $db_results = Dba::read($sql); + $sql = "SELECT `user_preference`.`preference`,`user_preference`.`value` FROM `user_preference`,`preference` " . + "WHERE `user_preference`.`preference` = `preference`.`id` AND `user_preference`.`user`='-1' AND `preference`.`catagory` !='system'"; + $db_results = Dba::read($sql); /* While through our base stuff */ - while ($r = Dba::fetch_assoc($db_results)) { + while ($r = Dba::fetch_assoc($db_results)) { $key = $r['preference']; - $zero_results[$key] = $r['value']; - } - } // if not user -1 + $zero_results[$key] = $r['value']; + } + } // if not user -1 // get me _EVERYTHING_ - $sql = "SELECT * FROM `preference`"; + $sql = "SELECT * FROM `preference`"; // If not system, exclude system... *gasp* - if ($user_id != '-1') { - $sql .= " WHERE catagory !='system'"; - } - $db_results = Dba::read($sql); + if ($user_id != '-1') { + $sql .= " WHERE catagory !='system'"; + } + $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { + while ($r = Dba::fetch_assoc($db_results)) { $key = $r['id']; - /* Check if this preference is set */ - if (!isset($results[$key])) { - if (isset($zero_results[$key])) { - $r['value'] = $zero_results[$key]; - } + /* Check if this preference is set */ + if (!isset($results[$key])) { + if (isset($zero_results[$key])) { + $r['value'] = $zero_results[$key]; + } $value = Dba::escape($r['value']); - $sql = "INSERT INTO user_preference (`user`,`preference`,`value`) VALUES ('$user_id','$key','$value')"; - $insert_db = Dba::write($sql); - } - } // while preferences + $sql = "INSERT INTO user_preference (`user`,`preference`,`value`) VALUES ('$user_id','$key','$value')"; + $insert_db = Dba::write($sql); + } + } // while preferences - /* Let's also clean out any preferences garbage left over */ - $sql = "SELECT DISTINCT(user_preference.user) FROM user_preference " . - "LEFT JOIN user ON user_preference.user = user.id " . - "WHERE user_preference.user!='-1' AND user.id IS NULL"; - $db_results = Dba::read($sql); + /* Let's also clean out any preferences garbage left over */ + $sql = "SELECT DISTINCT(user_preference.user) FROM user_preference " . + "LEFT JOIN user ON user_preference.user = user.id " . + "WHERE user_preference.user!='-1' AND user.id IS NULL"; + $db_results = Dba::read($sql); - $results = array(); + $results = array(); - while ($r = Dba::fetch_assoc($db_results)) { - $results[] = $r['user']; - } + while ($r = Dba::fetch_assoc($db_results)) { + $results[] = $r['user']; + } - foreach ($results as $data) { - $sql = "DELETE FROM user_preference WHERE user='$data'"; - $db_results = Dba::write($sql); - } + foreach ($results as $data) { + $sql = "DELETE FROM user_preference WHERE user='$data'"; + $db_results = Dba::write($sql); + } } // fix_preferences @@ -976,7 +976,7 @@ class User extends database_object { // Delete their shoutbox posts $sql = "DELETE FROM `user_shout` WHERE `user='$this->id'"; - $db_results = Dba::write($sql); + $db_results = Dba::write($sql); // Delete the user itself $sql = "DELETE FROM `user` WHERE `id`='$this->id'"; @@ -1039,12 +1039,12 @@ class User extends database_object { } // get_recently_played - /** - * get_ip_history - * This returns the ip_history from the - * last Config::get('user_ip_cardinality') days - */ - public function get_ip_history($count='',$distinct='') { + /** + * get_ip_history + * This returns the ip_history from the + * last Config::get('user_ip_cardinality') days + */ + public function get_ip_history($count='',$distinct='') { $username = Dba::escape($this->id); $count = $count ? intval($count) : intval(Config::get('user_ip_cardinality')); @@ -1055,21 +1055,21 @@ class User extends database_object { if ($distinct) { $group_sql = "GROUP BY `ip`"; } - /* Select ip history */ - $sql = "SELECT `ip`,`date` FROM `ip_history`" . - " WHERE `user`='$username'" . - " $group_sql ORDER BY `date` DESC $limit_sql"; - $db_results = Dba::read($sql); + /* Select ip history */ + $sql = "SELECT `ip`,`date` FROM `ip_history`" . + " WHERE `user`='$username'" . + " $group_sql ORDER BY `date` DESC $limit_sql"; + $db_results = Dba::read($sql); - $results = array(); + $results = array(); - while ($row = Dba::fetch_assoc($db_results)) { - $results[] = $row; - } + while ($row = Dba::fetch_assoc($db_results)) { + $results[] = $row; + } - return $results; + return $results; - } // get_ip_history + } // get_ip_history /** * activate_user @@ -1084,23 +1084,23 @@ class User extends database_object { } // activate_user - /** - * is_xmlrpc - * checks to see if this is a valid xmlrpc user - */ - public function is_xmlrpc() { + /** + * is_xmlrpc + * checks to see if this is a valid xmlrpc user + */ + public function is_xmlrpc() { - /* If we aren't using XML-RPC return true */ - if (!Config::get('xml_rpc')) { - return false; - } + /* If we aren't using XML-RPC return true */ + if (!Config::get('xml_rpc')) { + return false; + } - //FIXME: Ok really what we will do is check the MD5 of the HTTP_REFERER - //FIXME: combined with the song title to make sure that the REFERER - //FIXME: is in the access list with full rights - return true; + //FIXME: Ok really what we will do is check the MD5 of the HTTP_REFERER + //FIXME: combined with the song title to make sure that the REFERER + //FIXME: is in the access list with full rights + return true; - } // is_xmlrpc + } // is_xmlrpc /** * check_username diff --git a/lib/class/vainfo.class.php b/lib/class/vainfo.class.php index 2160985b..692d0229 100644 --- a/lib/class/vainfo.class.php +++ b/lib/class/vainfo.class.php @@ -1126,12 +1126,12 @@ class vainfo { */ public function set_broken() { - /* Pull In the config option */ - $order = Config::get('tag_order'); + /* Pull In the config option */ + $order = Config::get('tag_order'); - if (!is_array($order)) { - $order = array($order); - } + if (!is_array($order)) { + $order = array($order); + } $key = array_shift($order); diff --git a/lib/class/vauth.class.php b/lib/class/vauth.class.php index 4364d75e..dad3feda 100644 --- a/lib/class/vauth.class.php +++ b/lib/class/vauth.class.php @@ -278,12 +278,12 @@ class vauth { break; } // end switch on data type - $username = Dba::escape($data['username']); - $ip = $_SERVER['REMOTE_ADDR'] ? Dba::escape(inet_pton($_SERVER['REMOTE_ADDR'])) : '0'; - $type = Dba::escape($data['type']); - $value = Dba::escape($data['value']); + $username = Dba::escape($data['username']); + $ip = $_SERVER['REMOTE_ADDR'] ? Dba::escape(inet_pton($_SERVER['REMOTE_ADDR'])) : '0'; + $type = Dba::escape($data['type']); + $value = Dba::escape($data['value']); $agent = Dba::escape(substr($_SERVER['HTTP_USER_AGENT'],0,254)); - $expire = Dba::escape(time() + Config::get('session_length')); + $expire = Dba::escape(time() + Config::get('session_length')); /* We can't have null things here people */ if (!strlen($value)) { $value = ' '; } @@ -517,7 +517,7 @@ class vauth { } $row['type'] = 'mysql'; - $row['success'] = true; + $row['success'] = true; return $row; @@ -567,7 +567,7 @@ class vauth { $results['type'] = 'mysql'; $results['password'] = 'old'; - $results['success'] = true; + $results['success'] = true; return $results; @@ -647,7 +647,7 @@ class vauth { if ($info["count"] == 1) { $user_entry = ldap_first_entry($ldap_link, $sr); - $user_dn = ldap_get_dn($ldap_link, $user_entry); + $user_dn = ldap_get_dn($ldap_link, $user_entry); // bind using the user.. $retval = ldap_bind($ldap_link, $user_dn, $password); diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php index bb8516ec..4e13c0a1 100644 --- a/lib/class/xmldata.class.php +++ b/lib/class/xmldata.class.php @@ -229,8 +229,8 @@ class xmlData { $tag_string . "\t<albums>$artist->albums</albums>\n" . "\t<songs>$artist->songs</songs>\n" . - "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" . - "\t<rating>" . $rating->rating . "</rating>\n" . + "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" . + "\t<rating>" . $rating->rating . "</rating>\n" . "</artist>\n"; } // end foreach artists @@ -277,8 +277,8 @@ class xmlData { "\t<disk>$album->disk</disk>\n" . self::tags_string($album->tags,'album',$album->id) . "\t<art><![CDATA[$art_url]]></art>\n" . - "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" . - "\t<rating>" . $rating->rating . "</rating>\n" . + "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" . + "\t<rating>" . $rating->rating . "</rating>\n" . "</album>\n"; } // end foreach @@ -387,9 +387,9 @@ class xmlData { */ public static function videos($videos) { - if (count($videos) > self::$limit OR self::$offset > 0) { - $videos = array_slice($videos,self::$offset,self::$limit); - } + if (count($videos) > self::$limit OR self::$offset > 0) { + $videos = array_slice($videos,self::$offset,self::$limit); + } $string = ''; @@ -433,31 +433,31 @@ class xmlData { $song->format(); //FIXME: This is duplicate code and so wrong, functions need to be improved - $tag_string = ''; - - $tag = new Tag($song->tags['0']); - $song->genre = $tag->id; - $song->f_genre = $tag->name; - - $tag_string = self::tags_string($song->tags,'song',$song->id); - - $rating = new Rating($song_id,'song'); - - $art_url = Album::get_art_url($song->album,$_REQUEST['auth']); - - $string .= "<song id=\"$song->id\">\n" . - "\t<title><![CDATA[$song->title]]></title>\n" . - "\t<artist id=\"$song->artist\"><![CDATA[$song->f_artist_full]]></artist>\n" . - "\t<album id=\"$song->album\"><![CDATA[$song->f_album_full]]></album>\n" . - "\t<genre id=\"$song->genre\"><![CDATA[$song->f_genre]]></genre>\n" . - $tag_string . - "\t<track>$song->track</track>\n" . - "\t<time>$song->time</time>\n" . - "\t<mime>$song->mime</mime>\n" . - "\t<url><![CDATA[" . Song::play_url($song->id) . "]]></url>\n" . - "\t<size>$song->size</size>\n" . - "\t<art><![CDATA[" . $art_url . "]]></art>\n" . - "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" . + $tag_string = ''; + + $tag = new Tag($song->tags['0']); + $song->genre = $tag->id; + $song->f_genre = $tag->name; + + $tag_string = self::tags_string($song->tags,'song',$song->id); + + $rating = new Rating($song_id,'song'); + + $art_url = Album::get_art_url($song->album,$_REQUEST['auth']); + + $string .= "<song id=\"$song->id\">\n" . + "\t<title><![CDATA[$song->title]]></title>\n" . + "\t<artist id=\"$song->artist\"><![CDATA[$song->f_artist_full]]></artist>\n" . + "\t<album id=\"$song->album\"><![CDATA[$song->f_album_full]]></album>\n" . + "\t<genre id=\"$song->genre\"><![CDATA[$song->f_genre]]></genre>\n" . + $tag_string . + "\t<track>$song->track</track>\n" . + "\t<time>$song->time</time>\n" . + "\t<mime>$song->mime</mime>\n" . + "\t<url><![CDATA[" . Song::play_url($song->id) . "]]></url>\n" . + "\t<size>$song->size</size>\n" . + "\t<art><![CDATA[" . $art_url . "]]></art>\n" . + "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" . "\t<rating>" . $rating->rating . "</rating>\n" . "\t<vote>" . $democratic->get_vote($row_id) . "</vote>\n" . "</song>\n"; |