Blame
Date:
Mon Oct 10 04:00:18 2022 UTC
Message:
Daily backup
01
2021-12-17
jrmu
<?php if (!defined('PmWiki')) exit();
02
2021-12-17
jrmu
/* Copyright 2004-2005 Patrick R. Michaud (pmichaud@pobox.com)
03
2021-12-17
jrmu
This file is part of PmWiki; you can redistribute it and/or modify
04
2021-12-17
jrmu
it under the terms of the GNU General Public License as published
05
2021-12-17
jrmu
by the Free Software Foundation; either version 2 of the License, or
06
2021-12-17
jrmu
(at your option) any later version. See pmwiki.php for full details.
07
2021-12-17
jrmu
08
2021-12-17
jrmu
This file defines an alternate authentication scheme based on the
09
2021-12-17
jrmu
HTTP Basic authentication protocol (i.e., the scheme used by default
10
2021-12-17
jrmu
in PmWiki 1).
11
2021-12-17
jrmu
*/
12
2021-12-17
jrmu
13
2021-12-17
jrmu
## If the webserver has already authenticated someone, then use
14
2021-12-17
jrmu
## that identifier for our authorization id. We also disable
15
2021-12-17
jrmu
## the use of the browser's Basic Auth form later, since it tends
16
2021-12-17
jrmu
## to confuse webservers.
17
2021-12-17
jrmu
if (IsEnabled($EnableRemoteUserAuth, 1) && @$_SERVER['REMOTE_USER']) {
18
2021-12-17
jrmu
SDV($EnableHTTPBasicAuth, 0);
19
2021-12-17
jrmu
SDV($AuthId, $_SERVER['REMOTE_USER']);
20
2021-12-17
jrmu
}
21
2021-12-17
jrmu
22
2021-12-17
jrmu
## If the browser supplied a password, add that password to the
23
2021-12-17
jrmu
## list of passwords used for authentication
24
2021-12-17
jrmu
if (@$_SERVER['PHP_AUTH_PW'])
25
2021-12-17
jrmu
SessionAuth($pagename, array('authpw'=>array($_SERVER['PHP_AUTH_PW'] => 1)));
26
2021-12-17
jrmu
27
2021-12-17
jrmu
28
2021-12-17
jrmu
## $EnableHTTPBasicAuth tells PmWikiAuth to use the browser's
29
2021-12-17
jrmu
## HTTP Basic protocol prompt instead of a form-based prompt.
30
2021-12-17
jrmu
if (IsEnabled($EnableHTTPBasicAuth, 1))
31
2021-12-17
jrmu
SDV($AuthPromptFmt, 'function:HTTPBasicAuthPrompt');
32
2021-12-17
jrmu
33
2021-12-17
jrmu
## HTTPBasicAuthPrompt replaces PmWikiAuth's form-based password
34
2021-12-17
jrmu
## prompt with the browser-based HTTP Basic prompt.
35
2021-12-17
jrmu
function HTTPBasicAuthPrompt($pagename) {
36
2021-12-17
jrmu
global $AuthRealmFmt, $AuthDeniedFmt;
37
2021-12-17
jrmu
SDV($AuthRealmFmt,$GLOBALS['WikiTitle']);
38
2021-12-17
jrmu
SDV($AuthDeniedFmt,'A valid password is required to access this feature.');
39
2021-12-17
jrmu
$realm=FmtPageName($AuthRealmFmt,$pagename);
40
2021-12-17
jrmu
header("WWW-Authenticate: Basic realm=\"$realm\"");
41
2021-12-17
jrmu
header("Status: 401 Unauthorized");
42
2021-12-17
jrmu
header("HTTP-Status: 401 Unauthorized");
43
2021-12-17
jrmu
PrintFmt($pagename,$AuthDeniedFmt);
44
2021-12-17
jrmu
exit;
45
2021-12-17
jrmu
}
46
2021-12-17
jrmu
IRCNow