rejetto forum
Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: zhenhai on April 18, 2009, 05:59:42 AM
-
a white board code as that, ihave a question: how to limit the chat.txt filesize?
[chat]
{{if|{{?text}}|{{\
{{save|chat.txt|({{time}}){{?name1}}{{if|{{?name2}}|对{{?name2}}/if}}留言:\n{{?text}}\n{{load|chat.txt}}/save}}/}}/if}}
<form name=frm>
<input name=name1 size=10 value="{{?name1}}">对<input name=name2 size=10
value="{{?name2}}">留言:
<p><TEXTAREA name=text ROWS="3" COLS="40"></TEXTAREA>
<p><input type=submit value="提交留言" >
</form>
<script>document.frm.text.focus();</script>
<br><TEXTAREA ROWS="30" COLS="40">{{load|chat.txt}}</TEXTAREA>
-
this script deserves a full rewriting.
i will as i find the time.
-
A chat.tpl in vast version of that of rejetto, there is a limitation of the size and also the possibility of a command of reset of the file chat.txt
http://www.rejetto.com/forum/index.php?topic=5490.msg1032151#msg1032151
you have some solutions to use it:
1) create a real folder and put the chat.tpl into the folder and renamed as hfs.diff.tpl
2) create a virtual folder and put the code as a diff template
3) create into hfs.tpl asection named [chat], and the url to talk is /~chat
;)
-
i don't fully understand your chat script. i don't understand what's the reason of name1 and name2.
so, i will just make essential changes and don't advice anyone using what i'm publishing here.
{.if|{.?text.}|{:
{.save|chat.txt|({.time.}){.?name1.}{.if|{.?name2.}|对{.?name2.}/if.}留言:\n{.?text.}\n{.cut||20000|{.load|chat.txt.}.}/save.}:}/if.}
<form name=frm>
<input name=name1 size=10 value="{.?name1.}">对<input name=name2 size=10
value="{.?name2.}">留言::
<p><TEXTAREA name=text ROWS="3" COLS="40"></TEXTAREA>
<p><input type=submit value="提交留言" >
</form>
<script>document.frm.text.focus();</script>
<br><TEXTAREA ROWS="30" COLS="40">{.load|chat.txt.}</TEXTAREA>
this script limits the chat to 20000 bytes, as you see the number inside the script.
if you want to change that limit, just change that number.
-
Hello everyone, this question has been soveled as follow:
[chat]
{{if|{{?text}}|{{\
{{save|chat.txt|({{time}}){{?name1}}{{if|{{?name2}}|对{{?name2}}/if}}留言:\n{{?text}}\n{{load|chat.txt}}/save}}/}}/if}}
{{if|{{{.length|{{load|chat.txt}}.}>1500}}|{{\{{save|chat.txt|{.cut||1000|{{load|chat.txt}}.}/save}}/}}/if}}
<form name=frm>
<input name=name1 size=10 value="{{?name1}}">对<input name=name2 size=10 value="{{?name2}}">留言:
<p><TEXTAREA name=text ROWS="3" COLS="40"></TEXTAREA>
<p><input type=submit value="提交留言" >
</form>
<script>document.frm.text.focus();</script>
<br><TEXTAREA ROWS="30" COLS="40">{{load|chat.txt}}</TEXTAREA>
the code is added at main, before (<form><div id='footer'>) :
<td valign=top><br><a target='bank' href="/~chat">到留言板提交留言</a>
<br><TEXTAREA ROWS="25" COLS="20">{{load|chat.txt}}</TEXTAREA>
</table>
as a resume: I found my question is at the code:
|{.cut||1000|{{load|chat.txt}}.}
after the command .cut ,there three parameters, the first is a number [Start], the second is a number [END], the third is a string, the code means: cut (keep) the characters from start to end in the string.
the related help document at this forum didnt say detail in why two || found.
thank you.
-
the documentation is not on this forum, but by HFS > menu > help > full guide
http://www.rejetto.com/wiki/index.php/HFS:_Template_macros#Data_manipulation
-
thank you!
the [chat] section is come from chat.tpl in "hfs-last-beta-src" .
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: with A=2 and B=3 and C=abcdef you will get bcd because it is from character 2 and for a length of 3.
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.
-
the presence of chat.tpl in the archive is an error.
i created it while trying to help you.
-
thank you. in fact this chat.tpl can be use as a public BBS board.