diff --git a/src/elogd.c b/src/elogd.c index 8208b079..4897dd33 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -4529,7 +4529,7 @@ int el_retrieve(LOGBOOK * lbs, int message_id, char *date, char attr_list[MAX_N_ int el_submit_attachment(LOGBOOK * lbs, const char *afilename, const char *buffer, int buffer_size, char *full_name) { - char file_name[MAX_PATH_LENGTH], ext_file_name[MAX_PATH_LENGTH + 100], str[MAX_PATH_LENGTH], *p; + char file_name[MAX_PATH_LENGTH], ext_file_name[MAX_PATH_LENGTH + 100], str[MAX_PATH_LENGTH], *p, subdir[MAX_PATH_LENGTH]; int fh; time_t now; struct tm tms; @@ -4562,6 +4562,8 @@ int el_submit_attachment(LOGBOOK * lbs, const char *afilename, const char *buffe strlcpy(full_name, ext_file_name, MAX_PATH_LENGTH); strlcpy(str, lbs->data_dir, sizeof(str)); + generate_subdir_name(ext_file_name, subdir, sizeof(subdir)); + strlcat(str, subdir, sizeof(str)); strlcat(str, ext_file_name, sizeof(str)); /* save attachment */ @@ -4585,15 +4587,18 @@ int el_submit_attachment(LOGBOOK * lbs, const char *afilename, const char *buffe void el_delete_attachment(LOGBOOK * lbs, char *file_name) { int i; - char str[MAX_PATH_LENGTH]; + char str[MAX_PATH_LENGTH], subdir[MAX_PATH_LENGTH]; strlcpy(str, lbs->data_dir, sizeof(str)); + generate_subdir_name(file_name, subdir, sizeof(subdir)); + strlcat(str, subdir, sizeof(str)); strlcat(str, file_name, sizeof(str)); remove(str); strlcat(str, ".png", sizeof(str)); remove(str); for (i = 0;; i++) { strlcpy(str, lbs->data_dir, sizeof(str)); + strlcat(str, subdir, sizeof(str)); strlcat(str, file_name, sizeof(str)); sprintf(str + strlen(str), "-%d.png", i); if (file_exist(str)) { @@ -4602,6 +4607,7 @@ void el_delete_attachment(LOGBOOK * lbs, char *file_name) } strlcpy(str, lbs->data_dir, sizeof(str)); + strlcat(str, subdir, sizeof(str)); strlcat(str, file_name, sizeof(str)); if (strrchr(str, '.')) *strrchr(str, '.') = 0; @@ -4725,7 +4731,7 @@ int el_submit(LOGBOOK * lbs, int message_id, BOOL bedit, char *date, char attr_n \********************************************************************/ { - int n, i, j, size, fh, index, tail_size, orig_size, delta, reply_id; + int n, i, j, size, fh, index, tail_size, orig_size, delta, reply_id, status; char file_name[256], dir[256], str[NAME_LENGTH], date1[256], attrib[MAX_N_ATTR][NAME_LENGTH], reply_to1[MAX_REPLY_TO * 10], in_reply_to1[MAX_REPLY_TO * 10], encoding1[80], *message, *p, *old_text, *buffer; @@ -4860,7 +4866,16 @@ int el_submit(LOGBOOK * lbs, int message_id, BOOL bedit, char *date, char attr_n sprintf(file_name, "%c%c%02d%c%ca.log", date1[14], date1[15], i + 1, date1[5], date1[6]); generate_subdir_name(file_name, subdir, sizeof(subdir)); - + sprintf(str, "%s%s", dir, subdir); + if (strlen(str) > 0 && str[strlen(str)-1] == DIR_SEPARATOR) + str[strlen(str)-1] = 0; + +#ifdef OS_WINNT + status = mkdir(str); +#else + status = mkdir(str, 0755); +#endif + sprintf(str, "%s%s%s", dir, subdir, file_name); fh = open(str, O_CREAT | O_RDWR | O_BINARY, 0644); if (fh < 0) { @@ -5091,7 +5106,7 @@ int el_delete_message(LOGBOOK * lbs, int message_id, BOOL delete_attachments, if (index == *lbs->n_el_index) return -1; - sprintf(file_name, "%s%s", lbs->data_dir, lbs->el_index[index].file_name); + sprintf(file_name, "%s%s%s", lbs->data_dir, lbs->el_index[index].subdir, lbs->el_index[index].file_name); fh = open(file_name, O_RDWR | O_BINARY, 0644); if (fh < 0) return EL_FILE_ERROR; @@ -9326,7 +9341,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL svalue[MAX_N_ATTR + 10][NAME_LENGTH], owner[256], locked_by[256], class_value[80], class_name[80], ua[NAME_LENGTH], mid[80], title[256], login_name[256], full_name[256], cookie[256], orig_author[256], attr_moptions[MAX_N_LIST][NAME_LENGTH], ref[256], file_enc[256], tooltip[10000], - enc_attr[NAME_LENGTH], user_email[256], cmd[256], thumb_name[256], **user_list, fid[20], upwd[80]; + enc_attr[NAME_LENGTH], user_email[256], cmd[256], thumb_name[256], **user_list, fid[20], upwd[80], + subdir[256]; time_t now, ltime; char fl[8][NAME_LENGTH]; struct tm *pts; @@ -11515,6 +11531,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL } else { strlcpy(file_name, lbs->data_dir, sizeof(file_name)); + generate_subdir_name(att[index], subdir, sizeof(subdir)); + strlcat(file_name, subdir, sizeof(file_name)); strlcat(file_name, att[index], sizeof(file_name)); display_inline = is_image(file_name) || is_ascii(file_name); @@ -13358,7 +13376,7 @@ int ascii_compare2(const void *s1, const void *s2) void show_config_page(LOGBOOK * lbs) { - char str[256], user[80], password[80], full_name[80], user_email[80], logbook[256], auth[32], **user_list; + char str[256], user[80], password[80], full_name[256], user_email[256], logbook[256], auth[32], **user_list; int i, n, inactive; BOOL email_notify[1000]; @@ -13447,10 +13465,11 @@ void show_config_page(LOGBOOK * lbs) qsort(user_list, n, sizeof(char *), ascii_compare); for (i = 0; i < n; i++) { + get_user_line(lbs, user_list[i], NULL, full_name, user_email, NULL, NULL, NULL); if (strcmp(user_list[i], user) == 0) - rsprintf("