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

Commit f32fd048 authored by fauno's avatar fauno

(Merging) Changed double for single quotes and re-design profile

parent bd90a819
......@@ -41,17 +41,17 @@ class Album {
*/
function __construct($name, $artist) {
global $mdb2;
$res = $mdb2->query("SELECT name, artist_name, mbid, releasedate FROM Album WHERE "
. "name = " . $mdb2->quote($name, "text") . " AND "
. "artist_name = " . $mdb2->quote($artist, "text"));
$res = $mdb2->query('SELECT name, artist_name, mbid, releasedate FROM Album WHERE '
. 'name = ' . $mdb2->quote($name, 'text') . ' AND '
. 'artist_name = ' . $mdb2->quote($artist, 'text'));
if(!$res->numRows()) {
$this->name = "No such album.";
$this->name = 'No such album.';
} else {
$row = sanitize($res->fetchRow(MDB2_FETCHMODE_ASSOC));
$this->name = $row["name"];
$this->mbid = $row["mbid"];
$this->artist_name = $row["artist_name"];
$this->releasedate = $row["releasedate"];
$this->name = $row['name'];
$this->mbid = $row['mbid'];
$this->artist_name = $row['artist_name'];
$this->releasedate = $row['releasedate'];
}
}
......@@ -62,11 +62,11 @@ class Album {
*/
function getTracks() {
global $mdb2;
$res = $mdb2->query("SELECT name, artist FROM Track WHERE artist = "
. $mdb2->quote($this->artist_name, "text") . " AND album = "
$res = $mdb2->query('SELECT name, artist FROM Track WHERE artist = '
. $mdb2->quote($this->artist_name, 'text') . ' AND album = '
. $mdb2->quote($this->name));
while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
$tracks[] = new Track($row["name"], $row["artist"]);
$tracks[] = new Track($row['name'], $row['artist']);
}
return $tracks;
......
......@@ -21,8 +21,8 @@
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/sanitize.php');
require_once($install_path . '/utils/human-time.php');
/**
* Represents User data
......@@ -42,37 +42,37 @@ class User {
*/
function __construct($name) {
global $mdb2;
$res = $mdb2->query("SELECT * FROM Users WHERE "
. "username = " . $mdb2->quote($name, "text"));
$res = $mdb2->query('SELECT * FROM Users WHERE '
. 'username = ' . $mdb2->quote($name, 'text'));
if($res->numRows()) {
$row = sanitize($res->fetchRow(MDB2_FETCHMODE_ASSOC));
$this->name = $row["username"];
$this->email = $row["email"];
$this->fullname = $row["fullname"];
$this->homepage = $row["homepage"];
$this->bio = $row["bio"];
$this->location = $row["location"];
$this->userlevel = $row["userlevel"];
$this->name = $row['username'];
$this->email = $row['email'];
$this->fullname = $row['fullname'];
$this->homepage = $row['homepage'];
$this->bio = $row['bio'];
$this->location = $row['location'];
$this->userlevel = $row['userlevel'];
}
}
/**
* Get a user's scrobles ordered by time
*
* @param int number The number of scrobbles to return
* @return An array of scrobbles
*/
function getScrobbles($number) {
global $mdb2;
$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"]);
}
return $data;
}
}
/**
* Get a user's scrobbles ordered by time
*
* @param int number The number of scrobbles to return
* @return An array of scrobbles
*/
function getScrobbles($number) {
global $mdb2;
$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']);
}
return $data;
}
}
......@@ -19,16 +19,16 @@
*/
require_once("database.php");
require_once("templating.php");
require_once('database.php');
require_once('templating.php');
$res = $mdb2->query("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');
if(PEAR::isError($res)) {
die($res->getMessage());
}
$smarty->assign("recenttracks", $res->fetchAll(MDB2_FETCHMODE_ASSOC));
$smarty->assign('recenttracks', $res->fetchAll(MDB2_FETCHMODE_ASSOC));
$smarty->display("welcome.tpl");
$smarty->display('welcome.tpl');
?>
......@@ -20,48 +20,48 @@
*/
require_once("database.php");
require_once("templating.php");
require_once('database.php');
require_once('templating.php');
if(isset($_POST['login'])) {
$errors = "";
$errors = '';
$username = $_POST['username'];
$password = $_POST['password'];
if(empty($username)) {
$errors .= "You must enter a username.<br />";
$errors .= 'You must enter a username.<br />';
}
if(empty($password)) {
$errors .= "You must enter a password.<br />";
$errors .= 'You must enter a password.<br />';
}
if(empty($errors)) {
$res = $mdb2->query("SELECT username FROM Users WHERE "
. " username = " . $mdb2->quote($username, "text")
. " AND password = " . $mdb2->quote(md5($password), "text"));
$res = $mdb2->query('SELECT username FROM Users WHERE '
. ' username = ' . $mdb2->quote($username, 'text')
. ' AND password = ' . $mdb2->quote(md5($password), 'text'));
if(!$res->numRows()) {
$errors .= "Invalid username or password.";
$errors .= 'Invalid username or password.';
} else {
// Give the user a session id, like any other client
$session_id = md5(md5($password) . time());
$mdb2->query("INSERT INTO Scrobble_Sessions (username, sessionid, expires) VALUES ("
. $mdb2->quote($username, "text") . ", "
. $mdb2->quote($session_id, "text") . ", "
. $mdb2->quote(time() + 604800) . ")"); // Web sessions last a week
$mdb2->query('INSERT INTO Scrobble_Sessions (username, sessionid, expires) VALUES ('
. $mdb2->quote($username, 'text') . ', '
. $mdb2->quote($session_id, 'text') . ', '
. $mdb2->quote(time() + 604800) . ')'); // Web sessions last a week
$_SESSION['session_id'] = $session_id;
$logged_in = true;
$smarty->assign("logged_in", true);
$smarty->assign('logged_in', true);
}
}
}
if($logged_in) {
if(isset($logged_in) && $logged_in) {
// Send the user to the welcome page when they've logged in
header("Location: index.php");
//$smarty->display("welcome.tpl");
header('Location: index.php');
//$smarty->display('welcome.tpl');
} else {
$smarty->display("login.tpl");
$smarty->display('login.tpl');
}
?>
......@@ -22,29 +22,28 @@
require_once('database.php');
require_once('templating.php');
require_once('data/User.php');
require_once('utils/EmailAddressValidator.php');
if(!isset($_GET['user'])) {
$smarty->assign("error", "Error!");
$smarty->assign("details", "User not set! You shouldn't be here!");
$smarty->display("error.tpl");
if(!isset($_GET['user']) && $logged_in == false) {
$smarty->assign('error', 'Error!');
$smarty->assign('details', 'User not set! You shouldn\'t be here!');
$smarty->display('error.tpl');
die();
}
$user = new User($_GET['user']);
if(isset($user->name)) {
$smarty->assign("user", $user->name);
$smarty->assign("email", $user->email);
$smarty->assign("fullname", $user->fullname);
$smarty->assign("bio", $user->bio);
$smarty->assign("homepage", $user->homepage);
$smarty->assign("location", $user->location);
$smarty->assign("scrobbles", $user->getScrobbles(10));
$smarty->assign("userlevel", $user->userlevel);
$smarty->display("profile.tpl");
$smarty->assign('user', $user->name);
$smarty->assign('email', $user->email);
$smarty->assign('fullname', $user->fullname);
$smarty->assign('bio', $user->bio);
$smarty->assign('homepage', $user->homepage);
$smarty->assign('location', $user->location);
$smarty->assign('scrobbles', $user->getScrobbles(10));
$smarty->assign('userlevel', $user->userlevel);
$smarty->display('profile.tpl');
} else {
$smarty->assign("error", "User not found");
$smarty->assign("details", "Shall I call in a missing persons report?");
$smarty->display("error.tpl");
$smarty->assign('error', 'User not found');
$smarty->assign('details', 'Shall I call in a missing persons report?');
$smarty->display('error.tpl');
}
?>
......@@ -19,18 +19,18 @@
*/
require_once("config.php");
require_once("auth.php");
require_once("smarty/Smarty.class.php");
require_once('config.php');
require_once('auth.php');
require_once('smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = $install_path . "/themes/". $default_theme . "/templates/";
$smarty->compile_dir = $install_path. "/themes/" . $default_theme . '/templates_c/';
$smarty->assign("base_url", $base_url);
if($logged_in) {
$smarty->assign("logged_in", true);
$smarty->assign("username", $username);
$smarty->assign("userlevel", $userlevel);
$smarty->template_dir = $install_path . '/themes/'. $default_theme . '/templates/';
$smarty->compile_dir = $install_path. '/themes/' . $default_theme . '/templates_c/';
$smarty->assign('base_url', $base_url);
if(isset($logged_in)) {
$smarty->assign('logged_in', true);
$smarty->assign('username', $username);
$smarty->assign('userlevel', $userlevel);
}
?>
......@@ -129,3 +129,38 @@ ul.listcloud li dt a { color: #630000; text-decoration: none; }
ul.listcloud li dt a:hover { text-decoration: underline; }
ul#topartists.listcloud dd { font-size: 80%; }
/* Users */
.user {
font-size: .8em;
}
.photo, .avatar {
max-height: 96px;
max-width: 96px;
min-height: 32px;
min-width: 32px;
float: left;
}
.user .bio {
}
.user .nickname {
color: #666666
}
dl.gobbles { }
dl.gobbles dt.artist a {
text-decoration: none;
color: #2e3436;
}
dl.gobbles dt.artist a:hover {
text-decoration: underline;
}
dl.gobbles dd.gobble span.track-name {
font-weight: bold;
font-size: .8em
}
dl.gobbles dd.gobble small {
display: block;
color: #666;
font-size: .7em
}
......@@ -19,6 +19,6 @@
</head>
<body>
<div id="doc3" class="yui-t7">
<div id="hd" style="banner"><h1><a href="{$base_url}">Libre.fm</a></h1></div>
<div id="hd" class='vcard'><h1 class='fn org'><a href="{$base_url}" class='url'>Libre.fm</a></h1></div>
{include file='menu.tpl'}
<div id="main">
......@@ -2,17 +2,17 @@
<h2>Login</h2>
{if isset($errors)}
{if !empty($errors)}
<p id='errors'>{$errors}</p>
{/if}
<div id="login">
<form action='' method='post'>
<fieldset>
<label for='username'>Username:</label>
<label for='username'>Username<span>&nbsp;</span></label>
<input id='username' name='username' type='text' value='{$username}' maxlength='64' />
<label for='password'>Your password:</label>
<label for='password'>Password<span>&nbsp;</span></label>
<input id='password' name='password' type='password' value=''/>
<input type='submit' name='login' value="Let me in!" />
......
<div id="menu">
{if isset($logged_in)}
{if ($logged_in)}
<p>Logged in as: <a href="{$base_url}/profile.php?user={$username|urlencode}">{$username}</a></p>
{/if}
<ul id="navigation">
{if isset($logged_in)}
{if ($logged_in)}
<li>Invites disabled</li>
{if $userlevel > 0}
<li><a href="/admin.php">Admin panel</a></li>
......
{include file='header.tpl'}
<h2>{$user}'s profile</h2>
Username: {$user} <br />
Real Name: {$fullname} <br />
Homepage: <a href="{$homepage}">{$homepage}</a> <br />
Location: {$location} <br />
Bio: {$bio} <br />
<hr>
<b>Latest 10 Gobbles:</b>
<ul id="scrobbles" class="listcloud">
<dl class='user vcard'>
<dt class='fn'>
<span class='family-name'>{$fullname}</span>
(<span class='nickname'>{$user}</span>)
</dt>
<dd class='avatar'>
<!-- Avatar placeholder -->
<img src='{$avatar}' class='photo'/>
</dd>
<dd class='org'>
<a href='{$homepage}' rel='bookmark' class='url'>{$homepage}</a>
</dd>
<dd class='adr'>
<span class='locality'>{$location}</span>
</dd>
<dd class='bio'>
<p>{$bio}</p>
</dd>
</dl>
<h3>Latest 10 Gobbles:</h3>
{section name=i loop=$scrobbles}
<li>
<dl>
<dt><a href="artist.php?artist={$scrobbles[i].artist|stripslashes|urlencode}">
{$scrobbles[i].artist|stripslashes}</a></dt>
<dd>{$scrobbles[i].track|stripslashes}<br /><small>{$scrobbles[i].timehuman}</small></dd>
</dl>
</li>
{if $smarty.capture.artist_last <> $scrobbles[i].artist}
{if $i > 0}
</dl>
{/if}
<dl class='gobbles'>
<dt class='artist'>
<a href="artist.php?artist={$scrobbles[i].artist|stripslashes|urlencode}">{$scrobbles[i].artist}</a>
</dt>
{/if}
<dd class='gobble'><span class='track-name'>{$scrobbles[i].track|stripslashes}</span><small>{$scrobbles[i].timehuman}</small></dd>
{capture name=artist_last}{$scrobbles[i].artist}{/capture}
{/section}
</ul>
</dl>
{include file='footer.tpl'}
{include file='header.tpl'}
<h2>Welcome</h2>
<p><strong>libre.fm</strong> is a free network service that will allow users to share their
<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>What's hot? Recently gobbled.</h3>
......
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