Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
User Posts

Go to Profile

Template help — 2020-11-21 01:33:21 in M-BiTsy Support
"m-jay, post: 69583, member: 20288":

this is progress with profile controller still need to merge edit and admin, so all edit for staff is on same page as members edit - using session (or curuser for v3) to hide the staff parts like email, ratio
the reset pass, confirm still have separate pages i did have it all on one controller but the job doesn't seem as bad with smaller files lol

notice the submit function, ive started moving all inputs (if $_post etc) to there own method
<?php
class Profile extends Controller
{
   public function __construct()
   {
       $this->userModel = $this->model('User');
   }

   public function index()
   {
       dbconn();
       global $config;
       loggedinonly();

       $id = (int) Input::get("id");

       if (!is_valid_id($id)) {
           Redirect::autolink(TTURL . "/home",  "Bad ID.");
       }

       $user = User::getUserById($id);
       if (!$user) {
           Redirect::autolink(TTURL . "/home", Lang::T("NO_USER_WITH_ID") . " $id.");
       }

       // view own but not others
       if ($_SESSION["view_users"] == "no" && $_SESSION["id"] != $id) {
           Redirect::autolink(TTURL . "/home", Lang::T("NO_USER_VIEW"));
       }

       // user not ready to be seen yet
       if (($user["enabled"] == "no" || ($user["status"] == "pending")) && $_SESSION["edit_users"] == "no") {
           Redirect::autolink(TTURL . "/home", Lang::T("NO_ACCESS_ACCOUNT_DISABLED"));
       }

       // Start Blocked Users
       $blocked = DB::run("SELECT id FROM friends WHERE userid=$user[id] AND friend='enemy' AND friendid=$_SESSION[id]");
       $show = $blocked->rowCount();
       if ($show != 0 && $_SESSION["control_panel"] != "yes") {
           show_error_msg("Error", "<div style='margin-top:10px; margin-bottom:10px' align='center'><font size=2 color=#FF2000><b>You're blocked by this member and you can not see his profile!</b></font></div>", 1);
       }

       // $country
       $res = DB::run("SELECT name FROM countries WHERE id=? LIMIT 1", [$user['country']]);
       if ($res->rowCount() == 1) {
           $arr = $res->fetch();
           $country = "$arr[name]";
       }
       if (!$country) {
           $country = "<b>Unknown</b>";
       }

       // $ratio
       if ($user["downloaded"] > 0) {
           $ratio = $user["uploaded"] / $user["downloaded"];
       } else {
           $ratio = "---";
       }

       $numtorrents = get_row_count("torrents", "WHERE owner = $id");
       $numcomments = get_row_count("comments", "WHERE user = $id");
       $numforumposts = get_row_count("forum_posts", "WHERE userid = $id");
       $qry = DB::run("SELECT COUNT(`hnr`) FROM `snatched` WHERE `uid` = '$id' AND `hnr` = 'yes'");
       $res = $qry->fetch(PDO::FETCH_ASSOC);
       $numhnr = $res[0];

       $avatar = htmlspecialchars($user["avatar"]);
       if (!$avatar) {
           $avatar = $config["SITEURL"] . "/images/default_avatar.png";
       }

       $usersignature = stripslashes($user["signature"]); // todo

       $r = DB::run("SELECT id FROM friends WHERE userid=? AND friend=? AND friendid=?", [$_SESSION['id'], 'friend', $id]);
       $friend = $r->rowCount();
       $r = DB::run("SELECT id FROM friends WHERE userid=? AND friend=? AND friendid=?", [$_SESSION['id'], 'enemy', $id]);
       $block = $r->rowCount();

       $cardheader = sprintf(Lang::T("USER_DETAILS_FOR"), class_user_colour($user["username"]));
       $user1 = $this->userModel->getAll($id);
       $data = [
           'title' => $cardheader,
           'id' => $id,
           'friend' => $friend,
           'block' => $block,
           'country' => $country,
           'ratio' => $ratio,
           'numhnr' => $numhnr,
           'avatar' => $avatar,
           'numtorrents' => $numtorrents,
           'numcomments' => $numcomments,
           'numforumposts' => $numforumposts,
           'usersignature' => $usersignature,
           'selectuser' => $user1,
       ];
       $this->view('user/profile', $data, true);
   }

   public function edit()
   {
       dbconn();
       global $config, $THEME, $tzs, $pdo;
       loggedinonly();
       $id = (int) $_GET["id"];

       // Clear error
       $stylesheets = '';
       $tz = '';

       if ($_SESSION['class'] < 5 && $id != $_SESSION['id']) {
           autolink(TTURL . "/index", Lang::T("You dont have permission"));
       } else {
           //   echo 'im staff or curuser';
       }

       $user = $this->userModel->getAll($id);
       // Stylesheet
       $ss_r = DB::run("SELECT * from stylesheets");
       $ss_sa = array();
       while ($ss_a = $ss_r->fetch(PDO::FETCH_LAZY)) {
           $ss_id = $ss_a["uri"];
           $ss_name = $ss_a["name"];
           $ss_sa[$ss_name] = $ss_id;
       }
       ksort($ss_sa);
       reset($ss_sa);
       while (list($ss_name, $ss_id) = thisEach($ss_sa)) {
           if ($ss_id == $user["stylesheet"]) {
               $ss = " selected='selected'";
           } else {
               $ss = "";
           }
           $stylesheets .= "<option value='$ss_id'$ss>$ss_name</option>\n";
       }
       // Country
       $countries = "<option value='0'>----</option>\n";
       $ct_r = DB::run("SELECT id,name from countries ORDER BY name");
       while ($ct_a = $ct_r->fetch(PDO::FETCH_LAZY)) {
           $countries .= "<option value='$ct_a[id]'" . ($user['country'] == $ct_a['id'] ? " selected='selected'" : "") . ">$ct_a[name]</option>\n";
       }
       // Timezone
       ksort($tzs);
       reset($tzs);
       while (list($key, $val) = thisEach($tzs)) {
           if ($user["tzoffset"] == $key) {
               $tz .= "<option value=\"$key\" selected='selected'>$val[0]</option>\n";
           } else {
               $tz .= "<option value=\"$key\">$val[0]</option>\n";
           }
       }
       //Teams
       $teams = "<option value='0'>--- " . Lang::T("NONE_SELECTED") . " ----</option>\n";
       $sashok = DB::run("SELECT id,name FROM teams ORDER BY name");
       while ($sasha = $sashok->fetch(PDO::FETCH_LAZY)) {
           $teams .= "<option value='$sasha[id]'" . ($user['team'] == $sasha['id'] ? " selected='selected'" : "") . ">$sasha[name]</option>\n";
       }


       $gender = "<option value='Male'" . ($user['gender'] == "Male" ? " selected='selected'" : "") . ">" . Lang::T("MALE") . "</option>\n"
       . "<option value='Female'" . ($user['gender'] == "Female" ? " selected='selected'" : "") . ">" . Lang::T("FEMALE") . "</option>\n";

       $cardheader = sprintf(Lang::T("Edit Details"));
       $user1 = $this->userModel->getAll($id);
       $data = [
           'title' => $cardheader,
           'stylesheets' => $stylesheets,
           'countries' => $countries,
           'teams' => $teams,
           'tz' => $tz,
           'gender' => $gender,
           'id' => $id,
           'selectuser' => $user1,
       ];

       $this->view('user/edit', $data, true);
   }

