The EuroCMS API

Using REST API.

Generate an API key.

Settings

  • Generate API key
  • disable/enable features what this API key is allowed to use
  • reg_date?
  • expiration_date
  • GET requests limit?
  • IP block?
  • ...

Future features

  • xml output
  • yaml output?

Some basic yaml regex.

$print_r = print_r($_SERVER,true);

echo $print_r;

$match = preg_replace('/[ ]*\[/m', '', "$print_r");

echo preg_replace('/\] => /', ': ', "$match");

// https://3v4l.org/NEsVX
  • Custom output? Serialize and regex de PHP data array to an output that is needed.

We had XML, JSON and now yaml. In the future we could have a new output format. So, having an output creator, seems the best thing to do.

DB structures

api_iddomain_iduser_idgroup_iddescriptionunameapi_keypermission_idcreation_dateexp_daterequests_limitrequests_limit_perrequest_countauth_methodsip_denyip_allowpwordtimezonestatus
1111John's keyjohn{SHA512}1,2,3,4,5,6,7,8,9{creation_date}{exp_date}1000day123pword,api_keynull{CLIENT_IP}{BCRYPT}Europe/Amsterdamenabled
2238JNEnull{SHA512}1,2,3{creation_date}null100week25api_keynullnullnullnullenabled
2238BLDnull{SHA512}9,8,7,6,5{creation_date}nullnullnull54673567api_keyallCLIENT_IP{BCRYPT}Europe/Amsterdamdisabled
  • api_id: auto increment ID
  • domain_id: The domain ID of the domain that is currently being viewed.
  • user_id: The ID of the user that created this API key.
  • group_id: The ID of the group that has rights to this key.
  • description: The description of the API key.
  • uname: The username for this API key. Optional setting
  • api_key: The  - sha512sum - API key. This is used for authentication.
  • permission_id: All of the things this API has permission to.
  • creation_date: the registration date of the API key.
  • exp_date: When this API key will expire.
  • request_limit: The maximum amount of GET requests this api key is allowed to perform.
  • requests_limit_per: If set, the counter is reset per day/week/month.
  • request_count: The total amount of request this API has made.
  • auth_methods: How do you want users to authenticate using this key.
  • ip_deny: IP protect this API key. If this is set, this will block all other IPs instead of the ones specified.
  • ip_allow: Whitelist IPs. Only if the ip_deny is set, will this have any use.
  • pword: The password for this API key. Optional setting
  • timezone: Set the specific timezone for this key.
  • status: Set to enabled or expired, when the key is expired.

example json structure

{
  "api":{
    "headers":{
      "status":"HTTP/1.1 200 Connection established",
      "server":"nginx",
      "date":"Tue, 12 Apr 2022 06:45:32 GMT",
      "content-type":"text/html; charset=UTF-8",
      "expires":"Thu, 19 Nov 1981 08:52:00 GMT",
      "cache-control":"no-store, no-cache, must-revalidate",
      "pragma":"no-cache",
      "x-content-type-options":"nosniff",
      "x-frame-options":"SAMEORIGIN",
      "x-permitted-cross-domain-policies":"none",
      "referrer-policy":"no-referrer-when-downgrade",
      "strict-transport-security":"max-age=15768000",
      "access-control-allow-origin":"*",
      "x-xss-protection":"1; mode=block",
      "X-Firefox-Spdy":"h2"
    },
    "content":"The PHP data array here"
  }
}

Links