rejetto forum
May 25, 2012, 10:55:08 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: This forum is free, you do NOT need to register to post. But you may.
PROBLEMS? QUESTIONS? CLICK HERE!
Fill the survey!
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: command lines  (Read 3715 times)
0 Members and 3 Guests are viewing this topic.
raybob
Tireless poster
****
Offline Offline

United States United States

Posts: 206



View Profile WWW
« on: March 09, 2011, 04:44:38 PM »

Is it somehow possible to create a new user account using a command line?

Thanks for any input,
Raybob
« Last Edit: March 09, 2011, 05:42:50 PM by raybob95 » Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11831


View Profile
« Reply #1 on: March 14, 2011, 09:17:41 AM »

yes, there is, but you need to make it possible with a simple script.
the first method that comes to my mind is to have an event that runs every 1 or 5 seconds, and executes a specific file/script.
That's ALT+F6, and put this code
Code:
[every 2 seconds]
{.load|automatic.txt.}
{.delete|automatic.txt.}

Now, every time you want HFS to do something, you can make a script and save (or copy) it to automatic.txt (same folder as hfs.exe)

to create an account named "test", the script is
{.new account|my test.}

more details at http://www.rejetto.com/wiki/index.php/HFS:_scripting_commands#Account_manipulation

Follow members gave a thank to your post:

raybob

For this post, 1 member gave a thank you!
« Last Edit: March 14, 2011, 09:19:52 AM by rejetto » Logged
raybob
Tireless poster
****
Offline Offline

United States United States

Posts: 206



View Profile WWW
« Reply #2 on: March 15, 2011, 03:59:02 PM »

My end goal here is to make it so that it is somehow possible for a user to create their own account by submitting a form on one of the webpages.

This is what I'm thinking:

I could use Apache with PHP on another port, then have the form data submitted get put into a file like "automatic.txt" in the proper format and then have HFS automatically load the script every few seconds by putting that code you posted into HFS.events . . .

Is that a viable idea?

EDIT:  I wrote this script and it works perfectly.  Now I need to write some PHP to get it to submit the form data to this file in the proper syntax:

Code:
{.mkdir|D:\PERSON.}
{.add folder|real|D:\PERSON|.person.}
{.new account|person|password=password|enabled=true|member of=can change password|redirect=/.person/.}
{.set item|.person|hide=1|access=person|delete=person|upload=person.}

Only one problem I couldn't figure out: I need to make it so that the template of the folder is changed also.  Is this possible?  



EDIT 2:  Would it be possible to use an HFS functionality rather than PHP to get form data saved as a .txt ?
« Last Edit: March 16, 2011, 07:40:28 PM by raybob95 » Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11831


View Profile
« Reply #3 on: March 17, 2011, 12:19:22 PM »

consider you don't need to pass via Apache to have a form for account creation. Indeed you can find by searching on this forum some scripts doing it.
HFS is able to handle the form's data.

just use the {.postvar|name.} command to read "name" if you are using method=post
or even easier {.?name.} if the form is not using method=post
Logged
raybob
Tireless poster
****
Offline Offline

United States United States

Posts: 206



View Profile WWW
« Reply #4 on: March 17, 2011, 01:08:42 PM »

I've already written the PHP and gotten everything to work perfectly, so I'm going to use it for now.

However, there is one problem I have whether or not I use HFS or PHP for the form scripting.  That is, I need to be able to change a folder's default template in the VFS using command line manipulation, but I see nothing about it in the wiki.

Is that possible?  If not then could you include it in build 276?

Thanks,
Ray
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11831


View Profile
« Reply #5 on: March 17, 2011, 04:46:50 PM »

i don't know if i understood you.
you want to have different templates, based on the folder?
Logged
rejetto forum
« Reply #5 on: March 17, 2011, 04:46:50 PM »

Do you like this software? Consider even $2
 Logged
raybob
Tireless poster
****
Offline Offline

United States United States

Posts: 206



View Profile WWW
« Reply #6 on: March 17, 2011, 06:46:27 PM »

Yes.

You know how in HFS itself it lets you specify a different template for each folder?

I would like a way to specify the template with the command.

Ray
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11831


View Profile
« Reply #7 on: March 18, 2011, 05:01:45 AM »

yes, it's possible with the {.load tpl.} command.
it works for sure if you use it in event [request].
the template shall depend on the %url%.

please describe the rule that decides the template to be used
Logged
raybob
Tireless poster
****
Offline Offline

United States United States

Posts: 206



View Profile WWW
« Reply #8 on: March 18, 2011, 05:54:33 PM »

In HFS, if you go on the left, and right click a folder then hit properties, the properties box comes up.  One of the available tabs is 'Diff Template' which allows you to change the template for each specific folder, a feature that I rely on heavily.  I need a way to do this with the macro command line.

