Example #1
0
// Handle WebDAV
if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') {
    header('location: ' . OC_Helper::linkToRemote('webdav'));
    exit;
} elseif (!OC_User::isLoggedIn() && substr(OC::$REQUESTEDFILE, -3) == 'css') {
    OC_App::loadApps();
    OC::loadfile();
} elseif (OC_User::isLoggedIn()) {
    OC_App::loadApps();
    if (isset($_GET["logout"]) and $_GET["logout"]) {
        OC_User::logout();
        header("Location: " . OC::$WEBROOT . '/');
        exit;
    } else {
        if (is_null(OC::$REQUESTEDFILE)) {
            OC::loadapp();
        } else {
            OC::loadfile();
        }
    }
    // For all others cases, we display the guest page :
} else {
    OC_App::loadApps();
    $error = false;
    // remember was checked after last login
    if (isset($_COOKIE["oc_remember_login"]) && isset($_COOKIE["oc_token"]) && isset($_COOKIE["oc_username"]) && $_COOKIE["oc_remember_login"]) {
        if (defined("DEBUG") && DEBUG) {
            OC_Log::write('core', 'Trying to login from cookie', OC_Log::DEBUG);
        }
        // confirm credentials in cookie
        if (isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username']) && OC_Preferences::getValue($_COOKIE['oc_username'], "login", "token") === $_COOKIE['oc_token']) {