forked from maudigan/charbrowser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraidpoints.php
More file actions
194 lines (168 loc) · 6.81 KB
/
Copy pathraidpoints.php
File metadata and controls
194 lines (168 loc) · 6.81 KB
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
<?php
define('INCHARBROWSER', true);
include_once(__DIR__ . "/include/common.php");
include_once(__DIR__ . "/include/profile.php");
include_once(__DIR__ . "/include/db.php");
/*********************************************
SETUP PROFILE/PERMISSIONS
*********************************************/
if(!$_GET['char']) cb_message_die($language['MESSAGE_ERROR'],$language['MESSAGE_NO_CHAR']);
else $charName = $_GET['char'];
$order = (isset($_GET['order']) ? addslashes($_GET["order"]) : "n.`difficulty` ASC");
$unkilled = (isset($_GET['unkilled']) ? addslashes($_GET["unkilled"]) : 0);
//character initializations
$char = new profile($charName, $cbsql, $cbsql_content, $language, $showsoftdelete, $charbrowser_is_admin_page); //the profile class will sanitize the character name
$charID = $char->char_id();
$name = $char->GetValue('name');
$mypermission = GetPermissions($char->GetValue('gm'), $char->GetValue('anon'), $char->char_id());
$userip = getIPAddress();
$tpl =
<<<TPL
SELECT ai.ip as ip
FROM character_data cd
INNER JOIN account_ip AI on ai.accid = cd.account_id
WHERE cd.id = $charID
ORDER BY ai.lastused DESC
LIMIT 1
TPL;
$result = $cbsql->query($tpl);
$bots = $cbsql->fetch_all($result);
foreach($bots as $bot) {
if ($bot['ip'] == $userip || $userip == $defaultedlocalhost || $userip == $localipaddress || $userip == $defaultgateway) {
$ownercheck = 1;
}
}
//block view if user level doesnt have permission
if ($mypermission['raidpoints'] && $ownercheck != 1) cb_message_die($language['MESSAGE_ERROR'],$language['MESSAGE_PERMISSIONS_ERROR']);
/*********************************************
GATHER RELEVANT PAGE DATA
*********************************************/
//get raid kills from the character db
if ($order == 1) { $order = "NPCName ASC"; }
if ($order == 2) { $order = "NPCName DESC"; }
if ($order == 3) { $order = "n.`raid_points` ASC"; }
if ($order == 4) { $order = "n.`raid_points` DESC"; }
if ($order == 5) { $order = "z.`long_name` ASC"; }
if ($order == 6) { $order = "z.`long_name` DESC"; }
if ($order == 7) { $order = "n.`difficulty` ASC"; }
if ($order == 8) { $order = "n.`difficulty` DESC"; }
if (!$unkilled) {
$killtype = "Killed";
$tpl = <<<TPL
SELECT db.`key`, db.`value` AS EarnedValue, cd.`id` AS CharID, cd.`name` AS CharName, n.`id` AS NPCID, REPLACE(REPLACE(n.`name`,'_',' '),'#','') AS NPCName, n.`difficulty` AS NPCDiff, n.`raid_points` AS RaidPts, z.`short_name` AS ZoneSN, z.`long_name` AS ZoneLN -- , SUM(db.`value)
FROM data_buckets db
INNER JOIN character_data cd ON cd.`id` = SUBSTRING(db.`key`, 16, INSTR(SUBSTRING(db.`key`, 16), "-")+1)
INNER JOIN npc_types n ON n.`id` = SUBSTRING(db.`key`, INSTR(SUBSTRING(db.`key`, 16), "-")+16)
LEFT JOIN zone z ON z.`zoneidnumber` = FLOOR(CAST(n.`id` / 1000 AS DOUBLE))
WHERE db.`key` LIKE 'PlayerRaidKill-%'
AND cd.`id` = $charID
-- AND n.`raid_points` > 0
ORDER BY $order
TPL;
} else {
$killtype = "Unkilled";
$tpl = <<<TPL
SELECT n.`difficulty` AS NPCDiff, n.`raid_points` AS EarnedValue, n.`id` AS NPCID, REPLACE(REPLACE(n.`name`,'_',' '),'#','') AS NPCName, n.`raid_points` AS RaidPts, z.`short_name` AS ZoneSN, z.`long_name` AS ZoneLN -- , SUM(db.`value)
FROM npc_types n
INNER JOIN zone z ON z.zoneidnumber = FLOOR(CAST(n.id / 1000 AS DOUBLE))
WHERE NOT EXISTS (SELECT *
FROM qs_player_npc_kill_record kr
INNER JOIN qs_player_npc_kill_record_entries kre ON kre.event_id = kr.fight_id
WHERE kr.npc_id = n.id
AND kre.char_id = $charID)
AND n.`level` > 51 AND n.`level` < 99 AND n.loottable_id > 0
AND n.raid_target = 1
AND n.raid_points > 0
AND n.loottable_id > 0
AND n.id NOT BETWEEN 128041 AND 128044
ORDER BY $order
TPL;
}
#$query = sprintf($tpl, $charID);
$result = $cbsql->query($tpl);
$raid = $cbsql->fetch_all($result);
//get raid total points from db
$tpl = <<<TPL
SELECT db.`value` AS TotalPts
FROM data_buckets db
INNER JOIN character_data cd ON cd.`id` = SUBSTRING(db.`key`, 18)
WHERE db.`key` LIKE 'PlayerRaidPoints-%'
AND cd.`id` = $charID
TPL;
#$query = sprintf($tpl, $charID);
$result = $cbsql->query($tpl);
$raidtotal = $cbsql->fetch_all($result);
//get completed epics from db
$tpl = <<<TPL
SELECT db.`key`, db.`value` AS EarnedValue, cd.`id` AS CharID, cd.`name` AS CharName, i.`id` AS ItemID, i.`name` AS ItemName, db.`value` AS EarnedValue
FROM data_buckets db
INNER JOIN items i ON i.`id` = SUBSTRING(db.`key`, 19, INSTR(SUBSTRING(db.`key`, 19), "-")+1)
INNER JOIN character_data cd ON cd.`id` = SUBSTRING(db.`key`, INSTR(SUBSTRING(db.`key`, 19), "-")+19)
WHERE db.`key` LIKE 'RaidPtsEpicTurnIn-%'
AND cd.`id` = $charID
-- AND n.`raid_points` > 0
ORDER BY db.`value` ASC
TPL;
#$query = sprintf($tpl, $charID);
$result = $cbsql->query($tpl);
$epictotal = $cbsql->fetch_all($result);
/*********************************************
DROP HEADER
*********************************************/
$d_title = " - ".$name.$language['PAGE_TITLES_RAID'];
include(__DIR__ . "/include/header.php");
/*********************************************
DROP PROFILE MENU
*********************************************/
output_profile_menu($name, 'raid');
/*********************************************
POPULATE BODY
*********************************************/
$cb_template->set_filenames(array(
'raid' => 'raid_body.tpl')
);
$cb_template->assign_both_vars(array(
'NAME' => $name)
);
$cb_template->assign_vars(array(
'L_RAID' => $language['RAID_RAIDPTS'],
'L_DONE' => $language['BUTTON_DONE'])
);
foreach ($raid as $raidpts) {
if ($raidpts["EarnedValue"] == 0 && $raidpts["RaidPts"] > 0) {
$raidpts["EarnedValue"] = 'Dupe - 0';
}
if ($raidpts["RaidPts"] == 0) {
$raidpts["EarnedValue"] = 'No Value - 0';
}
$cb_template->assign_both_block_vars("raid", array(
'NPC_NAME' => $raidpts['NPCName'],
'NPC_ID' => $raidpts["NPCID"],
'NPC' => 'http://vegaseq.com/Allaclone/?a=npc&id=' . $raidpts["NPCID"],
'NPC_PTS' => $raidpts["EarnedValue"],
'NPC_ZONESN' => 'http://vegaseq.com/Allaclone/?a=zone&name=' . $raidpts["ZoneSN"],
'NPC_ZONELN' => $raidpts["ZoneLN"],
'NPC_DIFF' => number_format($raidpts["NPCDiff"]))
);
}
foreach ($raidtotal as $raidtotals) {
$cb_template->assign_both_block_vars("raidtotal", array(
'NPC_TOTALPTS' => $raidtotals["TotalPts"])
);
}
foreach ($epictotal as $epictotals) {
$cb_template->assign_both_block_vars("epictotal", array(
'ITEM_NAME' => $epictotals['ItemName'],
'ITEM_ID' => $epictotals["ItemID"],
'ITEM' => 'http://vegaseq.com/Allaclone/?a=item&id=' . $epictotals["ItemID"],
'ITEM_PTS' => $epictotals["EarnedValue"])
);
}
$cb_template->assign_both_block_vars("raidkilltype", array('KILL_TYPE' => $killtype));
/*********************************************
OUTPUT BODY AND FOOTER
*********************************************/
$cb_template->pparse('raid');
$cb_template->destroy;
include(__DIR__ . "/include/footer.php");
?>