PUT THIS FILE IN A DIRECTORY ON YOUR WEB SERVER (maybe a directory called w3btorrent) AND VISIT IT */ /* w3btorrent (keep it simple) - simple web fronted torrent client Copyright (C) 2005, 2007 Vegard Hammerseth (http://thewulong.com) w3btorrent is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. */ /* DON'T EDIT ANYTHING BELOW, UNLESS YOU KNOW WHAT YOU'RE DOING */ if (phpversion() < 4) { exit("Sorry, you need PHP4+ to be able to use w3btorrent."); } error_reporting(E_ALL); class install { var $title = "w3btorrent web installer v1.3"; var $logo = "http://w3btorrent.sourceforge.net/pix/w3btorrent.jpg"; var $url = "http://kent.dl.sourceforge.net/sourceforge/w3btorrent/w3btorrent_0.1.3.tar.gz"; var $steps = array("Writeable dir","Download","Extract archive","Binary check","Finish"); function is_installed() { if (isset($_SESSION['step'])) { return; } if (is_file("inc/class/w3btorrent.class.php")) { return true; } } function initial() { if (isset($_SESSION['step'])) { return; } $_SESSION['webuser'] = trim($this->safe_exec("whoami")); $_SESSION['realdirpath'] = dirname($_SERVER['SCRIPT_FILENAME'])."/"; $_SESSION['step'] = 2; } /* valid url */ function valid_url($arg_url) { if (preg_match("/(http(s?)|ftp):\/\//i",$arg_url) && @fopen($arg_url,"r")) { return true; } } function get_real_location($arg_url,$arg_max_redirects = 5) { $headers = array_reverse(get_headers($arg_url)); foreach ($headers as $value) { if (preg_match("/^location:(.*)/i",$value,$m)) { return trim($m['1']); } } } /* find executable path for program */ function exec_path($arg_cmd) { $paths = array("/usr/bin","/bin","/usr/local/bin","/usr/sbin","/sbin"); $paths = array_merge($paths,explode(":",$_SERVER['PATH'])); $paths = array_unique($paths); /* find and execute path */ foreach ($paths as $path) { if (is_executable($path."/".$arg_cmd)) { return $path."/".$arg_cmd; } } } /* be able to execute files even with safe_exec on! */ function safe_exec($arg_cmd) { $cmdlist = explode(" ",$arg_cmd); $cmd = $cmdlist['0']; $args = implode(" ",array_slice($cmdlist,1)); if (!is_executable($cmd) && !$path = $this->exec_path($cmd)) { return; } /* execute command with arguments and return result */ if (!$popen = popen("$cmd $args","r")) { return; } $return = ""; while (!feof($popen)) { $return .= fgets($popen,4096); } pclose($popen); return $return; } function download_archive($arg_url) { if (!isset($arg_url)) { return "Write a URL to a w3torrent archive."; } elseif (!$fdata = file_get_contents($arg_url)) { return "Problems with URL, check it that it works."; } $filename = basename($arg_url); /* save file this way, supporting PHP4 users */ if (!$f = fopen($filename,"w")) { return "Can't create new files in this directory."; } if (!fwrite($f,$fdata)) { fclose($f); return "Unable to write to system."; } fclose($f); } /* move contents within directory to another directory */ function move_dir_content($argdir,$argtodir) { if (!is_dir($argdir) || !$d = dir($argdir)) { return; } while ($entry = $d->read()) { if ($entry == "." || $entry == "..") { continue; } rename("$argdir/$entry","$argtodir/$entry"); } $d->close(); rmdir($argdir); return true; } /* use a valid directory */ function valid_dir($arg_dir) { if (is_dir($arg_dir) && is_readable($arg_dir) && is_executable($arg_dir) && is_writeable($arg_dir)) { return true; } } function decompress_archive($arg_file) { $file = escapeshellarg($arg_file); $this->safe_exec("tar xf $file"); /* did the execute work? */ if (!is_dir("w3btorrent")) { unset($_SESSION['filename']); return "We were unable to decompress '$arg_file'. Make sure it is a tar archive. Go back and download a new one."; } /* try move the directory's content's to curren dir */ if (!$this->move_dir_content("w3btorrent/",$_SESSION['realdirpath'])) { return "Unable to move the folder within 'w3btorrent/' to current directory, check permissions."; } } function binary_works() { $exec = $this->safe_exec("system/wctorrent -h 2>&1"); if (strlen($exec) > 1000) { return true; } } function configure($arg_dir) { $olddir = getcwd(); chdir($arg_dir); $exec = $this->safe_exec("bash configure --prefix=".escapeshellarg($arg_dir)); $exec = str_replace("... yes\n","... yes\n",$exec); $exec = str_replace("... no\n","... no\n",$exec); chdir($olddir); return $exec; } function compile($arg_dir) { $olddir = getcwd(); chdir($arg_dir); $exec = $this->safe_exec("make install"); if (substr($exec,0,7) == "cd . &&" && preg_match("/missing --run (.*)/",$exec,$m)) { $exec = "WARNING: `".$m['1']."' is needed, and you do not seem to have it handy on your\nsystem. You might have modified some files without having the\nproper tools for further handling them. Check the `README' file,\nit often tells you about the needed prerequirements for installing\nthis package. You may also peek at any GNU archive site, in case\nsome other package would contain this missing `".$m['1']."' program."; } chdir($olddir); return $exec; } } /* session */ $install = new install; session_name("w3btorrent".getcwd()); session_start(); ob_start(); /* if it's already installed hightlight this file so everyone can get it */ if ($install->is_installed()) { echo file_get_contents($_SERVER['SCRIPT_FILENAME']); exit(); } /* set values */ $install->initial(); /* highlight progress */ $install->steps[$_SESSION['step']-($install->valid_dir($_SESSION['realdirpath'])?1:2)] = "".$install->steps[$_SESSION['step']-($install->valid_dir($_SESSION['realdirpath'])?1:2)].""; /* for download, extract and compiling */ ini_set("max_execution_time",1600); // 30 min ?> <?php echo $install->title; ?>



