示例#1
0
/**
 * Implementation of hook_page.
 */
function ft_db_page($act)
{
    global $ft;
    $str = '';
    if ($act == 'db' && isset($ft['plugins']['db']['settings']['flushtables']) && $ft['plugins']['db']['settings']['flushtables'] === TRUE) {
        // Show all DB tables.
        $str .= "<h2>" . t('Database tables') . "</h2>";
        // Other users.
        if (is_array($ft['db']) && is_array($ft['db']['tables']) && count($ft['db']['tables']) > 0) {
            $str .= '<table><tr><th>' . t('Table name') . '</th><th>' . t('Delete?') . '</th></tr>';
            foreach ($ft['db']['tables'] as $name) {
                $str .= '<tr><td>' . $name . '</td><td>' . ft_make_link(t('delete'), 'act=db_delete&amp;value=' . $name) . '</td></tr>';
            }
            $str .= '</table>';
        } else {
            $str .= '<p>' . t('No tables present in database.') . '</p>';
        }
    } elseif ($act == 'db_delete') {
        $display_value = htmlentities($_GET['value']);
        $str = "<h2>" . t('Delete database table: !table', array('!table' => $display_value)) . "</h2>";
        $str .= "<p>" . t('Are you sure you want to continue? This will delete the table from the database.') . "</p>";
        $str .= '<form action="' . ft_get_self() . '" method="post">';
        $str .= '<div>';
        $str .= '<input type="hidden" name="value" value="' . $display_value . '">';
        $str .= '<input type="hidden" name="act" value="db_delete_submit">';
        $str .= '<input type="submit" name="ft_submit" value="' . t('Yes, delete this table') . '">';
        $str .= '<input type="submit" name="ft_submit" value="' . t('Cancel') . '">
      </div>
    </form>';
    }
    return $str;
}
/**
 * Implementation of hook_ajax.
 */
function ft_search_ajax($act)
{
    if ($act == 'search') {
        $new = array();
        $ret = "";
        $q = $_POST['q'];
        $type = $_POST['type'];
        if (!empty($q)) {
            if ($type == "true") {
                $list = _ft_search_find_files(ft_get_dir(), $q);
            } else {
                $list = _ft_search_find_files(ft_get_root(), $q);
            }
            if (is_array($list)) {
                if (count($list) > 0) {
                    foreach ($list as $c) {
                        if (empty($c['dir'])) {
                            $c['dirlink'] = "/";
                        } else {
                            $c['dirlink'] = $c['dir'];
                        }
                        if ($c['type'] == "file") {
                            $link = "<a href='" . ft_get_root() . "{$c['dir']}/{$c['name']}' title='" . t('Show !file', array('!file' => $c['name'])) . "'>{$c['shortname']}</a>";
                            if (HIDEFILEPATHS == TRUE) {
                                $link = ft_make_link($c['shortname'], 'method=getfile&amp;dir=' . rawurlencode($c['dir']) . '&amp;file=' . $c['name'], t('Show !file', array('!file' => $c['name'])));
                            }
                            $ret .= "<dt>{$link}</dt><dd>" . ft_make_link($c['dirlink'], "dir=" . rawurlencode($c['dir']) . "&amp;highlight=" . rawurlencode($c['name']) . "&amp;q=" . rawurlencode($q), t("Highlight file in directory")) . "</dd>";
                        } else {
                            $ret .= "<dt class='dir'>" . ft_make_link($c['shortname'], "dir=" . rawurlencode("{$c['dir']}/{$c['name']}") . "&amp;q={$q}", t("Show files in !folder", array('!folder' => $c['name']))) . "</dt><dd>" . ft_make_link($c['dirlink'], "dir=" . rawurlencode($c['dir']) . "&amp;highlight=" . rawurlencode($c['name']) . "&amp;q=" . rawurlencode($q), t("Highlight file in directory")) . "</dd>";
                        }
                    }
                    return $ret;
                } else {
                    return "<dt class='error'>" . t('No files found') . ".</dt>";
                }
            } else {
                return "<dt class='error'>" . t('Error.') . "</dt>";
            }
        } else {
            return "<dt class='error'>" . t('Enter a search string.') . "</dt>";
        }
    }
}
示例#3
0
/**
 * Create HTML for top header that shows breadcumb navigation.
 */
