aurweb/web/html/voters.php
Lukas Fleischer 323d418f02 Wrap mysql_real_escape_string() in a function
Wrap mysql_real_escape_string() in a wrapper function db_escape_string()
to ease porting to other databases, and as another step to pulling more
of the database code into a central location.

This is a rebased version of a patch by elij submitted about half a year
ago.

Thanks-to: elij <elij.mx@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2011-10-24 17:57:54 +02:00

40 lines
1,003 B
PHP

<?php
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
include('aur.inc.php');
include('pkgfuncs.inc.php');
function getvotes($pkgid) {
$dbh = db_connect();
$pkgid = db_escape_string($pkgid);
$result = db_query("SELECT UsersID,Username FROM PackageVotes LEFT JOIN Users on (UsersID = ID) WHERE PackageID = $pkgid ORDER BY Username", $dbh);
return $result;
}
$SID = $_COOKIE['AURSID'];
$pkgid = intval($_GET['ID']);
$votes = getvotes($pkgid);
$account = account_from_sid($SID);
if ($account == 'Trusted User' || $account == 'Developer') {
?>
<html>
<body>
<h3><?php echo account_from_sid($SID) ?></h3>
<h2>Votes for <a href="packages.php?ID=<?php echo $pkgid ?>"><?php echo pkgname_from_id($pkgid) ?></a></h2>
<?php
while ($row = mysql_fetch_assoc($votes)) {
$uid = $row['UsersID'];
$username = $row['Username'];
?>
<a href="account.php?Action=AccountInfo&amp;ID=<?php echo $uid ?>">
<?php echo htmlspecialchars($username) ?></a><br />
<?php
}
?>
</body>
</html>
<?php
}