Кэширование ф while

Разработка своих веб-приложений и страничек

Re: Кэширование ф while

Сообщение SPAWN » 20 янв 2010, 01:01

Rostov114 писал(а):http://vfose.ru/forum/viewtopic.php?p=36032#p36032
Потом пример читаем внизу страницы и выполняем кеш страницы ну скажем минуты на 2.
Можно так же мемкеш прикрутить. Что при высоких нагрузках гораздо быстрее будет работать.

чё ты свой форум закрыл forum.rostov114.net
блин пару полезных статей там было можешь в лс кинуть или открыть его
Изображение
Изображение
Изображение
SPAWN
Активный участник
 
Сообщения: 181
Зарегистрирован: 09 окт 2009, 23:38
Домен: extra-tracker.vfose.ru

Re: Кэширование ф while

Сообщение Rostov114 » 20 янв 2010, 01:48

SPAWN писал(а):
Rostov114 писал(а):http://vfose.ru/forum/viewtopic.php?p=36032#p36032
Потом пример читаем внизу страницы и выполняем кеш страницы ну скажем минуты на 2.
Можно так же мемкеш прикрутить. Что при высоких нагрузках гораздо быстрее будет работать.

чё ты свой форум закрыл forum.rostov114.net
блин пару полезных статей там было можешь в лс кинуть или открыть его

о_О на нем?
Пойду ка позырю. А вообще в планах открыть "быдло блог" и писать все туды.
В общем открыл. На баги не орать, лень исправлять.
Некоммерческий проект «HSDN»
Аватара пользователя
Rostov114
Автор
 
Сообщения: 3197
Зарегистрирован: 18 окт 2007, 02:21

Re: Кэширование ф while

Сообщение vk » 20 янв 2010, 10:15

Rostov114 писал(а):http://vfose.ru/forum/viewtopic.php?p=36032#p36032
Потом пример читаем внизу страницы и выполняем кеш страницы ну скажем минуты на 2.
Можно так же мемкеш прикрутить. Что при высоких нагрузках гораздо быстрее будет работать.

Колян, как работает кэш я прекрасно знаю, даже более того...
Тут ситуация конкретная, т.к. сталкиваюсь с такой сложной функцией - обращаюсь к вам. Вот собственно код:
В browse.php уже вывод функции и сам скл запрос (который является самым тяжелым в движке):

Код: Выделить всёРазвернуть
<?php

/*
// +--------------------------------------------------------------------------+
// | Project:    TBDevYSE - TBDev Yuna Scatari Edition                        |
// +--------------------------------------------------------------------------+
// | This file is part of TBDevYSE. TBDevYSE is based on TBDev,               |
// | originally by RedBeard of TorrentBits, extensively modified by           |
// | Gartenzwerg.                                                             |
// |                                                                          |
// | TBDevYSE is free software; you can redistribute it and/or modify         |
// | it under the terms of the GNU General Public License as published by     |
// | the Free Software Foundation; either version 2 of the License, or        |
// | (at your option) any later version.                                      |
// |                                                                          |
// | TBDevYSE is distributed in the hope that it will be useful,              |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            |
// | GNU General Public License for more details.                             |
// |                                                                          |
// | You should have received a copy of the GNU General Public License        |
// | along with TBDevYSE; if not, write to the Free Software Foundation,      |
// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            |
// +--------------------------------------------------------------------------+
// |                                               Do not remove above lines! |
// +--------------------------------------------------------------------------+
*/

require_once("include/bittorrent.php");

dbconn(false);

//loggedinorreturn();
parked();

$cats = genrelist();

$searchstr = unesc($_GET["search"]);
$cleansearchstr = htmlspecialchars($searchstr);
if (empty($cleansearchstr))
unset($cleansearchstr);

// sorting by MarkoStamcar

if ($_GET['sort'] && $_GET['type']) {

$column = '';
$ascdesc = '';

switch($_GET['sort']) {
case '1': $column = "name"; break;
case '2': $column = "numfiles"; break;
case '3': $column = "comments"; break;
case '4': $column = "added"; break;
case '5': $column = "size"; break;
case '6': $column = "times_completed"; break;
case '7': $column = "seeders"; break;
case '8': $column = "leechers"; break;
case '9': $column = "owner"; break;
case '10': if (get_user_class() >= UC_MODERATOR) $column = "moderatedby"; break;
default: $column = "id"; break;
}

    switch($_GET['type']) {
  case 'asc': $ascdesc = "ASC"; $linkascdesc = "asc"; break;
  case 'desc': $ascdesc = "DESC"; $linkascdesc = "desc"; break;
  default: $ascdesc = "DESC"; $linkascdesc = "desc"; break;
    }


$orderby = "ORDER BY torrents." . $column . " " . $ascdesc;
$pagerlink = "sort=" . intval($_GET['sort']) . "&type=" . $linkascdesc . "&";

} else {

$orderby = "ORDER BY torrents.sticky ASC, torrents.id DESC";
$pagerlink = "";

}

