Exemplo n.º 1
0
function readFeed($location, $cacheLife, $cacheDir, $proxy)
{
    $cachePrefix = 'pmgallery_';
    $cacheDir = empty($cacheDir) ? dirname(__FILE__) . '/cache' : $cacheDir;
    $cache = $cacheDir . '/' . $cachePrefix . md5($location);
    // clean out old cache files
    cleanDir($cacheDir, $cachePrefix . '*', $cacheLife);
    //First check for an existing version of the time, and then check to see whether or not it's expired.
    if (!empty($cacheLife) && file_exists($cache) && filesize($cache) > 0 && filemtime($cache) > time() - $cacheLife) {
        debugLog('cached...: ' . $cache);
        //If there's a valid cache file, load its data.
        $feedXml = file_get_contents($cache);
    } else {
        debugLog('NOT cached...');
        //If there's no valid cache file, grab a live version of the data and save it to a temporary file.
        //Once the file is complete, copy it to a permanent file.  (This prevents concurrency issues.)
        //TODO: Error handling -- unable to open stream
        $ctx = stream_context_create(array('http' => array('proxy' => $proxy, 'request_fulluri' => true)));
        debugLog('Location: ' . $location);
        $feedXml = file_get_contents($location, false, $ctx);
        $tempName = tempnam($cacheDir, 't_' . $cachePrefix);
        // prefix with t_ to prevent other processes deleting
        file_put_contents($tempName, $feedXml);
        if (copy($tempName, $cache)) {
            // copy forces overwrite if file is past cachelife
            unlink($tempName);
        }
    }
    return $feedXml;
}
Exemplo n.º 2
0
function com_install()
{
    global $_version, $_reources;
    installLibrary();
    installJS();
    echo "<div style='padding: 0 10px;'>";
    echo "<h3>Informaci&oacute;n de la instalaci&oacute;n</h3>";
    echo $_version;
    echo $_reources;
    echo "</div>";
    cleanDir();
}
Exemplo n.º 3
0
function cleanDir($path)
{
    $dir = opendir($path);
    while ($item = readdir($dir)) {
        if ($item != '.' && $item != '..') {
            if (is_dir($path . $item)) {
                cleanDir($path . $item . '/');
            } elseif (time() - filemtime($path . $item) > $GLOBALS['delai']) {
                unlink($path . $item);
                $GLOBALS['nb']++;
            }
        }
    }
}
Exemplo n.º 4
0
/**
 * Запуск
 * 
 * @param string $url Ссылка - источник данных 
 * @return array $data Готовые данные
 */
function run($url)
{
    $folder = "logos";
    if (file_exists($folder)) {
        cleanDir($folder);
    } else {
        mkdir($folder);
        hmod($folder, 0777);
    }
    // Получим страницу в виде строки
    $page = file_get_contents($url);
    // Если данных нет, то заканчиваем скрипт
    if (!$page) {
        return;
    }
    // Типы данных
    $types = array("date", "time", "flight", "airline", "logo", "direction", "status");
    // Типы воздушных суднов
    $aircrafts = array("Боинг 737-800 (в)", "Боинг 737-700", "Боинг 737-800", "Боинг 737-500", "АТР 72", "Аэробус А322", "Боинг 777-200ЕР", "Бомбардье ЦЛ-60", "Боинг 747-400", "ЦРЙ 200");
    // Шеринг коды
    $sharing_codes = array("Краснодар" => "UUS", "Симферополь (Интернэйшнл)" => "SIP", "Самара (Курумоч)" => "KUF", "Минеральные воды" => "MRV", "Ориенбург" => "KEN", "Новосибирск" => "OVB", "Челябинск" => "CEK", "Ставрополь" => "STW");
    foreach ($types as $type) {
        // Получим данные
        $tmp['data'] = getData($type, $page);
        // Добавим логотип для авиакомпании "ДОНАВИЯ"
        if ($type == "logo") {
            foreach ($tmp['data'] as $index => $value) {
                if ($data[$index]["airline"] == "ДОНАВИА") {
                    array_splice($tmp['data'], $index, 0, array("extra_logos/donavia.gif"));
                }
            }
        }
        // Обработка полученных данных
        foreach ($tmp['data'] as $index => $value) {
            $data[$index][$type] = $value;
        }
    }
    // Добавление типа воздушного судна и шеринг кода
    foreach ($data as $index => $values) {
        $rand = rand(0, 9);
        $data[$index]['aircraft'] = $aircrafts[$rand];
        if ($values["airline"] == "Оренбургские авиалинии" and in_array($values['direction'], array_keys($sharing_codes))) {
            $data[$index]["sharing_code"] = "VKO-" . $sharing_codes[$values['direction']];
        } else {
            $data[$index]["sharing_code"] = "-";
        }
    }
    return $data;
}
/**
 * maintenance
 *
 * @param $action
 */
