mcramer
2012-10-30 a1c925f9c924f55f9dc39f840a9e23a62d4b1af1
interface/lib/classes/ini_parser.inc.php
@@ -1,15 +1,7 @@
<?php
/**
 * ini parser
 *
 * @author Till Brehm
 * @copyright  2005, Till Brehm, projektfarm Gmbh
 * @version 0.1
 * @package ISPConfig
 */
/*
Copyright (c) 2006, Till Brehm, projektfarm Gmbh
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
@@ -40,11 +32,12 @@
   private $config;
   //* Converts a ini string to array
   public function parse_ini_string($ini) {
      $ini = str_replace("\r\n", "\n", $ini);
      $lines = explode("\n", $ini);
      foreach($lines as $line) {
            $line = trim($line);
         $line = trim($line);
         if($line != '') {
            if(preg_match("/^\[([\w\d_]+)\]$/", $line, $matches)) {
               $section = strtolower($matches[1]);
@@ -57,18 +50,25 @@
      return $this->config;
   }
   public function get_ini_string($file) {
   //* Converts a config array to a string
   public function get_ini_string($config_array = '') {
      if($config_array == '') $config_array = $this->config;
      $content = '';
      foreach($this->config as $section => $data) {
      foreach($config_array as $section => $data) {
         $content .= "[$section]\n";
         foreach($data as $item => $value) {
            if($value != ''){
                    $content .= "$item=$value\n";
                }
            if($item != ''){
               $value    = trim($value);
               $item    = trim($item);
               $content .= "$item=$value\n";
            }
         }
         $content .= "\n";
      }
      return $content;
   }
}
?>
?>