Dodaj do Bazy:
ALTER TABLE comments ADD `anonymous` enum('yes','no') NOT NULL default 'no';
bittorrent.php
Znajdź:
function commenttable($rows)
{
global $CURUSER;
begin_main_frame();
begin_frame();
$count = 0;
foreach ($rows as $row)
{
print("<p class=sub>#" . $row["id"] . " by ");
if (isset($row["username"]))
{
$title = $row["title"];
if ($title == "")
$title = get_user_class_name($row["class"]);
else
$title = htmlspecialchars($title);
print("<a name=comm". $row["id"] .
" href=userdetails.php?id=" . $row["user"] . ">" .
htmlspecialchars($row["username"]) . "[/url]" . ($row["donor"] == "yes" ? "<img src=pic/star.gif alt='Donor'>" : "") . ($row["warned"] == "yes" ? "<img src=".
"/pic/warned.gif alt=\"Warned\">" : "") . " ($title)\n");
}
else
print("<a name=\"comm" . $row["id"] . "\">(orphaned)[/url]\n");
print(" at " . $row["added"] . " GMT" .
($row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=edit&cid=$row[id]>Edit[/url]]" : "") .
(get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=delete&cid=$row[id]>Delete[/url]]" : "") .
($row["editedby"] && get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=vieworiginal&cid=$row[id]>View original[/url]]" : "") . "</p>\n");
$avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($row["avatar"]) : "");
if (!$avatar)
$avatar = "/pic/default_avatar.gif";
$text = format_comment($row["text"]);
if ($row["editedby"])
$text .= "<p><font size=1 class=small>Last edited by <a href=userdetails.php?id=$row[editedby]>$row[username][/url] at $row[editedat] GMT</font></p>\n";
begin_table(true);
print("<tr valign=top>\n");
print("<td align=center width=150 style='padding: 0px'><img width=150 src=$avatar></td>\n");
print("<td class=text>$text</td>\n");
print("</tr>\n");
end_table();
}
end_frame();
end_main_frame();
zamień na:
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("<p class=sub>#" . $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 = "<font color=$color>$ratio</font>"; } else if ($rat["uploaded"] > 0) $ratio = "Inf."; else $ratio = "---"; print("<a name=comm". $row["id"] . " href=userdetails.php?id=" . $row["user"] . ">" . htmlspecialchars($row["username"]) . "[/url] " . $title . " " . ($row["donor"] == "yes" ? "<img src=pic/star.gif alt='Donor'>" : "") . ($row["warned"] == "yes" ? "<img src=". "/pic/warned.gif alt=\"Warned\">" : "") . " (Ratio: $ratio)\n"); } else if (!isset($row["username"])) { print("<a name=\"comm" . $row["id"] . "\">(samotny)[/url]\n"); } else if ($arraya['anonymous'] == 'yes') { print("<a name=\"comm" . $row["id"] . "\"><font color=blue>Anonimowy</font>[/url]\n"); } print(" at " . $row["added"] . " GMT" . ($row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=edit&cid=$row[id]>".Edytuj."[/url]] " : "") . (get_user_class() >= UC_USER ? "- [<a href=report.php?commentid=$row[id]>Report[/url]] " : "") . (get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=delete&cid=$row[id]>".Usuń."[/url]]" : "") . ($row["editedby"] && get_user_class() >= UC_MODERATOR ? " - [<a href=comment.php?action=vieworiginal&cid=$row[id]>".View_original."[/url]]" : "") . "</p>\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("<tr valign=top>\n"); print("<td align=center width=100 style='padding: 0px'><img width=100 src=$avatar></td>\n"); print("<td class=text>" . format_comment($row["text"]) . "</td>\n"); print("</tr>\n"); end_table(); } end_frame(); end_main_frame(); }
comments.php
Znajdź:
$res = mysql_query("SELECT name FROM torrents WHERE id = $torrentid") or sqlerr(__FILE__,__LINE__);
Zamień na:
$res = mysql_query("SELECT name, owner, anonymous FROM torrents WHERE id = $torrentid") or sqlerr(__FILE__,__LINE__);
Znajdź:
mysql_query("INSERT INTO comments (user, torrent, added, text, ori_text) VALUES (" .
$CURUSER["id"] . ",$torrentid, '" . get_date_time() . "', " . sqlesc($text) .
"," . sqlesc($text) . ")");
Zamień na:
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)");
Znajdź:
$res = mysql_query("SELECT comments.id, text, comments.added,
Po dodaj:
comments.anonymous,
details.php
Znajdź:
$subres = mysql_query("SELECT comments.id, text, user, comments.added,
Po dodaj:
comments.anonymous,