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

Commit a7cba945 authored by clint's avatar clint

whitespace

parent 8831ef79
......@@ -44,8 +44,7 @@ $smarty->assign('extra_head_links', array(
'href' => $base_url.'/rdf.php?fmt=xml&page='.urlencode(htmlentities(str_replace($base_url, '', $album->getURL())))
)
));
$smarty->display('album.tpl');
$smarty->display('album.tpl');
?>
......@@ -19,15 +19,15 @@
*/
class XML {
public static function prettyXML($xml) {
$dom = new DOMDocument('1.0');
$dom = new DOMDocument('1.0');
$dom->preserveWhitespace = false;
$dom->loadXML($xml->asXML());
$dom->formatOutput = true;
return($dom->saveXML());
}
}
public static function error($status, $errcode, $errtext) {
$xml = new SimpleXMLElement('<lfm></lfm>');
$xml->addAttribute('status', $status);
......
......@@ -28,7 +28,7 @@ require_once($install_path . '/utils/linkeddata.php');
/**
* Represents album data
*
* General album attributes are accessible as public variables.
* General album attributes are accessible as public variables.
* Lists of tracks are only generated when requested.
*/
class Album {
......@@ -153,7 +153,7 @@ function go_get_album_art($artist, $album){
$image = $aws_xml->Items->Item->MediumImage->URL;
$URI = $aws_xml->Items->Item->DetailPageURL;
if ($image) {
if ($license == '') { $license = 'amazon'; }
......@@ -166,7 +166,7 @@ function go_get_album_art($artist, $album){
$sql = ('UPDATE Album SET image = '
. ($image) . ', '
. ' artwork_license = '
. ($license) . ' WHERE artist_name = '. ($artist)
. ($license) . ' WHERE artist_name = '. ($artist)
. ' AND name = ' . ($album));
try {
......
......@@ -30,7 +30,7 @@ require_once($install_path . '/utils/linkeddata.php');
/**
* Represents artist data
*
* General artist attributes are accessible as public variables.
* General artist attributes are accessible as public variables.
* Lists of tracks and albums are only generated when requested.
*/
class Artist {
......@@ -82,7 +82,7 @@ class Artist {
foreach($res as &$row) {
$albums[] = new Album($row['name'], $this->name);
}
return $albums;
}
......
......@@ -52,11 +52,11 @@ class Group {
else {
global $mdb2;
$res = $mdb2->query('SELECT * FROM Groups WHERE lower(groupname) = ' . $mdb2->quote(strtolower($name), 'text'));
if(PEAR::isError($res)) {
header('Content-Type: text/plain');
////($res);
exit;
}
......@@ -64,7 +64,7 @@ class Group {
$row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
}
}
if (is_array($row)) {
$this->gid = $row['id'];
$this->name = $row['groupname'];
......@@ -77,9 +77,9 @@ class Group {
$this->users = array();
if (! preg_match('/\:/', $this->id))
$this->id = $base.'/group/' . rawurlencode($this->name) . '#group';
}
}
}
/**
* Selects a random nixtape group.
*
......@@ -89,7 +89,7 @@ class Group {
static function random ()
{
global $mdb2;
if ( strtolower(substr($mdb2->phptype, 0, 5)) == 'mysql' )
{
$random = 'RAND';
......@@ -141,7 +141,7 @@ class Group {
{
return (new PEAR_Error("Not allowed to create a group called '{$name}' (reserved word)!"));
}
// Check to make sure no existing group with same name (case-insensitive).
$q = sprintf('SELECT groupname FROM Groups WHERE LOWER(groupname)=LOWER(%s)'
, $mdb2->quote($name, 'text'));
......@@ -160,7 +160,7 @@ class Group {
"The name '{$name}' it too similar to existing group '{$existing}'"
));
}
// Create new group
$q = sprintf('INSERT INTO Groups (groupname, owner, created, modified) VALUES (%s, %s, %d, %d)'
, $mdb2->quote($name, 'text')
......@@ -200,7 +200,7 @@ class Group {
// Return the newly created group. Callers should check the return value.
return (new Group($name));
}
static function groupList ($user=false)
{
global $mdb2;
......@@ -223,7 +223,7 @@ class Group {
.'LEFT JOIN Group_Members gm ON gm.grp=g.id '
.'GROUP BY g.groupname, g.owner, g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri, g.grouptype');
}
if(PEAR::isError($res))
{
header('Content-Type: text/plain');
......@@ -241,11 +241,11 @@ class Group {
return $list;
}
function save ()
{
global $mdb2;
$q = sprintf('UPDATE Groups SET '
. 'owner=%s, '
. 'fullname=%s, '
......@@ -261,9 +261,9 @@ class Group {
, $mdb2->quote($this->avatar_uri, 'text')
, time()
, $mdb2->quote($this->name, 'text'));
$res = $mdb2->query($q);
if(PEAR::isError($res)) {
header('Content-Type: text/plain');
////($res);
......@@ -289,7 +289,7 @@ class Group {
function getURL() {
return Server::getGroupURL($this->name);
}
function getURLAction ($action) {
$url = $this->getURL();
if (strstr($url, '?'))
......@@ -297,7 +297,7 @@ class Group {
else
return $url . '?action=' . rawurlencode($action);
}
function getUsers () {
global $mdb2;
......@@ -315,7 +315,7 @@ class Group {
$this->users[ $row['username'] ] = new User($row['username'], $row);
}
}
$this->count = count($this->users);
}
......@@ -328,22 +328,22 @@ class Group {
return true;
return false;
}
function memberJoin ($user) {
if ($this->memberCheck($user))
return false;
global $mdb2;
$res = $mdb2->query(sprintf('INSERT INTO Group_Members (grp, member, joined) VALUES (%s, %s, %d)',
$mdb2->quote($this->gid, 'integer'),
$mdb2->quote($user->name, 'text'),
time()));
if(PEAR::isError($res))
{
return false;
}
$this->users[ $user->name ] = $user;
return true;
}
......@@ -351,19 +351,19 @@ class Group {
function memberLeave ($user) {
if (!$this->memberCheck($user))
return false;
// Group owner cannot leave, so we need a way to reassign ownership.
if ($this->owner->name == $user->name)
return false;
global $mdb2;
$res = $mdb2->query(sprintf('DELETE FROM Group_Members WHERE grp=%s AND member=%s',
$mdb2->quote($this->gid, 'integer'),
$mdb2->quote($user->uniqueid, 'integer')));
if(PEAR::isError($res))
return false;
$this->users[ $user->name ] = null;
// The array key still exists though. That's annoying. PHP needs an equivalent of Perl's 'delete'.
// This shouldn't actually cause us any problems, but people should be aware of the oddness.
......
......@@ -27,8 +27,8 @@ require_once($install_path . '/data/User.php');
require_once($install_path . '/data/sanitize.php');
require_once($install_path . '/utils/linkeddata.php');
require_once($install_path . '/utils/arc/ARC2.php');
require_once($install_path . '/utils/resolve-external.php');
require_once($install_path . '/utils/licenses.php');
require_once($install_path . '/utils/resolve-external.php');
require_once($install_path . '/utils/licenses.php');
/**
* Provides access to server-wide data
......@@ -51,18 +51,18 @@ class Server {
if($username) {
$res = $adodb->CacheGetAll(60,
'SELECT
s.username,
s.artist,
s.track,
s.album,
s.time,
s.mbid,
s.username,
s.artist,
s.track,
s.album,
s.time,
s.mbid,
a.mbid AS artist_mbid,
l.mbid AS album_mbid,
l.image AS album_image,
l.artwork_license,
t.license
FROM Scrobbles s
FROM Scrobbles s
LEFT JOIN Artist a
ON s.artist=a.name
LEFT JOIN Album l
......@@ -72,15 +72,15 @@ class Server {
ON s.stid = st.id
LEFT JOIN Track t
ON st.track = t.id
WHERE lower(s.username) = ' . $adodb->qstr(strtolower($username)) . '
WHERE lower(s.username) = ' . $adodb->qstr(strtolower($username)) . '
ORDER BY
s.time DESC
s.time DESC
LIMIT ' . (int)($number));
} else {
$res = $adodb->CacheGetAll(60,
'SELECT
s.username,
s.artist,
s.artist,
s.track,
s.album,
s.time,
......@@ -101,7 +101,7 @@ class Server {
LEFT JOIN Track t
ON st.track = t.id
ORDER BY
s.time DESC
s.time DESC
LIMIT ' . (int)($number));
}
}
......@@ -111,7 +111,7 @@ class Server {
foreach($res as &$i) {
$row = sanitize($i);
$row['userurl'] = Server::getUserURL($row['username']);
if ($row['album']) {
$row['albumurl'] = Server::getAlbumURL($row['artist'], $row['album']);
......@@ -121,7 +121,7 @@ class Server {
$row['timehuman'] = human_timestamp($row['time']);
$row['timeiso'] = date('c', (int)$row['time']);
$row['id'] = identifierScrobbleEvent($row['username'], $row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], $row['album_mbid']);
$row['id_artist'] = identifierArtist($row['username'], $row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], $row['album_mbid']);
$row['id_track'] = identifierTrack($row['username'], $row['artist'], $row['track'], $row['album'], $row['time'], $row['mbid'], $row['artist_mbid'], $row['album_mbid']);
......@@ -139,7 +139,7 @@ class Server {
$row['licenseurl'] = $row['license'];
$row['license'] = simplify_license($row['licenseurl']);
$result[] = $row;
}
......@@ -232,7 +232,7 @@ class Server {
ORDER BY t.streamable DESC, n.expires DESC LIMIT ' . (int)($number));
}
}
catch (exception $e) {
catch (exception $e) {
return false;
}
......@@ -250,13 +250,13 @@ class Server {
$row['userurl'] = Server::getUserURL($row['username']);
$row['artisturl'] = Server::getArtistURL($row['artist']);
$row['trackurl'] = Server::getTrackURL($row['artist'], $row['album'], $row['track']);
// We really want to get an image URI from the database and only fall back to qm50.png if we can't find an image.
$row['albumart'] = $base_url . 'themes/' . $default_theme . '/images/qm50.png';
$row['licenseurl'] = $row['license'];
$row['license'] = simplify_license($row['licenseurl']);
$result[] = $row;
}
......@@ -333,7 +333,7 @@ class Server {
static function getLocationDetails($name) {
global $adodb;
if (!$name)
return array();
......@@ -342,15 +342,15 @@ class Server {
. 'FROM Places p '
. 'LEFT JOIN Countries c ON p.country=c.country '
. 'WHERE p.location_uri=' . $adodb->qstr($name, 'text'));
if($rv) {
if (! ($rv['latitude'] && $rv['longitude'] && $rv['country'])) {
$parser = ARC2::getRDFXMLParser();
$parser->parse($name);
$index = $parser->getSimpleIndex();
$rv = array(
'latitude' => $index[$name]['http://www.w3.org/2003/01/geo/wgs84_pos#lat'][0],
'longitude' => $index[$name]['http://www.w3.org/2003/01/geo/wgs84_pos#long'][0],
......@@ -368,7 +368,7 @@ class Server {
$parser = ARC2::getRDFXMLParser();
$parser->parse($name);
$index = $parser->getSimpleIndex();
$rv = array(
'latitude' => $index[$name]['http://www.w3.org/2003/01/geo/wgs84_pos#lat'][0],
'longitude' => $index[$name]['http://www.w3.org/2003/01/geo/wgs84_pos#long'][0],
......@@ -381,7 +381,7 @@ class Server {
(float)$rv['longitude'],
$adodb->qstr($rv['country'])));
}
return $rv;
}
......
......@@ -35,7 +35,7 @@ class Statistic {
*/
static function generatePlayStats($table, $field, $limit = 40, $constraint = null, $maxwidth = 100 ) {
global $mdb2;
if (!is_string($field)) return false;
if (!is_string($field)) return false;
if (!is_string($table)) return false;
if (!is_integer($limit)) return false;
$query = 'SELECT ' . $field . ', count(*) AS count FROM ' . $table;
......@@ -50,7 +50,7 @@ class Statistic {
if (PEAR::isError($res)) {
echo('ERROR' . $res->getMessage());
}
if (!$res->numRows()) {
return false;
} else {
......@@ -61,24 +61,24 @@ class Statistic {
$i['pageurl'] = Server::getArtistURL($i['artist']);
$i['size'] = $i['count'] / $max * $maxwidth;
}
return $data;
}
}
static function generatePlayByDays($table, $limit = 100, $constraint = null, $maxwidth = 100 ) {
global $mdb2;
global $connect_string;
if (!is_string($table)) return false;
if (!is_integer($limit)) return false;
/*
* todo: completly remove this dirty db type check.
* todo: completly remove this dirty db type check.
*/
$query = 'SELECT COUNT(*) as count, DATE(TO_TIMESTAMP(time)) as date FROM ' . $table;
if( strpos($connect_string , 'mysql' ) === 0 ) $query = 'SELECT COUNT(*) as count,DATE(FROM_UNIXTIME(time)) as date FROM ' . $table;
$query .= (!is_null($constraint)) ? ' WHERE ' : null;
$query .= (!is_null($constraint)) ? ' username = ' . $mdb2->quote($constraint, 'text') : null;
$query .= ' GROUP BY date ORDER BY date DESC LIMIT ' . $limit;
......@@ -86,9 +86,9 @@ class Statistic {
if (PEAR::isError($res)) {
echo('ERROR' . $res->getMessage());
}
if (!$res->numRows()) {
return false;
return false;
} else {
$data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
......@@ -97,7 +97,7 @@ class Statistic {
foreach($data as &$i){
if( $i['count'] > $max ) $max = $i['count'];
}
foreach($data as &$i){
$i['size'] = $i['count'] / $max * $maxwidth;
}
......
......@@ -23,7 +23,7 @@ require_once($install_path . '/data/Server.php');
require_once($install_path . '/config.php'); // Should already be required though.
class TagCloud {
/*
* returns an array counting appareances of a given field and his corresponding font-size.
* @param string $table table name to be queried
......@@ -36,7 +36,7 @@ class TagCloud {
*/
static function generateTagCloud($table, $field, $limit = 40, $constraint = null, $constrained_field = false) {
global $adodb;
if (!is_string($field)) return false;
if (!is_string($field)) return false;
if (!is_string($table)) return false;
if (!is_integer($limit)) return false;
$sizes = array('xx-large', 'x-large', 'large', 'medium', 'small', 'x-small', 'xx-small');
......@@ -65,7 +65,7 @@ class TagCloud {
return $res;
}
}
/**
* Returns the preferred table to generate scrobble data from.
*
......@@ -77,17 +77,17 @@ class TagCloud {
{
// This array can be set up in config.php
global $scrobblecloud_table;
if (!empty($scrobblecloud_table[$area]))
{
return $scrobblecloud_table[$area];
}
if ($area == 'main')
{
return 'Free_Scrobbles';
}
return 'Scrobbles';
}
}
......
......@@ -31,7 +31,7 @@ require_once($install_path . '/utils/linkeddata.php');
/**
* Represents track data
*
* All track attributes are accessible as public variables.
* All track attributes are accessible as public variables.
*/
class Track {
......@@ -66,7 +66,7 @@ class Track {
$this->licenseurl = $row['license'];
$this->downloadurl = resolve_external_url($row['downloadurl']);
$this->streamurl = resolve_external_url($row['streamurl']);
$this->id = identifierTrack(null, $this->artist_name, $this->name, $this->album_name, null, $this->mbid, null, null);
}
......
......@@ -78,15 +78,15 @@ class User {
$this->created = $row['created'];
$this->modified = $row['modified'];
$this->uniqueid = $row['uniqueid'];
$this->has_identica = preg_match('#^http://identi\.ca/#i', $this->laconica_profile);
if (! preg_match('/\:/', $this->id))
$this->id = $this->getURL() . '#me';
}
}
}
public static function new_from_uniqueid_number ($uid)
{
global $adodb;
......@@ -100,17 +100,17 @@ class User {
return false;
}
}
function save ()
{
global $adodb;
// It appears we just discard this data, but this is here for a reason!
// getLocationDetails will fill in latitude,longitude details into the Places table in the database
// if it's not already there. This is important as the location_uri field is a foreign key.
if (!empty($this->location_uri))
$dummy = Server::getLocationDetails($this->location_uri);
$q = sprintf('UPDATE Users SET '
. 'email=%s, ' # Send a confirmation email first??
. 'password=%s, '
......@@ -140,9 +140,9 @@ class User {
, $adodb->qstr($this->journal_rss)
, time()
, $adodb->qstr($this->name));
$res = $adodb->Execute($q);
if(PEAR::isError($res)) {
header('Content-Type: text/plain');
//($res);
......@@ -173,7 +173,7 @@ class User {
function getAvatar($size=64) {
if (!empty($this->avatar_uri))
return $this->avatar_uri;
return 'http://www.gravatar.com/avatar/' . md5($this->email) . '?s=' . $size . '&d=monsterid';
}
......
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