Example #1
0
    }
    if ($show_db) {
        fs_dummy_auth();
        fs_show_page(FS_ABS_PATH . '/php/page-database.php');
        return;
    }
    // any other case, procceed with normal login screen.
} else {
    if (fs_no_admin()) {
        fs_dummy_auth();
        fs_show_page(FS_ABS_PATH . '/php/page-add-admin.php');
        return;
    }
}
// to force login in DEMO mode, append ?login to the firestats url.
if (defined('DEMO') && !isset($_GET['login'])) {
    $user = new stdClass();
    $user->name = "Demo";
    $user->id = 1;
    $user->security_level = SEC_USER;
    $res = fs_start_user_session($user);
} else {
    $res = fs_resume_user_session();
}
// if authenticated or database is not yet configured propertly, show main page (that will show db configuration or admin user creation pages)
if ($res === true) {
    fs_show_page('php/tabbed-pane.php');
    return;
} else {
    fs_show_page(FS_ABS_PATH . '/login.php', true, true, true);
}
Example #2
0
/**
 * Authenticate the current user as an admin.
 * this should only be used if there is currenty no admin in the database.
 */
function fs_dummy_auth()
{
    if (!fs_no_admin()) {
        echo "Admin is already defined in the database";
        return;
    }
    $user = new stdClass();
    $user->dummy = true;
    $user->name = "Dummy admin";
    $user->security_level = SEC_ADMIN;
    $res = fs_start_user_session($user);
    if ($res) {
        fs_store_session();
    }
    if ($res === false) {
        return false;
    }
}
Example #3
0
function fs_page()
{
    $path = fs_get_firestats_path();
    if ($path) {
        if (!fs_full_installation()) {
            if (defined('DEMO')) {
                $user = new stdClass();
                $user->name = "Demo";
                $user->id = 1;
                $user->security_level = SEC_USER;
                $res = fs_start_user_session($user);
            } else {
                $res = fs_resume_user_session();
            }
            if ($res === true) {
                fs_show_embedded_page($path . '/php/tabbed-pane.php');
                return;
            } else {
                fs_show_embedded_page($path . '/login.php', true, true, true);
            }
        } else {
            if (fs_can_use() === true) {
                fs_show_embedded_page($path . '/php/tabbed-pane.php');
                return;
            } else {
                $msg = fs_r("You are not authorized to access FireStats");
                $msg = "<div class='error'>{$msg}</div>";
                fs_show_embedded_page($msg, false);
            }
        }
    } else {
        $href = sprintf("<a href='options-general.php?page=FireStats'>%s</a>", __('Options'));
        echo '<div class="error" style="margin-top:40px;margin-bottom:40px">' . sprintf(__('You need to configure FireStats in the %s menu'), $href) . '</div>';
    }
}