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
Error upload torrent
Controls ·  Search New posts · Mark unread

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

2020-11-25 19:48:57
After a while time I have that error message, no MySQL error shows in log file
Screenshot_14.png
Screenshot_14.png



www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2020-11-25 20:54:02
Make sure the error log txt files are empty find this line on controller/torrent
try {
               $ret = DB::run("INSERT INTO torrents (filename, owner, name, vip, descr, image1, image2, category, tube, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang, anon, last_action, freeleech, imdb)
                   VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
                   [$fname, $_SESSION['id'], $name, $vip, $descr, $inames[0], $inames[1], $catid, $tube, get_date_time(), $infohash, $torrentsize, $filecounts, $fname, $announce, $external, $nfo, $langid, $anon, get_date_time(), $free, $imdb]);
               } catch (PDOException $e) {
               rename("$torrent_dir/$fname", "$torrent_dir/duplicate.torrent"); // todo
               autolink(TTURL . '/index.php', 'Torrent already added. Duplicate Hash');
           }
           $id = DB::lastInsertId();


Replace with


               $ret = DB::run("INSERT INTO torrents (filename, owner, name, vip, descr, image1, image2, category, tube, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang, anon, last_action, freeleech, imdb)
                   VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
                   [$fname, $_SESSION['id'], $name, $vip, $descr, $inames[0], $inames[1], $catid, $tube, get_date_time(), $infohash, $torrentsize, $filecounts, $fname, $announce, $external, $nfo, $langid, $anon, get_date_time(), $free, $imdb]);
             
           $id = DB::lastInsertId();


Then check error log file, I am looking at ways to add back to database so these can be read in admin panel. Exceptions are a little more complicated
2020-11-25 22:01:42
Error
       

Oops somwthing went wrong, Admin have been notified if this continues please contact a member of staff. Thank you



Uncaught Exception: 2020-11-25 21:59:18 - syntax error, unexpected 'public' (T_PUBLIC) in file /home/tt-m-jay/public_html/controllers/Torrents.php on line 752

Call Stack

[0] File: /home/tt-m-jay/public_html/index.php Line: 3
Function: Router->__construct
Uncaught Exception: 2020-11-25 21:59:26 - syntax error, unexpected 'public' (T_PUBLIC) in file /home/tt-m-jay/public_html/controllers/Torrents.php on line 752

Call Stack

[0] File: /home/tt-m-jay/public_html/index.php Line: 3
Function: Router->__construct



www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2020-11-25 23:34:49
I think I found this "ghost" problem,
in torrent description I have [color=rgb(255, 0, 0)]=[/color] character
and it make all my error in every torrent I try to upload


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2020-11-26 16:37:39
description $desc = $_POST[desc] is just a form  input it, i can not recreate error - that error implies the file has not been read correctly public is a class method for a syntac error the controller would not load at all
unexpected 'public' (T_PUBLIC) in file /home/tt-m-jay/public_html/controllers/Torrents.php on line 752

im on php  7.4.11
i am updating the controllers so will investigate further, my next release a lot changes (not theme though) so if you follow project please keep note of any changes to any files except themes/dir
Untitledyu.png
Untitledyu.png
2020-11-26 18:34:53
"Botanicar, post: 69627, member: 19833":

in torrent description I have [color=rgb(255, 0, 0)]=[/color] character


Maybe someone else can see if they have this problem on upload
2020-11-26 21:50:14
"m-jay, post: 69629, member: 20288":

Maybe someone else can see if they have this problem on upload

From some reason, that error disappear now and it working without problems, I have made some things updating on my server and "viola" it works.
Back to business and theme work

PS
When we can expect a new extern torrent scraper, thanks to everyone


www.exyusubs.com
TorrentTrader V3.8.3 (SE)
OS: AlmaLinux 9.9 (BC)
Apache version: 2.4.71
PHP version: 8.5.13 (PHP-FPM)
MySQL version: 10.11.18-MariaDB
2020-11-27 05:49:27
"Botanicar, post: 69626, member: 19833":

Error
       

Oops somwthing went wrong, Admin have been notified if this continues please contact a member of staff. Thank you



