-
-/* write_confitem()
- *
- * inputs - kline, dline or resv type flag
- * - client pointer to report to
- * - user name of target
- * - host name of target
- * - reason for target
- * - time string
- * - type of xline
- * output - NONE
- * side effects - This function takes care of finding the right conf
- * file and adding the line to it, as well as notifying
- * opers and the user.
- */
-void
-write_confitem(KlineType type, struct Client *source_p, char *user,
- char *host, const char *reason, const char *oper_reason,
- const char *current_date, int xtype)
-{
- char buffer[1024];
- FILE *out;
- const char *filename; /* filename to use for kline */
-
- filename = get_conf_name(type);
-
- if(type == KLINE_TYPE)
- {
- if(EmptyString(oper_reason))
- {
- sendto_realops_snomask(SNO_GENERAL, L_ALL,
- "%s added K-Line for [%s@%s] [%s]",
- get_oper_name(source_p), user,
- host, reason);
- ilog(L_KLINE, "K %s 0 %s %s %s",
- get_oper_name(source_p), user, host, reason);
- }
- else
- {
- sendto_realops_snomask(SNO_GENERAL, L_ALL,
- "%s added K-Line for [%s@%s] [%s|%s]",
- get_oper_name(source_p), user,
- host, reason, oper_reason);
- ilog(L_KLINE, "K %s 0 %s %s %s|%s",
- get_oper_name(source_p), user, host,
- reason, oper_reason);
- }
-
- sendto_one_notice(source_p, ":Added K-Line [%s@%s]",
- user, host);
- }
- else if(type == DLINE_TYPE)
- {
- if(EmptyString(oper_reason))
- {
- sendto_realops_snomask(SNO_GENERAL, L_ALL,
- "%s added D-Line for [%s] [%s]",
- get_oper_name(source_p), host, reason);
- ilog(L_KLINE, "D %s 0 %s %s",
- get_oper_name(source_p), host, reason);
- }
- else
- {
- sendto_realops_snomask(SNO_GENERAL, L_ALL,
- "%s added D-Line for [%s] [%s|%s]",
- get_oper_name(source_p), host,
- reason, oper_reason);
- ilog(L_KLINE, "D %s 0 %s %s|%s",
- get_oper_name(source_p), host,
- reason, oper_reason);
- }
-
- sendto_one_notice(source_p, ":Added D-Line [%s] to %s", host, filename);
-
- }
- else if(type == RESV_TYPE)
- {
- sendto_realops_snomask(SNO_GENERAL, L_ALL,
- "%s added RESV for [%s] [%s]",
- get_oper_name(source_p), host, reason);
- ilog(L_KLINE, "R %s 0 %s %s",
- get_oper_name(source_p), host, reason);
-
- sendto_one_notice(source_p, ":Added RESV for [%s] [%s]",
- host, reason);
- }
-
- if((out = fopen(filename, "a")) == NULL)
- {
- sendto_realops_snomask(SNO_GENERAL, L_ALL, "*** Problem opening %s ", filename);
- sendto_one_notice(source_p, ":*** Problem opening file, added temporarily only");
- return;
- }
-
- if(oper_reason == NULL)
- oper_reason = "";
-
- if(type == KLINE_TYPE)
- {
- ircsnprintf(buffer, sizeof(buffer),
- "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n",
- user, host, reason, oper_reason, current_date,
- get_oper_name(source_p), CurrentTime);
- }
- else if(type == DLINE_TYPE)
- {
- ircsnprintf(buffer, sizeof(buffer),
- "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%ld\n", host,
- reason, oper_reason, current_date, get_oper_name(source_p), CurrentTime);
- }
- else if(type == RESV_TYPE)
- {
- ircsnprintf(buffer, sizeof(buffer), "\"%s\",\"%s\",\"%s\",%ld\n",
- host, reason, get_oper_name(source_p), CurrentTime);
- }
-
- if(fputs(buffer, out) == -1)
- {
- sendto_realops_snomask(SNO_GENERAL, L_ALL, "*** Problem writing to %s", filename);
- sendto_one_notice(source_p, ":*** Problem writing to file, added temporarily only");
- fclose(out);
- return;
- }
-
- if (fclose(out))
- {
- sendto_realops_snomask(SNO_GENERAL, L_ALL, "*** Problem writing to %s", filename);
- sendto_one_notice(source_p, ":*** Problem writing to file, added temporarily only");
- return;
- }