<?php
session_start();
//ini_set('error_reporting', E_ALL);
//ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
$host='localhost';
$dbname='Mbux';
$dbuser='MBuxUser';
$dbpass='MBuxPass';
$db = new PDO("mysql:host=$host;dbname=$dbname", $dbuser, $dbpass); 
//$okrugl = -3;	//Округление цен
$okrugl = 2;	//Округление цен
//$sql = "SET NAMES cp1251";
//$db->exec($sql);
//$sql = "SET NAMES utf8";
//$db->exec($sql);
$admin_mode=false;

$autorized_user_id='';

if (isset($_SESSION['autoriz_user'])){
	$sql = "SELECT * FROM users WHERE id=".$_SESSION['autoriz_user'];
	foreach ($db->query($sql) as $row) {
		$autorized_user_id=$row['id'];
		$autorized_user_name=$row['name'];
		$autorized_user_login=$row['login'];
		$autorized_user_group=$row['usergroup'];
		$autorized_user_bonus_uslugi=$row['bonus_uslugi'];
		$autorized_user_bonus_prodaji=$row['bonus_prod'];
		if ($autorized_user_group==0) $admin_mode=true;
		break;}
	if ($_COOKIE['last_user']<>$autorized_user_login){ 
		setcookie('last_user', $autorized_user_login, time()+15552000); //полгода
		}
	if (isset($_COOKIE['id_klient'])) { 
		setcookie('id_klient', $_COOKIE['id_klient'], time()+15552000); //полгода
		}
	}


?>
