Skip to content

Commit 0a6e9e0

Browse files
author
pedro_morgan
committed
ini_parser class now php5
1 parent 1d751b0 commit 0a6e9e0

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

interface/lib/classes/ini_parser.inc.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?php
2+
/**
3+
* ini parser
4+
*
5+
* @author Till Brehm
6+
* @copyright 2005, Till Brehm, projektfarm Gmbh
7+
* @version 0.1
8+
* @package ISPConfig
9+
*/
210

311
/*
412
Copyright (c) 2006, Till Brehm, projektfarm Gmbh
@@ -28,18 +36,16 @@
2836
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2937
*/
3038

31-
class ini_parser {
39+
class ini_parser{
3240

33-
var $config;
41+
private $config;
3442

35-
function parse_ini_string($ini) {
36-
$ini = str_replace("\r\n","\n",$ini);
37-
$lines = explode("\n",$ini);
38-
43+
public function parse_ini_string($ini) {
44+
$ini = str_replace("\r\n", "\n", $ini);
45+
$lines = explode("\n", $ini);
3946
foreach($lines as $line) {
40-
47+
$line = trim($line);
4148
if($line != '') {
42-
$line = trim($line);
4349
if(preg_match("/^\[([\w\d_]+)\]$/", $line, $matches)) {
4450
$section = strtolower($matches[1]);
4551
} elseif(preg_match("/^([\w\d_]+)=(.*)$/", $line, $matches) && $section != null) {
@@ -53,12 +59,14 @@ function parse_ini_string($ini) {
5359

5460

5561

56-
function get_ini_string($file) {
62+
public function get_ini_string($file) {
5763
$content = '';
5864
foreach($this->config as $section => $data) {
5965
$content .= "[$section]\n";
6066
foreach($data as $item => $value) {
61-
if($value != '') $content .= "$item=$value\n";
67+
if($value != ''){
68+
$content .= "$item=$value\n";
69+
}
6270
}
6371
}
6472
return $content;

0 commit comments

Comments
 (0)