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

Upload image error — 2020-08-16 18:06:32 in M-BiTsy Support
Started getting odd behaviour on latest dimaria so post here in case anyone else has it in future

Image uploaded but not in database

In sql
`image1` text NOT NULL,
 `image2` text NOT NULL,

change to
`image1` text default NULL,
 `image2` text default NULL,

The image var is array $iname[]
then in torrents upload we use
$iname[0] and $iname[1] in big query

If one was null it would empty array
Do you have a link mate, just wonder if it had a database table would be able to log browser activity easy then
For help i give a little example of how i use

in sql

ALTER TABLE users ADD opsystem char(13) default NULL;


for v3 i think logincookie

SQL_Query_exec("UPDATE users SET last_login = '".get_date_time()."' WHERE id = $id");


to something like

$info = new IPconnected();
$osName = $info->operatingSystem();
SQL_Query_exec("UPDATE users SET last_login = '".get_date_time()." AND  opsystem=".$osName." ' WHERE id = $id");


now you can use this in account, details, login block etc

echo $CURUSER['opsystem'];
this is a little class i use so put it in a block if useful to any one i use this instead of getip() and a few other things

create ipconnected_block.php
<?php
if (!$site_config["MEMBERSONLY"] || $CURUSER) {
       begin_block(T_("Ip Details"));

       $info = new IPconnected();

       $osName = $info->operatingSystem();
       $osVersion = $info->osVersion();
       $browserName = $info->browser()['browser'];
       $browserVersion = $info->browserVersion();
       $ip = $info->ip();

       echo '<font color=orange><b>Op Sys&nbsp;</b></font>'.$osName;
       echo '<br><font color=orange><b>Version&nbsp;</b></font>'.$osVersion;
       echo '<br><font color=orange><b>Browser&nbsp;</b></font>'.$browserName;
       echo '<br><font color=orange><b>Version&nbsp;</b></font>'.$browserVersion;
       echo '<br><font color=orange><b>Ip&nbsp;</b></font>'.$ip;
       end_block();
}


create IPconnected.php (you will need to include this in functions.php)
<?php
class IPconnected
{
   /**
    * Get user agent.
    */
   private static function agent()
   {
       return $_SERVER['HTTP_USER_AGENT'];
   }

   /**
    * Get OperatingSystem name.
    */
   public function operatingSystem()
   {
       $UserAgent = self::agent();
       if (preg_match_all('/windows/i', $UserAgent)) {
           $PlatForm = 'Windows';
       } elseif (preg_match_all('/linux/i', $UserAgent)) {
           $PlatForm = 'Linux';
       } elseif (preg_match('/macintosh|mac os x/i', $UserAgent)) {
           $PlatForm = 'Macintosh';
       } elseif (preg_match_all('/Android/i', $UserAgent)) {
           $PlatForm = 'Android';
       } elseif (preg_match_all('/iPhone/i', $UserAgent)) {
           $PlatForm = 'IOS';
       } elseif (preg_match_all('/ubuntu/i', $UserAgent)) {
           $PlatForm = 'Ubuntu';
       } else {
           $PlatForm = 'unknown';
       }

       return $PlatForm;
   }

   /**
    * Get Browser Name.
    */
   public function browser()
   {
       $UserAgent = self::agent();
       if (preg_match_all('/Edge/i', $UserAgent)) {
           $Browser = 'Microsoft Edge';
           $B_Agent = 'Edge';
       } elseif (preg_match_all('/MSIE/i', $UserAgent)) {
           $Browser = 'Mozilla Firefox';
           $B_Agent = 'Firefox';
       } elseif (preg_match_all('/OPR/i', $UserAgent)) {
           $Browser = 'Opera';
           $B_Agent = 'Opera';
       } elseif (preg_match_all('/Opera/i', $UserAgent)) {
           $Browser = 'Opera';
           $B_Agent = 'Opera';
       } elseif (preg_match_all('/Chrome/i', $UserAgent)) {
           $Browser = 'Google Chrome';
           $B_Agent = 'Chrome';
       } elseif (preg_match_all('/Safari/i', $UserAgent)) {
           $Browser = 'Apple Safari';
           $B_Agent = 'Safari';
       } elseif (preg_match_all('/firefox/i', $UserAgent)) {
           $Browser = 'Mozilla Firefox';
           $B_Agent = 'Firefox';
       } else {
           $Browser = null;
           $B_Agent = null;
       }

       return [
           'browser' => $Browser,
           'agent' => $B_Agent,
       ];
   }

