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
TorrentTrader MVC/PDO small issues highl
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / M-BiTsy / M-BiTsy Support

2020-05-15 17:23:52
Using the current code, I tried uploading torrent.

[ATTACH type="full" alt="1589563241592.png"]5533[/ATTACH]

I checked the directory permissions during the site creation, and double checked before upload the torrent. Still...

[ATTACH type="full" alt="1589563397195.png"]5534[/ATTACH]

Is it supposed to be like this? Code still being developed?
1589563241592.png
1589563241592.png
1589563397195.png
1589563397195.png

If It Ain't Dutch, It Ain't Much!!
2020-05-17 05:53:21
Checked the permissions, check the PHP modules. All looks ok.
Torrent file is copied as well.

[ATTACH type="full"]5538[/ATTACH]

Still have the same error message though.
1589694767510.png
1589694767510.png

If It Ain't Dutch, It Ain't Much!!
2020-05-21 06:50:45
[USER=20288]@m-jay[/USER] , is there something I might be doing wrong, or have not looked at?
Would you need more info from my side to help check?
If It Ain't Dutch, It Ain't Much!!
2020-05-21 09:59:49
Copy and paste that text in bold. Now find what you copied in /lang/english.php (CTRL-F + CTRL-V + Enter), assuming regex off.

Copy that language string (example, HOME_USER_DYN, etc) and repeat same steps for torrents-upload. You are tracing this error messaging to the root potential cause.

Can you copy the block containing that language var and post for us to review? I don't use this release so can't help.
2020-05-21 10:15:33
it seems to be when there is no image :unsure: found a quick fix - not sure why that stopped working lol ill see how that goes

controllers/torrentsupload.php find
    }else{
       $anon = "no";
   }


replace query below
 $inames = '';
$filecounts = (int)$filecount;
   $ret = DB::run("INSERT INTO torrents (filename, owner, name, descr, image1, image2, category, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang, anon, last_action)
   VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
   [$fname, $CURUSER['id'], $name, $descr, $inames[0], $inames[1], $catid, get_date_time(), $infohash, $torrentsize, $filecounts, $fname, $announce, $external, $nfo, $langid, $anon, get_date_time()]);
2020-05-21 10:20:37
I have to ask, because I have wondered 3 times today.. is this a prepared statement? how do you know if query or execute or prepare necessary? do you use transactional selection (SELECT, INSERT, UPDATE) detection to trigger transaction case? Are values binded in a class away from core? I don't think you have to declare INT on prepared queries with binded values. Binding all of that together calls for a DB class. Have you tried organizing that statement away from (potential) DB class, and copy over?

I've rewritten torrent-upload a week ago, and works but needs more work, its a different animal. But I was on this query just earlier..
2020-05-21 11:10:36
yes this is a prepared statement all values are escaped as there are used with place holders ? or you can use :var

the way you use pdo is through a connection
connect->prepare->bind->execute    this is perfectly fine and is the common way

its used this way because people wrap pdo with a class like the old TT mysql where you have a count function (rowCount) a query function (prepare) a insert function all sorts of functions to do what pdo does any way.
this can be a pain because its harder to write i think its easier just to chain everything and keep it simple this was a life saver when updating

Now knowing the above we write one simple function that is the same for everything so we have a pdo wrapper but it just says the way id like to format my queries passing them as arguments
    public function run($sql, $args = NULL)
   {
       if (!$args)
       {
           return $this->pdo->query($sql);
       }
       $stmt = $this->pdo->prepare($sql);
       $stmt->execute($args);
       return $stmt;
   }


i do not use prepare, excecute anywhere in my code except this function
from this excellent guide https://phpdelusions.net/pdo/pdo_wrapper

ill remove this in few days cause codes off topic but heres the seedbonus with this class ichavent used prepared statements yet

