<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Форум АлаичЪ'а о SEO - проблема с куки]]></title>
		<link>https://talk.alaev.info/topic/1450/</link>
		<atom:link href="https://talk.alaev.info/feed/rss/topic/1450/" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «проблема с куки».]]></description>
		<lastBuildDate>Sat, 06 Jun 2015 20:26:06 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: проблема с куки]]></title>
			<link>https://talk.alaev.info/post/9624/#p9624</link>
			<description><![CDATA[<p>Большое списибо. Если чем еще могу помочь - обращайтесь.</p>]]></description>
			<author><![CDATA[null@example.com (kosa1)]]></author>
			<pubDate>Sat, 06 Jun 2015 20:26:06 +0000</pubDate>
			<guid>https://talk.alaev.info/post/9624/#p9624</guid>
		</item>
		<item>
			<title><![CDATA[Re: проблема с куки]]></title>
			<link>https://talk.alaev.info/post/9623/#p9623</link>
			<description><![CDATA[<p>Ну цена обычно варьируется в промежутке между обычным &quot;Спасибо&quot; и &quot;Большим Спасибо&quot;<br /><img src="https://talk.alaev.info/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (svetlana)]]></author>
			<pubDate>Sat, 06 Jun 2015 15:38:43 +0000</pubDate>
			<guid>https://talk.alaev.info/post/9623/#p9623</guid>
		</item>
		<item>
			<title><![CDATA[Re: проблема с куки]]></title>
			<link>https://talk.alaev.info/post/9622/#p9622</link>
			<description><![CDATA[<p>Светлана - Вы волшебница! Я более чем 6 месяцев борюсь с этой проблемой, отписывал на многих форумах,&nbsp; в самой сапе не могли помочь... Весь интернет перерыл, находил схожие проблемы, но никто не мог справится, помогало обновление двига только.<br />Скажите сколько я Вам должен? Вы действительно мне помогли!</p>]]></description>
			<author><![CDATA[null@example.com (kosa1)]]></author>
			<pubDate>Sat, 06 Jun 2015 10:32:27 +0000</pubDate>
			<guid>https://talk.alaev.info/post/9622/#p9622</guid>
		</item>
		<item>
			<title><![CDATA[Re: проблема с куки]]></title>
			<link>https://talk.alaev.info/post/9621/#p9621</link>
			<description><![CDATA[<p>замените functions.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,2013 SoftNews Media Group
=====================================================
 Данный код защищен авторскими правами
=====================================================
 Файл: functions.php
-----------------------------------------------------
 Назначение: Основные функции
=====================================================
*/
if( ! defined( &#039;DATALIFEENGINE&#039; ) ) {
    die( &quot;Hacking attempt!&quot; );
}

if ( $config[&#039;auth_domain&#039;] ) {

    $domain_cookie = explode (&quot;.&quot;, clean_url( $_SERVER[&#039;HTTP_HOST&#039;] ));
    $domain_cookie_count = count($domain_cookie);
    $domain_allow_count = -2;
    
    if ( $domain_cookie_count &gt; 2 ) {
    
        if ( in_array($domain_cookie[$domain_cookie_count-2], array(&#039;com&#039;, &#039;net&#039;, &#039;org&#039;) )) $domain_allow_count = -3;
        if ( $domain_cookie[$domain_cookie_count-1] == &#039;ua&#039; ) $domain_allow_count = -3;
        $domain_cookie = array_slice($domain_cookie, $domain_allow_count);
    }
    
    $domain_cookie = &quot;.&quot; . implode (&quot;.&quot;, $domain_cookie);
    
    if( (ip2long($_SERVER[&#039;HTTP_HOST&#039;]) == -1 OR ip2long($_SERVER[&#039;HTTP_HOST&#039;]) === FALSE) AND strtoupper(substr(PHP_OS, 0, 3)) !== &#039;WIN&#039; ) define( &#039;DOMAIN&#039;, $domain_cookie );
    else define( &#039;DOMAIN&#039;, null );

} else define( &#039;DOMAIN&#039;, null );

$mcache = false;

if ( $config[&#039;cache_type&#039;] ) {

    if ( function_exists(&#039;memcache_connect&#039;) ) {

        $memcache_server = explode(&quot;:&quot;, $config[&#039;memcache_server&#039;]);

        $mcache = @memcache_connect( $memcache_server[0], $memcache_server[1] );

        if( $mcache AND function_exists(&#039;memcache_set_compress_threshold&#039;) )
        {
            memcache_set_compress_threshold( $mcache, 20000, 0.2 );
        }

    }

}

function dle_session( $sid = false ) {

    $params = session_get_cookie_params();

    if ( DOMAIN ) $params[&#039;domain&#039;] = DOMAIN;

    if( version_compare(PHP_VERSION, &#039;5.2&#039;, &#039;&lt;&#039;) ) {
        
        session_set_cookie_params($params[&#039;lifetime&#039;], &quot;/&quot;, $params[&#039;domain&#039;].&quot;; HttpOnly&quot;, $params[&#039;secure&#039;]);
    
    } else {
        
        session_set_cookie_params($params[&#039;lifetime&#039;], &quot;/&quot;, $params[&#039;domain&#039;], $params[&#039;secure&#039;], true);
    
    }

    if ( $sid ) @session_id( $sid );

    @session_start();

}

function formatsize($file_size) {
    if( $file_size &gt;= 1073741824 ) {
        $file_size = round( $file_size / 1073741824 * 100 ) / 100 . &quot; Gb&quot;;
    } elseif( $file_size &gt;= 1048576 ) {
        $file_size = round( $file_size / 1048576 * 100 ) / 100 . &quot; Mb&quot;;
    } elseif( $file_size &gt;= 1024 ) {
        $file_size = round( $file_size / 1024 * 100 ) / 100 . &quot; Kb&quot;;
    } else {
        $file_size = $file_size . &quot; b&quot;;
    }
    return $file_size;
}

class microTimer {
    function start() {
        global $starttime;
        $mtime = microtime();
        $mtime = explode( &#039; &#039;, $mtime );
        $mtime = $mtime[1] + $mtime[0];
        $starttime = $mtime;
    }
    function stop() {
        global $starttime;
        $mtime = microtime();
        $mtime = explode( &#039; &#039;, $mtime );
        $mtime = $mtime[1] + $mtime[0];
        $endtime = $mtime;
        $totaltime = round( ($endtime - $starttime), 5 );
        return $totaltime;
    }
}

function flooder($ip, $news_time = false) {
    global $config, $db;
    
    if ( $news_time ) {

        $this_time = time() + ($config[&#039;date_adjust&#039;] * 60) - $news_time;
        $db-&gt;query( &quot;DELETE FROM &quot; . PREFIX . &quot;_flood where id &lt; &#039;$this_time&#039; AND flag=&#039;1&#039; &quot; );
        
        $row = $db-&gt;super_query(&quot;SELECT COUNT(*) as count FROM &quot; . PREFIX . &quot;_flood WHERE ip = &#039;$ip&#039; AND flag=&#039;1&#039;&quot;);
        
        if( $row[&#039;count&#039;] ) return TRUE;
        else return FALSE;

    } else {

        $this_time = time() + ($config[&#039;date_adjust&#039;] * 60) - $config[&#039;flood_time&#039;];
        $db-&gt;query( &quot;DELETE FROM &quot; . PREFIX . &quot;_flood where id &lt; &#039;$this_time&#039; AND flag=&#039;0&#039; &quot; );
        
        $row = $db-&gt;super_query(&quot;SELECT COUNT(*) as count FROM &quot; . PREFIX . &quot;_flood WHERE ip = &#039;$ip&#039; AND flag=&#039;0&#039;&quot;);
        
        if( $row[&#039;count&#039;] ) return TRUE;
        else return FALSE;

    }

}

function totranslit($var, $lower = true, $punkt = true) {
    global $langtranslit;
    
    if ( is_array($var) ) return &quot;&quot;;

    if (!is_array ( $langtranslit ) OR !count( $langtranslit ) ) {
        $var = trim( strip_tags( $var ) );

        if ( $punkt ) $var = preg_replace( &quot;/[^a-z0-9\_\-.]+/mi&quot;, &quot;&quot;, $var );
        else $var = preg_replace( &quot;/[^a-z0-9\_\-]+/mi&quot;, &quot;&quot;, $var );

        $var = preg_replace( &#039;#[.]+#i&#039;, &#039;.&#039;, $var );
        $var = str_ireplace( &quot;.php&quot;, &quot;.ppp&quot;, $var );

        if ( $lower ) $var = strtolower( $var );

        return $var;
    }
    
    $var = trim( strip_tags( $var ) );
    $var = preg_replace( &quot;/\s+/ms&quot;, &quot;-&quot;, $var );
    $var = str_replace( &quot;/&quot;, &quot;-&quot;, $var );

    $var = strtr($var, $langtranslit);
    
    if ( $punkt ) $var = preg_replace( &quot;/[^a-z0-9\_\-.]+/mi&quot;, &quot;&quot;, $var );
    else $var = preg_replace( &quot;/[^a-z0-9\_\-]+/mi&quot;, &quot;&quot;, $var );

    $var = preg_replace( &#039;#[\-]+#i&#039;, &#039;-&#039;, $var );
    $var = preg_replace( &#039;#[.]+#i&#039;, &#039;.&#039;, $var );

    if ( $lower ) $var = strtolower( $var );

    $var = str_ireplace( &quot;.php&quot;, &quot;&quot;, $var );
    $var = str_ireplace( &quot;.php&quot;, &quot;.ppp&quot;, $var );

    if( strlen( $var ) &gt; 200 ) {
        
        $var = substr( $var, 0, 200 );
        
        if( ($temp_max = strrpos( $var, &#039;-&#039; )) ) $var = substr( $var, 0, $temp_max );
    
    }
    
    return $var;
}

function langdate($format, $stamp) {
    global $langdate;
    
    return strtr( @date( $format, $stamp ), $langdate );

}

function msgbox($title, $text) {
    global $tpl;

    if (!class_exists(&#039;dle_template&#039;)) {
        return;
    }
    
    $tpl_2 = new dle_template( );
    $tpl_2-&gt;dir = TEMPLATE_DIR;
    
    $tpl_2-&gt;load_template( &#039;info.tpl&#039; );
    
    $tpl_2-&gt;set( &#039;{error}&#039;, $text );
    $tpl_2-&gt;set( &#039;{title}&#039;, $title );
    
    $tpl_2-&gt;compile( &#039;info&#039; );
    $tpl_2-&gt;clear();
    
    $tpl-&gt;result[&#039;info&#039;] .= $tpl_2-&gt;result[&#039;info&#039;];
}

function ShowRating($id, $rating, $vote_num, $allow = true) {
    global $lang;
    
    if( $rating AND $vote_num ) $rating = round( ($rating / $vote_num), 0 );
    else $rating = 0;
    $rating = $rating * 17;
    
    if( !$allow ) {
        
        $rated = &lt;&lt;&lt;HTML
&lt;div class=&quot;rating&quot;&gt;
        &lt;ul class=&quot;unit-rating&quot;&gt;
        &lt;li class=&quot;current-rating&quot; style=&quot;width:{$rating}px;&quot;&gt;{$rating}&lt;/li&gt;
        &lt;/ul&gt;
&lt;/div&gt;
HTML;
        
        return $rated;
    }
    
    $rated = &lt;&lt;&lt;HTML
&lt;div id=&#039;ratig-layer-{$id}&#039;&gt;&lt;div class=&quot;rating&quot;&gt;
        &lt;ul class=&quot;unit-rating&quot;&gt;
        &lt;li class=&quot;current-rating&quot; style=&quot;width:{$rating}px;&quot;&gt;{$rating}&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;{$lang[&#039;useless&#039;]}&quot; class=&quot;r1-unit&quot; onclick=&quot;doRate(&#039;1&#039;, &#039;{$id}&#039;); return false;&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;{$lang[&#039;poor&#039;]}&quot; class=&quot;r2-unit&quot; onclick=&quot;doRate(&#039;2&#039;, &#039;{$id}&#039;); return false;&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;{$lang[&#039;fair&#039;]}&quot; class=&quot;r3-unit&quot; onclick=&quot;doRate(&#039;3&#039;, &#039;{$id}&#039;); return false;&quot;&gt;3&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;{$lang[&#039;good&#039;]}&quot; class=&quot;r4-unit&quot; onclick=&quot;doRate(&#039;4&#039;, &#039;{$id}&#039;); return false;&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;{$lang[&#039;excellent&#039;]}&quot; class=&quot;r5-unit&quot; onclick=&quot;doRate(&#039;5&#039;, &#039;{$id}&#039;); return false;&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
HTML;
    
    return $rated;
}

function userrating($id) {
    global $db;
    
    $row = $db-&gt;super_query( &quot;SELECT SUM(rating) as rating, SUM(vote_num) as num FROM &quot; . PREFIX . &quot;_post_extras WHERE user_id =&#039;{$id}&#039;&quot; );
    
    if( $row[&#039;num&#039;] ) $rating = round( ($row[&#039;rating&#039;] / $row[&#039;num&#039;]), 0 );
    else $rating = 0;

    $rating = $rating * 17;
    
    $rated = &lt;&lt;&lt;HTML
&lt;div class=&quot;rating&quot; style=&quot;display:inline;&quot;&gt;
        &lt;ul class=&quot;unit-rating&quot;&gt;
        &lt;li class=&quot;current-rating&quot; style=&quot;width:{$rating}px;&quot;&gt;{$rating}&lt;/li&gt;
        &lt;/ul&gt;
        &lt;/div&gt;
HTML;
    
    return $rated;
}

function CategoryNewsSelection($categoryid = 0, $parentid = 0, $nocat = TRUE, $sublevelmarker = &#039;&#039;, $returnstring = &#039;&#039;) {
    global $cat_info, $user_group, $member_id, $dle_module;

    if ($dle_module == &#039;addnews&#039;) $allow_list = explode( &#039;,&#039;, $user_group[$member_id[&#039;user_group&#039;]][&#039;cat_allow_addnews&#039;] );
    else $allow_list = explode( &#039;,&#039;, $user_group[$member_id[&#039;user_group&#039;]][&#039;allow_cats&#039;] );

    $spec_list = explode( &#039;,&#039;, $user_group[$member_id[&#039;user_group&#039;]][&#039;cat_add&#039;] );

    $root_category = array ();
    
    if( $parentid == 0 ) {
        if( $nocat ) $returnstring .= &#039;&lt;option value=&quot;0&quot;&gt;&lt;/option&gt;&#039;;
    } else {
        $sublevelmarker .= &#039;&amp;nbsp;&amp;nbsp;&amp;nbsp;&#039;;
    }
    
    if( count( $cat_info ) ) {
        
        foreach ( $cat_info as $cats ) {
            if( $cats[&#039;parentid&#039;] == $parentid ) $root_category[] = $cats[&#039;id&#039;];
        }
        
        if( count( $root_category ) ) {
            foreach ( $root_category as $id ) {
                
                if( $allow_list[0] == &quot;all&quot; OR in_array( $id, $allow_list ) ) {
                    
                    if( $spec_list[0] == &quot;all&quot; or in_array( $id, $spec_list ) ) $color = &quot;black&quot;;
                    else $color = &quot;red&quot;;
                    
                    $returnstring .= &quot;&lt;option style=\&quot;color: {$color}\&quot; value=\&quot;&quot; . $id . &#039;&quot; &#039;;
                    
                    if( is_array( $categoryid ) ) {
                        foreach ( $categoryid as $element ) {
                            if( $element == $id ) $returnstring .= &#039;SELECTED&#039;;
                        }
                    } elseif( $categoryid == $id ) $returnstring .= &#039;SELECTED&#039;;
                    
                    $returnstring .= &#039;&gt;&#039; . $sublevelmarker . $cat_info[$id][&#039;name&#039;] . &#039;&lt;/option&gt;&#039;;
                }
                $returnstring = CategoryNewsSelection( $categoryid, $id, $nocat, $sublevelmarker, $returnstring );
            }
        }
    }
    return $returnstring;
}

function get_ID($cat_info, $category) {
    foreach ( $cat_info as $cats ) {
        if( $cats[&#039;alt_name&#039;] == $category ) return $cats[&#039;id&#039;];
    }
    return false;
}

function set_vars($file, $data) {
    
    $fp = fopen( ENGINE_DIR . &#039;/cache/system/&#039; . $file . &#039;.php&#039;, &#039;wb+&#039; );
    fwrite( $fp, serialize( $data ) );
    fclose( $fp );
    
    @chmod( ENGINE_DIR . &#039;/cache/system/&#039; . $file . &#039;.php&#039;, 0666 );
}

function get_vars($file) {
    
    return unserialize( @file_get_contents( ENGINE_DIR . &#039;/cache/system/&#039; . $file . &#039;.php&#039; ) );
}

function filesize_url($url) {
    return ($data = @file_get_contents( $url )) ? strlen( $data ) : false;
}

function dle_cache($prefix, $cache_id = false, $member_prefix = false) {
    global $config, $is_logged, $member_id, $mcache;
    
    if( $config[&#039;allow_cache&#039;] != &quot;yes&quot; ) return false;
    
    if( $is_logged ) $end_file = $member_id[&#039;user_group&#039;];
    else $end_file = &quot;0&quot;;
    
    if( ! $cache_id ) {
        
        $key = $prefix;
    
    } else {
        
        $cache_id = md5( $cache_id );
        
        if( $member_prefix ) $key = $prefix . &quot;_&quot; . $cache_id . &quot;_&quot; . $end_file;
        else $key = $prefix . &quot;_&quot; . $cache_id;
    
    }

    if ( $mcache ) {

        return memcache_get( $mcache, md5( DBNAME . PREFIX . md5(DBUSER) .$key ) );

    } else {

        return @file_get_contents( ENGINE_DIR . &quot;/cache/&quot; . $key . &quot;.tmp&quot; );

    }
}

function create_cache($prefix, $cache_text, $cache_id = false, $member_prefix = false) {
    global $config, $is_logged, $member_id, $mcache;
    
    if( $config[&#039;allow_cache&#039;] != &quot;yes&quot; ) return false;
    
    if( $is_logged ) $end_file = $member_id[&#039;user_group&#039;];
    else $end_file = &quot;0&quot;;
    
    if( ! $cache_id ) {
        $key = $prefix;
    } else {
        $cache_id = md5( $cache_id );
        
        if( $member_prefix ) $key = $prefix . &quot;_&quot; . $cache_id . &quot;_&quot; . $end_file;
        else $key = $prefix . &quot;_&quot; . $cache_id;
    
    }
    

    if ( $mcache ) {

        memcache_set( $mcache, md5( DBNAME . PREFIX . md5(DBUSER) .$key ), $cache_text, MEMCACHE_COMPRESSED, 86400 );

    } else {

        file_put_contents (ENGINE_DIR . &quot;/cache/&quot; . $key . &quot;.tmp&quot;, $cache_text, LOCK_EX);
        
        @chmod( ENGINE_DIR . &quot;/cache/&quot; . $key . &quot;.tmp&quot;, 0666 );
    }
}

function clear_cache($cache_areas = false) {
    global $mcache;

    if ( $mcache ) {

        memcache_flush($mcache);

    }

    if ( $cache_areas ) {
        if(!is_array($cache_areas)) {
            $cache_areas = array($cache_areas);
        }
    }
        
    $fdir = opendir( ENGINE_DIR . &#039;/cache&#039; );
        
    while ( $file = readdir( $fdir ) ) {
        if( $file != &#039;.&#039; and $file != &#039;..&#039; and $file != &#039;.htaccess&#039; and $file != &#039;system&#039; ) {
            
            if( $cache_areas ) {
                
                foreach($cache_areas as $cache_area) if( strpos( $file, $cache_area ) !== false ) @unlink( ENGINE_DIR . &#039;/cache/&#039; . $file );
            
            } else {
                
                @unlink( ENGINE_DIR . &#039;/cache/&#039; . $file );
            
            }
        }
    }

}

function ChangeSkin($dir, $skin) {
    
    $templates_list = array ();
    
    $handle = opendir( $dir );
    
    while ( false !== ($file = readdir( $handle )) ) {
        if( @is_dir( &quot;./templates/$file&quot; ) and ($file != &quot;.&quot; AND $file != &quot;..&quot; AND $file != &quot;smartphone&quot;) ) {
            $templates_list[] = $file;
        }
    }
    
    closedir( $handle );
    sort($templates_list);
    
    $skin_list = &quot;&lt;form method=\&quot;post\&quot; action=\&quot;\&quot;&gt;&lt;select onchange=\&quot;submit()\&quot; name=\&quot;skin_name\&quot;&gt;&quot;;
    
    foreach ( $templates_list as $single_template ) {
        if( $single_template == $skin ) $selected = &quot; selected=\&quot;selected\&quot;&quot;;
        else $selected = &quot;&quot;;
        $skin_list .= &quot;&lt;option value=\&quot;$single_template\&quot;&quot; . $selected . &quot;&gt;$single_template&lt;/option&gt;&quot;;
    }
    
    $skin_list .= &#039;&lt;/select&gt;&lt;input type=&quot;hidden&quot; name=&quot;action_skin_change&quot; value=&quot;yes&quot; /&gt;&lt;/form&gt;&#039;;
    
    return $skin_list;
}

function custom_print( $matches=array() ) {
    global $db, $is_logged, $member_id, $xf_inited, $cat_info, $config, $user_group, $category_id, $_TIME, $lang, $smartphone_detected, $dle_module, $allow_comments_ajax, $PHP_SELF;

    if ( !count($matches) ) return &quot;&quot;;
    $param_str = trim($matches[1]);

    $aviable = array();
    $thisdate = date( &quot;Y-m-d H:i:s&quot;, $_TIME );
    $sql_select = &quot;SELECT p.id, p.autor, p.date, p.short_story, CHAR_LENGTH(p.full_story) as full_story, p.xfields, p.title, p.category, p.alt_name, p.comm_num, p.allow_comm, p.fixed, p.tags, e.news_read, e.allow_rate, e.rating, e.vote_num, e.votes, e.view_edit, e.editdate, e.editor, e.reason FROM &quot; . PREFIX . &quot;_post p LEFT JOIN &quot; . PREFIX . &quot;_post_extras e ON (p.id=e.news_id)&quot;;
    $where = array();
    $allow_cache = $config[&#039;allow_cache&#039;];

    if( preg_match( &quot;#aviable=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $aviable = explode( &#039;|&#039;, $match[1] );
    } else $aviable[] = &quot;global&quot;;

    $do = $dle_module ? $dle_module : &quot;main&quot;;

    if( ! (in_array( $do, $aviable )) and ($aviable[0] != &quot;global&quot;) ) return &quot;&quot;;

    if( preg_match( &quot;#id=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $custom_id = str_replace( &#039;,&#039;, &quot;&#039;,&#039;&quot;, $db-&gt;safesql( trim($match[1]) ) );
        $where[] = &quot;id IN (&#039;&quot; . $custom_id . &quot;&#039;)&quot;;
    }

    $allow_list = explode( &#039;,&#039;, $user_group[$member_id[&#039;user_group&#039;]][&#039;allow_cats&#039;] );
    
    if( $allow_list[0] != &quot;all&quot; AND !$user_group[$member_id[&#039;user_group&#039;]][&#039;allow_short&#039;] ) {

        if( $config[&#039;allow_multi_category&#039;] ) {
                
            $where[] = &quot;category regexp &#039;[[:&lt;:]](&quot; . implode( &#039;|&#039;, $allow_list ) . &quot;)[[:&gt;:]]&#039;&quot;;
            
        } else {
                
            $where[] = &quot;category IN (&#039;&quot; . implode( &quot;&#039;,&#039;&quot;, $allow_list ) . &quot;&#039;)&quot;;
            
        }
    
    }

    if( preg_match( &quot;#category=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {

        $custom_category = $db-&gt;safesql( trim(str_replace( &#039;,&#039;, &#039;|&#039;, $match[1] )) );

        if( $config[&#039;allow_multi_category&#039;] ) {
            
            $where[] = &quot;category regexp &#039;[[:&lt;:]](&quot; . $custom_category . &quot;)[[:&gt;:]]&#039;&quot;;
        
        } else {
            
            $custom_category = str_replace( &quot;|&quot;, &quot;&#039;,&#039;&quot;, $custom_category );
            $where[] = &quot;category IN (&#039;&quot; . $custom_category . &quot;&#039;)&quot;;
        
        }
    }

    if( preg_match( &quot;#days=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $days = intval(trim($match[1]));
        $where[] = &quot;p.date &gt;= &#039;{$thisdate}&#039; - INTERVAL {$days} DAY AND p.date &lt; &#039;{$thisdate}&#039;&quot;;
    } else $days = 0;

    if( preg_match( &quot;#author=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $author = $db-&gt;safesql(trim($match[1]));
        $where[] = &quot;p.autor like &#039;{$author}&#039;&quot;;
    } else $author = &quot;&quot;;

    $where[] = &quot;approve=1&quot;;

    if( $config[&#039;no_date&#039;] AND !$config[&#039;news_future&#039;] AND !$days) $where[] = &quot;date &lt; &#039;&quot; . $thisdate . &quot;&#039;&quot;;

    if( preg_match( &quot;#template=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $custom_template = trim($match[1]);
    } else $custom_template = &quot;shortstory&quot;;

    if( preg_match( &quot;#from=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $custom_from = intval($match[1]);
    } else $custom_from = 0;

    if( preg_match( &quot;#limit=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $custom_limit = intval($match[1]);
    } else $custom_limit = $config[&#039;news_number&#039;];

    if( preg_match( &quot;#cache=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        if( $match[1] == &quot;yes&quot; ) $config[&#039;allow_cache&#039;] = &quot;yes&quot;;
        else $config[&#039;allow_cache&#039;] = false;
    }

    if( preg_match( &quot;#fixed=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        if( $match[1] == &quot;yes&quot; ) $fixed = &quot;fixed DESC, &quot;;
        else $fixed = &quot;&quot;;
    } else $fixed = &quot;&quot;;

    if( $is_logged and ($user_group[$member_id[&#039;user_group&#039;]][&#039;allow_edit&#039;] and ! $user_group[$member_id[&#039;user_group&#039;]][&#039;allow_all_edit&#039;]) ) $config[&#039;allow_cache&#039;] = false;

    if( $cat_info[$custom_category][&#039;news_sort&#039;] != &quot;&quot; ) $news_sort = $cat_info[$custom_category][&#039;news_sort&#039;]; else $news_sort = $config[&#039;news_sort&#039;];
    if( $cat_info[$custom_category][&#039;news_msort&#039;] != &quot;&quot; ) $news_msort = $cat_info[$custom_category][&#039;news_msort&#039;]; else $news_msort = $config[&#039;news_msort&#039;];

    if( preg_match( &quot;#order=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $allowed_sort = array (&#039;date&#039; =&gt; &#039;date&#039;, &#039;rating&#039; =&gt; &#039;rating&#039;, &#039;reads&#039; =&gt; &#039;news_read&#039;, &#039;comments&#039; =&gt; &#039;comm_num&#039;,&#039;title&#039; =&gt; &#039;title&#039;, &#039;rand&#039; =&gt; &#039;RAND()&#039; );

        if ( $allowed_sort[$match[1]] ) $news_sort = $allowed_sort[$match[1]];

        if ($match[1] == &quot;rand&quot; ) { $fixed = &quot;&quot;; $news_msort = &quot;&quot;; } else $news_msort = &quot;DESC&quot;;
        if ($match[1] == &quot;title&quot; ) $news_msort = &quot;ASC&quot;;
    }

    $sql_select .= &quot; WHERE &quot;.implode(&#039; AND &#039;, $where).&quot; ORDER BY &quot; . $fixed . $news_sort . &quot; &quot; . $news_msort . &quot; LIMIT &quot; . $custom_from . &quot;,&quot; . $custom_limit;

    $custom_cache_id = $custom_id.$custom_category.$user_group[$member_id[&#039;user_group&#039;]][&#039;allow_cats&#039;].$custom_from.$custom_limit.$news_sort.$news_msort.$custom_template.$days.$author;

    $content = dle_cache( &quot;news&quot;, $custom_cache_id, true );
    
    if( $content !== false ) {
        $config[&#039;allow_cache&#039;] = $allow_cache;
        return $content;
    } else {

        $tpl = new dle_template();
        $tpl-&gt;dir = TEMPLATE_DIR;                
        
        include (ENGINE_DIR . &#039;/modules/show.custom.php&#039;);
        
        if( $config[&#039;files_allow&#039;] == &quot;yes&quot; ) if( strpos( $tpl-&gt;result[&#039;content&#039;], &quot;[attachment=&quot; ) !== false ) {
            $tpl-&gt;result[&#039;content&#039;] = show_attach( $tpl-&gt;result[&#039;content&#039;], $attachments );
        }
        
        create_cache( &quot;news&quot;, $tpl-&gt;result[&#039;content&#039;], $custom_cache_id, true );
        $config[&#039;allow_cache&#039;] = $allow_cache;
        return $tpl-&gt;result[&#039;content&#039;];
    
    }

}

function check_ip($ips) {
    
    $_IP = $_SERVER[&#039;REMOTE_ADDR&#039;];
    
    $blockip = FALSE;
    
    if( is_array( $ips ) ) {
        foreach ( $ips as $ip_line ) {
            
            $ip_arr = rtrim( $ip_line[&#039;ip&#039;] );
            
            $ip_check_matches = 0;
            $db_ip_split = explode( &quot;.&quot;, $ip_arr );
            $this_ip_split = explode( &quot;.&quot;, $_IP );
            
            for($i_i = 0; $i_i &lt; 4; $i_i ++) {
                if( $this_ip_split[$i_i] == $db_ip_split[$i_i] or $db_ip_split[$i_i] == &#039;*&#039; ) {
                    $ip_check_matches += 1;
                }
            
            }
            
            if( $ip_check_matches == 4 ) {
                $blockip = $ip_line[&#039;ip&#039;];
                break;
            }
        
        }
    }
    
    return $blockip;
}

function check_netz($ip1, $ip2) {
    
    $ip1 = explode( &quot;.&quot;, $ip1 );
    $ip2 = explode( &quot;.&quot;, $ip2 );
    
    if( $ip1[0] != $ip2[0] ) return false;
    if( $ip1[1] != $ip2[1] ) return false;
    
    return true;

}

function show_attach($story, $id, $static = false) {
    global $db, $config, $lang, $user_group, $member_id;

    $find_1 = array();
    $find_2 = array();
    $replace_1 = array();
    $replace_2 = array();
    
    if( $static ) {
        
        if( is_array( $id ) and count( $id ) ) $where = &quot;static_id IN (&quot; . implode( &quot;,&quot;, $id ) . &quot;)&quot;;
        else $where = &quot;static_id = &#039;&quot;.intval($id).&quot;&#039;&quot;;
        
        $db-&gt;query( &quot;SELECT id, name, onserver, dcount FROM &quot; . PREFIX . &quot;_static_files WHERE $where&quot; );
        
        $area = &quot;&amp;amp;area=static&quot;;
    
    } else {
        
        if( is_array( $id ) and count( $id ) ) $where = &quot;news_id IN (&quot; . implode( &quot;,&quot;, $id ) . &quot;)&quot;;
        else $where = &quot;news_id = &#039;&quot;.intval($id).&quot;&#039;&quot;;
        
        $db-&gt;query( &quot;SELECT id, name, onserver, dcount FROM &quot; . PREFIX . &quot;_files WHERE $where&quot; );
        
        $area = &quot;&quot;;
    
    }
    
    while ( $row = $db-&gt;get_row() ) {
        
        $size = formatsize( @filesize( ROOT_DIR . &#039;/uploads/files/&#039; . $row[&#039;onserver&#039;] ) );
        $row[&#039;name&#039;] = explode( &quot;/&quot;, $row[&#039;name&#039;] );
        $row[&#039;name&#039;] = end( $row[&#039;name&#039;] );

        $find_1[] = &#039;[attachment=&#039; . $row[&#039;id&#039;] . &#039;]&#039;;
        $find_2[] = &quot;#\[attachment={$row[&#039;id&#039;]}:(.+?)\]#i&quot;;

        if ( ! $user_group[$member_id[&#039;user_group&#039;]][&#039;allow_files&#039;] ) {

            $replace_1[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;{$lang[&#039;att_denied&#039;]}&lt;/span&gt;&quot;;
            $replace_2[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;{$lang[&#039;att_denied&#039;]}&lt;/span&gt;&quot;;

        } elseif( $config[&#039;files_count&#039;] == &#039;yes&#039; ) {

            $replace_1[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;&lt;a href=\&quot;{$config[&#039;http_home_url&#039;]}engine/download.php?id={$row[&#039;id&#039;]}{$area}\&quot; &gt;{$row[&#039;name&#039;]}&lt;/a&gt; [{$size}] ({$lang[&#039;att_dcount&#039;]} {$row[&#039;dcount&#039;]})&lt;/span&gt;&quot;;
            $replace_2[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;&lt;a href=\&quot;{$config[&#039;http_home_url&#039;]}engine/download.php?id={$row[&#039;id&#039;]}{$area}\&quot; &gt;\\1&lt;/a&gt; [{$size}] ({$lang[&#039;att_dcount&#039;]} {$row[&#039;dcount&#039;]})&lt;/span&gt;&quot;;

        } else {

            $replace_1[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;&lt;a href=\&quot;{$config[&#039;http_home_url&#039;]}engine/download.php?id={$row[&#039;id&#039;]}{$area}\&quot; &gt;{$row[&#039;name&#039;]}&lt;/a&gt; [{$size}]&lt;/span&gt;&quot;;
            $replace_2[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;&lt;a href=\&quot;{$config[&#039;http_home_url&#039;]}engine/download.php?id={$row[&#039;id&#039;]}{$area}\&quot; &gt;\\1&lt;/a&gt; [{$size}]&lt;/span&gt;&quot;;

        }

    }

    $db-&gt;free();

    $story = str_replace ( $find_1, $replace_1, $story );
    $story = preg_replace( $find_2, $replace_2, $story );
    
    return $story;

}

function xfieldsload($profile = false) {
    global $lang;
    
    if( $profile ) $path = ENGINE_DIR . &#039;/data/xprofile.txt&#039;;
    else $path = ENGINE_DIR . &#039;/data/xfields.txt&#039;;
    
    $filecontents = file( $path );
    
    if( ! is_array( $filecontents ) ) msgbox( &quot;System error&quot;, &quot;File &lt;b&gt;{$path}&lt;/b&gt; not found&quot; );
    else {
        foreach ( $filecontents as $name =&gt; $value ) {
            $filecontents[$name] = explode( &quot;|&quot;, trim( $value ) );
            foreach ( $filecontents[$name] as $name2 =&gt; $value2 ) {
                $value2 = str_replace( &quot;&amp;#124;&quot;, &quot;|&quot;, $value2 );
                $value2 = str_replace( &quot;__NEWL__&quot;, &quot;\r\n&quot;, $value2 );
                $filecontents[$name][$name2] = $value2;
            }
        }
    }
    return $filecontents;
}

function xfieldsdataload($id) {
    
    if( $id == &quot;&quot; ) return;
    
    $xfieldsdata = explode( &quot;||&quot;, $id );
    foreach ( $xfieldsdata as $xfielddata ) {
        list ( $xfielddataname, $xfielddatavalue ) = explode( &quot;|&quot;, $xfielddata );
        $xfielddataname = str_replace( &quot;&amp;#124;&quot;, &quot;|&quot;, $xfielddataname );
        $xfielddataname = str_replace( &quot;__NEWL__&quot;, &quot;\r\n&quot;, $xfielddataname );
        $xfielddatavalue = str_replace( &quot;&amp;#124;&quot;, &quot;|&quot;, $xfielddatavalue );
        $xfielddatavalue = str_replace( &quot;__NEWL__&quot;, &quot;\r\n&quot;, $xfielddatavalue );
        $data[$xfielddataname] = $xfielddatavalue;
    }
    return $data;
}

function create_keywords($story) {
    global $metatags, $config;
    
    $keyword_count = 20;
    $newarr = array ();
    
    $quotes = array (&quot;\x22&quot;, &quot;\x60&quot;, &quot;\t&quot;, &quot;\n&quot;, &quot;\r&quot;, &quot;,&quot;, &quot;.&quot;, &quot;/&quot;, &quot;¬&quot;, &quot;#&quot;, &quot;;&quot;, &quot;:&quot;, &quot;@&quot;, &quot;~&quot;, &quot;[&quot;, &quot;]&quot;, &quot;{&quot;, &quot;}&quot;, &quot;=&quot;, &quot;-&quot;, &quot;+&quot;, &quot;)&quot;, &quot;(&quot;, &quot;*&quot;, &quot;^&quot;, &quot;%&quot;, &quot;$&quot;, &quot;&lt;&quot;, &quot;&gt;&quot;, &quot;?&quot;, &quot;!&quot;, &#039;&quot;&#039;);
    $fastquotes = array (&quot;\x22&quot;, &quot;\x60&quot;, &quot;\t&quot;, &quot;\n&quot;, &quot;\r&quot;, &#039;&quot;&#039;, &quot;\\&quot;, &#039;\r&#039;, &#039;\n&#039;, &quot;/&quot;, &quot;{&quot;, &quot;}&quot;, &quot;[&quot;, &quot;]&quot; );
    
    $story = preg_replace( &quot;#\[hide\](.+?)\[/hide\]#is&quot;, &quot;&quot;, $story );
    $story = preg_replace( &quot;&#039;\[attachment=(.*?)\]&#039;si&quot;, &quot;&quot;, $story );
    $story = preg_replace( &quot;&#039;\[page=(.*?)\](.*?)\[/page\]&#039;si&quot;, &quot;&quot;, $story );
    $story = str_replace( &quot;{PAGEBREAK}&quot;, &quot;&quot;, $story );
    $story = str_replace( &quot;&amp;nbsp;&quot;, &quot; &quot;, $story );
    $story = str_replace( &#039;&lt;br /&gt;&#039;, &#039; &#039;, $story );
    $story = strip_tags( $story );
    $story = preg_replace( &quot;#&amp;(.+?);#&quot;, &quot;&quot;, $story );
    $story = trim(str_replace( &quot; ,&quot;, &quot;&quot;, stripslashes( $story )));
    
    $story = str_replace( $fastquotes, &#039;&#039;, $story );
    
    $metatags[&#039;description&#039;] = dle_substr( $story, 0, 190, $config[&#039;charset&#039;] );
    
    $story = str_replace( $quotes, &#039; &#039;, $story );
    
    $arr = explode( &quot; &quot;, $story );
    
    foreach ( $arr as $word ) {
        if( dle_strlen( $word, $config[&#039;charset&#039;] ) &gt; 4 ) $newarr[] = $word;
    }
    
    $arr = array_count_values( $newarr );
    arsort( $arr );
    
    $arr = array_keys( $arr );
    
    $total = count( $arr );
    
    $offset = 0;
    
    $arr = array_slice( $arr, $offset, $keyword_count );
    
    $metatags[&#039;keywords&#039;] = implode( &quot;, &quot;, $arr );
}

function allowed_ip($ip_array) {
    
    $ip_array = trim( $ip_array );
    
    if( $ip_array == &quot;&quot; ) {
        return true;
    }
    
    $ip_array = explode( &quot;|&quot;, $ip_array );
    
    $db_ip_split = explode( &quot;.&quot;, $_SERVER[&#039;REMOTE_ADDR&#039;] );
    
    foreach ( $ip_array as $ip ) {
        
        $ip_check_matches = 0;
        $this_ip_split = explode( &quot;.&quot;, trim( $ip ) );
        
        for($i_i = 0; $i_i &lt; 4; $i_i ++) {
            if( $this_ip_split[$i_i] == $db_ip_split[$i_i] or $this_ip_split[$i_i] == &#039;*&#039; ) {
                $ip_check_matches += 1;
            }
        
        }
        
        if( $ip_check_matches == 4 ) return true;
    
    }
    
    return FALSE;
}

function news_permission($id) {
    
    if( $id == &quot;&quot; ) return;
    
    $data = array ();
    $groups = explode( &quot;||&quot;, $id );
    foreach ( $groups as $group ) {
        list ( $groupid, $groupvalue ) = explode( &quot;:&quot;, $group );
        $data[$groupid] = $groupvalue;
    }
    return $data;
}

function bannermass($fest, $massiv) {
    return $fest . $massiv[@array_rand( $massiv )][&#039;text&#039;];
}

function get_sub_cats($id, $subcategory = &#039;&#039;) {
    
    global $cat_info;
    $subfound = array ();
    
    if( $subcategory == &#039;&#039; ) $subcategory = $id;
    
    foreach ( $cat_info as $cats ) {
        if( $cats[&#039;parentid&#039;] == $id ) {
            $subfound[] = $cats[&#039;id&#039;];
        }
    }
    
    foreach ( $subfound as $parentid ) {
        $subcategory .= &quot;|&quot; . $parentid;
        $subcategory = get_sub_cats( $parentid, $subcategory );
    }
    
    return $subcategory;

}

function check_xss() {

    $url = html_entity_decode( urldecode( $_SERVER[&#039;QUERY_STRING&#039;] ), ENT_QUOTES, &#039;ISO-8859-1&#039; );
    $url = str_replace( &quot;\\&quot;, &quot;/&quot;, $url );

    if ($_GET[&#039;do&#039;] == &quot;xfsearch&quot;) {

        $f = html_entity_decode( urldecode( $_GET[&#039;xf&#039;] ), ENT_QUOTES, &#039;ISO-8859-1&#039; );

        $count1 = substr_count ($f, &quot;&#039;&quot;);
        $count2 = substr_count ($f, &#039;&quot;&#039;);
        $count3 = substr_count ($url, &quot;&#039;&quot;);
        $count4 = substr_count ($url, &#039;&quot;&#039;);

        if ( $count1 == $count3 AND $count2 == $count4 AND (strpos( $url, &#039;&lt;&#039; ) === false) AND (strpos( $url, &#039;&gt;&#039; ) === false) AND (strpos( $url, &#039;./&#039; ) === false) AND (strpos( $url, &#039;../&#039; ) === false) AND (strpos( $url, &#039;.php&#039; ) === false) ) return;

    }

    if ($_GET[&#039;do&#039;] == &quot;tags&quot;) {

        $f = html_entity_decode( urldecode( $_GET[&#039;tag&#039;] ), ENT_QUOTES, &#039;ISO-8859-1&#039; );

        $count1 = substr_count ($f, &quot;&#039;&quot;);
        $count2 = substr_count ($url, &quot;&#039;&quot;);

        if ( $count1 == $count2 AND (strpos( $url, &#039;&lt;&#039; ) === false) AND (strpos( $url, &#039;&gt;&#039; ) === false) AND (strpos( $url, &#039;&quot;&#039; ) === false) AND (strpos( $url, &#039;./&#039; ) === false) AND (strpos( $url, &#039;../&#039; ) === false) AND (strpos( $url, &#039;.php&#039; ) === false) ) return;

    }
    
    if( $url ) {
        
        if( (strpos( $url, &#039;&lt;&#039; ) !== false) || (strpos( $url, &#039;&gt;&#039; ) !== false) || (strpos( $url, &#039;&quot;&#039; ) !== false) || (strpos( $url, &#039;./&#039; ) !== false) || (strpos( $url, &#039;../&#039; ) !== false) || (strpos( $url, &#039;\&#039;&#039; ) !== false) || (strpos( $url, &#039;.php&#039; ) !== false) ) {
            if( $_GET[&#039;do&#039;] != &quot;search&quot; OR $_GET[&#039;subaction&#039;] != &quot;search&quot; ) die( &quot;Hacking attempt!&quot; );
        }
    
    }
    
    $url = html_entity_decode( urldecode( $_SERVER[&#039;REQUEST_URI&#039;] ), ENT_QUOTES, &#039;ISO-8859-1&#039; );
    $url = str_replace( &quot;\\&quot;, &quot;/&quot;, $url );
    
    if( $url ) {
        
        if( (strpos( $url, &#039;&lt;&#039; ) !== false) || (strpos( $url, &#039;&gt;&#039; ) !== false) || (strpos( $url, &#039;&quot;&#039; ) !== false) || (strpos( $url, &#039;\&#039;&#039; ) !== false) ) {
            if( $_GET[&#039;do&#039;] != &quot;search&quot; OR $_GET[&#039;subaction&#039;] != &quot;search&quot; ) die( &quot;Hacking attempt!&quot; );
        
        }
    
    }

}

function check_category($cats, $block, $category, $action = true) {

    $cats = str_replace(&quot; &quot;, &quot;&quot;, $cats );    
    $cats = explode( &#039;,&#039;, $cats );
    $category = explode( &#039;,&#039;, $category );
    $found = false;
    
    foreach ( $category as $element ) {
        
        if( $action ) {
            
            if( in_array( $element, $cats ) ) {
                
                $block = str_replace( &#039;\&quot;&#039;, &#039;&quot;&#039;, $block );
                return $block;
            }
        
        } else {
            
            if( in_array( $element, $cats ) ) {
                $found = true;
            }
        
        }
    
    }

    if ( !$action AND !$found ) {    

        $block = str_replace( &#039;\&quot;&#039;, &#039;&quot;&#039;, $block  );
        return $block;
    }

    return &quot;&quot;;

}

function clean_url($url) {
    
    if( $url == &#039;&#039; ) return;
    
    $url = str_replace( &quot;http://&quot;, &quot;&quot;, strtolower( $url ) );
    $url = str_replace( &quot;https://&quot;, &quot;&quot;, $url );
    if( substr( $url, 0, 4 ) == &#039;www.&#039; ) $url = substr( $url, 4 );
    $url = explode( &#039;/&#039;, $url );
    $url = reset( $url );
    $url = explode( &#039;:&#039;, $url );
    $url = reset( $url );
    
    return $url;
}

function get_url($id) {
    
    global $cat_info;
    
    if( ! $id ) return;
    
    $parent_id = $cat_info[$id][&#039;parentid&#039;];
    
    $url = $cat_info[$id][&#039;alt_name&#039;];
    
    while ( $parent_id ) {
        
        $url = $cat_info[$parent_id][&#039;alt_name&#039;] . &quot;/&quot; . $url;
        
        $parent_id = $cat_info[$parent_id][&#039;parentid&#039;];
        
        if( $cat_info[$parent_id][&#039;parentid&#039;] == $cat_info[$parent_id][&#039;id&#039;] ) break;
    
    }
    
    return $url;
}

function get_categories($id) {
    
    global $cat_info, $config, $PHP_SELF;
    
    if( ! $id ) return;
    
    $parent_id = $cat_info[$id][&#039;parentid&#039;];
    
    if( $config[&#039;allow_alt_url&#039;] == &quot;yes&quot; ) $list = &quot;&lt;a href=\&quot;&quot; . $config[&#039;http_home_url&#039;] . get_url( $id ) . &quot;/\&quot;&gt;{$cat_info[$id][&#039;name&#039;]}&lt;/a&gt;&quot;;
    else $list = &quot;&lt;a href=\&quot;$PHP_SELF?do=cat&amp;amp;category={$cat_info[$id][&#039;alt_name&#039;]}\&quot;&gt;{$cat_info[$id][&#039;name&#039;]}&lt;/a&gt;&quot;;
    
    while ( $parent_id ) {
        
        if( $config[&#039;allow_alt_url&#039;] == &quot;yes&quot; ) $list = &quot;&lt;a href=\&quot;&quot; . $config[&#039;http_home_url&#039;] . get_url( $parent_id ) . &quot;/\&quot;&gt;{$cat_info[$parent_id][&#039;name&#039;]}&lt;/a&gt;&quot; . &quot; &amp;raquo; &quot; . $list;
        else $list = &quot;&lt;a href=\&quot;$PHP_SELF?do=cat&amp;amp;category={$cat_info[$parent_id][&#039;alt_name&#039;]}\&quot;&gt;{$cat_info[$parent_id][&#039;name&#039;]}&lt;/a&gt;&quot; . &quot; &amp;raquo; &quot; . $list;
        
        $parent_id = $cat_info[$parent_id][&#039;parentid&#039;];
        
        if( $cat_info[$parent_id][&#039;parentid&#039;] == $cat_info[$parent_id][&#039;id&#039;] ) break;
    
    }
    
    return $list;
}


function set_cookie($name, $value, $expires) {
    
    if( $expires ) {
        
        $expires = time() + ($expires * 86400);
    
    } else {
        
        $expires = FALSE;
    
    }
    
    if( PHP_VERSION &lt; 5.2 ) {

        if ( DOMAIN ) setcookie( $name, $value, $expires, &quot;/&quot;, &quot;; HttpOnly&quot; );
        else setcookie( $name, $value, $expires, &quot;/&quot;, DOMAIN . &quot;; HttpOnly&quot; );
    
    } else {
        
        setcookie( $name, $value, $expires, &quot;/&quot;, DOMAIN, NULL, TRUE );
    
    }
}

function news_sort($do) {
    
    global $config, $lang;
    
    if( ! $do ) $do = &quot;main&quot;;
    
    $find_sort = &quot;dle_sort_&quot; . $do;
    $direction_sort = &quot;dle_direction_&quot; . $do;
    
    $find_sort = str_replace( &quot;.&quot;, &quot;&quot;, $find_sort );
    $direction_sort = str_replace( &quot;.&quot;, &quot;&quot;, $direction_sort );
    
    $sort = array ();
    $allowed_sort = array (&#039;date&#039;, &#039;rating&#039;, &#039;news_read&#039;, &#039;comm_num&#039;, &#039;title&#039; );
    
    $soft_by_array = array (

    &#039;date&#039; =&gt; array (

    &#039;name&#039; =&gt; $lang[&#039;sort_by_date&#039;], &#039;value&#039; =&gt; &quot;date&quot;, &#039;direction&#039; =&gt; &quot;desc&quot;, &#039;image&#039; =&gt; &quot;&quot; ), 

    &#039;rating&#039; =&gt; array (

    &#039;name&#039; =&gt; $lang[&#039;sort_by_rating&#039;], &#039;value&#039; =&gt; &quot;rating&quot;, &#039;direction&#039; =&gt; &quot;desc&quot;, &#039;image&#039; =&gt; &quot;&quot; ), 

    &#039;news_read&#039; =&gt; array (

    &#039;name&#039; =&gt; $lang[&#039;sort_by_read&#039;], &#039;value&#039; =&gt; &quot;news_read&quot;, &#039;direction&#039; =&gt; &quot;desc&quot;, &#039;image&#039; =&gt; &quot;&quot; ), 

    &#039;comm_num&#039; =&gt; array (

    &#039;name&#039; =&gt; $lang[&#039;sort_by_comm&#039;], &#039;value&#039; =&gt; &quot;comm_num&quot;, &#039;direction&#039; =&gt; &quot;desc&quot;, &#039;image&#039; =&gt; &quot;&quot; ), 

    &#039;title&#039; =&gt; array (

    &#039;name&#039; =&gt; $lang[&#039;sort_by_title&#039;], &#039;value&#039; =&gt; &quot;title&quot;, &#039;direction&#039; =&gt; &quot;desc&quot;, &#039;image&#039; =&gt; &quot;&quot; )

     );
    
    if( isset( $_SESSION[$direction_sort] ) AND ($_SESSION[$direction_sort] == &quot;desc&quot; OR $_SESSION[$direction_sort] == &quot;asc&quot;) ) $direction = $_SESSION[$direction_sort];
    else $direction = $config[&#039;news_msort&#039;];

    if( isset( $_SESSION[$find_sort] ) AND $_SESSION[$find_sort] AND in_array( $_SESSION[$find_sort], $allowed_sort ) ) $soft_by = $_SESSION[$find_sort];
    else $soft_by = $config[&#039;news_sort&#039;];
    
    if( strtolower( $direction ) == &quot;asc&quot; ) {
        
        $soft_by_array[$soft_by][&#039;image&#039;] = &quot;&lt;img src=\&quot;{THEME}/dleimages/asc.gif\&quot; alt=\&quot;\&quot; /&gt;&quot;;
        $soft_by_array[$soft_by][&#039;direction&#039;] = &quot;desc&quot;;
    
    } else {
        
        $soft_by_array[$soft_by][&#039;image&#039;] = &quot;&lt;img src=\&quot;{THEME}/dleimages/desc.gif\&quot; alt=\&quot;\&quot; /&gt;&quot;;
        $soft_by_array[$soft_by][&#039;direction&#039;] = &quot;asc&quot;;
    }
    
    foreach ( $soft_by_array as $value ) {
        
        $sort[] = $value[&#039;image&#039;] . &quot;&lt;a href=\&quot;#\&quot; onclick=\&quot;dle_change_sort(&#039;{$value[&#039;value&#039;]}&#039;,&#039;{$value[&#039;direction&#039;]}&#039;); return false;\&quot;&gt;&quot; . $value[&#039;name&#039;] . &quot;&lt;/a&gt;&quot;;
    }
    
    $sort = &quot;&lt;form name=\&quot;news_set_sort\&quot; id=\&quot;news_set_sort\&quot; method=\&quot;post\&quot; action=\&quot;\&quot; &gt;&quot; . $lang[&#039;sort_main&#039;] . &quot;&amp;nbsp;&quot; . implode( &quot; | &quot;, $sort );
    
    $sort .= &lt;&lt;&lt;HTML
&lt;input type=&quot;hidden&quot; name=&quot;dlenewssortby&quot; id=&quot;dlenewssortby&quot; value=&quot;{$config[&#039;news_sort&#039;]}&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;dledirection&quot; id=&quot;dledirection&quot; value=&quot;{$config[&#039;news_msort&#039;]}&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;set_new_sort&quot; id=&quot;set_new_sort&quot; value=&quot;{$find_sort}&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;set_direction_sort&quot; id=&quot;set_direction_sort&quot; value=&quot;{$direction_sort}&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&gt;
&lt;!-- begin

function dle_change_sort(sort, direction){

  var frm = document.getElementById(&#039;news_set_sort&#039;);

  frm.dlenewssortby.value=sort;
  frm.dledirection.value=direction;

  frm.submit();
  return false;
};

// end --&gt;
&lt;/script&gt;&lt;/form&gt;
HTML;
    
    return $sort;
}

function compare_tags($a, $b) {
    
    if( $a[&#039;tag&#039;] == $b[&#039;tag&#039;] ) return 0;
    
    return strcasecmp( $a[&#039;tag&#039;], $b[&#039;tag&#039;] );

}

function convert_unicode($t, $to = &#039;windows-1251&#039;) {

    $to = strtolower( $to );

    if( $to == &#039;utf-8&#039; ) {
        
        return $t;
    
    } else {

        if( function_exists( &#039;mb_convert_encoding&#039; ) ) {

            $t = mb_convert_encoding( $t, $to, &quot;UTF-8&quot; );

        } elseif( function_exists( &#039;iconv&#039; ) ) {

            $t = iconv( &quot;UTF-8&quot;, $to . &quot;//IGNORE&quot;, $t );

        } else $t = &quot;The library iconv AND mbstring is not supported by your server&quot;;
    
    }

    return $t;
}

function check_smartphone() {

    if ( $_SESSION[&#039;mobile_enable&#039;] ) return true;

    $phone_array = array(&#039;iphone&#039;, &#039;android&#039;, &#039;pocket&#039;, &#039;palm&#039;, &#039;windows ce&#039;, &#039;windowsce&#039;, &#039;mobile windows&#039;, &#039;cellphone&#039;, &#039;opera mobi&#039;, &#039;operamobi&#039;, &#039;ipod&#039;, &#039;small&#039;, &#039;sharp&#039;, &#039;sonyericsson&#039;, &#039;symbian&#039;, &#039;symbos&#039;, &#039;opera mini&#039;, &#039;nokia&#039;, &#039;htc_&#039;, &#039;samsung&#039;, &#039;motorola&#039;, &#039;smartphone&#039;, &#039;blackberry&#039;, &#039;playstation portable&#039;, &#039;tablet browser&#039;, &#039;android&#039;);
    $agent = strtolower( $_SERVER[&#039;HTTP_USER_AGENT&#039;] );

    foreach ($phone_array as $value) {

        if ( strpos($agent, $value) !== false ) return true;

    }

    return false;

}

function build_js($js, $config) {

    $js_array = array();

    if ($config[&#039;js_min&#039;] AND version_compare(PHP_VERSION, &#039;5.1.0&#039;, &#039;&gt;&#039;) ) {

        $js_array[] = &quot;&lt;script type=\&quot;text/javascript\&quot; src=\&quot;{$config[&#039;http_home_url&#039;]}engine/classes/min/index.php?charset={$config[&#039;charset&#039;]}&amp;amp;g=general&amp;amp;9\&quot;&gt;&lt;/script&gt;&quot;;

        if ( count($js) ) $js_array[] = &quot;&lt;script type=\&quot;text/javascript\&quot; src=\&quot;{$config[&#039;http_home_url&#039;]}engine/classes/min/index.php?charset={$config[&#039;charset&#039;]}&amp;amp;f=&quot;.implode(&quot;,&quot;, $js).&quot;&amp;amp;9\&quot;&gt;&lt;/script&gt;&quot;;

        return implode(&quot;\n&quot;, $js_array);

    } else {

        $default_array = array (
            &#039;engine/classes/js/jquery.js&#039;,
            &#039;engine/classes/js/jqueryui.js&#039;,
            &#039;engine/classes/js/dle_js.js&#039;,
        );

        $js = array_merge($default_array, $js);

        foreach ($js as $value) {
        
            $js_array[] = &quot;&lt;script type=\&quot;text/javascript\&quot; src=\&quot;{$config[&#039;http_home_url&#039;]}{$value}\&quot;&gt;&lt;/script&gt;&quot;;
        
        }

        return implode(&quot;\n&quot;, $js_array);
    }
}

function check_static($names, $block, $action = true) {
    global $dle_module;

    $names = str_replace(&quot; &quot;, &quot;&quot;, $names );
    $names = explode( &#039;,&#039;, $names );

    if ( isset($_GET[&#039;page&#039;]) ) $page = trim($_GET[&#039;page&#039;]); else $page = &quot;&quot;;
    
    if( $action ) {
            
        if( in_array( $page, $names ) AND $dle_module == &quot;static&quot; ) {
                
            $block = str_replace( &#039;\&quot;&#039;, &#039;&quot;&#039;, $block );
            return $block;
        }
        
    } else {
            
        if( !in_array( $page, $names ) OR $dle_module != &quot;static&quot;) {
                
            $block = str_replace( &#039;\&quot;&#039;, &#039;&quot;&#039;, $block  );
            return $block;
        }
        
    }
    
    return &quot;&quot;;
}


function dle_strlen($value, $charset ) {

    if ( strtolower($charset) == &quot;utf-8&quot;) return iconv_strlen($value, &quot;utf-8&quot;);
    else return strlen($value);

}

function dle_substr($str, $start, $length, $charset ) {

    if ( strtolower($charset) == &quot;utf-8&quot;) return iconv_substr($str, $start, $length, &quot;utf-8&quot;);
    else return substr($str, $start, $length);

}

function dle_strrpos($str, $needle, $charset ) {

    if ( strtolower($charset) == &quot;utf-8&quot;) return iconv_strrpos($str, $needle, &quot;utf-8&quot;);
    else return strrpos($str, $needle);

}

function check_allow_login($ip, $max ) {
    global $db;

    $block_date = time()-1200;

    $row = $db-&gt;super_query( &quot;SELECT * FROM &quot; . PREFIX . &quot;_login_log WHERE ip=&#039;{$ip}&#039;&quot; );

    if ( $row[&#039;count&#039;] AND $row[&#039;date&#039;] &lt; $block_date ) $db-&gt;query( &quot;DELETE FROM &quot; . PREFIX . &quot;_login_log WHERE ip = &#039;{$ip}&#039;&quot; );

    if ($row[&#039;count&#039;] &gt; $max AND $row[&#039;date&#039;] &gt; $block_date ) return false;
    else return true;

} 

function detect_encoding($string) {  
  static $list = array(&#039;utf-8&#039;, &#039;windows-1251&#039;);
   
  foreach ($list as $item) {
     $sample = iconv($item, $item, $string);
     if (md5($sample) == md5($string))
       return $item;
   }
   return null;
}
 
function get_ip() {

    $ip_split = explode( &quot;.&quot;, $_SERVER[&#039;REMOTE_ADDR&#039;] );
    $_IP = array();
    
    for($i = 0; $i &lt; 4; $i++) {
        $_IP[] = intval($ip_split[$i]);
    }
    
    return implode(&quot;.&quot;, $_IP);
}
?&gt;</code></pre></div></div></div><p>и скорее всего будет вам счастье <img src="https://talk.alaev.info/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (svetlana)]]></author>
			<pubDate>Sat, 06 Jun 2015 10:03:20 +0000</pubDate>
			<guid>https://talk.alaev.info/post/9621/#p9621</guid>
		</item>
		<item>
			<title><![CDATA[Re: проблема с куки]]></title>
			<link>https://talk.alaev.info/post/9620/#p9620</link>
			<description><![CDATA[<p>Стояло нет - я поставил да.<br />Выдает: dim-kino.com&nbsp; (мой домен)<br />Мой functions.php приложил в файле и тут в коде...<br />Надеюсь только на Вашу помощь, так как уже пол года никто не может мне помочь...<br /></p><div class="codebox"><pre><code>&lt;?PHP
/*
=====================================================
 DataLife Engine - by SoftNews Media Group 
-----------------------------------------------------
 http://dle-news.ru/
-----------------------------------------------------
 Copyright (c) 2004,2013 SoftNews Media Group
=====================================================
 Данный код защищен авторскими правами
=====================================================
 Файл: functions.php
-----------------------------------------------------
 Назначение: Основные функции
=====================================================
*/
if( ! defined( &#039;DATALIFEENGINE&#039; ) ) {
    die( &quot;Hacking attempt!&quot; );
}

if ( $config[&#039;auth_domain&#039;] ) {

    $domain_cookie = explode (&quot;.&quot;, clean_url( $_SERVER[&#039;HTTP_HOST&#039;] ));
    $domain_cookie_count = count($domain_cookie);
    $domain_allow_count = -2;
    
    if ( $domain_cookie_count &gt; 2 ) {
    
        if ( in_array($domain_cookie[$domain_cookie_count-2], array(&#039;com&#039;, &#039;net&#039;, &#039;org&#039;) )) $domain_allow_count = -3;
        if ( $domain_cookie[$domain_cookie_count-1] == &#039;ua&#039; ) $domain_allow_count = -3;
        $domain_cookie = array_slice($domain_cookie, $domain_allow_count);
    }
    
    $domain_cookie = &quot;.&quot; . implode (&quot;.&quot;, $domain_cookie);
    
    if( (ip2long($_SERVER[&#039;HTTP_HOST&#039;]) == -1 OR ip2long($_SERVER[&#039;HTTP_HOST&#039;]) === FALSE) AND strtoupper(substr(PHP_OS, 0, 3)) !== &#039;WIN&#039; ) define( &#039;DOMAIN&#039;, $domain_cookie );
    else define( &#039;DOMAIN&#039;, null );

} else define( &#039;DOMAIN&#039;, null );

$mcache = false;

if ( $config[&#039;cache_type&#039;] ) {

    if ( function_exists(&#039;memcache_connect&#039;) ) {

        $memcache_server = explode(&quot;:&quot;, $config[&#039;memcache_server&#039;]);

        $mcache = @memcache_connect( $memcache_server[0], $memcache_server[1] );

        if( $mcache AND function_exists(&#039;memcache_set_compress_threshold&#039;) )
        {
            memcache_set_compress_threshold( $mcache, 20000, 0.2 );
        }

    }

}

function dle_session( $sid = false ) {

    $params = session_get_cookie_params();

    if ( DOMAIN ) $params[&#039;domain&#039;] = DOMAIN;

    if( version_compare(PHP_VERSION, &#039;5.2&#039;, &#039;&lt;&#039;) ) {
        
        session_set_cookie_params($params[&#039;lifetime&#039;], &quot;/&quot;, $params[&#039;domain&#039;].&quot;; HttpOnly&quot;, $params[&#039;secure&#039;]);
    
    } else {
        
        session_set_cookie_params($params[&#039;lifetime&#039;], &quot;/&quot;, $params[&#039;domain&#039;], $params[&#039;secure&#039;], true);
    
    }

    if ( $sid ) @session_id( $sid );

    @session_start();

}

function formatsize($file_size) {
    if( $file_size &gt;= 1073741824 ) {
        $file_size = round( $file_size / 1073741824 * 100 ) / 100 . &quot; Gb&quot;;
    } elseif( $file_size &gt;= 1048576 ) {
        $file_size = round( $file_size / 1048576 * 100 ) / 100 . &quot; Mb&quot;;
    } elseif( $file_size &gt;= 1024 ) {
        $file_size = round( $file_size / 1024 * 100 ) / 100 . &quot; Kb&quot;;
    } else {
        $file_size = $file_size . &quot; b&quot;;
    }
    return $file_size;
}

class microTimer {
    function start() {
        global $starttime;
        $mtime = microtime();
        $mtime = explode( &#039; &#039;, $mtime );
        $mtime = $mtime[1] + $mtime[0];
        $starttime = $mtime;
    }
    function stop() {
        global $starttime;
        $mtime = microtime();
        $mtime = explode( &#039; &#039;, $mtime );
        $mtime = $mtime[1] + $mtime[0];
        $endtime = $mtime;
        $totaltime = round( ($endtime - $starttime), 5 );
        return $totaltime;
    }
}

function flooder($ip, $news_time = false) {
    global $config, $db;
    
    if ( $news_time ) {

        $this_time = time() + ($config[&#039;date_adjust&#039;] * 60) - $news_time;
        $db-&gt;query( &quot;DELETE FROM &quot; . PREFIX . &quot;_flood where id &lt; &#039;$this_time&#039; AND flag=&#039;1&#039; &quot; );
        
        $row = $db-&gt;super_query(&quot;SELECT COUNT(*) as count FROM &quot; . PREFIX . &quot;_flood WHERE ip = &#039;$ip&#039; AND flag=&#039;1&#039;&quot;);
        
        if( $row[&#039;count&#039;] ) return TRUE;
        else return FALSE;

    } else {

        $this_time = time() + ($config[&#039;date_adjust&#039;] * 60) - $config[&#039;flood_time&#039;];
        $db-&gt;query( &quot;DELETE FROM &quot; . PREFIX . &quot;_flood where id &lt; &#039;$this_time&#039; AND flag=&#039;0&#039; &quot; );
        
        $row = $db-&gt;super_query(&quot;SELECT COUNT(*) as count FROM &quot; . PREFIX . &quot;_flood WHERE ip = &#039;$ip&#039; AND flag=&#039;0&#039;&quot;);
        
        if( $row[&#039;count&#039;] ) return TRUE;
        else return FALSE;

    }

}

function totranslit($var, $lower = true, $punkt = true) {
    global $langtranslit;
    
    if ( is_array($var) ) return &quot;&quot;;

    if (!is_array ( $langtranslit ) OR !count( $langtranslit ) ) {
        $var = trim( strip_tags( $var ) );

        if ( $punkt ) $var = preg_replace( &quot;/[^a-z0-9\_\-.]+/mi&quot;, &quot;&quot;, $var );
        else $var = preg_replace( &quot;/[^a-z0-9\_\-]+/mi&quot;, &quot;&quot;, $var );

        $var = preg_replace( &#039;#[.]+#i&#039;, &#039;.&#039;, $var );
        $var = str_ireplace( &quot;.php&quot;, &quot;.ppp&quot;, $var );

        if ( $lower ) $var = strtolower( $var );

        return $var;
    }
    
    $var = trim( strip_tags( $var ) );
    $var = preg_replace( &quot;/\s+/ms&quot;, &quot;-&quot;, $var );
    $var = str_replace( &quot;/&quot;, &quot;-&quot;, $var );

    $var = strtr($var, $langtranslit);
    
    if ( $punkt ) $var = preg_replace( &quot;/[^a-z0-9\_\-.]+/mi&quot;, &quot;&quot;, $var );
    else $var = preg_replace( &quot;/[^a-z0-9\_\-]+/mi&quot;, &quot;&quot;, $var );

    $var = preg_replace( &#039;#[\-]+#i&#039;, &#039;-&#039;, $var );
    $var = preg_replace( &#039;#[.]+#i&#039;, &#039;.&#039;, $var );

    if ( $lower ) $var = strtolower( $var );

    $var = str_ireplace( &quot;.php&quot;, &quot;&quot;, $var );
    $var = str_ireplace( &quot;.php&quot;, &quot;.ppp&quot;, $var );

    if( strlen( $var ) &gt; 200 ) {
        
        $var = substr( $var, 0, 200 );
        
        if( ($temp_max = strrpos( $var, &#039;-&#039; )) ) $var = substr( $var, 0, $temp_max );
    
    }
    
    return $var;
}

function langdate($format, $stamp) {
    global $langdate;
    
    return strtr( @date( $format, $stamp ), $langdate );

}

function msgbox($title, $text) {
    global $tpl;

    if (!class_exists(&#039;dle_template&#039;)) {
        return;
    }
    
    $tpl_2 = new dle_template( );
    $tpl_2-&gt;dir = TEMPLATE_DIR;
    
    $tpl_2-&gt;load_template( &#039;info.tpl&#039; );
    
    $tpl_2-&gt;set( &#039;{error}&#039;, $text );
    $tpl_2-&gt;set( &#039;{title}&#039;, $title );
    
    $tpl_2-&gt;compile( &#039;info&#039; );
    $tpl_2-&gt;clear();
    
    $tpl-&gt;result[&#039;info&#039;] .= $tpl_2-&gt;result[&#039;info&#039;];
}

function ShowRating($id, $rating, $vote_num, $allow = true) {
    global $lang;
    
    if( $rating AND $vote_num ) $rating = round( ($rating / $vote_num), 0 );
    else $rating = 0;
    $rating = $rating * 17;
    
    if( !$allow ) {
        
        $rated = &lt;&lt;&lt;HTML
&lt;div class=&quot;rating&quot;&gt;
        &lt;ul class=&quot;unit-rating&quot;&gt;
        &lt;li class=&quot;current-rating&quot; style=&quot;width:{$rating}px;&quot;&gt;{$rating}&lt;/li&gt;
        &lt;/ul&gt;
&lt;/div&gt;
HTML;
        
        return $rated;
    }
    
    $rated = &lt;&lt;&lt;HTML
&lt;div id=&#039;ratig-layer-{$id}&#039;&gt;&lt;div class=&quot;rating&quot;&gt;
        &lt;ul class=&quot;unit-rating&quot;&gt;
        &lt;li class=&quot;current-rating&quot; style=&quot;width:{$rating}px;&quot;&gt;{$rating}&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;{$lang[&#039;useless&#039;]}&quot; class=&quot;r1-unit&quot; onclick=&quot;doRate(&#039;1&#039;, &#039;{$id}&#039;); return false;&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;{$lang[&#039;poor&#039;]}&quot; class=&quot;r2-unit&quot; onclick=&quot;doRate(&#039;2&#039;, &#039;{$id}&#039;); return false;&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;{$lang[&#039;fair&#039;]}&quot; class=&quot;r3-unit&quot; onclick=&quot;doRate(&#039;3&#039;, &#039;{$id}&#039;); return false;&quot;&gt;3&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;{$lang[&#039;good&#039;]}&quot; class=&quot;r4-unit&quot; onclick=&quot;doRate(&#039;4&#039;, &#039;{$id}&#039;); return false;&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;{$lang[&#039;excellent&#039;]}&quot; class=&quot;r5-unit&quot; onclick=&quot;doRate(&#039;5&#039;, &#039;{$id}&#039;); return false;&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
HTML;
    
    return $rated;
}

function userrating($id) {
    global $db;
    
    $row = $db-&gt;super_query( &quot;SELECT SUM(rating) as rating, SUM(vote_num) as num FROM &quot; . PREFIX . &quot;_post_extras WHERE user_id =&#039;{$id}&#039;&quot; );
    
    if( $row[&#039;num&#039;] ) $rating = round( ($row[&#039;rating&#039;] / $row[&#039;num&#039;]), 0 );
    else $rating = 0;

    $rating = $rating * 17;
    
    $rated = &lt;&lt;&lt;HTML
&lt;div class=&quot;rating&quot; style=&quot;display:inline;&quot;&gt;
        &lt;ul class=&quot;unit-rating&quot;&gt;
        &lt;li class=&quot;current-rating&quot; style=&quot;width:{$rating}px;&quot;&gt;{$rating}&lt;/li&gt;
        &lt;/ul&gt;
        &lt;/div&gt;
HTML;
    
    return $rated;
}

function CategoryNewsSelection($categoryid = 0, $parentid = 0, $nocat = TRUE, $sublevelmarker = &#039;&#039;, $returnstring = &#039;&#039;) {
    global $cat_info, $user_group, $member_id, $dle_module;

    if ($dle_module == &#039;addnews&#039;) $allow_list = explode( &#039;,&#039;, $user_group[$member_id[&#039;user_group&#039;]][&#039;cat_allow_addnews&#039;] );
    else $allow_list = explode( &#039;,&#039;, $user_group[$member_id[&#039;user_group&#039;]][&#039;allow_cats&#039;] );

    $spec_list = explode( &#039;,&#039;, $user_group[$member_id[&#039;user_group&#039;]][&#039;cat_add&#039;] );

    $root_category = array ();
    
    if( $parentid == 0 ) {
        if( $nocat ) $returnstring .= &#039;&lt;option value=&quot;0&quot;&gt;&lt;/option&gt;&#039;;
    } else {
        $sublevelmarker .= &#039;&amp;nbsp;&amp;nbsp;&amp;nbsp;&#039;;
    }
    
    if( count( $cat_info ) ) {
        
        foreach ( $cat_info as $cats ) {
            if( $cats[&#039;parentid&#039;] == $parentid ) $root_category[] = $cats[&#039;id&#039;];
        }
        
        if( count( $root_category ) ) {
            foreach ( $root_category as $id ) {
                
                if( $allow_list[0] == &quot;all&quot; OR in_array( $id, $allow_list ) ) {
                    
                    if( $spec_list[0] == &quot;all&quot; or in_array( $id, $spec_list ) ) $color = &quot;black&quot;;
                    else $color = &quot;red&quot;;
                    
                    $returnstring .= &quot;&lt;option style=\&quot;color: {$color}\&quot; value=\&quot;&quot; . $id . &#039;&quot; &#039;;
                    
                    if( is_array( $categoryid ) ) {
                        foreach ( $categoryid as $element ) {
                            if( $element == $id ) $returnstring .= &#039;SELECTED&#039;;
                        }
                    } elseif( $categoryid == $id ) $returnstring .= &#039;SELECTED&#039;;
                    
                    $returnstring .= &#039;&gt;&#039; . $sublevelmarker . $cat_info[$id][&#039;name&#039;] . &#039;&lt;/option&gt;&#039;;
                }
                $returnstring = CategoryNewsSelection( $categoryid, $id, $nocat, $sublevelmarker, $returnstring );
            }
        }
    }
    return $returnstring;
}

function get_ID($cat_info, $category) {
    foreach ( $cat_info as $cats ) {
        if( $cats[&#039;alt_name&#039;] == $category ) return $cats[&#039;id&#039;];
    }
    return false;
}

function set_vars($file, $data) {
    
    $fp = fopen( ENGINE_DIR . &#039;/cache/system/&#039; . $file . &#039;.php&#039;, &#039;wb+&#039; );
    fwrite( $fp, serialize( $data ) );
    fclose( $fp );
    
    @chmod( ENGINE_DIR . &#039;/cache/system/&#039; . $file . &#039;.php&#039;, 0666 );
}

function get_vars($file) {
    
    return unserialize( @file_get_contents( ENGINE_DIR . &#039;/cache/system/&#039; . $file . &#039;.php&#039; ) );
}

function filesize_url($url) {
    return ($data = @file_get_contents( $url )) ? strlen( $data ) : false;
}

function dle_cache($prefix, $cache_id = false, $member_prefix = false) {
    global $config, $is_logged, $member_id, $mcache;
    
    if( $config[&#039;allow_cache&#039;] != &quot;yes&quot; ) return false;
    
    if( $is_logged ) $end_file = $member_id[&#039;user_group&#039;];
    else $end_file = &quot;0&quot;;
    
    if( ! $cache_id ) {
        
        $key = $prefix;
    
    } else {
        
        $cache_id = md5( $cache_id );
        
        if( $member_prefix ) $key = $prefix . &quot;_&quot; . $cache_id . &quot;_&quot; . $end_file;
        else $key = $prefix . &quot;_&quot; . $cache_id;
    
    }

    if ( $mcache ) {

        return memcache_get( $mcache, md5( DBNAME . PREFIX . md5(DBUSER) .$key ) );

    } else {

        return @file_get_contents( ENGINE_DIR . &quot;/cache/&quot; . $key . &quot;.tmp&quot; );

    }
}

function create_cache($prefix, $cache_text, $cache_id = false, $member_prefix = false) {
    global $config, $is_logged, $member_id, $mcache;
    
    if( $config[&#039;allow_cache&#039;] != &quot;yes&quot; ) return false;
    
    if( $is_logged ) $end_file = $member_id[&#039;user_group&#039;];
    else $end_file = &quot;0&quot;;
    
    if( ! $cache_id ) {
        $key = $prefix;
    } else {
        $cache_id = md5( $cache_id );
        
        if( $member_prefix ) $key = $prefix . &quot;_&quot; . $cache_id . &quot;_&quot; . $end_file;
        else $key = $prefix . &quot;_&quot; . $cache_id;
    
    }
    

    if ( $mcache ) {

        memcache_set( $mcache, md5( DBNAME . PREFIX . md5(DBUSER) .$key ), $cache_text, MEMCACHE_COMPRESSED, 86400 );

    } else {

        file_put_contents (ENGINE_DIR . &quot;/cache/&quot; . $key . &quot;.tmp&quot;, $cache_text, LOCK_EX);
        
        @chmod( ENGINE_DIR . &quot;/cache/&quot; . $key . &quot;.tmp&quot;, 0666 );
    }
}

function clear_cache($cache_areas = false) {
    global $mcache;

    if ( $mcache ) {

        memcache_flush($mcache);

    }

    if ( $cache_areas ) {
        if(!is_array($cache_areas)) {
            $cache_areas = array($cache_areas);
        }
    }
        
    $fdir = opendir( ENGINE_DIR . &#039;/cache&#039; );
        
    while ( $file = readdir( $fdir ) ) {
        if( $file != &#039;.&#039; and $file != &#039;..&#039; and $file != &#039;.htaccess&#039; and $file != &#039;system&#039; ) {
            
            if( $cache_areas ) {
                
                foreach($cache_areas as $cache_area) if( strpos( $file, $cache_area ) !== false ) @unlink( ENGINE_DIR . &#039;/cache/&#039; . $file );
            
            } else {
                
                @unlink( ENGINE_DIR . &#039;/cache/&#039; . $file );
            
            }
        }
    }

}

function ChangeSkin($dir, $skin) {
    
    $templates_list = array ();
    
    $handle = opendir( $dir );
    
    while ( false !== ($file = readdir( $handle )) ) {
        if( @is_dir( &quot;./templates/$file&quot; ) and ($file != &quot;.&quot; AND $file != &quot;..&quot; AND $file != &quot;smartphone&quot;) ) {
            $templates_list[] = $file;
        }
    }
    
    closedir( $handle );
    sort($templates_list);
    
    $skin_list = &quot;&lt;form method=\&quot;post\&quot; action=\&quot;\&quot;&gt;&lt;select onchange=\&quot;submit()\&quot; name=\&quot;skin_name\&quot;&gt;&quot;;
    
    foreach ( $templates_list as $single_template ) {
        if( $single_template == $skin ) $selected = &quot; selected=\&quot;selected\&quot;&quot;;
        else $selected = &quot;&quot;;
        $skin_list .= &quot;&lt;option value=\&quot;$single_template\&quot;&quot; . $selected . &quot;&gt;$single_template&lt;/option&gt;&quot;;
    }
    
    $skin_list .= &#039;&lt;/select&gt;&lt;input type=&quot;hidden&quot; name=&quot;action_skin_change&quot; value=&quot;yes&quot; /&gt;&lt;/form&gt;&#039;;
    
    return $skin_list;
}

function custom_print( $matches=array() ) {
    global $db, $is_logged, $member_id, $xf_inited, $cat_info, $config, $user_group, $category_id, $_TIME, $lang, $smartphone_detected, $dle_module, $allow_comments_ajax, $PHP_SELF;

    if ( !count($matches) ) return &quot;&quot;;
    $param_str = trim($matches[1]);

    $aviable = array();
    $thisdate = date( &quot;Y-m-d H:i:s&quot;, $_TIME );
    $sql_select = &quot;SELECT p.id, p.autor, p.date, p.short_story, CHAR_LENGTH(p.full_story) as full_story, p.xfields, p.title, p.category, p.alt_name, p.comm_num, p.allow_comm, p.fixed, p.tags, e.news_read, e.allow_rate, e.rating, e.vote_num, e.votes, e.view_edit, e.editdate, e.editor, e.reason FROM &quot; . PREFIX . &quot;_post p LEFT JOIN &quot; . PREFIX . &quot;_post_extras e ON (p.id=e.news_id)&quot;;
    $where = array();
    $allow_cache = $config[&#039;allow_cache&#039;];

    if( preg_match( &quot;#aviable=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $aviable = explode( &#039;|&#039;, $match[1] );
    } else $aviable[] = &quot;global&quot;;

    $do = $dle_module ? $dle_module : &quot;main&quot;;

    if( ! (in_array( $do, $aviable )) and ($aviable[0] != &quot;global&quot;) ) return &quot;&quot;;

    if( preg_match( &quot;#id=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $custom_id = str_replace( &#039;,&#039;, &quot;&#039;,&#039;&quot;, $db-&gt;safesql( trim($match[1]) ) );
        $where[] = &quot;id IN (&#039;&quot; . $custom_id . &quot;&#039;)&quot;;
    }

    $allow_list = explode( &#039;,&#039;, $user_group[$member_id[&#039;user_group&#039;]][&#039;allow_cats&#039;] );
    
    if( $allow_list[0] != &quot;all&quot; AND !$user_group[$member_id[&#039;user_group&#039;]][&#039;allow_short&#039;] ) {

        if( $config[&#039;allow_multi_category&#039;] ) {
                
            $where[] = &quot;category regexp &#039;[[:&lt;:]](&quot; . implode( &#039;|&#039;, $allow_list ) . &quot;)[[:&gt;:]]&#039;&quot;;
            
        } else {
                
            $where[] = &quot;category IN (&#039;&quot; . implode( &quot;&#039;,&#039;&quot;, $allow_list ) . &quot;&#039;)&quot;;
            
        }
    
    }

    if( preg_match( &quot;#category=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {

        $custom_category = $db-&gt;safesql( trim(str_replace( &#039;,&#039;, &#039;|&#039;, $match[1] )) );

        if( $config[&#039;allow_multi_category&#039;] ) {
            
            $where[] = &quot;category regexp &#039;[[:&lt;:]](&quot; . $custom_category . &quot;)[[:&gt;:]]&#039;&quot;;
        
        } else {
            
            $custom_category = str_replace( &quot;|&quot;, &quot;&#039;,&#039;&quot;, $custom_category );
            $where[] = &quot;category IN (&#039;&quot; . $custom_category . &quot;&#039;)&quot;;
        
        }
    }

    if( preg_match( &quot;#days=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $days = intval(trim($match[1]));
        $where[] = &quot;p.date &gt;= &#039;{$thisdate}&#039; - INTERVAL {$days} DAY AND p.date &lt; &#039;{$thisdate}&#039;&quot;;
    } else $days = 0;

    if( preg_match( &quot;#author=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $author = $db-&gt;safesql(trim($match[1]));
        $where[] = &quot;p.autor like &#039;{$author}&#039;&quot;;
    } else $author = &quot;&quot;;

    $where[] = &quot;approve=1&quot;;

    if( $config[&#039;no_date&#039;] AND !$config[&#039;news_future&#039;] AND !$days) $where[] = &quot;date &lt; &#039;&quot; . $thisdate . &quot;&#039;&quot;;

    if( preg_match( &quot;#template=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $custom_template = trim($match[1]);
    } else $custom_template = &quot;shortstory&quot;;

    if( preg_match( &quot;#from=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $custom_from = intval($match[1]);
    } else $custom_from = 0;

    if( preg_match( &quot;#limit=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $custom_limit = intval($match[1]);
    } else $custom_limit = $config[&#039;news_number&#039;];

    if( preg_match( &quot;#cache=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        if( $match[1] == &quot;yes&quot; ) $config[&#039;allow_cache&#039;] = &quot;yes&quot;;
        else $config[&#039;allow_cache&#039;] = false;
    }

    if( preg_match( &quot;#fixed=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        if( $match[1] == &quot;yes&quot; ) $fixed = &quot;fixed DESC, &quot;;
        else $fixed = &quot;&quot;;
    } else $fixed = &quot;&quot;;

    if( $is_logged and ($user_group[$member_id[&#039;user_group&#039;]][&#039;allow_edit&#039;] and ! $user_group[$member_id[&#039;user_group&#039;]][&#039;allow_all_edit&#039;]) ) $config[&#039;allow_cache&#039;] = false;

    if( $cat_info[$custom_category][&#039;news_sort&#039;] != &quot;&quot; ) $news_sort = $cat_info[$custom_category][&#039;news_sort&#039;]; else $news_sort = $config[&#039;news_sort&#039;];
    if( $cat_info[$custom_category][&#039;news_msort&#039;] != &quot;&quot; ) $news_msort = $cat_info[$custom_category][&#039;news_msort&#039;]; else $news_msort = $config[&#039;news_msort&#039;];

    if( preg_match( &quot;#order=[&#039;\&quot;](.+?)[&#039;\&quot;]#i&quot;, $param_str, $match ) ) {
        $allowed_sort = array (&#039;date&#039; =&gt; &#039;date&#039;, &#039;rating&#039; =&gt; &#039;rating&#039;, &#039;reads&#039; =&gt; &#039;news_read&#039;, &#039;comments&#039; =&gt; &#039;comm_num&#039;,&#039;title&#039; =&gt; &#039;title&#039;, &#039;rand&#039; =&gt; &#039;RAND()&#039; );

        if ( $allowed_sort[$match[1]] ) $news_sort = $allowed_sort[$match[1]];

        if ($match[1] == &quot;rand&quot; ) { $fixed = &quot;&quot;; $news_msort = &quot;&quot;; } else $news_msort = &quot;DESC&quot;;
        if ($match[1] == &quot;title&quot; ) $news_msort = &quot;ASC&quot;;
    }

    $sql_select .= &quot; WHERE &quot;.implode(&#039; AND &#039;, $where).&quot; ORDER BY &quot; . $fixed . $news_sort . &quot; &quot; . $news_msort . &quot; LIMIT &quot; . $custom_from . &quot;,&quot; . $custom_limit;

    $custom_cache_id = $custom_id.$custom_category.$user_group[$member_id[&#039;user_group&#039;]][&#039;allow_cats&#039;].$custom_from.$custom_limit.$news_sort.$news_msort.$custom_template.$days.$author;

    $content = dle_cache( &quot;news&quot;, $custom_cache_id, true );
    
    if( $content !== false ) {
        $config[&#039;allow_cache&#039;] = $allow_cache;
        return $content;
    } else {

        $tpl = new dle_template();
        $tpl-&gt;dir = TEMPLATE_DIR;                
        
        include (ENGINE_DIR . &#039;/modules/show.custom.php&#039;);
        
        if( $config[&#039;files_allow&#039;] == &quot;yes&quot; ) if( strpos( $tpl-&gt;result[&#039;content&#039;], &quot;[attachment=&quot; ) !== false ) {
            $tpl-&gt;result[&#039;content&#039;] = show_attach( $tpl-&gt;result[&#039;content&#039;], $attachments );
        }
        
        create_cache( &quot;news&quot;, $tpl-&gt;result[&#039;content&#039;], $custom_cache_id, true );
        $config[&#039;allow_cache&#039;] = $allow_cache;
        return $tpl-&gt;result[&#039;content&#039;];
    
    }

}

function check_ip($ips) {
    
    $_IP = $_SERVER[&#039;REMOTE_ADDR&#039;];
    
    $blockip = FALSE;
    
    if( is_array( $ips ) ) {
        foreach ( $ips as $ip_line ) {
            
            $ip_arr = rtrim( $ip_line[&#039;ip&#039;] );
            
            $ip_check_matches = 0;
            $db_ip_split = explode( &quot;.&quot;, $ip_arr );
            $this_ip_split = explode( &quot;.&quot;, $_IP );
            
            for($i_i = 0; $i_i &lt; 4; $i_i ++) {
                if( $this_ip_split[$i_i] == $db_ip_split[$i_i] or $db_ip_split[$i_i] == &#039;*&#039; ) {
                    $ip_check_matches += 1;
                }
            
            }
            
            if( $ip_check_matches == 4 ) {
                $blockip = $ip_line[&#039;ip&#039;];
                break;
            }
        
        }
    }
    
    return $blockip;
}

function check_netz($ip1, $ip2) {
    
    $ip1 = explode( &quot;.&quot;, $ip1 );
    $ip2 = explode( &quot;.&quot;, $ip2 );
    
    if( $ip1[0] != $ip2[0] ) return false;
    if( $ip1[1] != $ip2[1] ) return false;
    
    return true;

}

function show_attach($story, $id, $static = false) {
    global $db, $config, $lang, $user_group, $member_id;

    $find_1 = array();
    $find_2 = array();
    $replace_1 = array();
    $replace_2 = array();
    
    if( $static ) {
        
        if( is_array( $id ) and count( $id ) ) $where = &quot;static_id IN (&quot; . implode( &quot;,&quot;, $id ) . &quot;)&quot;;
        else $where = &quot;static_id = &#039;&quot;.intval($id).&quot;&#039;&quot;;
        
        $db-&gt;query( &quot;SELECT id, name, onserver, dcount FROM &quot; . PREFIX . &quot;_static_files WHERE $where&quot; );
        
        $area = &quot;&amp;amp;area=static&quot;;
    
    } else {
        
        if( is_array( $id ) and count( $id ) ) $where = &quot;news_id IN (&quot; . implode( &quot;,&quot;, $id ) . &quot;)&quot;;
        else $where = &quot;news_id = &#039;&quot;.intval($id).&quot;&#039;&quot;;
        
        $db-&gt;query( &quot;SELECT id, name, onserver, dcount FROM &quot; . PREFIX . &quot;_files WHERE $where&quot; );
        
        $area = &quot;&quot;;
    
    }
    
    while ( $row = $db-&gt;get_row() ) {
        
        $size = formatsize( @filesize( ROOT_DIR . &#039;/uploads/files/&#039; . $row[&#039;onserver&#039;] ) );
        $row[&#039;name&#039;] = explode( &quot;/&quot;, $row[&#039;name&#039;] );
        $row[&#039;name&#039;] = end( $row[&#039;name&#039;] );

        $find_1[] = &#039;[attachment=&#039; . $row[&#039;id&#039;] . &#039;]&#039;;
        $find_2[] = &quot;#\[attachment={$row[&#039;id&#039;]}:(.+?)\]#i&quot;;

        if ( ! $user_group[$member_id[&#039;user_group&#039;]][&#039;allow_files&#039;] ) {

            $replace_1[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;{$lang[&#039;att_denied&#039;]}&lt;/span&gt;&quot;;
            $replace_2[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;{$lang[&#039;att_denied&#039;]}&lt;/span&gt;&quot;;

        } elseif( $config[&#039;files_count&#039;] == &#039;yes&#039; ) {

            $replace_1[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;&lt;a href=\&quot;{$config[&#039;http_home_url&#039;]}engine/download.php?id={$row[&#039;id&#039;]}{$area}\&quot; &gt;{$row[&#039;name&#039;]}&lt;/a&gt; [{$size}] ({$lang[&#039;att_dcount&#039;]} {$row[&#039;dcount&#039;]})&lt;/span&gt;&quot;;
            $replace_2[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;&lt;a href=\&quot;{$config[&#039;http_home_url&#039;]}engine/download.php?id={$row[&#039;id&#039;]}{$area}\&quot; &gt;\\1&lt;/a&gt; [{$size}] ({$lang[&#039;att_dcount&#039;]} {$row[&#039;dcount&#039;]})&lt;/span&gt;&quot;;

        } else {

            $replace_1[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;&lt;a href=\&quot;{$config[&#039;http_home_url&#039;]}engine/download.php?id={$row[&#039;id&#039;]}{$area}\&quot; &gt;{$row[&#039;name&#039;]}&lt;/a&gt; [{$size}]&lt;/span&gt;&quot;;
            $replace_2[] = &quot;&lt;span class=\&quot;attachment\&quot;&gt;&lt;a href=\&quot;{$config[&#039;http_home_url&#039;]}engine/download.php?id={$row[&#039;id&#039;]}{$area}\&quot; &gt;\\1&lt;/a&gt; [{$size}]&lt;/span&gt;&quot;;

        }

    }

    $db-&gt;free();

    $story = str_replace ( $find_1, $replace_1, $story );
    $story = preg_replace( $find_2, $replace_2, $story );
    
    return $story;

}

function xfieldsload($profile = false) {
    global $lang;
    
    if( $profile ) $path = ENGINE_DIR . &#039;/data/xprofile.txt&#039;;
    else $path = ENGINE_DIR . &#039;/data/xfields.txt&#039;;
    
    $filecontents = file( $path );
    
    if( ! is_array( $filecontents ) ) msgbox( &quot;System error&quot;, &quot;File &lt;b&gt;{$path}&lt;/b&gt; not found&quot; );
    else {
        foreach ( $filecontents as $name =&gt; $value ) {
            $filecontents[$name] = explode( &quot;|&quot;, trim( $value ) );
            foreach ( $filecontents[$name] as $name2 =&gt; $value2 ) {
                $value2 = str_replace( &quot;&amp;#124;&quot;, &quot;|&quot;, $value2 );
                $value2 = str_replace( &quot;__NEWL__&quot;, &quot;\r\n&quot;, $value2 );
                $filecontents[$name][$name2] = $value2;
            }
        }
    }
    return $filecontents;
}

function xfieldsdataload($id) {
    
    if( $id == &quot;&quot; ) return;
    
    $xfieldsdata = explode( &quot;||&quot;, $id );
    foreach ( $xfieldsdata as $xfielddata ) {
        list ( $xfielddataname, $xfielddatavalue ) = explode( &quot;|&quot;, $xfielddata );
        $xfielddataname = str_replace( &quot;&amp;#124;&quot;, &quot;|&quot;, $xfielddataname );
        $xfielddataname = str_replace( &quot;__NEWL__&quot;, &quot;\r\n&quot;, $xfielddataname );
        $xfielddatavalue = str_replace( &quot;&amp;#124;&quot;, &quot;|&quot;, $xfielddatavalue );
        $xfielddatavalue = str_replace( &quot;__NEWL__&quot;, &quot;\r\n&quot;, $xfielddatavalue );
        $data[$xfielddataname] = $xfielddatavalue;
    }
    return $data;
}

function create_keywords($story) {
    global $metatags, $config;
    
    $keyword_count = 20;
    $newarr = array ();
    
    $quotes = array (&quot;\x22&quot;, &quot;\x60&quot;, &quot;\t&quot;, &quot;\n&quot;, &quot;\r&quot;, &quot;,&quot;, &quot;.&quot;, &quot;/&quot;, &quot;¬&quot;, &quot;#&quot;, &quot;;&quot;, &quot;:&quot;, &quot;@&quot;, &quot;~&quot;, &quot;[&quot;, &quot;]&quot;, &quot;{&quot;, &quot;}&quot;, &quot;=&quot;, &quot;-&quot;, &quot;+&quot;, &quot;)&quot;, &quot;(&quot;, &quot;*&quot;, &quot;^&quot;, &quot;%&quot;, &quot;$&quot;, &quot;&lt;&quot;, &quot;&gt;&quot;, &quot;?&quot;, &quot;!&quot;, &#039;&quot;&#039;);
    $fastquotes = array (&quot;\x22&quot;, &quot;\x60&quot;, &quot;\t&quot;, &quot;\n&quot;, &quot;\r&quot;, &#039;&quot;&#039;, &quot;\\&quot;, &#039;\r&#039;, &#039;\n&#039;, &quot;/&quot;, &quot;{&quot;, &quot;}&quot;, &quot;[&quot;, &quot;]&quot; );
    
    $story = preg_replace( &quot;#\[hide\](.+?)\[/hide\]#is&quot;, &quot;&quot;, $story );
    $story = preg_replace( &quot;&#039;\[attachment=(.*?)\]&#039;si&quot;, &quot;&quot;, $story );
    $story = preg_replace( &quot;&#039;\[page=(.*?)\](.*?)\[/page\]&#039;si&quot;, &quot;&quot;, $story );
    $story = str_replace( &quot;{PAGEBREAK}&quot;, &quot;&quot;, $story );
    $story = str_replace( &quot;&amp;nbsp;&quot;, &quot; &quot;, $story );
    $story = str_replace( &#039;&lt;br /&gt;&#039;, &#039; &#039;, $story );
    $story = strip_tags( $story );
    $story = preg_replace( &quot;#&amp;(.+?);#&quot;, &quot;&quot;, $story );
    $story = trim(str_replace( &quot; ,&quot;, &quot;&quot;, stripslashes( $story )));
    
    $story = str_replace( $fastquotes, &#039;&#039;, $story );
    
    $metatags[&#039;description&#039;] = dle_substr( $story, 0, 190, $config[&#039;charset&#039;] );
    
    $story = str_replace( $quotes, &#039; &#039;, $story );
    
    $arr = explode( &quot; &quot;, $story );
    
    foreach ( $arr as $word ) {
        if( dle_strlen( $word, $config[&#039;charset&#039;] ) &gt; 4 ) $newarr[] = $word;
    }
    
    $arr = array_count_values( $newarr );
    arsort( $arr );
    
    $arr = array_keys( $arr );
    
    $total = count( $arr );
    
    $offset = 0;
    
    $arr = array_slice( $arr, $offset, $keyword_count );
    
    $metatags[&#039;keywords&#039;] = implode( &quot;, &quot;, $arr );
}

function allowed_ip($ip_array) {
    
    $ip_array = trim( $ip_array );
    
    if( $ip_array == &quot;&quot; ) {
        return true;
    }
    
    $ip_array = explode( &quot;|&quot;, $ip_array );
    
    $db_ip_split = explode( &quot;.&quot;, $_SERVER[&#039;REMOTE_ADDR&#039;] );
    
    foreach ( $ip_array as $ip ) {
        
        $ip_check_matches = 0;
        $this_ip_split = explode( &quot;.&quot;, trim( $ip ) );
        
        for($i_i = 0; $i_i &lt; 4; $i_i ++) {
            if( $this_ip_split[$i_i] == $db_ip_split[$i_i] or $this_ip_split[$i_i] == &#039;*&#039; ) {
                $ip_check_matches += 1;
            }
        
        }
        
        if( $ip_check_matches == 4 ) return true;
    
    }
    
    return FALSE;
}

function news_permission($id) {
    
    if( $id == &quot;&quot; ) return;
    
    $data = array ();
    $groups = explode( &quot;||&quot;, $id );
    foreach ( $groups as $group ) {
        list ( $groupid, $groupvalue ) = explode( &quot;:&quot;, $group );
        $data[$groupid] = $groupvalue;
    }
    return $data;
}

function bannermass($fest, $massiv) {
    return $fest . $massiv[@array_rand( $massiv )][&#039;text&#039;];
}

function get_sub_cats($id, $subcategory = &#039;&#039;) {
    
    global $cat_info;
    $subfound = array ();
    
    if( $subcategory == &#039;&#039; ) $subcategory = $id;
    
    foreach ( $cat_info as $cats ) {
        if( $cats[&#039;parentid&#039;] == $id ) {
            $subfound[] = $cats[&#039;id&#039;];
        }
    }
    
    foreach ( $subfound as $parentid ) {
        $subcategory .= &quot;|&quot; . $parentid;
        $subcategory = get_sub_cats( $parentid, $subcategory );
    }
    
    return $subcategory;

}

function check_xss() {

    $url = html_entity_decode( urldecode( $_SERVER[&#039;QUERY_STRING&#039;] ), ENT_QUOTES, &#039;ISO-8859-1&#039; );
    $url = str_replace( &quot;\\&quot;, &quot;/&quot;, $url );

    if ($_GET[&#039;do&#039;] == &quot;xfsearch&quot;) {

        $f = html_entity_decode( urldecode( $_GET[&#039;xf&#039;] ), ENT_QUOTES, &#039;ISO-8859-1&#039; );

        $count1 = substr_count ($f, &quot;&#039;&quot;);
        $count2 = substr_count ($f, &#039;&quot;&#039;);
        $count3 = substr_count ($url, &quot;&#039;&quot;);
        $count4 = substr_count ($url, &#039;&quot;&#039;);

        if ( $count1 == $count3 AND $count2 == $count4 AND (strpos( $url, &#039;&lt;&#039; ) === false) AND (strpos( $url, &#039;&gt;&#039; ) === false) AND (strpos( $url, &#039;./&#039; ) === false) AND (strpos( $url, &#039;../&#039; ) === false) AND (strpos( $url, &#039;.php&#039; ) === false) ) return;

    }

    if ($_GET[&#039;do&#039;] == &quot;tags&quot;) {

        $f = html_entity_decode( urldecode( $_GET[&#039;tag&#039;] ), ENT_QUOTES, &#039;ISO-8859-1&#039; );

        $count1 = substr_count ($f, &quot;&#039;&quot;);
        $count2 = substr_count ($url, &quot;&#039;&quot;);

        if ( $count1 == $count2 AND (strpos( $url, &#039;&lt;&#039; ) === false) AND (strpos( $url, &#039;&gt;&#039; ) === false) AND (strpos( $url, &#039;&quot;&#039; ) === false) AND (strpos( $url, &#039;./&#039; ) === false) AND (strpos( $url, &#039;../&#039; ) === false) AND (strpos( $url, &#039;.php&#039; ) === false) ) return;

    }
    
    if( $url ) {
        
        if( (strpos( $url, &#039;&lt;&#039; ) !== false) || (strpos( $url, &#039;&gt;&#039; ) !== false) || (strpos( $url, &#039;&quot;&#039; ) !== false) || (strpos( $url, &#039;./&#039; ) !== false) || (strpos( $url, &#039;../&#039; ) !== false) || (strpos( $url, &#039;\&#039;&#039; ) !== false) || (strpos( $url, &#039;.php&#039; ) !== false) ) {
            if( $_GET[&#039;do&#039;] != &quot;search&quot; OR $_GET[&#039;subaction&#039;] != &quot;search&quot; ) die( &quot;Hacking attempt!&quot; );
        }
    
    }
    
    $url = html_entity_decode( urldecode( $_SERVER[&#039;REQUEST_URI&#039;] ), ENT_QUOTES, &#039;ISO-8859-1&#039; );
    $url = str_replace( &quot;\\&quot;, &quot;/&quot;, $url );
    
    if( $url ) {
        
        if( (strpos( $url, &#039;&lt;&#039; ) !== false) || (strpos( $url, &#039;&gt;&#039; ) !== false) || (strpos( $url, &#039;&quot;&#039; ) !== false) || (strpos( $url, &#039;\&#039;&#039; ) !== false) ) {
            if( $_GET[&#039;do&#039;] != &quot;search&quot; OR $_GET[&#039;subaction&#039;] != &quot;search&quot; ) die( &quot;Hacking attempt!&quot; );
        
        }
    
    }

}

function check_category($cats, $block, $category, $action = true) {

    $cats = str_replace(&quot; &quot;, &quot;&quot;, $cats );    
    $cats = explode( &#039;,&#039;, $cats );
    $category = explode( &#039;,&#039;, $category );
    $found = false;
    
    foreach ( $category as $element ) {
        
        if( $action ) {
            
            if( in_array( $element, $cats ) ) {
                
                $block = str_replace( &#039;\&quot;&#039;, &#039;&quot;&#039;, $block );
                return $block;
            }
        
        } else {
            
            if( in_array( $element, $cats ) ) {
                $found = true;
            }
        
        }
    
    }

    if ( !$action AND !$found ) {    

        $block = str_replace( &#039;\&quot;&#039;, &#039;&quot;&#039;, $block  );
        return $block;
    }

    return &quot;&quot;;

}

function clean_url($url) {
    
    if( $url == &#039;&#039; ) return;
    
    $url = str_replace( &quot;http://&quot;, &quot;&quot;, strtolower( $url ) );
    $url = str_replace( &quot;https://&quot;, &quot;&quot;, $url );
    if( substr( $url, 0, 4 ) == &#039;www.&#039; ) $url = substr( $url, 4 );
    $url = explode( &#039;/&#039;, $url );
    $url = reset( $url );
    $url = explode( &#039;:&#039;, $url );
    $url = reset( $url );
    
    return $url;
}

function get_url($id) {
    
    global $cat_info;
    
    if( ! $id ) return;
    
    $parent_id = $cat_info[$id][&#039;parentid&#039;];
    
    $url = $cat_info[$id][&#039;alt_name&#039;];
    
    while ( $parent_id ) {
        
        $url = $cat_info[$parent_id][&#039;alt_name&#039;] . &quot;/&quot; . $url;
        
        $parent_id = $cat_info[$parent_id][&#039;parentid&#039;];
        
        if( $cat_info[$parent_id][&#039;parentid&#039;] == $cat_info[$parent_id][&#039;id&#039;] ) break;
    
    }
    
    return $url;
}

function get_categories($id) {
    
    global $cat_info, $config, $PHP_SELF;
    
    if( ! $id ) return;
    
    $parent_id = $cat_info[$id][&#039;parentid&#039;];
    
    if( $config[&#039;allow_alt_url&#039;] == &quot;yes&quot; ) $list = &quot;&lt;a href=\&quot;&quot; . $config[&#039;http_home_url&#039;] . get_url( $id ) . &quot;/\&quot;&gt;{$cat_info[$id][&#039;name&#039;]}&lt;/a&gt;&quot;;
    else $list = &quot;&lt;a href=\&quot;$PHP_SELF?do=cat&amp;amp;category={$cat_info[$id][&#039;alt_name&#039;]}\&quot;&gt;{$cat_info[$id][&#039;name&#039;]}&lt;/a&gt;&quot;;
    
    while ( $parent_id ) {
        
        if( $config[&#039;allow_alt_url&#039;] == &quot;yes&quot; ) $list = &quot;&lt;a href=\&quot;&quot; . $config[&#039;http_home_url&#039;] . get_url( $parent_id ) . &quot;/\&quot;&gt;{$cat_info[$parent_id][&#039;name&#039;]}&lt;/a&gt;&quot; . &quot; &amp;raquo; &quot; . $list;
        else $list = &quot;&lt;a href=\&quot;$PHP_SELF?do=cat&amp;amp;category={$cat_info[$parent_id][&#039;alt_name&#039;]}\&quot;&gt;{$cat_info[$parent_id][&#039;name&#039;]}&lt;/a&gt;&quot; . &quot; &amp;raquo; &quot; . $list;
        
        $parent_id = $cat_info[$parent_id][&#039;parentid&#039;];
        
        if( $cat_info[$parent_id][&#039;parentid&#039;] == $cat_info[$parent_id][&#039;id&#039;] ) break;
    
    }
    
    return $list;
}

function set_cookie($name, $value, $expires) {
    
    if( $expires ) {
        
        $expires = time() + ($expires * 86400);
    
    } else {
        
        $expires = FALSE;
    
    }
    
    if( PHP_VERSION &lt; 5.2 ) {

        if ( DOMAIN ) setcookie( $name, $value, $expires, &quot;/&quot;,  &quot;; HttpOnly&quot; );
        else setcookie( $name, $value, $expires, &quot;/&quot;,  dim-kino.com . &quot;; HttpOnly&quot; );
    
    } else {
        
        setcookie( $name, $value, $expires, &quot;/&quot;, dim-kino.com, NULL, TRUE );
    
    }
}

function news_sort($do) {
    
    global $config, $lang;
    
    if( ! $do ) $do = &quot;main&quot;;
    
    $find_sort = &quot;dle_sort_&quot; . $do;
    $direction_sort = &quot;dle_direction_&quot; . $do;
    
    $find_sort = str_replace( &quot;.&quot;, &quot;&quot;, $find_sort );
    $direction_sort = str_replace( &quot;.&quot;, &quot;&quot;, $direction_sort );
    
    $sort = array ();
    $allowed_sort = array (&#039;date&#039;, &#039;rating&#039;, &#039;news_read&#039;, &#039;comm_num&#039;, &#039;title&#039; );
    
    $soft_by_array = array (

    &#039;date&#039; =&gt; array (

    &#039;name&#039; =&gt; $lang[&#039;sort_by_date&#039;], &#039;value&#039; =&gt; &quot;date&quot;, &#039;direction&#039; =&gt; &quot;desc&quot;, &#039;image&#039; =&gt; &quot;&quot; ), 

    &#039;rating&#039; =&gt; array (

    &#039;name&#039; =&gt; $lang[&#039;sort_by_rating&#039;], &#039;value&#039; =&gt; &quot;rating&quot;, &#039;direction&#039; =&gt; &quot;desc&quot;, &#039;image&#039; =&gt; &quot;&quot; ), 

    &#039;news_read&#039; =&gt; array (

    &#039;name&#039; =&gt; $lang[&#039;sort_by_read&#039;], &#039;value&#039; =&gt; &quot;news_read&quot;, &#039;direction&#039; =&gt; &quot;desc&quot;, &#039;image&#039; =&gt; &quot;&quot; ), 

    &#039;comm_num&#039; =&gt; array (

    &#039;name&#039; =&gt; $lang[&#039;sort_by_comm&#039;], &#039;value&#039; =&gt; &quot;comm_num&quot;, &#039;direction&#039; =&gt; &quot;desc&quot;, &#039;image&#039; =&gt; &quot;&quot; ), 

    &#039;title&#039; =&gt; array (

    &#039;name&#039; =&gt; $lang[&#039;sort_by_title&#039;], &#039;value&#039; =&gt; &quot;title&quot;, &#039;direction&#039; =&gt; &quot;desc&quot;, &#039;image&#039; =&gt; &quot;&quot; )

     );
    
    if( isset( $_SESSION[$direction_sort] ) AND ($_SESSION[$direction_sort] == &quot;desc&quot; OR $_SESSION[$direction_sort] == &quot;asc&quot;) ) $direction = $_SESSION[$direction_sort];
    else $direction = $config[&#039;news_msort&#039;];

    if( isset( $_SESSION[$find_sort] ) AND $_SESSION[$find_sort] AND in_array( $_SESSION[$find_sort], $allowed_sort ) ) $soft_by = $_SESSION[$find_sort];
    else $soft_by = $config[&#039;news_sort&#039;];
    
    if( strtolower( $direction ) == &quot;asc&quot; ) {
        
        $soft_by_array[$soft_by][&#039;image&#039;] = &quot;&lt;img src=\&quot;{THEME}/dleimages/asc.gif\&quot; alt=\&quot;\&quot; /&gt;&quot;;
        $soft_by_array[$soft_by][&#039;direction&#039;] = &quot;desc&quot;;
    
    } else {
        
        $soft_by_array[$soft_by][&#039;image&#039;] = &quot;&lt;img src=\&quot;{THEME}/dleimages/desc.gif\&quot; alt=\&quot;\&quot; /&gt;&quot;;
        $soft_by_array[$soft_by][&#039;direction&#039;] = &quot;asc&quot;;
    }
    
    foreach ( $soft_by_array as $value ) {
        
        $sort[] = $value[&#039;image&#039;] . &quot;&lt;a href=\&quot;#\&quot; onclick=\&quot;dle_change_sort(&#039;{$value[&#039;value&#039;]}&#039;,&#039;{$value[&#039;direction&#039;]}&#039;); return false;\&quot;&gt;&quot; . $value[&#039;name&#039;] . &quot;&lt;/a&gt;&quot;;
    }
    
    $sort = &quot;&lt;form name=\&quot;news_set_sort\&quot; id=\&quot;news_set_sort\&quot; method=\&quot;post\&quot; action=\&quot;\&quot; &gt;&quot; . $lang[&#039;sort_main&#039;] . &quot;&amp;nbsp;&quot; . implode( &quot; | &quot;, $sort );
    
    $sort .= &lt;&lt;&lt;HTML
&lt;input type=&quot;hidden&quot; name=&quot;dlenewssortby&quot; id=&quot;dlenewssortby&quot; value=&quot;{$config[&#039;news_sort&#039;]}&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;dledirection&quot; id=&quot;dledirection&quot; value=&quot;{$config[&#039;news_msort&#039;]}&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;set_new_sort&quot; id=&quot;set_new_sort&quot; value=&quot;{$find_sort}&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;set_direction_sort&quot; id=&quot;set_direction_sort&quot; value=&quot;{$direction_sort}&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&gt;
&lt;!-- begin

function dle_change_sort(sort, direction){

  var frm = document.getElementById(&#039;news_set_sort&#039;);

  frm.dlenewssortby.value=sort;
  frm.dledirection.value=direction;

  frm.submit();
  return false;
};

// end --&gt;
&lt;/script&gt;&lt;/form&gt;
HTML;
    
    return $sort;
}

function compare_tags($a, $b) {
    
    if( $a[&#039;tag&#039;] == $b[&#039;tag&#039;] ) return 0;
    
    return strcasecmp( $a[&#039;tag&#039;], $b[&#039;tag&#039;] );

}

function convert_unicode($t, $to = &#039;windows-1251&#039;) {

    $to = strtolower( $to );

    if( $to == &#039;utf-8&#039; ) {
        
        return $t;
    
    } else {

        if( function_exists( &#039;mb_convert_encoding&#039; ) ) {

            $t = mb_convert_encoding( $t, $to, &quot;UTF-8&quot; );

        } elseif( function_exists( &#039;iconv&#039; ) ) {

            $t = iconv( &quot;UTF-8&quot;, $to . &quot;//IGNORE&quot;, $t );

        } else $t = &quot;The library iconv AND mbstring is not supported by your server&quot;;
    
    }

    return $t;
}

function check_smartphone() {

    if ( $_SESSION[&#039;mobile_enable&#039;] ) return true;

    $phone_array = array(&#039;iphone&#039;, &#039;android&#039;, &#039;pocket&#039;, &#039;palm&#039;, &#039;windows ce&#039;, &#039;windowsce&#039;, &#039;mobile windows&#039;, &#039;cellphone&#039;, &#039;opera mobi&#039;, &#039;operamobi&#039;, &#039;ipod&#039;, &#039;small&#039;, &#039;sharp&#039;, &#039;sonyericsson&#039;, &#039;symbian&#039;, &#039;symbos&#039;, &#039;opera mini&#039;, &#039;nokia&#039;, &#039;htc_&#039;, &#039;samsung&#039;, &#039;motorola&#039;, &#039;smartphone&#039;, &#039;blackberry&#039;, &#039;playstation portable&#039;, &#039;tablet browser&#039;, &#039;android&#039;);
    $agent = strtolower( $_SERVER[&#039;HTTP_USER_AGENT&#039;] );

    foreach ($phone_array as $value) {

        if ( strpos($agent, $value) !== false ) return true;

    }

    return false;

}

function build_js($js, $config) {

    $js_array = array();

    if ($config[&#039;js_min&#039;] AND version_compare(PHP_VERSION, &#039;5.1.0&#039;, &#039;&gt;&#039;) ) {

        $js_array[] = &quot;&lt;script type=\&quot;text/javascript\&quot; src=\&quot;{$config[&#039;http_home_url&#039;]}engine/classes/min/index.php?charset={$config[&#039;charset&#039;]}&amp;amp;g=general&amp;amp;9\&quot;&gt;&lt;/script&gt;&quot;;

        if ( count($js) ) $js_array[] = &quot;&lt;script type=\&quot;text/javascript\&quot; src=\&quot;{$config[&#039;http_home_url&#039;]}engine/classes/min/index.php?charset={$config[&#039;charset&#039;]}&amp;amp;f=&quot;.implode(&quot;,&quot;, $js).&quot;&amp;amp;9\&quot;&gt;&lt;/script&gt;&quot;;

        return implode(&quot;\n&quot;, $js_array);

    } else {

        $default_array = array (
            &#039;engine/classes/js/jquery.js&#039;,
            &#039;engine/classes/js/jqueryui.js&#039;,
            &#039;engine/classes/js/dle_js.js&#039;,
        );

        $js = array_merge($default_array, $js);

        foreach ($js as $value) {
        
            $js_array[] = &quot;&lt;script type=\&quot;text/javascript\&quot; src=\&quot;{$config[&#039;http_home_url&#039;]}{$value}\&quot;&gt;&lt;/script&gt;&quot;;
        
        }

        return implode(&quot;\n&quot;, $js_array);
    }
}

function check_static($names, $block, $action = true) {
    global $dle_module;

    $names = str_replace(&quot; &quot;, &quot;&quot;, $names );
    $names = explode( &#039;,&#039;, $names );

    if ( isset($_GET[&#039;page&#039;]) ) $page = trim($_GET[&#039;page&#039;]); else $page = &quot;&quot;;
    
    if( $action ) {
            
        if( in_array( $page, $names ) AND $dle_module == &quot;static&quot; ) {
                
            $block = str_replace( &#039;\&quot;&#039;, &#039;&quot;&#039;, $block );
            return $block;
        }
        
    } else {
            
        if( !in_array( $page, $names ) OR $dle_module != &quot;static&quot;) {
                
            $block = str_replace( &#039;\&quot;&#039;, &#039;&quot;&#039;, $block  );
            return $block;
        }
        
    }
    
    return &quot;&quot;;
}


function dle_strlen($value, $charset ) {

    if ( strtolower($charset) == &quot;utf-8&quot;) return iconv_strlen($value, &quot;utf-8&quot;);
    else return strlen($value);

}

function dle_substr($str, $start, $length, $charset ) {

    if ( strtolower($charset) == &quot;utf-8&quot;) return iconv_substr($str, $start, $length, &quot;utf-8&quot;);
    else return substr($str, $start, $length);

}

function dle_strrpos($str, $needle, $charset ) {

    if ( strtolower($charset) == &quot;utf-8&quot;) return iconv_strrpos($str, $needle, &quot;utf-8&quot;);
    else return strrpos($str, $needle);

}

function check_allow_login($ip, $max ) {
    global $db;

    $block_date = time()-1200;

    $row = $db-&gt;super_query( &quot;SELECT * FROM &quot; . PREFIX . &quot;_login_log WHERE ip=&#039;{$ip}&#039;&quot; );

    if ( $row[&#039;count&#039;] AND $row[&#039;date&#039;] &lt; $block_date ) $db-&gt;query( &quot;DELETE FROM &quot; . PREFIX . &quot;_login_log WHERE ip = &#039;{$ip}&#039;&quot; );

    if ($row[&#039;count&#039;] &gt; $max AND $row[&#039;date&#039;] &gt; $block_date ) return false;
    else return true;

} 

function detect_encoding($string) {  
  static $list = array(&#039;utf-8&#039;, &#039;windows-1251&#039;);
   
  foreach ($list as $item) {
     $sample = iconv($item, $item, $string);
     if (md5($sample) == md5($string))
       return $item;
   }
   return null;
}
 
function get_ip() {

    $ip_split = explode( &quot;.&quot;, $_SERVER[&#039;REMOTE_ADDR&#039;] );
    $_IP = array();
    
    for($i = 0; $i &lt; 4; $i++) {
        $_IP[] = intval($ip_split[$i]);
    }
    
    return implode(&quot;.&quot;, $_IP);
}
?&gt;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (kosa1)]]></author>
			<pubDate>Sat, 06 Jun 2015 09:20:56 +0000</pubDate>
			<guid>https://talk.alaev.info/post/9620/#p9620</guid>
		</item>
		<item>
			<title><![CDATA[Re: проблема с куки]]></title>
			<link>https://talk.alaev.info/post/9619/#p9619</link>
			<description><![CDATA[<p>в основных настройках движка во вкладке Посетители есть пункт &quot;Авторизовать пользователей на домене и всех его поддоменах&quot;&nbsp; там стоит Да ?&nbsp; если нет, то поставьте Да <img src="https://talk.alaev.info/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>Проверьте работу $_SERVER[&#039;HTTP_HOST&#039;];<br />ну к примеру в index.php после<br /></p><div class="codebox"><pre><code>define ( &#039;DATALIFEENGINE&#039;, true );</code></pre></div><p>пропишите<br /></p><div class="codebox"><pre><code>echo $_SERVER[&#039;HTTP_HOST&#039;];</code></pre></div><p>и посмотрите что выведет на сайте в самом верху страницы, потом уберите вывод.</p><p>покажите что в вашем functions.php</p>]]></description>
			<author><![CDATA[null@example.com (svetlana)]]></author>
			<pubDate>Fri, 05 Jun 2015 13:21:50 +0000</pubDate>
			<guid>https://talk.alaev.info/post/9619/#p9619</guid>
		</item>
		<item>
			<title><![CDATA[проблема с куки]]></title>
			<link>https://talk.alaev.info/post/9616/#p9616</link>
			<description><![CDATA[<p>проблема с сайтом<br />на дле, не берут в сапу, так как говорят, что не<br />указан куки домена, сайт: dim-kino.com Ответ сервера:<br /> Set-Cookie:<br />PHPSESSID=a39e538b31a85ca0e6632f280075f4b6;<br />path=/; domain=.dim-kino.com; HttpOnly<br /> Set-Cookie: dle_user_id=deleted; expires=Thu,<br />01-Jan-1970 00:00:01 GMT; path=/; domain=0com; httponly<br /> Set-Cookie: dle_password=deleted; expires=Thu,<br />01-Jan-1970 00:00:01 GMT; path=/;<br />domain=0com; httponly<br /> Set-Cookie: dle_hash=deleted; expires=Thu, 01-<br />Jan-1970 00:00:01 GMT; path=/; domain=0com; httponly Домен не верный, заказал на сервере<br />обновление пчп, обновили до последней<br />версии, но домн все равно не прописался (хотя<br />в настройках движка прописан), до обновление<br />пчп, домена вообще никакого не стояло,<br />спросил поддержку сервака, ответили: Здравствуйте. В заголовках которые вы показали, веб-сайт<br />передает какието &quot;куки&quot;. Эти куки генерируются<br />на сервере самими скриптами, если при<br />генерации &quot;кук&quot; скрипт не указывает доменное<br />имя явно, тогда используется доменное имя из<br />переменной веб-окружения _SERVER [&quot;HTTP_HOST&quot;], которая содержит доменное<br />имя сайта. Более подробно о генерации кук php<br />скриптами вы можете прочитать тут:<br /> http://php.net/manual/ru/function.setcookie.php Таким образом, ваши скрипты указывают<br />&quot;0com&quot; явно.</p>]]></description>
			<author><![CDATA[null@example.com (kosa1)]]></author>
			<pubDate>Fri, 05 Jun 2015 07:42:16 +0000</pubDate>
			<guid>https://talk.alaev.info/post/9616/#p9616</guid>
		</item>
	</channel>
</rss>
