Rendevous |
4th May 2010 12:17 |
Anonymous Comments
bittorrent
find:
Code:
function commenttable($rows)
{
global $CURUSER;
begin_main_frame();
begin_frame();
$count = 0;
foreach ($rows as $row)
{
print("#" . $row["id"] . " by ");
if (isset($row["username"]))
{
$title = $row["title"];
if ($title == "")
$title = get_user_class_name($row["class"]);
else
$title = htmlspecialchars($title);
print("
" href=userdetails.php?id=" . $row["user"] . ">" .
htmlspecialchars($row["username"]) . "" . ($row["donor"] == "yes" ? "" : "") . ($row["warned"] == "yes" ? "" : "") . " ($title)\n");
}
else
print("(orphaned)\n");
print(" at " . $row["added"] . " GMT" .
($row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [Edit]" : "") .
(get_user_class() >= UC_MODERATOR ? "- [Delete]" : "") .
($row["editedby"] && get_user_class() >= UC_MODERATOR ? "- [View original]" : "") . " \n");
$avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($row["avatar"]) : "");
if (!$avatar)
$avatar = "/pic/default_avatar.gif";
$text = format_comment($row["text"]);
if ($row["editedby"])
$text .= "Last edited by $row[username] at $row[editedat] GMT \n";
begin_table(true);
print("\n");
print(" | \n");
print("$text | \n");
print(" \n");
end_table();
}
end_frame();
end_main_frame();
replace with:
Code:
function commenttable($rows) {
global $CURUSER, $HTTP_SERVER_VARS;
begin_main_frame();
begin_frame();
$count = 0;
foreach ($rows as $row)
{
$querie = mysql_query("SELECT anonymous FROM comments WHERE id = $row[id]");
$arraya = mysql_fetch_assoc($querie);
print("#" . $row["id"] . " by ");
$title = "(" . get_user_class_name($row["class"]) . ")";
$title = "";
if ($arraya['anonymous'] == 'no' && isset($row["username"]))
{
$username = $row["username"];
$ratres = mysql_query("SELECT uploaded, downloaded from users where username='$username'");
$rat = mysql_fetch_array($ratres);
if ($rat["downloaded"] > 0)
{
$ratio = $rat['uploaded'] / $rat['downloaded'];
$ratio = number_format($ratio, 3);
$color = get_ratio_color($ratio);
if ($color)
$ratio = "$ratio";
}
else
if ($rat["uploaded"] > 0)
$ratio = "Inf.";
else
$ratio = "---";
print("" . htmlspecialchars($row["username"]) . " " . $title . " " . ($row["donor"] == "yes" ? "" : "") . ($row["warned"] == "yes" ? "" : "") . " (Ratio: $ratio)\n");
}
else if (!isset($row["username"])) {
print("(orphaned)\n");
}
else if ($arraya['anonymous'] == 'yes') {
print("Anonymous\n");
}
print(" at " . $row["added"] . " GMT" .
($row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [".Edit."] " : "") .
(get_user_class() >= UC_USER ? "- [Report] " : "") .
(get_user_class() >= UC_MODERATOR ? "- [".Delete."]" : "") .
($row["editedby"] && get_user_class() >= UC_MODERATOR ? " - [".View_original."]" : "") . " \n");
$resa = mysql_query("SELECT owner, anonymous FROM torrents WHERE owner = $row[user]");
$array = mysql_fetch_assoc($resa);
if ($row['anonymous'] == 'yes' && $row['user'] == $array['owner']) {
$avatar = "/pic/default_avatar.gif";
}
else {
$avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($row["avatar"]) : "");
}
if (!$avatar)
$avatar = "/pic/default_avatar.gif";
begin_table(true);
print("\n");
print(" | \n");
print("" . format_comment($row["text"]) . " | \n");
print(" \n");
end_table();
}
end_frame();
end_main_frame();
}
Add this to sql:
Code:
ALTER TABLE comments ADD `anonymous` enum('yes','no') NOT NULL default 'no';
comments.php
find:
Code:
$res = mysql_query("SELECT name FROM torrents WHERE id = $torrentid") or sqlerr(__FILE__,__LINE__);
change too:
Code:
$res = mysql_query("SELECT name, owner, anonymous FROM torrents WHERE id = $torrentid") or sqlerr(__FILE__,__LINE__);
find:
Code:
mysql_query("INSERT INTO comments (user, torrent, added, text, ori_text) VALUES (" .
$CURUSER["id"] . ",$torrentid, '" . get_date_time() . "', " . sqlesc($text) .
"," . sqlesc($text) . ")");
replace with
Code:
if ($CURUSER['id'] == $arr['owner'] && $arr['anonymous'] == 'yes') {
$anon = "'yes'";
}
else {
$anon = "'no'";
}
mysql_query("INSERT INTO comments (user, torrent, added, text, ori_text, anonymous) VALUES (" .
$CURUSER["id"] . ",$torrentid, '" . get_date_time() . "', " . sqlesc($text) .
"," . sqlesc($text) . ", $anon)");
find:
Code:
$res = mysql_query("SELECT comments.id, text, comments.added,
after add:
Code:
comments.anonymous,
details.php
find:
Code:
$subres = mysql_query("SELECT comments.id, text, user, comments.added,
after add:
Code:
comments.anonymous,
Thanks to Wilba from Tbdev:drink:
|