rejetto forum

command lines

raybob · 39 · 28372

0 Members and 1 Guest are viewing this topic.

Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
But is {.name} actually a variable in HFS?  Don't I have to use {.postvar| } to get the posted variables?
« Last Edit: March 21, 2011, 01:51:16 PM by raybob95 »


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2068
    • View Profile
But is {.name} actually a variable in HFS?  Don't I have to use {.postvar| } to get the posted variables?

to access posted variables the only way is using {.postvar| .}

Macro Shortcuts

$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 <> != < <= > >= .
Retrieved from "http://www.rejetto.com/wiki/index.php/HFS:_scripting_commands"

« Last Edit: March 21, 2011, 04:38:53 PM by Mars »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
yes, you are right, postvar is for post.
the syntax i reported works if you don't put the "method=post" in your form.


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
Well, I put this script in:

Code: [Select]

[submission]
{.mkdir|D:\{.postvar|name.}.}
{.add folder|real|D:\{.postvar|name.}|.{.postvar|name.}.}
{.new account|{.postvar|name.}|password={.postvar|password.}|enabled=true|member of=can change password|redirect=/{.postvar|name.}/.}
{.set item|{.postvar|name.}|hide=1|access={.postvar|name.}|delete={.postvar|name.}|upload={.postvar|name.}.}
{.save|M:\User emails\{.postvar|name.}.txt|{.postvar|email.}.}
{.copy|D:\hfs.diff.tpl|D:\{.postvar|name.}\hfs.diff.tpl.}


And HFS simply crashes every time I try to load the page.  There isn't even a Windows warning that the program crashed.  (I'm using Beta 274)

EDIT:  I tried build 276 and the crash still happens.  I'm gonna try one line of code at a time to see where the problem is.

EDIT #2:  I figured out (duh) that the problem was that I couldn't use M:\ drive since the script was now on the same server as HFS, not over my local network.  Changing it to C:\ solved the problem and now it all works great!!!!!

I'm beginning to see that I can do a lot more than I previously though with macros.  And also, the admins on this forum are probably the most helpful I've ever seen on any forum.  Thank you very much!!!!
« Last Edit: March 21, 2011, 09:12:01 PM by raybob95 »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
ok, i got to reproduce that bug, and fixed it, for next release (277)


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
Rejetto, why does this script not work?  It still lets users through successfully (thus erasing my VFS with later code creating their account) even when the fields are left blank . . .

Originally I had %user% in place of the postvar user but that wouldn't work either.
Code: [Select]
{.

{.if|{.postvar|user.}|{.redirect|/~newaccount?alreadysignedup=yes.}{.break.}.}
{.not|{.postvar|name.}|{.redirect|/~newaccount?username=none.}{.break.}.}
{.not|{.postvar|password1.}|{.redirect|/~newaccount?password=none.}{.break.}.}

.}
« Last Edit: March 25, 2011, 08:25:32 PM by raybob95 »


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com

Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
the outer pair {. .} must be removed.
this pair marks a command, not a block like in most languages.
And the "body" of the {.if.} must be enclosed in this pair {: :} because otherwise it will always be executed.

{.if|{.postvar|user.}|{:{.redirect|/~newaccount?alreadysignedup=yes.}{.break.}:}.}

and i guess with {.not.} you meant {.if not.}

%user% is the username of the http authentication. Nothing to do with a field in a form that you named "user".


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
OK, I think I might finally be done with this topic . . .

This is what I got on the ~submission page.

