/** * reset Xfer-Stats * * @return true or function exits with error */ function resetStats() { global $db; // exec delete $db->Execute("DELETE FROM tf_xfer"); // set transfers-cache cacheTransfersSet(); //return return $db->ErrorNo() == 0 ? true : $db->ErrorMsg(); }
/** * resets totals of a transfer * * @param $transfer name of the transfer * @param $delete boolean if to delete meta-file * @return array */ function resetTransferTotals($transfer, $delete = false) { global $cfg, $db, $transfers; $msgs = array(); $tid = getTransferHash($transfer); $client = getTransferClient($transfer); // delete meta-file if ($delete) { $ch = ClientHandler::getInstance($client); $ch->delete($transfer); if (count($ch->messages) > 0) { $msgs = array_merge($msgs, $ch->messages); } } else { // reset in stat-file $sf = new StatFile($transfer, getOwner($transfer)); $sf->uptotal = 0; $sf->downtotal = 0; $sf->write(); if ($client == "vuzerpc") { require_once "inc/functions/functions.rpc.vuze.php"; vuzeResetUpload($tid); } } // reset in db $uid = (int) getTransferOwnerID($transfer); $sql = "UPDATE tf_transfer_totals SET uptotal=0 WHERE tid = " . $db->qstr($tid) . " AND uid IN (0,{$uid})"; $db->Execute($sql); if ($db->ErrorNo() != 0) { dbError($sql); } // set transfers-cache cacheTransfersSet(); return $msgs; }
/** * injects a transfer * * @param $transfer * @return boolean */ function injectTransfer($transfer) { global $cfg; $sf = new StatFile($transfer); $sf->running = "2"; // file is new $sf->size = getTransferSize($transfer); if ($sf->write()) { // set transfers-cache cacheTransfersSet(); return true; } else { AuditAction($cfg["constants"]["error"], "stat-file cannot be written when injecting : " . $transfer); return false; } }
/** * _updateStatFile * * @param $transfer */ function _updateStatFile($transfer) { global $transfers; $modded = 0; // create sf object $sf = new StatFile($transfer, getOwner($transfer)); if ($sf->percent_done > 0 && $sf->percent_done < 100) { // has downloaded something at some point, mark it is incomplete $sf->running = "0"; $sf->time_left = "Transfer Stopped"; $modded++; } if ($modded == 0) { if ($sf->percent_done == 0 || $sf->percent_done == "") { // We are going to write a '2' on the front of the stat file so that it will be set back to New Status $sf->running = "2"; $sf->time_left = ""; $modded++; } } if ($modded == 0) { if ($sf->percent_done == 100) { // transfer was done and is now being stopped $sf->running = "0"; $sf->time_left = "Download Succeeded!"; $modded++; } } if ($modded == 0) { // hmmm this stat-file is quite strange... just rewrite it stopped. $sf->running = "0"; $sf->time_left = "Transfer Stopped"; } // Write out the new Stat File $sf->write(); // set transfers-cache cacheTransfersSet(); }
/** * updates totals of a transfer */ function _updateTotals() { global $db; $tid = getTransferHash($this->transfer); $transferTotals = $this->getTransferTotal($this->transfer); $sql = $db->GetOne("SELECT 1 FROM tf_transfer_totals WHERE tid = " . $db->qstr($tid)) ? "UPDATE tf_transfer_totals SET uptotal = " . $db->qstr($transferTotals["uptotal"]) . ", downtotal = " . $db->qstr($transferTotals["downtotal"]) . " WHERE tid = " . $db->qstr($tid) : "INSERT INTO tf_transfer_totals (tid,uptotal,downtotal) VALUES (" . $db->qstr($tid) . "," . $db->qstr($transferTotals["uptotal"]) . "," . $db->qstr($transferTotals["downtotal"]) . ")"; $db->Execute($sql); // set transfers-cache cacheTransfersSet(); }
loadLanguageFile($cfg["language_file"]); // set cache cacheSet($currentUser); // login-tasks if (!isset($_SESSION['login_tasks'])) { // check main-directories. checkMainDirectories(); // maintenance-run require_once "inc/classes/MaintenanceAndRepair.php"; MaintenanceAndRepair::maintenance(MAINTENANCEANDREPAIR_TYPE_STD); $_SESSION['next_int_maintenance'] = null; // set flag $_SESSION['login_tasks'] = 1; } // set transfers-cache cacheTransfersSet(); // set session-settings $_SESSION['settings']['index_meta_refresh'] = $cfg["enable_index_meta_refresh"] != 0 ? 1 : 0; $_SESSION['settings']['index_ajax_update'] = $cfg["enable_index_ajax_update"] != 0 ? 1 : 0; $_SESSION['settings']['index_show_seeding'] = $cfg["index_show_seeding"] != 0 ? 1 : 0; // xfer if ($cfg['enable_xfer'] == 1) { // xfer-init Xfer::init(); } } else { // Check for valid theme if (isset($cfg["theme"])) { $cfg["theme"] = CheckandSetUserTheme(); } // Run internal maintenance regularly
/** * resets totals of a transfer * * @param $transfer name of the transfer * @param $delete boolean if to delete meta-file * @return array */ function resetTransferTotals($transfer, $delete = false) { global $cfg, $db, $transfers; $msgs = array(); $tid = getTransferHash($transfer); // delete meta-file if ($delete) { $ch = ClientHandler::getInstance(getTransferClient($transfer)); $ch->delete($transfer); if (count($ch->messages) > 0) { $msgs = array_merge($msgs, $ch->messages); } } else { // reset in stat-file $sf = new StatFile($transfer, getOwner($transfer)); $sf->uptotal = 0; $sf->downtotal = 0; $sf->write(); } // reset in db $sql = "DELETE FROM tf_transfer_totals WHERE tid = " . $db->qstr($tid); $db->Execute($sql); if ($db->ErrorNo() != 0) { dbError($sql); } // set transfers-cache cacheTransfersSet(); return $msgs; }
/** * reset transfer-Totals * * @return true or function exits with error */ function resetAllTransferTotals() { global $db; $db->Execute("DELETE FROM tf_transfer_totals"); // set transfers-cache cacheTransfersSet(); return $db->ErrorNo() == 0 ? true : $db->ErrorMsg(); }
/** * injects a torrent * * @param $url * @return boolean */ function inject($url) { global $cfg; // set vars from the url $this->setVarsFromUrl($url); // write meta-file $resultSuccess = false; if ($handle = @fopen($this->transferFilePath, "w")) { $resultSuccess = @fwrite($handle, $this->url) !== false; @fclose($handle); } if ($resultSuccess) { // Make an entry for the owner AuditAction($cfg["constants"]["file_upload"], basename($this->transferFilePath)); // inject stat $sf = new StatFile($this->transfer); $sf->running = "2"; // file is new $sf->size = getTransferSize($this->transfer); if (!$sf->write()) { $this->state = CLIENTHANDLER_STATE_ERROR; $msg = "wget-inject-error when writing stat-file for transfer : " . $this->transfer; array_push($this->messages, $msg); AuditAction($cfg["constants"]["error"], $msg); $this->logMessage($msg . "\n", true); $resultSuccess = false; } } else { $this->state = CLIENTHANDLER_STATE_ERROR; $msg = "wget-metafile cannot be written : " . $this->transferFilePath; array_push($this->messages, $msg); AuditAction($cfg["constants"]["error"], $msg); $this->logMessage($msg . "\n", true); } // set transfers-cache cacheTransfersSet(); // return return $resultSuccess; }