   /**
    * Get Os version.
    */
   public function oSVersion()
   {
       $UserAgent = self::agent();
       if (preg_match_all('/windows nt 10/i', $UserAgent)) {
           $OsVersion = 'Windows 10';
       } elseif (preg_match_all('/windows nt 6.3/i', $UserAgent)) {
           $OsVersion = 'Windows 8.1';
       } elseif (preg_match_all('/windows nt 6.2/i', $UserAgent)) {
           $OsVersion = 'Windows 8';
       } elseif (preg_match_all('/windows nt 6.1/i', $UserAgent)) {
           $OsVersion = 'Windows 7';
       } elseif (preg_match_all('/windows nt 6.0/i', $UserAgent)) {
           $OsVersion = 'Windows Vista';
       } elseif (preg_match_all('/windows nt 5.1/i', $UserAgent)) {
           $OsVersion = 'Windows Xp';
       } elseif (preg_match_all('/windows xp/i', $UserAgent)) {
           $OsVersion = 'Windows Xp';
       } elseif (preg_match_all('/windows me/i', $UserAgent)) {
           $OsVersion = 'Windows Me';
       } elseif (preg_match_all('/win98/i', $UserAgent)) {
           $OsVersion = 'Windows 98';
       } elseif (preg_match_all('/win95/i', $UserAgent)) {
           $OsVersion = 'Windows 95';
       } elseif (preg_match_all('/Windows Phone +[0-9]/i', $UserAgent, $match)) {
           $OsVersion = $match;
       } elseif (preg_match_all('/Android +[0-9]/i', $UserAgent, $match)) {
           $OsVersion = $match;
       } elseif (preg_match_all('/Linux +x[0-9]+/i', $UserAgent, $match)) {
           $OsVersion = $match;
       }

       return $OsVersion;
   }

   /**
    * Get Browser version.
    */
   public function browserVersion()
   {
       $UserAgent = self::agent();
       $B_Agent = self::Browser()['agent'];
       if ($B_Agent !== null) {
           $known = ['Version', $B_Agent, 'other'];
           $pattern = '#(?<browser>' . implode('|', $known) .
               ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
           if (!preg_match_all($pattern, $UserAgent, $matches)) {
           }
           $i = count($matches['browser']);
           if ($i != 1) {
               if (strripos($UserAgent, 'Version') < strripos($UserAgent, $B_Agent)) {
                   $Version = $matches['version'][0];
               } else {
                   $Version = $matches['version'][0];
               }
           } else {
               $Version = $matches['version'][0];
           }
       }

       return $Version;
   }

   /**
    * Get The user ip.
    */
   public function ip()
   {
       if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
           $ip_add = $_SERVER['HTTP_CLIENT_IP'];
       } elseif (!empty($_SERVER['        HTTP_X_FORWADED_FOR'])) {
           $ip_add = $_SERVER['HTTP_X_FORWADED_FOR'];
       } else {
           $ip_add = $_SERVER['REMOTE_ADDR'];
       }

       return $ip_add;
   }
}
Permission Class — 2020-08-16 13:29:53 in M-BiTsy Support
Maybe better to place in user class and pass session array so I can use that

If user->perm(viewuser)

Or User->loggedin()

