Esempio n. 1
0
                     <span class="price">
                       <?php 
        //procedurizzare
        $range_id = get_post_meta($post->ID, 'type', true);
        $term = get_term($range_id[0], 'types');
        $checkin = isset($_GET['checkin']) ? $_GET['checkin'] : date('d/m/Y');
        $checkout = isset($_GET['checkout']) ? $_GET['checkout'] : date('d/m/Y');
        $people = isset($_GET['people']) ? $_GET['people'] : 2;
        $room_number = isset($_GET['room_number']) ? $_GET['room_number'] : 1;
        $people = $people > 2 ? $people / $room_number : $people;
        $allotment = isset($_GET['room']) ? $_GET['room'] : default_allotment($term->slug, $people);
        if (!is_wp_error($term)) {
            ?>
                          &euro; <?php 
            echo check_price($checkin, $checkout, $allotment, $room_number);
        }
        ?>
                     </span>

                   </div>
                 </header>
                 <div class="listing-facitilities">
                   <div class="row">
                     <div class="col-md-3 col-sm-12">
                       <ul class="facilities-list custom-list">
                        <?php 
        $amenities = wp_get_object_terms($post->ID, 'amenities');
        if (!empty($amenities)) {
            $counter = 1;
            if (!is_wp_error($amenities)) {
									<?php 
}
wp_reset_query();
?>

				</select>
			</span>

			<?php 
if ($_GET['checkin']) {
    ?>
				<h5><?php 
    _e('Price', 'bookingwp');
    ?>
 <span> &euro; <?php 
    echo check_price($_GET['checkin'], $_GET['checkout'], default_allotment('superior', $people), 1);
    ?>
</span></h5>
			<?php 
}
?>
			<button class="btn btn-transparent-gray" id="book-single-button" data-toggle="modal" data-target="#myModal"><?php 
_e('Book now', 'bookingwp');
?>
</button>
		</form>


	</aside>
</div>
Esempio n. 3
0
 // post back to PayPal system to validate
 $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
 $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
 $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
 $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
 if (!$fp) {
     // HTTP ERROR
 } else {
     fputs($fp, $header . $req);
     while (!feof($fp)) {
         $res = fgets($fp, 1024);
         if (strcmp($res, "VERIFIED") == 0) {
             @mail("*****@*****.**", "PAYPAL DEBUGGING", "Verified Response<br />data = <pre>" . print_r($post, true) . "</pre>");
             // Validate payment (Check unique txnid & correct price)
             $valid_txnid = check_txnid($data['txn_id']);
             $valid_price = check_price($data['payment_amount'], $data['item_number']);
             // PAYMENT VALIDATED & VERIFIED!
             if ($valid_txnid && $valid_price) {
                 $orderid = updatePayments($data);
                 if ($orderid) {
                     // Payment has been made & successfully inserted into the Database
                 } else {
                     // Error inserting into DB
                     // E-mail admin or alert user
                 }
             } else {
                 // Payment made but data has been changed
                 // E-mail admin or alert user
             }
         } else {
             if (strcmp($res, "INVALID") == 0) {
Esempio n. 4
0
function buy_package($user, $package_id, $total = 1)
{
    if (empty($user) || empty($user["uid"])) {
        return error(-1, "用户不存在");
    }
    if ($total <= 0) {
        return error(-1, "购买数必须大于1");
    }
    if (empty($user["credit2"]) || doubleval($user["credit2"]) < 0) {
        return error(-1, "用户余额为0无法购买套餐.");
    }
    $group = kim_get_uni_group($package_id);
    if (empty($group)) {
        return error(-1, "模块不存在.");
    }
    $price = doubleval($group["price"]);
    if (intval($user['groupid']) > 0) {
        list($price, $discount) = check_price($price, intval($user['groupid']));
    }
    if (doubleval($user["credit2"]) < $price * $total) {
        return error(-1, "用户余额不足.");
    }
    $st = get_settings();
    $day = 30;
    if (intval($st[package_day]) > 0) {
        $day = intval($st[package_day]);
    }
    $package_price = $price * $total;
    $package_time = $total * $day * 24 * 60 * 60;
    load()->model("account");
    $account = uni_fetch();
    if (empty($account)) {
        return error(-1, "公众号不存在.");
    }
    $settings = uni_setting($account["uniacid"], array('groupdata'));
    $groupData = $settings['groupdata'] ? $settings['groupdata'] : array("endtime" => TIMESTAMP);
    $package_endTime = $package_time;
    if ($groupData["endtime"] - TIMESTAMP > 0) {
        $package_endTime = $groupData["endtime"] - TIMESTAMP + $package_time;
    }
    $old_package = kim_get_uni_group($account["groupid"]);
    try {
        pdo_begin();
        $endtime = date("Y-m-d", TIMESTAMP + $package_endTime);
        load()->model('user');
        $record = array();
        $record['uid'] = $user["uid"];
        $record['endtime'] = $endtime;
        user_update($record);
        $order_record = array("uniacid" => $account["uniacid"], "uid" => $user["uid"], "package" => $package_id, "buy_time" => TIMESTAMP, "expiration_time" => TIMESTAMP + $package_endTime);
        pdo_insert("users_packages", $order_record);
        $record_id = pdo_insertid();
        if ($record_id <= 0) {
            throw new Exception("保存记录失败");
        }
        //VIP时间同步
        $groupData["endtime"] = $groupData["endtime"] < TIMESTAMP ? TIMESTAMP : $groupData["endtime"];
        $old_over_time = date("Y-m-d", $groupData["endtime"]);
        $new_over_time = date("Y-m-d", TIMESTAMP + $package_endTime);
        $log = array(0, sprintf("自动续费: %s 套餐续费,续费前:%s 到期; 续费后:%s 到期", $group["name"], $old_over_time, $new_over_time));
        if (intval($account["groupid"]) != intval($package_id)) {
            $surplus_price = $old_package["price"] * round(($groupData["endtime"] - TIMESTAMP) / 86400);
            $surplus_price = $surplus_price / $day;
            $surplus_time = round($surplus_price / $group["price"]) * $day;
            $package_endTime = $surplus_time * 24 * 60 * 60 + $package_time;
            $new_over_time = date("Y-m-d", TIMESTAMP + $package_endTime);
            $log_text = sprintf("套餐变更: &lt;p&gt;A、原套餐: %s , %s 到期&lt;/p&gt;&lt;p&gt;B、变更后: %s , %s 到期.&lt;/p&gt;", $old_package["name"], $old_over_time, $group["name"], $new_over_time);
            $log = array(0, $log_text);
            if (pdo_update('uni_account', array('groupid' => $package_id), array('uniacid' => $account["uniacid"])) <= 0) {
                throw new Exception("更新套餐失败.");
            }
        }
        $new_groupdata = array('groupdata' => iserializer(array('isexpire' => 1, 'endtime' => TIMESTAMP + $package_endTime, 'oldgroupid' => $old_package['id'], 'is_auto' => 1)));
        if (pdo_update('uni_settings', $new_groupdata, array('uniacid' => $account["uniacid"])) <= 0) {
            throw new Exception("更新套餐失败!");
        }
        $result = user_credits_update($user["uid"], "credit2", -$package_price, $log);
        if (is_error($result)) {
            throw new Exception($result["message"]);
        }
        $_W['account']['groupid'] = $account["uniacid"];
        load()->model('module');
        module_build_privileges();
        pdo_update("users_packages", array("record_id" => $record_id, "status" => 1), array("id" => $record_id));
        pdo_commit();
        return true;
    } catch (Exception $e) {
        pdo_rollback();
        return error(-1, $e->getMessage());
    }
    return error(-1, "错误操作.");
}
Esempio n. 5
0
        exit;
    }
    // Check transaction ID
    $transaction_id = $listener->getData('txn_id');
    if (!check_transaction($transaction_id)) {
        throw new Exception('Unable to process IPN for transaction ID: ' . $transaction_id);
    }
    // Check receiver email
    $receiver_email = $listener->getData('receiver_email');
    if (!check_receiver_email($receiver_email)) {
        throw new Exception('Unable to process IPN for receiver email: ' . $receiver_email);
    }
    // Check price and currency
    $payment_total = $listener->getData('mc_gross');
    $payment_currency = $listener->getData('mc_currency');
    if (!check_price($payment_total, $payment_currency)) {
        throw new Exception('Unable to process IPN due to issues with price/currency');
    }
    // If we got this far, then its ok to fulfil the order
    $item_name = $listener->getData('item_name');
    $item_number = $listener->getData('item_number');
    $payer_name = trim($listener->getData('first_name') . ' ' . $listener->getData('last_name'));
    $payer_email = $listener->getData('payer_email');
    process_order($transaction_id, $item_name, $item_number, $payer_name, $payer_email);
    // Tell PayPal that we have successfully processing IPN.
    header('HTTP/1.1 200 OK');
} catch (Exception $e) {
    // Tell PayPal that we had problems processing IPN.
    header('HTTP/1.1 500 Internal Server Error');
    // Report error message.
    $message = 'IPN error: ' . (string) $e;
Esempio n. 6
0
function home_booking()
{
    if (!$_POST) {
        if (!defined("PHP_EOL")) {
            define("PHP_EOL", "\r\n");
        }
    }
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $checkin = $_POST['checkin'];
    $checkout = $_POST['checkout'];
    $room_id = $_POST['room_id'];
    $room = $_POST['room'];
    $adults = $_POST['adults'];
    $children = $_POST['children'];
    $room_number = $_POST['room_number'];
    $message = $_POST['message'];
    $lang = $_POST['current_lang'];
    //if availability
    if (!is_available($room_id, $checkin, $checkout)) {
        echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>La camera richiesta risulta occupata nelle date richieste!</div>';
        exit;
    }
    if (trim($email) == '') {
        echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Attention! Please enter a valid email address.</div>';
        exit;
    } else {
        if (trim($room) == '') {
            echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Attention! Please enter what kind of room.</div>';
            exit;
        } else {
            if (trim($checkin) == '') {
                echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Attention! Please enter your check-in date.</div>';
                exit;
            } else {
                if (trim($checkout) == '') {
                    echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Attention! Please enter your check-out date.</div>';
                    exit;
                } else {
                    if (!isEmail($email)) {
                        echo '<div class="alert alert-danger alert-dismissable">
	  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Attention! You have enter an invalid e-mail address, try again.</div>';
                        exit;
                    }
                }
            }
        }
    }
    if (get_magic_quotes_gpc()) {
        $comments = stripslashes($comments);
    }
    //titolo stanza composto da nome hotel + stanza x evitare duplicati...
    $main_name = 'booking ';
    $camera = get_the_title($room);
    // ADD THE FORM INPUT TO $new_post ARRAY
    $new_booking = array('post_title' => $main_name . ' - ' . $camera, 'post_type' => 'bookings', 'post_status' => 'waiting');
    //SAVE THE POST
    $bid = wp_insert_post($new_booking);
    $price = check_price($checkin, $checkout, $room, $room_number);
    $token = uniqid();
    $request_page = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    $manager_url = get_bloginfo('siteurl') . '/reservations-system/?token=' . $token;
    update_post_meta($bid, 'name', $name);
    update_post_meta($bid, 'email', $email);
    update_post_meta($bid, 'phone', $phone);
    update_post_meta($bid, 'room', $room);
    update_post_meta($bid, 'room_id', $room_id);
    update_post_meta($bid, 'token', $token);
    update_post_meta($bid, 'manager_url', $manager_url);
    update_post_meta($bid, 'checkin', convert_date_to_timestamp($checkin));
    update_post_meta($bid, 'checkout', convert_date_to_timestamp($checkout));
    update_post_meta($bid, 'adults', $adults);
    update_post_meta($bid, 'children', $children);
    update_post_meta($bid, 'room_number', $room_number);
    update_post_meta($bid, 'message', $message);
    update_post_meta($bid, 'lang', $lang);
    if ($price) {
        update_post_meta($bid, 'price', $price);
    }
    $room_type = get_the_title($room);
    //$address = "*****@*****.**";
    $address = mytheme_get_option('email');
    $from = mytheme_get_option('place_name') . ' <' . $address . '>';
    $email_bcc = get_bloginfo('admin_email');
    // Configuration option.
    $e_subject = 'Booking n # ' . $bid . ' da ' . $email;
    $e_body = "Richiesta di prenotazione da <b>: {$name} {$email} tel. {$phone}</b>\n\n\t\tRichiesta prenotazione per le seguenti date<br />\n\t\tCheckin: <b>: {$checkin} </b><br />\n\t\tCheck-out <b>: {$checkout} </b><br />\n\t\tmessaggio <b>: {$message} </b><br />\n\n\t\tLa richiesta &egrave; di n, <b>{$room_number}</b>  <b>{$room_type}</b> per <b>{$adults} Adulti</b> e <b>{$children} bambini</b>.<br />\n\t\tIl prezzo proposto dal sistema in base alle tue impostazioni &egrave; di &euro; <b>{$price}</b> .<br />\n\t\tRicevuta da: {$request_page}.<br />\n\t\tin lingua: {$lang}.<br />\n\t\t<hr />\n\t\t<a href='{$manager_url}'>Gestisci</a>" . PHP_EOL . PHP_EOL;
    $e_reply = "<br />You can contact the customer via email, {$email} or hit 'reply' in your email browser to make the reservation complete.";
    $msg = wordwrap($e_body . $e_reply, 70);
    $headers[] = "From: {$from}" . PHP_EOL;
    $headers[] = "Bcc: {$email_bcc}" . PHP_EOL;
    //if(mail($address, $e_subject, $msg, $headers)) {
    if (wp_mail($address, $e_subject, $e_body, $headers)) {
        //email to customer
        // Reset content-type to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578
        remove_filter('wp_mail_content_type', 'set_html_content_type');
        $price = check_price($checkin, $checkout, $room);
        // Email has sent successfully, echo a success page.
        //try to understand what kind of booking: instant on-request
        $booking_type = booking_get_option('booking_type');
        if ($booking_type == 'instant') {
            $confirmation_url = get_bloginfo('siteurl') . '/confirm-reservation?token=' . $token;
            //stop mostra prezzo per ora..
            echo '<div id="success_page" class="alert alert-warning"><h4><i class="fa fa-bolt"></i> ' . __('Secure instant booking', 'bookingwp') . '</h4></div>';
            echo '<h5>' . __('Price for your reservation is &euro;', 'bookingwp') . ' <b>' . $price . '</b></h5><br />';
            echo __('You can confirm now your reservation by clicking this link and leave your credit card as warranty or paying the entire fee of your booking with Paypal and instantly book the room!', 'bookingwp') . '<br /><hr />';
            echo '<a href="' . $confirmation_url . '" class="btn btn-success btn-block">Confirm reservation</a></p>';
        } else {
            echo '<div id="success_page" class="alert alert-success"><p>' . __('Your reservation has been submitted to us and well contact you as quickly as possible to complete your booking. Thank you', 'bookingwp') . '</p></div>';
        }
        exit;
    } else {
        echo 'ERROR!';
    }
}