   public function submit()
   {
       dbconn();
       global $config, $THEME, $tzs, $pdo;
       loggedinonly();
       $id = (int) $_GET["id"];
       if ($_POST) {

           $avatar = strip_tags($_POST["avatar"]);

           $title = strip_tags($_POST["title"]);
           $signature = $_POST["signature"];

           $stylesheet = $_POST["stylesheet"];
           $client = strip_tags($_POST["client"]);
           $age = $_POST["age"];
           $gender = $_POST["gender"];
           $country = $_POST["country"];
           $teams = $_POST["teams"];

           $acceptpms = $_POST["acceptpms"];
           $pmnotif = $_POST["pmnotif"];
           $privacy = $_POST["privacy"];
           $notifs = ($pmnotif == 'yes' ? "[pm]" : "");
           if ($_POST['resetpasskey']) {
               $passkey = '';
           }
           $timezone = (int) $_POST['tzoffset'];

           if ($acceptpms == "yes") {
               $acceptpms = 'yes';
           } else {
               $acceptpms = 'no';
           }

           $hideshoutbox = ($_POST["hideshoutbox"] == "yes") ? "yes" : "no";
           // Save New details.
           $pdo->run("UPDATE users
                      SET avatar=?, title=?, signature=?, stylesheet=?, client=?, age=?, gender=?, country=?, team=?, hideshoutbox=?, acceptpms=?, privacy=?, notifs=?, passkey=?, tzoffset=?
                      WHERE id =?", [$avatar, $title, $signature, $stylesheet, $client, $age, $gender, $country, $teams, $hideshoutbox, $acceptpms, $privacy, $notifs, $passkey, $timezone, $id]);
           autolink(TTURL . "/profile/edit?id=$id", "Success");
       }
   }

   public function admin()
   {
       dbconn();
       global $config, $THEME, $pdo;
       loggedinonly();
       $id = (int) $_GET["id"];
       if ($_SESSION['class'] < 5 && $id != $_SESSION['id']) {
           autolink(TTURL . "/index", Lang::T("You dont have permission"));
       } else {
           //   echo 'im staff or curuser';
       }
       if ($_POST) {
           $userid = $_POST["userid"];
           $downloaded = strtobytes($_POST["downloaded"]);
           $uploaded = strtobytes($_POST["uploaded"]);
           $ip = $_POST["ip"];
           $class = (int) $_POST["class"];
           $donated = (float) $_POST["donated"];
           $password = $_POST["password"];
           $warned = $_POST["warned"];
           $forumbanned = $_POST["forumbanned"];
           $downloadbanned = $_POST["downloadbanned"];
           $shoutboxpos = $_POST["shoutboxpos"];
           $modcomment = $_POST["modcomment"];
           $enabled = $_POST["enabled"];
           $invites = (int) $_POST["invites"];
           $email = $_POST["email"];
           $bonus = $_POST["bonus"];

           if (!validemail($email)) {
               show_error_msg(Lang::T("EDITING_FAILED"), Lang::T("EMAIL_ADDRESS_NOT_VALID"), 1);
           }

           //change user class
           $arr = DB::run("SELECT class FROM users WHERE id=?", [$id])->fetch();
           $uc = $arr['class'];

           // skip if class is same as current
           //if ($uc != $class && $class > 0) {
           if ($uc <= get_others_class($id)) { // todo
               show_error_msg(Lang::T("EDITING_FAILED"), Lang::T("11111111   YOU_CANT_DEMOTE_YOURSELF"), 1);
           } elseif ($uc <= get_others_class($id)) {
               show_error_msg(Lang::T("EDITING_FAILED"), Lang::T("222222   YOU_CANT_DEMOTE_SOMEONE_SAME_LVL"), 1);
           } else {
               DB::run("UPDATE users SET class=? WHERE id=?", [$class, $id]);
               // Notify user
               $prodemoted = ($class > $uc ? "promoted" : "demoted");
               $msg = "You have been $prodemoted to " . get_user_class_name($class) . " by " . $_SESSION["username"] . "";
               $added = get_date_time();

               //  DB::run("INSERT INTO messages (sender, receiver, msg, added) VALUES(0, $_SESSION[id], $msg, $added)");

           }
           // }
           //continue updates

           DB::run("UPDATE users
           SET email=?, downloaded=?, uploaded=?, ip=?, donated=?, forumbanned=?, warned=?,
            modcomment=?, enabled=?, invites=? , downloadbanned=?, shoutboxpos=?, seedbonus=?
           WHERE id=?", [$email, $downloaded, $uploaded, $ip, $donated, $forumbanned, $warned, $modcomment,
               $enabled, $invites, $downloadbanned, $shoutboxpos, $bonus, $id]);

           write_log($_SESSION['username'] . " has edited user: $id details");

           if ($_POST['resetpasskey'] == 'yes') {
               DB::run("UPDATE users SET passkey=? WHERE id=?", ['', $uploaded]);
           }

           $chgpasswd = $_POST['chgpasswd'] == 'yes' ? true : false;
           if ($chgpasswd) {
               //        $passreq = DB::run("SELECT password FROM users WHERE id=$userid");
               $passres = DB::run("SELECT password FROM users WHERE id=?", [$id])->fetch();
               if ($password != $passres['password']) {
                   $password = password_hash($password, PASSWORD_BCRYPT);
                   DB::run("UPDATE users SET password=? WHERE id=?", [$password, $id]);
                   write_log($_SESSION['username'] . " has changed password for user: $id");
               }
           }
           autolink(TTURL . "/profile/admin?id=$id", Lang::T("SUCCESS"));
           die;
       }

       $user = $this->userModel->getAll($id);
       //$ratio
       if ($user["downloaded"] > 0) {
           $ratio = $user["uploaded"] / $user["downloaded"];
       } else {
           $ratio = "---";
       }

       $data = [
           'id' => $id,
           'selectuser' => $user,
       ];
       $this->view('user/admin', $data, true);
   }

}