$userid   = $CURUSER['id'];
$tid      = $_POST["torrentid"];
$uid      = $CURUSER["class"] == "1" ? (int) $_POST["userid"] : (int) $CURUSER["id"];
$retrieve = DB::run("SELECT * FROM bonus");
$usertable = DB::run("SELECT * FROM users");
if (is_valid_id($_POST['id'])) {
   if (!$row || $CURUSER['seedbonus'] < $row->cost) {
       autolink("bonus.php", "Demand not valid.");
   }
   $updateuser = DB::run("UPDATE users SET seedbonus = seedbonus - '$row->cost' WHERE id = $userid");
   $row = $retrieve->fetch(PDO::FETCH_OBJ);
   switch ($row->type) {
       case 'invite':
           DB::run("UPDATE users SET invites = invites + '$row->value' WHERE id = $userid");
           break;
       case 'traffic':
           DB::run("UPDATE users SET uploaded = uploaded + '$row->value'  WHERE id = $userid");
           break;
       case 'HnR':
           if (empty($tid))
               autolink("bonus.php", "You must fill the box with the id of the torrent.");
           if (isset($uid) && isset($tid)) {
               $res = DB::run("SELECT * FROM snatched WHERE tid = $userid AND uid = $uid AND hnr = 'yes'");
               if ($res->rowCount() < 0)
                   autolink("mybonus.php", "No HnR found with this information.");
               $res1 = DB::run("SELECT username, class FROM users WHERE id = $uid");
               $row1 = $res1->fetch(PDO::FETCH_OBJ);
               $res2 = DB::run("SELECT name FROM torrents WHERE id = $tid");
               $row2           = $res2->fetch(PDO::FETCH_OBJ);
               $username       = htmlspecialchars($row1->username);
               $torname        = htmlspecialchars($row2->name);
               $new_modcomment = gmdate("M d Y H:i:s") . " - ";
               if ($uid == $CURUSER["id"])
                   $new_modcomment .= "H&R on the torrent " . htmlspecialchars($row2->name) . " cleared against " . $row->cost . " points \n";
               else
                   $new_modcomment .= "H&R on the torrent " . $row2->name . " cleared by " . $row1->username . " \n";
               $modcom = sqlesc($new_modcomment);
               DB::run("UPDATE users SET modcomment = CONCAT($modcom,modcomment) WHERE id = :uid");
               DB::run("UPDATE snatched SET ltime = '129600', hnr = 'no' WHERE tid = $userid AND uid = $uid");
           }
break;
       case 'other':
           break;
       case 'VIP':
           $days     = $row->value;
           $class    = $row1->class;
           $vipuntil = ($CURUSER["vipuntil"] > "0000-00-00 00:00:00") ? $vipuntil = get_date_time(strtotime($CURUSER["vipuntil"]) + ($days * 86400)) : $vipuntil = get_date_time(gmtime() + ($days * 86400));
           $oldclass = ($CURUSER["vipuntil"] > "0000-00-00 00:00:00") ? $oldclass = $CURUSER["oldclass"] : $oldclass = $CURUSER["class"];
           $stmt->prepare("UPDATE users SET class = $class, oldclass = $oldclass, vipuntil = $vipuntil WHERE id = $userid");
           break;
}
}
while ($row = $retrieve->fetch(PDO::FETCH_OBJ)) {
   echo '<class="card">';
   echo '<form method="post" action="/bonus.php">';
   echo '<input type="hidden" name="id" value="' . $row->id . '" />';
   echo '<div class="card-action ng-scope" style="font-size:22px">';
   echo "<span style=\"font-size:27px;font-weight:400;padding: 7px 5px 5px 10px;border-radius:7px;background:#C0C0C0;text-align:center;color:#FFF;box-shadow: inset 1px 5px 7px -6px #000000;margin-right:15px\">" . str_replace('Uploaded', '', $row->title) . "</span>";
   echo $row->descr;
   $disabled = '';
   $inputmsg = 'Exchange';
   if ($CURUSER['seedbonus'] < $row->cost) {
       $inputmsg = 'Not Enough';
       $disabled = 'disabled';
   }
   echo '<span>';
   echo "<button class=\"btn btn-danger\" onclick=\"this.form.submit();\" style=\"font-size:15px\" $disabled>$inputmsg</button></span>";
   echo '</div></form></article>';
}
?>
<div>
You receive
<?php echo $site_config['bonuspertime']; ?>
points per
<?php echo floor($site_config['autoclean_interval'] / 10); ?>
minutes the system registers you as a seeder by torrent.
</div>


