librefm-commits
[Top][All Lists]
Advanced

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

[Librefm-commits] [1538] merge gnukebox from trunk


From: Clint Adams
Subject: [Librefm-commits] [1538] merge gnukebox from trunk
Date: Wed, 13 May 2009 21:12:08 +0000

Revision: 1538
          http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1538
Author:   clint
Date:     2009-05-13 21:12:08 +0000 (Wed, 13 May 2009)
Log Message:
-----------
merge gnukebox from trunk

Modified Paths:
--------------
    branches/stable/gnukebox/README
    branches/stable/gnukebox/auth-utils.php
    branches/stable/gnukebox/database.php
    branches/stable/gnukebox/display.php
    branches/stable/gnukebox/fix-album-art.php
    branches/stable/gnukebox/install.php
    branches/stable/gnukebox/nowplaying/1.2/index.php
    branches/stable/gnukebox/scrobble-utils.php
    branches/stable/gnukebox/submissions/1.1/handshake.php
    branches/stable/gnukebox/submissions/1.2/handshake.php
    branches/stable/gnukebox/submissions/1.2/index.php

Added Paths:
-----------
    branches/stable/gnukebox/musicbrainz.php

Removed Paths:
-------------
    branches/stable/gnukebox/blocks.css
    branches/stable/gnukebox/blocks.php

Modified: branches/stable/gnukebox/README
===================================================================
--- branches/stable/gnukebox/README     2009-05-13 21:10:01 UTC (rev 1537)
+++ branches/stable/gnukebox/README     2009-05-13 21:12:08 UTC (rev 1538)
@@ -2,8 +2,7 @@
 
  To install visit http://yourserver.com/path/to/gobbler/install.php
 
- As things stand you'll need the MDB2 pear module installed (and at least one 
MDB2 driver) this can be achieved by running "pear install mdb2 mdb2#sqlite".
- (For distribution we can include the latest version of MDB2 in the release 
packages if we want to make things even simpler for people.)
+ As things stand you'll need the ADODB module installed.
 
 Web services API:
  To test the authentication API once the server is set up:

Modified: branches/stable/gnukebox/auth-utils.php
===================================================================
--- branches/stable/gnukebox/auth-utils.php     2009-05-13 21:10:01 UTC (rev 
1537)
+++ branches/stable/gnukebox/auth-utils.php     2009-05-13 21:12:08 UTC (rev 
1538)
@@ -23,36 +23,35 @@
 
 function check_web_auth($username, $token, $timestamp, $api_key, $sk) {
        // Validates authentication using a web services token
-       global $mdb2;
+       global $adodb;
 
        // Using the valid_api_key function from nixtape/2.0/index.php would be 
appropriate here
        if (strlen($api_key) != 32) {
                return false;
        }
 
-       $result = $mdb2->query('SELECT username FROM Auth WHERE '
+       $result = $adodb->GetOne('SELECT username FROM Auth WHERE '
                //. 'expires > ' . time() . ' AND '   // session keys have an 
infinite lifetime
-               . 'sk = ' . $mdb2->quote($sk, 'text')
+               . 'sk = ' . $adodb->qstr($sk)
                );
-       if (PEAR::isError($result) || !$result->numRows()) {
+       if (!$result) {
                // TODO: Log failures somewhere
                return false;
        }
 
-       return $result->fetchOne(0) == $username;
+       return $result == $username;
 }
 
 function check_standard_auth($username, $token, $timestamp) {
        // Validates authentication using a standard authentication token
-       global $mdb2;
+       global $adodb;
 
-       $result = $mdb2->query("SELECT password FROM Users WHERE username =" . 
$mdb2->quote($username, 'text'));
-       if (PEAR::isError($result) || !$result->numRows()) {
+       $pass = $adodb->GetOne("SELECT password FROM Users WHERE username =" . 
$adodb->qstr($username));
+       if (!$pass) {
                // TODO: Log failures somewhere
                return false;
        }
 
-       $pass = $result->fetchOne(0);
        $check_token = md5($pass . $timestamp);
 
        return $check_token == $token;

Deleted: branches/stable/gnukebox/blocks.css
===================================================================
--- branches/stable/gnukebox/blocks.css 2009-05-13 21:10:01 UTC (rev 1537)
+++ branches/stable/gnukebox/blocks.css 2009-05-13 21:12:08 UTC (rev 1538)
@@ -1,150 +0,0 @@
-/*
-Copyright (c) 2009 Libre.fm
-
-License AGPL
-
-*/
-
-body{background-image: none;}
-#cards {
-    width: 820px;
-    margin: 10px;
-    margin-left:250px;
-    text-align:center;
-    padding: 0;
-}
-
-#statistics {
-    clear:both;
-    position:absolute;
-    top: 380px;
-    left: 80px;
-    width: 120px;
-    height: 130px;
-    -moz-border-radius-topleft: 15px;
-    -webkit-border-radius-topleft: 15px;
-    -moz-border-radius-bottomright: 15px;
-    -webkit-border-radius-bottomright: 15px;
-    background: #fff;
-    border: 1px solid #ccc;
-}
-
-#statistics h2 {
-    margin:0;
-    margin-bottom:15px;
-    background: #980101;
-    color: #fff;
-    font-weight: bold;
-    font-size: 15px;
-    line-height: 20px;
-    height: 20px;
-    display:block;
-    padding-left:5px;
-    -moz-border-radius-topleft: 15px;
-    -webkit-border-radius-topleft: 15px;
-}
-
-#statistics p {
-    padding: 0 10px;
-}
-
-#message {
-    position: absolute;
-    width: 190px;
-    padding: 5px;
-    margin-left:20px;
-}
-
-#nowplaying {
-    position: relative;
-    left: -5px;
-    -moz-border-radius: 15px;
-    margin: 20px;
-    margin-left:260px;
-    width: 780px;
-    height: 200px;
-    background: #eee;
-    padding: 10px;
-    overflow:auto;
-    clear:both;
-}
-#nowtracks {
-    overflow:auto;
-}
-#nowplaying p {
-    display: block;
-    background: #fff;
-    -moz-border-radius: 5px;
-    padding: 5px;
-    width: 760px;
-    overflow:hidden;
-    margin: 2px auto;
-}
-.singlecard {
-    position:relative;
-    width: 150px;
-    height: 150px;
-    float:left;
-    margin: 5px;
-    border: 1px dashed #444;
-    -moz-border-radius-topleft: 15px;
-    -webkit-border-radius-topleft: 15px;
-    -moz-border-radius-bottomright: 15px;
-    -webkit-border-radius-bottomright: 15px;
-    border: 1px solid #ccc;
-    background: #fff;
-    overflow:hidden;
-}
-
-.username {
-    background-color: #000;
-    color: #fff;
-    font-weight: bold;
-    font-size: 15px;
-    line-height: 20px;
-    height: 20px;
-    -moz-border-radius-topleft: 15px;
-    -webkit-border-radius-topleft: 15px;
-    text-align:left;
-}
-
-.username a {
-    margin-left:5px;
-    color: #fff;
-    text-decoration:none;
-}
-
-.artist {
-    padding:5px;
-    margin-top:5px;
-    font-size: 80%;
-    height: 30px;
-    overflow: hidden;
-}
-
-.artist a {
-    text-decoration:none;
-    color: #000;
-}
-
-.track {
-    margin-top:0px;
-    padding:5px;
-    font-size: 110%;
-    height: 70px;
-    overflow: hidden;
-}
-
-.track a {
-    text-decoration:none;
-    color: #000;
-}
-
-.time {
-    position:absolute;
-    bottom:8px;
-    left: 8px;
-    margin-top: 2px;
-    color: #ccc;
-    font-size:8px;
-}

