git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@508 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
amber 2004-12-08 06:02:53 +00:00
parent db56870d32
commit 717714e5b8
22 changed files with 4888 additions and 4888 deletions

View File

@ -1,18 +1,18 @@
// Athena charcommand Configuration file. // Athena charcommand Configuration file.
// Translated by Peter Kieser <pfak@telus.net> // Translated by Peter Kieser <pfak@telus.net>
// Set here the symbol that you want to use for your commands // Set here the symbol that you want to use for your commands
// Only 1 character is get (default is '#'). You can set any character, // Only 1 character is get (default is '#'). You can set any character,
// except control-character (0x00-0x1f), '%' (party chat speaking) and '/' (standard ragnarok GM commands) // except control-character (0x00-0x1f), '%' (party chat speaking) and '/' (standard ragnarok GM commands)
// and '@' (Standard GM Commands) // and '@' (Standard GM Commands)
// With default character, all commands begin by a '#', example: #save SomePlayer // With default character, all commands begin by a '#', example: #save SomePlayer
command_symbol: # command_symbol: #
job: 60 job: 60
jobchange: 60 jobchange: 60
petrename: 50 petrename: 50
petfriendly: 50 petfriendly: 50
stats: 40 stats: 40
option: 60 option: 60
save: 60 save: 60
statsall: 40 statsall: 40

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,17 @@
//<Skill ID> <Mode> //<Skill ID> <Mode>
// //
// Mode: // Mode:
// 1 - Cannot be used in normal maps // 1 - Cannot be used in normal maps
// 2 - Cannot be used in PvP maps // 2 - Cannot be used in PvP maps
// 4 - Cannot be used in GvG maps // 4 - Cannot be used in GvG maps
// 8 - Cannot be used when WoE is on // 8 - Cannot be used when WoE is on
// 16 - Cannot be used in PK Mode maps // 16 - Cannot be used in PK Mode maps
// Example: 8,6 = Endure cannot be used in PvP and GvG maps (2+4) // Example: 8,6 = Endure cannot be used in PvP and GvG maps (2+4)
8,12 8,12
26,12 26,12
27,12 27,12
87,12 87,12
150,12 150,12
361,12 361,12
362,12 362,12
389,12 389,12

View File