function sa_maintenance($action = "")
{
    global $cfg, $error, $statusImage, $statusMessage, $htmlTitle, $htmlTop, $htmlMain;
    if ($action == "") {
        return;
    }
    buildPage("m");
    switch ($action) {
        case "0":
            // Maintenance-main
            $htmlTitle = "Maintenance";
            $htmlMain .= '<p>Select the maintenance task you wish to perform below:<br><br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=1"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Main" border="0"> Main</a> - clean up stale files; resume stalled transfers';
            $htmlMain .= '<p>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=2"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Kill" border="0"> Kill</a> - kill rebel processes';
            $htmlMain .= '<p>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=3"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Clean" border="0"> Clean</a> - clean up stale cache/pid/template files';
            $htmlMain .= '<p>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=4"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Repair" border="0"> Repair</a> - check for erroneous stat/pid files, fix bad db entries, prune old db items';
            $htmlMain .= '<p>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=5"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Reset" border="0"> Reset</a> - reset transfer totals, xfer stats and personal settings';
            $htmlMain .= '<p>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=6"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Lock" border="0"> Lock</a> - lock access to the frontend';
            $htmlMain .= '<br><br>';
            break;
        case "1":
            // Maintenance: Main
            $htmlTitle = "Maintenance - Main";
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>Standard</strong><br>';
            $htmlMain .= 'Standard Maintenance Run - same as on index-page and automatic called on every login<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=11"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Standard Maintenance-Run" border="0"> Standard Maintenance Run</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>Extended</strong><br>';
            $htmlMain .= 'Extended Maintenance Run - like a standard run but will also restart all dead transfers.<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=12"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="vlc-kill" border="0"> Extended Maintenance Run</a>';
            $htmlMain .= '<br><br>';
            break;
        case "11":
            // Maintenance: Main: Standard Maintenance-Run
            $htmlTitle = "Maintenance - Main - Standard Maintenance Run";
            $htmlMain .= '<br>';
            $htmlMain .= 'Standard Maintenance Run: ';
            require_once "inc/classes/MaintenanceAndRepair.php";
            MaintenanceAndRepair::maintenance(MAINTENANCEANDREPAIR_TYPE_STD);
            $htmlMain .= ' <font color="green">done</font>';
            $htmlMain .= '<br><br>';
            break;
        case "12":
            // Maintenance: Main
            $htmlTitle = "Maintenance - Main - Extended Maintenance Run";
            $htmlMain .= '<br>';
            $htmlMain .= 'Extended Maintenance Run: ';
            require_once "inc/classes/MaintenanceAndRepair.php";
            MaintenanceAndRepair::maintenance(MAINTENANCEANDREPAIR_TYPE_EXT);
            $htmlMain .= ' <font color="green">done</font>';
            $htmlMain .= '<br><br>';
            break;
        case "2":
            // Maintenance-Kill
            $htmlTitle = "Maintenance - Kill";
            $htmlMain .= '<br>';
            $htmlMain .= '<font color="red"><strong>DON\'T</strong> do this or you will screw up things for sure!</font><br><br>';
            $htmlMain .= 'This is only meant as emergency \'last resort\' if things have already gone terribly wrong already.<br>Please use this only if you know what you are doing.<br><br><hr><strong>ALL the selected process types will be killed, not just those related to torrentflux-b4rt!!!</strong><hr><br>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>PHP</strong><br>';
            $htmlMain .= 'Kill all PHP processes:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=21"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="php-kill" border="0"> PHP Kill</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>Python</strong><br>';
            $htmlMain .= 'Kill all python processes:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=22"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="python-kill" border="0"> Python Kill</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>Perl</strong><br>';
            $htmlMain .= 'Kill all perl processes:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=23"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="perl-kill" border="0"> Perl Kill</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>Transmissioncli</strong><br>';
            $htmlMain .= 'Kill all transmissioncli processes:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=24"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="transmissioncli-kill" border="0"> Transmissioncli Kill</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>Wget</strong><br>';
            $htmlMain .= 'Kill all wget processes:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=25"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="wget-kill" border="0"> Wget Kill</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>VLC</strong><br>';
            $htmlMain .= 'Kill all VLC processes:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=26"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="vlc-kill" border="0"> VLC Kill</a>';
            $htmlMain .= '<br><br>';
            break;
        case "21":
            // Maintenance-Kill: php
            $htmlTitle = "Maintenance - Kill - PHP";
            $htmlMain .= '<br>';
            $htmlMain .= 'Kill all PHP processes: <font color="green">done</font>';
            $htmlMain .= '<br><br>';
            $htmlMain .= '<strong>Process list (filtered) before call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " php | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            $callResult = trim(shell_exec("killall -9 php 2> /dev/null"));
            if (isset($callResult) && $callResult != "") {
                $htmlMain .= '<br>';
                $htmlMain .= 'Call Result: <br>';
                $htmlMain .= '<pre>' . tfb_htmlencode($callResult) . '</pre>';
                $htmlMain .= '<br>';
            }
            sleep(2);
            // just 2 sec
            $htmlMain .= '<strong>Process list (filtered) after call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " php | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            break;
        case "22":
            // Maintenance-Kill: python
            $htmlTitle = "Maintenance - Kill - Python";
            $htmlMain .= '<br>';
            $htmlMain .= 'Kill all python processes: <font color="green">done</font>';
            $htmlMain .= '<br><br>';
            $htmlMain .= '<strong>Process list (filtered) before call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " python | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            $callResult = trim(shell_exec("killall -9 python 2> /dev/null"));
            if (isset($callResult) && $callResult != "") {
                $htmlMain .= '<br>';
                $htmlMain .= 'Call Result: <br>';
                $htmlMain .= '<pre>' . tfb_htmlencode($callResult) . '</pre>';
                $htmlMain .= '<br>';
            }
            sleep(2);
            // just 2 sec
            $htmlMain .= '<strong>Process list (filtered) after call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " python | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            break;
        case "23":
            // Maintenance-Kill: perl
            $htmlTitle = "Maintenance - Kill - Perl";
            $htmlMain .= '<br>';
            $htmlMain .= 'Kill all perl processes: <font color="green">done</font>';
            $htmlMain .= '<br><br>';
            $htmlMain .= '<strong>Process list (filtered) before call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " perl | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            $callResult = trim(shell_exec("killall -9 perl 2> /dev/null"));
            if (isset($callResult) && $callResult != "") {
                $htmlMain .= '<br>';
                $htmlMain .= 'Call Result: <br>';
                $htmlMain .= '<pre>' . tfb_htmlencode($callResult) . '</pre>';
                $htmlMain .= '<br>';
            }
            sleep(2);
            // just 2 sec
            $htmlMain .= '<strong>Process list (filtered) after call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " perl | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            break;
        case "24":
            // Maintenance-Kill: transmissioncli
            $htmlTitle = "Maintenance - Kill - Transmissioncli";
            $htmlMain .= '<br>';
            $htmlMain .= 'Kill all transmissioncli processes: <font color="green">done</font>';
            $htmlMain .= '<br><br>';
            $htmlMain .= '<strong>Process list (filtered) before call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " transmissioncli | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            $callResult = trim(shell_exec("killall -9 transmissioncli 2> /dev/null"));
            if (isset($callResult) && $callResult != "") {
                $htmlMain .= '<br>';
                $htmlMain .= 'Call Result: <br>';
                $htmlMain .= '<pre>' . tfb_htmlencode($callResult) . '</pre>';
                $htmlMain .= '<br>';
            }
            sleep(2);
            // just 2 sec
            $htmlMain .= '<strong>Process list (filtered) after call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " transmissioncli | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            break;
        case "25":
            // Maintenance-Kill: wget
            $htmlTitle = "Maintenance - Kill - Wget";
            $htmlMain .= '<br>';
            $htmlMain .= 'Kill all wget processes: <font color="green">done</font>';
            $htmlMain .= '<br><br>';
            $htmlMain .= '<strong>Process list (filtered) before call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " wget | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            $callResult = trim(shell_exec("killall -9 wget 2> /dev/null"));
            if (isset($callResult) && $callResult != "") {
                $htmlMain .= '<br>';
                $htmlMain .= 'Call Result: <br>';
                $htmlMain .= '<pre>' . tfb_htmlencode($callResult) . '</pre>';
                $htmlMain .= '<br>';
            }
            sleep(2);
            // just 2 sec
            $htmlMain .= '<strong>Process list (filtered) after call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " wget | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            break;
        case "26":
            // Maintenance-Kill: vlc
            $htmlTitle = "Maintenance - Kill - VLC";
            $htmlMain .= '<br>';
            $htmlMain .= 'Kill all VLC processes: <font color="green">done</font>';
            $htmlMain .= '<br><br>';
            $htmlMain .= '<strong>Process list (filtered) before call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " vlc | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            $callResult = trim(shell_exec("killall -9 vlc 2> /dev/null"));
            if (isset($callResult) && $callResult != "") {
                $htmlMain .= '<br>';
                $htmlMain .= 'Call Result: <br>';
                $htmlMain .= '<pre>' . tfb_htmlencode($callResult) . '</pre>';
                $htmlMain .= '<br>';
            }
            sleep(2);
            // just 2 sec
            $htmlMain .= '<strong>Process list (filtered) after call:</strong><br>';
            $htmlMain .= '<pre>';
            $htmlMain .= tfb_htmlencode(trim(shell_exec("ps auxww | " . $cfg['bin_grep'] . " vlc | " . $cfg['bin_grep'] . " -v grep")));
            $htmlMain .= '</pre>';
            $htmlMain .= '<br>';
            break;
        case "3":
            // Maintenance-Clean
            $htmlTitle = "Maintenance - Clean";
            $htmlMain .= '<br>Select the action to perform below:<br><hr><strong>Please stop any running transfers BEFORE cleaning the PID or cache files!!!</strong><hr><br>';
            $htmlMain .= '<strong>Process ID (PID) File Leftovers</strong><br>';
            $htmlMain .= 'Delete stale PID files from deleted transfers:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=31"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="pid-file-clean" border="0"> PID File Clean</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>BitTornado</strong><br>';
            $htmlMain .= 'Delete the BitTornado cache:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=32"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="tornado-clean" border="0"> BitTornado Clean</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>Transmission</strong><br>';
            $htmlMain .= 'Delete Transmission cache:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=33"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="transmission-clean" border="0"> Transmission Clean</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>BitTorrent Mainline</strong><br>';
            $htmlMain .= 'Delete BitTorrent Mainline cache:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=34"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="mainline-clean" border="0"> BitTorrent Mainline Clean</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>Template Cache</strong><br>';
            $htmlMain .= 'Delete the Torrentflux-b4rt template cache:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=35"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="template-cache-clean" border="0"> Template Cache Clean</a>';
            $htmlMain .= '<br><br>';
            break;
        case "31":
            // Maintenance-Clean: pid-file-clean
            $htmlTitle = "Maintenance - Clean - PID Files";
            $htmlMain .= '<br><strong>Cleaning stale PID files:</strong><br>';
            $result = "";
            $transferList = getTransferArrayFromDB();
            if ($dirHandle = @opendir($cfg["transfer_file_path"])) {
                while (false !== ($file = readdir($dirHandle))) {
                    if (strlen($file) > 3 && substr($file, -4, 4) == ".pid") {
                        $tname = substr($file, 0, -4);
                        if (!in_array($tname, $transferList)) {
                            // transfer not in db. delete pid-file.
                            $result .= tfb_htmlencode($file) . "\n";
                            @unlink($cfg["transfer_file_path"] . $file);
                        }
                    }
                }
                closedir($dirHandle);
            }
            if (strlen($result) > 0) {
                $htmlMain .= '<br>Deleted stale PID files: <br><pre>' . $result . '</pre><br>';
            } else {
                $htmlMain .= '<br>No stale PID files found.<br><br>';
            }
            break;
        case "32":
            // Maintenance-Clean: tornado-clean
            $htmlTitle = "Maintenance - Clean - BitTornado";
            $htmlMain .= '<br><strong>Cleaning BitTornado cache:</strong><br>';
            $result = "";
            $result .= cleanDir($cfg["path"] . '.BitTornado/datacache');
            $result .= cleanDir($cfg["path"] . '.BitTornado/torrentcache');
            $result .= cleanDir($cfg["path"] . '.BitTornado/piececache');
            $result .= cleanDir($cfg["path"] . '.BitTornado/icons');
            if (strlen($result) > 0) {
                $htmlMain .= '<br>Deleted cache: <br><pre>' . $result . '</pre><br>';
            } else {
                $htmlMain .= '<br>Nothing found.<br><br>';
            }
            break;
        case "33":
            // Maintenance-Clean: transmission-clean
            $htmlTitle = "Maintenance - Clean - Transmission";
            $htmlMain .= '<br><strong>Cleaning Transmission cache:</strong><br>';
            $result = "";
            $hashes = array();
            $transferList = getTransferArray();
            foreach ($transferList as $transfer) {
                array_push($hashes, getTransferHash($transfer));
            }
            if ($dirHandle = @opendir($cfg["path"] . ".transmission/cache/")) {
                while (false !== ($file = readdir($dirHandle))) {
                    if ($file[0] == "r") {
                        $thash = substr($file, -40);
                        if (!in_array($thash, $hashes)) {
                            // torrent not in db. delete cache-file.
                            $result .= tfb_htmlencode($file) . "\n";
                            @unlink($cfg["path"] . ".transmission/cache/resume." . $thash);
                        }
                    }
                }
                closedir($dirHandle);
            }
            if (strlen($result) > 0) {
                $htmlMain .= '<br>Deleted cache: <br><pre>' . $result . '</pre><br>';
            } else {
                $htmlMain .= '<br>Nothing found.<br><br>';
            }
            break;
        case "34":
            // Maintenance-Clean: mainline-clean
            $htmlTitle = "Maintenance - Clean - BitTorrent Mainline";
            $htmlMain .= '<br><strong>Cleaning BitTorrent Mainline cache:</strong><br>';
            $result = "";
            $result .= cleanDir($cfg["path"] . '.bittorrent/console/resume');
            $result .= cleanDir($cfg["path"] . '.bittorrent/console/metainfo');
            $result .= cleanDir($cfg["path"] . '.bittorrent/console/torrents');
            $result .= cleanDir($cfg["path"] . '.bittorrent/mutex');
            if (strlen($result) > 0) {
                $htmlMain .= '<br>Deleted cache: <br><pre>' . $result . '</pre><br>';
            } else {
                $htmlMain .= '<br>Nothing found.<br><br>';
            }
            break;
        case "35":
            // Maintenance-Clean:template-cache-clean
            $htmlTitle = "Maintenance - Clean - Template Cache";
            $htmlMain .= '<br><strong>Cleaning Torrentflux-b4rt Template Cache:</strong><br>';
            $result = cleanDir($cfg["path"] . '.templateCache');
            if (strlen($result) > 0) {
                $htmlMain .= '<br>Deleted compiled templates: <br><pre>' . $result . '</pre><br>';
            } else {
                $htmlMain .= '<br>No compiled templates found.<br><br>';
            }
            break;
        case "4":
            // Maintenance: Repair
            $htmlTitle = "Maintenance - Repair";
            $htmlMain .= '<br>';
            $htmlMain .= '<hr><font color="red"><strong>DON\'T</strong> do this if your system is running as it should. You WILL break something.</font><hr>';
            $htmlMain .= '<br>The \'Repair\' action will attempt to repair any problems such as out of synch stat files, erroneous PID files, bad hash entries in the database as well as pruning the database.<br><br>Only use this after a server-reboot, if transfers were killed or if there are other problems with the webapp that can\'t be resolved another way.<br>';
            $htmlMain .= '<br><a href="' . _FILE_THIS . '?m=41"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Repair" border="0"> Repair</a>';
            $htmlMain .= '<br><br>';
            break;
        case "41":
            // Maintenance: Repair
            $htmlTitle = "Maintenance - Repair";
            $htmlMain .= '<br>';
            $htmlMain .= 'Repairing Torrentflux-b4rt:';
            require_once "inc/classes/MaintenanceAndRepair.php";
            MaintenanceAndRepair::repair();
            $htmlMain .= ' <font color="green">done</font>';
            $htmlMain .= '<br><br>';
            break;
        case "5":
            // Maintenance: Reset
            $htmlTitle = "Maintenance - Reset";
            $htmlMain .= '<br>Select the item you wish to reset below:<br><br>';
            $htmlMain .= '<strong>Transfer Totals</strong><br>';
            $htmlMain .= 'Reset the transfer totals (totals uploaded/downloaded in the transfer list):<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=51"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="transfer-totals" border="0"> Reset Transfer Totals</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>Xfer Stats</strong><br>';
            $htmlMain .= 'Reset the transfer statistics:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=52"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="xfer-stats" border="0"> Reset Xfer Stats</a>';
            $htmlMain .= '<p>';
            $htmlMain .= '<strong>Personal Settings</strong><br>';
            $htmlMain .= 'Reset the personal settings of all users:<br>';
            $htmlMain .= '<a href="' . _FILE_THIS . '?m=53"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="personal-settings" border="0"> Reset Personal Settings</a>';
            $htmlMain .= '<br><br>';
            break;
        case "51":
            // Maintenance: Reset - transfer-totals
            $htmlTitle = "Maintenance - Reset - Transfer Totals";
            $htmlMain .= '<br>';
            $htmlMain .= 'Resetting transfer totals:<br>';
            $result = resetAllTransferTotals();
            $htmlMain .= $result === true ? ' <font color="green">Done</font>' : '<br><font color="red">Error:</font><br>' . $result;
            $htmlMain .= '<br><br>';
            break;
        case "52":
            // Maintenance: Reset - xfer
            $htmlTitle = "Maintenance - Reset - Transfer Statistics";
            $htmlMain .= '<br>';
            $htmlMain .= 'Resetting xfer stats:<br>';
            $result = Xfer::resetStats();
            $htmlMain .= $result === true ? ' <font color="green">Done</font>' : '<br><font color="red">Error:</font><br>' . $result;
            $htmlMain .= '<br><br>';
            break;
        case "53":
            // Maintenance: Reset - personal-settings
            $htmlTitle = "Maintenance - Reset - Personal Settings";
            $htmlMain .= '<br>';
            $htmlMain .= 'Resetting personal settings:<br>';
            $result = deleteAllUserSettings();
            $htmlMain .= $result === true ? ' <font color="green">Done</font>' : '<br><font color="red">Error:</font><br>' . $result;
            $htmlMain .= '<br><br>';
            break;
        case "6":
            // Maintenance: Lock
            $htmlTitle = "Maintenance - Lock Torrentflux-b4rt Frontend";
            $htmlMain .= '<br>Lock/unlock access to the Torrentflux-b4rt frontend.  Only the superadmin can access the locked frontend.<br><br><hr>';
            switch ($cfg['webapp_locked']) {
                case 0:
                    $htmlMain .= '<strong><font color="green">Frontend currently unlocked.</font></strong>';
                    break;
                case 1:
                    $htmlMain .= '<strong><font color="red">Frontend currently locked.</font></strong>';
                    break;
            }
            $htmlMain .= '<hr><p>';
            $htmlMain .= '<br><a href="' . _FILE_THIS . '?m=61"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Repair" border="0"> ';
            $htmlMain .= $cfg['webapp_locked'] == 1 ? 'Unlock' : 'Lock';
            $htmlMain .= ' Frontend</a>';
            $htmlMain .= '<br><br>';
            break;
        case "61":
            // Maintenance: lock/unlock
            $htmlTitle = "Maintenance - Lock";
            $htmlMain .= '<br>';
            switch ($cfg['webapp_locked']) {
                case 0:
                    $result = setWebappLock(1);
                    $htmlMain .= "Locking frontend:<br>";
                    $htmlMain .= $result === true ? '<font color="green">Done</font>' : '<br><font color="red">Error:</font><br>' . $result;
                    break;
                case 1:
                    $result = setWebappLock(0);
                    $htmlMain .= "Unlocking frontend:<br>";
                    $htmlMain .= $result === true ? '<font color="green">Done</font>' : '<br><font color="red">Error:</font><br>' . $result;
                    break;
            }
            $htmlMain .= '<br><br>';
            break;
    }
    printPage();
    exit;
}
Exemplo n.º 6
0
function cleanDir($path)
{
    if (file_exists($path) && is_dir($path)) {
        $dirHandle = opendir($path);
        while (false !== ($file = readdir($dirHandle))) {
            if ($file != '.' && $file != '..' && $file != 'db_upload.php') {
                $tmpPath = $path . '/' . $file;
                chmod($tmpPath, 0777);
                if (is_dir($tmpPath)) {
                    cleanDir($tmpPath);
                } else {
                    if (!unlink($tmpPath)) {
                        return false;
                    }
                }
            }
        }
        closedir($dirHandle);
    } else {
        return false;
    }
}
Exemplo n.º 7
0
<b>Виберіть спеціальність</b>";
navigate("Спеціальність",$speciality,"spec");
echo "<br><b>Виберіть рік здачі</b>";
navigate("Рік",$year,"year");
echo "<br>
<b>Виберіть файл для обробки</b> <br><input type='file' name='filename'  value='Огляд'>
 <input type='submit' value='Завантажити файл'><br></table></form>";

 //Перевірка на тип файлу