To make prepared
$updateuser = DB::run("UPDATE users SET seedbonus = seedbonus - '$row->cost' WHERE id = $userid");
To
$updateuser = DB::run("UPDATE users SET seedbonus = seedbonus - '$row->cost' WHERE id = ?", [$userid]);
2020-05-21 11:38:31
"m-jay, post: 68627, member: 20288":

yes this is a prepared statement all values are escaped as there are used with place holders ? or you can use :var

the way you use pdo is through a connection
connect->prepare->bind->execute    this is perfectly fine and is the common way

its used this way because people wrap pdo with a class like the old TT mysql where you have a count function (rowCount) a query function (prepare) a insert function all sorts of functions to do what pdo does any way.
this can be a pain because its harder to write i think its easier just to chain everything and keep it simple this was a life saver when updating

Now knowing the above we write one simple function that is the same for everything so we have a pdo wrapper but it just says the way id like to format my queries passing them as arguments
    public function run($sql, $args = NULL)
   {
       if (!$args)
       {
           return $this->pdo->query($sql);
       }
       $stmt = $this->pdo->prepare($sql);
       $stmt->execute($args);
       return $stmt;
   }


i do not use prepare, excecute anywhere in my code except this function
from this excellent guide https://phpdelusions.net/pdo/pdo_wrapper

ill remove this in few days cause codes off topic but heres the seedbonus with this class ichavent used prepared statements yet

$userid   = $CURUSER['id'];
$tid      = $_POST["torrentid"];
$uid      = $CURUSER["class"] == "1" ? (int) $_POST["userid"] : (int) $CURUSER["id"];
$retrieve = DB::run("SELECT * FROM bonus");
$usertable = DB::run("SELECT * FROM users");
if (is_valid_id($_POST['id'])) {
   if (!$row || $CURUSER['seedbonus'] < $row->cost) {
       autolink("bonus.php", "Demand not valid.");
   }
   $updateuser = DB::run("UPDATE users SET seedbonus = seedbonus - '$row->cost' WHERE id = $userid");
   $row = $retrieve->fetch(PDO::FETCH_OBJ);
   switch ($row->type) {
       case 'invite':
           DB::run("UPDATE users SET invites = invites + '$row->value' WHERE id = $userid");
           break;
       case 'traffic':
           DB::run("UPDATE users SET uploaded = uploaded + '$row->value'  WHERE id = $userid");
           break;
       case 'HnR':
           if (empty($tid))
               autolink("bonus.php", "You must fill the box with the id of the torrent.");
           if (isset($uid) && isset($tid)) {
               $res = DB::run("SELECT * FROM snatched WHERE tid = $userid AND uid = $uid AND hnr = 'yes'");
               if ($res->rowCount() < 0)
                   autolink("mybonus.php", "No HnR found with this information.");
               $res1 = DB::run("SELECT username, class FROM users WHERE id = $uid");
               $row1 = $res1->fetch(PDO::FETCH_OBJ);
               $res2 = DB::run("SELECT name FROM torrents WHERE id = $tid");
               $row2           = $res2->fetch(PDO::FETCH_OBJ);
               $username       = htmlspecialchars($row1->username);
               $torname        = htmlspecialchars($row2->name);
               $new_modcomment = gmdate("M d Y H:i:s") . " - ";
               if ($uid == $CURUSER["id"])
                   $new_modcomment .= "H&R on the torrent " . htmlspecialchars($row2->name) . " cleared against " . $row->cost . " points \n";
               else
                   $new_modcomment .= "H&R on the torrent " . $row2->name . " cleared by " . $row1->username . " \n";
               $modcom = sqlesc($new_modcomment);
               DB::run("UPDATE users SET modcomment = CONCAT($modcom,modcomment) WHERE id = :uid");
               DB::run("UPDATE snatched SET ltime = '129600', hnr = 'no' WHERE tid = $userid AND uid = $uid");
           }
break;
       case 'other':
           break;
       case 'VIP':
           $days     = $row->value;
           $class    = $row1->class;
           $vipuntil = ($CURUSER["vipuntil"] > "0000-00-00 00:00:00") ? $vipuntil = get_date_time(strtotime($CURUSER["vipuntil"]) + ($days * 86400)) : $vipuntil = get_date_time(gmtime() + ($days * 86400));
           $oldclass = ($CURUSER["vipuntil"] > "0000-00-00 00:00:00") ? $oldclass = $CURUSER["oldclass"] : $oldclass = $CURUSER["class"];
           $stmt->prepare("UPDATE users SET class = $class, oldclass = $oldclass, vipuntil = $vipuntil WHERE id = $userid");
           break;
}
}
while ($row = $retrieve->fetch(PDO::FETCH_OBJ)) {
   echo '<class="card">';
   echo '<form method="post" action="/bonus.php">';
   echo '<input type="hidden" name="id" value="' . $row->id . '" />';
   echo '<div class="card-action ng-scope" style="font-size:22px">';
   echo "<span style=\"font-size:27px;font-weight:400;padding: 7px 5px 5px 10px;border-radius:7px;background:#C0C0C0;text-align:center;color:#FFF;box-shadow: inset 1px 5px 7px -6px #000000;margin-right:15px\">" . str_replace('Uploaded', '', $row->title) . "</span>";
   echo $row->descr;
   $disabled = '';
   $inputmsg = 'Exchange';
   if ($CURUSER['seedbonus'] < $row->cost) {
       $inputmsg = 'Not Enough';
       $disabled = 'disabled';
   }
   echo '<span>';
   echo "<button class=\"btn btn-danger\" onclick=\"this.form.submit();\" style=\"font-size:15px\" $disabled>$inputmsg</button></span>";
   echo '</div></form></article>';
}
?>
<div>
You receive
<?php echo $site_config['bonuspertime']; ?>
points per
<?php echo floor($site_config['autoclean_interval'] / 10); ?>
minutes the system registers you as a seeder by torrent.
</div>



