Beispiel #1
0
 /**
  * process a request
  */
 function instance_processRequest()
 {
     global $cfg, $db;
     // type-switch
     switch ($this->_type) {
         case "all":
             if (!($this->_format == "txt" && $this->_header == 0)) {
                 $this->_transferHeads = getTransferListHeadArray();
             }
             $this->_indent = " ";
             // xfer-init
             if ($cfg['xfer_realtime'] == 0) {
                 $cfg['xfer_realtime'] = 1;
                 // set xfer-newday
                 Xfer::setNewday();
             }
             $this->_transferList = getTransferListArray();
             $this->_initServerStats();
             $this->_initXferStats();
             $this->_initUserStats();
             break;
         case "server":
             $this->_indent = "";
             $this->_transferList = getTransferListArray();
             $this->_initServerStats();
             break;
         case "xfer":
             $this->_indent = "";
             // xfer-init
             if ($cfg['xfer_realtime'] == 0) {
                 $cfg['xfer_realtime'] = 1;
                 // set xfer-newday
                 Xfer::setNewday();
             }
             $this->_transferList = getTransferListArray();
             $this->_initXferStats();
             break;
         case "transfers":
             $this->_indent = "";
             $this->_transferList = getTransferListArray();
             if (!($this->_format == "txt" && $this->_header == 0)) {
                 $this->_transferHeads = getTransferListHeadArray();
             }
             break;
         case "transfer":
             // transfer-id
             if (empty($this->_transferID)) {
                 @error("missing params", "stats.php", "", array('i'));
             }
             // validate transfer
             if (tfb_isValidTransfer($this->_transferID) !== true) {
                 AuditAction($cfg["constants"]["error"], "INVALID TRANSFER: " . $this->_transferID);
                 @error("Invalid Transfer", "", "", array($this->_transferID));
             }
             $this->_indent = "";
             $this->_transferDetails = getTransferDetails($this->_transferID, false);
             break;
         case "users":
             $this->_indent = "";
             $this->_initUserStats();
             break;
         case "usage":
             $this->_sendUsage();
     }
     // action
     switch ($this->_format) {
         case "xml":
             $this->_sendXML();
         case "rss":
             $this->_sendRSS();
         case "txt":
             $this->_sendTXT();
     }
 }
 /**
  * Show Transfers
  *
  * @return mixed
  */
 function _transfers()
 {
     global $cfg;
     // print out transfers
     echo "Transfers:\n";
     $transferHeads = getTransferListHeadArray();
     echo "* Name * " . implode(" * ", $transferHeads) . "\n";
     $transferList = getTransferListArray();
     foreach ($transferList as $transferAry) {
         echo "- " . implode(" - ", $transferAry) . "\n";
     }
     // print out stats
     echo "Server:\n";
     if (!array_key_exists("total_download", $cfg)) {
         $cfg["total_download"] = 0;
     }
     if (!array_key_exists("total_upload", $cfg)) {
         $cfg["total_upload"] = 0;
     }
     echo $cfg['_UPLOADSPEED'] . "\t" . ': ' . number_format($cfg["total_upload"], 2) . ' kB/s' . "\n";
     echo $cfg['_DOWNLOADSPEED'] . "\t" . ': ' . number_format($cfg["total_download"], 2) . ' kB/s' . "\n";
     echo $cfg['_TOTALSPEED'] . "\t" . ': ' . number_format($cfg["total_download"] + $cfg["total_upload"], 2) . ' kB/s' . "\n";
     echo $cfg['_ID_CONNECTIONS'] . "\t" . ': ' . netstatConnectionsSum() . "\n";
     return true;
 }