Error TorrentFlux settings are not correct (path is not valid) -- please contact an admin.
"; } } } } $torrent = getRequestVar('torrent'); if(!empty($torrent)) { include_once("AliasFile.php"); if ($cfg["enable_file_priority"]) { include_once("setpriority.php"); // Process setPriority Request. setPriority($torrent); } $spo = getRequestVar('setPriorityOnly'); if (!empty($spo)){ // This is a setPriortiyOnly Request. }else { // if we are to start a torrent then do so // check to see if the path to the python script is valid if (!is_file($cfg["btphpbin"])) { AuditAction($cfg["constants"]["error"], "Error Path for ".$cfg["btphpbin"]." is not valid"); if (IsAdmin()) { header("location: admin.php?op=configSettings"); exit(); } else { $messages .= "Error TorrentFlux settings are not correct (path to python script is not valid) -- please contact an admin.
"; } } $command = ""; $rate = getRequestVar('rate'); if (empty($rate)) { if ($rate != "0") { $rate = $cfg["max_upload_rate"]; } } $drate = getRequestVar('drate'); if (empty($drate)) { if ($drate != "0") { $drate = $cfg["max_download_rate"]; } } $superseeder = getRequestVar('superseeder'); if (empty($superseeder)) { $superseeder = "0"; // should be 0 in most cases } $runtime = getRequestVar('runtime'); if (empty($runtime)) { $runtime = $cfg["torrent_dies_when_done"]; } $maxuploads = getRequestVar('maxuploads'); if (empty($maxuploads)) { if ($maxuploads != "0") { $maxuploads = $cfg["max_uploads"]; } } $minport = getRequestVar('minport'); if (empty($minport)) { $minport = $cfg["minport"]; } $maxport = getRequestVar('maxport'); if (empty($maxport)) { $maxport = $cfg["maxport"]; } $rerequest = getRequestVar("rerequest"); if (empty($rerequest)) { $rerequest = $cfg["rerequest_interval"]; } $sharekill = getRequestVar('sharekill'); if ($runtime == "True" ) { $sharekill = "-1"; } if (empty($sharekill)) { if ($sharekill != "0") { $sharekill = $cfg["sharekill"]; } } if ($cfg["AllowQueing"]) { if(IsAdmin()) { $queue = getRequestVar('queue'); if($queue == 'on') { $queue = "1"; }else { $queue = "0"; } } else { $queue = "1"; } } //$torrent = urldecode($torrent); $alias = getAliasName($torrent); $owner = getOwner($torrent); // The following lines of code were suggested by Jody Steele jmlsteele@stfu.ca // This is to help manage user downloads by their user names //if the user's path doesnt exist, create it if (!is_dir($cfg["path"]."/".$owner)) { if (is_writable($cfg["path"])) { mkdir($cfg["path"]."/".$owner, 0777); } else { AuditAction($cfg["constants"]["error"], "Error -- " . $cfg["path"] . " is not writable."); if (IsAdmin()) { header("location: admin.php?op=configSettings"); exit(); } else { $messages .= "Error TorrentFlux settings are not correct (path is not writable) -- please contact an admin.
"; } } } // create AliasFile object and write out the stat file $af = new AliasFile($cfg["torrent_file_path"].$alias.".stat", $owner); if ($cfg["AllowQueing"]) { if($queue == "1") { $af->QueueTorrentFile(); // this only writes out the stat file (does not start torrent) } else { $af->StartTorrentFile(); // this only writes out the stat file (does not start torrent) } } else { $af->StartTorrentFile(); // this only writes out the stat file (does not start torrent) } if (usingTornado()) { $command = escapeshellarg($runtime)." ".escapeshellarg($sharekill)." '".$cfg["torrent_file_path"].$alias.".stat' ".$owner." --responsefile '".$cfg["torrent_file_path"].$torrent."' --display_interval 5 --max_download_rate ". escapeshellarg($drate) ." --max_upload_rate ".escapeshellarg($rate)." --max_uploads ".escapeshellarg($maxuploads)." --minport ".escapeshellarg($minport)." --maxport ".escapeshellarg($maxport)." --rerequest_interval ".escapeshellarg($rerequest)." --super_seeder ".escapeshellarg($superseeder); if(file_exists($cfg["torrent_file_path"].$alias.".prio")) { $priolist = explode(',',file_get_contents($cfg["torrent_file_path"].$alias.".prio")); $priolist = implode(',',array_slice($priolist,1,$priolist[0])); $command .= " --priority ".escapeshellarg($priolist); } $command .= " ".escapeshellarg($cfg["cmd_options"])." > /dev/null &"; if ($cfg["AllowQueing"] && $queue == "1") { // This file is being queued. } else { // This flie is being started manually. if (! array_key_exists("pythonCmd", $cfg)) { insertSetting("pythonCmd","/usr/bin/python"); } if (! array_key_exists("debugTorrents", $cfg)) { insertSetting("debugTorrents", "0"); } if (!$cfg["debugTorrents"]) { $pyCmd = escapeshellarg($cfg["pythonCmd"]) . " -OO"; }else{ $pyCmd = escapeshellarg($cfg["pythonCmd"]); } $command = "cd " . $cfg["path"] . $owner . "; HOME=".$cfg["path"]."; export HOME; nohup " . $pyCmd . " " .escapeshellarg($cfg["btphpbin"]) . " " . $command; } } else { // Must be using the Original BitTorrent Client // This is now being required to allow Queing functionality //$command = "cd " . $cfg["path"] . $owner . "; nohup " . $cfg["btphpbin"] . " ".$runtime." ".$sharekill." ".$cfg["torrent_file_path"].$alias.".stat ".$owner." --responsefile \"".$cfg["torrent_file_path"].$torrent."\" --display_interval 5 --max_download_rate ". $drate ." --max_upload_rate ".$rate." --max_uploads ".$maxuploads." --minport ".$minport." --maxport ".$maxport." --rerequest_interval ".$rerequest." ".$cfg["cmd_options"]." > /dev/null &"; $messages .= "Error BitTornado is only supported Client at this time.
"; } // write the session to close so older version of PHP will not hang session_write_close(); if($af->running == "3") { writeQinfo($cfg["torrent_file_path"]."queue/".$alias.".stat",$command); AuditAction($cfg["constants"]["queued_torrent"], $torrent."
Die:".$runtime.", Sharekill:".$sharekill.", MaxUploads:".$maxuploads.", DownRate:".$drate.", UploadRate:".$rate.", Ports:".$minport."-".$maxport.", SuperSeed:".$superseeder.", Rerequest Interval:".$rerequest); AuditAction($cfg["constants"]["queued_torrent"], $command); } else { // The following command starts the torrent running! w00t! passthru($command); AuditAction($cfg["constants"]["start_torrent"], $torrent."
Die:".$runtime.", Sharekill:".$sharekill.", MaxUploads:".$maxuploads.", DownRate:".$drate.", UploadRate:".$rate.", Ports:".$minport."-".$maxport.", SuperSeed:".$superseeder.", Rerequest Interval:".$rerequest); // slow down and wait for thread to kick off. // otherwise on fast servers it will kill stop it before it gets a chance to run. sleep(1); } if ($messages == "") { if (array_key_exists("closeme",$_POST)) { ?> 0) && (strpos($output, "
") === false)) { if (is_file($cfg["torrent_file_path"].$file_name)) { // Error $messages .= "Error with (".htmlentities($file_name)."), the file already exists on the server.
[Refresh]
"; $ext_msg = "DUPLICATE :: "; } else { // open a file to write to $fw = fopen($cfg["torrent_file_path"].$file_name,'w'); fwrite($fw, $output); fclose($fw); } } else { $messages .= "Error Getting the File (".htmlentities($file_name)."), Could be a Dead URL.
[Refresh]
"; } if ($messages == "") { AuditAction($cfg["constants"]["url_upload"], $file_name); header("location: ".$_SERVER['PHP_SELF']); exit(); } else { // there was an error AuditAction($cfg["constants"]["error"], $cfg["constants"]["url_upload"]." :: ".$ext_msg.$file_name); } } // Handle the file upload if there is one if(!empty($_FILES['upload_file']['name'])) { $file_name = stripslashes($_FILES['upload_file']['name']); $file_name = str_replace(array("'",","), "", $file_name); $file_name = cleanFileName($file_name); $ext_msg = ""; if($_FILES['upload_file']['size'] <= 1000000 && $_FILES['upload_file']['size'] > 0) { if (ereg(getFileFilter($cfg["file_types_array"]), $file_name)) { //FILE IS BEING UPLOADED if (is_file($cfg["torrent_file_path"].$file_name)) { // Error $messages .= "Error with (".htmlentities($file_name)."), the file already exists on the server.
[Refresh]
"; $ext_msg = "DUPLICATE :: "; } else { if(move_uploaded_file($_FILES['upload_file']['tmp_name'], $cfg["torrent_file_path"].$file_name)) { chmod($cfg["torrent_file_path"].$file_name, 0644); AuditAction($cfg["constants"]["file_upload"], $file_name); header("location: ".$_SERVER['PHP_SELF']); } else { $messages .= "ERROR: File not uploaded, file could not be found or could not be moved:
".$cfg["torrent_file_path"] . htmlentities($file_name)."

