Exemple #1
0
function rtgui_session_start()
{
    global $tmp_add_dir, $private_storage_dir, $always_show_tags;
    if (!$_SESSION) {
        if (@file_put_contents("{$private_storage_dir}/test.txt", 'testing')) {
            @unlink("{$private_storage_dir}/test.txt");
        } else {
            die('<h1>ERROR: could not write to private storage directory (defined by the $private_storage_dir setting).</h1>');
        }
        if (@file_put_contents("{$tmp_add_dir}/test.txt", 'testing')) {
            @unlink("{$tmp_add_dir}/test.txt");
        } else {
            die('<h1>ERROR: could not write to temporary directory (defined by the $tmp_add_dir setting).</h1>');
        }
        session_name(get_rtgui_path());
        session_start();
    }
    $tags_filename = "{$private_storage_dir}/tags.txt";
    if (!is_array($_SESSION['tags']) || @filemtime($tags_filename) > $_SESSION['tags_modified']) {
        $tags = new PersistentObject($tags_filename);
        $used_tags = array();
        if (is_array($tags->data)) {
            foreach ($tags->data as $hash => $this_tags) {
                foreach ($this_tags as $this_tag) {
                    $used_tags[$this_tag] = true;
                }
            }
            $used_tags = array_keys($used_tags);
            if (count($used_tags)) {
                sort($used_tags);
            }
            $_SESSION['tags'] = $tags->data;
        } else {
            $_SESSION['tags'] = array();
        }
        $_SESSION['used_tags'] = $used_tags;
        $_SESSION['tags_modified'] = @filemtime($tags_filename);
    }
    if (is_array($always_show_tags)) {
        $_SESSION['used_tags'] = array_unique(array_merge($_SESSION['used_tags'], $always_show_tags));
    }
}
Exemple #2
0
//  along with rtGui.  If not, see <http://www.gnu.org/licenses/>.
$execstart = microtime(true);
require_once 'config.php';
require_once 'functions.php';
rtgui_session_start();
extract($_REQUEST, EXTR_PREFIX_ALL, 'r');
// Try using alternative XMLRPC library from http://sourceforge.net/projects/phpxmlrpc/
// (see http://code.google.com/p/rtgui/issues/detail?id=19)
if (!function_exists('xml_parser_create')) {
    require_once 'xmlrpc.inc';
    require_once 'xmlrpc_extension_api.inc';
}
if (!isset($r_debug)) {
    $r_debug = 0;
}
$config = array('diskAlertThreshold' => $disk_alert_threshold, 'debugTab' => $debug_mode, 'dateAddedFormat' => $date_added_format, 'rtGuiPath' => get_rtgui_path(), 'canHideUnhide' => $can_hide_unhide, 'defaultFilterText' => 'Filter');
$user_settings = array('refreshInterval' => (int) get_user_setting('refresh_interval'), 'sortVar' => get_user_setting('sort_var'), 'sortDesc' => get_user_setting('sort_desc') == 'yes' ? true : false, 'theme' => get_current_theme(), 'useDialogs' => get_user_setting('use_dialogs') == 'yes' ? true : false, 'showHidden' => get_user_setting('show_hidden') == 'yes' ? true : false);
// Reset saved data (if any)
$_SESSION['rpc_cache'] = array();
$_SESSION['persistent'] = array();
// Get the list of torrents downloading
if (!$r_view) {
    $r_view = 'main';
}
$data = get_all_torrents(array('for_html' => true, 'view' => $r_view));
// Sort the list of torrents
function compare_torrents($a, $b)
{
    global $user_settings;
    $cmp = $user_settings['sortDesc'] ? -1 : 1;
    $value_a = $a[$user_settings['sortVar']];
Exemple #3
0
function set_user_setting($key, $value)
{
    @setcookie($key, $value, time() + 60 * 60 * 24 * 365, get_rtgui_path());
    // HACK: make the desired value available before the next page load
    $_COOKIE[$key] = $value;
}