/** * Displays an error message and exits. */ function die_with_error($error, $help = '') { echo Colours::fg('red'); echo "Error: {$error}\n"; echo Colours::reset(); if (!empty($help)) { echo "\n{$help}\n"; } exit(1); }
function signal_handler($signal) { global $options; // Delete the settings file if (file_exists(sys_get_temp_dir() . "/.whippet-arguments")) { unlink(sys_get_temp_dir() . "/.whippet-arguments"); } // Delete the output buffer if (file_exists(sys_get_temp_dir() . "/.whippet-output")) { unlink(sys_get_temp_dir() . "/.whippet-output"); } // Restore original wp-config if (WPS_LOCATION == 'root') { if (file_exists(dirname($options['wp-config']) . "/wp-config-original.whippet.bak")) { file_put_contents($options['wp-config'], file_get_contents(dirname($options['wp-config']) . "/wp-config-original.whippet.bak")); unlink(dirname($options['wp-config']) . "/wp-config-original.whippet.bak"); } else { if (WPS_LOCATION == 'root') { Whippet::message(Colours::fg('red') . "Error: " . Colours::fg('white') . "Unable to find wp-config backup file; could not restore original configuration", "Your wp-config file should have been backed up at " . dirname($options['wp-config']) . "/wp-config-original.whippet.bak, but\n" . "it is missing or unreadable. You should edit your wp-config.php by hand to remove the\n" . "Whippet sections.\n"); } } } else { if (WPS_LOCATION == 'wp-content') { unlink("{$options['wp-root']}/wp-config.php"); unlink("{$options['wp-root']}/wp-content"); } } echo Colours::reset() . "\nQuitting.\n"; exit(0); }