/**
 * change torrent Owner (download same torrent again from another user)
 *
 * @param $transfer, $user
 * @return none
 */
function changeOwner($transfer, $user)
{
    global $cfg, $db, $transfers;
    $oldowner = getOwner($transfer);
    if ($oldowner != $user) {
        if (file_exists($cfg["transfer_file_path"] . $transfer . ".stat")) {
            $sf = new StatFile($transfer, $user);
            $sf->transferowner = $user;
            $sf->write();
        }
        $hash = getTransferHash($transfer);
        $uid = (int) GetUID($user);
        $sql = "INSERT INTO tf_transfer_totals(tid, uid, uptotal,downtotal) values (" . $db->qstr($hash) . "," . $uid . "," . "0,0" . ")";
        $result = $db->Execute($sql);
        if ($db->ErrorNo() != 0) {
            dbError($sql);
        }
        resetOwner($transfer);
    }
}
Exemplo n.º 2
0
function getOwner($file)
{
    global $cfg, $db;
    $rtnValue = "n/a";
    // Check log to see what user has a history with this file
    $sql = "SELECT user_id FROM tf_log WHERE file=" . $db->qstr($file) . " AND (action=" . $db->qstr($cfg["constants"]["file_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["url_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["reset_owner"]) . ") ORDER  BY time DESC";
    $user_id = $db->GetOne($sql);
    if ($user_id != "") {
        $rtnValue = $user_id;
    } else {
        // try and get the owner from the stat file
        $rtnValue = resetOwner($file);
    }
    return $rtnValue;
}
/**
 * get Owner
 *
 * @param $transfer
 * @return string
 */
function getOwner($transfer)
{
    global $cfg, $db, $transfers;
    if (isset($transfers['owner'][$transfer])) {
        return $transfers['owner'][$transfer];
    } else {
        // Check log to see what user has a history with this file
        $transfers['owner'][$transfer] = $db->GetOne("SELECT user_id FROM tf_log WHERE BINARY file=" . $db->qstr($transfer) . " AND (action=" . $db->qstr($cfg["constants"]["file_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["url_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["reset_owner"]) . ") ORDER BY time DESC");
        return $transfers['owner'][$transfer] != "" ? $transfers['owner'][$transfer] : resetOwner($transfer);
        // try and get the owner from the stat file;
    }
}