Esempio n. 1
0
            my_LoginError();
        }
    } else {
        // Search for the user's node by slug //
        $response['id'] = intval(node_GetNodeIdByParentIdAndSlug(CMW_NODE_USER, $login));
        // If a valid ID, retrieve the hash
        if ($response['id'] > 0) {
            $hash = user_GetHashById($response['id']);
        } else {
            my_LoginError();
        }
    }
    // If found, verify password against the stored hash.
    if (user_VerifyPassword($password, $hash)) {
        // Success! //
        user_StartSession(false);
        user_DoLogin($response['id']);
        user_EndSession();
        // TODO: Clear login attempt cache //
    } else {
        my_LoginError();
    }
    // ** Successfully Logged in ** //
    // Retrieve my info //
    // Retrieve my list of Favourites, and a list of most recent posts I've loved. //
} else {
    if ($action === 'logout') {
        user_Start();
        user_DoLogout();
        // Destroy session
    } else {
Esempio n. 2
0
function user_Start($force_regen = false, $preserve_token = false)
{
    user_StartSession();
    user_StartLogin($force_regen, $preserve_token);
}
Esempio n. 3
0
<?php

require_once __DIR__ . "/../web.php";
require_once __DIR__ . "/../core/internal/sanitize.php";
require_once __DIR__ . "/../core/internal/emoji.php";
require_once __DIR__ . "/../core/post.php";
user_StartSession();
//template_SetTheme("embed");
template_GetHeader();
?>

<body>

So. It has come to this...<br />
<br />
<?php 
$berg = apcu_fetch("Hamburg");
if ($berg === false) {
    $berg = 1;
} else {
    $berg++;
}
apcu_store("Hamburg", $berg);
echo "Mr Berg: " . $berg . "<br />";
if (user_getId() === 0) {
    user_setId(200);
} else {
    user_setId(user_getId() + 1);
}
?>
Esempio n. 4
0
function main()
{
    $out = "";
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $out .= print_r($_POST, true);
        $out .= "<br />";
        // Required Fields in the POST data //
        if (!isset($_POST['login'])) {
            return;
        }
        if (!isset($_POST['password'])) {
            return;
        }
        //if ( !isset($_POST['hashword']) ) return;
        // Password //
        $password = $_POST['password'];
        if (empty($password)) {
            return;
        }
        $login = $_POST['login'];
        // Can Login 3 ways:
        // - User Name (slug)
        // - Email
        // - User ID
        $mail = sanitize_Email($login);
        $id = sanitize_Id($login);
        $slug = sanitize_Slug($login);
        $hash = "";
        if (!empty($mail)) {
            $out .= "By Mail<br />";
            $data = user_GetIdAndHashByMail($mail);
            $id = $data['id'];
            $hash = $data['hash'];
        } else {
            if (!empty($id)) {
                $out .= "By User ID<br />";
                $hash = user_GetHashById($id);
            } else {
                if (!empty($slug)) {
                    $out .= "By Slug<br />";
                    $id = node_GetNodeIdByParentIdAndSlug(CMW_NODE_USER, $slug);
                    if ($id > 0) {
                        $hash = user_GetHashById($id);
                    }
                } else {
                    $out .= "Bad Login Method<br />";
                }
            }
        }
        $success = user_VerifyPassword($password, $hash);
        $out .= "Verify: " . ($success ? "Success!" : "failed") . "<br />";
        if ($success) {
            user_StartSession(true);
            user_SetLoginToken();
            user_SetID($id);
            user_EndSession();
        }
        $out .= "<br />";
    }
    return $out;
}