\n"; // if (file_exists($caFile)) // echo "\n"; } if (file_exists($caFile)) { Swekey_SetCAFile($caFile); } elseif (! empty($caFile) && (substr($_SESSION['SWEKEY']['CONF_SERVER_CHECK'], 0, 8) == "https://")) { return "Internal Error: CA File $caFile not found"; } $result = null; $swekey_id = $_GET['swekey_id']; $swekey_otp = $_GET['swekey_otp']; if (isset($swekey_id)) { unset($_SESSION['SWEKEY']['AUTHENTICATED_SWEKEY']); if (! isset($_SESSION['SWEKEY']['RND_TOKEN'])) { unset($swekey_id); } else { if (strlen($swekey_id) == 32) { $res = Swekey_CheckOtp($swekey_id, $_SESSION['SWEKEY']['RND_TOKEN'], $swekey_otp); unset($_SESSION['SWEKEY']['RND_TOKEN']); if (! $res) { $result = __('Hardware authentication failed!') . ' (' . Swekey_GetLastError() . ')'; } else { $_SESSION['SWEKEY']['AUTHENTICATED_SWEKEY'] = $swekey_id; $_SESSION['SWEKEY']['FORCE_USER'] = $_SESSION['SWEKEY']['VALID_SWEKEYS'][$swekey_id]; return null; } } else { $result = __('No valid authentication key plugged'); if ($_SESSION['SWEKEY']['CONF_DEBUG']) { $result .= "
" . htmlspecialchars($swekey_id); } unset($_SESSION['SWEKEY']['CONF_LOADED']); // reload the conf file } } } else { unset($_SESSION['SWEKEY']); } $_SESSION['SWEKEY']['RND_TOKEN'] = Swekey_GetFastRndToken(); if (strlen($_SESSION['SWEKEY']['RND_TOKEN']) != 64) { $result = __('Hardware authentication failed!') . ' (' . Swekey_GetLastError() . ')'; unset($_SESSION['SWEKEY']['CONF_LOADED']); // reload the conf file } if (! isset($swekey_id)) { ?> display(); if ($GLOBALS['error_handler']->hasDisplayErrors()) { echo '
'; $GLOBALS['error_handler']->dispErrors(); echo '
'; } } if (isset($_SESSION['SWEKEY']) && $_SESSION['SWEKEY']['ENABLED']) { echo ''; } } if (!empty($_GET['session_to_unset'])) { session_write_close(); session_id($_GET['session_to_unset']); session_start(); $_SESSION = array(); session_write_close(); session_destroy(); exit; } if (isset($_GET['swekey_reset'])) { unset($_SESSION['SWEKEY']); } ?>