This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head></head> | |
<body> | |
<form class="form" id="loginForm" action="./login.php" method="POST"> | |
<div class="form-group"> | |
<label for="usernameInput"> Username </label> | |
<input type="text" id="usernameInput" name="username" required/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$realUser = "user"; | |
$realPass = "1234"; | |
if( isset($_POST["username"]) && isset($_POST["pass"])) { | |
// Do I have the username and passwords set? | |
// If yes, check their validity. | |
if( $_POST["username"] === $realUser && $_POST["pass"] === $realPass ) { | |
// Credentials are correct so let's redirect our user to the home page |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function createHeader() { | |
return ' | |
<header> | |
<h1> | |
<span class="emoji">🚀</span> | |
TW Checklist | |
<span class="emoji">🚀</span> | |
</h1> | |
</header> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let actionsQueue = []; | |
document.addEventListener('keydown', function (e) { | |
if(37 <= e.keyCode && e.keyCode <= 40) { | |
//Store only arrow keys | |
actionsQueue.push(e.keyCode); | |
} | |
}); | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let enemyList = []; | |
paint(); | |
function paint() { | |
//This function gets called every frame | |
if(checkGameOver()) { | |
alert('Game over'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
paint(); | |
function paint() { | |
//This function gets called every frame | |
window.requestAnimationFrame(paint); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function PiggyBank(){ | |
let money = []; | |
return { | |
store: function(index, value){ | |
money[index] = value; | |
}, | |
push: function(value){ | |
money[money.length] = value; // with no function call, no vulnerability | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var money; | |
sharedPiggyBank.store('push', function(value) { | |
// YES, we can add properties to arrays! | |
this[this.length] = value; | |
money = this; | |
}); | |
sharedPiggyBank.push('$22'); // resolves to the push method we added and not to Array.prototype.push |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var money; | |
Array.prototype.push = function(value){ | |
this[this.length] = value; //we keep the intended push functionality so that mum doesn't notice we hacked the PiggyBank | |
money = this; | |
} | |
sharedPiggyBank.push('$22'); | |
sharedPiggyBank.push('$33'); // money = ['$22', '$33']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function PiggyBank(){ | |
let money = []; | |
return { | |
store: function(index, value){ | |
money[index] = value; | |
}, | |
push: function(value){ | |
money.push(value); | |
} | |
} |