Beispiel #1
0
function initDashboard()
{
    include_once ABSPATH . "/php/CDBConn.php";
    include_once ABSPATH . "/php/hostconfig.php";
    $conn = new CDBConn($jet_ip, $db_name, $db_user, "qwerty123");
    if (!$conn->connect_no_localhost()) {
        http_response_code(503);
        exit;
    }
    $cur_login = $_SESSION['g_username'];
    $get_hostel_id_sql = "SELECT hostel_id FROM users WHERE login = '******'";
    $conn->run_query($get_hostel_id_sql);
    $line = $conn->fetch_array();
    // We almost now from which hostel is user
    $hostel_id = $line['hostel_id'];
    // in case if hostel id is not set, it's an indicator that hostel  definetely has not been configured yet.
    if ($hostel_id === NULL) {
        header("Location: /configure/index.php");
        exit;
    }
    $get_is_configured_sql = "SELECT is_configured FROM hostels WHERE id = {$hostel_id}";
    $conn->run_query($get_is_configured_sql);
    $line = $conn->fetch_array();
    $is_configured = $line['is_configured'];
    // This is the case when user almost configured not
    if ($is_configured === 'f') {
        header("Location: /configure/index.php");
        // exit();
    }
    $conn->close();
}
Beispiel #2
0
<?php

