librefm-commits
[Top][All Lists]
Advanced

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

[Librefm-commits] [1874] use userids instead of usernames in scrobbles t


From: Clint Adams
Subject: [Librefm-commits] [1874] use userids instead of usernames in scrobbles table
Date: Wed, 03 Jun 2009 14:47:11 +0000

Revision: 1874
          http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1874
Author:   clint
Date:     2009-06-03 14:47:11 +0000 (Wed, 03 Jun 2009)
Log Message:
-----------
use userids instead of usernames in scrobbles table

Modified Paths:
--------------
    branches/stable/gnukebox/auth-utils.php
    branches/stable/gnukebox/display.php
    branches/stable/gnukebox/install.php
    branches/stable/gnukebox/scrobble-utils.php
    branches/stable/gnukebox/submissions/1.2/index.php

Modified: branches/stable/gnukebox/auth-utils.php
===================================================================
--- branches/stable/gnukebox/auth-utils.php     2009-06-03 14:46:35 UTC (rev 
1873)
+++ branches/stable/gnukebox/auth-utils.php     2009-06-03 14:47:11 UTC (rev 
1874)
@@ -30,6 +30,7 @@
                return false;
        }
 
+       $adodb->SetFetchMode(ADODB_FETCH_ASSOC); // this query should get the 
uniqueid and then return it on success
        $result = $adodb->GetOne('SELECT username FROM Auth WHERE '
                //. 'expires > ' . time() . ' AND '   // session keys have an 
infinite lifetime
                . 'sk = ' . $adodb->qstr($sk)
@@ -46,6 +47,7 @@
        // Validates authentication using a standard authentication token
        global $adodb;
 
+       $adodb->SetFetchMode(ADODB_FETCH_ASSOC); // this query should get the 
uniqueid and then return it on success
        $pass = $adodb->GetOne('SELECT password FROM Users WHERE username =' . 
$adodb->qstr($username));
        if (!$pass) {
                // TODO: Log failures somewhere

Modified: branches/stable/gnukebox/display.php
===================================================================
--- branches/stable/gnukebox/display.php        2009-06-03 14:46:35 UTC (rev 
1873)
+++ branches/stable/gnukebox/display.php        2009-06-03 14:47:11 UTC (rev 
1874)
@@ -45,7 +45,7 @@
 
        try {
 
-       $res = $adodb->CacheGetAll(60, "SELECT username, artist, track, time 
FROM Scrobbles ORDER BY time DESC LIMIT 100");
+       $res = $adodb->CacheGetAll(60, "SELECT userid, artist, track, time FROM 
Scrobbles ORDER BY time DESC LIMIT 100");
 
        }
 
@@ -58,7 +58,7 @@
 
                        foreach($res as &$row){
 
-                       echo "<li>" . $row['username'] . " listened to
+                       echo "<li>" . $row['userid'] . " listened to
                        " . $row['artist'] . "&mdash;" . $row['track']
                        . " (" . human_timestamp($row['time']) . ")</li>\n";
 

Modified: branches/stable/gnukebox/install.php
===================================================================
--- branches/stable/gnukebox/install.php        2009-06-03 14:46:35 UTC (rev 
1873)
+++ branches/stable/gnukebox/install.php        2009-06-03 14:47:11 UTC (rev 
1874)
@@ -172,7 +172,7 @@
        }
 
        $adodb->Execute("CREATE TABLE Scrobbles(
-               username VARCHAR(64) REFERENCES Users(username),
+               userid INTEGER REFERENCES Users(uniqueid),
                track VARCHAR(255),
                album VARCHAR(255),
                artist VARCHAR(255) REFERENCES Artist(name),

Modified: branches/stable/gnukebox/scrobble-utils.php
===================================================================
--- branches/stable/gnukebox/scrobble-utils.php 2009-06-03 14:46:35 UTC (rev 
1873)
+++ branches/stable/gnukebox/scrobble-utils.php 2009-06-03 14:47:11 UTC (rev 
1874)
@@ -22,7 +22,7 @@
 require_once('database.php');  // include the database connection string
 require_once('temp-utils.php');
 
-function usernameFromSID($session_id)
+function useridFromSID($session_id)
 {
 
 //derive the username from a session ID
@@ -46,8 +46,7 @@
                // the user has no session
        }
 
-       $username = uniqueid_to_username($res);
-       return $username;
+       return $res;
 
               // return the first user
 }
@@ -177,11 +176,11 @@
        }
 }
 
-function scrobbleExists($username, $artist, $track, $time) {
+function scrobbleExists($userid, $artist, $track, $time) {
        global $adodb;
 
        try {
-       $res = $adodb->GetOne('SELECT time FROM Scrobbles WHERE username = ' . 
($username) . ' AND artist = ' . ($artist) . ' AND track = ' . ($track) . ' AND 
time = ' . ($time));
+       $res = $adodb->GetOne('SELECT time FROM Scrobbles WHERE userid = ' . 
($userid) . ' AND artist = ' . ($artist) . ' AND track = ' . ($track) . ' AND 
time = ' . ($time));
        }
        catch (exception $e) {
                die('FAILED se ' . $e->getMessage() . '\n');

Modified: branches/stable/gnukebox/submissions/1.2/index.php
===================================================================
--- branches/stable/gnukebox/submissions/1.2/index.php  2009-06-03 14:46:35 UTC 
(rev 1873)
+++ branches/stable/gnukebox/submissions/1.2/index.php  2009-06-03 14:47:11 UTC 
(rev 1874)
@@ -34,7 +34,7 @@
 
 $session_id = $_POST['s'];
 
-$username = $adodb->qstr(usernameFromSID($session_id));
+$userid = $adodb->qstr(useridFromSID($session_id));
 $rowvalues = array();
 $actualcount = 0;
 
@@ -119,12 +119,12 @@
        $tid = getTrackCreateIfNew($artist, $album, $track, $mbid);
        $stid = getScrobbleTrackCreateIfNew($artist, $album, $track, $mbid, 
$tid);
 
-       $exists = scrobbleExists($username, $artist, $track, $time);
+       $exists = scrobbleExists($userid, $artist, $track, $time);
 
        if((!$exists) && $rating<>'S') {
        // Scrobble!
        $rowvalues[$actualcount] = "("
-               . $username . ", "
+               . $userid . ", "
                . $artist . ", "
                . $album . ", "
                . $track . ", "
@@ -145,7 +145,7 @@
                for($j = 0; $j < $actualcount; $j++) {
 
        // Scrobble!
-               $sql = "INSERT INTO Scrobbles (username, artist, album, track, 
time, mbid, source, rating, length, stid) VALUES " . $rowvalues[$j];
+               $sql = "INSERT INTO Scrobbles (userid, artist, album, track, 
time, mbid, source, rating, length, stid) VALUES " . $rowvalues[$j];
                try {
                $res =& $adodb->Execute($sql);
                }





reply via email to

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