log.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. // Logging functions by Azndragon & Codemaster
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include "../common/strlib.h"
  8. #include "../common/nullpo.h"
  9. #include "../common/showmsg.h"
  10. #include "itemdb.h"
  11. #include "map.h"
  12. #include "log.h"
  13. #ifndef SQL_DEBUG
  14. #define mysql_query(_x, _y) mysql_real_query(_x, _y, strlen(_y)) //supports ' in names and runs faster [Kevin]
  15. #else
  16. #define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
  17. #endif
  18. struct Log_Config log_config;
  19. char timestring[255];
  20. time_t curtime;
  21. //FILTER OPTIONS
  22. //0 = Don't log
  23. //1 = Log any item
  24. //Bits: ||
  25. //2 - Healing items (0)
  26. //3 - Etc Items(3) + Arrows (10)
  27. //4 - Usable Items(2) + Scrolls,Lures(11)
  28. //5 - Weapon(4)
  29. //6 - Shields,Armor,Headgears,Accessories,etc(5)
  30. //7 - Cards(6)
  31. //8 - Pet Accessories(8) + Eggs(7) (well, monsters don't drop 'em but we'll use the same system for ALL logs)
  32. //9 - Log expensive items ( >= price_log)
  33. //10 - Log big amount of items ( >= amount_log)
  34. //11 - Log refined items (if their refine >= refine_log )
  35. //12 - Log rare items (if their drop chance <= rare_log )
  36. //check if this item should be logged according the settings
  37. int should_log_item(int filter, int nameid, int amount) {
  38. struct item_data *item_data;
  39. if (nameid<501 || (item_data= itemdb_search(nameid)) == NULL) return 0;
  40. if ( (filter&1) || // Filter = 1, we log any item
  41. (filter&2 && item_data->type == 0 ) || //healing items
  42. (filter&4 && (item_data->type == 3 || item_data->type == 10) ) || //etc+arrows
  43. (filter&8 && (item_data->type == 2 || item_data->type == 11) ) || //usable
  44. (filter&16 && item_data->type == 4 ) || //weapon
  45. (filter&32 && item_data->type == 5 ) || //armor
  46. (filter&64 && item_data->type == 6 ) || //cards
  47. (filter&128 && (item_data->type == 7 || item_data->type == 8) ) || //eggs+pet access
  48. (filter&256 && item_data->value_buy >= log_config.price_items_log ) || //expensive items
  49. (filter&512 && amount >= log_config.amount_items_log ) || //big amount of items
  50. (filter&2048 && ((item_data->maxchance <= log_config.rare_items_log) || item_data->nameid == 714) ) //Rare items or Emperium
  51. ) return item_data->nameid;
  52. return 0;
  53. }
  54. int log_branch(struct map_session_data *sd)
  55. {
  56. #ifndef TXT_ONLY
  57. char t_name[NAME_LENGTH*2];
  58. #endif
  59. FILE *logfp;
  60. if(log_config.enable_logs <= 0)
  61. return 0;
  62. nullpo_retr(0, sd);
  63. #ifndef TXT_ONLY
  64. if(log_config.sql_logs > 0)
  65. {
  66. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%s')",
  67. log_config.log_branch_db, sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name), mapindex_id2name(sd->mapindex));
  68. if(mysql_query(&logmysql_handle, tmp_sql))
  69. {
  70. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  71. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  72. }
  73. } else {
  74. #endif
  75. if((logfp=fopen(log_config.log_branch,"a+")) != NULL) {
  76. time(&curtime);
  77. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  78. fprintf(logfp,"%s - %s[%d:%d]\t%s%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex), RETCODE);
  79. fclose(logfp);
  80. }
  81. #ifndef TXT_ONLY
  82. }
  83. #endif
  84. return 0;
  85. }
  86. int log_pick(struct map_session_data *sd, char *type, int mob_id, int nameid, int amount, struct item *itm)
  87. {
  88. FILE *logfp;
  89. char *mapname;
  90. int obj_id;
  91. if(log_config.enable_logs <= 0)
  92. return 0;
  93. nullpo_retr(0, sd);
  94. //Should we log this item? [Lupus]
  95. if (!should_log_item(log_config.pick,nameid, amount))
  96. return 0; //we skip logging this items set - they doesn't met our logging conditions [Lupus]
  97. //either PLAYER or MOB (here we get map name and objects ID)
  98. if(mob_id) {
  99. struct mob_data *md = (struct mob_data*)sd;
  100. obj_id = mob_id;
  101. mapname = map[md->bl.m].name;
  102. } else {
  103. obj_id = sd->char_id;
  104. mapname = (char*)mapindex_id2name(sd->mapindex);
  105. }
  106. if(mapname==NULL)
  107. mapname="";
  108. #ifndef TXT_ONLY
  109. if(log_config.sql_logs > 0)
  110. {
  111. if (itm==NULL) {
  112. //We log common item
  113. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%s')",
  114. log_config.log_pick_db, obj_id, type, nameid, amount, mapname);
  115. } else {
  116. //We log Extended item
  117. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')",
  118. log_config.log_pick_db, obj_id, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname);
  119. }
  120. if(mysql_query(&logmysql_handle, tmp_sql))
  121. {
  122. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  123. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  124. }
  125. } else {
  126. #endif
  127. if((logfp=fopen(log_config.log_pick,"a+")) != NULL) {
  128. time_t curtime;
  129. time(&curtime);
  130. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  131. if (itm==NULL) {
  132. //We log common item
  133. fprintf(logfp,"%s - %d\t%s\t%d,%d,%s%s",
  134. timestring, obj_id, type, nameid, amount, mapname, RETCODE);
  135. } else {
  136. //We log Extended item
  137. fprintf(logfp,"%s - %d\t%s\t%d,%d,%d,%d,%d,%d,%d,%s%s",
  138. timestring, obj_id, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname, RETCODE);
  139. }
  140. fclose(logfp);
  141. }
  142. #ifndef TXT_ONLY
  143. }
  144. #endif
  145. return 1; //Logged
  146. }
  147. int log_zeny(struct map_session_data *sd, char *type, struct map_session_data *src_sd, int amount)
  148. {
  149. // FILE *logfp;
  150. if(log_config.enable_logs <= 0 || (log_config.zeny!=1 && abs(amount)<log_config.zeny))
  151. return 0;
  152. nullpo_retr(0, sd);
  153. #ifndef TXT_ONLY
  154. if(log_config.sql_logs > 0)
  155. {
  156. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%s')",
  157. log_config.log_zeny_db, sd->char_id, src_sd->char_id, type, amount, mapindex_id2name(sd->mapindex));
  158. if(mysql_query(&logmysql_handle, tmp_sql))
  159. {
  160. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  161. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  162. }
  163. } else {
  164. #endif
  165. // if((logfp=fopen(log_config.log_zeny,"a+")) != NULL) {
  166. // time(&curtime);
  167. // strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  168. // fprintf(logfp,"%s - %s[%d]\t%s[%d]\t%d\t%s", timestring, sd->status.name, sd->status.account_id, target_sd->status.name, target_sd->status.account_id, sd->deal.zeny, RETCODE);
  169. // fclose(logfp);
  170. // }
  171. #ifndef TXT_ONLY
  172. }
  173. #endif
  174. return 0;
  175. }
  176. int log_drop(struct map_session_data *sd, int monster_id, int *log_drop)
  177. {
  178. FILE *logfp;
  179. int i,flag = 0;
  180. if(log_config.enable_logs <= 0)
  181. return 0;
  182. nullpo_retr(0, sd);
  183. for (i = 0; i<10; i++) { //Should we log these items? [Lupus]
  184. flag += should_log_item(log_config.drop,log_drop[i],1);
  185. }
  186. if (flag==0) return 0; //we skip logging this items set - they doesn't met our logging conditions [Lupus]
  187. #ifndef TXT_ONLY
  188. if(log_config.sql_logs > 0)
  189. {
  190. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`drop_date`, `kill_char_id`, `monster_id`, `item1`, `item2`, `item3`, `item4`, `item5`, `item6`, `item7`, `item8`, `item9`, `itemCard`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s') ", log_config.log_drop_db, sd->status.char_id, monster_id, log_drop[0], log_drop[1], log_drop[2], log_drop[3], log_drop[4], log_drop[5], log_drop[6], log_drop[7], log_drop[8], log_drop[9], mapindex_id2name(sd->mapindex));
  191. if(mysql_query(&logmysql_handle, tmp_sql))
  192. {
  193. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  194. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  195. }
  196. } else {
  197. #endif
  198. if((logfp=fopen(log_config.log_drop,"a+")) != NULL) {
  199. time_t curtime;
  200. time(&curtime);
  201. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  202. fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_drop[0], log_drop[1], log_drop[2], log_drop[3], log_drop[4], log_drop[5], log_drop[6], log_drop[7], log_drop[8], log_drop[9], RETCODE);
  203. fclose(logfp);
  204. }
  205. #ifndef TXT_ONLY
  206. }
  207. #endif
  208. return 1; //Logged
  209. }
  210. int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp)
  211. {
  212. FILE *logfp;
  213. if(log_config.enable_logs <= 0)
  214. return 0;
  215. nullpo_retr(0, sd);
  216. #ifndef TXT_ONLY
  217. if(log_config.sql_logs > 0)
  218. {
  219. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", log_config.log_mvpdrop_db, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex));
  220. if(mysql_query(&logmysql_handle, tmp_sql))
  221. {
  222. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  223. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  224. }
  225. } else {
  226. #endif
  227. if((logfp=fopen(log_config.log_mvpdrop,"a+")) != NULL) {
  228. time(&curtime);
  229. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  230. fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], RETCODE);
  231. fclose(logfp);
  232. }
  233. #ifndef TXT_ONLY
  234. }
  235. #endif
  236. return 0;
  237. }
  238. int log_present(struct map_session_data *sd, int source_type, int nameid)
  239. {
  240. FILE *logfp;
  241. #ifndef TXT_ONLY
  242. char t_name[NAME_LENGTH*2];
  243. #endif
  244. if(log_config.enable_logs <= 0)
  245. return 0;
  246. nullpo_retr(0, sd);
  247. if(!should_log_item(log_config.present,nameid,1)) return 0; //filter [Lupus]
  248. #ifndef TXT_ONLY
  249. if(log_config.sql_logs > 0)
  250. {
  251. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`present_date`, `src_id`, `account_id`, `char_id`, `char_name`, `nameid`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%s', '%d', '%s') ",
  252. log_config.log_present_db, source_type, sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name), nameid, mapindex_id2name(sd->mapindex));
  253. if(mysql_query(&logmysql_handle, tmp_sql))
  254. {
  255. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  256. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  257. }
  258. } else {
  259. #endif
  260. if((logfp=fopen(log_config.log_present,"a+")) != NULL) {
  261. time(&curtime);
  262. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  263. fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, source_type, nameid, RETCODE);
  264. fclose(logfp);
  265. }
  266. #ifndef TXT_ONLY
  267. }
  268. #endif
  269. return 0;
  270. }
  271. int log_produce(struct map_session_data *sd, int nameid, int slot1, int slot2, int slot3, int success)
  272. {
  273. FILE *logfp;
  274. #ifndef TXT_ONLY
  275. char t_name[NAME_LENGTH*2];
  276. #endif
  277. if(log_config.enable_logs <= 0)
  278. return 0;
  279. nullpo_retr(0, sd);
  280. if(!should_log_item(log_config.produce,nameid,1)) return 0; //filter [Lupus]
  281. #ifndef TXT_ONLY
  282. if(log_config.sql_logs > 0)
  283. {
  284. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`produce_date`, `account_id`, `char_id`, `char_name`, `nameid`, `slot1`, `slot2`, `slot3`, `map`, `success`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%s', '%d') ",
  285. log_config.log_produce_db, sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name), nameid, slot1, slot2, slot3, mapindex_id2name(sd->mapindex), success);
  286. if(mysql_query(&logmysql_handle, tmp_sql))
  287. {
  288. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  289. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  290. }
  291. } else {
  292. #endif
  293. if((logfp=fopen(log_config.log_produce,"a+")) != NULL) {
  294. time(&curtime);
  295. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  296. fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d,%d\t%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, nameid, slot1, slot2, slot3, success, RETCODE);
  297. fclose(logfp);
  298. }
  299. #ifndef TXT_ONLY
  300. }
  301. #endif
  302. return 0;
  303. }
  304. int log_refine(struct map_session_data *sd, int n, int success)
  305. {
  306. FILE *logfp;
  307. int log_card[MAX_SLOTS];
  308. int item_level;
  309. int i;
  310. #ifndef TXT_ONLY
  311. char t_name[NAME_LENGTH*2];
  312. #endif
  313. if(log_config.enable_logs <= 0)
  314. return 0;
  315. nullpo_retr(0, sd);
  316. if(success == 0)
  317. item_level = sd->status.inventory[n].refine; //leaving there 0 wasn't informative! we have SUCCESS field anyways
  318. else
  319. item_level = sd->status.inventory[n].refine + 1;
  320. if(!should_log_item(log_config.refine,sd->status.inventory[n].nameid,1) || log_config.refine_items_log>item_level) return 0; //filter [Lupus]
  321. for(i=0;i<MAX_SLOTS;i++)
  322. log_card[i] = sd->status.inventory[n].card[i];
  323. #ifndef TXT_ONLY
  324. if(log_config.sql_logs > 0)
  325. {
  326. char *str_p = tmp_sql;
  327. str_p += sprintf(str_p, "INSERT DELAYED INTO `%s` (`refine_date`, `account_id`, `char_id`, `char_name`, `nameid`, `refine`"
  328. ", `map`, `success`, `item_level`", log_config.log_refine_db);
  329. for (i=0; i < MAX_SLOTS; i++)
  330. str_p += sprintf(str_p, ", `card%d`", i);
  331. str_p += sprintf(str_p, ") VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d'",
  332. sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name),
  333. sd->status.inventory[n].nameid, sd->status.inventory[n].refine, mapindex_id2name(sd->mapindex), success, item_level);
  334. for(i=0; i<MAX_SLOTS; i++)
  335. str_p += sprintf(str_p, ", '%d'", log_card[i]);
  336. strcat(tmp_sql,")");
  337. if(mysql_query(&logmysql_handle, tmp_sql))
  338. {
  339. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  340. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  341. }
  342. } else {
  343. #endif
  344. if((logfp=fopen(log_config.log_refine,"a+")) != NULL) {
  345. time(&curtime);
  346. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  347. fprintf(logfp,"%s - %s[%d:%d]\t%d,%d\t",
  348. timestring, sd->status.name, sd->status.account_id, sd->status.char_id,
  349. sd->status.inventory[n].nameid, sd->status.inventory[n].refine);
  350. for (i=0; i<MAX_SLOTS; i++)
  351. fprintf(logfp,"%d,",log_card[i]);
  352. fprintf(logfp,"\t%d,%d%s", success, item_level, RETCODE);
  353. fclose(logfp);
  354. }
  355. #ifndef TXT_ONLY
  356. }
  357. #endif
  358. return 0;
  359. }
  360. int log_tostorage(struct map_session_data *sd,int n, int guild)
  361. {
  362. FILE *logfp;
  363. int i;
  364. if(log_config.enable_logs <= 0 || log_config.storage == 0 || log_config.log_storage[0] == '\0')
  365. return 0;
  366. nullpo_retr(0, sd);
  367. if(sd->status.inventory[n].nameid==0 || sd->inventory_data[n] == NULL)
  368. return 1;
  369. if(sd->status.inventory[n].amount < 0)
  370. return 1;
  371. if((logfp=fopen(log_config.log_trade,"a+")) != NULL) {
  372. time(&curtime);
  373. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  374. fprintf(logfp,"%s - to %s: %s[%d:%d]\t%d\t%d\t%d\t",
  375. timestring, guild ? "guild_storage": "storage", sd->status.name, sd->status.account_id, sd->status.char_id,
  376. sd->status.inventory[n].nameid, sd->status.inventory[n].amount, sd->status.inventory[n].refine);
  377. for (i=0; i<MAX_SLOTS; i++)
  378. fprintf(logfp, "%d,", sd->status.inventory[n].card[i]);
  379. fprintf(logfp, "%s", RETCODE);
  380. fclose(logfp);
  381. }
  382. return 0;
  383. }
  384. int log_fromstorage(struct map_session_data *sd,int n, int guild)
  385. {
  386. FILE *logfp;
  387. int i;
  388. if(log_config.enable_logs <= 0 || log_config.storage == 0 || log_config.log_storage[0] == '\0')
  389. return 0;
  390. nullpo_retr(0, sd);
  391. if(sd->status.inventory[n].nameid==0 || sd->inventory_data[n] == NULL)
  392. return 1;
  393. if(sd->status.inventory[n].amount < 0)
  394. return 1;
  395. if((logfp=fopen(log_config.log_trade,"a+")) != NULL) {
  396. time(&curtime);
  397. fprintf(logfp,"%s - from %s: %s[%d:%d]\t%d\t%d\t%d\t",
  398. timestring, guild ? "guild_storage": "storage", sd->status.name, sd->status.account_id, sd->status.char_id,
  399. sd->status.inventory[n].nameid, sd->status.inventory[n].amount, sd->status.inventory[n].refine);
  400. for (i=0; i<MAX_SLOTS; i++)
  401. fprintf(logfp, "%d,", sd->status.inventory[n].card[i]);
  402. fprintf(logfp, "%s", RETCODE);
  403. fclose(logfp);
  404. }
  405. return 0;
  406. }
  407. int log_trade(struct map_session_data *sd, struct map_session_data *target_sd, int n,int amount)
  408. {
  409. FILE *logfp;
  410. int log_nameid, log_amount, log_refine, log_card[MAX_SLOTS];
  411. int i;
  412. #ifndef TXT_ONLY
  413. char t_name[NAME_LENGTH*2],t_name2[NAME_LENGTH*2];
  414. #endif
  415. if(log_config.enable_logs <= 0)
  416. return 0;
  417. nullpo_retr(0, sd);
  418. if(sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL)
  419. return 1;
  420. if(sd->status.inventory[n].amount < 0)
  421. return 1;
  422. if(!should_log_item(log_config.trade,sd->status.inventory[n].nameid,sd->status.inventory[n].amount)) return 0; //filter [Lupus]
  423. log_nameid = sd->status.inventory[n].nameid;
  424. log_amount = sd->status.inventory[n].amount;
  425. log_refine = sd->status.inventory[n].refine;
  426. for(i=0;i<MAX_SLOTS;i++)
  427. log_card[i] = sd->status.inventory[n].card[i];
  428. #ifndef TXT_ONLY
  429. if(log_config.sql_logs > 0)
  430. {
  431. char *str_p = tmp_sql;
  432. str_p += sprintf(str_p, "INSERT DELAYED INTO `%s` (`trade_date`, `src_account_id`, `src_char_id`, `src_char_name`, `des_account_id`, `des_char_id`, `des_char_name`, `nameid`, `amount`, `refine`, `map`",
  433. log_config.log_trade_db);
  434. for (i=0; i < MAX_SLOTS; i++)
  435. str_p += sprintf(str_p, ", `card%d`", i);
  436. str_p += sprintf(str_p, ") VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%s'",
  437. sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name),
  438. target_sd->status.account_id, target_sd->status.char_id, jstrescapecpy(t_name2, target_sd->status.name),
  439. log_nameid, log_amount, log_refine, mapindex_id2name(sd->mapindex));
  440. for(i=0; i<MAX_SLOTS; i++)
  441. str_p += sprintf(str_p, ", '%d'", log_card[i]);
  442. strcat(tmp_sql, ")");
  443. if(mysql_query(&logmysql_handle, tmp_sql))
  444. {
  445. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  446. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  447. }
  448. } else {
  449. #endif
  450. if((logfp=fopen(log_config.log_trade,"a+")) != NULL) {
  451. time(&curtime);
  452. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  453. fprintf(logfp,"%s - %s[%d:%d]\t%s[%d:%d]\t%d\t%d\t%d\t",
  454. timestring, sd->status.name, sd->status.account_id, sd->status.char_id,
  455. target_sd->status.name, target_sd->status.account_id, target_sd->status.char_id,
  456. log_nameid, log_amount, log_refine);
  457. for (i=0; i<MAX_SLOTS; i++)
  458. fprintf(logfp, "%d,", sd->status.inventory[n].card[i]);
  459. fprintf(logfp, "%s", RETCODE);
  460. fclose(logfp);
  461. }
  462. #ifndef TXT_ONLY
  463. }
  464. #endif
  465. return 0;
  466. }
  467. int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int amount, int zeny)
  468. {
  469. FILE *logfp;
  470. int log_nameid, log_amount, log_refine, log_card[MAX_SLOTS];
  471. int i;
  472. #ifndef TXT_ONLY
  473. char t_name[NAME_LENGTH*2],t_name2[NAME_LENGTH*2];
  474. #endif
  475. if(log_config.enable_logs <= 0)
  476. return 0;
  477. nullpo_retr(0, sd);
  478. if(sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL)
  479. return 1;
  480. if(sd->status.inventory[n].amount< 0)
  481. return 1;
  482. if(!should_log_item(log_config.vend,sd->status.inventory[n].nameid,sd->status.inventory[n].amount)) return 0; //filter [Lupus]
  483. log_nameid = sd->status.inventory[n].nameid;
  484. log_amount = sd->status.inventory[n].amount;
  485. log_refine = sd->status.inventory[n].refine;
  486. for(i=0;i<MAX_SLOTS;i++)
  487. log_card[i] = sd->status.inventory[n].card[i];
  488. #ifndef TXT_ONLY
  489. if(log_config.sql_logs > 0)
  490. {
  491. char *str_p = tmp_sql;
  492. str_p += sprintf(str_p, "INSERT DELAYED INTO `%s` (`vend_date`, `vend_account_id`, `vend_char_id`, `vend_char_name`, `buy_account_id`, `buy_char_id`, `buy_char_name`, `nameid`, `amount`, `refine`, `map`, `zeny`",
  493. log_config.log_vend_db);
  494. for (i=0; i < MAX_SLOTS; i++)
  495. str_p += sprintf(str_p, ", `card%d`", i);
  496. str_p += sprintf(str_p, ") VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%s', '%d'",
  497. sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name),
  498. vsd->status.account_id, vsd->status.char_id, jstrescapecpy(t_name2, vsd->status.name),
  499. log_nameid, log_amount, log_refine, mapindex_id2name(sd->mapindex), zeny);
  500. for(i=0; i<MAX_SLOTS; i++)
  501. str_p += sprintf(str_p, ", '%d'", log_card[i]);
  502. strcat(tmp_sql, ")");
  503. if(mysql_query(&logmysql_handle, tmp_sql))
  504. {
  505. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  506. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  507. }
  508. } else {
  509. #endif
  510. if((logfp=fopen(log_config.log_vend,"a+")) != NULL) {
  511. time(&curtime);
  512. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  513. fprintf(logfp,"%s - %s[%d:%d]\t%s[%d:%d]\t%d\t%d\t%d\t",
  514. timestring, sd->status.name, sd->status.account_id, sd->status.char_id,
  515. vsd->status.name, vsd->status.account_id, vsd->status.char_id,
  516. log_nameid, log_amount, log_refine);
  517. for(i=0; i<MAX_SLOTS; i++)
  518. fprintf(logfp, "%d,", sd->status.inventory[n].card[i]);
  519. fprintf(logfp, "\t%d%s", zeny, RETCODE);
  520. fclose(logfp);
  521. }
  522. #ifndef TXT_ONLY
  523. }
  524. #endif
  525. return 0;
  526. }
  527. int log_atcommand(struct map_session_data *sd, const char *message)
  528. {
  529. FILE *logfp;
  530. #ifndef TXT_ONLY
  531. char t_name[NAME_LENGTH*2];
  532. char t_msg[MESSAGE_SIZE*2+1]; //These are the contents of an @ call, so there shouldn't be overflow danger here?
  533. #endif
  534. if(log_config.enable_logs <= 0)
  535. return 0;
  536. nullpo_retr(0, sd);
  537. #ifndef TXT_ONLY
  538. if(log_config.sql_logs > 0)
  539. {
  540. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ",
  541. log_config.log_gm_db, sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name), mapindex_id2name(sd->mapindex), jstrescapecpy(t_msg, (char *)message));
  542. if(mysql_query(&logmysql_handle, tmp_sql))
  543. {
  544. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  545. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  546. }
  547. } else {
  548. #endif
  549. if((logfp=fopen(log_config.log_gm,"a+")) != NULL) {
  550. time(&curtime);
  551. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  552. fprintf(logfp,"%s - %s[%d]: %s%s",timestring,sd->status.name,sd->status.account_id,message,RETCODE);
  553. fclose(logfp);
  554. }
  555. #ifndef TXT_ONLY
  556. }
  557. #endif
  558. return 0;
  559. }
  560. int log_npc(struct map_session_data *sd, const char *message)
  561. { //[Lupus]
  562. FILE *logfp;
  563. #ifndef TXT_ONLY
  564. char t_name[NAME_LENGTH*2];
  565. char t_msg[255+1]; //it's 255 chars MAX.
  566. #endif
  567. if(log_config.enable_logs <= 0)
  568. return 0;
  569. nullpo_retr(0, sd);
  570. #ifndef TXT_ONLY
  571. if(log_config.sql_logs > 0)
  572. {
  573. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ",
  574. log_config.log_npc_db, sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name), mapindex_id2name(sd->mapindex), jstrescapecpy(t_msg, (char *)message));
  575. if(mysql_query(&logmysql_handle, tmp_sql))
  576. {
  577. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  578. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  579. }
  580. } else {
  581. #endif
  582. if((logfp=fopen(log_config.log_npc,"a+")) != NULL) {
  583. time(&curtime);
  584. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  585. fprintf(logfp,"%s - %s[%d]: %s%s",timestring,sd->status.name,sd->status.account_id,message,RETCODE);
  586. fclose(logfp);
  587. }
  588. #ifndef TXT_ONLY
  589. }
  590. #endif
  591. return 0;
  592. }
  593. //ChatLogging
  594. // Log CHAT (currently only: Party, Guild, Whisper)
  595. // LOGGING FILTERS [Lupus]
  596. //=============================================================
  597. //0 = Don't log at all
  598. //1 = Log any chat messages
  599. //Advanced Filter Bits: ||
  600. //2 - Log Whisper messages
  601. //3 - Log Party messages
  602. //4 - Log Guild messages
  603. //5 - Log Common messages (not implemented)
  604. //6 - Don't log when WOE is on
  605. //Example:
  606. //log_chat: 1 = logs ANY messages
  607. //log_chat: 6 = logs both Whisper & Party messages
  608. //log_chat: 8 = logs only Guild messages
  609. //log_chat: 18 = logs only Whisper, when WOE is off
  610. int log_chat(char *type, int type_id, int src_charid, int src_accid, char *map, int x, int y, char *dst_charname, char *message){
  611. #ifndef TXT_ONLY
  612. char t_charname[NAME_LENGTH*2];
  613. char t_msg[MESSAGE_SIZE*2+1]; //Chat line fully escaped, with an extra space just in case.
  614. #else
  615. FILE *logfp;
  616. #endif
  617. //Check ON/OFF
  618. if(log_config.chat <= 0)
  619. return 0; //Deactivated
  620. #ifndef TXT_ONLY
  621. if(log_config.sql_logs > 0){
  622. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%s', '%d', '%d', '%d', '%s', '%d', '%d', '%s', '%s')",
  623. log_config.log_chat_db, type, type_id, src_charid, src_accid, map, x, y, jstrescapecpy(t_charname, (char *)dst_charname), jstrescapecpy(t_msg, (char *)message));
  624. if(mysql_query(&logmysql_handle, tmp_sql)){
  625. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  626. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  627. return -1;
  628. }else{
  629. return 0;
  630. }
  631. }
  632. #endif
  633. #ifdef TXT_ONLY
  634. if((logfp = fopen(log_config.log_chat, "a+")) != NULL){
  635. time(&curtime);
  636. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  637. //DATE - type,type_id,src_charid,src_accountid,src_map,src_x,src_y,dst_charname,message
  638. fprintf(logfp, "%s - %s,%d,%d,%d,%s,%d,%d,%s,%s%s",
  639. timestring, type, type_id, src_charid, src_accid, map, x, y, dst_charname, message, RETCODE);
  640. fclose(logfp);
  641. return 0;
  642. }else{
  643. return -1;
  644. }
  645. #endif
  646. return -1;
  647. }
  648. void log_set_defaults(void)
  649. {
  650. memset(&log_config, 0, sizeof(log_config));
  651. //LOG FILTER Default values
  652. log_config.refine_items_log = 5; //log refined items, with refine >= +7
  653. log_config.rare_items_log = 100; //log rare items. drop chance <= 1%
  654. log_config.price_items_log = 1000; //1000z
  655. log_config.amount_items_log = 100;
  656. }
  657. int log_config_read(char *cfgName)
  658. {
  659. static int count = 0;
  660. char line[1024], w1[1024], w2[1024];
  661. FILE *fp;
  662. if ((count++) == 0)
  663. log_set_defaults();
  664. if((fp = fopen(cfgName, "r")) == NULL)
  665. {
  666. ShowError("Log configuration file not found at: %s\n", cfgName);
  667. return 1;
  668. }
  669. while(fgets(line, sizeof(line) -1, fp))
  670. {
  671. if(line[0] == '/' && line[1] == '/')
  672. continue;
  673. if(sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2)
  674. {
  675. if(strcmpi(w1,"enable_logs") == 0) {
  676. log_config.enable_logs = (atoi(w2));
  677. } else if(strcmpi(w1,"sql_logs") == 0) {
  678. log_config.sql_logs = (atoi(w2));
  679. //start of common filter settings
  680. } else if(strcmpi(w1,"rare_items_log") == 0) {
  681. log_config.rare_items_log = (atoi(w2));
  682. } else if(strcmpi(w1,"refine_items_log") == 0) {
  683. log_config.refine_items_log = (atoi(w2));
  684. } else if(strcmpi(w1,"price_items_log") == 0) {
  685. log_config.price_items_log = (atoi(w2));
  686. } else if(strcmpi(w1,"amount_items_log") == 0) {
  687. log_config.amount_items_log = (atoi(w2));
  688. //end of common filter settings
  689. } else if(strcmpi(w1,"log_branch") == 0) {
  690. log_config.branch = (atoi(w2));
  691. } else if(strcmpi(w1,"log_pick") == 0) {
  692. log_config.pick = (atoi(w2));
  693. } else if(strcmpi(w1,"log_drop") == 0) {
  694. log_config.drop = (atoi(w2));
  695. } else if(strcmpi(w1,"log_steal") == 0) {
  696. log_config.steal = (atoi(w2));
  697. } else if(strcmpi(w1,"log_mvpdrop") == 0) {
  698. log_config.mvpdrop = (atoi(w2));
  699. } else if(strcmpi(w1,"log_present") == 0) {
  700. log_config.present = (atoi(w2));
  701. } else if(strcmpi(w1,"log_produce") == 0) {
  702. log_config.produce = (atoi(w2));
  703. } else if(strcmpi(w1,"log_refine") == 0) {
  704. log_config.refine = (atoi(w2));
  705. } else if(strcmpi(w1,"log_trade") == 0) {
  706. log_config.trade = (atoi(w2));
  707. } else if(strcmpi(w1,"log_storage") == 0) {
  708. log_config.storage = (atoi(w2));
  709. } else if(strcmpi(w1,"log_vend") == 0) {
  710. log_config.vend = (atoi(w2));
  711. } else if(strcmpi(w1,"log_zeny") == 0) {
  712. log_config.zeny = (atoi(w2));
  713. } else if(strcmpi(w1,"log_gm") == 0) {
  714. log_config.gm = (atoi(w2));
  715. } else if(strcmpi(w1,"log_npc") == 0) {
  716. log_config.npc = (atoi(w2));
  717. } else if(strcmpi(w1, "log_chat") == 0) {
  718. log_config.chat = (atoi(w2));
  719. }
  720. #ifndef TXT_ONLY
  721. else if(strcmpi(w1, "log_branch_db") == 0) {
  722. strcpy(log_config.log_branch_db, w2);
  723. if(log_config.branch == 1)
  724. ShowNotice("Logging Dead Branch Usage to table `%s`\n", w2);
  725. } else if(strcmpi(w1, "log_pick_db") == 0) {
  726. strcpy(log_config.log_pick_db, w2);
  727. if(log_config.pick == 1)
  728. ShowNotice("Logging Item Picks to table `%s`\n", w2);
  729. } else if(strcmpi(w1, "log_zeny_db") == 0) {
  730. strcpy(log_config.log_zeny_db, w2);
  731. if(log_config.zeny == 1)
  732. ShowNotice("Logging Zeny to table `%s`\n", w2);
  733. } else if(strcmpi(w1, "log_drop_db") == 0) {
  734. strcpy(log_config.log_drop_db, w2);
  735. if(log_config.drop == 1)
  736. ShowNotice("Logging Item Drops to table `%s`\n", w2);
  737. } else if(strcmpi(w1, "log_mvpdrop_db") == 0) {
  738. strcpy(log_config.log_mvpdrop_db, w2);
  739. if(log_config.mvpdrop == 1)
  740. ShowNotice("Logging MVP Drops to table `%s`\n", w2);
  741. } else if(strcmpi(w1, "log_present_db") == 0) {
  742. strcpy(log_config.log_present_db, w2);
  743. if(log_config.present == 1)
  744. ShowNotice("Logging Present Usage & Results to table `%s`\n", w2);
  745. } else if(strcmpi(w1, "log_produce_db") == 0) {
  746. strcpy(log_config.log_produce_db, w2);
  747. if(log_config.produce == 1)
  748. ShowNotice("Logging Producing to table `%s`\n", w2);
  749. } else if(strcmpi(w1, "log_refine_db") == 0) {
  750. strcpy(log_config.log_refine_db, w2);
  751. if(log_config.refine == 1)
  752. ShowNotice("Logging Refining to table `%s`\n", w2);
  753. } else if(strcmpi(w1, "log_trade_db") == 0) {
  754. strcpy(log_config.log_trade_db, w2);
  755. if(log_config.trade == 1)
  756. ShowNotice("Logging Item Trades to table `%s`\n", w2);
  757. // } else if(strcmpi(w1, "log_storage_db") == 0) {
  758. // strcpy(log_config.log_storage_db, w2);
  759. // if(log_config.storage == 1)
  760. // {
  761. // printf("Logging Item Storages");
  762. // printf(" to table `%s`\n", w2);
  763. // }
  764. } else if(strcmpi(w1, "log_vend_db") == 0) {
  765. strcpy(log_config.log_vend_db, w2);
  766. if(log_config.vend == 1)
  767. ShowNotice("Logging Vending to table `%s`\n", w2);
  768. } else if(strcmpi(w1, "log_gm_db") == 0) {
  769. strcpy(log_config.log_gm_db, w2);
  770. if(log_config.gm > 0)
  771. ShowNotice("Logging GM Level %d Commands to table `%s`\n", log_config.gm, w2);
  772. } else if(strcmpi(w1, "log_npc_db") == 0) {
  773. strcpy(log_config.log_npc_db, w2);
  774. if(log_config.npc > 0)
  775. ShowNotice("Logging NPC 'logmes' to table `%s`\n", w2);
  776. } else if(strcmpi(w1, "log_chat_db") == 0) {
  777. strcpy(log_config.log_chat_db, w2);
  778. if(log_config.chat > 0)
  779. ShowNotice("Logging CHAT to table `%s`\n", w2);
  780. }
  781. #endif
  782. else if(strcmpi(w1, "log_branch_file") == 0) {
  783. strcpy(log_config.log_branch, w2);
  784. if(log_config.branch > 0 && log_config.sql_logs < 1)
  785. ShowNotice("Logging Dead Branch Usage to file `%s`.txt\n", w2);
  786. } else if(strcmpi(w1, "log_drop_file") == 0) {
  787. strcpy(log_config.log_drop, w2);
  788. if(log_config.drop > 0 && log_config.sql_logs < 1)
  789. ShowNotice("Logging Item Drops to file `%s`.txt\n", w2);
  790. } else if(strcmpi(w1, "log_pick_file") == 0) {
  791. strcpy(log_config.log_pick, w2);
  792. if(log_config.pick > 0 && log_config.sql_logs < 1)
  793. ShowNotice("Logging Item Picks to file `%s`.txt\n", w2);
  794. } else if(strcmpi(w1, "log_zeny_file") == 0) {
  795. strcpy(log_config.log_zeny, w2);
  796. if(log_config.zeny > 0 && log_config.sql_logs < 1)
  797. ShowNotice("Logging Zeny to file `%s`.txt\n", w2);
  798. } else if(strcmpi(w1, "log_mvpdrop_file") == 0) {
  799. strcpy(log_config.log_mvpdrop, w2);
  800. if(log_config.mvpdrop > 0 && log_config.sql_logs < 1)
  801. ShowNotice("Logging MVP Drops to file `%s`.txt\n", w2);
  802. } else if(strcmpi(w1, "log_present_file") == 0) {
  803. strcpy(log_config.log_present, w2);
  804. if(log_config.present > 0 && log_config.sql_logs < 1)
  805. ShowNotice("Logging Present Usage & Results to file `%s`.txt\n", w2);
  806. } else if(strcmpi(w1, "log_produce_file") == 0) {
  807. strcpy(log_config.log_produce, w2);
  808. if(log_config.produce > 0 && log_config.sql_logs < 1)
  809. ShowNotice("Logging Producing to file `%s`.txt\n", w2);
  810. } else if(strcmpi(w1, "log_refine_file") == 0) {
  811. strcpy(log_config.log_refine, w2);
  812. if(log_config.refine > 0 && log_config.sql_logs < 1)
  813. ShowNotice("Logging Refining to file `%s`.txt\n", w2);
  814. } else if(strcmpi(w1, "log_trade_file") == 0) {
  815. strcpy(log_config.log_trade, w2);
  816. if(log_config.trade > 0 && log_config.sql_logs < 1)
  817. ShowNotice("Logging Item Trades to file `%s`.txt\n", w2);
  818. } else if(strcmpi(w1, "log_storage_file") == 0) {
  819. strcpy(log_config.log_storage, w2);
  820. if(log_config.storage > 0 && log_config.sql_logs < 1)
  821. ShowNotice("Logging Item Storages to file `%s`.txt\n", w2);
  822. } else if(strcmpi(w1, "log_vend_file") == 0) {
  823. strcpy(log_config.log_vend, w2);
  824. if(log_config.vend > 0 && log_config.sql_logs < 1)
  825. ShowNotice("Logging Vending to file `%s`.txt\n", w2);
  826. } else if(strcmpi(w1, "log_gm_file") == 0) {
  827. strcpy(log_config.log_gm, w2);
  828. if(log_config.gm > 0 && log_config.sql_logs < 1)
  829. ShowNotice("Logging GM Level %d Commands to file `%s`.txt\n", log_config.gm, w2);
  830. } else if(strcmpi(w1, "log_npc_file") == 0) {
  831. strcpy(log_config.log_npc, w2);
  832. if(log_config.npc > 0 && log_config.sql_logs < 1)
  833. ShowNotice("Logging NPC 'logmes' to file `%s`.txt\n", w2);
  834. } else if(strcmpi(w1, "log_chat_file") == 0) {
  835. strcpy(log_config.log_chat, w2);
  836. if(log_config.chat > 0 && log_config.sql_logs < 1)
  837. ShowNotice("Logging CHAT to file `%s`.txt\n", w2);
  838. //support the import command, just like any other config
  839. } else if(strcmpi(w1,"import") == 0) {
  840. log_config_read(w2);
  841. }
  842. }
  843. }
  844. fclose(fp);
  845. return 0;
  846. }