Exemplo n.º 1
0
<?php

session_start();
// If already signed in (when we came from, for example, actavateAccount)
if (isset($_SESSION['g_username'])) {
    echo "Session is on<br>";
    http_response_code(302);
    exit;
}
require_once "../app-config.php";
include_once ABSPATH . "/php/CDBConn.php";
include_once ABSPATH . "/php/hostconfig.php";
$login = json_decode($_POST['login']);
$password = json_decode($_POST['password']);
$conn = new CDBConn($jet_ip, $db_name, $db_user, "qwerty123");
if (!$conn->connect()) {
    http_response_code(503);
    exit;
}
$check_user_sql = "SELECT * FROM users WHERE login='******' AND password='******'";
echo $conn->run_select($check_user_sql);
if ($conn->affected_rows() != 1) {
    echo "user with login:'******'; and password:'******' doesnot exists" . "<br>";
    http_response_code(401);
    exit;
} else {
    $_SESSION['g_username'] = $login;
    $get_hostel_id_sql = "SELECT hostel_id FROM users WHERE login='******'";
    $conn->run_query($get_hostel_id_sql);
    $row = $conn->fetch_array();
    $hostel_id = $row['hostel_id'];
Exemplo n.º 2
0
<?php

session_start();
if (!isset($_SESSION['g_username'])) {
    http_response_code(401);
    exit;
}
$date_in = $_POST['date_in'];
$date_out = $_POST['date_out'];
$bed_index = $_POST['bed_index'];
$room_id = $_POST['room_id'];
require_once '../app-config.php';
include_once ABSPATH . '/php/CDBConn.php';
include_once ABSPATH . '/php/hostconfig.php';
$conn = new CDBConn($jet_ip, $db_name, $db_user, 'qwerty123', FALSE);
$conn->connect();
// Finding whether it overlaps with some of existing orders
$check_availability = "SELECT  guest_id, date_in, date_out, date_overlap(date_in, date_out, '{$date_in}', '{$date_out}') FROM orders WHERE bed_index={$bed_index} AND room_id={$room_id}";
$conn->run_query($check_availability);
$order_info = new stdClass();
while ($line = $conn->fetch_array()) {
    if ($line['date_overlap'] == 1) {
        // avail = 0; does mean there exists at least on order
        // which conflicts with the current order.
        $order_info->avail = 0;
        $order_info->date_in = $line['date_in'];
        $order_info->date_out = $line['date_out'];
        $guest_id = $line['guest_id'];
        $guest_query = "SELECT * FROM guests WHERE id = '{$guest_id}'";
        $conn->run_query($guest_query);
        if ($conn->affected_rows() == 1) {
Exemplo n.º 3
0
 function putRoomsToDatabase(&$arr, $rcount)
 {
     $path_to_hostconfig = $_SERVER['DOCUMENT_ROOT'] . "/php/hostconfig.php";
     include_once $path_to_hostconfig;
     $path_to_cdbconn = $_SERVER["DOCUMENT_ROOT"] . "/php/CDBConn.php";
     include_once $path_to_cdbconn;
     $my_conn = new CDBConn($jet_ip, $db_name, $db_user, "qwerty123", FALSE);
     $my_conn->connect();
     for ($i = 1; $i <= $rcount; $i++) {
         $nazv = "nazv" . $i;
         $room_info[$i] .= "<br><br>Room name: " . $arr[$nazv];
         $type_id = "type" . $i;
         $q_select = "SELECT room_type_name FROM room_type WHERE room_type_id = '" . $arr[$type_id] . "'";
         $my_conn->run_query($q_select);
         $line = pg_fetch_array($my_conn->getResult());
         $type_name = "type_name" . $i;
         $arr[$type_name] = $line[0];
         $room_info[$i] .= "<br><br>Category of room: " . $arr[$type_name];
         $capacity = "capacity" . $i;
         $room_info[$i] .= "<br><br>Capacity of the room: " . $arr[$capacity];
         //$q_insert = "INSERT INTO room (room_name, room_type_id, bed_count) VALUES('".$arr[$nazv]."',".$arr[$type_id].",".$arr[$capacity].")";
         //$my_conn->run_insert($q_insert);
     }
     $my_conn->close();
     return $room_info;
 }