@ -1,360 +1,360 @@
Effect list - #'s I found while testing, lots of possible advanced class effects we missed Effect list - #'s I found while testing, lots of possible advanced class effects we missed
(mixed old effect list of valaris and spira's new list...) (mixed old effect list of valaris and spira's new list...)
0-5. Attack Display 0-5. Attack Display
6. Being Warped 6. Being Warped
7. Being Healed 7. Being Healed
8. Yellow Ripple Effect 8. Yellow Ripple Effect
9. Different Type of Heal? 9. Different Type of Heal?
10. Mammomite 10. Mammomite
11. Endure 11. Endure
12. Yellow cast aura 12. Yellow cast aura
13. Blue Box 13. Blue Box
14. Blue heal? Blue pot? 14. Blue heal? Blue pot?
15. Soul Strike 15. Soul Strike
16. Hide animation 16. Hide animation
17. Magnum Break 17. Magnum Break
18. Steal 18. Steal
19. Invalid 19. Invalid
20. Envenom/Poison 20. Envenom/Poison
21. Slow Poison? (Envenom In Blue) 21. Slow Poison? (Envenom In Blue)
22. Sight 22. Sight
23. Stone Curse 23. Stone Curse
24. FireBall 24. FireBall
25. FireWall 25. FireWall
26. Nothing? 26. Nothing?
27. Frost Driver Cast 27. Frost Driver Cast
28. Frost Driver Hitting 28. Frost Driver Hitting
29. Lightning Bolt 29. Lightning Bolt
30. ThunderStorm 30. ThunderStorm
31. Bubbles Appearing From The Character? 31. Bubbles Appearing From The Character?
32. Explosion 32. Explosion
33. Ruwach 33. Ruwach
34. Warp out aura (blue) 34. Warp out aura (blue)
35. Casting Warp portal (blue) 35. Casting Warp portal (blue)
36. Warp portal (blue) 36. Warp portal (blue)
37. Agi up 37. Agi up
38. Agi down 38. Agi down
39. Something being made 39. Something being made
40. Cross thing (paladin skill?) 40. Cross thing (paladin skill?)
41. Angelus bell 41. Angelus bell
42. Blessing angels 42. Blessing angels
43. Dex + Agi up 43. Dex + Agi up
44. Little fog smoke. 44. Little fog smoke.
45. Faint little ball things. 45. Faint little ball things.
46. Sand? 46. Sand?
47. Torch 47. Torch
48. Circle of blue flat things 48. Circle of blue flat things
49. Firebolt/wall hits 49. Firebolt/wall hits
50. Spinning fire thing 50. Spinning fire thing
51. Icebolt hit 51. Icebolt hit
52. JT Hit 52. JT Hit
53. Puff of purpulish smoke? 53. Puff of purpulish smoke?
54-59. Cast animations 54-59. Cast animations
60. Cast target circle 60. Cast target circle
61. Warp portal (for maps) 61. Warp portal (for maps)
62. Sight rasher 62. Sight rasher
63. Fire sphere from some skill 63. Fire sphere from some skill
64. Weird purple/red light 64. Weird purple/red light
65. some sort of mob hit??? 65. some sort of mob hit???
66. potion effect? 66. potion effect?
67. Provoke 67. Provoke
68. MVP 68. MVP
69. Skid trap sign 69. Skid trap sign
70. Blue purple aura thing 70. Blue purple aura thing
71. Spiral Yellow balls 71. Spiral Yellow balls
72. Bigger Spiral Yellow balls 72. Bigger Spiral Yellow balls
73. Blue/yellow ripple 73. Blue/yellow ripple
74. Icewall sicle 74. Icewall sicle
75. Acolyte skill (3 singing girls) 75. Acolyte skill (3 singing girls)
76. Big angel that spreads wings (some aco skill) 76. Big angel that spreads wings (some aco skill)
77. Resurrection angel 77. Resurrection angel
78. Status recovery 78. Status recovery
79. Heaven drive spike? Earth spike? 79. Heaven drive spike? Earth spike?
80. Spear boomerange 80. Spear boomerange
81. Skill hit 81. Skill hit
82. Detect hidden 82. Detect hidden
83. Another aco skill i don't know (angel comes out of green light) 83. Another aco skill i don't know (angel comes out of green light)
84. Yet another stupid angel. 84. Yet another stupid angel.
85. Lex Divinia 85. Lex Divinia
86. Holy water? 86. Holy water?
87. Lex aeterna 87. Lex aeterna
88. Another damn priest/aco skill 88. Another damn priest/aco skill
89. SG 89. SG
90. LoV 90. LoV
91. Aco priest skill 91. Aco priest skill
92. Meteor Storm 92. Meteor Storm
93. JT ball 93. JT ball
94. JT hit 94. JT hit
95. Quagmire 95. Quagmire
96. Some sort of cool looking fire hit? 96. Some sort of cool looking fire hit?
97. Firepillar hit 97. Firepillar hit
98. 98.
99. Big blue light 99. Big blue light
100. Yellow ball fountain 100. Yellow ball fountain
101. Forge? 101. Forge?
102. Hammerfall 102. Hammerfall
103. Powerthrust? 103. Powerthrust?
104. Weapon perfection? 104. Weapon perfection?
105. Nothing? 105. Nothing?
106. Fire explosion. 106. Fire explosion.
107. Fire explosion (from trap?) 107. Fire explosion (from trap?)
108. blue smoke with noise 108. blue smoke with noise
109. blue bubbles 109. blue bubbles
110. yellow smoke (trap?) 110. yellow smoke (trap?)
111. some bs skill or something 111. some bs skill or something
117. Waterball 117. Waterball
120. Sound effect 120. Sound effect
132. Single Grimtooth 132. Single Grimtooth
138. Fire pillar 138. Fire pillar
139. Fireworks 139. Fireworks
154. refine success 154. refine success
155. refine fail 155. refine fail
156. Jobchange.str (crashes client) 156. Jobchange.str (crashes client)
157. Levelup.str (crashes client) 157. Levelup.str (crashes client)
158. joblvup 158. joblvup
159. Pvp circle 159. Pvp circle
160. Woe circle? 160. Woe circle?
161. Rain 161. Rain
162. Snow 162. Snow
163. Sakura leaves 163. Sakura leaves
164. nothing (npc/mob?) 164. nothing (npc/mob?)
165. Weird ball thing 165. Weird ball thing
166. turns sprite blue 166. turns sprite blue
167. Taming Success (crashes client) 167. Taming Success (crashes client)
168. Taming failed (crashes client) 168. Taming failed (crashes client)
169. blue light 169. blue light
170. explosion 170. explosion
171. venom dust 171. venom dust
172. black aura 172. black aura
173. red aura 173. red aura
174. blue aura 174. blue aura
175. yellow aura 175. yellow aura
176. purple aura 176. purple aura
177. red aura 177. red aura
178. white aura 178. white aura
179. purple aura 179. purple aura
180. darkness attack hit? 180. darkness attack hit?
181. water attack hit? 181. water attack hit?
182. wind attack hit 182. wind attack hit
183. self destruction 183. self destruction
184. nothing (npc/mob?) 184. nothing (npc/mob?)
185. nothing (npc/mob?) 185. nothing (npc/mob?)
186. yellow effect 186. yellow effect
187. yellow effect 187. yellow effect
188. yellow effect 188. yellow effect
189. yellow effect 189. yellow effect
190. yellow effect 190. yellow effect
191. target (piercing attack or something) 191. target (piercing attack or something)
192. purple cloud hit 192. purple cloud hit
193. mute or something (npc skill) 193. mute or something (npc skill)
194. stun attack? 194. stun attack?
195. stone curse 195. stone curse
196. curse 196. curse
197. sleep 197. sleep
198. nothing (npc/mob?) 198. nothing (npc/mob?)
199. some weird bubble 199. some weird bubble
200-203. Parts of the level 99 Aura 200-203. Parts of the level 99 Aura
204-211. Healing Items Effect 204-211. Healing Items Effect
212. Damage Effect (9999) 212. Damage Effect (9999)
213. Shield Appears (Guard?) 213. Shield Appears (Guard?)
214. 3 Weird Things Appear Around You (They All Look The Same) 214. 3 Weird Things Appear Around You (They All Look The Same)
215. Hide/Unhide? 215. Hide/Unhide?
216. 2 Red Balls shoot out 216. 2 Red Balls shoot out
217. 2 Blue Balls shoot out 217. 2 Blue Balls shoot out
218. Concentration Potion Effect 218. Concentration Potion Effect
219. Other Speed Potion 219. Other Speed Potion
220. Berserk Potion 220. Berserk Potion
221. White Alien Abduction Beam 221. White Alien Abduction Beam
222. Defender Skill Effect (Black Circle) 222. Defender Skill Effect (Black Circle)
223. Invalid Effect 223. Invalid Effect
224. White Wisp Revolving around you 224. White Wisp Revolving around you
225. Volcano Effect 225. Volcano Effect
226. Grand Cross Effect 226. Grand Cross Effect
227-230. Blank 227-230. Blank
231. Yuno Effect (Takes Alittle While) 231. Yuno Effect (Takes Alittle While)
232. Blank 232. Blank
233. Fog 233. Fog
234. Unknown To Me 234. Unknown To Me
235. Unknown To Me 235. Unknown To Me
236. Deluge Effect 236. Deluge Effect
237. Wind Gale Effect 237. Wind Gale Effect
238. Land Protect Effect 238. Land Protect Effect
239. Volcano Effect 2 239. Volcano Effect 2
240. Deluge Effect 2 240. Deluge Effect 2
241. Wind Gale Effect 2 241. Wind Gale Effect 2
242. Land Protect Effect 2 242. Land Protect Effect 2
243. Invalid Effect 243. Invalid Effect
244. Unknown To Me. 244. Unknown To Me.
245. Holy Cross Effect 245. Holy Cross Effect
246. Shield Charge Effect 246. Shield Charge Effect
247. Yuno Effect 2 (Larger) 247. Yuno Effect 2 (Larger)
248. Status Recovery? (Shows An Angel On Top Of Your Head) 248. Status Recovery? (Shows An Angel On Top Of Your Head)
249. Shield Boomerang 249. Shield Boomerang
250. Spear Quicken 250. Spear Quicken
251. Devotion 251. Devotion
252. Reflect Shield (Yellow Circle) 252. Reflect Shield (Yellow Circle)
259. Green Abduction Beam 259. Green Abduction Beam
260. Orange Abduction Beam 260. Orange Abduction Beam
261. red aura thing 261. red aura thing
262. yellow things that shoot out 262. yellow things that shoot out
263. Yellow ground effect. 263. Yellow ground effect.
264. nothing (npc/mob?) 264. nothing (npc/mob?)
265. laser beam ?! 265. laser beam ?!
266. bunch of white shit flies out 266. bunch of white shit flies out
267. gun shot! 267. gun shot!
268. money bag 268. money bag
269. sword thing 269. sword thing
270. shield thing 270. shield thing
271. armor thing 271. armor thing
272. cape thing? 272. cape thing?
273. Outter spinning white balls. 273. Outter spinning white balls.
274. flying gold 274. flying gold
275. spit 275. spit
276. stuff that flies out somewhat like crits 276. stuff that flies out somewhat like crits
277. white stuff that comes out around sprite 277. white stuff that comes out around sprite
295. frost joke 295. frost joke
296. scream 296. scream
298. fire bottle throwing 298. fire bottle throwing
300. Chemical Protection 300. Chemical Protection
301. Blank 301. Blank
302. Demonstration Fire Effect 302. Demonstration Fire Effect
303. Weird Effect you turn yellow and see six lines (3 sets of 2) going slanted 303. Weird Effect you turn yellow and see six lines (3 sets of 2) going slanted
304. After being warped 304. After being warped
305. Pharmacy Success 305. Pharmacy Success
306. Pharmacy Failed 306. Pharmacy Failed
307. Sunlight through the roof effect in Geffenia 307. Sunlight through the roof effect in Geffenia
308. Blank 308. Blank
309. Unknown to me 309. Unknown to me
310. Unknown to me 310. Unknown to me
311. Shout/Yell/Loud (Merchant Skill) Effect 311. Shout/Yell/Loud (Merchant Skill) Effect
312-313. Heal Effect? 312-313. Heal Effect?
314. Another Part of Warp/ Yuno Effect? 314. Another Part of Warp/ Yuno Effect?
315. Newer Safety Wall (Pink Portal) 315. Newer Safety Wall (Pink Portal)
316. Another Part of Warp (The Ripple Floor Part) 316. Another Part of Warp (The Ripple Floor Part)
317. Full Warp Effect 317. Full Warp Effect
322. daylight 322. daylight
323. daylight 323. daylight
324. daylight 324. daylight
328. asura strike word 328. asura strike word
329. tripple strike 329. tripple strike
333. Orange Leaves Falling 333. Orange Leaves Falling
334. blind (can stack it) 334. blind (can stack it)
335. poison (can stack it) 335. poison (can stack it)
336. defender shield? 336. defender shield?
337. joblvup 337. joblvup
338. supernovice angel 338. supernovice angel
341. pink warp portal 341. pink warp portal
342. pink aura 342. pink aura
343. pink heart thing (cool) 343. pink heart thing (cool)
344. teleport in 344. teleport in
346. big blue ball 346. big blue ball
347. wedding effect 347. wedding effect
349. waterfall (horizonatal) 349. waterfall (horizonatal)
350. waterfall (vertical) 350. waterfall (vertical)
351. sm waterfall (horizonatal) 351. sm waterfall (horizonatal)
352. sm waterfall (vertical) 352. sm waterfall (vertical)
353. drk waterfall (horizonatal) 353. drk waterfall (horizonatal)
354. drk waterfall (vertical) 354. drk waterfall (vertical)
355. drk sm waterfall (horizonatal) 355. drk sm waterfall (horizonatal)
356. drk sm waterfall (vertical) 356. drk sm waterfall (vertical)
358. niflheim ghost 358. niflheim ghost
359. niflheim bat slow 359. niflheim bat slow
360. niflheim bat fast 360. niflheim bat fast
361. shoots purple wave out 361. shoots purple wave out
362. nothing? 362. nothing?
363. valentine's day heart (wings) 363. valentine's day heart (wings)
364. valentine's day heart 364. valentine's day heart
365. falling cross 365. falling cross
368. make you red (berserk?) 368. make you red (berserk?)
369. 2h quicken? 369. 2h quicken?
371. lvup 371. lvup
372. death 372. death
373. smoke 373. smoke
375. white outline around sprite 375. white outline around sprite
376. makes red and shoots out stuff 376. makes red and shoots out stuff
377. shoots out yellow shit 377. shoots out yellow shit
380. shakes screen turns you all different colors 380. shakes screen turns you all different colors
387. spins you around shakes screen flashes white 387. spins you around shakes screen flashes white
394. big red ball around you 394. big red ball around you
403 = mind breaker 403 = mind breaker
404 = spider web 404 = spider web
405 = nothing 405 = nothing
406 = explosion effect on the head 406 = explosion effect on the head
407 = effect that starts big and fades in to your characters head 407 = effect that starts big and fades in to your characters head
408. Orange Bubble Grows Around 408. Orange Bubble Grows Around
409. Weird Poision Like Effect 409. Weird Poision Like Effect
410. Rainbow 410. Rainbow
411. (Usable, Just add in folder effect file called peong1.tga).errors/detoxify like. 411. (Usable, Just add in folder effect file called peong1.tga).errors/detoxify like.
413. nothing? 413. nothing?
417. flash 417. flash
418. red critical explosion? 418. red critical explosion?
419. Pulsating grey aura 419. Pulsating grey aura
420. gradual shrink char (possible minimize effect?) 420. gradual shrink char (possible minimize effect?)
421. instant minimize 421. instant minimize
422. grow back, but not all the way (baby height) 422. grow back, but not all the way (baby height)
423. mega size 423. mega size
424. makes sprite bright 424. makes sprite bright
425. 4 brownish replicas of sprite fly off? 425. 4 brownish replicas of sprite fly off?
426. shakes sprites (works on player sprites!) 426. shakes sprites (works on player sprites!)
427. nothing? (maybe for npc/mobs) 427. nothing? (maybe for npc/mobs)
428. yellow sparks 428. yellow sparks
429. blue sparks 429. blue sparks
430. blue sparks in different direction 430. blue sparks in different direction
431. another blue spark variant 431. another blue spark variant
432. can't find effect\elec1.tga 432. can't find effect\elec1.tga
433. nothing? (npc/mob?) 433. nothing? (npc/mob?)
434. white sparks 434. white sparks
435. can't find effect\storm2.tga (sometimes works and shows little tornado thing! 435. can't find effect\storm2.tga (sometimes works and shows little tornado thing!
436. white shield (for one of the defense skills?) 436. white shield (for one of the defense skills?)
437. blue aura (kinda like a comet!) 437. blue aura (kinda like a comet!)
438. another defense aura? blue ripples. blue pulsating shield 438. another defense aura? blue ripples. blue pulsating shield
439. can't fine effect\line3.tga 439. can't fine effect\line3.tga
440. high priest skill angel? Angelus type effect but with a cross 440. high priest skill angel? Angelus type effect but with a cross
441. another cast aura 441. another cast aura
442. nothing? (npc/mob?) 442. nothing? (npc/mob?)
443. nothing? (npc/mob?) 443. nothing? (npc/mob?)
444. white lines that fire out 444. white lines that fire out
445. your sprite flies up and disappears sometime sprite errors 445. your sprite flies up and disappears sometime sprite errors
446. your sprite falls down 446. your sprite falls down
447. nothing? (npc/mob?) 447. nothing? (npc/mob?)
448. nothing? (npc/mob?) 448. nothing? (npc/mob?)
449. turns you bright blue real quick 449. turns you bright blue real quick
450. darkcross effect (black grand cross) 450. darkcross effect (black grand cross)
451. red soul strike?! (high wiz skill?) 451. red soul strike?! (high wiz skill?)
452. A jupital thunder type of effect, electricity pulsates around your char 452. A jupital thunder type of effect, electricity pulsates around your char
453. Smoke (electricity type) surrounds char, can move and effect is still their. 453. Smoke (electricity type) surrounds char, can move and effect is still their.
454. black cast aura 454. black cast aura
455. red electric that covers body 455. red electric that covers body
456. looks like wind rushes up (reminds me of agi up but slower, bigger, and grey) 456. looks like wind rushes up (reminds me of agi up but slower, bigger, and grey)
457. forces attack animation. makes a dash like stance 457. forces attack animation. makes a dash like stance
458. causes sprite to jiggle. char pulsates and distorts (like 426) 458. causes sprite to jiggle. char pulsates and distorts (like 426)
459. effect\storm2.tga error, causes player sprite to spin around and you see a faint tornado aura 459. effect\storm2.tga error, causes player sprite to spin around and you see a faint tornado aura
460. same as 459. 460. same as 459.
461. faint tornado aura 461. faint tornado aura
462. same as 459. 462. same as 459.
463. same as 459. 463. same as 459.
464. same as 459. 464. same as 459.
465. same as 459. 465. same as 459.
466. nothing (npc/mob?) 466. nothing (npc/mob?)
467. sprite error (effect\hanmoon1.tga?) 467. sprite error (effect\hanmoon1.tga?)
468. sprite error (effect\hanmoon2.tga?) 468. sprite error (effect\hanmoon2.tga?)
469. sprite error (effect\hanmoon3.tga?) 469. sprite error (effect\hanmoon3.tga?)
470. sprite error (effect\hanmoon4.tga?) 470. sprite error (effect\hanmoon4.tga?)
471. sprite error (effect\hanmoon5.tga?) 471. sprite error (effect\hanmoon5.tga?)
472. sprite error (effect\hanmoon6.tga?) 472. sprite error (effect\hanmoon6.tga?)
473. sprite error (effect\hanmoon7.tga?) 473. sprite error (effect\hanmoon7.tga?)
474. nothing (npc/mob?) 474. nothing (npc/mob?)
475-484 = slow fade to blind, each one continues to make it smaller and smaller 475-484 = slow fade to blind, each one continues to make it smaller and smaller
485 = white critical explosion thing 485 = white critical explosion thing
486 = blue critical explosion thing 486 = blue critical explosion thing
487 = black portal ground effect 487 = black portal ground effect
488 = orange spikey aura that stretches up to fire type points 488 = orange spikey aura that stretches up to fire type points
489 = yellow/gold of 488 489 = yellow/gold of 488
489 = blue version 489 = blue version
491 = a small expoision above the head 491 = a small expoision above the head
492 = creates 1 small venom poison type of point on the ground 492 = creates 1 small venom poison type of point on the ground
493+ = invalid effects 493+ = invalid effects

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +1,65 @@
//===== eAthena Script ======================================= //===== eAthena Script =======================================
//= Lou Yang City NPC's //= Lou Yang City NPC's
//===== By: ================================================== //===== By: ==================================================
//= Vidar (1.0) //= Vidar (1.0)
//= Mass Zero (1.1) //= Mass Zero (1.1)
//===== Current Version: ===================================== //===== Current Version: =====================================
//= 1.0 //= 1.0
//===== Compatible With: ===================================== //===== Compatible With: =====================================
//= Any eAthena Version //= Any eAthena Version
//===== Description: ========================================= //===== Description: =========================================
//= Unofficial NPC's for Lou Yang city. //= Unofficial NPC's for Lou Yang city.
//===== Additional Comments: ================================= //===== Additional Comments: =================================
//= Originally made for Vidar //= Originally made for Vidar
//============================================================ //============================================================
louyang.gat,260,96,2 script Chun Hua 770,{ louyang.gat,260,96,2 script Chun Hua 770,{
mes "[^000080Chun Hua^000000]"; mes "[^000080Chun Hua^000000]";
mes "Welcome traveler, you must be hungry and thirsty."; mes "Welcome traveler, you must be hungry and thirsty.";
mes "Please come inside, there is much to eat."; mes "Please come inside, there is much to eat.";
next; next;
mes "[^000080Chun Hua^000000]"; mes "[^000080Chun Hua^000000]";
mes "Do not be afraid about how much you ask for, there is much to go around."; mes "Do not be afraid about how much you ask for, there is much to go around.";
close; close;
} }
lou_fild01.gat,188,102,1 script Extraordinary Sailor 100,{ lou_fild01.gat,188,102,1 script Extraordinary Sailor 100,{
mes "[Extraordinary Sailor]"; mes "[Extraordinary Sailor]";
mes "We run a line to Alberta, we could take you there if you like."; mes "We run a line to Alberta, we could take you there if you like.";
next; next;
menu "Let me travel to Alberta",L_Menu1,"No, thanks",L_Menu2; menu "Let me travel to Alberta",L_Menu1,"No, thanks",L_Menu2;
close; close;
L_Menu1: L_Menu1:
warp "alberta.gat",247,44; warp "alberta.gat",247,44;
L_Menu2: L_Menu2:
mes "[Extraordinary Sailor]"; mes "[Extraordinary Sailor]";
mes "Suit yourself."; mes "Suit yourself.";
close; close;
} }
alberta.gat,247,42,4 script Expert Sailor 100,{ alberta.gat,247,42,4 script Expert Sailor 100,{
mes "[Expert Sailor]"; mes "[Expert Sailor]";
mes "Have you ever been over seas?"; mes "Have you ever been over seas?";
next; next;
menu "Yes",YES,"No",NO; menu "Yes",YES,"No",NO;
YES: YES:
mes "Same here! I'm about to head back out that way again."; mes "Same here! I'm about to head back out that way again.";
mes "Would you like to come with me?"; mes "Would you like to come with me?";
next; next;
menu "Sure",L_Menu1,"No, thanks",L_Menu3; menu "Sure",L_Menu1,"No, thanks",L_Menu3;
close; close;
L_Menu1: L_Menu1:
warp "lou_fild01.gat",192,105; warp "lou_fild01.gat",192,105;
NO: NO:
mes "What a shame, it is truley a sight to behold. I'm about to head back out that way again."; mes "What a shame, it is truley a sight to behold. I'm about to head back out that way again.";
mes "Would you like to come with me?"; mes "Would you like to come with me?";
next; next;
menu "Sure",L_Menu2,"No, thanks",L_Menu3; menu "Sure",L_Menu2,"No, thanks",L_Menu3;
close; close;
L_Menu2: L_Menu2:
warp "lou_fild01.gat",192,105; warp "lou_fild01.gat",192,105;
L_Menu3: L_Menu3:
mes "[Expert Sailor]"; mes "[Expert Sailor]";
mes "Suit yourself."; mes "Suit yourself.";
close; close;
} }

View File

@ -1,491 +1,491 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <signal.h> #include <signal.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include "login.h" #include "login.h"
//-------------------------------- //--------------------------------
// Send to char // Send to char
//-------------------------------- //--------------------------------
int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len) {
int i, c; int i, c;
int fd; int fd;
c = 0; c = 0;
for(i = 0; i < MAX_SERVERS && i < servers_connected; i++) { for(i = 0; i < MAX_SERVERS && i < servers_connected; i++) {
if ((fd = server_fd[i]) > 0 && fd != sfd) { if ((fd = server_fd[i]) > 0 && fd != sfd) {
memcpy(WFIFOP(fd,0), buf, len); memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len); WFIFOSET(fd,len);
c++; c++;
} }
} }
return c; return c;
} }
//-------------------------------- //--------------------------------
// Char-server anti-freeze system // Char-server anti-freeze system
//-------------------------------- //--------------------------------
int char_anti_freeze_system(int tid, unsigned int tick, int id, int data) { int char_anti_freeze_system(int tid, unsigned int tick, int id, int data) {
int i; int i;
for(i = 0; i < MAX_SERVERS && i < servers_connected; i++) { for(i = 0; i < MAX_SERVERS && i < servers_connected; i++) {
if (server_fd[i] >= 0) {// if char-server is online if (server_fd[i] >= 0) {// if char-server is online
// printf("char_anti_freeze_system: server #%d '%s', flag: %d.\n", i, server[i].name, server_freezeflag[i]); // printf("char_anti_freeze_system: server #%d '%s', flag: %d.\n", i, server[i].name, server_freezeflag[i]);
if (server_freezeflag[i]-- < 1) {// Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed if (server_freezeflag[i]-- < 1) {// Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed
session[server_fd[i]]->eof = 1; session[server_fd[i]]->eof = 1;
} }
} }
} }
return 0; return 0;
} }
//------------------------------------------- //-------------------------------------------
// Request for account reg from char-server [Edit: Wizputer] // Request for account reg from char-server [Edit: Wizputer]
//------------------------------------------- //-------------------------------------------
void send_account_reg(int fd) { void send_account_reg(int fd) {
int account_id = RFIFOL(fd,2); int account_id = RFIFOL(fd,2);
int i; int i;
for(i=0;i<AUTH_FIFO_SIZE;i++){ for(i=0;i<AUTH_FIFO_SIZE;i++){
if (auth_fifo[i].account_id == account_id && if (auth_fifo[i].account_id == account_id &&
auth_fifo[i].login_id1 == RFIFOL(fd,6) && auth_fifo[i].login_id1 == RFIFOL(fd,6) &&
#if CMP_AUTHFIFO_LOGIN2 != 0 #if CMP_AUTHFIFO_LOGIN2 != 0
auth_fifo[i].login_id2 == RFIFOL(fd,10) && // relate to the versions higher than 18 auth_fifo[i].login_id2 == RFIFOL(fd,10) && // relate to the versions higher than 18
#endif #endif
auth_fifo[i].sex == RFIFOB(fd,14) && auth_fifo[i].sex == RFIFOB(fd,14) &&
#if CMP_AUTHFIFO_IP != 0 #if CMP_AUTHFIFO_IP != 0
auth_fifo[i].ip == RFIFOL(fd,15) && auth_fifo[i].ip == RFIFOL(fd,15) &&
#endif #endif
!auth_fifo[i].delflag) { !auth_fifo[i].delflag) {
auth_fifo[i].delflag = 1; auth_fifo[i].delflag = 1;
#ifdef DEBUG #ifdef DEBUG
printf("Client: [%d] Auth Number: [%d]\n",fd, i); printf("Client: [%d] Auth Number: [%d]\n",fd, i);
#endif #endif
break; break;
} }
} }
if (i != AUTH_FIFO_SIZE) { // send account_reg if (i != AUTH_FIFO_SIZE) { // send account_reg
int p; int p;
time_t connect_until_time = 0; time_t connect_until_time = 0;
char email[40] = ""; char email[40] = "";
sprintf(tmpsql, "SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'", login_db, login_db_account_id, account_id); sprintf(tmpsql, "SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'", login_db, login_db_account_id, account_id);
sql_query(tmpsql,"send_account_reg"); sql_query(tmpsql,"send_account_reg");
if ((sql_res = mysql_store_result(&mysql_handle))) { if ((sql_res = mysql_store_result(&mysql_handle))) {
if((sql_row = mysql_fetch_row(sql_res))) { if((sql_row = mysql_fetch_row(sql_res))) {
connect_until_time = atol(sql_row[1]); connect_until_time = atol(sql_row[1]);
strcpy(email, sql_row[0]); strcpy(email, sql_row[0]);
} }
} }
mysql_free_result(sql_res); mysql_free_result(sql_res);
if (account_id > 0) { if (account_id > 0) {
sprintf(tmpsql, "SELECT `str`,`value` FROM `global_reg_value` WHERE `type`='1' AND `account_id`='%d'",account_id); sprintf(tmpsql, "SELECT `str`,`value` FROM `global_reg_value` WHERE `type`='1' AND `account_id`='%d'",account_id);
sql_query(tmpsql,"send_account_reg"); sql_query(tmpsql,"send_account_reg");
if ((sql_res = mysql_store_result(&mysql_handle))) { if ((sql_res = mysql_store_result(&mysql_handle))) {
WFIFOW(fd,0) = 0x2729; WFIFOW(fd,0) = 0x2729;
WFIFOL(fd,4) = account_id; WFIFOL(fd,4) = account_id;
for(p = 8; (sql_row = mysql_fetch_row(sql_res));p+=36){ for(p = 8; (sql_row = mysql_fetch_row(sql_res));p+=36){
memcpy(WFIFOP(fd,p), sql_row[0], 32); memcpy(WFIFOP(fd,p), sql_row[0], 32);
WFIFOL(fd,p+32) = atoi(sql_row[1]); WFIFOL(fd,p+32) = atoi(sql_row[1]);
} }
WFIFOW(fd,2) = p; WFIFOW(fd,2) = p;
WFIFOSET(fd,p); WFIFOSET(fd,p);
#ifdef DEBUG #ifdef DEBUG
printf("account_reg2 send : login->char (auth fifo)\n"); printf("account_reg2 send : login->char (auth fifo)\n");
#endif #endif
WFIFOW(fd,0) = 0x2713; WFIFOW(fd,0) = 0x2713;
WFIFOL(fd,2) = account_id; WFIFOL(fd,2) = account_id;
WFIFOB(fd,6) = 0; WFIFOB(fd,6) = 0;
memcpy(WFIFOP(fd, 7), email, 40); memcpy(WFIFOP(fd, 7), email, 40);
WFIFOL(fd,47) = (unsigned long) connect_until_time; WFIFOL(fd,47) = (unsigned long) connect_until_time;
WFIFOSET(fd,51); WFIFOSET(fd,51);
} }
mysql_free_result(sql_res); mysql_free_result(sql_res);
} }
} else { } else {
WFIFOW(fd,0) = 0x2713; WFIFOW(fd,0) = 0x2713;
WFIFOL(fd,2) = account_id; WFIFOL(fd,2) = account_id;
WFIFOB(fd,6) = 1; WFIFOB(fd,6) = 1;
WFIFOSET(fd,51); WFIFOSET(fd,51);
} }
RFIFOSKIP(fd,19); RFIFOSKIP(fd,19);
} }
//---------------------------------------------------------- //----------------------------------------------------------
// Number of users in the world (connected char-server(s)) [Edit: Wizputer] // Number of users in the world (connected char-server(s)) [Edit: Wizputer]
//---------------------------------------------------------- //----------------------------------------------------------
void number_world_users(int fd, int id) { void number_world_users(int fd, int id) {
#ifdef DEBUG #ifdef DEBUG
if (server[id].users != RFIFOL(fd,2)) if (server[id].users != RFIFOL(fd,2))
printf("set number users %s : %d\n", server[id].name, RFIFOL(fd,2)); printf("set number users %s : %d\n", server[id].name, RFIFOL(fd,2));
#endif #endif
server[id].users = RFIFOL(fd,2); server[id].users = RFIFOL(fd,2);
if(anti_freeze_enable) if(anti_freeze_enable)
server_freezeflag[id] = 5; // Char anti-freeze system. Counter. 5 ok, 4...0 freezed server_freezeflag[id] = 5; // Char anti-freeze system. Counter. 5 ok, 4...0 freezed
sprintf(tmpsql,"UPDATE `sstatus` SET `user` = '%d' WHERE `index` = '%d'", server[id].users, id); sprintf(tmpsql,"UPDATE `sstatus` SET `user` = '%d' WHERE `index` = '%d'", server[id].users, id);
sql_query(tmpsql,"number_world_users"); sql_query(tmpsql,"number_world_users");
RFIFOSKIP(fd,6); RFIFOSKIP(fd,6);
} }
//----------------------------------------- //-----------------------------------------
// Email and Time request from char-server [Edit: Wizputer] // Email and Time request from char-server [Edit: Wizputer]
//----------------------------------------- //-----------------------------------------
void email_time_request(int fd, int id) { void email_time_request(int fd, int id) {
int account_id=RFIFOL(fd,2); int account_id=RFIFOL(fd,2);
time_t connect_until_time = 0; time_t connect_until_time = 0;
char email[40] = ""; char email[40] = "";
sprintf(tmpsql,"SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'",login_db, login_db_account_id, account_id); sprintf(tmpsql,"SELECT `email`,`connect_until` FROM `%s` WHERE `%s`='%d'",login_db, login_db_account_id, account_id);
sql_query(tmpsql,"email_time_request"); sql_query(tmpsql,"email_time_request");
if ((sql_res = mysql_store_result(&mysql_handle))) { if ((sql_res = mysql_store_result(&mysql_handle))) {
if((sql_row = mysql_fetch_row(sql_res))) { if((sql_row = mysql_fetch_row(sql_res))) {
connect_until_time = atol(sql_row[1]); connect_until_time = atol(sql_row[1]);
strcpy(email, sql_row[0]); strcpy(email, sql_row[0]);
} }
} }
mysql_free_result(sql_res); mysql_free_result(sql_res);
#ifdef DEBUG #ifdef DEBUG
printf("parse_fromchar: E-mail/limited time request from '%s' server (concerned account: %d)\n", server[id].name, account_id); printf("parse_fromchar: E-mail/limited time request from '%s' server (concerned account: %d)\n", server[id].name, account_id);
#endif #endif
WFIFOW(fd,0) = 0x2717; WFIFOW(fd,0) = 0x2717;
WFIFOL(fd,2) = account_id; WFIFOL(fd,2) = account_id;
memcpy(WFIFOP(fd, 6), email, 40); memcpy(WFIFOP(fd, 6), email, 40);
WFIFOL(fd,46) = (unsigned long) connect_until_time; WFIFOL(fd,46) = (unsigned long) connect_until_time;
WFIFOSET(fd,50); WFIFOSET(fd,50);
RFIFOSKIP(fd,6); RFIFOSKIP(fd,6);
} }
//-------------------------------- //--------------------------------
// Request to change email [Edit: Wizputer] // Request to change email [Edit: Wizputer]
//-------------------------------- //--------------------------------
void change_account_email(int fd, int id, char ip[16]) { void change_account_email(int fd, int id, char ip[16]) {
int acc = RFIFOL(fd,2); int acc = RFIFOL(fd,2);
char actual_email[40], new_email[40]; char actual_email[40], new_email[40];
memcpy(actual_email, RFIFOP(fd,6), 40); memcpy(actual_email, RFIFOP(fd,6), 40);
memcpy(new_email, RFIFOP(fd,46), 40); memcpy(new_email, RFIFOP(fd,46), 40);
if (e_mail_check(actual_email) == 0) { if (e_mail_check(actual_email) == 0) {
#ifdef DEBUG #ifdef DEBUG
printf("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)" RETCODE, printf("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command), but actual email is invalid (account: %d, ip: %s)" RETCODE,
server[id].name, acc, ip); server[id].name, acc, ip);
#endif #endif
} else if (e_mail_check(new_email) == 0) { } else if (e_mail_check(new_email) == 0) {
#ifdef DEBUG #ifdef DEBUG
printf("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)" RETCODE, printf("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a invalid new e-mail (account: %d, ip: %s)" RETCODE,
server[id].name, acc, ip); server[id].name, acc, ip);
#endif #endif
} else if (strcmpi(new_email, "athena@athena.com") == 0) { } else if (strcmpi(new_email, "athena@athena.com") == 0) {
#ifdef DEBUG #ifdef DEBUG
printf("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)" RETCODE, printf("Char-server '%s': Attempt to modify an e-mail on an account (@email GM command) with a default e-mail (account: %d, ip: %s)" RETCODE,
server[id].name, acc, ip); server[id].name, acc, ip);
#endif #endif
} else { } else {
sprintf(tmpsql, "SELECT `%s`,`email` FROM `%s` WHERE `%s` = '%d'", login_db_userid, login_db, login_db_account_id, acc); sprintf(tmpsql, "SELECT `%s`,`email` FROM `%s` WHERE `%s` = '%d'", login_db_userid, login_db, login_db_account_id, acc);
sql_query(tmpsql,"change_account_email"); sql_query(tmpsql,"change_account_email");
if ((sql_res = mysql_store_result(&mysql_handle))) { if ((sql_res = mysql_store_result(&mysql_handle))) {
if((sql_row = mysql_fetch_row(sql_res))) { //row fetching if((sql_row = mysql_fetch_row(sql_res))) { //row fetching
if (strcmpi(sql_row[1], actual_email) == 0) { if (strcmpi(sql_row[1], actual_email) == 0) {
sprintf(tmpsql, "UPDATE `%s` SET `email` = '%s' WHERE `%s` = '%d'", login_db, new_email, login_db_account_id, acc); sprintf(tmpsql, "UPDATE `%s` SET `email` = '%s' WHERE `%s` = '%d'", login_db, new_email, login_db_account_id, acc);
sql_query(tmpsql,"change_account_email"); sql_query(tmpsql,"change_account_email");
#ifdef DEBUG #ifdef DEBUG
printf("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s)." RETCODE, printf("Char-server '%s': Modify an e-mail on an account (@email GM command) (account: %d (%s), new e-mail: %s, ip: %s)." RETCODE,
server[id].name, acc, sql_row[0], actual_email, ip); server[id].name, acc, sql_row[0], actual_email, ip);
#endif #endif
} }
} }
} }
} }
RFIFOSKIP(fd, 86); RFIFOSKIP(fd, 86);
} }
//----------------------------------------------- //-----------------------------------------------
// State change request from map server (By Yor) [Edit: Wizputer] // State change request from map server (By Yor) [Edit: Wizputer]
//----------------------------------------------- //-----------------------------------------------
void status_change_request(int fd) { void status_change_request(int fd) {
int acc = RFIFOL(fd,2), status = RFIFOL(fd,6); int acc = RFIFOL(fd,2), status = RFIFOL(fd,6);
sprintf(tmpsql, "SELECT `state` FROM `%s` WHERE `%s` = '%d'", login_db, login_db_account_id, acc); sprintf(tmpsql, "SELECT `state` FROM `%s` WHERE `%s` = '%d'", login_db, login_db_account_id, acc);
sql_query(tmpsql,"status_change_request"); sql_query(tmpsql,"status_change_request");
if ((sql_res = mysql_store_result(&mysql_handle))) { if ((sql_res = mysql_store_result(&mysql_handle))) {
if((sql_row = mysql_fetch_row(sql_res))) { // row fetching if((sql_row = mysql_fetch_row(sql_res))) { // row fetching
if (atoi(sql_row[0]) != status && status != 0) { if (atoi(sql_row[0]) != status && status != 0) {
unsigned char buf[16]; unsigned char buf[16];
WBUFW(buf,0) = 0x2731; WBUFW(buf,0) = 0x2731;
WBUFL(buf,2) = acc; WBUFL(buf,2) = acc;
WBUFB(buf,6) = 0; // 0: change of statut, 1: ban WBUFB(buf,6) = 0; // 0: change of statut, 1: ban
WBUFL(buf,7) = status; // status or final date of a banishment WBUFL(buf,7) = status; // status or final date of a banishment
charif_sendallwos(-1, buf, 11); charif_sendallwos(-1, buf, 11);
} }
} }
sprintf(tmpsql,"UPDATE `%s` SET `state` = '%d' WHERE `%s` = '%d'", login_db, status,login_db_account_id,acc); sprintf(tmpsql,"UPDATE `%s` SET `state` = '%d' WHERE `%s` = '%d'", login_db, status,login_db_account_id,acc);
sql_query(tmpsql,"status_change_request"); sql_query(tmpsql,"status_change_request");
} }
RFIFOSKIP(fd,10); RFIFOSKIP(fd,10);
} }
//-------------------------------------- //--------------------------------------
// Ban request from map-server (By Yor) [Edit: Wizputer] // Ban request from map-server (By Yor) [Edit: Wizputer]
//-------------------------------------- //--------------------------------------
void ban_request(int fd) { void ban_request(int fd) {
int acc=RFIFOL(fd,2); int acc=RFIFOL(fd,2);
struct tm *tmtime; struct tm *tmtime;
time_t timestamp, tmptime; time_t timestamp, tmptime;
sprintf(tmpsql, "SELECT `ban_until` FROM `%s` WHERE `%s` = '%d'",login_db,login_db_account_id,acc); sprintf(tmpsql, "SELECT `ban_until` FROM `%s` WHERE `%s` = '%d'",login_db,login_db_account_id,acc);
sql_query(tmpsql,"ban_request"); sql_query(tmpsql,"ban_request");
if ((sql_res = mysql_store_result(&mysql_handle)) && (sql_row = mysql_fetch_row(sql_res))) { if ((sql_res = mysql_store_result(&mysql_handle)) && (sql_row = mysql_fetch_row(sql_res))) {
tmptime = atol(sql_row[0]); tmptime = atol(sql_row[0]);
if (tmptime == 0 || tmptime < time(NULL)) if (tmptime == 0 || tmptime < time(NULL))
timestamp = time(NULL); timestamp = time(NULL);
else else
timestamp = tmptime; timestamp = tmptime;
tmtime = localtime(&timestamp); tmtime = localtime(&timestamp);
tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,6); tmtime->tm_year = tmtime->tm_year + (short)RFIFOW(fd,6);
tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,8); tmtime->tm_mon = tmtime->tm_mon + (short)RFIFOW(fd,8);
tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,10); tmtime->tm_mday = tmtime->tm_mday + (short)RFIFOW(fd,10);
tmtime->tm_hour = tmtime->tm_hour + (short)RFIFOW(fd,12); tmtime->tm_hour = tmtime->tm_hour + (short)RFIFOW(fd,12);
tmtime->tm_min = tmtime->tm_min + (short)RFIFOW(fd,14); tmtime->tm_min = tmtime->tm_min + (short)RFIFOW(fd,14);
tmtime->tm_sec = tmtime->tm_sec + (short)RFIFOW(fd,16); tmtime->tm_sec = tmtime->tm_sec + (short)RFIFOW(fd,16);
timestamp = mktime(tmtime); timestamp = mktime(tmtime);
if (timestamp != -1) { if (timestamp != -1) {
if (timestamp <= time(NULL)) if (timestamp <= time(NULL))
timestamp = 0; timestamp = 0;
if (tmptime != timestamp) { if (tmptime != timestamp) {
if (timestamp != 0) { if (timestamp != 0) {
unsigned char buf[16]; unsigned char buf[16];
WBUFW(buf,0) = 0x2731; WBUFW(buf,0) = 0x2731;
WBUFL(buf,2) = acc; WBUFL(buf,2) = acc;
WBUFB(buf,6) = 1; // 0: change of statut, 1: ban WBUFB(buf,6) = 1; // 0: change of statut, 1: ban
WBUFL(buf,7) = timestamp; // status or final date of a banishment WBUFL(buf,7) = timestamp; // status or final date of a banishment
charif_sendallwos(-1, buf, 11); charif_sendallwos(-1, buf, 11);
} }
#ifdef DEBUG #ifdef DEBUG
printf("Account: [%d] Banned until: [%ld]\n", acc, timestamp); printf("Account: [%d] Banned until: [%ld]\n", acc, timestamp);
#endif #endif
sprintf(tmpsql, "UPDATE `%s` SET `ban_until` = '%ld', `state`='7' WHERE `%s` = '%d'", login_db, timestamp, login_db_account_id, acc); sprintf(tmpsql, "UPDATE `%s` SET `ban_until` = '%ld', `state`='7' WHERE `%s` = '%d'", login_db, timestamp, login_db_account_id, acc);
sql_query(tmpsql,"ban_request"); sql_query(tmpsql,"ban_request");
} }
} }
} }
RFIFOSKIP(fd,18); RFIFOSKIP(fd,18);
} }
//----------------------------- //-----------------------------
// Change sex [Edit: Wizputer] // Change sex [Edit: Wizputer]
//----------------------------- //-----------------------------
void change_sex(int fd) { void change_sex(int fd) {
int sex,acc=RFIFOL(fd,4); int sex,acc=RFIFOL(fd,4);
unsigned char buf[16]; unsigned char buf[16];
sprintf(tmpsql,"SELECT `sex` FROM `%s` WHERE `%s` = '%d'",login_db,login_db_account_id,acc); sprintf(tmpsql,"SELECT `sex` FROM `%s` WHERE `%s` = '%d'",login_db,login_db_account_id,acc);
sql_query(tmpsql,"change_sex"); sql_query(tmpsql,"change_sex");
if ((sql_res = mysql_store_result(&mysql_handle)) && (sql_row = mysql_fetch_row(sql_res))) { if ((sql_res = mysql_store_result(&mysql_handle)) && (sql_row = mysql_fetch_row(sql_res))) {
if (strcmpi(sql_row[0], "M") == 0) if (strcmpi(sql_row[0], "M") == 0)
sex = 1; sex = 1;
else else
sex = 0; sex = 0;
sprintf(tmpsql,"UPDATE `%s` SET `sex` = '%c' WHERE `%s` = '%d'", login_db, (sex==0?'M':'F'), login_db_account_id, acc); sprintf(tmpsql,"UPDATE `%s` SET `sex` = '%c' WHERE `%s` = '%d'", login_db, (sex==0?'M':'F'), login_db_account_id, acc);
sql_query(tmpsql,"change_sex"); sql_query(tmpsql,"change_sex");
WBUFW(buf,0) = 0x2723; WBUFW(buf,0) = 0x2723;
WBUFL(buf,2) = acc; WBUFL(buf,2) = acc;
WBUFB(buf,6) = sex; WBUFB(buf,6) = sex;
charif_sendallwos(-1, buf, 7); charif_sendallwos(-1, buf, 7);
} }
RFIFOSKIP(fd,6); RFIFOSKIP(fd,6);
} }
//------------------------------- //-------------------------------
// Save Account Reg [Edit: Wizputer] // Save Account Reg [Edit: Wizputer]
//------------------------------- //-------------------------------
void save_account_reg(int fd){ void save_account_reg(int fd){
int p,j,value,acc=RFIFOL(fd,4); int p,j,value,acc=RFIFOL(fd,4);
char str[32]; char str[32];
char temp_str[32]; char temp_str[32];
if (acc>0){ if (acc>0){
unsigned char buf[RFIFOW(fd,2)+1]; unsigned char buf[RFIFOW(fd,2)+1];
for(p=8,j=0;p<RFIFOW(fd,2) && j<ACCOUNT_REG2_NUM;p+=36,j++){ for(p=8,j=0;p<RFIFOW(fd,2) && j<ACCOUNT_REG2_NUM;p+=36,j++){
memcpy(str,RFIFOP(fd,p),32); memcpy(str,RFIFOP(fd,p),32);
value=RFIFOL(fd,p+32); value=RFIFOL(fd,p+32);
sprintf(tmpsql,"REPLACE INTO `global_reg_value` (`type`, `account_id`, `str`, `value`) VALUES ( 1 , '%d' , '%s' , '%d');", acc, jstrescapecpy(temp_str,str), value); sprintf(tmpsql,"REPLACE INTO `global_reg_value` (`type`, `account_id`, `str`, `value`) VALUES ( 1 , '%d' , '%s' , '%d');", acc, jstrescapecpy(temp_str,str), value);
sql_query(tmpsql,"save_account_reg"); sql_query(tmpsql,"save_account_reg");
} }
// Send to char // Send to char
memcpy(WBUFP(buf,0),RFIFOP(fd,0),RFIFOW(fd,2)); memcpy(WBUFP(buf,0),RFIFOP(fd,0),RFIFOW(fd,2));
WBUFW(buf,0)=0x2729; WBUFW(buf,0)=0x2729;
charif_sendallwos(fd,buf,WBUFW(buf,2)); charif_sendallwos(fd,buf,WBUFW(buf,2));
} }
RFIFOSKIP(fd,RFIFOW(fd,2)); RFIFOSKIP(fd,RFIFOW(fd,2));
#ifdef DEBUG #ifdef DEBUG
printf("login: save account_reg (from char)\n"); printf("login: save account_reg (from char)\n");
#endif #endif
} }
//------------------------------------------------ //------------------------------------------------
// Recieve unban request from map-server (by Yor) [Edit: Wizputer] // Recieve unban request from map-server (by Yor) [Edit: Wizputer]
//------------------------------------------------ //------------------------------------------------
void unban_request(int fd) { void unban_request(int fd) {
int acc = RFIFOL(fd,2); int acc = RFIFOL(fd,2);
sprintf(tmpsql,"UPDATE `%s` SET `ban_until` = '0', `state`='0' WHERE `%s` = '%d' AND `state`='6'", login_db,login_db_account_id,acc); sprintf(tmpsql,"UPDATE `%s` SET `ban_until` = '0', `state`='0' WHERE `%s` = '%d' AND `state`='6'", login_db,login_db_account_id,acc);
sql_query(tmpsql,"unban_request"); sql_query(tmpsql,"unban_request");
RFIFOSKIP(fd,6); RFIFOSKIP(fd,6);
} }
//----------------------------------------------------- //-----------------------------------------------------
// char-server packet parse [Edit: Wizputer] // char-server packet parse [Edit: Wizputer]
//----------------------------------------------------- //-----------------------------------------------------
int parse_fromchar(int fd){ int parse_fromchar(int fd){
int id; int id;
unsigned char *p = (unsigned char *) &session[fd]->client_addr.sin_addr; unsigned char *p = (unsigned char *) &session[fd]->client_addr.sin_addr;
char ip[16]; char ip[16];
sprintf(ip, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); sprintf(ip, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
for(id = 0; id < MAX_SERVERS && id < servers_connected; id++) for(id = 0; id < MAX_SERVERS && id < servers_connected; id++)
if (server_fd[id] == fd) if (server_fd[id] == fd)
break; break;
if (id == MAX_SERVERS) if (id == MAX_SERVERS)
session[fd]->eof = 1; session[fd]->eof = 1;
if(session[fd]->eof) { if(session[fd]->eof) {
if (id < MAX_SERVERS) { if (id < MAX_SERVERS) {
printf("Char-server '%s' has disconnected.\n", server[id].name); printf("Char-server '%s' has disconnected.\n", server[id].name);
server_fd[id] = -1; server_fd[id] = -1;
memset(&server[id], 0, sizeof(struct mmo_char_server)); memset(&server[id], 0, sizeof(struct mmo_char_server));
servers_connected--; servers_connected--;
// server delete // server delete
sprintf(tmpsql, "DELETE FROM `sstatus` WHERE `index`='%d'", id); sprintf(tmpsql, "DELETE FROM `sstatus` WHERE `index`='%d'", id);
sql_query(tmpsql,"parse_fromchar"); sql_query(tmpsql,"parse_fromchar");
} }
close(fd); close(fd);
delete_session(fd); delete_session(fd);
return 0; return 0;
} }
while(RFIFOREST(fd) >= 2) { while(RFIFOREST(fd) >= 2) {
#ifdef DEBUG_PACKETS #ifdef DEBUG_PACKETS
printf("char_parse: %d %d packet case=%x\n", fd, RFIFOREST(fd), RFIFOW(fd, 0)); printf("char_parse: %d %d packet case=%x\n", fd, RFIFOREST(fd), RFIFOW(fd, 0));
#endif #endif
switch (RFIFOW(fd,0)) { switch (RFIFOW(fd,0)) {
case 0x2712: case 0x2712:
if (RFIFOREST(fd) < 19) if (RFIFOREST(fd) < 19)
return 0; return 0;
send_account_reg(fd); send_account_reg(fd);
break; break;
case 0x2714: case 0x2714:
if (RFIFOREST(fd) < 6) if (RFIFOREST(fd) < 6)
return 0; return 0;
number_world_users(fd,id); number_world_users(fd,id);
break; break;
case 0x2716: case 0x2716:
if (RFIFOREST(fd) < 6) if (RFIFOREST(fd) < 6)
return 0; return 0;
email_time_request(fd, id); email_time_request(fd, id);
break; break;
case 0x2722: case 0x2722:
if (RFIFOREST(fd) < 86) if (RFIFOREST(fd) < 86)
return 0; return 0;
change_account_email(fd, id, ip); change_account_email(fd, id, ip);
break; break;
case 0x2724: case 0x2724:
if (RFIFOREST(fd) < 10) if (RFIFOREST(fd) < 10)
return 0; return 0;
status_change_request(fd); status_change_request(fd);
break; break;
case 0x2725: case 0x2725:
if (RFIFOREST(fd) < 18) if (RFIFOREST(fd) < 18)
return 0; return 0;
ban_request(fd); ban_request(fd);
break; break;
case 0x2727: case 0x2727:
if (RFIFOREST(fd) < 6) if (RFIFOREST(fd) < 6)
return 0; return 0;
change_sex(fd); change_sex(fd);
break; break;
case 0x2728: case 0x2728:
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0; return 0;
save_account_reg(fd); save_account_reg(fd);
break; break;
case 0x272a: case 0x272a:
if (RFIFOREST(fd) < 6) if (RFIFOREST(fd) < 6)
return 0; return 0;
unban_request(fd); unban_request(fd);
return 0; return 0;
case 0x272b: // Set account_id to online [Wizputer] case 0x272b: // Set account_id to online [Wizputer]
if (RFIFOREST(fd) < 6) if (RFIFOREST(fd) < 6)
return 0; return 0;
add_online_user(RFIFOL(fd,2)); add_online_user(RFIFOL(fd,2));
RFIFOSKIP(fd,6); RFIFOSKIP(fd,6);
break; break;
case 0x272c: // Set account_id to offline [Wizputer] case 0x272c: // Set account_id to offline [Wizputer]
if (RFIFOREST(fd) < 6) if (RFIFOREST(fd) < 6)
return 0; return 0;
remove_online_user(RFIFOL(fd,2)); remove_online_user(RFIFOL(fd,2));
RFIFOSKIP(fd,6); RFIFOSKIP(fd,6);
break; break;
default: default:
#ifdef DEBUG #ifdef DEBUG
printf("login: unknown packet %x! (from char).\n", RFIFOW(fd,0)); printf("login: unknown packet %x! (from char).\n", RFIFOW(fd,0));
#endif #endif
session[fd]->eof = 1; session[fd]->eof = 1;
} }
} }
return 0; return 0;
} }

View File

@ -1,2 +1,2 @@
int char_anti_freeze_system(int, unsigned int, int, int); int char_anti_freeze_system(int, unsigned int, int, int);
int parse_fromchar(int); int parse_fromchar(int);

View File

@ -1,370 +1,370 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <signal.h> #include <signal.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include "login.h" #include "login.h"
#include "char_int.h" #include "char_int.h"
//---------------------- //----------------------
// Client requesting login [Edit: Wizputer] // Client requesting login [Edit: Wizputer]
//---------------------- //----------------------
void client_request_login(int fd,unsigned char *p ) { void client_request_login(int fd,unsigned char *p ) {
struct mmo_account account; struct mmo_account account;
char t_uid[32]; char t_uid[32];
int server_num = 0,result,i; int server_num = 0,result,i;
if( !servers_connected) { if( !servers_connected) {
WFIFOW(fd,0) = 0x81; WFIFOW(fd,0) = 0x81;
WFIFOL(fd,2) = 1; // 01 = Server closed WFIFOL(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3); WFIFOSET(fd,3);
} }
#ifdef DEBUG #ifdef DEBUG
printf("client connection request %s from %d.%d.%d.%d\n", RFIFOP(fd, 6), p[0], p[1], p[2], p[3]); printf("client connection request %s from %d.%d.%d.%d\n", RFIFOP(fd, 6), p[0], p[1], p[2], p[3]);
#endif #endif
account.userid = RFIFOP(fd, 6); account.userid = RFIFOP(fd, 6);
account.passwd = RFIFOP(fd, 30); account.passwd = RFIFOP(fd, 30);
#ifdef PASSWORDENC #ifdef PASSWORDENC
account.passwdenc= (RFIFOW(fd,0)==0x64)?0:PASSWORDENC; account.passwdenc= (RFIFOW(fd,0)==0x64)?0:PASSWORDENC;
#else #else
account.passwdenc=0; account.passwdenc=0;
#endif #endif
result=mmo_auth(&account, fd); result=mmo_auth(&account, fd);
jstrescapecpy(t_uid,RFIFOP(fd, 6)); jstrescapecpy(t_uid,RFIFOP(fd, 6));
if(result==-1){ if(result==-1){
unsigned char gm_level = isGM(account.account_id); unsigned char gm_level = isGM(account.account_id);
if (min_level_to_connect > gm_level || !servers_connected) { if (min_level_to_connect > gm_level || !servers_connected) {
WFIFOW(fd,0) = 0x81; WFIFOW(fd,0) = 0x81;
WFIFOL(fd,2) = 1; // 01 = Server closed WFIFOL(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3); WFIFOSET(fd,3);
} else { } else {
if (p[0] != 127) { if (p[0] != 127) {
sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%d.%d.%d.%d', '%s','100', 'login ok')", loginlog_db, p[0], p[1], p[2], p[3], t_uid); sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%d.%d.%d.%d', '%s','100', 'login ok')", loginlog_db, p[0], p[1], p[2], p[3], t_uid);
sql_query(tmpsql,"client_request_login"); sql_query(tmpsql,"client_request_login");
} }
if (gm_level) { if (gm_level) {
#ifdef DEBUG #ifdef DEBUG
printf("Connection of the GM (level:%d) account '%s' accepted.\n", gm_level, account.userid); printf("Connection of the GM (level:%d) account '%s' accepted.\n", gm_level, account.userid);
#endif #endif
} else { } else {
#ifdef DEBUG #ifdef DEBUG
printf("Connection of the account '%s' accepted.\n", account.userid); printf("Connection of the account '%s' accepted.\n", account.userid);
#endif #endif
} }
for(i = 0; i < MAX_SERVERS || server_num < servers_connected ; i++) for(i = 0; i < MAX_SERVERS || server_num < servers_connected ; i++)
if (server_fd[i] >= 0) { if (server_fd[i] >= 0) {
//Lan check added by Kashy //Lan check added by Kashy
if (lan_ip_check(p)) if (lan_ip_check(p))
WFIFOL(fd,47+server_num*32) = inet_addr(lan_char_ip); WFIFOL(fd,47+server_num*32) = inet_addr(lan_char_ip);
else else
WFIFOL(fd,47+server_num*32) = server[i].ip; WFIFOL(fd,47+server_num*32) = server[i].ip;
WFIFOW(fd,47+server_num*32+4) = server[i].port; WFIFOW(fd,47+server_num*32+4) = server[i].port;
memcpy(WFIFOP(fd,47+server_num*32+6), server[i].name, 20); memcpy(WFIFOP(fd,47+server_num*32+6), server[i].name, 20);
WFIFOW(fd,47+server_num*32+26) = server[i].users; WFIFOW(fd,47+server_num*32+26) = server[i].users;
WFIFOW(fd,47+server_num*32+28) = server[i].maintenance; WFIFOW(fd,47+server_num*32+28) = server[i].maintenance;
WFIFOW(fd,47+server_num*32+30) = server[i].new; WFIFOW(fd,47+server_num*32+30) = server[i].new;
server_num++; server_num++;
} }
WFIFOW(fd,0)=0x69; WFIFOW(fd,0)=0x69;
WFIFOW(fd,2)=47+32*server_num; WFIFOW(fd,2)=47+32*server_num;
WFIFOL(fd,4)=account.login_id1; WFIFOL(fd,4)=account.login_id1;
WFIFOL(fd,8)=account.account_id; WFIFOL(fd,8)=account.account_id;
WFIFOL(fd,12)=account.login_id2; WFIFOL(fd,12)=account.login_id2;
WFIFOL(fd,16)=0; WFIFOL(fd,16)=0;
memcpy(WFIFOP(fd,20),account.lastlogin,24); memcpy(WFIFOP(fd,20),account.lastlogin,24);
WFIFOB(fd,46)=account.sex; WFIFOB(fd,46)=account.sex;
WFIFOSET(fd,47+32*server_num); WFIFOSET(fd,47+32*server_num);
if(auth_fifo_pos>=AUTH_FIFO_SIZE) if(auth_fifo_pos>=AUTH_FIFO_SIZE)
auth_fifo_pos=0; auth_fifo_pos=0;
auth_fifo[auth_fifo_pos].account_id=account.account_id; auth_fifo[auth_fifo_pos].account_id=account.account_id;
auth_fifo[auth_fifo_pos].login_id1=account.login_id1; auth_fifo[auth_fifo_pos].login_id1=account.login_id1;
auth_fifo[auth_fifo_pos].login_id2=account.login_id2; auth_fifo[auth_fifo_pos].login_id2=account.login_id2;
auth_fifo[auth_fifo_pos].sex=account.sex; auth_fifo[auth_fifo_pos].sex=account.sex;
auth_fifo[auth_fifo_pos].delflag=0; auth_fifo[auth_fifo_pos].delflag=0;
auth_fifo[auth_fifo_pos].ip = session[fd]->client_addr.sin_addr.s_addr; auth_fifo[auth_fifo_pos].ip = session[fd]->client_addr.sin_addr.s_addr;
auth_fifo_pos++; auth_fifo_pos++;
} }
} else { } else {
char error[32]; char error[32];
sprintf(tmpsql,"SELECT `error` FROM `errors` WHERE `result`='%d'",result); sprintf(tmpsql,"SELECT `error` FROM `errors` WHERE `result`='%d'",result);
sql_query(tmpsql,"client_request_login"); sql_query(tmpsql,"client_request_login");
if ((sql_res = mysql_store_result(&mysql_handle))) { if ((sql_res = mysql_store_result(&mysql_handle))) {
if ((sql_row = mysql_fetch_row(sql_res))) { if ((sql_row = mysql_fetch_row(sql_res))) {
sprintf(error,sql_row[0]); sprintf(error,sql_row[0]);
} else { } else {
sprintf(error,"No Error!"); sprintf(error,"No Error!");
} }
} }
sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%d.%d.%d.%d', '%s', '%d','login failed : %s')", loginlog_db, p[0], p[1], p[2], p[3], t_uid, result, error); sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%d.%d.%d.%d', '%s', '%d','login failed : %s')", loginlog_db, p[0], p[1], p[2], p[3], t_uid, result, error);
sql_query(tmpsql,"client_request_login"); sql_query(tmpsql,"client_request_login");
if ((result == 1) && (dynamic_pass_failure_ban != 0)){ // failed password if ((result == 1) && (dynamic_pass_failure_ban != 0)){ // failed password
sprintf(tmpsql,"SELECT count(*) FROM `%s` WHERE `ip` = '%d.%d.%d.%d' AND `rcode` = '1' AND `time` > NOW() - INTERVAL %d MINUTE", sprintf(tmpsql,"SELECT count(*) FROM `%s` WHERE `ip` = '%d.%d.%d.%d' AND `rcode` = '1' AND `time` > NOW() - INTERVAL %d MINUTE",
loginlog_db, p[0], p[1], p[2], p[3], dynamic_pass_failure_ban_time); //how many times filed account? in one ip. loginlog_db, p[0], p[1], p[2], p[3], dynamic_pass_failure_ban_time); //how many times filed account? in one ip.
sql_query(tmpsql,"client_request_login"); sql_query(tmpsql,"client_request_login");
if ((sql_res = mysql_store_result(&mysql_handle))) { if ((sql_res = mysql_store_result(&mysql_handle))) {
if ((sql_row = mysql_fetch_row(sql_res))) { if ((sql_row = mysql_fetch_row(sql_res))) {
if (atoi(sql_row[0]) >= dynamic_pass_failure_ban_how_many ) { if (atoi(sql_row[0]) >= dynamic_pass_failure_ban_how_many ) {
sprintf(tmpsql,"INSERT INTO `ipbanlist`(`list`,`btime`,`rtime`,`reason`) VALUES ('%d.%d.%d.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban: %s')", p[0], p[1], p[2], dynamic_pass_failure_ban_how_long, t_uid); sprintf(tmpsql,"INSERT INTO `ipbanlist`(`list`,`btime`,`rtime`,`reason`) VALUES ('%d.%d.%d.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban: %s')", p[0], p[1], p[2], dynamic_pass_failure_ban_how_long, t_uid);
sql_query(tmpsql,"client_request_login"); sql_query(tmpsql,"client_request_login");
} }
} }
} }
mysql_free_result(sql_res); mysql_free_result(sql_res);
} }
//cannot connect login failed //cannot connect login failed
memset(WFIFOP(fd,0),'\0',23); memset(WFIFOP(fd,0),'\0',23);
WFIFOW(fd,0)=0x6a; WFIFOW(fd,0)=0x6a;
WFIFOB(fd,2)=result-1; WFIFOB(fd,2)=result-1;
if (result == 6) { // 6 = Your are Prohibited to log in until %s if (result == 6) { // 6 = Your are Prohibited to log in until %s
char tmpstr[256]; char tmpstr[256];
strftime(tmpstr, 20, date_format, localtime(&account.ban_until_time)); strftime(tmpstr, 20, date_format, localtime(&account.ban_until_time));
tmpstr[19] = '\0'; tmpstr[19] = '\0';
memcpy(WFIFOP(fd,3), tmpstr, 20); memcpy(WFIFOP(fd,3), tmpstr, 20);
} else { // we send error message } else { // we send error message
memcpy(WFIFOP(fd,3), error, 20); memcpy(WFIFOP(fd,3), error, 20);
} }
} }
WFIFOSET(fd,23); WFIFOSET(fd,23);
RFIFOSKIP(fd,(RFIFOW(fd,0)==0x64)?55:47); RFIFOSKIP(fd,(RFIFOW(fd,0)==0x64)?55:47);
} }
//------------------------------------------------------ //------------------------------------------------------
// MD5 Key requested for encypted login [Edit: Wizputer // MD5 Key requested for encypted login [Edit: Wizputer
//------------------------------------------------------ //------------------------------------------------------
void md5_key_request(int fd) { void md5_key_request(int fd) {
#ifdef DEBUG #ifdef DEBUG
printf("Request Password key -%s\n",md5key); printf("Request Password key -%s\n",md5key);
#endif #endif
RFIFOSKIP(fd,2); RFIFOSKIP(fd,2);
WFIFOW(fd,0)=0x01dc; WFIFOW(fd,0)=0x01dc;
WFIFOW(fd,2)=4+md5keylen; WFIFOW(fd,2)=4+md5keylen;
memcpy(WFIFOP(fd,4),md5key,md5keylen); memcpy(WFIFOP(fd,4),md5key,md5keylen);
WFIFOSET(fd,WFIFOW(fd,2)); WFIFOSET(fd,WFIFOW(fd,2));
} }
//---------------------------------------------------- //----------------------------------------------------
// Char-server requesting connection [Edit: Wizputer] // Char-server requesting connection [Edit: Wizputer]
//----------------------------------------------------- //-----------------------------------------------------
void char_request_login(int fd, unsigned char *p) { void char_request_login(int fd, unsigned char *p) {
struct mmo_account account; struct mmo_account account;
unsigned char* server_name; unsigned char* server_name;
char t_uid[32]; char t_uid[32];
int result; int result;
sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%d.%d.%d.%d', '%s@%s','100', 'charserver - %s@%d.%d.%d.%d:%d')", loginlog_db, p[0], p[1], p[2], p[3], RFIFOP(fd, 2),RFIFOP(fd, 60),RFIFOP(fd, 60), RFIFOB(fd, 54), RFIFOB(fd, 55), RFIFOB(fd, 56), RFIFOB(fd, 57), RFIFOW(fd, 58)); sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%d.%d.%d.%d', '%s@%s','100', 'charserver - %s@%d.%d.%d.%d:%d')", loginlog_db, p[0], p[1], p[2], p[3], RFIFOP(fd, 2),RFIFOP(fd, 60),RFIFOP(fd, 60), RFIFOB(fd, 54), RFIFOB(fd, 55), RFIFOB(fd, 56), RFIFOB(fd, 57), RFIFOW(fd, 58));
sql_query(tmpsql,"char_request_login"); sql_query(tmpsql,"char_request_login");
#ifdef DEBUG #ifdef DEBUG
printf("server connection request %s @ %d.%d.%d.%d:%d (%d.%d.%d.%d)\n", printf("server connection request %s @ %d.%d.%d.%d:%d (%d.%d.%d.%d)\n",
RFIFOP(fd, 60), RFIFOB(fd, 54), RFIFOB(fd, 55), RFIFOB(fd, 56), RFIFOB(fd, 57), RFIFOW(fd, 58), RFIFOP(fd, 60), RFIFOB(fd, 54), RFIFOB(fd, 55), RFIFOB(fd, 56), RFIFOB(fd, 57), RFIFOW(fd, 58),
p[0], p[1], p[2], p[3]); p[0], p[1], p[2], p[3]);
#endif #endif
account.userid = RFIFOP(fd, 2); account.userid = RFIFOP(fd, 2);
account.passwd = RFIFOP(fd, 26); account.passwd = RFIFOP(fd, 26);
account.passwdenc = 0; account.passwdenc = 0;
server_name = RFIFOP(fd,60); server_name = RFIFOP(fd,60);
result = mmo_auth(&account, fd); result = mmo_auth(&account, fd);
#ifdef DEBUG #ifdef DEBUG
printf("Result: %d - Sex: %d - Account ID: %d\n",result,account.sex,(int) account.account_id); printf("Result: %d - Sex: %d - Account ID: %d\n",result,account.sex,(int) account.account_id);
#endif #endif
if(result == -1 && account.sex==2 && account.account_id<MAX_SERVERS && server_fd[account.account_id]==-1){ if(result == -1 && account.sex==2 && account.account_id<MAX_SERVERS && server_fd[account.account_id]==-1){
printf("Connection of the char-server '%s' accepted.\n", server_name); printf("Connection of the char-server '%s' accepted.\n", server_name);
memset(&server[account.account_id], 0, sizeof(struct mmo_char_server)); memset(&server[account.account_id], 0, sizeof(struct mmo_char_server));
server[account.account_id].ip=RFIFOL(fd,54); server[account.account_id].ip=RFIFOL(fd,54);
server[account.account_id].port=RFIFOW(fd,58); server[account.account_id].port=RFIFOW(fd,58);
memcpy(server[account.account_id].name,RFIFOP(fd,60),20); memcpy(server[account.account_id].name,RFIFOP(fd,60),20);
server[account.account_id].users=0; server[account.account_id].users=0;
server[account.account_id].maintenance=RFIFOW(fd,82); server[account.account_id].maintenance=RFIFOW(fd,82);
server[account.account_id].new=RFIFOW(fd,84); server[account.account_id].new=RFIFOW(fd,84);
server_fd[account.account_id]=fd; server_fd[account.account_id]=fd;
if(anti_freeze_enable) if(anti_freeze_enable)
server_freezeflag[account.account_id] = 5; // Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed server_freezeflag[account.account_id] = 5; // Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed
jstrescapecpy(t_uid,server[account.account_id].name); jstrescapecpy(t_uid,server[account.account_id].name);
sprintf(tmpsql,"REPLACE DELAYED INTO `sstatus`(`index`,`name`,`user`) VALUES ( '%ld', '%s', '%d')", sprintf(tmpsql,"REPLACE DELAYED INTO `sstatus`(`index`,`name`,`user`) VALUES ( '%ld', '%s', '%d')",
account.account_id, server[account.account_id].name,0); account.account_id, server[account.account_id].name,0);
sql_query(tmpsql,"char_request_login"); sql_query(tmpsql,"char_request_login");
WFIFOW(fd,0)=0x2711; WFIFOW(fd,0)=0x2711;
WFIFOB(fd,2)=0; WFIFOB(fd,2)=0;
WFIFOSET(fd,3); WFIFOSET(fd,3);
session[fd]->func_parse=parse_fromchar; session[fd]->func_parse=parse_fromchar;
realloc_fifo(fd,FIFOSIZE_SERVERLINK,FIFOSIZE_SERVERLINK); realloc_fifo(fd,FIFOSIZE_SERVERLINK,FIFOSIZE_SERVERLINK);
servers_connected++; servers_connected++;
} else { } else {
WFIFOW(fd, 0) =0x2711; WFIFOW(fd, 0) =0x2711;
WFIFOB(fd, 2)=3; WFIFOB(fd, 2)=3;
WFIFOSET(fd, 3); WFIFOSET(fd, 3);
} }
RFIFOSKIP(fd, 86); RFIFOSKIP(fd, 86);
} }
//--------------------------------------------- //---------------------------------------------
// Athena Version Info Request [Edit: Wizputer] // Athena Version Info Request [Edit: Wizputer]
//--------------------------------------------- //---------------------------------------------
void request_athena_info(int fd) { void request_athena_info(int fd) {
#ifdef DEBUG #ifdef DEBUG
printf ("Athena version check...\n"); printf ("Athena version check...\n");
#endif #endif
WFIFOW(fd,0)=0x7531; WFIFOW(fd,0)=0x7531;
WFIFOB(fd,2)=ATHENA_MAJOR_VERSION; WFIFOB(fd,2)=ATHENA_MAJOR_VERSION;
WFIFOB(fd,3)=ATHENA_MINOR_VERSION; WFIFOB(fd,3)=ATHENA_MINOR_VERSION;
WFIFOB(fd,4)=ATHENA_REVISION; WFIFOB(fd,4)=ATHENA_REVISION;
WFIFOB(fd,5)=ATHENA_RELEASE_FLAG; WFIFOB(fd,5)=ATHENA_RELEASE_FLAG;
WFIFOB(fd,6)=ATHENA_OFFICIAL_FLAG; WFIFOB(fd,6)=ATHENA_OFFICIAL_FLAG;
WFIFOB(fd,7)=ATHENA_SERVER_LOGIN; WFIFOB(fd,7)=ATHENA_SERVER_LOGIN;
WFIFOW(fd,8)=ATHENA_MOD_VERSION; WFIFOW(fd,8)=ATHENA_MOD_VERSION;
WFIFOSET(fd,10); WFIFOSET(fd,10);
RFIFOSKIP(fd,2); RFIFOSKIP(fd,2);
} }
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// Default packet parsing (normal players or administation/char-server connection requests) // Default packet parsing (normal players or administation/char-server connection requests)
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
int parse_login(int fd) { int parse_login(int fd) {
char ip[16]; char ip[16];
unsigned char *p = (unsigned char *) &session[fd]->client_addr.sin_addr; unsigned char *p = (unsigned char *) &session[fd]->client_addr.sin_addr;
sprintf(ip, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); sprintf(ip, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
if (ipban > 0) { if (ipban > 0) {
//ip ban //ip ban
//p[0], p[1], p[2], p[3] //p[0], p[1], p[2], p[3]
//request DB connection //request DB connection
//check //check
sprintf(tmpsql, "SELECT count(*) FROM `ipbanlist` WHERE `list` = '%d.*.*.*' OR `list` = '%d.%d.*.*' OR `list` = '%d.%d.%d.*' OR `list` = '%d.%d.%d.%d'", sprintf(tmpsql, "SELECT count(*) FROM `ipbanlist` WHERE `list` = '%d.*.*.*' OR `list` = '%d.%d.*.*' OR `list` = '%d.%d.%d.*' OR `list` = '%d.%d.%d.%d'",
p[0], p[0], p[1], p[0], p[1], p[2], p[0], p[1], p[2], p[3]); p[0], p[0], p[1], p[0], p[1], p[2], p[0], p[1], p[2], p[3]);
sql_query(tmpsql,"parse_login"); sql_query(tmpsql,"parse_login");
if((sql_res = mysql_store_result(&mysql_handle))) { if((sql_res = mysql_store_result(&mysql_handle))) {
if((sql_row = mysql_fetch_row(sql_res))) {//row fetching if((sql_row = mysql_fetch_row(sql_res))) {//row fetching
if (atoi(sql_row[0]) >0) { if (atoi(sql_row[0]) >0) {
// ip ban ok. // ip ban ok.
printf ("packet from banned ip : %d.%d.%d.%d" RETCODE, p[0], p[1], p[2], p[3]); printf ("packet from banned ip : %d.%d.%d.%d" RETCODE, p[0], p[1], p[2], p[3]);
sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%d.%d.%d.%d', 'unknown','-3', 'ip banned')", loginlog_db, p[0], p[1], p[2], p[3]); sprintf(tmpsql,"INSERT DELAYED INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%d.%d.%d.%d', 'unknown','-3', 'ip banned')", loginlog_db, p[0], p[1], p[2], p[3]);
sql_query(tmpsql,"parse_login"); sql_query(tmpsql,"parse_login");
#ifdef DEBUG #ifdef DEBUG
printf ("close session connection...\n"); printf ("close session connection...\n");
#endif #endif
// close connection // close connection
session[fd]->eof = 1; session[fd]->eof = 1;
} else { } else {
#ifdef DEBUG #ifdef DEBUG
printf ("packet from ip (ban check ok) : %d.%d.%d.%d" RETCODE, p[0], p[1], p[2], p[3]); printf ("packet from ip (ban check ok) : %d.%d.%d.%d" RETCODE, p[0], p[1], p[2], p[3]);
#endif #endif
} }
} }
} }
mysql_free_result(sql_res); mysql_free_result(sql_res);
} }
if (session[fd]->eof) { if (session[fd]->eof) {
int i; int i;
for(i = 0; i < MAX_SERVERS && i < servers_connected; i++) for(i = 0; i < MAX_SERVERS && i < servers_connected; i++)
if (server_fd[i] == fd) { if (server_fd[i] == fd) {
server_fd[i] = -1; server_fd[i] = -1;
servers_connected--; servers_connected--;
} }
close(fd); close(fd);
delete_session(fd); delete_session(fd);
return 0; return 0;
} }
while(RFIFOREST(fd)>=2){ while(RFIFOREST(fd)>=2){
#ifdef DEBUG_PACKETS #ifdef DEBUG_PACKETS
printf("parse_login : %d %d packet case=%x\n", fd, RFIFOREST(fd), RFIFOW(fd,0)); printf("parse_login : %d %d packet case=%x\n", fd, RFIFOREST(fd), RFIFOW(fd,0));
#endif #endif
switch(RFIFOW(fd,0)){ switch(RFIFOW(fd,0)){
case 0x200: // New alive packet: structure: 0x200 <account.userid>.24B. used to verify if client is always alive. case 0x200: // New alive packet: structure: 0x200 <account.userid>.24B. used to verify if client is always alive.
if (RFIFOREST(fd) < 26) if (RFIFOREST(fd) < 26)
return 0; return 0;
RFIFOSKIP(fd,26); RFIFOSKIP(fd,26);
break; break;
case 0x204: // New alive packet: structure: 0x204 <encrypted.account.userid>.16B. (new ragexe from 22 june 2004) case 0x204: // New alive packet: structure: 0x204 <encrypted.account.userid>.16B. (new ragexe from 22 june 2004)
if (RFIFOREST(fd) < 18) if (RFIFOREST(fd) < 18)
return 0; return 0;
RFIFOSKIP(fd,18); RFIFOSKIP(fd,18);
break; break;
case 0x64: case 0x64:
case 0x01dd: case 0x01dd:
if(RFIFOREST(fd)< ((RFIFOW(fd, 0) ==0x64)?55:47)) if(RFIFOREST(fd)< ((RFIFOW(fd, 0) ==0x64)?55:47))
return 0; return 0;
client_request_login(fd, p); client_request_login(fd, p);
break; break;
case 0x01db: case 0x01db:
if (session[fd]->session_data) { if (session[fd]->session_data) {
#ifdef DEBUG #ifdef DEBUG
printf("login: abnormal request of MD5 key (already opened session).\n"); printf("login: abnormal request of MD5 key (already opened session).\n");
#endif #endif
session[fd]->eof = 1; session[fd]->eof = 1;
return 0; return 0;
} }
md5_key_request(fd); md5_key_request(fd);
break; break;
case 0x2710: case 0x2710:
if(RFIFOREST(fd)<86) if(RFIFOREST(fd)<86)
return 0; return 0;
char_request_login(fd,p); char_request_login(fd,p);
break; break;
case 0x7530: case 0x7530:
request_athena_info(fd); request_athena_info(fd);
break; break;
case 0x7532: case 0x7532:
default: default:
#ifdef DEBUG #ifdef DEBUG
printf ("End of connection (ip: %s)" RETCODE, ip); printf ("End of connection (ip: %s)" RETCODE, ip);
#endif #endif
session[fd]->eof = 1; session[fd]->eof = 1;
return 0; return 0;
} }
} }
return 0; return 0;
} }

