108 lines
4.2 KiB
PHP
Executable File
108 lines
4.2 KiB
PHP
Executable File
<?php
|
||
#namespace main;
|
||
//use anySite;
|
||
class main extends MySQL {
|
||
//var $db; // Здесь объект для работы с MySQL
|
||
var $id;
|
||
/*
|
||
function __construct( $smarty, $settings, $db ){
|
||
$this -> db = $db;
|
||
if( $settings['cachePage'] > 0 && !@$_SESSION['user_id']){
|
||
$smarty -> caching = true;
|
||
$smarty -> cache_lifetime = $settings['cachePage'];
|
||
}
|
||
|
||
$this -> settings = $settings;
|
||
|
||
|
||
|
||
if (BD_TYPE=='SQLITE3'){
|
||
$db->free_sql2('CREATE TABLE IF NOT EXISTS `foto_albums` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `user_id` INTEGER, `srok` TEXT, `t` TEXT, `naim` TEXT, `reyt` INTEGER, `img` TEXT, `cena` INTEGER, `roznica` TEXT, `private` INTEGER, `public` INTEGER, `alias` TEXT, `dostup` INTEGER, `pwd` TEXT, `json` TEXT, FOREIGN KEY(`user_id`) REFERENCES `users`(`id`))');
|
||
|
||
|
||
$db->free_sql('CREATE TABLE IF NOT EXISTS `foto_img` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||
`user_id` TEXT, `private` INTEGER,
|
||
`album_id` INTEGER,
|
||
`img` TEXT, `tags` TEXT,
|
||
`reyt` INTEGER,
|
||
`downloads` INTEGER,
|
||
`t` TEXT, `naim` TEXT,
|
||
`audit` INTEGER,
|
||
`data_s` TEXT, `size` TEXT,
|
||
`md5` TEXT, `opis` TEXT,
|
||
`t_info` TEXT, `public` INTEGER,
|
||
`original_name` TEXT,
|
||
`json` TEXT,
|
||
FOREIGN KEY(`user_id`) REFERENCES `users`(`id`),
|
||
FOREIGN KEY(`album_id`) REFERENCES `foto_albums`(`id`))
|
||
');
|
||
}else{
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
}*/
|
||
|
||
|
||
/* ------------------------------------------------------------------------------------------------------------------------- */
|
||
function get_news($limit){ // получение новостей
|
||
$a['cat']=1;
|
||
$a['public']=1;
|
||
$db=$this->db;
|
||
$db->or_by_desc=1;
|
||
$postrow=$db->get_massiv('pages', $a, 'd', $limit);
|
||
@$num = count($postrow);
|
||
for($i = 0; $i < $num; $i++){
|
||
$y=substr($postrow[$i]['d'], 0, 4);
|
||
$m=substr($postrow[$i]['d'], 5, 2);
|
||
$d=substr($postrow[$i]['d'], 8, 2);
|
||
$postrow[$i]['dd']=$d . '.' . $m . '.' . $y;
|
||
}
|
||
return $postrow;
|
||
}
|
||
/* ------------------------------------------------------------------------------------------------------------------------- */
|
||
function get_last_page( $limit ){ // Получаем последние страницы
|
||
$db = $this -> db;
|
||
$db -> or_by_desc = 1;
|
||
$a['public']=1;
|
||
$postrow = $db -> get_massiv( 'pages', $a, 'id', $limit );
|
||
//print_r($postrow);
|
||
@$num = count ( $postrow );
|
||
//print($num);
|
||
if ($num>1){
|
||
for ( $i = 0; $i < $num; $i++ ) {
|
||
$a['id'] = $postrow[$i]['pages_cat'];
|
||
// $postrow[$i]['pages_cat'] = $db -> get_val ( 'pages', $a, 'title' );
|
||
}
|
||
}
|
||
return $postrow;
|
||
}
|
||
/* ------------------------------------------------------------------------------------------------------------------------- */
|
||
function get_slider(){ // Получаем слайдер
|
||
$db = $this -> db;
|
||
$db->or_by_desc=0;
|
||
$db -> get_massiv ( 'slider' ); //исполняем функцию с параметрами
|
||
$sliders = $db->result; //получаем результат
|
||
$this->id=$sliders[0]['id'];
|
||
return $sliders;
|
||
}
|
||
/* ------------------------------------------------------------------------------------------------------------------------- */
|
||
function get_carusel(){ // Получаем баннеры из папки
|
||
if ( file_exists ( MYDIR . '/files/template/banner' ) ) {
|
||
include_once ( MYDIR . '/api/php/list_file.php' );
|
||
$listfile = list_file ( MYDIR . '/files/template/banner' );
|
||
$c = count ( $listfile );
|
||
for ( $i = 0; $i < $c; $i++ ) $karusel[$i] = '/files/template/banner/' . $listfile[$i];
|
||
return $karusel;
|
||
}
|
||
}
|
||
}
|
||
?>
|