コード例 #1
0
 function performSearch($searchTerm)
 {
     if ($searchTerm == "") {
         $request = "/";
     } else {
         $searchTerm = str_replace(" ", "+", $searchTerm);
         $request = "/search.php?terms=" . $searchTerm;
     }
     $cat = tfb_getRequestVar("cat");
     if (empty($cat)) {
         $cat = tfb_getRequestVar("mainGenre");
     }
     if (!empty($cat)) {
         if (strpos($request, "?")) {
             $request .= "&cat=" . $cat;
         } else {
             $request .= "?cat=" . $cat;
         }
     }
     if (!empty($this->pg)) {
         if (strpos($request, "?")) {
             $request .= "&page=" . $this->pg;
         } else {
             $request .= "?page=" . $this->pg;
         }
     }
     if ($this->makeRequest($request)) {
         return $this->parseResponse();
     } else {
         return $this->msg;
     }
 }
コード例 #2
0
 function getLatest()
 {
     $cat = tfb_getRequestVar('mainGenre');
     if (empty($cat)) {
         $cat = tfb_getRequestVar('c');
     }
     if (!empty($cat)) {
         $request = "/browse";
         if (strpos($request, "?")) {
             $request .= "&c=" . $cat;
         } else {
             $request .= "?c=" . $cat;
         }
     } else {
         $request = "/?do=latest";
     }
     if (!empty($this->pg)) {
         if (strpos($request, "?")) {
             $request .= "&p=" . $this->pg;
         } else {
             $request .= "?p=" . $this->pg;
         }
     }
     $request .= "&o=72";
     // Sort Newest to Oldest
     //$request .= "&o=52";  // Sort Most Seeded
     if ($this->makeRequest($request)) {
         return $this->parseResponse();
     } else {
         return $this->msg;
     }
 }
コード例 #3
0
ファイル: login.php プロジェクト: Ezerbeth/torrentflux
        $md5password = "";
        if (!empty($user)) {
            $isLoginRequest = true;
            // test the captcha.
            auth_validateRecaptcha($user, $iamhim, $bSetRecaptcha);
        } else {
            // this is not a login request
            $bSetReCaptcha = true;
        }
        break;
    case 0:
        /* Form-Based Auth Standard */
    /* Form-Based Auth Standard */
    default:
        $user = strtolower(tfb_getRequestVar('username'));
        $iamhim = addslashes(tfb_getRequestVar('iamhim'));
        $md5password = "";
        if (!empty($user)) {
            $isLoginRequest = true;
        }
        break;
}
// process login if this is a login-request
if ($isLoginRequest) {
    // First User check
    $next_loc = "index.php?iid=index";
    $sql = "SELECT count(*) FROM tf_users";
    $user_count = $db->GetOne($sql);
    if ($user_count == 0) {
        firstLogin($user, $iamhim);
        $next_loc = "admin.php?op=serverSettings";
コード例 #4
0
    @ob_end_clean();
    @header("location: ../../index.php");
    exit;
}
/******************************************************************************/
// common functions
require_once 'inc/functions/functions.common.php';
// transfer functions
require_once 'inc/functions/functions.transfer.php';
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.transferControl.tmpl");
// init transfer
transfer_init();
// request-vars
$pageop = tfb_getRequestVar('pageop');
$client = tfb_getRequestVar('client');
// init ch-instance
$ch = $client == "" ? ClientHandler::getInstance(getTransferClient($transfer)) : ClientHandler::getInstance($client);
// customize-vars
transfer_setCustomizeVars();
// load settings, default if settings could not be loaded (fresh transfer)
if ($ch->settingsLoad($transfer) !== true) {
    $ch->settingsDefault();
    $settings_exist = 0;
} else {
    $settings_exist = 1;
}
$tmpl->setvar('settings_exist', $settings_exist);
// set running-field
$ch->running = isTransferRunning($transfer) ? 1 : 0;
$tmpl->setvar('running', $ch->running);
コード例 #5
0
 function parseResponse()
 {
     $thing = $this->htmlPage;
     // We got a response so display it.
     // Chop the front end off.
     if (strpos($thing, "Nothing here!") !== false) {
         $this->msg = "Your search did not match any torrents";
     } else {
         $output = $this->tableHeader();
         if (strpos($thing, "catHead") !== false) {
             $thing = substr($thing, strpos($thing, "<table"));
             $thing = substr($thing, strpos($thing, "<tr>"));
             $tmpList = substr($thing, 0, strpos($thing, "</table>"));
             // keep after for paging
             $thing = substr($thing, strlen($tmpList));
             // clean tabs
             $tmpList = str_replace("\t", "", $tmpList);
             // ok so now we have the listing.
             $tmpListArr = explode("</tr>", $tmpList);
             $bg = $this->cfg["bgLight"];
             foreach ($tmpListArr as $key => $value) {
                 $buildLine = true;
                 if (strpos($value, "download.php")) {
                     $ts = new fileTorrentDay($value);
                     // Determine if we should build this output
                     if (is_int(array_search($ts->CatName, $this->catFilter))) {
                         $buildLine = false;
                     }
                     if ($this->hideSeedless == "yes") {
                         if ($ts->Seeds == "N/A" || $ts->Seeds == "0") {
                             $buildLine = false;
                         }
                     }
                     if (!empty($ts->torrentFile) && $buildLine) {
                         $output .= trim($ts->BuildOutput($bg, $this->searchURL()));
                         // ok switch colors.
                         if ($bg == $this->cfg["bgLight"]) {
                             $bg = $this->cfg["bgDark"];
                         } else {
                             $bg = $this->cfg["bgLight"];
                         }
                     }
                 }
             }
             //foreach
         } else {
             $output .= "<tr><td>&nbsp;</td></tr>\n";
         }
         $output .= "</table>";
         // is there paging at the bottom?
         if (strpos($thing, "page=") !== false) {
             // Yes, then lets grab it and display it!  ;)
             $pages = substr($thing, strpos($thing, "<p"));
             $pages = substr($pages, strpos($pages, ">"));
             $pages = substr($pages, 0, strpos($pages, "</p>"));
             $thing = "";
             $lastSearch = $this->lastSearch;
             $pages = str_replace("&nbsp;", ' ', $pages);
             $tmpPageArr = explode("</a>", $pages);
             $pagesOut = '';
             foreach ($tmpPageArr as $key => $value) {
                 $value .= "</a>";
                 if (!preg_match("#((browse|0day|torrents\\-search|torrents|search)\\.php[^>]+)#", $value, $matches)) {
                     continue;
                 }
                 $url = rtrim($matches[0], '"');
                 $php = $matches[2];
                 //search,torrents...
                 if (!preg_match("#page=([\\d]+)#", $value, $matches)) {
                     continue;
                 }
                 $pgNum = (int) $matches[1];
                 $pagesOut .= str_replace($url, "XXXURLXXX" . $pgNum, $value);
             }
             $pagesout = str_replace($php . ".php?page=", "", $pagesOut);
             $cat = tfb_getRequestVar('subGenre');
             if (empty($cat) && !empty($_REQUEST['cat'])) {
                 $cat = $_REQUEST['cat'];
             }
             $cat = (int) $cat;
             if (stripos($this->curRequest, "LATEST")) {
                 if (!empty($cat)) {
                     $pages = str_replace("XXXURLXXX", $this->searchURL() . "&LATEST=1&cat=" . $cat . "&pg=", $pagesOut);
                 } else {
                     $pages = str_replace("XXXURLXXX", $this->searchURL() . "&LATEST=1&pg=", $pagesOut);
                 }
             } else {
                 if (!empty($cat)) {
                     $pages = str_replace("XXXURLXXX", $this->searchURL() . "&searchterm=" . $_REQUEST["searchterm"] . "&cat=" . $cat . "&pg=", $pagesOut);
                 } else {
                     $pages = str_replace("XXXURLXXX", $this->searchURL() . "&searchterm=" . $_REQUEST["searchterm"] . "&pg=", $pagesOut);
                 }
             }
             $output .= "<div align=center>" . substr($pages, 1) . "</div>";
         }
     }
     return $output;
 }
コード例 #6
0
ファイル: rename.php プロジェクト: Ezerbeth/torrentflux
    $sourceDir = $cfg["path"] . $dir;
    // only valid dirs + entries with permission
    if (!(tfb_isValidPath($sourceDir) && tfb_isValidPath($sourceDir . $file) && isValidEntry($file) && hasPermission($dir, $cfg["user"], 'w'))) {
        AuditAction($cfg["constants"]["error"], "ILLEGAL RENAME: " . $cfg["user"] . " tried to rename " . $file . " in " . $dir);
        @error("Illegal rename. Action has been logged.", "", "");
    }
    // template
    $tmpl->setvar('is_start', 1);
    $tmpl->setvar('file', $file);
    $tmpl->setvar('dir', $dir);
    $tmpl->setvar('_REN_FILE', $cfg['_REN_FILE']);
    $tmpl->setvar('_REN_STRING', $cfg['_REN_STRING']);
} else {
    $file = tfb_getRequestVar('fileFrom');
    $fileTo = tfb_getRequestVar('fileTo');
    $dir = tfb_getRequestVar('dir');
    $sourceDir = $cfg["path"] . $dir;
    $targetDir = $cfg["path"] . $dir . $fileTo;
    // Add slashes if magic_quotes off:
    if (get_magic_quotes_gpc() !== 1) {
        $targetDir = addslashes($targetDir);
        $sourceDir = addslashes($sourceDir);
    }
    // only valid dirs + entries with permission
    if (!(tfb_isValidPath($sourceDir) && tfb_isValidPath($sourceDir . $file) && tfb_isValidPath($targetDir) && isValidEntry($file) && isValidEntry($fileTo) && hasPermission($dir, $cfg["user"], 'w'))) {
        AuditAction($cfg["constants"]["error"], "ILLEGAL RENAME: " . $cfg["user"] . " tried to rename " . $file . " in " . $dir . " to " . $fileTo);
        @error("Illegal rename. Action has been logged.", "", "");
    }
    // Use single quote to escape mv args:
    $cmd = "mv '" . $sourceDir . $file . "' '" . $targetDir . "'";
    $cmd .= ' 2>&1';
コード例 #7
0
 function Initialize($cfg)
 {
     $rtnValue = false;
     $this->cfg = unserialize($cfg);
     $this->pg = tfb_getRequestVar('pg');
     if (empty($this->altURL)) {
         $this->altURL = $this->mainURL;
     }
     if (empty($this->cfg)) {
         $this->msg = "Config not passed";
         $this->initialized = false;
         return;
     }
     $this->catFilterName = $this->engineName . "GenreFilter";
     $this->mainCatalogName = $this->engineName . "_catalog";
     if (array_key_exists('hideSeedless', $_SESSION)) {
         $this->hideSeedless = $_SESSION['hideSeedless'];
     }
     $this->catFilter = array_key_exists($this->catFilterName, $this->cfg) ? $this->cfg[$this->catFilterName] : array();
     if (array_key_exists($this->mainCatalogName, $this->cfg)) {
         $this->mainCatalog = $this->cfg[$this->mainCatalogName];
     } else {
         $this->populateMainCategories();
     }
     if ($this->getConnection()) {
         $rtnValue = true;
     }
     $this->closeConnection();
     // in PHP 5 use
     //$this->curRequest = http_build_query($_REQUEST);
     $this->curRequest = $this->http_query_builder($_REQUEST);
     $this->initialized = $rtnValue;
 }
コード例 #8
0
ファイル: message.php プロジェクト: ThYpHo0n/torrentflux
    @header("location: index.php?iid=index");
    exit;
}
// message
$message = tfb_getRequestVar('message');
if (!empty($message)) {
    $to_all_r = tfb_getRequestVar('to_all');
    $force_read_r = tfb_getRequestVar('force_read');
    $message = check_html($message, "nohtml");
    SaveMessage($to_user, $cfg["user"], htmlentities($message), empty($to_all_r) ? 0 : 1, !empty($force_read_r) && $cfg['isAdmin'] ? 1 : 0);
    @header("location: index.php?iid=readmsg");
    exit;
}
// rmid
if (isset($_REQUEST['rmid'])) {
    $rmid = tfb_getRequestVar('rmid');
    if (!empty($rmid)) {
        list($from_user, $message, $ip, $time) = GetMessage($rmid);
        $message = $cfg['_DATE'] . ": " . date($cfg['_DATETIMEFORMAT'], $time) . "\n" . $from_user . " " . $cfg['_WROTE'] . ":\n\n" . $message;
        $message = ">" . str_replace("\n", "\n>", $message);
        $message = "\n\n\n" . $message;
    }
}
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.message.tmpl");
// set vars
$tmpl->setvar('to_user', $to_user);
$tmpl->setvar('user', $cfg["user"]);
$tmpl->setvar('message', $message);
//
$tmpl->setvar('_TO', $cfg['_TO']);
コード例 #9
0
/**
 * set file prio
 *
 * @param $transfer
 */
