restricted.php
2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* Include file that guards access to all admin php.
*
* If user is not in some role, make them login
* or let them determine a password that can be
* added to the WEB-INF/password.xml file.
*
* @author Sam
*/
require_once "WEB-INF/php/inc.php";
if (! ($is_read_role || $is_write_role) ) {
display_header("restricted.php", "Resin Administration", "");
$login_uri = uri("login.php?target=$target_uri");
?>
<h2>Login</h2>
<p>
<a href="<?= $login_uri ?>">Login is required</a>
</p>
<?php
if (! $is_localhost)
$is_localhost = $request->remoteHost == $request->serverName;
if (! $is_localhost)
$is_localhost = $request->remoteAddr == $request->localAddr;
if (! $is_localhost) {
display_footer("restricted.php");
exit;
}
?>
<h2>Create password</h2>
<?php
$authenticator = jndi_lookup("java:comp/env/caucho/admin/auth");
$password_file = $authenticator->path;
$is_virgin_password = $authenticator->userCount === 0;
if (empty($_REQUEST["digest_attempt"])) {
if ($is_virgin_password) {
?>
<p>
The following form can be used to establish an administration
password for Resin.
</p>
<?php
} else {
?>
<p>
If you have forgotten your administration password,
the following form can be used to establish a new one.
</p>
<?php
}
}
$digest_username = "";
include "digest.php";
if (empty($digest)) {
display_footer("restricted.php");
exit
}
?>
<?php
/** XXX:
<p>
The following can now be added to the file
<code><b><?= $password_file ?></b></code>
to enable administration functionality.
</p>
<pre>
<authenticator>
<user name='<?= $digest_username ?>' password='<?= $digest ?>' roles='read,write'/>
</authenticator>
</pre>
*/
?>
<p>
The following can now be set in the resin.conf file
to enable administration functionality.
</p>
<pre>
<resin:set var="resin_admin_user" value="<?= $digest_username ?>"/>
<resin:set var="resin_admin_password" value="<?= $digest ?>"/>
</pre>
<p>
By default, access to the administration application is limited
to the localhost. The default behaviour can be changed in the
resin.conf file. To enable access to clients other than localhost:
</p>
<pre>
<resin:set var="resin_admin_external" value="true"/>
</pre>
<p>
Once the file has been updated, you can
<a href="<?= $login_uri ?>">continue to the administration area</a>.
</p>
<p>
When prompted, use the username and password you provided.
</p>
<?php
display_footer("restricted.php");
exit
}
?>