function ft_make_header()
{
    global $ft;
    $str = "<h1 id='title'>" . ft_make_link(t("Home"), '', t("Go to home folder")) . " ";
    if (empty($_REQUEST['dir'])) {
        $str .= "/</h1>";
    } else {
        // Get breadcrumbs.
        if (!empty($_REQUEST['dir'])) {
            $crumbs = explode("/", $_REQUEST['dir']);
            // Remove first empty element.
            unset($crumbs[0]);
            // Output breadcrumbs.
            $path = "";
            foreach ($crumbs as $c) {
                $path .= "/{$c}";
                $str .= "/";
                $str .= ft_make_link($c, "dir=" . rawurlencode($path), t("Go to folder"));
            }
        }
        $str .= "</h1>";
    }
    // Display logout link.
    if (LOGIN == TRUE) {
        $str .= '<div id="logout"><p>';
        if (isset($ft['users']) && @count($ft['users']) > 0 && LOGIN == TRUE) {
            $str .= t('Logged in as !user ', array('!user' => $_SESSION['ft_user_' . MUTEX]));
        }
        $str .= ft_make_link(t("[logout]"), "act=logout", t("Logout of File Thingie")) . '</p>';
        $str .= '<div id="secondary_menu">' . implode("", ft_invoke_hook('secondary_menu')) . '</div>';
        $str .= '</div>';
    }
    return $str;
}
示例#4
0
/**
 * Implementation of hook_page.
 */
function ft_log_page($act)
{
    global $ft;
    $str = '';
    if ($act == 'log' && isset($ft['plugins']['log']['settings']['viewlogs']) && $ft['plugins']['log']['settings']['viewlogs'] === TRUE) {
        $types = ft_log_get_types();
        $boundaries = ft_log_get_boundaries();
        $month_min = date('m', strtotime($boundaries['oldest']));
        $month_max = date('m', strtotime($boundaries['newest']));
        $year_min = date('Y', strtotime($boundaries['oldest']));
        $year_max = date('Y', strtotime($boundaries['newest']));
        $str = "<h2>" . t('Log') . "</h2>";
        $str .= '<div>';
        // Filters.
        $str .= '<form action="' . ft_get_self() . '?act=log" method="get">';
        $str .= '<div>';
        $str .= ' <label for="type">' . t('Show') . ' </label>';
        $str .= '<select id="type" name="type">';
        $str .= '<option value="">All types</option>';
        foreach ($types as $type) {
            $str .= '<option value="' . $type . '" ' . ($type == $_GET['type'] ? 'selected="selected"' : '') . '>' . $type . '</option>';
        }
        $str .= '</select> ';
        $str .= '<label for="from">' . t('from:') . ' </label>';
        $str .= '<select id="from_day" name="from_day">';
        $str .= '<option value="">--</option>';
        $str .= ft_log_get_date_options('from_day');
        $str .= '</select> ';
        $str .= '<select id="from" name="from">';
        $str .= '<option value="">Any month</option>';
        $str .= ft_log_get_month_options($month_min, $month_max, $year_min, $year_max, 'from');
        $str .= '</select>';
        $str .= ' <label for="to">' . t('to:') . ' </label>';
        $str .= '<select id="to_day" name="to_day">';
        $str .= '<option value="">--</option>';
        $str .= ft_log_get_date_options('to_day');
        $str .= '</select> ';
        $str .= '<select id="to" name="to">';
        $str .= '<option value="">Any month</option>';
        $str .= ft_log_get_month_options($month_min, $month_max, $year_min, $year_max, 'to');
        $str .= '</select> ';
        $str .= '<input type="submit" name="ft_submit" value="' . t('Show') . '">';
        $str .= '<input type="hidden" name="act" value="log">';
        $str .= '</div>';
        $str .= '</form>';
        $str .= '<table id="log_table" class="tablesorter"><thead><tr><th>' . t('Type') . '</th><th>' . t('Message') . '</th><th>' . t('Location') . '<th>' . t('Timestamp') . '</th></tr></thead><tbody>';
        $items = ft_log_do_query($_GET['type'], $_GET['from_day'], $_GET['from'], $_GET['to_day'], $_GET['to']);
        foreach ($items as $row) {
            $str .= '<tr><td>' . $row['type'] . '</td><td>' . htmlentities($row['message']) . '</td><td>' . htmlentities($row['location']) . '</td><td>' . $row['timestamp'] . '</td></tr>';
        }
        $str .= '</tbody></table>';
        $str .= '<form action="' . ft_get_self() . '" method="post" accept-charset="utf-8" style="margin-left:300px;"><div><input type="submit" value="' . t('Delete records older than 7 months') . '"><input type="hidden" name="act" value="log_prune" /> ';
        $query = 'act=log_csv&type=' . $_GET['type'] . '&from_day=' . $_GET['from_day'] . '&from=' . $_GET['from'] . '&to_day=' . $_GET['to_day'] . '&to=' . $_GET['to'];
        $str .= ft_make_link(t('Download CSV report'), $query, t("Download CSV report of current view"));
        $str .= '</div></form>';
        $str .= '</div>';
    }
    return $str;
}
/**
 * Implementation of hook_secondary_menu.
 */
function ft_config_secondary_menu()
{
    return ft_make_link(t('[config]'), "act=config", t("Change File Thingie settings"));
}