We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 851f4384 authored by clint's avatar clint

break the main page

parent b2a76511
<?php
/* Libre.fm -- a free network service for sharing your music listening habits
Copyright (C) 2009 Libre.fm Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once($install_path . '/database.php');
require_once($install_path . '/data/sanitize.php');
require_once($install_path . '/utils/human-time.php');
/**
* Represents Server-wide data
*
*/
class Server {
public $nowplaying;
/**
* Server constructor
*
* @param string $name The name of the user to load
*/
function __construct() {
global $mdb2;
$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 time DESC');
$data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
foreach($data as &$i) {
$i = sanitize($i);
if($i["name"] == "") {
$clientstr = strip_tags(stripslashes($i["client"])) . "(unknown, please tell us what this is)";
} else {
$clientstr = "<a href=\"" . strip_tags(stripslashes($i["url"])) . "\">" . strip_tags(stripslashes($i["name"])) . "</a>";
}
$i["clientstr"] = $clientstr;
}
$this->nowplaying = $data;
}
}
......@@ -30,5 +30,20 @@ if(PEAR::isError($res)) {
$smarty->assign('recenttracks', $res->fetchAll(MDB2_FETCHMODE_ASSOC));
$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 time DESC');
$data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
foreach($data as &$i) {
$i = sanitize($i);
if($i["name"] == "") {
$clientstr = strip_tags(stripslashes($i["client"])) . "(unknown, please tell us what this is)";
} else {
$clientstr = "<a href=\"" . strip_tags(stripslashes($i["url"])) . "\">" . strip_tags(stripslashes($i["name"])) . "</a>";
}
$i["clientstr"] = $clientstr;
}
$smarty->assign('nowplaying', $data);
$smarty->display('welcome.tpl');
?>
......@@ -4,6 +4,20 @@
<p><strong><span class='vcard fn org'>libre.fm</span></strong> is a free network service that will allow users to share their
musical tastes with other people.</p>
<h3>Now playing</h3>
<ul id="nowplaying" class="listcloud">
{section name=np loop=$nowplaying}
<li>
<dl>
<dt><a href="artist.php?artist={$nowplaying[np].artist|stripslashes|urlencode}">
{$nowplaying[np].artist|stripslashes|htmlspecialchars}</a></dt>
<dd>{$nowplaying[np].track|stripslashes|htmlspecialchars}</dd>
</dl>
</li>
{/section}
</ul>
<h3>What's hot? Recently gobbled.</h3>
<ul id="recenttracks" class="listcloud">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment