Example #1
0
File: login.php Project: ekudel/vkt
?>
"/>

          <div class="error-placeholder"></div>
        </div>
      </div>
      <div class="field">
        <label for="register-password"><?php 
echo msg('password');
?>
:</label>

        <div>
          <input id="register-password" class="fill" name="password" type="password" autocomplete="off"
                 maxlength="<?php 
echo getCommonConstant('user.name.max.length');
?>
"/>

          <div class="error-placeholder"></div>
        </div>
      </div>
      <div class="field">
        <label for="register-repeat-password"><?php 
echo msg('repeat.password');
?>
:</label>

        <div>
          <!--suppress HtmlFormInputWithoutLabel -->
          <!--workaround of ignoring autocomplete="off" by Chrome-->
Example #2
0
if (is_null($userId)) {
    notAuthErrorResponse();
    return;
}
$description = trim(getIfExists($_POST, 'description'));
if ($description == '') {
    validationErrorResponse(msg('no.description'));
    return;
}
$descriptionMaxLength = getCommonConstant('description.max.length');
if (mb_strlen($description) > $descriptionMaxLength) {
    validationErrorResponse(msg('description.length.error', $descriptionMaxLength));
    return;
}
$price = floatval(getIfExists($_POST, 'price'));
if ($price < 1) {
    validationErrorResponse(msg('min.price.error') . ' 1 ' . msg('currency'));
    return;
}
$maxPrice = getCommonConstant('order.max.price');
if ($price > $maxPrice) {
    validationErrorResponse(msg('max.price.error') . ' ' . $maxPrice . ' ' . msg('currency'));
    return;
}
$orderFromDb = \storage\addOrder($userId, $description, $price);
if (is_null($orderFromDb)) {
    internalErrorResponse();
    return;
}
$order = ['order_id' => getCompositeOrderId($orderFromDb), 'customer_id' => $orderFromDb['customer_id'], 'description' => $orderFromDb['description'], 'price' => number_format($orderFromDb['price'], 2), 'time' => $orderFromDb['time']];
echo jsonEncode(['order' => $order]);
Example #3
0
<div class="home-content customer">
  <?php 
include 'home_header.php';
?>
  <script type="text/javascript" src="js/home_customer.js"></script>
  <div>
    <div class="hidden">
      <form id="new-order-form" action="#" method="POST" class="new-order-form">
        <div class="field">
          <label for="new-order-description"><?php 
echo msg('description');
?>
:</label>
          <textarea id="new-order-description" class="fill" name="description" rows="7"
                    maxlength="<?php 
echo getCommonConstant('description.max.length');
?>
"></textarea>

          <div class="error-placeholder"></div>
        </div>
        <div class="field">
          <label for="new-order-price"><?php 
echo msg('price');
?>
 (<?php 
echo msg('currency');
?>
):</label>
          <input id="new-order-price" class="fill" type="text" name="price" autocomplete="off"/>
Example #4
0
$userNameMaxLength = getCommonConstant('user.name.max.length');
if (mb_strlen($userName) > $userNameMaxLength) {
    validationErrorResponse(msg('user.name.length.error', $userNameMaxLength), 'user-name');
    return;
}
$userName = mb_strtolower($userName);
if (!preg_match('/^\\w+$/', $userName)) {
    validationErrorResponse(msg('invalid.char.in.username.error'), 'user-name');
    return;
}
if (!is_string($password) || mb_strlen($password) == 0) {
    validationErrorResponse(msg('no.password.error'), 'password');
    return;
}
$passwordMinLength = getCommonConstant('password.min.length');
$passwordMaxLength = getCommonConstant('password.max.length');
if (mb_strlen($password) < $passwordMinLength || mb_strlen($password) > $passwordMaxLength) {
    validationErrorResponse(msg('password.length.error', $passwordMinLength, $passwordMaxLength), 'password');
    return;
}
if ($repeatPassword !== $password) {
    validationErrorResponse(msg('passwords.matching.error'), 'repeat-password');
    return;
}
$intRole = intval($role);
if ($intRole != $role || $intRole < 0 || $intRole > 1) {
    validationErrorResponse(msg('invalid.value'), 'role');
    return;
}
$userId = \storage\getUserIdByName($userName);
if (is_null($userId)) {