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

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

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

    
$TMPL['header'] = $LNG['a_man_site_header'];

    if (isset(
$FORM['category'])) 
    {
      
$category intval($FORM['category']);
    }
    else {
      
$category 0;
    }

    
$categories_menu "<select name="category">n";
    foreach (
$CONF['categories'] as $idcat => $cat
    {
      
$categories_menu .= "<option value="">{$cat}</option>n";

      if(!isset(
$CONF['subcategories'][$idcat])) continue;
      foreach (
$CONF['subcategories'][$idcat] as $id => $subcat
      {
        if(
$category==$id)  $categories_menu .= "<option value="{$id}" selected>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;{$subcat}</option>n";
        else {
$categories_menu .= "<option value="{$id}">&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;{$subcat}</option>n";}
      }
    }
    
$categories_menu .= "</select>";

    
$TMPL['admin_content'] .= <<<EndHTML
<form action="index.php" method="get">
<input type="hidden" name="a" value="admin" />
<input type="hidden" name="b" value="manage_site" />
{$categories_menu}
<input type="submit" class="ButtonNormal" value="
{$LNG['a_subcat_view']}" />
</form><br>
EndHTML;

    if(
$category){list($num_sites) = $DB->fetch("SELECT COUNT(*) FROM {$CONF['sql_prefix']}_sites where idsubcat='{$category}' and add_admin='0' and check_admin ='1'"__FILE____LINE__);}
    else {list(
$num_sites) = $DB->fetch("SELECT COUNT(*) FROM {$CONF['sql_prefix']}_sites where add_admin='0'"__FILE____LINE__);}

    
//адрес этой страницы
    
$template_href="{$CONF['site_url']}?a=admin&b=manage_site";
    if(
$category){$template_href="{$CONF['site_url']}?a=admin&b=manage_site&category={$category}";}

    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="{$template_href}&pp=$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="{$template_href}&p=1&pp=$pp">1</a>&nbsp;";  //ссылка на самую первую страницу
                                   
$TMPL['page_menu'] .= "<a href="{$template_href}&p={$prev_page}&pp=$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="{$template_href}&p=$i&pp=$pp">$i</a>&nbsp;";

      }
      if(
$number_end_page $num_page) {
                                          
$next_page $number_end_page+1;
                                          
$TMPL['page_menu'] .= "<a href="{$template_href}&p={$next_page}&pp=$pp">...</a>&nbsp;";
                                          
$TMPL['page_menu'] .= "<a href="{$template_href}&p={$num_page}&pp=$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="{$template_href}&p={$PrevPage}&pp={$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="{$template_href}&p={$NextPage}&pp={$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['admin_content'] .= <<<EndHTML
<table width="100%">
<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>
</table>
EndHTML;


    
$TMPL['admin_content'] .= <<<EndHTML
<script language="javascript">
function check(form_name, field_name, value)
{
  var check_boxes = document.forms[form_name].elements[field_name];
  var num_check_boxes = check_boxes.length;

  if (!num_check_boxes)
  {
    check_boxes.checked = value;
  }
  else {
    for(var i = 0; i < num_check_boxes; i++)
    {
      check_boxes[i].checked = value;
    }
  }
}
</script>

<form action="
{$TMPL['site_url']}/index.php?a=admin&amp;b=delete_site" method="post" name="manage">
EndHTML;

    
$alt '';
    
$num 0;

    if(
$category){      $result $DB->select_limit("SELECT id, idsubcat, description, name, URL, email, visib, num_views, check_flag, check_possible, user_ip, banner_url FROM {$CONF['sql_prefix']}_sites where idsubcat='{$category}' and add_admin='0' and check_admin ='1' order by {$CONF['site_sorting_field']} {$CONF['site_sorting']}"$pp$start__FILE____LINE__);}
    else
    {
      
$result $DB->select_limit("SELECT id, idsubcat, description, name, URL, email, visib, num_views, check_flag, check_possible, user_ip, banner_url FROM {$CONF['sql_prefix']}_sites where add_admin='0' and check_admin ='1' order by {$CONF['site_sorting_field']} {$CONF['site_sorting']}"$pp$start__FILE____LINE__);
    }

    while (list(
$id$idsubcat$description$name$url$email$visib$num_views$check_flag$check_possible$user_ip$banner_url) = $DB->fetch_array($result))
    {
      list(
$subcatname) = $DB->fetch("SELECT name FROM {$CONF['sql_prefix']}_subcat WHERE id='{$idsubcat}'"__FILE____LINE__);

      if(
strlen($description) > $CONF['cut_descr'] and $CONF['cut_descr']!=0)
      {
        
$description substr($description0$CONF['cut_descr']);
        
$description .= "...";
        if(
$CONF['type_link']) {$html_cod="<a href="{$url}" target=blank><b>{$name}</b></a><br>{$description}";}
        else {
$html_cod="<a href="{$CONF['site_url']}/?a=redirect&id={$id}" target=blank><b>{$name}</b></a><br>{$description}";}
      }else
      {
         if(
$CONF['type_link']) {$html_cod="<a href="{$url}" target=blank><b>{$name}</b></a><br>{$description}";}
         else {
$html_cod="<a href="{$CONF['site_url']}/?a=redirect&id={$id}" target=blank><b>{$name}</b></a><br>{$description}";}
      }

      
$bl_status='';
      if(
$CONF['backlink_require'])
      {
        if(
$check_possible)
        {
          if(
$visib and $check_flag$bl_status "<a href="{$TMPL['site_url']}/index.php?a=admin&amp;b=check_backlink&amp;id={$id}" target="blank">{$LNG['a_add_bl_fnd']}</a>";
          if(!
$visib and $check_flag$bl_status "<a href="{$TMPL['site_url']}/index.php?a=admin&amp;b=check_backlink&amp;id={$id}" target="blank">{$LNG['a_add_bl_notfnd']}</a>";
          if(!
$visib and !$check_flag$bl_status "<a href="{$TMPL['site_url']}/index.php?a=admin&amp;b=check_backlink&amp;id={$id}" target="blank">{$LNG['a_add_bl_notch']}</a>";
        }
        else {
$bl_status $LNG['a_add_bl_empty'];}
      }
      else {
$bl_status $LNG['a_add_bl_notreq'];}

      
$TMPL['admin_content'] .= <<<EndHTML
<table cellpadding="1" cellspacing="0" width="100%" border=0 class="ListSitesTable">
<tr>
 <td width=3% align="center"><input type="checkbox" name="id[]" value="
{$id}" id="checkbox_{$num}" /></td>
 <td>
  <table cellpadding="1" cellspacing="1" width="100%" border=0>
   <tr align="center"><td colspan="3">
{$html_cod}</td></tr>
   <tr class="lightbgalt"><td width=15%>
{$LNG['a_add_site_id']}</td><td><a href="{$CONF['site_url']}/?a=site&id=$id" target=blank>{$id}</a></td><td width=15%></td></tr>
   <tr class="lightbg"><td>             
{$LNG['a_add_site']}</td><td><a href="{$url}" target=blank>{$url}</a></td><td></td></tr>
   <tr class="lightbgalt"><td>          
{$LNG['a_man_site_banner']}</td><td><a href="{$url}" target=blank><img src="{$banner_url}" width="{$CONF['max_banner_width']}" height="{$CONF['max_banner_height']}" border="0" title="{$name}"></a></td><td></td></tr>
   <tr class="lightbg"><td>          
{$LNG['g_email']}</td><td>{$email}</td><td></td></tr>
   <tr class="lightbgalt"><td>          
{$LNG['a_add_site_cat']}</td><td>{$subcatname}</td><td></td></tr>
   <tr class="lightbg"><td>          
{$LNG['a_add_site_bl']}</td><td>{$bl_status}</td><td >{$bl_action}</td></tr>

   <tr class="lightbgalt"><td>
{$LNG['g_add_from_ip']}</td><td>{$user_ip}</td><td></td></tr>
   <tr class="lightbg"><td>             
{$LNG['g_views']}</td><td>$num_views</td><td></td></tr>
   <tr class="lightbgblue"><td><a href="
{$TMPL['site_url']}/index.php?a=admin&amp;b=edit_site&amp;id={$id}">{$LNG['a_cat_edit']}</a></td><td></td><td><a href="{$TMPL['site_url']}/index.php?a=admin&amp;b=delete_site&amp;id={$id}">{$LNG['a_cat_delete']}</a></td></tr>
  </table>
 </td>
</tr>
</table><br>
EndHTML;
 
    }

    
$TMPL['admin_content'] .= <<<EndHTML
<br>
<table width="100%">
<tr><td colspan="2"><hr width=100% size="1" class="SeparatorHr"></td></tr>
<tr><td colspan="2" align=center>
{$TMPL['page_menu']}</td></tr>
</table>
<a href="javascript:void;" onclick="check('manage', 'id[]', true)">
{$LNG['a_man_all']}</a> | 
<a href="javascript:void;" onclick="check('manage', 'id[]', false)">
{$LNG['a_man_none']}</a><br><br>
<input type="submit" class="ButtonNormal" value="
{$LNG['a_man_del_sel']}" />
</form>
EndHTML;
  }
}
?>
Онлайн: 2
Реклама