<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум АлаичЪ'а о SEO - Проблемы с include на категориях]]></title>
	<link rel="self" href="https://talk.alaev.info/feed/atom/topic/303/" />
	<updated>2015-05-08T13:52:24Z</updated>
	<generator>PunBB</generator>
	<id>https://talk.alaev.info/topic/303/</id>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/9563/#p9563" />
			<content type="html"><![CDATA[<p>Ну хотя бы так<br />заменить оригинальный topnews.php на это<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>&lt;?php
/*
=====================================================
 DataLife Engine - by SoftNews Media Group 
-----------------------------------------------------
 http://dle-news.ru/
-----------------------------------------------------
 Copyright (c) 2004,2014 SoftNews Media Group
=====================================================
 Данный код защищен авторскими правами
=====================================================
 Файл: topnews.php
-----------------------------------------------------
 Назначение: вывод рейтинговых статей
=====================================================
*/

if( ! defined( &#039;DATALIFEENGINE&#039; ) ) {
    die( &quot;Hacking attempt!&quot; );
}

if ($category_id == &quot;19&quot;) {
    $tpl-&gt;result[&#039;topnews&#039;] = dle_cache( &quot;topnews19&quot;, $config[&#039;skin&#039;], true );

if( $tpl-&gt;result[&#039;topnews&#039;] === false ) {
    
    $this_month = date( &#039;Y-m-d H:i:s&#039;, $_TIME );

    $tpl-&gt;load_template( &#039;topnews.tpl&#039; );

    if( strpos( $tpl-&gt;copy_template, &quot;[xfvalue_&quot; ) !== false OR strpos( $tpl-&gt;copy_template, &quot;[xfgiven_&quot; ) !== false ) { $xfound = true; $xfields = xfieldsload();}
    else $xfound = false;

    $config[&#039;top_number&#039;] = intval($config[&#039;top_number&#039;]);
    if ($config[&#039;top_number&#039;] &lt; 1 ) $config[&#039;top_number&#039;] = 10;

    
    $db-&gt;query( &quot;SELECT p.id, p.date, p.short_story, p.xfields, p.title, p.category, p.alt_name FROM &quot; . PREFIX . &quot;_post p LEFT JOIN &quot; . PREFIX . &quot;_post_extras e ON (p.id=e.news_id) WHERE p.category = &#039;19&#039; AND p.approve=1 AND p.date &gt;= &#039;$this_month&#039; - INTERVAL 1 MONTH AND p.date &lt; &#039;$this_month&#039; ORDER BY rating DESC, comm_num DESC, news_read DESC, date DESC LIMIT 0,{$config[&#039;top_number&#039;]}&quot; );
    
    while ( $row = $db-&gt;get_row() ) {
        
        $row[&#039;date&#039;] = strtotime( $row[&#039;date&#039;] );

        if( ! $row[&#039;category&#039;] ) {
            $my_cat = &quot;---&quot;;
            $my_cat_link = &quot;---&quot;;
        } else {
            
            $my_cat = array ();
            $my_cat_link = array ();
            $cat_list = explode( &#039;,&#039;, $row[&#039;category&#039;] );

            if ($config[&#039;category_separator&#039;] != &#039;,&#039;) $config[&#039;category_separator&#039;] = &#039; &#039;.$config[&#039;category_separator&#039;];
         
            if( count( $cat_list ) == 1 ) {
                
                $my_cat[] = $cat_info[$cat_list[0]][&#039;name&#039;];
                
                $my_cat_link = get_categories( $cat_list[0], $config[&#039;category_separator&#039;] );
            
            } else {
                
                foreach ( $cat_list as $element ) {
                    if( $element ) {
                        $my_cat[] = $cat_info[$element][&#039;name&#039;];
                        if( $config[&#039;allow_alt_url&#039;] ) $my_cat_link[] = &quot;&lt;a href=\&quot;&quot; . $config[&#039;http_home_url&#039;] . get_url( $element ) . &quot;/\&quot;&gt;{$cat_info[$element][&#039;name&#039;]}&lt;/a&gt;&quot;;
                        else $my_cat_link[] = &quot;&lt;a href=\&quot;$PHP_SELF?do=cat&amp;category={$cat_info[$element][&#039;alt_name&#039;]}\&quot;&gt;{$cat_info[$element][&#039;name&#039;]}&lt;/a&gt;&quot;;
                    }
                }
                
                $my_cat_link = implode( &quot;{$config[&#039;category_separator&#039;]} &quot;, $my_cat_link );
            }
            
            $my_cat = implode( &quot;{$config[&#039;category_separator&#039;]} &quot;, $my_cat );
        }

        $row[&#039;category&#039;] = intval( $row[&#039;category&#039;] );
        
        if( $config[&#039;allow_alt_url&#039;] ) {
            
            if( $config[&#039;seo_type&#039;] == 1 OR $config[&#039;seo_type&#039;] == 2 ) {
                
                if( $row[&#039;category&#039;] and $config[&#039;seo_type&#039;] == 2 ) {
                    
                    $full_link = $config[&#039;http_home_url&#039;] . get_url( $row[&#039;category&#039;] ) . &quot;/&quot; . $row[&#039;id&#039;] . &quot;-&quot; . $row[&#039;alt_name&#039;] . &quot;.html&quot;;
                
                } else {
                    
                    $full_link = $config[&#039;http_home_url&#039;] . $row[&#039;id&#039;] . &quot;-&quot; . $row[&#039;alt_name&#039;] . &quot;.html&quot;;
                
                }
            
            } else {
                
                $full_link = $config[&#039;http_home_url&#039;] . date( &#039;Y/m/d/&#039;, $row[&#039;date&#039;] ) . $row[&#039;alt_name&#039;] . &quot;.html&quot;;
            }
        
        } else {
            
            $full_link = $config[&#039;http_home_url&#039;] . &quot;index.php?newsid=&quot; . $row[&#039;id&#039;];
        
        }

        if( date( &#039;Ymd&#039;, $row[&#039;date&#039;] ) == date( &#039;Ymd&#039;, $_TIME ) ) {
            
            $tpl-&gt;set( &#039;{date}&#039;, $lang[&#039;time_heute&#039;] . langdate( &quot;, H:i&quot;, $row[&#039;date&#039;] ) );
        
        } elseif( date( &#039;Ymd&#039;, $row[&#039;date&#039;] ) == date( &#039;Ymd&#039;, ($_TIME - 86400) ) ) {
            
            $tpl-&gt;set( &#039;{date}&#039;, $lang[&#039;time_gestern&#039;] . langdate( &quot;, H:i&quot;, $row[&#039;date&#039;] ) );
        
        } else {
            
            $tpl-&gt;set( &#039;{date}&#039;, langdate( $config[&#039;timestamp_active&#039;], $row[&#039;date&#039;] ) );
        
        }

        $news_date = $row[&#039;date&#039;];
        $tpl-&gt;copy_template = preg_replace_callback ( &quot;#\{date=(.+?)\}#i&quot;, &quot;formdate&quot;, $tpl-&gt;copy_template );

        $tpl-&gt;set( &#039;{category}&#039;, $my_cat );
        $tpl-&gt;set( &#039;{link-category}&#039;, $my_cat_link );

        $row[&#039;title&#039;] = stripslashes( $row[&#039;title&#039;] );

        $row[&#039;title&#039;] = str_replace( &quot;{&quot;, &quot;&amp;#123;&quot;, $row[&#039;title&#039;] );

        $tpl-&gt;set( &#039;{title}&#039;, $row[&#039;title&#039;] );
        
        if ( preg_match( &quot;#\\{title limit=[&#039;\&quot;](.+?)[&#039;\&quot;]\\}#i&quot;, $tpl-&gt;copy_template, $matches ) ) {
            $count= intval($matches[1]);

            $row[&#039;title&#039;] = strip_tags( $row[&#039;title&#039;] );

            if( $count AND dle_strlen( $row[&#039;title&#039;], $config[&#039;charset&#039;] ) &gt; $count ) {
                    
                $row[&#039;title&#039;] = dle_substr( $row[&#039;title&#039;], 0, $count, $config[&#039;charset&#039;] );
                    
                if( ($temp_dmax = dle_strrpos( $row[&#039;title&#039;], &#039; &#039;, $config[&#039;charset&#039;] )) ) $row[&#039;title&#039;] = dle_substr( $row[&#039;title&#039;], 0, $temp_dmax, $config[&#039;charset&#039;] ). &quot; ...&quot;;
                
            }

            $tpl-&gt;set( $matches[0], $row[&#039;title&#039;] );

        }


        $tpl-&gt;set( &#039;{link}&#039;, $full_link );

        $row[&#039;short_story&#039;] = stripslashes( $row[&#039;short_story&#039;] );

        if( $user_group[$member_id[&#039;user_group&#039;]][&#039;allow_hide&#039;] ) $row[&#039;short_story&#039;] = str_ireplace( &quot;[hide]&quot;, &quot;&quot;, str_ireplace( &quot;[/hide]&quot;, &quot;&quot;, $row[&#039;short_story&#039;]) );
        else $row[&#039;short_story&#039;] = preg_replace ( &quot;#\[hide\](.+?)\[/hide\]#ims&quot;, &quot;&lt;div class=\&quot;quote\&quot;&gt;&quot; . $lang[&#039;news_regus&#039;] . &quot;&lt;/div&gt;&quot;, $row[&#039;short_story&#039;] );

        if (stripos ( $tpl-&gt;copy_template, &quot;{image-&quot; ) !== false) {

            $images = array();
            preg_match_all(&#039;/(img|src)=(&quot;|\&#039;)[^&quot;\&#039;&gt;]+/i&#039;, $row[&#039;short_story&#039;], $media);
            $data=preg_replace(&#039;/(img|src)(&quot;|\&#039;|=&quot;|=\&#039;)(.*)/i&#039;,&quot;$3&quot;,$media[0]);

            foreach($data as $url) {
                $info = pathinfo($url);
                if (isset($info[&#039;extension&#039;])) {
                    if ($info[&#039;filename&#039;] == &quot;spoiler-plus&quot; OR $info[&#039;filename&#039;] == &quot;spoiler-plus&quot; ) continue;
                    $info[&#039;extension&#039;] = strtolower($info[&#039;extension&#039;]);
                    if (($info[&#039;extension&#039;] == &#039;jpg&#039;) || ($info[&#039;extension&#039;] == &#039;jpeg&#039;) || ($info[&#039;extension&#039;] == &#039;gif&#039;) || ($info[&#039;extension&#039;] == &#039;png&#039;)) array_push($images, $url);
                }
            }

            if ( count($images) ) {
                $i=0;
                foreach($images as $url) {
                    $i++;
                    $tpl-&gt;copy_template = str_replace( &#039;{image-&#039;.$i.&#039;}&#039;, $url, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &#039;[image-&#039;.$i.&#039;]&#039;, &quot;&quot;, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &#039;[/image-&#039;.$i.&#039;]&#039;, &quot;&quot;, $tpl-&gt;copy_template );
                }

            }

            $tpl-&gt;copy_template = preg_replace( &quot;#\[image-(.+?)\](.+?)\[/image-(.+?)\]#is&quot;, &quot;&quot;, $tpl-&gt;copy_template );
            $tpl-&gt;copy_template = preg_replace( &quot;#\\{image-(.+?)\\}#i&quot;, &quot;{THEME}/dleimages/no_image.jpg&quot;, $tpl-&gt;copy_template );

        }

        $tpl-&gt;set( &#039;{text}&#039;, $row[&#039;short_story&#039;] );

        if ( preg_match( &quot;#\\{text limit=[&#039;\&quot;](.+?)[&#039;\&quot;]\\}#i&quot;, $tpl-&gt;copy_template, $matches ) ) {
            $count= intval($matches[1]);

            $row[&#039;short_story&#039;] = str_replace( &quot;&lt;/p&gt;&lt;p&gt;&quot;, &quot; &quot;, $row[&#039;short_story&#039;] );
            $row[&#039;short_story&#039;] = strip_tags( $row[&#039;short_story&#039;], &quot;&lt;br&gt;&quot; );
            $row[&#039;short_story&#039;] = trim(str_replace( &quot;&lt;br&gt;&quot;, &quot; &quot;, str_replace( &quot;&lt;br /&gt;&quot;, &quot; &quot;, str_replace( &quot;\n&quot;, &quot; &quot;, str_replace( &quot;\r&quot;, &quot;&quot;, $row[&#039;short_story&#039;] ) ) ) ));

            if( $count AND dle_strlen( $row[&#039;short_story&#039;], $config[&#039;charset&#039;] ) &gt; $count ) {
                    
                $row[&#039;short_story&#039;] = dle_substr( $row[&#039;short_story&#039;], 0, $count, $config[&#039;charset&#039;] );
                    
                if( ($temp_dmax = dle_strrpos( $row[&#039;short_story&#039;], &#039; &#039;, $config[&#039;charset&#039;] )) ) $row[&#039;short_story&#039;] = dle_substr( $row[&#039;short_story&#039;], 0, $temp_dmax, $config[&#039;charset&#039;] );
                
            }

            $tpl-&gt;set( $matches[0], $row[&#039;short_story&#039;] );

        }

        // Обработка дополнительных полей
        if( $xfound ) {
            $xfieldsdata = xfieldsdataload( $row[&#039;xfields&#039;] );
            
            foreach ( $xfields as $value ) {
                $preg_safe_name = preg_quote( $value[0], &quot;&#039;&quot; );

                if ( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
                    $temp_array = explode( &quot;,&quot;, $xfieldsdata[$value[0]] );
                    $value3 = array();

                    foreach ($temp_array as $value2) {

                        $value2 = trim($value2);
                        $value2 = str_replace(&quot;&amp;#039;&quot;, &quot;&#039;&quot;, $value2);

                        if( $config[&#039;allow_alt_url&#039;] ) $value3[] = &quot;&lt;a href=\&quot;&quot; . $config[&#039;http_home_url&#039;] . &quot;xfsearch/&quot; . urlencode( $value2 ) . &quot;/\&quot;&gt;&quot; . $value2 . &quot;&lt;/a&gt;&quot;;
                        else $value3[] = &quot;&lt;a href=\&quot;$PHP_SELF?do=xfsearch&amp;amp;xf=&quot; . urlencode( $value2 ) . &quot;\&quot;&gt;&quot; . $value2 . &quot;&lt;/a&gt;&quot;;
                    }

                    $xfieldsdata[$value[0]] = implode(&quot;, &quot;, $value3);

                    unset($temp_array);
                    unset($value2);
                    unset($value3);

                }
        
                if( empty( $xfieldsdata[$value[0]] ) ) {
                    $tpl-&gt;copy_template = preg_replace( &quot;&#039;\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]&#039;is&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &quot;[xfnotgiven_{$value[0]}]&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &quot;[/xfnotgiven_{$value[0]}]&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                } else {
                    $tpl-&gt;copy_template = preg_replace( &quot;&#039;\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]&#039;is&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &quot;[xfgiven_{$value[0]}]&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &quot;[/xfgiven_{$value[0]}]&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                }
                
                $xfieldsdata[$value[0]] = stripslashes( $xfieldsdata[$value[0]] );

                if ( preg_match( &quot;#\\[xfvalue_{$preg_safe_name} limit=[&#039;\&quot;](.+?)[&#039;\&quot;]\\]#i&quot;, $tpl-&gt;copy_template, $matches ) ) {
                    $count= intval($matches[1]);
        
                    $xfieldsdata[$value[0]] = str_replace( &quot;&lt;/p&gt;&lt;p&gt;&quot;, &quot; &quot;, $xfieldsdata[$value[0]] );
                    $xfieldsdata[$value[0]] = strip_tags( $xfieldsdata[$value[0]], &quot;&lt;br&gt;&quot; );
                    $xfieldsdata[$value[0]] = trim(str_replace( &quot;&lt;br&gt;&quot;, &quot; &quot;, str_replace( &quot;&lt;br /&gt;&quot;, &quot; &quot;, str_replace( &quot;\n&quot;, &quot; &quot;, str_replace( &quot;\r&quot;, &quot;&quot;, $xfieldsdata[$value[0]] ) ) ) ));
        
                    if( $count AND dle_strlen( $xfieldsdata[$value[0]], $config[&#039;charset&#039;] ) &gt; $count ) {
                            
                        $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $count, $config[&#039;charset&#039;] );
                            
                        if( ($temp_dmax = dle_strrpos( $xfieldsdata[$value[0]], &#039; &#039;, $config[&#039;charset&#039;] )) ) $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $temp_dmax, $config[&#039;charset&#039;] );
                        
                    }
        
                    $tpl-&gt;set( $matches[0], $xfieldsdata[$value[0]] );
        
                } else    $tpl-&gt;copy_template = str_replace( &quot;[xfvalue_{$value[0]}]&quot;, $xfieldsdata[$value[0]], $tpl-&gt;copy_template );

            }
        }
        // Обработка дополнительных полей


        $tpl-&gt;compile( &#039;topnews&#039; );
    }

    $tpl-&gt;clear();    
    $db-&gt;free();

    create_cache( &quot;topnews19&quot;, $tpl-&gt;result[&#039;topnews&#039;], $config[&#039;skin&#039;], true );
}
}

else

{
$tpl-&gt;result[&#039;topnews&#039;] = dle_cache( &quot;topnews&quot;, $config[&#039;skin&#039;], true );

if( $tpl-&gt;result[&#039;topnews&#039;] === false ) {
    
    $this_month = date( &#039;Y-m-d H:i:s&#039;, $_TIME );

    $tpl-&gt;load_template( &#039;topnews.tpl&#039; );

    if( strpos( $tpl-&gt;copy_template, &quot;[xfvalue_&quot; ) !== false OR strpos( $tpl-&gt;copy_template, &quot;[xfgiven_&quot; ) !== false ) { $xfound = true; $xfields = xfieldsload();}
    else $xfound = false;

    $config[&#039;top_number&#039;] = intval($config[&#039;top_number&#039;]);
    if ($config[&#039;top_number&#039;] &lt; 1 ) $config[&#039;top_number&#039;] = 10;

    
    $db-&gt;query( &quot;SELECT p.id, p.date, p.short_story, p.xfields, p.title, p.category, p.alt_name FROM &quot; . PREFIX . &quot;_post p LEFT JOIN &quot; . PREFIX . &quot;_post_extras e ON (p.id=e.news_id) WHERE p.approve=1 AND p.date &gt;= &#039;$this_month&#039; - INTERVAL 1 MONTH AND p.date &lt; &#039;$this_month&#039; ORDER BY rating DESC, comm_num DESC, news_read DESC, date DESC LIMIT 0,{$config[&#039;top_number&#039;]}&quot; );
    
    while ( $row = $db-&gt;get_row() ) {
        
        $row[&#039;date&#039;] = strtotime( $row[&#039;date&#039;] );

        if( ! $row[&#039;category&#039;] ) {
            $my_cat = &quot;---&quot;;
            $my_cat_link = &quot;---&quot;;
        } else {
            
            $my_cat = array ();
            $my_cat_link = array ();
            $cat_list = explode( &#039;,&#039;, $row[&#039;category&#039;] );

            if ($config[&#039;category_separator&#039;] != &#039;,&#039;) $config[&#039;category_separator&#039;] = &#039; &#039;.$config[&#039;category_separator&#039;];
         
            if( count( $cat_list ) == 1 ) {
                
                $my_cat[] = $cat_info[$cat_list[0]][&#039;name&#039;];
                
                $my_cat_link = get_categories( $cat_list[0], $config[&#039;category_separator&#039;] );
            
            } else {
                
                foreach ( $cat_list as $element ) {
                    if( $element ) {
                        $my_cat[] = $cat_info[$element][&#039;name&#039;];
                        if( $config[&#039;allow_alt_url&#039;] ) $my_cat_link[] = &quot;&lt;a href=\&quot;&quot; . $config[&#039;http_home_url&#039;] . get_url( $element ) . &quot;/\&quot;&gt;{$cat_info[$element][&#039;name&#039;]}&lt;/a&gt;&quot;;
                        else $my_cat_link[] = &quot;&lt;a href=\&quot;$PHP_SELF?do=cat&amp;category={$cat_info[$element][&#039;alt_name&#039;]}\&quot;&gt;{$cat_info[$element][&#039;name&#039;]}&lt;/a&gt;&quot;;
                    }
                }
                
                $my_cat_link = implode( &quot;{$config[&#039;category_separator&#039;]} &quot;, $my_cat_link );
            }
            
            $my_cat = implode( &quot;{$config[&#039;category_separator&#039;]} &quot;, $my_cat );
        }

        $row[&#039;category&#039;] = intval( $row[&#039;category&#039;] );
        
        if( $config[&#039;allow_alt_url&#039;] ) {
            
            if( $config[&#039;seo_type&#039;] == 1 OR $config[&#039;seo_type&#039;] == 2 ) {
                
                if( $row[&#039;category&#039;] and $config[&#039;seo_type&#039;] == 2 ) {
                    
                    $full_link = $config[&#039;http_home_url&#039;] . get_url( $row[&#039;category&#039;] ) . &quot;/&quot; . $row[&#039;id&#039;] . &quot;-&quot; . $row[&#039;alt_name&#039;] . &quot;.html&quot;;
                
                } else {
                    
                    $full_link = $config[&#039;http_home_url&#039;] . $row[&#039;id&#039;] . &quot;-&quot; . $row[&#039;alt_name&#039;] . &quot;.html&quot;;
                
                }
            
            } else {
                
                $full_link = $config[&#039;http_home_url&#039;] . date( &#039;Y/m/d/&#039;, $row[&#039;date&#039;] ) . $row[&#039;alt_name&#039;] . &quot;.html&quot;;
            }
        
        } else {
            
            $full_link = $config[&#039;http_home_url&#039;] . &quot;index.php?newsid=&quot; . $row[&#039;id&#039;];
        
        }

        if( date( &#039;Ymd&#039;, $row[&#039;date&#039;] ) == date( &#039;Ymd&#039;, $_TIME ) ) {
            
            $tpl-&gt;set( &#039;{date}&#039;, $lang[&#039;time_heute&#039;] . langdate( &quot;, H:i&quot;, $row[&#039;date&#039;] ) );
        
        } elseif( date( &#039;Ymd&#039;, $row[&#039;date&#039;] ) == date( &#039;Ymd&#039;, ($_TIME - 86400) ) ) {
            
            $tpl-&gt;set( &#039;{date}&#039;, $lang[&#039;time_gestern&#039;] . langdate( &quot;, H:i&quot;, $row[&#039;date&#039;] ) );
        
        } else {
            
            $tpl-&gt;set( &#039;{date}&#039;, langdate( $config[&#039;timestamp_active&#039;], $row[&#039;date&#039;] ) );
        
        }

        $news_date = $row[&#039;date&#039;];
        $tpl-&gt;copy_template = preg_replace_callback ( &quot;#\{date=(.+?)\}#i&quot;, &quot;formdate&quot;, $tpl-&gt;copy_template );

        $tpl-&gt;set( &#039;{category}&#039;, $my_cat );
        $tpl-&gt;set( &#039;{link-category}&#039;, $my_cat_link );

        $row[&#039;title&#039;] = stripslashes( $row[&#039;title&#039;] );

        $row[&#039;title&#039;] = str_replace( &quot;{&quot;, &quot;&amp;#123;&quot;, $row[&#039;title&#039;] );

        $tpl-&gt;set( &#039;{title}&#039;, $row[&#039;title&#039;] );
        
        if ( preg_match( &quot;#\\{title limit=[&#039;\&quot;](.+?)[&#039;\&quot;]\\}#i&quot;, $tpl-&gt;copy_template, $matches ) ) {
            $count= intval($matches[1]);

            $row[&#039;title&#039;] = strip_tags( $row[&#039;title&#039;] );

            if( $count AND dle_strlen( $row[&#039;title&#039;], $config[&#039;charset&#039;] ) &gt; $count ) {
                    
                $row[&#039;title&#039;] = dle_substr( $row[&#039;title&#039;], 0, $count, $config[&#039;charset&#039;] );
                    
                if( ($temp_dmax = dle_strrpos( $row[&#039;title&#039;], &#039; &#039;, $config[&#039;charset&#039;] )) ) $row[&#039;title&#039;] = dle_substr( $row[&#039;title&#039;], 0, $temp_dmax, $config[&#039;charset&#039;] ). &quot; ...&quot;;
                
            }

            $tpl-&gt;set( $matches[0], $row[&#039;title&#039;] );

        }


        $tpl-&gt;set( &#039;{link}&#039;, $full_link );

        $row[&#039;short_story&#039;] = stripslashes( $row[&#039;short_story&#039;] );

        if( $user_group[$member_id[&#039;user_group&#039;]][&#039;allow_hide&#039;] ) $row[&#039;short_story&#039;] = str_ireplace( &quot;[hide]&quot;, &quot;&quot;, str_ireplace( &quot;[/hide]&quot;, &quot;&quot;, $row[&#039;short_story&#039;]) );
        else $row[&#039;short_story&#039;] = preg_replace ( &quot;#\[hide\](.+?)\[/hide\]#ims&quot;, &quot;&lt;div class=\&quot;quote\&quot;&gt;&quot; . $lang[&#039;news_regus&#039;] . &quot;&lt;/div&gt;&quot;, $row[&#039;short_story&#039;] );

        if (stripos ( $tpl-&gt;copy_template, &quot;{image-&quot; ) !== false) {

            $images = array();
            preg_match_all(&#039;/(img|src)=(&quot;|\&#039;)[^&quot;\&#039;&gt;]+/i&#039;, $row[&#039;short_story&#039;], $media);
            $data=preg_replace(&#039;/(img|src)(&quot;|\&#039;|=&quot;|=\&#039;)(.*)/i&#039;,&quot;$3&quot;,$media[0]);

            foreach($data as $url) {
                $info = pathinfo($url);
                if (isset($info[&#039;extension&#039;])) {
                    if ($info[&#039;filename&#039;] == &quot;spoiler-plus&quot; OR $info[&#039;filename&#039;] == &quot;spoiler-plus&quot; ) continue;
                    $info[&#039;extension&#039;] = strtolower($info[&#039;extension&#039;]);
                    if (($info[&#039;extension&#039;] == &#039;jpg&#039;) || ($info[&#039;extension&#039;] == &#039;jpeg&#039;) || ($info[&#039;extension&#039;] == &#039;gif&#039;) || ($info[&#039;extension&#039;] == &#039;png&#039;)) array_push($images, $url);
                }
            }

            if ( count($images) ) {
                $i=0;
                foreach($images as $url) {
                    $i++;
                    $tpl-&gt;copy_template = str_replace( &#039;{image-&#039;.$i.&#039;}&#039;, $url, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &#039;[image-&#039;.$i.&#039;]&#039;, &quot;&quot;, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &#039;[/image-&#039;.$i.&#039;]&#039;, &quot;&quot;, $tpl-&gt;copy_template );
                }

            }

            $tpl-&gt;copy_template = preg_replace( &quot;#\[image-(.+?)\](.+?)\[/image-(.+?)\]#is&quot;, &quot;&quot;, $tpl-&gt;copy_template );
            $tpl-&gt;copy_template = preg_replace( &quot;#\\{image-(.+?)\\}#i&quot;, &quot;{THEME}/dleimages/no_image.jpg&quot;, $tpl-&gt;copy_template );

        }

        $tpl-&gt;set( &#039;{text}&#039;, $row[&#039;short_story&#039;] );

        if ( preg_match( &quot;#\\{text limit=[&#039;\&quot;](.+?)[&#039;\&quot;]\\}#i&quot;, $tpl-&gt;copy_template, $matches ) ) {
            $count= intval($matches[1]);

            $row[&#039;short_story&#039;] = str_replace( &quot;&lt;/p&gt;&lt;p&gt;&quot;, &quot; &quot;, $row[&#039;short_story&#039;] );
            $row[&#039;short_story&#039;] = strip_tags( $row[&#039;short_story&#039;], &quot;&lt;br&gt;&quot; );
            $row[&#039;short_story&#039;] = trim(str_replace( &quot;&lt;br&gt;&quot;, &quot; &quot;, str_replace( &quot;&lt;br /&gt;&quot;, &quot; &quot;, str_replace( &quot;\n&quot;, &quot; &quot;, str_replace( &quot;\r&quot;, &quot;&quot;, $row[&#039;short_story&#039;] ) ) ) ));

            if( $count AND dle_strlen( $row[&#039;short_story&#039;], $config[&#039;charset&#039;] ) &gt; $count ) {
                    
                $row[&#039;short_story&#039;] = dle_substr( $row[&#039;short_story&#039;], 0, $count, $config[&#039;charset&#039;] );
                    
                if( ($temp_dmax = dle_strrpos( $row[&#039;short_story&#039;], &#039; &#039;, $config[&#039;charset&#039;] )) ) $row[&#039;short_story&#039;] = dle_substr( $row[&#039;short_story&#039;], 0, $temp_dmax, $config[&#039;charset&#039;] );
                
            }

            $tpl-&gt;set( $matches[0], $row[&#039;short_story&#039;] );

        }

        // Обработка дополнительных полей
        if( $xfound ) {
            $xfieldsdata = xfieldsdataload( $row[&#039;xfields&#039;] );
            
            foreach ( $xfields as $value ) {
                $preg_safe_name = preg_quote( $value[0], &quot;&#039;&quot; );

                if ( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
                    $temp_array = explode( &quot;,&quot;, $xfieldsdata[$value[0]] );
                    $value3 = array();

                    foreach ($temp_array as $value2) {

                        $value2 = trim($value2);
                        $value2 = str_replace(&quot;&amp;#039;&quot;, &quot;&#039;&quot;, $value2);

                        if( $config[&#039;allow_alt_url&#039;] ) $value3[] = &quot;&lt;a href=\&quot;&quot; . $config[&#039;http_home_url&#039;] . &quot;xfsearch/&quot; . urlencode( $value2 ) . &quot;/\&quot;&gt;&quot; . $value2 . &quot;&lt;/a&gt;&quot;;
                        else $value3[] = &quot;&lt;a href=\&quot;$PHP_SELF?do=xfsearch&amp;amp;xf=&quot; . urlencode( $value2 ) . &quot;\&quot;&gt;&quot; . $value2 . &quot;&lt;/a&gt;&quot;;
                    }

                    $xfieldsdata[$value[0]] = implode(&quot;, &quot;, $value3);

                    unset($temp_array);
                    unset($value2);
                    unset($value3);

                }
        
                if( empty( $xfieldsdata[$value[0]] ) ) {
                    $tpl-&gt;copy_template = preg_replace( &quot;&#039;\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]&#039;is&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &quot;[xfnotgiven_{$value[0]}]&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &quot;[/xfnotgiven_{$value[0]}]&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                } else {
                    $tpl-&gt;copy_template = preg_replace( &quot;&#039;\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]&#039;is&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &quot;[xfgiven_{$value[0]}]&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                    $tpl-&gt;copy_template = str_replace( &quot;[/xfgiven_{$value[0]}]&quot;, &quot;&quot;, $tpl-&gt;copy_template );
                }
                
                $xfieldsdata[$value[0]] = stripslashes( $xfieldsdata[$value[0]] );

                if ( preg_match( &quot;#\\[xfvalue_{$preg_safe_name} limit=[&#039;\&quot;](.+?)[&#039;\&quot;]\\]#i&quot;, $tpl-&gt;copy_template, $matches ) ) {
                    $count= intval($matches[1]);
        
                    $xfieldsdata[$value[0]] = str_replace( &quot;&lt;/p&gt;&lt;p&gt;&quot;, &quot; &quot;, $xfieldsdata[$value[0]] );
                    $xfieldsdata[$value[0]] = strip_tags( $xfieldsdata[$value[0]], &quot;&lt;br&gt;&quot; );
                    $xfieldsdata[$value[0]] = trim(str_replace( &quot;&lt;br&gt;&quot;, &quot; &quot;, str_replace( &quot;&lt;br /&gt;&quot;, &quot; &quot;, str_replace( &quot;\n&quot;, &quot; &quot;, str_replace( &quot;\r&quot;, &quot;&quot;, $xfieldsdata[$value[0]] ) ) ) ));
        
                    if( $count AND dle_strlen( $xfieldsdata[$value[0]], $config[&#039;charset&#039;] ) &gt; $count ) {
                            
                        $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $count, $config[&#039;charset&#039;] );
                            
                        if( ($temp_dmax = dle_strrpos( $xfieldsdata[$value[0]], &#039; &#039;, $config[&#039;charset&#039;] )) ) $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $temp_dmax, $config[&#039;charset&#039;] );
                        
                    }
        
                    $tpl-&gt;set( $matches[0], $xfieldsdata[$value[0]] );
        
                } else    $tpl-&gt;copy_template = str_replace( &quot;[xfvalue_{$value[0]}]&quot;, $xfieldsdata[$value[0]], $tpl-&gt;copy_template );

            }
        }
        // Обработка дополнительных полей


        $tpl-&gt;compile( &#039;topnews&#039; );
    }

    $tpl-&gt;clear();    
    $db-&gt;free();

    create_cache( &quot;topnews&quot;, $tpl-&gt;result[&#039;topnews&#039;], $config[&#039;skin&#039;], true );
}
}
?&gt;</code></pre></div></div></div>]]></content>
			<author>
				<name><![CDATA[svetlana]]></name>
				<uri>https://talk.alaev.info/user/783/</uri>
			</author>
			<updated>2015-05-08T13:52:24Z</updated>
			<id>https://talk.alaev.info/post/9563/#p9563</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/9560/#p9560" />
			<content type="html"><![CDATA[<p>C подключением разобрался, не подключалось из- за названия шаблона. А как можно вывести топ новости категории &quot;19&quot; чтобы отображались только новости этой категории</p>]]></content>
			<author>
				<name><![CDATA[xxEmagExx]]></name>
				<uri>https://talk.alaev.info/user/1054/</uri>
			</author>
			<updated>2015-05-08T01:55:41Z</updated>
			<id>https://talk.alaev.info/post/9560/#p9560</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/9559/#p9559" />
			<content type="html"><![CDATA[<p>ну потому же принципу<br />только </p><div class="codebox"><pre><code>$tpl-&gt;load_template ( &#039;main.tpl&#039; );</code></pre></div><p>заменить<br />на<br /></p><div class="codebox"><pre><code>if ($category_id == &quot;19&quot;) {$tpl-&gt;load_template ( &#039;main_другой.tpl&#039; );} 
else
{$tpl-&gt;load_template ( &#039;main.tpl&#039; );}</code></pre></div><p>Даже проверила и оба варианта работают нормально.</p>]]></content>
			<author>
				<name><![CDATA[svetlana]]></name>
				<uri>https://talk.alaev.info/user/783/</uri>
			</author>
			<updated>2015-05-07T21:42:09Z</updated>
			<id>https://talk.alaev.info/post/9559/#p9559</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/9557/#p9557" />
			<content type="html"><![CDATA[<p>Добавил код if ($category_id == &quot;19&quot;) {$config[&#039;skin&#039;] = &quot;novosti tehnologi&quot;;} все-равно ничего не меняется, работает основной шаблон который установлен по умолчанию... <br />Возможно ли как то подключить отдельно второй&nbsp; main.tpl для этой категории, а не целиком шаблон?</p>]]></content>
			<author>
				<name><![CDATA[xxEmagExx]]></name>
				<uri>https://talk.alaev.info/user/1054/</uri>
			</author>
			<updated>2015-05-07T10:19:39Z</updated>
			<id>https://talk.alaev.info/post/9557/#p9557</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/9556/#p9556" />
			<content type="html"><![CDATA[<p>В index.php <br />перед<br /></p><div class="codebox"><pre><code>$tpl-&gt;load_template ( &#039;main.tpl&#039; );</code></pre></div><p>вписать<br /></p><div class="codebox"><pre><code>if ($category_id == &quot;ид категории&quot;) {$config[&#039;skin&#039;] = &quot;имя шаблона&quot;;}</code></pre></div><p>но лучше найти причину по которой не работает стандартная функция, возможно что-то в init.php потерли.</p>]]></content>
			<author>
				<name><![CDATA[svetlana]]></name>
				<uri>https://talk.alaev.info/user/783/</uri>
			</author>
			<updated>2015-05-07T08:27:25Z</updated>
			<id>https://talk.alaev.info/post/9556/#p9556</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/9555/#p9555" />
			<content type="html"><![CDATA[<p>Шаблон планировалось сделать другой только для одной категории. Все остальное останется тоже самое</p>]]></content>
			<author>
				<name><![CDATA[xxEmagExx]]></name>
				<uri>https://talk.alaev.info/user/1054/</uri>
			</author>
			<updated>2015-05-07T04:47:29Z</updated>
			<id>https://talk.alaev.info/post/9555/#p9555</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/9554/#p9554" />
			<content type="html"><![CDATA[<p>А в остальном шаблон будет тот же? Только топ другой?<br />топ стандартный или модуль?</p>]]></content>
			<author>
				<name><![CDATA[svetlana]]></name>
				<uri>https://talk.alaev.info/user/783/</uri>
			</author>
			<updated>2015-05-06T20:28:03Z</updated>
			<id>https://talk.alaev.info/post/9554/#p9554</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/9553/#p9553" />
			<content type="html"><![CDATA[<p>Возникла подобная проблема: При установке в настройках категории отдельного шаблона ничего не меняется, при этом показывается что установлен выбранный мной шаблон.</p><p>Идея такова: сделать для категории &quot;1&quot; отдельный шаблон чтобы в нем можно было выводить топ новости (категории &quot;1&quot;) в левом блоке. Как можно организовать?</p>]]></content>
			<author>
				<name><![CDATA[xxEmagExx]]></name>
				<uri>https://talk.alaev.info/user/1054/</uri>
			</author>
			<updated>2015-05-06T09:30:49Z</updated>
			<id>https://talk.alaev.info/post/9553/#p9553</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/2222/#p2222" />
			<content type="html"><![CDATA[<p>Sorry! По русски я не знаток?</p><p>Если указать шаблон в категории тогда этот меню повторяются.</p>]]></content>
			<author>
				<name><![CDATA[TITAN-UZ]]></name>
				<uri>https://talk.alaev.info/user/44/</uri>
			</author>
			<updated>2012-12-06T21:27:02Z</updated>
			<id>https://talk.alaev.info/post/2222/#p2222</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/2193/#p2193" />
			<content type="html"><![CDATA[<p><strong>TITAN-UZ</strong>, Что-то у тебя с грамотой беда... Фиг поймешь, что ты хотел сказать <img src="https://talk.alaev.info/img/smilies/sad.png" width="15" height="15" alt="sad" /><br />Так при редактировании категории в админке укажи индивидуальный шаблон, зачем велосипед сочинять?</p>]]></content>
			<author>
				<name><![CDATA[admin]]></name>
				<uri>https://talk.alaev.info/user/2/</uri>
			</author>
			<updated>2012-12-05T09:07:14Z</updated>
			<id>https://talk.alaev.info/post/2193/#p2193</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/2191/#p2191" />
			<content type="html"><![CDATA[<p>Я сделал так чтоб короткие новости были скрыты с&nbsp; (site.ru/cetegory1/) на c1.tpl сделан меню с изображениями линьком на новость в этом категории.&nbsp; &nbsp;</p><p>Все кроме этого категории работает без проблем!</p>]]></content>
			<author>
				<name><![CDATA[TITAN-UZ]]></name>
				<uri>https://talk.alaev.info/user/44/</uri>
			</author>
			<updated>2012-12-05T07:53:49Z</updated>
			<id>https://talk.alaev.info/post/2191/#p2191</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/2190/#p2190" />
			<content type="html"><![CDATA[<p><strong>TITAN-UZ</strong>, А без инклуда все нормально?</p>]]></content>
			<author>
				<name><![CDATA[admin]]></name>
				<uri>https://talk.alaev.info/user/2/</uri>
			</author>
			<updated>2012-12-05T07:39:12Z</updated>
			<id>https://talk.alaev.info/post/2190/#p2190</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Проблемы с include на категориях]]></title>
			<link rel="alternate" href="https://talk.alaev.info/post/2189/#p2189" />
			<content type="html"><![CDATA[<p>Приветь!</p><p>Сделал инклуд на категории чтоб при открывание&nbsp; site.ru/cetegory1/&nbsp; &nbsp;показал отдельный шаблон.</p><div class="codebox"><pre><code>[category=1]{include file=&quot;team/c1.tpl&quot;}[/category]</code></pre></div><p>Все работает без проблем но google показывает ошибку 404 как лечить эту проблему?</p>]]></content>
			<author>
				<name><![CDATA[TITAN-UZ]]></name>
				<uri>https://talk.alaev.info/user/44/</uri>
			</author>
			<updated>2012-12-05T07:21:47Z</updated>
			<id>https://talk.alaev.info/post/2189/#p2189</id>
		</entry>
</feed>
