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

// Fill in application

if ($_POST["form"] != "1") {

  $res = mysql_query("SELECT status FROM uploadapp WHERE userid = $CURUSER[id]") or sqlerr(__FILE__, __LINE__);
  $arr = mysql_fetch_assoc($res);
  if ($CURUSER["class"] >= 4)
	show_error_msg("Access denied", "It appears you are allready part of our uploading team.");
  elseif ($arr["status"] == "pending")
	show_error_msg("Access denied", "It appears you are currently pending confirmation of your uploader application.");
  elseif ($arr["status"] == "rejected")
	show_error_msg("Access denied", "It appears you have applied for uploader before and have been rejected. If you would like a second chance please contact an administrator.");

  else {
	stdhead("Uploader application"); 
	begin_frame("Uploader application");
	print("<table width=99% class=tablebg cellspacing=0 cellpadding=10 align=center><tr><td>");
	print("<form action=uploadapp.php method=post enctype=multipart/form-data>");
	print("<table cellspacing=0 class=table_table cellpadding=5 align=center>");

	if ($CURUSER["downloaded"] > 0)
	  $ratio = $CURUSER['uploaded'] / $CURUSER['downloaded'];
	elseif ($CURUSER["uploaded"] > 0)
	  $ratio = 1;
	else
	  $ratio = 0;  

	$res = mysql_query("SELECT connectable FROM peers WHERE userid=$CURUSER[id]")or sqlerr(__FILE__, __LINE__);
	if ($row = mysql_fetch_row($res)) {
	  $connect = $row[0];
	  if ($connect == "yes")
		$connectable = "Yes";
	  else
		$connectable = "No";
	} else
	  $connectable = "Pending";

	print("<tr><td class=row1>My username is</td><td class=row2><input name=userid type=hidden value=".$CURUSER['id'].">".$CURUSER['username']."</td></tr>");
    print("<tr><td class=row1>I have joined at</td><td class=row2>".$CURUSER['added']." (".get_elapsed_time(sql_timestamp_to_unix_timestamp($CURUSER["added"]))." ago)</td></tr>");
	print("<tr><td class=row1>I have a positive ratio</td><td class=row2>".($ratio >= 1 ? "Yes" : "No")."</td></tr>");
	print("<tr><td class=row1>I am connectable</td><td class=row2><input name=connectable type=hidden value=$connectable>$connectable</td></tr>");
	print("<tr><td class=row1>My upload speed is</td><td class=row2><input type=text name=speed size=19></td></tr>");
	print("<tr><td class=row1>What I have to offer</td><td class=row2><textarea name=offer cols=40 rows=3 wrap=VIRTUAL></textarea></td></tr>");
	print("<tr><td class=row1>Why I should be promoted</td><td class=row2><textarea name=reason cols=30 rows=4 wrap=VIRTUAL></textarea></td></tr>");
	print("<tr><td class=row1>I am uploader at other sites</td><td class=row2><input type=radio name=sites value=yes>Yes<input name=sites type=radio value=no checked>No</td></tr>");
	print("<tr><td class=row1>Those sites are</td><td class=row2><textarea name=sitenames cols=40 rows=2 wrap=VIRTUAL></textarea></td></tr>");
	print("<tr><td class=row1>I have scene access</td><td class=row2><input type=radio name=scene value=yes>Yes<input name=scene type=radio value=no checked>No</td></tr>");
	print("<tr><td class=row1>I know how to create, upload and seed torrents</td><td class=row2><input type=radio name=creating value=yes>Yes<input name=creating type=radio value=no checked>No</td></tr>");
    print("<tr><td class=row1>I understand that I have to keep seeding my torrents until there are at least two other seeders</td><td class=row2><input type=radio name=seeding value=yes>Yes<input name=seeding type=radio value=no checked>No</td></tr><input name=form type=hidden value=1>");
	print("</td></tr>");
	print("</table>");
	print("<p align=center><input type=submit name=Submit value=Send></p>");
	print("</form>");
	print("</td></tr></table>"); 
    end_frame();
	stdfoot();
  }

// Process application

} else {

  $userid = 0 + $_POST["userid"];
  $connectable = $_POST["connectable"];
  $speed = $_POST["speed"];
  $offer = $_POST["offer"];
  $reason = $_POST["reason"];
  $sites = $_POST["sites"];
  $sitenames = $_POST["sitenames"];
  $scene = $_POST["scene"];
  $creating = $_POST["creating"];
  $seeding = $_POST["seeding"];

  if (!is_valid_id($userid))
	show_error_msg("Error", "It appears something went wrong while sending your application. Please <a href=uploadapp.php>try again</a>.");
  if (!$speed)
	show_error_msg("Error", "It appears you have left the field with your upload speed blank.");
  if (!$offer)
	show_error_msg("Error", "It appears you have left the field with the things you have to offer blank.");
  if (!$reason)
	show_error_msg("Error", "It appears you have left the field with the reason why we should promote you blank.");
  if ($sites == "yes" && !$sitenames)
	  show_error_msg("Error", "It appears you have left the field with the sites you are uploader at blank.");

  $res = mysql_query("INSERT INTO uploadapp(userid,applied,connectable,speed,offer,reason,sites,sitenames,scene,creating,seeding) VALUES($userid, ".implode(",",array_map("sqlesc",array(get_date_time(), $connectable, $speed, $offer, $reason, $sites, $sitenames, $scene, $creating, $seeding))).")") or sqlerr(__FILE__, __LINE__);
  if (!$res) {
	if (mysql_errno() == 1062)
	  show_error_msg("Error", "It appears you tried to send your application twice.");
	else
	  show_error_msg("Error", "It appears something went wrong while sending your application. Please <a href=uploadapp.php>try again</a>.");
  } else
	show_success_msg("Application sent", "Your application has succesfully been sent to the staff.");
}
?>
Return current item: H-tracker