$addparam = "";
$wherea = array();
$wherecatina = array();

if ($_GET["incldead"] == 1)
{
        $addparam .= "incldead=1&amp;";
        if (!isset($CURUSER) || get_user_class() < UC_ADMINISTRATOR)
                $wherea[] = "banned != 'yes'";
}
elseif ($_GET["incldead"] == 2)
{
        $addparam .= "incldead=2&amp;";
                $wherea[] = "visible = 'no'";
}
elseif ($_GET["incldead"] == 3)
{
        $addparam .= "incldead=3&amp;";
                $wherea[] = "free = 'yes'";
               $wherea[] = "visible = 'yes'";
}
elseif ($_GET["incldead"] == 4)
{
        $addparam .= "incldead=4&amp;";
                $wherea[] = "seeders = 0";
                $wherea[] = "visible = 'yes'";
}
        else
                $wherea[] = "visible = 'yes'";

$category = (int)$_GET["cat"];

$all = $_GET["all"];

if (!$all)
        if (!$_GET && $CURUSER["notifs"])
        {
          $all = True;
          foreach ($cats as $cat)
          {
            $all &= $cat[id];
            if (strpos($CURUSER["notifs"], "[cat" . $cat[id] . "]") !== False)
            {
              $wherecatina[] = $cat[id];
              $addparam .= "c$cat[id]=1&amp;";
            }
          }
        }
        elseif ($category)
        {
          if (!is_valid_id($category))
            stderr($tracker_lang['error'], "Invalid category ID.");
          $wherecatina[] = $category;
          $addparam .= "cat=$category&amp;";
        }
        else
        {
          $all = True;
          foreach ($cats as $cat)
          {
            $all &= $_GET["c$cat[id]"];
            if ($_GET["c$cat[id]"])
            {
              $wherecatina[] = $cat[id];
              $addparam .= "c$cat[id]=1&amp;";
            }
          }
        }

if ($all)
{
        $wherecatina = array();
  $addparam = "";
}

if (count($wherecatina) > 1)
        $wherecatin = implode(",",$wherecatina);
elseif (count($wherecatina) == 1)
        $wherea[] = "category = $wherecatina[0]";

$wherebase = $wherea;

if (isset($cleansearchstr))
{
      $wherea[] = "torrents.name LIKE '%" . sqlwildcardesc($searchstr) . "%'";
        $addparam .= "search=" . urlencode($searchstr) . "&amp;";
}

$where = implode(" AND ", $wherea);
if ($wherecatin)
        $where .= ($where ? " AND " : "") . "category IN (" . $wherecatin . ")";

if ($where != "")
        $where = "WHERE $where";

$res = sql_query("SELECT COUNT(*) FROM torrents $where") or die(mysql_error());
$row = mysql_fetch_array($res);
$count = $row[0];
$num_torrents = $count;

if (!$count && isset($cleansearchstr)) {
        $wherea = $wherebase;
        //$orderby = "ORDER BY id DESC";
        $searcha = explode(" ", $cleansearchstr);
        $sc = 0;
        foreach ($searcha as $searchss) {
                if (strlen($searchss) <= 1)
                        continue;
                $sc++;
                if ($sc > 5)
                        break;
                $ssa = array();
                $ssa[] = "torrents.name LIKE '%" . sqlwildcardesc($searchss) . "%'";
        }
        if ($sc) {
                $where = implode(" AND ", $wherea);
                if ($where != "")
                        $where = "WHERE $where";
                $res = sql_query("SELECT COUNT(*) FROM torrents $where");
                $row = mysql_fetch_array($res);
                $count = $row[0];
        }
}

$torrentsperpage = $CURUSER["torrentsperpage"];
if (!$torrentsperpage)
        $torrentsperpage = 25;

