blank.php

main 45 lines · 1.5 KB Raw
Alex Alex Commit Initial commit 01/10/2026 09:20
1<?php require_once '../../module.php';
2// Blank/empty module, nice code to start with when making custom stuff.
3
4// Configure module version number
5$response['version']['module'] = 1;
6
7/* Do PHP logic, you got access to:
8 -Znote AAC sql functions (prepared, use ? placeholders):
9 :db()->fetchOne($sql, $params), db()->fetchAll($sql, $params)
10 :db()->execute($sql, $params) for INSERT/UPDATE/DELETE
11 :db()->transaction(function ($db) { ... }) for several writes, all or nothing
12
13 -Config values
14 :etc $config['vocations']
15
16 -Cache system
17 :Sample:
18 $cache = new Cache('engine/cache/api/ApiModuleName');
19 if ($cache->hasExpired()) {
20 $players = db()->fetchAll("SELECT `name`, `level`, `experience` FROM `players` ORDER BY `experience` DESC LIMIT 5;");
21
22 $cache->setContent($players);
23 $cache->save();
24 } else {
25 $players = $cache->load();
26 }
27
28 -Functions found in general.php
29 :When fetching GET or POST from parameters, ALWAYS use getValue($value)
30 :Etc if you want to fetch character name from url, do it like this:
31 $playername = getValue($_GET['name'] ?? null);
32 if ($playername !== false) {
33 // $playername either contains player name, or false if failed to fetch name from GET.
34 }
35 :getValue is often used in 3 ways: Fetch GET and POST values, or sanitize/secure any value you wish.
36 :Check ZnoteAAC\engine\function\general.php for full list of available functions.
37*/
38
39// Save the results of previous logic to the response
40$response['data']['title'] = "The fabulous blank page!";
41
42// Send the response through JSON API
43SendResponse($response);
44?>
45
Top