pandemonium_engine/modules/web/doc_classes/FileCache.xml

88 lines
3.7 KiB
XML
Raw Normal View History

2022-08-21 00:40:49 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2024-02-25 10:26:26 +01:00
<class name="FileCache" inherits="Reference" version="4.3">
2022-08-21 00:40:49 +02:00
<brief_description>
2024-03-10 10:09:19 +01:00
The FileCache class provide functionality for file caching and name and path sanitization for the web module.
2022-08-21 00:40:49 +02:00
</brief_description>
<description>
2024-03-10 10:09:19 +01:00
The FileCache class provide functionality for file caching and name and path sanitization for the web module.
It helps with avoiding directory traversal attacks, as relative paths are not going to be expanded by accident.
(A directory traversal attach would be if an application receives this get request: [code]server.net/../../../etc/passwd[/code], and it would result in success, if the app then returns the contents of the "passwd" file, which is outside of the root folder of the server.)
2024-03-10 10:09:19 +01:00
It can save contents of files or pages into memory if needed using the [code]set_cached_body()[/code] helper method.
2022-08-21 00:40:49 +02:00
</description>
<tutorials>
</tutorials>
<methods>
<method name="clear">
<return type="void" />
<description>
2024-03-10 10:09:19 +01:00
Clear all internal caches.
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="get_cached_body">
<return type="String" />
<argument index="0" name="path" type="String" />
<description>
2024-03-10 10:09:19 +01:00
Get a previously stored page's or file's body.
2022-08-21 00:40:49 +02:00
</description>
</method>
2023-01-14 13:38:58 +01:00
<method name="get_wwwroot_abs">
<return type="String" />
<description>
2024-03-10 10:09:19 +01:00
Return the set [member wwwroot]'s absolute path.
2023-01-14 13:38:58 +01:00
</description>
</method>
2022-08-21 00:40:49 +02:00
<method name="has_cached_body">
<return type="bool" />
<argument index="0" name="path" type="String" />
<description>
2024-03-10 10:09:19 +01:00
Check whether a page's or file's body is available.
2022-08-21 00:40:49 +02:00
</description>
</method>
<method name="set_cached_body">
<return type="void" />
<argument index="0" name="path" type="String" />
<argument index="1" name="body" type="String" />
<description>
2024-03-10 10:09:19 +01:00
Store a page's or file's body.
2022-08-21 00:40:49 +02:00
</description>
</method>
2023-12-22 19:49:04 +01:00
<method name="wwwroot_get_file_abspath">
2023-01-14 13:38:58 +01:00
<return type="String" />
2023-12-22 19:49:04 +01:00
<argument index="0" name="file_path" type="String" />
2023-01-14 13:38:58 +01:00
<description>
2024-03-10 10:09:19 +01:00
Returns the absolute path to a file if it exists in the given [member wwwroot]. If it doesn't exists returns an empty [String].
Guards against directory traversal.
2024-03-10 10:36:13 +01:00
Note: file path should be the url you want to access the file with, including lead slash. e.g. http://127.0.0.1/a/b/d.jpg -&gt; /a/b/d.jpg
2024-03-10 10:09:19 +01:00
</description>
</method>
<method name="wwwroot_get_simplified_abs_path">
<return type="String" />
<argument index="0" name="file_path" type="String" />
<description>
Returns the absolute path to a file in the given [member wwwroot]. Does not checks if the file exists or not. Returns an empty [String] on error.
Guards against directory traversal.
2024-03-10 10:36:13 +01:00
Note: file path should be the url you want to access the file with, including lead slash. e.g. http://127.0.0.1/a/b/d.jpg -&gt; /a/b/d.jpg
2023-01-14 13:38:58 +01:00
</description>
</method>
2022-08-21 00:40:49 +02:00
<method name="wwwroot_has_file">
<return type="bool" />
<argument index="0" name="file_path" type="String" />
<description>
2024-03-10 10:09:19 +01:00
Check whether a file exists in the given [member wwwroot].
Guards against directory traversal.
2024-03-10 10:36:13 +01:00
Note: file path should be the url you want to access the file with, including lead slash. e.g. http://127.0.0.1/a/b/d.jpg -&gt; /a/b/d.jpg
2022-08-21 00:40:49 +02:00
</description>
</method>
</methods>
<members>
<member name="cache_invalidation_time" type="int" setter="set_cache_invalidation_time" getter="get_cache_invalidation_time" default="0">
2024-03-10 10:09:19 +01:00
How long a page's or file's body should be stored.
2022-08-21 00:40:49 +02:00
</member>
<member name="wwwroot" type="String" setter="set_wwwroot" getter="get_wwwroot" default="&quot;&quot;">
2024-03-10 10:09:19 +01:00
Set a www root directory for this [FileCache]. It can be both relative and absolute.
2022-08-21 00:40:49 +02:00
</member>
</members>
<constants>
</constants>
</class>