예제 #1
0
 public function assignKey($userId, $keyId)
 {
     if (!($uidKey = Db::querySingleOne('SELECT `uid_key` FROM `lock_attempts` WHERE `id` = ?', [$keyId]))) {
         return ['s' => 'error', 'cs' => 'Nepovedlo se vybrat správný záznam přístupu', 'en' => 'Sorry, we were not able to take right access record'];
     }
     if (Db::queryModify('UPDATE `users` SET `uid_key` = ? WHERE id_user = ?', [$uidKey, $userId])) {
         return ['s' => 'success', 'cs' => 'Povedlo se přidat právo vstupu', 'en' => 'Access was successfully assigned'];
     } else {
         return ['s' => 'error', 'cs' => 'Nepovedlo se přidat práva ke vstupu k uživateli', 'en' => 'Access was not assigned to a member'];
     }
 }
예제 #2
0
 public function checkInputs($newAdminId, $newAdminPlacesId)
 {
     if (!Db::querySingleOne('SELECT id_user FROM users WHERE id_user = ?', [$newAdminId])) {
         return ['s' => 'error', 'cs' => 'Uživatel nenalezen', 'en' => 'User not find'];
     }
     foreach ($newAdminPlacesId as $a) {
         if (!Db::querySingleOne('SELECT id FROM places WHERE id = ?', [$a])) {
             return ['s' => 'error', 'cs' => 'Place id ' . $a . ' nenalezeno', 'en' => 'Place with id ' . $a . ' is not find'];
         }
     }
     return ['s' => 'success'];
 }
