示例#1
0
文件: viewbook.php 项目: resahT/Group
<?php

@session_start();
require_once 'Api.php';
$bookId = $_REQUEST['bookId'];
$api = new Api();
$errors = array();
$response = $api->getItem($bookId, 'book');
$userInfoResult = $api->getCurrentUserInfo();
//add a log of the item that is being viewed
if ($userInfoResult['result'] == 'SUCCESS') {
    $bUserid = $userInfoResult['data']['bUserid'];
    $viewedItemResult = $api->addItemsViewed($bookId, $bUserid);
}
//get recommended items
$recommendedItems = array();
if ($userInfoResult['result'] == 'SUCCESS') {
    $recommededItemsResult = $api->getRecommendedItems($bUserid, 'book', $bookId);
    if ($recommededItemsResult['result'] == 'SUCCESS') {
        $recommendedItems = $recommededItemsResult['data'];
    }
}
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
    if (isset($_REQUEST['buyNow']) && $_REQUEST['buyNow'] == 'buyNow') {
        $result = $api->getCurrentUserInfo();
        if ($result['result'] == 'SUCCESS') {
            $bUserid = $result['data']['bUserid'];
            $buyResult = $api->buyItem($bUserid, $bookId, 'book', $response['data']['askingPrice']);
            if ($buyResult['result'] == 'SUCCESS') {
                header("Location: listbooks.php?status=itemPurchased");
                die;
示例#2
0
    $viewedItemResult = $api->addItemsViewed($houseId, $bUserid);
}
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
    $result = $api->getCurrentUserInfo();
    if ($result['result'] == 'SUCCESS') {
        $newBidAmount = $_REQUEST['newBidAmount'];
        $bUserid = $result['data']['bUserid'];
        $response = $api->addBid($houseId, $bUserid, $newBidAmount);
    } else {
        $errors[] = 'Unable to add bid because you are not logged in.';
    }
} else {
    //nothing to do here
}
$houses = array();
$response = $api->getItem($houseId, 'house');
$bidResponse = $api->viewBidHistory(2, $houseId);
$maxBidResponse = $api->getMaxBidAmount($houseId);
$maxBidAmount = $maxBidResponse['data']['maxBidAmount'];
$house = $response['data'];
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <?php 
include 'htmlhead.php';
?>
    </head>
    <body>