View File

@ -1 +1 @@
int parse_login(int); int parse_login(int);

File diff suppressed because it is too large Load Diff

View File

@ -1,50 +1,50 @@
#ifndef _CHARCOMMAND_H_ #ifndef _CHARCOMMAND_H_
#define _CHARCOMMAND_H_ #define _CHARCOMMAND_H_
enum CharCommandType { enum CharCommandType {
CharCommand_None = -1, CharCommand_None = -1,
CharCommandJobChange, CharCommandJobChange,
CharCommandPetRename, CharCommandPetRename,
CharCommandPetFriendly, CharCommandPetFriendly,
CharCommandReset, CharCommandReset,
CharCommandStats, CharCommandStats,
CharCommandOption, CharCommandOption,
CharCommandSave, CharCommandSave,
CharCommandStatsAll, CharCommandStatsAll,
#ifdef TXT_ONLY #ifdef TXT_ONLY
/* TXT_ONLY */ /* TXT_ONLY */
/* TXT_ONLY */ /* TXT_ONLY */
#else #else
/* SQL-only */ /* SQL-only */
/* SQL Only */ /* SQL Only */
#endif #endif
// End. No more commans after this line. // End. No more commans after this line.
CharCommand_Unknown, CharCommand_Unknown,
CharCommand_MAX CharCommand_MAX
}; };
typedef enum CharCommandType CharCommandType; typedef enum CharCommandType CharCommandType;
typedef struct CharCommandInfo { typedef struct CharCommandInfo {
CharCommandType type; CharCommandType type;
const char* command; const char* command;
int level; int level;
int (*proc)(const int, struct map_session_data*, int (*proc)(const int, struct map_session_data*,
const char* command, const char* message); const char* command, const char* message);
} CharCommandInfo; } CharCommandInfo;
CharCommandType CharCommandType
is_charcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl); is_charcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl);
CharCommandType charcommand( CharCommandType charcommand(
const int level, const char* message, CharCommandInfo* info); const int level, const char* message, CharCommandInfo* info);
int get_charcommand_level(const CharCommandType type); int get_charcommand_level(const CharCommandType type);
int charcommand_config_read(const char *cfgName); int charcommand_config_read(const char *cfgName);
#endif #endif

