rejetto forum

folder restrictions and etc... on creation

0 Members and 1 Guest are viewing this topic.

Offline Chrisp6825

  • Occasional poster
  • *
    • Posts: 20
    • View Profile
Hi.

I'm using this to create a "User folder" on user registration, and add it to the HFS tree as real, and add it to the user's redirect folder.
Code: [Select]
{.if|{.and|{.and|{.?username.}|{.?password.} /and.}|{.?password2.} /and.}|{:
{.if|{.=|{.?password.}|{.?password2.}.}|{:
{.chdir|C:\Documents and Settings\Chris\Desktop\website\Users\ .}
{.mkdir|{.?username.} .}
{.add folder|real|C:\Documents and Settings\Chris\Desktop\website\Users\{.?username.}\|Users\{.?username.} .}
{.new account|{.?username.}|password={.?password.}|enabled=yes|redirect=/Users/{.?username.}/ /new account.}
{.chdir|C:\Documents and Settings\Chris\Desktop\website\ .}
{.save|/Users/users.txt|{.?username.}
{.load|/Users/users.txt.}/save.}
{: <script language="JavaScript" type="text/javascript"> window.location="~login"; </script> :}
:} /if.}
:} /if.}

So basically, it makes the new user's folder onto the harddrive, then adds that folder to HFS as real, then creates the user's account, then adds the users name to a list, and finally asks the user to login and redirects them to their folder.

I want to know if I can make the folder locked, and only accessible by the new user. (and maybe add upload privileges)
And, when I add the folder to HFS, I have it to add it to "Users\{.?username.}" but it's always added to the root.
Also, can I have it to copy an index file to their new folder?

Thanks, and sorry for all the questions.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile
Hi chrisp, i enjoyed reading your script.
It is very simple but it is the solution to many requests made in the past on this forum.

Here are my suggestions

1. this is the same as yours, but just a little nicer

{.if|{.and| {.?username.} | {.?password.} | {.{.?password.} = {.?password2.}.} /and.}|{:
...
:} /if.}

2. i think you can change this

      {.chdir|C:\Documents and Settings\Chris\Desktop\website\Users\ .}
      {.mkdir|{.?username.} .}

into this

      {.mkdir|C:\Documents and Settings\Chris\Desktop\website\Users\{.?username.} .}

3. since you often refer to C:\Documents and Settings\Chris\Desktop\website
it may be a good idea to put it in a variable, so that you can eventually change the location with a single move.
{.set|path|C:\Documents and Settings\Chris\Desktop\website.}

and then
{.mkdir|{.^path.}\{.?username.} .}

4. consider using {.append.} instead of load+save

5. you can redirect the client also by using {.add header|Location: ~login.}
and you can use both methods.

6. coming to your questions, your solution should be something like
{.set item|/users/{.?username.} |access={.?username.} |upload={.?username.} .}

7. {.add folder.} was till now limited to adding to the root only. The new build (221) i am about to publish should solve this problem. Let me know!

8. to copy use {.copy.}


Offline Chrisp6825

  • Occasional poster
  • *
    • Posts: 20
    • View Profile
Sweet. This helps a bunch.
Thanks for the code clean-up, also.

I'm currently using this now :
Code: [Select]
{.if|{.and| {.?username.} | {.?password.} | {.{.?password.} = {.?password2.}.} /and.}|{:
{.mkdir|C:\Documents and Settings\Chris\Desktop\website\Users\{.?username.} .}
{.add folder|real|C:\Documents and Settings\Chris\Desktop\website\Users\{.?username.}|/Users/{.?username.} .}
{.new account|{.?username.}|password={.?password.}|enabled=yes|redirect=/Users/{.?username.}/ /new account.}
{.chdir|C:\Documents and Settings\Chris\Desktop\website\ .}
{.append|/Users/users.txt|{.?username.}
/append.}
{.set item|/users/{.?username.} |access={.?username.} |upload={.?username.} |delete={.?username.} .}
{.add header|Location="~login".}
:} /if.}

The append is on the next line, so when it adds the next user, the name will be on the next line.

The {.add header|Location="~login".} bit isn't really working.
I've tried that ^^^ and what you suggested {.add header|Location: ~login.} and neither work.
I'm just gonna stick with the javascript until I can get it cleared.



Other than that, everything works perfectly! Thanks a ton! I'll be using the copy command soon to try and get a "profile" or "home page" type thing going. It's all about what the visitors want, and my greedy visitors want customization. haha

Thanks for the help.

Edit: Oh um.. do you think you could give me a quick example of the copy command?
I'm guessing {.copy|from|to.} ? Thanks.
« Last Edit: February 04, 2009, 03:16:06 AM by Chrisp6825 »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile
yes. copy works exactly as if you would use "copy" from the Windows command line (dos prompt).
http://www.rejetto.com/wiki/index.php/HFS:_Template_macros#File_manipulation


location will work only with colon. i don't know why it isn't working.