profile template
<div class="card">
       <div class="card-header">
           <?php echo $data['title']; ?>
       </div>
       <div class="card-body">
      <?php foreach ($data['selectuser'] as $selectedid):
     
       if ($selectedid["privacy"] != "strong" || ($_SESSION["control_panel"] == "yes") || ($_SESSION["id"] == $user["id"])) {          
   ?>
           <a href='<?php echo TTURL; ?>/profile?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Profile</button></a>
   <?php if ($_SESSION["id"] == $data['id'] or $_SESSION["class"] > $config['Uploader']) {?>
   <a href='<?php echo TTURL; ?>/profile/edit?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Edit</button></a>&nbsp;
   <?php }?>
   <?php if ($_SESSION["id"] == $data['id']) {?>
   <a href='<?php echo TTURL; ?>/account/changepw?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Password</button></a>
   <a href='<?php echo TTURL; ?>/account/email?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Email</button></a>
   <a href='<?php echo TTURL; ?>/messages'><button type="button" class="btn btn-sm btn-primary">Messages</button></a>
   <a href='<?php echo TTURL; ?>/bonus'><button type="button" class="btn btn-sm btn-primary">Seed Bonus</button></a>
   <?php }?>
   <?php if ($_SESSION["view_users"]) {?>
   <a href='<?php echo TTURL; ?>/friends'><button type="button" class="btn btn-sm btn-primary">Your Friends</button></a>
   <?php }?>
   <?php if ($_SESSION["view_torrents"]) {?>
   <a href='<?php echo TTURL; ?>/peers/seeding?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Seeding</button></a>
   <a href='<?php echo TTURL; ?>/peers/uploaded?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Uploaded</button></a>
   <?php }?>
   <?php if ($_SESSION["class"] > $config['Uploader']) {?>
   <a href='<?php echo TTURL; ?>/warning?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Warn</button></a>
   <a href='<?php echo TTURL; ?>/profile/admin?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-success">Admin</button></a>
   <?php }
 
   ?>
           <table align="center" border="0" cellpadding="6" cellspacing="1" width="100%">
           <tr>
               <td width="50%"><b><?php echo Lang::T("PROFILE"); ?></b></td>
               <td width="50%"><b><?php echo Lang::T("ADDITIONAL_INFO"); ?></b></td>
           </tr>

           <tr valign="top">
               <td align="left">
               <?php echo Lang::T("USERNAME"); ?>: <?php echo class_user_colour($selectedid["username"]) ?><br />
               <?php echo Lang::T("EMAIL"); ?>: <?php echo $selectedid["email"]; ?><br />
               <?php echo Lang::T("PASSKEY"); ?>: <?php echo $selectedid["passkey"]; ?><br />
               <?php echo Lang::T("IP"); ?>: <?php echo $selectedid["ip"]; ?><br />
               <?php echo Lang::T("USERCLASS"); ?>: <?php echo get_user_class_name($selectedid["class"]) ?><br />
               <?php echo Lang::T("THEME_NAME"); ?>: <?php echo $selectedid["stylesheet"] ?><br />
               <?php echo Lang::T("TITLE"); ?>: <i><?php echo format_comment($selectedid["title"]) ?></i><br />
               <?php echo Lang::T("JOINED"); ?>: <?php echo htmlspecialchars(utc_to_tz($selectedid["added"])) ?><br />
               <?php echo Lang::T("LAST_VISIT"); ?>: <?php echo htmlspecialchars(utc_to_tz($selectedid["last_access"])) ?><br />
               <?php echo Lang::T("LAST_SEEN"); ?>: <?php echo htmlspecialchars($selectedid["page"]); ?><br />
               </td>

               <td align="left">
               <?php echo Lang::T("AGE"); ?>: <?php echo htmlspecialchars($selectedid["age"]) ?><br />
               <?php echo Lang::T("GENDER"); ?>: <?php echo Lang::T($selectedid["gender"]); ?><br />
               <?php echo Lang::T("CLIENT"); ?>: <?php echo htmlspecialchars($selectedid["client"]) ?><br />
               <?php echo Lang::T("COUNTRY"); ?>: <?php echo $data['country'] ?><br />
               <?php echo Lang::T("DONATED"); ?>  <?php echo $config['currency_symbol']; ?><?php echo number_format($selectedid["donated"], 2); ?><br />
               <?php echo Lang::T("WARNINGS"); ?>: <?php echo htmlspecialchars($selectedid["warned"]) ?><br />
               <?php if ($_SESSION["edit_users"] == "yes") {echo Lang::T("ACCOUNT_PRIVACY_LVL") . ": <b>" . Lang::T($selectedid["privacy"]) . "</b><br />";}?>
               <?php echo Lang::T("SIGNATURE"); ?>:</b> <?php echo format_comment($data['usersignature']); ?><br />
               </td>
           </tr>

           <tr>
               <td width="50%"><b><?php echo Lang::T("STATISTICS"); ?></b></td>
               <td width="50%"><b><?php echo Lang::T("OTHER"); ?></b></td>
           </tr>

           <tr valign="top">
               <td align="left">
               <?php echo Lang::T("UPLOADED"); ?>: <?php echo mksize($selectedid["uploaded"]); ?><br />
               <?php echo Lang::T("DOWNLOADED"); ?>: <?php echo mksize($selectedid["downloaded"]); ?><br />
               <?php echo Lang::T("RATIO"); ?>: <?php echo $data['ratio']; ?><br />
               <?php echo Lang::T("Hit & Run"); ?>: <?php echo $data['numhnr']; ?><br />
               <?php echo Lang::T("AVG_DAILY_DL"); ?>: <?php echo mksize($selectedid["downloaded"] / (DateDiff($selectedid["added"], time()) / 86400)); ?><br />
               <?php echo Lang::T("AVG_DAILY_UL"); ?>: <?php echo mksize($selectedid["uploaded"] / (DateDiff($selectedid["added"], time()) / 86400)); ?><br />
               <?php echo Lang::T("TORRENTS_POSTED"); ?>: <?php echo number_format($data['numtorrents']); ?><br />
               <?php echo Lang::T("COMMENTS_POSTED"); ?>: <?php echo number_format($data['numcomments']); ?><br />
               Forum Posts: <?php echo number_format($data['numforumposts']); ?><br />
               </td>

               <td align="left">
               <?php if ($_SESSION["class"] >= 5 && $_SESSION["class"] > $selectedid["class"]) {?>[<a href="<?php echo $config['SITEURL'] ?>/invite/invitetree?id=<?php echo $selectedid["id"] ?>">Invite Tree</a>]<?php }?><br />
               <img src="<?php echo $data['avatar']; ?>" alt="" title="<?php echo class_user_colour($selectedid["username"]); ?>" height="80" width="80" /><br />
               <a href="<?php echo $config['SITEURL'] ?>/messages/create?&amp;id=<?php echo $selectedid["id"] ?>"><button type='button' class='btn btn-sm btn-success'><?php echo Lang::T("SEND_PM") ?></button></a><br />
               <a href="<?php echo $config['SITEURL'] ?>/report/user?user=<?php echo $selectedid["id"] ?>"><button type='button' class='btn btn-sm btn-danger'><?php echo Lang::T("REPORT_MEMBER") ?></button></a><br />
           <?php if ($_SESSION["edit_users"] == "yes") {?>
         <div style="margin-bottom:3px"><a href="<?php echo $config['SITEURL']; ?>/snatched?uid=<?php echo $selectedid["id"] ?>"><button type='button' class='btn btn-sm btn-warning'><?php echo Lang::T("SNATCHLIST") ?></button></a></div>
       <?php }?>
               </td>
           </tr>
           <?php if ($_SESSION["edit_users"] == "yes") {?>
           <tr>
               <td width="50%"><b><?php echo Lang::T("STAFF_ONLY_INFO"); ?></b></td>
           </tr>

           <tr valign="top">
               <td align="left">
                   <?php
if ($user["invited_by"]) {
       $invited = $selectedid['invited_by'];
       $row = DB::run("SELECT username FROM users WHERE id=?", [$invited])->fetch();
       echo "<b>" . Lang::T("INVITED_BY") . ":</b> <a href=\"$config[SITEURL]/profile?id=$selectedid[invited_by]\">" . class_user_colour($row['username']) . "</a><br />";
   }
       echo "<b>" . Lang::T("INVITES") . ":</b> " . number_format($selectedid["invites"]) . "<br />";
       $invitees = array_reverse(explode(" ", $selectedid["invitees"]));
       $rows = array();
       foreach ($invitees as $invitee) {
           $res = DB::run("SELECT id, username FROM users WHERE id=? and status=?", [$invitee, 'confirmed']);
           if ($row = $res->fetch()) {
               $rows[] = "<a href=\"$config[SITEURL]/profile?id=$row[id]\">" . class_user_colour($row['username']) . "</a>";
           }
       }
       if ($rows) {
           echo "<b>" . Lang::T("INVITEES") . ":</b> " . implode(", ", $rows) . "<br />";
       }

       ?>
               </td>
           </tr>
           <?php
}
   //team
   $res = DB::run("SELECT name,image FROM teams WHERE id=? LIMIT 1", [$selectedid['team']]);
   if ($res->rowCount() == 1) {
       $arr = $res->fetch();
       echo "<tr><td colspan='2' align='left'><b>Team Member Of:</b><br />";
       echo "<img src='" . htmlspecialchars($arr["image"]) . "' alt='' /><br />" . sqlesc($arr["name"]) . "<br /><br /><a href='$config[SITEURL]/teams'>[View " . Lang::T("TEAMS") . "]</a></td></tr>";
   }
   ?>

           </table>

<div style="margin-bottom:10px">
<?php
if ($_SESSION["id"] != $selectedid["id"]) {

       if ($data['friend'] > 0) {
           print("[<a href=$config[SITEURL]/friends/delete?type=friend&targetid=$selectedid[id]>Remove from Friends</a>]");
       } elseif ($data['block'] > 0) {
           print("&nbsp;[<a href=$config[SITEURL]/friends/delete?type=block&targetid=$selectedid[id]>Remove from Blocked</a>]");
       } else {
           print("[<a href=$config[SITEURL]/friends/add?type=friend&targetid=$selectedid[id]><b>Add to Friends</b></a>]&nbsp;");
           print("&nbsp;[<a href=$config[SITEURL]/friends/add?type=block&targetid=$selectedid[id]><b>Add to Blocked</b></a>]");
       }
   }
   ?>
</div><?php

} else {
   echo sprintf(Lang::T("REPORT_MEMBER_MSG"), $selectedid["id"]);
}