Excellent explanation and much appreciated. I only learned preparing statements with bindvalue() and execute, that’s probably whyImwas a bit lost, the code I have is all along the same so seeing tenary operators in the statement was a bit confusing when first working with the svn head.

I hope the code does well, but know that something In query is preventing successful update to user table, not sure why. The absence of SQL_Query_exec() is lacking TT SQL error logging functionality, so it’s a blind miss at the moment.. can I pass error to write_log() ??
2020-05-22 14:37:12
Thanks for the fix!
I just downloaded the latest code from GIT, and uploading torrent worked flawless.

Looking at the torrent details, the field for leaving the comment floats over the NFO text. You would expect it to be hanging just below this field correct?
Or for the NFO not to be visible at all, but showing as popup when clicking the info link.

[ATTACH type="full"]5549[/ATTACH]
1590157429649.png
1590157429649.png

If It Ain't Dutch, It Ain't Much!!
2020-05-22 21:21:39
You need a max-height for the height of the text area by the looks of it, append style=“max-height:220px” and see what happens
2020-05-23 07:35:34
Updating the theme has thrown a few little things out but this is been looked at. There is no style just bootstrap so these little things will be inline css
its just a case of fixing these as we notice them

here is a example - the seedbonus template with no css ( this mod is finished just doing hitnrun )
  <center>
 This page displays the options that you can redeem accumulated points against depending on the share of torrents. <font color=yellow><b><?php echo $data['usersbonus']; ?></font></b>
 </center>
 <br />
 <div class='table-responsive'> <table class='table table-striped'><thead><tr>
     <th>Option</th>
     <th>What is it?</th>
     <th>Points</th>
     <th>Exchange</th>
 </tr></thead>
 <?php foreach ($data['bonus'] as $row): ?>
 <form method="post" action="<?php echo TTURL; ?>/bonus">
 <input type="hidden" name="id" value="<?php echo $row['id']; ?>" />
 <tbody><tr>
     <td><?php echo htmlspecialchars($row['title']); ?></td>
     <td><?php echo htmlspecialchars($row['descr']); ?></td>
     <td><?php echo $row['cost']; ?></td>
     <td><input type="submit" value="Exchange"></td>
 </tr></tbody>
 </form>
 <?php endforeach; ?>
 </table>
 <ul>
    <li>You recieve <font color=red><?php echo $data['configbonuspertime']; ?></font> points per <?php echo $data['configautoclean_interval']; ?> minutes the system registers you as a seeder by torrent.</li>
 </ul>
 <ul>
    <li><a href=<?php echo TTURL; ?>/usercp>Return to profile</a></li>
 </ul>
 </div>
