/**
 * indexDispatch
 */
function compat_tf_indexDispatch()
{
    // dispatcher-functions
    require_once "inc/functions/functions.dispatcher.php";
    // start
    if (isset($_REQUEST['torrent'])) {
        dispatcher_startTransfer(urldecode(tfb_getRequestVar('torrent')));
    }
    // stop
    if (isset($_REQUEST["kill_torrent"])) {
        dispatcher_stopTransfer(urldecode(tfb_getRequestVar('kill_torrent')));
    }
    // del
    if (isset($_REQUEST['delfile'])) {
        dispatcher_deleteTransfer(urldecode(tfb_getRequestVar('delfile')));
    }
    // deQueue
    if (isset($_REQUEST["QEntry"])) {
        dispatcher_deQueueTransfer(urldecode(tfb_getRequestVar('QEntry')));
    }
    // get torrent via url
    if (isset($_REQUEST['url_upload'])) {
        dispatcher_processDownload(tfb_getRequestVarRaw('url_upload'), 'torrent');
    }
    // file upload
    if (isset($_FILES['upload_file']) && !empty($_FILES['upload_file']['name'])) {
        compat_tf_processUpload();
    }
}
Exemple #2
0
*******************************************************************************/
// prevent direct invocation
if (!isset($cfg['user']) || isset($_REQUEST['cfg'])) {
    @ob_end_clean();
    @header("location: ../../index.php");
    exit;
}
/******************************************************************************/
// is enabled ?
if ($cfg["enable_dereferrer"] != 1) {
    AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: " . $cfg["user"] . " tried to use dereferrer");
    @error("dereferrer is disabled", "index.php?iid=index", "");
}
// check param
if (!isset($_REQUEST["u"])) {
    @header("location: index.php?iid=index");
    exit;
} else {
    $url = tfb_getRequestVarRaw("u");
}
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.dereferrer.tmpl");
// set vars
$url2 = tfb_htmlencode($url);
$tmpl->setvar('url', $url2);
$tmpl->setvar('meta_refresh', '0;URL=' . $url2);
//
tmplSetTitleBar($cfg["pagetitle"] . ' - dereferrer', false);
tmplSetFoot(false);
tmplSetIidVars();
$tmpl->pparse();
     }
     // title-bar
     tmplSetTitleBar("Administration - Fluxd Watch Settings");
     break;
 case "addJob":
 case "editJob":
 case "saveJob":
     $jobNumber = trim(tfb_getRequestVarRaw('job'));
     $isNew = empty($jobNumber);
     $watchdir = trim(tfb_getRequestVarRaw('watchdir'));
     $user = trim(tfb_getRequestVarRaw('user'));
     $profile = trim(tfb_getRequestVarRaw('profile'));
     $checkdir = trim(tfb_getRequestVarRaw('checkdir'));
     $postback = tfb_getRequestVarRaw('postback');
     $isPostback = $postback == '1';
     $refresh = tfb_getRequestVarRaw('refresh');
     $isRefresh = $refresh == '1';
     $isSave = $isPostback && !$isRefresh;
     $checkdir = $checkdir == '1' || $checkdir == 'on' || $checkdir == 'true';
     if ($isSave) {
         // saving (a new one or an existing one)
         $pageop2 = "saveJob";
         $paramErrors = 0;
         if (strlen($watchdir) == 0) {
             $paramErrors++;
         }
         if (strlen($user) == 0) {
             $paramErrors++;
         }
         if ($paramErrors != 0) {
             setWatchError('Error : Argument-Error.');
/**
 * log
 *
 * @param $action
 */
function sa_log($action = "")
{
    global $cfg, $error, $statusImage, $statusMessage, $htmlTitle, $htmlTop, $htmlMain;
    if ($action == "") {
        return;
    }
    buildPage("l");
    switch ($action) {
        case "0":
            // log-main
            $htmlTitle = "Log Viewer";
            $htmlMain .= '<br>Select the type of log you want to view below:<p>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?l=1"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="fluxd" border="0"> fluxd</a> - STDOUT logfiles for the torrentflux-b4rt fluxd daemon';
            $htmlMain .= '<p>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?l=2"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="fluxd-error" border="0"> fluxd-error</a> - STDERR logfiles for the torrentflux-b4rt fluxd daemon';
            $htmlMain .= '<p>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?l=3"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="fluazu" border="0"> fluazu</a> - logfiles for the fluazu interface to Azureus';
            $htmlMain .= '<p>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?l=5"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="mainline" border="0"> BitTorrent Mainline</a> - centralised logfile for the BitTorrent Mainline client';
            $htmlMain .= '<p>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?l=8"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="transfers" border="0"> Transfers</a> - logfiles for transfers in the current transfer list';
            $htmlMain .= '<br><br>';
            break;
        case "1":
            // fluxd-log
            $htmlTitle = "log - fluxd";
            $htmlMain .= '<div align="left" id="BodyLayer" name="BodyLayer" style="border: thin solid ' . $cfg['main_bgcolor'] . '; position:relative; width:740; height:498; padding-left: 5px; padding-right: 5px; z-index:1; overflow: scroll; visibility: visible">';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(@file_get_contents($cfg["path"] . '.fluxd/fluxd.log'));
            $htmlMain .= '</pre>';
            $htmlMain .= '</div>';
            break;
        case "2":
            // fluxd-error-log
            $htmlTitle = "log - fluxd - error-log";
            $htmlMain .= '<div align="left" id="BodyLayer" name="BodyLayer" style="border: thin solid ' . $cfg['main_bgcolor'] . '; position:relative; width:740; height:498; padding-left: 5px; padding-right: 5px; z-index:1; overflow: scroll; visibility: visible">';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(@file_get_contents($cfg["path"] . '.fluxd/fluxd-error.log'));
            $htmlMain .= '</pre>';
            $htmlMain .= '</div>';
            break;
        case "3":
            // fluazu-log
            $htmlTitle = "log - fluazu";
            $htmlMain .= '<div align="left" id="BodyLayer" name="BodyLayer" style="border: thin solid ' . $cfg['main_bgcolor'] . '; position:relative; width:740; height:498; padding-left: 5px; padding-right: 5px; z-index:1; overflow: scroll; visibility: visible">';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(@file_get_contents($cfg["path"] . '.fluazu/fluazu.log'));
            $htmlMain .= '</pre>';
            $htmlMain .= '</div>';
            break;
        case "5":
            // mainline-log
            $htmlTitle = "log - mainline";
            $htmlMain .= '<div align="left" id="BodyLayer" name="BodyLayer" style="border: thin solid ' . $cfg['main_bgcolor'] . '; position:relative; width:740; height:498; padding-left: 5px; padding-right: 5px; z-index:1; overflow: scroll; visibility: visible">';
            $htmlMain .= '<pre>';
            $mainlineLog = $cfg["path"] . '.bittorrent/tfmainline.log';
            if (is_file($mainlineLog)) {
                $htmlMain .= tfb_htmlencode(@file_get_contents($mainlineLog));
            } else {
                $htmlMain .= "mainline-log not found.";
            }
            $htmlMain .= '</pre>';
            $htmlMain .= '</div>';
            break;
        case "8":
            // transfers
            $htmlTitle = "log - transfers";
            $htmlMain .= "<br>Select the transfer you wish to view the logfile for from below:<br>";
            $logList = getTransferArray('na');
            if (isset($logList) && is_array($logList)) {
                $htmlMain .= '<ul>';
                foreach ($logList as $logFile) {
                    if (isset($logFile) && $logFile != "") {
                        $htmlMain .= '<li>';
                        $htmlMain .= '<a href="' . _FILE_THIS . '?l=9&transfer=' . urlencode($logFile) . '">';
                        $htmlMain .= tfb_htmlencode($logFile);
                        $htmlMain .= '</a>';
                        $htmlMain .= '</li>';
                    }
                }
                $htmlMain .= '</ul>';
            }
            break;
        case "9":
            // transfer-log
            if (isset($_REQUEST["transfer"])) {
                $transfer = trim(tfb_getRequestVarRaw('transfer'));
                // shorten name if too long
                if (strlen($transfer) >= 70) {
                    $htmlTitle = "log - transfer-log - " . tfb_htmlencodekeepspaces(substr($transfer, 0, 67)) . "...";
                } else {
                    $htmlTitle = "log - transfer-log - " . tfb_htmlencodekeepspaces($transfer);
                }
                $htmlMain .= '<div align="left" id="BodyLayer" name="BodyLayer" style="border: thin solid ' . $cfg['main_bgcolor'] . '; position:relative; width:740; height:498; padding-left: 5px; padding-right: 5px; z-index:1; overflow: scroll; visibility: visible">';
                $htmlMain .= '<pre>';
                $htmlMain .= tfb_htmlencode(getTransferLog($transfer));
                $htmlMain .= '</pre>';
                $htmlMain .= '</div>';
            } else {
                $htmlTitle = "log - transfer-log";
                $htmlMain .= '<font color="red">Error. missing params</font>';
            }
            break;
    }
    printPage();
    exit;
}
     dispatcher_setFilePriority(urldecode(tfb_getRequestVar('transfer')));
     break;
     /*******************************************************************************
      * injects
      ******************************************************************************/
 /*******************************************************************************
  * injects
  ******************************************************************************/
 case "fileUpload":
     dispatcher_processUpload();
     break;
 case "urlUpload":
     dispatcher_processDownload(tfb_getRequestVarRaw('url'), tfb_getRequestVar('type'));
     break;
 case "wget":
     dispatcher_injectWget(tfb_getRequestVarRaw('url'));
     break;
     /*******************************************************************************
      * metafile-download
      ******************************************************************************/
 /*******************************************************************************
  * metafile-download
  ******************************************************************************/
 case "metafileDownload":
     dispatcher_sendMetafile(tfb_getRequestVar('transfer'));
     break;
     /*******************************************************************************
      * set
      ******************************************************************************/
 /*******************************************************************************
  * set
/**
 * addRSS
 */
function admin_addRSS()
{
    global $cfg;
    $newRSS = tfb_getRequestVarRaw('newRSS');
    if (!empty($newRSS)) {
        addNewRSS($newRSS);
        AuditAction($cfg["constants"]["admin"], "New RSS: " . addslashes($newRSS));
    }
    @header("location: admin.php?op=editRSS");
    exit;
}
                     }
                 }
                 $tmpl->setloop('rssad_filters', $filterlist);
             }
         } else {
             $tmpl->setvar('rssad_job_loaded', 0);
             $tmpl->setvar('messages', $jobNumber);
         }
     }
     // title-bar
     tmplSetTitleBar("Administration - Fluxd Rssad - Edit Job");
     break;
 case "saveJob":
     $jobNumber = trim(tfb_getRequestVar('job'));
     $savedir = tfb_getRequestVar('savedir');
     $url = tfb_getRequestVarRaw('url');
     $filtername = tfb_getRequestVar('filtername');
     $checkdir = tfb_getRequestVar('checkdir');
     $isNew = empty($jobNumber) ? true : false;
     $doCheckdir = $checkdir == "true" ? true : false;
     $paramErrors = 0;
     if (empty($savedir)) {
         $paramErrors++;
     }
     if (empty($url)) {
         $paramErrors++;
     }
     if (empty($filtername)) {
         $paramErrors++;
     }
     if ($paramErrors != 0) {
require_once "inc/functions/functions.maketorrent.php";
// is enabled ?
if ($cfg["enable_maketorrent"] != 1) {
    AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: " . $cfg["user"] . " tried to use maketorrent");
    @error("maketorrent is disabled", "index.php?iid=index", "");
}
// check the needed bins
// python
if (@file_exists($cfg['pythonCmd']) !== true) {
    @error("Required binary could not be found", "", "", $cfg['isAdmin'] ? array('python is required for maketorrent', 'Specified python-binary does not exist: ' . $cfg['pythonCmd'], 'Check Settings on Admin-Server-Settings Page') : array('Please contact an Admin'));
}
/*******************************************************************************
 * create + page
 ******************************************************************************/
// file + torrent vars
$path = tfb_getRequestVarRaw('path');
$torrent = "";
if (!empty($path)) {
    $torrent = tfb_cleanFileName(StripFolders($path) . ".torrent");
    if ($torrent === false) {
        @error("Invalid torrent-name", "", "", array($path));
    }
}
// only valid dirs + entries with permission
if (!(tfb_isValidPath($cfg["path"] . $path) && hasPermission($path, $cfg["user"], 'w'))) {
    AuditAction($cfg["constants"]["error"], "ILLEGAL MAKETORRENT: " . $cfg["user"] . " tried to maketorrent with " . $path);
    @error("Illegal maketorrent. Action has been logged.", "", "");
}
// check if there is a var sent for client, if not use default
$client = isset($_REQUEST["client"]) ? tfb_getRequestVar('client') : $cfg["dir_maketorrent_default"];
// client-generic vars