/lib/Profile.php
PHP | 458 lines | 455 code | 3 blank | 0 comment | 0 complexity | f5aa6396eacb39ac7dc4c3a7a9e51d68 MD5 | raw file
Possible License(s): GPL-2.0
- <?php
- class UserProfile{
-
-
- public function userControlProfile(){
- global $user_info, $HTTP_SERVER_VARS, $PHP_SELF, $tzs, $timezone, $domain;
-
- stdhead($user_info["username"] . "'s", true, false);
- if (isset($_GET["edited"])) {
- print("<h2>Profile updated!</h2>\n");
- if ($_GET["mailsent"])
- print("<h2>Confirmation email has been sent!</h2>\n");
- }
- elseif (isset($_GET["emailch"]))
- print("<h2>Email address changed!</h2>\n");
- else
- echo "<h2>Welcome, <a href=\"?action=user&id=" . $user_info['id'] . "\">$user_info[username]</a>!</h2>\n";
-
- ?>
- <h2><font color="red">Are you new. We want to help you get started. Please <a href="gettingstarted">click here</a> for help on getting started.</font></h2>
- <table border="1" cellspacing="0" cellpadding="10" align="center">
- <tr>
- <td align="center" width="33%"><a href="?action=logout"><b>Logout</b></a></td>
- <td align="center" width="33%"><a href="?action=mytorrents"><b>My torrents</b></a></td>
- <td align="center" width="33%"><a href="?action=friends"><b>My Friends</b></a></td>
- </tr>
- <tr>
- <td colspan="3">
- <form enctype="multipart/form-data" id="creator" name="creator" accept-charset="UTF-8" method="post" action="index.php?action=profile2">
- <table border="1" cellspacing="0" cellpadding="5" width="100%">
- <?php
- $countries = "<option value=\"0\">---- None selected ----</option>\n";
- $ct_r = mysql_query("SELECT id,name FROM countries ORDER BY name") or die;
- while ($ct_a = mysql_fetch_array($ct_r))
- $countries .= "<option value=\"$ct_a[id]\"" . ($user_info["country"] == $ct_a['id'] ? " selected=\"yes\"" : "") . ">$ct_a[name]</option>\n";
- ksort($tzs);
- reset($tzs);
-
- while (list($key, $val) = each($tzs)) {
- if ($user_info["tzoffset"] == $key) {
- $timezone .= "<option value=\"$key\" selected>$val</option>\n";
- }
- else
- {
- $timezone .= "<option value=\"$key\">$val</option>\n";
- }
- }
- tr("Accept PMs", "<input type=\"radio\" name=\"acceptpms\"" . ($user_info["acceptpms"] == "yes" ? " checked" : "") . " value=\"yes\">All (except blocks)
- <input type=\"radio\" name=\"acceptpms\"" . ($user_info["acceptpms"] == "friends" ? " checked" : "") . " value=\"friends\">Friends only
- <input type=\"radio\" name=\"acceptpms\"" . ($user_info["acceptpms"] == "no" ? " checked" : "") . " value=\"no\">Staff only" ,1);
- tr("Delete PMs", "<input type=\"checkbox\" name=\"deletepms\"" . ($user_info["deletepms"] == "yes" ? " checked" : "") . "\"> (Default value for \"Delete PM on reply\")",1);
- tr("Save PMs", "<input type=\"checkbox\" name=\"savepms\"" . ($user_info["savepms"] == "yes" ? " checked" : "") . "\"> (Default value for \"Save PM to Sentbox\")",1);
-
- $r = mysql_query("SELECT id,name FROM categories ORDER BY name") or mysql_error();
- if (mysql_num_rows($r) > 0)
- {
- $categories = "<table><tr>\n";
- $i = 0;
- while ($a = mysql_fetch_assoc($r))
- {
- $categories .= ($i && $i % 2 == 0) ? "</tr><tr>" : "";
- $categories .= "<td class=\"bottom\" style=\"padding-right: 5px\">
- <input name=\"cat" . $a['id'] . "\" type=\"checkbox\"" . (strpos($user_info['notifs'], "[cat$a[id]]") !== false ? " checked" : "") . " value=\"yes\"> " . htmlspecialchars($a["name"]) . "</td>\n";
- $i++;
- }
- $categories .= "</tr></table>\n";
- }
-
- tr("Email notification", "<input type=\"checkbox\" name=\"pmnotif\"" . (strpos($user_info['notifs'], "[pm]") !== false ? " checked" : "") . "\" value=\"yes\"> Notify me when I have received a PM<br>\n" .
- "<input type=checkbox name=emailnotif" . (strpos($user_info['notifs'], "[email]") !== false ? " checked" : "") . " value=yes> Notify me when a torrent is uploaded in one of <br> my default browsing categories.\n", 1);
-
- tr("Browse default<br>categories",$categories,1);
- tr("Country", "<select name=country>\n$countries\n</select>",1);
- tr("Time zone", "<select name=tzoffset>\n$timezone\n</select><br />Be sure to select the correct time zone and be aware of Daylight Savings Time.(In the toolbar/forum/inbox)",1);
- tr("Avatar URL", "<input name=avatar size=50 value=\"" . htmlspecialchars($user_info["avatar"]) .
- "\"><br>\nWidth should be 150 pixels (will be resized if necessary)\n<br>If you need a host for the picture, try the <a href=bitbucket-upload>bitbucket</a>.",1);
- tr("Torrents per page", "<input type=text size=10 name=torrentsperpage value=$user_info[torrentsperpage]> (0=use default setting)",1);
- tr("Topics per page", "<input type=text size=10 name=topicsperpage value=$user_info[topicsperpage]> (0=use default setting)",1);
- tr("Posts per page", "<input type=text size=10 name=postsperpage value=$user_info[postsperpage]> (0=use default setting)",1);
- tr("View avatars", "<input type=checkbox name=avatars" . ($user_info["avatars"] == "yes" ? " checked" : "") . "> (Low bandwidth users might want to turn this off)",1);
- tr("Info", "<textarea name=info cols=50 rows=4>" . $user_info["info"] . "</textarea><br>Displayed on your public page. May contain <a href=tags target=_new>BB codes</a>.", 1);
- tr("Email address", "<input type=\"text\" name=\"email\" size=50 value=\"" . htmlspecialchars($user_info["email"]) . "\" />", 1);
- print("<tr><td colspan=\"2\" align=left><b>Note:</b> In order to change your email address, you will receive another<br>confirmation email to your new address.</td></tr>\n");
- tr("Reset passkey","<input type=checkbox name=resetpasskey value=1 /><br><font class=small>Any active torrents must be downloaded again to continue leeching/seeding.</font>", 1);
- tr("Change password", "<input type=\"password\" name=\"chpassword\" size=\"50\" />", 1);
- tr("Type password again", "<input type=\"password\" name=\"passagain\" size=\"50\" />", 1);
-
-
- ?>
- <tr>
- <td colspan="2" align="center">
- <input type="submit" value="Submit changes!" style='height: 25px'>
- <input type="reset" value="Revert changes!" style='height: 25px'>
- </td>
- </tr>
- </table>
- </form>
- </td>
- </tr>
- </table>
- <?
- if ($messages){
- print("<p>You have $messages message" . ($messages != 1 ? "s" : "") . " ($unread new) in your <a href=inbox><b>inbox</b></a>,<br>\n");
- if ($outmessages)
- print("and $outmessages message" . ($outmessages != 1 ? "s" : "") . " in your <a href=inbox?out=1><b>sentbox</b></a>.\n</p>");
- else
- print("and your <a href=inbox?out=1>sentbox</a> is empty.</p>");
- }
- else
- {
- print("<p>Your <a href=inbox>inbox</a> is empty, <br>\n");
- if ($outmessages)
- print("and you have $outmessages message" . ($outmessages != 1 ? "s" : "") . " in your <a href=inbox?out=1><b>sentbox</b></a>.\n</p>");
- else
- print("and so is your <a href=inbox?out=1>sentbox</a>.</p>");
- }
-
- print("<p><a href=users><b>Find User/Browse User List</b></a></p>");
- stdfoot();
- }
- private function bark($msg)
- {
- stdhead();
- stdmsg("Error", $msg);
- stdfoot();
- exit;
- }
- public function userViewProfile(){
- global $user_info, $HTTP_SERVER_VARS, $PHP_SELF, $tzs, $timezone, $domain;
-
- $id = $_GET["id"];
- if(!is_valid_id($id))
- bark("Bad ID $id.");
-
- if(!is_numeric($id)){
- die("EPIC FAIL");
- }
- $userSQL = "SELECT * FROM `users` WHERE `id`=$id";
-
- $r = @mysql_query($userSQL) or mysql_error();
-
- $user = mysql_fetch_array($r) or $this->bark("No user with ID $id.");
-
- if ($user["status"] == "pending") die;
-
- $r = mysql_query("SELECT id, name, seeders, leechers, category FROM torrents WHERE owner=$id ORDER BY name") or mysql_error();
-
- if ($user["ip"] && (get_user_class() >= UC_MODERATOR || $user["id"] == $user_info["id"]))
- {
- $ip = $user["ip"];
-
- $dom = @gethostbyaddr($user["ip"]);
-
- if ($dom == $user["ip"] || @gethostbyname($dom) != $user["ip"]){
- $addr = $ip;
- }
- else
- {
- $dom = strtoupper($dom);
-
- $domparts = explode(".", $dom);
-
- $domain = $domparts[count($domparts) - 2];
- }
- if ($domain == "COM" || $domain == "CO" || $domain == "NET" || $domain == "NE" || $domain == "ORG" || $domain == "OR" ){
- $l = 2;
- }
- else
- {
- $l = 1;
- $addr = "$ip ($dom)";
- }
- }
- if ($user[added] == "0000-00-00 00:00:00"){
- $joindate = 'N/A';
- }
- else
- {
- $joindate = "$user[added] (" . get_elapsed_time(sql_timestamp_to_unix_timestamp($user["added"])) . " ago)";
- $lastseen = $user["last_access"];
- }
- if ($lastseen == "0000-00-00 00:00:00"){
- $lastseen = "never";
- }
- else
- {
- $lastseen .= " (" . get_elapsed_time(sql_timestamp_to_unix_timestamp($lastseen)) . " ago)";
- }
- $res = mysql_query("SELECT COUNT(*) FROM comments WHERE user=" . $user[id]) or mysql_error();
- $arr3 = mysql_fetch_row($res);
- $torrentcomments = $arr3[0];
- $res = mysql_query("SELECT COUNT(*) FROM posts WHERE userid=" . $user[id]) or mysql_error();
- $arr3 = mysql_fetch_row($res);
- $forumposts = $arr3[0];
-
- if ($user['donated'] > 0){
- $don = "<img src=\"images/starbig.gif\">";
- }
- $res = mysql_query("SELECT name,flagpic FROM countries WHERE id=$user[country] LIMIT 1") or mysql_error();
- if (mysql_num_rows($res) == 1)
- {
- $arr = mysql_fetch_assoc($res);
- $country = "<img height=\"11\" width=\"16\" src=\"images/flag/$arr[flagpic]\" alt=\"" . $arr['name'] . "\">";
- $countryName = $arr['name'];
- }
-
- $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();
-
- if (mysql_num_rows($res) > 0){
- $leeching = maketable($res);
- $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();
- }
- if (mysql_num_rows($res) > 0){
- $seeding = maketable($res);
- }
- stdhead("Details for " . $user["username"]);
- $enabled = $user["enabled"] == 'yes';
- ?>
- <table width="100%" cellspacing="0" cellpadding="0" border="0">
- <tbody>
- <tr>
- <td width="100%" class="ctable_content">
- <table width="100%" cellspacing="0" cellpadding="3" border="0" class="font_12px">
- <tbody>
- <tr>
- <td height="94" align="center" rowspan="5"><img width="74" height="74" border="0" alt="" src="<?=htmlspecialchars($user["avatar"])?>"/></td>
- <td width="76" nowrap="" class="tone_1"><strong>Last visit:</strong></td>
- <td class="tone_1"><?=$lastseen?></td>
- <td width="76" nowrap="" class="tone_1"><strong>Country:</strong></td>
- <td class="tone_1"><?=$country?> <?=$countryName?></td>
- </tr>
- <tr>
- <td nowrap=""><strong>Join date: </strong></td>
- <td><?=$joindate?></td>
- <td nowrap=""><strong>Gender:</strong></td>
- <td>Not specified</td>
- </tr>
- <tr>
- <td nowrap="" class="tone_1"><strong>Rank:</strong></td>
- <td class="tone_1"><?=get_user_class_name($user["class"])?></td>
- <td nowrap="" class="tone_1"><strong>Forum Posts:</strong></td>
- <?php
- if ($forumposts && (($user["class"] >= UC_POWER_USER && $user["id"] == $user_info["id"]) || get_user_class() >= UC_MODERATOR))
- {
- print("<td class=\"tone_1\"><a href=\"userhistory.php?action=viewposts&id=$id\">$forumposts</a></td>\n");
- }
- else
- {
- print("<td class=\"tone_1\">$forumposts</td>\n");
- }
- ?>
- </tr>
- <tr>
- <td nowrap=""><strong>Downloaded:</strong></td>
- <td><?=mksize($user["downloaded"])?></td>
- <td nowrap=""><strong>Warnings:</strong></td>
- <td>0 <i class="font_10px">(5 to ban)</i></td>
- </tr>
- <tr>
- <td nowrap="" class="tone_1"><strong>Uploaded:</strong></td>
- <td class="tone_1"><?=mksize($user["uploaded"])?></td>
- <td nowrap="" class="tone_1"><strong>Uploaded torrents: </strong></td>
- <td class="tone_1">1</td>
- </tr>
- <tr>
- <?php
- if ($user["downloaded"] > 0)
- {
- $sr = $user["uploaded"] / $user["downloaded"];
- if ($sr >= 4)
- {
- $s = "w00t";
- }
- else if ($sr >= 2)
- {
- $s = "grin";
- }
- else if ($sr >= 1)
- {
- $s = "smile1";
- }
- else if ($sr >= 0.5)
- {
- $s = "noexpression";
- }
- else if ($sr >= 0.25)
- {
- $s = "sad";
- }
- else
- {
- $s = "cry";
- $sr = floor($sr * 1000) / 1000;
- $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> <img src=images/smilies/$s.gif></td></tr></table>";
- }
-
- }
- ?>
- <td valign="top" nowrap="" align="center"><a class="user" href="index.php?action=profile&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>
- <td valign="top" nowrap=""><strong>Ratio:</strong></td>
- <?php print("<td valign=\"top\">" . round($sr,2) . "</td>\n"); ?>
-
- <td valign="top"><strong>Torrent comments: </strong></td>
-
- <?php
- if ($torrentcomments && (($user["class"] >= UC_POWER_USER && $user["id"] == $user_info["id"]) || get_user_class() >= UC_MODERATOR))
- print("<td><a href=userhistory.php?action=viewcomments&id=$id>$torrentcomments</a></td>\n");
- else
- print("<td>$torrentcomments</td>\n");
- ?>
- </tr>
- <tr>
- <td nowrap="" align="left" class="tone_1" colspan="5"><strong>Favorite quote:</strong></td>
- </tr>
- <tr>
- </tr>
- <tr>
- <td nowrap="" align="left" colspan="5">It isn't illegal, we are copying not stealing.</td>
- </tr>
- <tr>
- <td nowrap="" align="left" class="tone_1" colspan="5"><strong>Signature:</strong></td>
- </tr>
- <tr>
- </tr>
- <tr>
- <td nowrap="" align="left" colspan="5">x00n.com<br/>Join the revolution</td>
- </tr>
- <tr align="left" class="tone_1">
- <td colspan="5"><b>More options:</b></td>
- </tr>
- <tr valign="top" align="left">
- <td colspan="5">
- <center>
- <a onclick="SWPop('/private_message.php?to=4025189','500', '450'); return false;" href="/private_message.php?to=4025189&go_back=%2Fusers%2Fdemonflicks">Send a private message</a> :: <a href="/files/?uid=4025189&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>
- </center>
- </td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- <?php
-
- if (get_user_class() >= UC_MODERATOR && $user["class"] < get_user_class())
- {
- begin_frame("Edit User", true);
- echo "<form method=\"post\" action=\"modtask.php\">
- <input type=\"hidden\" name=\"action\" value=\"edituser\">
- <input type=\"hidden\" name=\"userid\" value=\"$id\">
- <input type=\"hidden\" name=\"returnto\" value=\"index.php?action=profile&id=$id\">
- <table class=\"main\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">
- <tr><td class=\"rowhead\">Title</td><td colspan=\"2\" align=\"left\"><input type=\"text\" size=\"60\" name=\"title\" value=\"" . htmlspecialchars($user[title]) . "\"></tr>\n";
- $avatar = htmlspecialchars($user["avatar"]);
- echo "<tr><td class=\"rowhead\">Avatar URL</td><td colspan=\"2\" align=\"left\"><input type=\"text\" size=\"60\" name=\"avatar\" value=\"$avatar\"></tr>";
- // we do not want mods to be able to change user classes or amount donated...
- if ($user_info["class"] > UC_ADMINISTRATOR){
- 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");
- }
- elseif($user_info["class"] < UC_ADMINISTRATOR)
- {
- print("<input type=\"hidden\" name=\"donor\" value=\"$user[donor]\">\n");
-
- }
- else
- {
-
- }
-
- if (get_user_class() == UC_MODERATOR && $user["class"] > UC_DONOR)
- printf("<input type=hidden name=class value=$user[class]\n");
- else
- {
- print("<tr><td class=rowhead>Class</td><td colspan=2 align=left><select name=class>\n");
- if (get_user_class() == UC_MODERATOR)
- $maxclass = UC_DONOR;
- else
- $maxclass = get_user_class() - 1;
- for ($i = 0; $i <= $maxclass; ++$i)
- print("<option value=$i" . ($user["class"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n");
- print("</select></td></tr>\n");
- }
-
- $modcomment = htmlspecialchars($user["modcomment"]);
- print("<tr><td class=rowhead>Comment</td><td colspan=2 align=left><textarea cols=60 rows=6 name=modcomment>$modcomment</textarea></td></tr>\n");
- $warned = $user["warned"] == "yes";
-
- print("<tr><td class=rowhead" . (!$warned ? " rowspan=2": "") . ">Warned</td>
- <td align=left width=20%>" .
- ( $warned
- ? "<input name=warned value='yes' type=radio checked>Yes<input name=warned value='no' type=radio>No"
- : "No" ) ."</td>");
-
- if ($warned)
- {
- $warneduntil = $user['warneduntil'];
- if ($warneduntil == '0000-00-00 00:00:00')
- print("<td align=center>(arbitrary duration)</td></tr>\n");
- else
- {
- print("<td align=center>Until $warneduntil");
- print(" (" . mkprettytime(strtotime($warneduntil) - gmtime()) . " to go)</td></tr>\n");
- }
- }
- else
- {
- echo "
- <td>Warn for <select name=\"warnlength\">
- <option value=\"0\">------</option>
- <option value=\"1\">1 week</option>
- <option value=\"2\">2 weeks</option>
- <option value=\"4\">4 weeks</option>
- <option value=\"8\">8 weeks</option>
- <option value=\"255\">Unlimited</option>
- </select> PM comment:</td></tr>
- <tr><td colspan=\"2\" align=\"left\"><input type=\"text\" size=\"60\" name=\"warnpm\"></td></tr>
- ";
- }
- 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");
- print("<tr><td class=rowhead>Passkey</td><td colspan=2 align=left><input name=resetkey value=1 type=checkbox> Reset passkey</td></tr>n");
- print("</td></tr>");
- print("<tr><td colspan=3 align=center><input type=submit class=btn value='Okay'></td></tr>\n");
- print("</table>\n");
- print("</form>\n");
- end_frame();
- }
-
- end_main_frame();
- stdfoot();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }