summaryrefslogtreecommitdiff
path: root/src/tool/ladmin
blob: e3319d5de95187bb7c70c36190bc8351b767a04d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
#!/usr/bin/perl
use POSIX;
##########################################################################
# EAthena login-server remote administration tool
# New ladamin by [Yor]
##########################################################################
#-------------------------------INSTRUCTIONS------------------------------
# Set the 4 variables below:
#   IP of the login server.
#   Port where the login-server listens incoming packets.
#   Password of administration (same of config_athena.conf).
#   Displayed language of the sofware (if not correct, english is used).
# IMPORTANT:
#   Be sure that you authorize remote administration in login-server
#   (see login_athena.conf, 'admin_state' parameter)
#-------------------------------------------------------------------------
my($loginserverip) = "127.0.0.1";        # IP of login-server
my($loginserverport) = 6900;             # Port of login-server
my($loginserveradminpassword) = "admin"; # Administration password
my($connecttimeout) = 10;                # Timeout of connection (in seconds)
my($passenc) = 2;                        # Encoding type of the password
my($defaultlanguage) = "E";              # Default language (F: Fran�ais/E: English)
                                         # (if it's not 'F', default is English)

#-------------------------------------------------------------------------
#  LIST of COMMANDs that you can type at the prompt:
#    To use these commands you can only type only the first letters.
#    You must type a minimum of letters (you can not type 'a',
#      because ladmin doesn't know if it's for 'aide' or for 'add')
#    <Example> q <= quit, li <= list, pass <= passwd, etc.
#
#  Note: every time you must give a account_name, you can use "" or '' (spaces can be included)
#
#  aide/help/?
#    Display the description of the commands
#  aide/help/? [command]
#    Display the description of the specified command
#
#  add <account_name> <sex> <password>
#    Create an account with the default email (a@a.com).
#    Concerning the sex, only the first letter is used (F or M).
#    The e-mail is set to a@a.com (default e-mail). It's like to have no e-mail.
#    When the password is omitted, the input is done without displaying of the pressed keys.
#    <example> add testname Male testpass
#
#  ban/banish yyyy/mm/dd hh:mm:ss <account name>
#    Changes the final date of a banishment of an account.
#    Same command of banset, except that account_name is at end
#
#  banadd <account_name> <modifier>
#    Adds or substracts time from the final date of a banishment of an account.
#    Modifier is done as follows:
#      Adjustment value (-1, 1, +1, etc...)
#      Modified element:
#        a or y: year
#        m:  month
#        j or d: day
#        h:  hour
#        mn: minute
#        s:  second
#    <example> banadd testname +1m-2mn1s-6y
#              this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
#  NOTE: If you modify the final date of a non-banished account,
#        you fix the final date to (actual time +- adjustments)
#
#  banset <account_name> yyyy/mm/dd [hh:mm:ss]
#    Changes the final date of a banishment of an account.
#    Default time: 23:59:59
#  banset <account_name> 0
#    Set a non-banished account (0 = unbanished).
#
#  block <account name>
#    Set state 5 (You have been blocked by the GM Team) to an account.
#    Same command of state <account_name> 5.
#
#  check <account_name> <password>
#    Check the validity of a password for an account
#    NOTE: Server will never sends back a password.
#          It's the only method you have to know if a password is correct.
#          The other method is to have a ('physical') access to the accounts file.
#
#  create <account_name> <sex> <email> <password>
#    Like the 'add' command, but with e-mail moreover.
#    <example> create testname Male my@mail.com testpass
#
#  del <account name>
#    Remove an account.
#    This order requires confirmation. After confirmation, the account is deleted.
#
#  email <account_name> <email>
#    Modify the e-mail of an account.
#
#  getcount
#    Give the number of players online on all char-servers.
#
#  gm <account_name> [GM_level]
#    Modify the GM level of an account.
#    Default value remove GM level (GM level = 0).
#    <example> gm testname 80
#
#  id <account name>
#    Give the id of an account.
#
#  info <account_id>
#    Display complete information of an account.
#
#  kami <message>
#    Sends a broadcast message on all map-server (in yellow).
#  kamib <message>
#    Sends a broadcast message on all map-server (in blue).
#
#  language <language>
#    Change the language of displaying.
#
#  list/ls [start_id [end_id]]
#    Display a list of accounts.
#    'start_id', 'end_id': indicate end and start identifiers.
#    Research by name is not possible with this command.
#    <example> list 10 9999999
#
#  listBan/lsBan [start_id [end_id]]
#    Like list/ls, but only for accounts with state or banished
#
#  listGM/lsGM [start_id [end_id]]
#    Like list/ls, but only for GM accounts
#
#  listOK/lsOK [start_id [end_id]]
#    Like list/ls, but only for accounts without state and not banished
#
#  memo <account_name> <memo>
#    Modify the memo of an account.
#    'memo': it can have until 253 characters (with spaces or not).
#
#  name <account_id>
#    Give the name of an account.
#
#  passwd <account_name> <new_password>
#    Change the password of an account.
#    When new password is omitted, the input is done without displaying of the pressed keys.
#
#  quit/end/exit
#    End of the program of administration
#
#  reloadGM
#    Reload GM configuration file
#
#  search <expression>
#    Seek accounts.
#    Displays the accounts whose names correspond.
#  search -r/-e/--expr/--regex <expression>
#    Seek accounts by regular expression.
#    Displays the accounts whose names correspond.
#
#  sex <account_name> <sex>
#    Modify the sex of an account.
#    <example> sex testname Male
#
#  state <account_name> <new_state> <error_message_#7>
#    Change the state of an account.
#    'new_state': state is the state of the packet 0x006a + 1. The possibilities are:
#                 0 = Account ok            6 = Your Game's EXE file is not the latest version
#                 1 = Unregistered ID       7 = You are Prohibited to log in until %s
#                 2 = Incorrect Password    8 = Server is jammed due to over populated
#                 3 = This ID is expired    9 = No MSG
#                 4 = Rejected from Server  100 = This ID has been totally erased
#                 5 = You have been blocked by the GM Team
#                 all other values are 'No MSG', then use state 9 please.
#    'error_message_#7': message of the code error 6 = Your are Prohibited to log in until %s (packet 0x006a)
#
#  timeadd <account_name> <modifier>
#    Adds or substracts time from the validity limit of an account.
#    Modifier is done as follows:
#      Adjustment value (-1, 1, +1, etc...)
#      Modified element:
#        a or y: year
#        m:  month
#        j or d: day
#        h:  hour
#        mn: minute
#        s:  second
#    <example> timeadd testname +1m-2mn1s-6y
#              this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
#  NOTE: You can not modify a unlimited validity limit.
#        If you want modify it, you want probably create a limited validity limit.
#        So, at first, you must set the validity limit to a date/time.
#
#  timeset <account_name> yyyy/mm/dd [hh:mm:ss]
#    Changes the validity limit of an account.
#    Default time: 23:59:59
#  timeset <account_name> 0
#    Gives an unlimited validity limit (0 = unlimited).
#
#  unban/unbanish <account name>
#    Unban an account.
#    Same command of banset 0.
#
#  unblock <account name>
#    Set state 0 (Account ok) to an account.
#    Same command of state <account_name> 0.
#
#  version
#    Display the version of the login-server.
#
#  who <account name>
#    Displays complete information of an account.
#
#-------------------------------------------------------------------------
# Possibilities to execute ladmin in command line by usage of the software with a parameter:
# ./ladmin --mode param1 ...
#
#  --makesymlink                                    -- Create the symbolic links for a use in shell
#  --add <account_name> <sex> <password>            -- Create an account with the default email (or -a)
#  --ban yyyy/mm/dd hh:mm:ss <account_name>         -- Change the final date of a banishment of an account (or -b)
#  --banadd <account_name> <modifier>               -- Add or substract time from the final date of a banishment of an account (or - ba)
#  --banset <account_name> yyyy/mm/dd [hh:mm:ss]    -- Change the final date of a banishment of an account (or -bs)
#  --banset <account_name> 0                        -- Unbanish an account (or -bs)
#  --block <account_name>                           -- Set state 5 to an account (or -bl)
#  --check <account_name> <password>                -- Check the validity of a password for an account (or -check)
#  --create <account_name> <sex> <email> <password> -- Create an account with email (or -c)
#  --del <account_name>                             -- Remove an account (or -d)
#  --email <account_name> <email>                   -- Modify an email of an account (or -e)
#  --getcount                                       -- Give the number of players online on all char-servers (or -g)
#  --gm <account_name> <GM_level>                   -- Change the GM level of an account (or -gm)
#  --id <account_name>                              -- Give the id of an account (or -i)
#  --info <account_id>                              -- Display complete information of an account (or -info)
#  --kami <message>                                 -- Sends a broadcast message on all map-server (in yellow).
#  --kamib <message>                                -- Sends a broadcast message on all map-server (in blue).
#  --language <language>                            -- Change the language of displaying (-lang).
#  --list [First_id [Last_id]]                      -- Display a list of accounts (or -l)
#  --listBan [start_id [end_id]]                    -- Display a list of accounts with state or banished (or -lBan)
#  --listGM [First_id [Last_id]]                    -- Display a list of GM accounts (or -lGM)
#  --listOK [start_id [end_id]]                     -- Display a list of accounts without state and not banished (or -lOK)
#  --memo <account_name> <memo>                     -- Modify the memo of an account (or -e)
#  --name <account_id>                              -- Give the name of an account (or -n)
#  --passwd <account_name> <new_password>           -- Change the password of an account (or -p)
#  --reloadGM                                       -- Reload GM configuration file (or -r)
#  --search <expression>                            -- Seek accounts (or -s)
#  --search -e/-r/--expr/--regex <expression>       -- Seek accounts by REGEX (or -s)
#  --sex <account_name> <sex>                       -- Change the sex of an account (or -sex)
#  --state <account_name> <new_state> <error_message_#7> -- Change the state of an account (or -t)
#  --timeadd <account_name> <modifier>              -- Add or substract time from the validity limit of an account (or - ta)
#  --timeset <account_name> yyyy/mm/dd [hh:mm:ss]   -- Change the validify limit of an account (or -ts)
#  --timeset <account_name> 0                       -- Give a unlimited validity limit (or -ts)
#  --unban/unbanish <account_name>                  -- Unban an account (or -uba)
#  --unblock <account_name>                         -- Set state 0 to an account (or -ubl)
#  --version                                        -- Display the version of the login-server (or -v)
#  --who <account_name>                             -- Display complete information of an account (or -w)
#
#  <example> ./ladmin --addaccount testname Male testpass
#
#-------------------------------------------------------------------------
# Possibilities to execute ladmin with symbolic links in Shell
# To create the symbolic links, execute ladmin with the '-- makesymlink' option.
#
#  addaccount <account_name> <sex> <password>            -- Create an account with the default email
#  banaccount yyyy/mm/dd hh:mm:ss <account_name>         -- Change the final date of a banishment of an account
#  banaddaccount <account_name> <modifier>               -- Add or substract time from the final date of a banishment of an account
#  bansetaccount <account_name> yyyy/mm/dd [hh:mm:ss]    -- Change the final date of a banishment of an account
#  bansetaccount <account_name> 0                        -- Unbanish an account
#  blockaccount <account_name>                           -- Set state 5 (blocked by the GM Team) to an account
#  checkaccount <account_name> <password>                -- Check the validity of a password for an account
#  createaccount <account_name> <sex> <email> <password> -- Create an account with email
#  delaccount <account_name>                             -- Remove an account
#  emailaccount <account_name> <email>                   -- Modify an email of an account
#  getcount                                              -- Give the number of players online on all char-servers
#  gmaccount <account_name> <GM_level>                   -- Change the GM level of an account
#  idaccount <account_name>                              -- Give the id of an account
#  infoaccount <account_id>                              -- Display complete information of an account
#  kami <message>                                        -- Sends a broadcast message on all map-server (in yellow).
#  kamib <message>                                       -- Sends a broadcast message on all map-server (in blue).
#  ladminlanguage <language>                             -- Change the language of displaying.
#  listaccount [First_id [Last_id]]                      -- Display a list of accounts
#  listBanaccount [start_id [end_id]]                    -- Display a list of accounts with state or banished
#  listGMaccount [First_id [Last_id]]                    -- Display a list of GM accounts
#  listOKaccount [start_id [end_id]]                     -- Display a list of accounts without state and not banished
#  loginserverversion                                    -- Display the version of the login-server
#  memoaccount <account_name> <memo>                     -- Modify the memo of an account
#  nameaccount <account_id>                              -- Give the name of an account
#  passwdaccount <account_name> <new_password>           -- Change the password of an account
#  reloadGM                                              -- Reload GM configuration file
#  searchaccount <expression>                            -- Seek accounts
#  searchaccount -e/-r/--expr/--regex <expression>       -- Seek accounts by REGEX
#  sexaccount <account_name> <sex>                       -- Change the sex of an account (or -sex)
#  stateaccount <account_name> <new_state> <error_message_#7> -- Change the state of an account
#  timeaddaccount <account_name> <modifier>              -- Add or substract time from the validity limit of an account
#  timesetaccount <account_name> yyyy/mm/dd [hh:mm:ss]   -- Change the validify limit of an account
#  timesetaccount <account_name> 0                       -- Give a unlimited validity limit
#  unbanaccount <account_name>                           -- Unban an account
#  unblockaccount <account_name>                         -- Set state 0 (Account ok) to an account
#  whoaccount <account_name>                             -- Display complete information of an account
#  <exemple> ./addaccount testname Male testpass
#
#-------------------------------------------------------------------------
# About the encoding:
#
#   The Digest::MD5 module is necessary to use the encrypted password system.
#   When the software cannot found the Digest::MD5 module,
#     encoding is automatically disabled ($passenc=0), which allows
#     to use this program in any cases.
#
#-------------------------------------------------------------------------
# How to use ladmin with UNIX:
#
# You excecute ladmin as a standard command.
#  <Example of preparation to have an access to ladmin>
#    $ mv ladmin ladmin_org
#    $ nkf -eLu ladmin_org > ladmin
#    $ chmod 700 ladmin
#  <Example to start directly ladmin>
#    $ perl ladmin
#
##########################################################################


use strict;
use IO::Socket;
use Term::ReadLine;
eval { use POSIX qw(:termios_h); };
eval { use Digest::MD5 qw(md5); } if $passenc;
$passenc = 0 if($@);

my($ver) = "1.00";

# Start of termios
my($termios, $orgterml, $termlecho, $termlnoecho) = ();
eval{
	$termios = POSIX::Termios->new();
	$termios->getattr(fileno(STDIN));
	$orgterml = $termios->getlflag();
	$termlecho = ECHO | ECHOK | ICANON;
	$termlnoecho = $orgterml & ~$termlecho;
};

# Modification of termios for the displaying of passwords (no displays for pressed keys)
sub cbreak() {
	if ($termios) {
		$termios->setlflag($termlnoecho);
		$termios->setcc(VTIME, 1);
		$termios->setattr(fileno(STDIN), TCSANOW);
	}
}
# Modification of termios to return at the normal displaying (after input of the passwords)
sub cooked() {
	if ($termios) {
		$termios->setlflag($orgterml);
		$termios->setcc(VTIME,0);
		$termios->setattr(fileno(STDIN),TCSANOW);
	}
}
END{ cooked() }

if ($defaultlanguage eq "F") {
	print "Outil d'administration � distance de eAthena V.$ver\n";
} else {
	print "EAthena login-server administration tool V.$ver\n";
}

# Creation of the symbolic links for call of the program in line command of the shell
if ($ARGV[0] eq "--makesymlink") {
	symlink $0, "loginserverversion";
	symlink $0, "addaccount";
	symlink $0, "banaccount";
	symlink $0, "banaddaccount";
	symlink $0, "bansetaccount";
	symlink $0, "blockaccount";
	symlink $0, "checkaccount";
	symlink $0, "createaccount";
	symlink $0, "delaccount";
	symlink $0, "emailaccount";
	symlink $0, "getcount";
	symlink $0, "gmaccount";
	symlink $0, "idaccount";
	symlink $0, "infoaccount";
	symlink $0, "kami";
	symlink $0, "kamib";
	symlink $0, "ladminlanguage";
	symlink $0, "listaccount";
	symlink $0, "listBanaccount";
	symlink $0, "listGMaccount";
	symlink $0, "listOKaccount";
	symlink $0, "memoaccount";
	symlink $0, "nameaccount";
	symlink $0, "passwdaccount";
	symlink $0, "reloadGM";
	symlink $0, "searchaccount";
	symlink $0, "sexaccount";
	symlink $0, "stateaccount";
	symlink $0, "timeaddaccount";
	symlink $0, "timesetaccount";
	symlink $0, "unbanaccount";
	symlink $0, "unblockaccount";
	symlink $0, "whoaccount";
	if ($defaultlanguage eq "F") {
		print "Liens symbliques cr��s.\n";
	} else {
		print "Symbolic links created.\n";
	}
	exit(0);
}

