Exemplo n.º 1
0
    echo $CollageID;
    ?>
_box .images').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets"><?php 
    echo $FirstCol ? 'Hide' : 'Show';
    ?>
</a>
				</span>
			</td>
		</tr>
		<tr class="images<?php 
    echo $FirstCol ? '' : ' hidden';
    ?>
">
<?php 
    foreach ($Collage as $C) {
        $Group = Torrents::get_groups(array($C['GroupID']), true, true, false);
        extract(Torrents::array_group($Group[$C['GroupID']]));
        $Name = '';
        $Name .= Artists::display_artists(array('1' => $Artists), false, true);
        $Name .= $GroupName;
        ?>
			<td>
				<a href="torrents.php?id=<?php 
        echo $GroupID;
        ?>
">
					<img class="tooltip" title="<?php 
        echo $Name;
        ?>
" src="<?php 
        echo ImageTools::process($C['WikiImage'], true);
Exemplo n.º 2
0
<?php

function compare($X, $Y)
{
    return $Y['count'] - $X['count'];
}
// Build the data for the collage and the torrent list
// TODO: Cache this
$DB->query("\n\tSELECT\n\t\tct.GroupID,\n\t\tct.UserID\n\tFROM collages_torrents AS ct\n\t\tJOIN torrents_group AS tg ON tg.ID = ct.GroupID\n\tWHERE ct.CollageID = '{$CollageID}'\n\tORDER BY ct.Sort");
$GroupIDs = $DB->collect('GroupID');
$Contributors = $DB->to_pair('GroupID', 'UserID', false);
if (count($GroupIDs) > 0) {
    $TorrentList = Torrents::get_groups($GroupIDs);
    $UserVotes = Votes::get_user_votes($LoggedUser['ID']);
} else {
    $TorrentList = array();
}
// Loop through the result set, building up $Collage and $TorrentTable
// Then we print them.
$Collage = array();
$TorrentTable = '';
$NumGroups = count($TorrentList);
$NumGroupsByUser = 0;
$TopArtists = array();
$UserAdditions = array();
$Number = 0;
foreach ($GroupIDs as $GroupID) {
    if (!isset($TorrentList[$GroupID])) {
        continue;
    }
    $Group = $TorrentList[$GroupID];
Exemplo n.º 3
0
<?php

if (!check_perms('site_torrents_notify')) {
    json_die("failure");
}
define('NOTIFICATIONS_PER_PAGE', 50);
list($Page, $Limit) = Format::page_limit(NOTIFICATIONS_PER_PAGE);
$Results = $DB->query("\n\t\tSELECT\n\t\t\tSQL_CALC_FOUND_ROWS\n\t\t\tunt.TorrentID,\n\t\t\tunt.UnRead,\n\t\t\tunt.FilterID,\n\t\t\tunf.Label,\n\t\t\tt.GroupID\n\t\tFROM users_notify_torrents AS unt\n\t\t\tJOIN torrents AS t ON t.ID = unt.TorrentID\n\t\t\tLEFT JOIN users_notify_filters AS unf ON unf.ID = unt.FilterID\n\t\tWHERE unt.UserID = {$LoggedUser['ID']}" . (!empty($_GET['filterid']) && is_number($_GET['filterid']) ? " AND unf.ID = '{$_GET['filterid']}'" : '') . "\n\t\tORDER BY TorrentID DESC\n\t\tLIMIT {$Limit}");
$GroupIDs = array_unique($DB->collect('GroupID'));
$DB->query('SELECT FOUND_ROWS()');
list($TorrentCount) = $DB->next_record();
if (count($GroupIDs)) {
    $TorrentGroups = Torrents::get_groups($GroupIDs);
    $DB->query("\n\t\tUPDATE users_notify_torrents\n\t\tSET UnRead = '0'\n\t\tWHERE UserID = {$LoggedUser['ID']}");
    $Cache->delete_value("notifications_new_{$LoggedUser['ID']}");
}
$DB->set_query_id($Results);
$JsonNotifications = array();
$NumNew = 0;
$FilterGroups = array();
while ($Result = $DB->next_record(MYSQLI_ASSOC)) {
    if (!$Result['FilterID']) {
        $Result['FilterID'] = 0;
    }
    if (!isset($FilterGroups[$Result['FilterID']])) {
        $FilterGroups[$Result['FilterID']] = array();
        $FilterGroups[$Result['FilterID']]['FilterLabel'] = $Result['Label'] ? $Result['Label'] : false;
    }
    array_push($FilterGroups[$Result['FilterID']], $Result);
}
unset($Result);
Exemplo n.º 4
0
// Get $Limit last quote notifications
// We deal with the information about torrents and requests later on...
$sql = "\n\tSELECT\n\t\tSQL_CALC_FOUND_ROWS\n\t\tq.Page,\n\t\tq.PageID,\n\t\tq.PostID,\n\t\tq.QuoterID,\n\t\tq.Date,\n\t\tq.UnRead,\n\t\tf.ID as ForumID,\n\t\tf.Name as ForumName,\n\t\tt.Title as ForumTitle,\n\t\ta.Name as ArtistName,\n\t\tc.Name as CollageName\n\tFROM users_notify_quoted AS q\n\t\tLEFT JOIN forums_topics AS t ON t.ID = q.PageID\n\t\tLEFT JOIN forums AS f ON f.ID = t.ForumID\n\t\tLEFT JOIN artists_group AS a ON a.ArtistID = q.PageID\n\t\tLEFT JOIN collages AS c ON c.ID = q.PageID\n\tWHERE q.UserID = {$LoggedUser['ID']}\n\t\tAND (q.Page != 'forums' OR " . Forums::user_forums_sql() . ")\n\t\tAND (q.Page != 'collages' OR c.Deleted = '0')\n\t\t{$UnreadSQL}\n\tORDER BY q.Date DESC\n\tLIMIT {$Limit}";
$DB->query($sql);
$Results = $DB->to_array(false, MYSQLI_ASSOC, false);
$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
$TorrentGroups = $Requests = array();
foreach ($Results as $Result) {
    if ($Result['Page'] == 'torrents') {
        $TorrentGroups[] = $Result['PageID'];
    } elseif ($Result['Page'] == 'requests') {
        $Requests[] = $Result['PageID'];
    }
}
$TorrentGroups = Torrents::get_groups($TorrentGroups, true, true, false);
$Requests = Requests::get_requests($Requests);
//Start printing page
View::show_header('Quote Notifications');
?>
<div class="thin">
	<div class="header">
		<h2>
			Quote notifications
			<?php 
echo $NumResults && !empty($UnreadSQL) ? " ({$NumResults} new)" : '';
?>
		</h2>
		<div class="linkbox pager">
			<br />
<?php 
Exemplo n.º 5
0
<?php

if (($Results = $Cache->get_value('better_single_groupids')) === false) {
    $DB->query("\n\t\tSELECT\n\t\t\tt.ID AS TorrentID,\n\t\t\tt.GroupID AS GroupID\n\t\tFROM xbt_files_users AS x\n\t\t\tJOIN torrents AS t ON t.ID=x.fid\n\t\tWHERE t.Format='FLAC'\n\t\tGROUP BY x.fid\n\t\tHAVING COUNT(x.uid) = 1\n\t\tORDER BY t.LogScore DESC, t.Time ASC\n\t\tLIMIT 30");
    $Results = $DB->to_pair('GroupID', 'TorrentID', false);
    $Cache->cache_value('better_single_groupids', $Results, 30 * 60);
}
$Groups = Torrents::get_groups(array_keys($Results));
$JsonResults = array();
foreach ($Results as $GroupID => $FlacID) {
    if (!isset($Groups[$GroupID])) {
        continue;
    }
    $Group = $Groups[$GroupID];
    extract(Torrents::array_group($Group));
    $JsonArtists = array();
    if (count($Artists) > 0) {
        foreach ($Artists as $Artist) {
            $JsonArtists[] = array('id' => (int) $Artist['id'], 'name' => $Artist['name'], 'aliasId' => (int) $Artist['aliasid']);
        }
    }
    $JsonResults[] = array('torrentId' => (int) $FlacID, 'groupId' => (int) $GroupID, 'artist' => $JsonArtists, 'groupName' => $GroupName, 'groupYear' => (int) $GroupYear, 'downloadUrl' => "torrents.php?action=download&id={$FlacID}&authkey=" . $LoggedUser['AuthKey'] . '&torrent_pass='******'torrent_pass']);
}
print json_encode(array('status' => 'success', 'response' => $JsonResults));
Exemplo n.º 6
0
<?php

$GroupID = $_GET['groupid'];
if (!is_number($GroupID)) {
    error(404);
}
View::show_header("History for Group {$GroupID}");
$Groups = Torrents::get_groups(array($GroupID), true, true, false);
if (!empty($Groups[$GroupID])) {
    $Group = $Groups[$GroupID];
    $Title = Artists::display_artists($Group['ExtendedArtists']) . '<a href="torrents.php?id=' . $GroupID . '">' . $Group['Name'] . '</a>';
} else {
    $Title = "Group {$GroupID}";
}
?>

<div class="thin">
	<div class="header">
		<h2>History for <?php 
echo $Title;
?>
</h2>
	</div>
	<table>
		<tr class="colhead">
			<td>Date</td>
			<td>Torrent</td>
			<td>User</td>
			<td>Info</td>
		</tr>
<?php 
Exemplo n.º 7
0
<?php

$TorrentID = (int) $_GET['torrentid'];
$DB->query("\n\tSELECT last_action, LastReseedRequest, UserID, Time, GroupID\n\tFROM torrents\n\tWHERE ID = '{$TorrentID}'");
list($LastActive, $LastReseedRequest, $UploaderID, $UploadedTime, $GroupID) = $DB->next_record();
if (!check_perms('users_mod')) {
    if (time() - strtotime($LastReseedRequest) < 864000) {
        error('There was already a re-seed request for this torrent within the past 10 days.');
    }
    if ($LastActive == '0000-00-00 00:00:00' || time() - strtotime($LastActive) < 345678) {
        error(403);
    }
}
$DB->query("\n\tUPDATE torrents\n\tSET LastReseedRequest = NOW()\n\tWHERE ID = '{$TorrentID}'");
$Group = Torrents::get_groups(array($GroupID));
extract(Torrents::array_group($Group[$GroupID]));
$Name = Artists::display_artists(array('1' => $Artists), false, true);
$Name .= $GroupName;
$usersToNotify = array();
$DB->query("\n\tSELECT s.uid AS id, MAX(s.tstamp) AS tstamp\n\tFROM xbt_snatched as s\n\tINNER JOIN users_main as u\n\tON s.uid = u.ID\n\tWHERE s.fid = '{$TorrentID}'\n\tAND u.Enabled = '1'\n\tGROUP BY s.uid\n       ORDER BY tstamp DESC\n\tLIMIT 100");
if ($DB->has_results()) {
    $Users = $DB->to_array();
    foreach ($Users as $User) {
        $UserID = $User['id'];
        $TimeStamp = $User['tstamp'];
        $usersToNotify[$UserID] = array("snatched", $TimeStamp);
    }
}
$usersToNotify[$UploaderID] = array("uploaded", strtotime($UploadedTime));
foreach ($usersToNotify as $UserID => $info) {
    $Username = Users::user_info($UserID)['Username'];
Exemplo n.º 8
0
    $Cache->delete_value('torrents_details_' . $GroupID);
}
if (!empty($_GET['filter']) && $_GET['filter'] == 'all') {
    $Join = '';
    $All = true;
} else {
    $Join = "JOIN xbt_snatched AS x ON x.fid = tbt.TorrentID AND x.uid = " . $LoggedUser['ID'];
    $All = false;
}
View::show_header('Torrents with bad tags');
$DB->query("\n\tSELECT tbt.TorrentID, t.GroupID\n\tFROM torrents_bad_tags AS tbt\n\t\tJOIN torrents AS t ON t.ID = tbt.TorrentID\n\t\t{$Join}\n\tORDER BY tbt.TimeAdded ASC");
$TorrentsInfo = $DB->to_array('TorrentID', MYSQLI_ASSOC);
foreach ($TorrentsInfo as $Torrent) {
    $GroupIDs[] = $Torrent['GroupID'];
}
$Results = Torrents::get_groups($GroupIDs);
?>
<div class="header">
<?php 
if ($All) {
    ?>
		<h2>All torrents trumpable for bad tags</h2>
<?php 
} else {
    ?>
		<h2>Torrents trumpable for bad tags that you have snatched</h2>
<?php 
}
?>

	<div class="linkbox">
Exemplo n.º 9
0
 /**
  * Returns an array with User Bookmark data: group IDs, collage data, torrent data
  * @param string|int $UserID
  * @return array Group IDs, Bookmark Data, Torrent List
  */
 public static function get_bookmarks($UserID)
 {
     $UserID = (int) $UserID;
     if ($Data = G::$Cache->get_value("bookmarks_group_ids_{$UserID}")) {
         list($GroupIDs, $BookmarkData) = $Data;
     } else {
         $QueryID = G::$DB->get_query_id();
         G::$DB->query("\n\t\t\t\tSELECT GroupID, Sort, `Time`\n\t\t\t\tFROM bookmarks_torrents\n\t\t\t\tWHERE UserID = {$UserID}\n\t\t\t\tORDER BY Sort, `Time` ASC");
         $GroupIDs = G::$DB->collect('GroupID');
         $BookmarkData = G::$DB->to_array('GroupID', MYSQLI_ASSOC);
         G::$DB->set_query_id($QueryID);
         G::$Cache->cache_value("bookmarks_group_ids_{$UserID}", array($GroupIDs, $BookmarkData), 3600);
     }
     $TorrentList = Torrents::get_groups($GroupIDs);
     return array($GroupIDs, $BookmarkData, $TorrentList);
 }
Exemplo n.º 10
0
 $Debug->set_flag('SELECTed ' . $_GET['filter'] . ' torrents');
 $Snatched = $DB->to_array();
 $Debug->set_flag('Received data from DB');
 shuffle($Snatched);
 // randomize results
 while ($ResultCount < TORRENTS_PER_PAGE && count($Snatched) > 0) {
     // we throw TORRENTS_PER_PAGE results into Sphinx until we have at least TORRENTS_PER_PAGE results (or no snatches left)
     $SnatchedTmp = array_slice($Snatched, 0, TORRENTS_PER_PAGE);
     $Snatched = array_slice($Snatched, TORRENTS_PER_PAGE);
     $SphQL = transcode_init_sphql();
     $SphQL->where('groupid', array_map(function ($row) {
         return $row['GroupID'];
     }, $SnatchedTmp));
     $SphQLResult = $SphQL->query();
     $ResultsTmp = $SphQLResult->collect('groupid');
     $GroupsTmp = Torrents::get_groups(array_values($ResultsTmp));
     $GroupsTmp = transcode_parse_groups($GroupsTmp);
     // Since we're asking Sphinxql about groups and remidents, the result can/will contain different editions that are transcodable but weren't snatched, so let's filter them out
     foreach ($GroupsTmp as $GroupID => $Group) {
         foreach ($Group['Editions'] as $RemIdent => $Edition) {
             $EditionSnatched = false;
             foreach ($SnatchedTmp as $SnatchedTmpE) {
                 if (isset($Edition['FlacIDs'][$SnatchedTmpE['fid']])) {
                     $EditionSnatched = true;
                     break;
                 }
             }
             if (!$EditionSnatched || count($Edition['MP3s']) === 3) {
                 unset($GroupsTmp[$GroupID]['Editions'][$RemIdent]);
             }
         }
Exemplo n.º 11
0
    }
}
$NumRequests = count($Requests);
if (($Importances = $Cache->get_value("artist_groups_{$ArtistID}")) === false) {
    $DB->query("\n\t\tSELECT\n\t\t\tDISTINCTROW ta.GroupID, ta.Importance, tg.VanityHouse, tg.Year\n\t\tFROM torrents_artists AS ta\n\t\t\tJOIN torrents_group AS tg ON tg.ID = ta.GroupID\n\t\tWHERE ta.ArtistID = '{$ArtistID}'\n\t\tORDER BY tg.Year DESC, tg.Name DESC");
    $GroupIDs = $DB->collect('GroupID');
    $Importances = $DB->to_array(false, MYSQLI_BOTH, false);
    $Cache->cache_value("artist_groups_{$ArtistID}", $Importances, 0);
} else {
    $GroupIDs = array();
    foreach ($Importances as $Group) {
        $GroupIDs[] = $Group['GroupID'];
    }
}
if (count($GroupIDs) > 0) {
    $TorrentList = Torrents::get_groups($GroupIDs, true, true);
} else {
    $TorrentList = array();
}
$NumGroups = count($TorrentList);
//Get list of used release types
$UsedReleases = array();
foreach ($TorrentList as $GroupID => $Group) {
    if ($Importances[$GroupID]['Importance'] == '2') {
        $TorrentList[$GroupID]['ReleaseType'] = 1024;
        $GuestAlbums = true;
    }
    if ($Importances[$GroupID]['Importance'] == '3') {
        $TorrentList[$GroupID]['ReleaseType'] = 1023;
        $RemixerAlbums = true;
    }
Exemplo n.º 12
0
$EncodingKeys = array_fill_keys($Encodings, true);
// Get list of FLAC uploads
$DB->query("\n\tSELECT t.GroupID, t.ID\n\tFROM torrents AS t\n\t\tJOIN torrents_group AS tg ON tg.ID = t.GroupID\n\tWHERE t.Format='FLAC'\n\t\tAND ((t.LogScore = '100' AND t.Media = 'CD')\n\t\t\tOR t.Media != 'CD')\n\t\tAND tg.CategoryID = 1\n\t\tAND t.UserID = '{$UserID}'");
$UploadedTorrentIDs = array_fill_keys($DB->collect('ID'), true);
$UploadedGroupIDs = $DB->collect('GroupID');
if (count($UploadedGroupIDs) === 0) {
    error("You haven't uploaded any perfect FLACs!");
}
// Create hash table
$DB->query("\n\tCREATE TEMPORARY TABLE temp_sections_better_upload\n\tSELECT\n\t\tGroupID,\n\t\tGROUP_CONCAT(Encoding SEPARATOR ' ') AS EncodingList,\n\t\tCRC32(CONCAT_WS(\n\t\t\t' ', Media, Remasteryear, Remastertitle,\n\t\t\tRemasterrecordlabel, Remastercataloguenumber)\n\t\t) AS RemIdent\n\tFROM torrents\n\tWHERE GroupID IN (" . implode(',', $UploadedGroupIDs) . ")\n\t\tAND Format IN ('FLAC', 'MP3')\n\tGROUP BY GroupID, RemIdent");
$DB->query("\n\tSELECT GroupID\n\tFROM temp_sections_better_upload\n\tWHERE EncodingList NOT LIKE '%V0 (VBR)%'\n\t\tOR EncodingList NOT LIKE '%V2 (VBR)%'\n\t\tOR EncodingList NOT LIKE '%320%'");
$GroupIDs = array_fill_keys($DB->collect('GroupID'), true);
if (count($GroupIDs) === 0) {
    error('No results found.');
}
$Groups = Torrents::get_groups(array_keys($GroupIDs));
$TorrentGroups = array();
foreach ($Groups as $GroupID => $Group) {
    if (empty($Group['Torrents'])) {
        unset($Groups[$GroupID]);
        continue;
    }
    foreach ($Group['Torrents'] as $Torrent) {
        $TorRemIdent = "{$Torrent['Media']} {$Torrent['RemasterYear']} {$Torrent['RemasterTitle']} {$Torrent['RemasterRecordLabel']} {$Torrent['RemasterCatalogueNumber']}";
        if (!isset($TorrentGroups[$Group['ID']])) {
            $TorrentGroups[$Group['ID']] = array($TorRemIdent => array('FlacID' => 0, 'Formats' => array(), 'IsSnatched' => $Torrent['IsSnatched'], 'Medium' => $Torrent['Media'], 'RemasterTitle' => $Torrent['RemasterTitle'], 'RemasterYear' => $Torrent['RemasterYear'], 'RemasterRecordLabel' => $Torrent['RemasterRecordLabel'], 'RemasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber']));
        } elseif (!isset($TorrentGroups[$Group['ID']][$TorRemIdent])) {
            $TorrentGroups[$Group['ID']][$TorRemIdent] = array('FlacID' => 0, 'Formats' => array(), 'IsSnatched' => $Torrent['IsSnatched'], 'Medium' => $Torrent['Media'], 'RemasterTitle' => $Torrent['RemasterTitle'], 'RemasterYear' => $Torrent['RemasterYear'], 'RemasterRecordLabel' => $Torrent['RemasterRecordLabel'], 'RemasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber']);
        }
        if ($Torrent['Format'] == 'MP3' && isset($EncodingKeys[$Torrent['Encoding']])) {
            $TorrentGroups[$Group['ID']][$TorRemIdent]['Formats'][$Torrent['Encoding']] = true;
Exemplo n.º 13
0
 private static function to_html($Array)
 {
     global $SSL;
     self::$Levels++;
     /*
      * Hax prevention
      * That's the original comment on this.
      * Most likely this was implemented to avoid anyone nesting enough
      * elements to reach PHP's memory limit as nested elements are
      * solved recursively.
      * Original value of 10, it is now replaced in favor of
      * $MaximumNests.
      * If this line is ever executed then something is, infact
      * being haxed as the if before the block type switch for different
      * tags should always be limiting ahead of this line.
      * (Larger than vs. smaller than.)
      */
     if (self::$Levels > self::$MaximumNests) {
         return $Block['Val'];
         // Hax prevention, breaks upon exceeding nests.
     }
     $Str = '';
     foreach ($Array as $Block) {
         if (is_string($Block)) {
             $Str .= self::smileys($Block);
             continue;
         }
         if (self::$Levels < self::$MaximumNests) {
             switch ($Block['Type']) {
                 case 'b':
                     $Str .= '<strong>' . self::to_html($Block['Val']) . '</strong>';
                     break;
                 case 'u':
                     $Str .= '<span style="text-decoration: underline;">' . self::to_html($Block['Val']) . '</span>';
                     break;
                 case 'i':
                     $Str .= '<span style="font-style: italic;">' . self::to_html($Block['Val']) . "</span>";
                     break;
                 case 's':
                     $Str .= '<span style="text-decoration: line-through;">' . self::to_html($Block['Val']) . '</span>';
                     break;
                 case 'important':
                     $Str .= '<strong class="important_text">' . self::to_html($Block['Val']) . '</strong>';
                     break;
                 case 'user':
                     $Str .= '<a href="user.php?action=search&amp;search=' . urlencode($Block['Val']) . '">' . $Block['Val'] . '</a>';
                     break;
                 case 'artist':
                     $Str .= '<a href="artist.php?artistname=' . urlencode(Format::undisplay_str($Block['Val'])) . '">' . $Block['Val'] . '</a>';
                     break;
                 case 'rule':
                     $Rule = trim(strtolower($Block['Val']));
                     if ($Rule[0] != 'r' && $Rule[0] != 'h') {
                         $Rule = 'r' . $Rule;
                     }
                     $Str .= '<a href="rules.php?p=upload#' . urlencode(Format::undisplay_str($Rule)) . '">' . preg_replace('/[aA-zZ]/', '', $Block['Val']) . '</a>';
                     break;
                 case 'torrent':
                     $Pattern = '/(' . NONSSL_SITE_URL . '\\/torrents\\.php.*[\\?&]id=)?(\\d+)($|&|\\#).*/i';
                     $Matches = array();
                     if (preg_match($Pattern, $Block['Val'], $Matches)) {
                         if (isset($Matches[2])) {
                             $GroupID = $Matches[2];
                             $Groups = Torrents::get_groups(array($GroupID), true, true, false);
                             if ($Groups[$GroupID]) {
                                 $Group = $Groups[$GroupID];
                                 $Str .= Artists::display_artists($Group['ExtendedArtists']) . '<a href="torrents.php?id=' . $GroupID . '">' . $Group['Name'] . '</a>';
                             } else {
                                 $Str .= '[torrent]' . str_replace('[inlineurl]', '', $Block['Val']) . '[/torrent]';
                             }
                         }
                     } else {
                         $Str .= '[torrent]' . str_replace('[inlineurl]', '', $Block['Val']) . '[/torrent]';
                     }
                     break;
                 case 'wiki':
                     $Str .= '<a href="wiki.php?action=article&amp;name=' . urlencode($Block['Val']) . '">' . $Block['Val'] . '</a>';
                     break;
                 case 'tex':
                     $Str .= '<img style="vertical-align: middle;" src="' . STATIC_SERVER . 'blank.gif" onload="if (this.src.substr(this.src.length - 9, this.src.length) == \'blank.gif\') { this.src = \'https://chart.googleapis.com/chart?cht=tx&amp;chf=bg,s,FFFFFF00&amp;chl=' . urlencode(mb_convert_encoding($Block['Val'], 'UTF-8', 'HTML-ENTITIES')) . '&amp;chco=\' + hexify(getComputedStyle(this.parentNode, null).color); }" alt="' . $Block['Val'] . '" />';
                     break;
                 case 'plain':
                     $Str .= $Block['Val'];
                     break;
                 case 'pre':
                     $Str .= '<pre>' . $Block['Val'] . '</pre>';
                     break;
                 case 'code':
                     $Str .= '<code>' . $Block['Val'] . '</code>';
                     break;
                 case 'list':
                     $Str .= "<{$Block['ListType']} class=\"postlist\">";
                     foreach ($Block['Val'] as $Line) {
                         $Str .= '<li>' . self::to_html($Line) . '</li>';
                     }
                     $Str .= '</' . $Block['ListType'] . '>';
                     break;
                 case 'align':
                     $ValidAttribs = array('left', 'center', 'right');
                     if (!in_array($Block['Attr'], $ValidAttribs)) {
                         $Str .= '[align=' . $Block['Attr'] . ']' . self::to_html($Block['Val']) . '[/align]';
                     } else {
                         $Str .= '<div style="text-align: ' . $Block['Attr'] . ';">' . self::to_html($Block['Val']) . '</div>';
                     }
                     break;
                 case 'color':
                 case 'colour':
                     $ValidAttribs = array('aqua', 'black', 'blue', 'fuchsia', 'green', 'grey', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow');
                     if (!in_array($Block['Attr'], $ValidAttribs) && !preg_match('/^#[0-9a-f]{6}$/', $Block['Attr'])) {
                         $Str .= '[color=' . $Block['Attr'] . ']' . self::to_html($Block['Val']) . '[/color]';
                     } else {
                         $Str .= '<span style="color: ' . $Block['Attr'] . ';">' . self::to_html($Block['Val']) . '</span>';
                     }
                     break;
                 case 'headline':
                     $text = self::to_html($Block['Val']);
                     $raw = self::raw_text($Block['Val']);
                     if (!in_array($Block['Attr'], self::$HeadlineLevels)) {
                         $Str .= sprintf('%1$s%2$s%1$s', str_repeat('=', $Block['Attr'] + 1), $text);
                     } else {
                         $id = '_' . crc32($raw . self::$HeadlineID);
                         if (self::$InQuotes === 0) {
                             self::$Headlines[] = array($Block['Attr'], $raw, $id);
                         }
                         $Str .= sprintf('<h%1$d id="%3$s">%2$s</h%1$d>', $Block['Attr'] + 2, $text, $id);
                         self::$HeadlineID++;
                     }
                     break;
                 case 'inlinesize':
                 case 'size':
                     $ValidAttribs = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10');
                     if (!in_array($Block['Attr'], $ValidAttribs)) {
                         $Str .= '[size=' . $Block['Attr'] . ']' . self::to_html($Block['Val']) . '[/size]';
                     } else {
                         $Str .= '<span class="size' . $Block['Attr'] . '">' . self::to_html($Block['Val']) . '</span>';
                     }
                     break;
                 case 'quote':
                     self::$NoImg++;
                     // No images inside quote tags
                     self::$InQuotes++;
                     if (self::$InQuotes == self::$NestsBeforeHide) {
                         //Put quotes that are nested beyond the specified limit in [hide] tags.
                         $Str .= '<strong>Older quotes</strong>: <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>';
                         $Str .= '<blockquote class="hidden spoiler">';
                     }
                     if (!empty($Block['Attr'])) {
                         $Exploded = explode('|', self::to_html($Block['Attr']));
                         if (isset($Exploded[1]) && (is_numeric($Exploded[1]) || in_array($Exploded[1][0], array('a', 't', 'c', 'r')) && is_numeric(substr($Exploded[1], 1)))) {
                             // the part after | is either a number or starts with a, t, c or r, followed by a number (forum post, artist comment, torrent comment, collage comment or request comment, respectively)
                             $PostID = trim($Exploded[1]);
                             $Str .= '<a href="#" onclick="QuoteJump(event, \'' . $PostID . '\'); return false;"><strong class="quoteheader">' . $Exploded[0] . '</strong> wrote: </a>';
                         } else {
                             $Str .= '<strong class="quoteheader">' . $Exploded[0] . '</strong> wrote: ';
                         }
                     }
                     $Str .= '<blockquote>' . self::to_html($Block['Val']) . '</blockquote>';
                     if (self::$InQuotes == self::$NestsBeforeHide) {
                         //Close quote the deeply nested quote [hide].
                         $Str .= '</blockquote><br />';
                         // Ensure new line after quote train hiding
                     }
                     self::$NoImg--;
                     self::$InQuotes--;
                     break;
                 case 'hide':
                     $Str .= '<strong>' . ($Block['Attr'] ? $Block['Attr'] : 'Hidden text') . '</strong>: <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>';
                     $Str .= '<blockquote class="hidden spoiler">' . self::to_html($Block['Val']) . '</blockquote>';
                     break;
                 case 'mature':
                     if (G::$LoggedUser['EnableMatureContent']) {
                         if (!empty($Block['Attr'])) {
                             $Str .= '<strong class="mature" style="font-size: 1.2em;">Mature content:</strong><strong> ' . $Block['Attr'] . '</strong><br /> <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>';
                             $Str .= '<blockquote class="hidden spoiler">' . self::to_html($Block['Val']) . '</blockquote>';
                         } else {
                             $Str .= '<strong>Use of the [mature] tag requires a description.</strong> The correct format is as follows: <strong>[mature=description] ...content... [/mature]</strong>, where "description" is a mandatory description of the post. Misleading descriptions will be penalized. For further information on our mature content policies, please refer to this <a href="wiki.php?action=article&amp;id=1063">wiki</a>.';
                         }
                     } else {
                         $Str .= '<span class="mature_blocked" style="font-style: italic;"><a href="wiki.php?action=article&amp;id=1063">Mature content</a> has been blocked. You can choose to view mature content by editing your <a href="user.php?action=edit&amp;userid=' . G::$LoggedUser['ID'] . '">settings</a>.</span>';
                     }
                     break;
                 case 'img':
                     if (self::$NoImg > 0 && self::valid_url($Block['Val'])) {
                         $Str .= '<a rel="noreferrer" target="_blank" href="' . $Block['Val'] . '">' . $Block['Val'] . '</a> (image)';
                         break;
                     }
                     if (!self::valid_url($Block['Val'], '\\.(jpe?g|gif|png|bmp|tiff)')) {
                         $Str .= '[img]' . $Block['Val'] . '[/img]';
                     } else {
                         $LocalURL = self::local_url($Block['Val']);
                         if ($LocalURL) {
                             $Str .= '<img class="scale_image" onclick="lightbox.init(this, $(this).width());" alt="' . $Block['Val'] . '" src="' . $LocalURL . '" />';
                         } else {
                             $Str .= '<img class="scale_image" onclick="lightbox.init(this, $(this).width());" alt="' . $Block['Val'] . '" src="' . ImageTools::process($Block['Val']) . '" />';
                         }
                     }
                     break;
                 case 'aud':
                     if (self::$NoImg > 0 && self::valid_url($Block['Val'])) {
                         $Str .= '<a rel="noreferrer" target="_blank" href="' . $Block['Val'] . '">' . $Block['Val'] . '</a> (audio)';
                         break;
                     }
                     if (!self::valid_url($Block['Val'], '\\.(mp3|ogg|wav)')) {
                         $Str .= '[aud]' . $Block['Val'] . '[/aud]';
                     } else {
                         //TODO: Proxy this for staff?
                         $Str .= '<audio controls="controls" src="' . $Block['Val'] . '"><a rel="noreferrer" target="_blank" href="' . $Block['Val'] . '">' . $Block['Val'] . '</a></audio>';
                     }
                     break;
                 case 'url':
                     // Make sure the URL has a label
                     if (empty($Block['Val'])) {
                         $Block['Val'] = $Block['Attr'];
                         $NoName = true;
                         // If there isn't a Val for this
                     } else {
                         $Block['Val'] = self::to_html($Block['Val']);
                         $NoName = false;
                     }
                     if (!self::valid_url($Block['Attr'])) {
                         $Str .= '[url=' . $Block['Attr'] . ']' . $Block['Val'] . '[/url]';
                     } else {
                         $LocalURL = self::local_url($Block['Attr']);
                         if ($LocalURL) {
                             if ($NoName) {
                                 $Block['Val'] = substr($LocalURL, 1);
                             }
                             $Str .= '<a href="' . $LocalURL . '">' . $Block['Val'] . '</a>';
                         } else {
                             $Str .= '<a rel="noreferrer" target="_blank" href="' . $Block['Attr'] . '">' . $Block['Val'] . '</a>';
                         }
                     }
                     break;
                 case 'inlineurl':
                     if (!self::valid_url($Block['Attr'], '', true)) {
                         $Array = self::parse($Block['Attr']);
                         $Block['Attr'] = $Array;
                         $Str .= self::to_html($Block['Attr']);
                     } else {
                         $LocalURL = self::local_url($Block['Attr']);
                         if ($LocalURL) {
                             $Str .= '<a href="' . $LocalURL . '">' . substr($LocalURL, 1) . '</a>';
                         } else {
                             $Str .= '<a rel="noreferrer" target="_blank" href="' . $Block['Attr'] . '">' . $Block['Attr'] . '</a>';
                         }
                     }
                     break;
             }
         }
     }
     self::$Levels--;
     return $Str;
 }
Exemplo n.º 14
0
 /**
  * Get torrent group info and remove any torrents that don't match
  */
 private function process_results()
 {
     if (count($this->SphResults) == 0) {
         return;
     }
     $this->Groups = Torrents::get_groups($this->SphResults);
     if ($this->need_torrent_ft()) {
         // Query Sphinx for torrent IDs if torrent-specific fulltext filters were used
         $this->filter_torrents_sph();
     } elseif ($this->GroupResults) {
         // Otherwise, let PHP discard unmatching torrents
         $this->filter_torrents_internal();
     }
     // Ungrouped searches don't need any additional filtering
 }