core/api/modules/lk-new-tovar/class.php

62 lines
2.1 KiB
PHP
Raw Permalink Normal View History

2022-12-11 13:55:49 +05:00
<?php
class main extends MySQL{
var $db; // Здесь объект для работы с MySQL
var $id;
/*
function __construct($smarty, $settings){
if ( @$_SESSION['dostup'] !='a' && @$_SESSION['dostup'] !='e' )header( 'Location: /403/' );
@mkdir(MYDIR . '/img/pages_cat', 0700);
@mkdir(MYDIR . '/img/pages_cat/slider', 0700);
@mkdir(MYDIR . '/img/pages_cat/slider/' . ID, 0700);
@mkdir (MYDIR . '/img/slider/' . ID, 0700);
if( $settings['cachePage'] > 0 ){
$smarty -> caching = true;
$smarty -> cache_lifetime = $settings['cachePage'];
}
}*/
/* ----------------------------------------------------------------------
02.06.2022
Получаем информацию о пользователе
---------------------------------------------------------------------- */
function get_user_info(){
$a['id'] = $_SESSION['user_id'];
$user = $this -> get_massiv( 'users', $a, 'json');
return $user;
}
function formatBytes( $bytes, $precision = 2 ) {
$units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
$bytes = max( $bytes, 0 );
$pow = floor( ( $bytes ? log ( $bytes ) : 0 ) / log( 1024 ) );
$pow = min ( $pow, count( $units ) - 1 );
return round ( $bytes, $precision ) . ' ' . $units[$pow];
}
/* ----------------------------------------------------------------------
09.06.2022
Получаем историю заказов
---------------------------------------------------------------------- */
function get_orders( $limit=20 ){
$a['user_id'] = $_SESSION['user_id'];
$this -> or_by_desc = 1;
$orders = $this -> get_massiv( 'order', $a, 'id', $limit );
unset( $db -> or_by_desc );
$count = count($orders);
for ($i=0; $i < $count; $i++){
$orders[$i]['t']=date("H:i d.m.Y", $orders[$i]['t']);
unset($a);
$a['id']=$orders[$i]['status'];
$orders[$i]['status']=$this->get_val('order_status', $a, 'txt');
}
return $orders;
}
}
?>