Files
core/Zotlabs/Module
Harald Eilertsen 3d3580b23f Validate requests to perfstats
Make some stricter rules for accessing the perfstats module. We only
want to respond to GET request for json data made by a site admin.

This means we also need to pass along the credentials in the request.
Didn't immediately figure out how to do that using `z_fetch_url`, so we
just fall back to using the JavaScript to populate the widget. This
makes it idle for about 5 sec before it gets the first data sample.

I think that's probably OK.

Project......: Performance Profiling
Sponsored-by.: NLnet NGI0 Commons Fund
2026-02-23 21:21:09 +01:00
..
2025-04-23 18:17:23 +00:00
2025-04-15 14:28:42 +00:00
2021-08-22 18:56:04 +00:00
2024-11-17 16:17:05 +01:00
2024-07-23 22:08:42 +00:00
2024-11-09 08:45:45 +01:00
2024-11-09 08:45:45 +01:00
2023-09-21 08:34:02 +00:00
2023-02-14 07:33:05 +00:00
2023-08-28 08:11:32 +00:00
2023-03-19 13:29:35 +00:00
2024-11-09 08:45:45 +01:00
2022-10-18 12:39:13 +02:00
2021-03-11 20:11:05 +00:00
2023-09-21 08:34:02 +00:00
2021-12-15 12:17:19 +00:00
2024-02-29 17:35:05 +00:00
2024-11-14 18:40:15 +00:00
2022-10-21 11:20:23 +02:00
2025-04-04 15:34:55 +00:00
2024-03-09 21:00:13 +00:00
2020-12-14 11:02:20 +00:00
2021-03-01 18:48:11 +01:00
2024-11-14 18:40:15 +00:00
2024-10-11 17:16:44 +02:00
2021-10-22 07:27:37 +00:00
2024-11-14 12:47:40 +01:00
2023-09-21 08:34:02 +00:00
2025-10-10 15:41:54 +00:00
2025-11-11 11:47:57 +00:00
2022-10-23 14:02:19 +02:00
2023-07-25 09:07:32 -04:00
2022-10-26 18:12:56 +00:00
2024-11-14 18:40:15 +00:00
2024-11-09 08:45:45 +01:00
2024-11-14 18:40:15 +00:00
2025-04-21 11:52:34 +00:00
2022-09-14 12:31:19 +00:00
2025-11-11 11:47:57 +00:00
2024-11-14 18:40:15 +00:00
2022-11-03 11:57:35 +00:00
2026-02-23 21:21:09 +01:00
2024-11-09 08:45:45 +01:00
2022-10-20 13:16:03 +00:00
2023-06-02 11:33:44 +00:00
2025-05-16 20:43:04 +00:00
2022-10-12 10:02:18 +00:00
2022-10-23 14:02:19 +02:00
2024-08-02 08:50:50 +00:00
2021-08-26 11:57:50 +00:00
2025-10-16 08:20:55 +00:00
2021-03-01 18:48:11 +01:00
2024-11-18 23:15:29 +01:00
2026-01-22 15:26:20 +05:30
2022-10-23 14:02:19 +02:00
2025-10-23 14:46:04 +02:00
AS2
2024-02-25 19:29:50 +00:00
2022-10-20 11:15:06 +02:00
2024-03-09 20:53:18 +00:00
2024-11-09 08:45:45 +01:00
2024-06-26 09:35:53 +00:00
2022-10-13 16:38:18 +02:00
2024-11-17 07:58:11 +00:00
2022-10-23 14:02:19 +02:00
2024-11-14 18:40:15 +00:00
2022-10-21 11:20:23 +02:00
2023-03-08 13:15:33 +00:00
2021-12-15 12:17:19 +00:00
2022-11-03 15:26:46 +00:00
2022-10-21 11:20:23 +02:00
2023-06-02 11:33:44 +00:00
2022-10-12 10:02:18 +00:00

Zotlabs/Module

This directory contains controller modules for handling web requests. The lowercase class name indicates the head of the URL path which this module handles. There are other methods of attaching (routing) URL paths to controllers, but this is the primary method used in this project.

Module controllers MUST reside in this directory and namespace to be autoloaded (unless other specific routing methods are employed). They typically use and extend the class definition in Zotlabs/Web/Controller as a template.

Template:

<?php

namespace Zotlabs\Web;


class Controller {

	function init() {}
	function post() {}
	function get() {}

}

Typical Module declaration for the '/foo' URL route:

<?php
namespace Zotlabs\Module;

class Foo extends \Zotlabs\Web\Controller {

	function init() {
		// init() handler goes here
	}

	function post() {
		// post handler goes here
	}

	function get() {
		return 'Hello world.' . EOL;
	}

}

This model provides callbacks for public functions named init(), post(), and get(). init() is always called. post() is called if $_POST variables are present, and get() is called if none of the prior functions terminated the handler. The get() method typically retuns a string which represents the contents of the content region of the resulting page. Modules which emit json, xml or other machine-readable formats typically emit their contents inside the init() function and call 'killme()' to terminate the Module.

Modules are passed the URL path as argc,argv arguments. For a path such as

https://mysite.something/foo/bar/baz

The app will typically invoke the Module class 'Foo' and pass it

$x = argc(); // $x = 3

$x = argv(0); // $x = 'foo'
$x = argv(1); // $x = 'bar'
$x = argv(2); // $x = 'baz'

These are handled in a similar fashion to their counterparts in the Unix shell or C/C++ languages. Do not confuse the argc(),argv() functions with the global variables $argc,$argv which are passed to command line programs. These are handled separately by command line and Zotlabs/Daemon class functions.