# Connection to the login-server
my($so,$er) = ();
eval{
	$so = IO::Socket::INET->new(
		PeerAddr=> $loginserverip,
		PeerPort=> $loginserverport,
#		Proto   => "tcp",
		Timeout => $connecttimeout) or $er = 1;
};
if ($er || $@) {
	if ($defaultlanguage eq "F") {
		print "\nImpossible de se connecter au serveur de login [${loginserverip}:$loginserverport] !\n";
	} else {
		print "\nImpossible to have a connection with the login-server [${loginserverip}:$loginserverport] !\n";
	}
	print "$!\n";	# Displaying of the error
	exit(2);
}

# Sending the administration password
if ($passenc == 0) {
	print $so pack("v2a24",0x7918,0,$loginserveradminpassword);
	$so->flush();
} else {
	print $so pack("v",0x791a);
	$so->flush();
	my($buf) = readso(4);
	if (unpack("v",$buf) != 0x01dc) {
		if ($defaultlanguage eq "F") {
			print "Erreur au login (�chec de la cr�ation de la clef md5).\n";
		} else {
			print "Error at login (failure of the md5 key creation).\n";
		}
	}
	$buf = readso(unpack("x2v",$buf)-4);
	my($md5bin) = md5(($passenc == 1) ? $buf.$loginserveradminpassword : $loginserveradminpassword.$buf);
	print $so pack("v2a16",0x7918,$passenc,$md5bin);
	$so->flush();
}

# Waiting of the server reply
my($buf) = readso(3);

if (unpack("v",$buf) != 0x7919 || unpack("x2c",$buf) != 0) {
	if ($defaultlanguage eq "F") {
		print "Erreur de login:\n";
		print " - mot de passe incorrect,\n";
		print " - syst�me d'administration non activ�, ou\n";
		print " - IP non autoris�e.\n";
	} else {
		print "Error at login:\n";
		print " - incorrect password,\n";
		print " - administration system not activated, or\n";
		print " - unauthorised IP.\n";
	}
	quit();
	exit(4);
}

if ($defaultlanguage eq "F") {
	print "Connexion �tablie.\n";
} else {
	print "Established connection.\n";
}

#-------------------------------------------------------------------------
# Here are checked the command lines with arguments and symbolic links (no prompt)

if ($0 =~ /addaccount$/ ||
    (($ARGV[0] eq "-a" || $ARGV[0] eq "--add") && ((shift @ARGV), 1))) {
	my($r) = addaccount($ARGV[0], $ARGV[1], $ARGV[2]);
	quit();
	exit($r);
} elsif ($0 =~ /banaccount$/ || $0 =~ /banishaccount$/ ||
         (($ARGV[0] eq "-b" || $ARGV[0] eq "--ban" || $ARGV[0] eq "--banish") && ((shift @ARGV), 1))) {
	my($r) = bansetaccount($ARGV[1], $ARGV[2], $ARGV[0]);
	quit();
	exit($r);
} elsif ($0 =~ /banaddaccount$/ ||
         (($ARGV[0] eq "-ba" || $ARGV[0] eq "--banadd") && ((shift @ARGV), 1))) {
	my($r) = banaddaccount($ARGV[0], $ARGV[1]);
	quit();
	exit($r);
} elsif ($0 =~ /bansetaccount$/ ||
         (($ARGV[0] eq "-bs" || $ARGV[0] eq "--banset") && ((shift @ARGV), 1))) {
	my($r) = bansetaccount($ARGV[0], $ARGV[1], $ARGV[2]);
	quit();
	exit($r);
} elsif ($0 =~ /blockaccount$/ ||
         (($ARGV[0] eq "-bl" || $ARGV[0] eq "--block") && ((shift @ARGV), 1))) {
	my($r) = changestate($ARGV[0], 5, "");
	quit();
	exit($r);
} elsif ($0 =~ /checkaccount$/ ||
         (($ARGV[0] eq "-check" || $ARGV[0] eq "--check") && ((shift @ARGV), 1))) {
	my($r) = checkaccount($ARGV[0], $ARGV[1]);
	quit();
	exit($r);
} elsif ($0 =~ /createaccount$/ ||
         (($ARGV[0] eq "-c" || $ARGV[0] eq "--create") && ((shift @ARGV), 1))) {
	my($r) = createaccount($ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3]);
	quit();
	exit($r);
} elsif ($0 =~ /delaccount$/ ||
         (($ARGV[0] eq "-d" || $ARGV[0] eq "--del") && ((shift @ARGV), 1))) {
	my($r) = delaccount($ARGV[0]);
	quit();
	exit($r);
} elsif ($0 =~ /emailaccount$/ ||
         (($ARGV[0] eq "-e" || $ARGV[0] eq "--email") && ((shift @ARGV), 1))) {
	my($r) = changeemail($ARGV[0], $ARGV[1]);
	quit();
	exit($r);
} elsif ($0 =~ /getcount$/ ||
         (($ARGV[0] eq "-g" || $ARGV[0] eq "--getcount") && ((shift @ARGV), 1))) {
	my($r) = getlogincount();
	quit();
	exit($r);
} elsif ($0 =~ /gmaccount$/ ||
         (($ARGV[0] eq "-gm" || $ARGV[0] eq "--gm") && ((shift @ARGV), 1))) {
	my($r) = changegmlevel($ARGV[0], $ARGV[1]);
	quit();
	exit($r);
} elsif ($0 =~ /id$/ ||
         (($ARGV[0] eq "-i" || $ARGV[0] eq "--id") && ((shift @ARGV), 1))) {
	my($r) = idaccount($ARGV[0]);
	quit();
	exit($r);
} elsif ($0 =~ /infoaccount$/ ||
         (($ARGV[0] eq "-info" || $ARGV[0] eq "--info") && ((shift @ARGV), 1))) {
	my($r) = infoaccount($ARGV[0]);
	quit();
	exit($r);
} elsif ($0 =~ /kami$/ ||
         (($ARGV[0] eq "-kami" || $ARGV[0] eq "--kami") && ((shift @ARGV), 1))) {
	my($r) = sendbroadcast(0, $ARGV[0]);
	quit();
	exit($r);
} elsif ($0 =~ /kamib$/ ||
         (($ARGV[0] eq "-kamib" || $ARGV[0] eq "--kamib") && ((shift @ARGV), 1))) {
	my($r) = sendbroadcast(0x10, $ARGV[0]);
	quit();
	exit($r);
} elsif ($0 =~ /ladminlanguage$/ ||
         (($ARGV[0] eq "-lang" || $ARGV[0] eq "--language") && ((shift @ARGV), 1))) {
	my($r) = changelanguage($ARGV[0]);
	quit();
	exit($r);
} elsif ($0 =~ /listaccount$/ ||
         (($ARGV[0] eq "-l" || $ARGV[0] eq "--list") && ((shift @ARGV), 1))) {
	my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 0); # 0: to list all
	quit();
	exit($r);
} elsif ($0 =~ /listBanaccount$/ ||
         (($ARGV[0] eq "-lBan" || $ARGV[0] eq "--listBan") && ((shift @ARGV), 1))) {
	my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 3); # 3: to list only accounts with state or banished
	quit();
	exit($r);
} elsif ($0 =~ /listGMaccount$/ ||
         (($ARGV[0] eq "-lGM" || $ARGV[0] eq "--listGM") && ((shift @ARGV), 1))) {
	my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 1); # 1: to list only GM
	quit();
	exit($r);
} elsif ($0 =~ /listOKaccount$/ ||
         (($ARGV[0] eq "-lOK" || $ARGV[0] eq "--listOK") && ((shift @ARGV), 1))) {
	my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 4); # 4: to list only accounts without state and not banished
	quit();
	exit($r);
} elsif ($0 =~ /loginserverversion$/ ||
         (($ARGV[0] eq "-v" || $ARGV[0] eq "--version") && ((shift @ARGV), 1))) {
	my($r) = checkloginversion();
	quit();
	exit($r);
} elsif ($0 =~ /memoaccount$/ ||
         (($ARGV[0] eq "-m" || $ARGV[0] eq "--memo") && ((shift @ARGV), 1))) {
	my($r) = changememo($ARGV[0], $ARGV[1]);
	quit();
	exit($r);
} elsif ($0 =~ /nameaccount$/ ||
         (($ARGV[0] eq "-n" || $ARGV[0] eq "--name") && ((shift @ARGV), 1))) {
	my($r) = nameaccount(int($ARGV[0]));
	quit();
	exit($r);
} elsif ($0 =~ /passwdaccount$/ ||
         (($ARGV[0] eq "-p" || $ARGV[0] eq "--passwd") && ((shift @ARGV), 1))) {
	my($r) = changepasswd($ARGV[0], $ARGV[1]);
	quit();
	exit($r);
} elsif ($0 =~ /reloadGM$/ ||
         (($ARGV[0] eq "-r" || $ARGV[0] eq "--reloadGM") && ((shift @ARGV), 1))) {
	my($r) = reloadGM();
	quit();
	exit($r);
} elsif ($0 =~ /searchaccount$/ ||
         (($ARGV[0] eq "-s" || $ARGV[0] eq "--search") && ((shift @ARGV), 1))) {
	my($r) = searchaccount($ARGV[0], $ARGV[1]);
	quit();
	exit($r);
} elsif ($0 =~ /sexaccount$/ ||
         (($ARGV[0] eq "-sex" || $ARGV[0] eq "--sex") && ((shift @ARGV), 1))) {
	my($r) = changesex($ARGV[0], $ARGV[1]);
	quit();
	exit($r);
} elsif ($0 =~ /stateaccount$/ ||
         (($ARGV[0] eq "-t" || $ARGV[0] eq "--state") && ((shift @ARGV), 1))) {
	my($r) = changestate($ARGV[0], $ARGV[1], $ARGV[2]);
	quit();
	exit($r);
} elsif ($0 =~ /timeaddaccount$/ ||
         (($ARGV[0] eq "-ta" || $ARGV[0] eq "--timeadd") && ((shift @ARGV), 1))) {
	my($r) = timeaddaccount($ARGV[0], $ARGV[1]);
	quit();
	exit($r);
} elsif ($0 =~ /timesetaccount$/ ||
         (($ARGV[0] eq "-ts" || $ARGV[0] eq "--timeset") && ((shift @ARGV), 1))) {
	my($r) = timesetaccount($ARGV[0], $ARGV[1], $ARGV[2]);
	quit();
	exit($r);
} elsif ($0 =~ /unbanaccount$/ || $0 =~ /unbanishaccount$/ ||
         (($ARGV[0] eq "-uba" || $ARGV[0] eq "--unban" || $ARGV[0] eq "--unbanish") && ((shift @ARGV), 1))) {
	my($r) = bansetaccount($ARGV[0], 0, "");
	quit();
	exit($r);
} elsif ($0 =~ /unblockaccount$/ ||
         (($ARGV[0] eq "-ubl" || $ARGV[0] eq "--unblock") && ((shift @ARGV), 1))) {
	my($r) = changestate($ARGV[0], 0, "");
	quit();
	exit($r);
} elsif ($0 =~ /whoaccount$/ ||
         (($ARGV[0] eq "-w" || $ARGV[0] eq "--who") && ((shift @ARGV), 1))) {
	my($r) = whoaccount($ARGV[0]);
	quit();
	exit($r);
}

#-------------------------------------------------------------------------
if ($defaultlanguage eq "F") {
	print "Lecture de la version du serveur de login...\n";
} else {
	print "Reading of the version of the login-server...\n";
}
checkloginversion();

# Set the prompt line
my($term) = new Term::ReadLine "ladmin";