View File

@ -1,3 +1,3 @@
Date Added Date Added
12/3 12/3
* Creation of eAthena Web Server v2 [MC Cameri] * Creation of eAthena Web Server v2 [MC Cameri]

View File

@ -1,32 +1,32 @@
CC = gcc -pipe CC = gcc -pipe
MAKE = make MAKE = make
OPT = -g -O2 -ffast-math OPT = -g -O2 -ffast-math
ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN) ifeq ($(findstring CYGWIN,$(PLATFORM)), CYGWIN)
CFLAGS = $(OPT) -Wall -I../common CFLAGS = $(OPT) -Wall -I../common
else else
CFLAGS = $(OPT) -Wall -I../common CFLAGS = $(OPT) -Wall -I../common
endif endif
OBJ = main.o webserver.o ../common/showmsg.o OBJ = main.o webserver.o ../common/showmsg.o
LINKOBJ = main.o webserver.o ../common/showmsg.o LINKOBJ = main.o webserver.o ../common/showmsg.o
all: clean webserver run all: clean webserver run
clean: clean:
rm -f *.o webserver.exe ../common/showmsg.o rm -f *.o webserver.exe ../common/showmsg.o
webserver: main.o webserver.o ../common/showmsg.o webserver: main.o webserver.o ../common/showmsg.o
$(CC) $(OPT) -o "Webserver.exe" $(OBJ) $(CC) $(OPT) -o "Webserver.exe" $(OBJ)
main.o: main.c main.o: main.c
$(CC) $(OPT) -c main.c -o main.o $(CFLAGS) $(CC) $(OPT) -c main.c -o main.o $(CFLAGS)
webserver.o: webserver.c webserver.o: webserver.c
$(CC) $(OPT) -c webserver.c -o webserver.o $(CFLAGS) $(CC) $(OPT) -c webserver.c -o webserver.o $(CFLAGS)
../common/showmsg.o: ../common/showmsg.c ../common/showmsg.o: ../common/showmsg.c
$(CC) $(OPT) -c ../common/showmsg.c -o ../common/showmsg.o $(CFLAGS) $(CC) $(OPT) -c ../common/showmsg.c -o ../common/showmsg.o $(CFLAGS)
run: run:
./webserver ./webserver

