Added guest menu and user_email

SVN revision: 186
This commit is contained in:
2002-07-27 06:52:54 +00:00
parent 4e88e0da64
commit f53a91cd00
2 changed files with 103 additions and 44 deletions
+30 -8
View File
@@ -319,6 +319,23 @@ special command in addition to the above commands: The command <b><code>Last x</
behaviour without the "<I>Find Menu commands</I>" option.
<p>
<li><b><code>Guest Menu commands = &lt;list&gt;</code></b>
</br>
This option specifies the menu commands for guest logins. A guest login happens if a
password file is used, but someone accesses the logbook for the first time, which means
that no username/password is given. In that case the commands from the guest menu
are displayed, which usually contain a subset of the normal commands. A typical scenario
is a logbook which only has commands to read the logbook on the guest menu, but no
commands to write/edit entries. Instead, the <b>login</b> command is given in the guest
menu, with which one can login as a real user (username and password have to match those
from the password file), which then allowes full access via the <b>"Menu commands"</b> list.
A typical example for the menu settings for this scenario are:<p>
<pre>
Menu commands = New, Edit, Reply, Find, Last 10, Change password, Logout, Help
Guest menu commands = Find, Last 10, Login, Help
</pre>
<p>
<li><b><code>Bottom text = &lt;file&gt;</code></b>
</br>
If this option is present, the HTML contents of <b><code>file</code></b> is displayed at
@@ -500,7 +517,8 @@ text. This text can contain arbitrary fixed text and following values:
<LI><b>$host</b>: The host name where <code><b>elogd</b></code> is running
<LI><b>$remote_host</b>: The host name of the host from with the entry was submitted
<LI><b>$short_name</b>: The login name (if password file is present)
<LI><b>$long_name</b>: The full name (if password file is present)
<LI><b>$long_name</b>: The full name from the password file for the current user
<LI><b>$user_email</b>: The email address from the password file for the current user
<LI><b>$logbook</b>: The name of the current logbook
<LI><b>$date</b>: The current date, formatted via "<I>Date format</I>"
</UL>
@@ -570,21 +588,25 @@ must be re-entered.
An alternative to the read/write/admin passwords is the user level access with a
password file. This file contains user names and passwords in following format:
<p>
<ul><code><pre>&lt;login name1&gt;:&lt;password1&gt;:&lt;full name1&gt;
&lt;login name2&gt;:&lt;password2&gt;:&lt;full name2&gt;
&lt;login name3&gt;:&lt;password3&gt;:&lt;full name3&gt;
<ul><code><pre>&lt;login name1&gt;:&lt;password1&gt;:&lt;full name1&gt;:&lt;email1&gt;
&lt;login name2&gt;:&lt;password2&gt;:&lt;full name2&gt;:&lt;email1&gt;
&lt;login name3&gt;:&lt;password3&gt;:&lt;full name3&gt;:&lt;email1&gt;
...</pre></code></ul>
<p>
The passwords are encoded. To create or change them, use the "<I>Change
Password</I>" menu point. To create a new user, edit the password file
manually and use an empty password (like "<code>&lt;login name&gt;::&lt;full name&gt;</code>"), which can then be changed via the "<I>Change password</I>" menu point.
manually and use an empty password (like "<code>&lt;login name&gt;::&lt;full name&gt;:&lt;email&gt;</code>"), which can then be changed via the "<I>Change password</I>" menu point.
<p>
The presence of a password file requires all users to "<I>log in</I>" using their name and
password. An additional advantage of this method is that the user name can be used as
password, excep when a guest login is allowed via the <b>"Guest menu commands"</b> option.
An additional advantage of this method is that the user name can be used as
an attribute value for creating logbook entries. For example, the following line could be
added to the configuration file to fill in the <i>Author</i> attribute with the user name:
added to the configuration file to fill in the <i>Author</i> and the <i>Email</i> attributes
with the current user name and email:
<p>
<ul><code>Options Author = $long_name from $remote_host</code></ul>
<ul><code>Attributes = Author, Email, ...</code></ul>
<ul><code>Options Author = $long_name from $remote_host<br>
Options Email = $user_email</code></ul>
<p>
Thus the author name is not user-input anymore, ensuring the entry always contains the
actual user name. For a full listing of substitutions, see the "<I>Subst &lt;attrib></I>" option.
+73 -36
View File
@@ -6,8 +6,11 @@
Contents: Web server program for Electronic Logbook ELOG
$Log$
Revision 2.50 2002/07/27 06:52:14 midas
Added guest menu and user_email
Revision 2.49 2002/07/26 08:40:56 midas
Fixed 'POST' statement containing some blanks
Fixed type
Revision 2.48 2002/07/25 15:37:26 midas
Fixed bug with ss_find_file under unix
@@ -251,7 +254,7 @@
\********************************************************************/
/* Version of ELOG */
#define VERSION "2.0.5"
#define VERSION "2.0.6"
#include <stdio.h>
#include <sys/types.h>
@@ -3249,6 +3252,15 @@ int i, j;
rsprintf("<font size=3 face=verdana,arial,helvetica,sans-serif color=%s><b>&nbsp;&nbsp;%s \"%s\"<b></font></td>\n",
gt("Title fontcolor"), loc("Logged in as"), getparam("full_name"));
}
else
{
if (getcfg(logbook, "Guest menu commands", str))
{
rsprintf("<td bgcolor=%s align=center>", gt("Title BGColor"));
rsprintf("<font size=3 face=verdana,arial,helvetica,sans-serif color=%s><b>&nbsp;&nbsp;%s<b></font></td>\n",
gt("Title fontcolor"), loc("Not logged in"));
}
}
/* right cell */
rsprintf("<td bgcolor=%s align=right>", gt("Title BGColor"));
@@ -3469,6 +3481,11 @@ struct tm *ts;
strcpy(list[i], "long_name");
strcpy(value[i++], getparam("full_name"));
/* add email */
strcpy(list[i], "user_email");
strcpy(value[i], "mailto:");
strcat(value[i++], getparam("user_email"));
/* add logbook */
strcpy(list[i], "logbook");
strcpy(value[i++], lbs->name);
@@ -3938,7 +3955,8 @@ time_t now;
/* if attribute cannot be changed, just display text */
if ((attr_flags[index] & AF_LOCKED) || (bedit && (attr_flags[index] & AF_FIXED)))
{
rsprintf("<td bgcolor=%s>%s\n", gt("Categories bgcolor2"), attrib[index]);
rsprintf("<td bgcolor=%s>\n", gt("Categories bgcolor2"));
rsputs2(attrib[index]);
if (attr_flags[index] & AF_MULTI)
{
@@ -6463,8 +6481,12 @@ BOOL first;
if (!allow_user(lbs, command))
return;
/* get menu command */
getcfg(lbs->name, "Menu commands", menu_str);
/* check for guest access */
if (!getcfg(lbs->name, "Guest Menu commands", menu_str) ||
*getparam("unm") != 0)
getcfg(lbs->name, "Menu commands", menu_str);
/* default menu commands */
if (menu_str[0] == 0)
{
strcpy(menu_str, loc("New"));
@@ -7459,12 +7481,12 @@ char str[256];
/*------------------------------------------------------------------*/
BOOL get_user_line(LOGBOOK *lbs, char *user, char *password, char *full_name)
BOOL get_user_line(LOGBOOK *lbs, char *user, char *password, char *full_name, char *email)
{
char str[256], line[256], file_name[256], *p;
FILE *f;
password[0] = full_name[0] = 0;
password[0] = full_name[0] = email[0] = 0;
getcfg(lbs->name, "Password file", str);
if (str[0] == DIR_SEPARATOR || str[1] == ':')
@@ -7500,29 +7522,27 @@ FILE *f;
}
fclose(f);
/* if user found, check password */
p = line+strlen(user);
if (*p)
p++;
/* if user found, retrieve other info */
p = strtok(line, ":");
strcpy(str, p);
if (strchr(str, ':'))
*strchr(str, ':') = 0;
strcpy(password, str);
p += strlen(str);
if (*p)
p++;
strcpy(str, p);
if (strchr(str, ':'))
*strchr(str, ':') = 0;
if (strchr(str, '\r'))
*strchr(str, '\r') = 0;
if (strchr(str, '\n'))
*strchr(str, '\n') = 0;
strcpy(full_name, str);
if (p)
{
p = strtok(NULL, ":");
if (p)
{
strcpy(password, p);
p = strtok(NULL, ":");
if (p)
{
strcpy(full_name, p);
p = strtok(NULL, ":");
if (p)
{
strcpy(email, p);
}
}
}
}
return TRUE;
}
@@ -7534,12 +7554,16 @@ FILE *f;
BOOL check_user_password(LOGBOOK *lbs, char *user, char *password, char *redir)
{
char str[256], upwd[256], full_name[256];
char str[256], upwd[256], full_name[256], email[256];
if (get_user_line(lbs, user, upwd, full_name))
if (get_user_line(lbs, user, upwd, full_name, email))
{
if (user[0] && strcmp(password, upwd) == 0)
{
setparam("full_name", full_name);
setparam("user_email", email);
return TRUE;
}
/* show login password page */
show_standard_header("ELOG login", NULL);
@@ -7946,12 +7970,25 @@ LOGBOOK *cur_lb;
/*---- show ELog page --------------------------------------------*/
/* if password file given, check password and user name */
if (getcfg(logbook, "Password file", str))
{
logf("Connection of user \"%s\"",getparam("unm"));
if (!check_user_password(cur_lb, getparam("unm"), getparam("upwd"), path))
return;
/* check if guest access */
if (getcfg(cur_lb->name, "Guest menu commands", str) && *getparam("unm") == 0)
logf("Guest access");
else
{
logf("Connection of user \"%s\"",getparam("unm"));
if (!check_user_password(cur_lb, getparam("unm"), getparam("upwd"), path))
return;
}
}
if (equal_ustring(command, loc("Login")))
{
check_user_password(cur_lb, "", "", path);
return;
}
if (equal_ustring(command, loc("New")) ||
@@ -8089,7 +8126,7 @@ char *p, *pitem;
if (p[strlen(p)-1] == '/')
p[strlen(p)-1] = 0;
p = strtok(p,"&");
p = strtok(p, "&");
while (p != NULL)
{
pitem = p;
@@ -8102,7 +8139,7 @@ char *p, *pitem;
setparam(pitem, p);
p = strtok(NULL,"&");
p = strtok(NULL, "&");
}
}
}