core/api/modules/foto_show_album/class.php

75 lines
3.2 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{
var $db; // Здесь объект для работы с MySQL
var $id;
function __construct($smarty, $settings){
//if ( @$_SESSION['dostup'] !='a' && @$_SESSION['dostup'] !='e' )header( 'Location: /403/' );/*Если не админ - шлем в опу*/
/*
Создаем каталог под файлы раздела и определяемся с кэшем
*/
if( $settings['cachePage'] > 0 ){
if( !@$_SESSION['user_id'] ) { /* если не авторизован - кешируем на часок */
$smarty -> caching = true;
$smarty -> cache_lifetime = $settings['cachePage'];
}
}
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function install(){ // Инсталлятор
$db = $this -> db;
if ($_SESSION['user_id']){
@mkdir(MYDIR . '/img/albums/' . $_SESSION['user_id'], 0700);
@mkdir(MYDIR . '/img/albums/' . $_SESSION['user_id'] . '/' . ID, 0700);
@mkdir(MYDIR . '/img/albums/' . $_SESSION['user_id'] . '/' . ID . '/original', 0700);
@mkdir(MYDIR . '/img/albums/' . $_SESSION['user_id'] . '/' . ID . '/big', 0700);
}
$db->free_sql("CREATE TABLE `foto_img` (
`id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` int(10) NULL,
`album_id` int(10) NULL,
`img` varchar(15) NULL,
`tags` varchar(254) NULL,
`reyt` int(10) NULL DEFAULT '0',
`downloads` int(10) NULL,
`t` varchar(30) NULL,
FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
FOREIGN KEY (`album_id`) REFERENCES `foto_albums` (`id`)
) ENGINE='InnoDB';");
$db->free_sql2("ALTER TABLE `foto_img` ADD `naim` varchar(254) COLLATE 'utf8_general_ci' NULL;");
$db->free_sql2("ALTER TABLE `foto_img` ADD `audit` int(1) COLLATE 'utf8_general_ci' NULL;");
}
/* загрузка обложки раздела */
function upload($img){
if ( preg_match( '/[.](jpg)|(jpeg)|(JPG)|(JPEG)$/', $img['img']['name'] ) ){
include_once ( MYDIR . '/api/php/genpass.php' );
$img_name = generate_password( 10 );
$source = $img['img']['tmp_name'];
$target = MYDIR.'/img/pages_cat/' . $img_name . '.jpg';
copy( $source, $target );
}
return $img_name;
}
function add($massiv){
$db = $this -> db;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function get_pages( $id ){ // Получаем страницы
$db = $this -> db;
$db -> or_by_desc = 1;
$a['public'] = 1;
$a['post_type'] = 'page';
$a['pages_cat'] = $id;
$postrow = $db -> get_massiv( 'pages', $a, 't' );
//print_r( $postrow );
return $postrow;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
}
?>