コード例 #1
0
/**
 * Criação de dispositivo
 */
function createDevice()
{
    global $log;
    $device = null;
    $app = Slim::getInstance();
    try {
        $input = json_decode($app->request()->getBody());
        $log->Debug(sprintf("api - createDevice - %s", print_r($input, true)));
        $device = getDevice($input);
    } catch (Exception $e) {
        badRequest($e, $log);
        return;
    }
    try {
        $deviceCreated = DeviceManager::insertDevice($device);
        if ($deviceCreated) {
            created("Dispositivo criado com sucesso.");
        } else {
            conflict("O dispositivo já está cadastrado", $log);
        }
    } catch (Exception $e) {
        internalServerError($e, $log);
    }
}
コード例 #2
0
ファイル: conflict.php プロジェクト: nehaljwani/SSAD
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return 1;
    //when confilct 0 and not confilct 1
}
$ar1 = array(4 => 1);
$ar2 = array(5 => 2);
$ar1['evenStartDate'] = '1999-10-11';
$ar1['evenStartTime'] = '08:21';
$ar1['evenEndDate'] = '1999-10-15';
$ar1['evenEndTime'] = '08:28';
$ar2['evenStartDate'] = '1999-11-10';
$ar2['evenStartTime'] = '08:23';
$ar2['evenEndDate'] = '1999-11-14';
$ar2['evenEndTime'] = '08:30';
$t1 = 'evenStartTime';
$t2 = 'evenEndTime';
$d1 = 'evenStartDate';
$d2 = 'evenEndDate';
$result = conflict($ar2, $ar1);
if ($ar1[$t1] <= $ar2[$t1]) {
    echo "kapiliii{$result}</br>";
}
コード例 #3
0
ファイル: web.php プロジェクト: arteam/orders-system
    $customerSessionId = $request->getCookieParams()["cst_session_id"];
    $customer = getCustomer($customerSessionId);
    if (!isset($customer)) {
        logger($this)->addWarning('No contractor found by session id', array('cst_session_id' => $customerSessionId, 'uri' => $request->getUri()->getPath()));
        return forbidden($response);
    }
    $bid = json_decode($request->getBody());
    list($product, $amount, $price) = parseBid($bid);
    if (!isset($product)) {
        logger($this)->addWarning('Wrong bid', getPath($request));
        return badRequest($response);
    }
    $customerId = $customer['id'];
    if ($price > $customer['amount']) {
        logger($this)->addWarning("Customer doesn't have enough funds to place the bid with price", array('customer_id' => $customerId, 'price' => $price));
        return conflict($response);
    }
    try {
        $bidId = insertBid($product, $amount, $price, $customerId);
        $response->getBody()->write("api/bids/{$bidId}");
        return $response->withStatus(201);
    } catch (PDOException $e) {
        return handleError($e, $response);
    }
});
// LOGOUT
$app->post('/api/logout', function (Request $request, Response $response) {
    return $response->withHeader('Set-Cookie', 'cnt_session_id=""; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT')->withAddedHeader('Set-Cookie', 'cst_session_id=""; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT');
});
$app->run();
/**