if ($count)
{
    if ($addparam != "") {
if ($pagerlink != "") {
  if ($addparam{strlen($addparam)-1} != ";") { // & = &amp;
    $addparam = $addparam . "&" . $pagerlink;
  } else {
    $addparam = $addparam . $pagerlink;
  }
}
    } else {
$addparam = $pagerlink;
    }
        list($pagertop, $pagerbottom, $limit) = pager($torrentsperpage, $count, "browse.php?" . $addparam);
[b]        $query = "SELECT torrents.id, torrents.moderated, torrents.moderatedby, torrents.category, torrents.leechers, torrents.seeders, torrents.free, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.sticky, torrents.owner," .
        "IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, categories.name AS cat_name, categories.image AS cat_pic, users.username, users.class".($CURUSER ? ", EXISTS(SELECT * FROM readtorrents WHERE readtorrents.userid = ".sqlesc($CURUSER["id"])." AND readtorrents.torrentid = torrents.id) AS readtorrent" : ", 1 AS readtorrent")." FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit";
        $res = sql_query($query) or die(mysql_error());[/b]
}
else
        unset($res);
if (isset($cleansearchstr))
        stdhead($tracker_lang['search_results_for']." \"$cleansearchstr\"");
else
        stdhead($tracker_lang['browse']);

?>

<STYLE TYPE="text/css" MEDIA=screen>

  a.catlink:link, a.catlink:visited{
                text-decoration: none;
        }

        a.catlink:hover {
                color: #A83838;
        }

</STYLE>

<table class="embedded" cellspacing="0" cellpadding="5" width="100%">
<tr><td class="colhead" align="center" colspan="12">Список торрентов</td></tr>
<tr><td colspan="12">

<form method="get" action="browse.php">
<table class="embedded" align="center">
<tr>
<td class="bottom">
        <table class="bottom">
        <tr>

<?
$i = 0;
foreach ($cats as $cat)
{
        $catsperrow = 5;
        print(($i && $i % $catsperrow == 0) ? "</tr><tr>" : "");
        print("<td class=\"bottom\" style=\"padding-bottom: 2px;padding-left: 7px\"><input name=\"c$cat[id]\" type=\"checkbox\" " . (in_array($cat[id],$wherecatina) ? "checked " : "") . "value=\"1\"><a class=\"catlink\" href=\"browse.php?cat=$cat[id]\">" . htmlspecialchars($cat[name]) . "</a></td>\n");
        $i++;
}

$alllink = "<div align=\"left\">(<a href=\"browse.php?all=1\"><b>".$tracker_lang['show_all']."</b></a>)</div>";

$ncats = count($cats);
$nrows = ceil($ncats/$catsperrow);
$lastrowcols = $ncats % $catsperrow;

if ($lastrowcols != 0)
{
        if ($catsperrow - $lastrowcols != 1)
                {
                        print("<td class=\"bottom\" rowspan=\"" . ($catsperrow  - $lastrowcols - 1) . "\">&nbsp;</td>");
                }
}
?>
        </tr>
        </table>
</td>
</tr>
</form>
<tr><td class="embedded">
<form method="get" action="browse.php">
<center>
<?=$tracker_lang['search'];?>:
<input type="text" id="searchinput" name="search" size="40" autocomplete="off" ondblclick="suggest(event.keyCode,this.value);" onkeyup="suggest(event.keyCode,this.value);" onkeypress="return noenter(event.keyCode);" value="<?= htmlspecialchars($searchstr) ?>" />
<?=$tracker_lang['in'];?>
<select name="incldead">
<option value="0"><?=$tracker_lang['active'];?></option>
<option value="1"<? print($_GET["incldead"] == 1 ? " selected" : ""); ?>><?=$tracker_lang['including_dead'];?></option>
<option value="2"<? print($_GET["incldead"] == 2 ? " selected" : ""); ?>><?=$tracker_lang['only_dead'];?></option>
<option value="3"<? print($_GET["incldead"] == 3 ? " selected" : ""); ?>><?=$tracker_lang['golden_torrents'];?></option>
<option value="4"<? print($_GET["incldead"] == 4 ? " selected" : ""); ?>><?=$tracker_lang['no_seeds'];?></option>
</select>
<select name="cat">
<option value="0">(<?=$tracker_lang['all_types'];?>)</option>
<?


//$cats = genrelist();
$catdropdown = "";
foreach ($cats as $cat) {
$catdropdown .= "<option value=\"" . $cat["id"] . "\"";
if ($cat["id"] == $_GET["cat"])
$catdropdown .= " selected=\"selected\"";
$catdropdown .= ">" . htmlspecialchars($cat["name"]) . "</option>\n";
}

