core/api/modules/fxpos/class.php

49 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
class main{
var $db; // Здесь объект для работы с MySQL
var $id;
private $settings;
/* ------------------------------------------------------------------------------------------------------------------------- */
function __construct($smarty, $settings){
@mkdir (MYDIR . '/img/avatars', 0700);
$db=$this->db;
/* Создаем каталог под файлы раздела и определяемся с кэшем */
if( $settings['cachePage'] > 0 ){
if( !@$_SESSION['user_id'] ) { /* если не авторизован - кешируем на часок */
$smarty -> caching = true;
$smarty -> cache_lifetime = $settings['cachePage'];
}
}
$this -> settings = $settings;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function login ( $id ) { /* Получаем инормацию об авторе */
unset ( $id['ok'] );
$db = $this -> db;
if ( $id['remember'] == 'on' ) {
unset ( $id['remember'] );
$r = 1;
}
$id['pwd'] = md5 ( @$id['pwd'] ); // хеш пароля
$id['act'] = 1;
$a['user_id'] = $db -> get_val( 'users', $id, 'id' );// берем логин, пароль и данные о том, что юзер активен
$dostup = $db -> get_val( 'users_groupe', $a, 'dostup' );
if ( $dostup ) {
$_SESSION['dostup'] = $dostup;
$_SESSION['user_id'] = $a['user_id'];
}
if ( $r==1 && $dostup ) {
$_SESSION['pwd'] = $id['pwd'];
$cookies = base64_encode ( serialize ( $_SESSION ) );
$tri_mes = time() + 31536000;
setcookie ( 'cookies', $cookies, $tri_mes, '/', SITE );
}
}
/* ------------------------------------------------------------------------------------------------------------------------- */
}
?>