diff --git a/elogd.c b/elogd.c
index 1ee62d43..a98bc95a 100755
--- a/elogd.c
+++ b/elogd.c
@@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG
$Log$
+ Revision 2.56 2002/08/06 08:57:39 midas
+ Added email notify flag to password file
+
Revision 2.55 2002/08/05 15:37:21 midas
First version of self-registration
@@ -495,7 +498,7 @@ LOGBOOK *lb_list = NULL;
void show_error(char *error);
void show_http_header();
BOOL enum_user_line(LOGBOOK *lbs, int n, char *user);
-BOOL get_user_line(LOGBOOK *lbs, char *user, char *password, char *full_name, char *email);
+BOOL get_user_line(LOGBOOK *lbs, char *user, char *password, char *full_name, char *email, char *email_notify);
/*---- Funcions from the MIDAS library -----------------------------*/
@@ -4782,8 +4785,8 @@ int i, size;
(buf[strlen(buf)-1] != '\r' && buf[strlen(buf)-1] != '\n'))
fprintf(f, "\n");
- sprintf(str, "%s:%s:%s:%s", getparam("new_user_name"), new_pwd,
- getparam("new_full_name"), getparam("new_user_email"));
+ sprintf(str, "%s:%s:%s:%s:%s", getparam("new_user_name"), new_pwd,
+ getparam("new_full_name"), getparam("new_user_email"), getparam("email_notify"));
fprintf(f, "%s\n", str);
}
else
@@ -4792,8 +4795,8 @@ int i, size;
fseek(f, 0, SEEK_SET);
fwrite(buf, 1, pl-buf, f);
- sprintf(str, "%s:%s:%s:%s", getparam("new_user_name"), new_pwd,
- getparam("new_full_name"), getparam("new_user_email"));
+ sprintf(str, "%s:%s:%s:%s:%s", getparam("new_user_name"), new_pwd,
+ getparam("new_full_name"), getparam("new_user_email"), getparam("email_notify"));
fprintf(f, "%s\n", str);
pl += strlen(line);
@@ -4819,7 +4822,14 @@ int i, size;
set_login_cookies(lbs, getparam("new_user_name"), new_pwd);
return 0;
}
-
+
+ /* if new user, login as this user */
+ if (new_user && !*getparam("unm"))
+ {
+ set_login_cookies(lbs, getparam("new_user_name"), new_pwd);
+ return 0;
+ }
+
return 1;
}
@@ -4908,7 +4918,7 @@ int i, size;
void show_config_page(LOGBOOK *lbs)
{
-char str[256], user[80], password[80], full_name[80], user_email[80];
+char str[256], user[80], password[80], full_name[80], user_email[80], email_notify[256];
int i;
/*---- header ----*/
@@ -4968,7 +4978,7 @@ int i;
/*---- entry form ----*/
- get_user_line(lbs, user, password, full_name, user_email);
+ get_user_line(lbs, user, password, full_name, user_email, email_notify);
rsprintf("
| %s: | \n", gt("Categories bgcolor1"), loc("Password"));
rsprintf("\n", gt("Categories bgcolor2"));
@@ -6635,12 +6655,103 @@ MSG_LIST *msg_list;
/*------------------------------------------------------------------*/
+int compose_mail(LOGBOOK *lbs, char *mail_to, int message_id, char attrib[MAX_N_ATTR][NAME_LENGTH],
+ char *mail_param, int *n_mail)
+{
+int j;
+char str[256], mail_from[256], mail_text[TEXT_SIZE+1000], smtp_host[256], subject[256];
+char slist[MAX_N_ATTR+10][NAME_LENGTH], svalue[MAX_N_ATTR+10][NAME_LENGTH];
+
+ if (!getcfg("global", "SMTP host", smtp_host))
+ {
+ show_error(loc("No SMTP host defined in [global] section of configuration file"));
+ return 0;
+ }
+
+ if (getcfg(lbs->name, "Use Email from", mail_from))
+ {
+ j = build_subst_list(lbs, slist, svalue, attrib);
+ strsubst(mail_from, slist, svalue, j);
+ }
+ else
+ sprintf(mail_from, "ELog@%s", host_name);
+
+ sprintf(mail_text, loc("A new entry has been submitted on %s"), host_name);
+ sprintf(mail_text+strlen(mail_text), "\r\n\r\n");
+
+ sprintf(mail_text+strlen(mail_text), "%s : %s\r\n", loc("Logbook"), lbs->name);
+
+ for (j=0 ; jn_attr ; j++)
+ {
+ strcpy(str, " ");
+ memcpy(str, attr_list[j], strlen(attr_list[j]));
+ sprintf(str+20, ": %s\r\n", attrib[j]);
+
+ strcpy(mail_text+strlen(mail_text), str);
+ }
+
+ /* compose subject from attributes */
+ if (getcfg(lbs->name, "Use Email Subject", subject))
+ {
+ j = build_subst_list(lbs, slist, svalue, attrib);
+ strsubst(subject, slist, svalue, j);
+ }
+ else
+ strcpy(subject, "New ELOG entry");
+
+ /* try to get URL from referer */
+
+ if (!getcfg("global", "URL", str))
+ {
+ if (referer[0])
+ strcpy(str, referer);
+ else
+ {
+ if (tcp_port == 80)
+ sprintf(str, "http://%s/", host_name);
+ else
+ sprintf(str, "http://%s:%d/", host_name, tcp_port);
+ }
+ }
+ else
+ {
+ strcat(str, lbs->name);
+ strcat(str, "/");
+ }
+
+ sprintf(mail_text+strlen(mail_text), "\r\n%s URL : %s%d\r\n",
+ loc("Logbook"), str, message_id);
+
+ if (getcfg(lbs->name, "Email message body", str) &&
+ atoi(str) == 1)
+ {
+ sprintf(mail_text+strlen(mail_text), "\r\n=================================\r\n\r\n%s",
+ getparam("text"));
+ }
+
+ sendmail(smtp_host, mail_from, mail_to, subject, mail_text);
+
+ if (!getcfg(lbs->name, "Display email recipients", str) ||
+ atoi(str) == 1)
+ {
+ if (mail_param[0] == 0)
+ strcpy(mail_param, "?");
+ else
+ strcat(mail_param, "&");
+ sprintf(mail_param+strlen(mail_param), "mail%d=%s", (*n_mail)++, mail_to);
+ }
+
+ return 1;
+}
+
+/*------------------------------------------------------------------*/
+
void submit_elog(LOGBOOK *lbs)
{
-char str[256], mail_to[256], mail_from[256], file_name[256], error[1000], date[80],
- mail_text[TEXT_SIZE+1000], mail_list[MAX_N_LIST][NAME_LENGTH], list[10000], smtp_host[256],
- subject[256], attrib[MAX_N_ATTR][NAME_LENGTH], subst_str[256], in_reply_to[80],
- reply_to[256];
+char str[256], file_name[256], error[1000], date[80],
+ mail_list[MAX_N_LIST][NAME_LENGTH], list[10000],
+ attrib[MAX_N_ATTR][NAME_LENGTH], subst_str[256], in_reply_to[80],
+ reply_to[256], user[256], user_email[256], email_notify[256];
char *buffer[MAX_ATTACHMENTS], mail_param[1000];
char att_file[MAX_ATTACHMENTS][256];
char slist[MAX_N_ATTR+10][NAME_LENGTH], svalue[MAX_N_ATTR+10][NAME_LENGTH];
@@ -6791,6 +6902,8 @@ int i, j, n, missing, first, index, n_mail, suppress, message_id;
return;
}
+ /*---- email notifications ----*/
+
suppress = atoi(getparam("suppress"));
/* check for mail submissions */
@@ -6803,116 +6916,52 @@ int i, j, n, missing, first, index, n_mail, suppress, message_id;
}
else
{
- for (index=0 ; index <= lbs->n_attr ; index++)
+ if (!(*getparam("edit") && getcfg(lbs->name, "Suppress Email on edit", str) && atoi(str) == 1))
{
- if (index < lbs->n_attr)
+ /* go throuch "Email xxx" in configuration file */
+ for (index=0 ; index <= lbs->n_attr ; index++)
{
- strcpy(str, "Email ");
- if (strchr(attr_list[index], ' '))
- sprintf(str+strlen(str), "\"%s\"", attr_list[index]);
- else
- strcat(str, attr_list[index]);
- strcat(str, " ");
-
- if (strchr(getparam(attr_list[index]), ' '))
- sprintf(str+strlen(str), "\"%s\"", getparam(attr_list[index]));
- else
- strcat(str, getparam(attr_list[index]));
- }
- else
- sprintf(str, "Email ALL");
-
- if (getcfg(lbs->name, str, list))
- {
- n = strbreak(list, mail_list, MAX_N_LIST);
-
- if (verbose)
- printf("\n%s to %s\n\n", str, list);
-
- if (!getcfg("global", "SMTP host", smtp_host))
- if (!getcfg("global", "SMTP host", smtp_host))
- {
- show_error(loc("No SMTP host defined in [global] section of configuration file"));
- return;
- }
-
- for (i=0 ; in_attr)
{
- strcpy(mail_to, mail_list[i]);
-
- if (getcfg(lbs->name, "Use Email from", mail_from))
- {
- j = build_subst_list(lbs, slist, svalue, attrib);
- strsubst(mail_from, slist, svalue, j);
- }
+ strcpy(str, "Email ");
+ if (strchr(attr_list[index], ' '))
+ sprintf(str+strlen(str), "\"%s\"", attr_list[index]);
else
- sprintf(mail_from, "ELog@%s", host_name);
+ strcat(str, attr_list[index]);
+ strcat(str, " ");
- sprintf(mail_text, loc("A new entry has been submitted on %s"), host_name);
- sprintf(mail_text+strlen(mail_text), "\r\n\r\n");
-
- sprintf(mail_text+strlen(mail_text), "%s : %s\r\n", loc("Logbook"), lbs->name);
-
- for (j=0 ; jn_attr ; j++)
- {
- strcpy(str, " ");
- memcpy(str, attr_list[j], strlen(attr_list[j]));
- sprintf(str+20, ": %s\r\n", attrib[j]);
-
- strcpy(mail_text+strlen(mail_text), str);
- }
-
- /* compose subject from attributes */
- if (getcfg(lbs->name, "Use Email Subject", subject))
- {
- j = build_subst_list(lbs, slist, svalue, attrib);
- strsubst(subject, slist, svalue, j);
- }
+ if (strchr(getparam(attr_list[index]), ' '))
+ sprintf(str+strlen(str), "\"%s\"", getparam(attr_list[index]));
else
- strcpy(subject, "New ELOG entry");
-
- /* try to get URL from referer */
-
- if (!getcfg("global", "URL", str))
- {
- if (referer[0])
- strcpy(str, referer);
- else
- {
- if (tcp_port == 80)
- sprintf(str, "http://%s/", host_name);
- else
- sprintf(str, "http://%s:%d/", host_name, tcp_port);
- }
- }
- else
- {
- strcat(str, lbs->name);
- strcat(str, "/");
- }
-
- sprintf(mail_text+strlen(mail_text), "\r\n%s URL : %s%d\r\n",
- loc("Logbook"), str, message_id);
-
- if (getcfg(lbs->name, "Email message body", str) &&
- atoi(str) == 1)
- {
- sprintf(mail_text+strlen(mail_text), "\r\n=================================\r\n\r\n%s",
- getparam("text"));
- }
-
- sendmail(smtp_host, mail_from, mail_to, subject, mail_text);
-
- if (!getcfg(lbs->name, "Display email recipients", str) ||
- atoi(str) == 1)
- {
- if (mail_param[0] == 0)
- strcpy(mail_param, "?");
- else
- strcat(mail_param, "&");
- sprintf(mail_param+strlen(mail_param), "mail%d=%s", n_mail++, mail_to);
- }
+ strcat(str, getparam(attr_list[index]));
}
+ else
+ sprintf(str, "Email ALL");
+
+ if (getcfg(lbs->name, str, list))
+ {
+ n = strbreak(list, mail_list, MAX_N_LIST);
+
+ if (verbose)
+ printf("\n%s to %s\n\n", str, list);
+
+ for (i=0 ; iredir |