BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

advancedsearch.php 42KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. <?php
  2. #declare(strict_types = 1);
  3. $ENV = ENV::go();
  4. if (!empty($_GET['search'])) {
  5. if (preg_match('/^'.$ENV->IP_REGEX.'$/', $_GET['search'])) {
  6. $_GET['ip'] = $_GET['search'];
  7. } elseif (preg_match('/^'.EMAIL_REGEX.'$/i', $_GET['search'])) {
  8. $_GET['email'] = $_GET['search'];
  9. } elseif (preg_match(USERNAME_REGEX, $_GET['search'])) {
  10. $DB->query("
  11. SELECT ID
  12. FROM users_main
  13. WHERE Username = '".db_string($_GET['search'])."'");
  14. if (list($ID) = $DB->next_record()) {
  15. header("Location: user.php?id=$ID");
  16. error();
  17. }
  18. $_GET['username'] = $_GET['search'];
  19. } else {
  20. $_GET['comment'] = $_GET['search'];
  21. }
  22. }
  23. define('USERS_PER_PAGE', 30);
  24. function wrap($String, $ForceMatch = '', $IPSearch = false)
  25. {
  26. if (!$ForceMatch) {
  27. global $Match;
  28. } else {
  29. $Match = $ForceMatch;
  30. }
  31. if ($Match == ' REGEXP ') {
  32. if (strpos($String, '\'') !== false || preg_match('/^.*\\\\$/i', $String)) {
  33. error('Regex contains illegal characters.');
  34. }
  35. } else {
  36. $String = db_string($String);
  37. }
  38. if ($Match == ' LIKE ') {
  39. // Fuzzy search
  40. // Stick in wildcards at beginning and end of string unless string starts or ends with |
  41. if (($String[0] != '|') && !$IPSearch) {
  42. $String = "%$String";
  43. } elseif ($String[0] == '|') {
  44. $String = substr($String, 1, strlen($String));
  45. }
  46. if (substr($String, -1, 1) != '|') {
  47. $String = "$String%";
  48. } else {
  49. $String = substr($String, 0, -1);
  50. }
  51. }
  52. $String = "'$String'";
  53. return $String;
  54. }
  55. function date_compare($Field, $Operand, $Date1, $Date2 = '')
  56. {
  57. $Date1 = db_string($Date1);
  58. $Date2 = db_string($Date2);
  59. $Return = [];
  60. switch ($Operand) {
  61. case 'on':
  62. $Return [] = " $Field >= '$Date1 00:00:00' ";
  63. $Return [] = " $Field <= '$Date1 23:59:59' ";
  64. break;
  65. case 'before':
  66. $Return [] = " $Field < '$Date1 00:00:00' ";
  67. break;
  68. case 'after':
  69. $Return [] = " $Field > '$Date1 23:59:59' ";
  70. break;
  71. case 'between':
  72. $Return [] = " $Field >= '$Date1 00:00:00' ";
  73. $Return [] = " $Field <= '$Date2 00:00:00' ";
  74. break;
  75. }
  76. return $Return;
  77. }
  78. function num_compare($Field, $Operand, $Num1, $Num2 = '')
  79. {
  80. if ($Num1 != 0) {
  81. $Num1 = db_string($Num1);
  82. }
  83. if ($Num2 != 0) {
  84. $Num2 = db_string($Num2);
  85. }
  86. $Return = [];
  87. switch ($Operand) {
  88. case 'equal':
  89. $Return [] = " $Field = '$Num1' ";
  90. break;
  91. case 'above':
  92. $Return [] = " $Field > '$Num1' ";
  93. break;
  94. case 'below':
  95. $Return [] = " $Field < '$Num1' ";
  96. break;
  97. case 'between':
  98. $Return [] = " $Field > '$Num1' ";
  99. $Return [] = " $Field < '$Num2' ";
  100. break;
  101. default:
  102. print_r($Return);
  103. error();
  104. }
  105. return $Return;
  106. }
  107. // Arrays, regexes, and all that fun stuff we can use for validation, form generation, etc
  108. $DateChoices = array('inarray'=>array('on', 'before', 'after', 'between'));
  109. $SingleDateChoices = array('inarray'=>array('on', 'before', 'after'));
  110. $NumberChoices = array('inarray'=>array('equal', 'above', 'below', 'between', 'buffer'));
  111. $YesNo = array('inarray'=>array('any', 'yes', 'no'));
  112. $OrderVals = array('inarray'=>array('Username', 'Ratio', 'IP', 'Email', 'Joined', 'Last Seen', 'Uploaded', 'Downloaded', 'Invites', 'Snatches'));
  113. $WayVals = array('inarray'=>array('Ascending', 'Descending'));
  114. if (count($_GET)) {
  115. $DateRegex = array('regex' => '/\d{4}-\d{2}-\d{2}/');
  116. $ClassIDs = [];
  117. $SecClassIDs = [];
  118. foreach ($Classes as $ClassID => $Value) {
  119. if ($Value['Secondary']) {
  120. $SecClassIDs[] = $ClassID;
  121. } else {
  122. $ClassIDs[] = $ClassID;
  123. }
  124. }
  125. $Val->SetFields('comment', '0', 'string', 'Comment is too long.', array('maxlength' => 512));
  126. $Val->SetFields('disabled_invites', '0', 'inarray', 'Invalid disabled_invites field', $YesNo);
  127. $Val->SetFields('joined', '0', 'inarray', 'Invalid joined field', $DateChoices);
  128. $Val->SetFields('join1', '0', 'regex', 'Invalid join1 field', $DateRegex);
  129. $Val->SetFields('join2', '0', 'regex', 'Invalid join2 field', $DateRegex);
  130. $Val->SetFields('lastactive', '0', 'inarray', 'Invalid lastactive field', $DateChoices);
  131. $Val->SetFields('lastactive1', '0', 'regex', 'Invalid lastactive1 field', $DateRegex);
  132. $Val->SetFields('lastactive2', '0', 'regex', 'Invalid lastactive2 field', $DateRegex);
  133. $Val->SetFields('ratio', '0', 'inarray', 'Invalid ratio field', $NumberChoices);
  134. $Val->SetFields('uploaded', '0', 'inarray', 'Invalid uploaded field', $NumberChoices);
  135. $Val->SetFields('downloaded', '0', 'inarray', 'Invalid downloaded field', $NumberChoices);
  136. //$Val->SetFields('snatched', '0', 'inarray', 'Invalid snatched field', $NumberChoices);
  137. $Val->SetFields('matchtype', '0', 'inarray', 'Invalid matchtype field', array('inarray' => array('strict', 'fuzzy', 'regex')));
  138. $Val->SetFields('lockedaccount', '0', 'inarray', 'Invalid locked account field', array('inarray' => array('any', 'locked', 'unlocked')));
  139. $Val->SetFields('enabled', '0', 'inarray', 'Invalid enabled field', array('inarray' => array('', 0, 1, 2)));
  140. $Val->SetFields('class', '0', 'inarray', 'Invalid class', array('inarray' => $ClassIDs));
  141. $Val->SetFields('secclass', '0', 'inarray', 'Invalid class', array('inarray' => $SecClassIDs));
  142. $Val->SetFields('donor', '0', 'inarray', 'Invalid donor field', $YesNo);
  143. $Val->SetFields('warned', '0', 'inarray', 'Invalid warned field', $YesNo);
  144. $Val->SetFields('disabled_uploads', '0', 'inarray', 'Invalid disabled_uploads field', $YesNo);
  145. $Val->SetFields('order', '0', 'inarray', 'Invalid ordering', $OrderVals);
  146. $Val->SetFields('way', '0', 'inarray', 'Invalid way', $WayVals);
  147. $Val->SetFields('passkey', '0', 'string', 'Invalid passkey', array('maxlength' => 32));
  148. $Val->SetFields('avatar', '0', 'string', 'Avatar URL too long', array('maxlength' => 512));
  149. $Val->SetFields('stylesheet', '0', 'inarray', 'Invalid stylesheet', array_unique(array_keys($Stylesheets)));
  150. $Val->SetFields('cc', '0', 'inarray', 'Invalid Country Code', array('maxlength' => 2));
  151. $Err = $Val->ValidateForm($_GET);
  152. if (!$Err) {
  153. // Passed validation. Let's rock.
  154. $RunQuery = false; // if we should run the search
  155. if (isset($_GET['matchtype']) && $_GET['matchtype'] == 'strict') {
  156. $Match = ' = ';
  157. } elseif (isset($_GET['matchtype']) && $_GET['matchtype'] == 'regex') {
  158. $Match = ' REGEXP ';
  159. } else {
  160. $Match = ' LIKE ';
  161. }
  162. $OrderTable = array(
  163. 'Username' => 'um1.Username',
  164. 'Joined' => 'ui1.JoinDate',
  165. 'Email' => 'um1.Email',
  166. 'IP' => 'um1.IP',
  167. 'Last Seen' => 'um1.LastAccess',
  168. 'Uploaded' => 'um1.Uploaded',
  169. 'Downloaded' => 'um1.Downloaded',
  170. 'Ratio' => '(um1.Uploaded / um1.Downloaded)',
  171. 'Invites' => 'um1.Invites',
  172. 'Snatches' => 'Snatches');
  173. $WayTable = array('Ascending'=>'ASC', 'Descending'=>'DESC');
  174. $Where = [];
  175. $Having = [];
  176. $Join = [];
  177. $Group = [];
  178. $Distinct = '';
  179. $Order = '';
  180. $SQL = '
  181. SQL_CALC_FOUND_ROWS
  182. um1.ID,
  183. um1.Username,
  184. um1.Uploaded,
  185. um1.Downloaded,';
  186. if ($_GET['snatched'] == 'off') {
  187. $SQL .= "'X' AS Snatches,";
  188. } else {
  189. $SQL .= "
  190. (
  191. SELECT COUNT(xs.uid)
  192. FROM xbt_snatched AS xs
  193. WHERE xs.uid = um1.ID
  194. ) AS Snatches,";
  195. }
  196. if ($_GET['invitees'] == 'off') {
  197. $SQL .= "'X' AS Invitees,";
  198. } else {
  199. $SQL .= "
  200. (
  201. SELECT COUNT(ui2.UserID)
  202. FROM users_info AS ui2
  203. WHERE um1.ID = ui2.Inviter
  204. ) AS Invitees,";
  205. }
  206. $SQL .= '
  207. um1.PermissionID,
  208. um1.Email,
  209. um1.Enabled,
  210. um1.IP,
  211. um1.Invites,
  212. ui1.DisableInvites,
  213. ui1.Warned,
  214. ui1.Donor,
  215. ui1.JoinDate,
  216. um1.LastAccess
  217. FROM users_main AS um1
  218. JOIN users_info AS ui1 ON ui1.UserID = um1.ID ';
  219. if (!empty($_GET['username'])) {
  220. $Where[] = 'um1.Username'.$Match.wrap($_GET['username']);
  221. }
  222. if (!empty($_GET['email'])) {
  223. if (isset($_GET['email_history'])) {
  224. $Distinct = 'DISTINCT ';
  225. }
  226. $Join['the'] = ' JOIN users_emails_decrypted AS he ON he.ID = um1.ID ';
  227. $Where[] = ' he.Email '.$Match.wrap($_GET['email']);
  228. }
  229. if (!empty($_GET['email_cnt']) && is_number($_GET['email_cnt'])) {
  230. $Query = "
  231. SELECT UserID
  232. FROM users_history_emails
  233. GROUP BY UserID
  234. HAVING COUNT(DISTINCT Email) ";
  235. if ($_GET['emails_opt'] === 'equal') {
  236. $operator = '=';
  237. }
  238. if ($_GET['emails_opt'] === 'above') {
  239. $operator = '>';
  240. }
  241. if ($_GET['emails_opt'] === 'below') {
  242. $operator = '<';
  243. }
  244. $Query .= $operator.' '.$_GET['email_cnt'];
  245. $DB->query($Query);
  246. $Users = implode(',', $DB->collect('UserID'));
  247. if (!empty($Users)) {
  248. $Where[] = "um1.ID IN ($Users)";
  249. }
  250. }
  251. if (!empty($_GET['ip'])) {
  252. if (isset($_GET['ip_history'])) {
  253. $Distinct = 'DISTINCT ';
  254. }
  255. $Join['tip'] = ' JOIN users_ips_decrypted AS tip ON tip.ID = um1.ID ';
  256. $Where[] = ' tip.IP '.$Match.wrap($_GET['ip'], '', true);
  257. }
  258. if ($_GET['lockedaccount'] != '' && $_GET['lockedaccount'] != 'any') {
  259. $Join['la'] = '';
  260. if ($_GET['lockedaccount'] == 'unlocked') {
  261. $Join['la'] .= ' LEFT';
  262. $Where[] = ' la.UserID IS NULL';
  263. }
  264. $Join['la'] .= ' JOIN locked_accounts AS la ON la.UserID = um1.ID ';
  265. }
  266. if (!empty($_GET['tracker_ip'])) {
  267. $Distinct = 'DISTINCT ';
  268. $Join['xfu'] = ' JOIN xbt_files_users AS xfu ON um1.ID = xfu.uid ';
  269. $Where[] = ' xfu.ip '.$Match.wrap($_GET['tracker_ip'], '', true);
  270. }
  271. // if (!empty($_GET['tracker_ip'])) {
  272. // $Distinct = 'DISTINCT ';
  273. // $Join['xs'] = ' JOIN xbt_snatched AS xs ON um1.ID = xs.uid ';
  274. // $Where[] = ' xs.IP '.$Match.wrap($_GET['ip']);
  275. // }
  276. if (!empty($_GET['comment'])) {
  277. $Where[] = 'ui1.AdminComment'.$Match.wrap($_GET['comment']);
  278. }
  279. if (strlen($_GET['invites1'])) {
  280. $Invites1 = round($_GET['invites1']);
  281. $Invites2 = round($_GET['invites2']);
  282. $Where[] = implode(' AND ', num_compare('Invites', $_GET['invites'], $Invites1, $Invites2));
  283. }
  284. if (strlen($_GET['invitees1']) && $_GET['invitees'] != 'off') {
  285. $Invitees1 = round($_GET['invitees1']);
  286. $Invitees2 = round($_GET['invitees2']);
  287. $Having[] = implode(' AND ', num_compare('Invitees', $_GET['invitees'], $Invitees1, $Invitees2));
  288. }
  289. if ($_GET['disabled_invites'] == 'yes') {
  290. $Where[] = 'ui1.DisableInvites = \'1\'';
  291. } elseif ($_GET['disabled_invites'] == 'no') {
  292. $Where[] = 'ui1.DisableInvites = \'0\'';
  293. }
  294. if ($_GET['disabled_uploads'] == 'yes') {
  295. $Where[] = 'ui1.DisableUpload = \'1\'';
  296. } elseif ($_GET['disabled_uploads'] == 'no') {
  297. $Where[] = 'ui1.DisableUpload = \'0\'';
  298. }
  299. if ($_GET['join1']) {
  300. $Where[] = implode(' AND ', date_compare('ui1.JoinDate', $_GET['joined'], $_GET['join1'], $_GET['join2']));
  301. }
  302. if ($_GET['lastactive1']) {
  303. $Where[] = implode(' AND ', date_compare('um1.LastAccess', $_GET['lastactive'], $_GET['lastactive1'], $_GET['lastactive2']));
  304. }
  305. if ($_GET['ratio1']) {
  306. $Decimals = strlen(array_pop(explode('.', $_GET['ratio1'])));
  307. if (!$Decimals) {
  308. $Decimals = 0;
  309. }
  310. $Where[] = implode(' AND ', num_compare("ROUND(Uploaded/Downloaded,$Decimals)", $_GET['ratio'], $_GET['ratio1'], $_GET['ratio2']));
  311. }
  312. if (strlen($_GET['uploaded1'])) {
  313. $Upload1 = round($_GET['uploaded1']);
  314. $Upload2 = round($_GET['uploaded2']);
  315. if ($_GET['uploaded'] != 'buffer') {
  316. $Where[] = implode(' AND ', num_compare('ROUND(Uploaded / 1024 / 1024 / 1024)', $_GET['uploaded'], $Upload1, $Upload2));
  317. } else {
  318. $Where[] = implode(' AND ', num_compare('ROUND((Uploaded / 1024 / 1024 / 1024) - (Downloaded / 1024 / 1024 / 1023))', 'between', $Upload1 * 0.9, $Upload1 * 1.1));
  319. }
  320. }
  321. if (strlen($_GET['downloaded1'])) {
  322. $Download1 = round($_GET['downloaded1']);
  323. $Download2 = round($_GET['downloaded2']);
  324. $Where[] = implode(' AND ', num_compare('ROUND(Downloaded / 1024 / 1024 / 1024)', $_GET['downloaded'], $Download1, $Download2));
  325. }
  326. if (strlen($_GET['snatched1'])) {
  327. $Snatched1 = round($_GET['snatched1']);
  328. $Snatched2 = round($_GET['snatched2']);
  329. $Having[] = implode(' AND ', num_compare('Snatches', $_GET['snatched'], $Snatched1, $Snatched2));
  330. }
  331. if ($_GET['enabled'] != '') {
  332. $Where[] = 'um1.Enabled = '.wrap($_GET['enabled'], '=');
  333. }
  334. if ($_GET['class'] != '') {
  335. $Where[] = 'um1.PermissionID = '.wrap($_GET['class'], '=');
  336. }
  337. if ($_GET['secclass'] != '') {
  338. $Join['ul'] = ' JOIN users_levels AS ul ON um1.ID = ul.UserID ';
  339. $Where[] = 'ul.PermissionID = '.wrap($_GET['secclass'], '=');
  340. }
  341. if ($_GET['donor'] == 'yes') {
  342. $Where[] = 'ui1.Donor = \'1\'';
  343. } elseif ($_GET['donor'] == 'no') {
  344. $Where[] = 'ui1.Donor = \'0\'';
  345. }
  346. if ($_GET['warned'] == 'yes') {
  347. $Where[] = 'ui1.Warned IS NOT NULL';
  348. } elseif ($_GET['warned'] == 'no') {
  349. $Where[] = 'ui1.Warned IS NULL';
  350. }
  351. if ($_GET['disabled_ip']) {
  352. $Distinct = 'DISTINCT ';
  353. if ($_GET['ip_history']) {
  354. if (!isset($Join['tip'])) {
  355. $Join['tip'] = ' JOIN users_ips_decrypted AS tip ON tip.ID = um1.ID ';
  356. }
  357. $Join['tip2'] = ' JOIN users_ips_decrypted2 AS tip2 ON tip2.IP = tip.IP ';
  358. $Join['um2'] = ' JOIN users_main AS um2 ON um2.ID = tip2.ID AND um2.Enabled = \'2\' ';
  359. } else {
  360. $Join['um2'] = ' JOIN users_main AS um2 ON um2.IP = um1.IP AND um2.Enabled = \'2\' ';
  361. }
  362. }
  363. if (!empty($_GET['passkey'])) {
  364. $Where[] = 'um1.torrent_pass'.$Match.wrap($_GET['passkey']);
  365. }
  366. if (!empty($_GET['avatar'])) {
  367. $Where[] = 'ui1.Avatar'.$Match.wrap($_GET['avatar']);
  368. }
  369. if ($_GET['stylesheet'] != '') {
  370. $Where[] = 'ui1.StyleID = '.wrap($_GET['stylesheet'], '=');
  371. }
  372. if ($OrderTable[$_GET['order']] && $WayTable[$_GET['way']]) {
  373. $Order = ' ORDER BY '.$OrderTable[$_GET['order']].' '.$WayTable[$_GET['way']].' ';
  374. }
  375. //---------- Finish generating the search string
  376. $SQL = 'SELECT '.$Distinct.$SQL;
  377. $SQL .= implode(' ', $Join);
  378. if (count($Where)) {
  379. $SQL .= ' WHERE '.implode(' AND ', $Where);
  380. }
  381. if (count($Group)) {
  382. $SQL .= " GROUP BY " . implode(' ,', $Group);
  383. }
  384. if (count($Having)) {
  385. $SQL .= ' HAVING '.implode(' AND ', $Having);
  386. }
  387. $SQL .= $Order;
  388. if (count($Where) > 0 || count($Join) > 0 || count($Having) > 0) {
  389. $RunQuery = true;
  390. }
  391. list($Page, $Limit) = Format::page_limit(USERS_PER_PAGE);
  392. $SQL .= " LIMIT $Limit";
  393. } else {
  394. error($Err);
  395. }
  396. }
  397. View::show_header('User search');
  398. ?>
  399. <div>
  400. <form class="search_form" name="users" action="user.php" method="get">
  401. <input type="hidden" name="action" value="search" />
  402. <table class="layout">
  403. <tr>
  404. <td class="label nobr">Username:</td>
  405. <td width="24%">
  406. <input type="text" name="username" size="20"
  407. value="<?=display_str($_GET['username'])?>" />
  408. </td>
  409. <td class="label nobr">Joined:</td>
  410. <td width="24%">
  411. <select name="joined">
  412. <option value="on" <?php if ($_GET['joined'] === 'on') {
  413. echo ' selected="selected"';
  414. } ?>>On
  415. </option>
  416. <option value="before" <?php if ($_GET['joined'] === 'before') {
  417. echo ' selected="selected"';
  418. } ?>>Before
  419. </option>
  420. <option value="after" <?php if ($_GET['joined'] === 'after') {
  421. echo ' selected="selected"';
  422. } ?>>After
  423. </option>
  424. <option value="between" <?php if ($_GET['joined']==='between') {
  425. echo ' selected="selected"' ;
  426. } ?>>Between
  427. </option>
  428. </select>
  429. <input type="text" name="join1" size="10"
  430. value="<?=display_str($_GET['join1'])?>"
  431. placeholder="YYYY-MM-DD" />
  432. <input type="text" name="join2" size="10"
  433. value="<?=display_str($_GET['join2'])?>"
  434. placeholder="YYYY-MM-DD" />
  435. </td>
  436. <td class="label nobr">Enabled:</td>
  437. <td>
  438. <select name="enabled">
  439. <option value="" <?php if ($_GET['enabled'] === '') {
  440. echo ' selected="selected"';
  441. } ?>>Any
  442. </option>
  443. <option value="0" <?php if ($_GET['enabled']==='0') {
  444. echo ' selected="selected"' ;
  445. } ?>>Unconfirmed
  446. </option>
  447. <option value="1" <?php if ($_GET['enabled']==='1') {
  448. echo ' selected="selected"' ;
  449. } ?>>Enabled
  450. </option>
  451. <option value="2" <?php if ($_GET['enabled']==='2') {
  452. echo ' selected="selected"' ;
  453. } ?>>Disabled
  454. </option>
  455. </select>
  456. </td>
  457. </tr>
  458. <tr>
  459. <td class="label nobr">Email address:</td>
  460. <td>
  461. <input type="text" name="email" size="20"
  462. value="<?=display_str($_GET['email'])?>" />
  463. </td>
  464. <td class="label nobr">Last active:</td>
  465. <td width="30%">
  466. <select name="lastactive">
  467. <option value="on" <?php if ($_GET['lastactive'] === 'on') {
  468. echo ' selected="selected"';
  469. } ?>>On
  470. </option>
  471. <option value="before" <?php if ($_GET['lastactive'] === 'before') {
  472. echo ' selected="selected"';
  473. } ?>>Before
  474. </option>
  475. <option value="after" <?php if ($_GET['lastactive'] === 'after') {
  476. echo ' selected="selected"';
  477. } ?>>After
  478. </option>
  479. <option value="between" <?php if ($_GET['lastactive']==='between') {
  480. echo ' selected="selected"' ;
  481. } ?>
  482. >Between
  483. </option>
  484. </select>
  485. <input type="text" name="lastactive1" size="10"
  486. value="<?=display_str($_GET['lastactive1'])?>"
  487. placeholder="YYYY-MM-DD" />
  488. <input type="text" name="lastactive2" size="10"
  489. value="<?=display_str($_GET['lastactive2'])?>"
  490. placeholder="YYYY-MM-DD" />
  491. </td>
  492. <td class="label nobr">Primary class:</td>
  493. <td>
  494. <select name="class">
  495. <option value="" <?php if ($_GET['class']==='') {
  496. echo ' selected="selected"' ;
  497. } ?>>Any
  498. </option>
  499. <?php foreach ($ClassLevels as $Class) {
  500. if ($Class['Secondary']) {
  501. continue;
  502. } ?>
  503. <option value="<?=$Class['ID'] ?>"
  504. <?php
  505. if ($_GET['class']===$Class['ID']) {
  506. echo ' selected="selected"' ;
  507. } ?>><?=Format::cut_string($Class['Name'], 10, 1, 1).' ('.$Class['Level'].')'?>
  508. </option>
  509. <?php
  510. } ?>
  511. </select>
  512. </td>
  513. </tr>
  514. <tr>
  515. <td class="label tooltip nobr"
  516. title="To fuzzy search (default) for a block of addresses (e.g. 55.66.77.*), enter &quot;55.66.77.&quot; without the quotes">
  517. IP address:</td>
  518. <td>
  519. <input type="text" name="ip" size="20"
  520. value="<?=display_str($_GET['ip'])?>" />
  521. </td>
  522. <td class="label nobr">Locked Account:</td>
  523. <td>
  524. <select name="lockedaccount">
  525. <option value="any" <?php if ($_GET['lockedaccount']=='any') {
  526. echo ' selected="selected"' ;
  527. } ?>>Any
  528. </option>
  529. <option value="locked" <?php if ($_GET['lockedaccount']=='locked') {
  530. echo ' selected="selected"' ;
  531. } ?>>Locked
  532. </option>
  533. <option value="unlocked" <?php if ($_GET['lockedaccount']=='unlocked') {
  534. echo ' selected="selected"' ;
  535. } ?>
  536. >Unlocked
  537. </option>
  538. </select>
  539. </td>
  540. <td class="label nobr">Secondary class:</td>
  541. <td>
  542. <select name="secclass">
  543. <option value="" <?php if ($_GET['secclass']==='') {
  544. echo ' selected="selected"' ;
  545. } ?>>Any
  546. </option>
  547. <?php $Secondaries = [];
  548. // Neither level nor ID is particularly useful when searching secondary classes, so let's do some
  549. // kung-fu to sort them alphabetically.
  550. $fnc = function ($Class1, $Class2) {
  551. return strcmp($Class1['Name'], $Class2['Name']);
  552. };
  553. foreach ($ClassLevels as $Class) {
  554. if (!$Class['Secondary']) {
  555. continue;
  556. }
  557. $Secondaries[] = $Class;
  558. }
  559. usort($Secondaries, $fnc);
  560. foreach ($Secondaries as $Class) {
  561. ?>
  562. <option value="<?=$Class['ID'] ?>"
  563. <?php
  564. if ($_GET['secclass']===$Class['ID']) {
  565. echo ' selected="selected"' ;
  566. } ?>><?=Format::cut_string($Class['Name'], 20, 1, 1)?>
  567. </option>
  568. <?php
  569. } ?>
  570. </select>
  571. </td>
  572. </tr>
  573. <tr>
  574. <td class="label nobr">Extra:</td>
  575. <td>
  576. <ul class="options_list nobullet">
  577. <li>
  578. <input type="checkbox" name="ip_history" id="ip_history" <?php if ($_GET['ip_history']) {
  579. echo ' checked="checked"' ;
  580. } ?> />
  581. <label for="ip_history">IP history</label>
  582. </li>
  583. <li>
  584. <input type="checkbox" name="email_history" id="email_history" <?php if ($_GET['email_history']) {
  585. echo ' checked="checked"' ;
  586. } ?> />
  587. <label for="email_history">Email history</label>
  588. </li>
  589. </ul>
  590. </td>
  591. <td class="label nobr">Ratio:</td>
  592. <td width="30%">
  593. <select name="ratio">
  594. <option value="equal" <?php if ($_GET['ratio'] === 'equal') {
  595. echo ' selected="selected"';
  596. } ?>>Equal
  597. </option>
  598. <option value="above" <?php if ($_GET['ratio'] === 'above') {
  599. echo ' selected="selected"';
  600. } ?>>Above
  601. </option>
  602. <option value="below" <?php if ($_GET['ratio'] === 'below') {
  603. echo ' selected="selected"';
  604. } ?>>Below
  605. </option>
  606. <option value="between" <?php if ($_GET['ratio']==='between') {
  607. echo ' selected="selected"' ;
  608. } ?>>Between
  609. </option>
  610. </select>
  611. <input type="text" name="ratio1" size="6"
  612. value="<?=display_str($_GET['ratio1'])?>" />
  613. <input type="text" name="ratio2" size="6"
  614. value="<?=display_str($_GET['ratio2'])?>" />
  615. </td>
  616. <td class="label nobr">Donor:</td>
  617. <td>
  618. <select name="donor">
  619. <option value="" <?php if ($_GET['donor'] === '') {
  620. echo ' selected="selected"';
  621. } ?>>Any
  622. </option>
  623. <option value="yes" <?php if ($_GET['donor']==='yes') {
  624. echo ' selected="selected"' ;
  625. } ?>>Yes
  626. </option>
  627. <option value="no" <?php if ($_GET['donor'] === 'no') {
  628. echo ' selected="selected"';
  629. } ?>>No
  630. </option>
  631. </select>
  632. </td>
  633. </tr>
  634. <tr>
  635. <?php if (check_perms('users_mod')) { ?>
  636. <td class="label nobr">Staff notes:</td>
  637. <td>
  638. <input type="text" name="comment" size="20"
  639. value="<?=display_str($_GET['comment'])?>" />
  640. </td>
  641. <?php } else { ?>
  642. <td class="label nobr"></td>
  643. <td>
  644. </td>
  645. <?php } ?>
  646. <td class="label tooltip nobr" title="Units are in gibibytes (the base 2 sibling of gigabytes)">Uploaded:</td>
  647. <td width="30%">
  648. <select name="uploaded">
  649. <option value="equal" <?php if ($_GET['uploaded'] === 'equal') {
  650. echo ' selected="selected"';
  651. } ?>>Equal
  652. </option>
  653. <option value="above" <?php if ($_GET['uploaded'] === 'above') {
  654. echo ' selected="selected"';
  655. } ?>>Above
  656. </option>
  657. <option value="below" <?php if ($_GET['uploaded'] === 'below') {
  658. echo ' selected="selected"';
  659. } ?>>Below
  660. </option>
  661. <option value="between" <?php if ($_GET['uploaded']==='between') {
  662. echo ' selected="selected"' ;
  663. } ?>>Between
  664. </option>
  665. <option value="buffer" <?php if ($_GET['uploaded'] === 'buffer') {
  666. echo ' selected="selected"';
  667. } ?>>Buffer
  668. </option>
  669. </select>
  670. <input type="text" name="uploaded1" size="6"
  671. value="<?=display_str($_GET['uploaded1'])?>" />
  672. <input type="text" name="uploaded2" size="6"
  673. value="<?=display_str($_GET['uploaded2'])?>" />
  674. </td>
  675. <td class="label nobr">Warned:</td>
  676. <td>
  677. <select name="warned">
  678. <option value="" <?php if ($_GET['warned'] === '') {
  679. echo ' selected="selected"';
  680. } ?>>Any
  681. </option>
  682. <option value="yes" <?php if ($_GET['warned']==='yes') {
  683. echo ' selected="selected"' ;
  684. } ?>>Yes
  685. </option>
  686. <option value="no" <?php if ($_GET['warned'] === 'no') {
  687. echo ' selected="selected"';
  688. } ?>>No
  689. </option>
  690. </select>
  691. </td>
  692. </tr>
  693. <tr>
  694. <td class="label nobr"># of invites:</td>
  695. <td>
  696. <select name="invites">
  697. <option value="equal" <?php if ($_GET['invites'] === 'equal') {
  698. echo ' selected="selected"';
  699. } ?>>Equal
  700. </option>
  701. <option value="above" <?php if ($_GET['invites'] === 'above') {
  702. echo ' selected="selected"';
  703. } ?>>Above
  704. </option>
  705. <option value="below" <?php if ($_GET['invites'] === 'below') {
  706. echo ' selected="selected"';
  707. } ?>>Below
  708. </option>
  709. <option value="between" <?php if ($_GET['invites']==='between') {
  710. echo ' selected="selected"' ;
  711. } ?>>Between
  712. </option>
  713. </select>
  714. <input type="text" name="invites1" size="6"
  715. value="<?=display_str($_GET['invites1'])?>" />
  716. <input type="text" name="invites2" size="6"
  717. value="<?=display_str($_GET['invites2'])?>" />
  718. </td>
  719. <td class="label tooltip nobr" title="Units are in gibibytes (the base 2 sibling of gigabytes)">Downloaded:</td>
  720. <td width="30%">
  721. <select name="downloaded">
  722. <option value="equal" <?php if ($_GET['downloaded'] === 'equal') {
  723. echo ' selected="selected"';
  724. } ?>>Equal
  725. </option>
  726. <option value="above" <?php if ($_GET['downloaded'] === 'above') {
  727. echo ' selected="selected"';
  728. } ?>>Above
  729. </option>
  730. <option value="below" <?php if ($_GET['downloaded'] === 'below') {
  731. echo ' selected="selected"';
  732. } ?>>Below
  733. </option>
  734. <option value="between" <?php if ($_GET['downloaded']==='between') {
  735. echo ' selected="selected"' ;
  736. } ?>
  737. >Between
  738. </option>
  739. </select>
  740. <input type="text" name="downloaded1" size="6"
  741. value="<?=display_str($_GET['downloaded1'])?>" />
  742. <input type="text" name="downloaded2" size="6"
  743. value="<?=display_str($_GET['downloaded2'])?>" />
  744. </td>
  745. <td class="label tooltip nobr" title="Only display users that have a disabled account linked by IP address">
  746. <label for="disabled_ip">Disabled accounts<br />linked by IP:</label>
  747. </td>
  748. <td>
  749. <input type="checkbox" name="disabled_ip" id="disabled_ip" <?php if ($_GET['disabled_ip']) {
  750. echo ' checked="checked"' ;
  751. } ?> />
  752. </td>
  753. </tr>
  754. <tr>
  755. <td class="label nobr">Disabled invites:</td>
  756. <td>
  757. <select name="disabled_invites">
  758. <option value="" <?php if ($_GET['disabled_invites'] === '') {
  759. echo ' selected="selected"';
  760. } ?>>Any
  761. </option>
  762. <option value="yes" <?php if ($_GET['disabled_invites']==='yes') {
  763. echo ' selected="selected"' ;
  764. } ?>>Yes
  765. </option>
  766. <option value="no" <?php if ($_GET['disabled_invites'] === 'no') {
  767. echo ' selected="selected"';
  768. } ?>>No
  769. </option>
  770. </select>
  771. </td>
  772. <td class="label nobr">Snatched:</td>
  773. <td width="30%">
  774. <select name="snatched">
  775. <option value="equal" <?php if (isset($_GET['snatched']) && $_GET['snatched'] === 'equal') {
  776. echo ' selected="selected"';
  777. } ?>>Equal
  778. </option>
  779. <option value="above" <?php if (isset($_GET['snatched']) && $_GET['snatched'] === 'above') {
  780. echo ' selected="selected"';
  781. } ?>>Above
  782. </option>
  783. <option value="below" <?php if (isset($_GET['snatched']) && $_GET['snatched'] === 'below') {
  784. echo ' selected="selected"';
  785. } ?>>Below
  786. </option>
  787. <option value="between" <?php if (isset($_GET['snatched']) && $_GET['snatched']==='between') {
  788. echo ' selected="selected"' ;
  789. } ?>>Between
  790. </option>
  791. <option value="off" <?php if (!isset($_GET['snatched']) || $_GET['snatched'] === 'off') {
  792. echo ' selected="selected"';
  793. } ?>>Off
  794. </option>
  795. </select>
  796. <input type="text" name="snatched1" size="6"
  797. value="<?=display_str($_GET['snatched1'])?>" />
  798. <input type="text" name="snatched2" size="6"
  799. value="<?=display_str($_GET['snatched2'])?>" />
  800. </td>
  801. <td class="label nobr">Disabled uploads:</td>
  802. <td>
  803. <select name="disabled_uploads">
  804. <option value="" <?php if (isset($_GET['disabled_uploads']) && $_GET['disabled_uploads'] === '') {
  805. echo ' selected="selected"';
  806. } ?>>Any
  807. </option>
  808. <option value="yes" <?php if (isset($_GET['disabled_uploads']) && $_GET['disabled_uploads']==='yes') {
  809. echo ' selected="selected"' ;
  810. } ?>>Yes
  811. </option>
  812. <option value="no" <?php if (isset($_GET['disabled_uploads']) && $_GET['disabled_uploads'] === 'no') {
  813. echo ' selected="selected"';
  814. } ?>>No
  815. </option>
  816. </select>
  817. </td>
  818. </tr>
  819. <tr>
  820. <td width="30%" class="label nobr"># of invitees:</td>
  821. <td>
  822. <select name="invitees">
  823. <option value="equal" <?=isset($_GET['invitees']) && $_GET['invitees'] == 'equal' ? 'selected' : ''?>>Equal
  824. </option>
  825. <option value="above" <?=isset($_GET['invitees']) && $_GET['invitees'] == 'above' ? 'selected' : ''?>>Above
  826. </option>
  827. <option value="below" <?=isset($_GET['invitees']) && $_GET['invitees'] == 'below' ? 'selected' : ''?>>Below
  828. </option>
  829. <option value="between" <?=isset($_GET['invitees']) && $_GET['invitees'] == 'between' ? 'selected' : ''?>>Between
  830. </option>
  831. <option value="off" <?=!isset($_GET['invitees']) || $_GET['invitees'] == 'off' ? 'selected' : ''?>>Off
  832. </option>
  833. </select>
  834. <input type="text" name="invitees1" size="6"
  835. value="<?=display_str($_GET['invitees1'])?>" />
  836. <input type="text" name="invitees2" size="6"
  837. value="<?=display_str($_GET['invitees2'])?>" />
  838. </td>
  839. <td class="label nobr">Passkey:</td>
  840. <td>
  841. <input type="text" name="passkey" size="20"
  842. value="<?=display_str($_GET['passkey'])?>" />
  843. </td>
  844. <td class="label nobr">Tracker IP:</td>
  845. <td>
  846. <input type="text" name="tracker_ip" size="20"
  847. value="<?=display_str($_GET['tracker_ip'])?>" />
  848. </td>
  849. </tr>
  850. <tr>
  851. <td class="label tooltip nobr"
  852. title="Supports partial URL matching, e.g. entering &quot;&#124;https://whatimg.com&quot; will search for avatars hosted on https://whatimg.com">
  853. Avatar URL:</td>
  854. <td>
  855. <input type="text" name="avatar" size="20"
  856. value="<?=display_str($_GET['avatar'])?>" />
  857. </td>
  858. <td class="label nobr">Stylesheet:</td>
  859. <td>
  860. <select name="stylesheet" id="stylesheet">
  861. <option value="">Any</option>
  862. <?php foreach ($Stylesheets as $Style) { ?>
  863. <option value="<?=$Style['ID']?>"
  864. <?Format::selected('stylesheet', $Style['ID'])?>><?=$Style['ProperName']?>
  865. </option>
  866. <?php } ?>
  867. </select>
  868. </td>
  869. <td class="label tooltip nobr" title="Two-letter codes as defined in ISO 3166-1 alpha-2">Country code:</td>
  870. <td width="30%">
  871. <select name="cc_op">
  872. <option value="equal" <?php if ($_GET['cc_op'] === 'equal') {
  873. echo ' selected="selected"';
  874. } ?>>Equals
  875. </option>
  876. <option value="not_equal" <?php if ($_GET['cc_op']==='not_equal') {
  877. echo ' selected="selected"' ;
  878. } ?>>Not
  879. equal
  880. </option>
  881. </select>
  882. <input type="text" name="cc" size="2"
  883. value="<?=display_str($_GET['cc'])?>" />
  884. </td>
  885. </tr>
  886. <tr>
  887. <td class="label nobr">Search type:</td>
  888. <td>
  889. <ul class="options_list nobullet">
  890. <li>
  891. <input type="radio" name="matchtype" id="strict_match_type" value="strict" <?php if ($_GET['matchtype']=='strict' || !$_GET['matchtype']) {
  892. echo ' checked="checked"' ;
  893. } ?> />
  894. <label class="tooltip"
  895. title="A &quot;strict&quot; search uses no wildcards in search fields, and it is analogous to &#96;grep -E &quot;&circ;SEARCHTERM&#36;&quot;&#96;"
  896. for="strict_match_type">Strict</label>
  897. </li>
  898. <li>
  899. <input type="radio" name="matchtype" id="fuzzy_match_type" value="fuzzy" <?php if ($_GET['matchtype']=='fuzzy' || !$_GET['matchtype']) {
  900. echo ' checked="checked"' ;
  901. } ?> />
  902. <label class="tooltip"
  903. title="A &quot;fuzzy&quot; search automatically prepends and appends wildcards to search strings, except for IP address searches, unless the search string begins or ends with a &quot;&#124;&quot; (pipe). It is analogous to a vanilla grep search (except for the pipe stuff)."
  904. for="fuzzy_match_type">Fuzzy</label>
  905. </li>
  906. <li>
  907. <input type="radio" name="matchtype" id="regex_match_type" value="regex" <?php if ($_GET['matchtype']=='regex') {
  908. echo ' checked="checked"' ;
  909. } ?> />
  910. <label class="tooltip" title="A &quot;regex&quot; search uses MySQL's regular expression syntax."
  911. for="regex_match_type">Regex</label>
  912. </li>
  913. </ul>
  914. </td>
  915. <td class="label nobr">Order:</td>
  916. <td class="nobr">
  917. <select name="order">
  918. <?php
  919. foreach (array_shift($OrderVals) as $Cur) { ?>
  920. <option value="<?=$Cur?>" <?php if (isset($_GET['order']) &&
  921. $_GET['order']==$Cur || (!isset($_GET['order']) && $Cur=='Joined')) {
  922. echo ' selected="selected"' ;
  923. } ?>
  924. ><?=$Cur?>
  925. </option>
  926. <?php } ?>
  927. </select>
  928. <select name="way">
  929. <?php foreach (array_shift($WayVals) as $Cur) { ?>
  930. <option value="<?=$Cur?>" <?php if (isset($_GET['way']) &&
  931. $_GET['way']==$Cur || (!isset($_GET['way']) && $Cur=='Descending')) {
  932. echo ' selected="selected"' ;
  933. } ?>
  934. ><?=$Cur?>
  935. </option>
  936. <?php } ?>
  937. </select>
  938. </td>
  939. <td class="label nobr"># of emails:</td>
  940. <td>
  941. <select name="emails_opt">
  942. <option value="equal" <?php if ($_GET['emails_opt']==='equal') {
  943. echo ' selected="selected"' ;
  944. } ?>>Equal
  945. </option>
  946. <option value="above" <?php if ($_GET['emails_opt']==='above') {
  947. echo ' selected="selected"' ;
  948. } ?>>Above
  949. </option>
  950. <option value="below" <?php if ($_GET['emails_opt']==='below') {
  951. echo ' selected="selected"' ;
  952. } ?>>Below
  953. </option>
  954. </select>
  955. <input type="text" name="email_cnt" size="6"
  956. value="<?=display_str($_GET['email_cnt'])?>" />
  957. </td>
  958. </tr>
  959. <tr>
  960. <td colspan="6" class="center">
  961. <input type="submit" value="Search users" />
  962. </td>
  963. </tr>
  964. </table>
  965. </form>
  966. </div>
  967. <?php
  968. if ($RunQuery) {
  969. if (!empty($_GET['ip'])) {
  970. if (isset($_GET['ip_history'])) {
  971. $DB->query("SELECT UserID, IP FROM users_history_ips");
  972. } else {
  973. $DB->query("SELECT ID, IP FROM users_main");
  974. }
  975. while (list($ID, $EncIP) = $DB->next_record()) {
  976. $IPs[] = $ID.", '".Crypto::decrypt($EncIP)."'";
  977. }
  978. $DB->query("CREATE TEMPORARY TABLE users_ips_decrypted (ID INT(10) UNSIGNED NOT NULL, IP VARCHAR(45) NOT NULL, PRIMARY KEY (ID,IP)) ENGINE=MEMORY");
  979. $DB->query("INSERT IGNORE INTO users_ips_decrypted (ID, IP) VALUES(".implode("),(", $IPs).")");
  980. if ($_GET['disabled_ip'] && $_GET['ip_history']) {
  981. $DB->query("CREATE TEMPORARY TABLE users_ips_decrypted2 SELECT * FROM users_ips_decrypted");
  982. }
  983. }
  984. if (!empty($_GET['email'])) {
  985. if (isset($_GET['email_history'])) {
  986. $DB->query("SELECT UserID, Email FROM users_history_emails");
  987. } else {
  988. $DB->query("SELECT ID, Email FROM users_main");
  989. }
  990. while (list($ID, $EncEmail) = $DB->next_record()) {
  991. $Emails[] = $ID.", '".Crypto::decrypt($EncEmail)."'";
  992. }
  993. $DB->query("CREATE TEMPORARY TABLE users_emails_decrypted (ID INT(10) UNSIGNED NOT NULL, Email VARCHAR(255) NOT NULL, PRIMARY KEY (ID,Email)) ENGINE=MEMORY");
  994. $DB->query("INSERT IGNORE INTO users_emails_decrypted (ID, Email) VALUES(".implode("),(", $Emails).")");
  995. }
  996. $Results = $DB->query($SQL);
  997. $DB->query('SELECT FOUND_ROWS()');
  998. list($NumResults) = $DB->next_record();
  999. if (!empty($_GET['ip'])) {
  1000. $DB->query("DROP TABLE users_ips_decrypted");
  1001. }
  1002. if (!empty($_GET['email'])) {
  1003. $DB->query("DROP TABLE users_emails_decrypted");
  1004. }
  1005. $DB->set_query_id($Results);
  1006. } else {
  1007. $DB->query('SET @nothing = 0');
  1008. $NumResults = 0;
  1009. }
  1010. ?>
  1011. <div class="linkbox">
  1012. <?php
  1013. $Pages = Format::get_pages($Page, $NumResults, USERS_PER_PAGE, 11);
  1014. echo $Pages;
  1015. ?>
  1016. </div>
  1017. <div class="box pad center">
  1018. <h2><?=number_format($NumResults)?> results</h2>
  1019. <table width="100%">
  1020. <tr class="colhead">
  1021. <td>Username</td>
  1022. <td>Ratio</td>
  1023. <td>IP address</td>
  1024. <td>Email</td>
  1025. <td>Joined</td>
  1026. <td>Last seen</td>
  1027. <td>Upload</td>
  1028. <td>Download</td>
  1029. <td>Downloads</td>
  1030. <td>Snatched</td>
  1031. <td>Invites</td>
  1032. <?php if (isset($_GET['invitees']) && $_GET['invitees'] != 'off') { ?>
  1033. <td>Invitees</td>
  1034. <?php } ?>
  1035. </tr>
  1036. <?php
  1037. while (list($UserID, $Username, $Uploaded, $Downloaded, $Snatched, $Invitees, $Class, $Email, $Enabled, $IP, $Invites, $DisableInvites, $Warned, $Donor, $JoinDate, $LastAccess) = $DB->next_record()) {
  1038. $IP = apcu_exists('DBKEY') ? Crypto::decrypt($IP) : '[Encrypted]';
  1039. $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]'; ?>
  1040. <tr>
  1041. <td><?=Users::format_username($UserID, true, true, true, true)?>
  1042. </td>
  1043. <td><?=Format::get_ratio_html($Uploaded, $Downloaded)?>
  1044. </td>
  1045. <td style="word-break: break-all;"><?=display_str($IP)?>
  1046. </td>
  1047. <td><?=display_str($Email)?>
  1048. </td>
  1049. <td><?=time_diff($JoinDate)?>
  1050. </td>
  1051. <td><?=time_diff($LastAccess)?>
  1052. </td>
  1053. <td><?=Format::get_size($Uploaded)?>
  1054. </td>
  1055. <td><?=Format::get_size($Downloaded)?>
  1056. </td>
  1057. <?php $DB->query("
  1058. SELECT COUNT(ud.UserID)
  1059. FROM users_downloads AS ud
  1060. JOIN torrents AS t ON t.ID = ud.TorrentID
  1061. WHERE ud.UserID = $UserID");
  1062. list($Downloads) = $DB->next_record();
  1063. $DB->set_query_id($Results); ?>
  1064. <td><?=number_format((int)$Downloads)?>
  1065. </td>
  1066. <td><?=(is_numeric($Snatched) ? number_format($Snatched) : display_str($Snatched))?>
  1067. </td>
  1068. <td>
  1069. <?php if ($DisableInvites) {
  1070. echo 'X';
  1071. } else {
  1072. echo number_format($Invites);
  1073. } ?>
  1074. </td>
  1075. <?php if (isset($_GET['invitees']) && $_GET['invitees'] != 'off') { ?>
  1076. <td><?=number_format($Invitees)?>
  1077. </td>
  1078. <?php } ?>
  1079. </tr>
  1080. <?php
  1081. }
  1082. ?>
  1083. </table>
  1084. </div>
  1085. <div class="linkbox">
  1086. <?=$Pages?>
  1087. </div>
  1088. <?php View::show_footer();