09 Anonymous Uploader

Started by Mindless, July 21, 2012, 08:21:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mindless

Complete anonymous uploading by Wilba and Ininja

Code (sql) Select
ALTER TABLE `torrents` ADD `anonymous` ENUM( 'yes', 'no' ) DEFAULT 'no' NOT NULL;

in upload.php add
Code (php) Select
$HTMLOUT .= tr("{$lang['upload_anonymous']}", "<input type='checkbox' name='uplver' value='yes' />{$lang['upload_anonymous1']}", 1);

In takeupload.php find:
Code (php) Select
$f = $_FILES["file"];
    $fname = unesc($f["name"]);
    if (empty($fname))
      stderr($lang['takeupload_failed'], $lang['takeupload_no_filename']);


Change to this :
Code (php) Select
$f = $_FILES["file"];
     $fname = unesc($f["name"]);
     if (empty($fname))
     stderr($lang['takeupload_failed'], $lang['takeupload_no_filename']);
     if(isset($_POST['uplver']) && $_POST['uplver'] == 'yes') {
     $anonymous = "yes";
     $anon = "Anonymous";
     } else {
     $anonymous = "no";
     $anon = $CURUSER["username"];
     }


Find:
Code (php) Select
$ret = sql_query("INSERT INTO torrents (search_text, filename, owner, visible,

And add anonymous inline, like:
Code (php) Select
$ret = sql_query("INSERT INTO torrents (search_text, filename, owner, visible, anonymous, info_hash, name,

Do the same for:
Code (php) Select
implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, $CURUSER["id"], "no",

So it looks like this:
Code (php) Select
implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, $CURUSER["id"], "no", $anonymous, $infohash,

browse

Find:
Code (php) Select
torrents.filename,torrents.owner,

Replace that with:
Code (php) Select
torrents.filename,torrents.anonymous,torrents.owner,

details.php

Find the big query, and add anonymous, inline, like:
Code (php) Select
torrents.anonymous, categories.name AS cat_name, users.username

Now find:
Code (php) Select
$keepget = "";
$uprow = (isset($row["username"]) ? ("<a href='userdetails.php?id=" . $row["owner"] . "'><b>" . htmlspecialchars($row["username"]) . "</b></a>") : "<i>{$lang['details_unknown']}</i>");
if ($owned)
$uprow .= " $spacer<$editlink><b>{$lang['details_edit']}</b></a>";
$HTMLOUT .= tr("Upped by", $uprow, 1);


change to :
Code (php) Select
$keepget = "";
if($row['anonymous'] == 'yes') {
    if ($CURUSER['class'] < UC_UPLOADER)
    $uprow = "<i>Anonymous</i>";
    else
    $uprow = "<i>Anonymous</i> (<a href='userdetails.php?id=$row[owner]'><b>$row[username]</b></a>)";
    }
    else {
$uprow = (isset($row["username"]) ? ("<a href='{$INSTALLER09['baseurl']}/userdetails.php?id=" . $row["owner"] . "'><b>" . htmlspecialchars($row["username"]) . "</b></a>") : "<i>{$lang['details_unknown']}</i>");
}
if ($owned)
$uprow .= " $spacer<$editlink><b>{$lang['details_edit']}</b></a>";
$HTMLOUT .= tr("Upped by", $uprow, 1);


In function_torrenttable.php find:
Code (php) Select
if ($variant == "index")
$htmlout .= "<td align='center'>" . (isset($row["username"]) ? ("<a href='userdetails.php?id=" . $row["owner"] . "'><b>" . htmlspecialchars($row["username"]) . "</b></a>") : "<i>(".$lang["torrenttable_unknown_uploader"].")</i>") . "</td>\n";


And replace that with:
Code (php) Select
if ($variant == "index") {
       if ($row["anonymous"] == "yes") {
       $htmlout .= "<td align='center'><i>Anonymous</i></td>\n";
       }
       else {
       $htmlout .= "<td align='center'>" . (isset($row["username"]) ? ("<a href='{$INSTALLER09['baseurl']}/userdetails.php?id=" . $row["owner"] . "'><b>" . htmlspecialchars($row["username"]) . "</b></a>") : "<i>(".$lang["torrenttable_unknown_uploader"].")</i>") . "</td>\n";
       }
       }
       $htmlout .= "</tr>\n";
       }
       $htmlout .= "</table>\n";
       return $htmlout;
       }
   

