librefm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Librefm-commits] [1553] partial merge from trunk


From: Clint Adams
Subject: [Librefm-commits] [1553] partial merge from trunk
Date: Thu, 14 May 2009 03:55:35 +0000

Revision: 1553
          http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1553
Author:   clint
Date:     2009-05-14 03:55:34 +0000 (Thu, 14 May 2009)
Log Message:
-----------
partial merge from trunk

Modified Paths:
--------------
    branches/stable/nixtape/.htaccess
    branches/stable/nixtape/2.0/index.php
    branches/stable/nixtape/admin/report/mbid-mismatch.php
    branches/stable/nixtape/admin.php
    branches/stable/nixtape/album.php
    branches/stable/nixtape/api/ArtistXML.php
    branches/stable/nixtape/api/UserXML.php
    branches/stable/nixtape/api/auth/index.php
    branches/stable/nixtape/api/xml.php
    branches/stable/nixtape/artist.php
    branches/stable/nixtape/data/Album.php
    branches/stable/nixtape/data/Artist.php
    branches/stable/nixtape/data/Group.php
    branches/stable/nixtape/data/Server.php
    branches/stable/nixtape/data/Statistic.php
    branches/stable/nixtape/data/TagCloud.php
    branches/stable/nixtape/data/Track.php
    branches/stable/nixtape/data/User.php
    branches/stable/nixtape/database.php
    branches/stable/nixtape/database2.php
    branches/stable/nixtape/edit_group.php
    branches/stable/nixtape/explore.php
    branches/stable/nixtape/group.php
    branches/stable/nixtape/install.php
    branches/stable/nixtape/invite.php
    branches/stable/nixtape/js/player.js
    branches/stable/nixtape/listen.php
    branches/stable/nixtape/location.php
    branches/stable/nixtape/login.php
    branches/stable/nixtape/radio/adjust.php
    branches/stable/nixtape/radio/handshake.php
    branches/stable/nixtape/radio/radio-utils.php
    branches/stable/nixtape/radio/xspf.php
    branches/stable/nixtape/rdf.php
    branches/stable/nixtape/register.php
    branches/stable/nixtape/scrobble-proxy.php
    branches/stable/nixtape/templating.php
    branches/stable/nixtape/themes/librefm/alpha.css
    branches/stable/nixtape/themes/librefm/librefm.css
    branches/stable/nixtape/themes/librefm/player.css
    branches/stable/nixtape/themes/librefm/templates/admin.tpl
    branches/stable/nixtape/themes/librefm/templates/album.tpl
    branches/stable/nixtape/themes/librefm/templates/artist.tpl
    branches/stable/nixtape/themes/librefm/templates/edit_group.tpl
    branches/stable/nixtape/themes/librefm/templates/explore-artists.tpl
    branches/stable/nixtape/themes/librefm/templates/footer.tpl
    branches/stable/nixtape/themes/librefm/templates/group-list.tpl
    branches/stable/nixtape/themes/librefm/templates/group.tpl
    branches/stable/nixtape/themes/librefm/templates/invite.tpl
    branches/stable/nixtape/themes/librefm/templates/listen.tpl
    branches/stable/nixtape/themes/librefm/templates/location-country.tpl
    branches/stable/nixtape/themes/librefm/templates/login.tpl
    branches/stable/nixtape/themes/librefm/templates/maxiprofile.tpl
    branches/stable/nixtape/themes/librefm/templates/menu.tpl
    branches/stable/nixtape/themes/librefm/templates/player.tpl
    branches/stable/nixtape/themes/librefm/templates/register.tpl
    branches/stable/nixtape/themes/librefm/templates/request.tpl
    branches/stable/nixtape/themes/librefm/templates/track.tpl
    branches/stable/nixtape/themes/librefm/templates/user-edit.tpl
    branches/stable/nixtape/themes/librefm/templates/user-groups.tpl
    branches/stable/nixtape/themes/librefm/templates/user-journal.tpl
    branches/stable/nixtape/themes/librefm/templates/user-profile.tpl
    branches/stable/nixtape/themes/librefm/templates/user-recent-tracks.tpl
    branches/stable/nixtape/themes/librefm/templates/user-stats.tpl
    branches/stable/nixtape/track.php
    branches/stable/nixtape/user-edit.php
    branches/stable/nixtape/user-groups.php
    branches/stable/nixtape/user-journal.php
    branches/stable/nixtape/user-profile.php
    branches/stable/nixtape/user-recent-tracks.php
    branches/stable/nixtape/user-stats.php
    branches/stable/nixtape/utils/linkeddata.php

Added Paths:
-----------
    branches/stable/nixtape/delete-profile.php
    branches/stable/nixtape/reset.php
    branches/stable/nixtape/themes/librefm/images/header.svg
    branches/stable/nixtape/themes/librefm/images/qm160.svg
    branches/stable/nixtape/themes/librefm/locale/
    branches/stable/nixtape/themes/librefm/locale/README
    branches/stable/nixtape/themes/librefm/locale/de.po
    branches/stable/nixtape/themes/librefm/locale/nixtape.pot
    branches/stable/nixtape/themes/librefm/locale/translatable_strings.c
    branches/stable/nixtape/themes/librefm/locale/update.sh
    branches/stable/nixtape/themes/librefm/templates/adbard.tpl
    branches/stable/nixtape/themes/librefm/templates/delete-profile.tpl
    branches/stable/nixtape/themes/librefm/templates/language-selector.tpl
    branches/stable/nixtape/themes/librefm/templates/mbid-mismatch-report.tpl
    branches/stable/nixtape/themes/librefm/templates/profile-sidebar.tpl
    branches/stable/nixtape/themes/librefm/templates/reset.tpl
    branches/stable/nixtape/utils/licenses.php
    branches/stable/nixtape/utils/random_code_generator.php
    branches/stable/nixtape/utils/resolve-external.php

Removed Paths:
-------------
    branches/stable/nixtape/free.php
    branches/stable/nixtape/i/qm160.svg
    branches/stable/nixtape/licenses.php
    branches/stable/nixtape/recovery.php
    branches/stable/nixtape/resolve-external.php
    branches/stable/nixtape/themes/librefm/templates/recovery.tpl

Modified: branches/stable/nixtape/.htaccess
===================================================================
--- branches/stable/nixtape/.htaccess   2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/.htaccess   2009-05-14 03:55:34 UTC (rev 1553)
@@ -1,4 +1,4 @@
-Options +FollowSymLinks
+Options +FollowSymLinks -MultiViews
 RewriteEngine on
 
 RewriteRule ^user/([^/]+)/?$                                   
user-profile.php?user=$1                [B,NC]

Modified: branches/stable/nixtape/2.0/index.php
===================================================================
--- branches/stable/nixtape/2.0/index.php       2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/2.0/index.php       2009-05-14 03:55:34 UTC (rev 
1553)
@@ -19,51 +19,51 @@
 
 */
 
-require_once('../database.php');
+require_once('../database2.php');
 require_once('../api/ArtistXML.php');
 require_once('../api/UserXML.php');
 
 # Error constants
-define("LFM_INVALID_SERVICE",  2);
-define("LFM_INVALID_METHOD",   3);
-define("LFM_INVALID_TOKEN",    4);
-define("LFM_INVALID_FORMAT",   5);
-define("LFM_INVALID_PARAMS",   6);
-define("LFM_INVALID_RESOURCE", 7);
-define("LFM_TOKEN_ERROR",      8);
-define("LFM_INVALID_SESSION",  9);
-define("LFM_INVALID_APIKEY",   10);
-define("LFM_SERVICE_OFFLINE",  11);
-define("LFM_SUBSCRIPTION_ERROR",12);
-define("LFM_INVALID_SIGNATURE",        13);
-define("LFM_SUBSCRIPTION_REQD",        18);
+define('LFM_INVALID_SERVICE',  2);
+define('LFM_INVALID_METHOD',   3);
+define('LFM_INVALID_TOKEN',    4);
+define('LFM_INVALID_FORMAT',   5);
+define('LFM_INVALID_PARAMS',   6);
+define('LFM_INVALID_RESOURCE', 7);
+define('LFM_TOKEN_ERROR',      8);
+define('LFM_INVALID_SESSION',  9);
+define('LFM_INVALID_APIKEY',   10);
+define('LFM_SERVICE_OFFLINE',  11);
+define('LFM_SUBSCRIPTION_ERROR',12);
+define('LFM_INVALID_SIGNATURE',        13);
+define('LFM_SUBSCRIPTION_REQD',        18);
 
 # Error descriptions as per API documentation
 $error_text = array(
-       LFM_INVALID_SERVICE             => "Invalid service - This service does 
not exist",
-       LFM_INVALID_METHOD              => "Invalid Method - No method with 
that name in this package",
-       LFM_INVALID_TOKEN               => "Invalid authentication token 
supplied",
-       LFM_INVALID_FORMAT              => "Invalid format - This service 
doesn't exist in that format",
-       LFM_INVALID_PARAMS              => "Invalid parameters - Your request 
is missing a required parameter",
-       LFM_INVALID_RESOURCE            => "Invalid resource specified",
-       LFM_TOKEN_ERROR                 => "There was an error granting the 
request token. Please try again later",
-       LFM_INVALID_SESSION             => "Invalid session key - Please 
re-authenticate",
-       LFM_INVALID_APIKEY              => "Invalid API key - You must be 
granted a valid key by last.fm",
-       LFM_SERVICE_OFFLINE             => "Service Offline - This service is 
temporarily offline. Try again later.",
-       LFM_SUBSCRIPTION_ERROR          => "Subscription Error - The user needs 
to be subscribed in order to do that",
-       LFM_INVALID_SIGNATURE           => "Invalid method signature supplied",
-       LFM_SUBSCRIPTION_REQD           => "This user has no free radio plays 
left. Subscription required."
+       LFM_INVALID_SERVICE             => 'Invalid service - This service does 
not exist',
+       LFM_INVALID_METHOD              => 'Invalid Method - No method with 
that name in this package',
+       LFM_INVALID_TOKEN               => 'Invalid authentication token 
supplied',
+       LFM_INVALID_FORMAT              => 'Invalid format - This service 
doesn\'t exist in that format',
+       LFM_INVALID_PARAMS              => 'Invalid parameters - Your request 
is missing a required parameter',
+       LFM_INVALID_RESOURCE            => 'Invalid resource specified',
+       LFM_TOKEN_ERROR                 => 'There was an error granting the 
request token. Please try again later',
+       LFM_INVALID_SESSION             => 'Invalid session key - Please 
re-authenticate',
+       LFM_INVALID_APIKEY              => 'Invalid API key - You must be 
granted a valid key by last.fm',
+       LFM_SERVICE_OFFLINE             => 'Service Offline - This service is 
temporarily offline. Try again later.',
+       LFM_SUBSCRIPTION_ERROR          => 'Subscription Error - The user needs 
to be subscribed in order to do that',
+       LFM_INVALID_SIGNATURE           => 'Invalid method signature supplied',
+       LFM_SUBSCRIPTION_REQD           => 'This user has no free radio plays 
left. Subscription required.'
 );
 
 # Resolves method= parameters to handler functions
 $method_map = array(
-       "auth.gettoken"                 => method_auth_gettoken,
-       "auth.getsession"               => method_auth_getsession,
-       "auth.getmobilesession"         => method_auth_getmobilesession,
-       "artist.getinfo"                => method_artist_getinfo,
-       "artist.gettoptracks"           => method_artist_gettoptracks,
-       "user.getinfo"                  => method_user_getinfo,
-       "user.gettoptracks"             => method_user_gettoptracks
+       'auth.gettoken'                 => method_auth_gettoken,
+       'auth.getsession'               => method_auth_getsession,
+       'auth.getmobilesession'         => method_auth_getmobilesession,
+       'artist.getinfo'                => method_artist_getinfo,
+       'artist.gettoptracks'           => method_artist_gettoptracks,
+       'user.getinfo'                  => method_user_getinfo,
+       'user.gettoptracks'             => method_user_gettoptracks
 );
 
 function method_user_gettoptracks() {
@@ -71,7 +71,7 @@
                report_failure(LFM_INVALID_SIGNATURE);
        }
 
-       header("Content-Type: text/xml");
+       header('Content-Type: text/xml');
        print(XML::prettyXML(UserXML::getTopTracks($_GET['user'], 
$_GET['period'])));
 }
 
@@ -79,7 +79,7 @@
        if (!isset($_GET['user'])) {
                report_failure(LFM_INVALID_SIGNATURE);
        }
-       header("Content-Type: text/xml");
+       header('Content-Type: text/xml');
        print(XML::prettyXML(UserXML::getInfo($_GET['user'])));
 }
 
@@ -87,7 +87,7 @@
        if (!isset($_GET['artist'])) {
                report_failure(LFM_INVALID_SIGNATURE);
        }
-       header("Content-Type: text/xml");
+       header('Content-Type: text/xml');
        print(XML::prettyXML(ArtistXML::getInfo($_GET['artist'])));
 }
 
@@ -95,32 +95,35 @@
        if (!isset($_GET['artist'])) {
        report_failure(LFM_INVALID_SIGNATURE);
        }
