function changeQueryIntoJSON($nameJSON, $structure, $connection, $sql, $params, $operation, $pdo) { $result = generalQuery($connection, $sql, $params, $operation, $pdo); $restructured = $operation === 0 && rightResult($result) ? restructureArray($result, $structure) : $result; return changeArrayIntoJSON($nameJSON, $restructured); }
function restructureQuery($structure, $connection, $sql, $params, $operation, $pdo) { $result = generalQuery($connection, $sql, $params, $operation, $pdo); $restructured = $operation === 0 && rightResult($result) ? restructureArray($result, $structure) : $result; return $restructured; }
function checkbrute($userId) { //Get timestamp of current time $now = time(); //All login attempts are counted from the past 2 hours. $validAttempts = $now - 2 * 60 * 60; $sql = "SELECT ATT_Time\r\n FROM camAttempts\r\n WHERE ATT_USR_Id = :usr_id\r\n AND ATT_Time > :valid_attempts"; $structure = array('password' => 'DIS_Password'); $params = array('usr_id' => $userId, 'valid_attempts' => $validAttempts); $result = generalQuery(getConnection(), $sql, $params, 0, PDO::FETCH_ASSOC); if (count($result)) { if (rightResult($result)) { //If there have been more than 5 failed logins if (count($result) > 5) { return true; } else { return false; } } else { //Could not create a prepared statement header("Location: ../error.php?err=Database error: cannot prepare statement"); exit; } } return false; }