# Here begin the infinite loop to read prompts
while(1) {
	# Displaying of the prompt
	print "\n";
	if ($defaultlanguage eq "F") {
		printf "\033[32mPour afficher les commandes, tapez 'Entr�e'.\033[0m\n";
	} else {
		printf "\033[32mTo list the commands, type 'enter'.\033[0m\n";
	}
	my($cmd) = $term->readline("ladmin> ");
	# split and recovery of the input
	chomp $cmd; # remove cariage return
	$cmd =~ s/\x1b\[\d*\w//g; # remove (esc)[(number)(1alpha) = screen control sequence
	$cmd =~ s/[\x00-\x1f]//g; # remove control char
	my($command, $parameters) = split /\s+/,$cmd,2; # extract command and parameters
	$command = lc($command); # command in lowercase
	my(@paramlist) = split /\s+/,$parameters; # get list of parameters

	if ($command eq "?" || $command eq "") {
		$command = "aide" if ($defaultlanguage eq "F");
		$command = "help" if ($defaultlanguage ne "F");
	}

	# Analyse of the command
	eval {
# help
		if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
			displayhelp("aide", $paramlist[0]);
		} elsif ("help" =~ /^\Q$command/) {
			displayhelp("help", $paramlist[0]);

# general commands
		} elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(.*)/)) {
				addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> <sex> <password>
			} elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
				addaccount($paramlist[0], $paramlist[1], ""); # <account_name> <sex> <password>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(.*)/)) {
				addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> <sex> <password>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
				addaccount($paramlist[0], $paramlist[1], ""); # <account_name> <sex> <password>
			} else {
				@paramlist = split /\s+/,$parameters;
				addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> <sex> <password>
			}

		} elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) {
			if (@paramlist = ($parameters =~ m/^(\S+)\s+(\S+)\s+"(.*)"/)) { # yyyy/mm/dd hh:mm:ss <account_name>
				bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} elsif (@paramlist = ($parameters =~ m/^(\S+)\s+(\S+)\s+'(.*)'/)) { # yyyy/mm/dd hh:mm:ss <account_name>
				bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} else {
				@paramlist = split /\s+/,$parameters,3; # yyyy/mm/dd hh:mm:ss <account_name>
				bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # <account_name> yyyy/mm/dd [hh:mm:ss]
			}

		} elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
				banaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
				banaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
			} else {
				@paramlist = split /\s+/,$parameters;
				banaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
			}

		} elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) {
				bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
				bansetaccount($paramlist[0], $paramlist[1], "23:59:59"); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) {
				bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
				bansetaccount($paramlist[0], $paramlist[1], "23:59:59"); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} else {
				@paramlist = split /\s+/,$parameters;
				bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
			}

		} elsif ("block" =~ /^\Q$command/ && length($command) >= 2) {
			if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
				changestate($paramlist[0], 5, ""); # <account_name> <new_state> <error_message_#7>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
				changestate($paramlist[0], 5, ""); # <account_name> <new_state> <error_message_#7>
			} else {
				@paramlist = split /\s+/,$parameters,1;
				changestate($paramlist[0], 5, ""); # <account_name> <new_state> <error_message_#7>
			}

		} elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) {
				checkaccount($paramlist[0], $paramlist[1]); # <account_name> <password>
			} elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) {
				checkaccount($paramlist[0], ""); # <account_name> <password>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) {
				checkaccount($paramlist[0], $paramlist[1]); # <account_name> <password>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
				checkaccount($paramlist[0], ""); # <account_name> <password>
			} else {
				@paramlist = split /\s+/,$parameters;
				checkaccount($paramlist[0], $paramlist[1]); # <account_name> <password>
			}

		} elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)\s+(.*)/)) {
				createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # <account_name> <sex> <email> <password>
			} elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) {
				createaccount($paramlist[0], $paramlist[1], $paramlist[2], ""); # <account_name> <sex> <email> <password>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)\s+(.*)/)) {
				createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # <account_name> <sex> <email> <password>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) {
				createaccount($paramlist[0], $paramlist[1], $paramlist[2], ""); # <account_name> <sex> <email> <password>
			} else {
				@paramlist = split /\s+/,$parameters;
				createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # <account_name> <sex> <email> <password>
			}

		} elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) {
			if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
				delaccount($paramlist[0]); # <account_name>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
				delaccount($paramlist[0]); # <account_name>
			} else {
				@paramlist = split /\s+/,$parameters,1;
				delaccount($paramlist[0]); # <account_name>
			}

		} elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'?
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
				changeemail($paramlist[0], $paramlist[1]); # <account_name> <email>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
				changeemail($paramlist[0], $paramlist[1]); # <account_name> <email>
			} else {
				@paramlist = split /\s+/,$parameters;
				changeemail($paramlist[0], $paramlist[1]); # <account_name> <email>
			}

		} elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
			getlogincount();

		} elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
				changegmlevel($paramlist[0], int($paramlist[1])); # <account_name> <GM_level>
			} elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) {
				changegmlevel($paramlist[0], 0); # <account_name> <GM_level>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
				changegmlevel($paramlist[0], int($paramlist[1])); # <account_name> <GM_level>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
				changegmlevel($paramlist[0], 0); # <account_name> <GM_level>
			} else {
				@paramlist = split /\s+/,$parameters;
				changegmlevel($paramlist[0], int($paramlist[1])); # <account_name> <GM_level>
			}

		} elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
			if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
				idaccount($paramlist[0]); # <account_name>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
				idaccount($paramlist[0]); # <account_name>
			} else {
				@paramlist = split /\s+/,$parameters,1;
				idaccount($paramlist[0]); # <account_name>
			}

		} elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
			infoaccount(int($paramlist[0])); # <account_id>

		} elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'?
			@paramlist = split /\s+/,$parameters,1;
			sendbroadcast(0, $paramlist[0]); # <type> <message>

		} elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'?
			@paramlist = split /\s+/,$parameters,1;
			sendbroadcast(0x10, $paramlist[0]); # <type> <message>

		} elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'?
			changelanguage($paramlist[0]); # <language>

		} elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'?
			listaccount(int($paramlist[0]), int($paramlist[1]), 0); # [start_id [end_id]] 0: to list all

		} elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'?
			listaccount(int($paramlist[0]), int($paramlist[1]), 3); # [start_id [end_id]] 3: to list only accounts with state or banished

		} elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'?
			listaccount(int($paramlist[0]), int($paramlist[1]), 1); # [start_id [end_id]] 1: to list only GM

		} elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'?
			listaccount(int($paramlist[0]), int($paramlist[1]), 4); # [start_id [end_id]] 4: to list only accounts without state and not banished

		} elsif ("memo" =~ /^\Q$command/) {
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) {
				changememo($paramlist[0], $paramlist[1]); # <account_name> <memo>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) {
				changememo($paramlist[0], $paramlist[1]); # <account_name> <memo>
			} else {
				@paramlist = split /\s+/,$parameters,2;
				changememo($paramlist[0], $paramlist[1]); # <account_name> <memo>
			}

		} elsif ("name" =~ /^\Q$command/) {
			nameaccount(int($paramlist[0])); # <account_id>

		} elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) {
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) {
				changepasswd($paramlist[0], $paramlist[1]); # <account_name> <new_password>
			} elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) {
				changepasswd($paramlist[0], ""); # <account_name> <new_password>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) {
				changepasswd($paramlist[0], $paramlist[1]); # <account_name> <new_password>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
				changepasswd($paramlist[0], ""); # <account_name> <new_password>
			} else {
				@paramlist = split /\s+/,$parameters,2;
				changepasswd($paramlist[0], $paramlist[1]); # <account_name> <new_password>
			}

		} elsif ("reloadgm" =~ /^\Q$command/) {
			reloadGM();

		} elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
		          $command ne "se") { # check 2 letters command: 'search' or 'sex'?
			if (@paramlist = ($parameters =~ m/^(-{1,2}[re]\S*)\s+(.*)/)) {
				searchaccount($paramlist[0], $paramlist[1]); # -r/-e/--expr/--regex <expression> | <expression>
			} else {
				@paramlist = split /\s+/,$parameters,1;
				searchaccount($paramlist[0], ""); # -r/-e/--expr/--regex <expression> | <expression>
			}

		} elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
		          $command ne "se") { # check 2 letters command: 'search' or 'sex'?
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
				changesex($paramlist[0], $paramlist[1]); # <account_name> <sex>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
				changesex($paramlist[0], $paramlist[1]); # <account_name> <sex>
			} else {
				@paramlist = split /\s+/,$parameters;
				changesex($paramlist[0], $paramlist[1]); # <account_name> <sex>
			}

		} elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'?
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\d+)\s+(.*)/)) {
				changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # <account_name> <new_state> <error_message_#7>
			} elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\d+)/)) {
				changestate($paramlist[0], int($paramlist[1]), ""); # <account_name> <new_state> <error_message_#7>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\d+)\s+(.*)/)) {
				changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # <account_name> <new_state> <error_message_#7>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\d+)/)) {
				changestate($paramlist[0], int($paramlist[1]), ""); # <account_name> <new_state> <error_message_#7>
			} else {
				@paramlist = split /\s+/,$parameters,3;
				changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # <account_name> <new_state> <error_message_#7>
			}

		} elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
				timeaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
				timeaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
			} else {
				@paramlist = split /\s+/,$parameters;
				timeaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
			}

		} elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
			if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) {
				timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
				timesetaccount($paramlist[0], $paramlist[1], "23:59:59"); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) {
				timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
				timesetaccount($paramlist[0], $paramlist[1], "23:59:59"); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} else {
				@paramlist = split /\s+/,$parameters;
				timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
			}

		} elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) {
			if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
				bansetaccount($paramlist[0], 0, ""); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
				bansetaccount($paramlist[0], 0, ""); # <account_name> yyyy/mm/dd [hh:mm:ss]
			} else {
				@paramlist = split /\s+/,$parameters,1;
				bansetaccount($paramlist[0], 0, ""); # <account_name> yyyy/mm/dd [hh:mm:ss]
			}

		} elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) {
			if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
				changestate($paramlist[0], 0, ""); # <account_name> <new_state> <error_message_#7>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
				changestate($paramlist[0], 0, ""); # <account_name> <new_state> <error_message_#7>
			} else {
				@paramlist = split /\s+/,$parameters,1;
				changestate($paramlist[0], 0, ""); # <account_name> <new_state> <error_message_#7>
			}

		} elsif ("version" =~ /^\Q$command/) {
			checkloginversion();

		} elsif ("who" =~ /^\Q$command/) {
			if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
				whoaccount($paramlist[0]); # <account_name>
			} elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
				whoaccount($paramlist[0]); # <account_name>
			} else {
				@paramlist = split /\s+/,$parameters,1;
				whoaccount($paramlist[0]); # <account_name>
			}

# quit
		} elsif ("quit" =~ /^\Q$command/ ||
		         (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'?
			last;

# unknown command
		} elsif ($command) {
			if ($defaultlanguage eq "F") {
				print "Commande inconnue [".$command."]\n";
			} else {
				print "Unknown command [".$command."]\n";
			}
		}
#		$term->addhistory($cmd) if $command;
	};
	if ($@) {
		if ($defaultlanguage eq "F") {
			print "Erreur [".$command."]\n$@";
		} else {
			print "Error [".$command."]\n$@";
		}
	}
};

# End of the software
quit();

if ($defaultlanguage eq "F") {
	print "Au revoir.\n";
} else {
	print "Bye.\n";
}
exit(0);

#--------------------------------------------------------------------------