?>
<?= $catdropdown ?>
</select>
<input class="btn" type="submit" value="<?=$tracker_lang['search'];?>!" />
</center>
</form>
<script language="JavaScript" src="js/suggest.js" type="text/javascript"></script>
<div id="suggcontainer" style="text-align: left; width: 520px; display: none;">
<div id="suggestions" style="cursor: default; position: absolute; background-color: #FFFFFF; border: 1px solid #777777;"></div>
</div>
</td></tr></table>

<?

if (isset($cleansearchstr))
print("<tr><td class=\"index\" colspan=\"12\">".$tracker_lang['search_results_for']." \"" . htmlspecialchars($searchstr) . "\"</td></tr>\n");

print("</td></tr>");

if ($num_torrents) {

        print("<tr><td class=\"index\" colspan=\"12\">");
        print($pagertop);
        print("</td></tr>");

        [b]torrenttable($res, "index");[/b]

        print("<tr><td class=\"index\" colspan=\"12\">");
        print($pagerbottom);
        print("</td></tr>");

}
else {
        if (isset($cleansearchstr)) {
                print("<tr><td class=\"index\" colspan=\"12\">".$tracker_lang['nothing_found']."</td></tr>\n");
                //print("<p>Попробуйте изменить запрос поиска.</p>\n");
        }
        else {
                print("<tr><td class=\"index\" colspan=\"12\">".$tracker_lang['nothing_found']."</td></tr>\n");
                //print("<p>Извините, данная категория пустая.</p>\n");
        }
}

print("</table>");

stdfoot();

?>


А вот собственно сама гиганская функция:

