42 lines
2.2 KiB
PHP
Executable File
42 lines
2.2 KiB
PHP
Executable File
<?php
|
||
class main{
|
||
private $db; // Здесь объект для работы с MySQL
|
||
private $settings;
|
||
/* ------------------------------------------------------------------------------------------------------------------------- */
|
||
function __construct($smarty, $settings){
|
||
$db=$this->db;
|
||
if( $settings['cachePage'] > 0 && !ID){
|
||
if( !@$_SESSION['user_id'] ) { /* если не авторизован - кешируем на часок */
|
||
$smarty -> caching = true;
|
||
$smarty -> cache_lifetime = $settings['cachePage'];
|
||
}
|
||
}
|
||
$this -> settings = $settings;
|
||
}
|
||
|
||
/* ------------------------------------------------------------------------------------------------------------------------- */
|
||
/* ------------------------------------------------------------------------------------------------------------------------- */
|
||
private function check_assess( $user_id ) { //проверка доступа к редактору
|
||
$a = 0;
|
||
if ( $_SESSION['dostup'] == 'u' && $user_id == $_SESSION['user_id'] ) $a = 1;
|
||
if ( $_SESSION['dostup'] == 'a' || $_SESSION['dostup'] == 'a' ) $a = 1;
|
||
if ( $a==0 ) header( 'Location: /403/' );
|
||
}
|
||
|
||
/* ------------------------------------------------------------------------------------------------------------------------- */
|
||
function get_page($id){ // получение страницы
|
||
$db=$this->db;
|
||
$id != '' ? $tmp['alias'] = ID : $tmp['id'] = $settings['main_page'];
|
||
$postrow = $db -> get_massiv ( 'pages', $tmp, '', '1' );//Пробуем найти по алиасу
|
||
if ( !$postrow[0]['id'] ){//Если не получилось - по ID
|
||
unset($tmp);
|
||
$tmp['id'] = $id;
|
||
$postrow = $db -> get_massiv ( 'pages', $tmp, '', '1' );
|
||
}
|
||
$this->check_assess($postrow[0]['user_id']);
|
||
return $postrow;
|
||
}
|
||
/* ------------------------------------------------------------------------------------------------------------------------- */
|
||
/* ------------------------------------------------------------------------------------------------------------------------- */
|
||
}
|
||
?>
|