Guest User

Untitled

a guest
May 2nd, 2010
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 44.57 KB | None | 0 0
  1. <?php
  2. /*********************/
  3. /*                   */
  4. /*  Version : 5.1.0  */
  5. /*  Author  : RM     */
  6. /*  Comment : 071223 */
  7. /*                   */
  8. /*********************/
  9.  
  10. if ( !defined( "DATALIFEENGINE" ) )
  11. {
  12.     exit( "Hacking attempt!" );
  13. }
  14. $sblocks = get_vars( "sblocks" );
  15. if ( !is_array( $sblocks ) )
  16. {
  17.     $sblocks = array( );
  18.     $db->query( "SELECT * FROM ".PREFIX."_sblocks ORDER BY id ASC" );
  19.     while ( $row_s = $db->get_row( ) )
  20.     {
  21.         $sblocks[$row_s['title']] = array( );
  22.         foreach ( $row_s as $key => $value )
  23.         {
  24.             $sblocks[$row_s['title']][$key] = stripslashes( $value );
  25.         }
  26.     }
  27.     set_vars( "sblocks", $sblocks );
  28.     $db->free( );
  29. }
  30. $sbl = array( );
  31. $ajax_prefix = "_page_1";
  32. if ( $ajax_title && $ajax_start )
  33. {
  34.     $cstart = $ajax_start;
  35.     $ajax_prefix = "_page_".$cstart;
  36. }
  37. if ( 0 < count( $sblocks ) )
  38. {
  39.     require_once( ENGINE_DIR."/classes/parse.class.php" );
  40.     $parse = new parsefilter( );
  41.     function sblocks_descr( $story, $num = 0 )
  42.     {
  43.         global $db;
  44.         global $parse;
  45.         $fastquotes = array( "\"", "`", "\t", "\n", "\r", "\"", "\\r", "\\n", "/", "\\", "{", "}", "[", "]" );
  46.         $story = preg_replace( "'\\[hide\\](.*?)\\[/hide\\]'si", "", $story );
  47.         $story = preg_replace( "'\\[attachment=(.*?)\\]'si", "", $story );
  48.         $story = preg_replace( "'\\[page=(.*?)\\](.*?)\\[/page\\]'si", "", $story );
  49.         $story = str_replace( "{PAGEBREAK}", "", $story );
  50.         $story = str_replace( "&nbsp;", " ", $story );
  51.         $story = str_replace( "<br />", " ", $story );
  52.         $story = trim( strip_tags( $story ) );
  53.         $story = str_replace( $fastquotes, "", $story );
  54.         if ( $num )
  55.         {
  56.             $story = $db->safesql( substr( $story, 0, $num ) )."...";
  57.             return $story;
  58.         }
  59.         $story = $db->safesql( $story );
  60.         return $story;
  61.     }
  62.     function sblocks_attach( $id )
  63.     {
  64.         global $db;
  65.         global $config;
  66.         global $lang;
  67.         global $user_group;
  68.         global $member_id;
  69.         if ( is_array( $id ) && count( $id ) )
  70.         {
  71.             $where = "news_id IN (".implode( ",", $id ).")";
  72.         }
  73.         else
  74.         {
  75.             $where = "news_id = '".$id."'";
  76.         }
  77.         $link = "";
  78.         $sql_files = $db->query( "SELECT id, name, onserver, dcount FROM ".PREFIX.( "_files WHERE ".$where ) );
  79.         while ( ( $row = $db->get_row( $sql_files ) ) && $row['id'] )
  80.         {
  81.             $size = formatsize( @filesize( ROOT_DIR."/uploads/files/".$row['onserver'] ) );
  82.             $row['name'] = explode( "/", $row['name'] );
  83.             $row['name'] = end( $row['name'] );
  84.             if ( !$user_group[$member_id['user_group']]['allow_files'] )
  85.             {
  86.                 $link .= "<span class=\"attachment\">".$lang['att_denied']."</span>";
  87.             }
  88.             else if ( $config['files_count'] == "yes" )
  89.             {
  90.                 $link .= "<span class=\"attachment\"><a href=\"".$config['http_home_url']."engine/download.php?id={$row['id']}\" >{$row['name']}</a> [{$size}] ({$lang['att_dcount']} {$row['dcount']})</span>";
  91.             }
  92.             else
  93.             {
  94.                 $link .= "<span class=\"attachment\"><a href=\"".$config['http_home_url']."engine/download.php?id={$row['id']}\" >{$row['name']}</a> [{$size}]</span>";
  95.             }
  96.         }
  97.         $db->free( );
  98.         return $link;
  99.     }
  100.     function sblocks_time( )
  101.     {
  102.         list( $usec, $sec ) = explode( " ", microtime( ) );
  103.         return ( double )$usec + ( double )$sec;
  104.     }
  105.     function sblocks_thumb( $title, $image, $size = "auto" )
  106.     {
  107.         list( $width, $height ) = explode( ",", $size );
  108.         if ( $width == "auto" )
  109.         {
  110.             $width = "";
  111.         }
  112.         else if ( $width )
  113.         {
  114.             $width = "width=\"".$width."px\"";
  115.         }
  116.         else
  117.         {
  118.             return;
  119.         }
  120.         if ( !$height && $height == "auto" )
  121.         {
  122.             $height = "";
  123.         }
  124.         else
  125.         {
  126.             $height = "height=\"".$height."px\"";
  127.         }
  128.         return "<img src=\"".$image."\" title=\"".$title."\" ".$width." ".$height." alt=\"\" />";
  129.     }
  130.     if ( isset( $_REQUEST['cstart'] ) )
  131.     {
  132.         $cstart = intval( $_GET['cstart'] );
  133.     }
  134.     else
  135.     {
  136.         $cstart = 1;
  137.     }
  138.     foreach ( $sblocks as $name => $value )
  139.     {
  140.         $sblocks_start = sblocks_time( );
  141.         if ( !$value['approve'] && $ajax_title && $value['title'] != $ajax_title )
  142.         {
  143.             if ( $value['sertificate'] != md5( md5( md5( md5( md5( md5( trim( $value['title'].$value['sort'] ) ) ) ) ) ) ) )
  144.             {
  145.                 $sbl[$value['title']][] = "<div style=\"margin:10px 0;padding:10px; text-align:center; background:#f00; color:#bbb;font: bold 11px Tahoma;border:1px solid #000;\">Unregistered copy of <a style=\"color:#fff;\">\"S-Blocks v1.7 by Sander\"</a><br/>Visit: <a style=\"color:#fff;\" href=\"http://nfhelp.ru/\">http://nfhelp.ru/</a><br/>ICQ: <a style=\"color:#fff;\">404-037-556</a></div>";
  146.             }
  147.             else
  148.             {
  149.                 $cat_info = $cat_info ? $cat_info : get_vars( "category" );
  150.                 if ( $value['category'] != "all" )
  151.                 {
  152.                     $vald = explode( ",", $value['category'] );
  153.                     if ( $value['allow_sub_cats'] )
  154.                     {
  155.                         $i = 0;
  156.                         for ( ; $i < count( $vald );    ++$i    )
  157.                         {
  158.                             $vald[$i] = get_sub_cats( $vald[$i] );
  159.                         }
  160.                     }
  161.                     $value['category'] = implode( "|", $vald );
  162.                     $valc = explode( "|", $value['category'] );
  163.                 }
  164.                 else
  165.                 {
  166.                     $valc = array( );
  167.                     foreach ( $cat_info as $cats )
  168.                     {
  169.                         $valc[] = $cats['id'];
  170.                     }
  171.                 }
  172.                 $lim = $value['rows'] * $value['cols'];
  173.                 if ( $value['title'] != "content" )
  174.                 {
  175.                     $begin = $ajax_start ? ( $ajax_start - 1 ) * $lim : 0;
  176.                     if ( $value['fromcat'] && $value['catsel'] )
  177.                     {
  178.                         if ( !$category_id && !in_array( $category_id, $valc ) )
  179.                         {
  180.                             if ( $value['allow_sub_cats'] )
  181.                             {
  182.                                 $value['category'] = get_sub_cats( $category_id );
  183.                             }
  184.                             else
  185.                             {
  186.                                 $value['category'] = $category_id;
  187.                             }
  188.                         }
  189.                     }
  190.                     if ( $value['catsel'] && !$value['fromcat'] )
  191.                     {
  192.                         if ( !$category_id && !in_array( $category_id, $valc ) )
  193.                         {
  194.                             $value['approve'] = "1";
  195.                         }
  196.                     }
  197.                     if ( $value['fromcat'] && !$value['catsel'] || $category_id )
  198.                     {
  199.                         $value['category'] = $category_id;
  200.                     }
  201.                     if ( $value['fromcat'] && $category_id )
  202.                     {
  203.                         $code = dle_cache( "sblocks_".$value['title']."_category_".$cat_info[$category_id]['alt_name'].$ajax_prefix );
  204.                     }
  205.                     else
  206.                     {
  207.                         $code = dle_cache( "sblocks_".$value['title'].$ajax_prefix );
  208.                     }
  209.                 }
  210.                 if ( $value['force_cache'] || $value['sort'] == "RAND()" || $value['title'] == "content" )
  211.                 {
  212.                     $code = "";
  213.                 }
  214.                 if ( !$code )
  215.                 {
  216.                     $now = date( "Y-m-d H:i:s", $_TIME );
  217.                     if ( !$value['data'] && $value['data'] < 1 )
  218.                     {
  219.                         $datag = " AND date<'".$now."'";
  220.                     }
  221.                     else
  222.                     {
  223.                         $datag = " AND date >= '".$now."' - INTERVAL ".$value['data'].( " DAY AND date < '".$now."'" );
  224.                     }
  225.                     if ( $value['from_date'] && $value['to_date'] )
  226.                     {
  227.                         $from_date = $value['from_date'];
  228.                         $to_date = $value['to_date'];
  229.                         if ( $now < $to_date )
  230.                         {
  231.                             $to_date = $now;
  232.                         }
  233.                         $datag = " AND date>='".$from_date."' AND date<='{$to_date}'";
  234.                     }
  235.                     $where = "";
  236.                     if ( preg_match( "#({thumb}|{image}|{scr.?|{r-img}|\\[thumb|\\[image)#ies", $value['code'], $check_thumb ) && !$value['def_img'] )
  237.                     {
  238.                         $where .= " short_story LIKE '%src=%' AND";
  239.                         if ( preg_match( "#({scr.?|{r-img})#ies", $value['code'], $check_fimg ) )
  240.                         {
  241.                             $where .= " full_story LIKE '%src=%' AND";
  242.                         }
  243.                     }
  244.                     if ( preg_match( "#(\\{video\\}|\\{video-link\\}|\\[video=(.+)\\])#ies", $value['code'], $check_video ) )
  245.                     {
  246.                         $where .= " (short_story LIKE '%_video_%' OR full_story LIKE '%_video_%') AND ";
  247.                     }
  248.                     if ( preg_match( "#(\\{audio\\}|\\{audio-link\\}|\\[audio=(.+)\\])#ies", $value['code'], $check_audio ) )
  249.                     {
  250.                         $where .= " (short_story LIKE '%_audio_%' OR full_story LIKE '%_audio_%') AND ";
  251.                     }
  252.                     if ( $value['byid'] )
  253.                     {
  254.                         $where = " id regexp '[[:<:]](".$value[byid].")[[:>:]]' AND";
  255.                         $datag = " AND date<'".$now."'";
  256.                     }
  257.                     else
  258.                     {
  259.                         if ( $value['title'] != "content" )
  260.                         {
  261.                             if ( $value['category'] != "all" )
  262.                             {
  263.                                 $where .= " category regexp '[[:<:]](".$value[category].")[[:>:]]' AND";
  264.                             }
  265.                             if ( $value['from_main'] == 1 )
  266.                             {
  267.                                 $where .= " allow_main AND";
  268.                             }
  269.                             else if ( $value['from_main'] == 2 )
  270.                             {
  271.                                 $where .= " allow_main=0 AND";
  272.                             }
  273.                             if ( $value['sort'] == "RECOMMEND" )
  274.                             {
  275.                                 $where = " short_story LIKE '%<!--sblocks_recommend-->%' AND ";
  276.                                 $value['sort'] = "id ASC";
  277.                             }
  278.                             if ( preg_match( "#({reliz}|{reliz-date})#ies", $value['code'], $check_reliz ) )
  279.                             {
  280.                                 $where = " short_story LIKE '%<!--sblocks_reliz_begin-->%' AND ";
  281.                             }
  282.                         }
  283.                         else if ( $newsid )
  284.                         {
  285.                             if ( !$cstart && $cstart < 1 )
  286.                             {
  287.                                 $cstart = 1;
  288.                             }
  289.                             $begin = ( $cstart - 1 ) * $lim;
  290.                             $where = "";
  291.                             if ( $do == "lastnews" )
  292.                             {
  293.                                 $where = " approve AND";
  294.                                 $code = dle_cache( "sblocks_content_lastnews_page_".$cstart );
  295.                             }
  296.                             if ( $do == "tags" )
  297.                             {
  298.                                 $where = " id IN ".$tag_array." AND";
  299.                                 $code = dle_cache( "sblocks_content_tags_page_".$cstart );
  300.                                 $tag_array = array( );
  301.                                 unset( $tag_array );
  302.                             }
  303.                             if ( $subaction == "allnews" )
  304.                             {
  305.                                 $where = " autor = '".$user."' AND";
  306.                                 $code = dle_cache( "sblocks_content_allnews_page_".$cstart );
  307.                             }
  308.                             if ( $subaction == "newposts" )
  309.                             {
  310.                                 $where = " date between '".$lasttime."' and '{$thistime}' AND";
  311.                                 $code = dle_cache( "sblocks_content_newposts_page_".$cstart );
  312.                             }
  313.                             if ( $catalog != "" )
  314.                             {
  315.                                 $where = " symbol = '".$catalog."' AND";
  316.                                 $code = dle_cache( "sblocks_content_catalog_".$catalog."_page_".$cstart );
  317.                             }
  318.                             if ( $year != "" && $month == "" && $day == "" )
  319.                             {
  320.                                 $where = " date < '".$year."-01-01' + INTERVAL 1 YEAR AND";
  321.                                 $code = dle_cache( "sblocks_content_calendar_".$year."_page_".$cstart );
  322.                             }
  323.                             if ( $year != "" && $month != "" && $day == "" )
  324.                             {
  325.                                 $where = " date >= '".$year."-{$month}-01'AND date < '{$year}-{$month}-01' + INTERVAL 1 MONTH AND";
  326.                                 $code = dle_cache( "sblocks_content_calendar_".$year."_".$month."_page_".$cstart );
  327.                             }
  328.                             if ( $year != "" && $month != "" && $day != "" && $subaction == "" )
  329.                             {
  330.                                 $where = " date >= '".$year."-{$month}-{$day}' AND date < '{$year}-{$month}-{$day}' + INTERVAL 24 HOUR AND";
  331.                                 $code = dle_cache( "sblocks_content_calendar_".$year."_".$month."_".$day."_page_".$cstart );
  332.                             }
  333.                             if ( !$where )
  334.                             {
  335.                                 if ( !$category_id )
  336.                                 {
  337.                                     if ( $value['from_main'] == 1 )
  338.                                     {
  339.                                         $where .= " allow_main AND";
  340.                                     }
  341.                                     else if ( $value['from_main'] == 2 )
  342.                                     {
  343.                                         $where .= " allow_main=0 AND";
  344.                                     }
  345.                                 }
  346.                                 else if ( $value['allow_sub_cats'] )
  347.                                 {
  348.                                     $where .= " category regexp '[[:<:]](".get_sub_cats( $category_id ).")[[:>:]]' AND";
  349.                                 }
  350.                                 else
  351.                                 {
  352.                                     $where .= " category regexp '[[:<:]](".$category_id.")[[:>:]]' AND";
  353.                                 }
  354.                                 if ( $category_id && !$newsid )
  355.                                 {
  356.                                     $code = dle_cache( "sblocks_content_category_".$cat_info[$category_id]['alt_name']."_page_".$cstart );
  357.                                 }
  358.                                 else if ( $sblocks_content && !$newsid )
  359.                                 {
  360.                                     $code = dle_cache( "sblocks_content_page_".$cstart );
  361.                                 }
  362.                             }
  363.                             if ( $check_thumb && !$value['def_img'] )
  364.                             {
  365.                                 $where .= " short_story LIKE '%src=%' AND";
  366.                             }
  367.                             if ( $check_fimg && !$value['def_img'] )
  368.                             {
  369.                                 $where .= " full_story LIKE '%src=%' AND";
  370.                             }
  371.                         }
  372.                     }
  373.                     if ( !$value['force_cache'] || $value['sort'] == "RAND()" )
  374.                     {
  375.                         $code = "";
  376.                     }
  377.                     if ( !$code )
  378.                     {
  379.                         $value['code'] = str_replace( "&#39;", "'", $value['code'] );
  380.                         $colid = 0;
  381.                         $code = "<div id=\"sblocks_".$value['title']."\">\r";
  382.                         $sql_select = "SELECT id, autor, date, short_story, full_story, xfields, title, category, alt_name, comm_num, rating, vote_num, news_read, flag, descr FROM ".PREFIX."_post WHERE ".$where." approve ".$datag." ORDER BY ".$value[sort]." LIMIT ".$begin.", ".$lim;
  383.                         $sb_select = $db->query( $sql_select );
  384.                         while ( $rowc = $db->get_row( $sb_select ) )
  385.                         {
  386.                             if ( 1 < $value['cols'] )
  387.                             {
  388.                                 $code_temp = "\t<div style=\"float:left;width:".floor( 100 / $value['cols'] )."%;margin:0;padding:0;\">".$value['code']."</div>\r";
  389.                             }
  390.                             else
  391.                             {
  392.                                 $code_temp = "\t<div style=\"width:100%;margin:0;padding:0;\">".$value['code']."</div>\r";
  393.                             }
  394.                             $find = "";
  395.                             $replace = "";
  396.                             $findp = "";
  397.                             $replacep = "";
  398.                             $rowc['category'] = intval( $rowc['category'] );
  399.                             $rowc['date'] = strtotime( $rowc['date'] );
  400.                             if ( $value['title_words'] )
  401.                             {
  402.                                 $temp_title = explode( " ", $rowc['title'] );
  403.                             }
  404.                             if ( $value['title_cut'] && $value['title_cut'] < strlen( $rowc['title'] ) )
  405.                             {
  406.                                 $title = trim( substr( strip_tags( stripslashes( htmlspecialchars( $rowc['title'] ) ) ), 0, $value['title_cut'] ) )."...";
  407.                                 $title_trimmed = true;
  408.                             }
  409.                             else
  410.                             {
  411.                                 $title = strip_tags( stripslashes( htmlspecialchars( $rowc['title'] ) ) );
  412.                             }
  413.                             if ( $value['title_words'] && $title_trimmed )
  414.                             {
  415.                                 $temp_title_trim = explode( " ", $title );
  416.                                 if ( !in_array( end( $temp_title_trim ), $temp_title ) )
  417.                                 {
  418.                                     unset( $temp_title_trim[count( $temp_title_trim ) - 1] );
  419.                                 }
  420.                                 $title = implode( " ", $temp_title_trim );
  421.                             }
  422.                             $title = str_replace( "'", "`", $title );
  423.                             $title_full = strip_tags( stripslashes( htmlspecialchars( $rowc['title'] ) ) );
  424.                             $title_full = str_replace( "'", "`", $title_full );
  425.                             $find[] = "{title}";
  426.                             $replace[] = trim( $title );
  427.                             $find[] = "{title-full}";
  428.                             $replace[] = trim( $title_full );
  429.                             if ( $config['allow_alt_url'] == "yes" )
  430.                             {
  431.                                 if ( $rowc['flag'] && $config['seo_type'] )
  432.                                 {
  433.                                     if ( $rowc['category'] && $config['seo_type'] == 2 )
  434.                                     {
  435.                                         $full_link = $config['http_home_url'].get_url( $rowc['category'] )."/".$rowc['id']."-".$rowc['alt_name'].".html";
  436.                                     }
  437.                                     else
  438.                                     {
  439.                                         $full_link = $config['http_home_url'].$rowc['id']."-".$rowc['alt_name'].".html";
  440.                                     }
  441.                                 }
  442.                                 else
  443.                                 {
  444.                                     $full_link = $config['http_home_url'].date( "Y/m/d/", $rowc['date'] ).$rowc['alt_name'].".html";
  445.                                 }
  446.                             }
  447.                             else
  448.                             {
  449.                                 $full_link = $config['http_home_url']."index.php?newsid=".$rowc['id'];
  450.                             }
  451.                             $find[] = "{href}";
  452.                             $replace[] = $full_link;
  453.                             $find[] = "[full-link]";
  454.                             $replace[] = "<a href=\"".$full_link."\" title=\"".trim( $title_full )."\">";
  455.                             $find[] = "[/full-link]";
  456.                             $replace[] = "</a>";
  457.                             $find[] = "[com-link]";
  458.                             $replace[] = "<a href=\"".$full_link."#comment\" title=\"".trim( $title_full )." (комментарии)\">";
  459.                             $find[] = "[/com-link]";
  460.                             $replace[] = "</a>";
  461.                             if ( strstr( $value['code'], "{THEME}" ) )
  462.                             {
  463.                                 $find[] = "{THEME}";
  464.                                 $replace[] = $config['http_home_url']."templates/".$config['skin'];
  465.                             }
  466.                             if ( $check_thumb )
  467.                             {
  468.                                 $shab = "#src=\\\\?['\"](.+?)\\\\?['\"]#ies";
  469.                                 $shab_full = "#http://[^\"]+?(jpg|jpeg|png|gif|tga)#ies";
  470.                                 preg_match( $shab, $rowc['short_story'], $thumb );
  471.                                 $thumb = $thumb[1];
  472.                                 preg_match( $shab_full, $rowc['short_story'], $image );
  473.                                 $image = $image[0];
  474.                                 if ( !$thumb )
  475.                                 {
  476.                                     $thumb = $image;
  477.                                 }
  478.                                 if ( $value['def_img'] && !$thumb )
  479.                                 {
  480.                                     $thumb = $config['http_home_url']."templates/".$config['skin']."/images/".$value['def_img'];
  481.                                     $image = $config['http_home_url']."templates/".$config['skin']."/images/".$value['def_img'];
  482.                                 }
  483.                                 if ( $thumb )
  484.                                 {
  485.                                     if ( !$rowc['full_story'] )
  486.                                     {
  487.                                         $rowc['full_story'] = $rowc['short_story'];
  488.                                     }
  489.                                     preg_match_all( $shab, $rowc['full_story'], $imag );
  490.                                     $id_img = 0;
  491.                                     foreach ( $imag[1] as $imgs )
  492.                                     {
  493.                                         if ( $imgs )
  494.                                         {
  495.                                             $id_img += 1;
  496.                                             $find[] = "{scr".$id_img."}";
  497.                                             $replace[] = $imgs;
  498.                                         }
  499.                                     }
  500.                                     $r_img = mt_rand( 0, count( $imag[0] ) - 1 );
  501.                                     $r_img = $imag[1][$r_img];
  502.                                     $find[] = "{thumb}";
  503.                                     $replace[] = $thumb;
  504.                                     $find[] = "{image}";
  505.                                     $replace[] = $image;
  506.                                     $find[] = "{r-img}";
  507.                                     $replace[] = $r_img;
  508.                                     if ( preg_match( "#(\\[thumb|\\[image)#ies", $value['code'] ) )
  509.                                     {
  510.                                         preg_match( "#\\[thumb=([^\\]]+)\\]#is", $value['code'], $th_size );
  511.                                         $findp[] = "/\\[thumb=([^\\]]+)\\]/";
  512.                                         $replacep[] = sblocks_thumb( trim( $title_full ), $thumb, $th_size[1] );
  513.                                         $findp[] = "/\\[thumb\\]/";
  514.                                         $replacep[] = sblocks_thumb( trim( $title_full ), $thumb );
  515.                                         preg_match( "#\\[image=([^\\]]+)\\]#is", $value['code'], $im_size );
  516.                                         $findp[] = "/\\[image=([^\\]]+)\\]/";
  517.                                         $replacep[] = sblocks_thumb( trim( $title_full ), $image, $im_size[1] );
  518.                                         $findp[] = "/\\[image\\]/";
  519.                                         $replacep[] = sblocks_thumb( trim( $title_full ), $image );
  520.                                     }
  521.                                 }
  522.                             }
  523.                             if ( strstr( $value['code'], "{attachments}" ) )
  524.                             {
  525.                                 $find[] = "{attachments}";
  526.                                 $replace[] = sblocks_attach( $rowc['id'] );
  527.                             }
  528.                             if ( $check_video )
  529.                             {
  530.                                 if ( !$rowc['full_story'] )
  531.                                 {
  532.                                     $rowc['full_story'] = $rowc['short_story'];
  533.                                 }
  534.                                 preg_match( "#<!--dle_video_begin:(.+?)-->(.+?)<!--dle_video_end-->#is", $rowc['full_story'], $video );
  535.                                 $video = $video[1];
  536.                                 if ( !$video )
  537.                                 {
  538.                                     preg_match( "#<!--dle_video_begin-->(.+?)src=\"(.+?)\"(.+?)<!--dle_video_end-->#is", $rowc['full_story'], $video );
  539.                                     $video = $video[2];
  540.                                     if ( !$video )
  541.                                     {
  542.                                         preg_match( "#<embed(.+?)file=([^&\"]+\\.(flv|mp4|m4v|m4a|mov|3gp|f4v|avi|divx))(&|\")(.+?)>#is", $rowc['full_story'], $video );
  543.                                         $video = $video[2];
  544.                                         if ( !$video )
  545.                                         {
  546.                                             $video = "Link not found";
  547.                                         }
  548.                                     }
  549.                                 }
  550.                                 preg_match( "#\\[video=([^\\]]+)\\]#is", $value['code'], $ssize );
  551.                                 $find[] = "{video-link}";
  552.                                 $replace[] = $video;
  553.                                 $find[] = "{video}";
  554.                                 $replace[] = $parse->build_video( $video );
  555.                                 $findp[] = "/\\[video=([^\\]]+)\\]/";
  556.                                 $replacep[] = $parse->build_video( $video, $ssize[1] );
  557.                             }
  558.                             if ( $check_audio )
  559.                             {
  560.                                 if ( !$rowc['full_story'] )
  561.                                 {
  562.                                     $rowc['full_story'] = $rowc['short_story'];
  563.                                 }
  564.                                 preg_match( "#<!--dle_audio_begin:(.+?)-->(.+?)<!--dle_audio_end-->#is", $rowc['full_story'], $audio );
  565.                                 $audio = $audio[1];
  566.                                 if ( !$audio )
  567.                                 {
  568.                                     preg_match( "#<embed(.+?)file=([^&\"]+)(&|\")(.+?)>#is", $rowc['full_story'], $audio );
  569.                                     $audio = $audio[2];
  570.                                     if ( !$audio )
  571.                                     {
  572.                                         preg_match( "#<!--dle_audio_begin-->(.+?)src=\"(.+?)\"(.+?)<!--dle_audio_end-->#is", $rowc['full_story'], $audio );
  573.                                         $audio = $audio[2];
  574.                                         if ( !$audio )
  575.                                         {
  576.                                             $audio = "Link not found";
  577.                                         }
  578.                                     }
  579.                                 }
  580.                                 preg_match( "#\\[audio=([^\\]]+)\\]#is", $value['code'], $ssize );
  581.                                 if ( !$ssize[1] )
  582.                                 {
  583.                                     $ssize[1] = 425;
  584.                                 }
  585.                                 $find[] = "{audio-link}";
  586.                                 $replace[] = $audio;
  587.                                 $find[] = "{audio}";
  588.                                 $replace[] = $parse->build_audio( $audio );
  589.                                 $findp[] = "/\\[audio=([^\\]]+)\\]/";
  590.                                 $replacep[] = $parse->build_audio( $audio, $ssize[1] );
  591.                             }
  592.                             if ( preg_match( "#(\\[xfvalue_|\\[xfgiven_)#ies", $value['code'] ) )
  593.                             {
  594.                                 $xfields = xfieldsload( );
  595.                                 $xfieldsdata = xfieldsdataload( $rowc['xfields'] );
  596.                                 foreach ( $xfields as $val )
  597.                                 {
  598.                                     $preg_safe_name = preg_quote( $val[0], "'" );
  599.                                     if ( empty( $xfieldsdata[$val[0]] ) )
  600.                                     {
  601.                                         $findp[] = "'\\[xfgiven_".$preg_safe_name."\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is";
  602.                                         $replacep[] = "";
  603.                                     }
  604.                                     else
  605.                                     {
  606.                                         $findp[] = "'\\[xfgiven_".$preg_safe_name."\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is";
  607.                                         $replacep[] = "\\1";
  608.                                     }
  609.                                     $findp[] = "/\\[xfvalue_".$preg_safe_name."\\]/";
  610.                                     $replacep[] = $xfieldsdata[$val[0]];
  611.                                 }
  612.                             }
  613.                             if ( preg_match( "#({category}|{link-category}|{category-link})#ies", $value['code'] ) )
  614.                             {
  615.                                 if ( !$rowc['category'] )
  616.                                 {
  617.                                     $my_cat = "---";
  618.                                     $my_cat_link = "---";
  619.                                     $cat_link = "---";
  620.                                 }
  621.                                 else
  622.                                 {
  623.                                     $my_cat = array( );
  624.                                     $my_cat_link = array( );
  625.                                     $cat_list = explode( ",", $rowc['category'] );
  626.                                     if ( count( $cat_list ) == 1 )
  627.                                     {
  628.                                         $my_cat[] = $cat_info[$cat_list[0]]['name'];
  629.                                         $my_cat_link = get_categories( $cat_list[0] );
  630.                                     }
  631.                                     else
  632.                                     {
  633.                                         foreach ( $cat_list as $element )
  634.                                         {
  635.                                             if ( $element )
  636.                                             {
  637.                                                 $my_cat[] = $cat_info[$element]['name'];
  638.                                                 if ( $config['ajax'] )
  639.                                                 {
  640.                                                     $go_page = "onclick=\"DlePage('do=cat&category=".$cat_info[$element]['alt_name']."'); return false;\" ";
  641.                                                 }
  642.                                                 else
  643.                                                 {
  644.                                                     $go_page = "";
  645.                                                 }
  646.                                                 if ( $config['allow_alt_url'] == "yes" )
  647.                                                 {
  648.                                                     $my_cat_link[] = "<a ".$go_page."href=\"".$config['http_home_url'].get_url( $element ).( "/\">".$cat_info[$element]['name']."</a>" );
  649.                                                 }
  650.                                                 else
  651.                                                 {
  652.                                                     $my_cat_link[] = "<a ".$go_page."href=\"{$PHP_SELF}?do=cat&category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
  653.                                                 }
  654.                                             }
  655.                                         }
  656.                                         $my_cat_link = implode( ", ", $my_cat_link );
  657.                                     }
  658.                                     $my_cat = implode( ", ", $my_cat );
  659.                                     if ( $config['ajax'] )
  660.                                     {
  661.                                         $go_page = "onclick=\"DlePage('do=cat&category=".$cat_info[$cat_list[0]]['alt_name']."'); return false;\" ";
  662.                                     }
  663.                                     else
  664.                                     {
  665.                                         $go_page = "";
  666.                                     }
  667.                                     if ( $config['allow_alt_url'] == "yes" )
  668.                                     {
  669.                                         $cat_link = "<a ".$go_page."href=\"".$config['http_home_url'].get_url( $cat_list[0] ).( "/\">".$cat_info[$cat_list[0]]['name']."</a>" );
  670.                                     }
  671.                                     else
  672.                                     {
  673.                                         $cat_link = "<a ".$go_page."href=\"{$PHP_SELF}?do=cat&category={$cat_info[$cat_list[0]]['alt_name']}\">{$cat_info[$cat_list[0]]['name']}</a>";
  674.                                     }
  675.                                 }
  676.                                 $find[] = "{category}";
  677.                                 $replace[] = $my_cat;
  678.                                 $find[] = "{link-category}";
  679.                                 $replace[] = $my_cat_link;
  680.                                 $find[] = "{category-link}";
  681.                                 $replace[] = $cat_link;
  682.                             }
  683.                             if ( strstr( $value['code'], "{short-story}" ) )
  684.                             {
  685.                                 $find[] = "{short-story}";
  686.                                 if ( $config['rss_format'] != 1 )
  687.                                 {
  688.                                     $rowc['short_story'] = htmlspecialchars( strip_tags( stripslashes( str_replace( "<br />", " ", $rowc['short_story'] ) ) ) );
  689.                                 }
  690.                                 else
  691.                                 {
  692.                                     $rowc['short_story'] = stripslashes( $rowc['short_story'] );
  693.                                 }
  694.                                 $replace[] = trim( $rowc['short_story'] );
  695.                             }
  696.                             if ( strstr( $value['code'], "{full-story}" ) )
  697.                             {
  698.                                 $rowc['full_story'] = str_replace( "{PAGEBREAK}", "", $rowc['full_story'] );
  699.                                 $rowc['full_story'] = str_replace( "{pages}", "", $rowc['full_story'] );
  700.                                 $rowc['full_story'] = preg_replace( "'\\[PAGE=(.*?)\\](.*?)\\[/PAGE\\]'si", "\\2", $rowc['full_story'] );
  701.                                 $find[] = "{full-story}";
  702.                                 $replace[] = trim( $rowc['full_story'] );
  703.                             }
  704.                             if ( preg_match( "#{date}|{date=.+?}|\\[day-news\\]#ies", $value['code'] ) )
  705.                             {
  706.                                 if ( date( Ymd, $rowc['date'] ) == date( Ymd, $_TIME ) )
  707.                                 {
  708.                                     $date = $lang['time_heute'].langdate( ", H:i", $rowc['date'] );
  709.                                 }
  710.                                 else if ( date( Ymd, $rowc['date'] ) == date( Ymd, $_TIME - 86400 ) )
  711.                                 {
  712.                                     $date = $lang['time_gestern'].langdate( ", H:i", $rowc['date'] );
  713.                                 }
  714.                                 else
  715.                                 {
  716.                                     $date = langdate( $config['timestamp_active'], $rowc['date'] );
  717.                                 }
  718.                                 if ( $config['allow_alt_url'] == "yes" )
  719.                                 {
  720.                                     $day_news = "<a href=\"".$config['http_home_url'].date( "Y/m/d/", $rowc['date'] )."\" >";
  721.                                 }
  722.                                 else
  723.                                 {
  724.                                     $day_news = "<a href=\"".$PHP_SELF."?year=".date( "Y", $rowc['date'] )."&amp;month=".date( "m", $rowc['date'] )."&amp;day=".date( "d", $rowc['date'] )."\" >";
  725.                                 }
  726.                                 $find[] = "{date}";
  727.                                 $replace[] = $date;
  728.                                 $find[] = "[day-news]";
  729.                                 $replace[] = $day_news;
  730.                                 $find[] = "[/day-news]";
  731.                                 $replace[] = "</a>";
  732.                                 $code_temp = preg_replace( "#\\{date=(.+?)\\}#ie", "langdate('\\1', '".$rowc['date']."')", $code_temp );
  733.                             }
  734.                             if ( $check_reliz )
  735.                             {
  736.                                 preg_match( "#<!--sblocks_reliz_begin--><div style=\"display:none\">(.+?)</div><!--sblocks_reliz_end-->#is", $rowc['short_story'], $left );
  737.                                 $left = strtotime( $left[1] );
  738.                                 $reliz_date = langdate( "j F Y", $left );
  739.                                 $hour_now = date( "H", $_TIME );
  740.                                 $hour_reliz = date( "H", $left ) ? date( "H", $left ) : 1;
  741.                                 $hour_erase = date( "i", $left ) ? date( "i", $left ) : 23;
  742.                                 $left -= $_TIME;
  743.                                 $ryear = floor( $left / 31536000 );
  744.                                 $rmonth = date( "m", $left ) - 1;
  745.                                 $rday = date( "j", $left );
  746.                                 if ( $left <= 0 && -86000 < $left )
  747.                                 {
  748.                                     $ryear = 0;
  749.                                     $rmonth = 0;
  750.                                     $rday = 0;
  751.                                 }
  752.                                 else
  753.                                 {
  754.                                     if ( $left < -86000 )
  755.                                     {
  756.                                         break;
  757.                                     }
  758.                                 }
  759.                                 if ( $ryear == 0 )
  760.                                 {
  761.                                     $ryear = "";
  762.                                 }
  763.                                 else if ( $ryear == 1 )
  764.                                 {
  765.                                     $ryear .= " Год";
  766.                                 }
  767.                                 else if ( 1 < $ryear && $ryear < 5 )
  768.                                 {
  769.                                     $ryear .= " Года";
  770.                                 }
  771.                                 else if ( 4 < $ryear )
  772.                                 {
  773.                                     $ryear .= " Лет";
  774.                                 }
  775.                                 if ( $rmonth == 0 )
  776.                                 {
  777.                                     $rmonth = "";
  778.                                 }
  779.                                 else if ( $rmonth == 1 )
  780.                                 {
  781.                                     $rmonth .= " Месяц";
  782.                                 }
  783.                                 else if ( 1 < $rmonth && $rmonth < 5 )
  784.                                 {
  785.                                     $rmonth .= " Месяца";
  786.                                 }
  787.                                 else if ( 4 < $rmonth )
  788.                                 {
  789.                                     $rmonth .= " Месяцев";
  790.                                 }
  791.                                 if ( $rday == 0 )
  792.                                 {
  793.                                     $rday = "";
  794.                                 }
  795.                                 else if ( $rday == 1 || $rday == 21 || $rday == 31 )
  796.                                 {
  797.                                     $rday .= " День";
  798.                                 }
  799.                                 else if ( 1 < $rday && $rday < 5 )
  800.                                 {
  801.                                     $rday .= " Дня";
  802.                                 }
  803.                                 else if ( 21 < $rday && $rday < 25 )
  804.                                 {
  805.                                     $rday .= " Дня";
  806.                                 }
  807.                                 else if ( 4 < $rday && $rday < 21 )
  808.                                 {
  809.                                     $rday .= " Дней";
  810.                                 }
  811.                                 else if ( 24 < $rday && $rday < 31 )
  812.                                 {
  813.                                     $rday .= " Дней";
  814.                                 }
  815.                                 if ( $ryear == "" && $rday == "" && $rmonth == "" && $hour_reliz <= $hour_now && $hour_now < $hour_erase )
  816.                                 {
  817.                                     $reliz = "Релиз состоялся";
  818.                                 }
  819.                                 else
  820.                                 {
  821.                                     $reliz = $ryear." ".$rmonth." ".$rday;
  822.                                 }
  823.                                 if ( !$reliz && ( $reliz = " " ) )
  824.                                 {
  825.                                     $find[] = "{reliz}";
  826.                                     $replace[] = $reliz;
  827.                                     $find[] = "{reliz-date}";
  828.                                     $replace[] = $reliz_date;
  829.                                 }
  830.                             }
  831.                             if ( preg_match( "#({rate}|{rating}|{rate-num}|{vote-num})#ies", $value['code'] ) )
  832.                             {
  833.                                 if ( $config['short_rating'] && $user_group[$member_id['user_group']]['allow_rating'] )
  834.                                 {
  835.                                     $rating = shortrating( $rowc['id'], $rowc['rating'], $rowc['vote_num'], 1 );
  836.                                 }
  837.                                 else
  838.                                 {
  839.                                     $rating = shortrating( $rowc['id'], $rowc['rating'], $rowc['vote_num'], 0 );
  840.                                 }
  841.                                 $vote_num = $rowc['vote_num'] ? $rowc['vote_num'] : 1;
  842.                                 if ( $rowc['rating'] )
  843.                                 {
  844.                                     $rate = round( $rowc['rating'] / $vote_num, 0 );
  845.                                 }
  846.                                 else
  847.                                 {
  848.                                     $rate = 0;
  849.                                 }
  850.                                 $find[] = "{rate}";
  851.                                 $replace[] = $rate;
  852.                                 $find[] = "{vote-num}";
  853.                                 $replace[] = $vote_num;
  854.                                 $find[] = "{rating}";
  855.                                 $replace[] = $rating;
  856.                                 $find[] = "{rate-num}";
  857.                                 $replace[] = $rowc['rating'];
  858.                             }
  859.                             if ( preg_match( "#({descr-short}|{descr-full}|{descr})#ies", $value['code'] ) )
  860.                             {
  861.                                 $find[] = "{descr-short}";
  862.                                 $replace[] = sblocks_descr( $rowc['short_story'], $value['descr_cut'] );
  863.                                 $find[] = "{descr-full}";
  864.                                 $replace[] = sblocks_descr( $rowc['full_story'], $value['descr_cut'] );
  865.                                 $find[] = "{descr}";
  866.                                 $replace[] = sblocks_descr( $rowc['short_story'].$rowc['full_story'], $value['descr_cut'] );
  867.                             }
  868.                             if ( strstr( $value['code'], "{author-link}" ) )
  869.                             {
  870.                                 if ( $config['ajax'] )
  871.                                 {
  872.                                     $go_page = "onclick=\"DlePage(\\'subaction=userinfo&user=".urlencode( $rowc['autor'] )."\\'); return false;\" ";
  873.                                     $news_page = "onclick=\"DlePage(\\'subaction=allnews&user=".urlencode( $rowc['autor'] )."\\'); return false;\" ";
  874.                                 }
  875.                                 else
  876.                                 {
  877.                                     $go_page = "";
  878.                                     $news_page = "";
  879.                                 }
  880.                                 if ( $config['allow_alt_url'] == "yes" )
  881.                                 {
  882.                                     $go_page .= "href=\"".$config['http_home_url']."user/".urlencode( $rowc['autor'] )."/\"";
  883.                                     $news_page .= "href=\"".$config['http_home_url']."user/".urlencode( $rowc['autor'] )."/news/\"";
  884.                                     $tpl->set( "[day-news]", "<a href=\"".$config['http_home_url'].date( "Y/m/d/", $rowc['date'] )."\" >" );
  885.                                 }
  886.                                 else
  887.                                 {
  888.                                     $go_page .= "href=\"".$PHP_SELF."?subaction=userinfo&amp;user=".urlencode( $rowc['autor'] )."\"";
  889.                                     $news_page .= "href=\"".$PHP_SELF."?subaction=allnews&amp;user=".urlencode( $rowc['autor'] )."\"";
  890.                                 }
  891.                                 $go_page = "onclick=\"return dropdownmenu(this, event, UserNewsMenu('".htmlspecialchars( $go_page )."', '".htmlspecialchars( $news_page )."','".urlencode( $rowc['autor'] )."', '".$user_group[$member_id['user_group']]['admin_editusers']."'), '170px')\" onmouseout=\"delayhidemenu()\"";
  892.                                 if ( $config['allow_alt_url'] == "yes" )
  893.                                 {
  894.                                     $autor_link = "<a ".$go_page." href=\"".$config['http_home_url']."user/".urlencode( $rowc['autor'] )."/\">".$rowc['autor']."</a>";
  895.                                 }
  896.                                 else
  897.                                 {
  898.                                     $autor_link = "<a ".$go_page." href=\"{$PHP_SELF}?subaction=userinfo&amp;user=".urlencode( $rowc['autor'] )."\">".$rowc['autor']."</a>";
  899.                                 }
  900.                                 $find[] = "{author-link}";
  901.                                 $replace[] = $autor_link;
  902.                             }
  903.                             if ( 1 < $value['rows'] )
  904.                             {
  905.                                 ++$colid;
  906.                                 if ( $colid % $value['cols'] == 0 )
  907.                                 {
  908.                                     $code_temp .= "<div style=\"clear:both;heght:0;overflow:hidden;\"></div>";
  909.                                 }
  910.                             }
  911.                             $find[] = "{author}";
  912.                             $replace[] = $rowc['autor'];
  913.                             $find[] = "{views}";
  914.                             $replace[] = $rowc['news_read'];
  915.                             $find[] = "{comments-num}";
  916.                             $replace[] = $rowc['comm_num'];
  917.                             $code_temp = str_replace( $find, $replace, $code_temp );
  918.                             if ( $findp )
  919.                             {
  920.                                 $code_temp = preg_replace( $findp, $replacep, $code_temp );
  921.                             }
  922.                             $code .= $code_temp;
  923.                         }
  924.                         $db->free( );
  925.                         $code .= "<div style=\"clear:both;heght:0;overflow:hidden;\"></div>";
  926.                         if ( $value['title'] != "content" )
  927.                         {
  928.                             if ( $value['pages'] )
  929.                             {
  930.                                 $category = $category ? $category : 0;
  931.                                 $count_all = $db->super_query( "SELECT COUNT(*) as count FROM ".PREFIX."_post WHERE ".$where." approve ".$datag );
  932.                                 $count_all = $count_all['count'];
  933.                                 if ( 0 < $value['pages_count'] && $value['pages_count'] * $lim < $count_all )
  934.                                 {
  935.                                     $count_all = $value['pages_count'] * $lim;
  936.                                 }
  937.                                 $no_prev = false;
  938.                                 $no_next = false;
  939.                                 $navcode = "";
  940.                                 $ajax_start = $ajax_start ? $ajax_start : 1;
  941.                                 if ( isset( $ajax_start ) && $ajax_start != "" && 1 < $ajax_start )
  942.                                 {
  943.                                     $prev = $ajax_start - 1;
  944.                                     $navcode .= "<a title=\"Назад\" onClick=\"s_page('".$value['title']."',".$prev.",'".$category."')\">".$lang['sb_nav_prev']."</a>";
  945.                                 }
  946.                                 else
  947.                                 {
  948.                                     $navcode .= "<span>".$lang['sb_nav_prev']."</span>";
  949.                                     $no_prev = TRUE;
  950.                                 }
  951.                                 if ( $lim < $count_all )
  952.                                 {
  953.                                     $enpages_count = @ceil( $count_all / $lim );
  954.                                     $pages = "";
  955.                                     if ( $enpages_count <= 10 )
  956.                                     {
  957.                                         $j = 1;
  958.                                         for ( ; do
  959.     {
  960.     $j <= $enpages_count;   ++$j    )
  961.                                             {
  962.                                                 if ( $j != $ajax_start )
  963.                                                 {
  964.                                                     $pages .= "<a title=\"Страница: #".$j."\" onClick=\"s_page('".$value['title']."',".$j.",'".$category."')\">".$j."</a>";
  965.                                                 }
  966.                                                 else
  967.                                                 {
  968.                                                     $pages .= "<span>".$j."</span>";
  969.                                                 }
  970.                                                 break;
  971.                                             }
  972.                                         } while ( 1 );
  973.                                     }
  974.                                     else
  975.                                     {
  976.                                         $start = 1;
  977.                                         $end = 7;
  978.                                         $nav_prefix = "..";
  979.                                         if ( 0 < $ajax_start && 4 < $ajax_start )
  980.                                         {
  981.                                             $start = $ajax_start - 2;
  982.                                             $end = $start + 4;
  983.                                             if ( $enpages_count <= $end )
  984.                                             {
  985.                                                 $start = $enpages_count - 5;
  986.                                                 $end = $enpages_count - 1;
  987.                                                 $nav_prefix = "";
  988.                                             }
  989.                                             else
  990.                                             {
  991.                                                 $nav_prefix = "..";
  992.                                             }
  993.                                         }
  994.                                         if ( 2 <= $start )
  995.                                         {
  996.                                             $pages .= "<a title=\"Страница: #1\" onClick=\"s_page('".$value['title']."',1,'".$category."')\">1</a>..";
  997.                                         }
  998.                                         $j = $start;
  999.                                         for ( ; $j <= $end; ++$j    )
  1000.                                         {
  1001.                                             if ( $j != $ajax_start )
  1002.                                             {
  1003.                                                 $pages .= "<a title=\"Страница: #".$j."\" onClick=\"s_page('".$value['title']."',".$j.",'".$category."')\">".$j."</a>";
  1004.                                             }
  1005.                                             else
  1006.                                             {
  1007.                                                 $pages .= "<span>".$j."</span>";
  1008.                                             }
  1009.                                         }
  1010.                                         if ( $ajax_start != $enpages_count )
  1011.                                         {
  1012.                                             $pages .= $nav_prefix."<a title=\"Страница: #".$enpages_count."\" onClick=\"s_page('".$value['title']."',".$enpages_count.",'".$category."')\">".$enpages_count."</a>";
  1013.                                         }
  1014.                                         else
  1015.                                         {
  1016.                                             $pages .= $nav_prefix.( "<span>".$enpages_count."</span>" );
  1017.                                         }
  1018.                                     }
  1019.                                 }
  1020.                                 $navcode .= $pages;
  1021.                                 if ( $lim && $lim < $count_all && $ajax_start * $lim < $count_all )
  1022.                                 {
  1023.                                     $next_page = $ajax_start + 1;
  1024.                                     $navcode .= "<a title=\"Вперед\" onClick=\"s_page('".$value['title']."',".$next_page.",'".$category."')\">".$lang['sb_nav_next']."</a>";
  1025.                                 }
  1026.                                 else
  1027.                                 {
  1028.                                     $no_next = TRUE;
  1029.                                     $navcode .= "<span>".$lang['sb_nav_next']."</span>";
  1030.                                 }
  1031.                                 if ( !$no_prev && !$no_next )
  1032.                                 {
  1033.                                     if ( !$value['custom_style'] )
  1034.                                     {
  1035.                                         $code .= "<div align=\"center\" class=\"snav_".$value['title']."\">".$navcode."</div>";
  1036.                                     }
  1037.                                     else
  1038.                                     {
  1039.                                         $code .= "<div align=\"center\" class=\"".$value['custom_style']."\">".$navcode."</div>";
  1040.                                     }
  1041.                                 }
  1042.                             }
  1043.                         }
  1044.                         else
  1045.                         {
  1046.                             $tpl->load_template( "navigation.tpl" );
  1047.                             $count_all = $db->super_query( "SELECT COUNT(*) as count FROM ".PREFIX."_post WHERE ".$where." approve ".$datag );
  1048.                             $count_all = $count_all['count'];
  1049.                             $no_prev = false;
  1050.                             $no_next = false;
  1051.                             if ( isset( $cstart ) && $cstart != "" && 1 < $cstart )
  1052.                             {
  1053.                                 $prev = $cstart - 1;
  1054.                                 if ( $config['ajax'] )
  1055.                                 {
  1056.                                     $go_page = "onclick=\"DlePage('cstart=".$prev."&".$user_query."'); return false;\" ";
  1057.                                 }
  1058.                                 else
  1059.                                 {
  1060.                                     $go_page = "";
  1061.                                 }
  1062.                                 if ( $config['allow_alt_url'] == "yes" )
  1063.                                 {
  1064.                                     $prev_page = $url_page."/page/".$prev."/";
  1065.                                     $tpl->set_block( "'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<a ".$go_page."href=\"".$prev_page."\">\\1</a>" );
  1066.                                 }
  1067.                                 else
  1068.                                 {
  1069.                                     $prev_page = $PHP_SELF."?cstart=".$prev."&amp;".$user_query;
  1070.                                     $tpl->set_block( "'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<a ".$go_page."href=\"".$prev_page."\">\\1</a>" );
  1071.                                 }
  1072.                             }
  1073.                             else
  1074.                             {
  1075.                                 $tpl->set_block( "'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<span>\\1</span>" );
  1076.                                 $no_prev = TRUE;
  1077.                             }
  1078.                             if ( $lim )
  1079.                             {
  1080.                                 if ( $lim < $count_all )
  1081.                                 {
  1082.                                     $enpages_count = @ceil( $count_all / $lim );
  1083.                                     $pages = "";
  1084.                                     if ( $enpages_count <= 10 )
  1085.                                     {
  1086.                                         $j = 1;
  1087.                                         for ( ; do
  1088.     {
  1089.     $j <= $enpages_count;   ++$j    )
  1090.                                             {
  1091.                                                 if ( $j != $cstart )
  1092.                                                 {
  1093.                                                     if ( $config['ajax'] )
  1094.                                                     {
  1095.                                                         $go_page = "onclick=\"DlePage('cstart=".$j."&".$user_query."'); return false;\" ";
  1096.                                                     }
  1097.                                                     else
  1098.                                                     {
  1099.                                                         $go_page = "";
  1100.                                                     }
  1101.                                                     if ( $config['allow_alt_url'] == "yes" )
  1102.                                                     {
  1103.                                                         $pages .= "<a ".$go_page."href=\"".$url_page."/page/".$j.( "/\">".$j."</a> " );
  1104.                                                     }
  1105.                                                     else
  1106.                                                     {
  1107.                                                         $pages .= "<a ".$go_page."href=\"{$PHP_SELF}?cstart={$j}&amp;{$user_query}\">{$j}</a> ";
  1108.                                                     }
  1109.                                                 }
  1110.                                                 else
  1111.                                                 {
  1112.                                                     $pages .= "<span>".$j."</span> ";
  1113.                                                 }
  1114.                                                 break;
  1115.                                             }
  1116.                                         } while ( 1 );
  1117.                                     }
  1118.                                     else
  1119.                                     {
  1120.                                         $start = 1;
  1121.                                         $end = 10;
  1122.                                         if ( $lang['nav_trennen'] )
  1123.                                         {
  1124.                                             $nav_trennen = "<span class=\"nav_ext\">".$lang['nav_trennen']."</span> ";
  1125.                                         }
  1126.                                         else
  1127.                                         {
  1128.                                             $nav_trennen = "... ";
  1129.                                         }
  1130.                                         $nav_prefix = $nav_trennen;
  1131.                                         if ( 0 < $cstart && 5 < $cstart )
  1132.                                         {
  1133.                                             $start = $cstart - 4;
  1134.                                             $end = $start + 8;
  1135.                                             if ( $enpages_count <= $end )
  1136.                                             {
  1137.                                                 $start = $enpages_count - 9;
  1138.                                                 $end = $enpages_count - 1;
  1139.                                                 $nav_prefix = "";
  1140.                                             }
  1141.                                             else
  1142.                                             {
  1143.                                                 $nav_prefix = $nav_trennen;
  1144.                                             }
  1145.                                         }
  1146.                                         if ( 2 <= $start )
  1147.                                         {
  1148.                                             if ( $config['ajax'] )
  1149.                                             {
  1150.                                                 $go_page = "onclick=\"DlePage('cstart=1&".$user_query."'); return false;\" ";
  1151.                                             }
  1152.                                             else
  1153.                                             {
  1154.                                                 $go_page = "";
  1155.                                             }
  1156.                                             if ( $config['allow_alt_url'] == "yes" )
  1157.                                             {
  1158.                                                 $pages .= "<a ".$go_page."href=\"".$url_page.( "/page/1/\">1</a> ".$nav_trennen." " );
  1159.                                             }
  1160.                                             else
  1161.                                             {
  1162.                                                 $pages .= "<a ".$go_page."href=\"{$PHP_SELF}?cstart=1&amp;{$user_query}\">1</a> {$nav_trennen} ";
  1163.                                             }
  1164.                                         }
  1165.                                         $j = $start;
  1166.                                         for ( ; $j <= $end; ++$j    )
  1167.                                         {
  1168.                                             if ( $j != $cstart )
  1169.                                             {
  1170.                                                 if ( $config['ajax'] )
  1171.                                                 {
  1172.                                                     $go_page = "onclick=\"DlePage('cstart=".$j."&".$user_query."'); return false;\" ";
  1173.                                                 }
  1174.                                                 else
  1175.                                                 {
  1176.                                                     $go_page = "";
  1177.                                                 }
  1178.                                                 if ( $config['allow_alt_url'] == "yes" )
  1179.                                                 {
  1180.                                                     $pages .= "<a ".$go_page."href=\"".$url_page."/page/".$j.( "/\">".$j."</a> " );
  1181.                                                 }
  1182.                                                 else
  1183.                                                 {
  1184.                                                     $pages .= "<a ".$go_page."href=\"{$PHP_SELF}?cstart={$j}&amp;{$user_query}\">{$j}</a> ";
  1185.                                                 }
  1186.                                             }
  1187.                                             else
  1188.                                             {
  1189.                                                 $pages .= "<span>".$j."</span> ";
  1190.                                             }
  1191.                                         }
  1192.                                         if ( $cstart != $enpages_count )
  1193.                                         {
  1194.                                             if ( $config['ajax'] )
  1195.                                             {
  1196.                                                 $go_page = "onclick=\"DlePage('cstart=".$enpages_count."&".$user_query."'); return false;\" ";
  1197.                                             }
  1198.                                             else
  1199.                                             {
  1200.                                                 $go_page = "";
  1201.                                             }
  1202.                                             if ( $config['allow_alt_url'] == "yes" )
  1203.                                             {
  1204.                                                 $pages .= $nav_prefix.( "<a ".$go_page."href=\"" ).$url_page.( "/page/".$enpages_count."/\">{$enpages_count}</a>" );
  1205.                                             }
  1206.                                             else
  1207.                                             {
  1208.                                                 $pages .= $nav_prefix.( "<a ".$go_page."href=\"{$PHP_SELF}?cstart={$enpages_count}&amp;{$user_query}\">{$enpages_count}</a>" );
  1209.                                             }
  1210.                                         }
  1211.                                         else
  1212.                                         {
  1213.                                             $pages .= "<span>".$enpages_count."</span> ";
  1214.                                         }
  1215.                                     }
  1216.                                 }
  1217.                                 $tpl->set( "{pages}", $pages );
  1218.                                 if ( $lim && $lim < $count_all && $cstart * $lim < $count_all )
  1219.                                 {
  1220.                                     $next_page = $cstart + 1;
  1221.                                     if ( $config['ajax'] )
  1222.                                     {
  1223.                                         $go_page = "onclick=\"DlePage('cstart=".$next_page."&".$user_query."'); return false;\" ";
  1224.                                     }
  1225.                                     else
  1226.                                     {
  1227.                                         $go_page = "";
  1228.                                     }
  1229.                                     if ( $config['allow_alt_url'] == "yes" )
  1230.                                     {
  1231.                                         $next = $url_page."/page/".$next_page."/";
  1232.                                         $tpl->set_block( "'\\[next-link\\](.*?)\\[/next-link\\]'si", "<a ".$go_page."href=\"".$next."\">\\1</a>" );
  1233.                                     }
  1234.                                     else
  1235.                                     {
  1236.                                         $next = $PHP_SELF."?cstart=".$next_page."&amp;".$user_query;
  1237.                                         $tpl->set_block( "'\\[next-link\\](.*?)\\[/next-link\\]'si", "<a ".$go_page."href=\"".$next."\">\\1</a>" );
  1238.                                     }
  1239.                                 }
  1240.                             }
  1241.                             else
  1242.                             {
  1243.                                 $tpl->set_block( "'\\[next-link\\](.*?)\\[/next-link\\]'si", "<span>\\1</span>" );
  1244.                                 $no_next = TRUE;
  1245.                             }
  1246.                             if ( !$no_prev && !$no_next )
  1247.                             {
  1248.                                 $tpl->compile( "navigation_content" );
  1249.                                 $code .= $tpl->result['navigation_content'];
  1250.                             }
  1251.                             $tpl->clear( );
  1252.                         }
  1253.                         $code .= "</div>";
  1254.                         if ( $value['title'] == "content" )
  1255.                         {
  1256.                             do
  1257.                             {
  1258.                                 if ( $do == "lastnews" )
  1259.                                 {
  1260.                                     $cstop = true;
  1261.                                     create_cache( "sblocks_content_lastnews_page_".$cstart, $code );
  1262.                                 }
  1263.                                 if ( $do == "tags" )
  1264.                                 {
  1265.                                     $cstop = true;
  1266.                                     create_cache( "sblocks_content_tags_page_".$cstart, $code );
  1267.                                 }
  1268.                                 if ( $subaction == "allnews" )
  1269.                                 {
  1270.                                     $cstop = true;
  1271.                                     create_cache( "sblocks_content_allnews_page_".$cstart, $code );
  1272.                                 }
  1273.                                 if ( $subaction == "newposts" )
  1274.                                 {
  1275.                                     $cstop = true;
  1276.                                     create_cache( "sblocks_content_newposts_page_".$cstart, $code );
  1277.                                 }
  1278.                                 if ( $catalog != "" )
  1279.                                 {
  1280.                                     $cstop = true;
  1281.                                     create_cache( "sblocks_content_catalog_".$catalog."_page_".$cstart, $code );
  1282.                                 }
  1283.                                 if ( $year != "" && $month == "" && $day == "" )
  1284.                                 {
  1285.                                     $cstop = true;
  1286.                                     create_cache( "sblocks_content_calendar_".$year."_page_".$cstart, $code );
  1287.                                 }
  1288.                                 if ( $year != "" && $month != "" && $day == "" )
  1289.                                 {
  1290.                                     $cstop = true;
  1291.                                     create_cache( "sblocks_content_calendar_".$year."_".$month."_page_".$cstart, $code );
  1292.                                 }
  1293.                                 if ( $year != "" && $month != "" && $day != "" && $subaction == "" )
  1294.                                 {
  1295.                                     $cstop = true;
  1296.                                     create_cache( "sblocks_content_calendar_".$year."_".$month."_".$day."_page_".$cstart, $code );
  1297.                                 }
  1298.                                 if ( !$cstop )
  1299.                                 {
  1300.                                     if ( $category_id && !$newsid )
  1301.                                     {
  1302.                                         create_cache( "sblocks_content_category_".$cat_info[$category_id]['alt_name']."_page_".$cstart, $code );
  1303.                                     }
  1304.                                     else
  1305.                                     {
  1306.                                         if ( $sblocks_content && !$newsid )
  1307.                                         {
  1308.                                             create_cache( "sblocks_content_page_".$cstart, $code );
  1309.                                             break;
  1310.                                             break;
  1311.                                         }
  1312.                                     }
  1313.                                 }
  1314.                                 else if ( !$value['fromcat'] && !$category_id )
  1315.                                 {
  1316.                                 }
  1317.                                 else if ( $newsid )
  1318.                                 {
  1319.                                     break;
  1320.                                 }
  1321.                                 create_cache( "sblocks_".$value['title']."_category_".$cat_info[$category_id]['alt_name'].$ajax_prefix, $code );
  1322.                             } while ( 0 );
  1323.                         }
  1324.                         else
  1325.                         {
  1326.                             create_cache( "sblocks_".$value['title'].$ajax_prefix, $code );
  1327.                         }
  1328.                     }
  1329.                 }
  1330.                 $sbl[$value['title']][] = $code."\r<!--Время генерации блока: ".( sblocks_time( ) - $sblocks_start )." сек. S-Blocks by Sander-->\r";
  1331.             }
  1332.         }
  1333.     }
  1334. }
  1335. foreach ( $sbl as $key => $value )
  1336. {
  1337.     $sb_key = array_rand( $sbl[$key] );
  1338.     $sbl[$key] = $sbl[$key][$sb_key];
  1339. }
  1340. $sblocks = $sbl;
  1341. $sbl = array( );
  1342. unset( $sbl );
  1343. if ( $sblocks['content'] && $sblocks_content && !$newsid )
  1344. {
  1345.     $tpl->result['content'] = $sblocks['content'];
  1346. }
  1347. ?>
Advertisement
Add Comment
Please, Sign In to add comment