Вход Регистрация
Файл: system/inc/core.php
Строк: 118
<?php
/**
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) 2013-2014, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
 * @link          http://perf-engine.net
 * @package       PerfEngine
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
$system Core::config();
$settings User::settings();
$user User::profile();
if(
User::logged())
{
    
date_default_timezone_set($settings['timezone']);
}
else
{
    
date_default_timezone_set($system['timezone']);
}

$ip $_SERVER['REMOTE_ADDR'];
$browser browser($_SERVER['HTTP_USER_AGENT']);
if(!
User::logged())
{
    if(
$db->query("SELECT * FROM `guests` WHERE `ip` = '$ip' AND `browser` = '$browser' LIMIT 1")->rowCount() == 1
    {
        
$db->query("UPDATE `guests` SET `time` = '"time() ."' WHERE `ip` = '$ip' AND `browser` = '$browser' LIMIT 1");
    }
    else 
    {
        
$db->query("INSERT INTO `guests` SET `ip` = '$ip', `browser` = '$browser', `time` = '"time() ."'");
    }
}

if(
User::logged())
{
    
$ames $settings['ames'];

else
{
    
$ames $system['ames'];
}

$lng Core::language();

$theme parse_ini_file(Core::themePath().'/manifest.ini');

function 
notifications()
{
    global 
$db;
    if (
User::logged()) {
    
    
$new_mess $db->query("SELECT * FROM `mail` WHERE `who_id` = '"User::Id() ."' AND `read` = '0'")->rowCount();
    if(
$new_mess 0)
    {
        
Template::div('top''<a href="/mail/">'_t('new_message') .'</a> (+'.$new_mess.')');
    }
    
$new_friends $db->query("SELECT * FROM `friends` WHERE `friend_id` = '"User::Id() ."' AND `active` = '0'")->rowCount();
    if(
$new_friends 0)
    {
        
Template::div('top''<a href="/friends/requests">'_t('friends') .'</a> (+'.$db->query("SELECT * FROM `friends` WHERE `friend_id` = '"User::Id() ."' AND `active` = '0'")->rowCount().')');
    }
    
$new_notify $db->query("SELECT * FROM `notify` WHERE `user_id` = '"User::Id() ."' AND `read` = '0'")->rowCount();
    if(
$new_notify 0)
    {
        
Template::div('top''<a href="/user/notify">'_t('notify') .'</a> (+'.$new_notify.')');
    }
    
    }
}

function 
include_header($title 'Untitled page')
{
    global 
$db$page$locate$system;
    if(
User::logged()) 
    {
        if(!isset(
$locate))
        {
            
$locate 'in_site';
        }
        
$db->query("UPDATE `users` SET `locate` = '"$locate ."' WHERE `id` = '"User::Id() ."'"); 
    }
    
    
Template::view('header', array('title' => $title));

    
CoreAlert();
    
    
# Current site status
    
if($system['open_site'] == && $page != 'auth' && User::level() < 6)
    {
        
Template::div('menu'_t('site_closed'));
        
include_footer();
        exit;
    }
    elseif(
time() < User::profile('ban_time'))
    {
        
Template::div('title'_t('u_r_banned'));
        
Template::div('menu'_t('ban_text').': '.User::profile('ban_text').'<br/>
        '
._t('end_ban').': '.rtime(User::profile('ban_time')).'');
        
include_footer();
        exit;
    }
    elseif(
Core::moduleId())
    {
        if(
file_exists(ROOT.'/modules/'.Core::moduleId().'/module.ini'))
        {
            
$_module_ parse_ini_file(ROOT.'/modules/'.Core::moduleId().'/module.ini');
            if(
$_module_['open'] == && User::level() < 5)
            {
                echo 
'<div class="error">'._t('module_is_closed').'</div>';
                
Template::div('block'HICO .'<a href="/">'_t('home') .'</a>');
                
include_footer();
                exit;
            }
            elseif(
$_module_['access'] == && !User::logged() || $_module_['access'] == && User::level() < 6)
            {
                echo 
'<div class="error">'._t('module_no_access').'</div>';
                
Template::div('block'HICO .'<a href="/">'_t('home') .'</a>');
                
include_footer();
                exit;
            }
        }    
    }
    elseif(
$system['public_site'] == && !User::logged() && $page != 'reg')
    {
        
Template::div('title'_t('sign_in'));
        echo 
'<div class="menu">
        <form action="/user/sign_in?" method="post">
        '
_t('nick') .':<br/>
        <input type="text" name="nick" /><br/>
        '
_t('password') .':<br/>
        <input type="password" name="password" /><br/>
        <input type="submit" value="'
_t('sign_in') .'" />
        </form>
        </div>'
;
        
Template::div('block'NAV .'<a href="/user/sign_up/">'_t('sign_up') .'</a>');
        
include_footer();
        exit;
    }
}

function 
include_footer()
{
    
Template::view('footer');
}
Онлайн: 0
Реклама