# Sub-function: Displaying of the version of the login-server
sub checkloginversion() {
	print $so pack("v",30000); # 0x7530
	$so->flush();
	$buf = readso(10);
	# Analyse du Packet
	my($ret, $maver, $miver, $rev, $dev, $mod, $type, $mdver) = unpack("vc6v", $buf);
	if ($ret != 30001) { #0x7531
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		exit(6);
	}

	print "  Login-Server [$loginserverip:$loginserverport]\n";
	printf "  eAthena version %s-%d.%d", ("stable", "dev")[$dev], $maver, $miver;
	printf " revision %d", $rev if $rev;
	printf "%s%d.\n", ("", "-mod")[$mod], $mdver;
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: Displaying of the help
sub displayhelp() {
	my($help, $receivedcommand) = @_;

	my($command) = lc($receivedcommand); # command in lowercase

	if ($command eq "") {
		$command = "not a command"; # any value that is not a command
	}

	if ($command eq "?") {
		$command = "aide" if ($defaultlanguage eq "F");
		$command = "help" if ($defaultlanguage ne "F");
	}

	if ($help eq "aide") {
		if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
			printf "aide/help/?\n";
			printf "  Affiche la description des commandes\n";
			printf "aide/help/? [commande]\n";
			printf "  Affiche la description de la commande specifi�e\n";
		} elsif ("help" =~ /^\Q$command/) {
			printf "aide/help/?\n";
			printf "  Display the description of the commands\n";
			printf "aide/help/? [command]\n";
			printf "  Display the description of the specified command\n";
		} elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
			printf "add <nomcompte> <sexe> <motdepasse>\n";
			printf "  Cr�e un compte avec l'email par d�faut (a\@a.com).\n";
			printf "  Concernant le sexe, seule la premi�re lettre compte (F ou M).\n";
			printf "  L'e-mail est a\@a.com (e-mail par d�faut). C'est comme n'avoir aucun e-mail.\n";
			printf "  Lorsque motdepasse est omis, la saisie se fait sans que la frappe se voit.\n";
			printf "  <exemple> add testname Male testpass\n";
		} elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) {
			printf "ban/banish aaaa/mm/jj hh:mm:ss <nomcompte>\n";
			printf "  Change la date de fin de bannissement d'un compte.\n";
			printf "  La diff�rence avec banset est la position du nom du compte.\n";
		} elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
			printf "banadd <nomcompte> <Modificateur>\n";
			printf "  Ajoute ou soustrait du temps � la date de banissement d'un compte.\n";
			printf "  Les modificateurs sont construits comme suit:\n";
			printf "    Valeur d'ajustement (-1, 1, +1, etc...)\n";
			printf "    El�ment modifi�:\n";
			printf "      a ou y: ann�e\n";
			printf "      m:      mois\n";
			printf "      j ou d: jour\n";
			printf "      h:      heure\n";
			printf "      mn:     minute\n";
			printf "      s:      seconde\n";
			printf "  <exemple> banadd testname +1m-2mn1s-6a\n";
			printf "            Cette exemple ajoute 1 mois et une seconde, et soustrait 2 minutes\n";
			printf "            et 6 ans dans le m�me temps.\n";
			printf "NOTE: Si vous modifez la date de banissement d'un compte non bani,\n";
			printf "      vous indiquez comme date (le moment actuel +- les ajustements)\n";
		} elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
			printf "banset <nomcompte> aaaa/mm/jj [hh:mm:ss]\n";
			printf "  Change la date de fin de bannissement d'un compte.\n";
			printf "  Heure par d�faut: 23:59:59\n";
			printf "banset <nomcompte> 0\n";
			printf "  D�banni un compte (0 = de-banni).\n";
		} elsif ("block" =~ /^\Q$command/ && length($command) >= 2) {
			printf "block <nom compte>\n";
			printf "  Place le status d'un compte � 5 (You have been blocked by the GM Team).\n";
			printf "  La commande est l'�quivalent de state <nom_compte> 5.\n";
		} elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
			printf "check <nomcompte> <motdepasse>\n";
			printf "  V�rifie la validit� d'un mot de passe pour un compte\n";
			printf "  NOTE: Le serveur n'enverra jamais un mot de passe.\n";
			printf "        C'est la seule m�thode que vous poss�dez pour savoir\n";
			printf "        si un mot de passe est le bon. L'autre m�thode est\n";
			printf "        d'avoir un acc�s ('physique') au fichier des comptes.\n";
		} elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
			printf "create <nomcompte> <sexe> <email> <motdepasse>\n";
			printf "  Comme la commande add, mais avec l'e-mail en plus.\n";
			printf "  <exemple> create testname Male mon\@mail.com testpass\n";
		} elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) {
			printf "del <nomcompte>\n";
			printf "  Supprime un compte.\n";
			printf "  La commande demande confirmation. Apr�s confirmation, le compte est d�truit.\n";
		} elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'?
			printf "email <nomcompte> <email>\n";
			printf "  Modifie l'e-mail d'un compte.\n";
		} elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
			printf "getcount\n";
			printf "  Donne le nombre de joueurs en ligne par serveur de char.\n";
		} elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
			printf "gm <nomcompte> [Niveau_GM]\n";
			printf "  Modifie le niveau de GM d'un compte.\n";
			printf "  Valeur par d�faut: 0 (suppression du niveau de GM).\n";
			printf "  <exemple> gm nomtest 80\n";
		} elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
			printf "id <nomcompte>\n";
			printf "  Donne l'id d'un compte.\n";
		} elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
			printf "info <idcompte>\n";
			printf "  Affiche les informations sur un compte.\n";
		} elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'?
			printf "kami <message>\n";
			printf "  Envoi un message g�n�ral sur tous les serveurs de map (en jaune).\n";
		} elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'?
			printf "kamib <message>\n";
			printf "  Envoi un message g�n�ral sur tous les serveurs de map (en bleu).\n";
		} elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'?
			printf("language <langue>\n");
			printf("  Change la langue d'affichage.\n");
			printf("  Langues possibles: 'Fran�ais' ou 'English'.\n");
		} elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'?
			printf "list/ls [Premier_id [Dernier_id]]\n";
			printf "  Affiche une liste de comptes.\n";
			printf "  'Premier_id', 'Dernier_id': indique les identifiants de d�part et de fin.\n";
			printf "  La recherche par nom n'est pas possible avec cette commande.\n";
			printf "  <example> list 10 9999999\n";
		} elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'?
			printf "listBan/lsBan [Premier_id [Dernier_id]]\n";
			printf "  Comme list/ls, mais seulement pour les comptes GM avec un statut ou bannis.\n";
		} elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'?
			printf "listGM/lsGM [Premier_id [Dernier_id]]\n";
			printf "  Comme list/ls, mais seulement pour les comptes GM.\n";
		} elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'?
			printf "listOK/lsOK [Premier_id [Dernier_id]]\n";
			printf "  Comme list/ls, mais seulement pour les comptes sans statut et non bannis.\n";
		} elsif ("memo" =~ /^\Q$command/) {
			printf "memo <nomcompte> <memo>\n";
			printf "  Modifie le m�mo d'un compte.\n";
			printf "  'memo': Il peut avoir jusqu'� 253 caract�res (avec des espaces ou non).\n";
		} elsif ("name" =~ /^\Q$command/) {
			printf "name <idcompte>\n";
			printf "  Donne le nom d'un compte.\n";
		} elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) {
			printf "passwd <nomcompte> <nouveaumotdepasse>\n";
			printf "  Change le mot de passe d'un compte.\n";
			printf "  Lorsque nouveaumotdepasse est omis,\n";
			printf "  la saisie se fait sans que la frappe ne se voit.\n";
		} elsif ("reloadgm" =~ /^\Q$command/) {
			printf "reloadGM\n";
			printf "  Reload GM configuration file\n";
		} elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
		          $command ne "se") { # check 2 letters command: 'search' or 'sex'?
			printf "search <expression>\n";
			printf "  Cherche des comptes.\n";
			printf "  Affiche les comptes dont les noms correspondent.\n";
			printf "search -r/-e/--expr/--regex <expression>\n";
			printf "  Cherche des comptes par expression reguli�re.\n";
			printf "  Affiche les comptes dont les noms correspondent.\n";
		} elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
		          $command ne "se") { # check 2 letters command: 'search' or 'sex'?
			printf "sex <nomcompte> <sexe>\n";
			printf "  Modifie le sexe d'un compte.\n";
			printf "  <exemple> sex testname Male\n";
		} elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'?
			printf "state <nomcompte> <nouveaustatut> <message_erreur_7>\n";
			printf "  Change le statut d'un compte.\n";
			printf "  'nouveaustatut': Le statut est le m�me que celui du packet 0x006a + 1.\n";
			printf "               les possibilit�s sont:\n";
			printf "               0 = Compte ok\n";
			printf "               1 = Unregistered ID\n";
			printf "               2 = Incorrect Password\n";
			printf "               3 = This ID is expired\n";
			printf "               4 = Rejected from Server\n";
			printf "               5 = You have been blocked by the GM Team\n";
			printf "               6 = Your Game's EXE file is not the latest version\n";
			printf "               7 = You are Prohibited to log in until...\n";
			printf "               8 = Server is jammed due to over populated\n";
			printf "               9 = No MSG\n";
			printf "               100 = This ID has been totally erased\n";
			printf "               all other values are 'No MSG', then use state 9 please.\n";
			printf "  'message_erreur_7': message du code erreur 6 =\n";
			printf "                      = Your are Prohibited to log in until... (packet 0x006a)\n";
		} elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
			printf "timeadd <nomcompte> <modificateur>\n";
			printf "  Ajoute/soustrait du temps � la limite de validit� d'un compte.\n";
			printf "  Le modificateur est compos� comme suit:\n";
			printf "    Valeur modificatrice (-1, 1, +1, etc...)\n";
			printf "    El�ment modifi�:\n";
			printf "      a ou y: ann�e\n";
			printf "      m:      mois\n";
			printf "      j ou d: jour\n";
			printf "      h:      heure\n";
			printf "      mn:     minute\n";
			printf "      s:      seconde\n";
			printf "  <exemple> timeadd testname +1m-2mn1s-6a\n";
			printf "            Cette exemple ajoute 1 mois et une seconde, et soustrait 2 minutes\n";
			printf "            et 6 ans dans le m�me temps.\n";
			printf "NOTE: Vous ne pouvez pas modifier une limite de validit� illimit�e. Si vous\n";
			printf "      d�sirez le faire, c'est que vous voulez probablement cr�er un limite de\n";
			printf "      validit� limit�e. Donc, en premier, fix� une limite de valitid�.\n";
		} elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
			printf "timeset <nomcompte> aaaa/mm/jj [hh:mm:ss]\n";
			printf "  Change la limite de validit� d'un compte.\n";
			printf "  Heure par d�faut: 23:59:59\n";
			printf "timeset <nomcompte> 0\n";
			printf "  Donne une limite de validit� illimit�e (0 = illimit�e).\n";
		} elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) {
			printf "unban/unbanish <nom compte>\n";
			printf "  Ote le banissement d'un compte.\n";
			printf "  La commande est l'�quivalent de banset <nom_compte> 0.\n";
		} elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) {
			printf "unblock <nom compte>\n";
			printf "  Place le status d'un compte � 0 (Compte ok).\n";
			printf "  La commande est l'�quivalent de state <nom_compte> 0.\n";
		} elsif ("version" =~ /^\Q$command/) {
			printf "version\n";
			printf "  Affiche la version du login-serveur.\n";
		} elsif ("who" =~ /^\Q$command/) {
			printf "who <nomcompte>\n";
			printf "  Affiche les informations sur un compte.\n";
		} elsif ("quit" =~ /^\Q$command/ ||
		         (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'?\n";
			printf "quit/end/exit\n";
			printf "  Fin du programme d'administration.\n";
		} else {
			if ($receivedcommand ne "") {
				printf "Commande inconnue [%s] pour l'aide. Affichage de toutes les commandes.\n", $receivedcommand;
			}
			print << "ENDOFAIDE";
 aide/help/?                             -- Affiche cet aide
 aide/help/? [commande]                  -- Affiche l'aide de la commande
 add <nomcompte> <sexe> <motdepasse>     -- Cr�e un compte (sans email)
 ban/banish aaaa/mm/jj hh:mm:ss <nomcompte>-- Change la date finale de banismnt
 banadd/ba <nomcompte> <modificateur>    -- Ajout/soustrait du temps � la
   exemple: ba moncompte +1m-2mn1s-2y       date finale de banissement
 banset/bs <nomcompte> aaaa/mm/jj [hh:mm:ss] -- Change la date fin de banisemnt
 banset/bs <nomcompte> 0                 -- D�-banis un compte.
 block <nom compte>  -- Mets le status d'un compte  5 (blocked by the GM Team)
 check <nomcompte> <motdepasse>          -- Vrifie un mot de passe d'un compte
 create <nomcompte> <sexe> <email> <motdepasse> -- Cr�e un compte (avec email)
 del <nomcompte>                         -- Supprime un compte
 email <nomcompte> <email>               -- Modifie l'e-mail d'un compte
 getcount                                -- Donne le nb de joueurs en ligne
 gm <nomcompte> [Niveau_GM]              -- Modifie le niveau de GM d'un compte
 id <nomcompte>                          -- Donne l'id d'un compte
 info <idcompte>                         -- Affiche les infos sur un compte
 kami <message>                          -- Envoi un message gnral (en jaune)
 kamib <message>                         -- Envoi un message gnral (en bleu)
 language <langue>                       -- Change la langue d'affichage.
 list/ls [Premier_id [Dernier_id] ]      -- Affiche une liste de comptes
 listBan/lsBan [Premier_id [Dernier_id] ]-- Affiche une liste de comptes
                                            avec un statut ou bannis
 listGM/lsGM [Premier_id [Dernier_id] ]  -- Affiche une liste de comptes GM
 listOK/lsOK [Premier_id [Dernier_id] ]  -- Affiche une liste de comptes
                                            sans status et non bannis
 memo <nomcompte> <memo>                 -- Modifie le memo d'un compte
 name <idcompte>                         -- Donne le nom d'un compte
 passwd <nomcompte> <nouveaumotdepasse>  -- Change le mot de passe d'un compte
 quit/end/exit                           -- Fin du programme d'administation
 reloadGM                              -- Recharger le fichier de config des GM
 search <expression>                     -- Cherche des comptes
 search -e/-r/--expr/--regex <expression> -- Cherche des comptes par REGEX
 sex <nomcompte> <sexe>                  -- Modifie le sexe d'un compte
 state <nomcompte> <nouveaustatut> <messageerr7> -- Change le statut d'1 compte
 timeadd/ta <nomcompte> <modificateur>   -- Ajout/soustrait du temps � la
   exemple: ta moncompte +1m-2mn1s-2y       limite de validit�
 timeset/ts <nomcompte> aaaa/mm/jj [hh:mm:ss] -- Change la limite de validit�
 timeset/ts <nomcompte> 0                -- limite de validit� = illimit�e
 unban/unbanish <nom compte>             -- Ote le banissement d'un compte
 unblock <nom compte>            -- Mets le status d'un compte � 0 (Compte ok)
 version                                 -- Donne la version du login-serveur
 who <nomcompte>                         -- Affiche les infos sur un compte
ENDOFAIDE
			printf(" Note: Pour les noms de compte avec des espaces, tapez \"<nom compte>\" (ou ').\n");
		}
	} else {
		if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
			printf "aide/help/?\n";
			printf "  Display the description of the commands\n";
			printf "aide/help/? [command]\n";
			printf "  Display the description of the specified command\n";
		} elsif ("help" =~ /^\Q$command/) {
			printf "aide/help/?\n";
			printf "  Display the description of the commands\n";
			printf "aide/help/? [command]\n";
			printf "  Display the description of the specified command\n";
		} elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
			printf "add <account_name> <sex> <password>\n";
			printf "  Create an account with the default email (a\@a.com).\n";
			printf "  Concerning the sex, only the first letter is used (F or M).\n";
			printf "  The e-mail is set to a\@a.com (default e-mail). It's like to have no e-mail.\n";
			printf "  When the password is omitted,\n";
			printf "  the input is done without displaying of the pressed keys.\n";
			printf "  <example> add testname Male testpass\n";
		} elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) {
			printf "ban/banish yyyy/mm/dd hh:mm:ss <account_name>\n";
			printf "  Changes the final date of a banishment of an account.\n";
			printf "  The difference with banset is the position of the account name.\n";
		} elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
			printf "banadd <account_name> <modifier>\n";
			printf "  Adds or substracts time from the final date of a banishment of an account.\n";
			printf "  Modifier is done as follows:\n";
			printf "    Adjustment value (-1, 1, +1, etc...)\n";
			printf "    Modified element:\n";
			printf "      a or y: year\n";
			printf "      m:  month\n";
			printf "      j or d: day\n";
			printf "      h:  hour\n";
			printf "      mn: minute\n";
			printf "      s:  second\n";
			printf "  <example> banadd testname +1m-2mn1s-6y\n";
			printf "            this example adds 1 month and 1 second, and substracts 2 minutes\n";
			printf "            and 6 years at the same time.\n";
			printf "NOTE: If you modify the final date of a non-banished account,\n";
			printf "      you fix the final date to (actual time +- adjustments)\n";
		} elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
			printf "banset <account_name> yyyy/mm/dd [hh:mm:ss]\n";
			printf "  Changes the final date of a banishment of an account.\n";
			printf "  Default time: 23:59:59\n";
			printf "banset <account_name> 0\n";
			printf "  Set a non-banished account (0 = unbanished).\n";
		} elsif ("block" =~ /^\Q$command/ && length($command) >= 2) {
			printf "block <account name>\n";
			printf "  Set state 5 (You have been blocked by the GM Team) to an account.\n";
			printf "  Same command of state <account_name> 5.\n";
		} elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
			printf "check <account_name> <password>\n";
			printf "  Check the validity of a password for an account.\n";
			printf "  NOTE: Server will never sends back a password.\n";
			printf "        It's the only method you have to know if a password is correct.\n";
			printf "        The other method is to have a ('physical') access to the accounts file.\n";
		} elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
			printf "create <account_name> <sex> <email> <password>\n";
			printf "  Like the 'add' command, but with e-mail moreover.\n";
			printf "  <example> create testname Male my\@mail.com testpass\n";
		} elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) {
			printf "del <account_name>\n";
			printf "  Remove an account.\n";
			printf "  This order requires confirmation. After confirmation, the account is deleted.\n";
		} elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'?
			printf "email <account_name> <email>\n";
			printf "  Modify the e-mail of an account.\n";
		} elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
			printf "getcount\n";
			printf "  Give the number of players online on all char-servers.\n";
		} elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
			printf "gm <account_name> [GM_level]\n";
			printf "  Modify the GM level of an account.\n";
			printf "  Default value remove GM level (GM level = 0).\n";
			printf "  <example> gm testname 80\n";
		} elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
			printf "id <account_name>\n";
			printf "  Give the id of an account.\n";
		} elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
			printf "info <account_id>\n";
			printf "  Display complete information of an account.\n";
		} elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'?
			printf "kami <message>\n";
			printf "  Sends a broadcast message on all map-server (in yellow).\n";
		} elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'?
			printf "kamib <message>\n";
			printf "  Sends a broadcast message on all map-server (in blue).\n";
		} elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'?
			printf("language <language>\n");
			printf("  Change the language of displaying.\n");
			printf("  Possible languages: Franais or English.\n");
		} elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'?
			printf "list/ls [start_id [end_id]]\n";
			printf "  Display a list of accounts.\n";
			printf "  'start_id', 'end_id': indicate end and start identifiers.\n";
			printf "  Research by name is not possible with this command.\n";
			printf "  <example> list 10 9999999\n";
		} elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'?
			printf "listBan/lsBan [start_id [end_id]]\n";
			printf "  Like list/ls, but only for accounts with state or banished.\n";
		} elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'?
			printf "listGM/lsGM [start_id [end_id]]\n";
			printf "  Like list/ls, but only for GM accounts.\n";
		} elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'?
			printf "listOK/lsOK [start_id [end_id]]\n";
			printf "  Like list/ls, but only for accounts without state and not banished.\n";
		} elsif ("memo" =~ /^\Q$command/) {
			printf "memo <account_name> <memo>\n";
			printf "  Modify the memo of an account.\n";
			printf "  'memo': it can have until 253 characters (with spaces or not).\n";
		} elsif ("name" =~ /^\Q$command/) {
			printf "name <account_id>\n";
			printf "  Give the name of an account.\n";
		} elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) {
			printf "passwd <account_name> <new_password>\n";
			printf "  Change the password of an account.\n";
			printf "  When new password is omitted,\n";
			printf "  the input is done without displaying of the pressed keys.\n";
		} elsif ("reloadgm" =~ /^\Q$command/) {
			printf "reloadGM\n";
			printf "  Reload GM configuration file\n";
		} elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
		          $command ne "se") { # check 2 letters command: 'search' or 'sex'?
			printf "search <expression>\n";
			printf "  Seek accounts.\n";
			printf "  Displays the accounts whose names correspond.\n";
			printf "search -r/-e/--expr/--regex <expression>\n";
			printf "  Seek accounts by regular expression.\n";
			printf "  Displays the accounts whose names correspond.\n";
		} elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
		          $command ne "se") { # check 2 letters command: 'search' or 'sex'?
			printf "sex <account_name> <sex>\n";
			printf "  Modify the sex of an account.\n";
			printf "  <example> sex testname Male\n";
		} elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'?
			printf "state <account_name> <new_state> <error_message_#7>\n";
			printf "  Change the state of an account.\n";
			printf "  'new_state': state is the state of the packet 0x006a + 1.\n";
			printf "               The possibilities are:\n";
			printf "               0 = Account ok\n";
			printf "               1 = Unregistered ID\n";
			printf "               2 = Incorrect Password\n";
			printf "               3 = This ID is expired\n";
			printf "               4 = Rejected from Server\n";
			printf "               5 = You have been blocked by the GM Team\n";
			printf "               6 = Your Game's EXE file is not the latest version\n";
			printf "               7 = You are Prohibited to log in until...\n";
			printf "               8 = Server is jammed due to over populated\n";
			printf "               9 = No MSG\n";
			printf "               100 = This ID has been totally erased\n";
			printf "               all other values are 'No MSG', then use state 9 please.\n";
			printf "  'error_message_#7': message of the code error 6\n";
			printf "                      = Your are Prohibited to log in until... (packet 0x006a)\n";
		} elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
			printf "timeadd <account_name> <modifier>\n";
			printf "  Adds or substracts time from the validity limit of an account.\n";
			printf "  Modifier is done as follows:\n";
			printf "    Adjustment value (-1, 1, +1, etc...)\n";
			printf "    Modified element:\n";
			printf "      a or y: year\n";
			printf "      m:  month\n";
			printf "      j or d: day\n";
			printf "      h:  hour\n";
			printf "      mn: minute\n";
			printf "      s:  second\n";
			printf "  <example> timeadd testname +1m-2mn1s-6y\n";
			printf "            this example adds 1 month and 1 second, and substracts 2 minutes\n";
			printf "            and 6 years at the same time.\n";
			printf "NOTE: You can not modify a unlimited validity limit.\n";
			printf "      If you want modify it, you want probably create a limited validity limit.\n";
			printf "      So, at first, you must set the validity limit to a date/time.\n";
		} elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
			printf "timeset <account_name> yyyy/mm/dd [hh:mm:ss]\n";
			printf "  Changes the validity limit of an account.\n";
			printf "  Default time: 23:59:59\n";
			printf "timeset <account_name> 0\n";
			printf "  Gives an unlimited validity limit (0 = unlimited).\n";
		} elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) {
			printf "unban/unbanish <account name>\n";
			printf "  Remove the banishment of an account.\n";
			printf "  This command works like banset <account_name> 0.\n";
		} elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) {
			printf "unblock <account name>\n";
			printf "  Set state 0 (Account ok) to an account.\n";
			printf "  This command works like state <account_name> 0.\n";
		} elsif ("version" =~ /^\Q$command/) {
			printf "version\n";
			printf "  Display the version of the login-server.\n";
		} elsif ("who" =~ /^\Q$command/) {
			printf "who <account_name>\n";
			printf "  Displays complete information of an account.\n";
		} elsif ("quit" =~ /^\Q$command/ ||
		         (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'?\n";
			printf "quit/end/exit\n";
			printf "  End of the program of administration.\n";
		} else {
			if ($receivedcommand ne "") {
				printf "Unknown command [%s] for help. Displaying of all commands.\n", $receivedcommand;
			}
			print << "ENDOFHELP";
 aide/help/?                          -- Display this help
 aide/help/? [command]                -- Display the help of the command
 add <account_name> <sex> <password>  -- Create an account with default email
 ban/banish yyyy/mm/dd hh:mm:ss <account_name> -- Change final date of a ban
 banadd/ba <account_name> <modifier>  -- Add or substract time from the final
   example: ba apple +1m-2mn1s-2y        date of a banishment of an account
 banset/bs <account_name> yyyy/mm/dd [hh:mm:ss] -- Change final date of a ban
 banset/bs <account_name> 0           -- Un-banish an account
 block <account name>    -- Set state 5 (blocked by the GM Team) to an account
 check <account_name> <password>      -- Check the validity of a password
 create <account_name> <sex> <email> <passwrd> -- Create an account with email
 del <account_name>                   -- Remove an account
 email <account_name> <email>         -- Modify an email of an account
 getcount                             -- Give the number of players online
 gm <account_name> [GM_level]         -- Modify the GM level of an account
 id <account_name>                    -- Give the id of an account
 info <account_id>                    -- Display all information of an account
 kami <message>                       -- Sends a broadcast message (in yellow)
 kamib <message>                      -- Sends a broadcast message (in blue)
 language <language>                  -- Change the language of displaying.
 list/ls [First_id [Last_id]]         -- Display a list of accounts
 listBan/lsBan [First_id [Last_id]]   -- Display a list of accounts
                                         with state or banished
 listGM/lsGM [First_id [Last_id]]     -- Display a list of GM accounts
 listOK/lsOK [First_id [Last_id]]     -- Display a list of accounts
                                         without state and not banished
 memo <account_name> <memo>           -- Modify the memo of an account
 name <account_id>                    -- Give the name of an account
 passwd <account_name> <new_password> -- Change the password of an account
 quit/end/exit                        -- End of the program of administation
 reloadGM                             -- Reload GM configuration file
 search <expression>                  -- Seek accounts
 search -e/-r/--expr/--regex <expressn> -- Seek accounts by regular-expression
 sex <nomcompte> <sexe>               -- Modify the sex of an account
 state <account_name> <new_state> <error_message_#7> -- Change the state
 timeadd/ta <account_name> <modifier> -- Add or substract time from the
   example: ta apple +1m-2mn1s-2y        validity limit of an account
 timeset/ts <account_name> yyyy/mm/dd [hh:mm:ss] -- Change the validify limit
 timeset/ts <account_name> 0         -- Give a unlimited validity limit
 unban/unbanish <account name>       -- Remove the banishment of an account
 unblock <account name>              -- Set state 0 (Account ok) to an account
 version                             -- Gives the version of the login-server
 who <account_name>                  -- Display all information of an account
ENDOFHELP
			printf(" Note: To use spaces in an account name, type \"<account name>\" (or ').\n");
		}
	}

	return 0;
}
#--------------------------------------------------------------------------

