Вход Регистрация
Файл: CMS/comm/cfg.php
Строк: 98
<?php
define
('ROOT','../');
include(
'../core/inc.php');

$is_admin     = (bool) is_admin() ? true : false; // Администрация сайта
$is_admin_soo = false;                           // Создатель
$is_moder_soo = false;                          // Остальные админы

$id = !empty($_GET['id']) ? (int) $_GET['id'] : 0;
$mod = !empty($_GET['m']) ? (string) $_GET['m'] : '';
$page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;

$onpage = !empty($config['comm_onpage']) ? num($config['comm_onpage']) : 10;

if (
$page > 1) $from = ($page - 1) * $onpage; else $from = 0;

# Кеширование категорий сообществ
$categories = get_vars('comm_categories');

if (!
$categories) {

    
$db->query("UPDATE ?_comm_category SET `cats_count` = (SELECT COUNT(1) FROM ?_comm_comm 
                WHERE ?_comm_category.`cats_id` = ?_comm_comm.`comm_cats_id`);"
);

    
$categories = array();

    
$cats = $db->select("SELECT * FROM ?_comm_category ORDER BY `cats_order` ASC;");

    if (!empty(
$cats) && count($cats) > 0) {

        foreach( 
$cats as $cat ) {

            
$categories[$cat['cats_id']] = array($cat['cats_name'], $cat['cats_about'], $cat['cats_count']);
        }

        
set_vars('comm_categories',$categories);
    }
}

# Функция кэширования уменьшенных изображений
function resize_screen($dir, $name, $size = '', $alt = '') {

    global 
$config;

    
$name = str_replace(' ', '%20', $name);

    if ( @
file_exists( ROOTPATH . DS . $dir . $name ) ) {

        
$sign    = !empty($alt) ? $alt : $name;
        
$prename = 'small_';
        
$imgsize = @getimagesize( ROOTPATH . DS . $dir . $name );

        if (
$imgsize[0] <= $size && $imgsize[1] <= $size) {

            return 
'<img src="' . $config['site_url'] . DS . $dir . $name . '" alt="' . $sign . '" />';
        }

        if (!
file_exists(ROOTPATH . DS . $dir . $prename) || filesize(ROOTPATH . DS . $dir . $prename) < 18) {

            include_once( 
ENGINE . '/classes/upload.class.php' );

            
$handle = new upload(ROOTPATH . DS . $dir . $name);

            if (
$handle -> uploaded) {
                
$handle -> file_name_body_pre     = $prename;
                
$handle -> image_resize           = true;
                
$handle -> image_ratio            = true;
                
$handle -> image_ratio_no_zoom_in = true;
                
$handle -> image_y                = $size;
                
$handle -> image_x                = $size;
                
$handle -> file_overwrite = true;
                
$handle -> process(ROOTPATH . DS . $dir);
            }
        }

        return 
'<img src="' . $config['site_url'] . DS . $dir . $prename . $name . '" alt="' . $sign . '" />';
    }

    
$param = ($size < 100) ? ' height="' . $size . '" width="' . $size . '"' : '';
    return 
'<img src="' . $config['site_url'] . '/images/no_photos_small.png" alt=""' . $param . ' />';
}

# Функция удаление картинки с проверкой
function unlink_screen($dir, $image = '') {

    if (!empty(
$image)) {

        
clearstatcache();

        
$small = str_ireplace('_small', '', $image);

        if ( @
file_exists( $dir . $image ) ) {

            
unlink( $dir . $image );
        }

        if ( @
file_exists( $dir . $small ) ) {

            
unlink( $dir . $small );
        }
    }
}

# Вывод страниц в форуме
function forum_navigation($link = '', $id = '', $posts, $total) {

    global 
$page;

    if (
$total > 0) {

        
$ba   = ceil($total / $posts);
        
$ba2  = $ba * $posts - $posts;
        
$max  = $posts * 5;
        
$show = '';

        for(
$i = 0; $i < $max;) {

            if (
$i < $total && $i >= 0) {

                
$ii = floor(1 + $i / $posts);

                
$show .= ' <a href="' . gen_uri($link, $id, 'page=' . $ii . '&amp;' . RND) . '">' . $ii . '</a> ';
            }

            
$i += $posts;
        }

        if (
$max < $total) {

            if (
$max + $posts < $total) {

                 
$show .= ' ... <a href="' . gen_uri($link, $id, 'page=' . $ba . '&amp;' . RND) . '">' . $ba . '</a>';
            }
            else {

                
$show .= ' <a href="' . gen_uri($link, $id, 'page=' . $ba . '&amp;' . RND) . '">' . $ba . '</a>';
            }
        }

        return 
$show . '<br />';
    }
}

# Функция проверки пароля
function show_auth_form($idk = '', $pass = '') {

    if (!empty(
$_POST['pass']) && $_POST['pass'] == $pass) {

        
$_SESSION[SP]['comm_auth'][$idk] = md5($pass);

    }
    else if (empty(
$_SESSION[SP]['comm_auth'][$idk]) || md5($pass) <> $_SESSION[SP]['comm_auth'][$idk]) {


        
$form = new cmsForm();
        
$form->addCode(blink('Внимание!') . ' Доступ только по паролю<br />');
        
$form->addText('Ваш пароль:','pass');
        echo 
$form->Submit('Войти');
        
show_footer();
        exit();
    }
}

# Функция ген. ссылки для сообществ
function gen_comm($soo = '', $m = '', $id = '', $q = '') {

    global 
$config;

    return 
$config['site_url'] . '/comm/' . $soo . DS . gen_uri($m,$id,$q); 
}

?>
Онлайн: 0
Реклама