session_start();
require_once "../app-config.php";
include_once ABSPATH . "/php/hostconfig.php";
include_once ABSPATH . "/php/CDBConn.php";
$input_email = $_POST['email'];
$input_reg_token = $_POST['reg_token'];
$input_password1 = $_POST['password1'];
$input_password2 = $_POST['password2'];
//printf("input_email=%s<br>input_reg_token=%s<br>input_password1=%s<br>input_password2=%s<br>", $input_email, $input_reg_token, $input_password1, $input_password2);
$conn = new CDBConn($jet_ip, $db_name, $db_user, "qwerty123", FALSE);
$conn->connect();
$query = "SELECT reg_token, is_activated FROM users WHERE login='******'";
if ($conn->run_query($query)) {
    switch ($conn->affected_rows()) {
        case 0:
            echo "This email has no associated registration inquiry. Link is invalid. Please, review whether you fully copied the activation link. If you don't know what's happened, just try signup again.<br>";
            http_response_code(422);
            break;
        case 1:
            $arr = $conn->fetch_array();
            //var_dump($arr['reg_token']);
            //var_dump($_POST['reg_token']);
            if ($arr["reg_token"] == $input_reg_token) {
                $adduser_query = "UPDATE users SET is_activated = TRUE, password='******' WHERE login='******'";
                if ($arr["is_activated"] === 't') {
                    echo "Your email has been activated. You may log in to your account";
                    http_response_code(422);
                    exit;
                }
Beispiel #3
0
<?php

session_start();
if (!isset($_SESSION['g_username'])) {
    header("Location: /login/index.php");
    exit;
}
$path_to_cdbconn = $_SERVER["DOCUMENT_ROOT"] . "/php/CDBConn.php";
include_once $path_to_cdbconn;
$hostel_info = json_decode($_POST["hostel_info"]);
$rooms = json_decode($_POST["rooms"]);
$conn = new CDBConn($jet_ip, $db_name, $db_user, "qwerty123", TRUE);
$conn->connect();
// Creating new hostel
$insert_query = "INSERT INTO hostels (name, room_count, is_configured) VALUES('{$hostel_info->hostel_name}', {$hostel_info->room_count}, TRUE) RETURNING id";
$conn->run_query($insert_query);
echo $conn->affected_rows() . " rows inserted.";
$new_hostel_id = 0;
while ($line = $conn->fetch_array()) {
    echo "id = " . $line[0];
    $new_hostel_id = $line[0];
}
// Associating email with hostel
$login_from_session = $_SESSION['g_username'];
$update_query = "UPDATE users SET hostel_id = {$new_hostel_id} WHERE login = '******'";
$conn->run_query($update_query);
$_SESSION['g_hostel_id'] = $new_hostel_id;
// Associating rooms with hostel
for ($i = 0; $i < count($rooms); $i++) {
    $cur_room_name = $rooms[$i]->name;
    $cur_room_capacity = $rooms[$i]->capacity;
Beispiel #4
0
<?php

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_no_localhost();
$conn->printinfo();
$conn->close();
/**
 * Created by PhpStorm.
 * User: Elisha
 * Date: 26.12.2015
 * Time: 20:01
 */
Beispiel #5
0
<?php

session_start();
if (!isset($_SESSION['g_username'])) {
    http_response_code(401);
    exit;
}
$room_ids = $_POST['room_ids'];
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');
$conn->connect();
// Generating SQL query
$select_rooms_orders = "SELECT * FROM orders WHERE ";
//echo "Select rooms orders query(before)= ".$select_rooms_orders;
$append = "";
//echo "\n".sizeof($room_ids)."\n";
for ($i = 0; $i < sizeof($room_ids); $i++) {
    $current_id = $room_ids[$i];
    if ($i != 0) {
        $append = $append . " OR room_id={$current_id}";
    } else {
        $append = $append . " room_id={$current_id}";
    }
}
//echo "\nappend = ".$append."\n";
$select_rooms_orders = $select_rooms_orders . $append;
//echo "Select rooms orders query(after) = ".$select_rooms_orders;
$conn->run_query($select_rooms_orders);
$orders = [];
Beispiel #6
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'];
Beispiel #7
0
<?php

session_start();
if (!isset($_SESSION['g_username'])) {
    http_response_code(401);
    exit;
}
$hostel_id = $_POST['hostel_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");
$conn->connect_no_localhost();
$room_count_query = "SELECT room_count FROM hostels WHERE id = '{$hostel_id}'";
$conn->run_query($room_count_query);
$row = $conn->fetch_array();
if ($conn->affected_rows() == 1) {
    echo $row['room_count'];
    http_response_code(200);
    exit;
} else {
    http_response_code(401);
    exit;
}
Beispiel #8
0
<?php

session_start();
if (!isset($_SESSION['g_hostel_id'])) {
    http_response_code(401);
    exit;
}
$g_hostel_id = $_SESSION['g_hostel_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');
$conn->connect();
$sql = "SELECT name FROM hostels WHERE id = '{$g_hostel_id}'";
$conn->run_query($sql);
if ($conn->affected_rows() == 1) {
    $arr = $conn->fetch_array();
    $hostel_name = $arr['name'];
    $hostel_info = [];
    $hostel_info[0]->id = $g_hostel_id;
    $hostel_info[0]->name = $hostel_name;
    echo json_encode($hostel_info);
    http_response_code(200);
} else {
    echo "Please Contact support";
    http_response_code(401);
}
$conn->close();
exit;
Beispiel #9
0
<?php

session_start();
include_once "../app-config.php";
include_once ABSPATH . "/php/CDBConn.php";
include_once ABSPATH . "/php/hostconfig.php";
if (!isset($_SESSION['g_username'])) {
    header("Location: /login/index.php");
    exit;
} else {
    //
    $conn = new CDBConn($jet_ip, $db_name, $db_user, "qwerty123");
    if (!$conn->connect_no_localhost()) {
        echo "Database error<br>";
        exit;
    }
    $cur_login = $_SESSION['g_username'];
    $get_hostel_id_query = "SELECT hostel_id,login FROM users WHERE login='******'";
    $res = $conn->run_query($get_hostel_id_query);
    if ($conn->affected_rows() == 0) {
        echo "There is no such login in database. <br>";
        exit;
    }
    $line = $conn->fetch_array();
    $hostel_id = $line['hostel_id'];
    if ($hostel_id != NULL) {
        header("Location: /dashboard/");
        exit;
    }
}
// insert is_configured flag checking
Beispiel #10
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;
 }
Beispiel #11
0
<?php

$path_to_hostconfig = $_SERVER["DOCUMENT_ROOT"] . "/php/hostconfig.php";
$path_to_cdbconn = $_SERVER["DOCUMENT_ROOT"] . "/php/CDBConn.php";
include_once $path_to_hostconfig;
include_once $path_to_cdbconn;
$conn = new CDBConn($jet_ip, $db_name, $db_user, "qwerty123");
$conn->connect();
$sql = "SELECT * FROM room_types";
$conn->run_query($sql);
$data = array();
/*while ($line = pg_fetch_array($conn->getResult()))
{
  // echo $arr["room_type_id"].$arr["room_type_name"]."<br>";
   $data[$line["room_type_id"]] = $line["room_type_name"];
}

foreach($data as $id => $name)
{
   echo $id.$name."<br>";
}*/
while ($line = pg_fetch_row($conn->getResult())) {
    $data[] = $line;
}
echo json_encode($data);
$conn->close();
Beispiel #12
0
<?php

session_start();
if (!isset($_SESSION['g_username'])) {
    http_response_code(401);
    exit;
}
require_once '../app-config.php';
include_once ABSPATH . "/php/CDBConn.php";
include_once ABSPATH . "/php/hostconfig.php";
//$hostel_id = $_POST['hostel_id'];
$hostel_id = $_SESSION['g_hostel_id'];
$conn = new CDBConn($jet_ip, $db_name, $db_user, "qwerty123");
$conn->connect();
$sql = "SELECT name, bed_count,id FROM rooms WHERE hostel_id ={$hostel_id} ORDER BY id DESC";
$rooms = array();
$result = $conn->run_query($sql);
if (!$result) {
    http_response_code(404);
    exit;
} else {
    $i = 0;
    while ($room = $conn->fetch_array()) {
        $rooms[$i]->name = $room['name'];
        $rooms[$i]->bed_count = $room['bed_count'];
        $rooms[$i]->id = $room['id'];
        $i++;
    }
    echo json_encode($rooms);
}
$conn->close();
Beispiel #13
0
<?php

$confirm = $_GET['confirm'];
$table = $_GET['table'];
if ($table == "") {
    echo "Please, specify table name<br>";
    exit(1);
}
if ($confirm == 1) {
    $path_to_cdbconn = $_SERVER["DOCUMENT_ROOT"] . "/php/CDBConn.php";
    $path_to_hostconfig = $_SERVER["DOCUMENT_ROOT"] . "/php/hostconfig.php";
    include_once $path_to_cdbconn;
    include_once $path_to_hostconfig;
    $conn = new CDBConn($jet_ip, $db_name, $db_user, "qwerty123", TRUE);
    $conn->connect();
    $sql = 'DELETE FROM "public".' . $table . ' WHERE true';
    $conn->run_query($sql);
    echo $conn->affected_rows() . " rows deleted.<br>";
    $conn->close();
} else {
    echo "you must add confirm=1 param to delete";
}
Beispiel #14
0
<?php

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, $db_pass);
echo "CDBConn::connect_no_locathost();<br>";
$conn->connect_no_localhost();
$conn->printinfo();
$sql = "SELECT * FROM hostels";
echo "<div style=\"background-color:#00FF00\">" . $conn->run_select($sql) . "</div>";
$conn->close();
$conn2 = new CDBConn("127.0.0.1", $db_name, $db_user, $db_pass);
echo "<br>--------------<br>";
echo "CDBConn::connect()<br>";
$conn2->connect_no_localhost();
$conn2->printinfo();
$sql = "SELECT * FROM rooms";
echo "<div style=\"background-color:#00FF00\">" . $conn2->run_select($sql) . "</div>";
$conn2->close();
Beispiel #15
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) {
Beispiel #16
0
session_start();
if (!isset($_SESSION['g_username'])) {
    http_response_code(401);
    exit;
}
$bed_index = $_POST['bed_index'];
$room_id = $_POST['room_id'];
$telephone = $_POST['telephone'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$date_in = $_POST['date_in'];
$date_out = $_POST['date_out'];
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', TRUE);
$conn->connect();
/*
SELECT date_overlap(date_in, date_out, '2016-01-12', '2016-01-13') FROM orders WHERE bed_index=1 AND room_id=328
*/
// check avalability
$check_availability = "SELECT 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);
$line = $conn->fetch_array();
if ($line['date_overlap'] == 1) {
    echo 'dates are not available';
    http_response_code(409);
    exit;
}
$get_guest = "SELECT id FROM guests WHERE first_name='{$first_name}' AND last_name='{$last_name}' AND telephone = '{$telephone}'";
$conn->run_query($get_guest);
Beispiel #17
0
<?php

require_once "../app-config.php";
include_once ABSPATH . "/php/CDBConn.php";
include_once ABSPATH . "/php/hostconfig.php";
$send_to = $_GET["email"];
if ($send_to == "") {
    echo "Email is empty. nothing to do<br>";
    http_response_code(422);
    exit(1);
}
$conn = new CDBConn($jet_ip, $db_name, $db_user, "qwerty123", FALSE);
$conn->connect();
$conn->run_select("SELECT * FROM users WHERE login='******'");
if ($conn->affected_rows() > 0) {
    echo "Following email '{$send_to}' is already used or activation requested. Please, select another email, if appropriate.<br>";
    http_response_code(422);
    exit(1);
} else {
    $subject = "JetPMS.com Registration Request";
    $message = "Dear customer, <br><br><br>We are glad to inform that you have almost done with the registration at JetPMS.<br/> Please, follow further simple instruction and be ready for evaluating our product.<br>";
    /*$message .= "So far, you have requested JetPMS for:<br>";
    
          $message .= "Beds <b>".$_POST["bedscount"] . "</b><br/>";
          $message .= "Country <b>".$_POST["country"]."</b><br/>";
          $message .= "Total price: <b>".$_POST["b_price"]."$/month</b><br>";
          */
    $message .= "Please, click to this activation link: ";
    $reg_token = bin2hex(openssl_random_pseudo_bytes(16));
    $activation_link = "http://" . $_SERVER["HTTP_HOST"] . "/signup/activateAccount.php?email=" . $send_to . "&reg_token=" . $reg_token;
    $href_tag = "<a href=" . $activation_link . ">{$activation_link}</a>";