endforeach;?>
</div>
</div>
<br />


edit template
<div class="card">
   <div class="card-header">
       <?php echo $data['title']; ?>
   </div>
   <div class="card-body">
   <a href='<?php echo TTURL; ?>/profile?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Profile</button></a>
   <?php if ($_SESSION["id"] == $data['id'] or $_SESSION["class"] > $config['Uploader']) {?>
   <a href='<?php echo TTURL; ?>/profile/edit?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Edit</button></a>&nbsp;
   <?php }?>
   <?php if ($_SESSION["id"] == $data['id']) {?>
   <a href='<?php echo TTURL; ?>/account/changepw?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Password</button></a>
   <a href='<?php echo TTURL; ?>/account/email?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Email</button></a>
   <a href='<?php echo TTURL; ?>/messages'><button type="button" class="btn btn-sm btn-primary">Messages</button></a>
   <a href='<?php echo TTURL; ?>/bonus'><button type="button" class="btn btn-sm btn-primary">Seed Bonus</button></a>
   <?php }?>
   <?php if ($_SESSION["view_users"]) {?>
   <a href='<?php echo TTURL; ?>/friends'><button type="button" class="btn btn-sm btn-primary">Your Friends</button></a>
   <?php }?>
   <?php if ($_SESSION["view_torrents"]) {?>
   <a href='<?php echo TTURL; ?>/peers/seeding?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Seeding</button></a>
   <a href='<?php echo TTURL; ?>/peers/uploaded?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Uploaded</button></a>
   <?php }?>
   <?php if ($_SESSION["class"] > $config['Uploader']) {?>
   <a href='<?php echo TTURL; ?>/warning?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-primary">Warn</button></a>
   <a href='<?php echo TTURL; ?>/profile/admin?id=<?php echo $data['id']; ?>'><button type="button" class="btn btn-sm btn-success">Admin</button></a>
   <?php }
 
   ?><br>
       <form action="<?php echo TTURL; ?>/profile/submit?id=<?php echo $data['id']; ?>" method="post">
       <?php foreach ($data['selectuser'] as $selectedid): ?>
       <table class="f-border" cellspacing="0" cellpadding="5" max-width="100%" align="center">

<?php


