Ejemplo n.º 1
0
function transcode_init_sphql()
{
    // Initializes a basic SphinxqlQuery object
    $SphQL = new SphinxqlQuery();
    $SphQL->select('groupid')->from('better_transcode')->where('logscore', 100)->where_match('FLAC', 'format')->order_by('RAND()')->limit(0, TORRENTS_PER_PAGE, TORRENTS_PER_PAGE);
    if (in_array($_GET['target'], array('v0', 'v2', '320'))) {
        // V0/V2/320 is missing
        $SphQL->where_match('!' . $_GET['target'], 'encoding', false);
    } elseif ($_GET['target'] === 'all') {
        // all transcodes are missing
        $SphQL->where_match('!(v0 | v2 | 320)', 'encoding', false);
    } else {
        // any transcode is missing
        $SphQL->where_match('!(v0 v2 320)', 'encoding', false);
    }
    if (!empty($_GET['search'])) {
        $SphQL->where_match($_GET['search'], '(groupname,artistname,year,taglist)');
    }
    return $SphQL;
}
Ejemplo n.º 2
0
			</div>
			<div id="invitetree" class="hidden">
<?php 
    $Tree->make_tree();
    ?>
			</div>
		</div>
<?php 
}
if (check_perms('users_mod')) {
    DonationsView::render_donation_history(Donations::get_donation_history($UserID));
}
// Requests
if (empty($LoggedUser['DisableRequests']) && check_paranoia_here('requestsvoted_list')) {
    $SphQL = new SphinxqlQuery();
    $SphQLResult = $SphQL->select('id, votes, bounty')->from('requests, requests_delta')->where('userid', $UserID)->where('torrentid', 0)->order_by('votes', 'desc')->order_by('bounty', 'desc')->limit(0, 100, 100)->query();
    if ($SphQLResult->has_results()) {
        $SphRequests = $SphQLResult->to_array('id', MYSQLI_ASSOC);
        ?>
		<div class="box" id="requests_box">
			<div class="head">
				Requests <a href="#" onclick="$('#requests').gtoggle(); return false;" class="brackets">View</a>
			</div>
			<div id="requests" class="request_table hidden">
				<table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">
					<tr class="colhead_dark">
						<td style="width: 48%;">
							<strong>Request Name</strong>
						</td>
						<td>
							<strong>Vote</strong>
Ejemplo n.º 3
0
<?php

$SphQL = new SphinxqlQuery();
$SphQL->select('id, votes, bounty')->from('requests, requests_delta');
$SortOrders = array('votes' => 'votes', 'bounty' => 'bounty', 'lastvote' => 'lastvote', 'filled' => 'timefilled', 'year' => 'year', 'created' => 'timeadded', 'random' => false);
if (empty($_GET['order']) || !isset($SortOrders[$_GET['order']])) {
    $_GET['order'] = 'created';
}
$OrderBy = $_GET['order'];
if (!empty($_GET['sort']) && $_GET['sort'] === 'asc') {
    $OrderWay = 'asc';
} else {
    $_GET['sort'] = 'desc';
    $OrderWay = 'desc';
}
$NewSort = $_GET['sort'] === 'asc' ? 'desc' : 'asc';
if ($OrderBy === 'random') {
    $SphQL->order_by('RAND()', '');
    unset($_GET['page']);
} else {
    $SphQL->order_by($SortOrders[$OrderBy], $OrderWay);
}
$Submitted = !empty($_GET['submit']);
//Paranoia
if (!empty($_GET['userid'])) {
    if (!is_number($_GET['userid'])) {
        error('User ID must be an integer');
    }
    $UserInfo = Users::user_info($_GET['userid']);
    if (empty($UserInfo)) {
        error('That user does not exist');
Ejemplo n.º 4
0
}
/** End preparation of property arrays **/
/** Start query preparation **/
$SphQL = new SphinxqlQuery();
$SphQLTor = new SphinxqlQuery();
if ($OrderBy == 'random') {
    $SphQL->select('id, groupid, categoryid')->order_by('RAND()', '');
    $Random = true;
} elseif ($GroupResults) {
    $OrderProperties = $SortOrders[$OrderBy];
    $SphQL->select('groupid, categoryid' . (isset($AggregateExp[$OrderProperties[0]]) ? ', ' . $AggregateExp[$OrderProperties[0]] : ''))->group_by('groupid')->order_by($OrderProperties[0], $OrderWay)->order_group_by($OrderProperties[1], $OrderWay);
} else {
    $SphQL->select('id, groupid, categoryid')->order_by($SortOrders[$OrderBy], $OrderWay);
}
$SphQL->from('torrents, delta');
$SphQLTor->select('id, groupid')->from('torrents, delta');
/** End query preparation **/
/** Start building search query **/
$Filtered = false;
$EnableNegation = false;
// Sphinx needs at least one positive search condition to support the NOT operator
// File list searches make use of the proximity operator to ensure that all keywords match the same file
if (!empty($_GET['filelist'])) {
    $SearchString = trim($_GET['filelist']);
    if ($SearchString !== '') {
        $SearchString = '"' . Sphinxql::sph_escape_string($_GET['filelist']) . '"~20';
        $SphQL->where_match($SearchString, 'filelist', false);
        $SphQLTor->where_match($SearchString, 'filelist', false);
        $EnableNegation = true;
    }
}
Ejemplo n.º 5
0
if (!isset($_GET['type']) || !is_number($_GET['type']) || $_GET['type'] > 3) {
    error(0);
}
$Options = array('v0', 'v2', '320');
$Encodings = array('V0 (VBR)', 'V2 (VBR)', '320');
$EncodingKeys = array_fill_keys($Encodings, true);
if ($_GET['type'] === '3') {
    $List = "!(v0 | v2 | 320)";
} else {
    $List = '!' . $Options[$_GET['type']];
    if ($_GET['type'] !== '0') {
        $_GET['type'] = display_str($_GET['type']);
    }
}
$SphQL = new SphinxqlQuery();
$SphQL->select('id, groupid')->from('better_transcode')->where('logscore', 100)->where_match('FLAC', 'format')->where_match($List, 'encoding', false)->order_by('RAND()')->limit(0, TORRENTS_PER_PAGE, TORRENTS_PER_PAGE);
if (!empty($_GET['search'])) {
    $SphQL->where_match($_GET['search'], '(groupname,artistname,year,taglist)');
}
$SphQLResult = $SphQL->query();
$TorrentCount = $SphQLResult->get_meta('total');
if ($TorrentCount == 0) {
    error('No results found!');
}
$Results = $SphQLResult->to_array('groupid');
$Groups = Torrents::get_groups(array_keys($Results));
$TorrentGroups = array();
foreach ($Groups as $GroupID => $Group) {
    if (empty($Group['Torrents'])) {
        unset($Groups[$GroupID]);
        continue;
Ejemplo n.º 6
0
    if (!$NumResults) {
        $TotalMatches = 0;
    } elseif ($NumResults == LOG_ENTRIES_PER_PAGE) {
        // This is a lot faster than SQL_CALC_FOUND_ROWS
        $SphQL = new SphinxqlQuery();
        $Result = $SphQL->select('id')->from('log, log_delta')->limit(0, 1, 1)->query();
        $Debug->log_var($Result, '$Result');
        $TotalMatches = min(SPHINX_MAX_MATCHES, $Result->get_meta('total_found'));
    } else {
        $TotalMatches = $NumResults + $Offset;
    }
    $QueryStatus = 0;
} else {
    $Page = min(SPHINX_MAX_MATCHES / TORRENTS_PER_PAGE, $Page);
    $SphQL = new SphinxqlQuery();
    $SphQL->select('id')->from('log, log_delta')->where_match($_GET['search'], 'message')->order_by('id', 'DESC')->limit($Offset, LOG_ENTRIES_PER_PAGE, $Offset + LOG_ENTRIES_PER_PAGE);
    $Result = $SphQL->query();
    $Debug->log_var($Result, '$Result');
    $Debug->set_flag('Finished SphQL query');
    if ($QueryStatus = $Result->Errno) {
        $QueryError = $Result->Error;
    }
    $NumResults = $Result->get_result_info('num_rows');
    $TotalMatches = min(SPHINX_MAX_MATCHES, $Result->get_meta('total_found'));
    if ($NumResults > 0) {
        $LogIDs = $Result->collect('id');
        $Log = $DB->query('
			SELECT ID, Message, Time
			FROM log
			WHERE ID IN (' . implode(',', $LogIDs) . ')
			ORDER BY ID DESC');