61 lines
2.3 KiB
PHP
61 lines
2.3 KiB
PHP
<?php
|
||
class main{
|
||
var $db; // Здесь объект для работы с MySQL
|
||
var $id;
|
||
|
||
function __construct( $smarty, $settings, $db ){
|
||
$this -> db = $db;
|
||
if( $settings['cachePage'] > 0 ){
|
||
$smarty -> caching = true;
|
||
$smarty -> cache_lifetime = $settings['cachePage'];
|
||
}
|
||
$this -> settings = $settings;
|
||
}
|
||
|
||
|
||
/* ------------------------------------------------------------------------------------------------------------------------- */
|
||
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_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;
|
||
}
|
||
}
|
||
}
|
||
?>
|