ini class

Back to PHP-IRC Bugs

Page: 1  
From User Message Body
Mad_Clog
Post #321
user avatar
Member
Date: 1:18 pm, Aug 25 2006
Posts: 176


Started using the ini class.
So i created a file called maps.ini with a section called [maps]

Made a little script which i use to add maps to it, works fine and all.
But then when i send a "reloadfunc" command to the bot and add a new map after that i suddenly get an entry which says "=1" without the quotes...
Any idea's on how this can happen?

This is code, its part of a switch so thats why there's a case and a break in it.
The if-else build up at the part where it actually adds the map is a but stupid but thought that might be the problem, turns out its not
Code
// Add a map to the ini file
case 'ADD_MAP':
    $map = trim(strtolower($query['arg1']));
    if ($this->maps->getIniVal('maps', $map) === FALSE) {
        // add the map to the ini file
        if ($this->maps->setIniVal('maps', $map, '0') === TRUE) {
            if ($this->maps->writeIni() === TRUE)
                return $this->buildReply(array('status' => 1,'message' => $map.' has been added the maplist'));
            else
                return $this->buildReply(array('status' => 0,'message' => 'Could not write to maplist'));
        }    else {
            return $this->buildReply(array('status' => 0,'message' => 'Could not write to maplist'));
        }
    } else {
        // Map already exists
        return $this->buildReply(array('status' => 0,'message' => $map.' already exists in the maplist'));
    }
break;


This is the way i had it before but this had the same problem
Code
// Add a map to the ini file
case 'ADD_MAP':
    $map = trim(strtolower($query['arg1']));
    if ($this->maps->getIniVal('maps', $map) === FALSE) {
        // add the map to the ini file
        if ($this->maps->setIniVal('maps', $map, '0') && $this->maps->writeIni()) {
            return $this->buildReply(array('status' => 1,'message' => $map.' has been added the maplist'));
        }    else {
            return $this->buildReply(array('status' => 0,'message' => 'Could not write to maplist'));
        }
    } else {
        // Map already exists
        return $this->buildReply(array('status' => 0,'message' => $map.' already exists in the maplist'));
    }
break;


Manick
Post #322
user avatar
Admin
Date: 2:11 pm, Aug 26 2006
Posts: 223


yea we figured this out a while back... after line 92, you need to add:

Code
            if ($line == "")
            {
                continue;
            }


in ini.php

--Manick
PHP-IRC Developer
Mad_Clog
Post #323
user avatar
Member
Date: 7:37 am, Aug 28 2006
Posts: 176


Sorry, couldn't find this on the forum.

Thanks for the help once again

Manick
Post #324
user avatar
Admin
Date: 2:14 pm, Aug 28 2006
Posts: 223


yea it was discussed in the channel, not the forum.

--Manick
PHP-IRC Developer
   

Back to PHP-IRC Bugs