$acceptpms = $selectedid['acceptpms'] == "yes";
print("<tr><td align='right' class='alt2'><b>" . Lang::T("ACCEPT_PMS") . ":</b> </td><td class='alt2'><input type='radio' name='acceptpms'" . ($acceptpms ? " checked='checked'" : "") .
   " value='yes' /><b>" . Lang::T("FROM_ALL") . "</b> <input type='radio' name='acceptpms'" .
   ($acceptpms ? "" : " checked='checked'") . " value='no' /><b>" . Lang::T("FROM_STAFF_ONLY") . "</b><br /><i>" . Lang::T("ACCEPTPM_WHICH_USERS") . "</i></td></tr>");

print("<tr><td align='right' class='alt3'><b>" . Lang::T("ACCOUNT_PRIVACY_LVL") . ":</b> </td><td align='left' class='alt3'>" . priv("normal", "<b>" . Lang::T("NORMAL") . "</b>") . " " . priv("low", "<b>" . Lang::T("LOW") . "</b>") . " " . priv("strong", "<b>" . Lang::T("STRONG") . "</b>") . "<br /><i>" . Lang::T("ACCOUNT_PRIVACY_LVL_MSG") . "</i></td></tr>");

print("<tr><td align='right' class='alt2'><b>" . Lang::T("EMAIL_NOTIFICATION") . ":</b> </td><td align='left' class='alt2'><input type='checkbox' name='pmnotif' " . (strpos($selectedid['notifs'], "[pm]") !== false ? " checked='checked'" : "") .
   " value='yes' /><b>" . Lang::T("PM_NOTIFY_ME") . "</b><br /><i>" . Lang::T("EMAIL_WHEN_PM") . "</i></td></tr>");

print("<tr><td align='right' class='alt3'><b>" . Lang::T("THEME") . ":</b> </td><td align='left' class='alt3'><select name='stylesheet'>\n$data[stylesheets]\n</select></td></tr>");
print("<tr><td align='right' class='alt2'><b>" . Lang::T("PREFERRED_CLIENT") . ":</b> </td><td align='left' class='alt2'><input type='text' size='20' maxlength='20' name='client' value=\"" . htmlspecialchars($selectedid['client']) . "\" /></td></tr>");
print("<tr><td align='right' class='alt3'><b>" . Lang::T("AGE") . ":</b> </td><td align='left' class='alt3'><input type='text' size='3' maxlength='2' name='age' value=\"" . htmlspecialchars($selectedid['age']) . "\" /></td></tr>");
print("<tr><td align='right' class='alt2'><b>" . Lang::T("GENDER") . ":</b> </td><td align='left' class='alt2'><select size='1' name='gender'>\n$data[gender]\n</select></td></tr>");
print("<tr><td align='right' class='alt3'><b>" . Lang::T("COUNTRY") . ":</b> </td><td align='left' class='alt3'><select name='country'>\n$data[countries]\n</select></td></tr>");

if ($selectedid['class'] > 1) {
   print("<tr><td align='right' class='alt2'><b>" . Lang::T("TEAM") . ":</b> </td><td align='left' class='alt2'><select name='teams'>\n$data[teams]\n</select></td></tr>");
}

print("<tr><td align='right' class='alt3'><b>" . Lang::T("AVATAR_UPLOAD") . ":</b> </td><td align='left' class='alt3'><input type='text' name='avatar' size='50' value=\"" . htmlspecialchars($selectedid["avatar"]) .
   "\" /><br />\n<i>" . Lang::T("AVATAR_LINK") . "</i><br /></td></tr>");
print("<tr><td align='right' class='alt2'><b>" . Lang::T("CUSTOM_TITLE") . ":</b> </td><td align='left' class='alt2'><input type='text' name='title' size='50' value=\"" . strip_tags($selectedid["title"]) .
   "\" /><br />\n <i>" . Lang::T("HTML_NOT_ALLOWED") . "</i></td></tr>");
print("<tr><td align='right' class='alt3' valign='top'><b>" . Lang::T("SIGNATURE") . ":</b> </td><td align='left' class='alt3'><textarea name='signature' cols='50' rows='10'>" . htmlspecialchars($selectedid["signature"]) .
   "</textarea><br />\n <i>" . sprintf(Lang::T("MAX_CHARS"), 150) . ", " . Lang::T("HTML_NOT_ALLOWED") . "</i></td></tr>");

?>
       <tr><td align='right' class='alt2'><b><?php echo Lang::T("RESET_PASSKEY"); ?>:</b> </td><td align='left' class='alt2'><input type='checkbox' name='resetpasskey' value='1' />&nbsp;<i><?php echo Lang::T("RESET_PASSKEY_MSG"); ?></i></td></tr>
       <?php
if ($config["SHOUTBOX"]) {
   print("<tr><td align='right' class='table_col3'><b>" . Lang::T("HIDE_SHOUT") . ":</b></td><td align='left' class='table_col3'><input type='checkbox' name='hideshoutbox' value='yes' " . ($selectedid['hideshoutbox'] == 'yes' ? 'checked="checked"' : '') . " />&nbsp;<i>" . Lang::T("HIDE_SHOUT") . "</i></td></tr> ");
}?>
       <tr><td align='right' class='alt3'><b><?php echo Lang::T("TIMEZONE"); ?>:</b> </td><td align='left' class='alt3'><select name='tzoffset'><?php echo $data['tz']; ?></select></td></tr>
       <tr><td colspan="2" align="center"><button type='submit' class='btn btn-sm btn-primary'><?php echo Lang::T("SUBMIT"); ?></button> <input type="reset" value="<?php echo Lang::T("REVERT"); ?>" /></td></tr>
        </table>
        <?php endforeach;?>
       </form>
       </div>
       </div><br />



Thank you so much!!
Thanks man, Simply supporting UDP protocol with info hash as GET parameter.
Template help — 2020-11-20 14:52:57 in M-BiTsy Support
Do you have a user class for profiles (account-details)? I started work on profiles months ago but when I switched out to my own thing I lost some functionality in there, hoping to do this to keep people on and mingling
Template help — 2020-11-20 02:57:01 in M-BiTsy Support
"m-jay, post: 69574, member: 20288":

Slowly making my way through sorting out all the spaghetti code on pdo version and moving all the html to views so if any one has experience and wouldnt mind having a look

