Esempio n. 1
0
function reportExceptions($code, $descr, $filename, $line)
{
    // obey error_level set by system/user
    if (!($code & error_reporting())) {
        return;
    }
    // build a new AMFObject
    $amfout = new AMFObject("");
    // init a new error info object
    $error = array();
    // pass the code
    $error["code"] = "AMFPHP_RUNTIME_ERROR";
    // pass the description
    $error["description"] = $descr;
    // pass the details
    $error["details"] = $filename;
    // pass the level
    $error["level"] = AMFException::getFriendlyError($code);
    // pass the line number
    $error["line"] = $line;
    // add the error object to the body of the AMFObject
    $amfbody = new AMFBody(NULL, $GLOBALS['amfphp']['lastMethodCall']);
    $amfbody->setResults($error);
    $amfout->addBody($amfbody);
    // Add the trace headers we have so far while we're at it
    debugFilter($amfout);
    // create a new serializer
    $serializer = new AMFSerializer();
    // serialize the data
    $data = $serializer->serialize($amfout);
    // send the correct header
    header('Content-type: application/x-amf');
    // flush the amf data to the client.
    print $data;
    // kill the system after we find a single error
    exit;
}
Esempio n. 2
0
 /**
  * Wraps a string into an error AMF message
  * @param $data the original AMF data (needed to get the response index
  * @param $error The error to send back
  * @returns String containing the AMF data
  */
 function sendError($data, $error)
 {
     //Get the last response index, otherwise the error will not register
     //In the NetConnection debugger
     $amf = new AMFObject($data);
     // create the amf object
     $deserializer = new AMFDeserializer($data);
     $deserializer->deserialize($amf);
     $lastBody =& $amf->getBodyAt($amf->numBody() - 1);
     $lastIndex = $lastBody->responseIndex;
     // add the error object to the body of the AMFObject
     $amfout = new AMFObject(NULL);
     $amfbody = new AMFBody($lastIndex . "/onStatus", $lastIndex);
     //Get line number
     preg_match("/in ([A-Za-z0-9\\/\\.\\:]+) on line ([0-9]+)/", str_replace('\\', '/', $error), $matches);
     $file = $matches[1];
     $line = $matches[2];
     $level = substr($error, 0, strpos($error, ': '));
     $amfbody->setResults(array('description' => $error, 'line' => $line, 'file' => $file, 'level' => $level, 'code' => 'AMFPHP_DEBUG_ERROR'));
     $amfout->addBody($amfbody);
     // create a new serializer
     $serializer = new AMFSerializer();
     // serialize the data
     $result = $serializer->serialize($amfout);
     return $result;
 }
Esempio n. 3
0
/**
 * Adds debugging information to outgoing packet
 */
function debugFilter(&$amf)
{
    //Add trace headers before outputting
    if (!$GLOBALS['amfphp']['isFlashComm'] && !$GLOBALS['amfphp']['disableTrace'] && count(NetDebug::getTraceStack()) != 0) {
        //Get the last body in the stack
        $body =& $amf->getBodyAt($amf->numBody() - 1);
        $headers = new AMFBody(NULL, $body->responseIndex, NULL);
        // create a new amf body
        $headers->responseURI = $body->responseIndex . "/onDebugEvents";
        // set the response uri of this body
        $headerresults = array();
        // create a result array
        $headerresults[0] = array();
        // create a sub array in results (CF seems to do this, don't know why)
        $ts = NetDebug::getTraceStack();
        $headerresults[0][] = new TraceHeader($ts);
        $headers->setResults($headerresults);
        // set the results.
        $amf->addBodyAt(0, $headers);
    }
}