Progress steps as $x) { $s = $s.$x." -> "; } echo substr($s,0,-4); ?>


Install valid_dir($_SESSION['realdirpath'])) { ?> Unable to write to directory ''.
You must make this directory writeable to be able to install w3btorrent. You can fix it by ONE of the follwing:
  • Open your FTP client and change modification (chmod) on this directory to 777 (707 or 007).
  • Open your FTP client and change '' directory owner to ''.
  • Execute this command on this server from a user with enough access `chmod 777 `
  • Execute this command on this server from a user with enough access `chown `
download_archive($_POST['url'])) { $_SESSION['filename'] = basename($_POST['url']); $_SESSION['step'] = 3; header("location: ".$_SERVER['SCRIPT_NAME']); exit(); } /* an extra check if something else should fail */ elseif (isset($_POST['url']) && file_exists(basename($_POST['url'])) && sizeof(basename($_POST['url']) > 0)) { $_SESSION['filename'] = basename($_POST['url']); $_SESSION['step'] = 3; header("location: ".$_SERVER['SCRIPT_NAME']); exit(); } ?>
Link to w3btorrent archive     Need another mirror?


   
decompress_archive($_SESSION['filename'])) { unlink($_SESSION['filename']); unset($_SESSION['filename']); $_SESSION['step'] = 4; header("location: ".$_SERVER['SCRIPT_NAME']); exit(); } ?>
Archive to extract


   
".$install->configure($_SESSION['realdirpath']."system/ctorrent-dnh2.2-w3btorrent/").""; } elseif (isset($_POST['compile'])) { $exec = $install->compile($_SESSION['realdirpath']."system/ctorrent-dnh2.2-w3btorrent/"); if (is_executable("system/ctorrent-dnh2.2-w3btorrent/ctorrent")) { echo "Finish! it seems like your system succsessfully «created» ctorrent binary. Click \"Finish\" to end installer."; } else { echo "
".$exec."
"; } } /* binary check */ elseif (isset($_POST['finish']) || isset($_POST['continue']) || $install->binary_works()) { $_SESSION['step'] = 5; header("location: ".$_SERVER['SCRIPT_NAME']); exit(); } else { echo "Your system can't use the binarys following with w3btorrent, sorry. You can keep using BitTorrent/Tornado if you have these installed ".(!$install->exec_path("btdownloadcurses")?"(couldn't find any) ":"")."or you can try «create» them with this installer, just click \"Configure\" and \"Compile\" when configure is finish. Good luck."; } ?>

"; } elseif (is_dir("system/ctorrent-dnh2.2-w3btorrent/.deps")) { echo ""; } else { echo ""; } ?>
Install complete!
Do to be able to use w3btorrent follow these instructions.
  • Login with username Admin and password 1234
  • Select a download directory
  • Change password from '1234' to something else!

Link to use for future visits: http://