# Sub-function: Displaying of the accounts list
sub listaccount() {
	my($st, $ed, $listflag) = @_;
	my($i);
	my($n) = (0);
	#      0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567
	if ($defaultlanguage eq "F") {
		print " id_compte GM nom_utilisateur         sexe   count statut\n";
	} else {
		print "account_id GM user_name               sex    count state\n";
	}
	print "-------------------------------------------------------------------------------\n";
	while(1) {
		print $so pack("vV2", 0x7920, $st, $ed);
		$so->flush();
		$buf = readso(4);
		if (unpack("v", $buf) != 0x7921) {
			if ($defaultlanguage eq "F") {
				print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
			} else {
				print "Connection error to the server (incorrect answer).\n";
			}
			exit(10);
		}
		my($len) = unpack("x2v", $buf);
		last if ($len <= 4);
		for($i = 4; $i < $len; $i += 38) {
			my(@dat) = unpack("VCa24cVV", readso(38));
			$st = $dat[0] + 1;
			if ($listflag == 0 ||
			    ($listflag == 1 && $dat[1] > 0) || # check GM flag
			    ($listflag == 3 && $dat[5] != 0) || # check with state or banished
			    ($listflag == 4 && $dat[5] == 0)) { # check without state and not banished
				printf "%10d %2s %-24s%-5s %6d %-27s\n", $dat[0],
				        ($dat[1] == 0 ? "  " : $dat[1]),
				        $dat[2],
				        ($defaultlanguage eq "F" ? ("Femme","Male","Servr")[$dat[3]] : ("Femal","Male","Servr")[$dat[3]]),
				        $dat[4],
				        (($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"),
				         "Unregistered ID",
				         "Incorrect Password",
				         "This ID is expired",
				         "Rejected from Server",
				         "Blocked by the GM Team", # You have been blocked by the GM Team
				         "Your EXE file is too old", # Your Game's EXE file is not the latest version
				         "Banishement or\n                                                   Prohibited to login until %s", # You are Prohibited to log in until %s
				         "Server is over populated", # Server is jammed due to over populated
				         "No MSG",
				         "This ID is totally erased")[$dat[5] == 100 ? 10 : $dat[5]]; # This ID has been totally erased
				$n++;
			}
		}
	}
	if ($defaultlanguage eq "F") {
		if ($n == 0) {
			print "Aucun compte trouv�.\n";
		} elsif ($n == 1) {
			print "1 compte trouv�.\n";
		} else {
			print "$n comptes trouv�s.\n";
		}
	} else {
		if ($n == 0) {
			print "No account found.\n";
		} elsif ($n == 1) {
			print "1 account found.\n";
		} else {
			print "$n accounts found.\n";
		}
	}
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: add an account with the default e-mail
sub addaccount() {
	my($userid, $sex, $passwd) = @_;
	if ($userid eq "" || !defined($userid)) {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple> add nomtest Male motdepassetest\n";
		} else {
			print "Please input an account name.\n";
			print "<example> add testname Male testpass\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
#	if ($userid =~ /[^A-Za-z0-9\@-_]/) {
#		if ($defaultlanguage eq "F") {
#			print "Caract�re interdit trouv� dans le nom du compte ".$`."[${&}]${'}\n";
#		} else {
#			print "Illegal character found in the account name ".$`."[${&}]${'}\n";
#		}
#		return 101;
#	}
	$sex = uc(substr($sex, 0, 1));
	if ($sex !~ /^[MF]$/) {
		if ($defaultlanguage eq "F") {
			print "Sexe incorrect [$sex]. Entrez M ou F svp.\n";
		} else {
			print "Illegal gender [$sex]. Please input M or F.\n";
		}
		return 103;
	}
	if ($passwd eq "") {
		return 108 if (($passwd = typepasswd()) eq "");
	}
	if (verify_password($passwd) == 0) {
		return 104;
	}
	print $so pack("va24a24a1a40", 0x7930, $userid, $passwd, $sex, "");
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x7931) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 106;
	}
	$buf = readso(28);
	if (unpack("V", $buf) == -1 || unpack("V", $buf) == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Echec � la cr�ation du compte [$userid]. Un compte identique existe d�j�.\n";
		} else {
			print "Account [$userid] creation failed. Same account already exists.\n";
		}
		return 107;
	} else {
		if ($defaultlanguage eq "F") {
			printf "Compte [$userid] cr�� avec succ�s [id: %d].\n", unpack("V",$buf);
		} else {
			printf "Account [$userid] is successfully created [id: %d].\n", unpack("V",$buf);
		}
	}
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: add an account with an e-mail
sub createaccount() {
	my($userid, $sex, $email, $passwd) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple> create nomtest Male mon\@email.com motdepassetest\n";
		} else {
			print "Please input an account name.\n";
			print "<example> create testname Male my\@mail.com testpass\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
#	if ($userid =~ /[^A-Za-z0-9\@-_]/) {
#		if ($defaultlanguage eq "F") {
#			print "Caract�re interdit trouv� dans le nom du compte ".$`."[${&}]${'}\n";
#		} else {
#			print "Illegal character found in the account name ".$`."[${&}]${'}\n";
#		}
#		return 101;
#	}
	$sex = uc(substr($sex, 0, 1));
	if ($sex !~ /^[MF]$/) {
		if ($defaultlanguage eq "F") {
			print "Sexe incorrect [$sex]. Entrez M ou F svp.\n";
		} else {
			print "Illegal gender [$sex]. Please input M or F.\n";
		}
		return 103;
	}
	if (length($email) < 3) {
		if ($defaultlanguage eq "F") {
			print "Email trop courte [$email]. Entrez une e-mail valide svp.\n";
		} else {
			print "Email is too short [$email]. Please input a valid e-mail.\n";
		}
		return 109;
	}
	if (length($email) > 39) {
		if ($defaultlanguage eq "F") {
			print "Email trop longue [$email]. Entrez une e-mail de 39 caract�res maximum svp.\n";
		} else {
			print "Email is too long [$email]. Please input an e-mail with 39 bytes at the most.\n";
		}
		return 109;
	}
	if (verify_email($email) == 0) {
		if ($defaultlanguage eq "F") {
			print "Email incorrecte [$email]. Entrez une e-mail valide svp.\n";
		} else {
			print "Invalid email [$email]. Please input a valid e-mail.\n";
		}
		return 109;
	}
	if ($passwd eq "") {
		return 108 if (($passwd = typepasswd()) eq "");
	}
	if (verify_password($passwd) == 0) {
		return 104;
	}
	print $so pack("va24a24a1a40", 0x7930, $userid, $passwd, $sex, $email);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x7931) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 106;
	}
	$buf = readso(28);
	if (unpack("V", $buf) == -1 || unpack("V", $buf) == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Echec � la cr�ation du compte [$userid]. Un compte identique existe d�j�.\n";
		} else {
			print "Account [$userid] creation failed. Same account already exists.\n";
		}
		return 107;
	} else {
		if ($defaultlanguage eq "F") {
			printf "Compte [$userid] cr�� avec succ�s [id: %d].\n", unpack("V",$buf);
		} else {
			printf "Account [$userid] is successfully created [id: %d].\n", unpack("V",$buf);
		}
	}
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: deletion of an account
sub delaccount() {
	my($userid) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple> del nomtestasupprimer\n";
		} else {
			print "Please input an account name.\n";
			print "<example> del testnametodelete\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
	if ($defaultlanguage eq "F") {
		print "** Etes-vous vraiment s�r de vouloir SUPPRIMER le compte [$userid]? (o/n) ";
	} else {
		print "** Are you really sure to DELETE account [$userid]? (y/n) ";
	}
	if (lc(substr(<STDIN>, 0, 1)) !~ /[oy]/) {
		if ($defaultlanguage eq "F") {
			print "Suppression annul�e\n.";
		} else {
			print "Deletion canceled\n";
		}
		return 121;
	}
	print $so pack("va24", 0x7932, $userid);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x7933) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 122;
	}
	$buf = readso(28);
	my($id2, $name) = unpack("Va24", $buf);
	while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
		chop($name);
	};
	if ($id2 == -1 || $id2 == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Echec de la suppression du compte [$userid]. Le compte n'existe pas.\n";
		} else {
			print "Account [$userid] deletion failed. Account doesn't exist.\n";
		}
		return 123;
	} else {
		if ($defaultlanguage eq "F") {
			print "Compte [$name][id: $id2] SUPPRIME avec succ�s.\n";
		} else {
			print "Account [$name][id: $id2] is successfully DELETED.\n";
		}
	}
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: modification of a password
sub changepasswd() {
	my($userid, $passwd) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple> passwd nomtest nouveaumotdepasse\n";
		} else {
			print "Please input an account name.\n";
			print "<example> passwd testname newpassword\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
	if ($passwd eq "") {
		return 134 if (($passwd = typepasswd()) eq "");
	}
	if (verify_password($passwd) == 0) {
		return 131;
	}
	print $so pack("va24a24", 0x7934, $userid,$passwd);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x7935) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 132;
	}
	$buf = readso(28);
	my($id2, $name) = unpack("Va24", $buf);
	while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
		chop($name);
	};
	if ($id2 == -1 || $id2 == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Echec de la modification du mot de passe du compte [$userid].\n";
			print "Le compte [$userid] n'existe pas.\n";
		} else {
			print "Account [$userid] password changing failed.\n";
			print "Account [$userid] doesn't exist.\n";
		}
		return 133;
	} else {
		if ($defaultlanguage eq "F") {
			print "Modification du mot de passe du compte [$name][id: $id2] r�ussie.\n";
		} else {
			print "Account [$name][id: $id2] password successfully changed.\n";
		}
	}
	return 130;
}

#--------------------------------------------------------------------------

# Sub-function: modification of an account e-mail
sub changeemail() {
	my($userid, $email) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple> email testname nouveauemail\n";
		} else {
			print "Please input an account name.\n";
			print "<example> email testname newemail\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
	if (length($email) < 3) {
		if ($defaultlanguage eq "F") {
			print "Email trop courte [$email]. Entrez une e-mail valide svp.\n";
		} else {
			print "Email is too short [$email]. Please input a valid e-mail.\n";
		}
		return 109;
	}
	if (length($email) > 39) {
		if ($defaultlanguage eq "F") {
			print "Email trop longue [$email]. Entrez une e-mail de 39 caract�res maximum svp.\n";
		} else {
			print "Email is too long [$email]. Please input an e-mail with 39 bytes at the most.\n";
		}
		return 109;
	}
	if (verify_email($email) == 0) {
		if ($defaultlanguage eq "F") {
			print "Email incorrect [$email]. Entrez une e-mail valide svp.\n";
		} else {
			print "Invalid email [$email]. Please input a valid e-mail.\n";
		}
		return 109;
	}
	print $so pack("va24a40", 0x7940, $userid, $email);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x7941) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 162;
	}
	$buf = readso(28);
	my($id2, $name) = unpack("Va24", $buf);
	while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
		chop($name);
	};
	if ($id2 == -1 || $id2 == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Echec de la modification de l'e-mail du compte [$userid].\n";
			print "Le compte [$userid] n'existe pas.\n";
		} else {
			print "Account [$userid] e-mail changing failed.\n";
			print "Account [$userid] doesn't exist.\n";
		}
		return 133;
	} else {
		if ($defaultlanguage eq "F") {
			print "Modification de l'e-mail du compte [$name][id: $id2] r�ussie.\n";
		} else {
			print "Account [$name][id: $id2] e-mail successfully changed.\n";
		}
	}
	return 160;
}

#--------------------------------------------------------------------------

