All pastes #64910 Raw Edit

Someone

public text v1 · immutable
#64910 ·published 2006-06-12 19:40 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 = pathinfo($_FILES['torrent']['name']);
	if($_FILES['torrent']['type'] == 'application/x-bittorrent' || 'application/octet-stream'){
		if($torrent['extension'] == 'torrent'){
			$torrent['filename'] = $_FILES['torrent']['name'];
			$torrent['name'] = basename($_FILES['torrent']['name'], '.torrent');
			$torrent['hash'] = file_get_contents($_FILES['torrent']['tmp_name']);
			$torrent['category'] = $_POST['category'];
			$torrent['description'] = $_POST['description'];
			$torrent['tags'] = $_POST['tags'];
			$torrent = array_merge($torrent, BDecode($torrent['hash']));
			if(strpos($torrent['hash'], 'd8:announce') !== false){
				$mysql = new MySql;
				$mysql->FieldsRequest(array('id','name','md5'));
				$mysql->QueryRequest("SELECT * FROM torrentdb WHERE md5='{$torrent['info']['md5sum']}' LIMIT 1");
				if($mysql->outputfields['md5'][0] == $torrent['info']['md5sum']){
					$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{
					$torrent['scrape'] = str_replace('/announce', '/scrape', $torrent['announce']);
					$torrent['magnet'] = strtoupper(sha1(BEncode($torrent['info'])));
					$torrent['info']['private'] = ($torrent['info']['private']) ? 1 : 0;
					$torrent['multi'] = (isset($torrent['info']['files'])) ? 1 : 0;
					$torrent['info']['files'] = serialize($torrent['info']['files']);
					$torrent['hash'] = base64_encode($torrent['hash']);
					$mysql = new MySql;
					$mysql->QueryDebug("INSERT INTO torrentdb (
															filename, 
															hash, 
															description, 
															tags, 
															announce, 
															scrape, 
															magnet, 
															creation, 
															comment, 
															created_w, 
															created_b, 
															encoding, 
															seedurl, 
															md5, 
															sha1, 
															internal_name, 
															multifile, 
															files, 
															private, 
															f_size, 
															p_size, 
															t_size, 
															source, 
															category
														) VALUES (
															'{$torrent['filename']}', 
															'{$torrent['hash']}', 
															'{$torrent['description']}', 
															'{$torrent['tags']}', 
															'{$torrent['announce']}', 
															'{$torrent['scrape']}', 
															'{$torrent['magnet']}', 
															'{$torrent['creation date']}', 
															'{$torrent['comment']}', 
															'{$torrent['created by']}', 
															'{$torrent['user-agent']}', 
															'{$torrent['encoding']}', 
															'{$torrent['httpseeds']}', 
															'{$torrent['info']['md5sum']}', 
															'{$torrent['info']['sha1']}', 
															'{$torrent['info']['name']}', 
															'{$torrent['multi']}', 
															'{$torrent['info']['files']}', 
															'{$torrent['info']['private']}', 
															'{$torrent['info']['length']}', 
															'{$torrent['info']['piece length']}', 
															'{$torrent['size']}', 
															'{$torrent['info']['source']}', 
															'{$torrent['category']}'
														);");
					$template['success'] = "<a href=\"index.php?act=parse&amp;torrent={$torrent['info']['md5sum']}\">{$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.';
			}
		}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.';
		}
	}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=test">
  Torrent:
  <input type="file" id="torrent" name="torrent" /><br /><br />
  Description:<br />
  <textarea name="description" cols="70" rows="5"></textarea><br /><br />
  Tags: 
  <input type="text" name="tags" />Seperate each Tag with a comma.<br /><br />
  <input type="submit" id="submit" name="submit" value="Upload" onSubmit="this.value='Uploading...'" />
  <br />
  <?= $template['error']; ?>
  <?= $template['success']; ?>
</form>
<?php require_once(FOOTER); ?>