2.1.png
2.1.png
2.2.png
2.2.png
1.2.png
1.2.png
2020-05-23 08:13:12
"m-jay, post: 68638, member: 20288":

Updating the theme has thrown a few little things out but this is been looked at. There is no style just bootstrap so these little things will be inline css
its just a case of fixing these as we notice them

here is a example - the seedbonus template with no css ( this mod is finished just doing hitnrun )
  <center>
 This page displays the options that you can redeem accumulated points against depending on the share of torrents. <font color=yellow><b><?php echo $data['usersbonus']; ?></font></b>
 </center>
 <br />
 <div class='table-responsive'> <table class='table table-striped'><thead><tr>
     <th>Option</th>
     <th>What is it?</th>
     <th>Points</th>
     <th>Exchange</th>
 </tr></thead>
 <?php foreach ($data['bonus'] as $row): ?>
 <form method="post" action="<?php echo TTURL; ?>/bonus">
 <input type="hidden" name="id" value="<?php echo $row['id']; ?>" />
 <tbody><tr>
     <td><?php echo htmlspecialchars($row['title']); ?></td>
     <td><?php echo htmlspecialchars($row['descr']); ?></td>
     <td><?php echo $row['cost']; ?></td>
     <td><input type="submit" value="Exchange"></td>
 </tr></tbody>
 </form>
 <?php endforeach; ?>
 </table>
 <ul>
    <li>You recieve <font color=red><?php echo $data['configbonuspertime']; ?></font> points per <?php echo $data['configautoclean_interval']; ?> minutes the system registers you as a seeder by torrent.</li>
 </ul>
 <ul>
    <li><a href=<?php echo TTURL; ?>/usercp>Return to profile</a></li>
 </ul>
 </div>



Nice, looking good! I'll definitely stay with objects as all my ajax lines up nicely. Silly question.. does mod posted - POST form successfully? Didn't even work for me I just did the conversion.
2020-05-24 17:59:31
[USER=20288]@m-jay[/USER],

At this moment both the Torrent description and the Torrent NFO is creating long text fields, stretching in to the comments below.
Would you think it is a good idea to have both fields serve different purpose? Or maybe hide one, and show one.
I do not fully understand the need to have 2 big text fields more or less showing the same contents. Am I wrong?
If It Ain't Dutch, It Ain't Much!!
2020-05-24 18:02:45
Changed the topic name, as issues are small, and changes are FAST!
If It Ain't Dutch, It Ain't Much!!
2020-05-24 18:11:48
As per xyz/torrents/details?id=1

When nobody downloading, it should not show this:

Peers List:
Warning: Torrents::details(): This PDORow is not from a writable result set in //.xyz/controllers/Torrents.php on line 1023 Call Stack: 0.0001 405664 1. {main}() //.xyz/index.php:0 0.0025 514352 2. Router->__construct() //xyz/index.php:5 0.0029 520336 3. Torrents->details() //xyz/core/Router.php:45

It should just show: "Nobody downloading" or "No Leechers"
If It Ain't Dutch, It Ain't Much!!
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: 8
  • Members: 0
  • Guests online: 8
  • Comments: 3
  • Messages: 1,728