浏览代码

Add Fever API debug (#2063)

* Add Fever API debug

https://github.com/FreshRSS/FreshRSS/issues/2043

* Default without debug logging
Alexandre Alapetite 7 年之前
父节点
当前提交
a1dc5ada67
共有 1 个文件被更改,包括 30 次插入0 次删除
  1. 30 0
      p/api/fever.php

+ 30 - 0
p/api/fever.php

@@ -30,6 +30,36 @@ register_shutdown_function('session_destroy');
 Minz_Session::init('FreshRSS');
 // ================================================================================================
 
+// <Debug>
+$ORIGINAL_INPUT = file_get_contents('php://input', false, null, 0, 1048576);
+
+function debugInfo() {
+	if (function_exists('getallheaders')) {
+		$ALL_HEADERS = getallheaders();
+	} else {	//nginx	http://php.net/getallheaders#84262
+		$ALL_HEADERS = array();
+		foreach ($_SERVER as $name => $value) {
+			if (substr($name, 0, 5) === 'HTTP_') {
+				$ALL_HEADERS[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
+			}
+		}
+	}
+	global $ORIGINAL_INPUT;
+	return print_r(
+		array(
+			'date' => date('c'),
+			'headers' => $ALL_HEADERS,
+			'_SERVER' => $_SERVER,
+			'_GET' => $_GET,
+			'_POST' => $_POST,
+			'_COOKIE' => $_COOKIE,
+			'INPUT' => $ORIGINAL_INPUT
+		), true);
+}
+
+//Minz_Log::debug('----------------------------------------------------------------', API_LOG);
+//Minz_Log::debug(debugInfo(), API_LOG);
+// </Debug>
 
 class FeverDAO extends Minz_ModelPdo
 {