Uncaught Exception: 2020-11-25 21:59:18 - syntax error, unexpected 'public' (T_PUBLIC) in file /home/tt-m-jay/public_html/controllers/Torrents.php on line 752

Call Stack

[0] File: /home/tt-m-jay/public_html/index.php Line: 3
Function: Router->__construct
Uncaught Exception: 2020-11-25 21:59:26 - syntax error, unexpected 'public' (T_PUBLIC) in file /home/tt-m-jay/public_html/controllers/Torrents.php on line 752

Call Stack

[0] File: /home/tt-m-jay/public_html/index.php Line: 3
Function: Router->__construct



Doesn't this imply a language global is missing? Also a bit misleading, because it references "public" in plain text, which then explains that its a public function when it expects a private function, just my two cents. This upload script is terrible from the beginning to be honest, I had nothing but problems with it for a long time.

PHP 5 / 7 / 8 - 100% working


<?
if (session_status() == PHP_SESSION_NONE) { session_start(); }  
require_once '../site.php';
require_once '../classes/class.bencoding.php';
require_once '../classes/class.imageresizer.php';
$db->connect();

$errors = array();

if ($account->sessionLogin()) {

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
   check_csrf();

   $description = $_POST['description'];
   if (strlen($description) > 10000) {
       die('description too long');
   }

   if (!array_key_exists('torrent', $_FILES)) {
       die;
   }

   if ($_FILES['torrent']['size'] > $CONFIG['max_torrent_size']) {
       die('torrent too big');
   }

   $name = $_FILES['torrent']['name'];
   if (strlen($name) > 512) {
       die('torrent name too long');
   }
 
   //Added
   $tags = $_POST['tags'];
   if (strlen($tags) > 50) {
       die('tags are too long');
   }
   $version = $_POST['version'];
   if (strlen($version) > 15) {
       die('version is too long');
   }
 
   $dlc = $_POST['dlc'] ? 'yes' : 'no';
 
   $youtube = $_POST['youtube'];
   if (strlen($youtube) > 100) {
       die('YouTube url is too long');
   }
   //
 
   $ext = '.torrent';
   if (strlen($name) <= strlen($ext) || strpos($name, $ext, strlen($name) - strlen($ext)) === false) {
       die('not a .torrent file');
   }

   $fp = fopen($_FILES['torrent']['tmp_name'], 'rb');
   $data = '';
   while (!feof($fp)) {
       $data .= fread($fp, 8192);
   }
   fclose($fp);

   $arr = bdecode($data);
   if ($arr === false) {
       die('invalid torrent');
   }

   // TODO: more validity checks for torrent?

   if (!array_key_exists('info', $arr)) {
       die('invalid torrent');
   }
 
   if (array_key_exists('cover', $_FILES)) {

       $uploadedFile     = $_FILES['cover']['tmp_name'];
       $sourceProperties = getimagesize($uploadedFile);
       $newFileName      = sha1_file($uploadedFile);
       $dirPath          = 'images/covers/';
       $ext              = pathinfo($_FILES['cover']['name'], PATHINFO_EXTENSION);
       $imageType        = $sourceProperties[2];

       switch ($imageType)
       {
           case IMAGETYPE_PNG:
               $imageSrc = imagecreatefrompng($uploadedFile);
               $tmp      = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
               imagepng($tmp, $dirPath . $newFileName . "_thumb." . $ext);
           break;

           case IMAGETYPE_JPEG:
               $imageSrc = imagecreatefromjpeg($uploadedFile);
               $tmp      = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
               imagejpeg($tmp, $dirPath . $newFileName . "_thumb." . $ext);
           break;

           case IMAGETYPE_GIF:
               $imageSrc = imagecreatefromgif($uploadedFile);
               $tmp      = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
               imagegif($tmp, $dirPath . $newFileName . "_thumb." . $ext);
           break;

           default:
               die('invalid image.');
           break;
       }

       move_uploaded_file($uploadedFile, $dirPath . $newFileName . "." . $ext);  
       $cover_full  = $newFileName . "." . $ext;
       $cover_thumb = $newFileName . "_thumb." . $ext;  
   }
 
   if (array_key_exists('image1', $_FILES)) {

       $uploadedFile     = $_FILES['image1']['tmp_name'];
       $sourceProperties = getimagesize($uploadedFile);
       $newFileName      = sha1_file($uploadedFile);
       $dirPath          = 'uploads/images/';
       $ext              = pathinfo($_FILES['image1']['name'], PATHINFO_EXTENSION);
       $imageType        = $sourceProperties[2];

       switch ($imageType)
       {
           case IMAGETYPE_PNG:
               $imageSrc = imagecreatefrompng($uploadedFile);
               $tmp      = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
               imagepng($tmp, $dirPath . $newFileName . "_thumb." . $ext);
           break;

           case IMAGETYPE_JPEG:
               $imageSrc = imagecreatefromjpeg($uploadedFile);
               $tmp      = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
               imagejpeg($tmp, $dirPath . $newFileName . "_thumb." . $ext);
           break;

           case IMAGETYPE_GIF:
               $imageSrc = imagecreatefromgif($uploadedFile);
               $tmp      = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
               imagegif($tmp, $dirPath . $newFileName . "_thumb." . $ext);
           break;

           default:
               die('invalid image.');
           break;
       }

       move_uploaded_file($uploadedFile, $dirPath . $newFileName . "." . $ext);  
       $image1_full  = $newFileName . "." . $ext;
       $image1_thumb = $newFileName . "_thumb." . $ext;  
   }
 
   if (array_key_exists('image2', $_FILES)) {

       $uploadedFile     = $_FILES['image2']['tmp_name'];
       $sourceProperties = getimagesize($uploadedFile);
       $newFileName      = sha1_file($uploadedFile);
       $dirPath          = 'uploads/images/';
       $ext              = pathinfo($_FILES['image2']['name'], PATHINFO_EXTENSION);
       $imageType        = $sourceProperties[2];

       switch ($imageType)
       {
           case IMAGETYPE_PNG:
               $imageSrc = imagecreatefrompng($uploadedFile);
               $tmp      = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
               imagepng($tmp, $dirPath . $newFileName . "_thumb." . $ext);
           break;

           case IMAGETYPE_JPEG:
               $imageSrc = imagecreatefromjpeg($uploadedFile);
               $tmp      = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
               imagejpeg($tmp, $dirPath . $newFileName . "_thumb." . $ext);
           break;

           case IMAGETYPE_GIF:
               $imageSrc = imagecreatefromgif($uploadedFile);
               $tmp      = imageResize($imageSrc, $sourceProperties[0], $sourceProperties[1]);
               imagegif($tmp, $dirPath . $newFileName . "_thumb." . $ext);
           break;

           default:
               die('invalid image.');
           break;
       }

       move_uploaded_file($uploadedFile, $dirPath . $newFileName . "." . $ext);  
       $image2_full  = $newFileName . "." . $ext;
       $image2_thumb = $newFileName . "_thumb." . $ext;  
   }

   $infobc = bencode($arr['info']);
   if ($infobc === false) {
       die('bencoding error');
   }

   $info_hash = sha1($infobc);
   $total_size = 0;

   if ($checktype['info']['private'] = 1) { // Added - Check if torrent is private (this changes info_hash) - Sep 1, 2020
   if (array_key_exists('files', $arr['info'])) {
       foreach ($arr['info']['files'] as $file) {
           if (array_key_exists('length', $file)) {
               $total_size += $file['length'];
           }
       }
   } else if (array_key_exists('length', $arr['info'])) {
       $total_size += $arr['info']['length'];
   }
       $data = bencode($arr);
   }else{
       $data = bdecode($data); // Public torrent (does not change info_hash)
   }

   $an = array_key_exists('anonymous', $_POST);
   $torrent_id = $db->query_params("INSERT INTO torrents (user_id, name, descr, anon, info_hash, size, tags, version, dlc, youtube, cover1, cover2, image1, image2) VALUES (:user_id, :name, :description, :anonymous, :info_hash, :total_size, :tags, :version, :dlc, :youtube, :cover1, :cover2, :image1, :image2)", array('user_id' => $account->getId(), 'name' => $name, 'description' => $description, 'anonymous' => $db->encode_bool($an), 'info_hash' => $info_hash, 'total_size' => $total_size, 'tags' => $tags, 'version' => $version, 'dlc' => $dlc, 'youtube' => $youtube, 'cover1' => $cover_full, 'cover2' => $cover_thumb, 'image1' => $image1_full, 'image2' => $image2_full), 'torrent_id') or die('db error');
 
   // Updated for new torrents_blob table - Performance - Sep 2, 2020
   $db->query_params('INSERT INTO torrents_blob (torrent_id, user_id, data) VALUES (:last_id, :user_id, :data)', array('last_id' => $torrent_id, 'data' => $data, 'user_id' => $account->getId())); // array('data' => $data, 'last_id' => $torrent_id));

   header(sprintf('Location: %s/details/%s/', $CONFIG['base_url'], $torrent_id));
   die;
   }

}else{
   header(sprintf('Location: %s/login.php', $CONFIG['base_url']));
   die;
}

