diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2009-02-19 02:23:52 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2009-02-19 02:23:52 +0000 |
commit | a9bb2bd1b2c7f061279cae76c4c54ae7c8064db3 (patch) | |
tree | 39d42411c429bec5ea46a62ca15b12f97b3d596f | |
parent | 8857453916e282319db9f2517a4d5aa7ca29a9e7 (diff) | |
download | ampache-a9bb2bd1b2c7f061279cae76c4c54ae7c8064db3.tar.gz ampache-a9bb2bd1b2c7f061279cae76c4c54ae7c8064db3.tar.bz2 ampache-a9bb2bd1b2c7f061279cae76c4c54ae7c8064db3.zip |
cleanup of dead / old functions
-rw-r--r-- | lib/class/catalog.class.php | 88 | ||||
-rw-r--r-- | lib/class/genre.class.php | 259 | ||||
-rw-r--r-- | lib/class/playlist.class.php | 48 | ||||
-rw-r--r-- | lib/class/user.class.php | 11 | ||||
-rw-r--r-- | lib/xmlrpc.php | 12 |
5 files changed, 8 insertions, 410 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 3103c459..29809354 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -573,23 +573,6 @@ class Catalog extends database_object { } // add_files - /*! - @function get_albums - @discussion This gets albums for all songs passed in an array - */ - function get_albums($songs=array()) { - - foreach ($songs as $song_id) { - $sql = "SELECT album FROM song WHERE id='$song_id'"; - $db_results = mysql_query($sql, dbh()); - $results = mysql_fetch_array($db_results); - $albums[] = new Album($results[0]); - } // files - - return $albums; - - } // get_albums - /** * get_album_ids * This returns an array of ids of albums that have songs in this @@ -737,7 +720,6 @@ class Catalog extends database_object { } //get_catalog_files - /** * get_disabled * Gets an array of the disabled songs for all catalogs @@ -749,8 +731,8 @@ class Catalog extends database_object { if ($count) { $limit_clause = " LIMIT $count"; } - $sql = "SELECT id FROM song WHERE enabled='0' $limit_clause"; - $db_results = Dba::query($sql); + $sql = "SELECT `id` FROM `song` WHERE `enabled`='0' $limit_clause"; + $db_results = Dba::read($sql); while ($r = Dba::fetch_assoc($db_results)) { $results[] = new Song($r['id']); @@ -760,72 +742,6 @@ class Catalog extends database_object { } // get_disabled - /*! - @function get_files - @discussion Get's an array of .mp3s and returns the filenames - @param $path Get files starting at root $path - */ - function get_files($path) { - - /* Set it as an empty array */ - $files = array(); - - /* Open up the directory */ - $handle = @opendir($path); - - if (!is_resource($handle)) { echo "<font class=\"error\">" . _("Error: Unable to open") . " $path</font><br />\n"; } - - /* Change dir so we can tell if it's a directory */ - if (!@chdir($path)) { - echo "<font class=\"error\">Error: Unable to change to $path directory</font><br />\n"; - } - - // Determine the slash type and go from there - if (strstr($path,"/")) { - $slash_type = '/'; - } - else { - $slash_type = '\\'; - } - - /* Recurse through this dir and create the files array */ - while ( FALSE !== ($file = @readdir($handle)) ) { - - $full_file = $path . $slash_type . $file; - - /* Incase this is the second time through, unset it before checking */ - unset($failed_check); - - if (conf('no_symlinks')) { - if (is_link($full_file)) { $failed_check = true; } - } - - /* It's a dir */ - if (is_dir($full_file) AND $file != "." AND $file != ".." AND !$failed_check) { - /* Merge the results of the get_files with the current results */ - $files = array_merge($files,$this->get_files($full_file)); - } //isdir - - /* Get the file information */ - $file_info = filesize($full_file); - - $pattern = "/\.[" . conf('catalog_file_pattern') . "]$/i"; - - // REMOVE SECOND PREG_MATCH - if ( preg_match($pattern ,$file) && ($file_info > 0) && (!preg_match("/\.AppleDouble/", $file)) ) { - $files[] = $full_file; - } //is mp3 of at least some size - - } //end while - - /* Close the dir handle */ - @closedir($handle); - - /* Return the files array */ - return $files; - - } //get_files - /** * get_duplicate_songs * This function takes a search type and returns a list of all song_ids that diff --git a/lib/class/genre.class.php b/lib/class/genre.class.php deleted file mode 100644 index 468d727f..00000000 --- a/lib/class/genre.class.php +++ /dev/null @@ -1,259 +0,0 @@ -<?php -/* - - Copyright 2001 - 2007 Ampache.org - All Rights Reserved - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License v2 - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/** - * Genre Class - * This class takes care of the genre object - */ -class Genre { - - /* Variables */ - public $id; - public $name; - - /** - * Constructor - */ - public function __construct($genre_id=0) { - - if (!$genre_id) { return false; } - - $this->id = intval($genre_id); - $info = $this->_get_info(); - $this->name = $info['name']; - - - } // Genre - public static function build_cache($ids, $fields='*') { - $idlist = '(' . implode(',', $ids) . ')'; - $sql = "SELECT $fields FROM genre WHERE id in $idlist"; - $db_results = Dba::query($sql); - global $genre_cache; - $genre_cache = array(); - while ($results = Dba::fetch_assoc($db_results)) { - $genre_cache[intval($results['id'])] = $results; - } - } - /** - * Private Get Info - * This simply returns the information for this genre - */ - private function _get_info() { - global $genre_cache; - if (isset($genre_cache[intval($this->id)])) - return $genre_cache[intval($this->id)]; - $sql = "SELECT * FROM `genre` WHERE `id`='$this->id'"; - $db_results = Dba::query($sql); - - $results = Dba::fetch_assoc($db_results); - - return $results; - - } // _get_info - - /** - * format - * this reformats the genre object so it's all purdy and creates a link var - */ - public function format() { - - $this->f_link = "<a href=\"" . Config::get('web_path') . "/genre.php?action=show_genre&genre_id=" . $this->id . "\">" . scrub_out($this->name) . "</a>"; - - $this->play_link = Config::get('web_path') . '/stream.php?action=genre&genre=' . $this->id; - $this->random_link = Config::get('web_path') . '/stream.php?action=random_genre&genre=' . $this->id; - $this->download_link = Config::get('web_path') . '/batch.php?action=genre&id=' . $this->id; - - } // format - - /** - * get_song_count - * This returns the number of songs in said genre - */ - public function get_song_count() { - - $sql = "SELECT count(`song`.`id`) AS `total` FROM `song` WHERE `genre`='" . $this->id . "'"; - $db_results = Dba::query($sql); - - $total_items = Dba::fetch_assoc($db_results); - - return $total_items['total']; - - } // get_song_count - - /** - * get_album_count - * Returns the number of albums that contain a song of this genre - */ - public function get_album_count() { - - $sql = "SELECT COUNT(DISTINCT(song.album)) FROM `song` WHERE `genre`='" . $this->id . "'"; - $db_results = Dba::query($sql); - - $total_items = Dba::fetch_row($db_results); - - return $total_items['0']; - - } // get_album_count - - /** - * get_artist_count - * Returns the number of artists who have at least one song in this genre - */ - public function get_artist_count() { - - $sql = "SELECT COUNT(DISTINCT(`song`.`artist`)) FROM `song` WHERE `genre`='" . $this->id . "'"; - $db_results = Dba::query($sql); - - $total_items = Dba::fetch_row($db_results); - - return $total_items['0']; - - } // get_artist_count - - /** - * get_songs - * This gets all of the songs in this genre and returns an array of song objects - */ - public function get_songs() { - - $sql = "SELECT `song`.`id` FROM `song` WHERE `genre`='" . $this->id . "'"; - $db_results = Dba::query($sql); - - $results = array(); - - while ($r = Dba::fetch_assoc($db_results)) { - $results[] = $r['id']; - } - - return $results; - - } // get_songs - - /** - * get_random_songs - * This is the same as get_songs except it returns a random assortment of songs from this - * genre - */ - public function get_random_songs() { - - $sql = "SELECT `song`.`id` FROM `song` WHERE `genre`='" . $this->id . "' ORDER BY RAND()"; - $db_results = Dba::query($sql); - - $results = array(); - - while ($r = Dba::fetch_assoc($db_results)) { - $results[] = $r['id']; - } - - return $results; - - } // get_random_songs - - /** - * get_albums - * This gets all of the albums that have at least one song in this genre - * @package Genre - * @catagory Class - */ - function get_albums() { - - $sql = "SELECT DISTINCT(`song`.`album`) FROM `song` WHERE `genre`='" . $this->id . "'"; - $db_results = Dba::query($sql); - - $results = array(); - - while ($r = Dba::fetch_row($db_results)) { - $results[] = $r['0']; - } - - return $results; - - } // get_albums - - /** - * get_artists - * This gets all of the artists who have at least one song in this genre - */ - public function get_artists() { - - $sql = "SELECT DISTINCT(`song`.`artist`) FROM `song` WHERE `genre`='" . $this->id . "'"; - $db_results = Dba::query($sql); - - $results = array(); - - while ($r = Dba::fetch_assoc($db_results)) { - $results[] = $r['artist']; - } - - return $results; - - } // get_artists - - /** - * get_genres - * this returns an array of genres based on a sql statement that's passed - * @package Genre - * @catagory Class - */ - function get_genres($sql) { - - $db_results = mysql_query($sql, dbh()); - - $results = array(); - - while ($r = mysql_fetch_assoc($db_results)) { - $results[] = new Genre($r['id']); - } - - return $results; - - } // get_genres - - /** - * get_sql_from_match - * This is specificly for browsing it takes the match and returns the sql call that we want to use - * @package Genre - * @catagory Class - */ - function get_sql_from_match($match) { - - switch ($match) { - case 'Show_All': - case 'show_all': - case 'Show_all': - $sql = "SELECT `id` FROM `genre`"; - break; - case 'Browse': - case 'show_genres': - $sql = "SELECT `id` FROM `genre`"; - break; - default: - $sql = "SELECT `id` FROM `genre` WHERE `name` LIKE '" . Dba::escape($match) . "%'"; - break; - } // end switch on match - - return $sql; - - } // get_sql_from_match - -} //end of genre class - -?> diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php index 81114946..6fdc1bb5 100644 --- a/lib/class/playlist.class.php +++ b/lib/class/playlist.class.php @@ -208,27 +208,6 @@ class Playlist extends database_object { } // get_songs /** - * get_dyn_songs - * This returns an array of song_ids for a single dynamic playlist entry - */ - function get_dyn_songs($dyn_string) { - - /* Ok honestly I know this is risky, so we have to be - * 100% sure that the user never got to touch this. This - * Query has to return id which must be a song.id - */ - $db_results = mysql_query($dyn_string, dbh()); - $results = array(); - - while ($r = mysql_fetch_assoc($db_results)) { - $results[] = $r['id']; - } // end while - - return $results; - - } // get_dyn_songs - - /** * get_song_count * This simply returns a int of how many song elements exist in this playlist * For now let's consider a dyn_song a single entry @@ -375,33 +354,6 @@ class Playlist extends database_object { } // add_songs /** - * add_dyn_song - * This adds a dynamic song to a specified playlist this is just called as the - * song its self is stored in the session to keep it away from evil users - */ - function add_dyn_song() { - - $dyn_song = $_SESSION['userdata']['stored_search']; - - if (strlen($dyn_song) < 1) { echo "FAILED1"; return false; } - - if (substr($dyn_song,0,6) != 'SELECT') { echo "$dyn_song"; return false; } - - /* Test the query before we put it in */ - $db_results = @mysql_query($dyn_song, dbh()); - - if (!$db_results) { return false; } - - /* Ok now let's add it */ - $sql = "INSERT INTO playlist_data (`playlist`,`dyn_song`,`track`) " . - " VALUES ('" . sql_escape($this->id) . "','" . sql_escape($dyn_song) . "','0')"; - $db_results = mysql_query($sql, dbh()); - - return true; - - } // add_dyn_song - - /** * create * This function creates an empty playlist, gives it a name and type * Assumes $GLOBALS['user']->id as the user diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 5acce399..6be5f03c 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -852,17 +852,6 @@ class User extends database_object { } // fix_preferences - /*! - @function delete_stats - @discussion deletes the stats for this user - */ - function delete_stats() { - - $sql = "DELETE FROM object_count WHERE user='" . $this->id . "'"; - $db_results = mysql_query($sql, dbh()); - - } // delete_stats - /** * delete * deletes this user and everything assoicated with it. This will affect diff --git a/lib/xmlrpc.php b/lib/xmlrpc.php index b3a2612f..ffbf5bdf 100644 --- a/lib/xmlrpc.php +++ b/lib/xmlrpc.php @@ -52,9 +52,9 @@ function remote_catalog_query($m) { $sql = "SELECT name,COUNT(song.id) FROM catalog " . "LEFT JOIN song ON catalog.id = song.catalog " . "WHERE catalog_type='local' GROUP BY catalog.id"; - $db_result = mysql_query($sql, dbh()); + $db_results = Dba::read($sql); - while ( $i = mysql_fetch_row($db_result) ) { + while ( $i = Dba::fetch_row($db_result) ) { $result[] = $i; } @@ -93,14 +93,14 @@ function remote_song_query($params) { // Get me a list of all local catalogs $sql = "SELECT catalog.id FROM catalog WHERE catalog_type='local'"; - $db_results = mysql_query($sql, dbh()); + $db_results = Dba::read($sql); $results = array(); $sql = "SELECT song.id FROM song WHERE song.enabled='1' AND ("; // Get the catalogs and build the query! - while ($r = mysql_fetch_object($db_results)) { + while ($r = Dba::fetch_object($db_results)) { $sql .= " song.catalog='$r->id' OR"; } // build query @@ -108,11 +108,11 @@ function remote_song_query($params) { $sql .= ") LIMIT $start,$step"; - $db_results = mysql_query($sql, dbh()); + $db_results = Dba::read($sql); // Recurse through the songs and build a results // array that is base64_encoded - while ($r = mysql_fetch_object($db_results)) { + while ($r = Dba::fetch_object($db_results)) { $song = new Song($r->id); $song->fill_ext_info(); |