[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Librefm-commits] [1467] Start updating the code to reflect the string q
From: |
Michael Sheldon |
Subject: |
[Librefm-commits] [1467] Start updating the code to reflect the string quoting guidelines in the coding standards (plus offers very minor speed improvements) |
Date: |
Sun, 10 May 2009 14:09:53 +0000 |
Revision: 1467
http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1467
Author: elleo
Date: 2009-05-10 14:09:53 +0000 (Sun, 10 May 2009)
Log Message:
-----------
Start updating the code to reflect the string quoting guidelines in the coding
standards (plus offers very minor speed improvements)
Modified Paths:
--------------
trunk/nixtape/data/Album.php
trunk/nixtape/data/Artist.php
trunk/nixtape/data/Group.php
trunk/nixtape/data/Server.php
trunk/nixtape/data/Statistic.php
trunk/nixtape/data/TagCloud.php
trunk/nixtape/data/Track.php
trunk/nixtape/data/User.php
Modified: trunk/nixtape/data/Album.php
===================================================================
--- trunk/nixtape/data/Album.php 2009-05-10 13:32:00 UTC (rev 1466)
+++ trunk/nixtape/data/Album.php 2009-05-10 14:09:53 UTC (rev 1467)
@@ -60,12 +60,12 @@
$this->id = identifierAlbum(null, $this->artist_name,
null, $this->name, null, null, null, $this->mbid);
// this hack brought to you by mattl
- //if ($row['image'] == ""){
+ //if ($row['image'] == ''){
//go_get_album_art($this->artist_name, $this->name);
//}
// mattl hack ovar
- if($this->image == "") {
+ if($this->image == '') {
$this->image = false;
}
}
@@ -74,7 +74,7 @@
function getPlayCount() {
global $mdb2;
- $res = $mdb2->query("SELECT COUNT(*) AS scrobbles FROM
Scrobbles JOIN Track ON Scrobbles.track = Track.name WHERE Scrobbles.artist = "
+ $res = $mdb2->query('SELECT COUNT(*) AS scrobbles FROM
Scrobbles JOIN Track ON Scrobbles.track = Track.name WHERE Scrobbles.artist = '
. $mdb2->quote($this->artist_name, 'text') . ' AND
Track.album_name ='
. $mdb2->quote($this->name, 'text'));
if(PEAR::isError($res)) {
@@ -122,48 +122,48 @@
function go_get_album_art($artist, $album){
global $mdb2;
- $Access_Key_ID = "1EST86JB355JBS3DFE82"; // this is mattl's personal
key :)
+ $Access_Key_ID = '1EST86JB355JBS3DFE82'; // this is mattl's personal
key :)
$SearchIndex='Music';
$Keywords=urlencode($artist.' '.$album);
- $Operation = "ItemSearch";
- $Version = "2007-07-16";
- $ResponseGroup = "ItemAttributes,Images";
+ $Operation = 'ItemSearch';
+ $Version = '2007-07-16';
+ $ResponseGroup = 'ItemAttributes,Images';
$request=
- "http://ecs.amazonaws.com/onca/xml"
- . "?Service=AWSECommerceService"
- . "&AssociateTag=" . $Associate_tag
- . "&AWSAccessKeyId=" . $Access_Key_ID
- . "&Operation=" . $Operation
- . "&Version=" . $Version
- . "&SearchIndex=" . $SearchIndex
- . "&Keywords=" . $Keywords
- . "&ResponseGroup=" . $ResponseGroup;
+ 'http://ecs.amazonaws.com/onca/xml'
+ . '?Service=AWSECommerceService'
+ . '&AssociateTag=' . $Associate_tag
+ . '&AWSAccessKeyId=' . $Access_Key_ID
+ . '&Operation=' . $Operation
+ . '&Version=' . $Version
+ . '&SearchIndex=' . $SearchIndex
+ . '&Keywords=' . $Keywords
+ . '&ResponseGroup=' . $ResponseGroup;
- $aws_xml = simplexml_load_file($request) or die("xml response not
loading");
+ $aws_xml = simplexml_load_file($request) or die('xml response not
loading');
$image = $aws_xml->Items->Item->MediumImage->URL;
$URI = $aws_xml->Items->Item->DetailPageURL;
if ($image) {
- if ($license == "") { $license = "amazon"; }
+ if ($license == '') { $license = 'amazon'; }
$license = $mdb2->quote($license);
$image = $mdb2->quote($image);
$album = $mdb2->quote($album);
$artist = $mdb2->quote($artist);
- $sql = ("UPDATE Album SET image = "
- . ($image) . ", "
- . " artwork_license = "
- . ($license) . " WHERE artist_name = ". ($artist)
- . " AND name = " . ($album));
+ $sql = ('UPDATE Album SET image = '
+ . ($image) . ', '
+ . ' artwork_license = '
+ . ($license) . ' WHERE artist_name = '. ($artist)
+ . ' AND name = ' . ($album));
$res = $mdb2->query($sql);
if(PEAR::isError($res)) {
- die("FAILED " . $res->getMessage() . " query was :" .
$sql);
+ die('FAILED ' . $res->getMessage() . ' query was :' .
$sql);
}
}
Modified: trunk/nixtape/data/Artist.php
===================================================================
--- trunk/nixtape/data/Artist.php 2009-05-10 13:32:00 UTC (rev 1466)
+++ trunk/nixtape/data/Artist.php 2009-05-10 14:09:53 UTC (rev 1467)
@@ -21,10 +21,10 @@
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");
+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');
require_once($install_path . '/utils/linkeddata.php');
/**
@@ -48,22 +48,22 @@
function __construct($name, $mbid=false) {
global $mdb2;
- $res = $mdb2->query("SELECT name, mbid, streamable,
bio_published, bio_content, bio_summary, image_small, image_medium, image_large
FROM Artist WHERE "
- . "mbid = " . $mdb2->quote($mbid, "text") . " OR "
- . "name = " . $mdb2->quote($name, "text"));
+ $res = $mdb2->query('SELECT name, mbid, streamable,
bio_published, bio_content, bio_summary, image_small, image_medium, image_large
FROM Artist WHERE '
+ . 'mbid = ' . $mdb2->quote($mbid, 'text') . ' OR '
+ . 'name = ' . $mdb2->quote($name, 'text'));
if(!$res->numRows()) {
- return(new PEAR_Error("No such artist: " . $name));
+ return(new PEAR_Error('No such artist: ' . $name));
} else {
$row = sanitize($res->fetchRow(MDB2_FETCHMODE_ASSOC));
- $this->name = $row["name"];
- $this->mbid = $row["mbid"];
- $this->streamable = $row["streamable"];
- $this->bio_published = $row["bio_published"];
- $this->bio_content = $row["bio_content"];
- $this->bio_summary = $row["bio_summary"];
- $this->image_small = $row["image_small"];
- $this->image_medium = $row["image_medium"];
- $this->image_large = $row["image_large"];
+ $this->name = $row['name'];
+ $this->mbid = $row['mbid'];
+ $this->streamable = $row['streamable'];
+ $this->bio_published = $row['bio_published'];
+ $this->bio_content = $row['bio_content'];
+ $this->bio_summary = $row['bio_summary'];
+ $this->image_small = $row['image_small'];
+ $this->image_medium = $row['image_medium'];
+ $this->image_large = $row['image_large'];
$this->id = identifierArtist(null, $this->name, null,
null, null, null, $this->mbid, null);
}
@@ -76,10 +76,10 @@
*/
function getAlbums() {
global $mdb2;
- $res = $mdb2->query("SELECT name, image FROM Album WHERE
artist_name = "
- . $mdb2->quote($this->name, "text"));
+ $res = $mdb2->query('SELECT name, image FROM Album WHERE
artist_name = '
+ . $mdb2->quote($this->name, 'text'));
while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
- $albums[] = new Album($row["name"], $this->name);
+ $albums[] = new Album($row['name'], $this->name);
}
return $albums;
@@ -92,10 +92,10 @@
*/
function getTracks() {
global $mdb2;
- $res = $mdb2->query("SELECT name FROM Track WHERE artist_name =
"
- . $mdb2->quote($this->name, "text"));
+ $res = $mdb2->query('SELECT name FROM Track WHERE artist_name =
'
+ . $mdb2->quote($this->name, 'text'));
while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
- $tracks[] = new Track($row["name"], $this->name);
+ $tracks[] = new Track($row['name'], $this->name);
}
return $tracks;
@@ -109,13 +109,13 @@
*/
function getTopTracks($number) {
global $mdb2;
- $res = $mdb2->query("SELECT track, COUNT(track) AS freq,
COUNT(DISTINCT username) AS listeners FROM Scrobbles WHERE"
- . " artist = " . $mdb2->quote($this->name, 'text')
- . " GROUP BY track ORDER BY freq DESC LIMIT " .
$mdb2->quote($number, "integer"));
+ $res = $mdb2->query('SELECT track, COUNT(track) AS freq,
COUNT(DISTINCT username) AS listeners FROM Scrobbles WHERE'
+ . ' artist = ' . $mdb2->quote($this->name, 'text')
+ . ' GROUP BY track ORDER BY freq DESC LIMIT ' .
$mdb2->quote($number, 'integer'));
while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
- $track = new Track($row["track"], $this->name);
- $track->setPlayCount($row["freq"]);
- $track->setListenerCount($row["listeners"]);
+ $track = new Track($row['track'], $this->name);
+ $track->setPlayCount($row['freq']);
+ $track->setListenerCount($row['listeners']);
$tracks[] = $track;
}
@@ -128,12 +128,7 @@
* @return A string containing the URL of this artist
*/
function getURL() {
- global $friendly_urls, $base_url;
- if($friendly_urls) {
- return $base_url . "/artist/" .
rawurlencode(stripslashes($this->name));
- } else {
- return $base_url . "/artist.php?artist=" .
rawurlencode(stripslashes($this->name));
- }
+ Server::getArtistURL($this->name);
}
}
Modified: trunk/nixtape/data/Group.php
===================================================================
--- trunk/nixtape/data/Group.php 2009-05-10 13:32:00 UTC (rev 1466)
+++ trunk/nixtape/data/Group.php 2009-05-10 14:09:53 UTC (rev 1467)
@@ -54,7 +54,7 @@
$res = $mdb2->query('SELECT * FROM Groups WHERE
lower(groupname) = ' . $mdb2->quote(strtolower($name), 'text'));
if(PEAR::isError($res)) {
- header("Content-Type: text/plain");
+ header('Content-Type: text/plain');
////($res);
exit;
@@ -71,7 +71,7 @@
$this->fullname = $row['fullname'];
$this->homepage = $row['homepage'];
$this->bio = $row['bio'];
- $this->avatar_uri = $row["avatar_uri"];
+ $this->avatar_uri = $row['avatar_uri'];
$this->owner =
User::new_from_uniqueid_number($row['owner']);
$this->count = -1;
$this->users = array();
@@ -139,7 +139,7 @@
if (in_array(strtolower($name), array('new', 'search')))
{
- return (new PEAR_Error("Not allowed to create a group
called '$name' (reserved word)!"));
+ 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).
@@ -156,8 +156,8 @@
$existing = $row['groupname'];
return (new PEAR_Error(
($existing == $name) ?
- "There is already a group called
'$existing'." :
- "The name '$name' it too similar to
existing group '$existing'"
+ "There is already a group called
'{$existing}'." :
+ "The name '{$name}' it too similar to
existing group '{$existing}'"
));
}
@@ -182,7 +182,7 @@
}
elseif (!$res->numRows())
{
- return (new PEAR_Error("Something has gone horribly,
horribly wrong!"));
+ return (new PEAR_Error('Something has gone horribly,
horribly wrong!'));
}
$grp = $res->fetchOne(0);
@@ -207,26 +207,26 @@
if ($user)
{
- $res = $mdb2->query("SELECT gc.* FROM "
- . "Group_Members m "
- ."INNER JOIN (SELECT g.id, g.groupname,
g.owner, g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri,
g.grouptype, COUNT(*) AS member_count "
- ."FROM Groups g "
- ."LEFT JOIN Group_Members gm ON gm.grp=g.id "
- ."GROUP BY g.id, g.groupname, g.owner,
g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri,
g.grouptype) gc "
- ."ON m.grp=gc.id "
- ."WHERE
m.member=".$mdb2->quote($user->uniqueid, 'integer'));
+ $res = $mdb2->query('SELECT gc.* FROM '
+ .'Group_Members m '
+ .'INNER JOIN (SELECT g.id, g.groupname,
g.owner, g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri,
g.grouptype, COUNT(*) AS member_count '
+ .'FROM Groups g '
+ .'LEFT JOIN Group_Members gm ON gm.grp=g.id '
+ .'GROUP BY g.id, g.groupname, g.owner,
g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri,
g.grouptype) gc '
+ .'ON m.grp=gc.id '
+ .'WHERE
m.member='.$mdb2->quote($user->uniqueid, 'integer'));
}
else
{
- $res = $mdb2->query("SELECT g.groupname, g.owner,
g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri,
g.grouptype, COUNT(*) AS member_count "
- ."FROM Groups g "
- ."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");
+ $res = $mdb2->query('SELECT g.groupname, g.owner,
g.fullname, g.bio, g.homepage, g.created, g.modified, g.avatar_uri,
g.grouptype, COUNT(*) AS member_count '
+ .'FROM Groups g '
+ .'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");
+ header('Content-Type: text/plain');
////($res);
exit;
}
@@ -246,14 +246,14 @@
{
global $mdb2;
- $q = sprintf("UPDATE Groups SET "
- . "owner=%s, "
- . "fullname=%s, "
- . "homepage=%s, "
- . "bio=%s, "
- . "avatar_uri=%s, "
- . "modified=%d "
- . "WHERE groupname=%s"
+ $q = sprintf('UPDATE Groups SET '
+ . 'owner=%s, '
+ . 'fullname=%s, '
+ . 'homepage=%s, '
+ . 'bio=%s, '
+ . 'avatar_uri=%s, '
+ . 'modified=%d '
+ . 'WHERE groupname=%s'
, $mdb2->quote($this->owner->uniqueid,
'integer')
, $mdb2->quote($this->fullname, 'text')
, $mdb2->quote($this->homepage, 'text')
@@ -265,7 +265,7 @@
$res = $mdb2->query($q);
if(PEAR::isError($res)) {
- header("Content-Type: text/plain");
+ header('Content-Type: text/plain');
////($res);
exit;
}
@@ -283,7 +283,7 @@
global $base_uri;
if (!empty($this->avatar_uri))
return $this->avatar_uri;
- return $base_uri . "themes/" . $default_theme .
"/images/qm50.png";
+ return $base_uri . 'themes/' . $default_theme .
'/images/qm50.png';
}
function getURL() {
@@ -303,11 +303,11 @@
if (!isset($this->users[0]))
{
- $res = $mdb2->query("SELECT u.* "
- . "FROM Users u "
- . "INNER JOIN Group_Members gm ON
u.uniqueid=gm.member "
- . "WHERE
gm.grp=".$mdb2->quote($this->gid,'integer')
- . " ORDER BY gm.joined");
+ $res = $mdb2->query('SELECT u.* '
+ . 'FROM Users u '
+ . 'INNER JOIN Group_Members gm ON
u.uniqueid=gm.member '
+ . 'WHERE
gm.grp='.$mdb2->quote($this->gid,'integer')
+ . ' ORDER BY gm.joined');
if ($res->numRows())
{
while ($row =
$res->fetchRow(MDB2_FETCHMODE_ASSOC))
@@ -334,7 +334,7 @@
return false;
global $mdb2;
- $res = $mdb2->query(sprintf("INSERT INTO Group_Members (grp,
member, joined) VALUES (%s, %s, %d)",
+ $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()));
@@ -357,7 +357,7 @@
return false;
global $mdb2;
- $res = $mdb2->query(sprintf("DELETE FROM Group_Members WHERE
grp=%s AND member=%s",
+ $res = $mdb2->query(sprintf('DELETE FROM Group_Members WHERE
grp=%s AND member=%s',
$mdb2->quote($this->gid, 'integer'),
$mdb2->quote($user->uniqueid, 'integer')));
Modified: trunk/nixtape/data/Server.php
===================================================================
--- trunk/nixtape/data/Server.php 2009-05-10 13:32:00 UTC (rev 1466)
+++ trunk/nixtape/data/Server.php 2009-05-10 14:09:53 UTC (rev 1467)
@@ -24,10 +24,10 @@
// require_once($install_path . '/data/Group.php');
require_once($install_path . '/data/Track.php');
require_once($install_path . '/data/User.php');
-require_once($install_path . "/data/sanitize.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 . "/resolve-external.php"); // why isn't this in a
subdir?
+require_once($install_path . '/resolve-external.php'); // why isn't this in a
subdir?
require_once($install_path . '/licenses.php'); // why isn't this in a subdir?
/**
@@ -48,7 +48,7 @@
if($username) {
$res = $mdb2->query(
- "SELECT
+ 'SELECT
s.username,
s.artist,
s.track,
@@ -70,13 +70,13 @@
ON s.stid = st.id
LEFT JOIN Track t
ON st.track = t.id
- WHERE lower(s.username) = " .
$mdb2->quote(strtolower($username), "text") . '
+ WHERE lower(s.username) = ' .
$mdb2->quote(strtolower($username), 'text') . '
ORDER BY
s.time DESC
- LIMIT ' . $mdb2->quote($number, "integer"));
+ LIMIT ' . $mdb2->quote($number, 'integer'));
} else {
$res = $mdb2->query(
- "SELECT
+ 'SELECT
s.username,
s.artist,
s.track,
@@ -100,7 +100,7 @@
ON st.track = t.id
ORDER BY
s.time DESC
- LIMIT " . $mdb2->quote($number, "integer"));
+ LIMIT ' . $mdb2->quote($number, 'integer'));
}
if(PEAR::isError($res)) {
@@ -111,14 +111,15 @@
foreach($data as $i) {
$row = sanitize($i);
- $row["userurl"] = Server::getUserURL($row["username"]);
- if ($row['album'])
- $row["albumurl"] =
Server::getAlbumURL($row["artist"], $row["album"]);
- $row["artisturl"] =
Server::getArtistURL($row["artist"]);
- $row["trackurl"] = Server::getTrackURL($row['artist'],
$row['album'], $row['track']);
+ $row['userurl'] = Server::getUserURL($row['username']);
+ if ($row['album']) {
+ $row['albumurl'] =
Server::getAlbumURL($row['artist'], $row['album']);
+ }
+ $row['artisturl'] =
Server::getArtistURL($row['artist']);
+ $row['trackurl'] = Server::getTrackURL($row['artist'],
$row['album'], $row['track']);
$row['timehuman'] = human_timestamp($row['time']);
- $row["timeiso"] = date('c', (int)$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']);
@@ -131,12 +132,12 @@
$row['album_image'] =
resolve_external_url($row['album_image']);
}
- if ($row['artwork_license'] == "amazon") {
- $row['album_image'] =
str_replace("SL160","SL50",$row['album_image']);
+ if ($row['artwork_license'] == 'amazon') {
+ $row['album_image'] =
str_replace('SL160','SL50',$row['album_image']);
}
- $row["licenseurl"] = $row["license"];
- $row["license"] = simplify_license($row["licenseurl"]);
+ $row['licenseurl'] = $row['license'];
+ $row['license'] = simplify_license($row['licenseurl']);
$result[] = $row;
}
@@ -153,7 +154,7 @@
static function getTopArtists($number=20) {
global $mdb2;
- $res = $mdb2->query("SELECT COUNT(artist) as c, artist FROM
Scrobbles GROUP BY artist ORDER BY c DESC LIMIT 20");
+ $res = $mdb2->query('SELECT COUNT(artist) as c, artist FROM
Scrobbles GROUP BY artist ORDER BY c DESC LIMIT 20');
if(PEAR::isError($res)) {
return $res;
@@ -162,7 +163,7 @@
$data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
foreach($data as $i) {
$row = sanitize($i);
- $row["artisturl"] =
Server::getArtistURL($row["artist"]);
+ $row['artisturl'] =
Server::getArtistURL($row['artist']);
$result[] = $row;
}
@@ -179,7 +180,7 @@
global $mdb2;
if($username) {
- $res = $mdb2->query("SELECT
+ $res = $mdb2->query('SELECT
username,
n.artist,
n.track,
@@ -200,10 +201,10 @@
AND lower(n.album) =
lower(t.album_name)
AND lower(n.track) =
lower(t.name)
AND lower(n.mbid) =
lower(t.mbid)
- WHERE lower(username) = " .
$mdb2->quote(strtolower($username), "text") . "
- ORDER BY t.streamable DESC, n.expires
DESC LIMIT " . $mdb2->quote($number, "integer"));
+ WHERE lower(username) = ' .
$mdb2->quote(strtolower($username), 'text') . '
+ ORDER BY t.streamable DESC, n.expires
DESC LIMIT ' . $mdb2->quote($number, 'integer'));
} else {
- $res = $mdb2->query("SELECT
+ $res = $mdb2->query('SELECT
username,
n.artist,
n.track,
@@ -224,7 +225,7 @@
AND lower(n.album) =
lower(t.album_name)
AND lower(n.track) =
lower(t.name)
AND lower(n.mbid) =
lower(t.mbid)
- ORDER BY t.streamable DESC, n.expires
DESC LIMIT " . $mdb2->quote($number, "integer"));
+ ORDER BY t.streamable DESC, n.expires
DESC LIMIT ' . $mdb2->quote($number, 'integer'));
}
if(PEAR::isError($res)) {
@@ -235,23 +236,23 @@
foreach($data as &$i) {
$row = sanitize($i);
// this logic should be cleaned up and the free/nonfree
decision be moved into the smarty templates
- if($row["name"] == "") {
- $clientstr =
strip_tags(stripslashes($row["client"])) . " (unknown, <a
href=\"http://ideas.libre.fm/index.php/Client_Codes\">please tell us what this
is</a>)";
+ if($row['name'] == '') {
+ $clientstr =
strip_tags(stripslashes($row['client'])) . ' (unknown, <a
href=\"http://ideas.libre.fm/index.php/Client_Codes\">please tell us what this
is</a>)';
} elseif($row["free"] == "Y") {
- $clientstr = "<a href=\"" .
strip_tags(stripslashes($row["url"])) . "\">" .
strip_tags(stripslashes($row["name"])) . "</a>";
+ $clientstr = '<a href=\"' .
strip_tags(stripslashes($row['url'])) . '\">' .
strip_tags(stripslashes($row['name'])) . '</a>';
} else {
- $clientstr = "<a
href=\"http://en.wikipedia.org/wiki/Category:Free_media_players\">" .
strip_tags(stripslashes($row["name"])) . "</a>";
+ $clientstr = '<a
href=\"http://en.wikipedia.org/wiki/Category:Free_media_players\">' .
strip_tags(stripslashes($row['name'])) . '</a>';
}
- $row["clientstr"] = $clientstr;
- $row["userurl"] = Server::getUserURL($row["username"]);
- $row["artisturl"] =
Server::getArtistURL($row["artist"]);
- $row["trackurl"] = Server::getTrackURL($row['artist'],
$row['album'], $row['track']);
+ $row['clientstr'] = $clientstr;
+ $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"]);
+ $row['licenseurl'] = $row['license'];
+ $row['license'] = simplify_license($row['licenseurl']);
$result[] = $row;
}
@@ -271,9 +272,9 @@
global $friendly_urls, $base_url;
if ($component == 'edit')
{
- return $base_url . "/user-edit.php";
+ return $base_url . '/user-edit.php';
} elseif ($component == 'delete') {
- return $base_url . "/delete-profile.php";
+ return $base_url . '/delete-profile.php';
}
elseif($friendly_urls)
{
@@ -281,7 +282,7 @@
$component = '';
else
$component = "/{$component}";
- return $base_url . "/user/" . rawurlencode($username) .
$component;
+ return $base_url . '/user/' . rawurlencode($username) .
$component;
}
else
{
@@ -292,38 +293,38 @@
static function getGroupURL($groupname) {
global $friendly_urls, $base_url;
if($friendly_urls) {
- return $base_url . "/group/" . rawurlencode($groupname);
+ return $base_url . '/group/' . rawurlencode($groupname);
} else {
- return $base_url . "/group.php?group=" .
rawurlencode($groupname);
+ return $base_url . '/group.php?group=' .
rawurlencode($groupname);
}
}
static function getArtistURL($artist) {
global $friendly_urls, $base_url;
if($friendly_urls) {
- return $base_url . "/artist/" . rawurlencode($artist);
+ return $base_url . '/artist/' . rawurlencode($artist);
} else {
- return $base_url . "/artist.php?artist=" .
rawurlencode($artist);
+ return $base_url . '/artist.php?artist=' .
rawurlencode($artist);
}
}
static function getAlbumURL($artist, $album) {
global $friendly_urls, $base_url;
if($friendly_urls) {
- return $base_url . "/artist/" . rawurlencode($artist) .
"/album/" . rawurlencode($album);
+ return $base_url . '/artist/' . rawurlencode($artist) .
'/album/' . rawurlencode($album);
} else {
- return $base_url . "/album.php?artist=" .
rawurlencode($artist) . "&album=" . rawurlencode($album);
+ return $base_url . '/album.php?artist=' .
rawurlencode($artist) . '&album=' . rawurlencode($album);
}
}
static function getTrackURL($artist, $album, $track) {
global $friendly_urls, $base_url;
if ($friendly_urls && $album) {
- return $base_url . "/artist/" . rawurlencode($artist) .
"/album/" . rawurlencode($album) . "/track/" . rawurlencode($track);
+ return $base_url . '/artist/' . rawurlencode($artist) .
'/album/' . rawurlencode($album) . '/track/' . rawurlencode($track);
} elseif ($friendly_urls) {
- return $base_url . "/artist/" . rawurlencode($artist) .
"/track/" . rawurlencode($track);
+ return $base_url . '/artist/' . rawurlencode($artist) .
'/track/' . rawurlencode($track);
} else {
- return $base_url . "/track.php?artist=" .
rawurlencode($artist) . "&album=" . rawurlencode($album) . "&track=" .
rawurlencode($track);
+ return $base_url . '/track.php?artist=' .
rawurlencode($artist) . '&album=' . rawurlencode($album) . '&track=' .
rawurlencode($track);
}
}
@@ -393,16 +394,16 @@
global $mdb2;
$session_id = md5(mt_rand() . time());
if($username) {
- $sql = "INSERT INTO Radio_Sessions(username, session,
url, expires) VALUES ("
- . $mdb2->quote($username, "text") . ","
- . $mdb2->quote($session_id, "text") . ","
- . $mdb2->quote($station, "text") . ","
- . $mdb2->quote(time() + 86400) . ")";
+ $sql = 'INSERT INTO Radio_Sessions(username, session,
url, expires) VALUES ('
+ . $mdb2->quote($username, 'text') . ','
+ . $mdb2->quote($session_id, 'text') . ','
+ . $mdb2->quote($station, 'text') . ','
+ . $mdb2->quote(time() + 86400) . ')';
} else {
- $sql = "INSERT INTO Radio_Sessions(session, url,
expires) VALUES ("
- . $mdb2->quote($session_id, "text") . ","
- . $mdb2->quote($station, "text") . ","
- . $mdb2->quote(time() + 86400) . ")";
+ $sql = 'INSERT INTO Radio_Sessions(session, url,
expires) VALUES ('
+ . $mdb2->quote($session_id, 'text') . ','
+ . $mdb2->quote($station, 'text') . ','
+ . $mdb2->quote(time() + 86400) . ')';
}
$res = $mdb2->query($sql);
return $session_id;
Modified: trunk/nixtape/data/Statistic.php
===================================================================
--- trunk/nixtape/data/Statistic.php 2009-05-10 13:32:00 UTC (rev 1466)
+++ trunk/nixtape/data/Statistic.php 2009-05-10 14:09:53 UTC (rev 1467)
@@ -38,17 +38,17 @@
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";
+ $query = 'SELECT ' . $field . ', count(*) AS count FROM ' .
$table;
$query .= (!is_null($constraint)) ? ' WHERE ' : null;
- if ($field == "track") {
+ if ($field == 'track') {
$query .= (!is_null($constraint)) ? ' artist = ' .
$mdb2->quote($constraint, 'text') : null;
} else {
$query .= (!is_null($constraint)) ? ' username = ' .
$mdb2->quote($constraint, 'text') : null;
}
- $query .= " GROUP BY $field ORDER BY count DESC LIMIT $limit";
+ $query .= ' GROUP BY ' . $field . ' ORDER BY count DESC LIMIT '
. $limit;
$res = $mdb2->query($query);
if (PEAR::isError($res)) {
- echo("ERROR" . $res->getMessage());
+ echo('ERROR' . $res->getMessage());
}
if (!$res->numRows()) {
@@ -76,15 +76,15 @@
/*
* 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 = '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";
+ $query .= ' GROUP BY date ORDER BY date DESC LIMIT ' . $limit;
$res = $mdb2->query($query);
if (PEAR::isError($res)) {
- echo("ERROR" . $res->getMessage());
+ echo('ERROR' . $res->getMessage());
}
if (!$res->numRows()) {
Modified: trunk/nixtape/data/TagCloud.php
===================================================================
--- trunk/nixtape/data/TagCloud.php 2009-05-10 13:32:00 UTC (rev 1466)
+++ trunk/nixtape/data/TagCloud.php 2009-05-10 14:09:53 UTC (rev 1467)
@@ -40,20 +40,20 @@
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');
- $query = "SELECT $field, count(*) AS count FROM $table";
+ $query = 'SELECT ' . $field . ', count(*) AS count FROM ' .
$table;
$query .= (!is_null($constraint)) ? ' WHERE ' : null;
if ($constrained_field) {
- $query .= (!is_null($constraint)) ? "
$constrained_field = " . $adodb->qstr($constraint) : null;
- } elseif ($field == "track") {
+ $query .= (!is_null($constraint)) ? $constrained_field
. ' = ' . $adodb->qstr($constraint) : null;
+ } elseif ($field == 'track') {
$query .= (!is_null($constraint)) ? ' artist = ' .
$adodb->qstr($constraint) : null;
} else {
$query .= (!is_null($constraint)) ? ' username = ' .
$adodb->qstr($constraint) : null;
}
- $query .= " GROUP BY $field ORDER BY count DESC LIMIT $limit";
+ $query .= ' GROUP BY ' . $field . ' ORDER BY count DESC LIMIT '
. $limit;
$adodb->SetFetchMode(ADODB_FETCH_ASSOC);
$res = $adodb->CacheGetAll(7200,$query);
if (!$res) {
- echo("ERROR $query");
+ echo('ERROR $query');
} else {
foreach($res as $count => &$i) {
$i['size'] = $sizes[(int)
($count/(count($res)/7))];
Modified: trunk/nixtape/data/Track.php
===================================================================
--- trunk/nixtape/data/Track.php 2009-05-10 13:32:00 UTC (rev 1466)
+++ trunk/nixtape/data/Track.php 2009-05-10 14:09:53 UTC (rev 1467)
@@ -21,11 +21,11 @@
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");
-require_once($install_path . "/resolve-external.php");
-require_once($install_path . "/licenses.php");
+require_once($install_path . '/data/Artist.php');
+require_once($install_path . '/data/Album.php');
+require_once($install_path . '/data/Server.php');
+require_once($install_path . '/resolve-external.php');
+require_once($install_path . '/licenses.php');
require_once($install_path . '/utils/linkeddata.php');
/**
@@ -48,23 +48,23 @@
*/
function __construct($name, $artist) {
global $mdb2;
- $res = $mdb2->query("SELECT name, artist_name, album_name,
duration, streamable, license, downloadurl, streamurl, mbid FROM Track WHERE "
- . "name = " . $mdb2->quote($name, "text") . " AND "
- . "artist_name = " . $mdb2->quote($artist, "text"));
+ $res = $mdb2->query('SELECT name, artist_name, album_name,
duration, streamable, license, downloadurl, streamurl, mbid FROM Track WHERE '
+ . 'name = ' . $mdb2->quote($name, 'text') . ' AND '
+ . 'artist_name = ' . $mdb2->quote($artist, 'text'));
if(!$res->numRows()) {
- $this->name = "No such track: " . $name;
+ $this->name = 'No such track: ' . $name;
} else {
$row = sanitize($res->fetchRow(MDB2_FETCHMODE_ASSOC));
- $this->name = $row["name"];
- $this->mbid = $row["mbid"];
- $this->artist_name = $row["artist_name"];
- $this->album_name = $row["album_name"];
- $this->duration = $row["duration"];
- $this->streamable = $row["streamable"];
- $this->license = simplify_license($row["license"]);
- $this->licenseurl = $row["license"];
- $this->downloadurl =
resolve_external_url($row["downloadurl"]);
- $this->streamurl =
resolve_external_url($row["streamurl"]);
+ $this->name = $row['name'];
+ $this->mbid = $row['mbid'];
+ $this->artist_name = $row['artist_name'];
+ $this->album_name = $row['album_name'];
+ $this->duration = $row['duration'];
+ $this->streamable = $row['streamable'];
+ $this->license = simplify_license($row['license']);
+ $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);
}
@@ -120,10 +120,10 @@
private function _getPlayCountAndListenerCount() {
global $mdb2;
- $res = $mdb2->query("SELECT COUNT(track) AS freq,
COUNT(DISTINCT username) AS listeners FROM Scrobbles WHERE"
- . " artist = " . $mdb2->quote($this->artist_name,
'text')
- . " AND track = " . $mdb2->quote($this->name, "text")
- . " GROUP BY track ORDER BY freq DESC");
+ $res = $mdb2->query('SELECT COUNT(track) AS freq,
COUNT(DISTINCT username) AS listeners FROM Scrobbles WHERE'
+ . ' artist = ' . $mdb2->quote($this->artist_name,
'text')
+ . ' AND track = ' . $mdb2->quote($this->name, 'text')
+ . ' GROUP BY track ORDER BY freq DESC');
$row = $res->fetchRow(MDB2_FETCHMODE_ASSOC);
if (!isset($row)) {
Modified: trunk/nixtape/data/User.php
===================================================================
--- trunk/nixtape/data/User.php 2009-05-10 13:32:00 UTC (rev 1466)
+++ trunk/nixtape/data/User.php 2009-05-10 14:09:53 UTC (rev 1467)
@@ -67,15 +67,15 @@
$this->location = $row['location'];
$this->location_uri = $row['location_uri'];
$this->userlevel = $row['userlevel'];
- $this->id = $row["webid_uri"];
- $this->webid_uri = $row["webid_uri"];
- $this->avatar_uri = $row["avatar_uri"];
- $this->laconica_profile = $row["laconica_profile"];
- $this->journal_rss = $row["journal_rss"];
+ $this->id = $row['webid_uri'];
+ $this->webid_uri = $row['webid_uri'];
+ $this->avatar_uri = $row['avatar_uri'];
+ $this->laconica_profile = $row['laconica_profile'];
+ $this->journal_rss = $row['journal_rss'];
$this->acctid = $this->getURL() . '#acct';
- $this->created = $row["created"];
- $this->modified = $row["modified"];
- $this->uniqueid = $row["uniqueid"];
+ $this->created = $row['created'];
+ $this->modified = $row['modified'];
+ $this->uniqueid = $row['uniqueid'];
$this->has_identica =
preg_match('#^http://identi\.ca/#i', $this->laconica_profile);
@@ -105,21 +105,21 @@
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, "
- . "fullname=%s, "
- . "homepage=%s, "
- . "bio=%s, "
- . "location=%s, "
- . "userlevel=%d, "
- . "webid_uri=%s, "
- . "location_uri=%s, "
- . "avatar_uri=%s, "
- . "laconica_profile=%s, "
- . "journal_rss=%s, "
- . "modified=%d "
- . "WHERE username=%s"
+ $q = sprintf('UPDATE Users SET '
+ . 'email=%s, ' # Send a confirmation email
first??
+ . 'password=%s, '
+ . 'fullname=%s, '
+ . 'homepage=%s, '
+ . 'bio=%s, '
+ . 'location=%s, '
+ . 'userlevel=%d, '
+ . 'webid_uri=%s, '
+ . 'location_uri=%s, '
+ . 'avatar_uri=%s, '
+ . 'laconica_profile=%s, '
+ . 'journal_rss=%s, '
+ . 'modified=%d '
+ . 'WHERE username=%s'
, $mdb2->quote($this->email, 'text')
, $mdb2->quote($this->password, 'text')
, $mdb2->quote($this->fullname, 'text')
@@ -138,7 +138,7 @@
$res = $mdb2->query($q);
if(PEAR::isError($res)) {
- header("Content-Type: text/plain");
+ header('Content-Type: text/plain');
//($res);
exit;
}
@@ -168,7 +168,7 @@
if (!empty($this->avatar_uri))
return $this->avatar_uri;
- return "http://www.gravatar.com/avatar/" . md5($this->email) .
"?s=" . $size . "&d=monsterid";
+ return 'http://www.gravatar.com/avatar/' . md5($this->email) .
'?s=' . $size . '&d=monsterid';
}
function getURL($component='profile') {
@@ -192,11 +192,11 @@
function getScrobbleSession() {
global $mdb2;
$session_id = md5(mt_rand() . time());
- $sql = "INSERT INTO Scrobble_Sessions(username, sessionid,
client, expires) VALUES ("
- . $mdb2->quote($this->name, "text") . ","
- . $mdb2->quote($session_id, "text") . ","
- . "'lfm',"
- . $mdb2->quote(time() + 86400) . ")";
+ $sql = 'INSERT INTO Scrobble_Sessions(username, sessionid,
client, expires) VALUES ('
+ . $mdb2->quote($this->name, 'text') . ','
+ . $mdb2->quote($session_id, 'text') . ','
+ . '\'lfm\','
+ . $mdb2->quote(time() + 86400) . ')';
$mdb2->query($sql);
return $session_id;
}
@@ -219,7 +219,7 @@
function getTopTracks($number=20) {
global $mdb2;
- $res = $mdb2->query("SELECT COUNT(track) as c, artist, album,
track FROM Scrobbles WHERE username = ".$mdb2->quote($this->name,"text")."
GROUP BY artist,album,track ORDER BY c DESC LIMIT $number");
+ $res = $mdb2->query('SELECT COUNT(track) as c, artist, album,
track FROM Scrobbles WHERE username = '.$mdb2->quote($this->name,'text').'
GROUP BY artist,album,track ORDER BY c DESC LIMIT $number');
if(PEAR::isError($res)) {
return $res;
@@ -230,17 +230,17 @@
$data = $res->fetchAll(MDB2_FETCHMODE_ASSOC);
foreach($data as $i) {
$row = sanitize($i);
- $row["artisturl"] = Server::getArtistURL($row["artist"]);
- $row["trackurl"] =
Server::getTrackURL($row["artist"],$row["album"],$row["track"]);
- if ((int)$row["c"] > $maxcount) {
- $maxcount = (int)$row["c"];
+ $row['artisturl'] = Server::getArtistURL($row['artist']);
+ $row['trackurl'] =
Server::getTrackURL($row['artist'],$row['album'],$row['track']);
+ if ((int)$row['c'] > $maxcount) {
+ $maxcount = (int)$row['c'];
}
$result[] = $row;
}
if ($maxcount > 0) {
foreach($result as &$row) {
- $row["width"]=(int)(100 * ($row["c"]/$maxcount));
+ $row['width']=(int)(100 * ($row['c']/$maxcount));
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Librefm-commits] [1467] Start updating the code to reflect the string quoting guidelines in the coding standards (plus offers very minor speed improvements),
Michael Sheldon <=