// Get users passkey
$passkey = $db->query_params('SELECT passkey FROM users WHERE user_id = :user_id', array('user_id' => $account->getId())) or die('db error');
$getkey = $passkey->fetch();

site_header();
?>
2020-11-27 13:36:32
Thanks for sharing [USER=20382]@STorrents2020[/USER]  I'll have a play with that at some point, got the input logic separated for upload just need to go through it
For the scraper from what I've seen there is only two possible options the current one and the scrapeer class. I've got the current one running perfect on 2 out of 3 servers so its just pinpointing the server issue
Might be worth asking the host if you can do a support ticket there and I'll contact my host and ask them as well something is preventing it from scraping externally - its defo not allow_url_fopen
2020-11-27 15:09:53
"m-jay, post: 69633, member: 20288":

Thanks for sharing [USER=20382]@STorrents2020[/USER]  I'll have a play with that at some point, got the input logic separated for upload just need to go through it
For the scraper from what I've seen there is only two possible options the current one and the scrapeer class. I've got the current one running perfect on 2 out of 3 servers so its just pinpointing the server issue
Might be worth asking the host if you can do a support ticket there and I'll contact my host and ask them as well something is preventing it from scraping externally - its defo not allow_url_fopen


Sounds good I might have a weekend dedicated solely so just waiting on word for that.