View File

@ -1,35 +1,35 @@
# Project: Webserver # Project: Webserver
# Makefile created by Dev-C++ 4.9.8.0 # Makefile created by Dev-C++ 4.9.8.0
CPP = g++.exe -D__DEBUG__ CPP = g++.exe -D__DEBUG__
CC = gcc.exe -D__DEBUG__ CC = gcc.exe -D__DEBUG__
WINDRES = windres.exe WINDRES = windres.exe
RES = RES =
OBJ = main.o webserver.o ../common/showmsg.o $(RES) OBJ = main.o webserver.o ../common/showmsg.o $(RES)
LINKOBJ = main.o webserver.o ../common/showmsg.o $(RES) LINKOBJ = main.o webserver.o ../common/showmsg.o $(RES)
LIBS = -L"C:/Program Files/Dev-Cpp/lib" -L"C:/cygwin/lib" LIBS = -L"C:/Program Files/Dev-Cpp/lib" -L"C:/cygwin/lib"
INCS = -I"C:/Program Files/Dev-Cpp/include" -I"C:/cygwin/usr/include" -I"C:/cygwin/usr/include/mingw" INCS = -I"C:/Program Files/Dev-Cpp/include" -I"C:/cygwin/usr/include" -I"C:/cygwin/usr/include/mingw"
CXXINCS = -I"C:/Program Files/Dev-Cpp/include/c++" -I"C:/Program Files/Dev-Cpp/include/c++/mingw32" -I"C:/Program Files/Dev-Cpp/include/c++/backward" -I"C:/Program Files/Dev-Cpp/include" -I"C:/cygwin/usr/include/c++/3.3.1" CXXINCS = -I"C:/Program Files/Dev-Cpp/include/c++" -I"C:/Program Files/Dev-Cpp/include/c++/mingw32" -I"C:/Program Files/Dev-Cpp/include/c++/backward" -I"C:/Program Files/Dev-Cpp/include" -I"C:/cygwin/usr/include/c++/3.3.1"
BIN = webserver.exe BIN = webserver.exe
CXXFLAGS = $(CXXINCS) -pg -g3 CXXFLAGS = $(CXXINCS) -pg -g3
CFLAGS = $(INCS) -pg -g3 CFLAGS = $(INCS) -pg -g3
.PHONY: all all-before all-after clean clean-custom .PHONY: all all-before all-after clean clean-custom
all: all-before webserver.exe all-after all: all-before webserver.exe all-after
clean: clean-custom clean: clean-custom
rm -f $(OBJ) $(BIN) rm -f $(OBJ) $(BIN)
$(BIN): $(LINKOBJ) $(BIN): $(LINKOBJ)
$(CC) $(LINKOBJ) -o "webserver.exe" $(LIBS) $(CC) $(LINKOBJ) -o "webserver.exe" $(LIBS)
main.o: main.c main.o: main.c
$(CC) -c main.c -o main.o $(CFLAGS) $(CC) -c main.c -o main.o $(CFLAGS)
webserver.o: webserver.c webserver.o: webserver.c
$(CC) -c webserver.c -o webserver.o $(CFLAGS) $(CC) -c webserver.c -o webserver.o $(CFLAGS)
../common/showmsg.o: ../common/showmsg.c ../common/showmsg.o: ../common/showmsg.c
$(CC) -c ../common/showmsg.c -o ../common/showmsg.o $(CFLAGS) $(CC) -c ../common/showmsg.c -o ../common/showmsg.o $(CFLAGS)

