HFS: 宏脚本命令大全: Difference between revisions

From rejetto wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 65: Line 65:
   case C.split(B)[1]: return D;
   case C.split(B)[1]: return D;
   case C.split(B)[2]: return D;
   case C.split(B)[2]: return D;
  // ...
   case E.split(B)[0]: return F;
   case E.split(B)[0]: return F;
   case E.split(B)[1]: return F;
   case E.split(B)[1]: return F;
   ...
   // ...
}
}
</nowiki></pre>
</nowiki></pre>
Line 87: Line 88:


; for | A | B | C | D | E
; for | A | B | C | D | E
: repeats D by replacing variable <tt>{.^A.}</tt> with every value between B and C (they are meant to be numbers).
: ''释义:定义变量 A,使其值从 B 依次增加到 C,分别替换 D 中的 A 变量并扩展''
: Optionally you can specify a ''step'' for the numbers: that is, instead of going 1-by-1, they can go 2-by-2. The optional ''step'' is specified at position D; in such case the ''body'' is moved from position D to position E.
: 重复扩展为 D,且将其中的 <tt>{.^A.}</tt> 变量替换为 B C 之间的每一个数值(它们需要都为数字,步进为 1)。
: Remember to use quoting for the body.
: 您也可以在 D 处使用可选变量 ''step'',这样可以更改数值的步进。这样做时此宏将重复扩展为 E。
: 请记得引用在 D E 处的宏文本。


