-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfaction.php
146 lines (129 loc) · 5.45 KB
/
faction.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
<?php
/** Displays the faction identified by 'id' if it is specified and a faction by this ID exists.
* Otherwise queries for the factions identified by 'name'. Underscores are considered as spaces, for Wiki compatibility.
* If exactly one faction is found, displays this faction.
* Otherwise redirects to the faction search page, displaying the results for '%name%'.
* If neither 'id' nor 'name' are specified or if 'id' is not a valid faction ID, redirects to the faction search page.
*/
include('./includes/constantes.php');
include('./includes/config.php');
include($includes_dir.'functions.php');
include($includes_dir.'mysql.php');
/** Formats the npc/zone info selected in '$QueryResult' to display them by zone
* The top-level sort must be on the zone
*/
function PrintNpcsByZone($QueryResult)
{
if(mysql_num_rows($QueryResult) > 0)
{
$CurrentZone = "";
while($row = mysql_fetch_array($QueryResult))
{
if($CurrentZone != $row["zone"])
{
if($CurrentZone != "")
print " <br/><br/>\n";
print " <b>in <a href='zone.php?name=".$row["zone"]."'>".$row["long_name"]."</a> by </b>\n";
$CurrentZone = $row["zone"];
}
print "<li><a href='npc.php?id=".$row["id"]."'>".str_replace("_"," ",$row["name"])."</a> (".$row["id"].")</li>\n";
}
if($CurrentZone != "")
print " <br/><br/>\n";
}
}
$id = (isset($_GET[ 'id']) ? $_GET[ 'id'] : '');
$name = (isset($_GET['name']) ? addslashes($_GET['name']) : '');
if($id != "" && is_numeric($id))
{
$Query = "SELECT id,name FROM $tbfactionlist WHERE id='".$id."'";
$QueryResult = mysql_query($Query) or message_die('faction.php','MYSQL_QUERY',$Query,mysql_error());
if(mysql_num_rows($QueryResult) == 0)
{ header("Location: factions.php");
exit();
}
$FactionRow=mysql_fetch_array($QueryResult);
$name=$FactionRow["name"];
}
elseif($name != "")
{
$Query = "SELECT id,name FROM $tbfactionlist WHERE name like '$name'";
$QueryResult = mysql_query($Query) or message_die('faction.php','MYSQL_QUERY',$Query,mysql_error());
if(mysql_num_rows($QueryResult) == 0)
{
header("Location: factions.php?iname=".$name."&isearch=true");
exit();
}
else
{
$FactionRow = mysql_fetch_array($QueryResult);
$id = $FactionRow["id"];
$name = $FactionRow["name"];
}
}
else
{
header("Location: factions.php");
exit();
}
/** Here the following stands :
* $id : ID of the faction to display
* $name : name of the faction to display
* $FactionRow : row of the faction to display extracted from the database
* The faction actually exists
*/
$Title = "Faction :: ".$name;
$XhtmlCompliant = TRUE;
include($includes_dir.'headers.php');
print " <center>\n";
print " <table border='1' width='80%' style='background-color: black; filter:alpha(opacity=70); -moz-opacity:0.7; opacity: 0.7;'>\n";
// Title and Icon bar
print " <tr valign='top' align='left'>\n";
print " <td colspan='2' class='headerrow'>\n";
print " <a href='".$peqeditor_url."index.php?editor=faction&fid=".$id."'><img src='".$images_url."/peq_faction.png' align='right'/></a>\n";
print " <b>".$name."</b>\n";
print " <br/>id : ".$id."\n";
print " </td>\n";
print " </tr>\n";
print " </table>\n";
print " <table border='0' width='80%' style='background-color: ; filter:alpha(opacity=70); -moz-opacity:0.7; opacity: 0.7;'>\n";
print " <tr valign='top' align='left'>\n";
// NPCs raising the faction by killing them
print " <td width='50%' nowrap='1' align='left'>\n";
print " <b>NPCs whom death raises the faction</b><br/><br/>\n";
$Query="SELECT $tbnpctypes.id,$tbnpctypes.name,$tbzones.long_name,$tbspawn2.zone
FROM $tbnpcfactionentries,$tbnpctypes,$tbspawnentry,$tbspawn2,$tbzones
WHERE $tbnpcfactionentries.faction_id=$id
AND $tbnpcfactionentries.npc_faction_id=$tbnpctypes.npc_faction_id
AND $tbnpcfactionentries.value>0
AND $tbnpctypes.id=$tbspawnentry.npcID
AND $tbspawn2.spawngroupID=$tbspawnentry.spawngroupID
AND $tbzones.short_name=$tbspawn2.zone
GROUP BY $tbnpctypes.id
ORDER BY $tbzones.long_name ASC
";
$QueryResult = mysql_query($Query) or message_die('faction.php','MYSQL_QUERY',$query,mysql_error());
PrintNpcsByZone($QueryResult);
print " </td>\n";
// NPCs lowering the faction by killing them
print " <td width='50%' nowrap='1' align='left'>\n";
print " <b>NPCs whom death lowers the faction</b><br/><br/>\n";
$Query="SELECT $tbnpctypes.id,$tbnpctypes.name,$tbzones.long_name,$tbspawn2.zone
FROM $tbnpcfactionentries,$tbnpctypes,$tbspawnentry,$tbspawn2,$tbzones
WHERE $tbnpcfactionentries.faction_id=$id
AND $tbnpcfactionentries.npc_faction_id=$tbnpctypes.npc_faction_id
AND $tbnpcfactionentries.value<0
AND $tbnpctypes.id=$tbspawnentry.npcID
AND $tbspawn2.spawngroupID=$tbspawnentry.spawngroupID
AND $tbzones.short_name=$tbspawn2.zone
GROUP BY $tbnpctypes.id
ORDER BY $tbzones.long_name ASC
";
$QueryResult = mysql_query($Query) or message_die('faction.php','MYSQL_QUERY',$query,mysql_error());
PrintNpcsByZone($QueryResult);
print " </td>\n";
print " </tr>\n";
print " </table>\n";
print " </center>\n";
include($includes_dir."footers.php");
?>