View Single Post
  #1  
Old 30th October 2013, 06:07
shadowfox shadowfox is offline
Member
 
Join Date: Oct 2013
P2P
Posts: 2
Default Poor duplicate torrent detection in takeupload.php
With TBDev.2009(Final).rev.295 I've noticed a lot of duplicate torrents being posted, which seemed like something which would be coded against so I checked takeupload.php and it has a basic mysql check to try and prevent it.

Code:
    $ret = mysql_query("INSERT INTO torrents (search_text, filename, owner, visible, info_hash, name, size, numfiles, type, descr, ori_descr, category, save_as, added, last_action, nfo, client_created_by) VALUES (" .
        implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, $CURUSER["id"], "no", $infohash, $torrent, $totallen, count($filelist), $type, $descr, $descr, 0 + $_POST["type"], $dname))) .
        ", " . time() . ", " . time() . ", $nfo, $tmaker)");
    if (!$ret) {
      if (mysql_errno() == 1062)
        stderr($lang['takeupload_failed'], $lang['takeupload_already']);
      stderr($lang['takeupload_failed'], "mysql puked: ".mysql_error());
    }
    $id = mysql_insert_id();
This has been basically unchanged since before TBDev, I found the same function in TBSource from years prior. Has anyone modified their query to better avoid duplicates? I'm a novice at mysql queries so I'm not totally sure what it's checking to determine if the torrent already exists but it's certainly not foolproof. I see many duplicates getting posted despite the same file being already uploaded to a torrent with the same name?

I couldn't find anything on google suggesting a better way to do it, it's been an issue across versions, surely someone's done it better by now?
Reply With Quote