# Sub-function: search of accounts
sub searchaccount() {
	my($p1, $p2) = @_;
	my($exp) = ("");
	if ($p1 eq "-e" || $p1 eq "-r" || $p1 eq "--regex" || $p1 eq "--expr") {
		if ($p2 eq "") {
			if ($defaultlanguage eq "F") {
				print "Entrez une expression r�guli�re ou utilisez 'ls' pour avoir tous les comptes.\n";
			} else {
				print "Input a regular expression or use 'ls' to obtain all accounts.\n";
			}
			return 141;
		}
		$exp = $p2;
	} else {
		if ($p1 eq "") {
			if ($defaultlanguage eq "F") {
				print "Entrez une cha�ne ou utilisez 'ls' pour avoir tous les comptes.\n";
			} else {
				print "Input a string or use 'ls' to obtain all accounts.\n";
			}
			return 141;
		}
		my($c) = 0;
		$exp = lc($p1);
		$exp =~ s/([\@])/\\$1/g;
		$c += $exp =~ s/([\-\[\]])/\\$1/g;
		$c += $exp =~ s/([\*\?])/.$1/g;
		$c += $exp =~ s/\\\[(.)\\\-(.)\\\]/[$1-$2]/g;
		$exp = "^$exp\$" if $c;
	}
	if (eval{ "" =~ /$exp/; }, $@) {
		if ($defaultlanguage eq "F") {
			print "Expression r�guli�re non reconnue.\n";
		} else {
			print "Regular-Expression compiling failed.\n";
		}
		return 141;
	}
	my($i);
	my($n, $st) = (0, 0);
	#      0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567
	if ($defaultlanguage eq "F") {
		print " id_compte GM nom_utilisateur         sexe   count statut\n";
	} else {
		print "account_id GM user_name               sex    count state\n";
	}
	print "-------------------------------------------------------------------------------\n";
	while(1) {
		print $so pack("vV2", 0x7920, $st, 0);
		$so->flush();
		$buf = readso(4);
		if (unpack("v", $buf) != 0x7921) {
			if ($defaultlanguage eq "F") {
				print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
			} else {
				print "Connection error to the server (incorrect answer).\n";
			}
			exit(10);
		}
		my($len) = unpack("x2v", $buf);
		last if ($len <= 4);
		for($i = 4; $i < $len; $i += 38) {
			my(@dat) = unpack("VCa24cVV", readso(38));
			$st = $dat[0] + 1;
			next if (lc($dat[2]) !~ /$exp/);
			printf "%10d %2s %-24s%-5s %6d %-27s\n", $dat[0],
			        ($dat[1] == 0 ? "  " : $dat[1]),
			        $dat[2],
			        ($defaultlanguage eq "F" ? ("Femme","Male","Servr")[$dat[3]] : ("Femal","Male","Servr")[$dat[3]]),
			        $dat[4],
			        (($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"),
			         "Unregistered ID",
			         "Incorrect Password",
			         "This ID is expired",
			         "Rejected from Server",
			         "Blocked by the GM Team", # You have been blocked by the GM Team
			         "Your EXE file is too old", # Your Game's EXE file is not the latest version
			         "Banishement or\n                                                   Prohibited to login until %s", # You are Prohibited to log in until %s
			         "Server is over populated", # Server is jammed due to over populated
			         "No MSG",
			         "This ID is totally erased")[$dat[5] == 100 ? 10 : $dat[5]]; # This ID has been totally erased
			$n++;
		}
	}
	if ($defaultlanguage eq "F") {
		if ($n == 0) {
			print "Aucun compte trouv�.\n";
		} elsif ($n == 1) {
			print "1 compte trouv�.\n";
		} else {
			print "$n comptes trouv�s.\n";
		}
	} else {
		if ($n == 0) {
			print "No account found.\n";
		} elsif ($n == 1) {
			print "1 account found.\n";
		} else {
			print "$n accounts found.\n";
		}
	}
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: modify the sex of an account
sub changesex() {
	my($userid, $sex) = @_;
	if ($userid eq "" || !defined($userid)) {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple> sex nomtest Male\n";
		} else {
			print "Please input an account name.\n";
			print "<example> sex testname Male\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
#	if ($userid =~ /[^A-Za-z0-9\@-_]/) {
#		if ($defaultlanguage eq "F") {
#			print "Caract�re interdit trouv� dans le nom du compte ".$`."[${&}]${'}\n";
#		} else {
#			print "Illegal character found in the account name ".$`."[${&}]${'}\n";
#		}
#		return 101;
#	}
	$sex = uc(substr($sex, 0, 1));
	if ($sex !~ /^[MF]$/) {
		if ($defaultlanguage eq "F") {
			print "Sexe incorrect [$sex]. Entrez M ou F svp.\n";
		} else {
			print "Illegal gender [$sex]. Please input M or F.\n";
		}
		return 103;
	}
	print $so pack("va24a1", 0x793c, $userid, $sex);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x793d) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 152;
	}
	$buf = readso(28);
	my($id2, $name) = unpack("Va24", $buf);
	while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
		chop($name);
	};
	if ($id2 == -1 || $id2 == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Echec du changement du sexe du compte [$userid].\n";
			print "Le compte n'existe pas ou le sexe est d�j� celui demand�.\n";
		} else {
			print "Account [$userid] sex changing failed.\n";
			print "Account doesn't exist or the sex is already the good sex.\n";
		}
	} else {
		if ($defaultlanguage eq "F") {
			print "Sexe du compte [$name][id: $id2] chang� avec succ�s.\n";
		} else {
			print "Account [$name][id: $id2] sex successfully changed.\n";
		}
	}
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: modify the GM level of an account
sub changegmlevel() {
	my($userid, $gm_level) = @_;
	if ($userid eq "" || !defined($userid)) {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple> gm nomtest 80\n";
		} else {
			print "Please input an account name.\n";
			print "<example> gm testname 80\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
#	if ($userid =~ /[^A-Za-z0-9\@-_]/) {
#		if ($defaultlanguage eq "F") {
#			print "Caract�re interdit trouv� dans le nom du compte ".$`."[${&}]${'}\n";
#		} else {
#			print "Illegal character found in the account name ".$`."[${&}]${'}\n";
#		}
#		return 101;
#	}
	$gm_level = int($gm_level);
	if ($gm_level < 0 || $gm_level > 99) {
		if ($defaultlanguage eq "F") {
			print "Niveau de GM incorrect [$gm_level]. Entrez une valeur de 0 � 99 svp.\n";
		} else {
			print "Illegal GM level [$gm_level]. Please input a value from 0 to 99.\n";
		}
		return 103;
	}
	print $so pack("va24C", 0x793e, $userid, $gm_level);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x793f) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 152;
	}
	$buf = readso(28);
	my($id2, $name) = unpack("Va24", $buf);
	while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
		chop($name);
	};
	if ($id2 == -1 || $id2 == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Echec du changement du niveau de GM du compte [$userid].\n";
			print "Le compte n'existe pas, le niveau de GM est d�j� celui demand�,\n";
			print "ou il est impossible de modifier le fichier des comptes GM.\n";
		} else {
			print "Account [$userid] GM level changing failed.\n";
			print "Account doesn't exist, the GM level is already the good GM level,\n";
			print "or it's impossible to modify the GM accounts file.\n";
		}
	} else {
		if ($defaultlanguage eq "F") {
			print "Niveau de GM du compte [$name][id: $id2] chang� avec succ�s.\n";
		} else {
			print "Account [$name][id: $id2] GM level successfully changed.\n";
		}
	}
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: Modification of a state
sub changestate {
	my($userid, $s, $error_message) = @_;
	# Valid values: 0: ok, or value of the 0x006a packet + 1
	if ($s eq "" || (($s < 0 || $s > 9) && $s != 100)) {
		if ($defaultlanguage eq "F") {
			print "Entrez une des valeurs suivantes svp:\n";
			print "  0 = Compte ok             6 = Your Game's EXE file is not the latest version\n";
		} else {
			print "Please input one of these values:\n";
			print "  0 = Account ok            6 = Your Game's EXE file is not the latest version\n";
		}
		print "  1 = Unregistered ID       7 = You are Prohibited to log in until %s\n";
		print "  2 = Incorrect Password    8 = Server is jammed due to over populated\n";
		print "  3 = This ID is expired    9 = No MSG\n";
		print "  4 = Rejected from Server  100 = This ID has been totally erased\n";
		print "  5 = You have been blocked by the GM Team\n";
		if ($defaultlanguage eq "F") {
			print "<exemples> state nomtest 5\n";
			print "           state nomtest 7 fin de votre ban\n";
			print "           block <nom du compte>\n";
			print "           unblock <nom du compte>\n";
		} else {
			print "<examples> state testname 5\n";
			print "           state testname 7 end of your ban\n";
			print "           block <account name>\n";
			print "           unblock <account name>\n";
		}
		return 151;
	}
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemples> state nomtest 5\n";
			print "           state nomtest 7 fin de votre ban\n";
			print "           block <nom du compte>\n";
			print "           unblock <nom du compte>\n";
		} else {
			print "Please input an account name.\n";
			print "<examples> state testname 5\n";
			print "           state testname 7 end of your ban\n";
			print "           block <account name>\n";
			print "           unblock <account name>\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
	if ($s != 7) {
		$error_message = "-";
	} else {
		if (length($error_message) < 1) {
			if ($defaultlanguage eq "F") {
				print "Message d'erreur trop court. Entrez un message de 1-19 caract�res.\n";
			} else {
				print "Error message is too short. Please input a message of 1-19 bytes.\n";
			}
			return 102;
		}
		if (length($error_message) > 19) {
			if ($defaultlanguage eq "F") {
				print "Message d'erreur trop long. Entrez un message de 1-19 caract�res.\n";
			} else {
				print "Error message is too long. Please input a message of 1-19 bytes.\n";
			}
			return 102;
		}
	}
	print $so pack("va24Va20", 0x7936, $userid, $s, $error_message);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x7937) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 152;
	}
	$buf = readso(32);
	my(@dat) = unpack("Va24V", $buf);
	while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) {
		chop($dat[1]);
	};
	if ($dat[0] != -1 && $dat[0] != 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Statut du compte [$dat[1]][id: $dat[0]] chang� avec succ�s en [";
		} else {
			print "Account [$dat[1]][id: $dat[0]] state successfully changed in [";
		}
		print ((($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"),
		  "Unregistered ID",
		  "Incorrect Password",
		  "This ID is expired",
		  "Rejected from Server",
		  "You have been blocked by the GM Team",
		  "Your Game's EXE file is not the latest version",
		  "You are Prohibited to log in until %s",
		  "Server is jammed due to over populated",
		  "No MSG",
		  "This ID has been totally erased")[$dat[2] == 100 ? 10 : $dat[2]]);
		print "].\n";
	} else {
		if ($defaultlanguage eq "F") {
			print "Echec du changement du statut du compte [$userid]. Le compte n'existe pas.\n";
		} else {
			print "Account [$userid] state changing failed. Account doesn't exist.\n";
		}
	}
}

#--------------------------------------------------------------------------

# Sub-function: Displaying of the number of online players
sub getlogincount {
	# Request to the login-server
	print $so pack("v", 0x7938);
	$so->flush();

	$buf = readso(4);
	# Connection failed
	if (unpack("v", $buf) != 0x7939) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		exit(3);
	}

	# Get length of the received packet
	my($len) = unpack("x2v", $buf) - 4;

	# Read information of the servers
	if ($len < 1) {
		if ($defaultlanguage eq "F") {
			printf "  Aucun serveur n'est connect� au login serveur.\n";
		} else {
			printf "  No server is connected to the login-server.\n";
		}
	} else {
		my(@slist) = ();
		for(; $len > 0; $len -= 32) {
			my($name, $count) = unpack("x6 a20 V", readso(32));
			$name = substr($name, 0, index($name, "\0"));
			push @slist, [ $name, $count ];
		}
		# Displaying of result
		my($i);
		if ($defaultlanguage eq "F") {
			printf "  Nombre de joueurs en ligne (serveur: nb):\n";
		} else {
			printf "  Number of online players (server: number).\n";
		}
		foreach $i(@slist) {
			printf "    %-20s : %5d\n", $i->[0], $i->[1];
		}
	}
}

#--------------------------------------------------------------------------

# Sub-function: Modification of a memo field
sub changememo {
	my($userid, $memo) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple> memo nomtest nouveau memo\n";
		} else {
			print "Please input an account name.\n";
			print "<example> memo testname new memo\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
	if (length($memo) > 254) {
		if ($defaultlanguage eq "F") {
			print "M�mo trop long (".length($memo)." caract�res).\n";
			print "Entrez un m�mo de 254 caract�res maximum svp.\n";
		} else {
			print "Memo is too long (".length($memo)." characters).\n";
			print "Please input a memo of 254 bytes at the maximum.\n";
		}
		return 102;
	}
	if (length($memo) == 0) {
		print $so pack("va24v", 0x7942, $userid, 0);
	} else {
		print $so pack("va24va".length($memo), 0x7942, $userid, length($memo), $memo);
	}
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x7943) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 152;
	}
	$buf = readso(28);
	my($id2, $name) = unpack("Va24", $buf);
	while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
		chop($name);
	};
	if ($id2 == -1 || $id2 == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Echec du changement du m�mo du compte [$userid]. Le compte n'existe pas.\n";
		} else {
			print "Account [$userid] memo changing failed. Account doesn't exist.\n";
		}
	} else {
		if ($defaultlanguage eq "F") {
			print "M�mo du compte [$name][id: $id2] chang� avec succ�s.\n";
		} else {
			print "Account [$name][id: $id2] memo successfully changed.\n";
		}
	}
}

#--------------------------------------------------------------------------

# Sub-function: Request to obtain an account id
sub idaccount() {
	my($userid) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple> id nomtest\n";
		} else {
			print "Please input an account name.\n";
			print "<example> id testname\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
	print $so pack("va24", 0x7944, $userid);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x7945) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 122;
	}
	$buf = readso(28);
	my($id2, $name) = unpack("Va24", $buf);
	while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
		chop($name);
	};
	if ($id2 == -1 || $id2 == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Impossible de trouver l'id du compte [$userid]. Le compte n'existe pas.\n";
		} else {
			print "Unabled to find the account [$userid] id. Account doesn't exist.\n";
		}
		return 123;
	} else {
		if ($defaultlanguage eq "F") {
			print "Le compte [$name] a pour id: $id2.\n";
		} else {
			print "The account [$name] have the id: $id2.\n";
		}
	}
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: Request to obtain an account name
sub nameaccount() {
	my($id) = @_;
	if ($id < 0) {
		if ($defaultlanguage eq "F") {
			print "Entrez un id ayant une valeur positive svp.\n";
		} else {
			print "Please input a positive value for the id.\n";
		}
		return 136;
	}
	print $so pack("vV", 0x7946, $id);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x7947) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 122;
	}
	$buf = readso(28);
	my($id2, $name) = unpack("Va24", $buf);
	while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
		chop($name);
	};
	if (length($name) == 0 || $name eq "") {
		if ($defaultlanguage eq "F") {
			print "Impossible de trouver le nom du compte [id: $id2]. Le compte n'existe pas.\n";
		} else {
			print "Unabled to find the account [id: $id2] name. Account doesn't exist.\n";
		}
		return 123;
	} else {
		if ($defaultlanguage eq "F") {
			print "Le compte [id: $id2] a pour nom: $name.\n";
		} else {
			print "The account [id: $id2] have the name: $name.\n";
		}
	}
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: Set a validity limit of an account
sub timesetaccount() {
	my($userid, $date, $time) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple>: timeset <nom_du_compte> aaaa/mm/jj [hh:mm:ss]\n";
			print "           timeset <nom_du_compte> 0    (0 = illimit�)\n";
			printf "          Heure par d�faut [hh:mm:ss]: 23:59:59\n";
		} else {
			print "Please input an account name.\n";
			print "<example>: timeset <account_name> yyyy/mm/dd [hh:mm:ss]\n";
			print "           timeset <account_name> 0   (0 = unlimited)\n";
			printf "          Default time [hh:mm:ss]: 23:59:59\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
	my($year, $month, $day) = split(/[.\-\/]/, $date);
	my($hour, $minute, $second) = split(/:/, $time);
	if ($time eq "") {
		$hour = 23;
		$minute = 59;
		$second = 59;
	}
	my($timestamp);
	if ($year eq "" ||
	    ($year != 0 && ($month eq "" || $day eq "" || $hour eq "" || $minute eq "" || $second eq ""))) {
		if ($defaultlanguage eq "F") {
			print "Entrez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n";
		} else {
			print "Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n";
		}
		return 102;
	}
	if ($year == 0) {
		$timestamp = 0;
	} else {
		if ($year < 70) {
			$year = $year + 100;
		}
		if ($year >= 1900) {
			$year = $year - 1900;
		}
		if ($month < 1 || $month > 12) {
			if ($defaultlanguage eq "F") {
				print "Entrez un mois correct svp (entre 1 et 12).\n";
			} else {
				print "Please give a correct value for the month (from 1 to 12).\n";
			}
			return 102;
		}
		$month = $month - 1;
		if ($day < 1 || $day > 31) {
			if ($defaultlanguage eq "F") {
				print "Entrez un jour correct svp (entre 1 et 31).\n";
			} else {
				print "Please give a correct value for the day (from 1 to 31).\n";
			}
			return 102;
		}
		if ((($month == 3 || $month == 5 || $month == 8 || $month == 10) && $day > 30) ||
		    ($month == 1 && $day > 29)) {
			if ($defaultlanguage eq "F") {
				print "Entrez un jour correct en fonction du mois svp.\n";
			} else {
				print "Please give a correct value for a day of this month.\n";
			}
			return 102;
		}
		if ($hour < 0 || $hour > 23) {
			if ($defaultlanguage eq "F") {
				print "Entrez une heure correcte svp (entre 0 et 23).\n";
			} else {
				print "Please give a correct value for the hour (from 0 to 23).\n";
			}
			return 102;
		}
		if ($minute < 0 || $minute > 59) {
			if ($defaultlanguage eq "F") {
				print "Entrez des minutes correctes svp (entre 0 et 59).\n";
			} else {
				print "Please give a correct value for the minutes (from 0 to 59).\n";
			}
			return 102;
		}
		if ($second < 0 || $second > 59) {
			if ($defaultlanguage eq "F") {
				print "Entrez des secondes correctes svp (entre 0 et 59).\n";
			} else {
				print "Please give a correct value for the seconds (from 0 to 59).\n";
			}
			return 102;
		}
		$timestamp = POSIX::mktime($second, $minute, $hour, $day, $month, $year, 0, 0, -1); # -1: no winter/summer time modification
		if ($timestamp == undef) {
			if ($defaultlanguage eq "F") {
				print "Date incorrecte.\n";
				print "Ajoutez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n";
			} else {
				print "Invalid date.\n";
				print "Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n";
			}
			return 102;
		}
	}

	print $so pack("va24V", 0x7948, $userid, $timestamp);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x7949) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 152;
	}
	$buf = readso(32);
	my(@dat) = unpack("Va24V", $buf);
	while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) {
		chop($dat[1]);
	};
	if ($dat[0] != -1 && $dat[0] != 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Limite de validit� du compte [$dat[1]][id: $dat[0]] chang�e avec succ�s ".
			($dat[2] == 0 ? "en [illimit�].\n" : "pour �tre jusqu'au ".(POSIX::ctime($dat[2])));
		} else {
			print "Validity Limit of the account [$dat[1]][id: $dat[0]] successfully changed ".
			($dat[2] == 0 ? "to [unlimited].\n" : "to be until ".(POSIX::ctime($dat[2])));
		}
		# localtime($dat[2]) is also possible to display instead of POSIX::ctime.
	} else {
		if ($defaultlanguage eq "F") {
			print "Echec du changement de la validit� du compte [$userid]. Le compte n'existe pas.\n";
		} else {
			print "Account [$userid] validity limit changing failed. Account doesn't exist.\n";
		}
	}

	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: Add/substract time to the validity limit of an account
