ERROR: ".$dirName." Path is not valid. Please edit settings
"; } else { echo "ERROR: Contact an admin the Path is not valid.
"; } return; } $lastUser = ""; $arUserTorrent = array(); $arListTorrent = array(); while($entry = readdir($handle)) { if ($entry != "." && $entry != "..") { if (is_dir($dirName."/".$entry)) { // don''t do a thing } else { if (ereg($file_filter, $entry)) { $key = filemtime($dirName."/".$entry).md5($entry); $arList[$key] = $entry; } } } } // sort the files by date krsort($arList); $count = -1; foreach($arList as $entry) { $count++; $output = ""; $displayname = $entry; $show_run = true; $torrentowner = getOwner($entry); $owner = IsOwner($cfg["user"], $torrentowner); $kill_id = ""; $estTime = " "; $alias = getAliasName($entry).".stat"; $af = new AliasFile($dirName.$alias, $torrentowner); $timeStarted = ""; $torrentfilelink = ""; if(!file_exists($dirName.$alias)) { $af->running = "2"; // file is new $af->size = getDownloadSize($dirName.$entry); $af->WriteFile(); } if(strlen($entry) >= 47) { // needs to be trimmed $displayname = substr($entry, 0, 44); $displayname .= "..."; } // find out if any screens are running and take their PID and make a KILL option foreach ($runningTorrents as $key => $value) { $rt = new RunningTorrent($value); if ($rt->statFile == $alias) { if ($kill_id == "") { $kill_id = $rt->processId; } else { // there is more than one PID for this torrent // Add it so it can be killed as well. $kill_id .= "|".$rt->processId; } } } // Check to see if we have a pid without a process. if (is_file($cfg["torrent_file_path"].$alias.".pid") && empty($kill_id)) { // died outside of tf and pid still exists. @unlink($cfg["torrent_file_path"].$alias.".pid"); if(($af->percent_done < 100) && ($af->percent_done >= 0)) { // The file is not running and the percent done needs to be changed $af->percent_done = ($af->percent_done+100)*-1; } $af->running = "0"; $af->time_left = "Torrent Died"; $af->up_speed = ""; $af->down_speed = ""; // write over the status file so that we can display a new status $af->WriteFile(); } if ($cfg["enable_torrent_download"]) { $torrentfilelink = ""; } $hd = getStatusImage($af); $output .= "image."\" width=16 height=16 title=\"".$hd->title.$entry."\" border=0 align=\"absmiddle\">".$torrentfilelink.$displayname.""; $output .= "".formatBytesToKBMGGB($af->size).""; $output .= "".$torrentowner.""; $output .= "
"; if ($af->running == "2") { $output .= ""._NEW.""; } elseif ($af->running == "3" ) { $estTime = "Waiting..."; $qDateTime = ''; if(is_file($dirName."queue/".$alias.".Qinfo")) { $qDateTime = date("m/d/Y H:i:s", strval(filectime($dirName."queue/".$alias.".Qinfo"))); } $output .= "', CSSCLASS);\" onmouseout=\"return nd();\">"._QUEUED.""; } else { if ($af->time_left != "" && $af->time_left != "0") { $estTime = $af->time_left; } $sql_search_time = "Select time from tf_log where action like '%Upload' and file like '".$entry."%'"; $result_search_time = $db->Execute($sql_search_time); list($uploaddate) = $result_search_time->FetchRow(); $lastUser = $torrentowner; $sharing = $af->sharing."%"; $graph_width = 1; $progress_color = "#00ff00"; $background = "#000000"; $bar_width = "4"; $popup_msg = _ESTIMATEDTIME.": ".$af->time_left; $popup_msg .= "
"._DOWNLOADSPEED.": ".$af->down_speed; $popup_msg .= "
"._UPLOADSPEED.": ".$af->up_speed; $popup_msg .= "
"._SHARING.": ".$sharing; $popup_msg .= "
Seeds: ".$af->seeds; $popup_msg .= "
Peers: ".$af->peers; $popup_msg .= "
"._USER.": ".$torrentowner; $eCount = 0; foreach ($af->errors as $key => $value) { if(strpos($value," (x")) { $curEMsg = substr($value,strpos($value," (x")+3); $eCount += substr($curEMsg,0,strpos($curEMsg,")")); } else { $eCount += 1; } } $popup_msg .= "
"._ERRORSREPORTED.": ".strval($eCount); $popup_msg .= "
"._UPLOADED.": ".date("m/d/Y H:i:s", $uploaddate); if (is_file($dirName.$alias.".pid")) { $timeStarted = "
"._STARTED.": ".date("m/d/Y H:i:s", strval(filectime($dirName.$alias.".pid"))); } // incriment the totals if(!isset($cfg["total_upload"])) $cfg["total_upload"] = 0; if(!isset($cfg["total_download"])) $cfg["total_download"] = 0; $cfg["total_upload"] = $cfg["total_upload"] + GetSpeedValue($af->up_speed); $cfg["total_download"] = $cfg["total_download"] + GetSpeedValue($af->down_speed); if($af->percent_done >= 100) { if(trim($af->up_speed) != "" && $af->running == "1") { $popup_msg .= $timeStarted; $output .= "', CSSCLASS);\" onmouseout=\"return nd();\">seeding (".$af->up_speed.") ".$sharing.""; } else { $popup_msg .= "
"._ENDED.": ".date("m/d/Y H:i:s", strval(filemtime($dirName.$alias))); $output .= "', CSSCLASS);\" onmouseout=\"return nd();\">"._DONE.""; } $show_run = false; } else if ($af->percent_done < 0) { $popup_msg .= $timeStarted; $output .= "', CSSCLASS);\" onmouseout=\"return nd();\">"._INCOMPLETE.""; $show_run = true; } else { $popup_msg .= $timeStarted; if($af->percent_done > 1) { $graph_width = $af->percent_done; } if($graph_width == 100) { $background = $progress_color; } $output .= "', CSSCLASS);\" onmouseout=\"return nd();\">"; $output .= "".$af->percent_done."% @ ".$af->down_speed."
"; $output .= ""; $output .= ""; $output .= ""; $output .= "
"; } } $output .= "
"; $output .= "
".$estTime."
"; $output .= "
"; $torrentDetails = _TORRENTDETAILS; if ($lastUser != "") { $torrentDetails .= "\n"._USER.": ".$lastUser; } $output .= "running == 1) { $output .= "&als=false"; } $output .= "\">"; if ($owner || IsAdmin($cfg["user"])) { if($kill_id != "" && $af->percent_done >= 0 && $af->running == 1) { $output .= ""; $output .= ""; } else { if($torrentowner == "n/a") { $output .= ""; } else { if ($af->running == "3") { $output .= ""; } else { if (!is_file($cfg["torrent_file_path"].$alias.".pid")) { // Allow Avanced start popup? if ($cfg["advanced_start"]) { if($show_run) { $output .= ""; } else { $output .= ""; } } else { // Quick Start if($show_run) { $output .= ""; } else { $output .= ""; } } } else { // pid file exists so this may still be running or dieing. $output .= ""; } } } if (!is_file($cfg["torrent_file_path"].$alias.".pid")) { $deletelink = $_SERVER['PHP_SELF']."?alias_file=".$alias."&delfile=".urlencode($entry); $output .= ""; } else { // pid file present so process may be still running. don't allow deletion. $output .= ""; } } } else { $output .= ""; $output .= ""; } $output .= "
"; $output .= ""; $output .= "\n"; // Is this torrent for the user list or the general list? if ($cfg["user"] == getOwner($entry)) { array_push($arUserTorrent, $output); } else { array_push($arListTorrent, $output); } } closedir($handle); // Now spit out the junk echo ""; if (sizeof($arUserTorrent) > 0) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; foreach($arUserTorrent as $torrentrow) { echo $torrentrow; } } if (sizeof($arListTorrent) > 0) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; foreach($arListTorrent as $torrentrow) { echo $torrentrow; } } } // *************************************************************************** // *************************************************************************** // Display the Drive Space Graphical Bar function displayDriveSpaceBarAjax($drivespace) { global $cfg; $freeSpace = ""; if ($drivespace > 20) { $freeSpace = " (".formatFreeSpace($cfg["free_space"])." Free)"; } ?>
".$cfg["user"].": "._TORRENTFILE."
Size
"._USER."
"._STATUS."
"._ESTIMATEDTIME."
"._ADMIN."
"._TORRENTFILE."
Size
"._USER."
"._STATUS."
"._ESTIMATEDTIME."
"._ADMIN."
:
/images/proglass.gif" width="%">
/images/noglass.gif" width="%">
20) { $freeSpace = " (".formatFreeSpace($cfg["free_space"])." Free)"; } $dirName = $cfg["torrent_file_path"]; if (is_dir($dirName)) { $handle = opendir($dirName); } else { return; } $lastUser = ""; $arUserTorrent = array(); $arListTorrent = array(); while($entry = readdir($handle)) { if ($entry != "." && $entry != "..") { if (is_dir($dirName."/".$entry)) { // don''t do a thing } else { if (ereg($file_filter, $entry)) { $key = filemtime($dirName."/".$entry).md5($entry); $arList[$key] = $entry; } } } } // sort the files by date krsort($arList); $count = -1; foreach($arList as $entry) { $count++; $ajax_popup[$count] = ""; $ajax_status[$count] = ""; $ajax_time[$count] = " "; $ajax_progress[$count] = ""; $output = ""; $displayname = $entry; $show_run = true; $torrentowner = getOwner($entry); $owner = IsOwner($cfg["user"], $torrentowner); $kill_id = ""; $estTime = " "; $alias = getAliasName($entry).".stat"; $af = new AliasFile($dirName.$alias, $torrentowner); $timeStarted = ""; $torrentfilelink = ""; if(!file_exists($dirName.$alias)) { $af->running = "2"; // file is new $af->size = getDownloadSize($dirName.$entry); $af->WriteFile(); } if(strlen($entry) >= 47) { // needs to be trimmed $displayname = substr($entry, 0, 44); $displayname .= "..."; } // find out if any screens are running and take their PID and make a KILL option foreach ($runningTorrents as $key => $value) { $rt = new RunningTorrent($value); if ($rt->statFile == $alias) { if ($kill_id == "") { $kill_id = $rt->processId; } else { // there is more than one PID for this torrent // Add it so it can be killed as well. $kill_id .= "|".$rt->processId; } } } // Check to see if we have a pid without a process. if (is_file($cfg["torrent_file_path"].$alias.".pid") && empty($kill_id)) { // died outside of tf and pid still exists. @unlink($cfg["torrent_file_path"].$alias.".pid"); if(($af->percent_done < 100) && ($af->percent_done >= 0)) { // The file is not running and the percent done needs to be changed $af->percent_done = ($af->percent_done+100)*-1; } $af->running = "0"; $af->time_left = "Torrent Died"; $af->up_speed = ""; $af->down_speed = ""; // write over the status file so that we can display a new status $af->WriteFile(); } if ($cfg["enable_torrent_download"]) { $torrentfilelink = ""; } $hd = getStatusImage($af); $new_ajax_refresh_string .= $hd->image . ";"; $output .= "image."\" width=16 height=16 title=\"".$hd->title.$entry."\" border=0 align=\"absmiddle\">".$torrentfilelink.$displayname.""; $output .= "".formatBytesToKBMGGB($af->size).""; $output .= "".$torrentowner.""; $output .= "
"; if ($af->running == "2") { $new_ajax_refresh_string .= "new;"; $ajax_status[$count] = _NEW; } elseif ($af->running == "3" ) { $ajax_time[$count] = "Waiting..."; $qDateTime = ''; if(is_file($dirName."queue/".$alias.".Qinfo")) { $qDateTime = date("m/d/Y H:i:s", strval(filectime($dirName."queue/".$alias.".Qinfo"))); } $new_ajax_refresh_string .= "queued;"; $ajax_popup[$count] = "return overlib('"._QUEUED.": ".$qDateTime."
', CSSCLASS);"; $ajax_status[$count] = _QUEUED; } else { $new_ajax_refresh_string .= "running;"; if ($af->time_left != "" && $af->time_left != "0") { $ajax_time[$count] = $af->time_left; } $sql_search_time = "Select time from tf_log where action like '%Upload' and file like '".$entry."%'"; $result_search_time = $db->Execute($sql_search_time); list($uploaddate) = $result_search_time->FetchRow(); $lastUser = $torrentowner; $sharing = $af->sharing."%"; $graph_width = 1; $progress_color = "#00ff00"; $background = "#000000"; $bar_width = "4"; $ajax_popup[$count] = _ESTIMATEDTIME.": ".$af->time_left; $ajax_popup[$count] .= "
"._DOWNLOADSPEED.": ".$af->down_speed; $ajax_popup[$count] .= "
"._UPLOADSPEED.": ".$af->up_speed; $ajax_popup[$count] .= "
"._SHARING.": ".$sharing; $ajax_popup[$count] .= "
Seeds: ".$af->seeds; $ajax_popup[$count] .= "
Peers: ".$af->peers; $ajax_popup[$count] .= "
"._USER.": ".$torrentowner; $eCount = 0; foreach ($af->errors as $key => $value) { if(strpos($value," (x")) { $curEMsg = substr($value,strpos($value," (x")+3); $eCount += substr($curEMsg,0,strpos($curEMsg,")")); } else { $eCount += 1; } } $ajax_popup[$count] .= "
"._ERRORSREPORTED.": ".strval($eCount); $ajax_popup[$count] .= "
"._UPLOADED.": ".date("m/d/Y H:i:s", $uploaddate); if (is_file($dirName.$alias.".pid")) { $timeStarted = "
"._STARTED.": ".date("m/d/Y H:i:s", strval(filectime($dirName.$alias.".pid"))); } // incriment the totals if(!isset($cfg["total_upload"])) $cfg["total_upload"] = 0; if(!isset($cfg["total_download"])) $cfg["total_download"] = 0; $cfg["total_upload"] = $cfg["total_upload"] + GetSpeedValue($af->up_speed); $cfg["total_download"] = $cfg["total_download"] + GetSpeedValue($af->down_speed); if($af->percent_done >= 100) { if(trim($af->up_speed) != "" && $af->running == "1") { $ajax_popup[$count] .= $timeStarted; $ajax_popup[$count] = "return overlib('".$ajax_popup[$count]."
', CSSCLASS);"; $ajax_status[$count] = "seeding (".$af->up_speed.") ".$sharing; $new_ajax_refresh_string .= "seeding;"; } else { $ajax_popup[$count] .= "
"._ENDED.": ".date("m/d/Y H:i:s", strval(filemtime($dirName.$alias))); $ajax_popup[$count] = "return overlib('".$ajax_popup[$count]."
', CSSCLASS);"; $ajax_status[$count] = _DONE; $new_ajax_refresh_string .= "done;"; } $show_run = false; } else if ($af->percent_done < 0) { $ajax_popup[$count] .= $timeStarted; $ajax_popup[$count] = "return overlib('".$ajax_popup[$count]."
', CSSCLASS);"; $ajax_status[$count] = _INCOMPLETE; $new_ajax_refresh_string .= "incomplete;"; $show_run = true; } else { $ajax_popup[$count] .= $timeStarted; if($af->percent_done > 1) { $graph_width = $af->percent_done; } if($graph_width == 100) { $background = $progress_color; } $ajax_popup[$count] = "return overlib('".$ajax_popup[$count]."
', CSSCLASS);"; $ajax_status[$count] = "".$af->percent_done."% @ ".$af->down_speed; $ajax_progress[$count] = $graph_width; $new_ajax_refresh_string .= "downloading;"; } } $torrentDetails = _TORRENTDETAILS; if ($lastUser != "") { $torrentDetails .= "\n"._USER.": ".$lastUser; } $output .= "running == 1) { $output .= "&als=false"; } $output .= "\">"; if ($owner || IsAdmin($cfg["user"])) { if($kill_id != "" && $af->percent_done >= 0 && $af->running == 1) { $output .= ""; $output .= ""; $new_ajax_refresh_string .= "stop;"; } else { if($torrentowner == "n/a") { $output .= ""; } else { if ($af->running == "3") { $output .= ""; $new_ajax_refresh_string .= "delqueue;"; } else { if (!is_file($cfg["torrent_file_path"].$alias.".pid")) { // Allow Avanced start popup? if ($cfg["advanced_start"]) { if($show_run) { $output .= ""; $new_ajax_refresh_string .= "run;"; } else { $output .= ""; $new_ajax_refresh_string .= "seed;"; } } else { // Quick Start if($show_run) { $output .= ""; $new_ajax_refresh_string .= "run;"; } else { $output .= ""; $new_ajax_refresh_string .= "seed;"; } } } else { // pid file exists so this may still be running or dieing. $output .= ""; $new_ajax_refresh_string .= "stopping;"; } } } if (!is_file($cfg["torrent_file_path"].$alias.".pid")) { $deletelink = $_SERVER['PHP_SELF']."?alias_file=".$alias."&delfile=".urlencode($entry); $output .= ""; $new_ajax_refresh_string .= "delete;"; } else { // pid file present so process may be still running. don't allow deletion. $output .= ""; $new_ajax_refresh_string .= "stillstopping;"; } } } else { $output .= ""; $output .= ""; } $output .= "
"; $output .= ""; $output .= "\n"; // Is this torrent for the user list or the general list? if ($cfg["user"] == getOwner($entry)) { array_push($arUserTorrent, $output); } else { array_push($arListTorrent, $output); } } closedir($handle); // Prepare the update data. Everything is urlencoded and separated by '&'. // The keys are also separated from the values by '='. $result = ""; $result .= "drive=" . urlencode($drivespace) . "&"; $result .= "drive_free=" . urlencode($drivespace . "%" . $freeSpace). "&"; for ($i = 0; $i <= $count; $i++) { $result .= "popup_" . $i . "=" . urlencode($ajax_popup[$i]) . "&status_" . $i . "=" . urlencode($ajax_status[$i]) . "&time_" . $i . "=" . urlencode($ajax_time[$i]) . "&progress_" . $i . "="; if (isset($ajax_progress[$i])) { $result .= urlencode($ajax_progress[$i]) . "&"; } else { $result .= "&"; } } if(checkQManager() > 0) { $result .= "running=" . strval(getRunningTorrentCount()) . "&"; $result .= "queued=" . strval(getNumberOfQueuedTorrents()) . "&"; } $result .= "down=" . urlencode(number_format($cfg["total_download"], 2)) . "&"; $result .= "up=" . urlencode(number_format($cfg["total_upload"], 2)) . "&"; $result .= "free=" . urlencode(formatFreeSpace($cfg["free_space"])); if ($cfg["show_server_load"] && isFile($cfg["loadavg_path"])) { $loadavg_array = explode(" ", exec("cat ".$cfg["loadavg_path"])); $loadavg = $loadavg_array[2]; $result .= "&load=" . urlencode($loadavg); } // Check if we've updated before if (!isset($_SESSION['ajax_reload'])) { $_SESSION['ajax_reload'] = md5($new_ajax_refresh_string); return $result; } else { // Check if the page layout needs to change if ($_SESSION['ajax_reload'] != md5($new_ajax_refresh_string)) { // Need to refresh the page $result = "reload=" . urlencode("true"); unset($_SESSION['ajax_reload']); return $result; } else { // No refresh needed, send the update return $result; } } } ?>