}
    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $data->ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    $content = getStandaloneFile('dynmap_webchat.json');
    $gotold = false;
    if (isset($content)) {
        $old_messages = json_decode($content, true);
        $gotold = true;
    }
    if (!empty($old_messages)) {
        foreach ($old_messages as $message) {
            if ($timestamp - $config['updaterate'] - 10000 < $message['timestamp']) {
                $new_messages[] = $message;
            }
        }
    }
    $new_messages[] = $data;
    if ($gotold) {
        updateStandaloneFile('dynmap_webchat.json', json_encode($new_messages));
    } else {
        insertStandaloneFile('dynmap_webchat.json', json_encode($new_messages));
    }
    $_SESSION['lastchat'] = time() + $msginterval;
    echo "{ \"error\" : \"none\" }";
} elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && $lastchat > time()) {
    header('HTTP/1.1 403 Forbidden');
} else {
    echo "{ \"error\" : \"none\" }";
}
cleanupDb();
Example #2
0
            } else {
                $lines = array();
                $isnew = true;
            }
            if (!empty($lines)) {
                $cnt = count($lines) - 1;
                for ($i = 1; $i < $cnt; $i++) {
                    list($uid, $pc, $hsh) = split('=', rtrim($lines[$i]));
                    if ($uid == $useridlc) {
                        continue;
                    }
                    if (array_key_exists($uid, $pendingreg)) {
                        $newlines[] = $uid . '=' . $pc . '=' . $hsh;
                    }
                }
            }
            $newlines[] = $useridlc . '=' . $passcode . '=' . $hash;
            if ($isnew) {
                insertStandaloneFile('dynmap_reg.php', implode("\n", $newlines));
            } else {
                updateStandaloneFile('dynmap_reg.php', implode("\n", $newlines));
            }
        }
    }
}
if ($good) {
    echo "{ \"result\": \"success\" }";
} else {
    echo "{ \"result\": \"registerfailed\" }";
}
cleanupDb();