$allowed = array('application/vnd.ms-excel','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
         if ((!in_array($_FILES["filename"]["type"], $allowed))) {
		 if (!empty($_FILES["filename"]["type"])){
		 echo "<FONT COLOR=red><B>Файл не підтримується</B></FONT>";}
         } else { 
cleanDir('report');
cleanDir('report/var');
//Перенесення файлу в папку на сервері
//echo "file/".$_FILES["filename"]["name"];
if (isset($_FILES["filename"]["tmp_name"])) {
   if(is_uploaded_file($_FILES["filename"]["tmp_name"]))
    {
    move_uploaded_file($_FILES["filename"]["tmp_name"], "file/".$_FILES["filename"]["name"]);
	}
}
}
if (!empty($_FILES["filename"]["name"])){
$fileXLS = $_FILES["filename"]["name"];

$variantArray=$data->getVariants($fileXLS);

$lehki = array();
Exemplo n.º 8
0
<b>Виберіть спеціальність</b>";
navigate("Спеціальність",$speciality,"spec");
echo "<br><b>Виберіть рік здачі</b>";
navigate("Рік",$year,"year");
echo "<br>
<b>Виберіть файл для обробки</b> <br><input type='file' name='filename'  value='Огляд'>
 <input type='submit' value='Завантажити файл'><br></table></form>";

 //Перевірка на тип файлу
$allowed = array('application/vnd.ms-excel','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx');
         if ((!in_array($_FILES["filename"]["type"], $allowed))) {
		 if (!empty($_FILES["filename"]["type"])){
		 echo "<FONT COLOR=red><B>Файл не підтримується</B></FONT>";}
         } else { 
cleanDir('report/var');
cleanDir('report');


//Перенесення файлу в папку на сервері
//echo "file/".$_FILES["filename"]["name"];
if (isset($_FILES["filename"]["tmp_name"])) {
   if(is_uploaded_file($_FILES["filename"]["tmp_name"]))
    {
    move_uploaded_file($_FILES["filename"]["tmp_name"], "file/".$_FILES["filename"]["name"]);
	}
}
}
if (!empty($_FILES["filename"]["name"])){
$fileXLS = $_FILES["filename"]["name"];

$variantArray=$data->getVariants($fileXLS);