-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathnew_staff_actions.php
executable file
·1836 lines (1763 loc) · 56.9 KB
/
new_staff_actions.php
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
<?php
if (!defined('IN_STAFF'))
{
header('HTTP/1.1 400 Bad Request');
exit;
}
// Admin/Secretary/Assistant
function fed_user_form()
{
global $ir, $c, $h, $userid;
print
"<h3>Jailing User</h3>
The user will be put in fed jail and will be unable to do anything in the game.<br />
<form action='new_staff.php?action=fedsub' method='post'>
User: " . user_dropdown($c, 'user', $_GET['XID'])
. "<br />
Days: <input type='text' name='days' /><br />
Reason: <input type='text' name='reason' /><br />
<input type='submit' value='Jail User' /></form>";
}
function fed_user_submit()
{
global $ir, $c, $h, $userid;
$ins_user = abs((int) $_POST['user']);
$ins_days = abs((int) $_POST['days']);
$ins_reason =
mysql_real_escape_string(
htmlentities(stripslashes($_POST['reason']), ENT_QUOTES,
'ISO-8859-1'), $c);
$q = mysql_query("SELECT * FROM users WHERE userid={$ins_user}", $c);
if (mysql_num_rows($q) == 0)
{
return;
}
$r = mysql_fetch_array($q);
if (($ir['user_level'] != 2)
&& ($r['user_level'] == 2 || $r['user_level'] == 3))
{
print "You cannot jail other staff.";
}
else
{
$re =
mysql_query(
"UPDATE users SET fedjail=1 WHERE userid={$ins_user}",
$c);
if (mysql_affected_rows($c))
{
mysql_query(
"INSERT INTO fedjail VALUES(NULL,{$ins_user},{$ins_days},$userid,'{$ins_reason}')",
$c);
}
mysql_query(
"INSERT INTO jaillogs VALUES(NULL,$userid, {$ins_user}, {$ins_days}, '{$ins_reason}',"
. time() . ")", $c);
print "User jailed.";
}
}
function unfed_user_form()
{
global $ir, $c, $h, $userid;
print
"<h3>Unjailing User</h3>
The user will be taken out of fed jail.<br />
<form action='new_staff.php?action=unfedsub' method='post'>
User: " . fed_user_dropdown($c, 'user')
. "<br />
<input type='submit' value='Unjail User' /></form>";
}
function unfed_user_submit()
{
global $ir, $c, $h, $userid;
$ins_user = abs((int) $_POST['user']);
mysql_query("UPDATE users SET fedjail=0 WHERE userid={$ins_user}", $c);
mysql_query("DELETE FROM fedjail WHERE fed_userid={$ins_user}", $c);
mysql_query(
"INSERT INTO unjaillogs VALUES(NULL,$userid, {$ins_user}, "
. time() . ")", $c);
print "User unjailed.";
}
function view_attack_logs()
{
global $ir, $c, $h, $userid;
print
"<h3>Attack Logs</h3>
<table width=75%><tr style='background:gray'><th>Time</th><th>Detail</th></tr>";
$q = mysql_query("SELECT * FROM attacklogs ORDER BY time DESC", $c);
while ($r = mysql_fetch_array($q))
{
print
"<tr><td>" . date('F j, Y, g:i:s a', $r['time'])
. "</td><td>{$r['attacker']} attacked {$r['attacked']} and {$r['result']} and stole \${$r['stole']}</td></tr>";
}
print "</table>";
}
function ip_search_form()
{
global $ir, $c, $h, $userid;
print
"<h3>IP Search</h3>
<form action='new_staff.php?action=ipsub' method='post'>
IP: <input type='text' name='ip' value='...' /><br />
<input type='submit' value='Search' /></form>";
}
function ip_search_submit()
{
global $ir, $c, $h, $userid;
$disp_ip =
htmlentities(stripslashes($_POST['ip']), ENT_QUOTES, 'ISO-8859-1');
$mysql_ip = mysql_real_escape_string(stripslashes($_POST['ip']), $c);
print
"Searching for users with the IP: <b>{$disp_ip}</b><br />
<table width=75%><tr style='background:gray'> <th>User</th> <th>Level</th> <th>Money</th> </tr>";
$q = mysql_query("SELECT * FROM users WHERE lastip='{$mysql_ip}'", $c);
$ids = array();
while ($r = mysql_fetch_array($q))
{
$ids[] = $r['userid'];
print
"\n<tr> <td> <a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a></td> <td> {$r['level']}</td> <td>{$r['money']}</td> </tr>";
}
print
"</table><br />
<b>Mass Jail</b><br />
<form action='new_staff.php?action=massjailip' method='post'>
<input type='hidden' name='ids' value='" . implode(",", $ids)
. "' /> Days: <input type='text' name='days' value='300' /> <br />
Reason: <input type='text' name='reason' value='Same IP users, Mail [email protected] with your case.' /><br />
<input type='submit' value='Mass Jail' /></form>";
}
function mass_jail()
{
global $ir, $c, $h, $userid;
$ids = explode(",", $_POST['ids']);
$ins_days = abs((int) $_POST['days']);
$ins_reason =
mysql_real_escape_string(
htmlentities(stripslashes($_POST['reason']), ENT_QUOTES,
'ISO-8859-1'), $c);
foreach ($ids as $id)
{
if (ctype_digit($id))
{
$q = mysql_query("SELECT * FROM users WHERE userid=$id", $c);
if (mysql_num_rows($q) == 0)
{
continue;
}
$r = mysql_fetch_array($q);
if (($ir['user_level'] != 2)
&& ($r['user_level'] == 2 || $r['user_level'] == 3))
{
print "You cannot jail other staff.";
}
else
{
$re =
mysql_query(
"UPDATE users SET fedjail=1 WHERE userid={$id}",
$c);
if (mysql_affected_rows($c))
{
mysql_query(
"INSERT INTO fedjail VALUES(NULL,{$id},{$ins_days},$userid,'{$ins_reason}')",
$c);
}
mysql_query(
"INSERT INTO jaillogs VALUES(NULL,$userid, {$id}, {$ins_days}, '{$ins_reason}',"
. time() . ")", $c);
print "User jailed : $id.";
}
}
}
}
function view_itm_logs()
{
global $ir, $c, $h, $userid;
print
"<h3>Item Xfer Logs</h3>
<table width=75%><tr style='background:gray'><th>Time</th><th>Detail</th></tr>";
$q =
mysql_query(
"SELECT ix.*,u1.username as sender, u2.username as sent,i.itmname as item
FROM itemxferlogs ix
LEFT JOIN users u1 ON ix.ixFROM=u1.userid
LEFT JOIN users u2 ON ix.ixTO=u2.userid
LEFT JOIN items i ON i.itmid=ix.ixITEM
ORDER BY ix.ixTIME DESC", $c);
while ($r = mysql_fetch_array($q))
{
print
"<tr><td>" . date("F j, Y, g:i:s a", $r['ixTIME'])
. "</td><td>{$r['sender']} sent {$r['ixQTY']} {$r['item']}(s) to {$r['sent']} </td></tr>";
}
print "</table>";
}
function view_cash_logs()
{
global $ir, $c, $h, $userid;
print
"<h3>Cash Xfer Logs</h3>
<table width=75% border=1> <tr style='background:gray'> <th>ID</th> <th>Time</th> <th>User From</th> <th>User To</th> <th>Multi?</th> <th>Amount</th> <th> </th> </tr>";
$q =
mysql_query(
"SELECT cx.*,u1.username as sender, u2.username as sent FROM cashxferlogs cx LEFT JOIN users u1 ON cx.cxFROM=u1.userid LEFT JOIN users u2 ON cx.cxTO=u2.userid ORDER BY cx.cxTIME DESC",
$c)
or die(
mysql_error() . "<br />"
. "SELECT cx.*,u1.username as sender, u2.username as sent FROM cashxferlogs cx LEFT JOIN users u1 ON cx.cxFROM=u1.userid LEFT JOIN users u2 ON cx.cxTO=u2.userid ORDER BY cx.cxTIME DESC");
while ($r = mysql_fetch_array($q))
{
if ($r['cxFROMIP'] == $r['cxTOIP'])
{
$m = "<span style='color:red;font-weight:800'>MULTI</span>";
}
else
{
$m = "";
}
print
"<tr><td>{$r['cxID']}</td> <td>"
. date("F j, Y, g:i:s a", $r['cxTIME'])
. "</td><td><a href='viewuser.php?u={$r['cxFROM']}'>{$r['sender']}</a> [{$r['cxFROM']}] (IP: {$r['cxFROMIP']}) </td><td><a href='viewuser.php?u={$r['cxTO']}'>{$r['sent']}</a> [{$r['cxTO']}] (IP: {$r['cxTOIP']}) </td> <td>$m</td> <td> \${$r['cxAMOUNT']}</td> <td> [<a href='new_staff.php?action=fedform&XID={$r['cxFROM']}'>Jail Sender</a>] [<a href='new_staff.php?action=fedform&XID={$r['cxTO']}'>Jail Receiver</a>]</td> </tr>";
}
print "</table>";
}
// Admin or Secretary
function give_item_form()
{
global $ir, $c;
print
"<h3>Giving Item To User</h3>
<form action='new_staff.php?action=giveitemsub' method='post'>
User: " . user_dropdown($c, 'user') . "<br />
Item: " . item_dropdown($c, 'item')
. "<br />
Quantity: <input type='text' name='qty' value='1' /><br />
<input type='submit' value='Give Item' /></form>";
}
function give_item_submit()
{
global $ir, $c;
$_POST['item'] = abs(@intval($_POST['item']));
$_POST['user'] = abs(@intval($_POST['user']));
$_POST['qty'] = abs(@intval($_POST['qty']));
$d =
mysql_query(
"SELECT COUNT(itmid) FROM items WHERE itmid={$_POST['item']}",
$c);
if (mysql_result($d, 0, 0) == 0)
{
print "There is no such item.";
return;
}
mysql_query(
"INSERT INTO inventory VALUES(NULL,{$_POST['item']},{$_POST['user']},{$_POST['qty']})",
$c) or die(mysql_error());
print
"You gave {$_POST['qty']} of item ID {$_POST['item']} to user ID {$_POST['user']}";
}
function mail_user_form()
{
global $ir, $c, $h, $userid;
print
"<h3>Mail Banning User</h3>
The user will be banned from the mail system.<br />
<form action='new_staff.php?action=mailsub' method='post'>
User: " . user_dropdown($c, 'user', $_GET['XID'])
. "<br />
Days: <input type='text' name='days' /><br />
Reason: <input type='text' name='reason' /><br />
<input type='submit' value='Mailban User' /></form>";
}
function mail_user_submit()
{
global $ir, $c, $h, $userid;
$ins_user = abs((int) $_POST['user']);
$ins_days = abs((int) $_POST['days']);
$ins_reason =
mysql_real_escape_string(
htmlentities(stripslashes($_POST['reason']), ENT_QUOTES,
'ISO-8859-1'), $c);
$log_reason = stripslashes($_POST['reason']);
$re =
mysql_query(
"UPDATE users SET mailban={$ins_days},mb_reason='{$ins_reason}' WHERE userid={$ins_user}",
$c);
event_add($ins_user,
"You were banned from mail for {$ins_days} day(s) for the following reason: {$log_reason}",
$c);
print "User mail banned.";
}
function inv_user_begin()
{
global $ir, $c, $h, $userid;
print
"<h3>Viewing User Inventory</h3>
You may browse this user's inventory.<br />
<form action='new_staff.php?action=invuser' method='post'>
User: " . user_dropdown($c, 'user')
. "<br />
<input type='submit' value='View Inventory' /></form>";
}
function inv_user_view()
{
global $ir, $c, $h, $userid;
$test_user = abs((int) $_POST['user']);
$inv =
mysql_query(
"SELECT iv.*,i.*,it.* FROM inventory iv
LEFT JOIN items i ON iv.inv_itemid=i.itmid
LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid
WHERE iv.inv_userid={$test_user}", $c);
if (mysql_num_rows($inv) == 0)
{
print "<b>This person has no items!</b>";
}
else
{
print
"<b>Their items are listed below.</b><br />
<table width=100%><tr style='background-color:gray;'><th>Item</th><th>Sell Value</th><th>Total Sell Value</th><th>Links</th></tr>";
while ($i = mysql_fetch_array($inv))
{
print "<tr><td>{$i['itmname']}";
if ($i['inv_qty'] > 1)
{
print " x{$i['inv_qty']}";
}
print "</td><td>\${$i['itmsellprice']}</td><td>";
print "$" . ($i['itmsellprice'] * $i['inv_qty']);
print
"</td><td>[<a href='new_staff.php?action=deleinv&ID={$i['inv_id']}'>Delete</a>]";
print "</td></tr>";
}
print "</table>";
}
}
function inv_delete()
{
global $ir, $c, $h, $userid;
$del_id = abs((int) $_GET['ID']);
mysql_query("DELETE FROM inventory WHERE inv_id={$del_id}", $c);
print "Item deleted from inventory.";
}
function credit_user_form()
{
global $ir, $c, $h, $userid;
print
"<h3>Crediting User</h3>
You can give a user money/crystals.<br />
<form action='new_staff.php?action=creditsub' method='post'>
User: " . user_dropdown($c, 'user')
. "<br />
Money: <input type='text' name='money' /> Crystals: <input type='text' name='crystals' /><br />
<input type='submit' value='Credit User' /></form>";
}
function credit_user_submit()
{
global $ir, $c, $h, $userid;
$_POST['money'] = (int) $_POST['money'];
$_POST['crystals'] = (int) $_POST['crystals'];
$cred_user = abs((int) $_POST['user']);
mysql_query(
"UPDATE users u SET money=money+{$_POST['money']}, crystals=crystals+{$_POST['crystals']} WHERE u.userid={$cred_user}",
$c);
print "User credited.";
}
function view_mail_logs()
{
global $ir, $c, $h, $userid;
$_GET['st'] = abs((int) $_GET['st']);
$rpp = 100;
print
"<h3>Mail Logs</h3>
<table width=75% border=2> \n<tr style='background:gray'> <th>ID</th> <th>Time</th> <th>User From</th> <th>User To</th> <th width>Subj</th> <th width=30%>Msg</th> <th> </th> </tr>";
$q =
mysql_query(
"SELECT m.*,u1.username as sender, u2.username as sent FROM mail m LEFT JOIN users u1 ON m.mail_from=u1.userid LEFT JOIN users u2 ON m.mail_to=u2.userid WHERE m.mail_from != 0 ORDER BY m.mail_time DESC LIMIT {$_GET['st']},$rpp",
$c)
or die(
mysql_error() . "<br />"
. "SELECT cx.*,u1.username as sender, u2.username as sent FROM cashxferlogs cx LEFT JOIN users u1 ON cx.cxFROM=u1.userid LEFT JOIN users u2 ON cx.cxTO=u2.userid ORDER BY cx.cxTIME DESC LIMIT {$_GET['st']},$rpp");
while ($r = mysql_fetch_array($q))
{
print
"\n<tr><td>{$r['mail_id']}</td> <td>"
. date("F j, Y, g:i:s a", $r['mail_time'])
. "</td><td>{$r['sender']} [{$r['mail_from']}] </td> <td>{$r['sent']} [{$r['mail_to']}] </td> \n<td> {$r['mail_subject']}</td> \n<td>{$r['mail_text']}</td> <td> [<a href='new_staff.php?action=mailform&XID={$r['mail_from']}'>MailBan Sender</a>] [<a href='new_staff.php?action=mailform&XID={$r['mail_to']}'>MailBan Receiver</a>]</td> </tr>";
}
print "</table><br />
";
$q2 = mysql_query("SELECT mail_id FROM mail WHERE mail_from != 0", $c);
$rs = mysql_num_rows($q2);
$pages = ceil($rs / 20);
print "Pages: ";
for ($i = 1; $i <= $pages; $i++)
{
$st = ($i - 1) * 20;
print "<a href='new_staff.php?action=maillogs&st=$st'>$i</a> ";
if ($i % 7 == 0)
{
print "<br />\n";
}
}
}
function reports_view()
{
global $ir, $c, $h, $userid;
print
"<h3>Player Reports</h3>
<table width=80%><tr style='background:gray'><th>Reporter</th> <th>Offender</th> <th>What they did</th> <th> </th> </tr>";
$q =
mysql_query(
"SELECT pr.*,u1.username as reporter, u2.username as offender FROM preports pr LEFT JOIN users u1 ON u1.userid=pr.prREPORTER LEFT JOIN users u2 ON u2.userid=pr.prREPORTED ORDER BY pr.prID DESC",
$c) or die(mysql_error());
while ($r = mysql_fetch_array($q))
{
$report =
nl2br(htmlentities($r['prTEXT'], ENT_QUOTES, 'ISO-8859-1'));
print
"\n<tr>
<td><a href='viewuser.php?u={$r['prREPORTER']}'>{$r['reporter']}</a> [{$r['prREPORTER']}]</td>
<td><a href='viewuser.php?u={$r['prREPORTED']}'>{$r['offender']}</a> [{$r['prREPORTED']}]</td>
<td>{$report}</td>
<td><a href='new_staff.php?action=repclear&ID={$r['prID']}'>Clear</a></td>
</tr>";
}
print "</table>";
}
function report_clear()
{
global $ir, $c, $h, $userid;
$_GET['ID'] = abs((int) $_GET['ID']);
mysql_query("DELETE FROM preports WHERE prID={$_GET['ID']}", $c);
print
"Report cleared and deleted!<br />
<a href='new_staff.php?action=reportsview'>> Back</a>";
}
// Admins Only
function new_user_form()
{
global $ir, $c;
print
"Adding a new user.<br />
<form action='new_staff.php?action=newusersub' method='post'>
Username: <input type='text' name='username' /><br />
Login Name: <input type='text' name='login_name' /><br />
Email: <input type='text' name='email' /><br />
Password: <input type='text' name='userpass' /><br />
Type: <input type='radio' name='user_level' value='0' />NPC <input type='radio' name='user_level' value='1' checked='checked' />Regular Member<br />
Level: <input type='text' name='level' value='1' /><br />
Money: <input type='text' name='money' value='100' /><br />
Crystals: <input type='text' name='crystals' value='0' /><br />
Donator Days: <input type='text' name='donatordays' value='0' /><br />
Gender: <select name='gender' type='dropdown'><option>Male</option><option>Female</option></select><br />
<br />
<b>Stats</b><br />
Strength: <input type='text' name='strength' value='10' /><br />
Agility: <input type='text' name='agility' value='10' /><br />
Guard: <input type='text' name='guard' value='10' /><br />
Labour: <input type='text' name='labour' value='10' /><br />
IQ: <input type='text' name='labour' value='10' /><br />
<br />
<input type='submit' value='Create User' /></form>";
}
function new_user_submit()
{
global $ir, $c, $userid;
if (!isset($_POST['username']) || !isset($_POST['login_name'])
|| !isset($_POST['userpass']))
{
print
"You missed one or more of the required fields. Please go back and try again.<br />
<a href='new_staff.php?action=newuser'>> Back</a>";
$h->endpage();
exit;
}
$level = abs((int) $_POST['level']);
$money = abs((int) $_POST['money']);
$crystals = abs((int) $_POST['crystals']);
$donator = abs((int) $_POST['donatordays']);
$ulevel = abs((int) $_POST['user_level']);
$strength = abs((int) $_POST['strength']);
$agility = abs((int) $_POST['agility']);
$guard = abs((int) $_POST['guard']);
$labour = abs((int) $_POST['labour']);
$iq = abs((int) $_POST['iq']);
$energy = 10 + $level * 2;
$brave = 3 + $level * 2;
$hp = 50 + $level * 50;
$username =
mysql_real_escape_string(
strip_tags(stripslashes($_POST['username'])), $c);
$loginname =
mysql_real_escape_string(
strip_tags(stripslashes($_POST['login_name'])), $c);
$password = stripslashes($_POST['userpass']);
$salt = generate_pass_salt();
$enc_psw = encode_password($password);
$i_salt = mysql_real_escape_string($salt, $c);
$i_encpsw = mysql_real_escape_string($enc_psw, $c);
$email =
mysql_real_escape_string(
strip_tags(stripslashes($_POST['email'])), $c);
$gender =
(isset($_POST['gender'])
&& in_array($_POST['gender'], array('Male', 'Female')))
? $_POST['gender'] : 'Male';
mysql_query(
"INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays,
user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender,
signedup, email, bankmoney, pass_salt)
VALUES( '{$username}', '{$loginname}', '{$i_encpsw}', $level,
$money, $crystals, $donator, $ulevel, $energy, $energy, 100, 100, $brave, $brave, $hp, $hp, 1,
'{$gender}', " . time() . ", '{$email}', -1, '{$i_salt}')",
$c);
$i = mysql_insert_id($c);
mysql_query(
"INSERT INTO userstats VALUES($i, $strength, $agility, $guard, $labour, $iq)",
$c);
print "User created!";
}
function new_item_form()
{
global $ir, $c;
print
"<h3>Adding an item to the game</h3><form action='new_staff.php?action=newitemsub' method='post'>
Item Name: <input type='text' name='itmname' value='' /><br />
Item Desc.: <input type='text' name='itmdesc' value='' /><br />
Item Type: " . itemtype_dropdown($c, 'itmtype')
. "<br />
Item Buyable: <input type='checkbox' name='itmbuyable' checked='checked' /><br />
Item Price: <input type='text' name='itmbuyprice' /><br />
Item Sell Value: <input type='text' name='itmsellprice' /><br /><br />
<b>Specialized</b><br />
Item Energy Regen (food only): <input type='text' name='energy' value='1' /><br />
Item Health Regen (medical only): <input type='text' name='health' value='10' /><br />
Power (weapons only): <input type='text' name='damage' value='10' /><br />
Damage Off (armor only): <input type='text' name='Defence' value='10' /><br />
<input type='submit' value='Add Item To Game' /></form>";
}
function new_item_submit()
{
global $ir, $c, $h;
if (!isset($_POST['itmname']) || !isset($_POST['itmdesc'])
|| !isset($_POST['itmtype']) || !isset($_POST['itmbuyprice'])
|| !isset($_POST['itmsellprice']))
{
print
"You missed one or more of the fields. Please go back and try again.<br />
<a href='new_staff.php?action=newitem'>> Back</a>";
$h->endpage();
exit;
}
$itmname =
mysql_real_escape_string(
strip_tags(stripslashes($_POST['itmname'])), $c);
$itmdesc =
mysql_real_escape_string(
strip_tags(stripslashes($_POST['itmdesc'])), $c);
if ($_POST['itmbuyable'] == 'on')
{
$itmbuy = 1;
}
else
{
$itmbuy = 0;
}
// verify item type
$itmtype = abs(@intval($_POST['itmtype']));
$itq =
mysql_query(
"SELECT COUNT(`itmtypeid`) FROM itemtypes WHERE `itmtypeid` = {$itmtype}");
if (mysql_result($itq, 0, 0) == 0)
{
print
"That item type doesn't exist.<br />
<a href='new_staff.php?action=newitem'>> Back</a>";
$h->endpage();
exit;
}
$itmbuyp = abs(@intval($_POST['itmbuyprice']));
$itmsellp = abs(@intval($_POST['itmsellprice']));
$m =
mysql_query(
"INSERT INTO items VALUES(NULL,{$itmtype},'$itmname','$itmdesc',
{$itmbuyp},{$itmsellp},$itmbuy)", $c) or die(mysql_error());
if ($_POST['itmtype'] == 1)
{
$stat = abs(@intval($_POST['energy']));
$i = mysql_insert_id();
mysql_query("INSERT INTO food VALUES($i,{$stat})", $c)
or die(mysql_error());
}
if ($_POST['itmtype'] == 3 || $_POST['itmtype'] == 4)
{
$stat = abs(@intval($_POST['damage']));
$i = mysql_insert_id();
mysql_query("INSERT INTO weapons VALUES($i,{$stat})", $c)
or die(mysql_error());
}
if ($_POST['itmtype'] == 5)
{
$stat = abs(@intval($_POST['health']));
$i = mysql_insert_id();
mysql_query("INSERT INTO medical VALUES($i,{$stat})", $c)
or die(mysql_error());
}
if ($_POST['itmtype'] == 7)
{
$stat = abs(@intval($_POST['Defence']));
$i = mysql_insert_id();
mysql_query("INSERT INTO armour VALUES($i,{$stat})", $c)
or die(mysql_error());
}
print "The {$_POST['itmname']} Item was added to the game.";
}
function kill_item_form()
{
global $ir, $c, $h, $userid;
print
"<h3>Deleting Item</h3>
The item will be permanently removed from the game.<br />
<form action='new_staff.php?action=killitemsub' method='post'>
Item: " . item_dropdown($c, 'item')
. "<br />
<input type='submit' value='Kill Item' /></form>";
}
function kill_item_submit()
{
global $ir, $c, $h, $userid;
$_POST['item'] = abs(@intval($_POST['item']));
$d = mysql_query("SELECT * FROM items WHERE itmid={$_POST['item']}", $c);
if (mysql_num_rows($d) == 0)
{
print "There is no such item.";
return;
}
$itemi = mysql_fetch_array($d);
mysql_query("DELETE FROM items WHERE itmid={$_POST['item']}", $c);
mysql_query("DELETE FROM shopitems WHERE sitemITEMID={$_POST['item']}", $c);
mysql_query("DELETE FROM inventory WHERE inv_itemid={$_POST['item']}", $c);
mysql_query("DELETE FROM food WHERE item_id={$_POST['item']}", $c);
mysql_query("DELETE FROM weapons WHERE item_id={$_POST['item']}", $c);
mysql_query("DELETE FROM medical WHERE item_id={$_POST['item']}", $c);
mysql_query("DELETE FROM armour WHERE item_ID={$_POST['item']}", $c);
mysql_query("DELETE FROM itemmarket WHERE imITEM={$_POST['item']}", $c);
print "The {$itemi['itmname']} Item was removed from the game.";
}
function edit_item_begin()
{
global $ir, $c, $h, $userid;
print
"<h3>Editing Item</h3>
You can edit any aspect of this item.<br />
<form action='new_staff.php?action=edititemform' method='post'>
Item: " . item_dropdown($c, 'item')
. "<br />
<input type='submit' value='Edit Item' /></form>";
}
function edit_item_form()
{
global $ir, $c, $h;
$_POST['item'] = abs(@intval($_POST['item']));
$d = mysql_query("SELECT * FROM items WHERE itmid={$_POST['item']}", $c);
if (mysql_num_rows($d) == 0)
{
print "There is no such item.";
return;
}
$itemi = mysql_fetch_array($d);
$f =
mysql_query("SELECT * FROM food WHERE item_id={$_POST['item']}",
$c);
if (mysql_num_rows($f) > 0)
{
$a = mysql_fetch_array($f);
$energy = $a['energy'];
}
else
{
$energy = 1;
}
$f =
mysql_query(
"SELECT * FROM medical WHERE item_id={$_POST['item']}",
$c);
if (mysql_num_rows($f) > 0)
{
$a = mysql_fetch_array($f);
$health = $a['health'];
}
else
{
$health = 10;
}
$f =
mysql_query(
"SELECT * FROM weapons WHERE item_id={$_POST['item']}",
$c);
if (mysql_num_rows($f) > 0)
{
$a = mysql_fetch_array($f);
$damage = $a['damage'];
}
else
{
$damage = 1;
}
$f =
mysql_query(
"SELECT * FROM armour WHERE item_ID={$_POST['item']}", $c);
if (mysql_num_rows($f) > 0)
{
$a = mysql_fetch_array($f);
$def = $a['Defence'];
}
else
{
$def = 10;
}
print
"<h3>Editing Item</h3>
<form action='new_staff.php?action=edititemsub' method='post'>
<input type='hidden' name='itmid' value='{$_POST['item']}' />
Item Name: <input type='text' name='itmname' value='{$itemi['itmname']}' /><br />
Item Desc.: <input type='text' name='itmdesc' value='{$itemi['itmdesc']}' /><br />
Item Type: " . itemtype_dropdown($c, 'itmtype', $itemi['itmtype'])
. "<br />
Item Buyable: <input type='checkbox' name='itmbuyable'";
if ($itemi['itmbuyable'])
{
print " checked='checked'";
}
print
" /><br />
Item Price: <input type='text' name='itmbuyprice' value='{$itemi['itmbuyprice']}' /><br />
Item Sell Value: <input type='text' name='itmsellprice' value='{$itemi['itmsellprice']}'/><br /><br />
<b>Specialized</b><br />
Item Energy Regen (food only): <input type='text' name='energy' value='$energy' /><br />
Item Health Regen (medical only): <input type='text' name='health' value='$health' /><br />
Power (weapons only): <input type='text' name='damage' value='$damage' /><br />
Damage Off (armor only): <input type='text' name='Defence' value='$def' /><br />
<input type='submit' value='Edit Item' /></form>";
}
function edit_item_sub()
{
global $ir, $c, $h, $userid;
if (!isset($_POST['itmname']) || !isset($_POST['itmdesc'])
|| !isset($_POST['itmtype']) || !isset($_POST['itmbuyprice'])
|| !isset($_POST['itmsellprice']))
{
print
"You missed one or more of the fields. Please go back and try again.<br />
<a href='new_staff.php?action=edititem'>> Back</a>";
$h->endpage();
exit;
}
$itmid = abs(@intval($_POST['itmid']));
$iq =
mysql_query(
"SELECT COUNT(`itmid`) FROM items WHERE `itmid` = {$itmid}");
if (mysql_result($iq, 0, 0) == 0)
{
print
"That item doesn't exist.<br />
<a href='new_staff.php?action=edititem'>> Back</a>";
$h->endpage();
exit;
}
$itmname =
mysql_real_escape_string(
strip_tags(stripslashes($_POST['itmname'])), $c);
$itmdesc =
mysql_real_escape_string(
strip_tags(stripslashes($_POST['itmdesc'])), $c);
if ($_POST['itmbuyable'] == 'on')
{
$itmbuy = 1;
}
else
{
$itmbuy = 0;
}
// verify item type
$itmtype = abs(@intval($_POST['itmtype']));
$itq =
mysql_query(
"SELECT COUNT(`itmtypeid`) FROM itemtypes WHERE `itmtypeid` = {$itmtype}");
if (mysql_result($itq, 0, 0) == 0)
{
print
"That item type doesn't exist.<br />
<a href='new_staff.php?action=edititem'>> Back</a>";
$h->endpage();
exit;
}
$itmbuyp = abs(@intval($_POST['itmbuyprice']));
$itmsellp = abs(@intval($_POST['itmsellprice']));
mysql_query("DELETE FROM items WHERE itmid={$itmid}", $c);
mysql_query("DELETE FROM food WHERE item_id={$itmid}", $c);
mysql_query("DELETE FROM weapons WHERE item_id={$itmid}", $c);
mysql_query("DELETE FROM medical WHERE item_id={$itmid}", $c);
mysql_query("DELETE FROM armour WHERE item_ID={$itmid}", $c);
$m =
mysql_query(
"INSERT INTO items VALUES('{$itmid}',{$itmtype},'$itmname',
'$itmdesc',{$itmbuyp},{$itmsellp},$itmbuy)", $c)
or die(mysql_error());
if ($_POST['itmtype'] == 1)
{
$stat = abs(@intval($_POST['energy']));
mysql_query("INSERT INTO food VALUES({$itmid},{$stat})", $c)
or die(mysql_error());
}
if ($_POST['itmtype'] == 5)
{
$stat = abs(@intval($_POST['health']));
mysql_query("INSERT INTO medical VALUES({$itmid},{$stat})", $c)
or die(mysql_error());
}
if ($_POST['itmtype'] == 3 || $_POST['itmtype'] == 4)
{
$stat = abs(@intval($_POST['damage']));
mysql_query("INSERT INTO weapons VALUES({$itmid},{$stat})", $c)
or die(mysql_error());
}
if ($_POST['itmtype'] == 7)
{
$stat = abs(@intval($_POST['Defence']));
$i = mysql_insert_id();
mysql_query("INSERT INTO armour VALUES({$itmid},{$stat})", $c)
or die(mysql_error());
}
print "The {$_POST['itmname']} Item was edited successfully.";
}
function new_shop_form()
{
global $ir, $c, $h;
print
"<h3>Adding a New Shop</h3>
<form action='new_staff.php?action=newshopsub' method='post'>
Shop Name: <input type='text' name='sn' value='' /><br />
Shop Desc: <input type='text' name='sd' value='' /><br />
Shop Location: " . location_dropdown($c, "sl")
. "<br />
<input type='submit' value='Create Shop' /></form>";
}
function new_shop_submit()
{
global $ir, $c, $h;
if (!isset($_POST['sn']) || !isset($_POST['sd']))
{
print
"You missed a field, go back and try again.<br />
<a href='new_staff.php?action=newitem'>> Back</a>";
}
else
{
$sn =
mysql_real_escape_string(
strip_tags(stripslashes($_POST['sn'])), $c);
$sd =
mysql_real_escape_string(
strip_tags(stripslashes($_POST['sd'])), $c);
$location = abs(@intval($_POST['sl']));
// Verify location
$locq =
mysql_query(
"SELECT COUNT(`cityid`) FROM cities WHERE `cityid` = {$location}");
if (mysql_result($locq, 0, 0) == 0)
{
print
"That location doesn't exist.<br />
<a href='new_staff.php?action=newshop'>> Back</a>";
$h->endpage();
exit;
}
mysql_query("INSERT INTO shops VALUES(NULL,{$location},'$sn','$sd')",
$c);
print "The $sn Shop was successfully added to the game.";
}
}
function new_stock_form()
{
global $ir, $c, $h;
print
"<h3>Adding an item to a shop</h3>
<form action='new_staff.php?action=newstocksub' method='post'>
Shop: " . shop_dropdown($c, "shop") . "<br />
Item: " . item_dropdown($c, "item")
. "<br />
<input type='submit' value='Add Item To Shop' /></form>";
}
function new_stock_submit()
{
global $ir, $c, $h;
$shop = abs(@intval($_POST['shop']));
$item = abs(@intval($_POST['item']));
// Verify details
$shopq =
mysql_query(
"SELECT COUNT(`shopID`) FROM shops WHERE `shopID` = {$shop}",
$c);
if (mysql_result($shopq, 0, 0) == 0)
{
print
"That shop doesn't exist.<br />
<a href='new_staff.php?action=newstock'>> Back</a>";
$h->endpage();
exit;
}
$itemq =
mysql_query(
"SELECT COUNT(`itmid`) FROM items WHERE `itmid` = {$item}",
$c);
if (mysql_result($itemq, 0, 0) == 0)
{
print
"That item doesn't exist.<br />
<a href='new_staff.php?action=newstock'>> Back</a>";
$h->endpage();
exit;
}
mysql_query("INSERT INTO shopitems VALUES(NULL,{$shop},{$item})", $c);
print "Item ID {$item} was successfully added to shop ID {$shop}";
}
function edit_user_begin()
{
global $ir, $c, $h, $userid;
print
"<h3>Editing User</h3>
You can edit any aspect of this user. <br />
<form action='new_staff.php?action=edituserform' method='post'>
User: " . user_dropdown($c, 'user')
. "<br />
<input type='submit' value='Edit User' /></form>
OR enter a user ID to edit:
<form action='new_staff.php?action=edituserform' method='post'>
User: <input type='text' name='user' value='0' /><br />
<input type='submit' value='Edit User' /></form>";
}
function edit_user_form()
{
global $ir, $c, $h, $userid;
$user = abs(@intval($_POST['user']));
$d =
mysql_query(
"SELECT u.*,us.* FROM users u LEFT JOIN userstats us on u.userid=us.userid WHERE u.userid={$user}",
$c);
if (mysql_num_rows($d) == 0)
{
print
"That user doesn't exist.<br />