diff --git a/src/elogd.c b/src/elogd.c
index f619b73e..9acc8787 100755
--- a/src/elogd.c
+++ b/src/elogd.c
@@ -6,6 +6,9 @@
Contents: Web server program for Electronic Logbook ELOG
$Log$
+ Revision 1.662 2005/05/16 20:02:39 ritt
+ Implemented smiley bar
+
Revision 1.661 2005/05/15 12:43:30 ritt
Implemented url and img tags
@@ -6015,19 +6018,23 @@ typedef struct {
PATTERN_LIST pattern_list[] = {
/* smileys */
- { ":))","
" },
- { ":)", "
" },
- { ":(", "
" },
- { ";)", "
" },
- { ":D", "
" },
- { "?)", "
" },
- { ";(", "
" },
- { ":]", "
" },
- { ":O", "
" },
- { "8)", "
" },
- { "8o", "
" },
- { "X(", "
" },
- { ":P", "
" },
+ { ":))", "
" },
+ { ":-))","
" },
+ { ":)", "
" },
+ { ":-)", "
" },
+ { ":(", "
" },
+ { ":-(" "
" },
+ { ";)", "
" },
+ { ";-)", "
" },
+ { ":D", "
" },
+ { "?)", "
" },
+ { ";(", "
" },
+ { ":]", "
" },
+ { ":O", "
" },
+ { "8)", "
" },
+ { "8o", "
" },
+ { "X(", "
" },
+ { ":P", "
" },
/* formatting */
{ "[b]", "" },
@@ -6043,6 +6050,8 @@ PATTERN_LIST pattern_list[] = {
{ "[/color]", "" },
{ "[size=", "" },
{ "[/size]", "" },
+ { "[font=", "" },
+ { "[/font]", "" },
{ "[code]", "" },
{ "[/code]", "" },
@@ -6064,9 +6073,10 @@ PATTERN_LIST pattern_list[] = {
{ "[/img]", "" },
/* quote */
- { "[quote=", "*" },
- { "[quote]", "*" },
- { "[/quote]", "
" },
+ { "[quote=", "| %s: |
" },
+ { "[quote]", "| %s: |
| " },
+ { "[/quote]\r", " | " },
+ { "[/quote]", " |
" },
{ "", "" }
};
@@ -6192,12 +6202,34 @@ void rsputs_elcode(const char *str)
continue;
for (l = 0; pattern_list[l].pattern[0] ; l++) {
- if (strncmp(str + i, pattern_list[l].pattern, strlen(pattern_list[l].pattern)) == 0) {
+ if (strnicmp(str + i, pattern_list[l].pattern, strlen(pattern_list[l].pattern)) == 0) {
- if (strstr(pattern_list[l].subst, "%#")) {
+ if (stristr(pattern_list[l].pattern, "[quote")) {
+ if (pattern_list[l].pattern[strlen(pattern_list[l].pattern)-1] == '=') {
+ i += strlen(pattern_list[l].pattern);
+ strextract(str+i, ']', attrib, sizeof(attrib));
+ i += strlen(attrib)+1;
+
+ if (attrib[0] == '\"')
+ strcpy(attrib, attrib+1);
+ if (attrib[strlen(attrib)-1] == '\"')
+ attrib[strlen(attrib)-1] = 0;
+
+ sprintf(value, loc("%s wrote"), attrib);
+ sprintf(return_buffer + j, pattern_list[l].subst, value);
+ j += strlen(return_buffer + j);
+ } else {
+ sprintf(return_buffer + j, pattern_list[l].subst, loc("Quote"));
+ j += strlen(return_buffer + j);
+ i += strlen(pattern_list[l].pattern) - 1; // 1 gets added in for loop...
+ }
+ }
+
+ else if (strstr(pattern_list[l].subst, "%#")) {
/* special substitutions */
if (pattern_list[l].pattern[strlen(pattern_list[l].pattern)-1] == '=') {
+
i += strlen(pattern_list[l].pattern);
strextract(str+i, ']', attrib, sizeof(attrib));
i += strlen(attrib)+1;
@@ -6210,15 +6242,22 @@ void rsputs_elcode(const char *str)
strlcpy(subst, pattern_list[l].subst, sizeof(subst));
*strchr(subst, '#') = 's';
sprintf(return_buffer + j, subst, hattrib, value);
+
j += strlen(return_buffer + j);
+
} else if (pattern_list[l].pattern[strlen(pattern_list[l].pattern)-1] != '=') {
i += strlen(pattern_list[l].pattern);
strextract(str+i, '[', attrib, sizeof(attrib));
i += strlen(attrib)-1;
strlcpy(hattrib, attrib, sizeof(hattrib));
+
+ /* change /x to id/x for images */
+ if (strnicmp(attrib, "elog:/", 6) == 0)
+ sprintf(hattrib, "%d%s", _current_message_id, attrib+5);
+
/* add http:// if missing */
- if (strncmp(attrib, "http://", 7) != 0 &&
+ else if (strnicmp(attrib, "http://", 7) != 0 &&
strstr(pattern_list[l].subst, "mailto") == NULL &&
strstr(pattern_list[l].subst, "img") == NULL )
sprintf(hattrib, "http://%s", attrib);
@@ -6250,7 +6289,7 @@ void rsputs_elcode(const char *str)
if (pattern_list[l].pattern[0])
continue;
- if (strncmp(str + i, "
", 4) == 0) {
+ if (strnicmp(str + i, "
", 4) == 0) {
strcpy(return_buffer + j, "
");
j += 6;
i += 3;
@@ -8332,18 +8371,42 @@ void attrib_from_param(int n_attr, char attrib[MAX_N_ATTR][NAME_LENGTH])
/*------------------------------------------------------------------*/
+void ricon(char *name, char *comment, char *elcode)
+{
+ rsprintf("
");
+}
+
+/*------------------------------------------------------------------*/
+
+void rsicon(char *name, char *comment, char *elcode)
+{
+ rsprintf("
");
+}
+
+/*------------------------------------------------------------------*/
+
void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL bupload, BOOL breedit,
- BOOL bduplicate)
+ BOOL bduplicate, BOOL preview)
{
int i, j, n, index, aindex, size, width, height, fh, length, input_size, input_maxlen,
format_flags[MAX_N_ATTR], year, month, day, hour, min, sec, n_attr, n_disp_attr,
- attr_index[MAX_N_ATTR], enc_selected;
+ attr_index[MAX_N_ATTR], enc_selected, show_smileys;
char str[2 * NAME_LENGTH], preset[2 * NAME_LENGTH], *p, *pend, star[80], comment[10000], reply_string[256],
list[MAX_N_ATTR][NAME_LENGTH], file_name[256], *buffer, format[256], date[80],
attrib[MAX_N_ATTR][NAME_LENGTH], *text, orig_tag[80], reply_tag[MAX_REPLY_TO * 10],
att[MAX_ATTACHMENTS][256], encoding[80], slist[MAX_N_ATTR + 10][NAME_LENGTH],
svalue[MAX_N_ATTR + 10][NAME_LENGTH], owner[256], locked_by[256], class_value[80], class_name[80],
- condition[256], ua[NAME_LENGTH], mid[80], title[256], login_name[256];
+ condition[256], ua[NAME_LENGTH], mid[80], title[256], login_name[256], cookie[256];
time_t now, ltime;
char fl[8][NAME_LENGTH];
struct tm *pts;
@@ -8402,6 +8465,36 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
}
}
+ /* Determine encoding */
+ enc_selected = 0; /*Default is ELCode */
+ /* Overwrite from config file */
+ if (getcfg(lbs->name, "Default Encoding", str, sizeof(str)))
+ enc_selected = atoi(str);
+
+ /* detrmine if smiley bar should be displayed */
+ show_smileys = 1;
+ cookie[0] = 0;
+ if (isparam("hsm") && atoi(getparam("hsm")) == 1) /* cookie */
+ show_smileys = 0;
+ if (isparam("smcmd") && strieq(getparam("smcmd"), "hsm")) { /* turn off */
+ show_smileys = 0;
+ strcpy(cookie, "hsm=1");
+ }
+ if (isparam("smcmd") && strieq(getparam("smcmd"), "ssm")) { /* turn on */
+ show_smileys = 1;
+ strcpy(cookie, "hsm=0");
+ }
+
+ /* Overwrite from current entry */
+ if (message_id) {
+ if (encoding[0] == 'E')
+ enc_selected = 0;
+ else if (encoding[0] == 'p')
+ enc_selected = 1;
+ else if (encoding[0] == 'H')
+ enc_selected = 2;
+ }
+
/* check for preset attributes without any condition */
set_condition("");
for (index = 0; index < lbs->n_attr; index++) {
@@ -8662,7 +8755,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
}
/* header */
- show_html_header(lbs, FALSE, "ELOG", FALSE, FALSE, NULL);
+ show_html_header(lbs, FALSE, "ELOG", FALSE, FALSE, cookie);
/* java script for checking required attributes and to check for cancelled edits */
rsprintf("\n\n");
@@ -8872,6 +9011,7 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
}
rsprintf("\n");
+ rsprintf("\n");
/*---- title row ----*/
@@ -8886,6 +9026,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsprintf
("\n", loc("Submit"));
+ rsprintf
+ ("\n", loc("Preview"));
rsprintf
("\n", loc("Back"));
rsprintf("\n\n");
@@ -9332,8 +9474,134 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
}
}
+ if (preview) {
+ _current_message_id = message_id;
+ rsprintf("\n");
+
+ if (strieq(encoding, "plain")) {
+ rsputs("");
+ rsputs2(text);
+ rsputs("");
+ } else if (strieq(encoding, "ELCode"))
+ rsputs_elcode(text);
+ else
+ rsputs(text);
+
+ rsprintf(" |
\n");
+ }
+
+ if (enc_selected == 0) {
+ rsprintf("
\n");
+ }
+
+ /* main box for text box and icons */
+ rsprintf("\n");
+ if (enc_selected == 0)
+ rsprintf("| \n");
+ }
+
/* set textarea width */
- width = 76;
+ width = 112;
if (getcfg(lbs->name, "Message width", str, sizeof(str)))
width = atoi(str);
@@ -9368,8 +9636,6 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
if (getcfg(lbs->name, "Message height", str, sizeof(str)))
height = atoi(str);
- rsprintf(" | \n");
-
if (breply)
/* hidden text for original message */
rsprintf("\n", message_id);
@@ -9463,36 +9729,42 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
if (!getcfg(lbs->name, "Reply string", reply_string, sizeof(reply_string)))
strcpy(reply_string, "> ");
- do {
- if (strchr(p, '\n')) {
- *strchr(p, '\n') = 0;
+ if (enc_selected == 0) {
+ rsprintf("[quote]");
+ rsputs(text);
+ rsprintf("[/quote]\r\n");
+ } else {
+ do {
+ if (strchr(p, '\n')) {
+ *strchr(p, '\n') = 0;
- if (encoding[0] == 'H') {
- rsputs3(reply_string);
- rsprintf("%s \n", p);
+ if (encoding[0] == 'H') {
+ (reply_string);
+ rsprintf("%s \n", p);
+ } else {
+ rsputs(reply_string);
+ rsputs3(p);
+ rsprintf("\n");
+ }
+
+ p += strlen(p) + 1;
+ if (*p == '\n')
+ p++;
} else {
- rsputs(reply_string);
- rsputs3(p);
- rsprintf("\n");
+ if (encoding[0] == 'H') {
+ rsputs3(reply_string);
+ rsprintf("%s\n", p);
+ } else {
+ rsputs(reply_string);
+ rsputs3(p);
+ rsprintf("\n\n");
+ }
+
+ break;
}
- p += strlen(p) + 1;
- if (*p == '\n')
- p++;
- } else {
- if (encoding[0] == 'H') {
- rsputs3(reply_string);
- rsprintf("%s \n", p);
- } else {
- rsputs(reply_string);
- rsputs3(p);
- rsprintf("\n\n");
- }
-
- break;
- }
-
- } while (TRUE);
+ } while (TRUE);
+ }
}
if (getcfg(lbs->name, "Append on reply", str, sizeof(str))) {
@@ -9545,40 +9817,24 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
/* Encoding radio buttons */
- /* Default is ELCode */
- enc_selected = 0;
- /* Overwrite from config file */
- if (getcfg(lbs->name, "Default Encoding", str, sizeof(str)))
- enc_selected = atoi(str);
-
- /* Overwrite from current entry */
- if (message_id) {
- if (encoding[0] == 'E')
- enc_selected = 0;
- else if (encoding[0] == 'p')
- enc_selected = 1;
- else if (encoding[0] == 'H')
- enc_selected = 2;
- }
-
rsprintf("%s: ", loc("Encoding"));
if (enc_selected == 0)
rsprintf("");
else
- rsprintf("");
+ rsprintf("");
rsprintf("\n");
if (enc_selected == 1)
rsprintf("");
else
- rsprintf("");
+ rsprintf("");
rsprintf("\n");
if (enc_selected == 2)
rsprintf("");
else
- rsprintf("");
+ rsprintf("");
rsprintf("\n");
rsprintf(" \n");
@@ -9652,6 +9908,9 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsprintf(" | \n");
+ if (enc_selected == 0)
+ rsprintf("
|
\n");
+
if (!getcfg(lbs->name, "Enable attachments", str, sizeof(str))
|| atoi(str) > 0) {
i = 0;
@@ -9702,6 +9961,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
rsprintf("
\n\n");
@@ -15083,7 +15344,7 @@ BOOL is_command_allowed(LOGBOOK * lbs, char *command)
strlcat(menu_str, "Config, ", sizeof(menu_str));
}
- strcpy(other_str, "Update, Upload, Submit, Back, Search, Save, Download, CSV Import, ");
+ strcpy(other_str, "Update, Upload, Submit, Preview, Back, Search, Save, Download, CSV Import, ");
strcat(other_str, "Cancel, First, Last, Previous, Next, Requested, Forgot, ");
/* admin commands */
@@ -19261,7 +19522,7 @@ void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command)
}
if (show_text) {
- rsprintf("| \n");
+ rsprintf(" |
");
if (strieq(encoding, "plain")) {
rsputs("");
@@ -19274,13 +19535,20 @@ void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command)
rsputs(" |
\n");
+ n_hidden = 0;
for (i = 0, n_attachments = 0; i < MAX_ATTACHMENTS; i++) {
att_hide[i] = 0;
+
+ sprintf(str, "[img]elog:/%d[/img]", i+1);
+ if (strieq(encoding, "ELCode") &&
+ strstr(text, str)) {
+ att_hide[i] = 1;
+ n_hidden++;
+ }
if (attachment[i][0])
n_attachments++;
}
- n_hidden = 0;
if (isparam("hide")) {
strlcpy(str, getparam("hide"), sizeof(str));
p = strtok(str, ",");
@@ -19292,6 +19560,16 @@ void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command)
p = strtok(NULL, ",");
}
}
+ if (isparam("show")) {
+ strlcpy(str, getparam("show"), sizeof(str));
+ p = strtok(str, ",");
+ while (p != NULL) {
+ if (atoi(p) < MAX_ATTACHMENTS) {
+ att_hide[atoi(p)] = 0;
+ }
+ p = strtok(NULL, ",");
+ }
+ }
for (index = 0; index < MAX_ATTACHMENTS; index++) {
if (attachment[index][0] && strlen(attachment[index]) > 14) {
@@ -19358,6 +19636,7 @@ void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command)
if (att_hide[i] && i != index) {
rsprintf("%d,", i);
}
+ rsprintf("&show=%d", index);
rsprintf("\">%s", loc("Show"));
} else {
rsprintf("%s", message_id, loc("Show all"));
+ if (i < MAX_ATTACHMENTS) {
+ rsprintf(" | %s", loc("Show all"));
+ }
}
rsprintf("\n");
@@ -20928,7 +21212,7 @@ void interprete(char *lbook, char *path)
if (strieq(command, loc("New")) || strieq(command, loc("Edit")) || strieq(command, loc("Reply")) ||
strieq(command, loc("Duplicate")) || strieq(command, loc("Delete")) || strieq(command, loc("Upload"))
- || strieq(command, loc("Submit"))) {
+ || strieq(command, loc("Submit")) || strieq(command, loc("Preview"))) {
sprintf(str, "%s?cmd=%s", path, command);
if (!check_password(lbs, "Write password", getparam("wpwd"), str))
return;
@@ -21171,7 +21455,7 @@ void interprete(char *lbook, char *path)
}
if (strieq(command, loc("New"))) {
- show_edit_form(lbs, 0, FALSE, FALSE, FALSE, FALSE, FALSE);
+ show_edit_form(lbs, 0, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
return;
}
@@ -21196,41 +21480,46 @@ void interprete(char *lbook, char *path)
unsetparam(str);
}
- show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, TRUE, FALSE, FALSE);
+ show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, TRUE, FALSE, FALSE, FALSE);
return;
}
}
message_id = atoi(dec_path);
if (strieq(command, loc("Upload"))) {
- show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, TRUE, FALSE, FALSE);
+ show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, TRUE, FALSE, FALSE, FALSE);
return;
}
if (strieq(command, loc("Edit"))) {
if (message_id) {
- show_edit_form(lbs, message_id, FALSE, TRUE, FALSE, FALSE, FALSE);
+ show_edit_form(lbs, message_id, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE);
return;
}
}
if (strieq(command, loc("Reply"))) {
- show_edit_form(lbs, message_id, TRUE, FALSE, FALSE, FALSE, FALSE);
+ show_edit_form(lbs, message_id, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE);
return;
}
if (strieq(command, loc("Update"))) {
- show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, FALSE, TRUE, FALSE);
+ show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, FALSE, TRUE, FALSE, FALSE);
return;
}
if (strieq(command, loc("Duplicate"))) {
if (message_id) {
- show_edit_form(lbs, message_id, FALSE, FALSE, FALSE, FALSE, TRUE);
+ show_edit_form(lbs, message_id, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE);
return;
}
}
+ if (strieq(command, loc("Preview"))) {
+ show_edit_form(lbs, atoi(getparam("edit_id")), FALSE, TRUE, FALSE, TRUE, FALSE, TRUE);
+ return;
+ }
+
if (strieq(command, loc("Submit"))
|| strieq(command, "Submit")) {