Now, in edit.php, beneath:
Code (php) Select
if ($CURUSER['class'] >= UC_MODERATOR) //($CURUSER["admin"] == "yes")
    {
    $HTMLOUT  .= tr($lang['edit_banned'], "<input type='checkbox' name='banned'" . (($row["banned"] == "yes") ? " checked='checked'" : "" ) . " value='1' /> {$lang['edit_banned']}", 1);
    }


Add this:
Code (php) Select
$HTMLOUT .= tr($lang['edit_anonymous'], "<input type='checkbox' name='anonymous'" . (($row["anonymous"] == "yes") ? " checked='checked'" : "" ) . " value='1' />{$lang['edit_anonymous1']}", 1);

In takeedit.php near :
Code (php) Select
$updateset[] = "name = " . sqlesc($name);

Add:
Code (php) Select
$updateset[] = "anonymous = '" . (isset($_POST["anonymous"]) ? "yes" : "no") . "'";

then in lang/en/lang_edit.php add :
Code (php) Select
'edit_anonymous' => "Anonymous Uploader",
'edit_anonymous1' => "Check this box to hide the uploader of the torrent",


then in lang/en/lang_upload.php add :
Code (php) Select
'upload_anonymous' => "Anonymous Uploader",
'upload_anonymous1' => "Don't show my username in 'Uploaded By' field in browse.",


In peerlist.php

find
Code (PHP) Select
// user/ip/port
                  // check if anyone has this ip
                  //($unr = sql_query("SELECT username, privacy FROM users WHERE id=$e[userid] ORDER BY last_access DESC LIMIT 1")) or die;
                  //$una = mysql_fetch_assoc($unr);
          if ($e["privacy"] == "strong") continue;
      $htmlout .= "<tr>\n";
                  if ($e["username"])
                    $htmlout .= "<td><a href='userdetails.php?id=$e[userid]'><b>$e[username]</b></a></td>\n";
                  else
                    $htmlout .= "<td>" . ($mod ? $e["ip"] : preg_replace('/\.\d+$/', ".xxx", $e["ip"])) . "</td>\n";


change too
 
Code (php) Select
// check if anyone has this ip
      $unr = sql_query("SELECT id, username, anonymous, enabled, warned, donor FROM users WHERE id=".sqlesc($e['userid'])." ORDER BY last_access DESC LIMIT 1") or sqlerr(__FILE__,__LINE__);
      $una = mysql_fetch_assoc($unr);
      $highlight = $CURUSER["id"] == $una["id"] ? " bgcolor='#BBAF9B'" : ""; //$highlight
      $htmlout .= "<tr $highlight>\n";
      if ($una["username"]) {
      if ($CURUSER['class'] >= UC_MODERATOR || $torrent['anonymous'] != 'yes' || $e['userid'] != $torrent['owner']) {
      $htmlout .= "<td><a href='{$INSTALLER09['baseurl']}/userdetails.php?id=$e[userid]'><b>$una[username]</b></a>" . ($una["donor"] == "yes" ? "<img src='{$INSTALLER09['pic_base_url']}star.png' alt='Donor' title='Donor' />" : "") . ($una["enabled"] == "no" ? "<img src='{$INSTALLER09['pic_base_url']}disabled.gif' alt='This account is disabled' title'Account Disabled' style='margin-left: 2px' />" : ($una["warned"] == "yes" ? "<a href='{$INSTALLER09['baseurl']}/rules.php#warning' class='altlink'><img src='{$INSTALLER09['pic_base_url']}warned.png' alt='Warned' title='Warned' border='0' /></a>" : "</td>"));
      }
      elseif ($CURUSER['class'] >= UC_MODERATOR || $torrent['anonymous'] = 'yes') {
      $htmlout .= "<td><i>Anonymous</i></td>\n";
      }
      }
      else
      $htmlout .= "<td>(Unknown)</td>\n";


Above code is now validated.