"; } } } else { $messages .= "ERROR: The type of file you are uploading is not allowed.
"; } } else { $messages .= "ERROR: File not uploaded, check file size limit.
"; } if($messages != "") { // there was an error AuditAction($cfg["constants"]["error"], $cfg["constants"]["file_upload"]." :: ".$ext_msg.$file_name); } } // End File Upload // if a file was set to be deleted then delete it $delfile = SecurityClean(getRequestVar('delfile')); if(! $delfile == '') { $alias_file = SecurityClean(getRequestVar('alias_file')); if (($cfg["user"] == getOwner($delfile)) || IsAdmin()) { @unlink($cfg["torrent_file_path"].$delfile); @unlink($cfg["torrent_file_path"].$alias_file); // try to remove the QInfo if in case it was queued. @unlink($cfg["torrent_file_path"]."queue/".$alias_file.".Qinfo"); // try to remove the pid file @unlink($cfg["torrent_file_path"].$alias_file.".pid"); @unlink($cfg["torrent_file_path"].getAliasName($delfile).".prio"); AuditAction($cfg["constants"]["delete_torrent"], $delfile); header("location: ".$_SERVER['PHP_SELF']); exit(); } else { AuditAction($cfg["constants"]["error"], $cfg["user"]." attempted to delete ".$delfile); } } // Did the user select the option to kill a running torrent? $kill = getRequestVar('kill'); if(! $kill == '' && is_numeric($kill) ) { include_once("AliasFile.php"); include_once("RunningTorrent.php"); $kill_torrent = getRequestVar('kill_torrent'); $alias_file = SecurityClean(getRequestVar('alias_file')); // We are going to write a '0' on the front of the stat file so that // the BT client will no to stop -- this will report stats when it dies $the_user = getOwner($kill_torrent); // read the alias file // create AliasFile object $af = new AliasFile($cfg["torrent_file_path"].$alias_file, $the_user); if($af->percent_done < 100) { // The torrent is being stopped but is not completed dowloading $af->percent_done = ($af->percent_done + 100)*-1; $af->running = "0"; $af->time_left = "Torrent Stopped"; } else { // Torrent was seeding and is now being stopped $af->percent_done = 100; $af->running = "0"; $af->time_left = "Download Succeeded!"; } // see if the torrent process is hung. if (!is_file($cfg["torrent_file_path"].$alias_file.".pid")) { $runningTorrents = getRunningTorrents(); foreach ($runningTorrents as $key => $value) { $rt = new RunningTorrent($value); if ($rt->statFile == $alias_file) { AuditAction($cfg["constants"]["error"], "Posible Hung Process " . $rt->processId); // $result = exec("kill ".$rt->processId); } } } // Write out the new Stat File $af->WriteFile(); AuditAction($cfg["constants"]["kill_torrent"], $kill_torrent); $return = getRequestVar('return'); if (!empty($return)) { sleep(3); passthru("kill ".$kill); // try to remove the pid file @unlink($cfg["torrent_file_path"].$alias_file.".pid"); header("location: ".$return.".php?op=queueSettings"); exit(); } else { header("location: ".$_SERVER['PHP_SELF']); exit(); } } // Did the user select the option to remove a torrent from the Queue? if(isset($_REQUEST["dQueue"])) { $alias_file = SecurityClean(getRequestVar('alias_file')); $QEntry = getRequestVar('QEntry'); // Is the Qinfo file still there? if (file_exists($cfg["torrent_file_path"]."queue/".$alias_file.".Qinfo")) { // Yes, then delete it and update the stat file. include_once("AliasFile.php"); // We are going to write a '2' on the front of the stat file so that // it will be set back to New Status $the_user = getOwner($QEntry); // read the alias file // create AliasFile object $af = new AliasFile($cfg["torrent_file_path"].$alias_file, $the_user); if($af->percent_done > 0 && $af->percent_done < 100) { // has downloaded something at some point, mark it is incomplete $af->running = "0"; $af->time_left = "Torrent Stopped"; } if ($af->percent_done == 0 || $af->percent_done == "") { $af->running = "2"; $af->time_left = ""; } if ($af->percent_done == 100) { // Torrent was seeding and is now being stopped $af->running = "0"; $af->time_left = "Download Succeeded!"; } // Write out the new Stat File $af->WriteFile(); // Remove Qinfo file. @unlink($cfg["torrent_file_path"]."queue/".$alias_file.".Qinfo"); AuditAction($cfg["constants"]["unqueued_torrent"], $QEntry); } else { // torrent has been started... try and kill it. AuditAction($cfg["constants"]["unqueued_torrent"], $QEntry . "has been started -- TRY TO KILL IT"); header("location: ".$_SERVER['PHP_SELF']."?alias_file=".$alias_file."&kill=true&kill_torrent=".urlencode($QEntry)); exit(); } header("location: ".$_SERVER['PHP_SELF']); exit(); } $drivespace = getDriveSpace($cfg["path"]); sajax_init(); // $sajax_debug_mode = 1; sajax_export("ajaxUpdate"); sajax_handle_client_request(); /************************************************************ ************************************************************/ ?> <?php echo $cfg["pagetitle"] ?> /style.css" TYPE="text/css"> "; ?> "; echo " "> ">