-       header("Content-Type: text/xml");
+       header('Content-Type: text/xml');
        print(XML::prettyXML(ArtistXML::getTopTracks($_GET['artist'])));
 
 }
 
 function method_auth_gettoken() {
-       global $mdb2;
+       global $adodb;
 
        if (!isset($_GET['api_sig']) || !valid_api_sig($_GET['api_sig']))
                report_failure(LFM_INVALID_SIGNATURE);
 
        $key = md5(time() . rand());
 
-       $result = $mdb2->query('INSERT INTO Auth (token, expires) VALUES ('
-               . $mdb2->quote($key, 'text') . ", "
-               . $mdb2->quote(time() + 3600, 'integer')
+       try {
+       $result = $adodb->Execute('INSERT INTO Auth (token, expires) VALUES ('
+               . $adodb->qstr($key) . ", "
+               . (int)(time() + 3600)
                . ")");
-       if (PEAR::isError($result))
+       }
+       catch (exception $e) {
                report_failure(LFM_SERVICE_OFFLINE);
+       }
 
        print("<lfm status=\"ok\">\n");
-       print(" <token>$key</token></lfm>");
+       print(" <token>{$key}</token></lfm>");
 }
 
 function method_auth_getmobilesession() {
-       global $mdb2;
+       global $adodb;
 
        if (!isset($_GET['api_sig']) || !valid_api_sig($_GET['api_sig']))
                report_failure(LFM_INVALID_SIGNATURE);
@@ -129,9 +132,11 @@
                report_failure(LFM_INVALID_TOKEN);
 
        // Check for a token that is bound to a user
-       $result = $mdb2->queryRow('SELECT username, password FROM Users WHERE '
-               . 'username = ' . $mdb2->quote($_GET['username'], 'text'));
-       if (PEAR::isError($result)) {
+       try {
+       $result = $adodb->GetRow('SELECT username, password FROM Users WHERE '
+               . 'username = ' . $adodb->qstr($_GET['username']));
+       }
+       catch (exception $e) {
                report_failure(LFM_SERVICE_OFFLINE);
        }
        if (is_null($result)) {
@@ -147,27 +152,30 @@
        $session = md5(time() . rand());
 
        // Update the Auth record with the new session key
-       $result = $mdb2->query('INSERT INTO Auth (token, sk, expires, username) 
'
+       try {
+       $result = $adodb->Execute('INSERT INTO Auth (token, sk, expires, 
username) '
                . 'VALUES ('
-               . $mdb2->quote($key, 'text') . ', '
-               . $mdb2->quote($session, 'text') . ', '
-               . $mdb2->quote(time() + 3600, 'integer') . ', '
-               . $mdb2->quote($username, 'text')
+               . $adodb->qstr($key) . ', '
+               . $adodb->qstr($session) . ', '
+               . (int)(time() + 3600) . ', '
+               . $adodb->qstr($username)
                . ')');
-       if (PEAR::isError($result))
+       }
+       catch (exception $e) {
                report_failure(LFM_SERVICE_OFFLINE);
+       }
 
        print("<lfm status=\"ok\">\n");
        print(" <session>\n");
-       print("         <name>$username</name>\n");
-       print("         <key>$session</key>\n");
+       print("         <name>{$username}</name>\n");
+       print("         <key>{$session}</key>\n");
        print("         <subscriber>0</subscriber>\n");
        print(" </session>\n");
        print("</lfm>");
 }
 
 function method_auth_getsession() {
-       global $mdb2;
+       global $adodb;
 
        if (!isset($_GET['api_sig']) || !valid_api_sig($_GET['api_sig']))
                report_failure(LFM_INVALID_SIGNATURE);
@@ -176,28 +184,34 @@
                report_failure(LFM_INVALID_TOKEN);
 
        // Check for a token that (1) is bound to a user, and (2) is not bound 
to a session
-       $result = $mdb2->query('SELECT username FROM Auth WHERE '
-               . 'token = ' . $mdb2->quote($_GET['token'], 'text') . ' AND '
+       try {
+       $username = $adodb->GetOne('SELECT username FROM Auth WHERE '
+               . 'token = ' . $adodb->qstr($_GET['token']) . ' AND '
                . 'username IS NOT NULL AND sk IS NULL');
-       if (PEAR::isError($result))
+       }
+       catch (exception $e) {
                report_failure(LFM_SERVICE_OFFLINE);
-       if (!$result->numRows())
+       }
+       if (!$username) {
                report_failure(LFM_INVALID_TOKEN);
+       }
 
-       $username = $result->fetchOne(0);
        $session = md5(time() . rand());
 
        // Update the Auth record with the new session key
-       $result = $mdb2->query('UPDATE Auth SET '
-               . 'sk = ' . $mdb2->quote($session, 'text') . ' WHERE '
-               . 'token = ' . $mdb2->quote($_GET['token'], 'text'));
-       if (PEAR::isError($result))
+       try {
+       $result = $adodb->Execute('UPDATE Auth SET '
+               . 'sk = ' . $adodb->qstr($session) . ' WHERE '
+               . 'token = ' . $adodb->qstr($_GET['token']));
+       }
+       catch (exception $e) {
                report_failure(LFM_SERVICE_OFFLINE);
+       }
 
        print("<lfm status=\"ok\">\n");
        print(" <session>\n");
-       print("         <name>$username</name>\n");
-       print("         <key>$session</key>\n");
+       print("         <name>{$username}</name>\n");
+       print("         <key>{$session}</key>\n");
        print("         <subscriber>0</subscriber>\n");
        print(" </session>\n");
        print("</lfm>");
@@ -215,7 +229,7 @@
        global $error_text;
 
        print("<lfm status=\"failed\">\n");
-       print(" <error code=\"$code\">".$error_text[$code]."</error></lfm>");
+       print(" <error code=\"{$code}\">".$error_text[$code]."</error></lfm>");
        die();
 }
 

Modified: branches/stable/nixtape/admin/report/mbid-mismatch.php
===================================================================
--- branches/stable/nixtape/admin/report/mbid-mismatch.php      2009-05-14 
03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/admin/report/mbid-mismatch.php      2009-05-14 
03:55:34 UTC (rev 1553)
@@ -19,7 +19,7 @@
 
 */
 
-require("../../config.php");
+require('../../config.php');
 require_once($install_path . '/database2.php');
 require_once($install_path . '/templating.php');
 require_once($install_path . '/data/sanitize.php');
@@ -36,7 +36,7 @@
        $recordSet->MoveNext();
 }
 
-$smarty->assign("entries", $aEntries);
+$smarty->assign('entries', $aEntries);
 
-$smarty->display("mbid-mismatch-report.tpl");
+$smarty->display('mbid-mismatch-report.tpl');
 ?>

Modified: branches/stable/nixtape/admin.php
===================================================================
--- branches/stable/nixtape/admin.php   2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/admin.php   2009-05-14 03:55:34 UTC (rev 1553)
@@ -28,65 +28,65 @@
 $userlevel = $u_user->userlevel;
 
 function sendEmail($email) {
-    global $mdb2;
-    global $base_url;
-    global $u_user;    
-    $username = $u_user->name;
-    $code = md5(md5($username) . time());
+       global $mdb2;
+       global $base_url;
+       global $u_user;
+       $username = $u_user->name;
+       $code = md5(md5($username) . time());
 
-    // Insert the invitation into the table
-    $sql = 'INSERT INTO Invitations (inviter, code) VALUES (' 
-       . $mdb2->quote($username, 'text') . ', ' 
-       . $mdb2->quote($code, 'text') . ')';
+       // Insert the invitation into the table
+       $sql = 'INSERT INTO Invitations (inviter, code) VALUES ('
+               . $mdb2->quote($username, 'text') . ', '
+               . $mdb2->quote($code, 'text') . ')';
 
-    $affected =& $mdb2->exec($sql);
+       $affected =& $mdb2->exec($sql);
 
-    if (PEAR::isError($affected)) {
-           die($affected->getMessage());
-    }
-      
-    $url = $base_url . '/register.php?authcode=' . $code;
-    $headers = 'From: Libre.fm Invitations <address@hidden>';
-    $subject = 'Libre.fm Invitation';
-    $body = 'Hi!' . "\n\n" . 'You requested an invite to libre.fm, and here it 
is! Just click the link and fill in your details.';
-    $body .= "\n\n" . $url;
-    $body .= "\n\n - The Libre.fm Team";
-    mail($email, $subject, $body, $headers);
-    unset($url, $subject, $body, $headers);
+       if (PEAR::isError($affected)) {
+               die($affected->getMessage());
+       }
+
+       $url = $base_url . '/register.php?authcode=' . $code;
+       $headers = 'From: Libre.fm Invitations <address@hidden>';
+       $subject = 'Libre.fm Invitation';
+       $body = 'Hi!' . "\n\n" . 'You requested an invite to libre.fm, and here 
it is! Just click the link and fill in your details.';
+       $body .= "\n\n" . $url;
+       $body .= "\n\n - The Libre.fm Team";
+       mail($email, $subject, $body, $headers);
+       unset($url, $subject, $body, $headers);
 }
 
-if ($userlevel < 2) {  
-    $smarty->assign("error", "Error!");
-    $smarty->assign("details", "Invalid privileges.");
-    $smarty->display("error.tpl");
-    die();
+if ($userlevel < 2) {
+       $smarty->assign('error', 'Error!');
+       $smarty->assign('details', 'Invalid privileges.');
+       $smarty->display('error.tpl');
+       die();
 } else {
-    $action = $_GET['action'];
-    if (isset($action)) {
-       if ($action == "invite") {
-           if (!isset($_GET['email'])) {       
-               $smarty->assign("error", "Error!");
-               $smarty->assign("details", "Missing email.");
-               $smarty->display("error.tpl");
-               die();
-           } else {
-               // Send the email
-               sendEmail($_GET['email']);
-               $smarty->assign('sent', true);
-               $sql = "UPDATE Invitation_Request SET status=1 WHERE email=" . 
$mdb2->quote($_GET['email'], 'text');
-               $mdb2->exec($sql);
-           }
-       } else {
-           $smarty->assign('error', "Error!");
-           $smarty->assign('error', 'Missing argument!');
-           $smarty->display('error.tpl');
-           die();
+       $action = $_GET['action'];
+       if (isset($action)) {
+               if ($action == 'invite') {
+                       if (!isset($_GET['email'])) {
+                               $smarty->assign('error', 'Error!');
+                               $smarty->assign('details', 'Missing email.');
+                               $smarty->display('error.tpl');
+                               die();
+                       } else {
+                               // Send the email
+                               sendEmail($_GET['email']);
+                               $smarty->assign('sent', true);
+                               $sql = 'UPDATE Invitation_Request SET status=1 
WHERE email=' . $mdb2->quote($_GET['email'], 'text');
+                               $mdb2->exec($sql);
+                       }
+               } else {
+                       $smarty->assign('error', 'Error!');
+                       $smarty->assign('error', 'Missing argument!');
+                       $smarty->display('error.tpl');
+                       die();
+               }
        }
-    }
-    
+
 }
 
-$res = $mdb2->query("SELECT email,status FROM Invitation_Request ORDER BY time 
ASC");
+$res = $mdb2->query('SELECT email,status FROM Invitation_Request ORDER BY time 
ASC');
 $data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
 $smarty->assign('emails', $data);
 $smarty->display('admin.tpl');

Modified: branches/stable/nixtape/album.php
===================================================================
--- branches/stable/nixtape/album.php   2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/album.php   2009-05-14 03:55:34 UTC (rev 1553)
@@ -20,21 +20,31 @@
 */
 
 
-require_once("database.php");
-require_once("templating.php");
-require_once("data/Album.php");
+require_once('database.php');
+require_once('templating.php');
+require_once('data/Album.php');
 
 $album = new Album(urldecode($_GET['album']), urldecode($_GET['artist']));
 $artist = new Artist($album->artist_name);
 
-$smarty->assign("name", $album->name);
-$smarty->assign("artist", $artist);
+$smarty->assign('name', $album->name);
+$smarty->assign('id', $album->id);
+$smarty->assign('artist', $artist);
+$smarty->assign('album', $album);
 $aAlbumTracks = $album->getTracks();
 if (!PEAR::isError($aAlbumTracks )) {
-       $smarty->assign("tracks", $aAlbumTracks);
+       $smarty->assign('tracks', $aAlbumTracks);
 }
 
-$smarty->display("album.tpl");
+$smarty->assign('extra_head_links', array(
+               array(
+                       'rel' => 'meta',
+                       'type' => 'application/rdf+xml' ,
+                       'title' => 'Album Metadata',
+                       'href' => 
$base_url.'/rdf.php?fmt=xml&page='.urlencode(htmlentities(str_replace($base_url,
 '', $album->getURL())))
+                       )
+       ));
 
+$smarty->display('album.tpl');
 
 ?>

Modified: branches/stable/nixtape/api/ArtistXML.php
===================================================================
--- branches/stable/nixtape/api/ArtistXML.php   2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/api/ArtistXML.php   2009-05-14 03:55:34 UTC (rev 
1553)
@@ -32,31 +32,32 @@
         * @param string $lang A 2 character ISO 639 alpha-2 code indicating 
the language to return the information in
         * @return A SimpleXMLElement containing the artist's information
         */
-       public static function getInfo($artistName, $api_key=false, 
$mbid=false, $lang="en") {
+       public static function getInfo($artistName, $api_key=false, 
$mbid=false, $lang='en') {
                // We assume $api_key is valid and set at this point
                
                if (!isset($artistName) && !isset($mbid)) {
-                       echo XML::error("failed", "7", "Invalid resource 
specified");
+                       echo XML::error('failed', '7', 'Invalid resource 
specified');
                        return;
                }
 
                $artist = new Artist($artistName, $mbid);
 
                if (PEAR::isError($artist)) {   
-                       return(XML::error("failed", "7", "Invalid resource 
specified"));
+                       return(XML::error('failed', '7', 'Invalid resource 
specified'));
                }
 
-               $xml = new SimpleXMLElement("<lfm status=\"ok\"></lfm>");
+               $xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
 
-               $artistXml = $xml->addChild("artist", null);
-               $artistXml->addChild("name", utf8_encode($artist->name));
-               $artistXml->addChild("mbid", $artist->mbid);
-               $artistXml->addChild("streamable", $artist->streamable);
+               $artistXml = $xml->addChild('artist', null);
+               $artistXml->addChild('name', $artist->name);
+               $artistXml->addChild('mbid', $artist->mbid);
+               $artistXml->addChild('url', $artist->getURL());
+               $artistXml->addChild('streamable', $artist->streamable);
 
-               $bio = $artistXml->addChild("bio", null);
-               $bio->addChild("published", $artist->bio_published);
-               $bio->addChild("summary", repamp($artist->bio_summary));
-               $bio->addChild("content", repamp($artist->bio_content));
+               $bio = $artistXml->addChild('bio', null);
+               $bio->addChild('published', $artist->bio_published);
+               $bio->addChild('summary', $artist->bio_summary);
+               $bio->addChild('content', $artist->bio_content);
 
                return($xml);
        }
@@ -66,24 +67,23 @@
                $artist = new Artist($artistName);
 
                if (PEAR::isError($artist)) {
-                       return(XML::error("failed", "7", "Invalid resource 
specified"));
+                       return(XML::error('failed', '7', 'Invalid resource 
specified'));
                }
 
-               $xml = new SimpleXMLElement("<lfm status=\"ok\"></lfm>");
-               $root = $xml->addChild("toptracks", null);
-               $root->addAttribute("artist", repamp($artist->name));
+               $xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
+               $root = $xml->addChild('toptracks', null);
+               $root->addAttribute('artist', $artist->name);
 
                $tracks = $artist->getTopTracks(50);
 
                // Loop over every result and add as children to "toptracks".
-               // Encode trackname as utf8 and replace bad symbols with 
html-equivalents
                for($i = 1; $i < count($tracks); $i++) {
-                       $track = $root->addChild("track", null);
-                       $track->addAttribute("rank", $i);
-                       $track->addChild("name", repamp($tracks[$i]->name));
-                       $track->addChild("mbid", $tracks[$i]->mbid);
-                       $track->addChild("playcount", 
$tracks[$i]->getPlayCount());
-                       $track->addChild("listeners", 
$tracks[$i]->getListenerCount());
+                       $track = $root->addChild('track', null);
+                       $track->addAttribute('rank', $i);
+                       $track->addChild('name', $tracks[$i]->name);
+                       $track->addChild('mbid', $tracks[$i]->mbid);
+                       $track->addChild('playcount', 
$tracks[$i]->getPlayCount());
+                       $track->addChild('listeners', 
$tracks[$i]->getListenerCount());
                }
 
                return($xml);   

Modified: branches/stable/nixtape/api/UserXML.php
===================================================================
--- branches/stable/nixtape/api/UserXML.php     2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/api/UserXML.php     2009-05-14 03:55:34 UTC (rev 
1553)
@@ -24,109 +24,109 @@
 
 class UserXML {
 
-    public static function getInfo($username) {
+       public static function getInfo($username) {
 
-       $user = new User($username);
-       if (PEAR::isError($user)) {
-           return(XML::error("failed", "7", "Invalid resource specified"));
+               $user = new User($username);
+               if (PEAR::isError($user)) {
+                       return(XML::error('failed', '7', 'Invalid resource 
specified'));
+               }
+
+               $xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
+               $user_node = $xml->addChild('user', null);
+               $user_node->addChild('name', $user->name);
+               $user_node->addChild('email', $user->email);
+               $user_node->addChild('homepage', $user->homepage);
+               $user_node->addChild('location', $user->location);
+               $user_node->addChild('bio', $user->bio);
+               $user_node->addChild('profile_created', strftime('%c', 
$user->created));
+               if (isset($user->modified))
+                       $user_node->addChild('profile_updated', strftime('%c', 
$user->modified));
+
+               return($xml);
        }
 
-       $xml = new SimpleXMLElement("<lfm status=\"ok\"></lfm>");
-       $user_node = $xml->addChild("user", null);
-       $user_node->addChild("name", $user->name);
-       $user_node->addChild("email", $user->email);
-       $user_node->addChild("homepage", $user->homepage);
-       $user_node->addChild("location", $user->location);
-       $user_node->addChild("bio", $user->bio);
-       $user_node->addChild("profile_created", strftime("%c", $user->created));
-       if (isset($row['modified']))
-           $user_node->addChild("profile_updated", strftime("%c", 
$user->modified));
+       public static function getTopTracks($username, $time) {
+               global $mdb2;
 
-       return($xml);
-    }
+               $timestamp;
+               if (!isset($time))
+                       $time = 'overall';
+               //TODO: Do better, this is too ugly :\
+               if (strcmp($time, 'overall') == 0) {
+                       $timestamp = 0;
+               } else if (strcmp($time, '3month') == 0) {
+                       $timestamp = strtotime('-3 months');
+               } else if (strcmp($time, '6month') == 0) {
+                       $timestamp = strtotime('-6 months');
+               } else if (strcmp($time, '9month') == 0) {
+                       $timestamp = strtotime('-9 months');
+               } else if (strcmp($time, '12month') == 0) {
+                       $timestamp = strtotime('-12 months');
+               } else {
+                       return(XML::error('error', '13', 'Invalid method 
signature supplied'));
+               }
 
-    public static function getTopTracks($username, $time) {
-       global $mdb2;
+               $res = $mdb2->query('SELECT Track.*, Artist.mbid AS artmbid, 
COUNT(*) AS freq
+                       FROM Track, Scrobbles,Artist
+                       WHERE Scrobbles.username = ' . $mdb2->quote($username, 
'text') . '
+                       AND Scrobbles.track = Track.name AND Scrobbles.time > ' 
. $timestamp . ' AND Track.artist = Artist.name
+                       GROUP BY Track.name ORDER BY freq DESC LIMIT 20');
 
-       $timestamp;
-       if (!isset($time)) 
-           $time = "overall";
-       //TODO: Do better, this is too ugly :\
-       if (strcmp($time, "overall") == 0) {
-           $timestamp = 0;
-       } else if (strcmp($time, "3month") == 0) {
-           $timestamp = strtotime('-3 months');
-       } else if (strcmp($time, "6month") == 0) {
-           $timestamp = strtotime('-6 months');
-       } else if (strcmp($time, "9month") == 0) {
-           $timestamp = strtotime('-9 months');
-       } else if (strcmp($time, "12month") == 0) {
-           $timestamp = strtotime('-12 months');
-       } else {
-           return(XML::error("error", "13", "Invalid method signature 
supplied"));
-       }
+               if (PEAR::isError($res) || !$res->numRows()) {
+                       return(XML::error('failed', '7', 'Invalid resource 
specified'));
+               }
+               $xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
 
-       $res = $mdb2->query("SELECT Track.*, Artist.mbid AS artmbid, COUNT(*) 
AS freq 
-           FROM Track, Scrobbles,Artist 
-           WHERE Scrobbles.username =" . $mdb2->quote($username, 'text') . "
-           AND Scrobbles.track = Track.name AND Scrobbles.time > " . 
$timestamp . " AND Track.artist = Artist.name 
-           GROUP BY Track.name ORDER BY freq DESC");
+               $root = $xml->addChild('toptracks', null);
+               $root->addAttribute('user', $username);
+               $root->addAttribute('type', $time);
+               $i = 1;
+               while(($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) {
 
-       if (PEAR::isError($res) || !$res->numRows()) {
-           return(XML::error("failed", "7", "Invalid resource specified"));
-       }
-    
-       $xml = new SimpleXMLElement("<lfm status=\"ok\"></lfm>");
+                       $track = $root->addChild('track', null);
+                       $track->addAttribute('rank', $i);
+                       $track->addChild('name', repamp($row['name']));
 
-       $root = $xml->addChild("toptracks", null);
-       $root->addAttribute("user", $username);
-       $root->addAttribute("type", $time);
-       $i = 1;
-       while(($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) {
+                       $track->addChild('playcount', $row['freq']);
+                       $artist = $track->addChild('artist', 
repamp($row['artist']));
+                       $artist->addChild('mbid', $row['artmbid']);
+                       $i++;
+               }
 
-           $track = $root->addChild("track", null);
-           $track->addAttribute("rank", $i);
-           $track->addChild("name", repamp($row['name']));
-           $track->addChild("playcount", $row['freq']);
-           $artist = $track->addChild("artist", repamp($row['artist']));
-           $artist->addChild("mbid", $row['artmbid']);
-           $i++;
+               return($xml);
+
        }
 
-       return($xml);
+       public static function getRecentTracks($user, $limit) {
+               global $mdb2;
 
-    }
+               if (!isset($limit)) {
+                       $limit = 10;
+               }
 
-    public static function getRecentTracks($user, $limit) {
-       global $mdb2;
+               $res = $mdb2->query('SELECT Track . * , COUNT( * ) AS freq
+                       FROM Track, Scrobbles
+                       WHERE Scrobbles.username = ' . $mdb2->quote($user, 
'text') . '
+                       AND Scrobbles.track = Track.name
+                       GROUP BY Track.name
+                       LIMIT 10');
 
-       if (!isset($limit)) {
-           $limit = 10;
-       }
+               if (PEAR::isError($res) || !$res->numRows()) {
+                       return(XML::error('error', '7', 'Invalid resource 
specified'));
+               }
 
-       $res = $mdb2->query("SELECT Track . * , COUNT( * ) AS freq
-           FROM Track, Scrobbles
-           WHERE Scrobbles.username = " . $mdb2->quote($user, 'text') . "
-           AND Scrobbles.track = Track.name
-           GROUP BY Track.name
-           LIMIT 10");
+               $xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
+               $root = $xml->addChild('recenttracks', null);
+               $root->addAttribute('user', $user);
 
-       if (PEAR::isError($res) || !$res->numRows()) {
-           return(XML::error("error", "7", "Invalid resource specified"));
-       }
+               while (($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) {
+                       $track = $root->addChild('track', null);
+                       $artist = $track->addChild('artist', 
repamp($row['artist']));
+                       $artist->addAttribute('mbid', $row['artmbid']);
+                       $track->addChild('name', repamp($row['name']));
+               }
 
-       $xml = new SimpleXMLElement("<lfm status=\"ok\"></lfm>");
-       $root = $xml->addChild("recenttracks", null);
-       $root->addAttribute("user", $user);
-
-       while (($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) {
-           $track = $root->addChild("track", null);
-           $artist = $track->addChild("artist", repamp($row['artist']));
-           $artist->addAttribute("mbid", $row['artmbid']);
-           $track->addChild("name", repamp($row['name']));
+               return($xml);
        }
-
-       return($xml);
-    }  
 }
 ?>

Modified: branches/stable/nixtape/api/auth/index.php
===================================================================
--- branches/stable/nixtape/api/auth/index.php  2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/api/auth/index.php  2009-05-14 03:55:34 UTC (rev 
1553)
@@ -34,9 +34,9 @@
        . 'username = ' . $mdb2->quote($_POST['username'], 'text') . ' AND '
        . 'password = ' . $mdb2->quote(md5($_POST['password']), 'text'));
 if (PEAR::isError($result))
-       die("Database error");
+       die('Database error');
 if (!$result->numRows())
-       die("Authentication failed");
+       die('Authentication failed');
 
 // Bind the user to the token and cancel the expiration rule
 $result = $mdb2->query('UPDATE Auth SET '
@@ -45,7 +45,7 @@
        . 'WHERE '
        . 'token = ' . $mdb2->quote($_POST['token']));
 if (PEAR::isError($result))
-       die("Database error");
+       die('Database error');
 ?>
 
 <p>Thank you very much, <?php print($_POST['username']); ?>.  Your 
authorization has been recorded.</p>
@@ -64,9 +64,9 @@
        . 'token = ' . $mdb2->quote($_GET['token'], 'text') . ' AND '
        . 'username IS NULL');
 if (PEAR::isError($result))
-       die("Database error");
+       die('Database error');
 if (!$result->numRows())
-       die("Invalid token");
+       die('Invalid token');
 ?>
 
 <form method="post" action="">

Modified: branches/stable/nixtape/api/xml.php
===================================================================
--- branches/stable/nixtape/api/xml.php 2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/api/xml.php 2009-05-14 03:55:34 UTC (rev 1553)
@@ -19,25 +19,26 @@
  */
 
 class XML {
-    public static function prettyXML($xml) {
-       $dom = new DOMDocument('1.0'); 
-       $dom->preserveWhitespace = false;
-       $dom->loadXML(utf8_encode($xml->asXML()));  
-       $dom->formatOutput = true;
-       return($dom->saveXML());
-    } 
 
-    public static function error($status, $errcode, $errtext) {
-       $xml = new SimpleXMLElement("<lfm></lfm>");
-       $xml->addAttribute("status", $status);
-       $error = $xml->addChild("error", $errtext);
-       $error->addAttribute("code", $errcode);
-       return($xml);
-    }
+       public static function prettyXML($xml) {
+               $dom = new DOMDocument('1.0');
+               $dom->preserveWhitespace = false;
+               $dom->loadXML($xml->asXML());
+               $dom->formatOutput = true;
+               return($dom->saveXML());
+       }
+
+       public static function error($status, $errcode, $errtext) {
+               $xml = new SimpleXMLElement('<lfm></lfm>');
+               $xml->addAttribute('status', $status);
+               $error = $xml->addChild('error', $errtext);
+               $error->addAttribute('code', $errcode);
+               return($xml);
+       }
 }
 
 function repamp($input) {
-    $input = str_replace('&', '&amp;', $input);
-    return($input);
+       $input = str_replace('&', '&amp;', $input);
+       return($input);
 }
 ?>

Modified: branches/stable/nixtape/artist.php
===================================================================
--- branches/stable/nixtape/artist.php  2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/artist.php  2009-05-14 03:55:34 UTC (rev 1553)
@@ -28,20 +28,29 @@
 
 $artist = new Artist(urldecode($_GET['artist']));
 
-$smarty->assign("name", $artist->name);
-$smarty->assign("id", $artist->id);
-$smarty->assign("bio_summary", $artist->bio_summary);
+$smarty->assign('name', $artist->name);
+$smarty->assign('id', $artist->id);
+$smarty->assign('bio_summary', $artist->bio_summary);
 
-$aTagCloud = TagCloud::GenerateTagCloud('Free_Scrobbles', 'artist');
+$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
 if (!PEAR::isError ($aTagCloud)) {
         $smarty->assign('tagcloud', $aTagCloud);
 }
 
 $aArtistAlbums = $artist->getAlbums();
 if (!PEAR::isError($aArtistAlbums)) {
-       $smarty->assign("albums", $aArtistAlbums);
+       $smarty->assign('albums', $aArtistAlbums);
 }
 
+$smarty->assign('extra_head_links', array(
+               array(
+                       'rel' => 'meta',
+                       'type' => 'application/rdf+xml' ,
+                       'title' => 'FOAF',
+                       'href' => 
$base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', 
$artist->getURL()))
+                       )
+       ));
+
 $smarty->display("artist.tpl");
 
 

Modified: branches/stable/nixtape/data/Album.php
===================================================================
--- branches/stable/nixtape/data/Album.php      2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/data/Album.php      2009-05-14 03:55:34 UTC (rev 
1553)
@@ -19,16 +19,16 @@
 
 */
 
-require_once($install_path . '/database.php');
+require_once($install_path . '/database2.php');
 require_once($install_path . '/data/Artist.php');
 require_once($install_path . '/data/Track.php');
-require_once($install_path . "/resolve-external.php");
+require_once($install_path . "/utils/resolve-external.php");
 require_once($install_path . '/utils/linkeddata.php');
 
 /**
  * Represents album data
  *
- * General album attributes are accessible as public variables. 
+ * General album attributes are accessible as public variables.
  * Lists of tracks are only generated when requested.
  */
 class Album {
@@ -43,14 +43,16 @@
         * @param string artist The name of the artist who recorded this album
         */
        function __construct($name, $artist) {
-               global $mdb2;
-               $res = $mdb2->query('SELECT name, artist_name, mbid, image, 
releasedate FROM Album WHERE '
-                       . 'name = ' . $mdb2->quote($name, 'text') . ' AND '
-                       . 'artist_name = ' . $mdb2->quote($artist, 'text'));
-               if(!$res->numRows()) {
+               global $adodb;
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $r = $adodb->CacheGetRow(1200,
+                       'SELECT name, artist_name, mbid, image, releasedate 
FROM Album WHERE '
+                       . 'name = ' . $adodb->qstr($name) . ' AND '
+                       . 'artist_name = ' . $adodb->qstr($artist));
+               if(!$r) {
                        $this->name = 'No such album: ' . $name;
                } else {
-                       $row = sanitize($res->fetchRow(MDB2_FETCHMODE_ASSOC));
+                       $row = sanitize($r);
                        $this->name = $row['name'];
                        $this->mbid = $row['mbid'];
                        $this->artist_name = $row['artist_name'];
@@ -60,12 +62,12 @@
                        $this->id = identifierAlbum(null, $this->artist_name, 
null, $this->name, null, null, null, $this->mbid);
 
                        // this hack brought to you by  mattl
-                       //if ($row['image'] == ""){
+                       //if ($row['image'] == ''){
                        //go_get_album_art($this->artist_name, $this->name);
                        //}
                        // mattl hack ovar
 
-                       if($this->image == "") {
+                       if($this->image == '') {
                                $this->image = false;
                        }
                }
@@ -73,17 +75,22 @@
        }
 
        function getPlayCount() {
-               global $mdb2;
-               $res = $mdb2->query("SELECT COUNT(*) AS scrobbles FROM 
Scrobbles JOIN Track ON Scrobbles.track = Track.name WHERE Scrobbles.artist = "
-                       . $mdb2->quote($this->artist_name, 'text') . ' AND 
Track.album_name ='
-                       . $mdb2->quote($this->name, 'text'));
-               if(PEAR::isError($res)) {
+               global $adodb;
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               try {
+               $count = $adodb->CacheGetOne(600,
+                       'SELECT COUNT(*) AS scrobbles FROM Scrobbles JOIN Track 
ON Scrobbles.track = Track.name WHERE Scrobbles.artist = '
+                       . $adodb->qstr($this->artist_name) . ' AND 
Track.album_name ='
+                       . $adodb->qstr($this->name));
+               }
+               catch (exception $e) {
                        reportError($res->getMessage(), $res->getUserInfo());
-               } else if (!$res->numRows()) {
                        $c = 0;
+               }
+               if (!$count) {
+                       $c = 0;
                } else {
-                       $row = sanitize($res->fetchRow(MDB2_FETCHMODE_ASSOC));
-                       $c = $row['scrobbles'];
+                       $c = $count;
                }
                return $c;
        }
@@ -94,11 +101,12 @@
         * @return An array of Track objects
         */
        function getTracks() {
-               global $mdb2;
-               $res = $mdb2->query('SELECT name, artist_name FROM Track WHERE 
artist_name = '
-                       . $mdb2->quote($this->artist_name, 'text') . ' AND 
album_name = '
-                       . $mdb2->quote($this->name));
-               while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+               global $adodb;
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $res = $adodb->CacheGetAll(600, 'SELECT name, artist_name FROM 
Track WHERE artist_name = '
+                       . $adodb->qstr($this->artist_name) . ' AND album_name = 
'
+                       . $adodb->qstr($this->name));
+               foreach($res as &$row) {
                        $tracks[] = new Track($row['name'], 
$row['artist_name']);
                }
 
@@ -120,52 +128,52 @@
 
 
 function go_get_album_art($artist, $album){
-       global $mdb2;
+       global $adodb;
+       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
 
-       $Access_Key_ID = "1EST86JB355JBS3DFE82"; // this is mattl's personal 
key :)
+       $Access_Key_ID = '1EST86JB355JBS3DFE82'; // this is mattl's personal 
key :)
 
        $SearchIndex='Music';
        $Keywords=urlencode($artist.' '.$album);
-       $Operation = "ItemSearch";
-       $Version = "2007-07-16";
-       $ResponseGroup = "ItemAttributes,Images";
+       $Operation = 'ItemSearch';
+       $Version = '2007-07-16';
+       $ResponseGroup = 'ItemAttributes,Images';
        $request=
-               "http://ecs.amazonaws.com/onca/xml";
-               . "?Service=AWSECommerceService"
-               . "&AssociateTag=" . $Associate_tag
-               . "&AWSAccessKeyId=" . $Access_Key_ID
-               . "&Operation=" . $Operation
-               . "&Version=" . $Version
-               . "&SearchIndex=" . $SearchIndex
-               . "&Keywords=" . $Keywords
-               . "&ResponseGroup=" . $ResponseGroup;
+               'http://ecs.amazonaws.com/onca/xml'
+               . '?Service=AWSECommerceService'
+               . '&AssociateTag=' . $Associate_tag
+               . '&AWSAccessKeyId=' . $Access_Key_ID
+               . '&Operation=' . $Operation
+               . '&Version=' . $Version
+               . '&SearchIndex=' . $SearchIndex
+               . '&Keywords=' . $Keywords
+               . '&ResponseGroup=' . $ResponseGroup;
 
-       $aws_xml = simplexml_load_file($request) or die("xml response not 
loading");
+       $aws_xml = simplexml_load_file($request) or die('xml response not 
loading');
 
        $image = $aws_xml->Items->Item->MediumImage->URL;
        $URI = $aws_xml->Items->Item->DetailPageURL;
-       
+
        if ($image) {
 
-               if ($license == "") { $license = "amazon"; }
+               if ($license == '') { $license = 'amazon'; }
 
-               $license = $mdb2->quote($license);
-               $image = $mdb2->quote($image);
-               $album = $mdb2->quote($album);
-               $artist = $mdb2->quote($artist);
+               $license = $adodb->qstr($license);
+               $image = $adodb->qstr($image);
+               $album = $adodb->qstr($album);
+               $artist = $adodb->qstr($artist);
 
-               $sql = ("UPDATE Album SET image = " 
-                       . ($image) . ", "
-                       . " artwork_license = "
-                       . ($license) . " WHERE artist_name = ". ($artist) 
-                       . " AND name = "        . ($album));
+               $sql = ('UPDATE Album SET image = '
+                       . ($image) . ', '
+                       . ' artwork_license = '
+                       . ($license) . ' WHERE artist_name = '. ($artist)
+                       . ' AND name = '        . ($album));
 
-               $res = $mdb2->query($sql);
-
-               if(PEAR::isError($res)) {
-                       die("FAILED " . $res->getMessage() . " query was :" . 
$sql);
+               try {
+                       $res = $adodb->Execute($sql);
                }
-
+               catch (exception $e) {
+                       die('FAILED ' . $e->getMessage() . ' query was :' . 
$sql);
+               }
        }
-       
 }

Modified: branches/stable/nixtape/data/Artist.php
===================================================================
--- branches/stable/nixtape/data/Artist.php     2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/data/Artist.php     2009-05-14 03:55:34 UTC (rev 
1553)
@@ -20,17 +20,17 @@
 */
 
 
-require_once($install_path . '/database.php');
-require_once($install_path . "/data/sanitize.php");
-require_once($install_path . "/data/Album.php");
-require_once($install_path . "/data/Track.php");
-require_once($install_path . "/data/Server.php");
+require_once($install_path . '/database2.php');
+require_once($install_path . '/data/sanitize.php');
+require_once($install_path . '/data/Album.php');
+require_once($install_path . '/data/Track.php');
+require_once($install_path . '/data/Server.php');
 require_once($install_path . '/utils/linkeddata.php');
 
 /**
  * Represents artist data
  *
- * General artist attributes are accessible as public variables. 
+ * General artist attributes are accessible as public variables.
  * Lists of tracks and albums are only generated when requested.
  */
 class Artist {
@@ -46,24 +46,24 @@
         * @param string $mbid The mbid of the artist (optional)
         */
        function __construct($name, $mbid=false) {
-               global $mdb2;
+               global $adodb;
 
-               $res = $mdb2->query("SELECT name, mbid, streamable, 
bio_published, bio_content, bio_summary, image_small, image_medium, image_large 
FROM Artist WHERE "
-                       . "mbid = " . $mdb2->quote($mbid, "text") . " OR "
-                       . "name = " . $mdb2->quote($name, "text"));
-               if(!$res->numRows()) {
-                       return(new PEAR_Error("No such artist: " . $name));
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $row = $adodb->CacheGetRow(1200, 'SELECT name, mbid, 
streamable, bio_published, bio_content, bio_summary, image_small, image_medium, 
image_large FROM Artist WHERE '
+                       . 'mbid = ' . $adodb->qstr($mbid) . ' OR '
+                       . 'name = ' . $adodb->qstr($name));
+               if(!$row) {
+                       return(new PEAR_Error('No such artist: ' . $name));
                } else {
-                       $row = sanitize($res->fetchRow(MDB2_FETCHMODE_ASSOC));
-                       $this->name = $row["name"];
-                       $this->mbid = $row["mbid"];
-                       $this->streamable = $row["streamable"];
-                       $this->bio_published = $row["bio_published"];
-                       $this->bio_content = $row["bio_content"];
-                       $this->bio_summary = $row["bio_summary"];
-                       $this->image_small = $row["image_small"];
-                       $this->image_medium = $row["image_medium"];
-                       $this->image_large = $row["image_large"];
+                       $this->name = $row['name'];
+                       $this->mbid = $row['mbid'];
+                       $this->streamable = $row['streamable'];
+                       $this->bio_published = $row['bio_published'];
+                       $this->bio_content = $row['bio_content'];
+                       $this->bio_summary = $row['bio_summary'];
+                       $this->image_small = $row['image_small'];
+                       $this->image_medium = $row['image_medium'];
+                       $this->image_large = $row['image_large'];
 
                        $this->id = identifierArtist(null, $this->name, null, 
null, null, null, $this->mbid, null);
                }
@@ -75,13 +75,14 @@
         * @return An array of Album objects
         */
        function getAlbums() {
-               global $mdb2;
-               $res = $mdb2->query("SELECT name, image FROM Album WHERE 
artist_name = "
-                       . $mdb2->quote($this->name, "text"));
-               while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
-                       $albums[] = new Album($row["name"], $this->name);
+               global $adodb;
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $res = $adodb->CacheGetAll(600, 'SELECT name, image FROM Album 
WHERE artist_name = '
+                       . $adodb->qstr($this->name));
+               foreach($res as &$row) {
+                       $albums[] = new Album($row['name'], $this->name);
                }
-             
+
                return $albums;
        }
 
@@ -91,11 +92,12 @@
         * @return An array of Track objects
         */
        function getTracks() {
-               global $mdb2;
-               $res = $mdb2->query("SELECT name FROM Track WHERE artist_name = 
"
-                       . $mdb2->quote($this->name, "text"));
-               while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
-                       $tracks[] = new Track($row["name"], $this->name);
+               global $adodb;
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $res = $adodb->CacheGetAll(600, 'SELECT name FROM Track WHERE 
artist_name = '
+                       . $adodb->qstr($this->name));
+               foreach($res as &$row) {
+                       $tracks[] = new Track($row['name'], $this->name);
                }
 
                return $tracks;
@@ -108,14 +110,16 @@
         * @return An array of Track objects
         */
        function getTopTracks($number) {
-               global $mdb2;
-               $res = $mdb2->query("SELECT track, COUNT(track) AS freq, 
COUNT(DISTINCT username) AS listeners FROM Scrobbles WHERE"
-                       . " artist = " . $mdb2->quote($this->name, 'text')
-                       . " GROUP BY track ORDER BY freq DESC LIMIT " . 
$mdb2->quote($number, "integer"));
-               while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
-                       $track = new Track($row["track"], $this->name);
-                       $track->setPlayCount($row["freq"]);
-                       $track->setListenerCount($row["listeners"]);
+               global $adodb;
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $res = $adodb->CacheGetAll(600,
+                       'SELECT track, COUNT(track) AS freq, COUNT(DISTINCT 
username) AS listeners FROM Scrobbles WHERE'
+                       . ' artist = ' . $adodb->qstr($this->name)
+                       . ' GROUP BY track ORDER BY freq DESC LIMIT ' . 
(int)($number));
+               foreach($res as &$row) {
+                       $track = new Track($row['track'], $this->name);
+                       $track->setPlayCount($row['freq']);
+                       $track->setListenerCount($row['listeners']);
                        $tracks[] = $track;
                }
 
@@ -128,12 +132,7 @@
         * @return A string containing the URL of this artist
         */
        function getURL() {
-               global $friendly_urls, $base_url;
-               if($friendly_urls) {
-                       return $base_url . "/artist/" . 
rawurlencode(stripslashes($this->name));
-               } else {
-                       return $base_url . "/artist.php?artist=" . 
rawurlencode(stripslashes($this->name));
-               }
+               return Server::getArtistURL($this->name);
        }
 
 }

Modified: branches/stable/nixtape/data/Group.php
===================================================================
--- branches/stable/nixtape/data/Group.php      2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/data/Group.php      2009-05-14 03:55:34 UTC (rev 
1553)
@@ -52,11 +52,11 @@
                else {
                        global $mdb2;
                        $res = $mdb2->query('SELECT * FROM Groups WHERE 
lower(groupname) = ' . $mdb2->quote(strtolower($name), 'text'));
-                       
+
                        if(PEAR::isError($res)) {
-                               header("Content-Type: text/plain");
+                               header('Content-Type: text/plain');
                                ////($res);
-                               
+
                                exit;
                        }
 
@@ -64,22 +64,22 @@
                                $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
                        }
                }
-                       
+
                if (is_array($row)) {
                        $this->gid          = $row['id'];
                        $this->name         = $row['groupname'];
                        $this->fullname     = $row['fullname'];
                        $this->homepage     = $row['homepage'];
                        $this->bio          = $row['bio'];
-                       $this->avatar_uri   = $row["avatar_uri"];
+                       $this->avatar_uri   = $row['avatar_uri'];
                        $this->owner        = 
User::new_from_uniqueid_number($row['owner']);
                        $this->count        = -1;
                        $this->users        = array();
                        if (! preg_match('/\:/', $this->id))
                                $this->id = $base.'/group/' . 
rawurlencode($this->name) . '#group';
-               }               
+               }
        }
-       
+
        /**
         * Selects a random nixtape group.
         *
@@ -89,7 +89,7 @@
        static function random ()
        {
                global $mdb2;
-               
+
                if ( strtolower(substr($mdb2->phptype, 0, 5)) == 'mysql'  )
                {
                        $random = 'RAND';
@@ -139,9 +139,9 @@
 
                if (in_array(strtolower($name), array('new', 'search')))
                {
-                       return (new PEAR_Error("Not allowed to create a group 
called '$name' (reserved word)!"));
+                       return (new PEAR_Error("Not allowed to create a group 
called '{$name}' (reserved word)!"));
                }
-               
+
                // Check to make sure no existing group with same name 
(case-insensitive).
                $q = sprintf('SELECT groupname FROM Groups WHERE 
LOWER(groupname)=LOWER(%s)'
                                , $mdb2->quote($name, 'text'));
@@ -156,11 +156,11 @@
                        $existing = $row['groupname'];
                        return (new PEAR_Error(
                                        ($existing == $name) ?
-                                       "There is already a group called 
'$existing'." :
-                                       "The name '$name' it too similar to 
existing group '$existing'"
+                                       "There is already a group called 
'{$existing}'." :
+                                       "The name '{$name}' it too similar to 
existing group '{$existing}'"
                                ));
                }
-               
+
                // Create new group
                $q = sprintf('INSERT INTO Groups (groupname, owner, created, 
modified) VALUES (%s, %s, %d, %d)'
                                , $mdb2->quote($name, 'text')
@@ -182,7 +182,7 @@
                }
                elseif (!$res->numRows())
                {
-                       return (new PEAR_Error("Something has gone horribly, 
horribly wrong!"));
+                       return (new PEAR_Error('Something has gone horribly, 
horribly wrong!'));
                }
                $grp = $res->fetchOne(0);
 
@@ -200,33 +200,33 @@
                // Return the newly created group. Callers should check the 
return value.
                return (new Group($name));
        }
-       
+
        static function groupList ($user=false)
        {
                global $mdb2;
 
                if ($user)
                {
-                       $res = $mdb2->query("SELECT gc.* FROM "
-                               . "Group_Members m "
-                               ."INNER JOIN (SELECT g.id, g.groupname, 
g.owner, g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri, 
g.grouptype, COUNT(*) AS member_count "
-                               ."FROM Groups g "
-                               ."LEFT JOIN Group_Members gm ON gm.grp=g.id "
-                               ."GROUP BY g.id, g.groupname, g.owner, 
g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri, 
g.grouptype) gc "
-                               ."ON m.grp=gc.id "
-                               ."WHERE 
m.member=".$mdb2->quote($user->uniqueid, 'integer'));
+                       $res = $mdb2->query('SELECT gc.* FROM '
+                               .'Group_Members m '
+                               .'INNER JOIN (SELECT g.id, g.groupname, 
g.owner, g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri, 
g.grouptype, COUNT(*) AS member_count '
+                               .'FROM Groups g '
+                               .'LEFT JOIN Group_Members gm ON gm.grp=g.id '
+                               .'GROUP BY g.id, g.groupname, g.owner, 
g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri, 
g.grouptype) gc '
+                               .'ON m.grp=gc.id '
+                               .'WHERE 
m.member='.$mdb2->quote($user->uniqueid, 'integer'));
                }
                else
                {
-                       $res = $mdb2->query("SELECT g.groupname, g.owner, 
g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri, 
g.grouptype, COUNT(*) AS member_count "
-                               ."FROM Groups g "
-                               ."LEFT JOIN Group_Members gm ON gm.grp=g.id "
-                               ."GROUP BY g.groupname, g.owner, g.fullname, 
g.bio, g.homepage, g.created, g.modified, g.avatar_uri, g.grouptype");
+                       $res = $mdb2->query('SELECT g.groupname, g.owner, 
g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri, 
g.grouptype, COUNT(*) AS member_count '
+                               .'FROM Groups g '
+                               .'LEFT JOIN Group_Members gm ON gm.grp=g.id '
+                               .'GROUP BY g.groupname, g.owner, g.fullname, 
g.bio, g.homepage, g.created, g.modified, g.avatar_uri, g.grouptype');
                }
-               
+
                if(PEAR::isError($res))
                {
-                       header("Content-Type: text/plain");
+                       header('Content-Type: text/plain');
                        ////($res);
                        exit;
                }
@@ -241,19 +241,19 @@
 
                return $list;
        }
-       
+
        function save ()
        {
                global $mdb2;
-               
-               $q = sprintf("UPDATE Groups SET "
-                               . "owner=%s, "
-                               . "fullname=%s, "
-                               . "homepage=%s, "
-                               . "bio=%s, "
-                               . "avatar_uri=%s, "
-                               . "modified=%d "
-                               . "WHERE groupname=%s"
+
+               $q = sprintf('UPDATE Groups SET '
+                               . 'owner=%s, '
+                               . 'fullname=%s, '
+                               . 'homepage=%s, '
+                               . 'bio=%s, '
+                               . 'avatar_uri=%s, '
+                               . 'modified=%d '
+                               . 'WHERE groupname=%s'
                                , $mdb2->quote($this->owner->uniqueid, 
'integer')
                                , $mdb2->quote($this->fullname, 'text')
                                , $mdb2->quote($this->homepage, 'text')
@@ -261,11 +261,11 @@
                                , $mdb2->quote($this->avatar_uri, 'text')
                                , time()
                                , $mdb2->quote($this->name, 'text'));
-                               
+
                $res = $mdb2->query($q);
-               
+
                if(PEAR::isError($res)) {
-                       header("Content-Type: text/plain");
+                       header('Content-Type: text/plain');
                        ////($res);
                        exit;
                }
@@ -283,13 +283,13 @@
                global $base_uri;
                if (!empty($this->avatar_uri))
                        return $this->avatar_uri;
-               return $base_uri . "themes/" . $default_theme . 
"/images/qm50.png";
+               return $base_uri . 'themes/' . $default_theme . 
'/images/qm50.png';
        }
 
        function getURL() {
                return Server::getGroupURL($this->name);
        }
-       
+
        function getURLAction ($action) {
                $url = $this->getURL();
                if (strstr($url, '?'))
@@ -297,17 +297,17 @@
                else
                        return $url . '?action=' . rawurlencode($action);
        }
-       
+
        function getUsers () {
                global $mdb2;
 
                if (!isset($this->users[0]))
                {
-                       $res = $mdb2->query("SELECT u.* "
-                               . "FROM Users u "
-                               . "INNER JOIN Group_Members gm ON 
u.uniqueid=gm.member "
-                               . "WHERE 
gm.grp=".$mdb2->quote($this->gid,'integer')
-                               . " ORDER BY gm.joined");
+                       $res = $mdb2->query('SELECT u.* '
+                               . 'FROM Users u '
+                               . 'INNER JOIN Group_Members gm ON 
u.uniqueid=gm.member '
+                               . 'WHERE 
gm.grp='.$mdb2->quote($this->gid,'integer')
+                               . ' ORDER BY gm.joined');
                        if ($res->numRows())
                        {
                                while ($row = 
$res->fetchRow(MDB2_FETCHMODE_ASSOC))
@@ -315,7 +315,7 @@
                                        $this->users[ $row['username'] ] = new 
User($row['username'], $row);
                                }
                        }
-                       
+
                        $this->count = count($this->users);
                }
 
@@ -328,22 +328,22 @@
                        return true;
                return false;
        }
-       
+
        function memberJoin ($user) {
                if ($this->memberCheck($user))
                        return false;
-               
+
                global $mdb2;
-               $res = $mdb2->query(sprintf("INSERT INTO Group_Members (grp, 
member, joined) VALUES (%s, %s, %d)",
+               $res = $mdb2->query(sprintf('INSERT INTO Group_Members (grp, 
member, joined) VALUES (%s, %s, %d)',
                        $mdb2->quote($this->gid, 'integer'),
                        $mdb2->quote($user->name, 'text'),
                        time()));
-               
+
                if(PEAR::isError($res))
                {
                        return false;
                }
-                       
+
                $this->users[ $user->name ] = $user;
                return true;
        }
@@ -351,19 +351,19 @@
        function memberLeave ($user) {
                if (!$this->memberCheck($user))
                        return false;
-               
+
                // Group owner cannot leave, so we need a way to reassign 
ownership.
                if ($this->owner->name == $user->name)
                        return false;
-               
+
                global $mdb2;
-               $res = $mdb2->query(sprintf("DELETE FROM Group_Members WHERE 
grp=%s AND member=%s",
+               $res = $mdb2->query(sprintf('DELETE FROM Group_Members WHERE 
grp=%s AND member=%s',
                        $mdb2->quote($this->gid, 'integer'),
                        $mdb2->quote($user->uniqueid, 'integer')));
-               
+
                if(PEAR::isError($res))
                        return false;
-                       
+
                $this->users[ $user->name ] = null;
                // The array key still exists though. That's annoying. PHP 
needs an equivalent of Perl's 'delete'.
                // This shouldn't actually cause us any problems, but people 
should be aware of the oddness.

Modified: branches/stable/nixtape/data/Server.php
===================================================================
--- branches/stable/nixtape/data/Server.php     2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/data/Server.php     2009-05-14 03:55:34 UTC (rev 
1553)
@@ -19,16 +19,16 @@
 
 */
 
-require_once($install_path . '/database.php');
+require_once($install_path . '/database2.php');
 require_once($install_path . '/data/Artist.php');
 // require_once($install_path . '/data/Group.php');
 require_once($install_path . '/data/Track.php');
 require_once($install_path . '/data/User.php');
-require_once($install_path . "/data/sanitize.php");
+require_once($install_path . '/data/sanitize.php');
 require_once($install_path . '/utils/linkeddata.php');
 require_once($install_path . '/utils/arc/ARC2.php');
-require_once($install_path . "/resolve-external.php"); // why isn't this in a 
subdir?
-require_once($install_path . '/licenses.php'); // why isn't this in a subdir?
+require_once($install_path . '/utils/resolve-external.php');
+require_once($install_path . '/utils/licenses.php');
 
 /**
  * Provides access to server-wide data
@@ -44,23 +44,25 @@
         * @return An array of scrobbles or a PEAR_Error in case of failure
         */
        static function getRecentScrobbles($number=10, $username=false) {
-               global $mdb2;
+               global $adodb;
 
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               try {
                if($username) {
-                       $res = $mdb2->query(
-                               "SELECT
-                                       s.username, 
-                                       s.artist, 
-                                       s.track, 
-                                       s.album, 
-                                       s.time, 
-                                       s.mbid, 
+                       $res = $adodb->CacheGetAll(60,
+                               'SELECT
+                                       s.username,
+                                       s.artist,
+                                       s.track,
+                                       s.album,
+                                       s.time,
+                                       s.mbid,
                                        a.mbid AS artist_mbid,
                                        l.mbid AS album_mbid,
                                        l.image AS album_image,
                                        l.artwork_license,
                                        t.license
-                               FROM Scrobbles s 
+                               FROM Scrobbles s
                                LEFT JOIN Artist a
                                        ON s.artist=a.name
                                LEFT JOIN Album l
@@ -70,15 +72,15 @@
                                        ON s.stid = st.id
                                LEFT JOIN Track t
                                        ON st.track = t.id
-                               WHERE lower(s.username) = " . 
$mdb2->quote(strtolower($username), "text") . ' 
+                               WHERE lower(s.username) = ' . 
$adodb->qstr(strtolower($username)) . '
                                ORDER BY
-                                       s.time DESC 
-                               LIMIT ' . $mdb2->quote($number, "integer"));
+                                       s.time DESC
+                               LIMIT ' . (int)($number));
                } else {
-                       $res = $mdb2->query(
-                               "SELECT
+                       $res = $adodb->CacheGetAll(60,
+                               'SELECT
                                        s.username,
-                                       s.artist, 
+                                       s.artist,
                                        s.track,
                                        s.album,
                                        s.time,
@@ -99,27 +101,27 @@
                                LEFT JOIN Track t
                                        ON st.track = t.id
                                ORDER BY
-                                       s.time DESC 
-                               LIMIT " . $mdb2->quote($number, "integer"));
+                                       s.time DESC
+                               LIMIT ' . (int)($number));
                }
-
-               if(PEAR::isError($res)) {
-                       return $res;
                }
+               catch (exception $e) {
+                       return $false;
+               }
 
-               $data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
-               foreach($data as $i) {
+               foreach($res as &$i) {
                        $row = sanitize($i);
-                       
-                       $row["userurl"] = Server::getUserURL($row["username"]);
-                       if ($row['album'])
-                               $row["albumurl"] = 
Server::getAlbumURL($row["artist"], $row["album"]);
-                       $row["artisturl"] = 
Server::getArtistURL($row["artist"]);
-                       $row["trackurl"] = Server::getTrackURL($row['artist'], 
$row['album'], $row['track']);
 
-                       $row['timehuman'] = human_timestamp($row['time']);
-                       $row["timeiso"]   = date('c', (int)$row['time']);
-                       
+                       $row['userurl'] = Server::getUserURL($row['username']);
+                       if ($row['album']) {
+                               $row['albumurl'] = 
Server::getAlbumURL($row['artist'], $row['album']);
+                       }
+                       $row['artisturl'] = 
Server::getArtistURL($row['artist']);
+                       $row['trackurl'] = Server::getTrackURL($row['artist'], 
$row['album'], $row['track']);
+
+                       $row['timehuman'] = human_timestamp($row['time']);
+                       $row['timeiso']   = date('c', (int)$row['time']);
+
                        $row['id']        = 
identifierScrobbleEvent($row['username'], $row['artist'], $row['track'], 
$row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], 
$row['album_mbid']);
                        $row['id_artist'] = identifierArtist($row['username'], 
$row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], 
$row['artist_mbid'], $row['album_mbid']);
                        $row['id_track']  = identifierTrack($row['username'], 
$row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], 
$row['artist_mbid'], $row['album_mbid']);
@@ -131,44 +133,45 @@
                                $row['album_image'] = 
resolve_external_url($row['album_image']);
                        }
 
-                       if ($row['artwork_license'] == "amazon") {
-                               $row['album_image'] = 
str_replace("SL160","SL50",$row['album_image']);
+                       if ($row['artwork_license'] == 'amazon') {
+                               $row['album_image'] = 
str_replace('SL160','SL50',$row['album_image']);
                        }
 
-                       $row["licenseurl"] = $row["license"];
-                       $row["license"] = simplify_license($row["licenseurl"]);
-                       
+                       $row['licenseurl'] = $row['license'];
+                       $row['license'] = simplify_license($row['licenseurl']);
+
                        $result[] = $row;
                }
 
                return $result;
        }
 
-    /**
-     * Retrieves a list of popular artists
-     *
-     * @param int $number The number of artists to return
-     * @return An array of artists or a PEAR_Error in case of failure
-     */
-    static function getTopArtists($number=20) {
-        global $mdb2;
+       /**
+        * Retrieves a list of popular artists
+        *
+        * @param int $number The number of artists to return
+        * @return An array of artists or a PEAR_Error in case of failure
+       */
+       static function getTopArtists($number=20) {
+               global $adodb;
 
-        $res = $mdb2->query("SELECT COUNT(artist) as c, artist FROM Scrobbles 
GROUP BY artist ORDER BY c DESC LIMIT 20");
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               try {
+               $data = $adodb->CacheGetAll(720, 'SELECT COUNT(artist) as c, 
artist FROM Scrobbles GROUP BY artist ORDER BY c DESC LIMIT 20');
+               }
+               catch (exception $e) {
+                       return false;
+               }
 
-        if(PEAR::isError($res)) {
-            return $res;
-        }
+               foreach($data as &$i) {
+                       $row = sanitize($i);
+                       $row['artisturl'] = 
Server::getArtistURL($row['artist']);
+                       $result[] = $row;
+               }
 
-        $data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
-        foreach($data as $i) {
-            $row = sanitize($i);
-            $row["artisturl"] = Server::getArtistURL($row["artist"]);
-            $result[] = $row;
-        }
+               return $result;
+       }
 
-        return $result;
-    }
-
        /**
         * Retrieves a list of the currently playing tracks
         *
@@ -176,10 +179,12 @@
         * @return An array of now playing data or a PEAR_Error in case of 
failure
         */
        static function getNowPlaying($number, $username=false) {
-               global $mdb2;
+               global $adodb;
 
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               try {
                if($username) {
-                       $res = $mdb2->query("SELECT
+                       $data = $adodb->CacheGetAll(60, 'SELECT
                                                username,
                                                n.artist,
                                                n.track,
@@ -200,10 +205,10 @@
                                                AND lower(n.album) = 
lower(t.album_name)
                                                AND lower(n.track) = 
lower(t.name)
                                                AND lower(n.mbid) = 
lower(t.mbid)
-                                       WHERE lower(username) = " . 
$mdb2->quote(strtolower($username), "text") . "
-                                       ORDER BY t.streamable DESC, n.expires 
DESC LIMIT " . $mdb2->quote($number, "integer"));
+                                       WHERE lower(username) = ' . 
$adodb->qstr(strtolower($username)) . '
+                                       ORDER BY t.streamable DESC, n.expires 
DESC LIMIT ' . (int)($number));
                } else {
-                       $res = $mdb2->query("SELECT
+                       $data = $adodb->CacheGetAll(60, 'SELECT
                                                username,
                                                n.artist,
                                                n.track,
@@ -224,35 +229,34 @@
                                                AND lower(n.album) = 
lower(t.album_name)
                                                AND lower(n.track) = 
lower(t.name)
                                                AND lower(n.mbid) = 
lower(t.mbid)
-                                       ORDER BY t.streamable DESC, n.expires 
DESC LIMIT " . $mdb2->quote($number, "integer"));
+                                       ORDER BY t.streamable DESC, n.expires 
DESC LIMIT ' . (int)($number));
                }
-
-               if(PEAR::isError($res)) {
-                       return $res;
                }
+               catch (exception $e) {
+                       return false;
+               }
 
-               $data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
                foreach($data as &$i) {
                        $row = sanitize($i);
                        // this logic should be cleaned up and the free/nonfree 
decision be moved into the smarty templates
-                       if($row["name"] == "") {
-                               $clientstr = 
strip_tags(stripslashes($row["client"])) . " (unknown, <a 
href=\"http://ideas.libre.fm/index.php/Client_Codes\";>please tell us what this 
is</a>)";
+                       if($row['name'] == '') {
+                               $clientstr = 
strip_tags(stripslashes($row['client'])) . ' (unknown, <a 
href=\"http://ideas.libre.fm/index.php/Client_Codes\";>please tell us what this 
is</a>)';
                        } elseif($row["free"] == "Y") {
-                               $clientstr = "<a href=\"" . 
strip_tags(stripslashes($row["url"])) . "\">" . 
strip_tags(stripslashes($row["name"])) . "</a>";
+                               $clientstr = '<a href=\"' . 
strip_tags(stripslashes($row['url'])) . '\">' . 
strip_tags(stripslashes($row['name'])) . '</a>';
                        } else {
-                               $clientstr = "<a 
href=\"http://en.wikipedia.org/wiki/Category:Free_media_players\";>" . 
strip_tags(stripslashes($row["name"])) . "</a>";
+                               $clientstr = '<a 
href=\"http://en.wikipedia.org/wiki/Category:Free_media_players\";>' . 
strip_tags(stripslashes($row['name'])) . '</a>';
                        }
-                       $row["clientstr"] = $clientstr;
-                       $row["userurl"] = Server::getUserURL($row["username"]);
-                       $row["artisturl"] = 
Server::getArtistURL($row["artist"]);
-                       $row["trackurl"] = Server::getTrackURL($row['artist'], 
$row['album'], $row['track']);
-                       
+                       $row['clientstr'] = $clientstr;
+                       $row['userurl'] = Server::getUserURL($row['username']);
+                       $row['artisturl'] = 
Server::getArtistURL($row['artist']);
+                       $row['trackurl'] = Server::getTrackURL($row['artist'], 
$row['album'], $row['track']);
+
                        // We really want to get an image URI from the database 
and only fall back to qm50.png if we can't find an image.
                        $row['albumart'] = $base_url . 'themes/' . 
$default_theme . '/images/qm50.png';
 
-                       $row["licenseurl"] = $row["license"];
-                       $row["license"] = simplify_license($row["licenseurl"]);
-                       
+                       $row['licenseurl'] = $row['license'];
+                       $row['license'] = simplify_license($row['licenseurl']);
+
                        $result[] = $row;
                }
 
@@ -271,9 +275,9 @@
                global $friendly_urls, $base_url;
                if ($component == 'edit')
                {
-                       return $base_url . "/user-edit.php";
+                       return $base_url . '/user-edit.php';
                } elseif ($component == 'delete') {
-                       return $base_url . "/delete-profile.php";
+                       return $base_url . '/delete-profile.php';
                }
                elseif($friendly_urls)
                {
@@ -281,7 +285,7 @@
                                $component = '';
                        else
                                $component = "/{$component}";
-                       return $base_url . "/user/" . rawurlencode($username) . 
$component;
+                       return $base_url . '/user/' . rawurlencode($username) . 
$component;
                }
                else
                {
@@ -292,94 +296,119 @@
        static function getGroupURL($groupname) {
                global $friendly_urls, $base_url;
                if($friendly_urls) {
-                       return $base_url . "/group/" . rawurlencode($groupname);
+                       return $base_url . '/group/' . rawurlencode($groupname);
                } else {
-                       return $base_url . "/group.php?group=" . 
rawurlencode($groupname);
+                       return $base_url . '/group.php?group=' . 
rawurlencode($groupname);
                }
        }
 
        static function getArtistURL($artist) {
                global $friendly_urls, $base_url;
                if($friendly_urls) {
-                       return $base_url . "/artist/" . rawurlencode($artist);
+                       return $base_url . '/artist/' . rawurlencode($artist);
                } else {
-                       return $base_url . "/artist.php?artist=" . 
rawurlencode($artist);
+                       return $base_url . '/artist.php?artist=' . 
rawurlencode($artist);
                }
        }
 
        static function getAlbumURL($artist, $album) {
                global $friendly_urls, $base_url;
                if($friendly_urls) {
-                       return $base_url . "/artist/" . rawurlencode($artist) . 
"/album/" . rawurlencode($album);
+                       return $base_url . '/artist/' . rawurlencode($artist) . 
'/album/' . rawurlencode($album);
                } else {
-                       return $base_url . "/album.php?artist=" . 
rawurlencode($artist) . "&album=" . rawurlencode($album);
+                       return $base_url . '/album.php?artist=' . 
rawurlencode($artist) . '&album=' . rawurlencode($album);
                }
        }
 
        static function getTrackURL($artist, $album, $track) {
                global $friendly_urls, $base_url;
                if ($friendly_urls && $album) {
-                       return $base_url . "/artist/" . rawurlencode($artist) . 
"/album/" . rawurlencode($album) . "/track/" . rawurlencode($track);
+                       return $base_url . '/artist/' . rawurlencode($artist) . 
'/album/' . rawurlencode($album) . '/track/' . rawurlencode($track);
                } elseif ($friendly_urls) {
-                       return $base_url . "/artist/" . rawurlencode($artist) . 
"/track/" . rawurlencode($track);
+                       return $base_url . '/artist/' . rawurlencode($artist) . 
'/track/' . rawurlencode($track);
                } else {
-                       return $base_url . "/track.php?artist=" . 
rawurlencode($artist) .   "&album=" . rawurlencode($album) . "&track=" . 
rawurlencode($track);
+                       return $base_url . '/track.php?artist=' . 
rawurlencode($artist) . '&album=' . rawurlencode($album) . '&track=' . 
rawurlencode($track);
                }
        }
 
        static function getLocationDetails($name) {
-               global $mdb2;
-               
+               global $adodb;
+
                if (!$name)
                        return array();
 
-               $res = $mdb2->query('SELECT p.latitude, p.longitude, p.country, 
c.country_name, c.wikipedia_en '
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $rv = $adodb->GetRow('SELECT p.latitude, p.longitude, 
p.country, c.country_name, c.wikipedia_en '
                        . 'FROM Places p '
                        . 'LEFT JOIN Countries c ON p.country=c.country '
-                       . 'WHERE p.location_uri=' . $mdb2->quote($name, 
'text'));
-               
-               if($res->numRows()) {
-               
-                       $rv = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
-                       
+                       . 'WHERE p.location_uri=' . $adodb->qstr($name, 
'text'));
+
+               if($rv) {
+
                        if (! ($rv['latitude'] && $rv['longitude'] && 
$rv['country'])) {
-                       
+
                                $parser = ARC2::getRDFXMLParser();
                                $parser->parse($name);
                                $index = $parser->getSimpleIndex();
-                               
+
                                $rv = array(
                                        'latitude'  => 
$index[$name]['http://www.w3.org/2003/01/geo/wgs84_pos#lat'][0],
                                        'longitude' => 
$index[$name]['http://www.w3.org/2003/01/geo/wgs84_pos#long'][0],
                                        'country'   => 
strtoupper(substr($index[$name]['http://www.geonames.org/ontology#inCountry'][0],
 -2))
                                        );
 
-                               $mdb2->query(sprintf('UPDATE Places SET 
latitude=%f, longitude=%f, country=%s WHERE location_uri=%s',
+                               $adodb->Execute(sprintf('UPDATE Places SET 
latitude=%f, longitude=%f, country=%s WHERE location_uri=%s',
                                        (float)$rv['latitude'],
                                        (float)$rv['longitude'],
-                                       $mdb2->quote($rv['country'], 'text'),
-                                       $mdb2->quote($name, 'text')));
+                                       $adodb->qstr($rv['country']),
+                                       $adodb->qstr($name)));
                        }
                }
                else {
                        $parser = ARC2::getRDFXMLParser();
                        $parser->parse($name);
                        $index = $parser->getSimpleIndex();
-                       
+
                        $rv = array(
                                'latitude'  => 
$index[$name]['http://www.w3.org/2003/01/geo/wgs84_pos#lat'][0],
                                'longitude' => 
$index[$name]['http://www.w3.org/2003/01/geo/wgs84_pos#long'][0],
                                'country'   => 
strtoupper(substr($index[$name]['http://www.geonames.org/ontology#inCountry'][0],
 -2))
                                );
 
-                       $mdb2->query(sprintf('INSERT INTO Places VALUES (%s, 
%f, %f, %s)',
-                               $mdb2->quote($name, 'text'),
+                       $adodb->Execute(sprintf('INSERT INTO Places VALUES (%s, 
%f, %f, %s)',
+                               $adodb->qstr($name),
                                (float)$rv['latitude'],
                                (float)$rv['longitude'],
-                               $mdb2->quote($rv['country'], 'text')));
+                               $adodb->qstr($rv['country'])));
                }
-                       
+
                return $rv;
        }
 
+       /**
+        * Log in to the radio server
+        *
+        * @param string $station The station to be played
+        * @param string $username The user to associate this session with 
(optional)
+        * @return A string containing the session key to be used for streaming
+        */
+       static function getRadioSession($station, $username = false) {
+               global $adodb;
+               $session_id = md5(mt_rand() . time());
+               if($username) {
+                       $sql = 'INSERT INTO Radio_Sessions(username, session, 
url, expires) VALUES ('
+                               . $adodb->qstr($username) . ','
+                               . $adodb->qstr($session_id) . ','
+                               . $adodb->qstr($station) . ','
+                               . (int)(time() + 86400) . ')';
+               } else {
+                       $sql = 'INSERT INTO Radio_Sessions(session, url, 
expires) VALUES ('
+                               . $adodb->qstr($session_id) . ','
+                               . $adodb->qstr($station) . ','
+                               . (int)(time() + 86400) . ')';
+               }
+               $res = $adodb->Execute($sql);
+               return $session_id;
+       }
+
 }

Modified: branches/stable/nixtape/data/Statistic.php
===================================================================
--- branches/stable/nixtape/data/Statistic.php  2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/data/Statistic.php  2009-05-14 03:55:34 UTC (rev 
1553)
@@ -22,88 +22,88 @@
 require_once($install_path . '/data/Server.php');
 
 class Statistic {
-   /*
-    * returns an array counting appareances of a given field and his 
corresponding bargraph size
-    * @param string $table table name to be queried
-    * @param string $field field name to count
-    * @param integer $limit limit of the query
-    * @param string $constraint username or artistname depending on field
-    * @param integer $maxwidth bargraph max width ( to express visually the 
number of plays )
-    * inaccurate @param integer $sizes quantity of possible sizes
-    * inaccurate @param float $max_font_size maximum font size (px, em, %, etc)
-    * @return array playstats
-    */
-    static function generatePlayStats($table, $field, $limit = 40, $constraint 
= null, $maxwidth = 100 ) {
-        global $mdb2;
-        if (!is_string($field))          return false; 
-        if (!is_string($table))          return false;
-        if (!is_integer($limit))         return false;
-       $query = "SELECT $field, count(*) AS count FROM $table";
-        $query .= (!is_null($constraint)) ? ' WHERE ' : null;
-       if ($field == "track") {
-        $query .= (!is_null($constraint)) ? ' artist = ' . 
$mdb2->quote($constraint, 'text') : null;
-       } else {
-        $query .= (!is_null($constraint)) ? ' username = ' . 
$mdb2->quote($constraint, 'text') : null;
+       /*
+        * returns an array counting appareances of a given field and his 
corresponding bargraph size
+        * @param string $table table name to be queried
+        * @param string $field field name to count
+        * @param integer $limit limit of the query
+        * @param string $constraint username or artistname depending on field
+        * @param integer $maxwidth bargraph max width ( to express visually 
the number of plays )
+        * inaccurate @param integer $sizes quantity of possible sizes
+        * inaccurate @param float $max_font_size maximum font size (px, em, %, 
etc)
+        * @return array playstats
+        */
+       static function generatePlayStats($table, $field, $limit = 40, 
$constraint = null, $maxwidth = 100 ) {
+               global $mdb2;
+               if (!is_string($field))          return false;
+               if (!is_string($table))          return false;
+               if (!is_integer($limit))         return false;
+               $query = 'SELECT ' . $field . ', count(*) AS count FROM ' . 
$table;
+               $query .= (!is_null($constraint)) ? ' WHERE ' : null;
+               if ($field == 'track') {
+                       $query .= (!is_null($constraint)) ? ' artist = ' . 
$mdb2->quote($constraint, 'text') : null;
+               } else {
+                       $query .= (!is_null($constraint)) ? ' username = ' . 
$mdb2->quote($constraint, 'text') : null;
+               }
+               $query .= ' GROUP BY ' . $field . ' ORDER BY count DESC LIMIT ' 
. $limit;
+               $res = $mdb2->query($query);
+               if (PEAR::isError($res)) {
+                       echo('ERROR' . $res->getMessage());
+               }
+
+               if (!$res->numRows()) {
+                       return false;
+               } else {
+                       $data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
+                       $max = $data[0]['count'];
+
+                       foreach($data as &$i){
+                               $i['pageurl'] = 
Server::getArtistURL($i['artist']);
+                               $i['size'] = $i['count'] / $max * $maxwidth;
+                       }
+
+                       return $data;
+               }
        }
-        $query .= " GROUP BY $field ORDER BY count DESC LIMIT $limit";
-        $res = $mdb2->query($query);
-       if (PEAR::isError($res)) {
-               echo("ERROR" . $res->getMessage());
-       }
 
-        if (!$res->numRows()) {
-               return false;
-        } else {
-                $data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
-                $max = $data[0]['count'];
-                
-                       foreach($data as &$i){
-                                       $i['pageurl'] = 
Server::getArtistURL($i['artist']);
-                                       $i['size'] = $i['count'] / $max * 
$maxwidth;
-                }
-                
-                return $data;
-        }
-    }
-    
        static function generatePlayByDays($table, $limit = 100, $constraint = 
null, $maxwidth = 100 ) {
-        global $mdb2;
-        global $connect_string;
-        
-        if (!is_string($table))          return false;
-        if (!is_integer($limit))         return false;
-       
-        /*
-         * todo: completly remove this dirty db type check. 
-         */
-       $query = "SELECT COUNT(*) as count, DATE(TO_TIMESTAMP(time)) as date 
FROM $table";
-       if( strpos($connect_string , "mysql" ) === 0 ) $query = "SELECT 
COUNT(*) as count,DATE(FROM_UNIXTIME(time)) as date FROM $table";
-       
-        $query .= (!is_null($constraint)) ? ' WHERE ' : null;
+               global $mdb2;
+               global $connect_string;
+
+               if (!is_string($table))          return false;
+               if (!is_integer($limit))         return false;
+
+               /*
+                * todo: completly remove this dirty db type check.
+                */
+               $query = 'SELECT COUNT(*) as count, DATE(TO_TIMESTAMP(time)) as 
date FROM ' . $table;
+               if( strpos($connect_string , 'mysql' ) === 0 ) $query = 'SELECT 
COUNT(*) as count,DATE(FROM_UNIXTIME(time)) as date FROM ' .  $table;
+
+               $query .= (!is_null($constraint)) ? ' WHERE ' : null;
                $query .= (!is_null($constraint)) ? ' username = ' . 
$mdb2->quote($constraint, 'text') : null;
-        $query .= " GROUP BY date ORDER BY date DESC LIMIT $limit";
-        $res = $mdb2->query($query);
+               $query .= ' GROUP BY date ORDER BY date DESC LIMIT ' . $limit;
+               $res = $mdb2->query($query);
                if (PEAR::isError($res)) {
-                       echo("ERROR" . $res->getMessage());
+                       echo('ERROR' . $res->getMessage());
                }
 
-        if (!$res->numRows()) {
-               return false;
-        } else {
-            $data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
-            
-            $max = 0;
-                
-                   foreach($data as &$i){
+               if (!$res->numRows()) {
+                       return false;
+               } else {
+                       $data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
+
+                       $max = 0;
+
+                       foreach($data as &$i){
                                if( $i['count'] > $max ) $max =  $i['count'];
-            }
-            
-               foreach($data as &$i){
+                       }
+
+                       foreach($data as &$i){
                                $i['size'] = $i['count'] / $max * $maxwidth;
-            }
-            
-            return $data;
-        }
-    }
+                       }
+
+                       return $data;
+               }
+       }
 }
 ?>

Modified: branches/stable/nixtape/data/TagCloud.php
===================================================================
--- branches/stable/nixtape/data/TagCloud.php   2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/data/TagCloud.php   2009-05-14 03:55:34 UTC (rev 
1553)
@@ -23,48 +23,49 @@
 require_once($install_path . '/config.php'); // Should already be required 
though.
 
 class TagCloud {
-   /*
-    * returns an array counting appareances of a given field and his 
corresponding font-size.
-    * @param string $table table name to be queried
-    * @param string $field field name to count
-    * @param integer $limit limit of the query
-    * @param string $constraint username or artistname depending on field
-    * inaccurate @param integer $sizes quantity of possible sizes
-    * inaccurate @param float $max_font_size maximum font size (px, em, %, etc)
-    * @return array tagcloud
-    */
-    static function generateTagCloud($table, $field, $limit = 40, $constraint 
= null, $constrained_field = false) {
-        global $adodb;
-        if (!is_string($field))          return false; 
-        if (!is_string($table))          return false;
-        if (!is_integer($limit))         return false;
-        $sizes = array('xx-large', 'x-large', 'large', 'medium', 'small', 
'x-small', 'xx-small');
-        $query = "SELECT $field, count(*) AS count FROM $table";
-        $query .= (!is_null($constraint)) ? ' WHERE ' : null;
-        if ($constrained_field) {
-            $query .= (!is_null($constraint)) ? " $constrained_field  = " . 
$adodb->qstr($constraint) : null;
-        } elseif ($field == "track") {
-            $query .= (!is_null($constraint)) ? ' artist = ' . 
$adodb->qstr($constraint) : null;
-        } else {
-            $query .= (!is_null($constraint)) ? ' username = ' . 
$adodb->qstr($constraint) : null;
-        }
-        $query .= " GROUP BY $field ORDER BY count DESC LIMIT $limit";
-       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
-        $res = $adodb->CacheGetAll(7200,$query);
-        if (!$res) {
-            // echo("ERROR $query"); Stop echoing this, please. For the ponies.
-        } else {
-            foreach($res as $count => &$i) {
-                $i['size'] = $sizes[(int) ($count/(count($res)/7))];
-            }
-            foreach($res as &$i){
-                $i['pageurl'] = Server::getArtistURL($i['artist']);
-            }
-            sort($res);
-            return $res;
-        }
-    }
-    
+
+       /*
+        * returns an array counting appareances of a given field and his 
corresponding font-size.
+        * @param string $table table name to be queried
+        * @param string $field field name to count
+        * @param integer $limit limit of the query
+        * @param string $constraint username or artistname depending on field
+        * inaccurate @param integer $sizes quantity of possible sizes
+        * inaccurate @param float $max_font_size maximum font size (px, em, %, 
etc)
+        * @return array tagcloud
+        */
+       static function generateTagCloud($table, $field, $limit = 40, 
$constraint = null, $constrained_field = false) {
+               global $adodb;
+               if (!is_string($field))          return false;
+               if (!is_string($table))          return false;
+               if (!is_integer($limit))         return false;
+               $sizes = array('xx-large', 'x-large', 'large', 'medium', 
'small', 'x-small', 'xx-small');
+               $query = 'SELECT ' . $field . ', count(*) AS count FROM ' . 
$table;
+               $query .= (!is_null($constraint)) ? ' WHERE ' : null;
+               if ($constrained_field) {
+                       $query .= (!is_null($constraint)) ? $constrained_field  
. ' = ' . $adodb->qstr($constraint) : null;
+               } elseif ($field == 'track') {
+                       $query .= (!is_null($constraint)) ? ' artist = ' . 
$adodb->qstr($constraint) : null;
+               } else {
+                       $query .= (!is_null($constraint)) ? ' username = ' . 
$adodb->qstr($constraint) : null;
+               }
+               $query .= ' GROUP BY ' . $field . ' ORDER BY count DESC LIMIT ' 
. $limit;
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $res = $adodb->CacheGetAll(7200,$query);
+               if (!$res) {
+                       return(new PEAR_Error('ERROR ' . $query));
+               } else {
+                       foreach($res as $count => &$i) {
+                               $i['size'] = $sizes[(int) 
($count/(count($res)/7))];
+                       }
+                       foreach($res as &$i){
+                               $i['pageurl'] = 
Server::getArtistURL($i['artist']);
+                       }
+                       sort($res);
+                       return $res;
+               }
+       }
+
        /**
         * Returns the preferred table to generate scrobble data from.
         *
@@ -76,17 +77,17 @@
        {
                // This array can be set up in config.php
                global  $scrobblecloud_table;
-               
+
                if (!empty($scrobblecloud_table[$area]))
                {
                        return $scrobblecloud_table[$area];
                }
-               
+
                if ($area == 'main')
                {
                        return 'Free_Scrobbles';
                }
-               
+
                return 'Scrobbles';
        }
 }

Modified: branches/stable/nixtape/data/Track.php
===================================================================
--- branches/stable/nixtape/data/Track.php      2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/data/Track.php      2009-05-14 03:55:34 UTC (rev 
1553)
@@ -20,18 +20,18 @@
 */
 
 
-require_once($install_path . '/database.php');
-require_once($install_path . "/data/Artist.php");
-require_once($install_path . "/data/Album.php");
-require_once($install_path . "/data/Server.php");
-require_once($install_path . "/resolve-external.php");
-require_once($install_path . "/licenses.php");
+require_once($install_path . '/database2.php');
+require_once($install_path . '/data/Artist.php');
+require_once($install_path . '/data/Album.php');
+require_once($install_path . '/data/Server.php');
+require_once($install_path . '/utils/resolve-external.php');
+require_once($install_path . '/utils/licenses.php');
 require_once($install_path . '/utils/linkeddata.php');
 
 /**
  * Represents track data
  *
- * All track attributes are accessible as public variables. 
+ * All track attributes are accessible as public variables.
  */
 class Track {
 
@@ -47,25 +47,26 @@
         * @param string $artist The name of the artist who recorded this track
         */
        function __construct($name, $artist) {
-               global $mdb2;
-               $res = $mdb2->query("SELECT name, artist_name, album_name, 
duration, streamable, license, downloadurl, streamurl, mbid FROM Track WHERE "
-                       . "name = " . $mdb2->quote($name, "text") . " AND "
-                       . "artist_name = " . $mdb2->quote($artist, "text"));
-               if(!$res->numRows()) {
-                       $this->name = "No such track: " . $name;
+               global $adodb;
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $res = $adodb->CacheGetRow(600, 'SELECT name, artist_name, 
album_name, duration, streamable, license, downloadurl, streamurl, mbid FROM 
Track WHERE '
+                       . 'name = ' . $adodb->qstr($name) . ' AND '
+                       . 'artist_name = ' . $adodb->qstr($artist));
+               if(!$res) {
+                       $this->name = 'No such track: ' . $name;
                } else {
-                       $row = sanitize($res->fetchRow(MDB2_FETCHMODE_ASSOC));
-                       $this->name = $row["name"];
-                       $this->mbid = $row["mbid"];
-                       $this->artist_name = $row["artist_name"];
-                       $this->album_name = $row["album_name"];
-                       $this->duration = $row["duration"];
-                       $this->streamable = $row["streamable"];
-                       $this->license = simplify_license($row["license"]);
-                       $this->licenseurl = $row["license"];
-                       $this->downloadurl = 
resolve_external_url($row["downloadurl"]);
-                       $this->streamurl = 
resolve_external_url($row["streamurl"]);
-                       
+                       $row = $res;
+                       $this->name = $row['name'];
+                       $this->mbid = $row['mbid'];
+                       $this->artist_name = $row['artist_name'];
+                       $this->album_name = $row['album_name'];
+                       $this->duration = $row['duration'];
+                       $this->streamable = $row['streamable'];
+                       $this->license = simplify_license($row['license']);
+                       $this->licenseurl = $row['license'];
+                       $this->downloadurl = 
resolve_external_url($row['downloadurl']);
+                       $this->streamurl = 
resolve_external_url($row['streamurl']);
+
                        $this->id = identifierTrack(null, $this->artist_name, 
$this->name, $this->album_name, null, $this->mbid, null, null);
                }
 
@@ -118,14 +119,14 @@
 
 
        private function _getPlayCountAndListenerCount() {
-               global $mdb2;
+               global $adodb;
 
-               $res = $mdb2->query("SELECT COUNT(track) AS freq, 
COUNT(DISTINCT username) AS listeners FROM Scrobbles WHERE"
-                       . " artist = " . $mdb2->quote($this->artist_name, 
'text') 
-                       . " AND track = " . $mdb2->quote($this->name, "text")
-                       . " GROUP BY track ORDER BY freq DESC");
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $row = $adodb->CacheGetRow(300, 'SELECT COUNT(track) AS freq, 
COUNT(DISTINCT username) AS listeners FROM Scrobbles WHERE'
+                       . ' artist = ' . $adodb->qstr($this->artist_name)
+                       . ' AND track = ' . $adodb->qstr($this->name)
+                       . ' GROUP BY track ORDER BY freq DESC');
 
-               $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
                if (!isset($row)) {
                        $this->setPlaycount(0);
                        $this->setListenerCount(0);

Modified: branches/stable/nixtape/data/User.php
===================================================================
--- branches/stable/nixtape/data/User.php       2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/data/User.php       2009-05-14 03:55:34 UTC (rev 
1553)
@@ -19,7 +19,7 @@
 
 */
 
-require_once($install_path . '/database.php');
+require_once($install_path . '/database2.php');
 require_once($install_path . '/data/sanitize.php');
 require_once($install_path . '/utils/human-time.php');
 require_once($install_path . '/data/Server.php');
@@ -50,13 +50,15 @@
                        $row = $data;
                }
                else {
-                       global $mdb2;
-                       $res = $mdb2->query('SELECT * FROM Users WHERE 
lower(username) = ' . $mdb2->quote(strtolower($name), 'text'));
-                       if($res->numRows()) {
-                               $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
-                       }
+                       global $adodb;
+                       $query = 'SELECT * FROM Users WHERE lower(username) = ' 
. $adodb->qstr(strtolower($name));
+                       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+                       $row = $adodb->CacheGetRow(7200,$query);
+                       if (!$row) {
+                               return(new PEAR_Error('ERROR ' . $query));
+                       }
                }
-                       
+
                if (is_array($row)) {
                        $this->name         = $row['username'];
                        $this->password     = $row['password'];
@@ -67,78 +69,82 @@
                        $this->location     = $row['location'];
                        $this->location_uri = $row['location_uri'];
                        $this->userlevel    = $row['userlevel'];
-                       $this->id           = $row["webid_uri"];
-                       $this->webid_uri    = $row["webid_uri"];
-                       $this->avatar_uri   = $row["avatar_uri"];
-                       $this->laconica_profile = $row["laconica_profile"];
-                       $this->journal_rss  = $row["journal_rss"];
+                       $this->id           = $row['webid_uri'];
+                       $this->webid_uri    = $row['webid_uri'];
+                       $this->avatar_uri   = $row['avatar_uri'];
+                       $this->laconica_profile = $row['laconica_profile'];
+                       $this->journal_rss  = $row['journal_rss'];
                        $this->acctid       = $this->getURL() . '#acct';
-                       $this->created      = $row["created"];
-                       $this->modified     = $row["modified"];
-                       $this->uniqueid     = $row["uniqueid"];
-                       
+                       $this->created      = $row['created'];
+                       $this->modified     = $row['modified'];
+                       $this->uniqueid     = $row['uniqueid'];
+
                        $this->has_identica = 
preg_match('#^http://identi\.ca/#i', $this->laconica_profile);
-                       
+
                        if (! preg_match('/\:/', $this->id))
                                $this->id = $this->getURL() . '#me';
-               }               
+               }
        }
-       
-       
+
+
        public static function new_from_uniqueid_number ($uid)
        {
-               global $mdb2;
-               $res = $mdb2->query(sprintf('SELECT * FROM Users WHERE uniqueid 
= %d', (int)$uid));
-               if($res->numRows()) {
-                       $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
+               global $adodb;
+               $query = sprintf('SELECT * FROM Users WHERE uniqueid = %d', 
(int)$uid);
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $row = $adodb->CacheGetRow(7200,$query);
+
+               if($row) {
                        return new User($row['username'], $row);
+               } else {
+                       return false;
                }
        }
-       
+
        function save ()
        {
-               global $mdb2;
-               
+               global $adodb;
+
                // It appears we just discard this data, but this is here for a 
reason!
                // getLocationDetails will fill in latitude,longitude details 
into the Places table in the database
                // if it's not already there. This is important as the 
location_uri field is a foreign key.
                if (!empty($this->location_uri))
                        $dummy = 
Server::getLocationDetails($this->location_uri);
-               
-               $q = sprintf("UPDATE Users SET "
-                               . "email=%s, "     # Send a confirmation email 
first??
-                               . "password=%s, "
-                               . "fullname=%s, "
-                               . "homepage=%s, "
-                               . "bio=%s, "
-                               . "location=%s, "
-                               . "userlevel=%d, "
-                               . "webid_uri=%s, "
-                               . "location_uri=%s, "
-                               . "avatar_uri=%s, "
-                               . "laconica_profile=%s, "
-                               . "journal_rss=%s, "
-                               . "modified=%d "
-                               . "WHERE username=%s"
-                               , $mdb2->quote($this->email, 'text')
-                               , $mdb2->quote($this->password, 'text')
-                               , $mdb2->quote($this->fullname, 'text')
-                               , $mdb2->quote($this->homepage, 'text')
-                               , $mdb2->quote($this->bio, 'text')
-                               , $mdb2->quote($this->location, 'text')
+
+               $q = sprintf('UPDATE Users SET '
+                               . 'email=%s, '     # Send a confirmation email 
first??
+                               . 'password=%s, '
+                               . 'fullname=%s, '
+                               . 'homepage=%s, '
+                               . 'bio=%s, '
+                               . 'location=%s, '
+                               . 'userlevel=%d, '
+                               . 'webid_uri=%s, '
+                               . 'location_uri=%s, '
+                               . 'avatar_uri=%s, '
+                               . 'laconica_profile=%s, '
+                               . 'journal_rss=%s, '
+                               . 'modified=%d '
+                               . 'WHERE username=%s'
+                               , $adodb->qstr($this->email)
+                               , $adodb->qstr($this->password)
+                               , $adodb->qstr($this->fullname)
+                               , $adodb->qstr($this->homepage)
+                               , $adodb->qstr($this->bio)
+                               , $adodb->qstr($this->location)
                                , $this->userlevel
-                               , $mdb2->quote($this->id, 'text')
-                               , (empty($this->location_uri) ? 'NULL' : 
$mdb2->quote($this->location_uri, 'text'))
-                               , $mdb2->quote($this->avatar_uri, 'text')
-                               , $mdb2->quote($this->laconica_profile, 'text')
-                               , $mdb2->quote($this->journal_rss, 'text')
+                               , $adodb->qstr($this->id)
+                               , (empty($this->location_uri) ? 'NULL' : 
$adodb->qstr($this->location_uri))
+                               , $adodb->qstr($this->avatar_uri)
+                               , $adodb->qstr($this->laconica_profile)
+                               , $adodb->qstr($this->journal_rss)
                                , time()
-                               , $mdb2->quote($this->name, 'text'));
-                               
-               $res = $mdb2->query($q);
-               
+                               , $adodb->qstr($this->name));
+
+               $res = $adodb->Execute($q);
+
                if(PEAR::isError($res)) {
-                       header("Content-Type: text/plain");
+                       header('Content-Type: text/plain');
                        //($res);
                        exit;
                }
@@ -167,8 +173,8 @@
        function getAvatar($size=64) {
                if (!empty($this->avatar_uri))
                        return $this->avatar_uri;
-       
-               return "http://www.gravatar.com/avatar/"; . md5($this->email) . 
"?s=" . $size . "&d=monsterid";
+
+               return 'http://www.gravatar.com/avatar/' . md5($this->email) . 
'?s=' . $size . '&d=monsterid';
        }
 
        function getURL($component='profile') {
@@ -190,15 +196,18 @@
         * @return A string containing the session key to be used for scrobbling
         */
        function getScrobbleSession() {
-               global $mdb2;
+               global $adodb;
                $session_id = md5(mt_rand() . time());
-               $sql = "INSERT INTO Scrobble_Sessions(username, sessionid, 
client, expires) VALUES ("
-                       . $mdb2->quote($this->name, "text") . ","
-                       . $mdb2->quote($session_id, "text") . ","
-                       . "'lfm',"
-                       . $mdb2->quote(time() + 86400) . ")";
-               $mdb2->query($sql);
-               return $session_id;
+               $sql = 'INSERT INTO Scrobble_Sessions(username, sessionid, 
client, expires) VALUES ('
+                       . $adodb->qstr($this->name) . ','
+                       . $adodb->qstr($session_id) . ','
+                       . '\'lfm\','
+                       . (time() + 86400) . ')';
+               if($adodb->Execute($sql)) {
+                       return $session_id;
+               } else {
+                       return false;
+               }
        }
 
        /**
@@ -208,15 +217,7 @@
         * @return A string containing the session key to be used for streaming
         */
        function getRadioSession($station) {
-               global $mdb2;
-               $session_id = md5(mt_rand() . time());
-               $sql = "INSERT INTO Radio_Sessions(username, session, url, 
expires) VALUES ("
-                       . $mdb2->quote($this->name, "text") . ","
-                       . $mdb2->quote($session_id, "text") . ","
-                       . $mdb2->quote($station, "text") . ","
-                       . $mdb2->quote(time() + 86400) . ")";
-               $mdb2->query($sql);
-               return $session_id;
+               return Server::getRadioSession($station, $this->name);
        }
 
        /**
@@ -225,30 +226,30 @@
         * @return user's top 20 tracks
         */
        function getTopTracks($number=20) {
-               global $mdb2;
+               global $adodb;
 
-               $res = $mdb2->query("SELECT COUNT(track) as c, artist, album, 
track FROM Scrobbles WHERE username = ".$mdb2->quote($this->name,"text")." 
GROUP BY artist,album,track ORDER BY c DESC LIMIT $number");
+               $query = 'SELECT COUNT(track) as c, artist, album, track FROM 
Scrobbles WHERE username = '.$adodb->qstr($this->name).' GROUP BY 
artist,album,track ORDER BY c DESC LIMIT ' . ($number);
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+               $data = $adodb->CacheGetAll(7200,$query);
+               if (!$data) {
+                       return(new PEAR_Error('ERROR ' . $query));
+               }
 
-               if(PEAR::isError($res)) {
-                   return $res;
-               }
-
                $maxcount = 0;
 
-               $data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
-               foreach($data as $i) {
+               foreach($data as &$i) {
                    $row = sanitize($i);
-                   $row["artisturl"] = Server::getArtistURL($row["artist"]);
-                   $row["trackurl"] = 
Server::getTrackURL($row["artist"],$row["album"],$row["track"]);
-                   if ((int)$row["c"] > $maxcount) {
-                       $maxcount = (int)$row["c"];
+                   $row['artisturl'] = Server::getArtistURL($row['artist']);
+                   $row['trackurl'] = 
Server::getTrackURL($row['artist'],$row['album'],$row['track']);
+                   if ((int)$row['c'] > $maxcount) {
+                       $maxcount = (int)$row['c'];
                    }
                    $result[] = $row;
                }
 
                if ($maxcount > 0) {
                        foreach($result as &$row) {
-                       $row["width"]=(int)(100 * ($row["c"]/$maxcount));
+                       $row['width']=(int)(100 * ($row['c']/$maxcount));
                        }
                }
 
@@ -257,4 +258,3 @@
 
 
 }
-

Modified: branches/stable/nixtape/database.php
===================================================================
--- branches/stable/nixtape/database.php        2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/database.php        2009-05-14 03:55:34 UTC (rev 
1553)
@@ -20,8 +20,8 @@
 */
 
 
-if(!file_exists(dirname(__FILE__) . "/config.php")) {
-       die("Please run the <a href='install.php'>Install</a> script to 
configure your installation");
+if(!file_exists(dirname(__FILE__) . '/config.php')) {
+       die('Please run the <a href=\'install.php\'>Install</a> script to 
configure your installation');
 }
 
 require_once('config.php');
@@ -33,15 +33,15 @@
 }
 
 function reportError($text, $data) {
-    // make a fresh connection
-    $mdbe = MDB2::connect($connect_string);
-    if (PEAR::isError($mdbe)) {
-           die($mdbe->getMessage());
-    }
+       // make a fresh connection
+       $mdbe = MDB2::connect($connect_string);
+       if (PEAR::isError($mdbe)) {
+               die($mdbe->getMessage());
+       }
 
-    $mdbe->exec("INSERT INTO Error (msg, data, time) VALUES ("
-       . $mdbe->quote($text, 'text') . ", "
-       . $mdbe->quote($data, 'text') . ", "
-       . time() . ")");
+       $mdbe->exec('INSERT INTO Error (msg, data, time) VALUES ('
+               . $mdbe->quote($text, 'text') . ', '
+               . $mdbe->quote($data, 'text') . ', '
+               . time() . ')');
 }
 ?>

Modified: branches/stable/nixtape/database2.php
===================================================================
--- branches/stable/nixtape/database2.php       2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/database2.php       2009-05-14 03:55:34 UTC (rev 
1553)
@@ -20,8 +20,8 @@
 */
 
 
-if(!file_exists(dirname(__FILE__) . "/config.php")) {
-       die("Please run the <a href='install.php'>Install</a> script to 
configure your installation");
+if(!file_exists(dirname(__FILE__) . '/config.php')) {
+       die('Please run the <a href=\'install.php\'>Install</a> script to 
configure your installation');
 }
 
 require_once('config.php');

Added: branches/stable/nixtape/delete-profile.php
===================================================================
--- branches/stable/nixtape/delete-profile.php                          (rev 0)
+++ branches/stable/nixtape/delete-profile.php  2009-05-14 03:55:34 UTC (rev 
1553)
@@ -0,0 +1,76 @@
+<?php
+
+/* Libre.fm -- a free network service for sharing your music listening habits
+
+   Copyright (C) 2009 Libre.fm Project
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Affero General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   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 Affero General Public License for more details.
+
+   You should have received a copy of the GNU Affero General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+require_once ('templating.php');
+require_once ('data/User.php');
+require_once ('utils/random_code_generator.php');
+
+if ($logged_in == false) {
+       $smarty->assign('error', 'Error!');
+       $smarty->assign('details', 'Not logged in! You shouldn\'t be here!');
+       $smarty->display('error.tpl');
+       die ();
+} elseif ( isset ($_GET['code'])) {
+       $mdb2->exec('DELETE FROM Delete_Request WHERE expires < ' . 
$mdb2->quote(time(), 'integer'));
+
+       $username = $this_user->name;
+       $code = $_GET['code'];
+       $res = $mdb2->query('SELECT * FROM Delete_Request WHERE username = ' . 
$mdb2->quote($username, 'text') . ' AND code = ' . $mdb2->quote($code, 'text'));
+       if (PEAR::isError($res)) {
+               //($res);
+               exit ;
+       }
+       if (!$res->numRows()) {
+               $error = 'Invalid code.';
+               $smarty->assign('error', 'Error!');
+               $smarty->assign('details', $error);
+               $smarty->display('error.tpl');
+               die ();
+       } else {
+               $mdb2->exec('DELETE FROM Scrobble_Sessions WHERE username = ' . 
$mdb2->quote($username, 'text'));
+               $mdb2->exec('DELETE FROM Delete_Request WHERE username = ' . 
$mdb2->quote($username, 'text'));
+               $mdb2->exec('DELETE FROM Auth WHERE username = ' . 
$mdb2->quote($username, 'text'));
+               $mdb2->exec('DELETE FROM Group_Members WHERE member = ' . 
$mdb2->quote($this_user->uniqueid, 'integer'));
+               $mdb2->exec('DELETE FROM Radio_Sessions WHERE username = ' . 
$mdb2->quote($username, 'text'));
+               $mdb2->exec('DELETE FROM Recovery_Request WHERE username = ' . 
$mdb2->quote($username, 'text'));
+               $mdb2->exec('DELETE FROM Scrobbles WHERE username = ' . 
$mdb2->quote($username, 'text'));
+               $mdb2->exec('DELETE FROM User_Relationship_Flags WHERE uid1 = ' 
. $mdb2->quote($this_user->uniqueid, 'integer'));
+               $mdb2->exec('DELETE FROM User_Relationship_Flags WHERE uid2 = ' 
. $mdb2->quote($this_user->uniqueid, 'integer'));
+               $mdb2->exec('DELETE FROM User_Relationships WHERE uid1 = ' . 
$mdb2->quote($this_user->uniqueid, 'integer'));
+               $mdb2->exec('DELETE FROM User_Relationships WHERE uid2 = ' . 
$mdb2->quote($this_user->uniqueid, 'integer'));
+               $mdb2->exec('DELETE FROM Users WHERE lower(username) = ' . 
$mdb2->quote(strtolower($username), 'text'));
+               session_destroy();
+               header('Location: index.php');
+       }
+} else {
+       $code = generateCode();
+       $username = $this_user->name;
+       $email = $this_user->email;
+       $expire = time()+86400;
+       $mdb2->exec('INSERT INTO Delete_Request (code, expires, username) 
VALUES (' . $mdb2->quote($code, 'text') . ', ' . $mdb2->quote($expire, 'text') 
. "," .  $mdb2->quote($username, 'text') . ')');
+       $url = $base_url . '/delete-profile.php?code=' . $code;
+       $content = "Hi!\n\nSomeone from the IP address " . 
$_SERVER['REMOTE_ADDR'] . " requested account deletion at libre.fm.  To remove 
this account click: \n\n" . $url . "\n\n- The Libre.fm Team";
+       $headers = 'From: Libre.fm <address@hidden>';
+       $subject = 'Libre.fm Account Delete Request - Action needed!';
+       mail($email, $subject, $content, $headers);
+       $smarty->display('delete-profile.tpl');
+}
+?>

Modified: branches/stable/nixtape/edit_group.php
===================================================================
--- branches/stable/nixtape/edit_group.php      2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/edit_group.php      2009-05-14 03:55:34 UTC (rev 
1553)
@@ -37,11 +37,11 @@
 {
        if ($_REQUEST['new'])
        {
-               $result = Group::create($_REQUEST['new'], $this_user);
+         $result = Group::create(strtolower($_REQUEST['new']), $this_user);
 
                if ($result instanceof Group)
                {
-                       header("Location: 
{$base_url}/edit_group.php?group=".$_REQUEST['new']);
+                       header('Location: ' . $base_url . 
'/edit_group.php?group=' . $_REQUEST['new']);
                        exit();
                }
                elseif (PEAR::isError($result))
@@ -55,7 +55,7 @@
        else
        {
                $smarty->assign('newform', true);
-               $aTagCloud = TagCloud::GenerateTagCloud('Free_Scrobbles', 
'artist');
+               $aTagCloud = 
TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
                if (!PEAR::isError ($aTagCloud))
                {
                        $smarty->assign('tagcloud', $aTagCloud);
@@ -84,9 +84,9 @@
                # Need better URI validation, but this will do for now. I think
                # PEAR has a suitable module to help out here.
                if ( !preg_match('/^[a-z0-9\+\.\-]+\:/i', $_POST['homepage']) )
-                       $errors[] = "Homepage must be a URI.";
+                       $errors[] = 'Homepage must be a URI.';
                if ( preg_match('/\s/', $_POST['homepage']) )
-                       $errors[] = "Homepage must be a URI. Valid URIs cannot 
contain whitespace.";
+                       $errors[] = 'Homepage must be a URI. Valid URIs cannot 
contain whitespace.';
        }
 
        if (!empty($_POST['avatar_uri']))
@@ -94,27 +94,44 @@
                # Need better URI validation, but this will do for now. I think
                # PEAR has a suitable module to help out here.
                if ( !preg_match('/^[a-z0-9\+\.\-]+\:/i', $_POST['avatar_uri']) 
)
-                       $errors[] = "Avatar must be a URI.";
+                       $errors[] = 'Avatar must be a URI.';
                if ( preg_match('/\s/', $_POST['avatar_uri']) )
-                       $errors[] = "Avatar must be a URI. Valid URIs cannot 
contain whitespace.";
+                       $errors[] = 'Avatar must be a URI. Valid URIs cannot 
contain whitespace.';
        }
 
        if (!isset($errors[0]))
        {
+               if ($_POST['owner'] != $group->owner->username)
+               {
+                       $new_owner = new User($_POST['owner']);
+
+                       if (! $group->memberCheck($new_owner))
+                       {
+                               $smarty->assign('error', 'Error!');
+                               $smarty->assign('details', 'Cannot assign group 
ownership to someone who is not a member!');
+                               $smarty->display('error.tpl');
+                               die();
+                       }
+                       else
+                       {
+                               $group->owner = $new_owner;
+                       }
+               }
+
                $group->fullname    = $_POST['fullname'];
                $group->homepage    = $_POST['homepage'];
                $group->bio         = $_POST['bio'];
                $group->avatar_uri  = $_POST['avatar_uri'];
-               
+
                $group->save();
 
-               header("Location: " . $group->getURL());
+               header('Location: ' . $group->getURL());
                exit;
        }
 
        if (isset($errors[0]))
        {
-               header("Content-Type: text/plain");
+               header('Content-Type: text/plain');
                //($errors);
                exit;
        }
@@ -134,16 +151,19 @@
        }
        else
        {
-               $smarty->assign('fullname',     ($group->fullname));
-               $smarty->assign('bio',          ($group->bio));
-               $smarty->assign('homepage',     ($group->homepage));
-               $smarty->assign('avatar_uri',   ($group->avatar_uri));
+               $smarty->assign('fullname',     $group->fullname);
+               $smarty->assign('bio',          $group->bio);
+               $smarty->assign('homepage',     $group->homepage);
+               $smarty->assign('avatar_uri',   $group->avatar_uri);
        }
 
+       $smarty->assign('members', $group->getUsers());
+       $smarty->assign('owner',   $group->owner);
+
        # And display the page.
        $smarty->assign('errors', $errors);
        $smarty->assign('newform', false);
-       $aTagCloud = TagCloud::GenerateTagCloud('Free_Scrobbles', 'artist');
+       $aUserTagCloud = $group->tagCloudData();
        if (!PEAR::isError ($aTagCloud))
        {
                $smarty->assign('tagcloud', $aTagCloud);

Modified: branches/stable/nixtape/explore.php
===================================================================
--- branches/stable/nixtape/explore.php 2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/explore.php 2009-05-14 03:55:34 UTC (rev 1553)
@@ -27,16 +27,16 @@
 require_once('data/TagCloud.php');
 
 // This should be contextual based on the mode= parameter?
-$aTagCloud = TagCloud::GenerateTagCloud('Free_Scrobbles', 'artist');
+$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
 if (!PEAR::isError ($aTagCloud)) {
         $smarty->assign('tagcloud', $aTagCloud);
 }
 
 $aTopArtists = Server::getTopArtists(20);
 if (!PEAR::isError ($aTopArtists)) {
-    $smarty->assign("topartists", $aTopArtists);
+    $smarty->assign('topartists', $aTopArtists);
 }
-$smarty->assign("explore", true);
-$smarty->display("explore-artists.tpl");
+$smarty->assign('explore', true);
+$smarty->display('explore-artists.tpl');
 
 ?>

Deleted: branches/stable/nixtape/free.php
===================================================================
--- branches/stable/nixtape/free.php    2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/free.php    2009-05-14 03:55:34 UTC (rev 1553)
@@ -1,45 +0,0 @@
-<?php
-
-/* Libre.fm -- a free network service for sharing your music listening habits
-
-   Copyright (C) 2009 Libre.fm Project
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU Affero General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   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 Affero General Public License for more details.
-
-   You should have received a copy of the GNU Affero General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-require_once('database.php');
-require_once('templating.php');
-require_once('data/sanitize.php');
-require_once('data/Server.php');
-require_once('data/TagCloud.php');
-
-$aTagCloud = TagCloud::GenerateTagCloud('Free_Scrobbles', 'artist');
-if (!PEAR::isError ($aTagCloud)) {
-       $smarty->assign('tagcloud', $aTagCloud);
-}
-
-$aLastScrobbles = Server::getRecentScrobbles(20);
-if (!PEAR::isError ($aLastScrobbles)) {
-       $smarty->assign('recenttracks', $aLastScrobbles);
-}
-
-$aNowPlaying = Server::getNowPlaying(10);
-if (!PEAR::isError ($aNowPlaying)) {
-       $smarty->assign('nowplaying', $aNowPlaying);
-}
-
-$smarty->assign('welcome', true);
-$smarty->display('welcome.tpl');
-?>

Modified: branches/stable/nixtape/group.php
===================================================================
--- branches/stable/nixtape/group.php   2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/group.php   2009-05-14 03:55:34 UTC (rev 1553)
@@ -33,10 +33,10 @@
                                'rel' => 'meta',
                                'type' => 'application/rdf+xml' ,
                                'title' => 'FOAF',
-                               'href' => 
$base_url.'/rdf.php?fmt=xml&page='.htmlentities($_SERVER['REQUEST_URI'])
+                               'href' => 
$base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', 
$_SERVER['REQUEST_URI']))
                                )
                ));
-       $aTagCloud = TagCloud::GenerateTagCloud('Free_Scrobbles', 'artist');
+       $aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 
'artist');
        if (!PEAR::isError ($aTagCloud))
        {
                $smarty->assign('tagcloud', $aTagCloud);
@@ -53,15 +53,15 @@
                $group->memberJoin($this_user);
        elseif ($_GET['action'] == 'leave')
                $group->memberLeave($this_user);
-               
-       header("Location: " . $group->getURL());
+
+       header('Location: ' . $group->getURL());
        exit;
 }
 
 
 if(isset($group->name)) {
 
-       $smarty->assign("id", $group->id);
+       $smarty->assign('id', $group->id);
        $smarty->assign('group', $group->name);
        $smarty->assign('fullname', $group->fullname);
        $smarty->assign('bio', $group->bio);
@@ -87,7 +87,7 @@
                                'rel' => 'meta',
                                'type' => 'application/rdf+xml' ,
                                'title' => 'FOAF',
-                               'href' => 
$base_url.'/rdf.php?fmt=xml&page='.htmlentities($_SERVER['REQUEST_URI'])
+                               'href' => 
$base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', 
$_SERVER['REQUEST_URI']))
                                )
                ));
        

Deleted: branches/stable/nixtape/i/qm160.svg
===================================================================
--- branches/stable/nixtape/i/qm160.svg 2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/i/qm160.svg 2009-05-14 03:55:34 UTC (rev 1553)
@@ -1,429 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
-   xmlns:dc="http://purl.org/dc/elements/1.1/";
-   xmlns:cc="http://creativecommons.org/ns#";
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-   xmlns:svg="http://www.w3.org/2000/svg";
-   xmlns="http://www.w3.org/2000/svg";
-   xmlns:xlink="http://www.w3.org/1999/xlink";
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
-   width="160"
-   height="160.00002"
-   id="svg2"
-   sodipodi:version="0.32"
-   inkscape:version="0.46"
-   version="1.0"
-   inkscape:export-filename="/home/mattl/librefm/trunk/nixtape/i/qm160.png"
-   inkscape:export-xdpi="90.007538"
-   inkscape:export-ydpi="90.007538"
-   sodipodi:docname="qm160.svg"
-   inkscape:output_extension="org.inkscape.output.svg.inkscape">
-  <defs
-     id="defs4">
-    <inkscape:perspective
-       sodipodi:type="inkscape:persp3d"
-       inkscape:vp_x="0 : 526.18109 : 1"
-       inkscape:vp_y="0 : 1000 : 0"
-       inkscape:vp_z="744.09448 : 526.18109 : 1"
-       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
-       id="perspective10" />
-    <radialGradient
-       xlink:href="#linearGradient1851"
-       r="125.20509"
-       id="radialGradient1930"
-       fy="543.58928"
-       fx="-287.6184"
-       cy="598.36651"
-       cx="-289.0914"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       id="linearGradient1851">
-      <stop
-         style="stop-color: rgb(0, 0, 0); stop-opacity: 0.372414;"
-         offset="0.0000000"
-         id="stop1852" />
-      <stop
-         style="stop-color: rgb(0, 0, 0); stop-opacity: 0.110345;"
-         offset="0.50000000"
-         id="stop1854" />
-      <stop
-         style="stop-color: rgb(173, 173, 173); stop-opacity: 0;"
-         offset="1.0000000"
-         id="stop1853" />
-    </linearGradient>
-    <linearGradient
-       y2="620.60565"
-       y1="355.21766"
-       xlink:href="#linearGradient1612"
-       x2="-33.543156"
-       x1="-125.32088"
-       id="linearGradient1616"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       id="linearGradient1612">
-      <stop
-         style="stop-color: rgb(134, 134, 134); stop-opacity: 1;"
-         offset="0.0000000"
-         id="stop1613" />
-      <stop
-         style="stop-color: rgb(243, 243, 243); stop-opacity: 1;"
-         offset="0.39350441"
-         id="stop1768" />
-      <stop
-         style="stop-color: rgb(148, 148, 148); stop-opacity: 1;"
-         offset="0.47940385"
-         id="stop1769" />
-      <stop
-         style="stop-color: rgb(211, 211, 211); stop-opacity: 1;"
-         offset="1.0000000"
-         id="stop1614" />
-    </linearGradient>
-    <linearGradient
-       y2="321.57674"
-       y1="531.33623"
-       xlink:href="#linearGradient2089"
-       x2="-86.53583"
-       x1="-34.928335"
-       id="linearGradient1848"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       id="linearGradient2089">
-      <stop
-         style="stop-color: rgb(0, 0, 0); stop-opacity: 0.586207;"
-         offset="0.0000000"
-         id="stop2090" />
-      <stop
-         style="stop-color: rgb(0, 0, 0); stop-opacity: 0.310345;"
-         offset="0.73635292"
-         id="stop2091" />
-      <stop
-         style="stop-color: rgb(95, 95, 95); stop-opacity: 0;"
-         offset="1.0000000"
-         id="stop2092" />
-    </linearGradient>
-    <linearGradient
-       y2="373.7402"
-       y1="703.86141"
-       xlink:href="#linearGradient1601"
-       x2="339.08928"
-       x1="268.70404"
-       id="linearGradient1757"
-       gradientTransform="scale(1.0187221,0.9816219)"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       id="linearGradient1601">
-      <stop
-         style="stop-color: rgb(255, 255, 255); stop-opacity: 1;"
-         offset="0.0000000"
-         id="stop1602" />
-      <stop
-         style="stop-color: rgb(255, 255, 255); stop-opacity: 0;"
-         offset="1.0000000"
-         id="stop1603" />
-    </linearGradient>
-    <linearGradient
-       y2="417.2033"
-       y1="603.6567"
-       xlink:href="#linearGradient1608"
-       x2="-139.84261"
-       x1="18.752676"
-       id="linearGradient1855"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       id="linearGradient1608">
-      <stop
-         style="stop-color: rgb(0, 0, 0); stop-opacity: 0.455172;"
-         offset="0.0000000"
-         id="stop1609" />
-      <stop
-         style="stop-color: rgb(255, 255, 255); stop-opacity: 0.462069;"
-         offset="1.0000000"
-         id="stop1610" />
-    </linearGradient>
-    <linearGradient
-       y2="507.47124"
-       y1="414.25149"
-       xlink:href="#linearGradient1608"
-       x2="-112.11659"
-       x1="-112.11659"
-       id="linearGradient1604"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       y2="396.03963"
-       y1="566.04219"
-       xlink:href="#linearGradient1601"
-       x2="-32.234216"
-       x1="-118.47699"
-       id="linearGradient1738"
-       gradientTransform="scale(0.987334,1.0128285)"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       y2="398.14304"
-       y1="254.85888"
-       xlink:href="#linearGradient1601"
-       x2="-87.625109"
-       x1="-1.7180692"
-       id="linearGradient1607"
-       gradientTransform="scale(0.9050084,1.1049621)"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       y2="401.12195"
-       y1="669.9153"
-       xlink:href="#linearGradient1601"
-       x2="-142.87105"
-       x1="-345.63131"
-       id="linearGradient1752"
-       gradientTransform="scale(0.987334,1.0128284)"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       y2="384.01344"
-       y1="95.409241"
-       xlink:href="#linearGradient1753"
-       x2="-203.65021"
-       x1="9.3148219"
-       id="linearGradient1751"
-       gradientTransform="scale(0.8941943,1.1183252)"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       id="linearGradient1753">
-      <stop
-         style="stop-color: rgb(0, 0, 0); stop-opacity: 0.454902;"
-         offset="0.0000000"
-         id="stop1754" />
-      <stop
-         style="stop-color: rgb(0, 0, 0); stop-opacity: 0;"
-         offset="1.0000000"
-         id="stop1755" />
-    </linearGradient>
-    <linearGradient
-       y2="396.49017"
-       y1="220.76701"
-       xlink:href="#linearGradient1753"
-       x2="-83.902981"
-       x1="52.677472"
-       id="linearGradient1761"
-       gradientTransform="scale(0.8941942,1.1183253)"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       y2="397.45835"
-       y1="572.91971"
-       xlink:href="#linearGradient1601"
-       x2="-156.8936"
-       x1="-219.18004"
-       id="linearGradient1731"
-       gradientTransform="scale(0.987334,1.0128284)"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       y2="436.55967"
-       y1="380.68159"
-       xlink:href="#linearGradient899"
-       x2="-236.11141"
-       x1="-197.63092"
-       id="linearGradient848"
-       gradientTransform="scale(0.8941943,1.1183252)"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       id="linearGradient899">
-      <stop
-         style="stop-color: rgb(255, 255, 255); stop-opacity: 0;"
-         offset="0.0000000"
-         id="stop900" />
-      <stop
-         style="stop-color: rgb(255, 255, 255); stop-opacity: 1;"
-         offset="1.0000000"
-         id="stop901" />
-    </linearGradient>
-    <linearGradient
-       y2="372.88227"
-       y1="178.04991"
-       xlink:href="#linearGradient1601"
-       x2="-119.61194"
-       x1="58.723219"
-       id="linearGradient1863"
-       gradientTransform="scale(0.8941942,1.1183253)"
-       gradientUnits="userSpaceOnUse" />
-    <linearGradient
-       y2="383.42744"
-       y1="238.45076"
-       xlink:href="#linearGradient1601"
-       x2="-212.71039"
-       x1="-65.023436"
-       id="linearGradient1865"
-       gradientTransform="scale(0.8979021,1.1137071)"
-       gradientUnits="userSpaceOnUse" />
-    <inkscape:perspective
-       id="perspective3337"
-       inkscape:persp3d-origin="160 : 106.66667 : 1"
-       inkscape:vp_z="320 : 160 : 1"
-       inkscape:vp_y="0 : 1000 : 0"
-       inkscape:vp_x="0 : 160 : 1"
-       sodipodi:type="inkscape:persp3d" />
-    <linearGradient
-       inkscape:collect="always"
-       xlink:href="#linearGradient1601"
-       id="linearGradient3401"
-       x1="-118.47699"
-       y1="566.04219"
-       x2="-32.234216"
-       y2="396.03963"
-       gradientTransform="scale(0.987334,1.0128285)"
-       gradientUnits="userSpaceOnUse" />
-  </defs>
-  <sodipodi:namedview
-     id="base"
-     pagecolor="#ffffff"
-     bordercolor="#666666"
-     borderopacity="1.0"
-     gridtolerance="10000"
-     guidetolerance="10"
-     objecttolerance="10"
-     inkscape:pageopacity="0.0"
-     inkscape:pageshadow="2"
-     inkscape:zoom="4.3488769"
-     inkscape:cx="84.081373"
-     inkscape:cy="79.220113"
-     inkscape:document-units="px"
-     inkscape:current-layer="layer1"
-     showgrid="false"
-     showguides="true"
-     inkscape:guide-bbox="true"
-     inkscape:window-width="1680"
-     inkscape:window-height="975"
-     inkscape:window-x="0"
-     inkscape:window-y="25" />
-  <metadata
-     id="metadata7">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <g
-     inkscape:label="Layer 1"
-     inkscape:groupmode="layer"
-     id="layer1"
-     transform="translate(-1.3304396,-891.0318)">
-    <rect
-       
style="opacity:1;fill:#cccccf;fill-opacity:1;stroke:none;stroke-width:2.66087914;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-       id="rect2383"
-       width="160"
-       height="160.00002"
-       x="1.3304396"
-       y="891.0318" />
-    <flowRoot
-       xml:space="preserve"
-       id="flowRoot3155"
-       
style="fill:black;stroke:none;stroke-opacity:1;stroke-width:1px;stroke-linejoin:miter;stroke-linecap:butt;fill-opacity:1;font-family:Liberation
 
Sans;font-style:normal;font-weight:normal;font-size:72;-inkscape-font-specification:Liberation
 Sans;font-stretch:normal;font-variant:normal"><flowRegion
-         id="flowRegion3157"><rect
-           id="rect3159"
-           width="138.54578"
-           height="128.17841"
-           x="-161.1655"
-           y="12.500603" /></flowRegion><flowPara
-         id="flowPara3161"></flowPara></flowRoot>    <g
-       transform="matrix(0.3435955,0,0,0.3435955,-21.884913,873.87701)"
-       id="g3597">
-      <path
-         transform="matrix(1.37842,0,0,0.132178,693.72,357.735)"
-         
style="fill:url(#radialGradient1930);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-         id="path2036"
-         d="M -163.88631,598.36652 C -163.88631,529.21766 -219.94254,473.16143 
-289.0914,473.16143 C -358.24026,473.16143 -414.29649,529.21766 
-414.29649,598.36652 C -414.29649,667.51538 -358.24026,723.57161 
-289.0914,723.57161 C -219.94254,723.57161 -163.88631,667.51538 
-163.88631,598.36652 L -163.88631,598.36652 z" />
-      <path
-         transform="matrix(1.40617,0,0,1.40617,472.412,-428.379)"
-         
style="fill:url(#linearGradient1616);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient1848);stroke-width:1.27321994;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:0.58490601"
-         id="path965"
-         d="M -122.3125,353.84375 C -194.09388,353.84375 -252.375,412.09363 
-252.375,483.875 C -252.375,555.65638 -194.09388,613.93752 -122.3125,613.9375 C 
-50.531117,613.9375 7.7187499,555.65639 7.71875,483.875 C 7.71875,412.09362 
-50.531116,353.84375 -122.3125,353.84375 z M -122.3125,443.15625 C 
-99.836661,443.15626 -81.59375,461.39916 -81.59375,483.875 C 
-81.593751,506.35085 -99.83666,524.59375 -122.3125,524.59375 C 
-144.78834,524.59373 -163.03125,506.35084 -163.03125,483.875 C 
-163.03125,461.39917 -144.78834,443.15625 -122.3125,443.15625 z" />
-      <path
-         transform="matrix(1.0074,0,0,1.0074,20.4698,-97.5166)"
-         
style="fill:url(#linearGradient1757);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.96813803pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.207547"
-         id="path1756"
-         d="M 276.45327,182.08033 C 178.27042,182.08033 99.992836,248.79864 
99.992836,346.98148 C 99.992836,445.16434 179.70999,524.88152 
277.89284,524.88149 C 376.0757,524.88149 455.7501,445.16435 455.7501,346.98148 
C 455.7501,248.79862 374.63613,182.08033 276.45327,182.08033 z M 
277.89284,291.28621 C 308.63537,291.28623 333.58811,316.23895 
333.58811,346.98148 C 333.58811,377.72405 308.63537,402.67675 
277.89284,402.67675 C 247.15029,402.67671 222.19757,377.72404 
222.19757,346.98148 C 222.19757,316.23897 247.15029,291.28621 
277.89284,291.28621 z" />
-      <path
-         transform="matrix(1.40617,0,0,1.40617,472.412,-428.379)"
-         
style="fill:url(#linearGradient1855);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient1604);stroke-width:0.84881002;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1"
-         id="path964"
-         d="M -122.3125,439.14609 C -147.00186,439.14609 -167.04141,459.18565 
-167.04141,483.875 C -167.04141,508.56436 -147.00186,528.60389 
-122.3125,528.60391 C -97.623143,528.60391 -77.583594,508.56437 
-77.583593,483.875 C -77.583593,459.18564 -97.623144,439.1461 
-122.3125,439.14609 z M -122.79309,462.62619 C -111.06565,462.62618 
-101.54428,472.14756 -101.54428,483.875 C -101.54428,495.60245 
-111.06565,505.12381 -122.79309,505.12381 C -134.52053,505.12379 
-144.04189,495.60244 -144.04189,483.875 C -144.04189,472.14757 
-134.52053,462.62619 -122.79309,462.62619 z" />
-      <g
-         
transform="matrix(-1.40275,9.80325e-2,-9.80325e-2,-1.40275,174.529,941.703)"
-         id="g1745">
-        <path
-           
style="fill:url(#linearGradient3401);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-           id="path1746"
-           d="M -113.82264,438.8756 L -96.822435,356.09977 C 
-73.354046,361.06591 -27.814278,387.32121 -15.268914,409.54096 L 
-86.304686,457.1983 C -86.708084,453.10351 -104.73547,440.04011 
-113.82264,438.8756 z" />
-        <path
-           
style="fill:url(#linearGradient1607);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-           id="path1747"
-           d="M -102.62544,442.43835 L -70.865283,364.24319 C 
-57.067206,372.26311 -41.075392,380.45409 -29.826357,393.05124 L 
-89.358469,453.12659 C -92.306685,450.04973 -97.609979,445.38423 
-102.62544,442.43835 z" />
-        <g
-           transform="matrix(-1,0,0,-1,-346.848,969.168)"
-           id="g1748">
-          <path
-             
style="fill:url(#linearGradient1752);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-             id="path1749"
-             d="M -214.82706,441.10234 L -197.82685,358.32651 C 
-174.35846,363.29265 -128.81869,389.54795 -116.27333,411.7677 L 
-187.3091,459.42504 C -187.7125,455.33025 -205.73989,442.26685 
-214.82706,441.10234 z" />
-          <path
-             
style="fill:url(#linearGradient1751);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-             id="path1750"
-             d="M -203.62986,444.66509 L -171.8697,366.46993 C 
-158.07162,374.48985 -143.57864,383.94935 -132.56017,397.00775 L 
-190.36288,455.35333 C -193.3111,452.27647 -198.61439,447.61097 
-203.62986,444.66509 z" />
-        </g>
-      </g>
-      <g
-         
transform="matrix(0.837377,1.12965,-1.12965,0.837377,948.649,-14.5245)"
-         id="g1739">
-        <path
-           
style="fill:url(#linearGradient1738);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-           id="path1730"
-           d="M -113.82264,438.8756 L -96.822435,356.09977 C 
-73.354046,361.06591 -27.814278,387.32121 -15.268914,409.54096 L 
-86.304686,457.1983 C -86.708084,453.10351 -104.73547,440.04011 
-113.82264,438.8756 z" />
-        <path
-           
style="fill:url(#linearGradient1761);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-           id="path1606"
-           d="M -102.62544,442.43835 L -70.865283,364.24319 C 
-57.067206,372.26311 -42.574227,380.2641 -31.555754,393.3225 L 
-89.358469,453.12659 C -92.306685,450.04973 -97.609979,445.38423 
-102.62544,442.43835 z" />
-        <g
-           transform="matrix(-1,0,0,-1,-346.848,969.168)"
-           id="g1734">
-          <path
-             
style="fill:url(#linearGradient1731);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-             id="path1732"
-             d="M -214.82706,441.10234 L -197.82685,358.32651 C 
-174.35846,363.29265 -128.81869,389.54795 -116.27333,411.7677 L 
-187.3091,459.42504 C -187.7125,455.33025 -205.73989,442.26685 
-214.82706,441.10234 z" />
-          <path
-             
style="fill:url(#linearGradient848);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-             id="path1733"
-             d="M -203.62986,444.66509 L -171.8697,366.46993 C 
-158.07162,374.48985 -143.57864,383.94935 -132.56017,397.00775 L 
-190.36288,455.35333 C -193.3111,452.27647 -198.61439,447.61097 
-203.62986,444.66509 z" />
-        </g>
-      </g>
-      <g
-         
transform="matrix(6.51428e-3,1.40616,-1.40616,6.51428e-3,980.198,421.162)"
-         id="g1857">
-        <path
-           
style="fill:url(#linearGradient1863);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-           id="path1859"
-           d="M -102.62544,442.43835 L -70.865283,364.24319 C 
-57.067206,372.26311 -42.574227,381.72261 -31.555754,394.78101 L 
-89.358469,453.12659 C -92.306685,450.04973 -97.609979,445.38423 
-102.62544,442.43835 z" />
-        <g
-           transform="matrix(-1,0,0,-1,-346.848,969.168)"
-           id="g1860">
-          <path
-             
style="fill:url(#linearGradient1865);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-             id="path1862"
-             d="M -203.62986,444.66509 L -172.96695,367.19411 C 
-159.16887,375.21403 -143.57188,382.49085 -132.55341,395.54925 L 
-190.36288,455.35333 C -193.3111,452.27647 -198.61439,447.61097 
-203.62986,444.66509 z" />
-        </g>
-      </g>
-    </g>
-    <text
-       xml:space="preserve"
-       
style="font-size:62.63997650000000306px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#666666;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Liberation
 Sans;-inkscape-font-specification:Liberation Sans"
-       x="7.036489"
-       y="1043.4832"
-       id="text3409"><tspan
-         sodipodi:role="line"
-         id="tspan3411"
-         x="7.036489"
-         y="1043.4832"
-         
style="font-size:15.65999412999999940px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Futura
 Hv BT;-inkscape-font-specification:Futura Hv BT;fill:#666666">No album art 
found</tspan></text>
-  </g>
-</svg>

Modified: branches/stable/nixtape/install.php
===================================================================
--- branches/stable/nixtape/install.php 2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/install.php 2009-05-14 03:55:34 UTC (rev 1553)
@@ -23,19 +23,19 @@
 require_once('version.php');
 require_once('utils/get_absolute_url.php');
 
-if(file_exists("config.php")) {
-       die("A configuration file already exists. Please delete 
<i>config.php</i> if you wish to reinstall.");
+if(file_exists('config.php')) {
+       die('A configuration file already exists. Please delete 
<i>config.php</i> if you wish to reinstall.');
 }
 
 if (isset($_POST['install'])) {
 
        //Get the database connection string
        $dbms = $_POST['dbms'];
-       if($dbms == "sqlite") {
+       if($dbms == 'sqlite') {
                $filename = $_POST['filename'];
-               $connect_string = "sqlite:///" . $filename;
+               $connect_string = 'sqlite:///' . $filename;
        } else {
-               $connect_string = $dbms . "://" . $_POST['username'] . ":" . 
$_POST['password'] . "@" . $_POST['hostname'] . ":" . $_POST['port'] . "/" . 
$_POST['dbname'];
+               $connect_string = $dbms . '://' . $_POST['username'] . ':' . 
$_POST['password'] . '@' . $_POST['hostname'] . ':' . $_POST['port'] . '/' . 
$_POST['dbname'];
        }
 
        // Check the connection
@@ -45,25 +45,25 @@
        }
        $mdb2->disconnect();
 
-       $install_path = dirname(__FILE__) . "/";
+       $install_path = dirname(__FILE__) . '/';
 
        $default_theme = $_POST['default_theme'];
        $base_url = $_POST['base_url'];
        $submissions_server = $_POST['submissions_server'];
 
        //Write out the configuration
-       $config = "<?php\n \$config_version = " . $version .";\n 
\$connect_string = '" . $connect_string . "';\n \$default_theme = '" . 
$default_theme . "';\n \$base_url = '" . $base_url . "';\n \$submissions_server 
= '" . $submissions_server . "';\n \$install_path = '" . $install_path . "'; 
?>";
+       $config = "<?php\n \$config_version = " . $version .";\n 
\$connect_string = '" . $connect_string . "';\n \$default_theme = '" . 
$default_theme . "';\n \$base_url = '" . $base_url . "';\n \$submissions_server 
= '" . $submissions_server . "';\n \$install_path = '" . $install_path . "'; ";
 
-       $conf_file = fopen("config.php", "w");
+       $conf_file = fopen('config.php', 'w');
        $result = fwrite($conf_file, $config);
        fclose($conf_file);
 
        if(!$result) {
-               $print_config = str_replace("<", "&lt;", $config);
-               die("Unable to write to file '<i>config.php</i>'. Please create 
this file and copy the following in to it: <br /><pre>" . $print_config . 
"</pre>");
+               $print_config = str_replace('<', '&lt;', $config);
+               die('Unable to write to file \'<i>config.php</i>\'. Please 
create this file and copy the following in to it: <br /><pre>' . $print_config 
. '</pre>');
        }       
 
-       die("Configuration completed successfully!");
+       die('Configuration completed successfully!');
 }
 
 ?>
@@ -72,13 +72,13 @@
                <title>Libre.fm Website Installer</title>
                <script type='text/javascript'>
                        function showSqlite() {
-                               
document.getElementById("sqlite").style.visibility = "visible";
-                               
document.getElementById("networkdbms").style.visibility = "hidden";
+                               
document.getElementById('sqlite').style.visibility = 'visible';
+                               
document.getElementById('networkdbms').style.visibility = 'hidden';
                        }
 
                        function showNetworkDBMS() {
-                               
document.getElementById("sqlite").style.visibility = "hidden";
-                               
document.getElementById("networkdbms").style.visibility = "visible";
+                               
document.getElementById('sqlite').style.visibility = 'hidden';
+                               
document.getElementById('networkdbms').style.visibility = 'visible';
                        }
                </script>
        </head>
@@ -107,10 +107,10 @@
                        <h2>General</h2>
                        Default Theme: <select name="default_theme">
                        <?php   
-                               $dir = opendir("themes");
+                               $dir = opendir('themes');
                                while($theme = readdir($dir)) {
-                                       if(is_dir("themes/" . $theme) && 
$theme[0] != ".")  {
-                                               echo "<option>" . $theme . 
"</option>";
+                                       if(is_dir('themes/' . $theme) && 
$theme[0] != '.')  {
+                                               echo '<option>' . $theme . 
'</option>';
                                        }
                                }
                        ?>

Modified: branches/stable/nixtape/invite.php
===================================================================
--- branches/stable/nixtape/invite.php  2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/invite.php  2009-05-14 03:55:34 UTC (rev 1553)
@@ -23,7 +23,7 @@
 require_once('templating.php');
 require_once('utils/EmailAddressValidator.php');
 
-echo "<p>Invites are disabled.</p>";
+echo '<p>Invites are disabled.</p>';
 
 /*
 if(!$logged_in) {

Modified: branches/stable/nixtape/js/player.js
===================================================================
--- branches/stable/nixtape/js/player.js        2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/js/player.js        2009-05-14 03:55:34 UTC (rev 
1553)
@@ -3,9 +3,9 @@
 
    Copyright (C) 2009 Libre.fm Project
 
-   @licstart  The following is the entire license notice for the 
+   @licstart  The following is the entire license notice for the
    JavaScript code in this page.
-    
+
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
@@ -30,6 +30,13 @@
 var playable_songs = false;
 var streaming = false;
 
+/**
+ * Initialises the javascript player (player.tpl must also be included on the 
target page)
+ *
+ * @param array list A playlist in the form ([artist, album, track, trackurl], 
[...]) or false if playing a radio stream
+ * @param string sk Scrobble session key or false if the user isn't logged in
+ * @param string rk Radio session key or false if streaming isn't required
+ */
 function playerInit(list, sk, rk) {
        var audio = document.getElementById("audio");
        if (!list) {
@@ -58,9 +65,12 @@
        }
 }
 
+/**
+ * Finishes the player initialisation when the playlist has been loaded
+ */
 function playerReady() {
        var audio = document.getElementById("audio");
-       
+
        populatePlaylist();
        if(!playable_songs) {
                return;
@@ -75,18 +85,24 @@
        player_ready = true;
 }
 
+/**
+ * Begins playback
+ */
 function play() {
        var audio = document.getElementById("audio");
        audio.play();
        if(!now_playing) {
                nowPlaying();
        }
-       $("#play").fadeTo("normal", 0.5); 
+       $("#play").fadeTo("normal", 0.5);
        $("#pause").fadeTo("normal", 1);
        $("#seekforward").fadeTo("normal", 1);
        $("#seekback").fadeTo("normal", 1);
 }
 
+/**
+ * Pauses playback
+ */
 function pause() {
        var audio = document.getElementById("audio");
        audio.pause();
@@ -96,16 +112,25 @@
        $("#seekback").fadeTo("normal", 0.5);
 }
 
+/**
+ * Seeks backwards 10 seconds in the current song
+ */
 function seekBack() {
        var audio = document.getElementById("audio");
        audio.currentTime = audio.currentTime - 10;
 }
 
+/**
+ * Seeks forwards 10 seconds in the current song
+ */
 function seekForward() {
        var audio = document.getElementById("audio");
        audio.currentTime = audio.currentTime + 10;
 }
 
+/**
+ * Updates the progress bar every 900 milliseconds
+ */
 function updateProgress() {
        var audio = document.getElementById("audio");
        if (audio.duration > 0) {
@@ -119,17 +144,22 @@
        setTimeout("updateProgress()", 900)
 }
 
+/**
+ * Called automatically when a song finished. Loads the next song if there is 
one
+ */
 function songEnded() {
        var audio = document.getElementById("audio");
        if(current_song == playlist.length - 1) {
                pause();
        } else {
-               current_song++;
-               loadSong(current_song);
+               loadSong(current_song+1);
                play();
        }
 }
 
+/**
+ * Outputs the HTML playlist
+ */
 function populatePlaylist() {
        var i, url;
        //Clear the list
@@ -142,16 +172,26 @@
                } else {
                        playable_songs = true;
                }
-               $("#playlist > #songs").append("<li><a href='#' 
onclick='playSong(" + i + ")'>" + playlist[i]["artist"] + " - " + 
playlist[i]["track"] + "</li>");
+               $("#playlist > #songs").append("<li id='song-" + i + "'><a 
href='#' onclick='playSong(" + i + ")'>" + playlist[i]["artist"] + " - " + 
playlist[i]["track"] + "</li>");
        }
+       $("#song-" + current_song).css({fontWeight : "bold"});
 }
 
+/**
+ * Shows/Hides the HTML playlist display
+ */
 function togglePlaylist() {
        $("#playlist").toggle(1000);
        $("#showplaylist").toggle();
        $("#hideplaylist").toggle();
 }
 
+/**
+ * Submits a scrobble for the current song if a scrobble session key has been
+ * provided. Makes use of a simple proxy to support installations where the
+ * gnukebox installation is at a different domain/sub-domain to the nixtape
+ * installation.
+ */
 function scrobble() {
        var timestamp;
        scrobbled = true;
@@ -171,6 +211,10 @@
                        }, "text");
 }
 
+/**
+ * Submits 'now playing' data to the gnukebox server. Like scrobble() this
+ * makes use of a proxy.
+ */
 function nowPlaying() {
        var timestamp;
        var audio = document.getElementById("audio");
@@ -183,18 +227,33 @@
        $.post("/scrobble-proxy.php?method=nowplaying", { "a" : artist, "b" : 
album, "t" : track, "l" : audio.duration, "s" : session_key}, function(data) 
{}, "text");
 }
 
+/**
+ * Loads a song and beings playing it.
+ *
+ * @param int song The song number in the playlist that should be played
+ */
 function playSong(song) {
        var audio = document.getElementById("audio");
        loadSong(song);
        play();
 }
 
+/**
+ * Loads a song
+ *
+ * @param int song The song number in the playlist that should be loaded
+ */
 function loadSong(song) {
        var url = playlist[song]["url"];
        var audio = document.getElementById("audio");
        artist = playlist[song]["artist"];
        album = playlist[song]["album"];
        track = playlist[song]["track"];
+
+       // Highlight current song in the playlist
+       $("#song-" + current_song).css({fontWeight : "normal"});
+       $("#song-" + song).css({fontWeight : "bold"});
+
        current_song = song;
        scrobbled = false;
        now_playing = false;
@@ -206,13 +265,30 @@
                getRadioPlaylist();
        }
 
+       if(current_song > 0) {
+               $("#skipback").fadeTo("normal", 1.0);
+       } else {
+               $("#skipback").fadeTo("normal", 0.5);
+       }
+
+       if(current_song < playlist.length - 1) {
+               $("#skipforward").fadeTo("normal", 1.0);
+       } else {
+               $("#skipforward").fadeTo("normal", 0.5);
+       }
+
        $("#trackinfo > #artistname").text(artist);
        $("#trackinfo > #trackname").text(track);
 }
 
+/**
+ * Retrieves a playlist from the radio streaming service.
+ * A radio session key must be supplied when initialising
+ * the play for this to work.
+ */
 function getRadioPlaylist() {
        var tracks, artist, album, title, url, i;
-       $.get("/radio/xspf.php", {'sk' : radio_key, 'desktop' : 0}, 
function(data) { 
+       $.get("/radio/xspf.php", {'sk' : radio_key, 'desktop' : 0}, 
function(data) {
                        parser=new DOMParser();
                        xmlDoc=parser.parseFromString(data,"text/xml");
                        tracks = xmlDoc.getElementsByTagName("track")
@@ -230,10 +306,32 @@
                                playerReady();
                        } else {
                                populatePlaylist();
+                               // Re-enable the skip forward button now that 
we have more tracks
+                               $("#skipforward").fadeTo("normal", 1.0);
                        }
                }, "text");
 }
 
+/**
+ * Plays the song previous to the current one in the playlist
+ */
+function skipBack() {
+       playSong(current_song - 1);
+}
+
+/**
+ * Plays the song after the current one in the playlist
+ */
+function skipForward() {
+       playSong(current_song + 1);
+}
+
+/**
+ * Converts a timestamp to "MM:SS" format.
+ *
+ * @param int timestamp A timestamp in seconds.
+ * @return string The provided time in "MM:SS" format
+ */
 function friendlyTime(timestamp) {
        mins = Math.floor(timestamp / 60);
        sec = String(Math.floor(timestamp % 60));

Deleted: branches/stable/nixtape/licenses.php
===================================================================
--- branches/stable/nixtape/licenses.php        2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/licenses.php        2009-05-14 03:55:34 UTC (rev 
1553)
@@ -1,41 +0,0 @@
-<?php
-define('BY1',  1);
-define('BY2',  2);
-define('BY21', 3);
-define('BY25', 4);
-define('BY3',  5);
-define('BYSA1',        6);
-define('BYSA2',        7);
-define('BYSA21',       8);
-define('BYSA25',       9);
-define('BYSA3',        10);
-define('LAL',  11);
-
-// Arrays containing regular expressions for each license type
-// (so we can support multiple URL formats in the future if needed)
-$by1 = array("http://creativecommons.org/licenses/by/1.0/?.*";);
-$by2 = array("http://creativecommons.org/licenses/by/2.0/?.*";);
-$by21 = array("http://creativecommons.org/licenses/by/2.1/?.*";);
-$by25 =  array("http://creativecommons.org/licenses/by/2.5/?.*";);
-$by3 = array("http://creativecommons.org/licenses/by/3.0/?.*";);
-$bysa1 = array("http://creativecommons.org/licenses/by-sa/1.0/?.*";);
-$bysa2 =  array("http://creativecommons.org/licenses/by-sa/2.0/?.*";);
-$bysa21 = array("http://creativecommons.org/licenses/by-sa/2.1/?.*";);
-$bysa25 = array("http://creativecommons.org/licenses/by-sa/2.5/?.*";);
-$bysa3 = array("http://creativecommons.org/licenses/by-sa/3.0/?.*";);
-$lal = array("http://artlibre.org/licence.php/lal.html";);
-
-// map licenses to ids by array position
-$licenses = array(array(), $by1, $by2, $by21, $by25, $by3, $bysa1, $bysa2, 
$bysa21, $bysa25, $bysa3, $lal);
-
-function simplify_license($license) {
-       global $licenses;
-
-       foreach ($licenses as $key => $l) {
-               foreach ($l as $urlschema) {
-                       if (ereg($urlschema, $license))         return $key;
-               }
-       }
-
-       return 0;
-}

Modified: branches/stable/nixtape/listen.php
===================================================================
--- branches/stable/nixtape/listen.php  2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/listen.php  2009-05-14 03:55:34 UTC (rev 1553)
@@ -23,15 +23,20 @@
 require_once('templating.php');
 require_once('data/TagCloud.php');
 
-$aTagCloud = TagCloud::GenerateTagCloud('Free_Scrobbles', 'artist');
+$aTagCloud = TagCloud::GenerateTagCloud(TagCloud::scrobblesTable(), 'artist');
 if (!PEAR::isError ($aTagCloud)) {
         $smarty->assign('tagcloud', $aTagCloud);
 }
 
 if(isset($_GET['tag'])) {
-       $station = "librefm://globaltags/" . $_GET['tag'];
-       $smarty->assign("station", $station);
+       $station = 'librefm://globaltags/' . $_GET['tag'];
+       if(isset($this_user)) {
+               $radio_session = $this_user->getRadioSession($station);
+       } else {
+               $radio_session = Server::getRadioSession($station);
+       }
+       $smarty->assign('radio_session', $radio_session);
 }
 
-$smarty->display("listen.tpl");
+$smarty->display('listen.tpl');
 ?>

Modified: branches/stable/nixtape/location.php
===================================================================
--- branches/stable/nixtape/location.php        2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/location.php        2009-05-14 03:55:34 UTC (rev 
1553)
@@ -34,7 +34,7 @@
        
 if ($_REQUEST['country'])
 {
-       $q = sprintf("SELECT u.* FROM Users u INNER JOIN Places p ON 
u.location_uri=p.location_uri AND p.country=%s ORDER BY %s() LIMIT 100",
+       $q = sprintf('SELECT u.* FROM Users u INNER JOIN Places p ON 
u.location_uri=p.location_uri AND p.country=%s ORDER BY %s() LIMIT 100',
                $mdb2->quote(strtoupper($_REQUEST['country']), 'text'),
                $random);
        
@@ -46,7 +46,7 @@
        }
        
        $smarty->assign('country', strtoupper($_REQUEST['country']));
-       $res = $mdb2->query(sprintf("SELECT * FROM Countries WHERE country=%s 
LIMIT 1",
+       $res = $mdb2->query(sprintf('SELECT * FROM Countries WHERE country=%s 
LIMIT 1',
                $mdb2->quote(strtoupper($_REQUEST['country']), 'text')));
        if ( $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC) )
        {
@@ -60,7 +60,7 @@
                                'rel' => 'meta',
                                'type' => 'application/rdf+xml' ,
                                'title' => 'FOAF',
-                               'href' => 
$base_url.'/rdf.php?fmt=xml&page='.htmlentities($_SERVER['REQUEST_URI'])
+                               'href' => 
$base_url.'/rdf.php?fmt=xml&page='.urlencode(str_replace($base_url, '', 
$_SERVER['REQUEST_URI']))
                                )
                ));
                

Modified: branches/stable/nixtape/login.php
===================================================================
--- branches/stable/nixtape/login.php   2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/login.php   2009-05-14 03:55:34 UTC (rev 1553)
@@ -20,7 +20,7 @@
 */
 
 
-require_once('database.php');
+require_once('database2.php');
 require_once('templating.php');
 require_once($install_path . '/data/User.php');
 
@@ -44,11 +44,17 @@
        }
 
        if(empty($errors)) {
-               $res = $mdb2->query('SELECT username FROM Users WHERE '
-                       . ' lower(username) = ' . 
$mdb2->quote(strtolower($username), 'text')
-                       . ' AND password = ' . $mdb2->quote(md5($password), 
'text') . ' AND active = 1');
-               if(!$res->numRows()) {
+               try {
+               $res = $adodb->GetOne('SELECT username FROM Users WHERE '
+                       . ' lower(username) = ' . 
$adodb->qstr(strtolower($username))
+                       . ' AND password = ' . $adodb->qstr(md5($password)) . ' 
AND active = 1');
+               }
+               catch (exception $e) {
+                       $errors .= 'A database error happened.';
+               }
+               if(!$res) {
                        $errors .= 'Invalid username or password.';
+                       $smarty->assign('invalid', true);
                } else {
                        // Give the user a session id, like any other client
                        $session_id = md5(md5($password) . time());
@@ -57,10 +63,10 @@
                        } else {
                                $session_time = time() + 86400; // 1 day
                        }
-                       $mdb2->query('INSERT INTO Scrobble_Sessions (username, 
sessionid, expires) VALUES ('
-                               . $mdb2->quote($username, 'text') . ', '
-                               . $mdb2->quote($session_id, 'text') . ', '
-                               . $mdb2->quote($session_time, 'integer') . ')');
+                       $adodb->Execute('INSERT INTO Scrobble_Sessions 
(username, sessionid, expires) VALUES ('
+                               . $adodb->qstr($username) . ', '
+                               . $adodb->qstr($session_id) . ', '
+                               . (int)($session_time) . ')');
 
                        setcookie('session_id', $session_id, $session_time);
                        $logged_in = true;
@@ -70,17 +76,20 @@
 
 if(isset($logged_in) && $logged_in) {
        // Check that return URI is on this server. Prevents possible phishing 
uses.
-       if ( substr($_POST['return'], 0, 1) == '/' )
-               { header(sprintf('Location: http://%s%s', 
$_SERVER['SERVER_NAME'], $_POST['return'])); }
-       else
-               { header("Location: $base_url"); }
+       if ( substr($_POST['return'], 0, 1) == '/' ) {
+               header(sprintf('Location: http://%s%s', 
$_SERVER['SERVER_NAME'], $_POST['return']));
+       } else {
+               header('Location: ' . $base_url);
+       }
 
 } else {
-       if ( substr($_REQUEST['return'], 0, 1) == '/' )
-               { $smarty->assign('return', $_REQUEST['return']); }
-       else
-               { $smarty->assign('return', ''); }
-       
+       if ( substr($_REQUEST['return'], 0, 1) == '/' ) {
+               $smarty->assign('return', $_REQUEST['return']);
+       } else {
+               $smarty->assign('return', '');
+       }
+
+       $smarty->assign('username', $username);
+       $smarty->assign('errors', $errors);
        $smarty->display('login.tpl');
 }
-?>

Modified: branches/stable/nixtape/radio/adjust.php
===================================================================
--- branches/stable/nixtape/radio/adjust.php    2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/radio/adjust.php    2009-05-14 03:55:34 UTC (rev 
1553)
@@ -18,24 +18,24 @@
 
 */
 
-require_once("../database.php");
-require_once("radio-utils.php");
+require_once('../database.php');
+require_once('radio-utils.php');
 
 if(!isset($_GET['session']) || !isset($_GET['url'])) {
        die("FAILED\n");
 }
 
-$session = $_GET["session"];
-$url = $_GET["url"];
+$session = $_GET['session'];
+$url = $_GET['url'];
 
-$res = $mdb2->query("SELECT username FROM Radio_Sessions WHERE session = " . 
$mdb2->quote($session, "text"));
+$res = $mdb2->query('SELECT username FROM Radio_Sessions WHERE session = ' . 
$mdb2->quote($session, 'text'));
 
 if(!$res->numRows()) {
         die("BADSESSION\n");
 }
 
-if(ereg("^(globaltags|artist)/[^:]+$", $url, $regs)) {
-       $url = "librefm://" . $url; // compensate for shell-fm sending 
incomplete urls
+if(ereg('^(globaltags|artist)/[^:]+$', $url, $regs)) {
+       $url = 'librefm://' . $url; // compensate for shell-fm sending 
incomplete urls
 }
 
 $stationname=radio_title_from_url($url);
@@ -43,7 +43,7 @@
        die("FAILED Unavailable station\n");
 }
 
-$mdb2->exec("UPDATE Radio_Sessions SET url = " . $mdb2->quote($url, "text") . 
" WHERE session = " . $mdb2->quote($session, "text"));
+$mdb2->exec('UPDATE Radio_Sessions SET url = ' . $mdb2->quote($url, 'text') . 
' WHERE session = ' . $mdb2->quote($session, 'text'));
 
 echo "response=OK\n";
 echo "url=http://libre.fm\n";; // Need to parse the station request and give a 
real URL

Modified: branches/stable/nixtape/radio/handshake.php
===================================================================
--- branches/stable/nixtape/radio/handshake.php 2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/radio/handshake.php 2009-05-14 03:55:34 UTC (rev 
1553)
@@ -18,7 +18,7 @@
 
 */
 
-require_once("../database.php");
+require_once('../database.php');
 
 if(!isset($_GET['username']) || !isset($_GET['passwordmd5'])) {
        die("BADAUTH\n");
@@ -27,20 +27,20 @@
 $username = $_GET['username'];
 $passmd5 = $_GET['passwordmd5'];
 
-$res = $mdb2->query("SELECT username FROM Users WHERE username = " . 
$mdb2->quote($username, "text") . " AND password = " . $mdb2->quote($passmd5, 
"text"));
+$res = $mdb2->query('SELECT username FROM Users WHERE username = ' . 
$mdb2->quote($username, 'text') . ' AND password = ' . $mdb2->quote($passmd5, 
'text'));
 if (!$res->numRows()) {
        die("BADAUTH\n");
 }
 
 $session = md5($passmd5 . time());
 
-$mdb2->exec("DELETE FROM Radio_Sessions WHERE expires < " . 
$mdb2->quote(time(), "integer"));
+$mdb2->exec('DELETE FROM Radio_Sessions WHERE expires < ' . 
$mdb2->quote(time(), 'integer'));
 
-$mdb2->query("INSERT INTO Radio_Sessions (username, session, expires) VALUES ( 
" . $mdb2->quote($username, "text") . ", " . $mdb2->quote($session, "text") . 
", " . $mdb2->quote(time() + 259200,"integer") . ")");
+$mdb2->query('INSERT INTO Radio_Sessions (username, session, expires) VALUES ( 
' . $mdb2->quote($username, 'text"' . ', ' . $mdb2->quote($session, "text") . 
', ' . $mdb2->quote(time() + 259200,'integer') . ')');
 
 
-echo "session=" . $session . "\n";
-echo "stream_url=this.is.broken.$username.example.com\n";
+echo 'session=' . $session . "\n";
+echo "stream_url=this.is.broken.{$username}.example.com\n";
 echo "subscriber=0\n";
 echo "framehack=0..\n";
 echo "base_url=alpha.libre.fm\n";

Modified: branches/stable/nixtape/radio/radio-utils.php
===================================================================
--- branches/stable/nixtape/radio/radio-utils.php       2009-05-14 03:41:38 UTC 
(rev 1552)
+++ branches/stable/nixtape/radio/radio-utils.php       2009-05-14 03:55:34 UTC 
(rev 1553)
@@ -20,16 +20,16 @@
 
 function radio_title_from_url($url) {
 
-       if(ereg("l(ast|ibre)fm://globaltags/(.*)", $url, $regs)) {
+       if(ereg('l(ast|ibre)fm://globaltags/(.*)', $url, $regs)) {
                $tag = $regs[2];
-               return "Libre.fm " . ucwords($tag) . " Tag Radio";
+               return 'Libre.fm ' . ucwords($tag) . ' Tag Radio';
        }
-       if(ereg("l(ast|ibre)fm://artist/(.*)/similarartists", $url, $regs)) {
+       if(ereg('l(ast|ibre)fm://artist/(.*)/similarartists', $url, $regs)) {
                $artist = $regs[2];
-               return "Libre.fm " . $artist . " Artist Radio";
+               return 'Libre.fm ' . $artist . ' Artist Radio';
        }
 
-       return "FAILED";
+       return 'FAILED';
 }
 
 ?>

Modified: branches/stable/nixtape/radio/xspf.php
===================================================================
--- branches/stable/nixtape/radio/xspf.php      2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/radio/xspf.php      2009-05-14 03:55:34 UTC (rev 
1553)
@@ -21,7 +21,7 @@
 require_once('../database.php');
 require_once('../templating.php');
 require_once('../data/Track.php');
-require_once("radio-utils.php");
+require_once('radio-utils.php');
 
 // These deaths should probably just return an empty playlist
 
@@ -29,9 +29,9 @@
        die("BADSESSION\n"); // this should return a blank dummy playlist 
instead
 }
 
-$session = $_GET["sk"];
+$session = $_GET['sk'];
 
-$res = $mdb2->query("SELECT url FROM Radio_Sessions WHERE session = " . 
$mdb2->quote($session, "text"));
+$res = $mdb2->query('SELECT url FROM Radio_Sessions WHERE session = ' . 
$mdb2->quote($session, 'text'));
 
 if(!$res->numRows()) {
        die("BADSESSION\n"); // this should return a blank dummy playlist 
instead
@@ -42,12 +42,12 @@
 $title = radio_title_from_url($url);
 $smarty->assign('title', $title);
 
-if(ereg("l(ast|ibre)fm://globaltags/(.*)", $url, $regs)) {
+if(ereg('l(ast|ibre)fm://globaltags/(.*)', $url, $regs)) {
        $tag = $regs[2];
-       $res = $mdb2->query("SELECT Track.name, Track.artist_name, 
Track.album_name FROM Track INNER JOIN Tags ON Track.name=Tags.track AND 
Track.artist_name=Tags.artist AND Track.album_name=Tags.album WHERE 
streamurl<>'' AND streamable=1 AND lower(tag) = " . 
$mdb2->quote(mb_strtolower($tag, "UTF-8"), "text"));
-} elseif(ereg("l(ast|ibre)fm://artist/(.*)/similarartists", $url, $regs)) {
+       $res = $mdb2->query('SELECT Track.name, Track.artist_name, 
Track.album_name FROM Track INNER JOIN Tags ON Track.name=Tags.track AND 
Track.artist_name=Tags.artist AND Track.album_name=Tags.album WHERE 
streamurl<>\'\' AND streamable=1 AND lower(tag) = ' . 
$mdb2->quote(mb_strtolower($tag, 'UTF-8'), 'text'));
+} elseif(ereg('l(ast|ibre)fm://artist/(.*)/similarartists', $url, $regs)) {
        $artist = $regs[2];
-       $res = $mdb2->query("SELECT name, artist_name, album_name FROM Track 
WHERE streamurl<>'' AND streamable=1 AND lower(artist_name) = " . 
$mdb2->quote(mb_strtolower($artist, "UTF-8"), "text"));
+       $res = $mdb2->query('SELECT name, artist_name, album_name FROM Track 
WHERE streamurl<>\'\' AND streamable=1 AND lower(artist_name) = ' . 
$mdb2->quote(mb_strtolower($artist, 'UTF-8'), 'text'));
 } else {
        die("FAILED\n"); // this should return a blank dummy playlist instead
 }
@@ -70,9 +70,9 @@
        $res->seek($tr[$i]);
        $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
 
-       $track = new Track($row["name"], $row["artist_name"]);
-       $album = new Album($row["album_name"], $row["artist_name"]);
-       $artist = new Artist($row["artist_name"]);
+       $track = new Track($row['name'], $row['artist_name']);
+       $album = new Album($row['album_name'], $row['artist_name']);
+       $artist = new Artist($row['artist_name']);
 
        if($track->duration == 0) {
                $duration = 180000;
@@ -80,17 +80,17 @@
                $duration = $track->duration * 1000;
        }
 
-       $radiotracks[$i]["location"] = $track->streamurl;
-       $radiotracks[$i]["title"] = $track->name;
-       $radiotracks[$i]["id"] = "0000";
-       $radiotracks[$i]["album"] = $album->name;
-       $radiotracks[$i]["creator"] = $artist->name;
-       $radiotracks[$i]["duration"] = $duration;
-       $radiotracks[$i]["image"] = $album->image;
-       $radiotracks[$i]["artisturl"] = $artist->getURL();
-       $radiotracks[$i]["albumurl"] = $album->getURL();
-       $radiotracks[$i]["trackurl"] = $track->getURL();
-       $radiotracks[$i]["downloadurl"] = $track->getURL();
+       $radiotracks[$i]['location'] = $track->streamurl;
+       $radiotracks[$i]['title'] = $track->name;
+       $radiotracks[$i]['id'] = "0000";
+       $radiotracks[$i]['album'] = $album->name;
+       $radiotracks[$i]['creator'] = $artist->name;
+       $radiotracks[$i]['duration'] = $duration;
+       $radiotracks[$i]['image'] = $album->image;
+       $radiotracks[$i]['artisturl'] = $artist->getURL();
+       $radiotracks[$i]['albumurl'] = $album->getURL();
+       $radiotracks[$i]['trackurl'] = $track->getURL();
+       $radiotracks[$i]['downloadurl'] = $track->getURL();
 
        }
 

Modified: branches/stable/nixtape/rdf.php
===================================================================
--- branches/stable/nixtape/rdf.php     2009-05-14 03:41:38 UTC (rev 1552)
+++ branches/stable/nixtape/rdf.php     2009-05-14 03:55:34 UTC (rev 1553)
@@ -26,7 +26,7 @@
 $fmt  = $_GET['fmt'];
 
 if (empty($fmt)) $fmt = 'xml';
-if (empty($page)) die("Required parameter 'page' not provided.");
+if (empty($page)) die('Required parameter \'page\' not provided.');
 
 $parser = ARC2::getSemHTMLParser(array('sem_html_formats' => 'rdfa'));
 $parser->parse($base_url . $page);
@@ -49,33 +49,35 @@
 switch ($fmt)
 {
        case 'xml' :
-               header("Content-Type: application/rdf+xml");
+               header('Content-Type: application/rdf+xml');
                $ser = ARC2::getRDFXMLSerializer($conf);
                break;
        case 'ttl' :
-               header("Content-Type: application/x-turtle");
+               header('Content-Type: application/x-turtle');
                $ser = ARC2::getTurtleSerializer($conf);
                break;
        case 'rss' :
-               header("Content-Type: application/rss+xml");
+               header('Content-Type: application/rss+xml');
                $ser = ARC2::getRSS10Serializer($conf);
                break;
        case 'json' :
                if ($_GET['callback'])
-                       { header("Content-Type: text/javascript"); }
+                       { header('Content-Type: text/javascript'); }
                else 
-                       { header("Content-Type: application/json"); }
+                       { header('Content-Type: application/json'); }
                $ser = ARC2::getRDFJSONSerializer($conf);
                break;
        case 'nt' :
-               header("Content-Type: text/plain");
+               header('Content-Type: text/plain');
                $ser = ARC2::getNTriplesSerializer($conf);
                break;
 }
 
-if ($_GET['callback'])
+if ($_GET['callback']) {
        print $_GET['callback'] . '(';
+}
 print $ser->getSerializedIndex($index);
-if ($_GET['callback'])
+if ($_GET['callback']) {
        print ');';
+}
        

Deleted: branches/stable/nixtape/recovery.php
===================================================================
--- branches/stable/nixtape/recovery.php        2009-05-14 03:41:38 UTC (rev 
1552)
+++ branches/stable/nixtape/recovery.php        2009-05-14 03:55:34 UTC (rev 
1553)
@@ -1,106 +0,0 @@
-<?php
-
-/* Libre.fm -- a free network service for sharing your music listening habits
-
-   Copyright (C) 2009 Libre.fm Project
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU Affero General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   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 Affero General Public License for more details.
-
-   You should have received a copy of the GNU Affero General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
- */
-
-// TODO: Check if the request has expired before changing.
-
-require_once('database.php');
-require_once('templating.php');
-require_once('utils/EmailAddressValidator.php');
-
-global $mdb2;
-$errors = '';
-
-function sendEmail($text, $email) {
-    $headers = 'From: Libre.fm Recovery <address@hidden>';
-    $subject = 'Libre.fm Password Recovery';
-    mail($email, $subject, $text, $headers);
-}
-
-if (isset($_GET['code'])) {
-    $res = $mdb2->query("SELECT * FROM Recovery_Request WHERE code=" . 
$mdb2->quote($_GET['code'], 'text'));
-    if ($res->numRows() == 0) {
-       $errors .= "Invalid recovery token.\n";
-       $smarty->assign('errors', $errors);
-       $smarty->display('error.tpl');
-       die();
-    }
-
-    $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
-    
-    $password = "";
-    $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
-    
-    for ($i = 0; $i < 8; $i++) {
-       $password .= substr($chars, mt_rand(0, strlen($chars)-1), 1);
-    }
-
-    $email = $row['email'];
-
-    $sql = "UPDATE Users SET password=" . $mdb2->quote(md5($password), 'text') 
. " WHERE email="
-        . $mdb2->quote($email, 'text');
-
-    $mdb2->exec($sql);
-
-    $content = "Hi!\n\nYour password has been set to " . $password . "\n\n - 
The Libre.fm Team";
-    sendEmail($content, $email);

@@ Diff output truncated at 153600 characters. @@




reply via email to

[Prev in Thread] Current Thread [Next in Thread]