diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-02-29 06:14:46 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-02-29 06:14:46 +0000 |
commit | 2c337852cff31297d681fb87d3098cc3d9041101 (patch) | |
tree | 9853ce94387c4cc7756575598dfb1e2de44a8589 /lib | |
parent | c1f2b35e2a18b0752746f5db5794cf18714bc71d (diff) | |
download | ampache-2c337852cff31297d681fb87d3098cc3d9041101.tar.gz ampache-2c337852cff31297d681fb87d3098cc3d9041101.tar.bz2 ampache-2c337852cff31297d681fb87d3098cc3d9041101.zip |
major corrections to reading of preferences and a few misc fixes which I have now forgotten
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/access.class.php | 4 | ||||
-rw-r--r-- | lib/class/api.class.php | 8 | ||||
-rw-r--r-- | lib/class/browse.class.php | 2 | ||||
-rw-r--r-- | lib/class/localplay.class.php | 2 | ||||
-rw-r--r-- | lib/class/metadata.class.php | 4 | ||||
-rw-r--r-- | lib/class/stream.class.php | 13 | ||||
-rw-r--r-- | lib/class/vauth.class.php | 9 | ||||
-rw-r--r-- | lib/init.php | 5 | ||||
-rw-r--r-- | lib/localplay.lib.php | 136 |
9 files changed, 21 insertions, 162 deletions
diff --git a/lib/class/access.class.php b/lib/class/access.class.php index 98fd0b39..bfc7beb9 100644 --- a/lib/class/access.class.php +++ b/lib/class/access.class.php @@ -145,7 +145,7 @@ class Access { return false; } if (Config::get('allow_zip_download') AND $GLOBALS['user']->has_access(25)) { - return $GLOBALS['user']->prefs['download']; + return Config::get('download'); } break; default: @@ -237,7 +237,7 @@ class Access { switch ($type) { case 'localplay': // Check their localplay_level - if ($GLOBALS['user']->prefs['localplay_level'] >= $level) { + if (Config::get('localplay_level') >= $level) { return true; } else { diff --git a/lib/class/api.class.php b/lib/class/api.class.php index f1ff7a33..bd1b7ce0 100644 --- a/lib/class/api.class.php +++ b/lib/class/api.class.php @@ -86,13 +86,19 @@ class Api { $data['type'] = 'api'; $data['value'] = $timestamp; $token = vauth::session_create($data); + // Insert the token into the streamer $stream = new Stream(); $stream->user_id = $client->id; $stream->insert_session($token); debug_event('API','Login Success, passphrase matched','1'); - return array('auth'=>$token,'api'=>self::$version); + // We need to also get the 'last update' of the catalog information in an RFC 2822 Format + $sql = "SELECT MAX(`last_update`) AS `update`,MAX(`last_add`) AS `add` FROM `catalog`"; + $db_results = Dba::query($sql); + $row = Dba::fetch_assoc($db_results); + + return array('auth'=>$token,'api'=>self::$version,'update'=>date("r",$row['update']),'add'=>date("r",$row['add'])); } // match } // end while diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index cf5644b5..98dabce6 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -671,7 +671,7 @@ class Browse { self::$total_objects = count($object_ids); // Limit is based on the users preferences - $limit = $GLOBALS['user']->prefs['offset_limit'] ? $GLOBALS['user']->prefs['offset_limit'] : '25'; + $limit = Config::get('offset_limit') ? Config::get('offset_limit') : '25'; if (count($object_ids) > self::$start) { $object_ids = array_slice($object_ids,self::$start,$limit); diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index 1a4c8bef..7d793fa1 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -206,7 +206,7 @@ class Localplay { $this->_player->uninstall(); // If its our current player, reset player to nothing - if ($GLOBALS['user']->prefs['localplay_controller'] == $this->type) { + if (Config::get('localplay_controller') == $this->type) { Preference::update('localplay_controller',$GLOBALS['user']->id,''); } diff --git a/lib/class/metadata.class.php b/lib/class/metadata.class.php index 9e562090..ca7da903 100644 --- a/lib/class/metadata.class.php +++ b/lib/class/metadata.class.php @@ -47,7 +47,7 @@ class metadata { // For now it's only mystrands OpenStrands::set_auth_token(Config::get('mystrands_developer_key')); - $openstrands = new OpenStrands($GLOBALS['user']->prefs['mystrands_user'],$GLOBALS['user']->prefs['mystrands_pass']); + $openstrands = new OpenStrands(Config::get('mystrands_user'),Config::get('mystrands_pass')); // Make sure auth worked if (!$openstrands) { return false; } @@ -101,7 +101,7 @@ class metadata { // For now it's only mystrands OpenStrands::set_auth_token(Config::get('mystrands_developer_key')); - $openstrands = new OpenStrands($GLOBALS['user']->prefs['mystrands_user'],$GLOBALS['user']->prefs['mystrands_pass']); + $openstrands = new OpenStrands(Config::get('mystrands_user'),Config::get('mystrands_pass')); if (!$openstrands) { return false; } diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 80d05654..fee74523 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -223,9 +223,6 @@ class Stream { } $song = new Song($song_id); if ($song->type == ".flac") { $song->type = ".ogg"; } - if ($GLOBALS['user']->prefs['play_type'] == 'downsample') { - $ds = $GLOBALS['user']->prefs['sample_rate']; - } echo $song->get_url(); } // end foreach @@ -408,7 +405,7 @@ class Stream { //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 - if ($GLOBALS['user']->prefs['embed_xspf'] == 1 ){ + if (Config::get('embed_xspf') == 1 ){ header("Location: ".Config::get('web_path')."/index.php?xspf&play_info=".$GLOBALS['user']->playlist->id); } else { @@ -446,7 +443,7 @@ class Stream { function create_localplay() { // First figure out what their current one is and create the object - $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); + $localplay = new Localplay(Config::get('localplay_controller')); $localplay->connect(); //HACK!!! // Yea.. you know the baby jesus... he's crying right meow @@ -526,7 +523,7 @@ class Stream { $max_bitrate = Config::get('max_bit_rate'); $min_bitrate = Config::get('min_bit_rate'); $time = time(); - $user_sample_rate = $GLOBALS['user']->prefs['sample_rate']; + $user_sample_rate = Config::get('sample_rate'); $browser = new Browser(); if (!$song_name) { @@ -705,9 +702,9 @@ class Stream { if (AJAX_INCLUDE != '1') { return false; } // If we're doin the flash magic then run away as well - if ($GLOBALS['user']->prefs['play_type'] == 'xspf_player') { return false; } + if (Config::get('play_type') == 'xspf_player') { return false; } - switch ($GLOBALS['user']->prefs['playlist_method']) { + switch (Config::get('playlist_method')) { default: case 'clear': case 'default': diff --git a/lib/class/vauth.class.php b/lib/class/vauth.class.php index 5f67e442..b670db2d 100644 --- a/lib/class/vauth.class.php +++ b/lib/class/vauth.class.php @@ -236,7 +236,7 @@ class vauth { $session_name = Config::get('session_name'); Config::set('cookie_life',$remember_length,'1'); - setcookie($session_name . '_remember',"Rappelez-vous, rappelez-vous le 27 mars",time() + $remember_length,'/',Config::get('cookie_domain')); + setcookie($session_name . '_remember',"Rappelez-vous, rappelez-vous le 27 mars",time() + $remember_length,'/'); } // create_remember_cookie @@ -301,13 +301,6 @@ class vauth { // No cookie n go! if (!isset($_COOKIE[$session_name])) { return false; } - $key = scrub_in($_COOKIE[$session_name]); - $data = self::get_session_data($key); - - if (!is_array($data)) { - return false; - } - // Check for a remember me if (isset($_COOKIE[$session_name . '_remember'])) { self::create_remember_cookie(); diff --git a/lib/init.php b/lib/init.php index b86c3108..f63c3add 100644 --- a/lib/init.php +++ b/lib/init.php @@ -144,6 +144,7 @@ require_once $prefix . '/modules/infotools/openstrands.class.php'; $results = Preference::fix_preferences($results); Config::set_by_array($results,1); +debug_event('ZZWANG IS',$wang,'1'); // Modules (These are conditionaly included depending upon config values) if (Config::get('ratings')) { @@ -219,11 +220,10 @@ elseif (!Config::get('use_auth')) { // If Auth, but no session is set else { if (isset($_REQUEST['sessid'])) { - $sess_results = vauth::get_session_data($_REQUEST['sessid']); session_name(Config::get('session_name')); session_id(scrub_in($_REQUEST['sessid'])); session_start(); - $GLOBALS['user'] = User::get_from_username($sess_results['username']); + $GLOBALS['user'] = User::get_from_username($_SESSION['userdata']['username']); } else { $GLOBALS['user'] = new User(); @@ -264,5 +264,4 @@ if (! preg_match('/update\.php/', $_SERVER['PHP_SELF'])) { // For the XMLRPC stuff $GLOBALS['xmlrpc_internalencoding'] = Config::get('site_charset'); - ?> diff --git a/lib/localplay.lib.php b/lib/localplay.lib.php deleted file mode 100644 index 1795fc41..00000000 --- a/lib/localplay.lib.php +++ /dev/null @@ -1,136 +0,0 @@ -<?php -/* - - Copyright (c) 2001 - 2006 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. - -*/ - -/** - * insert_locaplay_preferences - * This takes a controller type and inserts the preferences - * Into the database, it is able to handle existing preferences - * It checks before inserting... - */ -function insert_localplay_preferences($type) { - - /* We can't assume the connect so let's just - * create it then get the preferences - */ - $localplay = new Localplay($type); - - $preferences = $localplay->get_preferences(); - - foreach ($preferences as $preference) { - $name = 'localplay_' . $type . '_' . $preference['name']; - /* Check for an existing record */ - $sql = "SELECT id FROM preferences WHERE name = '" . sql_escape($name) . "'"; - $db_results = mysql_query($sql, dbh()); - - if (mysql_num_rows($db_results)) { continue; } - - insert_preference($name,$preference['description'],$preference['default'],'25',$preference['type'],'streaming'); - - } // end foreach preferences - - /* Fix everyones preferences */ - $sql = "SELECT * FROM `user`"; - $db_results = Dba::query($sql); - - $temp_user = new User(); - $temp_user->fix_preferences('-1'); - - while ($r = mysql_fetch_assoc($db_results)) { - $temp_user->fix_preferences($r['username']); - } // end while - - return true; - -} // insert_localplay_preferences - -/** - * remove_localplay_preferences - * This function has two uses, if it is called with a specific type then it - * just removes the preferences for that type, however it if its called with - * nothing then it removes any set of preferences where the module no longer - * exists - */ -function remove_localplay_preferences($type=0) { - - /* If we've gotten a type wipe and go! */ - if ($type) { - $sql = "DELETE FROM preferences WHERE name LIKE 'localplay_" . sql_escape($type) . "_%'"; - $db_results = mysql_query($sql, dbh()); - return true; - } - - - /* Select everything but our two built-in ones - $sql = "SELECT * FROM preferences WHERE name != 'localplay_level' AND name != 'localplay_controller' AND name LIKE 'localplay_%'"; - $db_results = mysql_query($sql, dbh()); - - $results = array(); - - /* We need to organize by module to make it easy - * to figure out which modules no longer exist - * and wack the preferences... unless we've - * specified a name then just wack those - * preferences - */ - while ($r = mysql_fetch_assoc($db_results)) { - - $name = $r['name']; - preg_match("/localplay_([\w\d\-\]+)_.+/",$name,$matches); - $key = $matches['1']; - - $results[$key] = $r; - - } // end while - - /* If we've got a type */ - //FIXME!!! - - -} // remove_localplay_preferences - -/** - * This function stores the Localplay object - * It checks to see what access level you have - * and creates the localplay object based on that - * @package Local Play - */ -function init_localplay($reload=0) { - - static $localplay; - if ($GLOBALS['user']->prefs['localplay_level'] == '0') { return false; } - - if (!strlen($GLOBALS['user']->prefs['localplay_controller'])) { return false; } - - if ($GLOBALS['user']->prefs['localplay_level'] == '1' AND !is_object($localplay)) { - $localplay = new Localplay(conf('localplay_controller')); - $localplay->connect(); - } - - if ($GLOBALS['user']->prefs['localplay_level'] == '2' AND !is_object($localplay)) { - $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); - $localplay->connect(); - } - - return $localplay; - -} // function init_localplay - -?> |