-
Notifications
You must be signed in to change notification settings - Fork 56
/
char_mail.php
179 lines (147 loc) · 8.05 KB
/
char_mail.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
<?php
require_once 'header.php';
require_once 'libs/char_lib.php';
require_once 'libs/mail_lib.php';
require_once 'libs/item_lib.php';
valid_login($action_permission['read']);
//########################################################################################################################
// SHOW CHARACTERS MAILS
//########################################################################################################################
function char_mail(&$sqlr, &$sqlc)
{
global $output, $lang_global, $lang_char, $lang_mail,
$realm_id, $realm_db, $mmfpm_db, $characters_db,
$action_permission, $user_lvl, $user_name,
$item_datasite, $itemperpage;
require_once 'core/char/char_security.php';
//==========================$_GET and SECURE=================================
$start = (isset($_GET['start'])) ? $sqlc->quote_smart($_GET['start']) : 0;
if (is_numeric($start));
else
$start = 0;
$order_by = (isset($_GET['order_by'])) ? $sqlc->quote_smart($_GET['order_by']) : 'id';
if (preg_match('/^[_[:lower:]]{1,12}$/', $order_by));
else
$order_by = 'id';
$dir = (isset($_GET['dir'])) ? $sqlc->quote_smart($_GET['dir']) : 1;
if (preg_match('/^[01]{1}$/', $dir));
else
$dir = 1;
$order_dir = ($dir) ? 'ASC' : 'DESC';
$dir = ($dir) ? 0 : 1;
//==========================$_GET and SECURE end=============================
// getting character data from database
$result = $sqlc->query('SELECT account, name, race, class, level, gender
FROM characters WHERE guid = '.$id.' LIMIT 1');
if ($sqlc->num_rows($result))
{
$char = $sqlc->fetch_assoc($result);
// we get user permissions first
$owner_acc_id = $sqlc->result($result, 0, 'account');
$result = $sqlr->query('SELECT `username`, `gmlevel` FROM `account` LEFT JOIN `account_access` ON `account`.`id`=`account_access`.`id` WHERE `account`.`id` = '.$owner_acc_id.' ORDER BY `gmlevel` DESC LIMIT 1');
$owner_name = $sqlr->result($result, 0, 'username');
$owner_gmlvl = $sqlr->result($result, 0, 'gmlevel');
if (empty($owner_gmlvl))
$owner_gmlvl = 0;
if (($user_lvl > $owner_gmlvl)||($owner_name === $user_name))
{
//------------------------Character Tabs---------------------------------
// we start with a lead of 10 spaces,
// because last line of header is an opening tag with 8 spaces
// keep html indent in sync, so debuging from browser source would be easy to read
$output .= '
<center>
<div id="tab_content">
<h1>'.$lang_char['mail'].'</h1>
<br />';
require_once 'core/char/char_header.php';
$output .= '
<br /><br />
<table class="lined" style="width: 100%">';
//---------------Page Specific Starts Ends here----------------------------
$query = $sqlc->query('SELECT a.id as id, a.messageType as messagetype, a.sender as sender,
a.subject as subject, a.body as body, a.has_items as hasitems, a.money as money, a.cod as cod, a.checked as checked,
b.item_guid as itemtemplate, c.itemEntry
FROM mail a INNER JOIN mail_items b ON a.id = b.mail_id LEFT JOIN item_instance c ON b.item_guid = c.guid where a.receiver = '.$id .' LIMIT '.$start.', '.$itemperpage.'');
$total_mail = $sqlc->result($sqlc->query('SELECT count(*) FROM mail WHERE receiver= '.$id .''), 0);
$output .= '
<tr>
<td align="left">
Total Mails: '.$total_mail.'
</td>
<td align="right" width="45%">';
$output .= generate_pagination('char_mail.php?start='.$start.'&order_by='.$order_by.'&dir='.(($dir) ? 0 : 1), $total_mail, $itemperpage, $start);
$output .= '
</td>
</tr>
</table>
<table class="lined" style="width: 100%">
<tr>
<th width="5%">'.$lang_mail['mail_type'].'</th>
<th width="10%">'.$lang_mail['sender'].'</th>
<th width="15%">'.$lang_mail['subject'].'</th>
<th width="5%">'.$lang_mail['has_items'].'</th>
<th width="25%">'.$lang_mail['text'].'</th>
<th width="20%">'.$lang_mail['money'].'</th>
<th width="5%">'.$lang_mail['checked'].'</th>
</tr>';
while ($mail = $sqlc->fetch_assoc($query))
{
$output .= '
<tr valign=top>
<td>'.get_mail_source($mail['messagetype']).'</td>
<td><a href="char.php?id='.$mail['sender'].'">'.get_char_name($mail['sender']).'</a></td>
<td>'.$mail['subject'].'</td>
<td>
<a style="padding:2px;" href="'.$item_datasite.$mail['itemEntry'].'" target="_blank">
<img class="bag_icon" src="'.get_item_icon($mail['itemEntry'], $sqlm).'" alt="" />
</a>
</td>
<td>'.$mail['body'].'</td>
<td>
'.substr($mail['money'], 0, -4).'<img src="img/gold.gif" alt="" align="middle" />
'.substr($mail['money'], -4, 2).'<img src="img/silver.gif" alt="" align="middle" />
'.substr($mail['money'], -2).'<img src="img/copper.gif" alt="" align="middle" />
</td>
<td>'.get_check_state($mail['checked']).'</td>
</tr>';
}
//---------------Page Specific Data Ends here----------------------------
//---------------Character Tabs Footer-----------------------------------
$output .= '
</table>
</div>
<br />';
require_once 'core/char/char_footer.php';
$output .='
<br />
</center>
<!-- end of char_mail.php -->';
}
else
error($lang_char['no_permission']);
}
else
error($lang_char['no_char_found']);
}
//########################################################################################################################
// MAIN
//########################################################################################################################
// action variable reserved for future use
//$action = (isset($_GET['action'])) ? $_GET['action'] : NULL;
// load language
$lang_char = lang_char();
$lang_mail = lang_mail();
$output .= '
<div class="top">
<h1>'.$lang_char['character'].'</h1>
</div>';
// we getting links to realm database and character database left behind by header
// header does not need them anymore, might as well reuse the link
char_mail($sqlr, $sqlc);
//unset($action);
unset($action_permission);
unset($lang_char);
unset($lang_mail);
require_once 'footer.php';
?>