<?php
/*
 *  Copyright (C) 2018 Laksamadi Guko.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
session_start();
// hide all error
error_reporting(0);
if (substr($_SERVER["REQUEST_URI"], -11) == "readcfg.php") {
    header("Location:./");
};
// read config
function _getv($arr,$idx,$delim,$def=''){
    if (!is_array($arr)) return $def;
    $val = isset($arr[$idx]) ? $arr[$idx] : '';
    if ($val === '') return $def;
    $parts = explode($delim,$val,2);
    return isset($parts[1]) ? $parts[1] : $def;
}

$iphost = _getv($data[$session],1,'!', '');
$userhost = _getv($data[$session],2,'@|@', '');
$passwdhost = _getv($data[$session],3,'#|#', '');
$hotspotname = _getv($data[$session],4,'%', '');
$dnsname = _getv($data[$session],5,'^', '');
$currency = _getv($data[$session],6,'&', 'Rp');
$areload = _getv($data[$session],7,'*', '10');
$iface = _getv($data[$session],8,'(', '1');
$infolp = _getv($data[$session],9,')', '');
$idleto = _getv($data[$session],10,'=', 'disable');
$sesname = $session;
$useradm = _getv($data['mikhmon'],1,'<|<', '');
$passadm = _getv($data['mikhmon'],2,'>|>', '');
$livereport = _getv($data[$session],11,'@!@', 'disable');

$cekindo['indo'] = array(
    'RP', 'Rp', 'rp', 'IDR', 'idr', 'RP.', 'Rp.', 'rp.', 'IDR.', 'idr.',
);

$genieacs_url = _getv($data[$session],12,'~','http://localhost:7557');
$genieacs_user = _getv($data[$session],13,'u|u','');
$genieacs_pass = isset($data[$session][14]) ? decrypt(_getv($data[$session],14,'p|p','')) : '';
