Jump to content

File downloads menu for a PHP Server


fjdslafjdsklaa

Recommended Posts

Here is what made, its a html file that should go on a web server on the machine utorrent is on. you could use iis or wamp as the server. just change according to you utorrent port and password for webui, these are surrounded by ***. on your web server, make a folder called downloads in the same directory as this html file, tell utorrent to put downloads in this directory. i used firefox to make this, so it will look best that way.

<html>
<head>
<title>µTorrent Web UI</title>
<style>
body{
margin:0;
padding:0;
}
#u{
width:100%;
height:90%;
padding:0;
margin:0;
}
#nav{
width:100%;
height:28px;
background:#cccccc;
padding:0;
margin:0;
}
#nav li{
float:left;
list-style:none;
padding:1px;
padding-left:2px;
padding-right:2px;
margin:0;
margin-right: 5px;
margin-left: 5px;
color:white;
border:white 2px solid;
-moz-border-radius:5px;
}
#nav li:hover{
position:relative;
cursor:pointer;
top:-1px;
left:-1px;
float:left;
list-style:none;
padding:1px;
padding-left:2px;
padding-right:2px;
margin:0;
margin-right: 3px;
margin-left: 5px;
color:white;
border:white 3px solid;
-moz-border-radius:5px;
}
#nav ul{
padding:0;
margin:0;
}
#nav li a{
color:white;
padding:0;
margin:0;
}
</style>
<script type="text/javascript">
function changetouv() {
document.getElementById('u').src = 'http://***WEBUI Username here***:***password goes here***@localhost:***port here***/gui/index.html';
}
function changetodl() {
document.getElementById('u').src = 'downloads/';
}
</script>
</head>
<body>
<div id="nav">
<ul>
<li id="uv" onclick="changetouv()">µTorrent Web UI</li>
<li id="dl" onclick="changetodl()">Download</li>
</ul>
</div>
<iframe frameborder="0" id="u" scrolling="no" src="http://***WEBUI Username here***:***password goes here***@localhost:***port here***/gui/index.html"></iframe>
</body>
</html>

Another approach would be to create an alias to your utorrent download directory. If you use wamp server, you can simply click the task bar icon -> Apache -> alias directories -> add an alias. type downloads, then type you utorrent downloads path. this will make a directory on your site, localhost/downloads. then change ths line:

document.getElementById('u').src = 'downloads/';

to this:

document.getElementById('u').src = 'localhost/downloads/';

you would want to do this if you don't want to move you download location.

a note on the web UI devs: just create an alias with Apache as described. add a context menu item the links to the file in the alias directory. Example:

<a href="http://localhost/downoadalias/dynamic filename">Download</a>

Here's one that uses PHP:

index.html

<html>
<head>
<title>µTorrent Web UI</title>
<style>
body{
margin:0;
padding:0;
}
#u{
width:100%;
height:95%;
padding:0;
margin:0;
}
#nav{
width:100%;
height:28px;
background:url(nav.jpg);
padding:0;
margin:0;
}
#nav li{
float:left;
list-style:none;
padding:1px;
padding-left:2px;
padding-right:2px;
margin:0;
margin-right: 5px;
margin-left: 5px;
color:white;
border:white 2px solid;
-moz-border-radius:5px;
}
#nav li:hover{
position:relative;
cursor:pointer;
top:-1px;
left:-1px;
float:left;
list-style:none;
padding:1px;
padding-left:2px;
padding-right:2px;
margin:0;
margin-right: 3px;
margin-left: 5px;
color:white;
border:white 3px solid;
-moz-border-radius:5px;
}
#nav ul{
padding:0;
margin:0;
}
#nav li a{
color:white;
padding:0;
margin:0;
}
</style>
<script type="text/javascript">
function changetouv() {
document.getElementById('u').src = 'http://***WEBUI Username here***:***WEBUI Password here***@localhost:***WEBUI Port here***/gui/index.html';
}
function changetodl() {
document.getElementById('u').src = 'dl.php';
}
</script>
</head>
<body>
<div id="nav">
<ul>
<li id="uv" onclick="changetouv()">µTorrent Web UI</li>
<li id="dl" onclick="changetodl()">Download</li>
</ul>
</div>
<iframe frameborder="0" id="u" src="http://***WEBUI Username here***:***WEBUI Password here***@localhost:***WEBUI Port here***/gui/index.html"></iframe>
</body>
</html>

dl.php

<?php
$number = 0;
$script = '<script type="text/javascript">';
if ($handle = opendir('file://C:\Documents and Settings\All Users\DL')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
if ((substr($file, -4, 1)) == "."){
$ext = substr($file, -3);
$ext = strtolower($ext);
}

if($ext == "avi" || $ext == "mp4"){
$ext = "<img src='movie.gif' />";
}
if ($ext == "php" || $ext == "!ut"){
$ext = "<img src='unknown.gif' />";
}
if ($ext == "exe"){
$ext = "<img src='exe.gif' />";
}
if ($ext == "rar"){
$ext = "<img src='rar.gif' />";
}
if ($ext == "txt" || $ext == "nfo"){
$ext = "<img src='text.gif' />";
}
if(filetype("file://C:\Documents and Settings\All Users\DL\\" . $file) == "dir"){
$ext = "<img src='folder.gif' onclick='hide".$number."()' />";
}
if ($file != "Thumbs.db"){
$thelist .= '<li>' . $ext . '<a href="http://localhost/dl/'.$file.'">'.$file.'</a></li>';
}
if(filetype("file://C:\Documents and Settings\All Users\DL\\" . $file) == "dir"){
$thelist .= '<table><tr class="col" id="subdir'. $number .'"><td><ul>';
$script .= "function hide".$number."(){
if(document.getElementById('subdir".$number."').style.visibility == 'visible'){
document.getElementById('subdir".$number."').style.visibility = 'collapse';
}else{
document.getElementById('subdir".$number."').style.visibility = 'visible';
}
}"
;
$number = $number + 1;
if ($handle2 = opendir('file://C:\***DOWNLOAD DIR***\\' . $file)) {
while (false !== ($file2 = readdir($handle2)))
{
if ($file2 != "." && $file2 != "..") {
if ((substr($file2, -4, 1)) == "."){
$ext = substr($file2, -3);
$ext = strtolower($ext);
}
if(filetype("file://C:\***DOWNLOAD DIR ***\\".$file."\\" . $file2) == "dir"){
$ext = "<img src='folder.gif' />";
}
if($ext == "avi" || $ext == "mp4"){
$ext = "<img src='movie.gif' />";
}
if ($ext == "txt" || $ext == "nfo"){
$ext = "<img src='text.gif' />";
}
if ($ext == "exe"){
$ext = "<img src='exe.gif' />";
}
if ($ext == "php" || $ext == "!ut"){
$ext = "<img src='unknown.gif' />";
}
if ($ext == "rar"){
$ext = "<img src='rar.gif' />";
}
if ($file2 != "Thumbs.db"){
$thelist .= '<li>'.$ext.'<a href="http://localhost/dl/'.$file .'/'.$file2.'">'.$file2.'</a></li>';
}
$ext = "";
}
}
closedir($handle2);
$thelist .= '</ul></td></tr></table>';
}
}
$ext = "";
}
}
closedir($handle);
}
?>
<style>
.col{
visibility: collapse;
}
</style>
<ul>
<?php echo $script."</script>". $thelist ?>
</ul>

***DOWNLOAD DIR*** is where you download files from utorrent Example: C:/My documents and settings/downlaods. Leave the double //, it needs to be escaped. Post back for and questions!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...