function cliWatchDir($tpath = "", $username = "") { global $cfg; if (isset($tpath) && $tpath != "" && isset($username) && $username != "") { if (is_dir($tpath)) { $cfg['user'] = $username; $watchDir = checkDirPathString($tpath); if ($dirHandle = opendir($tpath)) { while (false !== ($file = readdir($dirHandle))) { if (strtolower(substr($file, -8)) == ".torrent") { $file_name = stripslashes($file); $file_name = str_replace(array("'", ","), "", $file_name); $file_name = cleanFileName($file_name); echo "Injecting and Starting " . $watchDir . $file . " as " . $file_name . " for user " . $cfg['user'] . "..."; if (is_file($watchDir . $file) && copy($watchDir . $file, $cfg["torrent_file_path"] . $file_name)) { @unlink($watchDir . $file); chmod($cfg["torrent_file_path"] . $file_name, 0644); AuditAction($cfg["constants"]["file_upload"], $file_name); // init stat-file injectTorrent($file_name); // file-prio if ($cfg["enable_file_priority"]) { include_once "setpriority.php"; // Process setPriority Request. setPriority($file_name); } // queue if ($cfg["AllowQueing"]) { $_REQUEST['queue'] = 'on'; } else { $_REQUEST['queue'] = 'off'; } // start include_once "ClientHandler.php"; $clientHandler = ClientHandler::getClientHandlerInstance($cfg); $clientHandler->startTorrentClient($file_name, 0); // just 2 secs.. sleep(2); if ($clientHandler->status == 3) { // hooray echo " done\n"; } else { // start failed echo "\n ERROR : " . $clientHandler->messages . "\n"; } } else { echo "\n ERROR: File could not be found or could not be copied: " . $watchDir . $file . "\n"; } } } closedir($dirHandle); } } else { echo "ERROR: " . $tpath . " is not a dir.\n"; exit; } } else { printUsage(); } exit; }
function indexProcessUpload() { global $cfg, $messages; $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 .= "<b>Error</b> with (<b>" . $file_name . "</b>), the file already exists on the server.<br><center><a href=\"" . $_SERVER['PHP_SELF'] . "\">[Refresh]</a></center>"; $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); // init stat-file injectTorrent($file_name); // instant action ? $actionId = getRequestVar('aid'); if (isset($actionId)) { switch ($actionId) { case 3: $_REQUEST['queue'] = 'on'; case 2: if ($cfg["enable_file_priority"]) { include_once "setpriority.php"; // Process setPriority Request. setPriority(urldecode($file_name)); } include_once "ClientHandler.php"; $clientHandler = ClientHandler::getClientHandlerInstance($cfg); $clientHandler->startTorrentClient($file_name, 0); // just a sec.. sleep(1); break; } } } else { $messages .= "<font color=\"#ff0000\" size=3>ERROR: File not uploaded, file could not be found or could not be moved:<br>" . $cfg["torrent_file_path"] . $file_name . "</font><br>"; } } } else { $messages .= "<font color=\"#ff0000\" size=3>ERROR: The type of file you are uploading is not allowed.</font><br>"; } } else { $messages .= "<font color=\"#ff0000\" size=3>ERROR: File not uploaded, check file size limit.</font><br>"; } if ($messages != "") { // there was an error AuditAction($cfg["constants"]["error"], $cfg["constants"]["file_upload"] . " :: " . $ext_msg . $file_name); } else { header("location: index.php"); exit; } }
if (isset($messages) && $messages != "") { // there was an error AuditAction($cfg["constants"]["error"], $cfg["constants"]["file_upload"] . " :: " . $ext_msg . $file_name); } } // End File Upload // instant action ? if (isset($actionId)) { switch ($actionId) { case 3: $_REQUEST['queue'] = 'on'; case 2: include_once "ClientHandler.php"; foreach ($tStack as $torrent) { // init stat-file injectTorrent($torrent); // if ($cfg["enable_file_priority"]) { include_once "setpriority.php"; // Process setPriority Request. setPriority(urldecode($torrent)); } $clientHandler = ClientHandler::getClientHandlerInstance($cfg); $clientHandler->startTorrentClient($torrent, 0); // just a sec.. sleep(1); } break; } } // back to index if no errors