View Single Post
  #1  
Old 4th May 2010, 12:17
Rendevous Rendevous is offline
Senior Member
 
Join Date: Nov 2009
Romania
Posts: 43
Default Anonymous Comments
bittorrent

find:

Code:
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"] . "><b>" .
        	htmlspecialchars($row["username"]) . "</b></a>" . ($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"] . "\"><i>(orphaned)</i></a>\n");

		print(" at " . $row["added"] . " GMT" .
			($row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=edit&amp;cid=$row[id]>Edit</a>]" : "") .
			(get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=delete&amp;cid=$row[id]>Delete</a>]" : "") .
			($row["editedby"] && get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=vieworiginal&amp;cid=$row[id]>View original</a>]" : "") . "</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]><b>$row[username]</b></a> 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();
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("<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"] . "><b>" . htmlspecialchars($row["username"]) . "</b></a> " . $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"] . "\"><i>(orphaned)</i></a>\n");
        }

        else if ($arraya['anonymous'] == 'yes') {
        print("<a name=\"comm" . $row["id"] . "\"><font color=blue><b>Anonymous</b></font></a>\n");
        }

        print(" at " . $row["added"] . " GMT" .
          ($row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=edit&amp;cid=$row[id]>".Edit."</a>] " : "") .
          (get_user_class() >= UC_USER ? "- [<a href=report.php?commentid=$row[id]>Report</a>] " : "") .
          (get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=delete&amp;cid=$row[id]>".Delete."</a>]" : "") .
          ($row["editedby"] && get_user_class() >= UC_MODERATOR ? " - [<a href=comment.php?action=vieworiginal&amp;cid=$row[id]>".View_original."</a>]" : "") . "</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();
}
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
Reply With Quote
The Following 3 Users Say Thank You to Rendevous For This Useful Post:
d6bmg (7th June 2011), kalwin (19th January 2012), Tibys08 (29th May 2011)