Function loggedin {
if session[loggedin == true
Return  true
}

Just trying to find the cleanest way to change from global to oop
Permission Class — 2020-08-16 11:39:26 in M-BiTsy Support
with sessions
if (Permissions::hasPermission($_SESSION['id'], $_SESSION["LOGGEDIN"])) {


or object
if (Permissions::hasPermission($user->id, $user->loggedin)) {
Permission Class — 2020-08-16 11:19:37 in M-BiTsy Support
Planning on cleaning my code & formatting. going to spend as much time doing that next week as i can and ive had some ideas about the classes and models so ill post odd one if its of any interest to anyone else

here is my starting point for permissions class - to install make Permissions.php and include it in functions.php if you have any suggestions feel free as i go through code this will be extended

<?php
class Permissions
{
   public static function hasPermission($id, $permission)
   {
       global $site_config, $CURUSER;
       if ($id == $CURUSER['id'] && $permission == 1) {
           return true;
       } else {
           return false;
       }
   }
}



You pass curuser id or user id as first var then 2nd var is permission - this will be extended to check bigger() smaller() siteconfig()  (i have session available for permissions)

lets see if curuser id is loggedin permission
if (Permissions::hasPermission($CURUSER['id'], $site_config["MEMBERSONLY"])) {
   echo "<br>Success<br>";
}
thanks for updating post, youtube in torrenttable / details, and them friend ones can be removed  :D
ive not added friend block yet but all rest is there just trying to make into one db table instead on two
i need more examples as well for style not keen on big blocks
In functions The torrenttable function is taken from micromonkey v3 version
The torrenttableimage is your code
My code is different so for style and resizing I am not as helpful, one thing i notice for example
You have vip mod, v3 does not - concentrate on torrenttable that function needs fine tuning for your needs
haha & try these if not
this should do it use all 3
here try these two
use code above updated
My mistake i see now use this instead - this was mistake  }else{

// End
if ($count)
{
       if ($site_config['torrimagetable'] == true) {
       torrenttableimage($res);
      print $pagerbottom;
       } else {
       torrenttable($res);
      print $pagerbottom;
   }
   }else
Maybe 3/4 minutes
make backup of torrents.php & functions.php

in torrents.php find

// End
if ($count)
{
   torrenttable($res);
   print $pagerbottom;
}


replace with

// End
if ($count)
{
       if ($site_config['torrimagetable'] == true) {
       torrenttable($res);
      print $pagerbottom;
       } else {
       torrenttableimage($res);
      print $pagerbottom;
   }
   }else


in functions.php find
function torrenttable($res) {


replace with
function torrenttableimage($res) {


find
function pager($rpp, $count, $href, $opts = array()) {


before add
function torrenttable($res) {
   global $site_config, $CURUSER, $THEME, $LANGUAGE;  //Define globals

   if ($site_config["MEMBERSONLY_WAIT"] && $site_config["MEMBERSONLY"] && in_array($CURUSER["class"], explode(",",$site_config["WAIT_CLASS"]))) {
       $gigs = $CURUSER["uploaded"] / (1024*1024*1024);
       $ratio = (($CURUSER["downloaded"] > 0) ? ($CURUSER["uploaded"] / $CURUSER["downloaded"]) : 0);
       if ($ratio < 0 || $gigs < 0) $wait = $site_config["WAITA"];
       elseif ($ratio < $site_config["RATIOA"] || $gigs < $site_config["GIGSA"]) $wait = $site_config["WAITA"];
       elseif ($ratio < $site_config["RATIOB"] || $gigs < $site_config["GIGSB"]) $wait = $site_config["WAITB"];
       elseif ($ratio < $site_config["RATIOC"] || $gigs < $site_config["GIGSC"]) $wait = $site_config["WAITC"];
       elseif ($ratio < $site_config["RATIOD"] || $gigs < $site_config["GIGSD"]) $wait = $site_config["WAITD"];
       else $wait = 0;
   }

   // Columns
   $cols = explode(",", $site_config["torrenttable_columns"]);
   $cols = array_map("strtolower", $cols);
   $cols = array_map("trim", $cols);
   $colspan = count($cols);
   // End

   // Expanding Area
   $expandrows = array();
   if (!empty($site_config["torrenttable_expand"])) {
       $expandrows = explode(",", $site_config["torrenttable_expand"]);
       $expandrows = array_map("strtolower", $expandrows);
       $expandrows = array_map("trim", $expandrows);
   }
   // End

   echo '<table align="center" class="ttable_headinner" width="100%"><thead><tr class="ttable_head">';

   foreach ($cols as $col) {
       switch ($col) {
           case 'category':
               echo "<th>".T_("TYPE")."</th>";
           break;
           case 'name':
               echo "<th>".T_("NAME")."</th>";
           break;
           case 'dl':
               echo "<th>".T_("DL")."</th>";
           break;
           case 'uploader':
               echo "<th>".T_("UPLOADER")."</th>";
           break;
           case 'comments':
               echo "<th>".T_("COMM")."</th>";
           break;
           case 'nfo':
               echo "<th>".T_("NFO")."</th>";
           break;
           case 'size':
               echo "<th>".T_("SIZE")."</th>";
           break;
           case 'completed':
               echo "<th>".T_("C")."</th>";
           break;
           case 'seeders':
               echo "<th>".T_("S")."</th>";
           break;
           case 'leechers':
               echo "<th>".T_("L")."</th>";
           break;
           case 'health':
               echo "<th>".T_("HEALTH")."</th>";
           break;
           case 'external':
               if ($site_config["ALLOWEXTERNAL"])
                   echo "<th>".T_("L/E")."</th>";
           break;
           case 'added':
               echo "<th>".T_("ADDED")."</th>";
           break;
           case 'speed':
               echo "<th>".T_("SPEED")."</th>";
           break;
           case 'wait':
               if ($wait)
                   echo "<th>".T_("WAIT")."</th>";
           break;
           case 'rating':
               echo "<th>".T_("RATINGS")."</th>";
           break;
       }
   }
   if ($wait && !in_array("wait", $cols))
       echo "<th>".T_("WAIT")."</th>";

   echo "</tr></thead>";

   while ($row = mysqli_fetch_assoc($res)) {
       $id = $row["id"];

       print("<tr class='t-row'>\n");

   $x = 1;

   foreach ($cols as $col) {
       switch ($col) {
           case 'category':
               print("<td class='ttable_col$x' align='center' valign='middle'>");
               if (!empty($row["cat_name"])) {
                   print("<a href=\"torrents.php?cat=" . $row["category"] . "\">");
                   if (!empty($row["cat_pic"]) && $row["cat_pic"] != "")
                       print("<img border=\"0\"src=\"" . $site_config['SITEURL'] . "/images/categories/" . $row["cat_pic"] . "\" alt=\"" . $row["cat_name"] . "\" />");
                   else
                       print($row["cat_parent"].": ".$row["cat_name"]);
                   print("</a>");
               } else
                   print("-");
               print("</td>\n");
           break;
           case 'name':
               $char1 = 35; //cut name length
               $smallname = htmlspecialchars(CutName($row["name"], $char1));
               $dispname = "<b>".$smallname."</b>";
         
               $last_access = $CURUSER["last_browse"];
               $time_now = gmtime();
               if ($last_access > $time_now || !is_numeric($last_access))
                   $last_access = $time_now;
               if (sql_timestamp_to_unix_timestamp($row["added"]) >= $last_access)
                   $dispname .= "<b><font color='#ff0000'> - (".T_("NEW")."!)</font></b>";

               if ($row["freeleech"] == 1)
                   $dispname .= " <img src='images/free.gif' border='0' alt='' />";
               print("<td class='ttable_col$x' nowrap='nowrap'>".(count($expandrows)?"<a href=\"javascript: klappe_torrent('t".$row['id']."')\"><img border=\"0\" src=\"".$site_config["SITEURL"]."/images/plus.gif\" id=\"pict".$row['id']."\" alt=\"Show/Hide\" class=\"showthecross\" /></a>":"")."&nbsp;<a title=\"".$row["name"]."\" href=\"torrents-details.php?id=$id&amp;hit=1\">$dispname</a></td>");
           break;
           case 'dl':
               print("<td class='ttable_col$x' align='center'><a href=\"download.php?id=$id&amp;name=" . rawurlencode($row["filename"]) . "\"><img src='" . $site_config['SITEURL'] . "/images/icon_download.gif' border='0' alt=\"Download .torrent\" /></a></td>");
           break;
           case 'uploader':
               echo "<td class='ttable_col$x' align='center'>";
               if (($row["anon"] == "yes" || $row["privacy"] == "strong") && $CURUSER["id"] != $row["owner"] && $CURUSER["edit_torrents"] != "yes")
                   echo "Anonymous";
               elseif ($row["username"])
                   echo "<a href='account-details.php?id=$row[owner]'>$row[username]</a>";
               else
                   echo "Unknown";
               echo "</td>";
           break;
           case 'comments':
               print("<td class='ttable_col$x' align='center'><font size='1' face='verdana'><a href='comments.php?type=torrent&amp;id=$id'>" . number_format($row["comments"]) . "</a></font></td>\n");
           break;
           case 'nfo':
               if ($row["nfo"] == "yes")
                   print("<td class='ttable_col$x' align='center'><a href='nfo-view.php?id=$row[id]'><img src='" . $site_config['SITEURL'] . "/images/icon_nfo.gif' border='0' alt='View NFO' /></a></td>");
               else
                   print("<td class='ttable_col$x' align='center'>-</td>");
           break;
           case 'size':
               print("<td class='ttable_col$x' align='center'>".mksize($row["size"])."</td>\n");
           break;
           case 'completed':
               print("<td class='ttable_col$x' align='center'><font color='orange'><b>".number_format($row["times_completed"])."</b></font></td>");
           break;
           case 'seeders':
               print("<td class='ttable_col$x' align='center'><font color='green'><b>".number_format($row["seeders"])."</b></font></td>\n");
           break;
           case 'leechers':
               print("<td class='ttable_col$x' align='center'><font color='#ff0000'><b>" . number_format($row["leechers"]) . "</b></font></td>\n");
           break;
           case 'health':
               print("<td class='ttable_col$x' align='center'><img src='".$site_config["SITEURL"]."/images/health/health_".health($row["leechers"], $row["seeders"]).".gif' alt='' /></td>\n");
           break;
           case 'external':
               if ($site_config["ALLOWEXTERNAL"]){
                   if ($row["external"]=='yes')
                       print("<td class='ttable_col$x' align='center'>".T_("E")."</td>\n");
                   else
                       print("<td class='ttable_col$x' align='center'>".T_("L")."</td>\n");
               }
           break;
           case 'added':
               print("<td class='ttable_col$x' align='center'>".date("d-m-Y H:i:s", utc_to_tz_time($row['added']))."</td>");
           break;
           case 'speed':
               if ($row["external"] != "yes" && $row["leechers"] >= 1){
                   $speedQ = SQL_Query_exec("SELECT (SUM(downloaded)) / (UNIX_TIMESTAMP('".get_date_time()."') - UNIX_TIMESTAMP(started)) AS totalspeed FROM peers WHERE seeder = 'no' AND torrent = '$id' ORDER BY started ASC");
                   $a = mysqli_fetch_assoc($speedQ);
                   $totalspeed = mksize($a["totalspeed"]) . "/s";
               } else
                   $totalspeed = "--";
           print("<td class='ttable_col$x' align='center'>$totalspeed</td>");
           break;
           case 'wait':
               if ($wait){
                   $elapsed = floor((gmtime() - strtotime($row["added"])) / 3600);
                   if ($elapsed < $wait && $row["external"] != "yes") {
                       $color = dechex(floor(127*($wait - $elapsed)/48 + 128)*65536);
                       print("<td class='ttable_col$x' align='center'><a href=\"faq.php#section46\"><font color=\"$color\">" . number_format($wait - $elapsed) . " h</font></a></td>\n");
                   } else
                       print("<td class='ttable_col$x' align='center'>--</td>\n");
               }
           break;
           case 'rating':
               if (!$row["rating"])
                   $rating = "--";
               else
                   $rating = "<a title='$row[rating]/5'>".ratingpic($row["rating"])."</a>";
                   //$rating = ratingpic($row["rating"]);
                    //$srating .= "$rpic (" . $row["rating"] . " out of 5) " . $row["numratings"] . " users have rated this torrent";
               print("<td class='ttable_col$x' align='center'>$rating</td>");
           break;
       }
       if ($x == 2)
           $x--;
       else
           $x++;
   }


       //Wait Time Check
       if ($wait && !in_array("wait", $cols)) {
           $elapsed = floor((gmtime() - strtotime($row["added"])) / 3600);
           if ($elapsed < $wait && $row["external"] != "yes") {
               $color = dechex(floor(127*($wait - $elapsed)/48 + 128)*65536);
               print("<td class='ttable_col$x' align='center'><a href=\"faq.php\"><font color=\"$color\">" . number_format($wait - $elapsed) . " h</font></a></td>\n");
           } else
               print("<td class='ttable_col$x' align='center'>--</td>\n");
           $colspan++;
           if ($x == 2)
               $x--;
           else
               $x++;
       }
 
       print("</tr>\n");

       //Expanding area
       if (count($expandrows)) {
           print("<tr class='t-row'><td class='ttable_col$x' colspan='$colspan'><div id=\"kt".$row['id']."\" style=\"margin-left: 2px; display: none;\">");
           print("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
           foreach ($expandrows as $expandrow) {
               switch ($expandrow) {
                   case 'size':
                       print("<tr><td><b>".T_("SIZE")."</b>: ".mksize($row['size'])."</td></tr>");
                   break;
                   case 'speed':
                       if ($row["external"] != "yes" && $row["leechers"] >= 1){
                           $speedQ = SQL_Query_exec("SELECT (SUM(downloaded)) / (UNIX_TIMESTAMP('".get_date_time()."') - UNIX_TIMESTAMP(started)) AS totalspeed FROM peers WHERE seeder = 'no' AND torrent = '$id' ORDER BY started ASC");
                           $a = mysqli_fetch_assoc($speedQ);
                           $totalspeed = mksize($a["totalspeed"]) . "/s";
                           print("<tr><td><b>".T_("SPEED").":</b> $totalspeed</td></tr>");
                       }
                   break;
                   case 'added':
                       print("<tr><td><b>".T_("ADDED").":</b> ".date("d-m-Y \\a\\t H:i:s", utc_to_tz_time($row['added']))."</td></tr>");
                   break;
                   case 'tracker':
                   if ($row["external"] == "yes")
                       print("<tr><td><b>".T_("TRACKER").":</b> ".htmlspecialchars($row["announce"])."</td></tr>");
                   break;
                   case 'completed':
                       print("<tr><td><b>".T_("COMPLETED")."</b>: ".number_format($row['times_completed'])."</td></tr>");
                   break;
               }
           }
               print("</table></div></td></tr>\n");
       }
       //End Expanding Area


   }

   print("</table><br />\n");

}


Config.php to see use true or false
$site_config["torrimagetable"] = true;
can you post full function after this, first we make it work then add user setting
for now config to see

index.php find

   $res = DB::run($query);
   if ($res->rowCount()) {
       torrenttable($res);
       torrenttableimage($res);
   }else {



replace with
    $res = DB::run($query);
   if ($res->rowCount()) {
       if ($site_config['torrimagetable'] == true) {
       torrenttable($res);
       } else {
       torrenttableimage($res);
   }
   }else {


config.php add
$site_config["torrimagetable"] = true;


functions.php
You need OLD torrenttable function AND NEW function torrenttableimage

note - mine i edit my function with your code - sort is missing & i notice there is no default image
I like this idea I will make later today and share  (y)

My sql is rusty ?  for v3 but I'm sure [USER=20382]@STorrents2020[/USER] or [USER=311]@MicroMonkey[/USER] can help with any db queries if needed
for each user its must be setting in database
$example = select torrtable from users where id
if ($example = true)
maybe have 2 two functions my friend, you would need config - $site_config['torrent_image'] = true (or false)

torrenttable()  &   torrenttableimage()

if ($site_config['torrent_image'] == true) {
torrenttableimage()
} else {
torrenttable()
}


A option
And you may also move these functions to something like  torrenttables.php in functions find require_once(BACKEND."/languages.php");
below add the new file require_once(BACKEND."/new_file_name.php");
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: 10

  • Online

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