diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/song.class.php | 4 | ||||
-rw-r--r-- | lib/class/update.class.php | 251 | ||||
-rw-r--r-- | lib/class/user.class.php | 211 | ||||
-rw-r--r-- | lib/general.lib.php | 2 | ||||
-rw-r--r-- | lib/init.php | 42 | ||||
-rw-r--r-- | lib/ui.lib.php | 54 |
6 files changed, 419 insertions, 145 deletions
diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 36785a36..64c99509 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -799,7 +799,7 @@ class Song { function get_url($session_id='',$force_http='') { /* Define Variables we are going to need */ - $username = scrub_out($GLOBALS['user']->username); + $user_id = scrub_out($GLOBALS['user']->id); $song_id = $this->id; if (conf('require_session')) { @@ -837,7 +837,7 @@ class Song { } } - $url = $web_path . "/play/index.php?song=$song_id&uid=$username$session_string$ds_string&name=/$song_name"; + $url = $web_path . "/play/index.php?song=$song_id&uid=$user_id$session_string$ds_string&name=/$song_name"; return $url; diff --git a/lib/class/update.class.php b/lib/class/update.class.php index bb357806..c2dd6c5f 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -347,6 +347,14 @@ class Update { $version[] = array('version' => '333004','description' => $update_string); + $update_string = '- Moved back to ID for user tracking internally.<br />' . + '- Added date to user_vote to allow sorting by vote time.<br />' . + '- Added Random Method and Object Count Preferences.<br />' . + '- Removed some unused tables/fields.<br />' . + '- Added Label, Catalog # and Language to Extended Song Data Table<br />'; + + $version[] = array('version' => '340001','description' => $update_string); + return $version; } // populate_version @@ -393,6 +401,9 @@ class Update { /* Nuke All Active session before we start the mojo */ $sql = "DELETE * FROM session"; $db_results = mysql_query($sql, dbh()); + + // Prevent the script from timing out, which could be bad + set_time_limit(0); /* Verify that there are no plugins installed //FIXME: provide a link to remove all plugins, otherwise this could turn into a catch 22 @@ -1284,7 +1295,7 @@ class Update { $user = new User(0); while ($results = mysql_fetch_array($db_results)) { - $user->fix_preferences($results[0]); + $user->username_fix_preferences($results[0]); } @@ -1658,7 +1669,7 @@ class Update { $user->fix_preferences('-1'); while ($r = mysql_fetch_assoc($db_results)) { - $user->fix_preferences($r['username']); + $user->username_fix_preferences($r['username']); } // while results /* Last but not least revert play types to downsample or stream */ @@ -1694,7 +1705,7 @@ class Update { $user->fix_preferences('-1'); while ($r = mysql_fetch_assoc($db_results)) { - $user->fix_preferences($r['username']); + $user->username_fix_preferences($r['username']); } // while results $this->set_version('db_version','332011'); @@ -1835,7 +1846,7 @@ class Update { $user->fix_preferences('-1'); while ($r = mysql_fetch_assoc($db_results)) { - $user->fix_preferences($r['username']); + $user->username_fix_preferences($r['username']); } // while results $this->set_version('db_version','332012'); @@ -1975,7 +1986,7 @@ class Update { $user->fix_preferences('-1'); while ($r = mysql_fetch_assoc($db_results)) { - $user->fix_preferences($r['username']); + $user->username_fix_preferences($r['username']); } // while results /* Store all current Stats */ @@ -2111,7 +2122,7 @@ class Update { $user->fix_preferences('-1'); while ($r = mysql_fetch_assoc($db_results)) { - $user->fix_preferences($r['username']); + $user->username_fix_preferences($r['username']); } // while results /* Drop the unused user_catalog table */ @@ -2143,7 +2154,7 @@ class Update { $user->fix_preferences('-1'); while ($r = mysql_fetch_assoc($db_results)) { - $user->fix_preferences($r['username']); + $user->username_fix_preferences($r['username']); } // while results $this->set_version('db_version','333003'); @@ -2174,12 +2185,236 @@ class Update { $user->fix_preferences('-1'); while ($r = mysql_fetch_assoc($db_results)) { - $user->fix_preferences($r['username']); + $user->username_fix_preferences($r['username']); } // while results $this->set_version('db_version','333004'); } // update_333004 + /** + * update_340001 + * This update moves back to the ID for user UID and + * adds date to the user_vote so that it can be sorted + * correctly + */ + function update_340001() { + + + // Build the User -> ID map using the username as the key + $sql = "SELECT `id`,`username` FROM `user`"; + $db_results = mysql_query($sql,dbh()); + + $user_array = array(); + + while ($r = mysql_fetch_assoc($db_results)) { + $username = $r['username']; + $user_array[$username] = sql_escape($r['id']); + } // end while + + // Alter the user table so that you can't have an ID beyond the + // range of the other tables which have to allow for -1 + $sql = "ALTER TABLE `user` CHANGE `id` `id` INT ( 11 ) NOT NULL AUTO_INCREMENT"; + $db_results = mysql_query($sql,dbh()); + + // Now pull the access list users, alter table and then re-insert + $sql = "SELETE DISTINCT(`user`) FROM `access_list`"; + $db_results = mysql_query($sql,dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + // Build the new SQL + $username = $r['user']; + $user_id = $user_array[$username]; + $username = sql_escape($username); + + $sql = "UPDATE `access_list` SET `user`='$user_id' WERE `user`='$username'"; + $update_results = mysql_query($sql,dbh()); + + } // end while access_list + + // Alter the table + $sql = "ALTER TABLE `access_list` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = mysql_query($sql,dbh()); + + // Now pull flagged users, update and alter + $sql = "SELECT DISTINCT(`user`) FROM `flagged`"; + $db_results = mysql_query($sql,dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = sql_escape($username); + + $sql = "UPDATE `flagged` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = mysql_query($sql,dbh()); + + } // end while + + // Alter the table + $sql = "ALTER TABLE `flagged` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = mysql_query($sql,dbh()); + + + // Now fix up the ip history + $sql = "SELECT DISTINCT(`user`) FROM `ip_history`"; + $db_results = mysql_query($sql,dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = sql_escape($username); + + $sql = "UPDATE `ip_history` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = mysql_query($sql,dbh()); + + } // end while + + // Alter the table + $sql = "ALTER TABLE `ip_history` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = mysql_query($sql,dbh()); + + // Now fix now playing + $sql = "SELECT DISTINCT(`user`) FROM `now_playing`"; + $db_results = mysql_query($sql,dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = sql_escape($username); + + $sql = "UPDATE `now_playing` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = mysql_query($sql,dbh()); + + } // end while + + // Alter the table + $sql = "ALTER TABLE `now_playing` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = mysql_query($sql,dbh()); + + // Now fix the playlist table + $sql = "SELECT DISTINCT(`user`) FROM `playlist`"; + $db_results = mysql_query($sql,dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = sql_escape($username); + + $sql = "UPDATE `playlist` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = mysql_query($sql,dbh()); + + } // end while + + // Alter the table + $sql = "ALTER TABLE `playlist` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = mysql_query($sql,dbh()); + + // Drop unused table + $sql = "DROP TABLE `playlist_permission`"; + $db_results = mysql_query($sql,dbh()); + + // Now fix the ratings table + $sql = "SELECT DISTINCT(`user`) FROM `ratings`"; + $db_results = mysql_query($sql,dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = sql_escape($username); + + $sql = "UPDATE `ratings` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = mysql_query($sql,dbh()); + + } // end while + + $sql = "ALTER TABLE `ratings` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = mysql_query($sql,dbh()); + + // Now work on the tag_map + $sql = "ALTER TABLE `tag_map` CHANGE `user_id` `user` INT ( 11 ) NOT NULL"; + $db_results = mysql_query($sql,dbh()); + + // Now fix user preferences + $sql = "SELECT DISTINCT(`user`) FROM `user_preference`"; + $db_results = mysql_query($sql,dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $username = $r['user']; + $user_id = $user_array[$username]; + $username = sql_escape($username); + + $sql = "UPDATE `user_preference` SET `user`='$user_id' WHERE `user`='$username'"; + $update_results = mysql_query($sql,dbh()); + + } // end while + + // Alter the table + $sql = "ALTER TABLE `user_preference` CHANGE `user` `user` INT ( 11 ) NOT NULL"; + $db_results = mysql_query($sql,dbh()); + + // Add a date to the user_vote + $sql = "ALTER TABLE `user_vote` ADD `date` INT( 11 ) UNSIGNED NOT NULL"; + $db_results = mysql_query($sql,dbh()); + + // Add the index for said field + $sql = "ALTER TABLE `user_vote` ADD INDEX(`date`)"; + $db_results = mysql_query($sql,dbh()); + + // Add the thumb fields to album + $sql = "ALTER TABLE `album` ADD `thumb` TINYBLOB NULL ,ADD `thumb_mime` VARCHAR( 128 ) NULL"; + $db_results = mysql_query($sql,dbh()); + + // Now add in the min_object_count preference and the random_method + $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES('min_object_count','0','Min Element Count','5','integer','interface')"; + $db_results = mysql_query($sql,dbh()); + + $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . + "VALUES('random_method','default','Random Method','5','string','interface')"; + $db_results = mysql_query($sql,dbh()); + + // Delete old preference + $sql = "DELETE FROM `preferences` WHERE `name`='min_album_size'"; + $db_results = mysql_query($sql,dbh()); + + // Make Hash a non-required field and smaller + $sql = "ALTER TABLE `song` CHANGE `hash` `hash` VARCHAR ( 64 ) NULL"; + $db_results = mysql_query($sql,dbh()); + + // Make user access an int, nothing else + $sql = "UPDATE `user` SET `access`='100' WHERE `access`='admin'"; + $db_results = mysql_query($sql,dbh()); + + $sql = "UPDATE `user` SET `access`='25' WHERE `access`='user'"; + $db_results = mysql_query($sql,dbh()); + + $sql = "UPDATE `user` SET `access`='5' WHERE `access`='guest'"; + $db_results = mysql_query($sql,dbh()); + + // Alter the table + $sql = "ALTER TABLE `user` CHANGE `access` `access` TINYINT ( 4 ) UNSIGNED NOT NULL"; + $db_results = mysql_query($sql,dbh()); + + // Add in Label and Catalog # and language + $sql = "ALTER TABLE `song_ext_data` ADD `label` VARCHAR ( 128 ) NULL, ADD `catalog_number` VARCHAR ( 128 ) NULL, ADD `language` VARCHAR ( 128 ) NULL"; + $db_results = mysql_query($sql,dbh()); + + /* Fix every users preferences */ + $sql = "SELECT `id` FROM `user`"; + $db_results = mysql_query($sql,dbh()); + + $user = new User(); + $user->fix_preferences('-1'); + + while ($r = mysql_fetch_assoc($db_results)) { + $user->fix_preferences($r['id']); + } // while results + + $this->set_version('db_version','340001'); + + return true; + + } //update_340001 + } // end update class ?> diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 97ae99c9..87fa825c 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -47,18 +47,17 @@ class User { * class, it currently takes a username * //FIXME take UID */ - function User($username=0) { + function User($id=0) { - if (!$username) { + if (!$id) { return true; } - $this->username = sql_escape($username); + $this->id = $id; $info = $this->_get_info(); if (!count($info)) { return false; } - $this->id = $this->username; $this->uid = $info->id; $this->username = $info->username; $this->fullname = $info->fullname; @@ -82,13 +81,9 @@ class User { */ function _get_info() { - /* Hack during transition back to UID for user creation */ - if (is_numeric($this->username)) { - $sql = "SELECT * FROM user WHERE id='" . $this->username . "'"; - } - else { - $sql = "SELECT * FROM user WHERE username='$this->username'"; - } + $id = sql_escape($this->id); + + $sql = "SELECT * FROM `user` WHERE `id`='" . $id . "'"; $db_results = mysql_query($sql, dbh()); @@ -108,7 +103,7 @@ class User { function get_preferences($user_id=0,$type=0) { if (!$user_id) { - $user_id = $this->username; + $user_id = $this->id; } if (!conf('use_auth')) { $user_id = '-1'; } @@ -279,7 +274,7 @@ class User { */ function is_logged_in() { - $sql = "SELECT id FROM session WHERE username='$this->username'" . + $sql = "SELECT id FROM session WHERE `id`='$this->id'" . " AND expire > ". time(); $db_results = mysql_query($sql,dbh()); @@ -298,13 +293,9 @@ class User { */ function has_access($needed_level) { - if ($this->access == "admin") { $level = 100; } - elseif ($this->access == "user") { $level = 25; } - else { $level = $this->access; } - if (!conf('use_auth') || conf('demo_mode')) { return true; } - if ($level >= $needed_level) { return true; } + if ($this->access >= $needed_level) { return true; } return false; @@ -377,7 +368,7 @@ class User { function update_username($new_username) { $new_username = sql_escape($new_username); - $sql = "UPDATE user SET username='$new_username' WHERE username='$this->username'"; + $sql = "UPDATE `user` SET `username`='$new_username' WHERE `id`='$this->id'"; $this->username = $new_username; $db_results = mysql_query($sql, dbh()); @@ -392,7 +383,7 @@ class User { function update_validation($new_validation) { $new_validation = sql_escape($new_validation); - $sql = "UPDATE user SET validation='$new_validation',disabled='1' WHERE username='$this->username'"; + $sql = "UPDATE user SET validation='$new_validation',disabled='1' WHERE `id`='$this->id'"; $this->validation = $new_validation; $db_results = mysql_query($sql, dbh()); @@ -407,7 +398,7 @@ class User { function update_fullname($new_fullname) { $new_fullname = sql_escape($new_fullname); - $sql = "UPDATE user SET fullname='$new_fullname' WHERE username='$this->id'"; + $sql = "UPDATE user SET fullname='$new_fullname' WHERE `id`='$this->id'"; $db_results = mysql_query($sql, dbh()); } // update_fullname @@ -419,7 +410,7 @@ class User { function update_email($new_email) { $new_email = sql_escape($new_email); - $sql = "UPDATE user SET email='$new_email' WHERE username='$this->id'"; + $sql = "UPDATE user SET email='$new_email' WHERE `id`='$this->id'"; $db_results = mysql_query($sql, dbh()); } // update_email @@ -431,11 +422,47 @@ class User { function update_offset($new_offset) { $new_offset = sql_escape($new_offset); - $sql = "UPDATE user SET offset_limit='$new_offset' WHERE username='$this->id'"; + $sql = "UPDATE user SET offset_limit='$new_offset' WHERE `id`='$this->id'"; $db_results = mysql_query($sql, dbh()); } // update_offset + /** + * disable + * This disables the current user + */ + function disable() { + + // Make sure we aren't disabling the last admin + $sql = "SELECT `id` FROM `user` WHERE `disabled` = '0' AND `id` != '" . $this->id . "' AND `access`='100'"; + $db_results = mysql_query($sql,dbh()); + + if (!mysql_num_rows($db_results)) { return false; } + + $sql = "UPDATE `user` SET `disabled`='1' WHERE id='" . $this->id . "'"; + $db_results = mysql_query($sql,dbh()); + + // Delete any sessions they may have + $sql = "DELETE FROM `session` WHERE `username`='" . sql_escape($this->username) . "'"; + $db_results = mysql_query($sql,dbh()); + + return true; + + } // disable + + /** + * enable + * this enables the current user + */ + function enable() { + + $sql = "UPDATE `user` SET `disabled`='0' WHERE id='" . $this->id . "'"; + $db_results = mysql_query($sql,dbh()); + + return true; + + } // enable + /** * update_access * updates their access level @@ -443,37 +470,16 @@ class User { */ function update_access($new_access) { - /* Check for all disable */ - if ($new_access == 'disabled') { - $sql = "SELECT username FROM user WHERE disabled != '1' AND username != '$this->username'"; - $db_results = mysql_query($sql,dbh()); - if (!mysql_num_rows($db_results)) { return false; } - } - /* Prevent Only User accounts */ - if ($new_access == 'user') { + if ($new_access == '25') { $sql = "SELECT username FROM user WHERE (access='admin' OR access='100') AND username != '$this->username'"; $db_results = mysql_query($sql, dbh()); if (!mysql_num_rows($db_results)) { return false; } } - if ($new_access == 'enabled') { - $new_access = sql_escape($new_access); - $sql = "UPDATE user SET disabled='0' WHERE username='$this->username'"; - $db_results = mysql_query($sql, dbh()); - - } - elseif ($new_access == 'disabled') { - $sql = "UPDATE user SET disabled='1' WHERE username='$this->username'"; - $db_results = mysql_query($sql, dbh()); - $sql = "DELETE FROM session WHERE username='" . sql_escape($this->username) . "'"; - $db_results = mysql_query($sql, dbh()); - } - else { - $new_access = sql_escape($new_access); - $sql = "UPDATE user SET access='$new_access' WHERE username='$this->username'"; - $db_results = mysql_query($sql, dbh()); - } + $new_access = sql_escape($new_access); + $sql = "UPDATE `user` SET `access`='$new_access' WHERE `id`='$this->id'"; + $db_results = mysql_query($sql, dbh()); } // update_access @@ -483,7 +489,7 @@ class User { */ function update_last_seen() { - $sql = "UPDATE user SET last_seen='" . time() . "' WHERE username='$this->username'"; + $sql = "UPDATE user SET last_seen='" . time() . "' WHERE `id`='$this->id'"; $db_results = mysql_query($sql, dbh()); } // update_last_seen @@ -583,10 +589,13 @@ class User { if (!$db_results) { return false; } + // Get the insert_id + $insert_id = mysql_insert_id(dbh()); + /* Populates any missing preferences, in this case all of them */ - $this->fix_preferences($username); + $this->fix_preferences($insert_id); - return $username; + return $insert_id; } // create @@ -714,16 +723,100 @@ class User { } // format_recommendations /** - * fix_preferences - * this makes sure that the specified user - * has all the correct preferences. This function - * should be run whenever a system preference is run - * it's a cop out... FIXME! - * @todo Fix it so this isn't a hack - * @package User - * @catagory Class + * fix_preferences + * This is the new fix_preferences function, it does the following + * Remove Duplicates from user, add in missing + * If -1 is passed it also removes duplicates from the `preferences` + * table. */ function fix_preferences($user_id=0) { + + if (!$user_id) { + $user_id = $this->id; + } + + $user_id = sql_escape($user_id); + + /* Get All Preferences for the current user */ + $sql = "SELECT * FROM `user_preference` WHERE `user`='$user_id'"; + $db_results = mysql_query($sql,dbh()); + + $results = array(); + + while ($r = mysql_fetch_assoc($db_results)) { + $pref_id = $r['preference']; + /* Check for duplicates */ + if (isset($results[$pref_id])) { + $r['value'] = sql_escape($r['value']); + $sql = "DELETE FROM `user_preference` WHERE `user`='$user_id' AND `preference`='" . $r['preference'] . "' AND" . + " `value`='" . sql_escape($r['value']) . "'"; + $delete_results = mysql_query($sql,dbh()); + } // if its set + else { + $results[$pref_id] = 1; + } + } // end while + + /* 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`,`preferences` " . + "WHERE `user_preference.preference` = `preferences.id` AND `user_preference.user`='-1' AND `preferences.catagory` !='system'"; + $db_results = mysql_query($sql, dbh()); + /* While through our base stuff */ + while ($r = mysql_fetch_object($db_results)) { + $zero_results[$r->preference] = $r->value; + } + } // if not user -1 + + // get me _EVERYTHING_ + $sql = "SELECT * FROM `preferences`"; + + // If not system, exclude system... *gasp* + if ($user_id != '-1') { + $sql .= " WHERE catagory !='system'"; + } + $db_results = mysql_query($sql, dbh()); + + while ($r = mysql_fetch_object($db_results)) { + + /* Check if this preference is set */ + if (!isset($results[$r->id])) { + if (isset($zero_results[$r->id])) { + $r->value = $zero_results[$r->id]; + } + $value = sql_escape($r->value); + $sql = "INSERT INTO user_preference (`user`,`preference`,`value`) VALUES ('$user_id','$r->id','$value')"; + $insert_db = mysql_query($sql, dbh()); + } + } // 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 = mysql_query($sql, dbh()); + + $results = array(); + + while ($r = mysql_fetch_assoc($db_results)) { + $results[] = $r['user']; + } + + foreach ($results as $data) { + $sql = "DELETE FROM user_preference WHERE user='$data'"; + $db_results = mysql_query($sql, dbh()); + } + + + } // fix_preferences + + /** + * username_fix_preferences + * this is an old function that takes a username + * and fixes the preferences based on that it is no longer + * used by has to be maintained due to the update class + */ + function username_fix_preferences($user_id=0) { if (!$user_id) { $user_id = $this->username; diff --git a/lib/general.lib.php b/lib/general.lib.php index e55af3cb..e0070839 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -996,7 +996,7 @@ function invert_boolean($value) { */ function get_user_from_username($username) { - $sql = "SELECT id FROM user WHERE username='" . sql_escape($username) . "'"; + $sql = "SELECT `id` FROM `user` WHERE `username`='" . sql_escape($username) . "'"; $db_results = mysql_query($sql, dbh()); $results = mysql_fetch_assoc($db_results); diff --git a/lib/init.php b/lib/init.php index 49ff4a79..6d8c9158 100644 --- a/lib/init.php +++ b/lib/init.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -67,33 +67,19 @@ if (!$results = read_config($configfile,0)) { } /** This is the version.... fluf nothing more... **/ -$results['version'] = '3.3.3'; -$results['int_config_version'] = '1'; +$results['version'] = '3.4-Alpha1 (Build 001)'; +$results['int_config_version'] = '2'; $results['raw_web_path'] = $results['web_path']; $results['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['web_path']; -$results['catalog_file_pattern']= 'mp3|mpc|m4p|m4a|mp4|aac|ogg|rm|wma|asf|flac|spx|ra|ape|shn|wv'; $results['http_port'] = $_SERVER['SERVER_PORT']; -if (!$results['prefix']) { - $results['prefix'] = $prefix; -} -if (!$results['stop_auth']) { - $results['stop_auth'] = $results['prefix'] . "/modules/vauth/gone.fishing"; -} +$results['prefix'] = $prefix; +$results['stop_auth'] = $results['prefix'] . "/modules/vauth/gone.fishing"; if (!$results['http_port']) { $results['http_port'] = '80'; } if (!$results['site_charset']) { - $results['site_charset'] = "iso-8859-1"; -} -if (!$results['ellipse_threshold_album']) { - $results['ellipse_threshold_album'] = 27; -} -if (!$results['ellipse_threshold_artist']) { - $results['ellipse_threshold_artist'] = 27; -} -if (!$results['ellipse_threshold_title']) { - $results['ellipse_threshold_title'] = 27; + $results['site_charset'] = "UTF-8"; } if (!$results['raw_web_path']) { $results['raw_web_path'] = '/'; @@ -113,11 +99,6 @@ if (!$results['user_ip_cardinality']) { if (!$results['local_length']) { $results['local_length'] = '9000'; } -/* Default it for now until I can get the auto-config updater working */ -if (!$results['tag_order']) { - $results['tag_order'] = array('id3v2','id3v1','vorbiscomment','quicktime','file'); -} - /* Variables needed for vauth Module */ $results['cookie_path'] = $results['raw_web_path']; @@ -162,7 +143,7 @@ require_once(conf('prefix') . "/modules/id3/getid3/getid3.php"); require_once(conf('prefix') . '/modules/id3/vainfo.class.php'); require_once(conf('prefix') . '/modules/infotools/Snoopy.class.php'); require_once(conf('prefix') . '/modules/infotools/AmazonSearchEngine.class.php'); -require_once(conf('prefix') . '/modules/infotools/jamendoSearch.class.php'); +//require_once(conf('prefix') . '/modules/infotools/jamendoSearch.class.php'); require_once(conf('prefix') . '/lib/xmlrpc.php'); require_once(conf('prefix') . '/modules/xmlrpc/xmlrpc.inc'); @@ -257,18 +238,13 @@ if (in_array("http",$results['auth_methods'])) { } // end if http auth -if ($no_session) { - define('NO_SESSION','1'); -} - - // If we don't want a session if (NO_SESSION != '1' AND conf('use_auth')) { /* Verify Their session */ if (!vauth_check_session()) { logout(); exit; } /* Create the new user */ - $user = new User($_SESSION['userdata']['username']); + $user = get_user_from_username($_SESSION['userdata']['username']); /* If they user ID doesn't exist deny them */ if (!$user->uid AND !conf('demo_mode')) { logout(); exit; } @@ -303,7 +279,7 @@ else { session_id(scrub_in($_REQUEST['sessid'])); session_start(); } - $user = new user($sess_results['username']); + $user = get_user_from_username($sess_results['username']); init_preferences(); } diff --git a/lib/ui.lib.php b/lib/ui.lib.php index f676adc5..8a928e3b 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -119,38 +119,6 @@ function access_denied() { } // access_denied /** - * show_users - * shows all users (admin function) - */ -function show_users () { - - $dbh = dbh(); - - // Setup the View Ojbect - $view = new View(); - $view->import_session_view(); - - // if we are returning - if ($_REQUEST['keep_view']) { - $view->initialize(); - } - // If we aren't keeping the view then initlize it - else { - $sql = "SELECT username FROM user"; - $db_results = mysql_query($sql, $dbh); - $total_items = mysql_num_rows($db_results); - if ($match != "Show_all") { $offset_limit = $_SESSION['userdata']['offset_limit']; } - $view = new View($sql, 'admin/users.php','fullname',$total_items,$offset_limit); - } - - $db_result = mysql_query($view->sql, $dbh); - // wow this is stupid - $GLOBALS['view'] = $view; - require(conf('prefix') . "/templates/show_users.inc"); - -} // show_users() - -/** * return_referer * returns the script part of the referer address passed by the web browser * this is not %100 accurate. Also because this is not passed by us we need @@ -1421,19 +1389,21 @@ function xml_get_footer($type){ } //xml_get_footer /** - * show_manage_users - * This is the admin page for showing all of the users + * get_users + * This returns an array of user objects and takes an sql statement */ -function show_manage_users() { +function get_users($sql) { - show_box_top(_('Manage Users')); - echo "<ul>\n\t<li><a href=\"".conf('web_path') . "/admin/users.php?action=show_add_user\">" . _('Add a new user') . "</a></li>\n</ul>\n"; - show_box_bottom(); + $db_results = mysql_query($sql,dbh()); + + $results = array(); - /* Show the Users */ - show_users(); + while ($u = mysql_fetch_assoc($db_results)) { + $results[] = new User($u['id']); + } -} // show_manage_users + return $results; +} // get_users ?> |