From 489f45e7c59000c23b55541008894577ab626d0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Thu, 5 Feb 2009 09:24:08 +0000
Subject: [PATCH] Debugging missing parameters and adding debug backtrace on
 output

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1239 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/ldapstatus/lib/LDAPTester.php | 19 +++++++++++-
 modules/ldapstatus/www/index.php      | 44 ++++++++++++++++++---------
 2 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/modules/ldapstatus/lib/LDAPTester.php b/modules/ldapstatus/lib/LDAPTester.php
index 214b59a33..197731bea 100644
--- a/modules/ldapstatus/lib/LDAPTester.php
+++ b/modules/ldapstatus/lib/LDAPTester.php
@@ -43,6 +43,15 @@ class sspmod_ldapstatus_LDAPTester {
 	}
 	
 	
+	private function checkParameter($conf, $req) {
+		$res = $this->checkConfig($conf, array($req));
+		if ($res[0]) {
+			return 'Parameter [' . $req . '] found';
+		} else {
+			return 'Parameter [' . $req . '] NOT found';
+		}
+	}
+	
 	private function log($str) {
 		if ($this->debugOutput) {
 			echo '<p>' . $str;
@@ -85,7 +94,12 @@ class sspmod_ldapstatus_LDAPTester {
 			$result['time'] = microtime(TRUE) - $start;
 			return $result;
 		}
-	
+		
+		$this->log($this->checkParameter($this->orgconfig, 'adminUser'));
+		$this->log($this->checkParameter($this->orgconfig, 'adminPassword'));
+		$this->log($this->checkParameter($this->orgconfig, 'testUser'));
+		$this->log($this->checkParameter($this->orgconfig, 'testPassword'));
+		
 		$urldef = explode(' ', $this->orgconfig['hostname']);
 		$url = parse_url($urldef[0]);
 		$port = 389;
@@ -95,6 +109,9 @@ class sspmod_ldapstatus_LDAPTester {
 		$this->log('ldapstatus Url parse [' . $this->orgconfig['hostname'] . '] => [' . $url['host'] . ']:[' . $port . ']' );
 	
 	
+
+	
+	
 		$result['ping'] = $this->phpping($url['host'], $port);
 	
 		if (!$result['ping'][0]) {
diff --git a/modules/ldapstatus/www/index.php b/modules/ldapstatus/www/index.php
index 2aaedd1b3..50cab23a1 100644
--- a/modules/ldapstatus/www/index.php
+++ b/modules/ldapstatus/www/index.php
@@ -11,25 +11,39 @@ if (!$session->isValid('login-admin') ) {
 }
 
 
-function myErrorHandler($errno, $errstr, $errfile, $errline) {
-
-    switch ($errno) {
-    case E_USER_ERROR:
-    	echo('<p>PHP_ERROR   : [' . $errno . '] ' . $errstr . '. Fatal error on line ' . $errline . ' in file ' . $errfile);
-    	break;
+function backtrace() {
+	return join(' - ', debug_backtrace());
+}
 
-    case E_USER_WARNING:
-    	echo('<p>PHP_WARNING : [' . $errno . '] ' . $errstr . '. Warning on line ' . $errline . ' in file ' . $errfile);
-    	break;
+function myErrorHandler($errno, $errstr, $errfile, $errline) {
 
-    case E_USER_NOTICE:
-    	echo('<p>PHP_WARNING : [' . $errno . '] ' . $errstr . '. Warning on line ' . $errline . ' in file ' . $errfile);        
-    	break;
 
-    default:
-    	echo('<p>PHP_UNKNOWN : [' . $errno . '] ' . $errstr . '. Unknown error on line ' . $errline . ' in file ' . $errfile);        
-        break;
+	echo('<div style="border: 1px dotted #ccc; margin: .3em; padding: .4em;">');
+	switch ($errno) {
+		case E_USER_ERROR:
+			echo('<p>PHP_ERROR   : [' . $errno . '] ' . $errstr . '. Fatal error on line ' . $errline . ' in file ' . $errfile);
+			break;
+	
+		case E_USER_WARNING:
+			echo('<p>PHP_WARNING : [' . $errno . '] ' . $errstr . '. Warning on line ' . $errline . ' in file ' . $errfile);
+			break;
+	
+		case E_USER_NOTICE:
+			echo('<p>PHP_WARNING : [' . $errno . '] ' . $errstr . '. Warning on line ' . $errline . ' in file ' . $errfile);        
+			break;
+	
+		default:
+			echo('<p>PHP_UNKNOWN : [' . $errno . '] ' . $errstr . '. Unknown error on line ' . $errline . ' in file ' . $errfile);        
+			break;
     }
+    
+#    echo('<div style="font-style:monospace; font-size: x-small; margin: 1em; color: #966"><li>' . join('</li><li>', debug_backtrace()) . '</li></div>');
+    echo('<pre style="font-style:monospace; font-size: small; margin: 1em; color: #966">');
+    echo(debug_print_backtrace()); 
+    echo('</pre>');
+	echo('</div>');
+
+    
     flush();
 
     /* Don't execute PHP internal error handler */
-- 
GitLab