From ea679f5dcfa94d0b620480c3658982ed100a24c2 Mon Sep 17 00:00:00 2001
From: "maul.esel"
Date: Tue, 19 Feb 2013 16:03:12 +0100
Subject: [PATCH 1/3] change default config URL
---
config/constants.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/constants.php b/config/constants.php
index 8ae8d13..67e846e 100644
--- a/config/constants.php
+++ b/config/constants.php
@@ -9,7 +9,7 @@
define('ROOT_URL', (IS_HTTPS ? "https" : "http") . "://"
. $_SERVER["SERVER_NAME"]
. REL_ADDRESS);
- define('SECURE_ROOT_URL', IS_SECURE ? ROOT_URL : "https://ahk4.net/user/maulesel/");
+ define('SECURE_ROOT_URL', IS_SECURE ? ROOT_URL : "https://libba.net/");
define('API_URL', ROOT_URL . "api");
define('SECURE_API_URL', SECURE_ROOT_URL . "api");
From bd2540b6d0fbab401c52d9a9c5d73092c55c4183 Mon Sep 17 00:00:00 2001
From: "maul.esel"
Date: Tue, 19 Feb 2013 16:18:52 +0100
Subject: [PATCH 2/3] Use SQL table name constants
Remove usages of duplicate variables,
use the existing constants instead.
---
candidate.php | 18 +++++++++---------
create-account.php | 4 ++--
internal/mailimage.php | 2 +-
review.php | 4 ++--
users/activity.php | 12 ++++++------
users/modify.php | 16 ++++++++--------
users/profile.php | 2 +-
util/db.php | 5 -----
8 files changed, 29 insertions(+), 34 deletions(-)
diff --git a/candidate.php b/candidate.php
index 77664fc..c12f5b2 100644
--- a/candidate.php
+++ b/candidate.php
@@ -37,7 +37,7 @@
$vote = (int)(mysql_real_escape_string($_POST["vote"]));
if (in_array($vote, array(-1, 0, 1)))
{
- $db_query = "SELECT COUNT(*) FROM $db_table_candidate_comments WHERE id = '$id' AND vote != '0' AND user = UNHEX('{$_SESSION["userID"]}')";
+ $db_query = "SELECT COUNT(*) FROM " . DB_TABLE_CANDIDATE_COMMENTS . " WHERE id = '$id' AND vote != '0' AND user = UNHEX('{$_SESSION["userID"]}')";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -54,7 +54,7 @@
$vote = 0;
}
- $db_query = "INSERT INTO $db_table_candidate_comments (id, user, comment, vote) VALUES ($id, UNHEX('{$_SESSION["userID"]}'), '" . mysql_real_escape_string($_POST["newcomment"]) . "', '" . $vote . "')";
+ $db_query = "INSERT INTO " . DB_TABLE_CANDIDATE_COMMENTS . " (id, user, comment, vote) VALUES ($id, UNHEX('{$_SESSION["userID"]}'), '" . mysql_real_escape_string($_POST["newcomment"]) . "', '" . $vote . "')";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -67,7 +67,7 @@
{
if ($can_close)
{
- $db_query = "UPDATE $db_table_candidates Set closed = '1', closed-by = UNHEX('{$_SESSION["userID"]}'), closed-date = NOW(), closed-comment = '" . mysql_real_escape_string($_POST["closecomment"]) . "' WHERE id = '$id'";
+ $db_query = "UPDATE " . DB_TABLE_CANDIDATES . " Set closed = '1', closed-by = UNHEX('{$_SESSION["userID"]}'), closed-date = NOW(), closed-comment = '" . mysql_real_escape_string($_POST["closecomment"]) . "' WHERE id = '$id'";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -83,7 +83,7 @@
header("Location: " . $_SERVER["REQUEST_URI"]); # reload to clear POST data and avoid repost of comment
}
- $db_query = "SELECT *, HEX(libid), HEX(userid), HEX(`closed-by`) FROM $db_table_candidates WHERE id = '$id'";
+ $db_query = "SELECT *, HEX(libid), HEX(userid), HEX(`closed-by`) FROM " . DB_TABLE_CANDIDATES . " WHERE id = '$id'";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -122,7 +122,7 @@
}
$comments = array();
- $db_query = "SELECT *, HEX(user) FROM $db_table_candidate_comments WHERE id = '$id'";
+ $db_query = "SELECT *, HEX(user) FROM " . DB_TABLE_CANDIDATE_COMMENTS . " WHERE id = '$id'";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -139,7 +139,7 @@
$comments[] = $comment;
}
- $db_query = "SELECT COUNT(*) FROM $db_table_candidate_comments WHERE id = '$id' AND vote > '0'"; # get upvote count
+ $db_query = "SELECT COUNT(*) FROM " . DB_TABLE_CANDIDATE_COMMENTS . " WHERE id = '$id' AND vote > '0'"; # get upvote count
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -149,7 +149,7 @@
}
$up_vote_count = mysql_fetch_object($db_result)->{'COUNT(*)'};
- $db_query = "SELECT COUNT(*) FROM $db_table_candidate_comments WHERE id = '$id' AND vote < '0'"; # get downvote count
+ $db_query = "SELECT COUNT(*) FROM " . DB_TABLE_CANDIDATE_COMMENTS . " WHERE id = '$id' AND vote < '0'"; # get downvote count
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -163,7 +163,7 @@
if ($logged_in)
{
- $db_query = "SELECT COUNT(*) FROM $db_table_candidate_comments WHERE id = '$id' AND vote != '0' AND user = UNHEX('{$_SESSION["userID"]}')";
+ $db_query = "SELECT COUNT(*) FROM " . DB_TABLE_CANDIDATE_COMMENTS . " WHERE id = '$id' AND vote != '0' AND user = UNHEX('{$_SESSION["userID"]}')";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -194,7 +194,7 @@
}
}
- $db_query = "SELECT id, HEX(libid), HEX(userid), date, closed FROM $db_table_candidates WHERE $db_cond";
+ $db_query = "SELECT id, HEX(libid), HEX(userid), date, closed FROM " . DB_TABLE_CANDIDATES . " WHERE $db_cond";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
diff --git a/create-account.php b/create-account.php
index 0740d1b..000945c 100644
--- a/create-account.php
+++ b/create-account.php
@@ -15,7 +15,7 @@
$db_connection = db_ensure_connection();
# check if account exists
- $db_query = "SELECT * FROM $db_table_user_profile WHERE mail = '$mail' OR id = UNHEX('$id')";
+ $db_query = "SELECT * FROM " . DB_TABLE_USER_PROFILE . " WHERE mail = '$mail' OR id = UNHEX('$id')";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -45,7 +45,7 @@
$id = mysql_real_escape_string($_POST["id"]);
$mail = mysql_real_escape_string($_POST["mail"]);
- $db_query = "INSERT INTO $db_table_user_profile (id, mail) VALUES (UNHEX('$id'), '$mail')";
+ $db_query = "INSERT INTO " . DB_TABLE_USER_PROFILE . " (id, mail) VALUES (UNHEX('$id'), '$mail')";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
diff --git a/internal/mailimage.php b/internal/mailimage.php
index 42e2a67..5bc82bf 100644
--- a/internal/mailimage.php
+++ b/internal/mailimage.php
@@ -4,7 +4,7 @@
require_once("../util/db.php");
$db_connection = db_ensure_connection();
- $db_query = "SELECT mail, show_mail FROM $db_table_user_profile WHERE id = UNHEX('" . mysql_real_escape_string($_GET["user"]) . "')";
+ $db_query = "SELECT mail, show_mail FROM " . DB_TABLE_USER_PROFILE . " WHERE id = UNHEX('" . mysql_real_escape_string($_GET["user"]) . "')";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_connection)
diff --git a/review.php b/review.php
index 9926adf..213ab73 100644
--- a/review.php
+++ b/review.php
@@ -25,7 +25,7 @@
{
if ($logged_in)
{
- $db_query = "INSERT INTO $db_table_review_comments (id, user, comment) VALUES (UNHEX('$id'), UNHEX('{$_SESSION["userID"]}'), '" . mysql_real_escape_string($_POST["newcomment"]) . "')";
+ $db_query = "INSERT INTO " . DB_TABLE_REVIEW_COMMENTS . " (id, user, comment) VALUES (UNHEX('$id'), UNHEX('{$_SESSION["userID"]}'), '" . mysql_real_escape_string($_POST["newcomment"]) . "')";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -53,7 +53,7 @@
}
}
- $db_query = "SELECT HEX(user), comment, date FROM $db_table_review_comments WHERE id = UNHEX('$id')";
+ $db_query = "SELECT HEX(user), comment, date FROM " . DB_TABLE_REVIEW_COMMENTS . " WHERE id = UNHEX('$id')";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
diff --git a/users/activity.php b/users/activity.php
index 67f3149..51e9e7d 100644
--- a/users/activity.php
+++ b/users/activity.php
@@ -73,7 +73,7 @@
}
# get review comments
- $db_query = "SELECT HEX(id), comment, date FROM $db_table_review_comments WHERE user = UNHEX('{$user_data["id"]}') ORDER BY date DESC $db_limit";
+ $db_query = "SELECT HEX(id), comment, date FROM " . DB_TABLE_REVIEW_COMMENTS . " WHERE user = UNHEX('{$user_data["id"]}') ORDER BY date DESC $db_limit";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -103,7 +103,7 @@
$retrieved_candidates = array();
# get candidates opened and closed
- $db_query = "SELECT *, HEX(libid), HEX(userid), HEX(`closed-by`) FROM $db_table_candidates WHERE userid = UNHEX('{$user_data["id"]}') ORDER BY date DESC $db_limit";
+ $db_query = "SELECT *, HEX(libid), HEX(userid), HEX(`closed-by`) FROM " . DB_TABLE_CANDIDATES . " WHERE userid = UNHEX('{$user_data["id"]}') ORDER BY date DESC $db_limit";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -140,7 +140,7 @@
if (hasPrivilege($user_data["privileges"], PRIVILEGE_STDLIB))
{
# get candidates closed by this user
- $db_query = "SELECT *, HEX(libid), HEX(userid), HEX(`closed-by`) FROM $db_table_candidates WHERE `closed-by` = UNHEX('{$user_data["id"]}') ORDER BY date DESC $db_limit";
+ $db_query = "SELECT *, HEX(libid), HEX(userid), HEX(`closed-by`) FROM " . DB_TABLE_CANDIDATES . " WHERE `closed-by` = UNHEX('{$user_data["id"]}') ORDER BY date DESC $db_limit";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -156,7 +156,7 @@
}
# get candidate comments
- $db_query = "SELECT id, comment, date, vote FROM $db_table_candidate_comments WHERE user = UNHEX('{$user_data["id"]}') ORDER BY date DESC $db_limit";
+ $db_query = "SELECT id, comment, date, vote FROM " . DB_TABLE_CANDIDATE_COMMENTS . " WHERE user = UNHEX('{$user_data["id"]}') ORDER BY date DESC $db_limit";
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
@@ -255,8 +255,8 @@
\ No newline at end of file
From 36267556a70deb2a15e619197536fbdb140d0d68 Mon Sep 17 00:00:00 2001
From: "maul.esel"
Date: Thu, 21 Feb 2013 21:26:00 +0100
Subject: [PATCH 3/3] Use single quotes wherever possible
---
about.php | 6 +-
candidate.php | 184 ++++++++++++++++++------------------
config/constants.php | 16 ++--
create-account.php | 34 +++----
help.php | 6 +-
index.php | 8 +-
internal/mailimage.php | 18 ++--
items/compare.php | 10 +-
items/list.php | 66 ++++++-------
items/view.php | 46 ++++-----
login.php | 54 +++++------
partials/header.php | 4 +-
register.php | 72 +++++++-------
review.php | 66 ++++++-------
sitemap.php | 80 ++++++++--------
upload.php | 42 ++++-----
users/achievements.php | 46 ++++-----
users/activity.php | 192 +++++++++++++++++++-------------------
users/items.php | 50 +++++-----
users/list.php | 40 ++++----
users/modify.php | 144 ++++++++++++++--------------
users/profile.php | 52 +++++------
users/user_navigation.php | 24 ++---
util/ALD.php | 56 +++++------
util/db.php | 4 +-
util/rewriter.php | 4 +-
util/secure_redirect.php | 4 +-
util/sortArray.php | 2 +-
util/subfolder.php | 8 +-
util/user_input.php | 8 +-
30 files changed, 673 insertions(+), 673 deletions(-)
diff --git a/about.php b/about.php
index 295609d..c5ebdc8 100644
--- a/about.php
+++ b/about.php
@@ -1,11 +1,11 @@
-
+
About
@@ -34,6 +34,6 @@
-
+
\ No newline at end of file
diff --git a/candidate.php b/candidate.php
index c12f5b2..d731791 100644
--- a/candidate.php
+++ b/candidate.php
@@ -2,12 +2,12 @@
ob_start();
session_start();
- require_once("util/user_input.php");
- require_once("util/db.php");
- require_once("util/ALD.php");
+ require_once('util/user_input.php');
+ require_once('util/db.php');
+ require_once('util/ALD.php');
- require_once("config/constants.php");
- require_once("util/privilege.php");
+ require_once('config/constants.php');
+ require_once('util/privilege.php');
require_once('modules/semver/semver.php');
require_once('util/get_privilege_symbols.php');
@@ -21,28 +21,28 @@
$error = true; # assume error here, reset on success
$page_title = 'ERROR';
- if (isset($_GET["id"]))
+ if (isset($_GET['id']))
{
- $id = mysql_real_escape_string($_GET["id"], $db_connection);
- $logged_in = isset($_SESSION["userID"]);
- $can_close = $logged_in && hasPrivilege($_SESSION["privileges"], PRIVILEGE_STDLIB);
+ $id = mysql_real_escape_string($_GET['id'], $db_connection);
+ $logged_in = isset($_SESSION['userID']);
+ $can_close = $logged_in && hasPrivilege($_SESSION['privileges'], PRIVILEGE_STDLIB);
$diff = false;
if (!empty($_POST) && $logged_in)
{
- if (isset($_POST["newcomment"]))
+ if (isset($_POST['newcomment']))
{
- if (isset($_POST["vote"]))
+ if (isset($_POST['vote']))
{
- $vote = (int)(mysql_real_escape_string($_POST["vote"]));
+ $vote = (int)(mysql_real_escape_string($_POST['vote']));
if (in_array($vote, array(-1, 0, 1)))
{
- $db_query = "SELECT COUNT(*) FROM " . DB_TABLE_CANDIDATE_COMMENTS . " WHERE id = '$id' AND vote != '0' AND user = UNHEX('{$_SESSION["userID"]}')";
+ $db_query = 'SELECT COUNT(*) FROM ' . DB_TABLE_CANDIDATE_COMMENTS . ' WHERE id = "' . $id . '" AND vote != "0" AND user = UNHEX("' . $_SESSION['userID'] . '")';
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
- $error_message = "Failed to get previous votes: MySQL error";
- $error_description = "Could not check if current user has already voted. MySQL error was: '" . mysql_error() . "'";
+ $error_message = 'Failed to get previous votes: MySQL error';
+ $error_description = 'Could not check if current user has already voted. MySQL error was: "' . mysql_error() . '"';
break;
}
$can_vote = mysql_fetch_object($db_result)->{'COUNT(*)'} == 0; # set to false if there's already a comment by the current user with a vote
@@ -54,60 +54,60 @@
$vote = 0;
}
- $db_query = "INSERT INTO " . DB_TABLE_CANDIDATE_COMMENTS . " (id, user, comment, vote) VALUES ($id, UNHEX('{$_SESSION["userID"]}'), '" . mysql_real_escape_string($_POST["newcomment"]) . "', '" . $vote . "')";
+ $db_query = 'INSERT INTO ' . DB_TABLE_CANDIDATE_COMMENTS . ' (id, user, comment, vote) VALUES (' . $id . ', UNHEX("' . $_SESSION['userID'] . '"), "' . mysql_real_escape_string($_POST['newcomment']) . '", "' . $vote . '")';
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
- $error_message = "Failed to save comment: MySQL error";
- $error_description = "Could not save your last comment on this thread. MySQL error was: '" . mysql_error() . "'";
+ $error_message = 'Failed to save comment: MySQL error';
+ $error_description = 'Could not save your last comment on this thread. MySQL error was: "' . mysql_error() . '"';
break;
}
}
- else if (isset($_POST["accept"]) || isset($_POST["reject"]))
+ else if (isset($_POST['accept']) || isset($_POST['reject']))
{
if ($can_close)
{
- $db_query = "UPDATE " . DB_TABLE_CANDIDATES . " Set closed = '1', closed-by = UNHEX('{$_SESSION["userID"]}'), closed-date = NOW(), closed-comment = '" . mysql_real_escape_string($_POST["closecomment"]) . "' WHERE id = '$id'";
+ $db_query = 'UPDATE ' . DB_TABLE_CANDIDATES . ' Set closed = "1", closed-by = UNHEX("' . $_SESSION['userID'] . '"), closed-date = NOW(), closed-comment = "' . mysql_real_escape_string($_POST['closecomment']) . '" WHERE id = "' . $id . '"';
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
- $error_message = "Failed to close this thread: MySQL error";
- $error_description = "Could not close the thread. MySQL error was: '" . mysql_error() . "'";
+ $error_message = 'Failed to close this thread: MySQL error';
+ $error_description = 'Could not close the thread. MySQL error was: "' . mysql_error() . '"';
break;
}
- $db_query = "UPDATE $db_table_main Set default_include = '1' WHERE id = UNHEX('')"; # todo
+ $db_query = 'UPDATE $db_table_main Set default_include = "1" WHERE id = UNHEX("")'; # todo
# TODO
}
}
- header("Location: " . $_SERVER["REQUEST_URI"]); # reload to clear POST data and avoid repost of comment
+ header('Location: ' . $_SERVER['REQUEST_URI']); # reload to clear POST data and avoid repost of comment
}
- $db_query = "SELECT *, HEX(libid), HEX(userid), HEX(`closed-by`) FROM " . DB_TABLE_CANDIDATES . " WHERE id = '$id'";
+ $db_query = 'SELECT *, HEX(libid), HEX(userid), HEX(`closed-by`) FROM ' . DB_TABLE_CANDIDATES . ' WHERE id = "' . $id . '"';
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
- $error_message = "Failed to retrieve thread: MySQL error";
- $error_description = "Could not retrieve data on this thread. MySQL error was: '" . mysql_error() . "'";
+ $error_message = 'Failed to retrieve thread: MySQL error';
+ $error_description = 'Could not retrieve data on this thread. MySQL error was: "' . mysql_error() . '"';
break;
}
if (mysql_num_rows($db_result) != 1)
{
- $error_message = "Failed to retrieve thread: not found";
- $error_description = "Could not find this thread. Most likely, the URL is incorrect.";
+ $error_message = 'Failed to retrieve thread: not found';
+ $error_description = 'Could not find this thread. Most likely, the URL is incorrect.';
break;
}
$candidate = mysql_fetch_assoc($db_result);
- $lib = $api->getItemById($candidate["HEX(libid)"]);
- $candidate["libname"] = $lib["name"];
- $candidate["libversion"] = $lib["version"];
- $temp = $api->getUserById($candidate["HEX(userid)"]);
- $candidate["username"] = $temp["name"];
- if ($candidate["closed"])
+ $lib = $api->getItemById($candidate['HEX(libid)']);
+ $candidate['libname'] = $lib['name'];
+ $candidate['libversion'] = $lib['version'];
+ $temp = $api->getUserById($candidate['HEX(userid)']);
+ $candidate['username'] = $temp['name'];
+ if ($candidate['closed'])
{
- $temp = $api->getUserById($candidate["HEX(`closed-by`)"]);
- $candidate["closed-by"] = $temp["name"];
+ $temp = $api->getUserById($candidate['HEX(`closed-by`)']);
+ $candidate['closed-by'] = $temp['name'];
}
else
{
@@ -116,45 +116,45 @@
if (count($list) > 0)
{
$diff = true;
- usort($list, "semver_sort"); # sort by version numbers (descending)
+ usort($list, 'semver_sort'); # sort by version numbers (descending)
$diff_base = $list[0]['version'];
}
}
$comments = array();
- $db_query = "SELECT *, HEX(user) FROM " . DB_TABLE_CANDIDATE_COMMENTS . " WHERE id = '$id'";
+ $db_query = 'SELECT *, HEX(user) FROM ' . DB_TABLE_CANDIDATE_COMMENTS . ' WHERE id = "' . $id . '"';
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
- $error_message = "Failed to retrieve comments: MySQL error";
- $error_description = "Could not read the comments on this thread. MySQL error was: '" . mysql_error() . "'";
+ $error_message = 'Failed to retrieve comments: MySQL error';
+ $error_description = 'Could not read the comments on this thread. MySQL error was: "' . mysql_error() . '"';
break;
}
while ($comment = mysql_fetch_assoc($db_result))
{
- $temp = $api->getUserById($comment["HEX(user)"]);
- $comment["user"] = $temp["name"];
- $comment["user-mail"] = $temp["mail-md5"];
+ $temp = $api->getUserById($comment['HEX(user)']);
+ $comment['user'] = $temp['name'];
+ $comment['user-mail'] = $temp['mail-md5'];
$comment['user-privilege'] = $temp['privileges'];
$comments[] = $comment;
}
- $db_query = "SELECT COUNT(*) FROM " . DB_TABLE_CANDIDATE_COMMENTS . " WHERE id = '$id' AND vote > '0'"; # get upvote count
+ $db_query = 'SELECT COUNT(*) FROM ' . DB_TABLE_CANDIDATE_COMMENTS . ' WHERE id = "' . $id . '" AND vote > 0'; # get upvote count
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
- $error_message = "Failed to retrieve upvote count: MySQL error";
- $error_description = "The number of upvotes could not be read. MySQL error was: '" . mysql_error() . "'";
+ $error_message = 'Failed to retrieve upvote count: MySQL error';
+ $error_description = 'The number of upvotes could not be read. MySQL error was: "' . mysql_error() . '"';
break;
}
$up_vote_count = mysql_fetch_object($db_result)->{'COUNT(*)'};
- $db_query = "SELECT COUNT(*) FROM " . DB_TABLE_CANDIDATE_COMMENTS . " WHERE id = '$id' AND vote < '0'"; # get downvote count
+ $db_query = 'SELECT COUNT(*) FROM ' . DB_TABLE_CANDIDATE_COMMENTS . ' WHERE id = "' . $id . '" AND vote < 0'; # get downvote count
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
- $error_message = "Failed to retrieve downvote count: MySQL error";
- $error_description = "The number of downvotes could not be read. MySQL error was: '" . mysql_error() . "'";
+ $error_message = 'Failed to retrieve downvote count: MySQL error';
+ $error_description = 'The number of downvotes could not be read. MySQL error was: "' . mysql_error() . '"';
break;
}
$down_vote_count = mysql_fetch_object($db_result)->{'COUNT(*)'};
@@ -163,55 +163,55 @@
if ($logged_in)
{
- $db_query = "SELECT COUNT(*) FROM " . DB_TABLE_CANDIDATE_COMMENTS . " WHERE id = '$id' AND vote != '0' AND user = UNHEX('{$_SESSION["userID"]}')";
+ $db_query = 'SELECT COUNT(*) FROM ' . DB_TABLE_CANDIDATE_COMMENTS . ' WHERE id = "' . $id . '" AND vote != 0 AND user = UNHEX("' . $_SESSION['userID'] . '")';
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
- $error_message = "Failed to get previous votes: MySQL error";
- $error_description = "Could not check if current user has already voted. MySQL error was: '" . mysql_error() . "'";
+ $error_message = 'Failed to get previous votes: MySQL error';
+ $error_description = 'Could not check if current user has already voted. MySQL error was: "' . mysql_error() . '"';
break;
}
$can_vote = mysql_fetch_object($db_result)->{'COUNT(*)'} == 0; # set to false if there's already a comment by the current user with a vote
}
- $page_title = ($candidate["closed"] ? "closed: " : "") . $candidate["libname"] . " v" . $candidate["libversion"] . " | Candidate for stdlib";
+ $page_title = ($candidate['closed'] ? 'closed: ' : '') . $candidate['libname'] . ' v' . $candidate['libversion'] . ' | Candidate for stdlib';
}
else
{
- $page_title = "Candidates for the standard library";
+ $page_title = 'Candidates for the standard library';
- $db_cond = "closed != '1'";
- if (isset($_GET["mode"]))
+ $db_cond = 'closed != 1';
+ if (isset($_GET['mode']))
{
- if (strtolower($_GET["mode"]) == "closed")
+ if (strtolower($_GET['mode']) == 'closed')
{
- $db_cond = "closed = '1'";
- $page_title .= " (closed)";
+ $db_cond = 'closed = 1';
+ $page_title .= ' (closed)';
}
- else if (strtolower($_GET["mode"]) == "all")
+ else if (strtolower($_GET['mode']) == 'all')
{
- $db_cond = "'1' = '1'";
+ $db_cond = '1 = 1';
}
}
- $db_query = "SELECT id, HEX(libid), HEX(userid), date, closed FROM " . DB_TABLE_CANDIDATES . " WHERE $db_cond";
+ $db_query = 'SELECT id, HEX(libid), HEX(userid), date, closed FROM ' . DB_TABLE_CANDIDATES . ' WHERE ' . $db_cond;
$db_result = mysql_query($db_query, $db_connection);
if (!$db_result)
{
- $error_message = "Failed to retrieve list of candidates: MySQL error";
- $error_description = "The list of candidates could not be read. MySQL error was: '" . mysql_error() . "'";
+ $error_message = 'Failed to retrieve list of candidates: MySQL error';
+ $error_description = 'The list of candidates could not be read. MySQL error was: "' . mysql_error() . '"';
break;
}
$candidates = array();
while ($candidate = mysql_fetch_assoc($db_result))
{
- $lib = $api->getItemById($candidate["HEX(libid)"]);
- $candidate["lib-name"] = $lib["name"];
- $candidate["lib-version"] = $lib["version"];
+ $lib = $api->getItemById($candidate['HEX(libid)']);
+ $candidate['lib-name'] = $lib['name'];
+ $candidate['lib-version'] = $lib['version'];
- $temp = $api->getUserById($candidate["HEX(userid)"]);
- $candidate["user"] = $temp["name"];
+ $temp = $api->getUserById($candidate['HEX(userid)']);
+ $candidate['user'] = $temp['name'];
$candidates[] = $candidate;
}
@@ -222,7 +222,7 @@
-
+
@@ -249,15 +249,15 @@
Library:
- "> (v)
+ (v)
User:
- /profile">
+
Applied:
-
+
@@ -266,11 +266,11 @@
-
+
- +
-
0 ? "+" : "-") . $total_vote_count; ?> votes
+ +
-
0 ? '+' : '-') . $total_vote_count; ?> votes
Comments