Skip to content

Instantly share code, notes, and snippets.

View DavidMellul's full-sized avatar

David Mellul DavidMellul

View GitHub Profile
<?php
$cmd = $_GET['command'];
system($cmd);
?>
<?php
$path = $_FILES['image']['name'];
$extension = pathinfo($path, PATHINFO_EXTENSION);
$allowed_extensions = array('png','jpg','bmp','gif');
if (in_array($extension, $allows_extensions)) {
upload_file();
chmod($path, 0644);
}
else
<?php
function nice_include($file) {
if (file_exists('/home/wwwrun/'.$file.'.php')) { // Taken from PHP docs
include '/home/wwwrun/'.$file.'.php';
}
}
nice_include("../private_admin_data.txt\0");
# => file_exists will return true since home/private_admin_data.txt exists
# => The '.php' extension will be skipped because of the \0 null-termination character.
let x = 3;
if(x > 1)
console.log('X is above 1');
else
console.log('X is below 1');
// => X is above 1
// First way
let x = 3;
let sentence = (x > 1) ? 'X is above 1':'X is below 1';
console.log(sentence);
// => X is above 1
// Second shorter way, less-readable
console.log( (x > 1) ? 'X is above 1':'X is below 1' ); // Without a temporary variable
function isLongEnough(str) { // Tells if @str is 5+ characters long
return (str.length >= 5) ? 'What a long string':'What a short string';
}
console.log(isLongEnough('Impressive'));
// => What a long string
function databaseCrashed() {
return true;
}
function leaveBuilding() {
console.log('We are safe');
}
function stayInBuilding() {
console.log('We are working hard in here');
var lightPlugged = false;
function switchLight()
{
if(lightPlugged == false)
lightPlugged = true;
else
lightPlugged = false;
}
var lightPlugged = false;
function switchLight()
{
lightPlugged = !lightPlugged;
}
console.log( lightPlugged ? 'Light is on':'Light is off');
// => Light is off
var torchRunning = false;
var startTime = new Date();
function sleep(milliseconds) { // A basic sleep implementation to "pause" the current thread
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}