View File

@ -1,24 +1,24 @@
[Editors] [Editors]
Focused=-1 Focused=-1
Order=-1,0 Order=-1,0
[Editor_0] [Editor_0]
Open=1 Open=1
Top=0 Top=0
CursorCol=5 CursorCol=5
CursorRow=30 CursorRow=30
TopLine=1 TopLine=1
LeftChar=1 LeftChar=1
[Editor_1] [Editor_1]
Open=1 Open=1
Top=0 Top=0
CursorCol=1 CursorCol=1
CursorRow=35 CursorRow=35
TopLine=16 TopLine=16
LeftChar=1 LeftChar=1
[Editor_2] [Editor_2]
Open=1 Open=1
Top=1 Top=1
CursorCol=14 CursorCol=14
CursorRow=4 CursorRow=4
TopLine=1 TopLine=1
LeftChar=1 LeftChar=1

View File

@ -1,97 +1,97 @@
[Project] [Project]
FileName=Webserver.dev FileName=Webserver.dev
Name=Webserver Name=Webserver
UnitCount=5 UnitCount=5
Type=1 Type=1
Ver=1 Ver=1
ObjFiles= ObjFiles=
Includes= Includes=
Libs= Libs=
PrivateResource= PrivateResource=
ResourceIncludes= ResourceIncludes=
MakeIncludes= MakeIncludes=
Compiler= Compiler=
CppCompiler= CppCompiler=
Linker= Linker=
IsCpp=0 IsCpp=0
Icon= Icon=
ExeOutput= ExeOutput=
ObjectOutput= ObjectOutput=
OverrideOutput=1 OverrideOutput=1
OverrideOutputName=webserver.exe OverrideOutputName=webserver.exe
HostApplication= HostApplication=
Folders=common Folders=common
CommandLine= CommandLine=
IncludeVersionInfo=0 IncludeVersionInfo=0
SupportXPThemes=0 SupportXPThemes=0
CompilerSet=1 CompilerSet=1
CompilerSettings=000000000000000000 CompilerSettings=000000000000000000
[Unit1] [Unit1]
FileName=main.c FileName=main.c
CompileCpp=0 CompileCpp=0
Folder= Folder=
Compile=1 Compile=1
Link=1 Link=1
Priority=1000 Priority=1000
OverrideBuildCmd=0 OverrideBuildCmd=0
BuildCmd=$(CC) -c main.c -o main.o webserver.o $(CFLAGS) BuildCmd=$(CC) -c main.c -o main.o webserver.o $(CFLAGS)
[VersionInfo] [VersionInfo]
Major=0 Major=0
Minor=1 Minor=1
Release=1 Release=1
Build=1 Build=1
LanguageID=1033 LanguageID=1033
CharsetID=1252 CharsetID=1252
CompanyName= CompanyName=
FileVersion= FileVersion=
FileDescription=Developed using the Dev-C++ IDE FileDescription=Developed using the Dev-C++ IDE
InternalName= InternalName=
LegalCopyright= LegalCopyright=
LegalTrademarks= LegalTrademarks=
OriginalFilename= OriginalFilename=
ProductName= ProductName=
ProductVersion= ProductVersion=
AutoIncBuildNr=0 AutoIncBuildNr=0
[Unit2] [Unit2]
FileName=webserver.c FileName=webserver.c
CompileCpp=0 CompileCpp=0
Folder= Folder=
Compile=1 Compile=1
Link=1 Link=1
Priority=1000 Priority=1000
OverrideBuildCmd=1 OverrideBuildCmd=1
BuildCmd=$(CC) -c webserver.c -o webserver.o $(CFLAGS) BuildCmd=$(CC) -c webserver.c -o webserver.o $(CFLAGS)
[Unit3] [Unit3]
FileName=webserver.h FileName=webserver.h
CompileCpp=0 CompileCpp=0
Folder= Folder=
Compile=1 Compile=1
Link=1 Link=1
Priority=1000 Priority=1000
OverrideBuildCmd=0 OverrideBuildCmd=0
BuildCmd= BuildCmd=
[Unit4] [Unit4]
FileName=..\common\showmsg.c FileName=..\common\showmsg.c
CompileCpp=0 CompileCpp=0
Folder=common Folder=common
Compile=1 Compile=1
Link=1 Link=1
Priority=1000 Priority=1000
OverrideBuildCmd=0 OverrideBuildCmd=0
BuildCmd= BuildCmd=
[Unit5] [Unit5]
FileName=..\common\showmsg.h FileName=..\common\showmsg.h
CompileCpp=0 CompileCpp=0
Folder=common Folder=common
Compile=1 Compile=1
Link=1 Link=1
Priority=1000 Priority=1000
OverrideBuildCmd=0 OverrideBuildCmd=0
BuildCmd= BuildCmd=

