if (array_key_exists($flagName, $permissions) && $permissions[$flagName]) {
        $perms |= $flagVal;
    }
}
$jResult .= "theWebUI.showFlags = " . $perms . ";\n";
$jResult .= "theURLs.XMLRPCMountPoint = '" . $XMLRPCMountPoint . "';\n";
$jResult .= "theWebUI.systemInfo = {};\ntheWebUI.systemInfo.php = { canHandleBigFiles : " . (PHP_INT_SIZE <= 4 ? "false" : "true") . " };\n";
if ($handle = opendir('../plugins')) {
    ignore_user_abort(true);
    set_time_limit(0);
    @chmod('/tmp', 0777);
    if (!function_exists('preg_match_all')) {
        $jResult .= "log(theUILang.PCRENotFound);";
    } else {
        $theSettings = new rTorrentSettings();
        $theSettings->obtain();
        if (!$theSettings->linkExist) {
            $jResult .= "log(theUILang.badLinkTorTorrent);";
            $jResult .= "theWebUI.systemInfo.rTorrent = { started: false, version : '?', libVersion : '?' };\n";
        } else {
            $jResult .= "theWebUI.systemInfo.rTorrent = { started: true, version : '" . $theSettings->version . "', libVersion : '" . $theSettings->libVersion . "' };\n";
            if ($do_diagnostic) {
                $up = getUploadsPath();
                $st = getSettingsPath();
                @chmod($up, 0777);
                @chmod($st, 0777);
                @chmod('./test.sh', 0755);
                if (!isUserHavePermission($theSettings->myuid, $theSettings->mygid, $up, 0x7)) {
                    $jResult .= "log(theUILang.badUploadsPath+' (" . $up . ")');";
                }
                if (!isUserHavePermission($theSettings->myuid, $theSettings->mygid, $st, 0x7)) {