summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-04-23 20:33:57 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-04-23 20:33:57 +0000
commit13dd43450a56bd72067b6f2350f5d188c5c7e254 (patch)
treeb2bc0d26b1f7f904a15322413a044035aeca0d0f /lib
parenta12f1083e30ae16ded9dc7aa464015ad07413632 (diff)
downloadampache-13dd43450a56bd72067b6f2350f5d188c5c7e254.tar.gz
ampache-13dd43450a56bd72067b6f2350f5d188c5c7e254.tar.bz2
ampache-13dd43450a56bd72067b6f2350f5d188c5c7e254.zip
fixed up part of single album view, show songs is all gone, working on replacement browse method
Diffstat (limited to 'lib')
-rw-r--r--lib/class/access.class.php42
-rw-r--r--lib/class/album.class.php33
-rw-r--r--lib/class/rating.class.php12
-rw-r--r--lib/class/user.class.php26
-rw-r--r--lib/general.lib.php25
-rw-r--r--lib/preferences.php8
-rw-r--r--lib/rating.lib.php2
-rw-r--r--lib/themes.php23
-rw-r--r--lib/ui.lib.php2
9 files changed, 78 insertions, 95 deletions
diff --git a/lib/class/access.class.php b/lib/class/access.class.php
index fc01adfb..dae463de 100644
--- a/lib/class/access.class.php
+++ b/lib/class/access.class.php
@@ -144,26 +144,50 @@ class Access {
$db_results = mysql_query($sql, dbh());
} // delete
+
+ /**
+ * check_function
+ * This checks if a specific functionality is enabled
+ * it takes a type only
+ */
+ public static function check_function($type) {
+
+ switch ($type) {
+ 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 $GLOBALS['user']->prefs['download'];
+ }
+ break;
+ default:
+ return false;
+ break;
+ } // end switch
+
+ } // check_function
/**
- * check
+ * check_network
* This takes a type, ip, user, level and key
* and then returns true or false if they have access to this
* the IP is passed as a dotted quad
*/
- public static function check($type,$ip,$user,$level,$key='') {
+ public static function check_network($type,$ip,$user,$level,$key='') {
// They aren't using access control
// lets just keep on trucking
- if (!conf('access_control')) {
+ if (!Config::get('access_control')) {
return true;
}
// Clean incomming variables
$ip = ip2int($ip);
- $user = sql_escape($user);
- $key = sql_escape($key);
- $level = sql_escape($level);
+ $user = Dba::escape($user);
+ $key = Dba::escape($key);
+ $level = Dba::escape($level);
switch ($type) {
/* This is here because we want to at least check IP before even creating the xml-rpc server
@@ -190,10 +214,10 @@ class Access {
break;
} // end switch on type
- $db_results = mysql_query($sql, dbh());
+ $db_results = Dba::query($sql);
// Yah they have access they can use the mojo
- if (mysql_fetch_row($db_results)) {
+ if (Dba::fetch_row($db_results)) {
return true;
}
@@ -202,7 +226,7 @@ class Access {
return false;
}
- } // check
+ } // check_network
/**
* validate_type
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 5e44af8b..72abfab4 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -97,11 +97,15 @@ class Album {
* get_songs
* gets the songs for this album
*/
- public function get_songs($limit = 0) {
+ public function get_songs($limit = 0,$artist='') {
$results = array();
+
+ if ($artist) {
+ $artist_sql = "AND `artist`='" . Dba::escape($artist) . "'";
+ }
- $sql = "SELECT `id` FROM `song` WHERE `album`='$this->id' ORDER BY `track`, `title`";
+ $sql = "SELECT `id` FROM `song` WHERE `album`='$this->id' $artist_sql ORDER BY `track`, `title`";
if ($limit) { $sql .= " LIMIT $limit"; }
$db_results = Dba::query($sql);
@@ -114,31 +118,6 @@ class Album {
} // get_songs
/**
- * get_song_ids
- * This returns an array of the song id's that are on this album. This is used by the
- * show_songs function and can be pased and artist if you so desire to limit it to that
- */
- function get_song_ids($artist='') {
-
- /* If they pass an artist then constrain it based on the artist as well */
- if ($artist) {
- $artist_sql = " AND artist='" . sql_escape($artist) . "'";
- }
-
- $sql = "SELECT id FROM song WHERE album='" . sql_escape($this->id) . "' $artist_sql ORDER BY track";
- $db_results = mysql_query($sql, dbh());
-
- $results = array();
-
- while ($r = mysql_fetch_assoc($db_results)) {
- $results[] = $r['id'];
- }
-
- return $results;
-
- } // get_song_ids
-
- /**
* format
* This is the format function for this object. It sets cleaned up
* albumĀ information with the base required
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php
index 32a85253..43200f90 100644
--- a/lib/class/rating.class.php
+++ b/lib/class/rating.class.php
@@ -41,7 +41,7 @@ class Rating {
function Rating($id,$type) {
$this->id = intval($id);
- $this->type = sql_escape($type);
+ $this->type = Dba::escape($type);
// Check for the users rating
if ($rating = $this->get_user($GLOBALS['user']->id)) {
@@ -62,12 +62,12 @@ class Rating {
*/
function get_user($user_id) {
- $user_id = sql_escape($user_id);
+ $user_id = Dba::escape($user_id);
$sql = "SELECT rating FROM ratings WHERE user='$user_id' AND object_id='$this->id' AND object_type='$this->type'";
- $db_results = mysql_query($sql, dbh());
+ $db_results = Dba::query($sql);
- $results = mysql_fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
return $results['rating'];
@@ -83,11 +83,11 @@ class Rating {
function get_average() {
$sql = "SELECT user_rating as rating FROM ratings WHERE object_id='$this->id' AND object_type='$this->type'";
- $db_results = mysql_query($sql, dbh());
+ $db_results = Dba::query($sql);
$i = 0;
- while ($r = mysql_fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$i++;
$total += $r['rating'];
} // while we're pulling results
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index e50b6bb8..d678ad1c 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -111,36 +111,36 @@ class User {
* []['admin'] = t/f value if this is an admin only section
*/
function get_preferences($user_id=0,$type=0) {
-
- if (!$user_id) {
- $user_id = $this->id;
- }
+
+ // Fill out the user id
+ $user_id = $user_id ? Dba::escape($user_id) : Dba::escape($this->id);
- if (!conf('use_auth')) { $user_id = '-1'; }
+ if (!Config::get('use_auth')) { $user_id = '-1'; }
if ($user_id != '-1') {
$user_limit = "AND preferences.catagory != 'system'";
}
-
+
if ($type != '0') {
- $user_limit = "AND preferences.catagory = '" . sql_escape($type) . "'";
+ $user_limit = "AND preferences.catagory = '" . Dba::escape($type) . "'";
}
- $sql = "SELECT preferences.name, preferences.description, preferences.catagory, user_preference.value FROM preferences,user_preference " .
- "WHERE user_preference.user='$user_id' AND user_preference.preference=preferences.id $user_limit ORDER BY id";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT preferences.name, preferences.description, preferences.catagory, user_preference.value " .
+ "FROM preferences RIGHT JOIN user_preference ON user_preference.preference=preferences.id " .
+ "WHERE user_preference.user='$user_id' $user_limit";
+ $db_results = Dba::query($sql);
/* Ok this is crapy, need to clean this up or improve the code FIXME */
- while ($r = mysql_fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$type = $r['catagory'];
$admin = false;
if ($type == 'system') { $admin = true; }
- $type_array[$type][] = array('name'=>$r['name'],'description'=>$r['description'],'value'=>$r['value']);
+ $type_array[$type][$r['name']] = array('name'=>$r['name'],'description'=>$r['description'],'value'=>$r['value']);
+ ksort($type_array[$type]);
$results[$type] = array ('title'=>ucwords($type),'admin'=>$admin,'prefs'=>$type_array[$type]);
} // end while
-
return $results;
} // get_preferences
diff --git a/lib/general.lib.php b/lib/general.lib.php
index bff578a1..ff641e6f 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -279,27 +279,6 @@ function scrub_in($str) {
} // scrub_in
/*!
- @function batch_ok()
- @discussion return boolean if user can batch download
- //FIXME: This needs to be fixed, it shouldn't be an independent function
- //FIXME: It should reference a central one maybe the access object?
-*/
-function batch_ok( ) {
-
- /* Also make sure that they have ZLIB */
- if (!function_exists('gzcompress')) { return false; }
-
- // i check this before showing any link
- // should make it easy to tie to a new pref if you choose to add it
- if (conf('allow_zip_download') AND $GLOBALS['user']->has_access(25)) {
- return( $GLOBALS['user']->prefs['download'] );
- } // if allowed zip downloads
-
- return false;
-
-} // batch_ok
-
-/*!
@function set_memory_limit
@discussion this function attempts to change the
php memory limit using init_set but it will
@@ -664,7 +643,7 @@ function make_bool($string) {
function get_languages() {
/* Open the locale directory */
- $handle = @opendir(conf('prefix') . '/locale');
+ $handle = @opendir(Config::get('prefix') . '/locale');
if (!is_resource($handle)) {
debug_event('language','Error unable to open locale directory','1');
@@ -677,7 +656,7 @@ function get_languages() {
while ($file = readdir($handle)) {
- $full_file = conf('prefix') . '/locale/' . $file;
+ $full_file = Config::get('prefix') . '/locale/' . $file;
/* Check to see if it's a directory */
if (is_dir($full_file) AND substr($file,0,1) != '.' AND $file != 'base') {
diff --git a/lib/preferences.php b/lib/preferences.php
index 7e8cc62c..5fb1a696 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -268,16 +268,16 @@ function create_preference_input($name,$value) {
else { $is_stream = "selected=\"selected\""; }
echo "<select name=\"$name\">\n";
echo "\t<option value=\"\">" . _('None') . "</option>\n";
- if (conf('allow_stream_playback')) {
+ if (Config::get('allow_stream_playback')) {
echo "\t<option value=\"stream\" $is_stream>" . _('Stream') . "</option>\n";
}
- if (conf('allow_downsample_playback')) {
+ if (Config::get('allow_downsample_playback')) {
echo "\t<option value=\"downsample\" $is_down>" . _('Downsample') . "</option>\n";
}
- if (conf('allow_democratic_playback')) {
+ if (Config::get('allow_democratic_playback')) {
echo "\t<option value=\"democratic\" $is_vote>" . _('Democratic') . "</option>\n";
}
- if (conf('allow_localplay_playback')) {
+ if (Config::get('allow_localplay_playback')) {
echo "\t<option value=\"localplay\" $is_local>" . _('Localplay') . "</option>\n";
}
echo "\t<option value=\"xspf_player\" $is_xspf_player>" . _('XSPF Player') . "</option>\n";
diff --git a/lib/rating.lib.php b/lib/rating.lib.php
index ee589618..8dee7c8e 100644
--- a/lib/rating.lib.php
+++ b/lib/rating.lib.php
@@ -27,7 +27,7 @@ function show_rating($object_id,$type) {
$rating = new Rating($object_id,$type);
- include(conf('prefix') . '/templates/show_object_rating.inc.php');
+ require Config::get('prefix') . '/templates/show_object_rating.inc.php';
} // show_rating
diff --git a/lib/themes.php b/lib/themes.php
index f2f27740..d7b23ace 100644
--- a/lib/themes.php
+++ b/lib/themes.php
@@ -20,31 +20,32 @@
*/
-/*!
- @function get_themes()
- @discussion this looks in /themes and pulls all of the
- theme.cfg.php files it can find and returns an
- array of the results
-*/
+/**
+ * get_themes
+ * this looks in /themes and pulls all of the
+ * theme.cfg.php files it can find and returns an
+ * array of the results
+ */
function get_themes() {
/* Open the themes dir and start reading it */
- $handle = @opendir(conf('prefix') . "/themes");
+ $handle = @opendir(Config::get('prefix') . '/themes');
if (!is_resource($handle)) {
- debug_event('theme',"Error unable to open Themes Directory",'2');
+ debug_event('theme',"Error unable to open Themes Directory",'2');
+ return array();
}
$results = array();
while ($file = readdir($handle)) {
- $full_file = conf('prefix') . "/themes/" . $file;
+ $full_file = Config::get('prefix') . '/themes/' . $file;
/* See if it's a directory */
if (is_dir($full_file) AND substr($file,0,1) != ".") {
- $config_file = $full_file . "/theme.cfg.php";
+ $config_file = $full_file . '/theme.cfg.php';
/* Open the theme.cfg.php file */
- $r = read_config($config_file);
+ $r = @parse_ini_file($config_file);
$r['path'] = $file;
$name = $r['name'];
$results[$name] = $r;
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 9c7fd148..af88b29e 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -837,7 +837,7 @@ function get_location() {
*/
function show_preference_box($preferences) {
- include (conf('prefix') . '/templates/show_preference_box.inc.php');
+ require Config::get('prefix') . '/templates/show_preference_box.inc.php';
} // show_preference_box