Файл: CMS/load/cfg.php
Строк: 135
<?php
define('ROOT','../');
include('../core/inc.php');
$is_admin = (bool) is_admin() ? true : false;
$sorts = array(
'downs_time' => array('По дате', '`downs_time` DESC'),
'downs_load' => array('Скачивания', '`downs_load` DESC'),
'downs_rated' => array('Оценки', '`downs_rated` DESC'),
'downs_comments' => array('Комментарии', '`downs_comments` DESC'),
);
# Кеширование категорий з.ц
$categories = get_vars('loads_categories');
if (!$categories) {
$db->query("UPDATE ?_blog_category SET `cats_count` = (SELECT COUNT(`blog_id`) FROM ?_blog_posts
WHERE ?_blog_category.`cats_id` = ?_blog_posts.`blog_cats_id`);");
$categories = array();
$cats = $db->select("SELECT * FROM ?_downs_category
WHERE `cats_user` = '' AND `cats_parent` = '0';");
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('loads_categories',$categories);
}
}
# Кеширование категорий для обратных ссылок
$cats_names = get_vars('loads_cats_names');
if (!$cats_names) {
$rows = $db->select("SELECT `cats_id`, `cats_name`, `cats_parent` FROM ?_downs_category
ORDER BY `cats_order` ASC;");
$cats_names = array();
if (!empty($rows) && count($rows) > 0) {
foreach($rows as $row) {
$cats_names[$row['cats_id']] = $row['cats_name'];
}
set_vars('loads_cats_names', $cats_names);
}
}
# Функция проверки пароля
function show_auth_form($idk = '', $pass = '') {
if (!empty($_POST['pass']) && $_POST['pass'] == $pass) {
$_SESSION[SP]['hidden'][$idk] = md5($pass);
}
else if (empty($_SESSION[SP]['hidden'][$idk]) || md5($pass) <> $_SESSION[SP]['hidden'][$idk]) {
$form = new cmsForm();
$form->addCode(blink('Внимание!') . ' Доступ только по паролю<br />');
$form->addText('Ваш пароль:','pass');
echo $form->Submit('Ок');
show_footer();
exit();
}
}
# Функция проверки возраста 18+
function show_xxx_form($back_id = '') {
global $id, $config;
if (empty($_SESSION['xxx']) || !isset($_SESSION['xxx'])) {
if (!empty($_POST['xxx_code']) && $_POST['xxx_code'] == $_SESSION['captcha_key']) {
$_SESSION['xxx'] = $_POST['xxx_code'];
}
else {
$config['load_warning'] = str_replace('{SITE_NAME}', $config['site_name'], $config['load_warning']);
$form = new cmsForm();
$form->addCaptcha($config['load_warning'],'xxx_code');
echo $form->Submit('согласен');
echo '<div class="b">';
echo icon('return.png') . ' <a href="' . gen_uri('files', $back_id, RND) . '">Назад</a><br />';
echo '</div>';
show_footer();
die;
}
}
}
# Функция кэширования уменьшенных изображений
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/img/photo.jpg" alt="nophoto"' . $param . ' />';
}
# Функция вывода обраных ссылок
function show_back_link($arr = '', $del = ' -> ') {
global $cats_names;
$exp = explode(',', $arr);
$exp = array_unique($exp);
$show = array();
$show[] = icon('return.png') . ' <a href="' . gen_uri('index', '', RND) . '">Загруз Зона</a>';
if (!empty($exp) && count($exp) > 0) {
foreach($exp as $key => $val) {
if (!empty($cats_names[$val])) {
$show[] = '<a href="' . gen_uri('category', $val, RND) . '">' .$cats_names[$val] . '</a>';
}
}
}
return implode($del, $show);
}
# Кеширование категорий з.ц
$categories = get_vars('loads_categories');
if (!$categories) {
$db->query("UPDATE ?_blog_category SET `cats_count` = (SELECT COUNT(`blog_id`) FROM ?_blog_posts
WHERE ?_blog_category.`cats_id` = ?_blog_posts.`blog_cats_id`);");
$categories = array();
$cats = $db->select("SELECT * FROM ?_downs_category
WHERE `cats_user` = '' AND `cats_parent` = '0';");
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('loads_categories',$categories);
}
}
$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['blog_num']) ? num($config['blog_num']) : 10;
if ($page > 1) $from = ($page - 1) * $onpage; else $from = 0;
?>