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
Torrent Trader PDO Update Beta Test
Controls ·  Search New posts · Mark unread

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

Unknown User
2020-02-13 14:36:23
[USER=20288]@m-jay[/USER] I was auditing the code to check for some exploits and there is a major one which is exposing the backend ip address even if cloudflare is used.

Basically avatar image php code is leaking server ip. If attacker hosts image on their server and use that image on torrenttrader as avatar, the ip will be exposed and they will get it into their access logs.

This must be removed
# Validate Image.
$im = @getimagesize( $avatar );
             
if ( !$im[ 2 ] || !@array_key_exists( $im['mime'], $allowed_types ) )
$message = "The avatar url was determined to be of a invalid nature.";


I've replaced it via regular expression to check if link is an image.
2020-02-13 19:54:17
I'll have a look do you have a fix m8
Been thinking of replacing config as well and putting it in a class what do you think this means mysql.php can be removed

So config.php now
$site_config = array();
$site_config['ttversion'] = '3.0'

Used like
$site_config['ttversion']


Would be a static class to remove global var
class config {
static ttversion = '3.0'

Used like
config::ttversion


Then settings and database details and the database itself can be called on a init.php/autoloader or in the future in a tt_framework class
Tt_framework::init which would include
Files, defined paths and autoload all classes
Unknown User
2020-02-13 20:43:47
Yes, the fix is to never run any curl / file read request from your server to external url.

I've found with this method alone exposed ips of 4 very big public trackers

if (!preg_match('/^https?:\/\/(?:[a-z0-9\-]+\.)+[a-z]{2,6}(?:\/[^\/#?]+)+\.(?:jpe?g|gif|png)$/', $avatar);
$message = "The avatar url was determined to be of a invalid nature.";


This will also prevent .jpg?query=malicious_attack
2020-02-14 10:14:42
did a quick test with a static class but had a issue with dirs been called although i could put them in a file for defined paths, i think ill go with a init.php with a array then a config class that calls it
im about to share my finished base so any help is welcome :D
2020-02-16 10:49:18
i just need to add a router now so i can move all the root files to a app folder and run everything through index.php. Ive got it fully working but im going to leave it is for now unless someone has a simple way.

Ive moved everything except the root and this is the structure and the config side

config. php this is a a array thats global (we dont call global though)

$GLOBALS['config'] = array(
   'mysql' => array(
'mysql_host' => 'localhost', //leave this as localhost if you are unsure
'mysql_user' => "name", //Username to connect
'mysql_pass' => "pass", //Password to connect
'mysql_db' => "name",  //Database name
'ttversion' => '3.0',                            //DONT CHANGE THIS!

// Main Site Settings
'SITENAME' => 'TorrentTrader',                //Site Name
'SITEEMAIL' => 'change@myemailsux.com',        //Emails will be sent from this address


called anywhere with Config.Class.php (its a static)
class Config
{
   public static function get($path = null)
   {
       if ($path) {
           $config = $GLOBALS['config'];
           $path = explode('/', $path);
           foreach ($path as $bit) {
               if (isset($config[$bit])) {
                   $config = $config[$bit];
               }
           }
           return $config;
       }
       return $false;
   }
}


And then the init.php
define("BACKEND", dirname(__FILE__));
$BACKEND = BACKEND;

include("/ttcore/helpers/exceptionhelper.php");
// Register custom exception handler
set_exception_handler("handleUncaughtException");

require_once("/config/config.php");
require_once("/ttcore/database/dbclass.php"); //Get MYSQL Connection Info
require_once("/ttcore/libraries/Config.Class.php");  //Get Site Settings and Vars ($site_config)
require_once("/ttcore/libraries/cache.php"); // Caching
require_once("/ttcore/libraries/mail.php"); // Mail functions


config called like
$this->cachedir = Config::get('mysql/cache_dir');


And ive attached how my test site is running currently just need to move all root files like memberlist.php but now everythings working i might leave that for time been
Untitled.png
Untitled.png
Unknown User
2020-02-16 13:22:32
[USER=20288]@m-jay[/USER] add just require instead of require_once because it needs more time to go through all files and check for duplicates.
and i would just use object array for config file without adding additional hoops because those are just making it a bit more complicated than it needs to be.

Include config.php inside init and add something like [ICODE]require 'Config.php';[/ICODE]

$config = (object)
[
        'SITENAME' => 'TorrentTrader',                //Site Name
        'SITEEMAIL' => 'change@myemailsux.com',        //Emails will be sent from this address
];
echo $config->SITENAME; // TorrentTrader


People on stackoverflow are generally against static methods and will call your coding bad. (The only usage for static which is still criticized but accepted is database connection)
The main two reasons against using static methods are:

   code using static methods is hard to test
   code using static methods is hard to extend

Having a static method call inside some other method is actually worse than importing a global variable.
2020-02-16 14:01:42
Statics are a good tool but are frowned on because you cant extend them and If there do too much can bite you in ass in future but these two I have both are tiny, one is just settings in one file and the only connection to db so are strictly one purpose using another db like sqlite might change that but as far as I know with this dbclass I just need to change the dsn a little
Once I'm done the two statics can be removed easily then added to function parameters I've got a new db ready but mass editing keeps breaking it lol need to do each file one by one but that can wait its just a case of autoloader(init.php) then define class
$pdo = new db
$Config = require (config/config.php

Example function dbconn($pdo, $config)

I've added a router just playing with the dynamic links hopefully it works, moved memberlist.php out of root and it works just some of the links
The urls look better though siteurl/memberlist
2020-02-17 21:15:29
will You be compiling a changelog on what has been transitioned to PDO? Makes a heavily modified site look quite discouraging.
Unknown User
2020-02-18 12:56:04
"STorrents2020, post: 67920, member: 20382":

will You be compiling a changelog on what has been transitioned to PDO? Makes a heavily modified site look quite discouraging.

Its really not recommended to shift existing site. You won't gain any noticable performance boost, but could gain some security loop hole which may compromise the site.
Unknown User
2020-02-22 13:44:24
I have deploye an expΓ©rimental tracker with this version
[url='https://ttv3-dev.minzord.eu.org/']https://ttv3-dev.minzord.eu.org[/url]  :) Move to PDO it's a good ideas
2020-02-22 13:57:38
this is a stable release so please report any bugs or thoughts for improving
Unknown User
2020-02-22 13:59:21
"m-jay, post: 67942, member: 20288":

this is a stable release so please report any bugs or thoughts for improving

You want me to do the french.php?
Unknown User
2020-02-22 18:03:59
Gj [USER=20288]@m-jay[/USER]
2020-02-22 21:39:10
Awesome work guys! Will check out the stable release today.
2020-02-23 06:38:15
Ive placed all files for stable release back to the rightful location, i have them all moved but im having a issue with dynamic links with the router it doesnt like all url ( id/do/action/edit etc ) statements

At least this makes it easy to compare changes  from v3 and everything is in the right place for mods to be added and every ones familiar with the code.
The base is fully done and has been tested by me but  just need more people to test but its now a stable release that ill be posting around.
The only thing is the style been so basic but im hoping to remove most of the theme when i add bootstrap for each page. At the minute theme frame & torrent-details are bootstrap

I just need to add init.php from mine but any changes will be commented on github and im going to add a few mods

remove mysql.php
https://github.com/M-jay84/Torrent-Trader-2020-PDO/commit/b89583720767de4b018ecd6918abd4302173b050
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: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728