rejetto forum

parsing hfs.ini in PHP

raybob · 1 · 3408

0 Members and 1 Guest are viewing this topic.

Offline raybob

  • Tireless poster
  • ****
    • Posts: 453
    • View Profile
    • FileSplat.com
I don't know if anyone would ever have any use for this but I figured I'd share it... here's a PHP script that loads, parses and returns an array of keys in hfs.ini, including separating every account and decoding the usernames and notes.

Code: [Select]
<?php

function loadHFS($file) {

$output = array();

$hfsini preg_split("/\r\n|\n|\r/"file_get_contents("hfs.ini"));

foreach ($hfsini as $string) { if ($string) {

$split explode("=",$string,2);

if (isset($split[0]) && isset($split[1])) { $output[$split[0]] = $split[1]; }
}}

$accounts explode(";",$output['accounts']); $output['accounts'] = array();

foreach ($accounts as $string) { if ($string) {

$string explode("|",$string); $account = array();

foreach ($string as $info) {

$split explode(':',$info,2);

if (isset($split[0]) && isset($split[1])) { $account[$split[0]] = $split[1]; }
}

if (!empty($account['login'])) { $account['login'] = explode(":",base64_decode($account['login'])); }

if (!empty($account['notes'])) {

$notes preg_split("/\r\n|\n|\r/",zlib_decode(base64_decode($account['notes']))); $data = array();

foreach ($notes as $note) {

$split explode("=",$note);

$data[$split[0]] = $split[1];
}

$account['notes'] = $data;
}

array_push($output['accounts'],$account);
}}

return $output;
}

print_rloadHFS("hfs.ini") );

?>