heres the controller for forum page (the sql will be moved to model classes when im happy with it)
    /**
    * View Forum Index.
    */
   public function index()
   {
       dbconn();
       global $config;
       // todo add to validation class
       if (!$config["FORUMS_GUESTREAD"]) {
           loggedinonly();
       }
       if ($_SESSION["forumbanned"] == "yes" || $_SESSION["view_forum"] == "no") {
           Session::flashmsg('danger', Lang::T("FORUM_BANNED"), 1);
       }

       //Here we decide if the forums is on or off
       if ($config["FORUMS"]) {
           $themedir = $config['SITEURL'] . "/themes/" . ($_SESSION['stylesheet'] ?: $config['default_theme']) . "/forums/";
           // Action: DEFAULT ACTION (VIEW FORUMS)
           if (isset($_GET["catchup"])) {
               catch_up();
           }

           // Action: SHOW MAIN FORUM INDEX
           $forums_res = DB::run("SELECT forumcats.id AS fcid, forumcats.name AS fcname, forum_forums.* FROM forum_forums LEFT JOIN forumcats ON forumcats.id = forum_forums.category ORDER BY forumcats.sort, forum_forums.sort, forum_forums.name");
           if ($forums_res->rowCount() == 0) {
               Redirect::autolink1($config['SITEURL'] . '/index', 'danger', 'There is no Forums available');
           }
         
           //topic count and post counts
           $postcount = number_format(get_row_count("forum_posts"));
           $topiccount = number_format(get_row_count("forum_topics"));

           $data = [
               'mainquery' => $forums_res,
               'themedir' => $themedir,
               'postcount' => $postcount,
               'topiccount' => $topiccount,
           ];
           $this->view('forum/index', $data, true);
       } else {
           //HEY IF FORUMS ARE OFF, SHOW THIS FLASH MESSAGE
           Session::flashmsg('warning', Lang::T("Unfortunatley the forums are not currently available."), 1);
       }
   }


and here is the view/template
<div class="card">
   <div class="card-header">
       <?php echo Lang::T("Forum Home"); ?>
   </div>
<div class="card-body">
   <div>
       <img src='$config[SITEURL]/images/forum/help.png'  alt='' />&nbsp;
       <a href='$config[SITEURL]/faq'><?php echo Lang::T("FORUM_FAQ"); ?></a>&nbsp; &nbsp;&nbsp;
       <img src='<?php echo $config['SITEURL']; ?>/images/forum/search.png' alt='' />&nbsp;
       <a href='<?php echo $config['SITEURL']; ?>/forums/search'><?php echo Lang::T("SEARCH"); ?></a>&nbsp; &nbsp;
       <b><?php echo Lang::T("FORUM_CONTROL"); ?></b>
        &middot; <a href='<?php echo $config['SITEURL']; ?>/forums/viewunread'><?php echo Lang::T("FORUM_NEW_POSTS"); ?></a>
        &middot; <a href='<?php echo $config['SITEURL']; ?>/forums?catchup'><?php echo Lang::T("FORUM_MARK_READ"); ?></a>
   </div><br>
   <div><?php echo Lang::T("YOU_ARE_IN"); ?>: &nbsp;<a href='<?php echo $config['SITEURL']; ?>/forums'><?php echo Lang::T("FORUMS"); ?></a> <b style='vertical-align:middle'>/ index</b></div>
           <?php

latestforumposts();

// MAIN LAYOUT
$fcid = 0;

while ($forums_arr = $data['mainquery']->fetch(PDO::FETCH_ASSOC)) {

   if ($_SESSION['class'] < $forums_arr["minclassread"] && $forums_arr["guest_read"] == "no") {
       continue;
   }

   if ($forums_arr['fcid'] != $fcid) {
       ?>
                   <div class='table'><table class='table table-striped'>
                   <thead><tr>
                   <th  style='border: 1px solid black' align='left' colspan='2'><?php echo htmlspecialchars($forums_arr['fcname']); ?></th>
                   <th  style='border: 1px solid black' width='37' align='right'>Topics</th>
                   <th  style='border: 1px solid black' width='47' align='right'>Posts</th>
                   <th  style='border: 1px solid black' align='right' width='180'>Last post</th>
                   </tr></thead><tbody>
                       <?php
$fcid = $forums_arr['fcid'];
   }

   $forumid = 0 + $forums_arr["id"];
   $forumname = htmlspecialchars($forums_arr["name"]);
   $forumdescription = htmlspecialchars($forums_arr["description"]);
   $postcount = number_format(get_row_count("forum_posts", "WHERE topicid IN (SELECT id FROM forum_topics WHERE forumid=$forumid)"));
   $topiccount = number_format(get_row_count("forum_topics", "WHERE forumid = $forumid"));
   $lastpostid = get_forum_last_post($forumid);

   // Get last post info
   $post_res = DB::run("SELECT added,topicid,userid FROM forum_posts WHERE id=$lastpostid");
   if ($post_res->rowCount() == 1) {
       $post_arr = $post_res->fetch(PDO::FETCH_ASSOC) or showerror(Lang::T("ERROR"), "Bad forum last_post");
       $lastposterid = $post_arr["userid"];
       $lastpostdate = utc_to_tz($post_arr["added"]);
       $lasttopicid = $post_arr["topicid"];
       $user_res = DB::run("SELECT username FROM users WHERE id=$lastposterid");
       $user_arr = $user_res->fetch(PDO::FETCH_ASSOC);
       $lastposter = class_user_colour($user_arr["username"]);
       $topic_res = DB::run("SELECT subject FROM forum_topics WHERE id=$lasttopicid");
       $topic_arr = $topic_res->fetch(PDO::FETCH_ASSOC);
       $lasttopic = stripslashes(htmlspecialchars($topic_arr['subject']));

       //cut last topic
       $latestleng = 10;

       $lastpost = "<small><a href='$config[SITEURL]/forums/viewtopic&amp;topicid=$lasttopicid&amp;page=last#last'><b>" . CutName($lasttopic, $latestleng) . "</b></a> by <a href='$config[SITEURL]/profile?id=$lastposterid'><b>$lastposter</b></a><br />$lastpostdate</small>";

       if ($_SESSION['loggedin'] == true) {
           $a = DB::run("SELECT lastpostread FROM forum_readposts WHERE userid=$_SESSION[id] AND topicid=$lasttopicid")->fetch();
       }

       //define the images for new posts or not on index
       if ($a && $a[0] == $lastpostid) {
           $img = "folder";
       } else {
           $img = "folder_new";
       }

   } else {
       $lastpost = "<span class='small'>No Posts</span>";
       $img = "folder";
   }

//following line is each forums display ?>
<tr>
<td style='border: 1px solid black' width='5%' >
<img src='<?php echo $data['themedir']; ?><?php echo $img; ?>.png' alt='' width='100% heigh= '100%' /></td>
<td style='border: 1px solid black' >
<a href='<?php echo $config['SITEURL']; ?>/forums/viewforum&amp;forumid=<?php echo $forumid; ?>'><b><?php echo $forumname; ?></b></a><br>
<small>- <?php echo $forumdescription; ?></small></td>
<td style='border: 1px solid black' ><?php echo $topiccount; ?></td>
<td style='border: 1px solid black' ><?php echo $postcount; ?></td>
<td style='border: 1px solid black' ><b><?php echo $lastpost; ?></b></td></tr>
<?php } ?>
     </tbody></table></div>

