From 88d899db2dedb799fecf941d7021b1dd30d87a17 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 09 Jul 2008 15:32:11 -0400
Subject: [PATCH] Better debugging and exit conditions in mysql databse plugin.

---
 install/lib/install.lib.php |   46 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/install/lib/install.lib.php b/install/lib/install.lib.php
index 923f094..5c037fb 100644
--- a/install/lib/install.lib.php
+++ b/install/lib/install.lib.php
@@ -66,11 +66,11 @@
 	
 		if(trim(file_get_contents('/etc/debian_version')) == '4.0') {
 			$distname = 'debian40';
-			swriteln('Operating System: Debian 4.0 or compatible');
+			swriteln("Operating System: Debian 4.0 or compatible\n");
 		}
 		if(trim(file_get_contents('/etc/debian_version')) == 'lenny/sid') {
 			$distname = 'debian40';
-			swriteln('Operating System: Debian Lenny/Sid or compatible');
+			swriteln("Operating System: Debian Lenny/Sid or compatible\n");
 		}
 	}
 	
@@ -83,9 +83,7 @@
 }
 
 function sread() {
-    $f = fopen('/dev/stdin', 'r');
-    $input = fgets($f, 255);
-    fclose($f);
+    $input = fgets(STDIN);
     return rtrim($input);
 }
 
@@ -404,4 +402,42 @@
 	wf($xinetd_conf, $contents);
 }
 
+//* Converts a ini string to array
+function ini_to_array($ini) {
+	$config = '';
+	$ini = str_replace("\r\n", "\n", $ini);
+	$lines = explode("\n", $ini);
+	foreach($lines as $line) {
+        $line = trim($line);                
+		if($line != '') {
+			if(preg_match("/^\[([\w\d_]+)\]$/", $line, $matches)) {
+				$section = strtolower($matches[1]);
+			} elseif(preg_match("/^([\w\d_]+)=(.*)$/", $line, $matches) && $section != null) {
+				$item = trim($matches[1]);
+				$config[$section][$item] = trim($matches[2]);
+			}
+		}
+	}
+	return $config;
+}
+	
+	
+//* Converts a config array to a string
+function array_to_ini($config_array = '') {
+	if($config_array == '') $config_array = $this->config;
+	$content = '';
+	foreach($config_array as $section => $data) {
+		$content .= "[$section]\n";
+		foreach($data as $item => $value) {
+			if($item != ''){
+                $content .= "$item=$value\n";
+            }
+		}
+		$content .= "\n";
+	}
+	return $content;
+}
+
+
+
 ?>
\ No newline at end of file

--
Gitblit v1.9.1