Код: Выделить всёРазвернуть
function torrenttable($res, $variant = "index") {
      global $pic_base_url, $CURUSER, $use_wait, $use_ttl, $ttl_days, $tracker_lang;

  if ($use_wait)
  if (($CURUSER["class"] < UC_VIP) && $CURUSER) {
        $gigs = $CURUSER["uploaded"] / (1024*1024*1024);
        $ratio = (($CURUSER["downloaded"] > 0) ? ($CURUSER["uploaded"] / $CURUSER["downloaded"]) : 0);
        if ($ratio < 0.5 || $gigs < 5) $wait = 48;
        elseif ($ratio < 0.65 || $gigs < 6.5) $wait = 24;
        elseif ($ratio < 0.8 || $gigs < 8) $wait = 12;
        elseif ($ratio < 0.95 || $gigs < 9.5) $wait = 6;
        else $wait = 0;
  }

print("<tr>\n");

// sorting by MarkoStamcar

$count_get = 0;

foreach ($_GET as $get_name => $get_value) {

$get_name = mysql_escape_string(strip_tags(str_replace(array("\"","'"),array("",""),$get_name)));

$get_value = mysql_escape_string(strip_tags(str_replace(array("\"","'"),array("",""),$get_value)));

if ($get_name != "sort" && $get_name != "type") {
if ($count_get > 0) {
$oldlink = $oldlink . "&" . $get_name . "=" . $get_value;
} else {
$oldlink = $oldlink . $get_name . "=" . $get_value;
}
$count_get++;
}

}

if ($count_get > 0) {
$oldlink = $oldlink . "&";
}


if ($_GET['sort'] == "1") {
if ($_GET['type'] == "desc") {
$link1 = "asc";
} else {
$link1 = "desc";
}
}

if ($_GET['sort'] == "2") {
if ($_GET['type'] == "desc") {
$link2 = "asc";
} else {
$link2 = "desc";
}
}

if ($_GET['sort'] == "3") {
if ($_GET['type'] == "desc") {
$link3 = "asc";
} else {
$link3 = "desc";
}
}

if ($_GET['sort'] == "4") {
if ($_GET['type'] == "desc") {
$link4 = "asc";
} else {
$link4 = "desc";
}
}

if ($_GET['sort'] == "5") {
if ($_GET['type'] == "desc") {
$link5 = "asc";
} else {
$link5 = "desc";
}
}

if ($_GET['sort'] == "7") {
if ($_GET['type'] == "desc") {
$link7 = "asc";
} else {
$link7 = "desc";
}
}

if ($_GET['sort'] == "8") {
if ($_GET['type'] == "desc") {
$link8 = "asc";
} else {
$link8 = "desc";
}
}

if ($_GET['sort'] == "9") {
if ($_GET['type'] == "desc") {
$link9 = "asc";
} else {
$link9 = "desc";
}
}

if ($_GET['sort'] == "10") {
if ($_GET['type'] == "desc") {
$link10 = "asc";
} else {
$link10 = "desc";
}
}

if ($link1 == "") { $link1 = "asc"; } // for torrent name
if ($link2 == "") { $link2 = "desc"; }
if ($link3 == "") { $link3 = "desc"; }
if ($link4 == "") { $link4 = "desc"; }
if ($link5 == "") { $link5 = "desc"; }
if ($link7 == "") { $link7 = "desc"; }
if ($link8 == "") { $link8 = "desc"; }
if ($link9 == "") { $link9 = "desc"; }
if ($link10 == "") { $link10 = "desc"; }

?>
<td class="colhead" align="center"><?=$tracker_lang['type'];?></td>
<td class="colhead" align="left"><a href="browse.php?<? print $oldlink; ?>sort=1&type=<? print $link1; ?>" class="altlink_white"><?=$tracker_lang['name'];?></a> / <a href="browse.php?<? print $oldlink; ?>sort=4&type=<? print $link4; ?>" class="altlink_white"><?=$tracker_lang['added'];?></a></td>
<!--<td class="heading" align="left">DL</td>-->
<?
if ($wait)
   print("<td class=\"colhead\" align=\"center\">".$tracker_lang['wait']."</td>\n");

if ($variant == "mytorrents")
   print("<td class=\"colhead\" align=\"center\">".$tracker_lang['visible']."</td>\n");


?>
<td class="colhead" align="center"><a href="browse.php?<? print $oldlink; ?>sort=2&type=<? print $link2; ?>" class="altlink_white"><?=$tracker_lang['files'];?></a></td>
<td class="colhead" align="center"><a href="browse.php?<? print $oldlink; ?>sort=3&type=<? print $link3; ?>" class="altlink_white"><?=$tracker_lang['comments'];?></a></td>
<? if ($use_ttl) {
?>
   <td class="colhead" align="center"><?=$tracker_lang['ttl'];?></td>
<?
}
?>
<td class="colhead" align="center"><a href="browse.php?<? print $oldlink; ?>sort=5&type=<? print $link5; ?>" class="altlink_white"><?=$tracker_lang['size'];?></a></td>
<!--
<td class="colhead" align="right">Views</td>
<td class="colhead" align="right">Hits</td>
-->
<td class="colhead" align="center"><a href="browse.php?<? print $oldlink; ?>sort=7&type=<? print $link7; ?>" class="altlink_white"><?=$tracker_lang['seeds'];?></a>|<a href="browse.php?<? print $oldlink; ?>sort=8&type=<? print $link8; ?>" class="altlink_white"><?=$tracker_lang['leechers'];?></a></td>
<?

if ($variant == "index" || $variant == "bookmarks")
   print("<td class=\"colhead\" align=\"center\"><a href=\"browse.php?{$oldlink}sort=9&type={$link9}\" class=\"altlink_white\">".$tracker_lang['uploadeder']."</a></td>\n");

if ((get_user_class() >= UC_MODERATOR) && $variant == "index")
   print("<td class=\"colhead\" align=\"center\"><a href=\"browse.php?{$oldlink}sort=10&type={$link10}\" class=\"altlink_white\">Изменен</td>");

if ((get_user_class() >= UC_MODERATOR) && $variant == "index")
   print("<td class=\"colhead\" align=\"center\">".$tracker_lang['delete']."</td>\n");

if ($variant == "bookmarks")
   print("<td class=\"colhead\" align=\"center\">".$tracker_lang['delete']."</td>\n");

print("</tr>\n");

print("<tbody id=\"highlighted\">");

if ((get_user_class() >= UC_MODERATOR) && $variant == "index")
   print("<form method=\"post\" action=\"deltorrent.php?mode=delete\">");

   if ($variant == "bookmarks")
      print ("<form method=\"post\" action=\"takedelbookmark.php\">");

   while ($row = mysql_fetch_assoc($res)) {
      $id = $row["id"];
      print("<tr".($row["sticky"] == "yes" ? " class=\"highlight\"" : "").">\n");

      print("<td align=\"center\" style=\"padding: 0px\">");
      if (isset($row["cat_name"])) {
         print("<a href=\"browse.php?cat=" . $row["category"] . "\">");
         if (isset($row["cat_pic"]) && $row["cat_pic"] != "")
            print("<img border=\"0\" src=\"$pic_base_url/cats/" . $row["cat_pic"] . "\" alt=\"" . $row["cat_name"] . "\" />");
         else
            print($row["cat_name"]);
         print("</a>");
      }
      else
         print("-");
      print("</td>\n");

      $dispname = $row["name"];
      $thisisfree = ($row[free]=="yes" ? "<img src=\"pic/freedownload.gif\" title=\"".$tracker_lang['golden']."\" alt=\"".$tracker_lang['golden']."\">" : "");
      print("<td align=\"left\">".($row["sticky"] == "yes" ? "Важный: " : "")."<a href=\"details.php?");
      if ($variant == "mytorrents")
         print("returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "&amp;");
      print("id=$id");
      if ($variant == "index" || $variant == "bookmarks")
         print("&amp;hit=1");
      print("\"><b>$dispname</b></a> $thisisfree\n");

         if ($variant != "bookmarks" && $CURUSER)
            print("<a href=\"bookmark.php?torrent=$row[id]\"><img border=\"0\" src=\"pic/bookmark.gif\" alt=\"".$tracker_lang['bookmark_this']."\" title=\"".$tracker_lang['bookmark_this']."\" /></a>\n");

         print("<a href=\"download.php?id=$id&amp;name=" . rawurlencode($row["filename"]) . "\"><img src=\"pic/download.gif\" border=\"0\" alt=\"".$tracker_lang['download']."\" title=\"".$tracker_lang['download']."\"></a>\n");

      if ($CURUSER["id"] == $row["owner"] || get_user_class() >= UC_MODERATOR)
         $owned = 1;
      else
         $owned = 0;

            if ($owned)
         print("<a href=\"edit.php?id=$row[id]\"><img border=\"0\" src=\"pic/pen.gif\" alt=\"".$tracker_lang['edit']."\" title=\"".$tracker_lang['edit']."\" /></a>\n");

            if ($row["readtorrent"] == 0 && $variant == "index")
               print ("<b><font color=\"red\" size=\"1\">[новый]</font></b>");

         print("<br /><i>".$row["added"]."</i>");

                        if ($wait)
                        {
                          $elapsed = floor((gmtime() - strtotime($row["added"])) / 3600);
            if ($elapsed < $wait)
            {
              $color = dechex(floor(127*($wait - $elapsed)/48 + 128)*65536);
              print("<td align=\"center\"><nobr><a href=\"faq.php#dl8\"><font color=\"$color\">" . number_format($wait - $elapsed) . " h</font></a></nobr></td>\n");
            }
            else
              print("<td align=\"center\"><nobr>".$tracker_lang['no']."</nobr></td>\n");
      }

   print("</td>\n");

      if ($variant == "mytorrents") {
         print("<td align=\"right\">");
         if ($row["visible"] == "no")
            print("<font color=\"red\"><b>".$tracker_lang['no']."</b></font>");
         else
            print("<font color=\"green\">".$tracker_lang['yes']."</font>");
         print("</td>\n");
      }

      if ($row["type"] == "single")
         print("<td align=\"right\">" . $row["numfiles"] . "</td>\n");
      else {
         if ($variant == "index")
            print("<td align=\"right\"><b><a href=\"details.php?id=$id&amp;hit=1&amp;filelist=1\">" . $row["numfiles"] . "</a></b></td>\n");
         else
            print("<td align=\"right\"><b><a href=\"details.php?id=$id&amp;filelist=1#filelist\">" . $row["numfiles"] . "</a></b></td>\n");
      }

      if (!$row["comments"])
         print("<td align=\"right\">" . $row["comments"] . "</td>\n");
      else {
         if ($variant == "index")
            print("<td align=\"right\"><b><a href=\"details.php?id=$id&amp;hit=1&amp;tocomm=1\">" . $row["comments"] . "</a></b></td>\n");
         else
            print("<td align=\"right\"><b><a href=\"details.php?id=$id&amp;page=0#startcomments\">" . $row["comments"] . "</a></b></td>\n");
      }

//      print("<td align=center><nobr>" . str_replace(" ", "<br />", $row["added"]) . "</nobr></td>\n");
            $ttl = ($ttl_days*24) - floor((gmtime() - sql_timestamp_to_unix_timestamp($row["added"])) / 3600);
            if ($ttl == 1) $ttl .= " час"; else $ttl .= "&nbsp;часов";
      if ($use_ttl)
         print("<td align=\"center\">$ttl</td>\n");
      print("<td align=\"center\">" . str_replace(" ", "<br />", mksize($row["size"])) . "</td>\n");
//      print("<td align=\"right\">" . $row["views"] . "</td>\n");
//      print("<td align=\"right\">" . $row["hits"] . "</td>\n");

      print("<td align=\"center\">");

      if ($row["seeders"]) {
         if ($variant == "index")
         {
            if ($row["leechers"]) $ratio = $row["seeders"] / $row["leechers"]; else $ratio = 1;
            print("<b><a href=\"details.php?id=$id&amp;hit=1&amp;toseeders=1\"><font color=" .
              get_slr_color($ratio) . ">" . $row["seeders"] . "</font></a></b>\n");
         }
         else
            print("<b><a class=\"" . linkcolor($row["seeders"]) . "\" href=\"details.php?id=$id&amp;dllist=1#seeders\">" .
              $row["seeders"] . "</a></b>\n");
      }
      else
         print("<span class=\"" . linkcolor($row["seeders"]) . "\">" . $row["seeders"] . "</span>");

      print(" | ");

      if ($row["leechers"]) {
         if ($variant == "index")
            print("<b><a href=\"details.php?id=$id&amp;hit=1&amp;todlers=1\">" .
               number_format($row["leechers"]) . ($peerlink ? "</a>" : "") .
               "</b>\n");
         else
            print("<b><a class=\"" . linkcolor($row["leechers"]) . "\" href=\"details.php?id=$id&amp;dllist=1#leechers\">" .
              $row["leechers"] . "</a></b>\n");
      }
      else
         print("0\n");

      print("</td>");

      if ($variant == "index" || $variant == "bookmarks")
         print("<td align=\"center\">" . (isset($row["username"]) ? ("<a href=\"userdetails.php?id=" . $row["owner"] . "\"><b>" . get_user_class_color($row["class"], htmlspecialchars_uni($row["username"])) . "</b></a>") : "<i>(unknown)</i>") . "</td>\n");

      if ($variant == "bookmarks")
         print ("<td align=\"center\"><input type=\"checkbox\" name=\"delbookmark[]\" value=\"" . $row[bookmarkid] . "\" /></td>");

      if ((get_user_class() >= UC_MODERATOR) && $variant == "index") {
         if ($row["moderated"] == "no")
            print("<td align=\"center\"><font color=\"red\"><b>Нет</b></font></td>\n");
         else
            print("<td align=\"center\"><a href=\"userdetails.php?id=$row[moderatedby]\"><font color=\"green\"><b>Да</b></font></a></td>\n");
      }

      if ((get_user_class() >= UC_MODERATOR) && $variant == "index")
         print("<td align=\"center\"><input type=\"checkbox\" name=\"delete[]\" value=\"" . $id . "\" /></td>\n");

   print("</tr>\n");

   }

   print("</tbody>");

   if ($variant == "index" && $CURUSER)
      print("<tr><td class=\"colhead\" colspan=\"12\" align=\"center\"><a href=\"markread.php\" class=\"altlink_white\">Все торренты прочитаны</a></td></tr>");

   //print("</table>\n");

   if ($variant == "index") {
      if (get_user_class() >= UC_MODERATOR) {
         print("<tr><td align=\"right\" colspan=\"12\"><input type=\"submit\" value=\"Удалить\"></td></tr>\n");
      }
   }

   if ($variant == "bookmarks")
      print("<tr><td colspan=\"12\" align=\"right\"><input type=\"submit\" value=\"".$tracker_lang['delete']."\"></td></tr>\n");

   if ($variant == "index" || $variant == "bookmarks") {
      if (get_user_class() >= UC_MODERATOR) {
         print("</form>\n");
      }
   }

   return $rows;
}


Тоесть кэш у нас такого видабудет: if (!$sam_zapros = $cache->get('luboe_nazvanie'.$list)), где лист -это номер страници в бровсе, т.е. страница с торрентами (1,2, 3, и тд)
vk
Активный участник
 
Сообщения: 95
Зарегистрирован: 22 фев 2009, 15:24

Пред.

Вернуться в PHP, HTML, CSS...

Кто сейчас на конференции

Сейчас этот форум просматривают: Yandex [bot] и гости: 28

cron