-
Notifications
You must be signed in to change notification settings - Fork 6
/
weaponeditor.php
115 lines (108 loc) · 4.18 KB
/
weaponeditor.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
<?php
// translator ready
// addnews ready
// mail ready
require_once("common.php");
require_once("lib/showform.php");
require_once("lib/http.php");
check_su_access(SU_EDIT_EQUIPMENT);
translator::tlschema("weapon");
page_header("Weapon Editor");
$weaponlevel = (int)http::httpget("level");
require_once("lib/superusernav.php");
superusernav();
output::addnav("Editor");
output::addnav("Weapon Editor Home","weaponeditor.php?level=$weaponlevel");
output::addnav("Add a weapon","weaponeditor.php?op=add&level=$weaponlevel");
$values = array(1=>48,225,585,990,1575,2250,2790,3420,4230,5040,5850,6840,8010,9000,10350);
rawoutput("<h3>");
if ($weaponlevel == 1) {
output::doOutput("`&Weapons for 1 Dragon Kill`0");
} else {
output::doOutput("`&Weapons for %s Dragon Kills`0",$weaponlevel);
}
rawoutput("<h3>");
$weaponarray=array(
"Weapon,title",
"weaponid"=>"Weapon ID,hidden",
"weaponname"=>"Weapon Name",
"damage"=>"Damage,range,1,15,1");
$op = http::httpget('op');
$id = http::httpget('id');
if($op=="edit" || $op=="add"){
if ($op=="edit"){
$sql = "SELECT * FROM " . db_prefix("weapons") . " WHERE weaponid='$id'";
$result = db_query($sql);
$row = db_fetch_assoc($result);
}else{
$sql = "SELECT max(damage+1) AS damage FROM " . db_prefix("weapons") . " WHERE level=$weaponlevel";
$result = db_query($sql);
$row = db_fetch_assoc($result);
}
rawoutput("<form action='weaponeditor.php?op=save&level=$weaponlevel' method='POST'>");
output::addnav("","weaponeditor.php?op=save&level=$weaponlevel");
showform($weaponarray,$row);
rawoutput("</form>");
}else if($op=="del"){
$sql = "DELETE FROM " . db_prefix("weapons") . " WHERE weaponid='$id'";
db_query($sql);
$op = "";
httpset("op", $op);
}else if($op=="save"){
$weaponid = (int)httppost("weaponid");
$damage = httppost("damage");
$weaponname = httppost("weaponname");
if ($weaponid>0){
$sql = "UPDATE " . db_prefix("weapons") . " SET weaponname=\"$weaponname\",damage=\"$damage\",value=" . $values[$damage]." WHERE weaponid='$weaponid'";
}else{
$sql = "INSERT INTO " . db_prefix("weapons") . " (level,damage,weaponname,value) VALUES ($weaponlevel,\"$damage\",\"$weaponname\",".$values[$damage].")";
}
db_query($sql);
//output::doOutput($sql);
$op = "";
httpset("op", $op);
}
if ($op==""){
$sql = "SELECT max(level+1) as level FROM " . db_prefix("weapons");
$res = db_query($sql);
$row = db_fetch_assoc($res);
$max = $row['level'];
for ($i=0;$i<=$max;$i++){
if ($i == 1)
output::addnav("Weapons for 1 DK","weaponeditor.php?level=$i");
else
output::addnav(array("Weapons for %s DKs",$i),"weaponeditor.php?level=$i");
}
$sql = "SELECT * FROM " . db_prefix("weapons") . " WHERE level=$weaponlevel ORDER BY damage";
$result= db_query($sql);
$ops = translator::translate_inline("Ops");
$name = translator::translate_inline("Name");
$cost = translator::translate_inline("Cost");
$damage = translator::translate_inline("Damage");
$level = translator::translate_inline("Level");
$edit = translator::translate_inline("Edit");
$del = translator::translate_inline("Del");
$delconfirm = translator::translate_inline("Are you sure you wish to delete this weapon?");
rawoutput("<table border=0 cellpadding=2 cellspacing=1 bgcolor='#999999'>");
rawoutput("<tr class='trhead'><td>$ops</td><td>$name</td><td>$cost</td><td>$damage</td><td>$level</td></tr>");
$number=db_num_rows($result);
for ($i=0;$i<$number;$i++){
$row = db_fetch_assoc($result);
rawoutput("<tr class='".($i%2?"trdark":"trlight")."'>");
rawoutput("<td>[<a href='weaponeditor.php?op=edit&id={$row['weaponid']}&level=$weaponlevel'>$edit</a>|<a href='weaponeditor.php?op=del&id={$row['weaponid']}&level=$weaponlevel' onClick='return confirm(\"Are you sure you wish to delete this weapon?\");'>$del</a>]</td>");
output::addnav("","weaponeditor.php?op=edit&id={$row['weaponid']}&level=$weaponlevel");
output::addnav("","weaponeditor.php?op=del&id={$row['weaponid']}&level=$weaponlevel");
rawoutput("<td>");
output_notl($row['weaponname']);
rawoutput("</td><td>");
output_notl($row['value']);
rawoutput("</td><td>");
output_notl($row['damage']);
rawoutput("</td><td>");
output_notl($row['level']);
rawoutput("</td>");
rawoutput("</tr>");
}
rawoutput("</table>");
}
page_footer();