function setFilePriority($transfer)
{
    global $cfg;
    $isTransmissionTorrent = false;
    if ($cfg["transmission_rpc_enable"] && isHash($transfer)) {
        require_once 'inc/functions/functions.rpc.transmission.php';
        $theTorrent = getTransmissionTransfer($transfer, array('hashString', 'id', 'name'));
        $isTransmissionTorrent = is_array($theTorrent);
    }
    if ($isTransmissionTorrent) {
        foreach ($_REQUEST['files'] as $fileid) {
            $selectedFiles[] = (int) $fileid;
        }
        # Get files that are wanted or not for download, then we can compare.
        $responseWantedFiles = getTransmissionTransfer($transfer, array('wanted'));
        $wantedFiles = $responseWantedFiles['wanted'];
        $thearray = array_fill(0, count($wantedFiles), 0);
        foreach ($selectedFiles as $fileid) {
            $thearray[$fileid] = 1;
        }
        $counter = 0;
        foreach ($wantedFiles as $fileid => $wanted) {
            if ($thearray[$counter] == 1 && $wantedFiles[$counter] == 0) {
                // the file is not marked as selected in the gui but it has been saved as "wanted"
                $includeFiles[] = (int) $counter;
                // deselect this files
            }
            if ($thearray[$counter] == 0 && $wantedFiles[$counter] == 1) {
                // the file is not marked as selected in the gui but it has been saved as "wanted"
                $excludeFiles[] = (int) $counter;
                // deselect this files
            }
            $counter++;
        }
        if (count($includeFiles) > 0) {
            $includeFiles = array_values($includeFiles);
            setTransmissionTransferProperties($transfer, array("files-wanted" => $includeFiles));
        }
        if (count($excludeFiles) > 0) {
            $excludeFiles = array_values($excludeFiles);
            setTransmissionTransferProperties($transfer, array("files-unwanted" => $excludeFiles));
        }
    } else {
        // we will use this to determine if we should create a prio file.
        // if the user passes all 1's then they want the whole thing.
        // so we don't need to create a prio file.
        // if there is a -1 in the array then they are requesting
        // to skip a file. so we will need to create the prio file.
        $okToCreate = false;
        if (!empty($transfer)) {
            $fileName = $cfg["transfer_file_path"] . $transfer . ".prio";
            $result = array();
            $files = array();
            if (isset($_REQUEST['files'])) {
                $filesTemp = is_array($_REQUEST['files']) ? $_REQUEST['files'] : array($_REQUEST['files']);
                $files = array_filter($filesTemp, "getFile");
            }
            // if there are files to get then process and create a prio file.
            if (count($files) > 0) {
                for ($i = 0; $i <= tfb_getRequestVar('count'); $i++) {
                    if (in_array($i, $files)) {
                        array_push($result, 1);
                    } else {
                        $okToCreate = true;
                        array_push($result, -1);
                    }
                }
                if ($okToCreate) {
                    $fp = fopen($fileName, "w");
                    fwrite($fp, tfb_getRequestVar('filecount') . ",");
                    fwrite($fp, implode($result, ','));
                    fclose($fp);
                } else {
                    // No files to skip so must be wanting them all.
                    // So we will remove the prio file.
                    @unlink($fileName);
                }
            } else {
                // No files selected so must be wanting them all.
                // So we will remove the prio file.
                @unlink($fileName);
            }
        }
    }
}
コード例 #10
0
require_once 'inc/functions/functions.common.php';
// dir functions
require_once 'inc/functions/functions.dir.php';
// is enabled ?
if ($cfg["enable_sfvcheck"] != 1) {
    AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: " . $cfg["user"] . " tried to use checkSFV");
    @error("checkSFV is disabled", "index.php?iid=index", "");
}
// check the needed bins
// cksfv
if (@file_exists($cfg['bin_cksfv']) !== true) {
    @error("Required binary could not be found", "", "", $cfg['isAdmin'] ? array('cksfv is required for sfv-checking', 'Specified cksfv-binary does not exist: ' . $cfg['bin_cksfv'], 'Check Settings on Admin-Server-Settings Page') : array('Please contact an Admin'));
}
// target
$dir = tfb_getRequestVar('dir');
$file = tfb_getRequestVar('file');
// validate dir + file
if (!empty($dir)) {
    $dirS = str_replace($cfg["path"], '', $dir);
    if (!(tfb_isValidPath($dir) && hasPermission($dirS, $cfg["user"], 'r'))) {
        AuditAction($cfg["constants"]["error"], "ILLEGAL SFV-ACCESS: " . $cfg["user"] . " tried to check " . $dirS);
        @error("Illegal access. Action has been logged.", "", "");
    }
}
if (!empty($file)) {
    $fileS = str_replace($cfg["path"], '', $file);
    if (!(tfb_isValidPath($file) && isValidEntry(basename($file)) && hasPermission($fileS, $cfg["user"], 'r'))) {
        AuditAction($cfg["constants"]["error"], "ILLEGAL SFV-ACCESS: " . $cfg["user"] . " tried to check " . $fileS);
        @error("Illegal access. Action has been logged.", "", "");
    }
}
コード例 #11
0
ファイル: index.php プロジェクト: Ezerbeth/torrentflux
// incoming-path
$tmpl->setvar('path_incoming', $cfg["enable_home_dirs"] != 0 ? $cfg["user"] : $cfg["path_incoming"]);
// some configs
$tmpl->setvar('enable_metafile_download', $cfg["enable_metafile_download"]);
$tmpl->setvar('enable_multiops', $cfg["enable_multiops"]);
$tmpl->setvar('twd', $cfg["transfer_window_default"]);
$tmpl->setvar('transfer_delete_data', $cfg["transfer_delete_data"]);
// =============================================================================
// transfer-list
// =============================================================================
$arUserTorrent = array();
$arListTorrent = array();
// settings
$settings = convertIntegerToArray($cfg["index_page_settings"]);
// sortOrder
$sortOrder = tfb_getRequestVar("so");
$tmpl->setvar('sortOrder', empty($sortOrder) ? $cfg["index_page_sortorder"] : $sortOrder);
// t-list
$arList = getTransferArray($sortOrder);
$progress_color = "#22BB22";
$bar_width = "4";
$bUseRPC = false;
// ---------------------------------------------------------------------
if ($cfg["transmission_rpc_enable"]) {
    $bUseRPC = true;
    require_once 'inc/functions/functions.rpc.transmission.php';
    try {
        if ($cfg["transmission_rpc_enable"] == 2) {
            $aTrTorrents = getUserTransmissionTransfers((int) $cfg['uid']);
        } else {
            $aTrTorrents = getUserTransmissionTransfers();
コード例 #12
0
/**
 * This method gets the list of transfer
 *
 * @return array
 */
function getTransferListArray()
{
    global $cfg, $db, $transfers;
    $kill_id = "";
    $lastUser = "";
    $arUserTransfers = array();
    $arListTransfers = array();
    // settings
    $settings = convertIntegerToArray($cfg["index_page_settings"]);
    // sortOrder
    $sortOrder = tfb_getRequestVar("so");
    if ($sortOrder == "") {
        $sortOrder = $cfg["index_page_sortorder"];
    }
    if ($cfg["transmission_rpc_enable"] == 2) {
        require_once 'inc/functions/functions.rpc.transmission.php';
        // New method for transmission-daemon transfers
        $result = getUserTransmissionTransfers($cfg['uid']);
        foreach ($result as $aTorrent) {
            if ($aTorrent['status'] == 4 || $aTorrent['status'] == 8) {
                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($aTorrent['rateUpload'] / 1000);
                $cfg["total_download"] = $cfg["total_download"] + GetSpeedValue($aTorrent['rateDownload'] / 1000);
            }
            array_push($arUserTransfers, $aTorrent);
        }
    }
    $arList = getTransferArray($sortOrder);
    foreach ($arList as $transfer) {
        // init some vars
        $displayname = $transfer;
        $show_run = true;
        $transferowner = getOwner($transfer);
        $owner = IsOwner($cfg["user"], $transferowner);
        // stat
        $sf = new StatFile($transfer, $transferowner);
        // settings
        if (isset($transfers['settings'][$transfer])) {
            $settingsAry = $transfers['settings'][$transfer];
        } else {
            $settingsAry = array();
            if (substr(str_replace('.imported', '', $transfer), -8) == ".torrent") {
                // this is a t-client
                $settingsAry['type'] = "torrent";
                $settingsAry['client'] = $cfg["btclient"];
            } else {
                if (substr($transfer, -5) == ".wget") {
                    // this is wget.
                    $settingsAry['type'] = "wget";
                    $settingsAry['client'] = "wget";
                } else {
                    if (substr($transfer, -4) == ".nzb") {
                        // this is nzbperl.
                        $settingsAry['type'] = "nzb";
                        $settingsAry['client'] = "nzbperl";
                    } else {
                        AuditAction($cfg["constants"]["error"], "INVALID TRANSFER: " . $transfer);
                        @error("Invalid Transfer", "", "", array($transfer));
                    }
                }
            }
            $settingsAry['hash'] = "";
            $settingsAry["savepath"] = $cfg["enable_home_dirs"] != 0 ? $cfg["path"] . $transferowner . '/' : $cfg["path"] . $cfg["path_incoming"] . '/';
            $settingsAry['datapath'] = "";
        }
        // cache running-flag in local var. we will access that often
        $transferRunning = $sf->running;
        // cache percent-done in local var. ...
        $percentDone = $sf->percent_done;
        // ---------------------------------------------------------------------
        //XFER: update1: add upload/download stats to the xfer array
        if ($cfg['enable_xfer'] == 1 && $cfg['xfer_realtime'] == 1) {
            @Xfer::update1($transfer, $transferowner, $settingsAry['client'], $settingsAry['hash'], $sf->uptotal, $sf->downtotal);
        }
        // ---------------------------------------------------------------------
        // injects
        if (!file_exists($cfg["transfer_file_path"] . $transfer . ".stat")) {
            $transferRunning = 2;
            $sf->running = "2";
            $sf->size = getTransferSize($transfer);
            injectTransfer($transfer);
        }
        // use default client if client is not set
        if (!isset($settingsAry['client'])) {
            $settingsAry['client'] = $cfg['btclient'];
        }
        // totals-preparation
        // if downtotal + uptotal + progress > 0
        if ($settings[2] + $settings[3] + $settings[5] > 0) {
            $ch = ClientHandler::getInstance($settingsAry['client']);
            $transferTotals = $ch->getTransferTotalOP($transfer, $settingsAry['hash'], $sf->uptotal, $sf->downtotal);
        }
        // ---------------------------------------------------------------------
        // preprocess stat-file and get some vars
        $estTime = "";
        $statusStr = "";
        switch ($transferRunning) {
            case 2:
                // new
                $statusStr = 'New';
                break;
            case 3:
                // queued
                $statusStr = 'Queued';
                $estTime = 'Waiting';
                break;
            default:
                // running + stopped
                // increment the totals
                if (!isset($cfg["total_upload"])) {
                    $cfg["total_upload"] = 0;
                }
                if (!isset($cfg["total_download"])) {
                    $cfg["total_download"] = 0;
                }
                $cfg["total_upload"] += GetSpeedValue($sf->up_speed);
                $cfg["total_download"] += GetSpeedValue($sf->down_speed);
                // $estTime
                if ($transferRunning == 0) {
                    $estTime = $sf->time_left;
                } else {
                    if ($sf->time_left != "" && $sf->time_left != "0") {
                        if ($cfg["display_seeding_time"] == 1 && $sf->percent_done >= 100) {
                            $estTime = $sf->seedlimit > 0 && !empty($sf->up_speed) && intval($sf->up_speed[0]) > 0 ? convertTimeText(($sf->seedlimit / 100 * $sf->size - $sf->uptotal) / GetSpeedInBytes($sf->up_speed)) : '-';
                        } else {
                            $estTime = $sf->time_left;
                        }
                    }
                }
                // $lastUser
                $lastUser = $transferowner;
                // $show_run + $statusStr
                if ($percentDone >= 100) {
                    $statusStr = $transferRunning == 1 && trim($sf->up_speed) != "" ? 'Seeding' : 'Done';
                    $show_run = false;
                } else {
                    if ($percentDone < 0) {
                        $statusStr = 'Stopped';
                        $show_run = true;
                    } else {
                        $statusStr = 'Leeching';
                    }
                }
                break;
        }
        // ---------------------------------------------------------------------
        // fill temp array
        $transferAry = array();
        // ================================================================ name
        array_push($transferAry, $transfer);
        // =============================================================== owner
        if ($settings[0] != 0) {
            array_push($transferAry, $transferowner);
        }
        // ================================================================ size
        if ($settings[1] != 0) {
            array_push($transferAry, @formatBytesTokBMBGBTB($sf->size));
        }
        // =========================================================== downtotal
        if ($settings[2] != 0) {
            array_push($transferAry, @formatBytesTokBMBGBTB($transferTotals["downtotal"]));
        }
        // ============================================================= uptotal
        if ($settings[3] != 0) {
            array_push($transferAry, @formatBytesTokBMBGBTB($transferTotals["uptotal"]));
        }
        // ============================================================== status
        if ($settings[4] != 0) {
            array_push($transferAry, $statusStr);
        }
        // ============================================================ progress
        if ($settings[5] != 0) {
            $percentage = "";
            if ($percentDone >= 100 && trim($sf->up_speed) != "") {
                $percentage = @number_format($transferTotals["uptotal"] / $sf->size * 100, 2) . '%';
            } else {
                if ($percentDone >= 1) {
                    $percentage = $percentDone . '%';
                } else {
                    if ($percentDone < 0) {
                        $percentage = round($percentDone * -1 - 100, 1) . '%';
                    } else {
                        $percentage = '0%';
                    }
                }
            }
            array_push($transferAry, $percentage);
        }
        // ================================================================ down
        if ($settings[6] != 0) {
            $down = "";
            if ($transferRunning == 1) {
                $down = trim($sf->down_speed) != "" ? $sf->down_speed : '0.0 kB/s';
            }
            array_push($transferAry, $down);
        }
        // ================================================================== up
        if ($settings[7] != 0) {
            $up = "";
            if ($transferRunning == 1) {
                $up = trim($sf->up_speed) != "" ? $sf->up_speed : '0.0 kB/s';
            }
            array_push($transferAry, $up);
        }
        // =============================================================== seeds
        if ($settings[8] != 0) {
            $seeds = $transferRunning == 1 ? $sf->seeds : "";
            array_push($transferAry, $seeds);
        }
        // =============================================================== peers
        if ($settings[9] != 0) {
            $peers = $transferRunning == 1 ? $sf->peers : "";
            array_push($transferAry, $peers);
        }
        // ================================================================= ETA
        if ($settings[10] != 0) {
            array_push($transferAry, $estTime);
        }
        // ============================================================== client
        if ($settings[11] != 0) {
            switch ($settingsAry['client']) {
                case "tornado":
                    array_push($transferAry, "B");
                    break;
                case "transmission":
                    array_push($transferAry, "T");
                    break;
                case "transmissionrpc":
                    array_push($transferAry, "Tr");
                    break;
                case "mainline":
                    array_push($transferAry, "M");
                    break;
                case "azureus":
                    array_push($transferAry, "A");
                    break;
                case "vuzerpc":
                    array_push($transferAry, "V");
                    break;
                case "wget":
                    array_push($transferAry, "W");
                    break;
                case "nzbperl":
                    array_push($transferAry, "N");
                    break;
                default:
                    array_push($transferAry, "U");
            }
        }
        // ---------------------------------------------------------------------
        // Is this transfer for the user list or the general list?
        if ($owner) {
            array_push($arUserTransfers, $transferAry);
        } else {
            array_push($arListTransfers, $transferAry);
        }
    }
    //XFER: update 2
    if ($cfg['enable_xfer'] == 1 && $cfg['xfer_realtime'] == 1) {
        @Xfer::update2();
    }
    // -------------------------------------------------------------------------
    // build output-array
    $retVal = array();
    if (sizeof($arUserTransfers) > 0) {
        foreach ($arUserTransfers as $torrentrow) {
            array_push($retVal, $torrentrow);
        }
    }
    $boolCond = true;
    if ($cfg['enable_restrictivetview'] == 1) {
        $boolCond = $cfg['isAdmin'];
    }
    if ($boolCond && sizeof($arListTransfers) > 0) {
        foreach ($arListTransfers as $torrentrow) {
            array_push($retVal, $torrentrow);
        }
    }
    return $retVal;
}
コード例 #13
0
 GNU General Public License for more details.

 To read the license please visit http://www.gnu.org/copyleft/gpl.html

*******************************************************************************/
// prevent direct invocation
if (!isset($cfg['user']) || isset($_REQUEST['cfg'])) {
    @ob_end_clean();
    @header("location: ../../../index.php");
    exit;
}
/******************************************************************************/
$newUser = tfb_getRequestVar('newUser');
$pass1 = tfb_getRequestVar('pass1');
$pass2 = tfb_getRequestVar('pass2');
$userType = tfb_getRequestVar('userType');
// check username
$usernameCheck = checkUsername($newUser);
// check password
$passwordCheck = checkPassword($pass1, $pass2);
// new user ?
$newUser = strtolower($newUser);
if ($usernameCheck === true && $passwordCheck === true) {
    addNewUser($newUser, $pass1, $userType);
    AuditAction($cfg["constants"]["admin"], $cfg['_NEWUSER'] . ": " . $newUser);
    @header("location: admin.php?op=showUsers");
    exit;
}
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.admin.addUser.tmpl");
// set vars
コード例 #14
0
ファイル: ItomaEngine.php プロジェクト: ThYpHo0n/torrentflux
 function parseResponse($latest = true)
 {
     $output = $this->tableHeader();
     $thing = $this->htmlPage;
     if (strpos($thing, "Error:") > 0) {
         $tmpStr = substr($thing, strpos($thing, "Error:") + strlen("Error:"));
         $tmpStr = substr($tmpStr, 0, strpos($tmpStr, "</p>"));
         $this->msg = strip_tags($tmpStr);
         return $output . "<center>" . $this->msg . "</center><br>";
     }
     // We got a response so display it.
     // Chop the front end off.
     $thing = substr($thing, strpos($thing, "CONTENT START"));
     $thing = substr($thing, strpos($thing, 'Health</td></tr>') + strlen('Health</td></tr>'));
     $table = substr($thing, 0, strpos($thing, "</table><BR>"));
     //var_dump(htmlentities($thing)); exit;
     // ok so now we have the listing.
     $tmpListArr = explode("<tr>", $table);
     //print_r($tmpListArr);
     $bg = $this->cfg["bgLight"];
     foreach ($tmpListArr as $key => $value) {
         $buildLine = true;
         if (strpos($value, "download.php?id")) {
             $ts = new fileItoma($value, $this->altURL);
             //print_r($ts);
             // Determine if we should build this output
             if (is_int(array_search($ts->MainId, $this->catFilter))) {
                 $buildLine = false;
             }
             if ($this->hideSeedless == "yes") {
                 if (intval($ts->Seeds) == 0) {
                     $buildLine = false;
                 }
             } elseif ($this->hideSeedless == "only") {
                 if (intval($ts->Seeds) > 0) {
                     $buildLine = false;
                 }
             }
             if (!empty($ts->torrentFile) && $buildLine) {
                 $output .= trim($ts->BuildOutput($bg, $this->searchURL()));
                 // ok switch colors.
                 if ($bg == $this->cfg["bgLight"]) {
                     $bg = $this->cfg["bgDark"];
                 } else {
                     $bg = $this->cfg["bgLight"];
                 }
             }
         }
     }
     // set thing to end of this table.
     //$thing = substr($thing,strpos($thing,"</table>"));
     $output .= "</table>";
     // is there paging at the bottom?
     if (strpos($thing, "page=") !== false) {
         // Yes, then lets grab it and display it!  ;)
         $pages = substr($thing, strpos($thing, "<p"));
         $pages = substr($pages, strpos($pages, ">"));
         $pages = substr($pages, 0, strpos($pages, "</p>"));
         $pages = str_replace("&nbsp; ", '', $pages);
         $tmpPageArr = explode("</a>", $pages);
         array_pop($tmpPageArr);
         $pagesout = '';
         foreach ($tmpPageArr as $key => $value) {
             $value .= "</a> &nbsp;";
             if (!preg_match("#((browse|torrents\\-search|torrents|search)\\.php[^>]+)#", $value, $matches)) {
                 continue;
             }
             $url = rtrim($matches[0], '"');
             $php = $matches[2];
             //browse,search,torrents...
             if (!preg_match("#page=([\\d]+)#", $value, $matches)) {
                 continue;
             }
             $pgNum = (int) $matches[1];
             $pagesout .= str_replace($url, "XXXURLXXX" . $pgNum, $value);
         }
         $pagesout = str_replace($php . ".php?page=", "", $pagesout);
         $cat = tfb_getRequestVar('mainGenre');
         if (empty($cat) && !empty($_REQUEST['cat'])) {
             $cat = $_REQUEST['cat'];
         }
         if (stripos($this->curRequest, "LATEST")) {
             if (!empty($cat)) {
                 $pages = str_replace("XXXURLXXX", $this->searchURL() . "&LATEST=1&cat=" . $cat . "&pg=", $pagesout);
             } else {
                 $pages = str_replace("XXXURLXXX", $this->searchURL() . "&LATEST=1&pg=", $pagesout);
             }
         } else {
             if (!empty($cat)) {
                 $pages = str_replace("XXXURLXXX", $this->searchURL() . "&searchterm=" . $_REQUEST["searchterm"] . "&cat=" . $cat . "&pg=", $pagesout);
             } else {
                 $pages = str_replace("XXXURLXXX", $this->searchURL() . "&searchterm=" . $_REQUEST["searchterm"] . "&pg=", $pagesout);
             }
         }
         $output .= "<div align=center>" . substr($pages, 1) . "</div>";
     }
     return $output;
 }
コード例 #15
0
 To read the license please visit http://www.gnu.org/copyleft/gpl.html

*******************************************************************************/
// prevent direct invocation
if (!isset($cfg['user']) || isset($_REQUEST['cfg'])) {
    @ob_end_clean();
    @header("location: ../../../index.php");
    exit;
}
/******************************************************************************/
// search engine base
require_once "inc/searchEngines/SearchEngineBase.php";
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.admin.searchSettings.tmpl");
// set vars
$searchEngine = tfb_getRequestVar('searchEngine');
if (empty($searchEngine)) {
    $searchEngine = $cfg["searchEngine"];
}
if (is_file('inc/searchEngines/' . $searchEngine . 'Engine.php')) {
    include_once 'inc/searchEngines/' . $searchEngine . 'Engine.php';
    $sEngine = new SearchEngine(serialize($cfg));
    if ($sEngine->initialized) {
        $tmpl->setvar('is_file', 1);
        $tmpl->setvar('mainTitle', $sEngine->mainTitle);
        $tmpl->setvar('searchEngine', $searchEngine);
        $tmpl->setvar('mainURL', $sEngine->mainURL);
        $tmpl->setvar('author', $sEngine->author);
        $tmpl->setvar('version', $sEngine->version);
        if (strlen($sEngine->updateURL) > 0) {
            $tmpl->setvar('update_pos', 1);
コード例 #16
0
 $settingsCurrent = array();
 $settingsCurrent['savepath'] = $ch->savepath;
 $settingsCurrent['max_upload_rate'] = $ch->rate;
 $settingsCurrent['max_download_rate'] = $ch->drate;
 $settingsCurrent['max_uploads'] = $ch->maxuploads;
 $settingsCurrent['superseeder'] = $ch->superseeder;
 $settingsCurrent['die_when_done'] = $ch->runtime;
 $settingsCurrent['sharekill'] = $ch->sharekill;
 $settingsCurrent['minport'] = $ch->minport;
 $settingsCurrent['maxport'] = $ch->maxport;
 $settingsCurrent['maxcons'] = $ch->maxcons;
 $settingsCurrent['rerequest'] = $ch->rerequest;
 // new settings
 $settingsNew = array();
 foreach ($settingsKeys as $settingsKey) {
     $settingsNew[$settingsKey] = tfb_getRequestVar($settingsKey);
     if ($settingsNew[$settingsKey] == "") {
         $settingsNew[$settingsKey] = $settingsCurrent[$settingsKey];
     }
 }
 // customize settings
 if ($cfg['transfer_customize_settings'] == 2) {
     $customize_settings = 1;
 } elseif ($cfg['transfer_customize_settings'] == 1 && $cfg['isAdmin']) {
     $customize_settings = 1;
 } else {
     $customize_settings = 0;
 }
 // process changes
 $settingsChanged = array();
 foreach ($settingsKeys as $settingsKey) {
コード例 #17
0
 function performSearch($searchTerm)
 {
     $searchTerm = str_replace(" ", "+", $searchTerm);
     $request = "/torrents-search.php?search=" . $searchTerm;
     if (!empty($cat)) {
         $request .= "&cat=" . $cat;
     }
     $count = tfb_getRequestVar('count');
     if (!empty($count)) {
         $request .= "&count=" . $count;
     }
     $onlyname = tfb_getRequestVar('onlyname');
     if (empty($onlyname)) {
         $onlyname = "no";
     }
     $request .= "&onlyname=" . $onlyname;
     $incldead = tfb_getRequestVar('incldead');
     if (empty($incldead)) {
         $incldead = "0";
     }
     $request .= "&incldead=" . $incldead;
     $request .= "&submit=";
     if (!empty($this->pg)) {
         $request .= "&page=" . $this->pg;
     }
     if ($this->makeRequest($request, true)) {
         return $this->parseResponse();
     } else {
         return $this->msg;
     }
 }
コード例 #18
0
ファイル: move.php プロジェクト: Ezerbeth/torrentflux
/******************************************************************************/
// common functions
require_once 'inc/functions/functions.common.php';
// dir functions
require_once 'inc/functions/functions.dir.php';
// is enabled ?
if ($cfg["enable_move"] != 1) {
    AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: " . $cfg["user"] . " tried to use move");
    @error("move is disabled. Action has been logged.", "", "");
}
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.move.tmpl");
// set vars
if (isset($_REQUEST['start']) && $_REQUEST['start'] == true) {
    $path = stripslashes($_REQUEST['path']);
    $dir = tfb_getRequestVar('path');
    $source = $cfg["path"] . $dir;
    // only valid paths + entries with permission
    if (!(tfb_isValidPath($source) && isValidEntry(basename($source)) && hasPermission($dir, $cfg["user"], 'w'))) {
        AuditAction($cfg["constants"]["error"], "ILLEGAL MOVE: " . $cfg["user"] . " tried to move " . $dir);
        @error("Illegal move. Action has been logged.", "", "");
    }
    //
    $tmpl->setvar('is_start', 1);
    $tmpl->setvar('path', $path);
    $tmpl->setvar('_MOVE_STRING', $cfg['_MOVE_STRING']);
    $tmpl->setvar('_MOVE_FILE', $cfg['_MOVE_FILE']);
    if (isset($cfg["move_paths"]) && strlen($cfg["move_paths"]) > 0) {
        $tmpl->setvar('move_start', 1);
        $dirs = explode(":", trim($cfg["move_paths"]));
        $dir_list = array();
コード例 #19
0
ファイル: readmsg.php プロジェクト: Ezerbeth/torrentflux
/******************************************************************************/
// common functions
require_once 'inc/functions/functions.common.php';
// delete
if (isset($_REQUEST['delete'])) {
    $delete = tfb_getRequestVar('delete');
    if (!empty($delete)) {
        DeleteMessage($delete);
    }
    @header("location: index.php?iid=readmsg");
    exit;
}
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.readmsg.tmpl");
if (isset($_REQUEST['mid'])) {
    $mid = tfb_getRequestVar('mid');
    list($from_user, $message, $ip, $time, $isnew, $force_read) = GetMessage($mid);
    if (!empty($from_user) && $isnew == 1) {
        // We have a Message that is being seen
        // Mark it as NOT new.
        MarkMessageRead($mid);
    }
    $message = check_html($message, "a");
    $message = html_entity_decode($message);
    $message = str_replace("\n", "<br>", $message);
    if (IsUser($from_user)) {
        $tmpl->setvar('IsUser', 1);
    }
    $tmpl->setvar('from_user', $from_user);
    $tmpl->setvar('message', $message);
    $tmpl->setvar('mid', $mid);
コード例 #20
0
/**
 * backup
 *
 * @param $action
 */
function sa_backup($action = "")
{
    global $cfg, $error, $statusImage, $statusMessage, $htmlTitle, $htmlTop, $htmlMain;
    if ($action == "") {
        return;
    }
    switch ($action) {
        case "0":
            // choose backup-type
            buildPage("b");
            $htmlTitle = "Backup - Create";
            $htmlMain .= '<br>Select the format and location to save the backup to:<br><br>';
            $htmlMain .= '<form name="backupServer" action="' . _FILE_THIS . '" method="post">';
            $htmlMain .= '<select name="c">';
            $htmlMain .= '<option value="0">none</option>';
            $htmlMain .= '<option value="1" selected>gzip</option>';
            $htmlMain .= '<option value="2">bzip2</option>';
            $htmlMain .= '</select>&nbsp;&nbsp;';
            $htmlMain .= '<input type="Hidden" name="b" value="1">';
            $htmlMain .= '<input type="submit" value="Backup on Server">';
            $htmlMain .= '</form><p>';
            $htmlMain .= '<form name="backupClient" action="' . _FILE_THIS . '" method="post">';
            $htmlMain .= '<select name="c">';
            $htmlMain .= '<option value="0">none</option>';
            $htmlMain .= '<option value="1" selected>gzip</option>';
            $htmlMain .= '<option value="2">bzip2</option>';
            $htmlMain .= '</select>&nbsp;&nbsp;';
            $htmlMain .= '<input type="Hidden" name="b" value="2">';
            $htmlMain .= '<input type="submit" value="Backup to Client">';
            $htmlMain .= '</form><p>';
            $htmlMain .= '<br><strong>Notes:</strong><br>"Backup on Server" will save the backup archive to the following path:<br>';
            $htmlMain .= '<em>' . tfb_htmlencodekeepspaces($cfg["path"] . _DIR_BACKUP) . '/</em>';
            $htmlMain .= '<br><br>';
            $htmlMain .= '"Backup to Client" will create the backup archive and prompt you to save in your web browser.<br><br><strong>Please wait</strong> until the backup is complete.  Don\'t click stuff while backup archive is being created - you will be informed if something goes wrong so no need to stress it.<br><br>';
            $htmlMain .= "<hr><strong>What Data is Backed Up?</strong><br>";
            $htmlMain .= "<ul>";
            $htmlMain .= "<li>Document root directory structure -<br>all files underneath the webserver document root folder where you installed Torrentflux-b4rt.<br><br></li>";
            $htmlMain .= "<li>The Transfers folder directory structure -<br>all files in the .transfers folder located in the path configured in the admin pages 'server' tab.<br><br></li>";
            $htmlMain .= "<li>The fluxd folder directory structure -<br>all files in the .fluxd folder located in the path configured in the admin pages 'server' tab.<br><br></li>";
            $htmlMain .= "<li>The MRTG folder directory structure -<br>all files in the .mrtg folder located in the path configured in the admin pages 'server' tab.<br><br></li>";
            $htmlMain .= "<li>The Torrentflux-b4rt database -<br>the database used to store information used in the day to day running of torrentflux-b4rt.<br><br></li>";
            $htmlMain .= "</ul><hr>";
            printPage();
            exit;
        case "1":
            // server-backup
            buildPage("b");
            $htmlTitle = "Backup - Create - Server";
            printPageStart(1);
            echo $htmlMain;
            $backupArchive = backupCreate(true, tfb_getRequestVar('c'));
            if ($backupArchive == "") {
                sendLine('<br>');
                sendLine('<font color="red"><strong>Backup - Error</strong></font><br><br>');
                sendLine($error);
            } else {
                sendLine('<br>');
                sendLine('<strong>Backup Created</strong>');
                sendLine('<br><br>Archive of backup is <em>' . tfb_htmlencodekeepspaces($backupArchive) . '</em>');
                sendLine('<br><br>');
                sendLine(backupListDisplay());
            }
            printPageEnd(1);
            exit;
        case "2":
            // client-backup
            $backupArchive = backupCreate(false, tfb_getRequestVar('c'));
            if ($backupArchive == "") {
                buildPage("-b");
                $htmlTitle = "Backup - Create - Client";
                $htmlMain .= '<br><br>';
                $htmlMain .= '<font color="red"><strong>Backup - Error</strong></font><br><br>';
                $htmlMain .= $error;
                printPage();
            } else {
                backupSend($backupArchive, true);
            }
            exit;
        case "3":
            // backup-list
            $htmlTitle = "Backup - Backups on Server";
            buildPage("b");
            $htmlMain .= '<br>';
            $htmlMain .= backupListDisplay();
            printPage();
            exit;
        case "4":
            // download backup
            $backupArchive = tfb_getRequestVar('f');
            if (backupParamCheck($backupArchive)) {
                backupSend($backupArchive, false);
            } else {
                buildPage("-b");
                $htmlTitle = "Backup - Download";
                $htmlMain .= '<br><br>';
                $htmlMain .= '<font color="red"><strong>Backup - Error</strong></font><br><br>';
                $htmlMain .= tfb_htmlencodekeepspaces($backupArchive) . ' is not a valid Backup-ID';
                printPage();
            }
            exit;
        case "5":
            // delete backup
            $backupArchive = tfb_getRequestVar('f');
            if (backupParamCheck($backupArchive)) {
                backupDelete($backupArchive);
                buildPage("b");
                $htmlTitle = "Backup - Delete";
                $htmlMain .= '<br>';
                $htmlMain .= '<em>' . tfb_htmlencodekeepspaces($backupArchive) . '</em> deleted.';
                $htmlMain .= '<br><br>';
                $htmlMain .= backupListDisplay();
            } else {
                buildPage("-b");
                $htmlTitle = "Backup - Delete";
                $htmlMain .= '<br><br>';
                $htmlMain .= '<font color="red"><strong>Backup - Error</strong></font><br><br>';
                $htmlMain .= tfb_htmlencodekeepspaces($backupArchive) . ' is not a valid Backup-ID';
            }
            printPage();
            exit;
    }
    exit;
}
コード例 #21
0
    @header("location: ../../../index.php");
    exit;
}
/******************************************************************************/
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.admin.fluxdSettings.tmpl");
// superadmin-links
$tmpl->setvar('SuperAdminLink1', getSuperAdminLink('?f=1', '<font class="adminlink">log</font></a>'));
$tmpl->setvar('SuperAdminLink2', getSuperAdminLink('?f=2', '<font class="adminlink">error-log</font></a>'));
$tmpl->setvar('SuperAdminLink3', getSuperAdminLink('?f=3', '<font class="adminlink">ps</font></a>'));
$tmpl->setvar('SuperAdminLink4', getSuperAdminLink('?f=4', '<font class="adminlink">status</font></a>'));
$tmpl->setvar('SuperAdminLink5', getSuperAdminLink('?f=5', '<font class="adminlink">check</font></a>'));
$tmpl->setvar('SuperAdminLink6', getSuperAdminLink('?f=6', '<font class="adminlink">db-debug</font></a>'));
$tmpl->setvar('SuperAdminLink9', getSuperAdminLink('?f=9', '<font class="adminlink">version</font></a>'));
// message section
$message = tfb_getRequestVar('m');
if ($message != "") {
    $tmpl->setvar('message', urldecode($message));
}
// fluxd requirements checks
$failed = 0;
// check the needed bins
// perl
if (@file_exists($cfg['perlCmd']) !== true) {
    $failed++;
    $tmpl->setvar('perlMissing', 1);
}
// php-cli
if (@file_exists($cfg['bin_php']) !== true) {
    $failed++;
    $tmpl->setvar('phpMissing', 1);
コード例 #22
0
                if ($with_profiles) {
                    $profiles = GetProfilesByUserName($user, $profile);
                    $public_profiles = GetPublicProfiles($profile);
                    $tmpl->setloop('profiles', $profiles);
                    $tmpl->setloop('public_profiles', $public_profiles);
                }
                // checkdir
                $tmpl->setvar('checkdir', !$isRefresh || $checkdir ? 1 : 0);
            }
            $tmpl->setvar('watch_job_loaded', !$wasWatchError);
            // title-bar
            tmplSetTitleBar("Administration - Fluxd Watch - " . ($isNew ? "Add" : "Edit") . " Job");
        }
        break;
    case "deleteJob":
        $jobNumber = trim(tfb_getRequestVar('job'));
        if (empty($jobNumber)) {
            setWatchError('Error : No Job-Number.');
            $tmpl->setvar('watch_job_deleted', 0);
        } else {
            $tmpl->setvar('watch_job_deleted', FluxdWatch::jobDelete($jobNumber) === true ? 1 : 0);
        }
        // title-bar
        tmplSetTitleBar("Administration - Fluxd Watch - Delete Job");
        break;
}
$tmpl->setvar('pageop2', $pageop2);
//
$tmpl->setvar('enable_dereferrer', $cfg["enable_dereferrer"]);
//
tmplSetAdminMenu();
コード例 #23
0
/**
 * set iid vars
 */
function tmplSetIidVars()
{
    global $cfg, $tmpl;
    // set some vars
    $_iid = tfb_getRequestVar('iid');
    $tmpl->setvar('iid', $_iid);
    $tmpl->setvar('mainMenu', isset($cfg['mainMenu'][$_iid]) ? $cfg['mainMenu'][$_iid] : "home");
    $tmpl->setvar('fluxlink_display', $cfg['ui_displayfluxlink']);
    $fluxlink = getTorrentFluxLink();
    $tmpl->setvar('fluxlink_url', $fluxlink['address']);
    $tmpl->setvar('fluxlink_name', $fluxlink['name']);
    // The width should be used on all sites
    $tmpl->setvar('ui_dim_main_w', $cfg["ui_dim_main_w"]);
}
コード例 #24
0
 $tmpl->setvar('total_total', formatFreeSpace(@$xfer_total['total']['total'] / 1048576));
 $tmpl->setvar('total_month', formatFreeSpace(@$xfer_total['month']['total'] / 1048576));
 $tmpl->setvar('total_week', formatFreeSpace(@$xfer_total['week']['total'] / 1048576));
 $tmpl->setvar('total_day', formatFreeSpace(@$xfer_total['day']['total'] / 1048576));
 //
 $username = tfb_getRequestVar('user');
 $tmpl->setvar('user', $username);
 $_month = tfb_getRequestVar('month');
 if (isset($_REQUEST['month'])) {
     $mstart = $_month . '-' . $cfg['month_start'];
     $mend = date('Y-m-d', strtotime('+1 Month', strtotime($mstart)));
 } else {
     $mstart = 0;
     $mend = 0;
 }
 $_week = tfb_getRequestVar('week');
 if (isset($_REQUEST['week'])) {
     $wstart = $_week;
     $wend = date('Y-m-d', strtotime('+1 Week', strtotime($wstart)));
 } else {
     $wstart = $mstart;
     $wend = $mend;
 }
 // month stats
 $xferStats = Xfer::getUsageByDate($username);
 $start = '';
 $download = 0;
 $upload = 0;
 $month_list = array();
 foreach ($xferStats as $row) {
     $rtime = strtotime($row[2]);
コード例 #25
0
/**
 * exit
 */
function dispatcher_exit()
{
    global $cfg;
    $redir = isset($_REQUEST['riid']) ? tfb_getRequestVar('riid') : "index";
    switch ($redir) {
        case "_exit_":
            exit("1");
        case "_none_":
            break;
        case "_referer_":
            if (isset($_SERVER["HTTP_REFERER"])) {
                @header("location: " . $_SERVER["HTTP_REFERER"]);
            }
            break;
        default:
            if (preg_match('/^[a-zA-Z]+$/D', $redir)) {
                @header("location: index.php?iid=" . $redir);
            } else {
                AuditAction($cfg["constants"]["error"], "INVALID PAGE (riid): " . $redir);
                @error("Invalid Page", "", "", array($redir));
            }
    }
    // exit
    exit;
}
コード例 #26
0
 /**
  * sets common settings-fields
  */
 function _settingsInit()
 {
     global $cfg;
     // customize settings
     if ($cfg['transfer_customize_settings'] == 2) {
         $customize_settings = 1;
     } elseif ($cfg['transfer_customize_settings'] == 1 && $cfg['isAdmin']) {
         $customize_settings = 1;
     } else {
         $customize_settings = 0;
     }
     // init default-settings
     $this->settingsDefault();
     // only read request-vars if enabled
     if ($customize_settings == 1) {
         // rate
         $reqvar = tfb_getRequestVar('max_upload_rate');
         if ($reqvar != "") {
             $this->rate = $reqvar;
         }
         // drate
         $reqvar = tfb_getRequestVar('max_download_rate');
         if ($reqvar != "") {
             $this->drate = $reqvar;
         }
         // maxuploads
         $reqvar = tfb_getRequestVar('max_uploads');
         if ($reqvar != "") {
             $this->maxuploads = $reqvar;
         }
         // superseeder
         $reqvar = tfb_getRequestVar('superseeder');
         if ($reqvar != "") {
             $this->superseeder = $reqvar;
         }
         // runtime
         $reqvar = tfb_getRequestVar('die_when_done');
         if ($reqvar != "") {
             $this->runtime = $reqvar;
         }
         // sharekill
         $reqvar = tfb_getRequestVar('sharekill');
         if ($reqvar != "") {
             $this->sharekill = $reqvar;
         }
         // minport
         $reqvar = tfb_getRequestVar('minport');
         if (!empty($reqvar)) {
             $this->minport = $reqvar;
         }
         // maxport
         $reqvar = tfb_getRequestVar('maxport');
         if (!empty($reqvar)) {
             $this->maxport = $reqvar;
         }
         // maxcons
         $reqvar = tfb_getRequestVar('maxcons');
         if ($reqvar != "") {
             $this->maxcons = $reqvar;
         }
         // rerequest
         $reqvar = tfb_getRequestVar('rerequest');
         if ($reqvar != "") {
             $this->rerequest = $reqvar;
         }
     }
     // savepath
     if ($cfg["showdirtree"] == 1) {
         $this->savepath = tfb_getRequestVar('savepath');
     }
     // skip_hash_check
     $this->skip_hash_check = tfb_getRequestVar('skiphashcheck');
 }
コード例 #27
0
ファイル: images.php プロジェクト: ThYpHo0n/torrentflux
/******************************************************************************/
// default-type
define('_DEFAULT_TYPE', 'server');
// default-targets
define('_DEFAULT_TARGET_SERVER', 'all');
define('_DEFAULT_TARGET_MRTG', 'traffic');
// input-dir mrtg
define('_MRTG_DIR_INPUT', $cfg["path"] . '.mrtg');
// image-defines
define('_IMAGE_URL', "image.php");
define('_IMAGE_PREFIX_MRTG', "?i=mrtg&f=");
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.images.tmpl");
// request-vars
$type = isset($_REQUEST['type']) ? tfb_getRequestVar('type') : _DEFAULT_TYPE;
$target = tfb_getRequestVar('target');
// types
$type_list = array();
array_push($type_list, array('name' => "server", 'selected' => $type == "server" ? 1 : 0));
array_push($type_list, array('name' => "mrtg", 'selected' => $type == "mrtg" ? 1 : 0));
$tmpl->setloop('type_list', $type_list);
// type-switch
switch ($type) {
    // server
    case "server":
        // target
        if ($target == "") {
            $target = _DEFAULT_TARGET_SERVER;
        }
        // targets
        $target_list = array();
コード例 #28
0
/**
 * get array with colors. try to read values from the request-vars. 
 * use default-colors if no colors provided in request-vars.
 *
 * @return colors[][]
 */
function image_getColors()
{
    $rc1 = tfb_getRequestVar('c1');
    $rc2 = tfb_getRequestVar('c2');
    $color1 = empty($rc1) ? array('r' => 0x0, 'g' => 0xeb, 'b' => 0xc) : Image::stringToRGBColor($rc1);
    $color2 = empty($rc2) ? array('r' => 0x10, 'g' => 0x0, 'b' => 0xff) : Image::stringToRGBColor($rc2);
    return array($color1, $color2);
}
コード例 #29
0
 function parseResponse($latest = true)
 {
     $output = $this->tableHeader();
     $thing = $this->htmlPage;
     if (strpos($thing, "Error:") > 0) {
         $tmpStr = substr($thing, strpos($thing, "Error:") + strlen("Error:"));
         $tmpStr = substr($tmpStr, 0, strpos($tmpStr, "</p>"));
         $this->msg = strip_tags($tmpStr);
         return $output . "<center>" . $this->msg . "</center><br>";
     }
     // We got a response so display it.
     // Chop the front end off.
     $thing = substr($thing, strpos($thing, ">Hits<"));
     $thing = substr($thing, strpos($thing, "</tr>") + strlen("</tr>"));
     $tmpList = substr($thing, 0, strpos($thing, "</table>"));
     // ok so now we have the listing.
     $tmpListArr = explode("</tr>", $tmpList);
     $bg = $this->cfg["bgLight"];
     foreach ($tmpListArr as $key => $value) {
         //echo $value;
         $buildLine = true;
         if (strpos($value, "id=")) {
             $ts = new fileMP3($value, $this->mainURL);
             // Determine if we should build this output
             if (is_int(array_search($ts->MainId, $this->catFilter))) {
                 $buildLine = false;
             }
             if ($this->hideSeedless == "yes") {
                 if ($ts->Seeds == "N/A" || $ts->Seeds == "0") {
                     $buildLine = false;
                 }
             }
             if (!empty($ts->torrentFile) && $buildLine) {
                 $output .= trim($ts->BuildOutput($bg, $this->searchURL()));
                 // ok switch colors.
                 if ($bg == $this->cfg["bgLight"]) {
                     $bg = $this->cfg["bgDark"];
                 } else {
                     $bg = $this->cfg["bgLight"];
                 }
             }
         }
     }
     // set thing to end of this table.
     $thing = substr($thing, strpos($thing, "</table>"));
     $output .= "</table>";
     // is there paging at the bottom?
     if (strpos($thing, "page=") != false) {
         // Yes, then lets grab it and display it!  ;)
         $pages = substr($thing, strpos($thing, "<p"));
         $pages = substr($pages, strpos($pages, ">"));
         $pages = substr($pages, 0, strpos($pages, "</p>"));
         $pages = str_replace("&nbsp; ", '', $pages);
         $tmpPageArr = explode("</a>", $pages);
         array_pop($tmpPageArr);
         $pagesout = '';
         foreach ($tmpPageArr as $key => $value) {
             $value .= "</a> &nbsp;";
             //$tmpVal = substr($value,strpos($value,"browse.php?"));
             $tmpVal = substr($value, strpos($value, "browse.php?"), strpos($value, "\">") - 2);
             $pgNum = substr($tmpVal, strpos($tmpVal, "page=") + strlen("page="));
             $pagesout .= str_replace($tmpVal, "XXXURLXXX" . $pgNum, $value);
         }
         $pagesout = str_replace("se.php?page=", "", $pagesout);
         $cat = tfb_getRequestVar('mainGenre');
         if (empty($cat)) {
             $cat = tfb_getRequestVar('cat');
         }
         if (strpos($this->curRequest, "LATEST")) {
             if (!empty($cat)) {
                 $pages = str_replace("XXXURLXXX", $this->searchURL() . "&LATEST=1&cat=" . $cat . "&pg=", $pagesout);
             } else {
                 $pages = str_replace("XXXURLXXX", $this->searchURL() . "&LATEST=1&pg=", $pagesout);
             }
         } else {
             if (!empty($cat)) {
                 $pages = str_replace("XXXURLXXX", $this->searchURL() . "&searchterm=" . $_REQUEST["searchterm"] . "&cat=" . $cat . "&pg=", $pagesout);
             } else {
                 $pages = str_replace("XXXURLXXX", $this->searchURL() . "&searchterm=" . $_REQUEST["searchterm"] . "&pg=", $pagesout);
             }
         }
         $output .= "<div align=center>" . substr($pages, 1) . "</div>";
     }
     return $output;
 }
コード例 #30
0
    $sEngine = new SearchEngine(serialize($cfg));
    if (!$sEngine->initialized) {
        $tmpl->setvar('sEngine_error', 1);
        $tmpl->setvar('sEngine_msg', $sEngine->msg);
    } else {
        // Search Engine ready to go
        $mainStart = true;
        $catLinks = '';
        $tmpCatLinks = '';
        $tmpLen = 0;
        $link_list = array();
        foreach ($sEngine->getMainCategories() as $mainId => $mainName) {
            array_push($link_list, array('searchEngine' => $searchEngine, 'mainId' => $mainId, 'mainName' => $mainName));
        }
        $tmpl->setloop('link_list', $link_list);
        $mainGenre = tfb_getRequestVar('mainGenre');
        $subCats = $sEngine->getSubCategories($mainGenre);
        if (empty($mainGenre) && array_key_exists("subGenre", $_REQUEST) || count($subCats) <= 0) {
            $tmpl->setvar('no_genre', 1);
            $tmpl->setvar('performSearch', array_key_exists("LATEST", $_REQUEST) && $_REQUEST["LATEST"] == "1" ? $sEngine->getLatest() : $sEngine->performSearch($searchterm));
        } else {
            $mainGenreName = $sEngine->GetMainCatName($mainGenre);
            $tmpl->setvar('mainGenreName', $mainGenreName);
            $list_cats = array();
            foreach ($subCats as $subId => $subName) {
                array_push($list_cats, array('subId' => $subId, 'subName' => $subName));
            }
            $tmpl->setloop('list_cats', $list_cats);
        }
    }
}