[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Librefm-commits] [1108] merge gnukebox from trunk
From: |
Clint Adams |
Subject: |
[Librefm-commits] [1108] merge gnukebox from trunk |
Date: |
Sat, 02 May 2009 04:00:47 +0000 |
Revision: 1108
http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1108
Author: clint
Date: 2009-05-02 04:00:44 +0000 (Sat, 02 May 2009)
Log Message:
-----------
merge gnukebox from trunk
Modified Paths:
--------------
branches/stable/gnukebox/auth-utils.php
branches/stable/gnukebox/blocks.php
branches/stable/gnukebox/database.php
branches/stable/gnukebox/display.php
branches/stable/gnukebox/fix-album-art.php
branches/stable/gnukebox/index.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
branches/stable/gnukebox/tests/SubmissionsTest.php
branches/stable/gnukebox/version.php
Added Paths:
-----------
branches/stable/gnukebox/utils/get_absolute_url.php
Modified: branches/stable/gnukebox/auth-utils.php
===================================================================
--- branches/stable/gnukebox/auth-utils.php 2009-05-02 03:13:53 UTC (rev
1107)
+++ branches/stable/gnukebox/auth-utils.php 2009-05-02 04:00:44 UTC (rev
1108)
@@ -2,7 +2,7 @@
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
Modified: branches/stable/gnukebox/blocks.php
===================================================================
--- branches/stable/gnukebox/blocks.php 2009-05-02 03:13:53 UTC (rev 1107)
+++ branches/stable/gnukebox/blocks.php 2009-05-02 04:00:44 UTC (rev 1108)
@@ -2,7 +2,7 @@
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
Modified: branches/stable/gnukebox/database.php
===================================================================
--- branches/stable/gnukebox/database.php 2009-05-02 03:13:53 UTC (rev
1107)
+++ branches/stable/gnukebox/database.php 2009-05-02 04:00:44 UTC (rev
1108)
@@ -2,7 +2,7 @@
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
Modified: branches/stable/gnukebox/display.php
===================================================================
--- branches/stable/gnukebox/display.php 2009-05-02 03:13:53 UTC (rev
1107)
+++ branches/stable/gnukebox/display.php 2009-05-02 04:00:44 UTC (rev
1108)
@@ -1,7 +1,7 @@
<?php
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
@@ -21,19 +21,20 @@
header('Content-type: text/html; charset=utf-8');
require_once('database.php');
require_once('utils/human-time.php');
+
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Libre.fm — discover new music</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="<?php echo $submissions_server
?>/reset-fonts-grids.css" type="text/css">
+ <link rel="stylesheet" href="<?php echo $submissions_server ?>/base.css"
type="text/css">
+ <link rel="stylesheet" href="<?php echo $submissions_server ?>/librefm.css"
type="text/css">
</head>
<body>
<div id="doc2" class="yui-t7">
- <div id="hd" role="navigation"><h1><a href="/">Header</a></h1>
+ <div id="hd" role="navigation"><h1><a href="<?php echo $submissions_server
?>">Header</a></h1>
<ul>
<li><a
href="https://savannah.nongnu.org/svn/?group=librefm">Code</a></li>
@@ -55,9 +56,9 @@
<div style="padding: 10px;">
<?php
-$req_user = urldecode($_GET["u"]);
-$req_artist = urldecode($_GET["a"]);
-$req_track = urldecode($_GET["t"]);
+ $req_user = urldecode($_GET["u"]);
+ $req_artist = urldecode($_GET["a"]);
+ $req_track = urldecode($_GET["t"]);
if ($req_user) {
@@ -102,7 +103,7 @@
echo ($i % 2 == 0) ? "<tr class=\"even\">" :
"<tr class=\"odd\">";
foreach($row as $field => $value) {
if($field == "username"){
- $value = "<a href=\"/user/" . $value .
"\">$value</a>";}
+ $value = "<a href=\"" .
$submissions_server . "/user/" . $value . "\">$value</a>";}
if($field == "time") {
$value = '<abbr title=\'' .
strftime('%c', $value) . '\'>' . human_timestamp($value) . '</abbr>';
}
@@ -194,7 +195,7 @@
<div id="ft" role="navigation">
<ul>
- <li class="copy">© 2009 Libre.fm Project</li>
+ <li class="copy">© 2009 Free Software Foundation, Inc</li>
<li><a href="http://libre.fm/contributors/">Contributors</a></li>
<li><a href="http://libre.fm/licensing/">Licensing information</a></li>
<li><a href="http://libre.fm/developer/">Developers</a></li>
@@ -209,7 +210,7 @@
<p><img src="http://libre.fm/i/cc-by-sa.png" alt="Attribution-ShareAlike
3.0" /></p>
-<p><a href="/data">Data dumps are here</a></p>
+ <p><a href="<? echo $submissions_server; ?>/data">Data dumps are
here</a></p>
</div>
</div>
Modified: branches/stable/gnukebox/fix-album-art.php
===================================================================
--- branches/stable/gnukebox/fix-album-art.php 2009-05-02 03:13:53 UTC (rev
1107)
+++ branches/stable/gnukebox/fix-album-art.php 2009-05-02 04:00:44 UTC (rev
1108)
@@ -1,7 +1,7 @@
<?php
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
Modified: branches/stable/gnukebox/index.php
===================================================================
--- branches/stable/gnukebox/index.php 2009-05-02 03:13:53 UTC (rev 1107)
+++ branches/stable/gnukebox/index.php 2009-05-02 04:00:44 UTC (rev 1108)
@@ -2,7 +2,7 @@
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
Modified: branches/stable/gnukebox/install.php
===================================================================
--- branches/stable/gnukebox/install.php 2009-05-02 03:13:53 UTC (rev
1107)
+++ branches/stable/gnukebox/install.php 2009-05-02 04:00:44 UTC (rev
1108)
@@ -2,7 +2,7 @@
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
@@ -21,6 +21,7 @@
require_once('MDB2.php');
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.");
@@ -48,8 +49,13 @@
location_uri VARCHAR(255) unique,
latitude FLOAT,
longitude FLOAT,
- country CHAR(2));");
+ country CHAR(2))");
+ $mdb2->query("CREATE TABLE Countries (
+ country varchar(2) PRIMARY KEY,
+ country_name varchar(200),
+ wikipedia_en varchar(120));");
+
$mdb2->query("CREATE TABLE Users (
username VARCHAR(64) PRIMARY KEY,
password VARCHAR(32) NOT NULL,
@@ -58,14 +64,32 @@
bio TEXT,
homepage VARCHAR(255),
location VARCHAR(255),
- created int NOT NULL,
+ created INTEGER NOT NULL,
modified INTEGER,
userlevel INTEGER DEFAULT 0,
webid_uri VARCHAR(255),
avatar_uri VARCHAR(255),
- active integer DEFAULT 1,
- location_uri VARCHAR(255) REFERENCES Places(location_uri));");
+ active INTEGER DEFAULT 1,
+ location_uri VARCHAR(255) REFERENCES Places(location_uri),
+ laconica_profile VARCHAR(255),
+ journal_rss VARCHAR(255))");
+ $res = $mdb2->query("CREATE TABLE Groups (
+ groupname VARCHAR(64) PRIMARY KEY,
+ owner VARCHAR(64) REFERENCES Users(username),
+ fullname VARCHAR(255),
+ bio TEXT,
+ homepage VARCHAR(255),
+ created INTEGER NOT NULL,
+ modified INTEGER,
+ avatar_uri VARCHAR(255),
+ grouptype INTEGER)");
+
+ $res = $mdb2->query("CREATE TABLE Group_Members (
+ groupname VARCHAR(64) REFERENCES Groups(groupname),
+ member VARCHAR(64) REFERENCES Users(username),
+ joined INTEGER NOT NULL)");
+
$mdb2->query("CREATE TABLE AccountActivation(
username VARCHAR(64),
authcode VARCHAR(32))");
@@ -86,7 +110,8 @@
image_small VARCHAR(255),
image_medium VARCHAR(255),
image_large VARCHAR(255),
- homepage VARCHAR(255));");
+ homepage VARCHAR(255),
+ origin VARCHAR(255) REFERENCES Places(location_uri))");
$mdb2->query("CREATE TABLE Album(
name VARCHAR(255),
@@ -96,27 +121,43 @@
artwork_license VARCHAR(255),
releasedate INTEGER,
albumurl VARCHAR(255),
- downloadurl VARCHAR(255));");
+ downloadurl VARCHAR(255))");
// Table for registering similar artists
$mdb2->query("CREATE TABLE Similar_Artist(
name_a VARCHAR(255) REFERENCES Artist(name),
name_b VARCHAR(255) REFERENCES Artist(name),
- PRIMARY KEY(name_a, name_b));");
+ PRIMARY KEY(name_a, name_b))");
- $mdb2->query("CREATE TABLE Track(
- id INTEGER NOT NULL DEFAULT nextval('track_id_seq'::regclass)
PRIMARY KEY,
- name VARCHAR(255),
- artist VARCHAR(255) REFERENCES Artist(name),
- album VARCHAR(255),
- mbid VARCHAR(36),
- duration INTEGER,
- streamable INTEGER,
- license VARCHAR(255),
- downloadurl VARCHAR(255),
- streamurl VARCHAR(255),
- otherid VARCHAR(16));");
-
+ if ( strtolower(substr($mdb2->phptype, 0, 5)) == 'mysql' ) {
+ $mdb2->query("CREATE TABLE Track(
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ name VARCHAR(255),
+ artist VARCHAR(255) REFERENCES Artist(name),
+ album VARCHAR(255),
+ mbid VARCHAR(36),
+ duration INTEGER,
+ streamable INTEGER DEFAULT 0,
+ license VARCHAR(255),
+ downloadurl VARCHAR(255),
+ streamurl VARCHAR(255),
+ otherid VARCHAR(16))");
+ } else {
+ $mdb2->query("CREATE SEQUENCE track_id_seq;");
+ $mdb2->query("CREATE TABLE Track(
+ id INTEGER NOT NULL DEFAULT
nextval('track_id_seq'::regclass) PRIMARY KEY,
+ name VARCHAR(255),
+ artist VARCHAR(255) REFERENCES Artist(name),
+ album VARCHAR(255),
+ mbid VARCHAR(36),
+ duration INTEGER,
+ streamable INTEGER DEFAULT 0,
+ license VARCHAR(255),
+ downloadurl VARCHAR(255),
+ streamurl VARCHAR(255),
+ otherid VARCHAR(16))");
+ }
+
$mdb2->query("CREATE TABLE Scrobbles(
username VARCHAR(64) REFERENCES Users(username),
track VARCHAR(255),
@@ -126,13 +167,14 @@
mbid VARCHAR(36),
source VARCHAR(6),
rating CHAR(1),
- length INTEGER);");
+ length INTEGER,
+ stid INTEGER)");
$mdb2->query("CREATE TABLE Scrobble_Sessions(
username VARCHAR(64) REFERENCES Users(username),
sessionid VARCHAR(32) PRIMARY KEY,
client CHAR(3),
- expires INTEGER);");
+ expires INTEGER)");
$res = $mdb2->query("CREATE TABLE Now_Playing(
sessionid VARCHAR(32) PRIMARY KEY REFERENCES
Scrobble_Sessions(sessionid),
@@ -140,54 +182,76 @@
artist VARCHAR(255) REFERENCES Artist(name),
album VARCHAR(255),
mbid VARCHAR(36),
- expires INTEGER);");
+ expires INTEGER)");
$res = $mdb2->query("CREATE TABLE Invitation_Request(
email VARCHAR(255) PRIMARY KEY,
- time INTEGER);");
+ time INTEGER)");
$res = $mdb2->query("CREATE TABLE Invitations(
inviter VARCHAR(64) REFERENCES Users(username),
invitee VARCHAR(64) REFERENCES Users(username),
code VARCHAR(32),
- PRIMARY KEY(inviter, invitee, code));");
+ PRIMARY KEY(inviter, invitee, code))");
$res = $mdb2->query("CREATE TABLE ClientCodes(
code CHAR(3),
name VARCHAR(32),
url VARCHAR(256),
free CHAR(1),
- PRIMARY KEY(code));");
+ PRIMARY KEY(code))");
$res = $mdb2->query("CREATE TABLE Tags(
username VARCHAR(64) REFERENCES Users(username),
tag VARCHAR(64),
artist VARCHAR(255) REFERENCES Artist(name),
album VARCHAR(255),
- track VARCHAR(255));");
+ track VARCHAR(255))");
$res = $mdb2->query("CREATE TABLE Error(
- id int(11) AUTO_INCREMENT KEY,
- msg text,
- data text,
- time int);");
+ id INTEGER(11) AUTO_INCREMENT KEY,
+ msg TEXT,
+ data TEXT,
+ time INTEGER)");
$res = $mdb2->query("CREATE TABLE Recovery_Request(
username VARCHAR(64),
email VARCHAR(255),
code VARCHAR(32),
- expires int,
- PRIMARY KEY(username));");
+ expires INTEGER,
+ PRIMARY KEY(username))");
+ $res = $mdb2->query("CREATE TABLE Radio_Sessions(
+ username VARCHAR(64),
+ session VARCHAR(32),
+ url VARCHAR(255),
+ expires INTEGER NOT NULL DEFAULT 0,
+ PRIMARY KEY(username,session))");
+
+ $res = $mdb2->exec("CREATE TABLE Scrobble_Track(
+ id SERIAL PRIMARY KEY,
+ artist VARCHAR(255) NOT NULL,
+ album VARCHAR(255),
+ name VARCHAR(255) NOT NULL,
+ mbid VARCHAR(36),
+ track INTEGER NOT NULL)");
+
+ $res = $mdb2->exec("CREATE VIEW Free_Scrobbles AS SELECT s.* FROM
Scrobbles s INNER JOIN Track t on lower(s.artist)=lower(t.artist) and
lower(s.track)=lower(t.name) where t.streamable=1");
+
+
// uncomment these to solve performance problems with getRecentScrobbles
// $res = $mdb2->exec("CREATE INDEX album_artistname_idx ON
Album(artist_name)");
// $res = $mdb2->exec("CREATE INDEX scrobbles_artist_idx ON
Scrobbles(artist)");
// $res = $mdb2->exec("CREATE INDEX scrobbles_time_idx ON
Scrobbles(time)");
-// $res = $mdb2->exec("CREATE INDEX track_artisttrack_idx ON
Track(lower(artist),lower(name))");
+// $res = $mdb2->exec("CREATE INDEX track_artist_idx ON
Track(lower(artist))");
+// $res = $mdb2->exec("CREATE INDEX track_name_idx ON
Track(lower(name))");
+// $res = $mdb2->exec("CREATE INDEX track_streamable_idx on
Track(streamable);");
+// $res = $mdb2->exec("CREATE INDEX scrobbles_artist_idx on
Scrobbles(lower(artist))");
+// $res = $mdb2->exec("CREATE INDEX scrobbles_track_idx on
Scrobbles(lower(track))");
-
// uncomment these if you're using postgresql and want to run the software as
www-data
-// $res = $mdb2->exec("GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE
Album, Artist, Auth, Clientcodes, Error, Invitation_Request, Invitations,
Now_Playing, Places, Radio_Sessions, Scrobble_Sessions, Scrobbles,
Similar_artist, Tags, Track, Users to \"www-data\"");
-// $res = $mdb2->exec("GRANT SELECT, UPDATE ON users_uniqueid_seq to
\"www-data\"");
+// $res = $mdb2->exec("GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE
Album, Artist, Auth, Clientcodes, Error, Invitation_Request, Invitations,
Now_Playing, Places, Radio_Sessions, Scrobble_Sessions, Scrobbles,
Scrobble_Track, Similar_Artist, Tags, Track, Users to \"www-data\"");
+// $res = $mdb2->exec("GRANT SELECT ON Free_Scrobbles to \"www-data\"");
+// $res = $mdb2->exec("GRANT SELECT, UPDATE ON users_uniqueid_seq,
scrobble_track_id_seq to \"www-data\"");
// Test user configuration
$res = $mdb2->query("INSERT INTO Users
@@ -201,7 +265,7 @@
$install_path = dirname(__FILE__) . "/";
//Write out the configuration
- $config = "<?php \$config_version = " . $version .";\n \$connect_string
= '" . $connect_string . "';\n \$submissions_server = '" . $submissions_server
. "';\n\$install_path = '" . $install_path . "'; ?>";
+ $config = "<?php\n \$config_version = " . $version .";\n
\$connect_string = '" . $connect_string . "';\n \$submissions_server = '" .
$submissions_server . "';\n\$install_path = '" . $install_path . "'; ?>";
$conf_file = fopen("config.php", "w");
$result = fwrite($conf_file, $config);
@@ -253,7 +317,7 @@
</div>
<br />
<h2>Servers</h2>
- Submissions Server URL: <input type="text"
name="submissions" value="http://localhost/" /><br />
+ Submissions Server URL: <input type="text"
name="submissions" value="<?php echo getAbsoluteURL(); ?>" /><br />
<br />
<input type="submit" value="Install" name="install" />
</form>
Modified: branches/stable/gnukebox/nowplaying/1.2/index.php
===================================================================
--- branches/stable/gnukebox/nowplaying/1.2/index.php 2009-05-02 03:13:53 UTC
(rev 1107)
+++ branches/stable/gnukebox/nowplaying/1.2/index.php 2009-05-02 04:00:44 UTC
(rev 1108)
@@ -1,7 +1,7 @@
<?php
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
@@ -41,11 +41,7 @@
}
$track = $mdb2->quote($_POST['t'], "text");
if(isset($_POST['l']) && is_numeric($_POST['l'])) {
- $length = (int) $_POST['l'];
- if($length > 9999) {
- die("FAILED Track length seems very very wrong\n"); // Jerboa seems
highly broken
- }
- $expires = time() + $length;
+ $expires = time() + (int) $_POST['l'];
} else {
$expires = time() + 250; //Expire in 5 minutes if we don't know the
track length
}
@@ -60,7 +56,7 @@
if($album != 'NULL') {
createAlbumIfNew($artist, $album);
}
-createTrackIfNew($artist, $album, $track, $mbid);
+getTrackCreateIfNew($artist, $album, $track, $mbid);
//Expire old tracks
$mdb2->query("DELETE FROM Now_Playing WHERE expires < " . time());
Modified: branches/stable/gnukebox/scrobble-utils.php
===================================================================
--- branches/stable/gnukebox/scrobble-utils.php 2009-05-02 03:13:53 UTC (rev
1107)
+++ branches/stable/gnukebox/scrobble-utils.php 2009-05-02 04:00:44 UTC (rev
1108)
@@ -2,7 +2,7 @@
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
@@ -19,24 +19,34 @@
*/
-require_once('database.php');
+require_once('database.php'); // include the database connection string
-function usernameFromSID($session_id) {
- global $mdb2;
+function usernameFromSID($session_id)
+{
+//derive the username from a session ID
+
+ global $mdb2; // include the Database connector
+
// Delete any expired session ids
$mdb2->query("DELETE FROM Scrobble_Sessions WHERE expires < " . time());
- $res = $mdb2->query("SELECT username FROM Scrobble_Sessions WHERE
sessionid = " . $mdb2->quote($session_id, "text"));
- if(PEAR::isError($res)) {
+ $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 " . $res->getMessage() . "\n");
+ // die is there is an error, printing the error
}
if(!$res->numRows()) {
die("BADSESSION\n");
+
+ // the user has no session
}
return $res->fetchOne(0);
+
+ // return the first user
}
function createArtistIfNew($artist) {
@@ -61,7 +71,7 @@
function createAlbumIfNew($artist, $album) {
global $mdb2;
- $res = $mdb2->query("SELECT name FROM Album WHERE name = " . ($album));
+ $res = $mdb2->query("SELECT name FROM Album WHERE name = " . ($album) .
" AND artist_name = " . ($artist));
if(PEAR::isError($res)) {
die("FAILED " . $res->getMessage() . "\n");
}
@@ -87,16 +97,16 @@
}
}
-function createTrackIfNew($artist, $album, $track, $mbid) {
+function getTrackCreateIfNew($artist, $album, $track, $mbid) {
global $mdb2;
$track = NoSpamTracks($track);
$artist = NoSpamTracks($artist);
if($album) {
- $res = $mdb2->query("SELECT name FROM Track WHERE lower(name) = " .
(strtolower($track)) . " AND lower(artist) = " . (strtolower($artist)) . " AND
lower(album) = " . strtolower($album));
+ $res = $mdb2->query("SELECT id FROM Track WHERE lower(name) = " .
(strtolower($track)) . " AND lower(artist) = " . (strtolower($artist)) . " AND
lower(album) = " . strtolower($album));
} else {
- $res = $mdb2->query("SELECT name FROM Track WHERE lower(name) = " .
(strtolower($track)) . " AND lower(artist) = " . (strtolower($artist)) . "AND
album IS NULL");
+ $res = $mdb2->query("SELECT id FROM Track WHERE lower(name) = " .
(strtolower($track)) . " AND lower(artist) = " . (strtolower($artist)) . "AND
album IS NULL");
}
if(PEAR::isError($res)) {
die("FAILED " . $res->getMessage() . "\n");
@@ -112,9 +122,37 @@
if(PEAR::isError($res)) {
die("FAILED " . $res->getMessage() . "\n");
}
+ return getTrackCreateIfNew($artist, $album, $track, $mbid);
+ } else {
+ return $res->fetchOne(0);
}
}
+function getScrobbleTrackCreateIfNew($artist, $album, $track, $mbid, $tid) {
+ global $mdb2;
+
+ $res = $mdb2->query("SELECT id FROM Scrobble_Track WHERE name = " .
(strtolower($track)) . " AND artist = " . (strtolower($artist)) . " AND album =
" . strtolower($album) . " AND mbid = " . strtolower($mbid));
+ if(PEAR::isError($res)) {
+ die("FAILED " . $res->getMessage() . "\n");
+ }
+
+ if(!$res->numRows()) {
+ // Create new track
+ $res = $mdb2->exec("INSERT INTO Scrobble_Track (name, artist,
album, mbid, track) VALUES ("
+ . strtolower($track) . ", "
+ . strtolower($artist) . ", "
+ . strtolower($album) . ", "
+ . strtolower($mbid) . ","
+ . strtolower($tid) . ")");
+ if(PEAR::isError($res)) {
+ die("FAILED " . $res->getMessage() . "\n");
+ }
+ return getScrobbleTrackCreateIfNew($artist, $album, $track,
$mbid, $tid);
+ } else {
+ return $res->fetchOne(0);
+ }
+}
+
function scrobbleExists($username, $artist, $track, $time) {
global $mdb2;
Modified: branches/stable/gnukebox/submissions/1.1/handshake.php
===================================================================
--- branches/stable/gnukebox/submissions/1.1/handshake.php 2009-05-02
03:13:53 UTC (rev 1107)
+++ branches/stable/gnukebox/submissions/1.1/handshake.php 2009-05-02
04:00:44 UTC (rev 1108)
@@ -1,7 +1,7 @@
<?php
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
Modified: branches/stable/gnukebox/submissions/1.2/handshake.php
===================================================================
--- branches/stable/gnukebox/submissions/1.2/handshake.php 2009-05-02
03:13:53 UTC (rev 1107)
+++ branches/stable/gnukebox/submissions/1.2/handshake.php 2009-05-02
04:00:44 UTC (rev 1108)
@@ -1,7 +1,7 @@
<?php
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
Modified: branches/stable/gnukebox/submissions/1.2/index.php
===================================================================
--- branches/stable/gnukebox/submissions/1.2/index.php 2009-05-02 03:13:53 UTC
(rev 1107)
+++ branches/stable/gnukebox/submissions/1.2/index.php 2009-05-02 04:00:44 UTC
(rev 1108)
@@ -1,7 +1,7 @@
<?php
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
@@ -32,13 +32,6 @@
die("FAILED Track parameters must be arrays\n");
}
-if(isset($_POST['l']) && is_numeric($_POST['l'])) {
- $len = (int)$_POST['l'];
- if($len > 9999) {
- die("FAILED Track length seems very very wrong\n");
- }
-}
-
$session_id = $_POST['s'];
$username = $mdb2->quote(usernameFromSID($session_id), "text");
@@ -115,7 +108,8 @@
if($album != 'NULL') {
createAlbumIfNew($artist, $album);
}
- createTrackIfNew($artist, $album, $track, $mbid);
+ $tid = getTrackCreateIfNew($artist, $album, $track, $mbid);
+ $stid = getScrobbleTrackCreateIfNew($artist, $album, $track, $mbid,
$tid);
$exists = scrobbleExists($username, $artist, $track, $time);
@@ -130,7 +124,8 @@
. $mbid . ", "
. $source . ","
. $rating . ","
- . $length . ")";
+ . $length . ","
+ . $stid . ")";
$actualcount++;
}
@@ -142,7 +137,7 @@
for($j = 0; $j < $actualcount; $j++) {
// Scrobble!
- $sql = "INSERT INTO Scrobbles (username, artist, album, track,
time, mbid, source, rating, length) VALUES " . $rowvalues[$j];
+ $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();
Modified: branches/stable/gnukebox/tests/SubmissionsTest.php
===================================================================
--- branches/stable/gnukebox/tests/SubmissionsTest.php 2009-05-02 03:13:53 UTC
(rev 1107)
+++ branches/stable/gnukebox/tests/SubmissionsTest.php 2009-05-02 04:00:44 UTC
(rev 1108)
@@ -1,7 +1,7 @@
<?php
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
Copied: branches/stable/gnukebox/utils/get_absolute_url.php (from rev 1079,
branches/stable/gnukebox/version.php)
===================================================================
--- branches/stable/gnukebox/utils/get_absolute_url.php
(rev 0)
+++ branches/stable/gnukebox/utils/get_absolute_url.php 2009-05-02 04:00:44 UTC
(rev 1108)
@@ -0,0 +1,30 @@
+<?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/>.
+
+*/
+
+function getAbsoluteURL() {
+ $scriptName = $_SERVER['SCRIPT_NAME'];
+ $path = explode("/", $scriptName);
+ array_pop($path);
+ $server = $_SERVER['HTTP_HOST'];
+ $string = (implode("/", $path).'/');
+ return "http://".$server.$string;
+}
+?>
Modified: branches/stable/gnukebox/version.php
===================================================================
--- branches/stable/gnukebox/version.php 2009-05-02 03:13:53 UTC (rev
1107)
+++ branches/stable/gnukebox/version.php 2009-05-02 04:00:44 UTC (rev
1108)
@@ -2,7 +2,7 @@
/* Libre.fm -- a free network service for sharing your music listening habits
- Copyright (C) 2009 Libre.fm Project
+ 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
@@ -19,5 +19,5 @@
*/
-$version = 0.1;
+$version = 0.1; // set up the version number
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Librefm-commits] [1108] merge gnukebox from trunk,
Clint Adams <=