If you could go more in-depth on how to do this I would appreciate it greatly.

Thanks,
Ray
Logged
Mars
Operator
Insane poster
*****
Offline Offline

France France

Posts: 1481



View Profile WWW
« Reply #9 on: March 19, 2011, 10:26:53 AM »

Quote
In HFS, if you go on the left, and right click a folder then hit properties, the properties box comes up.  One of the available tabs is 'Diff Template' which allows you to change the template for each specific folder, a feature that I rely on heavily.

if you add a directiory into the vfs as real folder, you can edit the diff template by putting the {.load tpl|"full_path_tpl".} command. or you can use a file named hfs.diff.tpl inside the folder, then it's possible to create modify or delete this last file with another application, see wiki about.

by security there is no way to modify a diff template.  Wink


Follow members gave a thank to your post:

raybob

For this post, 1 member gave a thank you!
Logged
raybob
Tireless poster
****
Offline Offline

United States United States

Posts: 206



View Profile WWW
« Reply #10 on: March 19, 2011, 09:42:04 PM »

Yes!  Creating an hfs.diff.tpl is exactly the type of thing I was looking for.  I didn't know you could do that.    Smiley

Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11831


View Profile
« Reply #11 on: March 20, 2011, 08:47:43 AM »

diff tpl is mainly designed for making changes to the current template.
but in case you need to use whole different templates, you don't need to make a copy of the template in each folder (named hfs.diff.tpl).
you can use {.load tpl.} and then {.section.} to reload the main section of the template.
another way is to load the template in events, event [request]
Logged
raybob
Tireless poster
****
Offline Offline

United States United States

Posts: 206



View Profile WWW
« Reply #12 on: March 20, 2011, 12:17:03 PM »

Alright!  I got the whole thing coded out exactly as I need it.  Maybe one day when I feel up to it I'll write an HFS Script rather than PHP.  Or I could just wait until HFS can use PHP  Grin

But here's what I got in HFS.events:

Code:
[every 1 seconds]
{.load|automatic.txt.}
{.delete|automatic.txt.}

In Submitted.php in XAMPP:

Code:
<?php



// Get posted variables for Name, password, and email

$name $_POST["name"];
$password $_POST["password"];
$email $_POST["email"];



// Specify the new HFS Script and the Email Log File

$myFile "M:\automatic.txt";
$myFile2 "M:\User emails\\$name.txt";
$fh fopen($myFile'w');
$fh2 fopen($myFile2'w');



// Specify the contents of the two new files, one with the HFS Macros and the other with the user's email address

$string1 "{.mkdir|D:\\$name.}
{.add folder|real|D:\\$name|.$name.}
{.new account|$name|password=$password|enabled=true|member of=can change password|redirect=/.$name/.}
{.set item|.$name|hide=1|access=$name|delete=$name|upload=$name.}"
;

$string2 "$email";



// Create the two files and write the new contents

fwrite($fh"$string1");
fclose($fh);

fwrite($fh2"$string2");
fclose($fh2);



// Wait 1 second for HFS to create the new directory

sleep(2);



// Copy over the HFS template to the new directory

$old "D:/hfs.diff.tpl";
$new "D:/$name/hfs.diff.tpl";

copy($old$new);



?>


I hope I'm not asking too much, but if anybody gets the time, could someone please "convert" this PHP script to HFS macros?  That would be hugely appreciated.

Thanks,
Ray

« Last Edit: March 20, 2011, 04:33:21 PM by raybob95 » Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11831


View Profile
« Reply #13 on: March 21, 2011, 06:26:18 AM »

i'm just noticing that you can't use "set item" to set the diff tpl of the folder.
if you could, you would be able to get rid of those hfs.diff.tpl in every folder.
you would just need to set the diff tpl field of the folder to D:\hfs.diff.tpl
and the content would be automatically be loaded from that.
I will add this in next release (277)

as a side note, you can have a much shorter form with php, like this

file_put_contents("M:\automatic.txt",
    "{.mkdir|D:\\$name.}
    {.add folder|real|D:\\$name|.$name.}
    {.new account|$name|password=$password|enabled=true|member of=can change password|redirect=/.$name/.}
    {.set item|.$name|hide=1|access=$name|delete=$name|upload=$name.}");
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11831


View Profile
« Reply #14 on: March 21, 2011, 06:41:53 AM »

I hope I'm not asking too much, but if anybody gets the time, could someone please "convert" this PHP script to HFS macros?  That would be hugely appreciated.

not tested.
put this in the root/home diff template

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

then point the action of your form to /~process-form
« Last Edit: March 21, 2011, 06:45:28 AM by rejetto » Logged
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!


Google visited last this page May 24, 2012, 10:42:13 PM
anything