forked from opencaching/opencaching-pl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmycaches_logs.php
246 lines (218 loc) · 11.1 KB
/
mycaches_logs.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
<?php
global $lang, $usr, $rootpath, $dateFormat;
if (!isset($rootpath))
$rootpath = '';
//include template handling
require_once($rootpath . 'lib/common.inc.php');
require_once($rootpath . 'lib/cache_icon.inc.php');
// require_once($stylepath . '/lib/icons.inc.php');
//Preprocessing
if ($error == false) {
//user logged in?
if ($usr == false) {
$target = urlencode(tpl_get_current_page());
tpl_redirect('login.php?target=' . $target);
} else {
if (isset($_REQUEST['userid'])) {
$user_id = $_REQUEST['userid'];
tpl_set_var('userid', $user_id);
}
function cleanup_text($str)
{
$str = strip_tags($str, "<li>");
$from[] = '<p> </p>';
$to[] = '';
$from[] = ' ';
$to[] = ' ';
$from[] = '<p>';
$to[] = '';
$from[] = '\n';
$to[] = '';
$from[] = '\r';
$to[] = '';
$from[] = '</p>';
$to[] = "";
$from[] = '<br>';
$to[] = "";
$from[] = '<br />';
$to[] = "";
$from[] = '<br/>';
$to[] = "";
$from[] = '<li>';
$to[] = " - ";
$from[] = '</li>';
$to[] = "";
$from[] = 'ó';
$to[] = 'o';
$from[] = '"';
$to[] = '"';
$from[] = '&[^;]*;';
$to[] = '';
$from[] = '&';
$to[] = '';
$from[] = '\'';
$to[] = '';
$from[] = '"';
$to[] = '';
$from[] = '<';
$to[] = '';
$from[] = '>';
$to[] = '';
$from[] = '(';
$to[] = ' -';
$from[] = ')';
$to[] = '- ';
$from[] = ']]>';
$to[] = ']] >';
$from[] = '';
$to[] = '';
for ($i = 0; $i < count($from); $i++)
$str = str_replace($from[$i], $to[$i], $str);
return filterevilchars($str);
}
function filterevilchars($str)
{
return str_replace('[\\x00-\\x09|\\x0A-\\x0E-\\x1F]', '', $str);
}
//get the news
$tplname = 'mycaches_logs';
require($stylepath . '/newlogs.inc.php');
$rsGeneralStat = sql("SELECT username FROM user WHERE user_id=&1", $user_id);
$user_record = sql_fetch_array($rsGeneralStat);
tpl_set_var('username', $user_record['username']);
mysql_free_result($rsGeneralStat);
$LOGS_PER_PAGE = 50;
$PAGES_LISTED = 10;
$rs = sql("SELECT count(id) FROM cache_logs, caches
WHERE `cache_logs`.`cache_id`=`caches`.`cache_id`
AND `cache_logs`.`deleted`=0
AND `caches`.`status` != 4
AND `caches`.`status` != 5
AND `caches`.`status` != 6
AND `caches`.`user_id`='" . sql_escape($_REQUEST['userid']) . "'");
$total_logs = mysql_result($rs, 0);
mysql_free_result($rs);
$pages = "";
$total_pages = ceil($total_logs / $LOGS_PER_PAGE);
if (!isset($_GET['start']) || intval($_GET['start']) < 0 || intval($_GET['start']) > $total_logs)
$start = 0;
else
$start = intval($_GET['start']);
$startat = max(0, floor((($start / $LOGS_PER_PAGE) + 1) / $PAGES_LISTED) * $PAGES_LISTED);
if (($start / $LOGS_PER_PAGE) + 1 >= $PAGES_LISTED)
$pages .= '<a href="mycaches_logs.php?userid=' . $user_id . '&start=' . max(0, ($startat - $PAGES_LISTED - 1) * $LOGS_PER_PAGE) . '">{first_img}</a> ';
else
$pages .= "{first_img_inactive}";
for ($i = max(1, $startat); $i < $startat + $PAGES_LISTED; $i++) {
$page_number = ($i - 1) * $LOGS_PER_PAGE;
if ($page_number == $start)
$pages .= '<b>';
$pages .= '<a href="mycaches_logs.php?userid=' . $user_id . '&start=' . $page_number . '">' . $i . '</a> ';
if ($page_number == $start)
$pages .= '</b>';
}
if ($total_pages > $PAGES_LISTED)
$pages .= '<a href="mycaches_logs.php?userid=' . $user_id . '&start=' . (($i - 1) * $LOGS_PER_PAGE) . '">{last_img}</a> ';
else
$pages .= '{last_img_inactive}';
$rs = sql("SELECT `cache_logs`.`id`
FROM `cache_logs`, `caches`
WHERE `cache_logs`.`cache_id`=`caches`.`cache_id`
AND `cache_logs`.`deleted`=0
AND `caches`.`status` != 4
AND `caches`.`status` != 5
AND `caches`.`status` != 6
AND `caches`.`user_id`='" . sql_escape($_REQUEST['userid']) . "'
ORDER BY `cache_logs`.`date_created` DESC
LIMIT " . intval($start) . ", " . intval($LOGS_PER_PAGE));
$log_ids = '';
if (mysql_num_rows($rs) == 0)
$log_ids = '0';
for ($i = 0; $i < mysql_num_rows($rs); $i++) {
$record = sql_fetch_array($rs);
if ($i > 0) {
$log_ids .= ', ' . $record['id'];
} else {
$log_ids = $record['id'];
}
}
mysql_free_result($rs);
$rs = sql("SELECT cache_logs.id, cache_logs.cache_id AS cache_id,
cache_logs.type AS log_type,
cache_logs.text AS log_text,
cache_logs.date AS log_date,
caches.name AS cache_name,
caches.user_id AS cache_owner,
cache_logs.encrypt encrypt,
cache_logs.user_id AS luser_id,
user.username AS user_name,
user.user_id AS user_id,
caches.wp_oc AS wp_name,
caches.type AS cache_type,
cache_type.icon_small AS cache_icon_small,
log_types.icon_small AS icon_small,
IF(ISNULL(`cache_rating`.`cache_id`), 0, 1) AS `recommended`,COUNT(gk_item.id) AS geokret_in
FROM ((cache_logs INNER JOIN caches ON (caches.cache_id = cache_logs.cache_id))) INNER JOIN user ON (cache_logs.user_id = user.user_id) INNER JOIN log_types ON (cache_logs.type = log_types.id) INNER JOIN cache_type ON (caches.type = cache_type.id) LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id` AND `cache_logs`.`user_id`=`cache_rating`.`user_id`
LEFT JOIN gk_item_waypoint ON gk_item_waypoint.wp = caches.wp_oc
LEFT JOIN gk_item ON gk_item.id = gk_item_waypoint.id AND
gk_item.stateid<>1 AND gk_item.stateid<>4 AND gk_item.typeid<>2 AND gk_item.stateid !=5
WHERE cache_logs.deleted=0 AND cache_logs.id IN (" . $log_ids . ") AND `caches`.`user_id`='" . sql_escape($_REQUEST['userid']) . "'
GROUP BY cache_logs.id ORDER BY cache_logs.date_created DESC");
if (mysql_num_rows($rs) != 0) {
$file_content = '';
for ($i = 0; $i < mysql_num_rows($rs); $i++) {
$log_record = sql_fetch_array($rs);
$file_content .= '<tr>';
$file_content .= '<td style="width: 70px;">' . htmlspecialchars(date($dateFormat, strtotime($log_record['log_date'])), ENT_COMPAT, 'UTF-8') . '</td>';
if ($log_record['geokret_in'] != '0') {
$file_content .= '<td width="22"> <img src="images/gk.png" border="0" alt="" title="GeoKret" /></td>';
} else {
$file_content .='<td width="22"> </td>';
}
//$rating_picture
if ($log_record['recommended'] == 1 && $log_record['log_type'] == 1) {
$file_content .= '<td width="22"><img src="images/rating-star.png" border="0" alt=""/></td>';
} else {
$file_content .= '<td width="22"> </td>';
}
$file_content .= '<td width="22"><img src="tpl/stdstyle/images/' . $log_record['icon_small'] . '" border="0" alt="" /></td>';
$file_content .= '<td width="22"><a class="links" href="viewcache.php?cacheid=' . $log_record['cache_id'] . '"><img src="tpl/stdstyle/images/' . $log_record['cache_icon_small'] . '" border="0" alt=""/></a></td>';
$file_content .= '<td><b><a class="links" href="viewlogs.php?logid=' . htmlspecialchars($log_record['id'], ENT_COMPAT, 'UTF-8') . '" onmouseover="Tip(\'';
// ukrywanie nicka autora komentarza COG
// Łza
if ($log_record['log_type'] == 12 && !$usr['admin']) {
$log_record['user_name'] = tr('cog_user_name');
$log_record['user_id'] = 0;
}
// koniec ukrywania nicka autora komentarza COG
$file_content .= '<b>' . $log_record['user_name'] . '</b>: ';
if ($log_record['encrypt'] == 1 && $log_record['cache_owner'] != $usr['userid'] && $log_record['luser_id'] != $usr['userid']) {
$file_content .= "<img src=\'/tpl/stdstyle/images/free_icons/lock.png\' alt=\`\` /><br/>";
}
if ($log_record['encrypt'] == 1 && ($log_record['cache_owner'] == $usr['userid'] || $log_record['luser_id'] == $usr['userid'])) {
$file_content .= "<img src=\'/tpl/stdstyle/images/free_icons/lock_open.png\' alt=\`\` /><br/>";
}
$data = cleanup_text(str_replace("\r\n", " ", $log_record['log_text']));
$data = str_replace("\n", " ", $data);
if ($log_record['encrypt'] == 1 && $log_record['cache_owner'] != $usr['userid'] && $log_record['luser_id'] != $usr['userid']) {//crypt the log ROT13, but keep HTML-Tags and Entities
$data = str_rot13_html($data);
} else {
$file_content .= "<br/>";
}
$file_content .=$data;
$file_content .= '\', PADDING,5, WIDTH,280,SHADOW,true)" onmouseout="UnTip()">' . htmlspecialchars($log_record['cache_name'], ENT_COMPAT, 'UTF-8') . '</a></b></td>';
$file_content .= '<td><b><a class="links" href="viewprofile.php?userid=' . htmlspecialchars($log_record['user_id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($log_record['user_name'], ENT_COMPAT, 'UTF-8') . '</a></b></td>';
$file_content .= "</tr>";
}
}
$pages = mb_ereg_replace('{last_img}', $last_img, $pages);
$pages = mb_ereg_replace('{first_img}', $first_img, $pages);
$pages = mb_ereg_replace('{first_img_inactive}', $first_img_inactive, $pages);
$pages = mb_ereg_replace('{last_img_inactive}', $last_img_inactive, $pages);
tpl_set_var('file_content', $file_content);
tpl_set_var('pages', $pages);
}
}
//make the template and send it out
tpl_BuildTemplate();
?>