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

Commit 419c53d0 authored by jurgbohn's avatar jurgbohn

Started on admin-panel for web

parent 2ff6a411
......@@ -52,6 +52,7 @@ if (isset($_POST['install'])) {
location VARCHAR(255),
created int NOT NULL,
modified int,
userlevel int DEFAULT 0,
FULLTEXT(fullname, bio, location));");
$res = $mdb2->query("CREATE TABLE Auth (token VARCHAR(32) PRIMARY KEY,
......
<?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('database.php');
require_once('templating.php');
$res = $mdb2->query("SELECT userlevel FROM Users WHERE username=" . $mdb2->quote($user, 'text'));
if ($res->numRows() != 1) {
$smarty->assign("error", "Error!");
$smarty->assign("details", "Invalid user specified.");
$smarty->display("error.tpl");
die();
}
$row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
if ($row['userlevel'] < 2) {
$smarty->assign("error", "Error!");
$smarty->assign("details", "Invalid privileges.");
$smarty->display("error.tpl");
die();
} else {
$smarty->display('admin.tpl');
echo "Access to admin-panel granted.";
}
......@@ -33,7 +33,7 @@ require_once($install_path . "/utils/human-time.php");
class User {
public $name, $email, $fullname, $bio, $location, $homepage, $error;
public $name, $email, $fullname, $bio, $location, $homepage, $error,$userlevel;
/**
* Artist constructor
......@@ -51,7 +51,8 @@ class User {
$this->fullname = $row["fullname"];
$this->homepage = $row["homepage"];
$this->bio = $row["bio"];
$this->location = $row["location"];
$this->location = $row["location"];
$this->userlevel = $row["userlevel"];
}
}
function getscrobbles($number) {
......
......@@ -40,6 +40,7 @@ if(isset($user->name)) {
$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");
......
{include file='header.tpl'}
<h2>Admin panel</h2>
<hr>
<b>Latest 10 Gobbles:</b>
<ul id="scrobbles" class="listcloud">
{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>
{/section}
</ul>
{include file='footer.tpl'}
......@@ -6,6 +6,9 @@ Real Name: {$fullname} <br />
Homepage: {$homepage} <br />
Location: {$location} <br />
Bio: {$bio} <br />
{if $userlevel > 1}
<a href="/admin.php">Admin Panel</a><br />
{/if}
<hr>
<b>Latest 10 Gobbles:</b>
<ul id="scrobbles" 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