Thanks mate
-----------------------------------------------------------------------
Need to be installed this Mod
https://torrenttrader.uk/post/9734
I successfully upgraded the IMDB integration to be compatible with PHP 8.4
IMDB Mod working with php8.4
------------------------------------------------------------
First and important add this function in backend/functions.php:
spl_autoload_register(function ($f) {
require_once('backend/' . $f . '.php');
});
Change file TTIMDB.php like this:
-------------------------------------------------------------
<?php
class TTIMDB
{
private $_nodes = ['https://www.omdbapi.com/?apikey=YOUR_OMDB_KEY&i=%s'];
public function get($uri = null)
{
if (preg_match('#tt(\d+)#', $uri, $m)) {
return $this->_try($m[0]);
}
return false;
}
private function _try($id)
{
for ($i = 0; $i < count($this->_nodes); $i++) {
if ($data = $this->_request($id, $i)) {
return $data;
}
}
return false;
}
private function _request($id, $i)
{
$ch = curl_init();
if ($ch) {
curl_setopt($ch, CURLOPT_URL, sprintf($this->_nodes[$i], $id));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_USERAGENT, 'TT API Client v1.0');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
curl_close($ch);
return !empty($data) ? $this->_parse($data) : false;
}
return false;
}
private function _parse($data)
{
$info = json_decode($data);
return ($info && !isset($info->Error)) ? $info : false;
}
public function getImage($poster, $id) {
return (!empty($poster) && $poster !== "N/A")
? $poster
: "images/imdb/no-poster.png";
}
public function getRating($rating) {
return (!empty($rating) && $rating !== "N/A")
? $rating . "/10"
: null;
}
public function renderStars10($rating) {
if (empty($rating) || $rating === "N/A") {
return '<span class="no-rating">Not rated</span>';
}
$stars = round($rating);
$html = '<div class="stars">';
for ($i = 1; $i <= 10; $i++) {
$html .= ($i <= $stars)
? '<span class="star full">★</span>'
: '<span class="star empty">☆</span>';
}
$html .= " <span class=\"rating-text\">($rating/10)</span></div>";
return $html;
}
public function getRated($rated) {
return (!empty($rated) && $rated !== "N/A")
? $rated
: "Unrated";
}
public function getReleased($released) {
return (!empty($released) && $released !== "N/A")
? $released
: "Unknown";
}
public function getUpdated($timestamp) {
return !empty($timestamp)
? date("d-m-Y H:i", $timestamp)
: "n/A";
}
}
?>
------------------------------------------------------------------
In torrents-details.php add in IMDB part like this:
//===| Start IMDb
$TTIMDB = new TTIMDB;
if ((($_data = $TTCache->Get("imdb/$id", 900)) === false) && ($_data = $TTIMDB->Get($row['imdb'])))
{
$_data->Poster = $TTIMDB->getImage($_data->Poster, $id);
if ( ! isset( $_data->imdbTime ) )
{
$_data->imdbTime = time();
$_data->imdbVideo = null;
}
$TTCache->Set("imdb/$id", $_data, 900);
}
if ( is_object($_data) ): ?>
<fieldset class="download">
<legend><b><?php echo T_("IMDB_SHORT"); ?></b> • <?php echo $_data->Title; ?></legend>
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td width="230"><img src="<?php echo $_data->Poster; ?>" alt="<?php echo $_data->Title; ?>" title="<?php echo $_data->Title; ?>"class="polaroid" height="350px" width="244px" /></td>
<td valign="top">
<?php if (($rating = $TTIMDB->getRating($_data->imdbRating)) !== null) { ?>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>
<div class="f-border imdb-box" style="padding:7px; margin-bottom:10px">
<table border="0" cellpadding="3" cellspacing="0">
<tr><td colspan="2"><?php echo $TTIMDB->renderStars10($_data->imdbRating); ?></td></tr>
<tr><td width="1%"><b><?php echo T_("IMDB_RATED"); ?></b>:</td><td> <?php echo $TTIMDB->getRated( $_data->Rated ); ?></td></tr>
<tr><td width="1%"><b><?php echo T_("IMDB_VOTES"); ?></b>:</td><td> <?php echo $_data->imdbVotes; ?> </td></tr>
</table>
</div>
</td></tr></table>
<?php } else { ?>
<table border="0" cellpadding="0" cellspacing="0"><tr><td>
<div class="f-border" style="padding:7px; margin-bottom:10px">
<table border="0" cellpadding="3" cellspacing="0">
<tr><td><img src="images/imdb/00.png" border="0"></td></tr>
<tr><td><?php echo T_("NOT_YET_RATED"); ?>...</td></tr>
</table>
</div>
</td></tr></table>.........
This is the important lines: !!!(need to be changed like this):
<div class="f-border imdb-box" style="padding:7px; margin-bottom:10px">
<tr><td colspan="2"><?php echo $TTIMDB->renderStars10($_data->imdbRating); ?></td></tr>
-------------------------------------------------------------------------------
In theme.css add this:
.stars {
font-size: 20px;
color: gold;
display: inline-block;
}
.star.empty {
color: #ccc;
}
.no-rating {
color: #999;
font-style: italic;
}
.imdb-box {
width: 100%;
max-width: 600px;
}
.rating-text {
font-size: 14px;
color: #ffd700;
margin-left: 6px;
vertical-align: middle;
}
PS: File imdb.class.php no need in this case, rename or delete.
Thats all.
Regards from me
Last edited by coco on 2025-10-30 22:55:29