View File

@ -1,38 +1,38 @@
[Editors] [Editors]
Focused=0 Focused=0
Order=0,2,1,-1 Order=0,2,1,-1
[Editor_0] [Editor_0]
Open=1 Open=1
Top=1 Top=1
CursorCol=55 CursorCol=55
CursorRow=128 CursorRow=128
TopLine=95 TopLine=95
LeftChar=1 LeftChar=1
[Editor_1] [Editor_1]
Open=1 Open=1
Top=0 Top=0
CursorCol=25 CursorCol=25
CursorRow=113 CursorRow=113
TopLine=92 TopLine=92
LeftChar=1 LeftChar=1
[Editor_2] [Editor_2]
Open=1 Open=1
Top=0 Top=0
CursorCol=1 CursorCol=1
CursorRow=21 CursorRow=21
TopLine=1 TopLine=1
LeftChar=1 LeftChar=1
[Editor_3] [Editor_3]
Open=0 Open=0
Top=0 Top=0
CursorCol=20 CursorCol=20
CursorRow=2 CursorRow=2
TopLine=1 TopLine=1
LeftChar=1 LeftChar=1
[Editor_4] [Editor_4]
Open=0 Open=0
Top=0 Top=0
CursorCol=20 CursorCol=20
CursorRow=1 CursorRow=1
TopLine=1 TopLine=1
LeftChar=1 LeftChar=1

View File

@ -1,36 +1,36 @@
############################################################# #############################################################
# ______ __ __ # # ______ __ __ #
# /\ _ \/\ \__/\ \ # # /\ _ \/\ \__/\ \ #
# __\ \ \L\ \ \ ,_\ \ \___ __ ___ __ # # __\ \ \L\ \ \ ,_\ \ \___ __ ___ __ #
# /'__`\ \ __ \ \ \/\ \ _ `\ /'__`\/' _ `\ /'__`\ # # /'__`\ \ __ \ \ \/\ \ _ `\ /'__`\/' _ `\ /'__`\ #
# /\ __/\ \ \/\ \ \ \_\ \ \ \ \/\ __//\ \/\ \/\ \L\.\_ # # /\ __/\ \ \/\ \ \ \_\ \ \ \ \/\ __//\ \/\ \/\ \L\.\_ #
# \ \____\\ \_\ \_\ \__\\ \_\ \_\ \____\ \_\ \_\ \__/.\_\ # # \ \____\\ \_\ \_\ \__\\ \_\ \_\ \____\ \_\ \_\ \__/.\_\ #
# \/____/ \/_/\/_/\/__/ \/_/\/_/\/____/\/_/\/_/\/__/\/_/ # # \/____/ \/_/\/_/\/__/ \/_/\/_/\/____/\/_/\/_/\/__/\/_/ #
# eAthena Web Server (Second Edition) # # eAthena Web Server (Second Edition) #
# by MC Cameri # # by MC Cameri #
# ------------------------------------------------------- # # ------------------------------------------------------- #
# -Website/Forum- # # -Website/Forum- #
# http://eathena.deltaanime.net/ # # http://eathena.deltaanime.net/ #
# -Download URL- # # -Download URL- #
# http://eathena.systeminplace.net/ # # http://eathena.systeminplace.net/ #
# -IRC Channel- # # -IRC Channel- #
# irc://irc.deltaanime.net/#athena # # irc://irc.deltaanime.net/#athena #
############################################################# #############################################################
// Display the eAthena Logo at startup? // Display the eAthena Logo at startup?
show_title: 1 show_title: 1
//Web Server Port //Web Server Port
port: 81 port: 81
//Web Server Password //Web Server Password
password: juan16 password: juan16
//Page Header //Page Header
header: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> header: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
//Document index //Document index
document_index: index.xhtml document_index: index.xhtml
//Send favorite icon if provided? //Send favorite icon if provided?
favicon: yes favicon: yes

View File

@ -1,144 +1,144 @@
/****************************************************************************** /******************************************************************************
# ______ __ __ # # ______ __ __ #
# /\ _ \/\ \__/\ \ # # /\ _ \/\ \__/\ \ #
# __\ \ \L\ \ \ ,_\ \ \___ __ ___ __ # # __\ \ \L\ \ \ ,_\ \ \___ __ ___ __ #
# /'__`\ \ __ \ \ \/\ \ _ `\ /'__`\/' _ `\ /'__`\ # # /'__`\ \ __ \ \ \/\ \ _ `\ /'__`\/' _ `\ /'__`\ #
# /\ __/\ \ \/\ \ \ \_\ \ \ \ \/\ __//\ \/\ \/\ \L\.\_ # # /\ __/\ \ \/\ \ \ \_\ \ \ \ \/\ __//\ \/\ \/\ \L\.\_ #
# \ \____\\ \_\ \_\ \__\\ \_\ \_\ \____\ \_\ \_\ \__/.\_\ # # \ \____\\ \_\ \_\ \__\\ \_\ \_\ \____\ \_\ \_\ \__/.\_\ #
# \/____/ \/_/\/_/\/__/ \/_/\/_/\/____/\/_/\/_/\/__/\/_/ # # \/____/ \/_/\/_/\/__/ \/_/\/_/\/____/\/_/\/_/\/__/\/_/ #
# eAthena Web Server (Second Edition) # # eAthena Web Server (Second Edition) #
# by MC Cameri # # by MC Cameri #
# ------------------------------------------------------- # # ------------------------------------------------------- #
# -Website/Forum- # # -Website/Forum- #
# http://eathena.deltaanime.net/ # # http://eathena.deltaanime.net/ #
# -Download URL- # # -Download URL- #
# http://eathena.systeminplace.net/ # # http://eathena.systeminplace.net/ #
# -IRC Channel- # # -IRC Channel- #
# irc://irc.deltaanime.net/#athena # # irc://irc.deltaanime.net/#athena #
******************************************************************************/ ******************************************************************************/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <strings.h> #include <strings.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include "../common/showmsg.h" #include "../common/showmsg.h"
#include "webserver.h" #include "webserver.h"
char ws_password[17]; char ws_password[17];
char ws_header[128]; char ws_header[128];
#define WEB_CONF "conf/webserver-athena.conf" #define WEB_CONF "conf/webserver-athena.conf"
#define MAX_CONNECTIONS 10 #define MAX_CONNECTIONS 10
#define HOME "home/" #define HOME "home/"
struct config config; struct config config;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int server_fd, client_fd; int server_fd, client_fd;
int sin_size; int sin_size;
struct sockaddr_in server_addr; struct sockaddr_in server_addr;
struct sockaddr_in client_addr; struct sockaddr_in client_addr;
struct sigaction sa; struct sigaction sa;
char recvin[1024]; char recvin[1024];
char path[1024]; char path[1024];
char line[1024]; char line[1024];
int optval = 1; int optval = 1;
if (ws_config_read(WEB_CONF)) exit(0); if (ws_config_read(WEB_CONF)) exit(0);
if (config.show_title) if (config.show_title)
ws_display_title(); ws_display_title();
else else
printf("eAthena Web Server (Second Edition)\n"); printf("eAthena Web Server (Second Edition)\n");
if (strcmpEx(ws_password,"webpass")==0) if (strcmpEx(ws_password,"webpass")==0)
ShowWarning("You are using the default password (webpass), we highly " ShowWarning("You are using the default password (webpass), we highly "
"recommend\n that you change it.\n"); "recommend\n that you change it.\n");
else if (strstr(ws_password,"webpass")) else if (strstr(ws_password,"webpass"))
ShowWarning("Your password should not contain \"webpass\" in it, it is" ShowWarning("Your password should not contain \"webpass\" in it, it is"
" highly\n recommended that you change it.\n"); " highly\n recommended that you change it.\n");
printf("Web Server Password: %s\n",ws_password); printf("Web Server Password: %s\n",ws_password);
printf("Web Server Port: %d\n",config.port); printf("Web Server Port: %d\n",config.port);
if ((server_fd = socket(AF_INET, SOCK_STREAM,0)) == -1) { if ((server_fd = socket(AF_INET, SOCK_STREAM,0)) == -1) {
ShowError("In main() -> Could not open socket.\n"); ShowError("In main() -> Could not open socket.\n");
return 1; return 1;
} }
if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(int)) == -1) { if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(int)) == -1) {
ShowError("In main() -> Could not set socket options.\n"); ShowError("In main() -> Could not set socket options.\n");
return 1; return 1;
} }
server_addr.sin_family = AF_INET; server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(config.port); server_addr.sin_port = htons(config.port);
server_addr.sin_addr.s_addr = INADDR_ANY; server_addr.sin_addr.s_addr = INADDR_ANY;
memset(&(server_addr.sin_zero), '\0', 8); memset(&(server_addr.sin_zero), '\0', 8);
if (bind(server_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) < 0) { if (bind(server_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) < 0) {
snprintf(tmp_output,sizeof(tmp_output),"In main() -> Could not bind to port number: %d\n",config.port); snprintf(tmp_output,sizeof(tmp_output),"In main() -> Could not bind to port number: %d\n",config.port);
ShowError(tmp_output); ShowError(tmp_output);
return 1; return 1;
} }
if (listen(server_fd, MAX_CONNECTIONS) < 0) { if (listen(server_fd, MAX_CONNECTIONS) < 0) {
snprintf(tmp_output,sizeof(tmp_output),"In main() -> Could not listen on port number: %d\n",config.port); snprintf(tmp_output,sizeof(tmp_output),"In main() -> Could not listen on port number: %d\n",config.port);
ShowError(tmp_output); ShowError(tmp_output);
return 1; return 1;
} }
sa.sa_handler = ws_sigchld_handler; sa.sa_handler = ws_sigchld_handler;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART; sa.sa_flags = SA_RESTART;
if (sigaction(SIGCHLD, &sa, NULL) < 0) { if (sigaction(SIGCHLD, &sa, NULL) < 0) {
ShowError("In main() -> Invalid sigaction.\n"); ShowError("In main() -> Invalid sigaction.\n");
return 1; return 1;
} }
ShowInfo("eAthena Web Server is now listening for incoming connections.\n"); ShowInfo("eAthena Web Server is now listening for incoming connections.\n");
while(1) while(1)
{ {
sin_size = sizeof(struct sockaddr_in); sin_size = sizeof(struct sockaddr_in);
client_fd = accept(server_fd, (struct sockaddr *)&client_addr, &sin_size); client_fd = accept(server_fd, (struct sockaddr *)&client_addr, &sin_size);
if (!fork()) if (!fork())
{ {
close(server_fd); close(server_fd);
memset(recvin, 0x0, 500); memset(recvin, 0x0, 500);
recv(client_fd, recvin, 500, 0); recv(client_fd, recvin, 500, 0);
char *html_output; char *html_output;
int count = 0; int count = 0;
if (sscanf(recvin,"GET %[a-zA-Z_-.+\%#@~] %*[^\n]",path)==1) { if (sscanf(recvin,"GET %[a-zA-Z_-.+\%#@~] %*[^\n]",path)==1) {
FILE *fp; FILE *fp;
strcpy(tmp_output,HOME); strcpy(tmp_output,HOME);
strcat(tmp_output,path); strcat(tmp_output,path);
fp = fopen(tmp_output,"r+"); fp = fopen(tmp_output,"r+");
if (fp==NULL) { if (fp==NULL) {
send(client_fd,"File not found",strlen("File not found"), 0); send(client_fd,"File not found",strlen("File not found"), 0);
close(client_fd); close(client_fd);
} }
memset(tmp_output,0x0,strlen(tmp_output)); memset(tmp_output,0x0,strlen(tmp_output));
html_output = (char*)malloc(sizeof(char)*2); html_output = (char*)malloc(sizeof(char)*2);
while (fgets(line,1023,fp)) { while (fgets(line,1023,fp)) {
html_output = (char*)realloc(sizeof(html_output)+(sizeof(char)*count)); html_output = (char*)realloc(sizeof(html_output)+(sizeof(char)*count));
strcat(html_output,line); strcat(html_output,line);
printf(line); printf(line);
} }
send(client_fd,tmp_output,sizeof(tmp_output),0); send(client_fd,tmp_output,sizeof(tmp_output),0);
fclose(fp); fclose(fp);
} }
// send(client_fd, ws_header, strlen(ws_header), 0); // send(client_fd, ws_header, strlen(ws_header), 0);
// generate_page(password, client_fd, get_query(recvin), inet_ntoa(client_addr.sin_addr)); // generate_page(password, client_fd, get_query(recvin), inet_ntoa(client_addr.sin_addr));
// log_visit(get_query(recvin), inet_ntoa(client_addr.sin_addr)); // log_visit(get_query(recvin), inet_ntoa(client_addr.sin_addr));
close(client_fd); close(client_fd);
exit(0); exit(0);
} }
close(client_fd); close(client_fd);
} }
return 0; return 0;
} }

