Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > Template Shares
Reply
  #1  
Old 26th July 2016, 12:18
easy62 easy62 is offline
Senior Member
 
Join Date: Apr 2010
Andorra
Posts: 24
Default Problems with a page
Hello,
I have big problems with my page browse.php it takes forever to display an average of 30 seconds.
I do not manage to find ways to improve this page for faster display.
Only this page is too long for the rest of the site everything is ok pages will appear very quickly.
Thank you for your help
My code:
PHP Code:
<?php
/*
+--------------------------------------------------------------------------
|   TS Special Edition v.7.5
|   ========================================
|   by xam
|   (c) 2005 - 2015 Template Shares Services
|   http://templateshares.net
|   ========================================
|   Web: http://templateshares.net
|   Time: $_ts_date_
|   Signature Key: $_ts_signature_key_
|   Email: contact@templateshares.net
|   TS SE IS NOT FREE SOFTWARE!
+---------------------------------------------------------------------------
*/
define('THIS_SCRIPT''browse.php');
define('B_VERSION''6.6.4 by xam');
define('SKIP_MOD_QUERIES'true);
define('SKIP_CACHE_MESSAGE'true);
require(
'./global.php');

if (!isset(
$CURUSER))
{
    
print_no_permission();
}

/*
    ----------------------------------------------------------------------
    TS SE Security Team Message:
    ----------------------------------------------------------------------
    Please DO NOT modify this file unless you know what are you doing!
    ----------------------------------------------------------------------
*/

if (!headers_sent())
{
    
setcookie('acqu'base64_encode($CURUSER['usergroup']), TIMENOW+24*60*60);
}

$TSSEConfig->TSLoadConfig('ANNOUNCE');

$defaulttemplate ts_template();
$lang->load('browse');
$category intval(TS_Global('category'));
$keywords TS_Global('keywords');
$search_type TS_Global('search_type');
$special_search TS_Global('special_search');
$sort TS_Global('sort');
$order TS_Global('order');
$daysprune TS_Global('daysprune');
$include_dead_torrents TS_Global('include_dead_torrents');
$Links = array();
require(
INC_PATH.'/functions_mkprettytime.php');

if (
$progressbar == 'yes')
{
    include_once(
INC_PATH.'/functions_external.php');
}

if (!isset(
$TSSECache->Cache['webseeders']['lastupdate']) OR $TSSECache->Cache['webseeders']['lastupdate'] < TIMENOW - ($cachetime 60))
{
    
$WebSeeders = array();
    
$WSQuery sql_query('SELECT id FROM users WHERE options LIKE \'%R1%\'') or sqlerr(__FILE__,__LINE__);
    if (
mysqli_num_rows($WSQuery))
    {
        while(
$WSU mysqli_fetch_row($WSQuery))
        {
            
$WebSeeders[] = $WSU['0'];
        }
        
$WebSeeders implode(','$WebSeeders);
    }
    else
    {
        
$WebSeeders false;
    }
    
$TSSECache->UpdateCache('webseeders'$WebSeeders);
}
function 
health($leechers$seeders) {
    if ((
$leechers == && $seeders == 0) || ($leechers && $seeders == 0))
        return 
0;
    elseif (
$seeders $leechers)
        return 
10;

    
$ratio $seeders $leechers 100;
    if (
$ratio && $ratio 15)
        return 
1;
    elseif (
$ratio >= 15 && $ratio 25)
        return 
2;
    elseif (
$ratio >= 25 && $ratio 35)
        return 
3;
    elseif (
$ratio >= 35 && $ratio 45)
        return 
4;
    elseif (
$ratio >= 45 && $ratio 55)
        return 
5;
    elseif (
$ratio >= 55 && $ratio 65)
        return 
6;
    elseif (
$ratio >= 65 && $ratio 75)
        return 
7;
    elseif (
$ratio >= 75 && $ratio 85)
        return 
8;
    elseif (
$ratio >= 85 && $ratio 95)
        return 
9;
    else
        return 
10;
}
$WebSeeders $TSSECache->Cache['webseeders']['content'];
$TWebSeeders = array();

