Outils pour utilisateurs

Outils du site


php:i_m_feeling_lucky

Ceci est une ancienne révision du document !


Principe: ce script calcule le hash crc32 de l'adresse IP, convertit hex→dec, additionne au timestamp (-3 unités), hashe crc32, et regarde le dernier chiffre hexa.

Selon ce chiffre, le visiteur lit une situation donnée et est sensibilité sur le risque concerné. Ainsi, le visiteur peut s'imaginer confronté à la situation pour pouvoir mieux la prévenir.

imfeelinglucky.php
<?php
header('Content-type: text/plain');
?>
==============================
 Feeling lucky ? Let's see...
==============================
 
<?php
$iphash = hash('crc32', $_SERVER['REMOTE_ADDR']);
$data1 = substr(time(), 0, -3);
$data2 = hexdec($iphash);
$base = $data1+$data2;
$roll = substr(hash('crc32', $base), -1);
echo "Situation '$roll'\n\n";
if ($roll === '0') { echo "Your hard disk just headcrashed, disk surface is scratched, data cannot be recovered.\nWhen did you last backup all your data ?\n\n>Remember: backup regularly, backup often."; }
else if ($roll === '1') { echo "Nothing happens to your PC.\n>Take a deep breath."; }
else if ($roll === '2') { echo "Google, Microsoft, Yahoo, Facebook and Twitter just closed your accounts for copyright infringement, without appeal.\nDo you have separate email and social accounts ?\n\n>Never rely on a single company to manage your online life."; }
else if ($roll === '3') { echo "Some random Windows Genuine Advantage pops up, asking you to buy a license or see your PC locked down in 4 days.\n\n>You know what to do. -> GNU/Linux"; }
else if ($roll === '4') { echo "Nothing happens to your PC.\n>Take a deep breath."; }
else if ($roll === '5') { echo "Antivirus software says it has found and cleaned something. Viruses on your PC ?"; }
else if ($roll === '6') { echo "Linus Torvalds says \"fuck you\" to some company. "; }
else if ($roll === '7') { echo "BSoD (blue screen of death) or kernel panic.\n Did you save your work ?\n\n>Always check if autosave is activated while you work."; }
else if ($roll === '8') { echo "Power disruption.\n Did you save your work ?\n\n>Always check if autosave is activated while you work."; }
else if ($roll === '9') { echo "Nothing happens to your PC.\n>Take a deep breath."; }
else if ($roll === 'a') { echo "PC suddenly very slow.\n\n>Could you deal with it ?"; }
else if ($roll === 'b') { echo "A family member of yours asks you by mail your bank account number.\n\n>Do never send information like this. Your family member could have been infected by virus."; }
else if ($roll === 'c') { echo "Nothing happens to your PC.\n>Take a deep breath."; }
else if ($roll === 'd') { echo "You spill coffee on your keyboard, it's broken.\n\n>Always have a spare keyboard and mouse."; }
else if ($roll === 'e') { echo "You've been robbed, all your electronic stuff is gone.\n\n>Always have an external backup of your data, disk encryption and tracing software."; }
else if ($roll === 'f') { echo "Nothing happens to your PC.\n>Take a deep breath."; }
echo "\n\n\n\nCome back in ~16 minutes. If you dare.";
?>
php/i_m_feeling_lucky.1361302080.txt.gz · Dernière modification : 2013-07-13 16:50 (modification externe)