Ejemplo n.º 1
0
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");
    }
    // Delete the callback cache
    if (file_exists($options['cb-cache'])) {
        unlink($options['cb-cache']);
    }
    // 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");
        }
    }
    echo "\nQuitting.\n";
    exit(0);
}
Ejemplo n.º 2
0
<?php

require dirname(__FILE__) . "/colours.class.php";
require dirname(__FILE__) . "/helpers.php";
require dirname(__FILE__) . "/whippet.class.php";
$whippet = new Whippet();
// Run returns some code that needs to be executed at global scope
$code = $whippet->run();
eval($code);
// The code eval'd above might call die() or exit(), so we won't necessarily end up here.
// If you want to run something that executes when WordPress is finished, add a shutdown
// filter for it, or add your code to Whippet::wps_filter_shutdown
Ejemplo n.º 3
0
 /**
  * This function actually emits handled PHP errors. It's here instead of
  * in handle_php_error because we want a static version to be used from
  * the bootstrap script.
  */
 public static function emit_php_error($number, $error, $file, $line, $options = array('show-errors' => E_ALL))
 {
     if ($number != E_ERROR && !isset($options['show-wp-errors']) && Whippet::file_is_in_core($file, $options)) {
         return;
     }
     $error_type = array(E_ERROR => 'Fatal error', E_WARNING => 'Warning', E_PARSE => 'Parsing error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core error', E_CORE_WARNING => 'Core warning', E_COMPILE_ERROR => 'Compile error', E_COMPILE_WARNING => 'Compile warning', E_USER_ERROR => 'User error', E_USER_WARNING => 'User warning', E_USER_NOTICE => 'User notice', E_STRICT => 'Strict notice', E_RECOVERABLE_ERROR => 'Recoverable error', E_DEPRECATED => 'Deprecated', E_USER_DEPRECATED => 'User Deprecated');
     // If the error is unknown, pass it through directly
     if (empty($error_type[$number])) {
         $error_type[$number] = $number;
     }
     // Should we show this error?
     if (($number & $options['show-errors']) != $number) {
         return;
     }
     // Display the error
     Whippet::message(Colours::fg('bold_red') . $error_type[$number] . Colours::fg('red') . ": " . $error . Colours::fg('brown') . " in " . $file . " at line {$line}" . Colours::off());
     // Show a notification, if we've got libnotify
     if (!empty($options['libnotify']) && $number === E_ERROR) {
         $message = "{$error_type[$number]}: {$error} in {$file} at line {$line}";
         $message = str_replace("'", "\\'", $message);
         exec("{$options['libnotify']} -i error 'Whippet' '{$message}'");
     }
 }