| 1 |
<?php</span> |
|---|
| 2 |
<span class="code-lang">$root_path = './'; |
|---|
| 3 |
require ($root_path . 'include/config.php'); |
|---|
| 4 |
require ($root_path . 'include/functions_search.php'); |
|---|
| 5 |
require ($root_path . 'languages/lang_' . $config['default_lang'] . '/lang_modcomment_log.php'); |
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
function search_id_from_string ( $string ) {</span> |
|---|
| 9 |
<span class="code-keyword"> |
|---|
| 10 |
$ary = array(); |
|---|
| 11 |
|
|---|
| 12 |
while ( true ) { |
|---|
| 13 |
$first_pos = strpos($string, '<!--S-->'); |
|---|
| 14 |
|
|---|
| 15 |
if ( $first_pos !== false ) { |
|---|
| 16 |
$last_pos = strpos($string, '<!--E-->'); |
|---|
| 17 |
$_pos = strpos($string, '_'); |
|---|
| 18 |
$_pos = strpos($string, '_', $_pos + 1); |
|---|
| 19 |
$substr = substr($string, $first_pos + 8, $_pos - $first_pos - 8); |
|---|
| 20 |
|
|---|
| 21 |
$_pos = strpos($substr, '_'); |
|---|
| 22 |
|
|---|
| 23 |
$id = substr($substr, $_pos + 1); |
|---|
| 24 |
$type = substr($substr, 0, $_pos); |
|---|
| 25 |
|
|---|
| 26 |
$string = preg_replace('/<!--S-->' . $type . '_' . $id . '_(.*?)<!--E-->/si', '', $string); |
|---|
| 27 |
|
|---|
| 28 |
$ary[$id] = $type; |
|---|
| 29 |
} |
|---|
| 30 |
else { |
|---|
| 31 |
break; |
|---|
| 32 |
} |
|---|
| 33 |
} |
|---|
| 34 |
|
|---|
| 35 |
if ( sizeof($ary) ) { |
|---|
| 36 |
return $ary; |
|---|
| 37 |
} |
|---|
| 38 |
else { |
|---|
| 39 |
return false; |
|---|
| 40 |
} |
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
$userdata = session_pagestart($user_ip); |
|---|
| 45 |
init_userprefs($userdata); |
|---|
| 46 |
loggedinorreturn(); |
|---|
| 47 |
|
|---|
| 48 |
$log_level_view = request_var('log_level_view', -1); |
|---|
| 49 |
$query = request_var('query', '');</span> |
|---|
| 50 |
<span class="code-lang"> |
|---|
| 51 |
if ( $userdata['class'] == UC_MODERATOR ) { |
|---|
| 52 |
$level = LOG_VIEW_MOD; |
|---|
| 53 |
} |
|---|
| 54 |
elseif ( $userdata['class'] == UC_ADMINISTRATOR ) { |
|---|
| 55 |
$level = LOG_VIEW_ADMIN; |
|---|
| 56 |
} |
|---|
| 57 |
elseif ( $userdata['class'] == UC_SYSOP ) { |
|---|
| 58 |
$level = LOG_VIEW_SYSOP; |
|---|
| 59 |
} |
|---|
| 60 |
else { |
|---|
| 61 |
$level = LOG_VIEW_USER; |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
if ( $log_level_view > $level && $log_level_view <> -1 ) { |
|---|
| 65 |
$log_level_view = $level; |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
$colors = array(); |
|---|
| 69 |
$colors_ary = array('#33CC00', '#FF0000', '#FF0000', '#3399FF');</span> |
|---|
| 70 |
<span class="code-lang"> |
|---|
| 71 |
for ( $i = 0; $i < sizeof($lang['log_highlights_ary']); ++$i ) { |
|---|
| 72 |
$colors[$lang['log_highlights_ary'][$i]] = $colors_ary[$i]; |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
if ( $level <> LOG_VIEW_USER ) { |
|---|
| 76 |
$log_level_select = '<select name="log_level_view">'; |
|---|
| 77 |
$log_level_select .= '<option value="-1"' . ( $log_level_view == -1 ? ' selected="selected"' : '' ) . '>' . $lang['log_level'] . '</option>'; |
|---|
| 78 |
$log_level_select .= '<option value="' . LOG_VIEW_USER . '"' . ( $log_level_view == LOG_VIEW_USER ? ' selected="selected"' : '' ) . '>' . $lang['log_level_user'] . '</option>'; |
|---|
| 79 |
$log_level_select .= '<option value="' . LOG_VIEW_MOD . '"' . ( $log_level_view == LOG_VIEW_MOD ? ' selected="selected"' : '' ) . '>' . $lang['log_level_mod'] . '</option>'; |
|---|
| 80 |
$log_level_select .= ( $userdata['class'] > UC_MODERATOR ? '<option value="' . LOG_VIEW_ADMIN . '"' . ( $log_level_view == LOG_VIEW_ADMIN ? ' selected="selected"' : '' ) . '>' . $lang['log_level_admin'] . '</option>' : '' ); |
|---|
| 81 |
$log_level_select .= ( $userdata['class'] > UC_ADMINISTRATOR ? '<option value="' . LOG_VIEW_SYSOP . '"' . ( $log_level_view == LOG_VIEW_SYSOP ? ' selected="selected"' : '' ) . '>' . $lang['log_level_sysop'] . '</option>' : '' ); |
|---|
| 82 |
$log_level_select .= '</select>'; |
|---|
| 83 |
} |
|---|
| 84 |
else { |
|---|
| 85 |
$log_level_select = ''; |
|---|
| 86 |
} |
|---|
| 87 |
|
|---|
| 88 |
$template->assign_vars(array(</span> |
|---|
| 89 |
<span class="code-lang"> 'S_FORM_ACTION' => append_sid('log.php') |
|---|
| 90 |
)); |
|---|
| 91 |
|
|---|
| 92 |
if ( $query ) { |
|---|
| 93 |
$template->assign_vars(array( |
|---|
| 94 |
'SEARCH_RESULTS' => sprintf($lang['search_results'], $query), |
|---|
| 95 |
'SEARCH_VALUE' => $query |
|---|
| 96 |
)); |
|---|
| 97 |
|
|---|
| 98 |
$query = searchfield($query); |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
$secs = time() - 2 * 7 * 24 * 60 * 60; |
|---|
| 102 |
$sql = 'DELETE FROM ' . SITELOG_TABLE . ' WHERE added < ' . $secs; |
|---|
| 103 |
$db->sql_query($sql); |
|---|
| 104 |
|
|---|
| 105 |
$template->assign_vars(array(</span> |
|---|
| 106 |
<span class="code-lang"> 'LOG_LEVEL_SELECT' => $log_level_select |
|---|
| 107 |
)); |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
$sql = 'SELECT COUNT(*) AS count</span> |
|---|
| 111 |
<span class="code-lang"> FROM ' . SITELOG_TABLE . ' |
|---|
| 112 |
WHERE ' . ( $log_level_view <> -1 ? 'log_view_level = ' . $log_level_view : 'log_view_level <= ' . $level ) . |
|---|
| 113 |
( $query ? ' AND txt LIKE ' . "'%" . $db->sql_escape($query) . "%'" : '' ); |
|---|
| 114 |
$result = $db->sql_query($sql); |
|---|
| 115 |
$count = ( $row = $db->sql_fetchrow($result) ) ? $row['count'] : 0;</span> |
|---|
| 116 |
<span class="code-lang"> |
|---|
| 117 |
if ( $count ) { |
|---|
| 118 |
list($pagertop, $pagerbottom, $offset, $limit) = pager(50, $count, 'log.php?' . ( $query ? 'query=' . $query . '&' : '' ) . ( $log_level_view <> -1 ? 'log_level_view=' . $log_level_view . '&' : '' ) ); |
|---|
| 119 |
$template->assign_vars(array( |
|---|
| 120 |
'PAGERBOTTOM' => $pagerbottom |
|---|
| 121 |
)); |
|---|
| 122 |
|
|---|
| 123 |
$sql = 'SELECT added, txt |
|---|
| 124 |
FROM ' . SITELOG_TABLE . ' |
|---|
| 125 |
WHERE ' . ( $log_level_view <> -1 ? 'log_view_level = ' . $log_level_view : 'log_view_level <= ' . $level ) . |
|---|
| 126 |
( isset($query) ? ' AND txt LIKE ' . "'%" . $db->sql_escape($query) . "%'" : '' ) . ' ORDER BY added DESC'; |
|---|
| 127 |
$result = $db->sql_query_limit($sql, $limit, $offset); |
|---|
| 128 |
|
|---|
| 129 |
$tor_ary = array(); |
|---|
| 130 |
$user_ary = array(); |
|---|
| 131 |
$log_ary = array(); |
|---|
| 132 |
$cats = $cache->obtain_cats(); |
|---|
| 133 |
|
|---|
| 134 |
while ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 135 |
if ( $search = search_id_from_string($row['txt']) ) { |
|---|
| 136 |
foreach ( $search AS $id => $type ) { |
|---|
| 137 |
switch ( $type ) { |
|---|
| 138 |
case 'TORRENT': |
|---|
| 139 |
$tor_ary[] = $id; |
|---|
| 140 |
break; |
|---|
| 141 |
case 'USER': |
|---|
| 142 |
$user_ary[] = $id; |
|---|
| 143 |
break; |
|---|
| 144 |
} |
|---|
| 145 |
} |
|---|
| 146 |
} |
|---|
| 147 |
|
|---|
| 148 |
$log_ary[] = $row; |
|---|
| 149 |
} |
|---|
| 150 |
if ( sizeof($user_ary) ) { |
|---|
| 151 |
$user_ary = array_unique($user_ary); |
|---|
| 152 |
$sql = 'SELECT name, privacy, uid FROM ' . USERS_TABLE . ' WHERE uid IN (' . implode(',', $user_ary) . ')'; |
|---|
| 153 |
$result = $db->sql_query($sql); |
|---|
| 154 |
$user_ary = array(); |
|---|
| 155 |
while ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 156 |
$user_ary[$row['uid']] = $row; |
|---|
| 157 |
} |
|---|
| 158 |
} |
|---|
| 159 |
if ( sizeof($tor_ary) ) { |
|---|
| 160 |
$tor_ary = array_unique($tor_ary); |
|---|
| 161 |
$sql = 'SELECT name, fid, category FROM ' . TORRENTS_TABLE . ' WHERE fid IN (' . implode(',', $tor_ary) . ')'; |
|---|
| 162 |
$result = $db->sql_query($sql); |
|---|
| 163 |
$tor_ary = array(); |
|---|
| 164 |
while ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 165 |
$tor_ary[$row['fid']] = $row; |
|---|
| 166 |
} |
|---|
| 167 |
} |
|---|
| 168 |
|
|---|
| 169 |
foreach ( $log_ary AS $_null => $ary ) { |
|---|
| 170 |
|
|---|
| 171 |
$date = create_date($ary['added']); |
|---|
| 172 |
$text = $ary['txt']; |
|---|
| 173 |
$continue = false; |
|---|
| 174 |
|
|---|
| 175 |
$log_color = ''; |
|---|
| 176 |
foreach ( $colors AS $txt => $color ) { |
|---|
| 177 |
if ( strpos($text, $txt) ) { |
|---|
| 178 |
$log_color = $color; |
|---|
| 179 |
} |
|---|
| 180 |
} |
|---|
| 181 |
|
|---|
| 182 |
if ( $search = search_id_from_string($text) ) { |
|---|
| 183 |
foreach ( $search AS $id => $type ) { |
|---|
| 184 |
switch ( $type ) { |
|---|
| 185 |
case 'TORRENT': |
|---|
| 186 |
if ( isset($tor_ary[$id]['category']) ) { |
|---|
| 187 |
$cat_id = $tor_ary[$id]['category']; |
|---|
| 188 |
$cat_parent_id = ( isset($cats[$cats[$cat_id]['cat_parent']]['cat_id']) ? $cats[$cats[$cat_id]['cat_parent']]['cat_id'] : 0 ); |
|---|
| 189 |
|
|---|
| 190 |
if ( $cat_parent_id ) { |
|---|
| 191 |
$seo->set_url($cats[$cat_parent_id]['cat_name'], $cat_parent_id, $seo->seo_static['browse']); |
|---|
| 192 |
$seo->set_parent($cat_id, $seo->seo_static['browse'], $cat_parent_id, $seo->seo_static['browse']); |
|---|
| 193 |
} |
|---|
| 194 |
|
|---|
| 195 |
$seo->set_url($cats[$cat_id]['cat_name'], $cat_id, $seo->seo_static['browse']); |
|---|
| 196 |
|
|---|
| 197 |
$seo->set_parent($id, $seo->seo_static['details'], $cat_id, $seo->seo_static['browse']); |
|---|
| 198 |
|
|---|
| 199 |
$seo->set_url($tor_ary[$id]['name'], $id, $seo->seo_static['details']); |
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
$text = preg_replace('/<!--S-->TORRENT_' . $id . '_(.*?)<!--E-->/', '<a href="' . append_sid($root_path . 'details.php?id=' . $id) . '">' . $tor_ary[$id]['name'] . '</a>', $text); |
|---|
| 203 |
} |
|---|
| 204 |
else { |
|---|
| 205 |
$text = preg_replace('/<!--S-->TORRENT_' . $id . '_(.*?)<!--E-->/', '\\1', $text); |
|---|
| 206 |
} |
|---|
| 207 |
break; |
|---|
| 208 |
case 'USER': |
|---|
| 209 |
if ( $user_ary[$id]['privacy'] == PRIVACY_LEVEL_HIGH && $userdata['class'] < UC_MODERATOR && $userdata['name'] <> $user_ary[$id]['name'] ) { |
|---|
| 210 |
if ( $query ) { |
|---|
| 211 |
$continue = true; |
|---|
| 212 |
} |
|---|
| 213 |
$text = preg_replace('/<!--S-->USER_' . $id . '_(.*?)<!--E-->/', $lang['anonymous'], $text); |
|---|
| 214 |
} |
|---|
| 215 |
else { |
|---|
| 216 |
|
|---|
| 217 |
$seo->set_user_url($user_ary[$id]['name'], $id); |
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 |
$text = preg_replace('/<!--S-->USER_' . $id . '_(.*?)<!--E-->/', '<a href="' . append_sid($root_path . 'userdetails.php?id=' . $id) . '">' . $user_ary[$id]['name'] . '</a>', $text); |
|---|
| 221 |
} |
|---|
| 222 |
break; |
|---|
| 223 |
} |
|---|
| 224 |
} |
|---|
| 225 |
} |
|---|
| 226 |
|
|---|
| 227 |
if ( $continue ) { |
|---|
| 228 |
continue; |
|---|
| 229 |
} |
|---|
| 230 |
|
|---|
| 231 |
$template->assign_block_vars('log_row', array( |
|---|
| 232 |
'COLOR' => $log_color, |
|---|
| 233 |
'DATE' => $date, |
|---|
| 234 |
'ACTION' => $text |
|---|
| 235 |
)); |
|---|
| 236 |
} |
|---|
| 237 |
|
|---|
| 238 |
} |
|---|
| 239 |
else { |
|---|
| 240 |
$template->assign_block_vars('log_empty', array()); |
|---|
| 241 |
} |
|---|
| 242 |
|
|---|
| 243 |
stdhead($lang['log']); |
|---|
| 244 |
$template->set_filenames(array(</span> |
|---|
| 245 |
<span class="code-lang"> 'body' => 'log.html') |
|---|
| 246 |
); |
|---|
| 247 |
stdfoot(); |
|---|
| 248 |
?> |
|---|
| 249 |
|
|---|