sub timeaddaccount() {
	my($userid, $modif) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "  <exemple> timeadd nomtest +1m-2mn1s-6y\n";
			print "            Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n";
			print "            et 6 ans dans le m�me temps.\n";
		} else {
			print "Please input an account name.\n";
			print "  <example> timeadd testname +1m-2mn1s-6y\n";
			print "            this example adds 1 month and 1 second, and substracts 2 minutes\n";
			print "            and 6 years at the same time.\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
	my($year, $month, $day) = (0, 0 ,0);
	my($hour, $minute, $second) = (0, 0 ,0);

	$modif = lc($modif);
	while (length($modif) > 0) {
		my($value) = int($modif);
		if ($value == 0) {
			$modif = substr($modif, 1);
		} else {
			if (substr($modif, 0, 1) =~ /[\-\+]/) {
				$modif = substr($modif, 1);
			}
			while (length($modif) > 0 && substr($modif, 0, 1) =~ /[0-9]/) {
				$modif = substr($modif, 1);
			}
			if (index($modif, "s") == 0) {
				$second = $value;
				$modif = substr($modif, 1);
			} elsif (index($modif, "mn") == 0) {
				$minute = $value;
				$modif = substr($modif, 2);
			} elsif (index($modif, "h") == 0) {
				$hour = $value;
				$modif = substr($modif, 1);
			} elsif (index($modif, "d") == 0 || index($modif, "j") == 0) {
				$day = $value;
				$modif = substr($modif, 1);
			} elsif (index($modif, "m") == 0) {
				$month = $value;
				$modif = substr($modif, 1);
			} elsif (index($modif, "y") == 0 || index($modif, "a") == 0) {
				$year = $value;
				$modif = substr($modif, 1);
			} else {
				$modif = substr($modif, 1);
			}
		}
	}

	if ($defaultlanguage eq "F") {
		print " ann�e:   $year\n";
		print " mois:    $month\n";
		print " jour:    $day\n";
		print " heure:   $hour\n";
		print " minute:  $minute\n";
		print " seconde: $second\n";
	} else {
		print " year:   $year\n";
		print " month:  $month\n";
		print " day:    $day\n";
		print " hour:   $hour\n";
		print " minute: $minute\n";
		print " second: $second\n";
	}

	if ($year == 0 && $month == 0 && $day == 0 && $hour == 0 && $minute == 0 && $second == 0) {
		if ($defaultlanguage eq "F") {
			print "Vous devez entrer un ajustement avec cette commande, svp:\n";
			print "  Valeur d'ajustement (-1, 1, +1, etc...)\n";
			print "  Element modifi�:\n";
			print "    a ou y: ann�e\n";
			print "    m:      mois\n";
			print "    j ou d: jour\n";
			print "    h:      heure\n";
			print "    mn:     minute\n";
			print "    s:      seconde\n";
			print "  <exemple> timeadd nomtest +1m-2mn1s-6y\n";
			print "            Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n";
			print "            et 6 ans dans le m�me temps.\n";
		} else {
			print "Please give an adjustment with this command:\n";
			print "  Adjustment value (-1, 1, +1, etc...)\n";
			print "  Modified element:\n";
			print "    a or y: year\n";
			print "    m:      month\n";
			print "    j or d: day\n";
			print "    h:       hour\n";
			print "    mn:      minute\n";
			print "    s:       second\n";
			print "  <example> timeadd testname +1m-2mn1s-6y\n";
			print "            this example adds 1 month and 1 second, and substracts 2 minutes\n";
			print "            and 6 years at the same time.\n";
		}
		return 137;
	}
	if ($year > 127 || $year < -127) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement d'ann�es correct (de -127 � 127), svp.\n";
		} else {
			print "Please give a correct adjustment for the years (from -127 to 127).\n";
		}
		return 137;
	}
	if ($month > 255 || $month < -255) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement de mois correct (de -255 � 255), svp.\n";
		} else {
			print "Please give a correct adjustment for the months (from -255 to 255).\n";
		}
		return 137;
	}
	if ($day > 32767 || $day < -32767) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement de jours correct (de -32767 � 32767), svp.\n";
		} else {
			print "Please give a correct adjustment for the days (from -32767 to 32767).\n";
		}
		return 137;
	}
	if ($hour > 32767 || $hour < -32767) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement d'heures correct (de -32767 � 32767), svp.\n";
		} else {
			print "Please give a correct adjustment for the hours (from -32767 to 32767).\n";
		}
		return 137;
	}
	if ($minute > 32767 || $minute < -32767) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement de minutes correct (de -32767 � 32767), svp.\n";
		} else {
			print "Please give a correct adjustment for the minutes (from -32767 to 32767).\n";
		}
		return 137;
	}
	if ($second > 32767 || $second < -32767) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement de secondes correct (de -32767 � 32767), svp.\n";
		} else {
			print "Please give a correct adjustment for the seconds (from -32767 to 32767).\n";
		}
		return 137;
	}

	print $so pack("va24vvvvvv", 0x7950, $userid, $year, $month, $day, $hour, $minute, $second);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x7951) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 152;
	}
	$buf = readso(32);
	my(@dat) = unpack("Va24V", $buf);
	while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) {
		chop($dat[1]);
	};
	if ($dat[0] == -1 || $dat[0] == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Echec du changement de la validit� du compte [$userid]. Le compte n'existe pas.\n";
		} else {
			print "Account [$userid] validity limit changing failed. Account doesn't exist.\n";
		}
	} elsif ($dat[2] == 0) {
		if ($defaultlanguage eq "F") {
			print "Limite de validit� du compte [$dat[1]][id: $dat[0]] inchang�e.\n";
			print "Le compte a une validit� illimit�e ou\n";
			print "la modification est impossible avec les ajustements demand�s.\n";
		} else {
			print "Validity limit of the account [$dat[1]][id: $dat[0]] unchanged.\n";
			print "The account have an unlimited validity limit or\n";
			print "the changing is impossible with the proposed adjustments.\n";
		}
	} else {
		if ($defaultlanguage eq "F") {
			print "Limite de validit� du compte [$dat[1]][id: $dat[0]] chang�e avec succ�s ".
			($dat[2] == 0 ? "en [illimit�].\n" : "pour �tre jusqu'au ".(POSIX::ctime($dat[2])));
		} else {
			print "Validity limit of the account [$dat[1]][id: $dat[0]] successfully changed ".
			($dat[2] == 0 ? "to [unlimited].\n" : "to be until ".(POSIX::ctime($dat[2])));
		}
		# localtime($dat[2]) is also possible to display instead of POSIX::ctime.
	}

	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: Set the final date of a banishment of an account
sub bansetaccount() {
	my($userid, $date, $time) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple>: banset <nom_du_compte> aaaa/mm/jj [hh:mm:ss]\n";
			print "           banset <nom_du_compte> 0    (0 = d�-bani)\n";
			print "           ban/banish aaaa/mm/jj hh:mm:ss <nom du compte>\n";
			print "           unban/unbanish <nom du compte>\n";
			printf "          Heure par d�faut [hh:mm:ss]: 23:59:59\n";
		} else {
			print "Please input an account name.\n";
			print "<example>: banset <account_name> yyyy/mm/dd [hh:mm:ss]\n";
			print "           banset <account_name> 0   (0 = un-banished)\n";
			print "           ban/banish yyyy/mm/dd hh:mm:ss <account name>\n";
			print "           unban/unbanish <account name>\n";
			printf "          Default time [hh:mm:ss]: 23:59:59\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
	my($year, $month, $day) = split(/[.\-\/]/, $date);
	my($hour, $minute, $second) = split(/:/, $time);
	if ($time eq "") {
		$hour = 23;
		$minute = 59;
		$second = 59;
	}
	my($timestamp);
	if ($year eq "" ||
	    ($year != 0 && ($month eq "" || $day eq "" || $hour eq "" || $minute eq "" || $second eq ""))) {
		if ($defaultlanguage eq "F") {
			print "Entrez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n";
		} else {
			print "Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n";
		}
		return 102;
	}
	if ($year == 0) {
		$timestamp = 0;
	} else {
		if ($year < 70) {
			$year = $year + 100;
		}
		if ($year >= 1900) {
			$year = $year - 1900;
		}
		if ($month < 1 || $month > 12) {
			if ($defaultlanguage eq "F") {
				print "Entrez un mois correct svp (entre 1 et 12).\n";
			} else {
				print "Please give a correct value for the month (from 1 to 12).\n";
			}
			return 102;
		}
		$month = $month - 1;
		if ($day < 1 || $day > 31) {
			if ($defaultlanguage eq "F") {
				print "Entrez un jour correct svp (entre 1 et 31).\n";
			} else {
				print "Please give a correct value for the day (from 1 to 31).\n";
			}
			return 102;
		}
		if ((($month == 3 || $month == 5 || $month == 8 || $month == 10) && $day > 30) ||
		    ($month == 1 && $day > 29)) {
			if ($defaultlanguage eq "F") {
				print "Entrez un jour correct en fonction du mois svp.\n";
			} else {
				print "Please give a correct value for a day of this month.\n";
			}
			return 102;
		}
		if ($hour < 0 || $hour > 23) {
			if ($defaultlanguage eq "F") {
				print "Entrez une heure correcte svp (entre 0 et 23).\n";
			} else {
				print "Please give a correct value for the hour (from 0 to 23).\n";
			}
			return 102;
		}
		if ($minute < 0 || $minute > 59) {
			if ($defaultlanguage eq "F") {
				print "Entrez des minutes correctes svp (entre 0 et 59).\n";
			} else {
				print "Please give a correct value for the minutes (from 0 to 59).\n";
			}
			return 102;
		}
		if ($second < 0 || $second > 59) {
			if ($defaultlanguage eq "F") {
				print "Entrez des secondes correctes svp (entre 0 et 59).\n";
			} else {
				print "Please give a correct value for the seconds (from 0 to 59).\n";
			}
			return 102;
		}
		$timestamp = POSIX::mktime($second, $minute, $hour, $day, $month, $year, 0, 0, -1); # -1: no winter/summer time modification
		if ($timestamp == undef) {
			if ($defaultlanguage eq "F") {
				print "Date incorrecte.\n";
				print "Ajoutez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n";
			} else {
				print "Invalid date.\n";
				print "Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n";
			}
			return 102;
		}
	}

	print $so pack("va24V", 0x794a, $userid, $timestamp);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x794b) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 152;
	}
	$buf = readso(32);
	my(@dat) = unpack("Va24V", $buf);
	while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) {
		chop($dat[1]);
	};
	if ($dat[0] != -1 && $dat[0] != 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Date finale de banissement du compte [$dat[1]][id: $dat[0]] chang�e avec succ�s ".
			($dat[2] == 0 ? "en [d�-bannie].\n" : "pour �tre jusqu'au ".(POSIX::ctime($dat[2])));
		} else {
			print "Final date of banishment of the account [$dat[1]][id: $dat[0]] successfully changed ".
			($dat[2] == 0 ? "to [unbanished].\n" : "to be until ".(POSIX::ctime($dat[2])));
		}
		# localtime($dat[2]) is also possible to display instead of POSIX::ctime.
	} else {
		if ($defaultlanguage eq "F") {
			print "Echec du changement de la date finale de banissement du compte [$userid]. Le compte n'existe pas.\n";
		} else {
			print "Account [$userid] final date of banishment changing failed. Account doesn't exist.\n";
		}
	}

	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: Add/substract time to the final date of a banishment of an account
sub banaddaccount() {
	my($userid, $modif) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "  <exemple> banadd nomtest +1m-2mn1s-6y\n";
			print "            Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n";
			print "            et 6 ans dans le m�me temps.\n";
		} else {
			print "Please input an account name.\n";
			print "  <example> banadd testname +1m-2mn1s-6y\n";
			print "            this example adds 1 month and 1 second, and substracts 2 minutes\n";
			print "            and 6 years at the same time.\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
	my($year, $month, $day) = (0, 0 ,0);
	my($hour, $minute, $second) = (0, 0 ,0);

	$modif = lc($modif);
	while (length($modif) > 0) {
		my($value) = int($modif);
		if ($value == 0) {
			$modif = substr($modif, 1);
		} else {
			if (substr($modif, 0, 1) =~ /[\-\+]/) {
				$modif = substr($modif, 1);
			}
			while (length($modif) > 0 && substr($modif, 0, 1) =~ /[0-9]/) {
				$modif = substr($modif, 1);
			}
			if (index($modif, "s") == 0) {
				$second = $value;
				$modif = substr($modif, 1);
			} elsif (index($modif, "mn") == 0) {
				$minute = $value;
				$modif = substr($modif, 2);
			} elsif (index($modif, "h") == 0) {
				$hour = $value;
				$modif = substr($modif, 1);
			} elsif (index($modif, "d") == 0 || index($modif, "j") == 0) {
				$day = $value;
				$modif = substr($modif, 1);
			} elsif (index($modif, "m") == 0) {
				$month = $value;
				$modif = substr($modif, 1);
			} elsif (index($modif, "y") == 0 || index($modif, "a") == 0) {
				$year = $value;
				$modif = substr($modif, 1);
			} else {
				$modif = substr($modif, 1);
			}
		}
	}

	if ($defaultlanguage eq "F") {
		print " ann�e:   $year\n";
		print " mois:    $month\n";
		print " jour:    $day\n";
		print " heure:   $hour\n";
		print " minute:  $minute\n";
		print " seconde: $second\n";
	} else {
		print " year:   $year\n";
		print " month:  $month\n";
		print " day:    $day\n";
		print " hour:   $hour\n";
		print " minute: $minute\n";
		print " second: $second\n";
	}

	if ($year == 0 && $month == 0 && $day == 0 && $hour == 0 && $minute == 0 && $second == 0) {
		if ($defaultlanguage eq "F") {
			print "Vous devez entrer un ajustement avec cette commande, svp:\n";
			print "  Valeur d'ajustement (-1, 1, +1, etc...)\n";
			print "  Element modifi�:\n";
			print "    a ou y: ann�e\n";
			print "    m:      mois\n";
			print "    j ou d: jour\n";
			print "    h:      heure\n";
			print "    mn:     minute\n";
			print "    s:      seconde\n";
			print "  <exemple> banadd nomtest +1m-2mn1s-6y\n";
			print "            Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n";
			print "            et 6 ans dans le m�me temps.\n";
		} else {
			print "Please give an adjustment with this command:\n";
			print "  Adjustment value (-1, 1, +1, etc...)\n";
			print "  Modified element:\n";
			print "    a or y: year\n";
			print "    m: month\n";
			print "    j or d: day\n";
			print "    h: hour\n";
			print "    mn: minute\n";
			print "    s: second\n";
			print "  <example> banadd testname +1m-2mn1s-6y\n";
			print "            this example adds 1 month and 1 second, and substracts 2 minutes\n";
			print "            and 6 years at the same time.\n";
		}
		return 137;
	}
	if ($year > 127 || $year < -127) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement d'ann�es correct (de -127 � 127), svp.\n";
		} else {
			print "Please give a correct adjustment for the years (from -127 to 127).\n";
		}
		return 137;
	}
	if ($month > 255 || $month < -255) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement de mois correct (de -255 � 255), svp.\n";
		} else {
			print "Please give a correct adjustment for the months (from -255 to 255).\n";
		}
		return 137;
	}
	if ($day > 32767 || $day < -32767) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement de jours correct (de -32767 � 32767), svp.\n";
		} else {
			print "Please give a correct adjustment for the days (from -32767 to 32767).\n";
		}
		return 137;
	}
	if ($hour > 32767 || $hour < -32767) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement d'heures correct (de -32767 � 32767), svp.\n";
		} else {
			print "Please give a correct adjustment for the hours (from -32767 to 32767).\n";
		}
		return 137;
	}
	if ($minute > 32767 || $minute < -32767) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement de minutes correct (de -32767 � 32767), svp.\n";
		} else {
			print "Please give a correct adjustment for the minutes (from -32767 to 32767).\n";
		}
		return 137;
	}
	if ($second > 32767 || $second < -32767) {
		if ($defaultlanguage eq "F") {
			print "Entrez un ajustement de secondes correct (de -32767 � 32767), svp.\n";
		} else {
			print "Please give a correct adjustment for the seconds (from -32767 to 32767).\n";
		}
		return 137;
	}

	print $so pack("va24vvvvvv", 0x794c, $userid, $year, $month, $day, $hour, $minute, $second);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x794d) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 152;
	}
	$buf = readso(32);
	my(@dat) = unpack("Va24V", $buf);
	while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) {
		chop($dat[1]);
	};
	if ($dat[0] == -1 || $dat[0] == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Echec du changement de la date finale de banissement du compte [$userid]. Le compte n'existe pas.\n";
		} else {
			print "Account [$userid] final date of banishment changing failed. Account doesn't exist.\n";
		}
	} else {
		if ($defaultlanguage eq "F") {
			print "Date finale de banissement du compte [$dat[1]][id: $dat[0]] chang�e avec succ�s ".
			($dat[2] == 0 ? "en [d�-bannie].\n" : "pour �tre jusqu'au ".(POSIX::ctime($dat[2])));
		} else {
			print "Final date of banishment of the account [$dat[1]][id: $dat[0]] successfully changed ".
			($dat[2] == 0 ? "to [unbanished].\n" : "to be until ".(POSIX::ctime($dat[2])));
		}
		# localtime($dat[2]) is also possible to display instead of POSIX::ctime.
	}

	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: Request to displaying information about an account (by its name)
