<commit_before><?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/>.

*/

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="blocks.css" type="text/css">
   <link rel="stylesheet" href="librefm.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">

  <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 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 10");

			echo "<h2>Last 10 Gobbles by " . $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 10");

			echo "<h2>Last 10 Gobbles of " . $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 10");

			echo "<h2>Last 10 Gobbles of " . $req_track . "</h2>";

} elseif (!$res) {

			$res = $mdb2->query("SELECT username, artist, track, time FROM Scrobbles ORDER BY time DESC LIMIT 10");

			echo "<h2>Last 10 Gobbles</h2>";

}

			if(PEAR::isError($res)) {
				die($res->getMessage());
			}
			while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
                                echo "<div id='card".$i."' class='singlecard'>";
				foreach($row as $field => $value) {
					if($field == "time") {
						$value = strftime("%c", $value);
					}
                                        if($field == "username") {
					    echo "<div class='".stripslashes($field)."'><a href='/blocks.php?u=" . stripslashes($value) . "'>" . stripslashes($value) . "</a></div>";
                                        } else {
					    echo "<div class='".stripslashes($field)."'>". stripslashes($value) . "</div>";
                                        }
				echo "</div>";
			}

		?>
</div>

		<h2>Now Playing?</h2>

		<?php
			$res = $mdb2->query("SELECT username, artist, track FROM Now_Playing ORDER BY 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>";
			}
		?>

		<h2>Statistics</h2><commit_msg>Fix unclosed bracket in blocks.php<commit_after><?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/>.

*/

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="blocks.css" type="text/css">
   <link rel="stylesheet" href="librefm.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">

  <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 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 10");

			echo "<h2>Last 10 Gobbles by " . $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 10");

			echo "<h2>Last 10 Gobbles of " . $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 10");

			echo "<h2>Last 10 Gobbles of " . $req_track . "</h2>";

} elseif (!$res) {

			$res = $mdb2->query("SELECT username, artist, track, time FROM Scrobbles ORDER BY time DESC LIMIT 10");

			echo "<h2>Last 10 Gobbles</h2>";

}

			if(PEAR::isError($res)) {
				die($res->getMessage());
			}
			while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
                                echo "<div id='card".$i."' class='singlecard'>";
				foreach($row as $field => $value) {
					if($field == "time") {
						$value = strftime("%c", $value);
					}
                                        if($field == "username") {
					    echo "<div class='".stripslashes($field)."'><a href='/blocks.php?u=" . stripslashes($value) . "'>" . stripslashes($value) . "</a></div>";
                                        } else {
					    echo "<div class='".stripslashes($field)."'>". stripslashes($value) . "</div>";
                                        }
                                }
				echo "</div>";
			}

		?>
</div>

		<h2>Now Playing?</h2>

		<?php
			$res = $mdb2->query("SELECT username, artist, track FROM Now_Playing ORDER BY 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>";
			}
		?>

		<h2>Statistics</h2>
{'fraction_non_alphanumeric': 0.1728, 'fraction_numerical': 0.014506666666666666, 'mean_word_length': 3.217723796671165, 'pattern_counts': {'":': 0, '<': 129, '<?xml version=': 0, '>': 149, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '872583', 'n_tokens_mistral': 3385, 'n_tokens_neox': 3062, 'n_words': 883}