Last x
behaviour without the "Find Menu commands" option.
+
Guest Menu commands = <list>
+
+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 login 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 "Menu commands" list.
+A typical example for the menu settings for this scenario are:
+
+Menu commands = New, Edit, Reply, Find, Last 10, Change password, Logout, Help
+Guest menu commands = Find, Last 10, Login, Help
+
+
+
Bottom text = <file>
If this option is present, the HTML contents of file is displayed at
@@ -500,7 +517,8 @@ text. This text can contain arbitrary fixed text and following values:
$host: The host name where elogd is running
$remote_host: The host name of the host from with the entry was submitted
$short_name: The login name (if password file is present)
- $long_name: The full name (if password file is present)
+ $long_name: The full name from the password file for the current user
+ $user_email: The email address from the password file for the current user
$logbook: The name of the current logbook
$date: The current date, formatted via "Date format"
@@ -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:
-
<login name1>:<password1>:<full name1>
-<login name2>:<password2>:<full name2>
-<login name3>:<password3>:<full name3>
+
<login name1>:<password1>:<full name1>:<email1>
+<login name2>:<password2>:<full name2>:<email1>
+<login name3>:<password3>:<full name3>:<email1>
...
The passwords are encoded. To create or change them, use the "Change
Password" menu point. To create a new user, edit the password file
-manually and use an empty password (like "<login name>::<full name>"), which can then be changed via the "Change password" menu point.
+manually and use an empty password (like "<login name>::<full name>:<email>"), which can then be changed via the "Change password" menu point.
The presence of a password file requires all users to "log in" 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 "Guest menu commands" 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 Author attribute with the user name:
+added to the configuration file to fill in the Author and the Email attributes
+with the current user name and email:
-
Options Author = $long_name from $remote_host
+Attributes = Author, Email, ...
+Options Author = $long_name from $remote_host
+Options Email = $user_email
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 "Subst <attrib>" option.
diff --git a/elogd.c b/elogd.c
index 2cf91bf1..458cdf68 100755
--- a/elogd.c
+++ b/elogd.c
@@ -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
#include
@@ -3249,6 +3252,15 @@ int i, j;
rsprintf(" %s \"%s\"\n",
gt("Title fontcolor"), loc("Logged in as"), getparam("full_name"));
}
+ else
+ {
+ if (getcfg(logbook, "Guest menu commands", str))
+ {
+ rsprintf("", gt("Title BGColor"));
+ rsprintf(" %s \n",
+ gt("Title fontcolor"), loc("Not logged in"));
+ }
+ }
/* right cell */
rsprintf("", 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(" %s\n", gt("Categories bgcolor2"), attrib[index]);
+ rsprintf(" \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, "&");
}
}
}