; for each | A | B | C ... | Z
; for each | A | B | C ... | Z
: a (sometimes) handier version of ''for'', that will repeat Z but replacing variable <tt>{.^A.}</tt> with value B the first time, value C the second time, D etc etc. Remember to quote the body.  
: ''释义:定义变量 A,使其值分别为 B, C, D, ...,分别替换最后一个参数中的 A 变量并扩展''
: example: <tt>{.for each|i|10|100|1000|{:now it's {.^i.} :}.}</tt>
: 一个有时更有用的 ''for'' 版本。请记得引用最后一个变量中的宏文本。
: : <tt>{.for each|i|10|100|1000|{:now it's {.^i.} :}.}</tt>


; while | A | B
; while | A | B
: repeats B for as long as A is true. Both B is automatically dequoted. If A is quoted, then it's expanded, otherwise is considered the a variable name.
: ''释义:当 A 为真时,重复扩展为 B''
: Optional parameter ''else'' will be expanded if B is never done.
: 当 A 为真时,重复扩展为 B。B 变量将被自动取消引用。若 A 被引用,它将被扩展,否则它会成为替换 B 中相应变量的一个变量。
: Optional parameter ''timeout'' let you specify (in seconds) the maximum time the loop can live before it is stopped. It's 1 second by default.
: 可选参数 ''else'' 的值将会在 B 未被执行过时扩展。
: Optional parameter ''var'' saves the output in a variable instead of just expanding to it.
: 可选参数 ''timeout'' 可以让您定义此循环可进行的最大时间(单位为秒)。在未定义时它默认为 1 秒。
: Example: <tt>{.while|#x|{: {.dec|#x.} welcome! :}.}</tt> will welcome 10 times if <tt>#x</tt> is 10.
: 可选参数 ''var'' 会使宏不扩展,而将本应扩展的值存入定义的变量。
: : <tt>{.while|#x|{: {.dec|#x.} 欢迎! :}.}</tt> 会在 <tt>#x</tt> 变量值为 10 时欢迎您 10 次。


; after the list | A
; after the list | A

Revision as of 10:51, 25 September 2020

宏脚本命令也叫模板宏。HFS 已预置许多功能性的指令,而您可以将其用于模板或事件文件中以创建、改进模板,制作出原本没有的功能。

一些指令会简单地扩展为文本,用以显示一些信息。也有一些指令可以用以进行服务器端操作,例如删除文件。

每一个指令都以名称的形式表达,有时也需要参数,用管道字符“|”分隔。

以下将介绍一些宏,以供您使用。

在阅读之前,您可能需要首先了解模板编写

逻辑与流程

if | A | B | C
释义:如果 A 为真,那么 B,否则 C
如果 A 为真,那么 B 将被执行(扩展),否则 C 将被执行(扩展)。当它扩展为 B 时,C 就消失不见了。反之亦然。
如何判断 A 为真?假值即空字符串或者数字 0。其余情况都为真。
当 B 或 C 为宏时,请引用它们。
if not | A | B | C
释义:如果 A 为假,那么 B,否则 C
if 相似,但是逻辑相反。
not | A
释义:非 A
反转逻辑。A 真则为假,A 假则为真。
and | A | B | ...
释义:A 且 B ……
当 A 与 B 都为真时则为真。具体说来,当结果为真时,它将返回(扩展为)最后一个参数。与 JavaScript 和 Python 相似,参数的个数没有限制。
or | A | B | ...
释义:A 或 B ……
如果 A 与 B 其中有一个为真,则为真。具体说来,它将返回第一个为真的值。如果参数都为假,那么它扩展为假值。这与 JavaScript 和 Python 相似。
由于 HFS 宏基于字符串,您可以这样:{.if| A B | C .}。A 与 B 连接为单个字符串,如果有真值则为真。这可以方便地替代 {.or.}。
xor | A | B
释义:A 异或 B
当 A、B 中仅有一个为真时扩展为真值。
= | A | B | ...
释义:A 等于 B ……
若 A 与 B 相等则为真。它对字母大小写敏感。不等于则为: != 或者 <>。两者等价。参数的个数没有限制。
> | A | B | ...
释义:A 大于 B ……
若 A 大于 B 则为真。小于则为 <。参数的个数没有限制。
>= | A | B
释义:A 大于或等于 B ……
若 A 大于或等于 B 则为真。小于或等于则为 <=。参数的个数没有限制。
between | A | B | C
释义:B 在 A 与 C 之间
若 B 在 A 与 C 之间则为真。包含 A、C(即闭区间)。
between! | A | B | C
释义:B 在 A 与 C 之间
若 B 在 A 与 C 之间则为真。不包含 A、C(即开区间)。
switch | A | B | C | D | E | F ...
释义:把 C,E…… 用 B 内容分隔后,若 A 包含于 C 中则 D,若 A 包含于 E 中则 F ……
这对非程序员可能难以理解。您可以参阅维基百科相关内容并进行探究。
switch(A) {
  case C.split(B)[0]: return D;
  case C.split(B)[1]: return D;
  case C.split(B)[2]: return D;
  // ...
  case E.split(B)[0]: return F;
  case E.split(B)[1]: return F;
  // ...
}
B 是 C 与 E 内容的分隔符。更确切地说:如果 C 中包含几个用特定字符分隔的结果(如:3,5,7),您想让它们都返回 D 值,那么您可以指定一个 B 参数。
C 与 D、E 与 F 都是配对的。若最后一个参数未配对,那么它将作为默认(default)返回值——即当其他条件都不匹配时被返回。
以下为维基百科页面中第一个样例在 HFS 宏中的表示:
{.switch|%n%|,|
  0|您输入了零。|
  3,5,7|%n% 是一个质数。|
  4,6,8|%n% 是一个偶数。|
  2|%n% 既是质数又是偶数。|
  1,9|%n% 是一个完全平方数。|
  仅支持输入个位数。
.}

若需要使用许多 {.if.} 和 {.=.},{.switch.} 无疑是更好的选择。

for | A | B | C | D | E
释义:定义变量 A,使其值从 B 依次增加到 C,分别替换 D 中的 A 变量并扩展
重复扩展为 D,且将其中的 {.^A.} 变量替换为 B 与 C 之间的每一个数值(它们需要都为数字,步进为 1)。
您也可以在 D 处使用可选变量 step,这样可以更改数值的步进。这样做时此宏将重复扩展为 E。
请记得引用在 D 或 E 处的宏文本。
for each | A | B | C ... | Z
释义:定义变量 A,使其值分别为 B, C, D, ...,分别替换最后一个参数中的 A 变量并扩展
一个有时更有用的 for 版本。请记得引用最后一个变量中的宏文本。
例: {.for each|i|10|100|1000|{:now it's {.^i.} :}.}
while | A | B
释义:当 A 为真时,重复扩展为 B
当 A 为真时,重复扩展为 B。B 变量将被自动取消引用。若 A 被引用,它将被扩展,否则它会成为替换 B 中相应变量的一个变量。
可选参数 else 的值将会在 B 未被执行过时扩展。
可选参数 timeout 可以让您定义此循环可进行的最大时间(单位为秒)。在未定义时它默认为 1 秒。
可选参数 var 会使宏不扩展,而将本应扩展的值存入定义的变量。
如: {.while|#x|{: {.dec|#x.} 欢迎! :}.} 会在 #x 变量值为 10 时欢迎您 10 次。
after the list | A
释义:仅在文件列表工作结束后执行 A
解除引用并执行 A——仅在文件列表工作结束之后才会如此。
dequote | A
释义:解除 A 的引用
如果 A 被 {:引用:},那么解除其引用(其中包含的宏文本也会被执行)。
123 if 2 | A | B | C
释义:如果 B 为真,则扩展为 ABC
如果 B 为真,则扩展为 ABC 连接后的结果;否则扩展为空。
这是 {.if | B |{: A B C :}.} 的快捷方式。
break
释义:中断
中断宏的执行。
可选参数 if 可以添加中断时的限制条件(相当于嵌套一个 {.if.})。
可选参数的用法示例:{.break|if={.=|%user%|root.}.}
可选参数 result 会在宏中断后显示一行文本(仅当与可选参数 if 配合使用时)。

数据的获取

section | A
释义:获取节 A 的内容
A 是您希望加载的一个 [节] 的名称。Note: till build #160 it was case sensitive.
Optional parameter file to load the section from an external file.
Optional parameter back=1 will work in diff templates to access the section in the original template. So you can access it even if you overwrote it.
Example: {.section|names|file=tables.txt.}
get | A
where A is the name of a value you are interested in, like to know if an option is enabled or not.
This is a list of supported values for A:
can upload
true if in the current folder the user is allowed to upload files. An additional parameter path will tell you about a different folder instead of the current one.
can delete
true if the user is allowed to delete the current item. An additional parameter path will tell you about a different folder instead of the current one.
can access
true if the current item in list is accessible by the user. An additional parameter path will tell you about a different folder instead of the current one.
can recur
true if the option Recursive listing is enabled
can archive
true if the current item in list is archivable. outside the list it refers to the current folder.
is new
true if the current item in list is flagged as "new"
accounts
semicolon-separated list of username of all accounts. By specifying an additional parameter groups you'll get only groups. Respectively, a parameter users will give you only non-group accounts.
stop spiders
true if stop spider option is enabled.
protocolon
expands to http:// unless you enabled option URLs starting with https in which case it expands to https:// (please notice the final S).
speed limit
gives the current global speed limit, as a number (in KB/s).
agent
Tells the user's browser. E.g., Firefox expands to Mozilla and IE8 will expand to MSIE 8.0.
urlvar | A
url variable. Let's say in the url you see ?sort=s and you want to know that s, just use the macro urlvar|sort.
Optional parameter var will put the resulting text in the specified variable.
postvar | A
just as urlvar but reads the value from the POST part of the request instead of the URL.
Optional parameter var will put the resulting text in the specified variable.
header | A
get any value from the HTTP request header. A is the name of the header field. This is something mostly for techies. Don't fret if you don't even know what the header is.
time | A
returns current time information. The format is specified by optional parameter A. Refer to this page for format syntax. If A is not supplied, value "c" will be used.
Optional parameter when to specify a time other than current.
Optional parameter offset to specify the number of days differing from the current time.
cookie | A
expands to the value A passed by the browser.
With an optional parameter value you will set a new value.
Every known standard parameter for cookies is accepted, as expires and path. Expires can be expressed in many ways: if it starts with + or - will be the number of days in the future or in the past. If it's a number will be considered as unix time format or HFS format. You can even specify it as a date: 2/4/2013.
Example: {.cookie|step.} will give you the current value
Example: {.cookie|step|value=3|expires=+30.} will set step to 3 and the cookie will expire in 30 days.
Setting a cookie can also be accomplished by using {.add header.} with Set-Cookie.

Data manipulation

substring | A | B | C
cut C from A to B, with B not included.
Example: substring|(|belong|you (are) belong to us.} will be (are).
If A is not specified, C is taken from the start. If B is not specified, C is taken to the end.
Optional parameter case=1 to turn on case sensitivity.
Optional parameter include to say if A and/or B must be included. Values: 0 (none), 1 (only A), 2 (only B), 1+2 (both).
cut | A | B | C
cut C from position A, for B characters. The difference with macro substring is that here you specify where to cut by numeric positions.
Example: cut|2|3|abcdef will expand to bcd
If you don't specify A, it defaults to 1. If you don't specify B, it defaults to the length of C.
If A is negative, then you are counting backward from the end of C. If B is negative, then you are considering the length of C minus the amount of B.
Optional parameter to will let you specify the number of character to cut. B is ignored in this case.
Optional parameter var specifies the variable name to work on. You can use it instead of C, but in such case the output will be stored in the variable.
Optional parameter remainder works only with parameter var, and let you specify a variable name where all that is cut out is stored.
You can use named parameter from instead of A, size instead of B, and what instead of C.
Example: cut|from=3|size=2|abcdef will expand to cd
repeat | A | B
repeat B for A times. Example: for A=5 and B=+ the result is +++++
upper | A
returns A with all letters uppercased. Example: for A=Hello the result is HELLO
lower | A
returns A with all letters lowercased. Example: for A=Hello the result is hello
trim | A
returns A with any leading and trailing space removed
replace | A | B | C
returns C with every A replaced with B. This command can apply multiple replacements by having multiple pairs of parameters A-B. But you always need to have a final parameter C, that's the text that will be manipulated.
Optional parameter var in place of parameter C will make use of the specified variable as both input and output.
calc | A
return the result of the mathematical expression A. Example: for 1+(5/2) the result is 3.5
supported operators are + - * / % (as modulus)
round | A | B
returns rounded value of A, where A is a non-integer number, and B is the number of digits after the decimal point. B is zero by default if not specified.
add | A | B
returns A+B where A and B are numbers
sub | A | B
returns A-B where A and B are numbers
mul | A | B
returns A*B where A and B are numbers
div | A | B
returns A/B where A and B are numbers
mod | A | B
returns A modulus B where A and B are numbers
min | A | B ...
returns the minimum over all parameters. You can have more than 2 parameters.
max | A | B ...
returns the maximum over all parameters. You can have more than 2 parameters.
count substring | A | B
tells the number of times A is present in B (case sensitive)
encodeuri | A
all characters are encoded in the %XX form used for URLs, except alphanumerics and #/,&?:$@=+
You can add more characters to the set that will be encoded by using the optional parameter add, as well as you can decide to exclude some characters by using the optional parameter not.
You can also decide to specify the whole set, one by one, with optional parameter only.
In all these optional parameters you can specify many characters just by having them as a string, one after another.
decodeuri | A
all encoded characters in the form %XX are decoded.
convert | A | B | C
converts C from charset A to charset B. At the moment only supported charsets are ansi and utf-8.
force ansi | A
if template is using UTF-8 charset, then A is converted to ANSI. Otherwise A is left unchanged.
maybe utf8 | A
if template is using UTF-8 charset, then A is converted to UTF-8. Otherwise A is left unchanged.
123 if 2 | A | B | C
returns nothing if B is false/empty, otherwise a concatenation of ABC.
chr | A | B ...
returns characters with ANSI code A, B, etc. Numbers are decimal. To use hex numbers, precede them with an "x".
Example: {.chr|13|10|x0D|x0A.}
js encode | A | B
Encodes characters specified by B using javascript encoding for strings, in text A. If you mean to encode characters a and b, parameter B should simply be ab.
If B is not specified, characters encoded are only single-quote and double-quotes. This is supposed to be the frequently used case, when you are passing some data into a javascript string that's enclosed in any form of quotes.

Variables and functions

set | A | B
what you actually do is to bind B (the content) to the name A (the variable). It is called variable because you can always change the content of it. You can later recall B by passing A to the macro "call".
You can have as many variables as you want. All of them will be bound to the single page/request. When the page is finished and provided (or anyway the execution flow is over) the variables are cleared (and lost) unless you prepend a # to the name (e.g. #myVariable). In this latter case you are using global variables. These will survive until you clear them explicitly.
If you are used to programming, you may already know what variables and functions are. Here functions are a special case of variable, when the content is made of other commands. When you specify commands for the function, you need to quote them, otherwise they will be executed immediately while instead you want them to be executed at call-time. You can also have parameters: the first one is $1, and so on, that you can specify inside the body B.
Remember to use quoting if you use macros in the body (B).
Example: {.set|x|1.} or {.set|double|{:{.mul|$1|2.}:}.}
Optional parameter var will let you copy variables.
Example: {.set|y|var=x.}
Optional parameter mode can be append or prepend, to concatenate existing content of the variable to the new content, as AB or BA.
Example: {.set|x| is a good boy|mode=append.}
call | A | B | C | ...
this macro (shortcut by ^) expands to the value bound to A. Such value can be a number or a text, doesn't matter. If the value contains symbols $1 and $2, then they are replaced with the parameters B and C (and so on).
Example referring to above: {.call|double|15.} will expand to 30
You can find some examples for "set" and "call" on the forum.
inc | A | B
if A is a variable with numeric value, then its value is incremented by the number B. If B is omitted, it defaults to 1.
dec | A | B
just as the inc above, but the value is decremented
count | A
each call returns and increments A, so the sequence will be 0 1 2 3...
variable A is not actually a variable, you can't access it throught {.^A.} and its value can be retrieved only through another call to count.
from table | A | B
A is the table and B is the key. The table is a variable or a section with this form
key1=value1
key2=value2
key3=value3
Let's say such text is the content of variable foo, then to get value2 you should do {.from table|foo|key2.}. (yes, poetry)
If it was the content of table [bar] instead, then you should do {.from table|$bar|key2.}.
set table | A | B
it's the counterpart of from table. A is the name of the table, while B is in the form key=value.
If the key already exists, it's replaced, added otherwise.
Example: set table|foo|key2=new value
Loading entire database-like TXT files can be achieved by replacing A with the database path:
{.for each|value|{.replace|;|{.no pipe||.}|{.load| A .}.}|{:{.if|{.^value.}|{:{.set table|table|{.^value.}.}:}.}:}.}
The database file must use the syntax of key1=value1;key2=value2;key3=value3;
cache | A | B | C
expands to retrieved value B from cache-table A. If not found, the new value C will be set. You can quote C if you need it.
This is a very useful tool when C takes too much time and you want to be sure you will do it only once.
Example: {.cache|#countries|%ip%|{:{.load|http://server/giveMeTheCoutry?ip=%ip% .}:}.}
var domain | A
returns a list of all variable names starting with prefix A, separated by |.
Optional parameter separator to specify a different separator.
Optional parameter get=values will return variable values instead of names.

Localization

Here goes a macro useful for template localization.

Inside the template you can use identifiers (IDs) instead of real text. So you can gather all the text in one place, and ease the work of whom wants to translate to another language.

Lets say that you have a link <a href ='..'>Go up one level</a>. You can replace with <a href ='..'>{.!up.}</a>, moving the text to section [special:strings].

[special:strings]
up=Go up one level

You can optionally provide a parameter (like {.!up|Go to parent folder.}) that will be the default text in case up is not found in [special:strings].


If no parameter is provided, then the ID itself will be used as default text.

File manipulation

Consider most of these macros work only with operating system oriented paths, not the ones of the virtual file system.

load | A
you'll love this one. You can specify A as a file name, or as a URL. It will load and expand to it. The file or URL you specify must be accessible from the server machine. A can be C:\windows\win.ini or also http://another_hfs_in_lan/the_file_i_want.txt.
With an optional parameter var you can specify the name of a variable where the whole content of the file will be stored. In such case, the macro will not expand to the content of the file, it's just in the var.
Optional parameter from to specify an offset from where to start reading.
Optional parameter size to specify how much to read.
Optional parameter to to specify the last byte to read, as an offset from the beginning.
All parameters from, size and to are expressed as number of bytes.
Example: {.load|document.txt|var=mytext.} or {.load|http://www.domain.tld/test.txt.}
filesize | A
tells you the size in bytes of the file A. At the moment URL are not supported, only local filenames.
save | A | B
stores B to file path A. The path can be absolute, URI based or relative to HFS folder.
You can supply an optional parameter var instead of B, and the content of the specified variable will be saved.
append | A | B
add B at the end of file A. This may is also useful to keep special logs.
delete | A
moves the file A to the recycle bin.
Optional parameter forced=1 will force deletion in case the bin is not available.
Optional parameter bin=0 will delete the file permanently instead of moving to the recycled bin.
rename | A | B
renames the file A to B. Files can be specified with their disk path or in the URI form.
md5 file | A
computes and expands to the MD5 hash for file A.
copy | A | B
copies file A to B, where B can be a folder or a full path+filename. A can eventually be specified in the URI form.
move | A | B
as copy, but A is moved instead of duplicated.
chdir | A
changes the current working directory of the HFS process.
mkdir | A
creates the specified folder. URI is supported in A, but it must refer a real folder.
exists | A
checks A for existence, may it be a file or folder.
is file | A
checks A for existence as a file.
filename | A
returns only the filename part of A, removing eventual path information.
filepath | A
returns only the path of A, removing the file name.
filetime | A
returns timestamp for file A, express in the usual format.
disk free | A
returns available disk space for specified path in bytes. For example, to display available disk space for drive C:\ in Gigabytes use : {.round|{.div| {.disk free|C:\.} | 1073741824.}|2.}
dir | A
lists all the files found at path A, separated by |.
Optional parameter separator to specify a different separator.
file changed | A
returns true if file A has changed since last time checked (with this same command).
Optional second parameter will specify a variable name where to load the content of file A if the check returns true.

Virtual File System manipulation

add folder | A | B | C
adds a folder to the virtual file system. A specifies real or virtual, while B is the name of the folder.
For real folders B should be the path on disk, but if published name is different than the real one, you can specify the path in parameter B, and the name in C.
Where in place of a simple name, you specify a virtual path, it will be used to place the folder (otherwise it will be place on the root).
Any existent folder with same name will be overwritten, unless you specify a parameter overwrite=0.
Example: {.add folder|virtual|/personal/my pictures.}
a virtual folder "my pictures" will be added under existing folder "personal".
Example: {.add folder|real|C:\music|my music|overwrite=0.}
folder on hard disk C:\music is published with public "my music". If a folder with same name is in the VFS, it's left untouched and no new folder is created.
set item | A
modifies the item A in the virtual file system by using any of these optional parameters
hide
set to 1/0 to decide item visibility
hide tree
set to 1/0 to decide item visibility and sub-items
no log
set to 1/0 to decide item logging
not as download
set 1/0, it's the same as don't consider as a download. For folders, set it to * for all files, or any other file mask you want.
comment
set the comment
resource
Set the resource. It's the physical path for files and real folders, or the URL for links.
archivable
Set whether the folder is archivable or not.
browsable
Set whether or not the folder is browsable.
download forbidden
Set whether or not to forbid downloading from this folder
files filter
Show only certain files in the folder.
folders filter
Show only certain folders in the folder.
diff template
Change the diff template of a vfs item.
Example: {.set item|private files|hide=0|comment=you should never see this!.}
access / delete / upload
you can set permissions on the item, by specifying a list of usernames.
Example: set item|videos|upload=robert will give account robert the ability to upload files in /videos.
Moreover, you can prefix permission by add or remove. In the previous example you set the upload permission. If mike already had upload permission, it is now lost. To add robert instead of just overwriting, you should {.set item|videos|add upload=robert.}. Now mike is happy too. As well, if you change your mind, and want to revoke your grant, just set item|videos|remove upload=robert.
You can specify more than one username this way: robert;mike;rupert.
Special usernames are @anonymous @any account @anyone.
get item | A | B
retrieves information B about VFS item specified by A.
Supported values for B are: exists, comment, resource, hide, hide tree, no log, not as download, access, upload, delete.
Example: {.get item|/putYourFilesHere|upload.} will tell you who is allowed to upload files in that folder.
vfs select | A
A specifies what VFS item to select, but it's optional. If no parameter is provided, the currently selected item is returned.
If A is next, the item coming after the current selection becomes the new selection.
If A is a named parameter path, then you are specifying what item to select in the URI form.
Example: {.vfs select| path=/ .} will reset selection to the home/root, and looping through {.vfs select| next .} will select every VFS item, until {.vfs select.} is false (an empty string).
vfs to disk | A
a web path (URI) is converted to its related drive path. Relative paths like .. are calculated based on the VFS folder where the script is running.

Connections control

disconnect | A | B
with no parameters, it disconnects current connection. If A is supplied, it is considered an IP mask, and every connection matching it (instead of the current one) will be disconnected. If also B is supplied, it will select only connections with port number same as B.
set speed limit for connection | A
set a speed limit A in KB/s for the current connection
set speed limit for address | A | B
set a speed limit B in KB/s for all connections coming from address A (no masks allowed).
When A is omitted, then it actually sets the value for the option Speed limit for single address in the GUI.
disconnection reason | A
this reason determines if a download must be aborted. Any value will abort the download, but if the value is empty the download goes on.
This macro will always return the value of the reason just before its call. So with a single call you are reading and setting the value. If no parameter is specified, then you are only reading.
Optional named parameter if=CONDITION is a shortcut for {.if|CONDITION|{:{.disconnection reason.}:}.}
Example: {.disconnection reason|Try firefox|if={.{.get|agent.} != Mozilla.}.}
add header | A
adds line A to the HTTP header.
redirect | A
tells the browser to change to a different address (the specified one).
current downloads
expands to the number of current downloads.
Optional named parameter user will count only downloads made by specified user.
Optional named parameter ip will count only downloads made by the specified address.
Optional parameter file=this will count only downloads of this current file.
Example: {.current downloads|user=%user%|file=this.} will tell you how many connections this user is using to download this same file.
current downloads of file
number of current downloads of current file.
If an unnamed optional parameter is specified, it is used as IP mask, and only matching connections will be counted.
If the parameter is given name user, only connections by such user will be counted.

Account manipulation

set account | A | ...
with this command you can change all attributes of the account whose username is specified in first parameter. If the username is left empty, current username is used, given this makes sense in current context.
Other parameters are the attributes you want to change, in the form set account|username|thing=value|thing2=value2.
Here is a list of such attributes
password
set a new password
newname
set a new username
redirect
set the homonymous field
no limits
set the homonymous field (true/false)
enabled
set the homonymous field (true/false)
is group
set the homonymous field (true/false)
member of
set the member of field (specify more than one group separating by semicolons ";" )
add member of
add more groups to the above
remove member of
remove some groups to the above
notes
set the homonymous field
notes key
set the notes as it was a table with {.set table.}
Example: {.set account|mike|notes key=last time=%timestamp%.}
new account | A | ...
creates a new account with username A. After the username, you can also specify all the values available in the set account macro.
delete account | A
delete specified account (by username).
get account | A | B
expands to the value of property B of account A.
Supported value for B are redirect, no limits, enabled, is group, member of, notes, notes key. Group names for member of are semicolon-separated. Special case for notes key where you should specify the key to retrieve, while the notes are treated as a table, just as for {.from table.}.
If A is omitted, current username is used, given this makes sense in current context.
member of | A
true if the current user is member of group A (specify more than one group separating by semicolons ";").
Optional parameter user to check a different user.
Example member of|administrators|user=rejetto
If A is omitted, you will get the full membership for current (or specified) user. This is different from {.get account||member of.} because this latter form will consider only direct first-level membership, while {.member of.} will actually consider membership at any level.

Others

comment | A
this is just discarded. It's for your convenience, to put a comment in the template. HTML comments are readable by visitors if they use show html source in their browser. Using this macro you will have comments that will never leave your server.
length | A
if A is 5 characters length, like abcde, it expands to 5.
Optional parameter var in place of A, will work on the specified variable instead of considering A as text.
match | A | B
it is true if the content B is matched by the mask A.
match address | A | B
just like the macro match, but the mask supports ip ranges like 10.0.0.1-10.0.0.25
random | A | B | C | ...
it expands to any of the parameters, randomly
random number | A | B
if only A is specified then a number between 0 and A is generated. If also B is specified then the number will be between A and B (included).
pos | A | B
expands to the position of A in B. Zero if not found.
Optional parameter from will start searching from specified position.
Optional parameter case will decide case sensitivity. Default is: insensitive.
Example pos|the|i'm the alpha and the omega|from=14|case=1 expands to 19
regexp | A | B
Try to match pattern A on text B.
When the pattern doesn't match, it just expands to nothing (then, false).
When it does, the matched sub-pattern is returned.
You can provide optional parameter var instead of B, and the text will be the content of the specified variable.
Optional parameter case will determine case sensitivity. (off by default)
Optional parameter sub will specify the name of a variable that will be set as a table, where you can retrieve every sub-pattern by numerical index.
If optional parameter replace=YYY is used, the command returns no more the matched pattern, but the whole text B with every matched pattern replaced by YYY. If you use replace and var together, the resulting text will not be returned, but stored in the specified input variable (that means, it's used both for input and output).
Example: regexp|\d+|var=weWantNumbers
breadcrumbs | A
builds a breadcrumbs based on the current folder path. The A is a little html template that is repeated for every piece of the path, for which 3 symbols are provided: %bread-url% , %bread-name% and %bread-idx%.
Remember to use quoting, especially if you use macros in the parameter.
Optional parameter from will let you specify how many steps of the path to skip.
Example: {.breadcrumbs|{:<a href ="%bread-url%">%bread-name%/</a>:}.}
dialog | A | B | C
display a server-side message in a dialog box. A is the message itself, and only required parameter. B are options separated by spaces, and C a title for the dialog.
Possible options are
okcancel
offers buttons OK and CANCEL. It will return 1/true if OK is pressed, false otherwise.
yesno
offers buttons YES and NO. It will return 1/true if YES is pressed, false otherwise.
yesnocancel
offers buttons YES, NO and CANCEL. It will return 1/true if YES is pressed, 'cancel' if CANCEL is pressed, false otherwise.
error
this is an error reporting dialog
question
this is a questioning dialog
warning
this is a warning dialog
information
this is an informational dialog
Example: {.if|{.dialog|stop server?|yesno question.}|{:{.stop server.}:}.}
mime | A
set the mime-type sent to the browser. It describes the nature of the content. For techies, it's the value of the header field "Content-type".
any macro marker | A
it is true if any macro marker is present in A. Macro markers are {.delimiters.} , {:quotings:} and the parameters separator (the pipe, "|").
play system event | A
specify the name of the event bound to a sound that you want to play. SystemStart and MailBeep are just examples, for a full list you can open your registry at HKEY_CURRENT_USER\AppEvents\EventLabels .
exec | A
ask system to run file A, eventually with parameters. If you need to use the pipe, then use macro quoting.
Optional parameter out will let you capture the console output of the program in the variable specified by name.
Optional parameter timeout will specify the max number of seconds the app should be left running.
Example: {.exec|notepad.}
add to log | A
add A to the log panel.
Optional parameter color to specify the color.
get ini | A
where A is a text in the same format you can find in hfs.ini (save options -> to file).
example: {.get ini|speed limit.} will return the global speed limit, if any.
set ini | A
where A is a text in the same format you can find in hfs.ini (save options -> to file).
example: {.set ini|speed limit=100.} will turn the global speed limit to 100KB/s.
focus
will bring HFS window on front of the user.
load tpl | A
for this connection only, template A will be used.
Example: {.if| it's a mobile | {:{.load tpl|mobile.tpl.}:} /if.}
notify | A
The message A will come out as a balloon over the HFS tray icon.
Optional parameter title will let you specify the title of the balloon.
Optional parameter timeout specifies the amount of time to show the message.
Optional parameter type will show an icon according to its value. Allowed values are info, error and warning.

Shortcuts

!A
is a shortcut for translation, see [special:strings] part
$A
is a shortcut for section | A
?A
is a shortcut for urlvar | A
^A
is a shortcut for call | A
A = B
is a shortcut for =|A|B
?name = X
is a shortcut for {.?name.} = X .
It works also for <> != < <= > >= .