sub whoaccount() {
	my($userid) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple> who nomtest\n";
		} else {
			print "Please input an account name.\n";
			print "<example> who testname\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}

	print $so pack("va24", 0x7952, $userid);
	$so->flush();

	$buf = readso(2);
	if (unpack("v", $buf) != 0x7953) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 122;
	}
	my($id2, $GM_level, $name, $sex, $count, $status, $error_message, $last_login, $last_ip, $email, $validite, $ban_date, $memo_size) = unpack("VCa24cVVa20a24a16a40VVv", readso(148));
	my($memo) = "";
	if ($memo_size > 0) {
		$memo = unpack("a".$memo_size, readso($memo_size));
	}
	while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
		chop($name);
	};
	while (length($error_message) > 0 && substr($error_message, length($error_message)-1, 1) eq chr(0)) {
		chop($error_message);
	};
	while (length($last_login) > 0 && substr($last_login, length($last_login)-1, 1) eq chr(0)) {
		chop($last_login);
	};
	while (length($last_ip) > 0 && substr($last_ip, length($last_ip)-1, 1) eq chr(0)) {
		chop($last_ip);
	};
	while (length($email) > 0 && substr($email, length($email)-1, 1) eq chr(0)) {
		chop($email);
	};
	while (length($memo) > 0 && substr($memo, length($memo)-1, 1) eq chr(0)) {
		chop($memo);
	};

	if ($id2 == -1 || $id2 == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Impossible de trouver le compte [$userid]. Le compte n'existe pas.\n";
		} else {
			print "Unabled to find the account [$userid]. Account doesn't exist.\n";
		}
		return 123;
	} else {
		if ($defaultlanguage eq "F") {
			print "Le compte [$userid] a les caract�ristiques suivantes:\n";
		} else {
			print "The account [$userid] is set with:\n";
		}
		if ($GM_level == 0) {
			print " Id:     $id2 (non-GM)\n";
		} else {
			if ($defaultlanguage eq "F") {
				print " Id:     $id2 (GM niveau $GM_level)\n";
			} else {
				print " Id:     $id2 (GM level $GM_level)\n";
			}
		}
		if ($defaultlanguage eq "F") {
			print " Nom:    '$name'\n";
			print " Sexe:   ".("Femme", "Male", "Serveur")[$sex]."\n";
		} else {
			print " Name:   '$name'\n";
			print " Sex:    ".("Female", "Male", "Server")[$sex]."\n";
		}
		print " E-mail: $email\n";
		if ($status == 7) {
			print " Statut: 7 [You are Prohibited to log in until $error_message]\n";
		} else {
			print " Statut: $status [".(
			      ($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"),
			      "Unregistered ID",
			      "Incorrect Password",
			      "This ID is expired",
			      "Rejected from Server",
			      "You have been blocked by the GM Team",
			      "Your Game's EXE file is not the latest version",
			      "You are Prohibited to log in until %s",
			      "Server is jammed due to over populated",
			      "No MSG",
			      "This ID is totally erased")[$status == 100 ? 10 : $status]."]\n";
		}
		if ($defaultlanguage eq "F") {
			print " Banissement: ".($ban_date == 0 ? "non banni.\n" : "jusqu'au ".(POSIX::ctime($ban_date)));
			print " Compteur: $count connexion".("s", "")[$count > 1 ? 0 : 1]."\n";
			print " Derni�re connexion le: $last_login (ip: $last_ip)\n";
			print " Limite de validit�: ".($validite == 0 ? "illimit�.\n" : "jusqu'au ".(POSIX::ctime($validite)));
		} else {
			print " Banishment: ".($ban_date == 0 ? "not banished.\n" : "until ".(POSIX::ctime($ban_date)));
			print " Count: $count connection".("s", "")[$count > 1 ? 0 : 1]."\n";
			print " Last connection at: $last_login (ip: $last_ip)\n";
			print " Validity limit: ".($validite == 0 ? "unlimited.\n" : "until ".(POSIX::ctime($validite)));
		}
		print " Memo:   '$memo'\n";
	}
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: Request to displaying information about an account (by its id)
sub infoaccount() {
	my($id) = @_;
	if ($id < 0) {
		if ($defaultlanguage eq "F") {
			print "Entrez un id ayant une valeur positive svp.\n";
		} else {
			print "Please input a positive value for the id.\n";
		}
		return 136;
	}

	print $so pack("vV", 0x7954, $id);
	$so->flush();

	$buf = readso(2);
	if (unpack("v", $buf) != 0x7953) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 122;
	}
	my($id2, $GM_level, $name, $sex, $count, $status, $error_message, $last_login, $last_ip, $email, $validite, $ban_date, $memo_size) = unpack("VCa24cVVa20a24a16a40VVv", readso(148));
	my($memo) = "";
	if ($memo_size > 0) {
		$memo = unpack("a".$memo_size, readso($memo_size));
	}
	while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
		chop($name);
	};
	while (length($error_message) > 0 && substr($error_message, length($error_message)-1, 1) eq chr(0)) {
		chop($error_message);
	};
	while (length($last_login) > 0 && substr($last_login, length($last_login)-1, 1) eq chr(0)) {
		chop($last_login);
	};
	while (length($last_ip) > 0 && substr($last_ip, length($last_ip)-1, 1) eq chr(0)) {
		chop($last_ip);
	};
	while (length($email) > 0 && substr($email, length($email)-1, 1) eq chr(0)) {
		chop($email);
	};
	while (length($memo) > 0 && substr($memo, length($memo)-1, 1) eq chr(0)) {
		chop($memo);
	};

	if (length($name) == 0 || $name eq "") {
		if ($defaultlanguage eq "F") {
			print "Impossible de trouver le nom du compte [id: $id2]. Le compte n'existe pas.\n";
		} else {
			print "Unabled to find the account [id: $id2] name. Account doesn't exist.\n";
		}
		return 123;
	} else {
		if ($defaultlanguage eq "F") {
			print "Le compte [id: $id2] a les caract�ristiques suivantes:\n";
		} else {
			print "The account [id: $id2] is set with:\n";
		}
		if ($GM_level == 0) {
			print " Id:     $id2 (non-GM)\n";
		} else {
			if ($defaultlanguage eq "F") {
				print " Id:     $id2 (GM niveau $GM_level)\n";
			} else {
				print " Id:     $id2 (GM level $GM_level)\n";
			}
		}
		if ($defaultlanguage eq "F") {
			print " Nom:    '$name'\n";
			print " Sexe:   ".("Femme", "Male", "Serveur")[$sex]."\n";
		} else {
			print " Name:   '$name'\n";
			print " Sex:    ".("Female", "Male", "Server")[$sex]."\n";
		}
		print " E-mail: $email\n";
		if ($status == 7) {
			print " Statut: 7 [You are Prohibited to log in until $error_message]\n";
		} else {
			print " Statut: $status [".(
			      ($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"),
			      "Unregistered ID",
			      "Incorrect Password",
			      "This ID is expired",
			      "Rejected from Server",
			      "You have been blocked by the GM Team",
			      "Your Game's EXE file is not the latest version",
			      "You are Prohibited to log in until %s",
			      "Server is jammed due to over populated",
			      "No MSG",
			      "This ID is totally erased")[$status == 100 ? 10 : $status]."]\n";
		}
		if ($defaultlanguage eq "F") {
			print " Banissement: ".($ban_date == 0 ? "non banni.\n" : "jusqu'au ".(POSIX::ctime($ban_date)));
			print " Compteur: $count connexion".("s", "")[$count > 1 ? 0 : 1]."\n";
			print " Derni�re connexion le: $last_login (ip: $last_ip)\n";
			print " Limite de validit�: ".($validite == 0 ? "illimit�.\n" : "jusqu'au ".(POSIX::ctime($validite)));
		} else {
			print " Banishment: ".($ban_date == 0 ? "not banished.\n" : "until ".(POSIX::ctime($ban_date)));
			print " Count: $count connection".("s", "")[$count > 1 ? 0 : 1]."\n";
			print " Last connection at: $last_login (ip: $last_ip)\n";
			print " Validity limit: ".($validite == 0 ? "unlimited.\n" : "until ".(POSIX::ctime($validite)));
		}
		print " Memo:   '$memo'\n";
	}
	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: Check the validity of a password
# (Note: never send back a password with login-server!! security of passwords)
sub checkaccount() {
	my($userid, $passwd) = @_;
	if ($userid eq "") {
		if ($defaultlanguage eq "F") {
			print "Entrez un nom de compte svp.\n";
			print "<exemple> check testname motdepasse\n";
		} else {
			print "Please input an account name.\n";
			print "<example> check testname password\n";
		}
		return 136;
	}
	if (verify_accountname($userid) == 0) {
		return 102;
	}
	if ($passwd eq "") {
		return 134 if (($passwd = typepasswd()) eq "");
	}
	if (verify_password($passwd) == 0) {
		return 131;
	}
	print $so pack("va24a24", 0x793a, $userid,$passwd);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x793b) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 132;
	}
	$buf = readso(28);
	my($id2, $name) = unpack("Va24", $buf);
	while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
		chop($name);
	};
	if ($id2 == -1 || $id2 == 4294967295) {
		if ($defaultlanguage eq "F") {
			print "Le compte [$userid] n'existe pas ou le mot de passe est incorrect.\n";
		} else {
			print "The account [$userid] doesn't exist or the password is incorrect.\n";
		}
		return 133;
	} else {
		if ($defaultlanguage eq "F") {
			print "Le mot de passe donn� correspond bien au compte [$name][id: $id2].\n";
		} else {
			print "The proposed password is correct for the account [$name][id: $id2].\n";
		}
	}
	return 130;
}

#--------------------------------------------------------------------------

# Sub-function: Request to login-server to reload GM configuration file
sub reloadGM() {
	print $so pack("v", 0x7955);
	$so->flush();
	if ($defaultlanguage eq "F") {
		print "Demande de recharger le fichier de configuration des GM envoy�e.\n";
		print "V�rifiez les comptes GM actuels (apr�s rechargement):\n";
	} else {
		print "Request to reload the GM configuration file sended.\n";
		print "Check the actual GM accounts (after reloading):\n";
	}
	&listaccount(0, 0, 1); # 1: to list only GM
	return 180;
}

#--------------------------------------------------------------------------

# Sub-function: Send a broadcast message
sub sendbroadcast() {
	my($type, $message) = @_;
	if ($message eq "" || length($message) == 0) {
		if ($defaultlanguage eq "F") {
			print "Entrez un message svp.\n";
			if ($type == 0) {
				print "<exemple> kami un message\n";
			} else {
				print "<exemple> kamib un message\n";
			}
		} else {
			print "Please input a message.\n";
			if ($type == 0) {
				print "<example> kami a message\n";
			} else {
				print "<example> kamib a message\n";
			}
		}
		return 136;
	}

	print $so pack("vvVa".length($message), 0x794e, $type, length($message), $message);
	$so->flush();
	$buf = readso(2);
	if (unpack("v", $buf) != 0x794f) {
		if ($defaultlanguage eq "F") {
			print "Probl�me de connexion au serveur (r�ponse incorrecte).\n";
		} else {
			print "Connection error to the server (incorrect answer).\n";
		}
		return 152;
	}
	$buf = readso(2);
	my($answer) = unpack("v", $buf);
	if ($answer == -1 || $answer == 65535) {
		if ($defaultlanguage eq "F") {
			print "Echec de l'envoi du message. Aucun server de char en ligne.\n";
		} else {
			print "Message sending failed. No online char-server.\n";
		}
	} else {
		if ($defaultlanguage eq "F") {
			print "Message transmis au server de logins avec succ�s.\n";
		} else {
			print "Message successfully sended to login-server.\n";
		}
	}
}

#--------------------------------------------------------------------------

# Sub-function: Change language of displaying
sub changelanguage() {
	my($language) = @_;
	if ($language eq "" || length($language) == 0) {
		if ($defaultlanguage == 'F') {
			printf("Entrez une langue svp.\n");
			printf("<exemple> language english\n");
			printf("          language fran�ais\n");
		} else {
			printf("Please input a language.\n");
			printf("<example> language english\n");
			printf("          language fran�ais\n");
		}
		return 136;
	}

	$language = uc(substr($language, 0, 1));
	if ($language =~ /^[EF]$/) {
		$defaultlanguage = $language;
		if ($defaultlanguage == 'F') {
			printf("Changement de la langue d'affichage en Fran�ais.\n");
		} else {
			printf("Displaying language changed to English.\n");
		}
	} else {
		if ($defaultlanguage == 'F') {
			printf("Langue non param�tr�e (langues possibles: 'Fran�ais' ou 'English').\n");
		} else {
			printf("Undefined language (possible languages: Fran�ais or English).\n");
		}
	}

	return 0;
}

#--------------------------------------------------------------------------

# Sub-function: sending 'end of connection' packet
sub quit() {
	print $so pack("v", 0x7532);
	$so->flush();
}

#--------------------------------------------------------------------------

# Sub-function: Get datas from the socket
sub readso() {
	my($len) = shift;
	my($buf);
	if (read($so, $buf, $len) < $len) {
		if ($defaultlanguage eq "F") {
			print "Erreur de lecture sur la Socket.\n";
		} else {
			print "Socket read error.\n";
		}
		exit(3);
	}
	return $buf;
}

#--------------------------------------------------------------------------

# Sub-function: Input of a password
sub typepasswd {
	my($passwd1, $passwd2);
	cbreak();
	if ($defaultlanguage eq "F") {
		print "Entrez le mot de passe > "; $passwd1 = <STDIN>; chomp($passwd1); print "\n";
		print "R�-entrez le mot de passe > "; $passwd2 = <STDIN>; chomp($passwd2); print "\n";
	} else {
		print "Type the password > "; $passwd1 = <STDIN>; chomp($passwd1); print "\n";
		print "Verify the password > "; $passwd2 = <STDIN>; chomp($passwd2); print "\n";
	}
	cooked();
	if ($passwd1 ne $passwd2) {
		if ($defaultlanguage eq "F") {
			print "Erreur de v�rification du mot de passe: Saisissez le m�me mot de passe svp.\n";
		} else {
			print "Password verification failed. Please input same password.\n";
		}
		return "";
	}
	return $passwd1;
}

#--------------------------------------------------------------------------

# Sub-function: Return ordonal text of a number
sub makeordinal {
	my($c) = shift;
	if ($defaultlanguage eq "F") {
		if ($c < 1) {
			return $c;
		}
		return $c.("er", "�me")[$c == 1 ? 0 : 1];
	} else {
		if ($c % 10 < 4 && $c % 10 != 0 && ($c < 10 || $c > 20)) {
			return $c.("st","nd","rd")[$c % 10 - 1];
		}
		return $c."th";
	}
}

#--------------------------------------------------------------------------

# Sub-function: Test of the validity of an account name (return 0 if incorrect, and 1 if ok)
sub verify_accountname {
	my($account_name) = @_;       # Get the account_name
	if ($account_name =~ /[\x00-\x1f]/) { # remove control char
		my($c) = length($`) + 1;
		if ($defaultlanguage eq "F") {
			print "Caract�re interdit trouv� dans le nom du compte (".makeordinal($c)." caract�re).\n";
		} else {
			print "Illegal character found in the account name (".makeordinal($c)." character).\n";
		}
		return 0;
	}
	if (length($account_name) < 4) {
		if ($defaultlanguage eq "F") {
			print "Nom du compte trop court. Entrez un nom de compte de 4-23 caract�res.\n";
		} else {
			print "Account name is too short. Please input an account name of 4-23 bytes.\n";
		}
		return 0;
	}
	if (length($account_name) > 23) {
		if ($defaultlanguage eq "F") {
			print "Nom du compte trop long. Entrez un nom de compte de 4-23 caract�res.\n";
		} else {
			print "Account name is too long. Please input an account name of 4-23 bytes.\n";
		}
		return 0;
	}
	return 1;
}

#--------------------------------------------------------------------------

# Sub-function: Test of the validity of password (return 0 if incorrect, and 1 if ok)
sub verify_password {
	my($password) = @_;       # Get the password
	if ($password =~ /[\x00-\x1f]/) {
		my($c) = length($`) + 1;
		if ($defaultlanguage eq "F") {
			print "Caract�re interdit trouv� dans le mot de passe (".makeordinal($c)." caract�re).\n";
		} else {
			print "Illegal character found in the password (".makeordinal($c)." character).\n";
		}
		return 0;
	}
	if (length($password) < 4) {
		if ($defaultlanguage eq "F") {
			print "Mot de passe trop court. Entrez un mot de passe de 4-23 caract�res.\n";
		} else {
			print "Password is too short. Please input a password of 4-23 bytes.\n";
		}
		return 0;
	}
	if (length($password) > 23) {
		if ($defaultlanguage eq "F") {
			print "Mot de passe trop long. Entrez un mot de passe de 4-23 caract�res.\n";
		} else {
			print "Password is too long. Please input a password of 4-23 bytes.\n";
		}
		return 0;
	}
	return 1;
}

#--------------------------------------------------------------------------

# Sub-function: Test of the validity of an e-mail (return 0 if incorrect, and 1 if ok)
sub verify_email {
	my($email) = @_;       # Get the e-mail
	# To ignore a '.' before the @ (wanadoo, a provider, do that)
	$email =~ s/\.\@/\@/;
	# If the e-mail is void, it's not correct -> return 0
	if ($email eq '') {
		return(0);
	}
	# If the e-mail have no "@", it's not correct -> return 0
	if ($email !~ /\@/) {
		return(0);
	}
	# If the e-mail have a ",", a space, a tab or a ";", it's not correct -> return 0
	if ($email =~ /[\,|\s|\;]/) {
		return(0)
	};
	# IF
	#    (the e-mail contains 2 "@", or ".." or "@." or starts or finishes by a ".")
	# OR IF
	#    (the e-mail doesn't contain "@localhost" AND
	# - it doesn't contain characters followed by "@" itself followed by letters itself followed by "." and 2 or more letters
	# - or an IP address)
	# -> so, it's not good ! (finish !)
	if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/ ||
		($email !~ /^.+\@localhost$/ &&
		$email !~ /^.+\@\[?(\w|[-.])+\.[a-zA-Z]{2,3}|[0-9]{1,3}\]?$/)) {
		return(0); # non-valid email
	} else {
		# If not, the e-email address is correct
		return(1); # valid email
	}
}