Пример #1
0
$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) {
            $guest_row = $conn->fetch_array();
            $order_info->first_name = $guest_row['first_name'];
            $order_info->last_name = $guest_row['last_name'];
            $order_info->telephone = $guest_row['telephone'];
        } else {
            $order_info->first_name = 'Name';
            $order_info->last_name = 'Surname';
            $order_info->telephone = '';
        }
        echo json_encode($order_info);
        // Not available
        http_response_code(200);
        exit;
    }
}
Пример #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;
                }
Пример #3
0
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;
    $cur_room_type = $rooms[$i]->type;
Пример #4
0
/*
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);
$guest_id = 0;
if ($conn->affected_rows() == 0) {
    $insert_guest = "INSERT INTO guests(first_name, last_name, telephone) VALUES('{$first_name}','{$last_name}','{$telephone}') RETURNING id";
    $conn->run_query($insert_guest);
    $arr = $conn->fetch_array();
    $guest_id = $arr['id'];
    echo "New guest id = " . $guest_id . "<br>";
} else {
    if ($conn->affected_rows() == 1) {
        $arr = $conn->fetch_array();
        $guest_id = $arr['id'];
        echo 'Old guest id = ' . $guest_id . "<br>";
    } else {
        echo "Please, contact support";
        http_response_code(409);
        exit;
    }
Пример #5
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";
}
Пример #6
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>";