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

Commit 58af1743 authored by elleo's avatar elleo

Update User to provide constructed urls

Move Artist url construction to Server
Update profile template to use friendly urls
parent cc0fc615
......@@ -24,6 +24,7 @@ require_once($install_path . '/database.php');
require_once($install_path . "/data/sanitize.php");
require_once($install_path . "/data/Album.php");
require_once($install_path . "/data/Track.php");
require_once($install_path . "/data/Server.php");
/**
* Represents artist data
......
......@@ -104,4 +104,13 @@ class Server {
}
}
static function getArtistURL($artist) {
global $friendly_urls, $base_url;
if($friendly_urls) {
return $base_url . "/artist/" . urlencode(stripslashes($artist));
} else {
return $base_url . "/artist.php?artist=" . urlencode(stripslashes($artist));
}
}
}
......@@ -23,6 +23,7 @@
require_once($install_path . '/database.php');
require_once($install_path . "/data/Artist.php");
require_once($install_path . "/data/Album.php");
require_once($install_path . "/data/Server.php");
/**
* Represents track data
......
......@@ -23,6 +23,7 @@
require_once($install_path . '/database.php');
require_once($install_path . '/data/sanitize.php');
require_once($install_path . '/utils/human-time.php');
require_once($install_path . '/data/Server.php');
/**
* Represents User data
......@@ -67,10 +68,12 @@ class User {
$res = $mdb2->query('SELECT * FROM Scrobbles WHERE username = ' .$mdb2->quote($this->name, 'text') . ' ORDER BY time DESC LIMIT '.$mdb2->quote($number, 'integer'));
$data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
foreach($data as &$i) {
$i = sanitize($i);
$i['timehuman'] = human_timestamp($i['time']);
$row = sanitize($i);
$row['timehuman'] = human_timestamp($row['time']);
$row['artisturl'] = Server::getArtistURL($row['artist']);
$result[] = $row;
}
return $data;
return $result;
}
/**
......@@ -84,12 +87,7 @@ class User {
}
function getURL() {
global $friendly_urls, $base_url;
if($friendly_urls) {
return $base_url . "/user/" . urlencode(stripslashes($this->name));
} else {
return $base_url . "/profile.php?user=" . urlencode(stripslashes($this->name));
}
return Server::getUserURL($this->name);
}
/**
......@@ -104,16 +102,18 @@ class User {
$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)";
$row = sanitize($i);
if($row["name"] == "") {
$clientstr = strip_tags(stripslashes($row["client"])) . " (unknown, please tell us what this is)";
} else {
$clientstr = "<a href=\"" . strip_tags(stripslashes($i["url"])) . "\">" . strip_tags(stripslashes($i["name"])) . "</a>";
$clientstr = "<a href=\"" . strip_tags(stripslashes($row["url"])) . "\">" . strip_tags(stripslashes($row["name"])) . "</a>";
}
$i["clientstr"] = $clientstr;
$row["clientstr"] = $clientstr;
$row["artisturl"] = Server::getArtistURL($row["artist"]);
$result[] = $row;
}
return $data;
return $result;
}
}
......
......@@ -26,7 +26,7 @@
{section name=i loop=$nowplaying}
<li>{$nowplaying[i].track}
by
<a href="artist.php?artist={$nowplaying[i].artist|stripslashes|urlencode|htmlspecialchars}">{$nowplaying[i].artist}</a>
<a href="{$nowplaying[i].artisturl}">{$nowplaying[i].artist}</a>
with {$nowplaying[i].clientstr}</li>
{/section}
</ul>
......@@ -40,7 +40,7 @@ with {$nowplaying[i].clientstr}</li>
{/if}
<dl class='gobbles'>
<dt class='artist'>
<a href="artist.php?artist={$scrobbles[i].artist|stripslashes|urlencode|htmlspecialchars}">{$scrobbles[i].artist}</a>
<a href="{$scrobbles[i].artisturl}">{$scrobbles[i].artist}</a>
</dt>
{/if}
<dd class='gobble'><span class='track-name'>{$scrobbles[i].track|stripslashes}</span><small>{$scrobbles[i].timehuman}</small></dd>
......
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