73 lines
2.7 KiB
PHP
Executable File
73 lines
2.7 KiB
PHP
Executable File
<?php
|
|
/*
|
|
20.11.2017 добавлен поиск по алиасу (ЧПУ) /alias.html
|
|
*/
|
|
if( $settings['cachePage'] > 0 ){
|
|
if( !@$_SESSION['user_id'] ) { /* если не авторизован - кешируем на часок */
|
|
$smarty -> caching = true;
|
|
$smarty -> cache_lifetime = $settings['cachePage'];//минута
|
|
}
|
|
}
|
|
unset($tmp);
|
|
//echo $settings['main_page'];
|
|
//echo ID;
|
|
if (@$_GET['id'])
|
|
$tmp['alias']=ID;
|
|
else
|
|
$tmp['id']=$settings['main_page'];
|
|
//print_r($tmp);
|
|
//ID != '' ? $tmp['alias'] = ID : $tmp['id'] = $settings['main_page'];
|
|
//print_r($tmp);
|
|
$page = $db -> get_massiv ( 'pages', $tmp, '', '1' );
|
|
//print_r($page);
|
|
if (!$page[0]['id']){//Если не получилось - по ID
|
|
unset($tmp);
|
|
$tmp['id'] = ID;
|
|
$page = $db -> get_massiv ( 'pages', $tmp, '', '1' );
|
|
}
|
|
//print_r($page);
|
|
/*Записываем просмотры*/
|
|
if(!@$_SESSION['user_id']) {
|
|
$p['reyt']=$page[0]['reyt']+1;
|
|
$db->update('pages', ID, $p);
|
|
}
|
|
/* редирект на алиас, если он есть (исключение - главная страница) */
|
|
if ( @$page[0]['alias'] && ID != @$page[0]['alias'] && $page[0]['id'] != $settings['main_page'] ){
|
|
header( 'HTTP/1.1 301 Moved Permanently' );
|
|
header( 'Location: /' . $page[0]['alias'] . '.html' );
|
|
}
|
|
if (@$page[0]['rdir']){//редирект на новую страницу
|
|
header( 'HTTP/1.1 301 Moved Permanently' );
|
|
header( 'Location: ' . $page[0]['rdir'] );
|
|
}
|
|
if ($page[0]['public']==0 && $_SESSION['dostup']!=='a')header( 'Location: /403/' );
|
|
//if (!$page[0]['id'])header( 'Location: /404/' );
|
|
$smarty->assign('page', @$page);
|
|
$smarty->assign('h1', $page[0]['title']);
|
|
/*если страница главная - получаем новости */
|
|
if (!@$_GET['id'] && $settings['show_news_main_page']==1){
|
|
unset($postrow);
|
|
unset($a);
|
|
$a['cat']=2;
|
|
$a['public']=1;
|
|
$db->or_by_desc=1;
|
|
$postrow=$db->get_massiv('pages', $a, 'd', $settings['news_limit']);
|
|
//$result = mysql_query('SELECT * FROM `pages` WHERE `cat` = "2" AND `public`=1 ORDER BY `d` DESC LIMIT ' . $settings['news_limit']);
|
|
//while ( @$postrow[] = mysql_fetch_array($result));
|
|
//print_r($postrow);
|
|
$smarty->assign('postrow', @$postrow);
|
|
@$num = count($postrow);
|
|
for($i = 0; $i < $num; $i++){
|
|
$y=substr($postrow[$i]['d'], 0, 4);
|
|
$m=substr($postrow[$i]['d'], 5, 2);
|
|
$d=substr($postrow[$i]['d'], 8, 2);
|
|
$postrow[$i]['dd']=$d . '.' . $m . '.' . $y;
|
|
}
|
|
$smarty->assign('list', @$postrow);
|
|
}
|
|
//загружаем список картинок
|
|
unset($c);
|
|
$db -> or_by_desc = '';
|
|
$c['page_id']=$page[0]['id'];
|
|
$smarty -> assign( 'img', $db->get_massiv ( 'img', $c));
|
|
?>
|