Code: [Select]
{.if     | {.postvar|user.}                                                                   |   {: {.redirect | /~newaccount?alreadysignedup=yes.}{.break.}  :}        |.}
{.if not | {.postvar|name.}                                                                   |   {: {.redirect | /~newaccount?username=none.}{.break.}        :}        |.}
{.if     | {.>= | {.count substring|{|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|.|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring| |{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|?|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|}|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|]|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|[|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|;|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|:|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|"|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|'|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|>|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|<|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|,|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|!|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|@|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|#|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|$|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|%|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|^|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|&|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|*|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|(|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|)|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|-|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|_|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|=|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|+|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|~|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if     | {.>= | {.count substring|`|{.postvar|name.}.}|1.}                                  |   {: {.redirect | /~newaccount?usernamee=invalid.}{.break.}    :}        |.}
{.if not | {.postvar|email.}                                                                  |   {: {.redirect | /~newaccount?emailgiven=no.}{.break.}        :}        |.}
{.if not | {.=  | {.count substring|@|{.postvar|email.}.}|1.}                                 |   {: {.redirect | /~newaccount?emailgiven=no.}{.break.}        :}        |.}
{.if not | {.>= | {.count substring|.|{.postvar|email.}.}|1.}                                 |   {: {.redirect | /~newaccount?emailgiven=no.}{.break.}        :}        |.}
{.if not | {.postvar|password1.}                                                              |   {: {.redirect | /~newaccount?passwordA=none.}{.break.}       :}        |.}
{.if not | {.postvar|password2.}                                                              |   {: {.redirect | /~newaccount?passwordB=none.}{.break.}       :}        |.}
{.if not | {.>= | {.length|{.postvar|password1.} .} | 8 .}                                    |   {: {.redirect | /~newaccount?password=short.}{.break.}       :}        |.}
{.if not | {.=  | {.postvar|password1.}             | {.postvar|password2.} .}                |   {: {.redirect | /~newaccount?passwordmatch=no.}{.break.}     :}        |.}
{.if not | {.=  | {.postvar|agree.}                 | yes.}                                   |   {: {.redirect | /~newaccount?agreement=no.}{.break.}         :}        |.}
{.if not | {.=  | {.postvar|spamcheck.}|{.add |{.postvar|x.}|{.postvar|y.}.}.}                |   {: {.redirect | /~newaccount?wrongmath=yes.}{.break.}        :}        |.}

{.mkdir|D:\{.upper|{.postvar|name.}.}.}
{.add folder|real|D:\{.upper|{.postvar|name.}.}|.{.postvar|name.}.}
{.new account|{.postvar|name.}|password={.postvar|password1.}|enabled=true|member of=can change password|redirect=/.{.postvar|name.}/.}
{.set item|.{.postvar|name.}|hide=1|access={.postvar|name.}|delete={.postvar|name.}|upload={.postvar|name.}.}
{.save|C:\Documents and Settings\Beck\Desktop\User emails\{.postvar|name.}.txt|{.postvar|email.}.}
{.copy|C:\Documents and Settings\Beck\Desktop\User Template.tpl|D:\{.upper|{.postvar|name.}.}\hfs.diff.tpl.}

Everything is spaced out to make it a bit easier to read, but it still functions the same.  By the way, I do know how %user% works.  In the original newaccount form, there is a hidden field which has a value of %user% and then it posts the variable to here, which is how I retrieve it on this page.  It works just fine.
« Last Edit: March 27, 2011, 08:06:53 PM by raybob95 »


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
Is there a scripting command to remove an item from the VFS?  Or was this intentionally left out because of possible security vulnerabilities?


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
if you want to check validity of username and email there's a much better method, {.regexp.} i will tell you more asap.

first i will just say something general about the scripting.
you are using the >= to don't act when the value is zero,
but you don't need it because 0 is considered false.

so,
{.if     | {.>= | {.count substring|,|{.postvar|name.}.}|1.}
and
{.if     | {.count substring|,|{.postvar|name.}.}
will do the same

MORE

the "count substring" will give you a number.
if you just put every counting in line, you will always get a number, just longer, like   00001000.
Since you are ok only when all is zero, then again the {.if.} will treat it right.
You can shorten it as

{.if | {.count substring|,|{.postvar|name.}.}{.count substring|;|{.postvar|name.}.}{.count substring|:|{.postvar|name.}.}
etc etc

but the truly cool solution is using {.regexp.} but i'm in a rush. I'll continue later.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
here it is

{.if not| {.regexp|[-A-Z0-9_.]+|{.postvar|name.}.} | {: ...redirect... :} .}

{.if not| {.regexp|[-A-Z0-9_.]+@[-A-Z0-9_.]+\.[A-Z]{2,4}|{.postvar|email.}.} | {: ...redirect... :} .}

regexp stands for regular expressions, that is a standard way to define rules for text (google if interested).

the first one accept characters, numbers, underscores, dots and dashes.
and it cannot be empty.

the second one is the same, but then a @ must follow, and the rest.


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
Thanks for that!  Simplifies things a bit.

2 more questions (as of now  :P ) about scripting commands.

1)  Is there a command to delete a folder from the VFS?
2)  Is there a command to set a folder in the VFS as archivable?


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
1) nope
2) no, i see its useful,  i will add it in next release (278)


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
Is there a parameter to set a File/Folder mask on a folder using {.add folder.} or {.set item.} ?
If not then would it be possible to add it in the next build?

Thanks
« Last Edit: April 06, 2011, 02:07:15 AM by raybob95 »