Deleted: branches/stable/gnukebox/blocks.php
===================================================================
--- branches/stable/gnukebox/blocks.php 2009-05-13 21:10:01 UTC (rev 1537)
+++ branches/stable/gnukebox/blocks.php 2009-05-13 21:12:08 UTC (rev 1538)
@@ -1,197 +0,0 @@
-<?php
-
-/* Libre.fm -- a free network service for sharing your music listening habits
-
-   Copyright (C) 2009 Free Software Foundation, Inc
-
-   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/>.
-
-*/
-
-header('Content-type: text/html; charset=utf-8');
-require_once('database.php');
-require_once('version.php');
-
-if (!isset($config_version) || $config_version != $version) {
-       die("Configuration file is out of date. Please delete it (and 
associated database) and <a href='install.php'>reinstall</a>."); //TODO: 
Upgrade script for release versions
-}
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd";>
-<html>
-<head>
-               <title>Libre.fm Gobble Server</title>
-   <link rel="stylesheet" href="reset-fonts-grids.css" type="text/css">
-   <link rel="stylesheet" href="base.css" type="text/css">
-   <link rel="stylesheet" href="librefm.css" type="text/css">
-   <link rel="stylesheet" href="blocks.css" type="text/css">
-<!--
-<rdf:RDF xmlns="http://web.resource.org/cc/";
-         xmlns:dc="http://purl.org/dc/elements/1.1/";
-         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
-<license rdf:resource="http://creativecommons.org/licenses/by-sa/3.0/us/"; />
-</Work>
-<License rdf:about="http://creativecommons.org/licenses/by-sa/3.0/us/";>
-</License>
-</rdf:RDF>
--->
-</head>
-<body>
-<div id="doc3" class="yui-t7">
-   <div id="hd" style="banner"><h1><a href="http://libre.fm/";>Libre.fm Gobble 
Server</a></h1></div>
-   <div id="bd" style="main">
-       <div id="yui-main">
-       <div class="yui-b"><div class="yui-g">
-<div id='message'>
-  <p>This is a demo site for the libre.fm 'gobbler' server. That name might 
change. If you'd like an account, come to our IRC channel and ask mattl, Elleo 
or Clint nicely. You'll need to supply us with a username, password and email 
address.</p>
-
-<p>You'll also need to be comfortable editing your 'hosts' file and understand 
the implications of doing that.</p>
-</div>
-
-<div id="cards">
-               <?php
-
-  $req_user = $_GET["u"];
-$req_artist = $_GET["a"];
-$req_track = $_GET["t"];
-
-
-if ($req_user) {
-
-                       $res = $mdb2->query("SELECT username, artist, track, 
time FROM Scrobbles WHERE username = '" . $req_user . "' ORDER BY time DESC 
LIMIT 15");
-
-                       echo "<h2>Last 15 Gobbles by " . 
stripslashes($req_user) . "</h2>";
-
-} elseif ($req_artist) {
-
-                       $res = $mdb2->query("SELECT username, artist, track, 
time FROM Scrobbles WHERE artist = '" . $req_artist ."' ORDER BY time DESC 
LIMIT 15");
-
-                       echo "<h2>Last 15 Gobbles of " . 
stripslashes($req_artist) . "</h2>";
-
-} elseif ($req_track) {
-
-                       $res = $mdb2->query("SELECT username, artist, track, 
time FROM Scrobbles WHERE track = '" . $req_track . "' ORDER BY time DESC LIMIT 
15");
-
-                       echo "<h2>Last 15 Gobbles of " . 
stripslashes($req_track) . "</h2>";
-
-} elseif (!$res) {
-
-                       $res = $mdb2->query("SELECT username, artist, track, 
time FROM Scrobbles ORDER BY time DESC LIMIT 15");
-
-                       echo "<h2>Last 15 Gobbles</h2>";
-
-}
-
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
-                       }
-                        $i=0;
-                       while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
-                                $i++;
-                                echo "<div id='card".$i."' 
class='singlecard'>";
-                               foreach($row as $field => $value) {
-                                       if($field == "artist") {
-                                               echo "<div 
class='".stripslashes($field)."'><a href='/blocks.php?a=".
-                                                   
htmlspecialchars(stripslashes($value), ENT_QUOTES)."'>"  .stripslashes($value) 
. "</a></div>";
-                                       }
-                                       else if($field == "track") {
-                                               echo "<div 
class='".stripslashes($field)."'><a href='/blocks.php?t=".
-                                                   
htmlspecialchars(stripslashes($value), ENT_QUOTES)."'>"  .stripslashes($value) 
. "</a></div>";
-                                       }
-                                       else if($field == "time") {
-                                               $value = strftime("%c", $value);
-                                               echo "<div 
class='".stripslashes($field)."'>". stripslashes($value) . "</div>";
-                                       }
-                                       else if($field == "username") {
-                                           echo "<div 
class='".stripslashes($field)."'><a href='/blocks.php?u=" . 
stripslashes($value) . "'>" . stripslashes($value) . "</a></div>";
-                                        }
-                                }
-                               echo "</div>";
-                       }
-
-               ?>
-</div>
-<div id="nowplaying">
-               <h2>Now Playing?</h2>
-
-<div id="nowtracks">
-               <?php
-                        if(empty($req_user)) {
-                               $res = $mdb2->query("SELECT username, artist, 
track, ClientCodes.name from Now_Playing LEFT OUTER JOIN Scrobble_Sessions ON 
Now_Playing.sessionid=Scrobble_Sessions.sessionid LEFT OUTER JOIN ClientCodes 
ON Scrobble_Sessions.client=ClientCodes.code ORDER BY Now_Playing.expires DESC 
LIMIT 10");
-                        } else {
-                               $res = $mdb2->query("SELECT username, artist, 
track, ClientCodes.name from Now_Playing LEFT OUTER JOIN Scrobble_Sessions ON 
Now_Playing.sessionid=Scrobble_Sessions.sessionid LEFT OUTER JOIN ClientCodes 
ON Scrobble_Sessions.client=ClientCodes.code WHERE username = '" . 
stripslashes($req_user) . "' ORDER BY Now_Playing.expires DESC LIMIT 10");
-                        }
-
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
-                       }
-                       while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
-                               echo "<p>" . stripslashes($row["username"]) . " 
is listening to " . stripslashes($row["track"]) . " by " . 
stripslashes($row["artist"]) . "</p>";
-                       }
-               ?>
-</div>
-</div>
-<div id="statistics">
-               <h2>Statistics</h2>
-               <?php
-                       $res = $mdb2->query("SELECT COUNT(*) as total from 
Scrobbles");
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
-                       }
-                       $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
-                       echo "<p>" . stripslashes($row["total"]) . " 
gobbles</p>";
-
-                       $res = $mdb2->query("SELECT COUNT(*) as total from 
Track");
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
-                       }
-                       $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
-                       echo "<p>" . stripslashes($row["total"]) . " 
tracks</p>";
-
-                       $res = $mdb2->query("SELECT COUNT(*) as total from 
Users");
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
-                       }
-                       $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
-                       echo "<p>" . stripslashes($row["total"]) . " users</p>";
-
-               ?>
-</div>
- <p>
-    <a href="http://validator.w3.org/check?uri=referer";><img
-        src="http://www.w3.org/Icons/valid-html401";
-        alt="Valid HTML 4.01 Strict" height="31" width="88"></a>
-  </p>
-
-
-</div>
-</div>
-       </div>
-
-       </div>
-   <div id="ft" style="contentinfo">
-
-<p>This site handles <em>gobble</em> and <em>now playing</em>
-submissions from client applications and offers access to our web
-services API. If you just want to use <a
-href="http://libre.fm";>libre.fm</a> then you probably want to
-visit the <a href="http://libre.fm";>main site</a>, but if you're
-a developer then here are some useful stats to help you see
-what's happening.</p>
-
-<p><a 
href="http://svn.savannah.gnu.org/viewvc/trunk/gobbler/?root=librefm";>http://svn.savannah.gnu.org/viewvc/trunk/gobbler/?root=librefm</a></p></div>
-</div>
-</body>
-</html>
-

Modified: branches/stable/gnukebox/database.php
===================================================================
--- branches/stable/gnukebox/database.php       2009-05-13 21:10:01 UTC (rev 
1537)
+++ branches/stable/gnukebox/database.php       2009-05-13 21:12:08 UTC (rev 
1538)
@@ -20,29 +20,19 @@
 */
 
 
-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');
-require_once('MDB2.php');
+require_once('adodb/adodb-exceptions.inc.php');
+require_once('adodb/adodb.inc.php');
 
-$mdb2 =& MDB2::connect($connect_string);
-if (PEAR::isError($mdb2)) {
-       die($mdb2->getMessage());
+try {
+       $adodb =& NewADOConnection($adodb_connect_string);
+} catch (exception $e) {
+       var_dump($e);
+       adodb_backtrace($e->gettrace());
 }
 
-function reportError($text, $data) {
-    // make a fresh connection
-    global $connect_string;
-    $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() . ")");
-}
 ?>

Modified: branches/stable/gnukebox/display.php
===================================================================
--- branches/stable/gnukebox/display.php        2009-05-13 21:10:01 UTC (rev 
1537)
+++ branches/stable/gnukebox/display.php        2009-05-13 21:12:08 UTC (rev 
1538)
@@ -60,32 +60,37 @@
                $req_artist     = urldecode($_GET["a"]);
                $req_track      = urldecode($_GET["t"]);
 
+               $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
 
+               try {
 if ($req_user) {
-//                     echo "SELECT username, artist, track, time FROM 
Scrobbles WHERE username = '" . $mdb2->quote($req_user, 'text') . "' ORDER BY 
time DESC LIMIT 100";
-                       $res = $mdb2->query("SELECT username, artist, track, 
time FROM Scrobbles WHERE username = " . $mdb2->quote($req_user, 'text') . " 
ORDER BY time DESC LIMIT 100");
+//                     echo "SELECT username, artist, track, time FROM 
Scrobbles WHERE username = '" . $adodb->qstr($req_user) . "' ORDER BY time DESC 
LIMIT 100";
+                       $res = $adodb->CacheGetAll(60, "SELECT username, 
artist, track, time FROM Scrobbles WHERE username = " . $adodb->qstr($req_user) 
. " ORDER BY time DESC LIMIT 100");
 
                        echo "<h2>" . $req_user . "'s most recent listening 
data</h2>";
 
 } elseif ($req_artist) {
 
-                       $res = $mdb2->query("SELECT username, artist, track, 
time FROM Scrobbles WHERE artist = '" . $mdb2->quote($req_artist, 'text') ."' 
ORDER BY time DESC LIMIT 100");
+                       $res = $adodb->CacheGetAll(60, "SELECT username, 
artist, track, time FROM Scrobbles WHERE artist = '" . 
$adodb->qstr($req_artist) ."' ORDER BY time DESC LIMIT 100");
 
                        echo "<h2>Last 100 Tracks by " . $req_artist . "</h2>";
 
 } elseif ($req_track) {
 
-                       $res = $mdb2->query("SELECT username, artist, track, 
time FROM Scrobbles WHERE track = '" . $mdb2->quote($req_track, 'text') . "' 
ORDER BY time DESC LIMIT 100");
+                       $res = $adodb->CacheGetAll(60, "SELECT username, 
artist, track, time FROM Scrobbles WHERE track = '" . $adodb->qstr($req_track) 
. "' ORDER BY time DESC LIMIT 100");
 
                        echo "<h2>Last 100 plays of " . $req_track . "</h2>";
 
 } elseif (!$res) {
+                       $res = $adodb->CacheGetAll(60, "SELECT username, 
artist, track, time FROM Scrobbles ORDER BY time DESC LIMIT 10");
 
-                       $res = $mdb2->query("SELECT username, artist, track, 
time FROM Scrobbles ORDER BY time DESC LIMIT 10");
-
                        echo "<h2>Last 10 tracks received</h2>";
-
+               }
 }
+                       catch (exception $e)
+                       {
+                               die($e->getMessage());
+                       }
 
 ?>
 
@@ -94,11 +99,8 @@
 
 <?php
 
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
-                       }
                        $i = 0;
-                       while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+                       foreach($res as &$row){
                        $i++;
                                echo ($i % 2 == 0) ? "<tr class=\"even\">" : 
"<tr class=\"odd\">";
                                foreach($row as $field => $value) {
@@ -122,37 +124,36 @@
                <h2>Statistics</h2>
 
                <?php
-                       $res = $mdb2->query("SELECT COUNT(*) as total from 
Scrobbles");
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
+                       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+                       $total = $adodb->CacheGetOne(60, 'SELECT COUNT(*) as 
total from Scrobbles');
+                       if(!$res) {
+                               die("sql error");
                        }
-                       $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
-                       echo "<p>" . stripslashes($row["total"]) . " 
gobbles.</p>";
+                       echo "<p>" . stripslashes($total) . " gobbles.</p>";
 
-                       $res = $mdb2->query("SELECT COUNT(*) as total from 
Track");
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
+                       $total = $adodb->CacheGetOne(120, 'SELECT COUNT(*) as 
total from Track');
+                       if(!$res) {
+                               die("sql error");
                        }
-                       $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
-                       echo "<p>" . stripslashes($row["total"]) . " 
tracks.</p>";
+                       echo "<p>" . stripslashes($total) . " tracks.</p>";
 
-                       $res = $mdb2->query("SELECT COUNT(*) as total from 
Users");
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
+                       $total = $adodb->CacheGetOne(720, 'SELECT COUNT(*) as 
total from Users');
+                       if(!$res) {
+                               die("sql error");
                        }
-                       $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
-                       echo "<p>" . stripslashes($row["total"]) . " 
users.</p>";
+                       echo "<p>" . stripslashes($total) . " users.</p>";
 
                ?>
 
                <h2>Now Playing?</h2>
 
                <?php
-                       $res = $mdb2->query("SELECT username, artist, track, 
client, ClientCodes.name, ClientCodes.url from Now_Playing LEFT OUTER JOIN 
Scrobble_Sessions ON Now_Playing.sessionid=Scrobble_Sessions.sessionid LEFT 
OUTER JOIN ClientCodes ON Scrobble_Sessions.client=ClientCodes.code ORDER BY 
Now_Playing.expires DESC LIMIT 10");
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
+                       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+                       $res = $adodb->GetAll('SELECT username, artist, track, 
client, ClientCodes.name, ClientCodes.url from Now_Playing LEFT OUTER JOIN 
Scrobble_Sessions ON Now_Playing.sessionid=Scrobble_Sessions.sessionid LEFT 
OUTER JOIN ClientCodes ON Scrobble_Sessions.client=ClientCodes.code ORDER BY 
Now_Playing.expires DESC LIMIT 10');
+                       if(!$res) {
+                               die("sql error");
                        }
-                       while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+                       foreach($res as &$row){
                                if($row["name"] == "") {
                                  $client = 
strip_tags(stripslashes($row["client"])) . "(unknown, please tell us what this 
is)";
                                } else {
@@ -178,7 +179,7 @@
 </div>
 <div class="yui-g">
     <div class="yui-u first" id="links">
-This site handles <em>gobble</em> and <em>now playing</em>
+This site handles <em>track</em> and <em>now playing</em>
 submissions from client applications and offers access to our web
 services API. If you just want to use <a
 href="http://libre.fm";>libre.fm</a> then you probably want to

Modified: branches/stable/gnukebox/fix-album-art.php
===================================================================
--- branches/stable/gnukebox/fix-album-art.php  2009-05-13 21:10:01 UTC (rev 
1537)
+++ branches/stable/gnukebox/fix-album-art.php  2009-05-13 21:12:08 UTC (rev 
1538)
@@ -26,27 +26,25 @@
 header('Content-type: text/html; charset=utf-8');
 require_once('database.php');
 
-  $res = $mdb2->query("SELECT name, artist_name, image, artwork_license FROM 
Album WHERE artwork_license IS NULL LIMIT 5000");
+       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+       try {
+       $res = $adodb->GetAll("SELECT name, artist_name, image, artwork_license 
FROM Album WHERE artwork_license IS NULL LIMIT 5000");
+       }
+       catch (exception $e) {
+               die($e->getMessage());
+       }
+               foreach($res as &$row) {
+               echo "<img width=50 src=" . 
go_get_album_art($row['artist_name'], $row['name']) ." />&nbsp;";
 
-                       if(PEAR::isError($res)) {
-                               die($res->getMessage());
-                       }
-                       while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
-                       echo "<img width=50 src=" . 
go_get_album_art($row['artist_name'], $row['name']) ." />&nbsp;";
+               sleep (3);
+               for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
 
+               ob_implicit_flush(1)  ;
+               }
+               echo "</ol>";
 
-                           sleep (3);
-                          for ($i = 0; $i < ob_get_level(); $i++) { 
ob_end_flush(); }
-    ob_implicit_flush(1)  ;
-
-
-                       
-
-                       }
-                        echo "</ol>";
-
        function go_get_album_art($artist, $album){
-               global $mdb2;
+               global $adodb;
 
   $Access_Key_ID = "1EST86JB355JBS3DFE82"; // this is mattl's personal key :)
 
@@ -71,16 +69,16 @@
 $image = $aws_xml->Items->Item->MediumImage->URL;
        
        if (!$image) { $image = "/i/qm50.png"; $license="librefm";}
-       
+
        if ($image) {
 
         
           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 = " 
 
@@ -91,12 +89,12 @@
                        . ($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($e->getMessage() . ", FAILED query was :" . $sql);
+               }
 
        return $image;
        }

Modified: branches/stable/gnukebox/install.php
===================================================================
--- branches/stable/gnukebox/install.php        2009-05-13 21:10:01 UTC (rev 
1537)
+++ branches/stable/gnukebox/install.php        2009-05-13 21:12:08 UTC (rev 
1538)
@@ -307,7 +307,7 @@
 // uncomment these if you're using postgresql and want to run the software as 
www-data
 //     $adodb->Execute("GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE Album, 
Artist, Auth, Clientcodes, Delete_Request Error, Invitation_Request, 
Invitations, Now_Playing, Places, Radio_Sessions, Scrobble_Sessions, Scrobbles, 
Scrobble_Track, Similar_Artist, Tags, Track, Users, User_Relationships, 
User_Relationship_Flags to \"www-data\"");
 //     $adodb->Execute("GRANT SELECT ON Free_Scrobbles, Relationship_Flags to 
\"www-data\"");
-//     $adodb->Execute("GRANT SELECT, UPDATE ON users_uniqueid_seq, 
scrobble_track_id_seq, groups_id_seq to \"www-data\"");
+//     $adodb->Execute("GRANT SELECT, UPDATE ON users_uniqueid_seq, 
scrobble_track_id_seq, groups_id_seq, artist_id_seq, album_id_seq to 
\"www-data\"");
 
        // Test user configuration
        $adodb->Execute("INSERT INTO Users

Added: branches/stable/gnukebox/musicbrainz.php
===================================================================
--- branches/stable/gnukebox/musicbrainz.php                            (rev 0)
+++ branches/stable/gnukebox/musicbrainz.php    2009-05-13 21:12:08 UTC (rev 
1538)
@@ -0,0 +1,99 @@
+<?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/>.
+
+*/
+
+    @apache_setenv('no-gzip', 1);
+    @ini_set('zlib.output_compression', 0);
+    @ini_set('implicit_flush', 1);
+
+
+header('Content-type: text/html; charset=utf-8');
+require_once('database.php');
+require_once('utils/human-time.php');
+
+$adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+$res = $adodb->GetAll("SELECT artist, track from scrobbles where Album is null 
LIMIT 20;");
+
+     echo "<ul>";
+
+                       if(!$res) {
+                               die("sql error");
+                       }
+                       foreach($res as &$row) {
+
+                       echo "<li>" . $row['artist'] . "&mdash;" . 
$row['track'] . "</li>";
+
+                       echo "Finding album...";
+
+                       echo doABunchOfShit($row['artist'], $row['track']);
+
+                          for ($i = 0; $i < ob_get_level(); $i++) { 
ob_end_flush(); }
+    ob_implicit_flush(1)  ;
+
+                       }
+
+
+function doABunchOfShit($artist, $track){
+
+        $album = ScrobbleLookup($artist, $track);
+
+        if ($album){
+
+        return $album;
+
+        } else {
+
+        $album = BrainzLookup ($artist, $track);
+
+        return $album;}
+
+}
+
+function ScrobbleLookup($artist, $track){
+       global $adodb;
+
+       $sql = "SELECT album from scrobbles where artist = " . 
$adodb->qstr($artist) . " and track = " . $adodb->qstr($track) . " LIMIT 1;";
+
+       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+       $album = $adodb->GetOne($sql);
+
+       if(!$album) {
+               die("sql error");
+       }
+
+       return $album;
+}
+
+function BrainzLookup($artist, $track){
+
+       global $adodb;
+
+       $sql = "select a.name as artist,l.name as album, t.name as track,t.gid 
as mbid from brainz.track t left join brainz.artist a on t.artist=a.id left 
join brainz.albumjoin j on j.track=t.id left join brainz.album l on 
l.id=j.album  where lower(t.name)=" . $adodb->qstr(mb_strtolower($track, 
"UTF-8")) . " and lower(a.name)=" . $adodb->qstr(mb_strtolower($artist, 
"UTF-8")) . " LIMIT 1;";
+
+       $adodb->SetFetchMode(ADODB_FETCH_ASSOC);
+       $albumData = $adodb->GetRow($sql);
+
+       if(!$albumData)) {
+               die("sql error");
+       }
+
+       return $albumData['album'];
+}
+?>
+               </ul>

Modified: branches/stable/gnukebox/nowplaying/1.2/index.php
===================================================================
--- branches/stable/gnukebox/nowplaying/1.2/index.php   2009-05-13 21:10:01 UTC 
(rev 1537)
+++ branches/stable/gnukebox/nowplaying/1.2/index.php   2009-05-13 21:12:08 UTC 
(rev 1538)
@@ -30,16 +30,15 @@
 
 $session_id = $_POST['s'];
 
-$username = $mdb2->quote(usernameFromSID($session_id), "text");
-$MQsess = $mdb2->quote($session_id, "text");
+$MQsess = $adodb->qstr($session_id);
 
-$artist = $mdb2->quote($_POST['a'], "text");
+$artist = $adodb->qstr($_POST['a']);
 if(isset($_POST['b'])) {
-       $album = $mdb2->quote($_POST['b'], "text");
+       $album = $adodb->qstr($_POST['b']);
 } else {
        $album = 'NULL';
 }
-$track = $mdb2->quote($_POST['t'], "text");
+$track = $adodb->qstr($_POST['t']);
 if(isset($_POST['l']) && is_numeric($_POST['l'])) {
        $expires = time() + (int) $_POST['l'];
 } else {
@@ -49,7 +48,7 @@
 $mb = validateMBID($_POST['m']);
 
 if($mb) {
-       $mbid = $mdb2->quote($mb, "text");
+       $mbid = $adodb->qstr($mb);
 } else {
        $mbid = 'NULL';
 }
@@ -61,20 +60,24 @@
 getTrackCreateIfNew($artist, $album, $track, $mbid);
 
 //Expire old tracks
-$mdb2->exec("DELETE FROM Now_Playing WHERE expires < " . time());
+$adodb->Execute("DELETE FROM Now_Playing WHERE expires < " . time());
 
 //Delete this user's last playing song (if any)
-$mdb2->exec("DELETE FROM Now_Playing WHERE sessionid = " . ($MQsess));
+$adodb->Execute("DELETE FROM Now_Playing WHERE sessionid = " . ($MQsess));
 
-$mdb2->exec("INSERT INTO Now_Playing (sessionid, artist, album, track, 
expires, mbid) VALUES ("
-       . $MQsess . ", "
-       . $artist . ", "
-       . $album . ", "
-       . $track . ", "
-       . $expires . ", "
-       . $mbid . ")");
+try {
+       $adodb->Execute("INSERT INTO Now_Playing (sessionid, artist, album, 
track, expires, mbid) VALUES ("
+                       . $MQsess . ", "
+                       . $artist . ", "
+                       . $album . ", "
+                       . $track . ", "
+                       . $expires . ", "
+                       . $mbid . ")");
+}
+catch (exception $e) {
+       die("FAILED " . $e->getMessage() . "\n");
+}
 
-
 die("OK\n");
 
 ?>

Modified: branches/stable/gnukebox/scrobble-utils.php
===================================================================
--- branches/stable/gnukebox/scrobble-utils.php 2009-05-13 21:10:01 UTC (rev 
1537)
+++ branches/stable/gnukebox/scrobble-utils.php 2009-05-13 21:12:08 UTC (rev 
1538)
@@ -26,148 +26,166 @@
 
 //derive the username from a session ID
 
-       global $mdb2;          // include the Database connector
+       global $adodb;         // include the Database connector
 
        // Delete any expired session ids
-       $mdb2->query("DELETE FROM Scrobble_Sessions WHERE expires < " . time());
+       $adodb->Execute('DELETE FROM Scrobble_Sessions WHERE expires < ' . 
time());
 
-       $res = $mdb2->query("SELECT username FROM Scrobble_Sessions WHERE 
sessionid = " . $mdb2->quote($session_id, "text")); // get the username from 
the table
-
-       if(PEAR::isError($res)) {   
-               die("FAILED ufs " . $res->getMessage() . "\n");
+       try {
+               $res = $adodb->GetOne('SELECT username FROM Scrobble_Sessions 
WHERE sessionid = ' . $adodb->qstr($session_id)); // get the username from the 
table
+       }
+       catch (exception $e) {
+               die('FAILED ufs ' . $e->getMessage() . '\n');
                // die is there is an error, printing the error
        }
 
-       if(!$res->numRows()) {
-               die("BADSESSION\n");
+       if(!$res) {
+               die('BADSESSION\n');
 
                // the user has no session
        }
 
-       return $res->fetchOne(0);
+       return $res;
 
               // return the first user
 }
 
 function createArtistIfNew($artist) {
-       global $mdb2;
+       global $adodb;
 
        $artist = NoSpamTracks($artist);
 
-       $res = $mdb2->query("SELECT name FROM Artist WHERE name = " . 
($artist));
-       if(PEAR::isError($res)) {
-               die("FAILED art " . $res->getMessage() . "\n");
+       try {
+               $res = $adodb->GetOne('SELECT name FROM Artist WHERE 
lower(name) = lower(' . ($artist) . ')');
        }
+       catch (exception $e) {
+               die('FAILED art ' . $e->getMessage() . '\n');
+       }
 
-       if(!$res->numRows()) {
+       if(!$res) {
                // Artist doesn't exist, so we create them
-               $res = $mdb2->query("INSERT INTO Artist (name) VALUES (" . 
($artist) . ")");
-               if(PEAR::isError($res)) {
-                       die("FAILED artc " . $res->getMessage() . "\n");
+               try {
+                       $res = $adodb->Execute('INSERT INTO Artist (name) 
VALUES (' . ($artist) . ')');
                }
+               catch (exception $e) {
+                       die('FAILED artc ' . $e->getMessage() . '\n');
+               }
        }
 }
 
 function createAlbumIfNew($artist, $album) {
-       global $mdb2;
+       global $adodb;
 
-       $res = $mdb2->query("SELECT name FROM Album WHERE name = " . ($album) . 
" AND artist_name = " . ($artist));
-       if(PEAR::isError($res)) {
-               die("FAILED alb " . $res->getMessage() . "\n");
+       try {
+               $name = $adodb->GetOne('SELECT name FROM Album WHERE 
lower(name) = lower(' . ($album) . ') AND lower(artist_name) = lower(' . 
($artist) . ')');
        }
+       catch (exception $e) {
+               die('FAILED alb ' . $e->getMessage() . '\n');
+       }
 
-       if(!$res->numRows()) {
+       if(!$name) {
                // Album doesn't exist, so create it
-               
-         $art = $mdb2->quote(getAlbumArt($artist, $album));
-         if ($art !="") {
-           $license = $mdb2->quote("amazon");
 
-           $res = $mdb2->query("INSERT INTO Album (name, artist_name, image, 
artwork_license) VALUES (" . ($album) . ", " . ($artist) . ", " . ($art) . ", " 
. ($license) .")");
+               $art = $adodb->qstr(getAlbumArt($artist, $album));
 
-         } else {
+               if ($art !="") {
+                       $license = $adodb->qstr('amazon');
 
-               $res = $mdb2->query("INSERT INTO Album (name, artist_name) 
VALUES (" . ($album) . ", " . ($artist) . ")");
+                       $sql = 'INSERT INTO Album (name, artist_name, image, 
artwork_license) VALUES (' . ($album) . ', ' . ($artist) . ', ' . ($art) . ', ' 
. ($license) .')';
 
-         }
-
-               if(PEAR::isError($res)) {
-                       die("FAILED albc " . $res->getMessage() . "\n");
+               } else {
+                       $sql = 'INSERT INTO Album (name, artist_name) VALUES (' 
. ($album) . ', ' . ($artist) . ')';
                }
+               try {
+                       $adodb->Execute($sql);
+               }
+               catch (exception $e) {
+                       die('FAILED albc ' . $e->getMessage() . '\n');
+               }
        }
 }
 
 function getTrackCreateIfNew($artist, $album, $track, $mbid) {
-       global $mdb2;
+       global $adodb;
 
        $track = NoSpamTracks($track);
        $artist = NoSpamTracks($artist);
 
+       try {
        if($album != 'NULL') {
-       $res = $mdb2->query("SELECT id FROM Track WHERE lower(name) = lower(" . 
($track) . ") AND lower(artist_name) = lower(" . ($artist) . ") AND 
lower(album_name) = lower(" . ($album) . ")");
+       $res = $adodb->GetOne('SELECT id FROM Track WHERE lower(name) = lower(' 
. ($track) . ') AND lower(artist_name) = lower(' . ($artist) . ') AND 
lower(album_name) = lower(' . ($album) . ')');
        } else {
-       $res = $mdb2->query("SELECT id FROM Track WHERE lower(name) = lower(" . 
($track) . ") AND lower(artist_name) = lower(" . ($artist) . ") AND album_name 
IS NULL");
+       $res = $adodb->GetOne('SELECT id FROM Track WHERE lower(name) = lower(' 
. ($track) . ') AND lower(artist_name) = lower(' . ($artist) . ') AND 
album_name IS NULL');
        }
-       if(PEAR::isError($res)) {
-               die("FAILED trk " . $res->getMessage() . "\n");
        }
+       catch (exception $e) {
+               die('FAILED trk ' . $e->getMessage() . '\n');
+       }
 
-       if(!$res->numRows()) {
+       if(!$res) {
                // Create new track
-               $res = $mdb2->exec("INSERT INTO Track (name, artist_name, 
album_name, mbid) VALUES ("
-                       . ($track) . ", "
-                       . ($artist) . ", "
-                       . ($album) . ", "
-                       . ($mbid) . ")");
-               if(PEAR::isError($res)) {
-                       die("FAILED trkc " . $res->getMessage() . "\n");
+               try {
+               $res = $adodb->Execute('INSERT INTO Track (name, artist_name, 
album_name, mbid) VALUES ('
+                       . ($track) . ', '
+                       . ($artist) . ', '
+                       . ($album) . ', '
+                       . ($mbid) . ')');
                }
+               catch (exception $e) {
+                       die('FAILED trkc ' . $e->getMessage() . '\n');
+               }
                return getTrackCreateIfNew($artist, $album, $track, $mbid);
        } else {
-               return $res->fetchOne(0);
+               return $res;
        }
 }
 
 function getScrobbleTrackCreateIfNew($artist, $album, $track, $mbid, $tid) {
-       global $mdb2;
+       global $adodb;
 
-       $res = $mdb2->query("SELECT id FROM Scrobble_Track WHERE name = lower("
-               . ($track) . ") AND artist = lower(" . ($artist) . ") AND album 
"
-               . (($album == 'NULL') ? "IS NULL" : ("= lower(" . ($album) . 
")")) . " AND mbid "
-               . (($mbid == 'NULL') ? "IS NULL" : ("= lower(" . ($mbid) . 
")")));
-       if(PEAR::isError($res)) {
-               die("FAILED st " . $res->getMessage() . "\n");
+       try {
+       $res = $adodb->GetOne('SELECT id FROM Scrobble_Track WHERE name = 
lower('
+               . ($track) . ') AND artist = lower(' . ($artist) . ') AND album 
'
+               . (($album == 'NULL') ? 'IS NULL' : ('= lower(' . ($album) . 
')')) . ' AND mbid '
+               . (($mbid == 'NULL') ? 'IS NULL' : ('= lower(' . ($mbid) . 
')')));
        }
+       catch (exception $e) {
+               die('FAILED st ' . $e->getMessage() . '\n');
+       }
 
-       if(!$res->numRows()) {
-               $sql = "INSERT INTO Scrobble_Track (name, artist, album, mbid, 
track) VALUES ("
-                       . "lower(" . ($track) . "), "
-                       . "lower(" . ($artist) . "), "
-                       . (($album == 'NULL') ? "NULL" : "lower(" . ($album) . 
")") . ", "
-                       . (($mbid == 'NULL') ? "NULL" : "lower(" . ($mbid) . 
")") . ", "
-                       . ($tid) . ")";
-               $res = $mdb2->exec($sql);
-               if(PEAR::isError($res)) {
-                       $msg = $res->getMessage() . " - " . $res->getUserInfo();
+       if(!$res) {
+               $sql = 'INSERT INTO Scrobble_Track (name, artist, album, mbid, 
track) VALUES ('
+                       . 'lower(' . ($track) . '), '
+                       . 'lower(' . ($artist) . '), '
+                       . (($album == 'NULL') ? 'NULL' : 'lower(' . ($album) . 
')') . ', '
+                       . (($mbid == 'NULL') ? 'NULL' : 'lower(' . ($mbid) . 
')') . ', '
+                       . ($tid) . ')';
+               try {
+                       $res = $adodb->Execute($sql);
+               }
+               catch (exception $e) {
+                       $msg = $e->getMessage() . ' - ' . $e->getUserInfo();
                        reportError($msg, $sql);
 
-                       die("FAILED stc " . $res->getMessage() . "\n");
+                       die('FAILED stc ' . $res->getMessage() . '\n');
                }
                return getScrobbleTrackCreateIfNew($artist, $album, $track, 
$mbid, $tid);
        } else {
-               return $res->fetchOne(0);
+               return $res;
        }
 }
 
 function scrobbleExists($username, $artist, $track, $time) {
-       global $mdb2;
+       global $adodb;
 
-       $res = $mdb2->query("SELECT time FROM Scrobbles WHERE username = " . 
($username) . " AND artist = " . ($artist) . " AND track = " . ($track) . " AND 
time = " . ($time));
-       if(PEAR::isError($res)) {
-               die("FAILED se " . $res->getMessage() . "\n");
+       try {
+       $res = $adodb->GetOne('SELECT time FROM Scrobbles WHERE username = ' . 
($username) . ' AND artist = ' . ($artist) . ' AND track = ' . ($track) . ' AND 
time = ' . ($time));
        }
+       catch (exception $e) {
+               die('FAILED se ' . $e->getMessage() . '\n');
+       }
 
-       if(!$res->numRows()) {
+       if(!$res) {
                return false;
        } else {
                return true;
@@ -177,7 +195,7 @@
 
   // This function exists to remove things like '(PREVIEW: buy it at 
www.magnatune.com)' from track names.
 
-  $track = str_replace(" (PREVIEW: buy it at www.magnatune.com)", "", $track);
+  $track = str_replace(' (PREVIEW: buy it at www.magnatune.com)', "", $track);
 
   return $track;
   
@@ -185,25 +203,25 @@
 
 function getAlbumArt($artist, $album) {
 
-  $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\n");
+$aws_xml = simplexml_load_file($request) or die('xml response not loading\n');
 
 $image = $aws_xml->Items->Item->MediumImage->URL;
         $URI = $aws_xml->Items->Item->DetailPageURL;

Modified: branches/stable/gnukebox/submissions/1.1/handshake.php
===================================================================
--- branches/stable/gnukebox/submissions/1.1/handshake.php      2009-05-13 
21:10:01 UTC (rev 1537)
+++ branches/stable/gnukebox/submissions/1.1/handshake.php      2009-05-13 
21:12:08 UTC (rev 1538)
@@ -42,24 +42,27 @@
 
 $timestamp = time();
 
-$res = $mdb2->query("SELECT password FROM Users WHERE username = ". 
$mdb2->quote($username, "text"));
-if(PEAR::isError($res)) {
-       die("FAILED " . $res->getMessage() . "\n");
+try {
+       $res = $adodb->GetOne("SELECT password FROM Users WHERE username = ". 
$adodb->qstr($username));
 }
+catch (exception $e) {
+       die("FAILED " . $e->getMessage() . "\n");
+}
 if(!$res->numRows()) {
        die("BADUSER\n");
 }
-$password = $res->fetchOne(0);
+$password = $res;
 $session_id = md5($password . $timestamp);
-$res = $mdb2->exec("INSERT INTO Scrobble_Sessions(username, sessionid, client, 
expires) VALUES ("
-       . $mdb2->quote($username, "text") . ","
-       . $mdb2->quote($session_id, "text") . ","
-       . $mdb2->quote($client, "text") . ","
-       . $mdb2->quote(time() + 86400) . ")");
-
-if(PEAR::isError($res)) {
-        die("FAILED " . $res->getMessage() . "\n");
+try {
+$res = $adodb->Execute("INSERT INTO Scrobble_Sessions(username, sessionid, 
client, expires) VALUES ("
+       . $adodb->qstr($username, "text") . ","
+       . $adodb->qstr($session_id, "text") . ","
+       . $adodb->qstr($client, "text") . ","
+       . $adodb->qstr(time() + 86400) . ")");
 }
+catch (exception $e) {
+        die("FAILED " . $e->getMessage() . "\n");
+}
 
 echo "UPTODATE\n";
 echo $timestamp . "\n";

Modified: branches/stable/gnukebox/submissions/1.2/handshake.php
===================================================================
--- branches/stable/gnukebox/submissions/1.2/handshake.php      2009-05-13 
21:10:01 UTC (rev 1537)
+++ branches/stable/gnukebox/submissions/1.2/handshake.php      2009-05-13 
21:12:08 UTC (rev 1538)
@@ -56,15 +56,16 @@
 
 $session_id = md5($auth_token . time());
 $sql = "INSERT INTO Scrobble_Sessions(username, sessionid, client, expires) 
VALUES ("
-       . $mdb2->quote($username, "text") . ","
-       . $mdb2->quote($session_id, "text") . ","
-       . $mdb2->quote($client, "text") . ","
-       . $mdb2->quote(time() + 86400) . ")";
+       . $adodb->qstr($username) . ","
+       . $adodb->qstr($session_id) . ","
+       . $adodb->qstr($client) . ","
+       . (time() + 86400) . ")";
 
-$res = $mdb2->exec($sql);
-
-if(PEAR::isError($res)) {
-       $msg = $res->getMessage();
+try {
+$res = $adodb->Execute($sql);
+}
+catch (exception $e) {
+       $msg = $e->getMessage();
        reportError($msg, $sql);
        die("FAILED " . $msg . "\n");
 }

Modified: branches/stable/gnukebox/submissions/1.2/index.php
===================================================================
--- branches/stable/gnukebox/submissions/1.2/index.php  2009-05-13 21:10:01 UTC 
(rev 1537)
+++ branches/stable/gnukebox/submissions/1.2/index.php  2009-05-13 21:12:08 UTC 
(rev 1538)
@@ -22,10 +22,10 @@
 require_once('../../scrobble-utils.php');
 
 if(!isset($_POST['s']) || !isset($_POST['a']) || !isset($_POST['t']) || 
!isset($_POST['i'])) {
-       die("Failed Required POST parameters are not set\n");
+       die("FAILED Required POST parameters are not set\n");
 }
 if(empty($_POST['s']) || empty($_POST['a']) || empty($_POST['t']) || 
empty($_POST['i'])) {
-       die("Failed Required POST parameters are empty\n");
+       die("FAILED Required POST parameters are empty\n");
 }
 
 if(!is_array($_POST['a']) || !is_array($_POST['t']) || !is_array($_POST['i'])) 
{
@@ -34,7 +34,7 @@
 
 $session_id = $_POST['s'];
 
-$username = $mdb2->quote(usernameFromSID($session_id), "text");
+$username = $adodb->qstr(usernameFromSID($session_id));
 $rowvalues = array();
 $actualcount = 0;
 
@@ -42,16 +42,16 @@
                switch (mb_detect_encoding($_POST['a'][$i])) {
                case "ASCII":
                case "UTF-8":
-                       $artist = $mdb2->quote($_POST['a'][$i], "text");
+                       $artist = $adodb->qstr($_POST['a'][$i]);
                        break;
                default:
                        die("FAILED Bad encoding in artist submission $i\n");
                }
-       if(isset($_POST['b'][$i]) && !empty($_POST['b'])) {
+       if(isset($_POST['b'][$i]) && !empty($_POST['b'][$i])) {
                switch (mb_detect_encoding($_POST['b'][$i])) {
                case "ASCII":
                case "UTF-8":
-                       $album = $mdb2->quote($_POST['b'][$i], "text");
+                       $album = $adodb->qstr($_POST['b'][$i]);
                        break;
                default:
                        die("FAILED Bad encoding in album submission $i\n");
@@ -71,7 +71,7 @@
        switch (mb_detect_encoding($_POST['t'][$i])) {
                case "ASCII":
                case "UTF-8":
-                   $track = $mdb2->quote($_POST['t'][$i], "text");
+                   $track = $adodb->qstr($_POST['t'][$i]);
                    break;
                default:
                        die("FAILED Bad encoding in title submission $i\n");
@@ -87,23 +87,23 @@
        $mb = validateMBID($_POST['m'][$i]);
 
        if($mb) {
-               $mbid = $mdb2->quote($mb, "text");
+               $mbid = $adodb->qstr($mb);
        } else {
                $mbid = 'NULL';
        }
 
        if(isset($_POST['o'][$i])) {
-               $source = $mdb2->quote($_POST['o'][$i], "text");
+               $source = $adodb->qstr($_POST['o'][$i]);
        } else {
                $source = 'NULL';
        }
        if(!empty($_POST['r'][$i])) {
-               $rating = $mdb2->quote($_POST['r'][$i], "text");
+               $rating = $adodb->qstr($_POST['r'][$i]);
        } else {
-               $rating = $mdb2->quote("0", "text"); // use the fake rating 
code 0 for now
+               $rating = $adodb->qstr("0"); // use the fake rating code 0 for 
now
        }
        if(isset($_POST['l'][$i])) {
-               $length = $mdb2->quote($_POST['l'][$i], "integer");
+               $length = (int)($_POST['l'][$i]);
        } else {
                $length = 'NULL';
        }
@@ -140,34 +140,36 @@
 
        if(($i+1) == count($_POST['a']) && $actualcount>0) {
 
-               $mdb2->exec("BEGIN");
+               $adodb->StartTrans();
 
                for($j = 0; $j < $actualcount; $j++) {
 
        // Scrobble!
                $sql = "INSERT INTO Scrobbles (username, artist, album, track, 
time, mbid, source, rating, length, stid) VALUES " . $rowvalues[$j];
-               $res =& $mdb2->exec($sql);
-               if(PEAR::isError($res)) {
-                   $msg = $res->getMessage() . " - " . $res->getUserInfo();
-                   $mdb2->exec("ROLLBACK");
+               try {
+               $res =& $adodb->Execute($sql);
+               }
+               catch (exception $e) {
+                   $msg = $e->getMessage() . " - " . $e->getUserInfo();
+                   $adodb->FailTrans();
+                   $adodb->CompleteTrans();
                    reportError($msg, $sql);
                     die("FAILED " . $msg . "\nError has been reported to site 
administrators.\n");
                }
 
                }
 
-               $mdb2->exec("COMMIT");
-
-               if(PEAR::isError($res)) {
-                   $msg = $res->getMessage() . " - " . $res->getUserInfo();
-                   $mdb2->exec("ROLLBACK");
-                   reportError($msg, $sql);
-                    die("FAILED " . $msg . "\nError has been reported to site 
administrators.\n");
+               try {
+                       $adodb->CompleteTrans();
                }
+               catch (exception $e) {
+                    die("FAILED " . $e->getMessage() . "\n");
+               }
 
+       }
+
                // Destroy now_playing since it is almost certainly obsolescent
-               $mdb2->exec("DELETE FROM Now_Playing WHERE sessionid = " . 
$mdb2->quote($session_id, "text"));
-       }
+               $adodb->Execute("DELETE FROM Now_Playing WHERE sessionid = " . 
$adodb->qstr($session_id));
 }
 
 die("OK\n");





reply via email to

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