function node_Resolve($action) { $paths = [CMW_NODE_ROOT]; foreach ($action as $key => $slug) { $id = node_GetNodeIdByParentIdAndSlug($paths[$key], $slug); if (!empty($id)) { $paths[] = $id; } else { return null; } } return $paths; }
$response['login'] = $login; $response['pw'] = $password; */ // By E-mail // if ($mail) { // Search user_table for a matching e-mail. $data = user_GetIdAndHashByMail($mail); if ($data) { $response['id'] = intval($data['id']); $hash = $data['hash']; } else { 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 {
$mode = M_DEFAULT; $args = core_ParseActionURL(); $args_count = count($args); // Sanitize Input foreach ($args as $arg) { $arg = sanitize_Slug($arg); if (empty($arg)) { $mode = M_ERROR; break; } } if ($mode > 0) { $args_merged = implode('/', $args); $paths = [CMW_NODE_ROOT]; foreach ($args as $key => $slug) { $id = node_GetNodeIdByParentIdAndSlug($paths[$key], $slug); if (!empty($id)) { $paths[] = $id; } else { $mode = M_ERROR; break; } } if ($mode > 0) { $paths_count = count($paths); $this_node_id =& $paths[$paths_count - 1]; $this_node = node_GetNodeById($this_node_id); $author_node = []; if (!empty($this_node['author']) && $this_node['author'] > 0) { $author_node = node_GetNodeById($this_node['author']); }
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; }