From 748bd4efbb65ba96015b2bc23bfcf8e915f17f67 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Mon, 18 Aug 2008 12:21:23 -0400
Subject: [PATCH]
---
install/lib/install.lib.php | 83 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/install/lib/install.lib.php b/install/lib/install.lib.php
index 503b074..d8eb0d6 100644
--- a/install/lib/install.lib.php
+++ b/install/lib/install.lib.php
@@ -59,11 +59,18 @@
//** Get distribution identifier
function get_distname() {
- //** Debian
+ $distname = '';
+
+ //** Debian or Ubuntu
if(file_exists('/etc/debian_version')) {
if(trim(file_get_contents('/etc/debian_version')) == '4.0') {
$distname = 'debian40';
+ 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\n");
}
}
@@ -76,9 +83,7 @@
}
function sread() {
- $f = fopen('/dev/stdin', 'r');
- $input = fgets($f, 255);
- fclose($f);
+ $input = fgets(STDIN);
return rtrim($input);
}
@@ -397,4 +402,74 @@
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;
+}
+
+function is_user($user){
+ global $mod;
+ $user_datei = '/etc/passwd';
+ $users = no_comments($user_datei);
+ $lines = explode("\n", $users);
+ if(is_array($lines)){
+ foreach($lines as $line){
+ if(trim($line) != ""){
+ list($f1, $f2, $f3, $f4, $f5, $f6, $f7) = explode(":", $line);
+ if($f1 == $user) return true;
+ }
+ }
+ }
+ return false;
+}
+
+function is_group($group){
+ global $mod;
+ $group_datei = '/etc/group';
+ $groups = no_comments($group_datei);
+ $lines = explode("\n", $groups);
+ if(is_array($lines)){
+ foreach($lines as $line){
+ if(trim($line) != ""){
+ list($f1, $f2, $f3, $f4) = explode(":", $line);
+ if($f1 == $group) return true;
+ }
+ }
+ }
+ return false;
+}
+
+
+
?>
\ No newline at end of file
--
Gitblit v1.9.1