2020-09-30 19:12:34 +00:00
< ? php
2021-08-25 15:24:12 +00:00
2022-08-09 19:57:43 +00:00
use Battles\ { Database\Db , Hostel , Travel , User , UserEffect };
2021-08-25 15:24:12 +00:00
2020-10-29 23:30:05 +00:00
require_once 'config.php' ;
2018-01-28 16:40:49 +00:00
2022-08-09 19:57:43 +00:00
$host = new Hostel ();
if ( ! empty ( $_GET [ 'exit' ])) {
Travel :: toRoom ( 26 , 661 );
2018-07-02 15:35:25 +00:00
}
2022-08-09 19:57:43 +00:00
if ( ! empty ( $_GET [ 'to_room' ])) {
if ( empty ( $host -> getHid ())) {
$host -> setError ( 'У В а с , нету комнаты!' );
2018-07-02 15:35:25 +00:00
}
2022-08-09 19:57:43 +00:00
if ( $host -> getTime () <= time ()) {
$host -> setError ( 'У В а с просрочена аренда. Оплатите что-бы продолжить пользоваться нашими услугами!' );
2018-07-02 15:35:25 +00:00
}
2022-08-09 19:57:43 +00:00
if ( $host -> getStatus ()[ 'type' ] !== 'error' ) {
Travel :: toRoom ( 661 , 26 );
2020-09-30 19:12:34 +00:00
}
2018-01-28 16:40:49 +00:00
}
2022-08-09 19:57:43 +00:00
if ( ! empty ( $_GET [ 'pays' ])) {
$host -> changeTime ( $_GET [ 'pays' ]);
2018-01-28 16:40:49 +00:00
}
2022-08-09 19:57:43 +00:00
if ( ! empty ( $_POST [ 'select' ]) && ! empty ( $_POST [ 'tariff' ])) {
$host -> newRent (( int ) $_POST [ 'tariff' ]);
2018-01-28 16:40:49 +00:00
}
2022-08-09 19:57:43 +00:00
if ( ! empty ( $_GET [ 'del' ])) {
$host -> remove ();
2018-01-28 16:40:49 +00:00
}
2022-08-09 19:57:43 +00:00
if ( ! empty ( $_POST [ 'deselect' ]) && ! empty ( $_POST [ 'retariff' ])) {
$host -> changeType (( int ) $_POST [ 'retariff' ]);
header ( 'Location: main.php' );
2018-01-28 16:40:49 +00:00
}
2022-08-09 19:57:43 +00:00
if ( ! empty ( $_GET [ 'sleep' ])) {
if ( UserEffect :: getRemainingEffectTime ( User :: getInstance () -> getId (), 8 ) <= time ()) {
//Разморозка таймеров эффектов??!
UserEffect :: add ( User :: getInstance () -> getId (), 8 , UserEffect :: $effectName [ 8 ], time () + 60 * 60 * 2 );
Db :: getInstance () -> execute ( 'update users_effects set remaining_time = remaining_time - ? where owner_id = ? and type not in (11,12,13,14,5,4,3,2,8)' , [ time (), User :: getInstance () -> getId ()]);
2020-09-30 19:12:34 +00:00
header ( 'Location: hostel.php' );
} else {
2022-08-09 19:57:43 +00:00
$host -> setError ( 'Нельзя спать! Приходите через: ' . timeOut ( $user [ 'sleep_time' ] - time ()));
2018-01-28 16:40:49 +00:00
}
}
2022-08-09 19:57:43 +00:00
if ( ! empty ( $_GET [ 'unsleep' ])) {
//Заморозка таймеров эффектов??!
UserEffect :: remove ( User :: getInstance () -> getId (), 8 );
Db :: getInstance () -> execute ( 'update users_effects set remaining_time = remaining_time + ? where owner_id = ? and type not in (11,12,13,14,5,4,3,2,8)' , [ time (), User :: getInstance () -> getId ()]);
2020-09-30 19:12:34 +00:00
header ( 'Location: hostel.php' );
2018-01-28 16:40:49 +00:00
}
2022-08-09 19:57:43 +00:00
require_once 'views/hostel.php' ;