Location: PHPKode > projects > H-tracker > taketransfer.php
<?
//
//  H-Tracker v0.2
//    http://h-tracker.org
//    Based on TorrentTrader (http://www.torrenttrader.org)
//
//
require "backend/functions.php";
dbconn();
loggedinonly();

if ($HTTP_SERVER_VARS["REQUEST_METHOD"] != "POST")
show_error_msg("Error","This file can not be accessed directly");

$username = $_POST["username"];
$credit = $_POST["credit"];
$kb = 1024;
$mb = 1024*1024;
$gb = 1024*1024*1024;
$tb = 1024*1024*1024*1024;
if ($_POST["unit"] == 'kb') $credit = $credit*$kb;
elseif ($_POST["unit"] == 'mb') $credit = $credit*$mb;
elseif ($_POST["unit"] == 'gb') $credit = $credit*$gb;
elseif ($_POST["unit"] == 'tb') $credit = $credit*$tb;
if ($credit < 1 || (!$CURUSER))
show_error_msg("Sorry","You are not logged in or you upload is to small");
if ($_POST["username"]==$CURUSER['username'])
show_error_msg("Sorry","You can't transfer to youself!");
if ($CURUSER["uploaded"] < $credit)
show_error_msg("Sorry","You upload is to small to transfer this");

$query = mysql_query("SELECT id,uploaded FROM users WHERE username = '$username'") or die(mysql_error());
$res = mysql_fetch_assoc($query);
$receiver = $res["id"];
$sender = $CURUSER["id"];
mysql_query("UPDATE users SET uploaded = uploaded + $credit WHERE id = '$receiver'") or die(mysql_error());
mysql_query("UPDATE users SET uploaded = uploaded - $credit WHERE id = '$sender'") or die(mysql_error());
$msg = sqlesc("User " . $CURUSER['username']." transfered " . mksize($credit) . "");
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES($sender, $receiver, NOW(), $msg, 0)") or die(mysql_error());
write_transferlog("User <a href=account-details.php?id=" . $CURUSER[id] . "><b>$CURUSER[username]</b></a> transfered " . mksize($credit) . " to user <a href=account-details.php?id=" . $res["id"] . "><b>$username</b></a>");
autolink("account-details.php?id=" . $res["id"] . "", "You have transfered " . mksize($credit) . " to  <a href=account-details.php?id=" . $res["id"] . "><b>$username</b></a>");  
?>
Return current item: H-tracker