Skip to content

Commit

Permalink
hashed prax4 passwords and node is weird
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparkivistik committed Dec 11, 2017
1 parent ab3e06a commit 88f76f3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion prax4/src/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
<?php
if (isset($_REQUEST['username']) and isset($_REQUEST['password'])) {
$username = $_REQUEST['username'];
$password = escape($connection, $_REQUEST['password']);
$password = $_REQUEST['password'];
$password = hash('md5', $password);
$query = "SELECT * FROM 164347_users WHERE user_name = '$username' AND password = '$password'";
if (count(mysqli_fetch_array(mysqli_query($connection, $query)))) {
$_SESSION['username'] = $username;
Expand Down
2 changes: 1 addition & 1 deletion prax4/src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ function escape($db, $string) {
$string = mysqli_real_escape_string($db, $string);
$string = htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
return $string;
}
}
3 changes: 2 additions & 1 deletion prax4/src/signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ function validifyData($username, $db) {
if (isset($_REQUEST['username']) and isset($_REQUEST['password']) and isset($_REQUEST['fullname']) and isset($_REQUEST['email'])) {
$username = escape($connection, $_REQUEST['username']);
$password = escape($connection, $_REQUEST['password']);
$hash = hash('md5', $password);
$fullname = escape($connection, $_REQUEST["fullname"]);
$email = escape($connection, $_REQUEST["email"]);
if (validifyData($username, $connection)) {
$sql = "INSERT INTO 164347_users VALUES ('$username', '$password', '$fullname', '$email')";
$sql = "INSERT INTO 164347_users VALUES ('$username', '$hash', '$fullname', '$email')";
if ($connection->query($sql) === true) {
$message = "Success!";
echo "<script type='text/javascript'>alert('$message');</script>";
Expand Down
8 changes: 7 additions & 1 deletion prax5/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
function move(pick) {



function changeScore(win, lose) {
var score = $('$score').text();
win = win + parseInt(score.substr(0, score.indexOf('-')));
lose = lose + parseInt(score.substr(0, score.indexOf('-') + 1));
$('score').text(win + "-" + lose);
}
5 changes: 4 additions & 1 deletion prax5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>rock papa scisas</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="stylesheet.css">
<link rel="stylesheet" href="/stylesheet.css">
<link rel="stylesheet" href="https://bootswatch.com/4/cosmo/bootstrap.min.css">
<script src="app.js"></script>
</head>
Expand All @@ -21,6 +21,9 @@ <h1 class="centered-content">
<a id="playerrock"><img width="150" height="150" src="rock.png" alt="kivi"></a>
<a id="playerpaper"><img width="150" height="150" src="paper.jpg" alt="paber"></a>
<a id="playerscissors"><img width="150" height="150" src="scissors.jpg" alt="käärid"></a>

<h1 class="centered-content">scores</h1>
<div class="score" id="score"><h3>0-0</h3></div>
</div>
</body>
</html>
File renamed without changes.

0 comments on commit 88f76f3

Please sign in to comment.