Вход Регистрация
Файл: sources/cat.php
Строк: 209
<?php

if (!defined('VAPHP')) 
{
  die(
"Этот файл недоступен.");
}

class 
cat extends base
{
  function 
cat()
  {
    global 
$FORM$TMPL$LNG$DB$CONF;

    if (isset(
$FORM['id']) and !empty($FORM['id'])) 
    {
      
$id intval($FORM['id']);
      list(
$catname) = $DB->fetch("SELECT name FROM {$CONF['sql_prefix']}_cat WHERE id = '$id'"__FILE____LINE__);
      if (empty(
$catname))
      {
        
$TMPL['header'] = $LNG['g_error'];
        
$base = new base;
        
$base->error($LNG['g_page_empty']);
      }
      
$TMPL['header'] = "{$catname}";

      
$TMPL['navmenu'] = "<span class="PathMenu"><a href="{$CONF['site_url']}">{$LNG['main_menu_index']}</a>&nbsp;&nbsp;<img src="{$CONF['skins_image']}/bullet.gif">&nbsp;&nbsp;$catname</span>";

      list(
$num_sites) = $DB->fetch("SELECT COUNT(*) FROM {$CONF['sql_prefix']}_sites, {$CONF['sql_prefix']}_subcat WHERE {$CONF['sql_prefix']}_subcat.idcat='{$id}' and {$CONF['sql_prefix']}_subcat.id={$CONF['sql_prefix']}_sites.idsubcat and {$CONF['sql_prefix']}_sites.visib = '1'"__FILE____LINE__);

      if (
$FORM['pp'])
      {
        
$pp intval($FORM['pp']);
        if (
$pp $CONF['sites_per_page'][0]) {$pp $CONF['sites_per_page'][0];}
      }
      else {
$pp $CONF['sites_per_page'][0];}

      foreach(
$CONF['sites_per_page'] as $value)
      {
        if (
$pp == $value) {$per_page_menu.= "<b>$value</b>&nbsp;&nbsp;";}
        else{
        
$per_page_menu.=<<<EndHTML
<a href="{$CONF['site_url']}/cat/{$id}/$value">{$value}</a>&nbsp;&nbsp;
EndHTML;
        }
      }
      
      if (isset(
$FORM['p']))
      {
        
$p intval ($FORM['p']);

        if (
$p ceil($num_sites/$pp) || $p 1) {$p=1;} //если номер страницы больше максимально возможного - присваиваем ему значение 1

        
$start intval($p 1);
        if (
$start 0$start=0;
        
$start $start $pp;
      }
      else
      {
        
$p 1;
        
$start 0;
      }
      
      if(
$num_sites $pp)  //проверка необходимости в постраничном выводе
      
{
        
$TMPL['page_menu'] = '';
        
$num_page ceil($num_sites/$pp);                         //количество страниц
        
$PrevPage $p-1;
        
$NextPage $p+1;
        
        
//определение переменных для счетчика цикла
        
if($num_page $CONF['lenght_pp_block']){
          
$left_pages floor(($CONF['lenght_pp_block']-1)/2);

          
$number_start_page $p-$left_pages;
          if(
$number_start_page <= 0) {$number_start_page 1;}

          
$number_end_page $number_start_page $CONF['lenght_pp_block']-1;
          if(
$number_end_page $num_page) {$number_end_page $num_page$number_start_page $number_end_page-$CONF['lenght_pp_block']+1;}
        }else
        {
          
$number_start_page 1;
          
$number_end_page $num_page;
        }
//само построение кода постраничного вывода
        
if($number_start_page 1) {
                                     
$prev_page $number_start_page-1;
                                     
$TMPL['page_menu'] .= "<a href="{$CONF['site_url']}/cat/{$id}/1/$pp">1</a>&nbsp;";  //ссылка на самую первую страницу
                                     
$TMPL['page_menu'] .= "<a href="{$CONF['site_url']}/cat/{$id}/{$prev_page}/$pp">...</a>&nbsp;";  //
                                   
}
                                   
        for(
$i=$number_start_page$i<=$number_end_page$i++)
        {
          if(
$i == $p)
          
$TMPL['page_menu'] .= "<b>$i</b>&nbsp;";
          else
          
$TMPL['page_menu'] .= "<a href="{$CONF['site_url']}/cat/{$id}/$i/$pp">$i</a>&nbsp;";

        }
        if(
$number_end_page $num_page) {
                                          
$next_page $number_end_page+1;
                                          
$TMPL['page_menu'] .= "<a href="{$CONF['site_url']}/cat/{$id}/{$next_page}/$pp">...</a>&nbsp;";
                                          
$TMPL['page_menu'] .= "<a href="{$CONF['site_url']}/cat/{$id}/{$num_page}/$pp">$num_page</a>&nbsp;";
                                         }


        if(
$p <= 1) {$TMPL['AtStart'] = "<span class=AtStart><IMG style="BORDER-TOP-WIDTH0pxBORDER-LEFT-WIDTH0pxBORDER-BOTTOM-WIDTH0pxBORDER-RIGHT-WIDTH0px" src="{$CONF['skins_image']}/button_prev.gif"></span>";}
        else {
$TMPL['AtStart'] = "<a href="{$CONF['site_url']}/cat/{$id}/{$PrevPage}/{$pp}" class=AtStart><IMG style="BORDER-TOP-WIDTH0pxBORDER-LEFT-WIDTH0pxBORDER-BOTTOM-WIDTH0pxBORDER-RIGHT-WIDTH0px" src="{$CONF['skins_image']}/button_prev_act.gif"></a>";}
        
        if(
$p >= $num_page) {$TMPL['AtEnd']="<a class=AtEnd><IMG style="BORDER-TOP-WIDTH0pxBORDER-LEFT-WIDTH0pxBORDER-BOTTOM-WIDTH0pxBORDER-RIGHT-WIDTH0px" src="{$CONF['skins_image']}/button_next.gif"></a>";}
        else {
$TMPL['AtEnd']="<a href="{$CONF['site_url']}/cat/{$id}/{$NextPage}/{$pp}" class=AtEnd><IMG style="BORDER-TOP-WIDTH0pxBORDER-LEFT-WIDTH0pxBORDER-BOTTOM-WIDTH0pxBORDER-RIGHT-WIDTH0px" src="{$CONF['skins_image']}/button_next_act.gif"></a>";}

        
$TMPL['page_menu'] = $TMPL['AtStart'].$TMPL['page_menu'].$TMPL['AtEnd'];
        
$TMPL['page_menu']="<div class="PagingStrip">".$TMPL['page_menu']."</div>";
//конец построение кода постраничного вывода
      
}
      
      
$num_first_site $start 1;
      
$num_final_site $num_first_site $pp 1;
      if (
$num_final_site $num_sites) {$num_final_site $num_sites;}
      
$LNG['g_number_of_all'] = sprintf($LNG['g_number_of_all'], $num_first_site$num_final_site$num_sites);
      
      if (
$num_sites != 0)         $TMPL['list_sites'] .= <<<EndHTML
<tr><td colspan="2">
  <table width="100%" border=0>
   <tr>
    <td width="33%"></td>
    <td width="33%" align="center"><span class="GreyTextNormal">
{$LNG['g_number_of_all']}</span></td>
    <td width="33%" align="right"><span class="GreyTextSmall">
{$LNG['g_sites_per_page']}&nbsp;&nbsp;<img src="{$CONF['skins_image']}/arrow_right.gif">&nbsp;&nbsp;$per_page_menu</span></td>
   </tr>
  </table>
</td></tr>
<tr><td colspan="2"><hr width=100% size="1" class="SeparatorHr2"></td></tr>
<tr><td colspan="2" align=center>
{$TMPL['page_menu']}</td></tr>
<tr><td colspan="2"><hr width=100% size="1" class="SeparatorHr"></td></tr>
EndHTML;


      
//формирование списка сайтов
      
$result $DB->select_limit("SELECT {$CONF['sql_prefix']}_sites.id, {$CONF['sql_prefix']}_sites.banner_url, {$CONF['sql_prefix']}_sites.URL, {$CONF['sql_prefix']}_sites.name, {$CONF['sql_prefix']}_sites.description, {$CONF['sql_prefix']}_sites.num_views, {$CONF['sql_prefix']}_sites.add_admin FROM {$CONF['sql_prefix']}_sites, {$CONF['sql_prefix']}_subcat WHERE {$CONF['sql_prefix']}_subcat.idcat='{$id}' and {$CONF['sql_prefix']}_subcat.id={$CONF['sql_prefix']}_sites.idsubcat and {$CONF['sql_prefix']}_sites.visib = '1' order by {$CONF['site_sorting_field']} {$CONF['site_sorting']}"$pp$start__FILE____LINE__);
      while(
$result_sites_fetch=mysql_fetch_array($result))
      {
        if(
$result_sites_fetch['add_admin']){$html_cod $result_sites_fetch['description']; $href_button "{$CONF['site_url']}/site/{$result_sites_fetch['id']}";}
        else
        {
          if(
strlen($result_sites_fetch['description']) > $CONF['cut_descr'] and $CONF['cut_descr']!=0)
          {
              
$TMPL['meta_description']=substr($result_sites_fetch['description'], 0160);
              
$TMPL['meta_description'] = substr($TMPL['meta_description'],0,strrpos($TMPL['meta_description']," "));
              
$TMPL['meta_keywords']="";
            
$description substr($result_sites_fetch['description'], 0$CONF['cut_descr']);
            
$description .= "...";
            
$description =$this->fnrepl($description);
            
$html_cod="<a href="{$CONF['site_url']}/site/{$result_sites_fetch['id']}"><b>{$result_sites_fetch['name']}</b></a><br>{$description}";
          }else
          {
            
$html_cod="<a href="{$CONF['site_url']}/site/{$result_sites_fetch['id']}"><b>{$result_sites_fetch['name']}</b></a><br>{$result_sites_fetch['description']}";
          }
            
$href_button "{$CONF['site_url']}/site/{$result_sites_fetch['id']}";
        }

        
$TMPL['list_sites'] .= <<<EndHTML
<tr>
  <td><a href="
{$href_button}"><img src="{$result_sites_fetch['banner_url']}" width="{$CONF['max_banner_width']}" height="{$CONF['max_banner_height']}" border="0" title="{$result_sites_fetch['name']}"></a></td>
  <td width=100%>
    <table width=100%>
    <tr><td colspan="2">
$html_cod</td></tr>
    <tr>
      <td width=50%>
{$LNG['g_views']}:&nbsp;{$result_sites_fetch['num_views']}</td>
      <td><a href="
{$CONF['site_url']}/site/{$result_sites_fetch['id']}">{$LNG['g_detail']} >></a></td>
    </tr>
    </table>
  </td>
</tr>

<tr><td colspan="2"><hr width=100% size="1" class="SeparatorHr"></td></tr>
EndHTML;
      }
      
$TMPL['content'] = $this->do_skin('list_sites');
    }
    else
    { 
      
$TMPL['header'] = $LNG['g_error'];
      
$base = new base;
      
$base->error($LNG['g_page_empty']);
    }
  }
}
?>
Онлайн: 1
Реклама