59 lines
2.2 KiB
PHP
59 lines
2.2 KiB
PHP
|
<?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;
|
|||
|
$db->free_sql2("CREATE TABLE IF NOT EXISTS `foto_albums` (
|
|||
|
`id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|||
|
`user_id` int(10) NULL,
|
|||
|
`srok` varchar(30) NULL,
|
|||
|
`t` varchar(30) NULL,
|
|||
|
`img` varchar(14) NULL,
|
|||
|
`naim` varchar(254) NULL,
|
|||
|
`reyt` int(10) NULL,
|
|||
|
`cena` int(6) NULL,
|
|||
|
FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
|
|||
|
) ENGINE='InnoDB';");
|
|||
|
|
|||
|
|
|||
|
|
|||
|
$db->free_sql2("ALTER TABLE `foto_albums` ADD `cena` int(6) NULL;");
|
|||
|
|
|||
|
// @mkdir (MYDIR . '/img/albums/' . ID, 0700);
|
|||
|
|
|||
|
}
|
|||
|
/* загрузка обложки раздела */
|
|||
|
function upload($img){
|
|||
|
$db = $this -> db;
|
|||
|
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/albums/' . $img_name . '.jpg';
|
|||
|
copy( $source, $target );
|
|||
|
}
|
|||
|
include_once (MYDIR . '/api/php/img2.php');
|
|||
|
|
|||
|
rimg ( $target, 740, 556, $target, $zip=100, $c=0 );
|
|||
|
|
|||
|
return $img_name;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/* ------------------------------------------------------------------------------------------------------------------------- */
|
|||
|
|
|||
|
}
|
|||
|
?>
|