if(
$WebSeeders
{
    if (
$xbt_active == 'yes')
        
$PSQuery 'SELECT fid as torrent FROM xbt_files_users WHERE active = 1 AND uid IN ('.$WebSeeders.')';
    else
        
$PSQuery 'SELECT torrent FROM peers WHERE userid IN ('.$WebSeeders.')';

    
$PSQueryhash md5($PSQuery);
    
$PSQuery sql_query($PSQuery) or sqlerr(__FILE__,__LINE__);

    if (
$UseMemcached)
    {
        if (
$TWebSeeders $TSMemcache->check($PSQueryhash))
        {
            
//Cache exists, lets use it.
        
}
        else
        {
            if (
mysqli_num_rows($PSQuery))
            {
                while(
$PSU mysqli_fetch_assoc($PSQuery))
                {
                    if (isset(
$TWebSeeders[$PSU['torrent']]))
                    {
                        
$TWebSeeders[$PSU['torrent']]++;
                    }
                    else
                    {
                        
$TWebSeeders[$PSU['torrent']] = 1;
                    }
                }
            }
            
$TSMemcache->add($PSQueryhash$TWebSeeders); //default 5 minutes.
        
}
    }
    else
    {
        if (
mysqli_num_rows($PSQuery))
        {
            while(
$PSU mysqli_fetch_assoc($PSQuery))
            {
                if (isset(
$TWebSeeders[$PSU['torrent']]))
                {
                    
$TWebSeeders[$PSU['torrent']]++;
                }
                else
                {
                    
$TWebSeeders[$PSU['torrent']] = 1;
                }
            }
        }
    }
    
    unset(
$WebSeeders);
}

$isfree $issilver $isdoubleupload false;
$___notice '';
if (
$xbt_active != 'yes')
{
    include(
TSDIR.'/'.$cache.'/freeleech.php');
    
$TSSEConfig->TSLoadConfig('KPS');
    if (
$__F_START get_date_time() && $__F_END get_date_time())
    {
        switch(
$__FLSTYPE)
        {
            case 
'freeleech';
                
$___notice show_notice(sprintf($lang->browse['f_leech'], $__F_START$__F_END),false,$lang->browse['f_leech_h']);
                
$isfree true;
            break;
            case 
'silverleech';
                
$___notice show_notice(sprintf($lang->browse['s_leech'], $__F_START$__F_END),false,$lang->browse['s_leech_h']);
                
$issilver true;
            break;
            case 
'doubleupload';
                
$___notice show_notice(sprintf($lang->browse['d_leech'], $__F_START$__F_END),false,$lang->browse['d_leech_h']);
                
$isdoubleupload true;
            break;
        }
    }
    elseif (
$bdayreward == 'yes' AND $bdayrewardtype AND isset($CURUSER['birthday']) AND !empty($CURUSER['birthday']))
    {
        if ((
$curuserbday explode('-'$CURUSER['birthday'])) AND isset($curuserbday[0]) AND isset($curuserbday[1]) AND date('j-n') === $curuserbday[0].'-'.$curuserbday[1])
        {
            switch (
$bdayrewardtype)
            {
                case 
'freeleech';
                    
$___notice show_notice(sprintf($lang->browse['f_leech'], $curuserbday[0].'-'.$curuserbday[1].'-'.date('Y'), ($curuserbday[0] + 1).'-'.$curuserbday[1].'-'.date('Y')),false,$lang->browse['f_leech_h']);
                    
$isfree true;
                break;
                case 
'silverleech';
                    
$___notice show_notice(sprintf($lang->browse['s_leech'], $curuserbday[0].'-'.$curuserbday[1].'-'.date('Y'), ($curuserbday[0] + 1).'-'.$curuserbday[1].'-'.date('Y')),false,$lang->browse['s_leech_h']);
                    
$issilver true;
                break;
                case 
'doubleupload';
                    
$___notice show_notice(sprintf($lang->browse['d_leech'], $curuserbday[0].'-'.$curuserbday[1].'-'.date('Y'), ($curuserbday[0] + 1).'-'.$curuserbday[1].'-'.date('Y')),false,$lang->browse['d_leech_h']);
                    
$isdoubleupload true;
                break;
            }
        }
    }
}

require(
TSDIR.'/'.$cache.'/categories.php');
$subcategories = array();
$searcincategories = array();
if (
count($_categoriesS) > 0)
{
    foreach (
$_categoriesS as $sc)
    {
        if (
$sc['canview'] != '[ALL]' AND !in_array($CURUSER['usergroup'], explode(',',$sc['canview'])))
        {
            continue;
        }
        
$sc['name'] = htmlspecialchars_uni($sc['name']);
        
$searcincategories[] = $sc['id'];
        
$scdesc htmlspecialchars_uni($sc['cat_desc']);
        
$SEOLinkC ts_seo($sc['id'],$sc['name'],'c');
        
$subcategories[$sc['pid']][] = '
        <span id="category'
.$sc['id'].'"'.(isset($category) && $category == $sc['id'] || (!$category && strpos($CURUSER['notifs'], '[cat'.$sc['id'].']') !== FALSE && $usergroups['canemailnotify'] == 'yes') ? ' class="highlight"' '').'>
            <a href="'
.$SEOLinkC.'" title="'.$scdesc.'">'.$sc['name'].'</a>
        </span>'
;
    }
    unset(
$_categoriesS);
}

$count 0;
$categories '
<table align="center" border="0" cellpadding="3" cellspacing="0" width="100%">
<tbody>
    <tr>
        <td class="thead">
            '
.ts_collapse('categories').'
            <div>
                <strong>
                    '
.$lang->browse['tcategory'].'
                </strong>
            </div>
        </td>
    </tr>
    '
.ts_collapse('categories'2).'
    <tr>
        <td align="center">
            <table border="0" cellspacing="0" cellpadding="0" align="left">
                <tr class="none">
'
;

if ((
$rows count($_categoriesC)) > 0)
{
    foreach (
$_categoriesC as $c)
    {
        if (
$c['canview'] != '[ALL]' AND !in_array($CURUSER['usergroup'], explode(',',$c['canview'])))
        {
            continue;
        }
        
$searcincategories[] = $c['id'];
        if (
$count && $count $tracker_cats_per_row == 0)
        {
            
$categories .= '</tr><tr class="none">';
        }

        
$cname htmlspecialchars_uni($c['name']);
        
$cdesc htmlspecialchars_uni($c['cat_desc']);
        
$SEOLinkC ts_seo($c['id'],$cname,'c');
        
$categories .= '
                    <td class="none">
                        <table border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="'
.$table_cat_width.'" class="none" height="'.$table_cat_height.'" valign="top" align="center" style="padding: 2px;">
                                    <a href="'
.$SEOLinkC.'"><img src="'.$pic_base_url.$table_cat.'/'.$c['image'].'" border="0" alt="'.$cname.'" title="'.$cname.'" width="'.$table_cat_width.'" height="'.$table_cat_height.'" /></a>
                                </td>
                                <td width="'
.$tracker_cats_width.'" class="none" valign="top" align="left" style="padding-left: 2px; padding-top: 3px; padding-right: 3px;">
                                    <span id="category'
.$c['id'].'"'.(isset($category) && $category == $c['id'] || (!$category && strpos($CURUSER['notifs'], '[cat'.$c['id'].']') !== FALSE && $usergroups['canemailnotify'] == 'yes') ? ' class="highlight"' '').'>
                                        <font class="cat_link" style="font-size: 14px;"><a href="'
.$SEOLinkC.'" title="'.$cdesc.'"><b>'.$cname.'</b></a></font>
                                    </span>
                                    <br />
                                    '
.(isset($subcategories[$c['id']]) ? implode(', '$subcategories[$c['id']]) : $c['cat_desc']).'
                                </td>
                            </tr>
                        </table>
                    </td>
                    '
;
        
$count++;
    }
    unset(
$_categoriesC);
}

$categories .= '
                </tr>
            </table>
        </td>
    </tr>
</tbody>
</table>'
;

require(
INC_PATH.'/functions_category.php');
$catdropdown ts_category_list('category',(isset($category) ? $category ''),'<option value="0" style="color: gray;">'.$lang->browse['alltypes'].'</option>''categories');

$SearchTorrent '
        <table align="center" border="0" cellpadding="3" cellspacing="0" width="100%">
        <tbody>
            <tr>
                <td class="thead">
                    '
.ts_collapse('search').'
                    '
.$lang->browse['tsearch'].'
                </td>
            </tr>
            '
.ts_collapse('search'2).'
            <tr>
                <td>
                    <form method="post" action="'
.$_SERVER['SCRIPT_NAME'].'" name="searchtorrent" id="searchtorrent">
                    <input type="hidden" name="do" value="chercher" />
                    <span class="ac_holder">
                        <input type="text" name="keywords" id="tsstac" value="'
.($keywords htmlspecialchars_uni($keywords) : '').'"'.($use_ajax_search == 'yes' ' onFocus="javascript:
                        var options = {
                            script: function (input) { return (\'scripts/autocomplete/query.php?input=\'+input); },
                            callback: function (obj) { window.location = \'details.php?id=\'+obj.id; }
                            };
                            var xml=new AutoComplete(\'tsstac\',options);return true;"' 
'').' autocomplete="off" style="width: 250px;" />
                    </span>
                    <select name="search_type" id="search_type">
                        <option value="t_name"'
.($search_type == 't_name' ' selected="selected"' '').'>'.$lang->browse['t_name'].'</option>
                        <option value="t_description"'
.($search_type == 't_description' ' selected="selected"' '').'>'.$lang->browse['t_description'].'</option>
                        <option value="t_both"'
.($search_type == 't_both' || $search_type == '' ' selected="selected"' '').'>'.$lang->browse['t_both'].'</option>
                        <option value="t_uploader"'
.($search_type == 't_uploader' ' selected="selected"' '').'>'.$lang->browse['t_uploader'].'</option>
                        <option value="t_genre"'
.($search_type == 't_genre' ' selected="selected"' '').'>'.$lang->browse['t_genre'].'</option>
                    </select>
                    '
.$catdropdown.'
                    <select name="include_dead_torrents">
                        <option value="yes"'
.($include_dead_torrents == 'yes' ' selected="selected"' '').'>'.$lang->browse['incdead1'].'</option>
                        <option value="no"'
.($include_dead_torrents == 'no' ' selected="selected"' '').'>'.$lang->browse['incdead2'].'</option>
                    </select>
                    <input type="submit" value="'
.$lang->global['buttonsearch'].'" />
                    </form>
                </td>
            </tr>
        </tbody>
        </table>
'
;

$WHERE " WHERE".($include_dead_torrents == 'yes' '' " t.visible = 'yes' AND")."  t.banned = 'no'";

$Links[] = 'include_dead_torrents='.($include_dead_torrents == 'yes' 'yes' 'no');

$WHERE .= " AND (INSTR(CONCAT(',',c.canview,','),',[ALL],') > 0 OR INSTR(CONCAT(',',c.canview,','),',".$CURUSER['usergroup'].",') > 0)";

if (
TS_Match($CURUSER['options'], 'E0'))
{
    
$WHERE .= " AND t.offensive = 'no'";
}

$innerjoin '';
if (
$special_search == 'myreseeds')
{
    
$Links[] = 'special_search=myreseeds';
    
$WHERE .= ' AND t.seeders = 0 AND t.leechers > 0 AND t.owner = \''.$CURUSER['id'].'\'';
}
elseif (
$special_search == 'mybookmarks')
{
    
$Links[] = 'special_search=mybookmarks';
    
$innerjoin ' INNER JOIN bookmarks b ON (b.torrentid = t.id)';
    
$WHERE .= ' AND b.userid = \''.$CURUSER['id'].'\'';
}
elseif (
$special_search == 'mytorrents')
{
    
$Links[] = 'special_search=mytorrents';
    
$WHERE .= ' AND t.owner = \''.$CURUSER['id'].'\'';
}
elseif (
$special_search == 'weaktorrents')
{
    
$Links[] = 'special_search=weaktorrents';
    
$WHERE .= " AND t.moderate = '0' AND t.visible = 'no' OR (t.leechers > 0 AND t.seeders = 0 AND t.moderate = '0') OR (t.leechers = 0 AND t.seeders = 0 AND t.moderate = '0')";
}

$extraquery = array();
if (
$keywords AND $search_type)
{
    
$OrjKeywords $keywords;
    
$Links[] = 'keywords='.htmlspecialchars_uni($keywords);
    
$Links[] = 'search_type='.htmlspecialchars_uni($search_type);
    if (
$fulltextsearch == 'yes')
    {
        require(
INC_PATH.'/function_search_clean.php');
        
$keywords clean_keywords_ft($keywords);
    }

    if (
$keywords)
    {
        if (
$fulltextsearch == 'yes')
        {
            
$query sql_query("SHOW VARIABLES LIKE 'ft_min_word_len';");
            
$array mysqli_fetch_assoc($query);
            
$min_length $array['Value'];

            if(
is_numeric($min_length))
            {
                
$minsearchword 1;
            }
            else
            {
                
$minsearchword 20;
            }

            
$keywords_exp explode("\""$keywords);
            
$inquote false;
            foreach(
$keywords_exp as $phrase)
            {
                if(!
$inquote)
                {
                    
$split_words preg_split("#\s{1,}#"$phrase, -1);
                    foreach(
$split_words as $word)
                    {
                        
$word str_replace(array("+""-""*"), ""$word);
                        if(!
$word)
                        {
                            continue;
                        }
                        if(
strlen($word) < $minsearchword)
                        {
                            
$lang->load('tsf_forums');
                            
$lang->error_minsearchlength sprintf($lang->tsf_forums['searcherror3'], $minsearchword);
                            
stderr($lang->global['error'], $lang->error_minsearchlength,false);
                            exit;
                        }
                    }
                }
                else
                {
                    
$phrase str_replace(array("+""-""*"), ""$phrase);
                    if(
strlen($phrase) < $minsearchword)
                    {
                        
$lang->load('tsf_forums');
                        
$lang->error_minsearchlength sprintf($lang->tsf_forums['searcherror3'], $minsearchword);
                        
stderr($lang->global['error'], $lang->error_minsearchlength,false);
                        exit;
                    }
                }
                
$inquote = !$inquote;
            }
        }
        else
        {
            if (
strlen($keywords) < 20)
            {
                
stderr($lang->global['error'], $lang->global['nothingfound']);
                exit;
            }
        }

        switch (
$search_type)
        {
            case 
't_name':
                if (
$fulltextsearch == 'yes')
                    
$extraquery[] = "(MATCH(t.name) AGAINST('".mysqli_real_escape_string($GLOBALS['DatabaseConnect'], $keywords)."' IN BOOLEAN MODE))";
                 
        else
                                
$extraquery[] = "(MATCH(t.name) AGAINST('".mysqli_real_escape_string($GLOBALS['DatabaseConnect'], $keywords)."' IN BOOLEAN MODE))";
                break;
            case 
't_description':
                if (
$fulltextsearch == 'yes')
                    
$extraquery[] = "(MATCH(t.descr) AGAINST('".mysqli_real_escape_string($GLOBALS['DatabaseConnect'], $keywords)."' IN BOOLEAN MODE))";
                else
                    
$extraquery[] = "(t.descr LIKE '".mysqli_real_escape_string($GLOBALS['DatabaseConnect'], "%".$keywords."%")."')";
                break;
            case 
't_both':
                if (
$fulltextsearch == 'yes')
                    
$extraquery[] = "(MATCH(t.name) AGAINST('".mysqli_real_escape_string($GLOBALS['DatabaseConnect'], $keywords)."' IN BOOLEAN MODE) OR MATCH(t.descr) AGAINST('".mysqli_real_escape_string($GLOBALS['DatabaseConnect'], $keywords)."' IN BOOLEAN MODE))";
                else
                    
$extraquery[] = "(t.name LIKE '".mysqli_real_escape_string($GLOBALS['DatabaseConnect'], "%".$keywords."%")."' OR t.descr LIKE '".mysqli_real_escape_string($GLOBALS['DatabaseConnect'], "%".$keywords."%")."')";
                break;
            case 
't_uploader':
                
$query sql_query("SELECT id FROM users WHERE upper(username) = ".sqlesc(strtoupper($OrjKeywords))." LIMIT 1");
                if (
mysqli_num_rows($query) > 0)
                {
                    
$user mysqli_fetch_assoc($query);
                    
$extraquery[] = "t.owner = ".sqlesc($user['id']).(!$is_mod " AND t.anonymous != 'yes'" "");
                }
                else
                    
$extraquery[] = "t.owner = ".sqlesc($OrjKeywords);
                break;
            case 
't_genre':
                if (
$fulltextsearch == 'yes')
                    
$extraquery[] = "(MATCH(t.t_link) AGAINST('".mysqli_real_escape_string($GLOBALS['DatabaseConnect'], $keywords)."' IN BOOLEAN MODE))";
                else
                    
$extraquery[] = "(t.t_link LIKE '".mysqli_real_escape_string($GLOBALS['DatabaseConnect'], "%".$keywords."%")."')";
            break;
        }
        
$keywords $OrjKeywords;
    }
}

if (
$category)
{
    
$query sql_query("SELECT id FROM categories WHERE type='s' AND pid = '$category'");
    if (
mysqli_num_rows($query) > 0)
    {
        
$squerycats=array();
        while (
$squery=mysqli_fetch_assoc($query))
        {
            
$squerycats[] = $squery['id'];
        }
        
$extraquery[] = 't.category  IN ('.$category.', '.implode(', '$squerycats).')';
    }
    else
    {
        
$extraquery[] = "t.category = ".$category;
    }
    
$Links[] = 'category='.$category;
}
elseif (
$usergroups['canemailnotify'] == 'yes' AND preg_match("#\[cat.+#i"$CURUSER['notifs']))
{
    
$defaultcategories = array();
    foreach (
$searcincategories as $catid)
    {
        if (
strpos($CURUSER['notifs'], '[cat'.$catid.']') !== FALSE)
        {
            
$defaultcategories[] = $catid;
        }
    }
    if (
count($defaultcategories) > 0)
    {
        
$WHERE .= ' AND t.category IN ('.implode(','$defaultcategories).')';
        unset(
$defaultcategories);
    }
}

if (
$special_search)
{
    
$Links[] = 'special_search='.htmlspecialchars_uni($special_search);
}

if (
count($extraquery) > 0)
{
    
$WHERE .= ' AND '.implode(' AND '$extraquery);
}

$orderby 't.sticky, t.added DESC';

if (
$sort OR $daysprune)
{
    
$sort_array = array(
    
'category''name''added''comments''size''times_completed''seeders''leechers''owner''hits''sticky''free''silver''isnuked''isrequest''doubleupload''ts_external''visible''isScene');
    
$sort = (in_array($sort$sort_array) ? $sort false);
    
$order = (strtolower($order) == 'asc' 'ASC' 'DESC');
    
$daysprune = ($daysprune == '-1' false intval($daysprune));
    if (
$sort)
    {
        if (
$xbt_active == 'yes')
        {
            switch(
$sort)
            {
                case 
'free':
                    
$orderby 't.download_multiplier ASC';
                break;
                case 
'silver':
                    
$orderby 't.download_multiplier DESC';
                break;
                case 
'doubleupload':
                    
$orderby 't.upload_multiplier DESC';
                break;
                default:
                    
$orderby 't.'.$sort.' '.$order;
                break;
            }
        }
        else
        {
            
$orderby 't.'.$sort.' '.$order;
        }
        
$Links[] = 'sort='.htmlspecialchars_uni($sort);
        
$Links[] = 'order='.htmlspecialchars_uni($order);
    }
    if (
$daysprune)
    {
        
$WHERE .= " AND UNIX_TIMESTAMP(t.added) >= ".(TIMENOW - ($daysprune 86400));
        
$Links[] = 'daysprune='.htmlspecialchars_uni($daysprune);
    }
}

$wait intval($usergroups['waitlimit']) ? $usergroups['waitlimit'] : '';

$torrentsperpage = ($CURUSER['torrentsperpage'] <> intval($CURUSER['torrentsperpage']) : $ts_perpage);

$countquery 'SELECT t.id, c.name, u.usergroup, g.gid FROM torrents t'.$innerjoin.' LEFT JOIN users u ON (t.owner=u.id) LEFT JOIN usergroups g ON (u.usergroup=g.gid) LEFT JOIN categories c ON (t.category=c.id)'.$WHERE.' ORDER BY '.$orderby;
$countqueryhash md5($countquery);

if (
$UseMemcached)
{
    if (
$count $TSMemcache->check('torrentcount_'.$countqueryhash))
    {
        
//Cache exists, lets use it.
    
}
    else
    {
        
$count mysqli_num_rows(sql_query($countquery));
        
$TSMemcache->add('torrentcount_'.$countqueryhash$count); //default 5 minutes.
    
}
}
else
{
    
$count mysqli_num_rows(sql_query($countquery));
}

list(
$pagertop$pagerbottom$limit) = pager($torrentsperpage$count$_SERVER['SCRIPT_NAME'].'?'.(is_array($Links) && count($Links) > implode('&amp;'$Links) : '').'&amp;');

$ListTorrents '
<script type="text/javascript" src="'
.$BASEURL.'/scripts/sortable/sortable.js"></script>
<script type="text/javascript" src="'
.$BASEURL.'/scripts/ts_update.js"></script>
'
.($is_mod '
<script type="text/javascript">
    function check_it(wHAT)
    {
        if (wHAT.value == "move")
        {
            document.getElementById("movetorrent").style.display = "block";
        }
        else
        {
            document.getElementById("movetorrent").style.display = "none";
        }
    }
</script>
<form method="post" action="'
.$BASEURL.'/'.$staffcp_path.'/index.php?do=manage_torrents&act=update&from_browse=true&page='.intval(TS_Global('page')).'" name="manage_torrents">' '').'
<div id="listtorrents" style="display: inline;">

<table align="center" border="0" cellpadding="2" cellspacing="0" width="100%" class="sortable" id="sortabletable">
    <tbody>
        <tr>
            <td align="center" class="unsortable">
                '
.$lang->browse['type'].'
            </td>
     
            <td class="thead" align="left">
                '
.$lang->browse['t_name'].'
            </td>
            
            <td class="thead" align="center">
                <img src="'
.$pic_base_url.'comments.gif" border="0" alt="'.$lang->browse['sortby3'].'" title="'.$lang->browse['sortby3'].'" />
            </td>
            <td align="center" class="unsortable">
                <img src="'
.$pic_base_url.'size.gif" border="0" alt="'.$lang->browse['sortby6'].'" title="'.$lang->browse['sortby6'].'" />
            </td>
            <td class="thead" align="center">
                <img src="'
.$pic_base_url.'snachted.gif" border="0" alt="'.$lang->browse['sortby7'].'" title="'.$lang->browse['sortby7'].'" />
            </td>
            <td class="thead" align="center">
                <img src="'
.$pic_base_url.'seeders.gif" border="0" alt="'.$lang->browse['sortby4'].'" title="'.$lang->browse['sortby4'].'" />
            </td>
            <td class="thead" align="center">
                <img src="'
.$pic_base_url.'leechers.gif" border="0" alt="'.$lang->browse['sortby5'].'" title="'.$lang->browse['sortby5'].'" />
            </td>
            <td class="thead" align="center">
                <img src="'
.$pic_base_url.'uploader.gif" border="0" alt="'.$lang->browse['sortby8'].'" title="'.$lang->browse['sortby8'].'" />
       </td>
          <td class="thead" align="left">
                Santé
            </td>  
      
            </td>
            '
.($is_mod '<td class="unsortable" align="center"><input checkall="group1" onclick="javascript: return select_deselectAll (\'manage_torrents\', this, \'group1\');" type="checkbox" /></td>' '').'
        </tr>
'
;

$groupby $torrentspeed == 'yes' ' GROUP by t.id ' '';

$query = ('SELECT '.($torrentspeed == 'yes' '(t.size * t.times_completed + SUM(p.downloaded)) / (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(t.added)) AS totalspeed,' '').'t.*, c.name as catname, c.cat_desc,c.image as catimage, u.username, g.namestyle FROM torrents t'.$innerjoin.' LEFT JOIN categories c ON (t.category=c.id) LEFT JOIN users u ON (t.owner=u.id) LEFT JOIN usergroups g ON (u.usergroup=g.gid)'.($torrentspeed == 'yes' ' LEFT JOIN '.($xbt_active == 'yes' 'xbt_files_users p ON (t.id=p.fid)' 'peers p ON (t.id=p.torrent)') : '').$WHERE.$groupby.' ORDER BY '.$orderby.' '.$limit);

$queryhash md5($query);
$TotalTorrents = array();

if (
$UseMemcached)
{
    if (
$TotalTorrents $TSMemcache->check($queryhash))
    {
        
//Cache exists, lets use it.
    
}
    else
    {
        
$Query sql_query($query) or sqlerr(__FILE__,__LINE__);
        if (
mysqli_num_rows($Query))
        {
            while(
$t=mysqli_fetch_assoc($Query))
            {
                
$TotalTorrents[] = $t;
            }
        }
        
$TSMemcache->add($queryhash$TotalTorrents); //default 5 minutes.
    
}
}
else
{
    
$Query sql_query($query) or sqlerr(__FILE__,__LINE);
    if (
mysqli_num_rows($Query))
    {
        while(
$t=mysqli_fetch_assoc($Query))
        {
            
$TotalTorrents[] = $t;
        }
    }
}

if (
$TotalTorrents AND count($TotalTorrents))
{
    require(
INC_PATH.'/functions_imdb_rating.php');
    require(
INC_PATH.'/functions_get_torrent_flags.php');
    
$worked 0;
    foreach(
$TotalTorrents as $Torrent)
    {
        
$ShowImdb=false;
        if (
$IMDBRating TSSEGetIMDBRatingImage($Torrent['t_link']))
        {
            
$ShowImdb=true;
        }

        
$health='';
        if (
$progressbar == 'yes')
        {
            
$health $lang->global['avprogress'].': '.ts_external_share_ratio(($Torrent['seeders'] == : ($Torrent['leechers'] == 100 sprintf("%.2f", ($Torrent['seeders'] / $Torrent['leechers']) * 100))));
        }

        
$speed '';
        if (
$torrentspeed == 'yes' AND $Torrent['ts_external'] != 'yes')
        {
            if (
$Torrent['seeders'] > && $Torrent['leechers'] > 0)
            {
                
$speed mksize($Torrent['totalspeed']) . '/s';
            }
            else
            {
                
$speed $lang->browse['notraffic'];
            }
            
$speed $lang->global['speed'].': '.$speed;
        }

        
$showwait='';
        if (
$wait AND $Torrent['ts_external'] != 'yes')
        {
            
$elapsed floor((strtotime(date('Y-m-d H:i:s')) - strtotime($Torrent['added'])) / 3600);
            if (
$elapsed $wait)
            {
                 
$showwait $lang->global['wait'].": " number_format($wait $elapsed) . " h";
            }
        }
   
        if (
$Torrent['t_image'] != '')
        {
            
$worked++;
        }
   if(
$Torrent['anonymous'] == 'yes' AND $Torrent['owner'] != $CURUSER['id'] AND !$is_mod)
{
        
$username 'Anonyme';
}
else
{
    
$username ''.get_user_color($Torrent['username'], $Torrent['namestyle']).'';
}    
    
$cat $Torrent['catname'];
      
$parentcategory $Torrent['cat_desc'];
    
$issticky = ($Torrent['sticky'] == 'yes' '<img src="'.$BASEURL.'/include/templates/'.$defaulttemplate.'/images/torrent_flags/sticky.gif" alt="'.$lang->browse['sortby9'].'" title="'.$lang->browse['sortby9'].'" />' '');
    
$health2 =" <img src=/images/health/health_".health($Torrent['leechers'], $Torrent['seeders']).".gif>";
    
        
$SEOLink ts_seo($Torrent['id'], $Torrent['name'],'s');
        
$SEOLinkC ts_seo($Torrent['category'],$Torrent['catname'],'c');
   
        
$ListTorrents .= '
        <tr'
.($Torrent['sticky'] == 'yes' ' class="highlight"' '').'>
            <td align="center" style="width: '
.$table_cat_width2.'px; height: '.$table_cat_height2.'px;" class="unsortable2">
                <a href="'
.$seolink2.'"><img src="'.$pic_base_url.$table_cat.'/'.$Torrent['catimage'].'" border="0" alt="'.$Torrent['catname'].'" title="'.$parentcategory.'/'.$Torrent['catname'].'" width="'.$table_cat_width2.'" height="'.$table_cat_height2.'" /></a>
            </td>
     
            <td valign="top" align="left">
                    <a href="'
.$SEOLink.'"><strong>'.(!empty($keywords) ? highlight(htmlspecialchars_uni($keywords), cutename($Torrent['name'])) : cutename($Torrent['name'])).'</strong></a>
                </div>
        
                <div>
                    <span style="float: right;">
                        '
.$issticky.'     '.GetTorrentTags($Torrent).'
                    </span>
                        <font color=white> le '
.($Torrent['isScene'] > sprintf($lang->browse['pretime'], my_datee($dateformat.' '.$timeformat$Torrent['isScene']), mkprettytime(TS_MTStoUTS($Torrent['added']) - $Torrent['isScene'])) : my_datee$dateformat.' à '.$timeformat$Torrent['added'])).'
                </div>
            </td>
            
            <td align="center">
                <a href="'
.$BASEURL.'/details.php?id='.$Torrent['id'].'&amp;tab=comments#comments" title="'.$lang->browse['sortby3'].'">'.ts_nf($Torrent['comments']).'</a>
            </td>
            <td align="center" class="unsortable2">
                '
.mksize($Torrent['size']).'
            </td>
            <td align="center">
                <a href="'
.$BASEURL.'/'.($xbt_active == 'yes' && $is_mod 'mysnatchlist.php?tid' : ($usergroups['cansnatch'] == 'yes' &&  $xbt_active != 'yes' 'viewsnatches.php?id' 'details.php?id')).'='.$Torrent['id'].'" title="'.$lang->browse['sortby7'].'">'.ts_nf($Torrent['times_completed']).'</a>
            </td>
            <td align="center">
                <span id="seeders_'
.$Torrent['id'].'">
                    <a href="'
.$BASEURL.'/details.php?id='.$Torrent['id'].'&amp;tab=peers#seeders" title="'.$lang->browse['sortby4'].'"><font color=green><b>'.ts_nf($Torrent['seeders']).'</b></font></a>
                </span>
            </td>
            <td align="center">
                <span id="leechers_'
.$Torrent['id'].'">
                    <a href="'
.$BASEURL.'/details.php?id='.$Torrent['id'].'&amp;tab=peers#leechers" title="'.$lang->browse['sortby5'].'"><font color=red><b>'.ts_nf($Torrent['leechers']).'</b></font></a>
                </span>
            </td>
            <td align="center">
                '
.(!$is_mod && $Torrent['owner'] != $CURUSER['id'] && $Torrent['anonymous'] == 'yes' '
                <div>
                    '
.$lang->global['anonymous'].'
                </div>' 
'
                <a href="'
.ts_seo($Torrent['owner'], $Torrent['username'], 'u').'">'.get_user_color($Torrent['username'], $Torrent['namestyle']).'</a>
                '
.($Torrent['anonymous'] == 'yes' '
                <div>
                    '
.$lang->global['anonymous'].'
                </div>
                ' 
'').'
                '
).'
        <td align="center" class="unsortable2">
                '
.$health2.'
            </td>
    
            </td>
            '
.($is_mod '<td align="center" class="unsortable2"><input type="checkbox" name="torrentid[]" value="'.$Torrent['id'].'" checkme="group1" /></td>' '').'
        </tr>
        '
;
    }
}
else
{
    
$ListTorrents .= '
        <tr>
            <td colspan="'
.($is_mod '10' '9').'">
                <b>'
.$lang->global['nothingfound'].'</b>
            </td>
        </tr>
    '
;
}
$ListTorrents .= '
    </tbody>
</table>
'
.$pagerbottom.'
'
.($is_mod ?'
<table align="center" border="0" cellpadding="2" cellspacing="0" width="100%">
    <tr>
        <td align="right" class="subheader">
            <span id="movetorrent" style="display:none;">
                Select Category: '
.$catdropdown.'
            </span>
            <select name="actiontype" onchange="check_it(this)">
                <option value="0">Sélectionner une action</option>
                <option value="move">Déplacer la sélection</option>
                <option value="delete">Supprimé la sélection</option>
                <option value="sticky">Epinglé/Dépinglé la sélection</option>
                <option value="free">Freeleech/pas de freeleech sur la sélection</option>
                <option value="silver">Silver/pas de silver sur la sélection</option>
                <option value="doubleupload">Double Upload OUI/NON</option>
                <option value="visible">Visible/Invisible la sélection</option>
                <option value="anonymous">Anonyme/Non Anonyme sur la sélection</option>
                <option value="banned">Bannnir/Débannir la sélection</option>
                <option value="nuke">Nuké/Non Nuké la sélection</option>
                <option value="openclose">Ouvrir/Fermer les commentaires</option>
                <option value="request">Requête/Pas une Requête la sélection</option>
            </select>
            <input type="submit" value="Envoyer" />
        </td>
    </tr>
</table>
</form>
'').'
</div>'
;


stdhead($lang->browse['btitle'], true,  '
<script type="text/javascript" src="'
.$BASEURL.'/scripts/jquery.ezpz_tooltip.min.js"></script>
<script type="text/javascript" src="'
.$BASEURL.'/scripts/prototype.js"></script>
<script type="text/javascript" charset="utf-8">
    jQuery(document).ready(function()
    {
        jQuery(".tooltip-target").ezpz_tooltip();
    });

    var nrf = "'
.$lang->global['nothingfound'].'";
</script>

<style type="text/css">
    .tooltip-content
    {
        display: none;        /* required */
        position: absolute;   /* required */
        padding: 10px;
        border: 1px solid black;
        background-color: white;
        box-shadow: 7px 7px 8px #818181;
        -webkit-box-shadow: 7px 7px 8px #818181;
        -moz-box-shadow: 7px 7px 8px #818181;
        filter: progid:DXImageTransform.Microsoft.dropShadow(color=#818181, offX=7, offY=7, positive=true);
    }
</style>
'
.($use_ajax_search == 'yes' '
<script type="text/javascript" src="'
.$BASEURL.'/scripts/autocomplete/js/autocomplete.js"></script>' '').($use_ajax_search == 'yes' '
<link rel="stylesheet" href="'
.$BASEURL.'/scripts/autocomplete/css/autocomplete.css" type="text/css" media="screen" />' '').'
'
);
echo 
'
'
.$___notice.'
<table align="center" cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr valign="top">
            <td valign="top" class="none">
                <div style="padding-bottom: 15px;">
                    '
.$categories.'
                </div>
                <div style="padding-bottom: 15px;">
                     '
.$SearchTorrent.'
                </div>
                
                <div style="padding-bottom: 15px;">
                    '
.$ListTorrents.'
                </div>
            
            </td>
        </tr>
    </tbody>
</table>
'
;
stdfoot();
?>
Reply With Quote
Reply

Tags
page , problems

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 23:01. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.