rathena / FluxCP

A web-based Control Panel for rAthena servers written in PHP. Manage player accounts, databases, support tickets, etc via your browser.
GNU Lesser General Public License v3.0
180 stars 211 forks source link

Built in API #155

Closed jhasselbring closed 2 years ago

jhasselbring commented 7 years ago

Some of us use REST APIs heavily. Sometime for AJAX requests and sometimes for external apps.

Is there anyway to have this feature built in instead of being forced to do logic in the theme/themeName/header.php.

I was thinking, if the path starts with /API/ before the query, it will cue the Flux to use a different header.php that will handle the proper header();

Akkarinage commented 6 years ago

I'll look into this if anyone can provide real-world usage examples. All i can really think of is user registration, but since a user wanting to register would have access to the internet and the fluxcp site where they want to register there's really no need to expand past the registration page.

Thoughts?

jhasselbring commented 6 years ago

To be clear, I've already build my own custom integration that resides outside of rAthena flux. I purposely did not edit the core flux in case of future updates.

In order to integrate dynamic information such as per server status, online player counts, market data or any data that is stored in the database, theme developers need to build a custom database connections either loading the config or hard coding database credentials.

The most common use case is getting server status and online player count followed by WoE status, market and top players.

The solution I am proposing is as simple as capturing a new $_GET['return'] parameter ie: www.domain.com/flux/?module=server&action=status&return=json if(isset($_GET['return']) && $_GET['return'] == 'json'){ // disable header.php and footer.php header('Content-Type: application/json'); }

jhasselbring commented 6 years ago

With this implemented, using return=json on pages that are not designed to return a json object will print/echo the body source code but that, in theory, will not be a security concern(unless the theme developer is stupid)

jovvybersamin commented 3 years ago

how this one go? @jhasselbring

jhasselbring commented 3 years ago

It didn't go anywhere.

It feels like an open source that's not very open.

jhasselbring commented 3 years ago

It's a paint to build using react/vue because of this lack of cunctionality.

Akkarinage commented 2 years ago

This would be better served as an API built into rAthena itself for serving it's data, instead of adding tools inside of other tools.