This is preventable with cURL correct? That old function has been blocked on free / paid web hosting since way back in the day, often encouraging people to upgrade to β€œpaid hosting” to enable that function.

β€” they will bitch about the number of outbound connections, and ask if you are using a BitTorrent script (UDP protocol will not be possible). Pain in the ass since 2005

If your testing on public hosting, they will wipe the tracker immediately. Get a dedicated box in your house and dump Linux on it and LAN it up to your router, DMZ the IP and update the IP for a DNS serve (like FreeDNS or Cloudflare) and you should have zero problems testing that script on a default stack installation.

My baby is flawless and purrs all day with maximum settings, I can throw anything at it so maybe I have much more leverage here...
2020-11-29 07:17:11
And everyone, for the sake of simplicity, speed and security (and not using 6 functions to achieve a simple check case), this is super good to memorise

instead of
isset($_POST['name'] or !empty or ! or whatever..

start using
array_key_exists('name', $_REQUEST)

$_REQUEST means _GET, _SERVER, _POST, etc etc

Its easy to get confused, like "why cant I just use in_array() ?" because most of the time, these functions expect additional parameters passed to actually utilize the function properly for those certain cases. Here, we are talking about server request checking.

name in this case is array a array [color=rgb(44, 130, 201)]key

You are simply checking if that key is in the request.
[/color]

Your interpreter (the PHP binary) will thank you, and your code comes out clean, easy to read & easy to maintain.

Focus on array data exclusively. Its a life saver and its CPU light. All versions welcome it, and so should we. I see a lot of code posted that is ??? but this will drop in place and fix "what should I use here?". I can repost code posted that is clean and fixed up but its good if we all start using this logic across the board. Cheers!
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: 5
  • Members: 0
  • Guests online: 5
  • Comments: 3
  • Messages: 1,728