core/api/modules/reg/class.php

51 lines
2.4 KiB
PHP
Executable File
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 extends MySQL{
var $id;
var $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 redirect( $dostup ){
if ( $dostup=='a' ) header( 'Location: /admin/' );
if ( $dostup=='e' ) header( 'Location: /admin/' );
if ( $dostup=='u' ) header( 'Location: /' );
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function login ( $id ) { /* Получаем инормацию об авторе */
unset ( $id['ok'] );
if ( @$id['remember'] == 'on' ) {
unset ( $id['remember'] );
$r = 1;
}
$r=1;
$id['pwd'] = md5 ( @$id['pwd'] ); // хеш пароля
$id['act'] = 1;
$a['user_id'] = $this -> get_val( 'users', $id, 'id' );// берем логин, пароль и данные о том, что юзер активен
$dostup = $this -> get_val( 'users', $id, 'dostup' );
if ( $dostup ) {
$_SESSION['dostup'] = $dostup;
$_SESSION['user_id'] = $a['user_id'];
}
if ( $r==1 && $dostup ) {
$_SESSION['pwd'] = $id['pwd'];
$cookies = base64_encode ( $this -> to_j ( $_SESSION ) );
$tri_mes = time() + 31536000;
setcookie ( 'cookies', $cookies, $tri_mes, '/', SITE );
}
$this -> redirect( $dostup );
}
/* ------------------------------------------------------------------------------------------------------------------------- */
}
?>