" cellpadding="4" cellspacing="0" width="100%">
/images/bar.gif">
">
:

:

Torrent :
" width="310" valign="top"> "; $arUsers = GetUsers(); $arOnlineUsers = array(); $arOfflineUsers = array(); for($inx = 0; $inx < count($arUsers); $inx++) { if(IsOnline($arUsers[$inx])) { array_push($arOnlineUsers, $arUsers[$inx]); } else { array_push($arOfflineUsers, $arUsers[$inx]); } } echo ""; ?>
:
".$link['sitename']."
\n"; } } echo "
"; echo ""._ONLINE.":
"; for($inx = 0; $inx < count($arOnlineUsers); $inx++) { echo ""; echo "". $arOnlineUsers[$inx]; echo "
\n"; } echo "
"; // Does the user want to see offline users? if ($cfg["hide_offline"] == false) { echo ""._OFFLINE.":
"; // Show offline users for($inx = 0; $inx < count($arOfflineUsers); $inx++) { echo ""; echo "".$arOfflineUsers[$inx]; echo "
\n"; } echo "
"; } echo "
" colspan="2">
" colspan="2">
" colspan="6">
                        Download Torrent
0) { echo " Queue Manager Running
"; echo "".strval(getRunningTorrentCount())." torrent(s) running and ".strval(getNumberOfQueuedTorrents())." queued.
"; echo "Total torrents server will run: ".$cfg["maxServerThreads"]."
"; echo "Total torrents a user may run: ".$cfg["maxUserThreads"]."
"; echo "* Torrents are queued when limits are met.
"; } else { echo " Queue Manager Off

"; } ?>
".$cfg["page_refresh"]." "._SECONDS." ***
"; echo ""._TURNOFFREFRESH.""; echo "   Turn ON Ajax"; } else { echo "*** "._PAGEWILLREFRESH." ".$cfg["ajax_refresh"]." "._SECONDS." ***
"; echo ""._TURNOFFREFRESH.""; echo "   Turn OFF Ajax"; } } else { echo ""._TURNONREFRESH.""; } if($drivespace >= 98) { echo "\n\n"; } if (!array_key_exists("total_download",$cfg)) $cfg["total_download"] = 0; if (!array_key_exists("total_upload",$cfg)) $cfg["total_upload"] = 0; ?>
: kB/s
: kB/s
:
: ".$loadavg.""; } else { echo "n/a"; } ?>