PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/users.php

https://bitbucket.org/nexea/x00n
PHP | 315 lines | 285 code | 29 blank | 1 comment | 69 complexity | fbe555ec9052c2ed759d36a52c7fd155 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?
  2. require "Settings.php";
  3. require "lib/Library.php";
  4. dbconn(false);
  5. loggedinorreturn();
  6. function bark($msg)
  7. {
  8. stdhead();
  9. stdmsg("Error", $msg);
  10. stdfoot();
  11. exit;
  12. }
  13. $id = $_GET["id"];
  14. if(!is_valid_id($id))
  15. bark("Bad ID $id.");
  16. $userSQL = "SELECT * FROM `users` WHERE `id`=$id";
  17. $r = @mysql_query($userSQL) or mysql_error();
  18. $user = mysql_fetch_array($r) or bark("No user with ID $id.");
  19. if ($user["status"] == "pending") die;
  20. $r = mysql_query("SELECT id, name, seeders, leechers, category FROM torrents WHERE owner=$id ORDER BY name") or mysql_error();
  21. if ($user["ip"] && (get_user_class() >= UC_MODERATOR || $user["id"] == $CURUSER["id"]))
  22. {
  23. $ip = $user["ip"];
  24. $dom = @gethostbyaddr($user["ip"]);
  25. if ($dom == $user["ip"] || @gethostbyname($dom) != $user["ip"]){
  26. $addr = $ip;
  27. }
  28. else
  29. {
  30. $dom = strtoupper($dom);
  31. $domparts = explode(".", $dom);
  32. $domain = $domparts[count($domparts) - 2];
  33. }
  34. if ($domain == "COM" || $domain == "CO" || $domain == "NET" || $domain == "NE" || $domain == "ORG" || $domain == "OR" ){
  35. $l = 2;
  36. }
  37. else
  38. {
  39. $l = 1;
  40. $addr = "$ip ($dom)";
  41. }
  42. }
  43. if ($user[added] == "0000-00-00 00:00:00"){
  44. $joindate = 'N/A';
  45. }
  46. else
  47. {
  48. $joindate = "$user[added] (" . get_elapsed_time(sql_timestamp_to_unix_timestamp($user["added"])) . " ago)";
  49. $lastseen = $user["last_access"];
  50. }
  51. if ($lastseen == "0000-00-00 00:00:00"){
  52. $lastseen = "never";
  53. }
  54. else
  55. {
  56. $lastseen .= " (" . get_elapsed_time(sql_timestamp_to_unix_timestamp($lastseen)) . " ago)";
  57. }
  58. $res = mysql_query("SELECT COUNT(*) FROM comments WHERE user=" . $user[id]) or mysql_error();
  59. $arr3 = mysql_fetch_row($res);
  60. $torrentcomments = $arr3[0];
  61. $res = mysql_query("SELECT COUNT(*) FROM posts WHERE userid=" . $user[id]) or mysql_error();
  62. $arr3 = mysql_fetch_row($res);
  63. $forumposts = $arr3[0];
  64. if ($user['donated'] > 0){
  65. $don = "<img src=\"images/starbig.gif\">";
  66. }
  67. $res = mysql_query("SELECT name,flagpic FROM countries WHERE id=$user[country] LIMIT 1") or mysql_error();
  68. if (mysql_num_rows($res) == 1)
  69. {
  70. $arr = mysql_fetch_assoc($res);
  71. $country = "<img height=\"11\" width=\"16\" src=\"images/flag/$arr[flagpic]\" alt=\"" . $arr['name'] . "\">";
  72. $countryName = $arr['name'];
  73. }
  74. $res = mysql_query("SELECT torrent,added,uploaded,downloaded,torrents.name as torrentname,categories.name as catname,size,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id WHERE userid=$id AND seeder='no'") or mysql_error();
  75. if (mysql_num_rows($res) > 0){
  76. $leeching = maketable($res);
  77. $res = mysql_query("SELECT torrent,added,uploaded,downloaded,torrents.name as torrentname,categories.name as catname,size,image,category,seeders,leechers FROM peers LEFT JOIN torrents ON peers.torrent = torrents.id LEFT JOIN categories ON torrents.category = categories.id WHERE userid=$id AND seeder='yes'") or mysql_error();
  78. }
  79. if (mysql_num_rows($res) > 0){
  80. $seeding = maketable($res);
  81. }
  82. stdhead("Details for " . $user["username"]);
  83. $enabled = $user["enabled"] == 'yes';
  84. ?>
  85. <table width="100%" cellspacing="0" cellpadding="0" border="0">
  86. <tbody>
  87. <tr>
  88. <td width="100%" class="ctable_content">
  89. <table width="100%" cellspacing="0" cellpadding="3" border="0" class="font_12px">
  90. <tbody>
  91. <tr>
  92. <td height="94" align="center" rowspan="5"><img width="74" height="74" border="0" alt="" src="<?=htmlspecialchars($user["avatar"])?>"/></td>
  93. <td width="76" nowrap="" class="tone_1"><strong>Last visit:</strong></td>
  94. <td class="tone_1"><?=$lastseen?></td>
  95. <td width="76" nowrap="" class="tone_1"><strong>Country:</strong></td>
  96. <td class="tone_1"><?=$country?> <?=$countryName?></td>
  97. </tr>
  98. <tr>
  99. <td nowrap=""><strong>Join date: </strong></td>
  100. <td><?=$joindate?></td>
  101. <td nowrap=""><strong>Gender:</strong></td>
  102. <td>Not specified</td>
  103. </tr>
  104. <tr>
  105. <td nowrap="" class="tone_1"><strong>Rank:</strong></td>
  106. <td class="tone_1"><?=get_user_class_name($user["class"])?></td>
  107. <td nowrap="" class="tone_1"><strong>Forum Posts:</strong></td>
  108. <?php
  109. if ($forumposts && (($user["class"] >= UC_POWER_USER && $user["id"] == $CURUSER["id"]) || get_user_class() >= UC_MODERATOR))
  110. {
  111. print("<td class=\"tone_1\"><a href=\"userhistory.php?action=viewposts&id=$id\">$forumposts</a></td>\n");
  112. }
  113. else
  114. {
  115. print("<td class=\"tone_1\">$forumposts</td>\n");
  116. }
  117. ?>
  118. </tr>
  119. <tr>
  120. <td nowrap=""><strong>Downloaded:</strong></td>
  121. <td><?=mksize($user["downloaded"])?></td>
  122. <td nowrap=""><strong>Warnings:</strong></td>
  123. <td>0 <i class="font_10px">(5 to ban)</i></td>
  124. </tr>
  125. <tr>
  126. <td nowrap="" class="tone_1"><strong>Uploaded:</strong></td>
  127. <td class="tone_1"><?=mksize($user["uploaded"])?></td>
  128. <td nowrap="" class="tone_1"><strong>Uploaded torrents: </strong></td>
  129. <td class="tone_1">1</td>
  130. </tr>
  131. <tr>
  132. <?php
  133. if ($user["downloaded"] > 0)
  134. {
  135. $sr = $user["uploaded"] / $user["downloaded"];
  136. if ($sr >= 4)
  137. {
  138. $s = "w00t";
  139. }
  140. else if ($sr >= 2)
  141. {
  142. $s = "grin";
  143. }
  144. else if ($sr >= 1)
  145. {
  146. $s = "smile1";
  147. }
  148. else if ($sr >= 0.5)
  149. {
  150. $s = "noexpression";
  151. }
  152. else if ($sr >= 0.25)
  153. {
  154. $s = "sad";
  155. }
  156. else
  157. {
  158. $s = "cry";
  159. $sr = floor($sr * 1000) / 1000;
  160. $sr = "<table border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><font color=" . get_ratio_color($sr) . ">" . number_format($sr, 3) . "</font></td><td class=embedded>&nbsp;&nbsp;<img src=images/smilies/$s.gif></td></tr></table>";
  161. }
  162. }
  163. ?>
  164. <td valign="top" nowrap="" align="center"><a class="user" href="userdetails?id=<?=$user["id"]?>"><img width="8" height="8" border="0" title="Ratio: <?=round($sr,2)?>" alt="Ratio: <?=round($sr,2)?>" src="/images/ratio/n05.gif"/><img width="2" height="1" border="0" alt="" src="/images/p.gif"/><?=$user["username"]?></a></td>
  165. <td valign="top" nowrap=""><strong>Ratio:</strong></td>
  166. <?php print("<td valign=\"top\">" . round($sr,2) . "</td>\n"); ?>
  167. <td valign="top"><strong>Torrent comments: </strong></td>
  168. <?php
  169. if ($torrentcomments && (($user["class"] >= UC_POWER_USER && $user["id"] == $CURUSER["id"]) || get_user_class() >= UC_MODERATOR))
  170. print("<td><a href=userhistory.php?action=viewcomments&id=$id>$torrentcomments</a></td>\n");
  171. else
  172. print("<td>$torrentcomments</td>\n");
  173. ?>
  174. </tr>
  175. <tr>
  176. <td nowrap="" align="left" class="tone_1" colspan="5"><strong>Favorite quote:</strong></td>
  177. </tr>
  178. <tr>
  179. </tr>
  180. <tr>
  181. <td nowrap="" align="left" colspan="5">It isn't illegal, we are copying not stealing.</td>
  182. </tr>
  183. <tr>
  184. <td nowrap="" align="left" class="tone_1" colspan="5"><strong>Signature:</strong></td>
  185. </tr>
  186. <tr>
  187. </tr>
  188. <tr>
  189. <td nowrap="" align="left" colspan="5">x00n.com<br/>Join the revolution</td>
  190. </tr>
  191. <tr align="left" class="tone_1">
  192. <td colspan="5"><b>More options:</b></td>
  193. </tr>
  194. <tr valign="top" align="left">
  195. <td colspan="5">
  196. <center>
  197. <a onclick="SWPop('/private_message.php?to=4025189','500', '450'); return false;" href="/private_message.php?to=4025189&amp;go_back=%2Fusers%2Fdemonflicks">Send a private message</a> :: <a href="/files/?uid=4025189&amp;seeded=2">View this user's torrents</a> :: <a href="/rss/users/demonflicks.xml">RSS Feed<img width="16" hspace="5" height="16" border="0" alt="" src="/images/rss.jpg"/></a>
  198. </center>
  199. </td>
  200. </tr>
  201. </tbody>
  202. </table>
  203. </td>
  204. </tr>
  205. </tbody>
  206. </table>
  207. <?php
  208. if (get_user_class() >= UC_MODERATOR && $user["class"] < get_user_class())
  209. {
  210. begin_frame("Edit User", true);
  211. echo "<form method=\"post\" action=\"modtask.php\">
  212. <input type=\"hidden\" name=\"action\" value=\"edituser\">
  213. <input type=\"hidden\" name=\"userid\" value=\"$id\">
  214. <input type=\"hidden\" name=\"returnto\" value=\"userdetails.php?id=$id\">
  215. <table class=\"main\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">
  216. <tr><td class=\"rowhead\">Title</td><td colspan=\"2\" align=\"left\"><input type=\"text\" size=\"60\" name=\"title\" value=\"" . htmlspecialchars($user[title]) . "\"></tr>\n";
  217. $avatar = htmlspecialchars($user["avatar"]);
  218. echo "<tr><td class=\"rowhead\">Avatar&nbsp;URL</td><td colspan=\"2\" align=\"left\"><input type=\"text\" size=\"60\" name=\"avatar\" value=\"$avatar\"></tr>";
  219. // we do not want mods to be able to change user classes or amount donated...
  220. if ($CURUSER["class"] > UC_ADMINISTRATOR){
  221. print("<tr><td class=\"rowhead\">Donor</td><td colspan=\"2\" align=\"left\"><input type=\"radio\" name=\"donor\" value=\"yes" .($user["donor"] == "yes" ? " checked" : "")."\">Yes <input type=\"radio\" name=\"donor\" value=\"no" .($user["donor"] == "no" ? " checked" : "")."\">No</td></tr>\n");
  222. }
  223. elseif($CURUSER["class"] < UC_ADMINISTRATOR)
  224. {
  225. print("<input type=\"hidden\" name=\"donor\" value=\"$user[donor]\">\n");
  226. }
  227. else
  228. {
  229. }
  230. if (get_user_class() == UC_MODERATOR && $user["class"] > UC_DONOR)
  231. printf("<input type=hidden name=class value=$user[class]\n");
  232. else
  233. {
  234. print("<tr><td class=rowhead>Class</td><td colspan=2 align=left><select name=class>\n");
  235. if (get_user_class() == UC_MODERATOR)
  236. $maxclass = UC_DONOR;
  237. else
  238. $maxclass = get_user_class() - 1;
  239. for ($i = 0; $i <= $maxclass; ++$i)
  240. print("<option value=$i" . ($user["class"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n");
  241. print("</select></td></tr>\n");
  242. }
  243. $modcomment = htmlspecialchars($user["modcomment"]);
  244. print("<tr><td class=rowhead>Comment</td><td colspan=2 align=left><textarea cols=60 rows=6 name=modcomment>$modcomment</textarea></td></tr>\n");
  245. $warned = $user["warned"] == "yes";
  246. print("<tr><td class=rowhead" . (!$warned ? " rowspan=2": "") . ">Warned</td>
  247. <td align=left width=20%>" .
  248. ( $warned
  249. ? "<input name=warned value='yes' type=radio checked>Yes<input name=warned value='no' type=radio>No"
  250. : "No" ) ."</td>");
  251. if ($warned)
  252. {
  253. $warneduntil = $user['warneduntil'];
  254. if ($warneduntil == '0000-00-00 00:00:00')
  255. print("<td align=center>(arbitrary duration)</td></tr>\n");
  256. else
  257. {
  258. print("<td align=center>Until $warneduntil");
  259. print(" (" . mkprettytime(strtotime($warneduntil) - gmtime()) . " to go)</td></tr>\n");
  260. }
  261. }
  262. else
  263. {
  264. echo "
  265. <td>Warn for <select name=\"warnlength\">
  266. <option value=\"0\">------</option>
  267. <option value=\"1\">1 week</option>
  268. <option value=\"2\">2 weeks</option>
  269. <option value=\"4\">4 weeks</option>
  270. <option value=\"8\">8 weeks</option>
  271. <option value=\"255\">Unlimited</option>
  272. </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PM comment:</td></tr>
  273. <tr><td colspan=\"2\" align=\"left\"><input type=\"text\" size=\"60\" name=\"warnpm\"></td></tr>
  274. ";
  275. }
  276. print("<tr><td class=rowhead>Enabled</td><td colspan=2 align=left><input name=enabled value='yes' type=radio" . ($enabled ? " checked" : "") . ">Yes <input name=enabled value='no' type=radio" . (!$enabled ? " checked" : "") . ">No</td></tr>\n");
  277. print("<tr><td class=rowhead>Passkey</td><td colspan=2 align=left><input name=resetkey value=1 type=checkbox> Reset passkey</td></tr>n");
  278. print("</td></tr>");
  279. print("<tr><td colspan=3 align=center><input type=submit class=btn value='Okay'></td></tr>\n");
  280. print("</table>\n");
  281. print("</form>\n");
  282. end_frame();
  283. }
  284. end_main_frame();
  285. stdfoot();
  286. ?>