Not logged in. · Lost password · Register
Forum: General Discussion Installation and Configuration RSS
TIP: How to solve problem with parse_ini_file disabled
How to solve parse_ini_file disabled function
robsongehl #1
Member for a week · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: TIP: How to solve problem with parse_ini_file disabled
Hi!

 Include the override function for parse_ini_file on dokuwiki.
 See at http://www.php.net/parse_ini_file, the function readINIfile works fine:

function readINIfile ($filename, $commentchar) {
  $array1 = file($filename);
  $section = '';
  for ($line_num = 0; $line_num <= sizeof($array1); $line_num++) {
   $filedata = $array1[$line_num];
   $dataline = trim($filedata);
   $firstchar = substr($dataline, 0, 1);
   if ($firstchar!=$commentchar && $dataline!='') {
     //It's an entry (not a comment and not a blank line)
     if ($firstchar == '[' && substr($dataline, -1, 1) == ']') {
       //It's a section
       $section = strtolower(substr($dataline, 1, -1));
     }else{
       //It's a key...
       $delimiter = strpos($dataline, '=');
       if ($delimiter > 0) {
         //...with a value
         $key = strtolower(trim(substr($dataline, 0, $delimiter)));
         $array2[$section][$key] = '';
         $value = trim(substr($dataline, $delimiter + 1));
         while (substr($value, -1, 1) == '\\') {
             //...value continues on the next line
             $value = substr($value, 0, strlen($value)-1);
             $array2[$section][$key] .= stripcslashes($value);
             $line_num++;
             $value = trim($array1[$line_num]);
         }
         $array2[$section][$key] .= stripcslashes($value);
         $array2[$section][$key] = trim($array2[$section][$key]);
         if (substr($array2[$section][$key], 0, 1) == '"' && substr($array2[$section][$key], -1, 1) == '"') {
            $array2[$section][$key] = substr($array2[$section][$key], 1, -1);
         }
       }else{
         //...without a value
         $array2[$section][strtolower(trim($dataline))]='';
       }
     }
   }else{
     //It's a comment or blank line.  Ignore.
   }
  }
  return $array2;
}

 For instalation, remove 'parse_ini_file' from the string in install.php:

    $funcs = explode(' ','addslashes basename call_user_func chmod copy fgets '.
                         'file file_exists fseek flush filesize ftell fopen '.
                         'glob header ignore_user_abort ini_get mail mkdir '.
                         'ob_start opendir readfile realpath '.
                         'rename rmdir serialize session_start unlink usleep '.
                         'preg_replace file_get_contents');

 After install, replace the function on lib\exe\css.php file:


$ini = readINIfile($tplinc.'style.ini');


Best regards,
Robson Gehl
Avatar
chi (Moderator) #2
Member since Jun 2006 · 607 posts · Location: Munich Germany
Group memberships: Global Moderators, Members
Show profile · Link to this post
Nice, could you please also create a wiki page in the wiki.splitbrain.org/wiki:tips: namespace?
Please add [SOLVED] to the initial thread subject if you feel your question has been answered.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please note the verification code from the picture into the text field next to it.
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 1.6.4, © 2003-7 by Yves Goergen
Current time: 2008-05-17, 06:22:51 (UTC +02:00)
WikiForumIRCBugsTranslate