<table cellspacing='0' cellpadding='3'><tr valign='middle'>
<td><img src='<?php echo $data['themedir']; ?>folder_new.png' style='margin: 5px' alt='' /></td><td>New posts</td>
<td><img src='<?php echo $data['themedir']; ?>folder.png' style='margin: 5px' alt='' /></td><td>No New posts</td>;
<td><img src='<?php echo $data['themedir']; ?>folder_locked.png' style='margin: 5px' alt='' /></td><td><?php echo Lang::T("FORUMS_LOCKED"); ?> topic</td>
<td><img src='<?php echo $data['themedir']; ?>folder_sticky.png' style='margin: 5px' alt='' /></td><td><?php echo Lang::T("FORUMS_STICKY"); ?> topic</td>
</tr></table>

<center>Our members have made <?php echo $data[' $postcount']; ?> posts in  <?php echo $data['topiccount']; ?> topics</center>
<?php insert_quick_jump_menu(); ?>
</div>
</div><br />


its this part causing the headache if anyone has any ideas on how to move this out of the view, i was thinking of passing the $forums_arr array to a function but there might be a better way
    $forumid = 0 + $forums_arr["id"];
   $forumname = htmlspecialchars($forums_arr["name"]);
   $forumdescription = htmlspecialchars($forums_arr["description"]);
   $postcount = number_format(get_row_count("forum_posts", "WHERE topicid IN (SELECT id FROM forum_topics WHERE forumid=$forumid)"));
   $topiccount = number_format(get_row_count("forum_topics", "WHERE forumid = $forumid"));
   $lastpostid = get_forum_last_post($forumid);
   // Get last post info
   $post_res = DB::run("SELECT added,topicid,userid FROM forum_posts WHERE id=$lastpostid");

   if ($post_res->rowCount() == 1) {
       $post_arr = $post_res->fetch(PDO::FETCH_ASSOC) or showerror(Lang::T("ERROR"), "Bad forum last_post");
       $lastposterid = $post_arr["userid"];
       $lastpostdate = utc_to_tz($post_arr["added"]);
       $lasttopicid = $post_arr["topicid"];
       $user_res = DB::run("SELECT username FROM users WHERE id=$lastposterid");
       $user_arr = $user_res->fetch(PDO::FETCH_ASSOC);
       $lastposter = class_user_colour($user_arr["username"]);
       $topic_res = DB::run("SELECT subject FROM forum_topics WHERE id=$lasttopicid");
       $topic_arr = $topic_res->fetch(PDO::FETCH_ASSOC);
       $lasttopic = stripslashes(htmlspecialchars($topic_arr['subject']));
       //cut last topic
       $latestleng = 10;

       $lastpost = "<small><a href='$config[SITEURL]/forums/viewtopic&amp;topicid=$lasttopicid&amp;page=last#last'><b>" . CutName($lasttopic, $latestleng) . "</b></a> by <a href='$config[SITEURL]/profile?id=$lastposterid'><b>$lastposter</b></a><br />$lastpostdate</small>";
       if ($_SESSION['loggedin'] == true) {
           $a = DB::run("SELECT lastpostread FROM forum_readposts WHERE userid=$_SESSION[id] AND topicid=$lasttopicid")->fetch();
       }

       //define the images for new posts or not on index
       if ($a && $a[0] == $lastpostid) {
           $img = "folder";
       } else {
           $img = "folder_new";
       }
   } else {
       $lastpost = "<span class='small'>No Posts</span>";
       $img = "folder";
   }



Good code! I like what I see, you may of picked up a thing or two from the discussions or ZIP. Trust me, you’ll be years ahead by that approach.
ratio — 2020-11-20 02:54:16 in v3 Support
$search = trim($_GET['search']);

if (array_key_exists(‘search’, $_GET))

Faster and safer. While it’s missing a dictionary definition to the keys, it will still do it’s job.

Array structures are lightening fast on CPU and out of the box perfect for any version of PHP (including BETA 8).
I will be testing against a array of tracker urls and testing exactly 5 public torrents with DHT enabled and announce-list populated for best results.

NOTE to those reading: This has been a battle for a long time throughout the history of TorrentTrader and other tracker scripts as well. We will be wrapping this up finally, once and for all. Work will begin head-on on Saturday.

I will be testing several classes as well as compatibility towards those 5 selected torrents. [USER=20288]@m-jay[/USER] if you like me to move this most let me know.
"m-jay, post: 69568, member: 20288":

I had a go with this mate bit more modern
[URL unfurl="true"]https://github.com/medariox/scrapeer[/url]

With that it was again tempermental - again a  setting something to do with the function socket_create() -   sockets is enabled

It would explain why it stopped working on different versions it's not code its server/host side im sure - xammp runs scraping perfect every time now on update I'm working on at minute with the old mod from here  :unsure:


Leave it to me on my ST platform. I'll get it going..
I don’t see why this is so difficult, all we are doing is fetching query data for a URL parameter based on the info hash. Just sounds like domains/IP announces are problematic.
In this script I wrote months ago, it works like this (so you want DOM extension installed for PHP if absent)


// Mass check life on public announce URLs  

include_once('simple_html_dom.php');

// Create DOM from URL
$html = file_get_html('http://www.torrenttrackerlist.com/torrent-tracker-list/');

// find all trackers on URL
foreach($html->find('pre.prettyprint') as $e)

$geturls = $e->innertext;

// Format rendered tracker list
$trackerlist = str_replace('announce', 'announce<br>', $geturls);

echo $trackerlist;


It's worth adding this to the above code, too ensure you have DOM enabled before include_once()


if (!class_exists('DOMDocument') {
   die('DOM not enabled. This will not work.');
}


Full ZIP attached ;)
"Botanicar, post: 69563, member: 19833":

it was a very quick response from you mate,
most use the following opentrackers:


udp://tracker.opentrackr.org:1337/announce
udp://9.rarbg.to:2990
udp://tracker.coppersurfer.tk:6969/announce
udp://eddie4.nl:6969/announce
udp://9.rarbg.me:2720
udp://tracker.leechers-paradise.org:6969/announce
[URL unfurl="true"]http://tracker.trackerfix.com:80/announce[/url]
udp://tracker.zer0day.to:1337/announce

etc etc ...

hope you resolve some problems with that

Regards


Good work. I also have a master list that is updated weekly, we can compare and ping each one to find out which one is alive.

I feed this list to my active torrents in my seedbox and I get upwards of 57mbps on some torrents ?

