/** * Retourne un tableau contenant les informations des releases * @return array */ public function getReleaseTable() { //Création du tableau $aResponse = array(); $aRegex = Regex::getAllRegex(); $aTrackers = Tracker::getTrackers(); while ($aResult = $this->oResults->fetch_assoc()) { $row = array(); if ($aResult['id_links'] != NULL) { $aTags = explode(';', $aResult['tags']); $row['tags'] = array(); foreach ($aTags as $iTagId) { if ($iTagId != NULL) { $row['tags'][$iTagId] = $aRegex[$iTagId]->getName(); } } $row['categorie'] = $aResult['id_categorie']; $row['fiche'] = $aResult['id_fiche']; $row["release"] = $aResult['name']; $row["release_id"] = $aResult['id']; //Récupération des éléments $aTrackersId = explode(';', $aResult['trackers']); $aLinks = explode(';', $aResult['id_links']); $aDates = explode(';', $aResult['dates']); $aTorrentsId = explode(';', $aResult['id_torrents']); //Récupération du premier up $iFirstPost = 0; $iKeyFirst = 0; foreach ($aDates as $iKey => $sDate) { if ($iFirstPost == 0 || strtotime($sDate) < $iFirstPost) { $iFirstPost = strtotime($sDate); $iKeyFirst = $iKey; } } $row["first_tracker"] = $aTrackersId[$iKeyFirst]; //Affichage des liens $sBottom = ''; foreach ($aTrackersId as $iKey => $iTrackerId) { $aTorrent = array(); $aTorrent['tracker'] = $iTrackerId; //Calcul du pretime $sDate = $aDates[$iKey]; if ($aResult['pretime'] != "0000-00-00 00:00:00") { $iDelay = strtotime($sDate) - strtotime($aResult['pretime']); $sBottom = 'PRE Time : ' . $aResult['pretime']; $row['origin'] = 'Scene'; } else { $iDelay = strtotime($sDate) - $iFirstPost; $sBottom = 'Premier torrent : ' . date("Y-m-j G:i:s", $iFirstPost); $row['origin'] = 'P2P'; } if ($iDelay == 0) { $sDelay = "-"; } else { // Traitement pour affichage $iDelayJ = floor($iDelay / 86400); $iDelayH = floor(($iDelay - $iDelayJ * 86400) / 3600); $iDelayM = floor(($iDelay - $iDelayJ * 86400 - $iDelayH * 3600) / 60); $iDelayS = ($iDelay - $iDelayJ * 86400 - $iDelayH * 3600) % 60; $sDelay = ($iDelayJ != 0 ? $iDelayJ . 'j ' : '') . ($iDelayH != 0 ? $iDelayH . 'h ' : '') . ($iDelayM != 0 ? $iDelayM . 'm ' : '') . ($iDelayS != 0 ? $iDelayS . 's ' : ''); } $aTorrent['delay'] = $sDelay; //Affichage des liens $sFicheLink = $this->oCurrentUser->getLinkWithPasskey($iTrackerId, $aTrackers[$iTrackerId]->getLink()); if ($sFicheLink != false) { $sFicheLink = str_replace('{IDTORRENT}', $aLinks[$iKey], $sFicheLink); $aTorrent['fichelink'] = $sFicheLink; } $sDirectLink = $this->oCurrentUser->getLinkWithPasskey($iTrackerId, $aTrackers[$iTrackerId]->getDirectLink()); if ($sDirectLink != false) { $sDirectLink = str_replace('{IDTORRENT}', $aLinks[$iKey], $sDirectLink); $aTorrent['directlink'] = $sDirectLink; $aTorrent['torrentid'] = $aTorrentsId[$iKey]; } $row["torrents"][] = $aTorrent; } $row['first'] = $sBottom; $aResponse[$aResult['id']] = $row; } } return $aResponse; }
JOIN tks_torrents as t ON t.id = a.id_torrent JOIN tks_releases as r ON t.id_release = r.id JOIN tks_trackers as s ON t.id_tracker = s.id WHERE a.id_user = '******'SELECT r.name as release_name,r.id_categorie,t.id, t.id_link,t.date,s.link,s.directlink,s.name as tracker_name,t.id_tracker FROM tks_torrents as t JOIN tks_releases as r ON t.id_release = r.id JOIN tks_trackers as s ON t.id_tracker = s.id '; if ($iCat !== 0) { $sSqlRequest .= ' WHERE r.id_categorie = ' . $iCat; } $sSqlRequest .= ' ORDER by t.id DESC LIMIT 20'; } $oResults = $oMysqli->query($sSqlRequest); while ($aResult = $oResults->fetch_assoc()) { $sDirectLink = $oCurrentUser->getLinkWithPasskey($aResult['id_tracker'], $aResult['directlink']); $sLink = $oCurrentUser->getLinkWithPasskey($aResult['id_tracker'], $aResult['link']); if ($sLink != false) { $sLink = str_replace('{IDTORRENT}', $aResult['id_link'], $sLink); $sDirectLink = str_replace('{IDTORRENT}', $aResult['id_link'], $sDirectLink); $oItem = $oXml->createElement("item"); $oChannel->appendChild($oItem); $oTitle = $oXml->createElement("title"); $oItem->appendChild($oTitle); $oTextTitle = $oXml->createTextNode($aResult['release_name']); $oTitle->appendChild($oTextTitle); $oDesc = $oXml->createElement("description"); $oItem->appendChild($oDesc); $oTextDesc = $oXml->createTextNode($sLink); $oDesc->appendChild($oTextDesc); $oLink = $oXml->createElement("link");