All pastes #63755 Raw Edit

Untitled

public text v1 · immutable
#63755 ·published 2006-06-10 16:30 UTC
rendered paste body
<?php if(!isset($is_loaded)){die('&raquo Must be loaded from core');} ?>
<?php require_once(HEADER); ?>
<?php 
if($_POST['submit'] == 'Upload'){
	$torrent['extention'] = substr($_FILES['torrent']['name'], -8);
	if($_FILES['torrent']['name'] == 'application/x-bittorrent' || $torrent['extention'] == '.torrent' && $_FILES['torrent']['name'] == 'application/octet-stream'){
		$torrent['md5']  = md5_file($_FILES['torrent']['tmp_name']);
		$torrent['name'] = basename($_FILES['torrent']['name'], '.torrent');
		$torrent['size'] = $_FILES['torrent']['size'];
		$torrent['hash'] = $_FILES['torrent']['tmp_name'];
		$torrent['hash'] = file_get_contents($torrent['hash']);
		$torrent['ohash'] = $torrent['hash'];
		$torrent['hash'] = base64_encode($torrent['hash']);
		
		$mysql = new MySql;
		$mysql->FieldsRequest(array('id','name','md5'));
		$mysql->QueryRequest("SELECT * FROM torrents WHERE md5='{$torrent['md5']}' LIMIT 1");
		if($mysql->outputfields['md5'][0] == $torrent['md5']){
			$template['error'] = "Oops!, the file that you are trying to upload already exist in out database under the name <a href=\"index.php?act=torrent&amp;torrent={$mysql->outputfields['md5'][0]}\">{$mysql->outputfields['name'][0]}.torrent</a>";
		}else{
			$mysql = new MySql;
			$mysql->QueryInsert("INSERT INTO torrents (name,hash,size,md5) VALUES ('{$torrent['name']}','{$torrent['hash']}','{$torrent['size']}','{$torrent['md5']}');");
			$template['success'] = "<a href=\"index.php?act=torrent&amp;torrent={$torrent['md5']}\">{$torrent['name']}.torrent</a> Succesfully uploaded!";
			$mysql->Query("OPTIMIZE TABLE torrents");
		}
	}else{
		$template['error'] = "Oops!, it seems that the file you are trying to upload is not a .torrent file. Please check the file and try again";
	}
}
?>
<form enctype="multipart/form-data" id="upload" name="upload" method="post" action="index.php?act=idx">
  Torrent:
  <input type="file" id="torrent" name="torrent" />
  <input type="submit" id="submit" name="submit" value="Upload" onSubmit="this.value='Uploading...'" />
  <br />
  <?= $template['error']; ?>
  <?= $template['success']; ?>
  Stupid debug tool what do you see here? <?= $torrent['extention']; ?>
</form>
<?php require_once(FOOTER); ?>