An object for sending captured error info to an HTTP server. An object for sending captured error info to an HTTP server. In particular this is made to work with the Trac plugin Autotrac, though it would be quite simple to make another HTTP server to work with it. A simple way to use this object is to create an error handler to the following function report_bug(): function report_bug ($p_number, $p_string, $p_file, $p_line) { $reporter = new BugReporter ($p_number, $p_string, $p_file, $p_line); $reporter->setServer ("http://myserver.com/mydirectory") $reporter->sendToServer(); } The errors are always sent to the server URL plus the extension "/report". So the above example would POST the error variables to http://myserver.com/mydirectory/newreport . The error variables POSTed are: - f_backtrace - f_id - f_software - f_str - f_num - f_file - f_line - f_backtrace * - f_description - f_email
Esempio n. 1
0
function camp_call_bug_reporter($p_number, $p_string, $p_file, $p_line)
{
    global $ADMIN_DIR, $ADMIN, $Campsite;
    require_once ($GLOBALS['g_campsiteDir'] . "/classes/BugReporter.php");

    // --- Don't print the previous screen (in which the error occurred) ---
    ob_end_clean();

    echo "<html><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n<tr><td>\n";
    require_once($Campsite['HTML_DIR'] . "/$ADMIN_DIR/menu.php");
    echo "</td></tr>\n<tr><td>\n";

    $reporter = new BugReporter ($p_number, $p_string, $p_file, $p_line, "Campsite", $Campsite['VERSION']);
    $reporter->setPingStatus(false);

    include ($Campsite['HTML_DIR'] . "/bugreporter/senderrorform.php");

    $buffer = ob_get_contents();

    echo ($buffer);

    exit();
}
Esempio n. 2
0
 function test_formatOfLine ()
 {
     $reporter = new BugReporter (2, "bad bad error", "/nondir/nonfile.php", 3, "Campsite", "2.5.0", $this->vars->time, $this->vars->backtrace);
     $backtrace = $reporter->getBacktraceString();
     $this->assertWantedPattern
         ("/[a-z_]+\:\:[a-z_]+\(\)\ called\ at\ \[[^][:]+\.php\:[1-9][0-9]*\]/", $backtrace);
 }
Esempio n. 3
0
/**
 * Called for all Campsite errors.
 *
 * If the flag $Campsite['DEBUG'] is set to false, this function will
 * return minor errors (ie notices and warnings) without having
 * processed them.  Errors with fsockopen() are returned without being
 * processed regardless of the $Campsite['DEBUG'] flag.
 *
 * @param int    $p_number The error number.
 * @param string $p_string The error message.
 * @param string $p_file The name of the file in which the error occurred.
 * @param int    $p_line The line number in which the error occurred.
 * @return void
 */
function camp_bug_handler_main($p_number, $p_string, $p_file, $p_line)
{
    global $ADMIN_DIR;
    global $ADMIN;
    global $Campsite;
    global $g_bugReporterDefaultServer;
    global $g_user;

    $server = $g_bugReporterDefaultServer;

    // --- Return on unimportant errors ---
    if (!$Campsite['DEBUG']) {
        switch ($p_number) {
            case E_NOTICE:
            case E_WARNING:
            case E_USER_NOTICE:
            case E_USER_WARNING:
                return;
        }
    }

    // -- Return on getid3 errors ---
    if (preg_match ('/^Undefined index:/i', $p_string)){
    	return;
    }
    if (preg_match ('/^Undefined variable:/i', $p_string)){
    	return;
    }
    if (preg_match ('/^Undefined offset:/i', $p_string)){
        return;
    }

    // -- SimpleXMLElement errors ---
    if (preg_match('/^SimpleXMLElement/i', $p_string)) {
        return;
    }

    // -- Return on URL parse errors
    if (preg_match('/^parse_url/i', $p_string)) {
    	return;
    }

    // -- Return on mysql connect errors ---
    if (preg_match ('/^mysql_connect/i', $p_string)){
	return;
    }

    // --- Return on socket errors ---
    if (preg_match ('/^fsockopen/i', $p_string)){
        return;
    }

    // --- Return on unlink errors ---
    if (preg_match ('/^unlink/i', $p_string)){
        return;
    }

    // --- Return on upload file errors ---
    if (preg_match ('/^move_uploaded_file/i', $p_string)){
        return;
    }

    // -- Return on getimagesize errors --
    if (preg_match ('/^getimagesize/i', $p_string)){
        return;
    }

    // -- Return on imagecreate* errors --
    if (preg_match ('/^imagecreate/i', $p_string)) {
        return;
    }

    // -- Return on rmdir errors --
    if (preg_match ('/^rmdir/i', $p_string)){
        return;
    }

    // -- Return on mkdir errors --
    if (preg_match ('/^mkdir/i', $p_string)){
        return;
    }

    // -- Return on fopen errors --
    if (preg_match ('/^fopen/i', $p_string)){
        return;
    }

    // -- Return on chown errors --
    if (preg_match ('/^chown/i', $p_string)){
        return;
    }

    // -- Return on chgrp errors --
    if (preg_match ('/^chgrp/i', $p_string)){
        return;
    }

    // --- Don't print out the previous screen (in which the error occurred). ---
    ob_end_clean();

    if (is_object($g_user)) {
	    echo "<html><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n<tr><td>\n";
    	require_once($Campsite['HTML_DIR'] . "/$ADMIN_DIR/menu.php");
    	echo "</td></tr>\n<tr><td>\n";
    }

    // --- If reporter doesn't exist, make one ($reporter might exist
    //     already if this script is an 'include') ---
    // Remove the code name from the version number.
    $version = explode(" ", $Campsite['VERSION']);
    $version = array_shift($version);

    if (!isset($reporter)) {
        $reporter = new BugReporter($p_number, $p_string, $p_file, $p_line, 'Campsite', $version);
    }

    $reporter->setServer($server);

    // --- Ping AutoTrac Server ---
    $wasPinged = $reporter->pingServer();

    // --- Print results ---
    if ($wasPinged) {
        include($Campsite['HTML_DIR'] . "/$ADMIN_DIR/bugreporter/errormessage.php");
    } else {
        include($Campsite['HTML_DIR'] . "/$ADMIN_DIR/bugreporter/emailus.php");
    }
    exit();
}
Esempio n. 4
0
$f_isFromInterface = Input::Get("f_isFromInterface", "boolean", false);
$f_email = Input::Get("f_email", "string", "", true);
$f_description = Input::Get("f_description", "string", "", true);
$f_body = Input::Get("f_body", "string", "");

// --- If this information is a POST from errormessage.php, send it to
//     the server ---
if ($f_isFromInterface && ($_SERVER['REQUEST_METHOD'] == "POST") ) {

    $wasSent = false;

   	// Remove the code name from the version number.
    $version = explode(" ", $Campsite['VERSION']);
    $version = array_shift($version);

    $reporter = new BugReporter(0, "",  mktime(), "", "Campsite", $version);
    $reporter->setBacktraceString($f_body);
    $reporter->setServer($server);
    $reporter->setDescription($f_description);
    $reporter->setEmail($f_email);
    $wasSent = $reporter->sendToServer();


    // --- Verify send was successful, and say thank you or sorry
    //     accordingly ---
    if ($wasSent == true) {
        include($Campsite['HTML_DIR'] . "/$ADMIN_DIR/feedback/thankyou.php");
    } else {
    	include($Campsite['HTML_DIR'] . "/$ADMIN_DIR/feedback/emailus.php");
    }
}