예제 #3
0
    public function isKeyValid($key, $lockName)
    {
        $result = Db::querySingleOne('SELECT `uid_key` FROM `users`
			JOIN `tariffs` ON `tariffs`.`id_tariff` = `users`.`user_tariff`
			JOIN `places` ON `places`.`id` = `tariffs`.`place_id`
			JOIN `locks` ON `locks`.`id_place` = `places`.`id`
			WHERE `uid_key` = ? && `lock_name` = ?', [$key, $lockName]);
        if ($result) {
            return true;
        } else {
            return false;
        }
    }
예제 #4
0
 private function getPaymentFlag($userId)
 {
     $r = Db::querySingleOne('SELECT `status` FROM `payments`
                              WHERE `id_payer` = ? ORDER BY ?, ?, `status` DESC', [$userId, 'received', 'confirmed']);
     if ($r == 'received' || $r == 'confirmed') {
         return 'success';
     }
     if (empty($r)) {
         return 'unknown';
     } else {
         return 'error';
     }
 }
예제 #5
0
파일: Csrf.php 프로젝트: vane00ssa/TMS2
 public static function validateCsrfRequest($returnedToken)
 {
     $storedToken = Db::querySingleOne('SELECT `token` FROM `csrf`
                                        WHERE `user_id` = ? AND `active` = 1
                                        ORDER BY `id` DESC', [$_SESSION['id_user']]);
     //unactive all entries
     Db::queryModify('UPDATE `csrf` SET `active` = 0 WHERE `user_id` = ? AND `active` = 1', [$_SESSION['id_user']]);
     //add referer uri into hash to get stored value
     $returnedRefererToken = hash('sha512', $_SERVER['HTTP_REFERER'] . $returnedToken, false);
     if ($storedToken == $returnedRefererToken) {
         return true;
     } else {
         self::newTicket('warning', $_SESSION['id_user'], 'Possible CSRF attack (returned false on stored token ' . $storedToken);
         return false;
     }
 }
예제 #6
0
 public function isLinkValid($validationLink)
 {
     if (empty($validationLink)) {
         return ['error', 'Aktivační klíč je prázdný'];
     }
     $link = Db::querySingleOne('SELECT `validation_string` FROM `restart_password`
                                 JOIN `users` ON `users`.`email` = `restart_password`.`email`
                                 WHERE `validation_string` = ?', [$validationLink]);
     //link is not in database
     if ($link[0] == null) {
         return ['s' => 'error', 'cs' => 'Link pro validaci není v databázi', 'en' => 'Link for validation is not in our database'];
     }
     $timeOfAttempt = date("Y-m-d H:i:s", time() - CHANGE_PASS_TIME_VALIDITY);
     $restart = Db::queryOne('SELECT `timestamp` FROM `restart_password`
                              WHERE `validation_string` = ? && `active` = ?', [$validationLink, 1]);
     if ($restart[0] == null) {
         return ['s' => 'error', 'cs' => 'Link už byl použit. <a href"' . ROOT . '/cs/GetLinkForNewPassword">Získat nový link pro změnu hesla?</a>', 'en' => 'Link is already used. <a href"' . ROOT . '/en/GetLinkForNewPassword">Get a new restart password link?</a>'];
     }
     if ($restart['timestamp'] < $timeOfAttempt) {
         return ['s' => 'error', 'cs' => 'Vypršela časová platnost linku. <a href"' . ROOT . '/cs/GetLinkForNewPassword">Získat nový link pro změnu hesla?</a>', 'en' => 'Link is timed up. <a href"' . ROOT . '/en/GetLinkForNewPassword">Get a new restart password link?</a>'];
     }
     return ['success'];
 }
예제 #7
0
    public function getStatusOfPaymentFromExtraId($extraId)
    {
        return Db::querySingleOne('SELECT `status` FROM `payments`
 			JOIN `extras` ON `extras`.`payment_id` = `payments`.`id_payment`
			WHERE `id_extra` = ?', [$extraId]);
    }
예제 #8
0
    public function getPaymentStatus($paymentId)
    {
        return Db::querySingleOne('SELECT `status` FROM `payments` 
			WHERE id_payment = ?', [$paymentId]);
    }
예제 #9
0
 public function getUserIdFromInvoiceId($invoiceId)
 {
     return Db::querySingleOne('SELECT `id_payer` FROM `payments` WHERE `invoice_fakturoid_id` = ?', [$invoiceId]);
 }
예제 #10
0
 private function getPaymentIdFromFakturoidInvoiceId($fakturoidInvoiceId)
 {
     return Db::querySingleOne('SELECT `id_payment` FROM `payments` WHERE `invoice_fakturoid_id` = ?', [$fakturoidInvoiceId]);
 }
예제 #11
0
파일: Payments.php 프로젝트: vane00ssa/TMS2
 public function makeNewPayments($user, $tariff, $lang)
 {
     $active = $user['active'];
     if ($active) {
         $new = false;
         $userId = $user['id_user'];
         $dbStartDate = $user['invoicing_start_date'];
         $currentDate = date('Y-m-d');
         $startOfLastGeneratedMonth = Db::querySingleOne('
             SELECT `payment_first_date` FROM `payments`
             WHERE `id_payer` = ?
             ORDER BY `payment_first_date` DESC', [$userId]);
         if (empty($startOfLastGeneratedMonth)) {
             //add beginning for new user
             $startDate = $dbStartDate;
         } else {
             //or deside when if use last day of previous payment or newly begin set
             if (strtotime($startOfLastGeneratedMonth) >= strtotime($dbStartDate)) {
                 $startDate = date('Y-m-d', strtotime($startOfLastGeneratedMonth . ' +1 month'));
             } else {
                 $startDate = $dbStartDate;
             }
         }
         //and add following invoices till today
         while (strtotime($startDate) <= strtotime($currentDate)) {
             $this->createPayment($user, $tariff, $startDate, $lang);
             $startDate = date('Y-m-d', strtotime($startDate . ' +1 month'));
             $new = true;
         }
         if ($new == true) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
예제 #12
0
 public function getBitcoinpayId($paymentId)
 {
     return Db::querySingleOne('SELECT `bitcoinpay_payment_id` FROM `payments`
         WHERE `id_payment` = ?', [$paymentId]);
 }
예제 #13
0
파일: Model.php 프로젝트: vane00ssa/TMS2
 public function getTariffName($tariffId, $lang)
 {
     if ($lang == 'cs') {
         return Db::querySingleOne('SELECT `tariffCZE` FROM `tariffs`
         WHERE `id_tariff` = ?', [$tariffId]);
     }
     if ($lang == 'en') {
         return Db::querySingleOne('SELECT `tariffENG` FROM `tariffs`
         WHERE `id_tariff` = ?', [$tariffId]);
     }
     return false;
 }
예제 #14
0
 public function getFakturoidIdFromUserId($userId)
 {
     return Db::querySingleOne('SELECT `fakturoid_id` FROM `users` WHERE `id_user` = ?', [$userId]);
 }