View File

@ -1,136 +1,136 @@
/****************************************************************************** /******************************************************************************
# ______ __ __ # # ______ __ __ #
# /\ _ \/\ \__/\ \ # # /\ _ \/\ \__/\ \ #
# __\ \ \L\ \ \ ,_\ \ \___ __ ___ __ # # __\ \ \L\ \ \ ,_\ \ \___ __ ___ __ #
# /'__`\ \ __ \ \ \/\ \ _ `\ /'__`\/' _ `\ /'__`\ # # /'__`\ \ __ \ \ \/\ \ _ `\ /'__`\/' _ `\ /'__`\ #
# /\ __/\ \ \/\ \ \ \_\ \ \ \ \/\ __//\ \/\ \/\ \L\.\_ # # /\ __/\ \ \/\ \ \ \_\ \ \ \ \/\ __//\ \/\ \/\ \L\.\_ #
# \ \____\\ \_\ \_\ \__\\ \_\ \_\ \____\ \_\ \_\ \__/.\_\ # # \ \____\\ \_\ \_\ \__\\ \_\ \_\ \____\ \_\ \_\ \__/.\_\ #
# \/____/ \/_/\/_/\/__/ \/_/\/_/\/____/\/_/\/_/\/__/\/_/ # # \/____/ \/_/\/_/\/__/ \/_/\/_/\/____/\/_/\/_/\/__/\/_/ #
# eAthena Web Server (Second Edition) # # eAthena Web Server (Second Edition) #
# by MC Cameri # # by MC Cameri #
# ------------------------------------------------------- # # ------------------------------------------------------- #
# -Website/Forum- # # -Website/Forum- #
# http://eathena.deltaanime.net/ # # http://eathena.deltaanime.net/ #
# -Download URL- # # -Download URL- #
# http://eathena.systeminplace.net/ # # http://eathena.systeminplace.net/ #
# -IRC Channel- # # -IRC Channel- #
# irc://irc.deltaanime.net/#athena # # irc://irc.deltaanime.net/#athena #
******************************************************************************/ ******************************************************************************/
#include <stdio.h> #include <stdio.h>
#include <strings.h> #include <strings.h>
#include "../common/showmsg.h" #include "../common/showmsg.h"
#include "webserver.h" #include "webserver.h"
char ws_password[17] = "pass"; char ws_password[17] = "pass";
char ws_header[128] = {'\0'}; char ws_header[128] = {'\0'};
/* Displays the eAthena Logo */ /* Displays the eAthena Logo */
void ws_display_title(void) void ws_display_title(void)
{ {
printf("\033[2J"); printf("\033[2J");
printf("\033[37;44m (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)\033[K\033[0m\n"); printf("\033[37;44m (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)\033[K\033[0m\n");
printf("\033[0;44m (\033[1;33m (c)2004 eAthena Development Team presents \033[0;44m)\033[K\033[0m\n"); printf("\033[0;44m (\033[1;33m (c)2004 eAthena Development Team presents \033[0;44m)\033[K\033[0m\n");
printf("\033[0;44m (\033[1m ______ __ __ \033[0;44m)\033[K\033[0m\n"); printf("\033[0;44m (\033[1m ______ __ __ \033[0;44m)\033[K\033[0m\n");
printf("\033[0;44m (\033[1m /\\ _ \\/\\ \\__/\\ \\ \033[0;44m)\033[K\033[0m\n"); printf("\033[0;44m (\033[1m /\\ _ \\/\\ \\__/\\ \\ \033[0;44m)\033[K\033[0m\n");
printf("\033[0;44m (\033[1m __\\ \\ \\_\\ \\ \\ ,_\\ \\ \\___ __ ___ __ \033[0;44m)\033[K\033[0m\n"); printf("\033[0;44m (\033[1m __\\ \\ \\_\\ \\ \\ ,_\\ \\ \\___ __ ___ __ \033[0;44m)\033[K\033[0m\n");
printf("\033[0;44m (\033[1m /'__`\\ \\ __ \\ \\ \\/\\ \\ _ `\\ /'__`\\/' _ `\\ /'__`\\ \033[0;44m)\033[K\033[0m\n"); printf("\033[0;44m (\033[1m /'__`\\ \\ __ \\ \\ \\/\\ \\ _ `\\ /'__`\\/' _ `\\ /'__`\\ \033[0;44m)\033[K\033[0m\n");
printf("\033[0;44m (\033[1m /\\ __/\\ \\ \\/\\ \\ \\ \\_\\ \\ \\ \\ \\/\\ __//\\ \\/\\ \\/\\ \\_\\.\\_ \033[0;44m)\033[K\033[0m\n"); printf("\033[0;44m (\033[1m /\\ __/\\ \\ \\/\\ \\ \\ \\_\\ \\ \\ \\ \\/\\ __//\\ \\/\\ \\/\\ \\_\\.\\_ \033[0;44m)\033[K\033[0m\n");
printf("\033[0;44m (\033[1m \\ \\____\\\\ \\_\\ \\_\\ \\__\\\\ \\_\\ \\_\\ \\____\\ \\_\\ \\_\\ \\__/.\\_\\ \033[0;44m)\033[K\033[0m\n"); printf("\033[0;44m (\033[1m \\ \\____\\\\ \\_\\ \\_\\ \\__\\\\ \\_\\ \\_\\ \\____\\ \\_\\ \\_\\ \\__/.\\_\\ \033[0;44m)\033[K\033[0m\n");
printf("\033[0;44m (\033[1m \\/____/ \\/_/\\/_/\\/__/ \\/_/\\/_/\\/____/\\/_/\\/_/\\/__/\\/_/ \033[0;44m)\033[K\033[0m\n"); printf("\033[0;44m (\033[1m \\/____/ \\/_/\\/_/\\/__/ \\/_/\\/_/\\/____/\\/_/\\/_/\\/__/\\/_/ \033[0;44m)\033[K\033[0m\n");
printf("\033[0;44m (\033[1m _ _ _ _ _ _ _ _ _ _ _ _ _ \033[0;44m)\033[K\033[0m\n"); // 1: bold char, 0: normal char printf("\033[0;44m (\033[1m _ _ _ _ _ _ _ _ _ _ _ _ _ \033[0;44m)\033[K\033[0m\n"); // 1: bold char, 0: normal char
printf("\033[0;44m (\033[1m / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ \033[0;44m)\033[K\033[0m\n"); // 1: bold char, 0: normal char printf("\033[0;44m (\033[1m / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ / \\ \033[0;44m)\033[K\033[0m\n"); // 1: bold char, 0: normal char
printf("\033[0;44m (\033[1m ( e | n | g | l | i | s | h ) ( A | t | h | e | n | a ) \033[0;44m)\033[K\033[0m\n"); // 1: bold char, 0: normal char printf("\033[0;44m (\033[1m ( e | n | g | l | i | s | h ) ( A | t | h | e | n | a ) \033[0;44m)\033[K\033[0m\n"); // 1: bold char, 0: normal char
printf("\033[0;44m (\033[1m \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \033[0;44m)\033[K\033[0m\n"); // 1: bold char, 0: normal char printf("\033[0;44m (\033[1m \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \033[0;44m)\033[K\033[0m\n"); // 1: bold char, 0: normal char
printf("\033[0;44m (\033[1m \033[0;44m)\033[K\033[0m\n"); // yellow writing (33) printf("\033[0;44m (\033[1m \033[0;44m)\033[K\033[0m\n"); // yellow writing (33)
printf("\033[0;44m (\033[1;33m Advanced Fusion Maps (c) 2003-2004 The Fusion Project \033[0;44m)\033[K\033[0m\n"); // yellow writing (33) printf("\033[0;44m (\033[1;33m Advanced Fusion Maps (c) 2003-2004 The Fusion Project \033[0;44m)\033[K\033[0m\n"); // yellow writing (33)
printf("\033[37;44m (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)\033[K\033[0m\n\n"); // reset color printf("\033[37;44m (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)\033[K\033[0m\n\n"); // reset color
} }
/* Returns a boolean value given character string */ /* Returns a boolean value given character string */
int ws_config_switch(const char *str) { int ws_config_switch(const char *str) {
if (strcmpEx(str, "on") == 0 || strcmpEx(str, "yes") == 0 || if (strcmpEx(str, "on") == 0 || strcmpEx(str, "yes") == 0 ||
strcmpEx(str, "oui") == 0 || strcmpEx(str, "ja") == 0 || strcmpEx(str, "oui") == 0 || strcmpEx(str, "ja") == 0 ||
strcmpEx(str, "si") == 0 || strcmpEx(str,"true") == 0) strcmpEx(str, "si") == 0 || strcmpEx(str,"true") == 0)
return 1; return 1;
if (strcmpEx(str, "off") == 0 || strcmpEx(str, "no") == 0 || if (strcmpEx(str, "off") == 0 || strcmpEx(str, "no") == 0 ||
strcmpEx(str, "non") == 0 || strcmpEx(str, "nein") == 0 || strcmpEx(str, "non") == 0 || strcmpEx(str, "nein") == 0 ||
strcmpEx(str, "false") == 0) strcmpEx(str, "false") == 0)
return 0; return 0;
return atoi(str); return atoi(str);
} }
/* Reads the eAthena Web Server's configuration file */ /* Reads the eAthena Web Server's configuration file */
int ws_config_read(const char *cfgName) int ws_config_read(const char *cfgName)
{ {
int i; int i;
char line[1024],w1[1024],w2[1024],temp[1024]; char line[1024],w1[1024],w2[1024],temp[1024];
FILE *fp; FILE *fp;
/* Default values */ /* Default values */
config.show_title=0; config.show_title=0;
config.port=80; config.port=80;
fp=fopen(cfgName,"r"); fp=fopen(cfgName,"r");
if(fp==NULL){ if(fp==NULL){
snprintf(temp,sizeof(temp),"Could not open \033[1;29m%s\033[0;0m, file not found.\n",cfgName); snprintf(temp,sizeof(temp),"Could not open \033[1;29m%s\033[0;0m, file not found.\n",cfgName);
ShowMessage(temp,MSG_ERROR); ShowMessage(temp,MSG_ERROR);
return 1; return 1;
} }
while(fgets(line,1020,fp)){ while(fgets(line,1020,fp)){
const struct { const struct {
char str[128]; char str[128];
int *val; int *val;
} data[] ={ } data[] ={
//List of variables //List of variables
{ "show_title", &config.show_title }, { "show_title", &config.show_title },
{ "port", &config.port }, { "port", &config.port },
}; };
if((line[0] == '/' && line[1] == '/') || (line[0]=='#') || if((line[0] == '/' && line[1] == '/') || (line[0]=='#') ||
(sscanf(line,"%1023[^:]:%1023[^\n]",w1,w2) !=2)) (sscanf(line,"%1023[^:]:%1023[^\n]",w1,w2) !=2))
continue; continue;
for(i=0;i<sizeof(data)/(sizeof(data[0]));i++) { for(i=0;i<sizeof(data)/(sizeof(data[0]));i++) {
if(strcmpEx(w1,data[i].str)==0){ if(strcmpEx(w1,data[i].str)==0){
*data[i].val=ws_config_switch(w2); *data[i].val=ws_config_switch(w2);
break; break;
} }
} }
if(strcmpEx(w1,"import")==0) { if(strcmpEx(w1,"import")==0) {
ws_config_read(w2); ws_config_read(w2);
continue; continue;
} }
if(strcmpEx(w1,"password")==0) { if(strcmpEx(w1,"password")==0) {
if (strlen(w2)>16) { if (strlen(w2)>16) {
ShowError("The Web Server password is too long, maximum passwor" ShowError("The Web Server password is too long, maximum passwor"
"d length is 16 characters.\n"); "d length is 16 characters.\n");
return 1; return 1;
} }
strcpy(ws_password,w2); strcpy(ws_password,w2);
continue; continue;
} }
if(strcmpEx(w1,"header")==0) { if(strcmpEx(w1,"header")==0) {
if (strlen(w2)>127) { if (strlen(w2)>127) {
ShowError("The Web Server header is too long, maximum header" ShowError("The Web Server header is too long, maximum header"
"d length is 127 characters.\n"); "d length is 127 characters.\n");
return 1; return 1;
} }
strcpy(ws_header,w2); strcpy(ws_header,w2);
continue; continue;
} }
} }
fclose(fp); fclose(fp);
//Correct values //Correct values
if(config.show_title < 0) if(config.show_title < 0)
config.show_title = 0; config.show_title = 0;
if(config.port < 1 || config.port > 65534) if(config.port < 1 || config.port > 65534)
config.port=80; config.port=80;
return 0; return 0;
} }
void ws_sigchld_handler(int s) void ws_sigchld_handler(int s)
{ {
while(wait(NULL) > 0); while(wait(NULL) > 0);
} }

View File

@ -1,21 +1,21 @@
#ifndef WEBSERV_H_ #ifndef WEBSERV_H_
#define WEBSERV_H_ #define WEBSERV_H_
#define strcmpEx(x,y) (strcasecmp(x,y)) #define strcmpEx(x,y) (strcasecmp(x,y))
extern void ws_display_title(void); extern void ws_display_title(void);
extern int ws_config_read(const char *cfgName); extern int ws_config_read(const char *cfgName);
extern struct config { extern struct config {
int show_title; int show_title;
int port; int port;
} config; } config;
extern char ws_password[17]; //16 chars + \0 extern char ws_password[17]; //16 chars + \0
extern char ws_header[128]; //!? extern char ws_header[128]; //!?
extern void ws_sigchld_handler(int s); extern void ws_sigchld_handler(int s);
#endif #endif