I’ve written a script that fetches a complete text list of urls from the website that has these urls so no need to even visit that site, just run the script and you get 100% updated trackers!

It scrapes the front page for the list, which we can easilyparse these into a array and read from that. Will be a little extra overhead, but it should be reliable.
"coco, post: 69559, member: 20298":

I don't know what's going on but still the same error.
I changed line 415 in Account.php
$sql = "INSERT INTO users (username, password, secret, email, status, added, last_access, age, country, gender, client, stylesheet, language, class, ip) VALUES (" . implode(",", array_map("sqlesc", array($wantusername, $wantpassword, $secret, $email, $status, get_date_time(), get_date_time(), $age, $country, $gender, $client, $config["default_theme"], $config["default_language"], $signupclass, getip()))) . ")";
               $ins_user = DB::run($sql);
               $id = DB::lastInsertId();


with this
$ins_user = DB::run("INSERT INTO users
(username, password, secret, email, status, added, last_login, last_access, age, country, gender, client, stylesheet, language, class, ip)
VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
[$wantusername, $wantpassword, $secret, $email, $status, get_date_time(), get_date_time(), get_date_time(), $age, $country, $gender, $client, $config["default_theme"], $config["default_language"], $signupclass, getip()]);
$id = DB::lastInsertId()


in address bar https://xxxxxxx.xxx/exceptions/error
error_log and exception_log.txt files are empty

And also this line $config['SITEURL'] = '[url='http://localhost/pdo;']http://localhost/pdo';[/url] //Main Site URL how it should be?
In main config is $config['SITEURL'] = 'https://xxxxxxx.xxx'; //Main Site URL without pdo, if you add it many redirects start


Thank you  m-jay


I dont see the need for array_map() here as the statement is designed to call array keys regardless, no need for a callback I believe. Go vanilla on this one and bind the array keys like you normally would. Also think array_push may be useful for handling those keys.

“The number of parameters that the callback function accepts should match the number of arrays passed to array_map()”

might be the issue. This sounds a lot like a finicky PHP version where this function may change upon releases.

Also.. “...If the arrays are of unequal length, shorter ones will be extended with empty elements to match the length of the longest.” Will produce a problem if the column is not ALLOW NULL.

2 possible issues here. That query is too complex for what it’s doing, and it’s not doing much in terms of additional steps or parsing.

I would write a solution if I was at home ?
I’ll be taking another shot at public torrent scraping, I need it by this weekend so should be of result. Seems we get a working solution, and it goes down over time. Maybe a public tracker list is needed for this script.
I put this together as a way to extend user voting stats, scores and more across games etc. Maybe useful if vote feature is used - not sure if this was stock in V3 or a mod, but this feeds the users who voted.

[ATTACH type="full" alt="usersvoted.png"]5964[/ATTACH]

// Users Who Rated
$usersrated = SQL_Query_exec("SELECT u.username, u.avatar, u.id, r.torrent FROM ratings r INNER JOIN users u ON u.id = r.user WHERE r.torrent = $row[id]") or die('Query error');
foreach ($usersrated as $row) {
   print("<a title=\"$row[username]\" href=\"/details/$row[id]/\"><img itemprop=\"image\" class=\"responsive-img\" src=\"/$row[avatar]\" alt=\"$row[username]\" style=\"border:2px solid #FFF; width: 75px; height: 75px; margin-right: 10px; border-radius: 100%\" border=\"0\" /></a>");
}


Place it somewhere in torrents-details.php

I brought this over for V3 so hopefully it works if you use rating system. Enjoy.
While this is included in BETA5, here is high traffic proof of this in action. I am including voucher codes for upload data in certain torrents as to see how effective it is, and users are using it often now.

This should be ported to V3 / mysqli as it will add a nice twist to your tracker! Recommended!;)

[ATTACH type="full"]5963[/ATTACH]
Announce/BETA6 — 2020-11-15 02:40:41 in Downloads & Updates
Work now underway. Leave a comment if you want Upcoming list ported to your edition.
ratio — 2020-11-14 18:23:09 in v3 Support
"m-jay, post: 69548, member: 20288":

If you use it mate will you test the other code, once I know the syntax works I can easily add it to the memberlist table for niki


with some porting, I sure will and report back as to its functionality.
ratio — 2020-11-13 20:01:30 in v3 Support
"m-jay, post: 69546, member: 20288":

It's on v2.08
function get_ratio_color($ratio)
{
   if ($ratio < 0.1) {
       return "#ff0000";
   }

   if ($ratio < 0.2) {
       return "#ee0000";
   }

   if ($ratio < 0.3) {
       return "#dd0000";
   }

   if ($ratio < 0.4) {
       return "#cc0000";
   }

   if ($ratio < 0.5) {
       return "#bb0000";
   }

   if ($ratio < 0.6) {
       return "#aa0000";
   }

   if ($ratio < 0.7) {
       return "#990000";
   }

   if ($ratio < 0.8) {
       return "#880000";
   }

   if ($ratio < 0.9) {
       return "#770000";
   }

   if ($ratio < 1) {
       return "#660000";
   }

   return "#000000";



Thats actually really useful logic, permissions, text or banner for user can be added etc :unsure: very cool
ratio — 2020-11-13 17:55:57 in v3 Support
"m-jay, post: 69544, member: 20288":

You can try this, depending where you put it the id needs changing for show we use $CUR[user]
$res = SQL_Query_exec("SELECT uploaded, downloaded FROM users WHERE id = $CURUSER[id]");
while ($row = mysqli_fetch_assoc($res)) {

 if ($row['downloaded'] > 0)
{
$ratio = $row['uploaded'] / $row['downloaded'];
$ratio = number_format($ratio, 2);
$color = get_ratio_color($ratio);
if ($color)
     $ratio = "<font color=#ffff00>$ratio</font>";
} else if ($row['uploaded'] > 0)
    $ratio = 'Inf.';
}
echo $ratio;
}

Test on index.php at top (above check block) if it works we look at you memberlist.php


Where is the function for get_ratio_color() ?
Auto-Promote Users — 2020-11-12 22:41:02 in v3 Mods Completed
I can’t confirm this code, but thanks Nikki. Typically, a foreach loop will need to be unset() if exiting out of an array outside of the loop in older versions of PHP. This has since been declared unnecessary since 7+ to my knowledge.

As it stands, it’s useful for destroying variables, not sure about objects though.
ratio — 2020-11-12 15:05:26 in v3 Support
It’s a matter of rounding 2 columns by 2 (users.uploaded & users.downloaded). What version, mysqli?
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 3
  • Members: 0
  • Guests online: 3
  • Comments: 3
  • Messages: 1,728