function printr($what) { ob_start(); print_r($what); $result = ob_get_clean(); NetDebug::getTraceStack($result); }
/** * Debug action */ function debugAction(&$body) { if (count(NetDebug::getTraceStack()) != 0) { $previousResults = $body->getResults(); $debugInfo = NetDebug::getTraceStack(); $debugString = "<!-- " . implode("\n", $debugInfo) . "-->"; $body->setResults($debugString . "\n" . $previousResults); } }
/** * This function is used to create the connection from the database * @return <Connection> */ public static function createConnection() { $con = mysql_connect(Database::server, Database::username, Database::password); if (!$con) { NetDebug::trace('Could not connect'); die('could not connect' . mysql_error()); } mysql_select_db(Database::databasename, $con); return $con; }
function serializationAction(&$body) { //Take the raw response $rawResponse =& $body->getResults(); adapterMap($rawResponse); //Now serialize it $encodedResponse = json_encode($rawResponse); if (count(NetDebug::getTraceStack()) > 0) { $trace = "/*" . implode("\n", NetDebug::getTraceStack()) . "*/"; $encodedResponse = $trace . "\n" . $encodedResponse; } $body->setResults($encodedResponse); }
function twistResultsFilter(&$amf) { $GLOBALS['amfphp']['encoding'] = "amf3"; $bodycount = $amf->numBody(); for ($i = 0; $i < $bodycount; $i++) { $amfbody =& $amf->getBodyAt($i); $results = $amfbody->getResults(); NetDebug::trace("result: " . serialize($results)); $serializer = new AMFSerializer(); $serializer->writeAmf3Data($results); $data = $serializer->outBuffer; $data = gzcompress($data); $outBa = new ByteArray($data); $amfbody->setResults($outBa); //$amfbody->setResults($data); //echo "<br>$results"; return true; } }
/** * Get the list of services * @returns An array of array ready to be bound to a Tree */ function getServices() { NetDebug::trace("In getServices"); $this->_omit = array(); $this->_path = dirname(dirname(realpath(__FILE__))) . '/'; $services = $this->_listServices(); //Now sort on key ksort($services); $out = array(); foreach ($services as $key => $val) { if ($key == "zzz_default") { foreach ($val as $key2 => $val2) { $out[] = array("label" => Inflector::camelize($val2[0]), "data" => $val2[1]); } } else { $children = array(); foreach ($val as $key2 => $val2) { $children[] = array("label" => $val2[0], "data" => $val2[1]); } $out[] = array("label" => $key, "children" => $children, "open" => true); } } return $out; }
/** * A static function that traces stuff in the NetDebug window * * Note emulation of static variables */ function trace($what) { NetDebug::getTraceStack($what); }
/** * The service method runs the gateway application. It turns the gateway 'on'. You * have to call the service method as the last line of the gateway script after all of the * gateway configuration properties have been set. * * Right now the service method also includes a very primitive debugging mode that * just dumps the raw amf input and output to files. This may change in later versions. * The debugging implementation is NOT thread safe so be aware of file corruptions that * may occur in concurrent environments. */ function service() { //Set the parameters for the charset handler CharsetHandler::setMethod($this->_charsetMethod); CharsetHandler::setPhpCharset($this->_charsetPhp); CharsetHandler::setSqlCharset($this->_charsetSql); //Attempt to call charset handler to catch any uninstalled extensions $ch = new CharsetHandler('flashtophp'); $ch->transliterate('?'); $ch2 = new CharsetHandler('sqltophp'); $ch2->transliterate('?'); $GLOBALS['amfphp']['actions'] = $this->actions; if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) { $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents('php://input'); } if (isset($GLOBALS["HTTP_RAW_POST_DATA"]) && $GLOBALS["HTTP_RAW_POST_DATA"] != "") { //Start NetDebug NetDebug::initialize(); error_reporting($GLOBALS['amfphp']['errorLevel']); //Enable loose mode if requested if ($this->_looseMode) { ob_start(); } $amf = new AMFObject($GLOBALS["HTTP_RAW_POST_DATA"]); // create the amf object if ($this->incomingMessagesFolder != NULL) { $mt = microtime(); $pieces = explode(' ', $mt); file_put_contents($this->incomingMessagesFolder . 'in.' . $pieces[1] . '.' . substr($pieces[0], 2) . ".amf", $GLOBALS["HTTP_RAW_POST_DATA"]); } foreach ($this->filters as $key => $filter) { $filter($amf); // invoke the first filter in the chain } $output = $amf->outputStream; // grab the output stream //Clear the current output buffer if requested if ($this->_looseMode) { if ($this->_obLogging !== FALSE) { $this->_appendRawDataToFile($this->_obLogging, ob_get_clean()); } else { ob_end_clean(); } } //Send content length header //Thanks to Alec Horley for pointing out the necessity //of this for FlashComm support header(AMFPHP_CONTENT_TYPE); // define the proper header header("Content-length: " . strlen($output)); //Send expire header, apparently helps for SSL //Thanks to Gary Rogers for that //And also to Lucas Filippi from openAMF list //And to Robert Reinhardt who appears to be the first who //documented the bug //Finally to Gary who appears to have find a solution which works even more reliably if ($this->useSslFirstMethod) { $dateStr = date("D, j M Y ") . date("H:i:s", strtotime("-2 days")); header("Expires: {$dateStr} GMT"); header("Pragma: no-store"); header("Cache-Control: no-store"); } //else don't send any special headers at all if ($this->outgoingMessagesFolder != NULL) { $mt = microtime(); $pieces = explode(' ', $mt); file_put_contents($this->outgoingMessagesFolder . 'out.' . $pieces[1] . '.' . substr($pieces[0], 2) . ".amf", $output); } print $output; // flush the binary data } else { echo "<p>amfphp and this gateway are installed correctly. You may now connect " . "to this gateway from Flash.</p><p>Note: If you're reading an " . "old tutorial, it will tell you that you should see a download " . "window instead of this message. This confused people so this is " . "the new behaviour starting from amfphp 1.2.</p><p>" . "<a href='http://www.amfphp.org/docs'>View the amfphp documentation</p>"; } }
/** * The service method runs the gateway application. It turns the gateway 'on'. You * have to call the service method as the last line of the gateway script after all of the * gateway configuration properties have been set. * * Right now the service method also includes a very primitive debugging mode that * just dumps the raw amf input and output to files. This may change in later versions. * The debugging implementation is NOT thread safe so be aware of file corruptions that * may occur in concurrent environments. */ function service() { //Set the parameters for the charset handler CharsetHandler::setMethod($this->_charsetMethod); CharsetHandler::setPhpCharset($this->_charsetPhp); CharsetHandler::setSqlCharset($this->_charsetSql); //Attempt to call charset handler to catch any uninstalled extensions $ch = new CharsetHandler('flashtophp'); $ch->transliterate('?'); $ch2 = new CharsetHandler('sqltophp'); $ch2->transliterate('?'); $GLOBALS['amfphp']['actions'] = $this->actions; if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) { $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents('php://input'); } if (isset($GLOBALS["HTTP_RAW_POST_DATA"]) && $GLOBALS["HTTP_RAW_POST_DATA"] != "") { //Start NetDebug NetDebug::initialize(); error_reporting($GLOBALS['amfphp']['errorLevel']); //Enable loose mode if requested if ($this->_looseMode) { ob_start(); } $amf = new AMFObject($GLOBALS["HTTP_RAW_POST_DATA"]); // create the amf object if ($this->incomingMessagesFolder != NULL) { $mt = microtime(); $pieces = explode(' ', $mt); file_put_contents($this->incomingMessagesFolder . 'in.' . $pieces[1] . '.' . substr($pieces[0], 2) . ".amf", $GLOBALS["HTTP_RAW_POST_DATA"]); } foreach ($this->filters as $key => $filter) { $filter($amf); // invoke the first filter in the chain } $output = $amf->outputStream; // grab the output stream //Clear the current output buffer if requested if ($this->_looseMode) { ob_end_clean(); } //Send content length header //Thanks to Alec Horley for pointing out the necessity //of this for FlashComm support header(AMFPHP_CONTENT_TYPE); // define the proper header if (Headers::getHeader('serviceBrowser') == true) { //Add the total time header $toAddPos = strpos($output, "СА"); $time = (int) ((microtime_float() - $GLOBALS['amfphp']['startTime']) * 1000); $b = pack("d", $time); // pack the bytes if (AMFPHP_BIG_ENDIAN) { // if we are a big-endian processor $r = strrev($b); } else { // add the bytes to the output $r = $b; } $output = substr($output, 0, $toAddPos) . $r . substr($output, $toAddPos + 8); } //Send expire header, apparently helps for SSL //Thanks to Gary Rogers for that //And also to Lucas Filippi from openAMF list //And to Robert Reinhardt who appears to be the first who //documented the bug //Finally to Gary who appears to have find a solution which works even more reliably $dateStr = date("D, j M Y ") . date("H:i:s", strtotime("-2 days")); header("Expires: {$dateStr} GMT"); header("Pragma: no-store"); header("Cache-Control: no-store"); //else don't send any special headers at all if ($this->outgoingMessagesFolder != NULL) { $mt = microtime(); $pieces = explode(' ', $mt); file_put_contents($this->outgoingMessagesFolder . 'out.' . $pieces[1] . '.' . substr($pieces[0], 2) . ".amf", $output); } $doCompress = false; $outputCompression = @ini_get("zlib.output_compression"); if (!$outputCompression) { if (strlen($output) > $this->_gzipCompressionThreshold && extension_loaded("zlib") && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE && $this->_enableGzipCompression) { $doCompress = true; ob_start(); ob_start('ob_gzhandler'); } else { header("Content-length: " . strlen($output)); } } print $output; // flush the binary data if ($doCompress) { ob_end_flush(); header("Content-length: " . ob_get_length()); ob_end_flush(); } } else { $versionData = explode("\n", file_get_contents(APP . DS . "plugins" . DS . "cpamf" . DS . "version.txt")); $cpamfVersion = $versionData[count($versionData) - 1]; echo "<p> CpAmf plugin v" . $cpamfVersion . " (CakePHP 1.2)</p>"; echo "<p>amfphp and this gateway are installed correctly. You may now connect " . "to this gateway from Flash.</p>"; if (function_exists("amf_decode")) { echo "<p>AMF C Extension is loaded " . ($GLOBALS['amfphp']['native'] ? "and enabled." : "but disabled") . "</p>"; } echo "<p>Note: If you're reading an " . "old tutorial, it will tell you that you should see a download " . "window instead of this message. This confused people so this is " . "the new behaviour starting from amfphp 1.2.</p><p>" . "<a href='http://www.amfphp.org/docs'>View the amfphp documentation</p>" . "<p><a href='browser'>Load the service browser</a></p>"; echo "<pre>"; } }
/** * Adds debugging information to outgoing packet */ function debugFilter(&$amf) { //Add trace headers before outputting if (!$GLOBALS['amfphp']['isFlashComm'] && !$GLOBALS['amfphp']['disableTrace']) { $headerresults = array(); // create a result array $headerresults[0] = array(); // create a sub array in results (CF seems to do this, don't know why) if (count(NetDebug::getTraceStack()) != 0) { $ts = NetDebug::getTraceStack(); $headerresults[0][] = new TraceHeader($ts); } if (Headers::getHeader("serviceBrowser") == true) { global $amfphp; $amfphp['totalTime'] = microtime_float() - $amfphp['startTime']; $headerresults[0][] = new ProfilingHeader(); } //Get the last body in the stack if (count($headerresults[0]) > 0) { $body =& $amf->getBodyAt($amf->numBody() - 1); $headers = new MessageBody(NULL, $body->responseIndex, NULL); // create a new amf body $headers->responseURI = $body->responseIndex . "/onDebugEvents"; // set the response uri of this body $headers->setResults($headerresults); // set the results. $amf->addBodyAt(0, $headers); } } }
private function testDB() { $dbh = dbconnect(); NetDebug::trace($dbh); $query = "INSERT INTO images(owner_id, quadrant) VALUES (12, 00)"; $count = $dbh->exec($query); $insert_id = $dbh->lastInsertId(); NetDebug::trace("insert_id: {$insert_id}"); return true; }
/** * Stupid dummy comment * * @access private * @roles administrator */ function getAverageStupidityFactor() { NetDebug::trace("inside stupid"); return "huge"; }
/** * 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); } }