| 1 |
<?php</span> |
|---|
| 2 |
<span class="code-lang">$root_path = './'; |
|---|
| 3 |
require ($root_path . 'include/config.php'); |
|---|
| 4 |
require ($root_path . 'languages/lang_' . $config['default_lang'] . '/lang_modcomment_log.php'); |
|---|
| 5 |
|
|---|
| 6 |
$userdata = session_pagestart($user_ip); |
|---|
| 7 |
init_userprefs($userdata); |
|---|
| 8 |
loggedinorreturn();</span> |
|---|
| 9 |
<span class="code-lang"> |
|---|
| 10 |
if ($userdata['class'] < UC_SYSOP) { |
|---|
| 11 |
trigger_error($lang['access_denied']); |
|---|
| 12 |
} |
|---|
| 13 |
|
|---|
| 14 |
$mode = request_var('mode', ''); |
|---|
| 15 |
$show_banned = request_var('show_banned', 0);</span> |
|---|
| 16 |
<span class="code-lang"> |
|---|
| 17 |
if ( isset($_POST['id']) ) { |
|---|
| 18 |
$ids = request_var('id', array(0=>0)); |
|---|
| 19 |
$modcomment_ban = "\n" . sprintf($lang['modcomment_account_disabled'], 't' . time(), $userdata['name'], $lang['cheater']); |
|---|
| 20 |
|
|---|
| 21 |
meta_refresh(3, append_sid($root_path . 'cheaters.php' . ( $mode == 'stealth_downers' ? '?mode=stealth_downers' : '' ) . ( $show_banned ? '&show_banned=1' : '' ))); |
|---|
| 22 |
|
|---|
| 23 |
switch ( $mode ) { |
|---|
| 24 |
|
|---|
| 25 |
case 'stealth_downers': |
|---|
| 26 |
|
|---|
| 27 |
if ( isset($_POST['ban']) ) { |
|---|
| 28 |
|
|---|
| 29 |
$sql = 'SELECT name, uid, modcomment, ip FROM ' . USERS_TABLE . ' WHERE uid IN (' . implode(', ', $ids) . ') AND enabled = 1'; |
|---|
| 30 |
$result = $db->sql_query($sql); |
|---|
| 31 |
|
|---|
| 32 |
while ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 33 |
$modcomment = $row['modcomment'] . $modcomment_ban; |
|---|
| 34 |
|
|---|
| 35 |
$sql = 'UPDATE ' . USERS_TABLE . ' SET enabled = 0, warneduntil = 0, modcomment = \'' . $db->sql_escape($modcomment) . '\' WHERE uid = ' . $row['uid']; |
|---|
| 36 |
$db->sql_query($sql); |
|---|
| 37 |
|
|---|
| 38 |
session_reset_keys($row['uid'], $row['ip']); |
|---|
| 39 |
|
|---|
| 40 |
write_log(sprintf($lang['log_account_disable'], 'userdetails_' . $row['uid'], $row['name'], $userdata['name'], $lang['cheater']), LOG_VIEW_ADMIN); |
|---|
| 41 |
} |
|---|
| 42 |
trigger_error($lang['success_banned']); |
|---|
| 43 |
} |
|---|
| 44 |
break; |
|---|
| 45 |
|
|---|
| 46 |
default: |
|---|
| 47 |
if ( isset($_POST['ban']) ) { |
|---|
| 48 |
$sql = 'SELECT u.name, u.uid AS user_id, modcomment, ip FROM ' . USERS_TABLE . ' u, ' . CHEATERS_TABLE . ' c |
|---|
| 49 |
WHERE u.uid = c.userid AND u.uid IN (' . implode(', ', $ids) . ') AND enabled = 1 GROUP BY u.uid'; |
|---|
| 50 |
$result = $db->sql_query($sql); |
|---|
| 51 |
|
|---|
| 52 |
while ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 53 |
$modcomment = $row['modcomment'] . $modcomment_ban; |
|---|
| 54 |
|
|---|
| 55 |
$sql = 'UPDATE ' . USERS_TABLE . ' SET enabled = 0, warneduntil = 0, modcomment = \'' . $db->sql_escape($modcomment) . '\' WHERE uid = ' . $row['user_id']; |
|---|
| 56 |
$db->sql_query($sql); |
|---|
| 57 |
|
|---|
| 58 |
session_reset_keys($row['user_id'], $row['ip']); |
|---|
| 59 |
|
|---|
| 60 |
write_log(sprintf($lang['log_account_disable'], 'userdetails_' . $row['user_id'], $row['name'], $userdata['name'], $lang['cheater']), LOG_VIEW_ADMIN); |
|---|
| 61 |
} |
|---|
| 62 |
trigger_error($lang['success_banned']); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
if ( isset($_POST['delete']) ) { |
|---|
| 66 |
$sql = 'DELETE FROM ' . CHEATERS_TABLE . ' WHERE userid IN (' . implode(', ', $ids) . ')'; |
|---|
| 67 |
$db->sql_query($sql); |
|---|
| 68 |
|
|---|
| 69 |
trigger_error ($lang['success_delete']); |
|---|
| 70 |
} |
|---|
| 71 |
|
|---|
| 72 |
break; |
|---|
| 73 |
|
|---|
| 74 |
} |
|---|
| 75 |
} |
|---|
| 76 |
else { |
|---|
| 77 |
|
|---|
| 78 |
switch ( $mode ) { |
|---|
| 79 |
|
|---|
| 80 |
case 'stealth_downers'; |
|---|
| 81 |
|
|---|
| 82 |
$template->assign_vars(array( |
|---|
| 83 |
'S_FORM_ACTION' => append_sid('cheaters.php'. ( $show_banned ? '?show_banned=1' : '' )), |
|---|
| 84 |
'U_SHOW_BANNED' => append_sid('cheaters.php?mode=stealth_downers' . ( !$show_banned ? '&show_banned=1' : '' ) ), |
|---|
| 85 |
'L_SHOW_ENABLED' => ( $show_banned ? $lang['hide_disabled'] : $lang['show_disabled'] ) |
|---|
| 86 |
)); |
|---|
| 87 |
|
|---|
| 88 |
$sql = 'SELECT COUNT(s.torrentid) AS utc, u.uid, u.name, u.class, u.downloaded, u.uploaded, u.enabled, u.parked, u.warneduntil, u.donor, u.added AS reg_date, t.fid |
|---|
| 89 |
FROM ' . USERS_TABLE . ' u, ' . SNATCHED_TABLE . ' s, ' . TORRENTS_TABLE . ' t |
|---|
| 90 |
WHERE u.uid = s.userid AND s.torrentid = t.fid AND s.completedat = 0 AND t.owner != s.userid' . ( !$show_banned ? ' AND u.enabled = 1' : '' ) . ' AND s.uploaded = 0 AND t.ctime < ' . ( time() - 7 * 24 * 60 * 60 ) . ' |
|---|
| 91 |
GROUP BY u.uid |
|---|
| 92 |
HAVING COUNT(s.torrentid) > 20 |
|---|
| 93 |
ORDER BY utc DESC'; |
|---|
| 94 |
|
|---|
| 95 |
$result = $db->sql_query($sql); |
|---|
| 96 |
$i = 0; |
|---|
| 97 |
$page = request_var('page', 0); |
|---|
| 98 |
|
|---|
| 99 |
while ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 100 |
++$i; |
|---|
| 101 |
|
|---|
| 102 |
$template->assign_block_vars('cheaters_row', array( |
|---|
| 103 |
'NUM' => $i + ( $page * 100 ), |
|---|
| 104 |
'U_USERDETAILS' => append_sid('userdetails.php?id=' . $row['uid']), |
|---|
| 105 |
'USER_ID' => $row['uid'], |
|---|
| 106 |
'USERNAME' => get_user_class_color($row['class'], $row['name']), |
|---|
| 107 |
'USER_ICONS' => get_user_icons($row), |
|---|
| 108 |
'UNCOMPLETED_TORRENTS_COUNT' => $row['utc'], |
|---|
| 109 |
'REG_DATE' => create_date($row['reg_date']) |
|---|
| 110 |
)); |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
stdhead($lang['cheaters']); |
|---|
| 114 |
$template->set_filenames(array( |
|---|
| 115 |
'body' => 'cheaters_stealth_downers.html') |
|---|
| 116 |
); |
|---|
| 117 |
stdfoot(); |
|---|
| 118 |
break; |
|---|
| 119 |
|
|---|
| 120 |
case 'show_data': |
|---|
| 121 |
|
|---|
| 122 |
require ($root_path . 'include/ajax.php'); |
|---|
| 123 |
$JsHttpRequest = new JsHttpRequest(); |
|---|
| 124 |
$db->sql_return_on_error(true); |
|---|
| 125 |
|
|---|
| 126 |
$uid = request_var('user_id', 0); |
|---|
| 127 |
|
|---|
| 128 |
if ( !$uid ) { |
|---|
| 129 |
return $_RESULT = array( 'data' => $bad_data ); |
|---|
| 130 |
} |
|---|
| 131 |
|
|---|
| 132 |
else { |
|---|
| 133 |
$sql = 'SELECT t.name, s.uploaded, s.downloaded, s.last_action, t.size, p.uid |
|---|
| 134 |
FROM ' . SNATCHED_TABLE . ' s LEFT JOIN ' . PEERS_TABLE . ' p ON ( s.torrentid = p.fid AND s.userid = p.uid ), ' . TORRENTS_TABLE . ' t |
|---|
| 135 |
WHERE s.torrentid = t.fid AND s.completedat = 0 AND t.owner != s.userid AND s.userid = ' . $uid . ' |
|---|
| 136 |
ORDER BY s.last_action DESC'; |
|---|
| 137 |
if ( !($result = $db->sql_query($sql)) ) { |
|---|
| 138 |
$error = $db->sql_error($result); |
|---|
| 139 |
return $_RESULT = array( 'data' => $error['message'] ); |
|---|
| 140 |
} |
|---|
| 141 |
else { |
|---|
| 142 |
$data = ''; |
|---|
| 143 |
$format_string = '<span style="color:green" title="' . $lang['active'] . '">%s</span>'; |
|---|
| 144 |
while ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 145 |
$data .= $lang['torrent'] . ': ' . ( !empty($row['uid']) ? sprintf($format_string, $row['name']) : $row['name'] ) . '<br />'; |
|---|
| 146 |
$data .= $lang['size'] . ': ' . mksize($row['size']) . '<br />'; |
|---|
| 147 |
$data .= $lang['uploaded'] . ': ' . mksize($row['uploaded']) . '<br />'; |
|---|
| 148 |
$data .= $lang['downloaded'] . ': ' . mksize($row['downloaded']) . '<br />'; |
|---|
| 149 |
$data .= $lang['last_action'] . ': ' . create_date($row['last_action']) . '<br />'; |
|---|
| 150 |
$data .= '<hr />'; |
|---|
| 151 |
} |
|---|
| 152 |
|
|---|
| 153 |
return $_RESULT = array( 'data' => $data ); |
|---|
| 154 |
} |
|---|
| 155 |
} |
|---|
| 156 |
break; |
|---|
| 157 |
|
|---|
| 158 |
default: |
|---|
| 159 |
|
|---|
| 160 |
$template->assign_vars(array( |
|---|
| 161 |
'S_FORM_ACTION' => append_sid('cheaters.php'), |
|---|
| 162 |
'U_SHOW_BANNED' => append_sid('cheaters.php' . ( !$show_banned ? '?show_banned=1' : '' ) ), |
|---|
| 163 |
'L_SHOW_ENABLED' => ( $show_banned ? $lang['hide_disabled'] : $lang['show_disabled'] ) |
|---|
| 164 |
)); |
|---|
| 165 |
|
|---|
| 166 |
$sql = 'SELECT c.*, u.uid AS user_id, u.name, u.class, u.downloaded, u.uploaded, u.enabled, u.parked, u.warneduntil, u.donor, u.added AS reg_date, t.name AS torrent_name, t.fid AS torrent_id, t.size |
|---|
| 167 |
FROM ' . CHEATERS_TABLE . ' c, ' . USERS_TABLE . ' u, ' . TORRENTS_TABLE . ' t |
|---|
| 168 |
WHERE c.userid = u.uid AND c.torrentid = t.fid' . ( !$show_banned ? ' AND u.enabled = 1' : '' ) . ' |
|---|
| 169 |
ORDER BY added DESC '; |
|---|
| 170 |
$result = $db->sql_query($sql); |
|---|
| 171 |
|
|---|
| 172 |
$page = request_var('page', 0); |
|---|
| 173 |
|
|---|
| 174 |
$i = 0; |
|---|
| 175 |
|
|---|
| 176 |
$users_ary = array(); |
|---|
| 177 |
$i = 0; |
|---|
| 178 |
|
|---|
| 179 |
while ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 180 |
|
|---|
| 181 |
$ratio = get_ratio($row['uploaded'], $row['downloaded']); |
|---|
| 182 |
$ratio_color = get_ratio_color($ratio); |
|---|
| 183 |
$uppd = mksize($row['upthis']); |
|---|
| 184 |
|
|---|
| 185 |
$username = get_user_class_color($row['class'], $row['name']); |
|---|
| 186 |
$reg_date = create_date($row['reg_date']); |
|---|
| 187 |
$user_icons = get_user_icons($row); |
|---|
| 188 |
|
|---|
| 189 |
$ary_key = $username . '|' . $row['user_id'] . '|' . $row['userip'] . '|' . $reg_date . '|' . $user_icons; |
|---|
| 190 |
|
|---|
| 191 |
$users_ary[$ary_key][$row['torrent_id'] . '|' . $row['torrent_name']][] = array( |
|---|
| 192 |
'USERNAME' => get_user_class_color($row['class'], $row['name']), |
|---|
| 193 |
'UPLOADED' => $uppd, |
|---|
| 194 |
'SPEED' => mksize($row['rate']) . '/' . $lang['secs_short'], |
|---|
| 195 |
'WITHIN' => $row['timediff'] . $lang['secs_short'], |
|---|
| 196 |
'CLIENT' => getagent($row['che_useragent'], $row['che_peer_id']), |
|---|
| 197 |
'IP' => $row['userip'], |
|---|
| 198 |
'ID' => $row['id'], |
|---|
| 199 |
'ADDED' => create_date($row['added']), |
|---|
| 200 |
'TORRENT_ID' => $row['torrent_id'], |
|---|
| 201 |
'TORRENT_SIZE' => mksize($row['size']) |
|---|
| 202 |
); |
|---|
| 203 |
} |
|---|
| 204 |
|
|---|
| 205 |
@ksort($users_ary); |
|---|
| 206 |
|
|---|
| 207 |
foreach ( $users_ary AS $user_id => $ary ) { |
|---|
| 208 |
|
|---|
| 209 |
++$i; |
|---|
| 210 |
|
|---|
| 211 |
list($username, $user_id, $user_ip, $reg_date, $user_icons) = explode('|', $user_id); |
|---|
| 212 |
|
|---|
| 213 |
$template->assign_block_vars('cheat_users_row', array( |
|---|
| 214 |
'USER_ID' => $user_id, |
|---|
| 215 |
'USERNAME' => $username, |
|---|
| 216 |
'USER_IP' => $user_ip, |
|---|
| 217 |
'U_USERDETAILS' => append_sid('userdetails.php?id=' . $user_id), |
|---|
| 218 |
'REG_DATE' => $reg_date, |
|---|
| 219 |
'USER_ICONS' => $user_icons, |
|---|
| 220 |
'NUMBER' => $i |
|---|
| 221 |
)); |
|---|
| 222 |
|
|---|
| 223 |
foreach ( $ary AS $torrent_id => $sub_ary ) { |
|---|
| 224 |
|
|---|
| 225 |
list($torrent_id, $torrent_name) = explode('|', $torrent_id); |
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
$seo->set_url(censor_text($torrent_name), $torrent_id, $seo->seo_static['details']); |
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
$template->assign_block_vars('cheat_users_row.torrents_row', array( |
|---|
| 232 |
'U_TORRENT' => append_sid($root_path . 'details.php?id=' . $torrent_id), |
|---|
| 233 |
'TORRENT_NAME' => $torrent_name, |
|---|
| 234 |
)); |
|---|
| 235 |
|
|---|
| 236 |
foreach ( $sub_ary AS $_null => $sub_sub_ary ) { |
|---|
| 237 |
|
|---|
| 238 |
$template->assign_block_vars('cheat_users_row.torrents_row.torrents_data', array( |
|---|
| 239 |
'UPLOADED' => $sub_sub_ary['UPLOADED'], |
|---|
| 240 |
'SPEED' => $sub_sub_ary['SPEED'], |
|---|
| 241 |
'WITHIN' => $sub_sub_ary['WITHIN'], |
|---|
| 242 |
'CLIENT' => $sub_sub_ary['CLIENT'], |
|---|
| 243 |
'IP' => $sub_sub_ary['IP'], |
|---|
| 244 |
'ADDED' => $sub_sub_ary['ADDED'], |
|---|
| 245 |
'TORRENT_SIZE' => $sub_sub_ary['TORRENT_SIZE'], |
|---|
| 246 |
)); |
|---|
| 247 |
} |
|---|
| 248 |
} |
|---|
| 249 |
} |
|---|
| 250 |
|
|---|
| 251 |
stdhead($lang['cheaters']); |
|---|
| 252 |
$template->set_filenames(array( |
|---|
| 253 |
'body' => 'cheaters_body.html') |
|---|
| 254 |
); |
|---|
| 255 |
stdfoot(); |
|---|
| 256 |
break; |
|---|
| 257 |
} |
|---|
| 258 |
} |
|---|
| 259 |
?> |
|---|