Авторизуйтесь по паролю
ARTEXO 21.03.2017 Общие вопросы по вёрстке, Общие вопросы по PHP, Хаки 1457
Gott - 2016-07-2321 марта 2017 11:20 - #62673
ARTYOM - 2016-07-2321 марта 2017 11:47 - #62674
vitnet - 2016-07-2321 марта 2017 13:10 - #62679
ARTYOM - 2016-07-2324 марта 2017 12:58 - #62761
vitnet - 2016-07-2324 марта 2017 19:42 - #62780
function dle_cache($prefix, $cache_id = false, $member_prefix = false) { global $config, $is_logged, $member_id, $mcache; if( !$config['allow_cache'] ) return false; $config['clear_cache'] = (intval($config['clear_cache']) > 1) ? intval($config['clear_cache']) : 0; $end_file = $is_logged ? $member_id['user_group'] : "0"; if( !$cache_id ) { $key = $prefix; } else { $cache_id = md5( $cache_id ); $key = $member_prefix ? $prefix . "_" . $cache_id . "_" . $end_file : $prefix . "_" . $cache_id; } if( $mcache ) { return memcache_get( $mcache, md5( DBNAME . PREFIX . md5(SECURE_AUTH_KEY) . $key ) ); } else { $buffer = @file_get_contents( ENGINE_DIR . "/cache/" . $key . ".tmp" ); if( $buffer !== false AND $config['clear_cache'] ) { $file_date = @filemtime( ENGINE_DIR . "/cache/" . $key . ".tmp" ); $file_date = time()-$file_date; if( $file_date > ( $config['clear_cache'] * 60 ) ) { $buffer = false; @unlink( ENGINE_DIR . "/cache/" . $key . ".tmp" ); } return $buffer; } else return $buffer; } } function create_cache($prefix, $cache_text, $cache_id = false, $member_prefix = false) { global $config, $is_logged, $member_id, $mcache; if( !$config['allow_cache'] ) return false; $end_file = $is_logged ? $member_id['user_group'] : "0"; if( !$cache_id ) { $key = $prefix; } else { $cache_id = md5( $cache_id ); $key = $member_prefix ? $prefix . "_" . $cache_id . "_" . $end_file : $prefix . "_" . $cache_id; } if( $mcache ) { $config['clear_cache'] = (intval($config['clear_cache']) > 1) ? intval($config['clear_cache']) : 0; $set_time = $config['clear_cache'] ? $config['clear_cache'] * 60 : 86400; memcache_set( $mcache, md5( DBNAME . PREFIX . md5(SECURE_AUTH_KEY) .$key ), $cache_text, MEMCACHE_COMPRESSED, $set_time ); } else { file_put_contents (ENGINE_DIR . "/cache/" . $key . ".tmp", $cache_text, LOCK_EX); @chmod( ENGINE_DIR . "/cache/" . $key . ".tmp", 0666 ); } } function catCountFunction($cat_id, $config, $db, $curdate = false) { $cat_ids = array(); if( substr_count($cat_id[1], ",") ) $cat_ids = explode(",", $db->safesql(trim(strip_tags(stripslashes($cat_id[1]))))); else $cat_ids[] = is_numeric($cat_id[1]) ? intval($cat_id[1]) : false; if( !count($cat_ids) ) return; $cache_cat_news = false; $cache_cat_news = dle_cache("news_acn" . intval($curdate), $config['skin'] . implode($cat_ids), false); if( $config['allow_multi_category'] ) { $cat_query = "category regexp '[[:<:]](" . implode ( '|', $cat_ids ) . ")[[:>:]]'"; } else { $cat_query = "category IN ('" . implode ( "','", $cat_ids ) . "')"; } if( !$cache_cat_news ) { if( $curdate == false ) { $row = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_post WHERE {$cat_query}"); } else { $row = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_post WHERE {$cat_query} AND date LIKE '" . date("Y-m-d") . "%'"); } $newscount = ($row['count'] > 0) ? intval($row['count']) : false; if( $newscount ) { $cache_cat_news = $newscount; create_cache("news_acn" . intval($curdate), $cache_cat_news, $config['skin'] . implode($cat_ids), false); } } return ($cache_cat_news > 0 ? (($curdate == true) ? "+" : "") . $cache_cat_news : ""); }
$skin_footer = <<<HTML
$skin_header = preg_replace_callback( "#{cat_all\:(.+?)}#is", function($data) use ($db, $config) { return catCountFunction($data, $config, $db); }, $skin_header ); $skin_header = preg_replace_callback( "#{cat_today\:(.+?)}#is", function($data) use ($db, $config) { return catCountFunction($data, $config, $db, true); }, $skin_header );
{cat_all:1} или {cat_all:1,2,3,4} - выведет количество новостей за все время с этих категорий. {cat_today:1} или {cat_today:1,2,3,4} - выведет количество новостей за сегодня с этих категорий.
.ui-dialog {
z-index: 9999;
$tpl->set( '{short-story}', $row['short_story'] );
$tpl->set( '{short-story}', $row['short_story'] ); $tpl->set_block("'\\[short_story\\](.*?)\\[/short_story\\]'si", $row['short_story'] ? '\\1' : '');
[short-story]Показать этот текст, если есть краткая новость[/short-story]
[not-short-story]Показать этот текст, если краткой новости нет[/not-short-story]