Jump to content

Mantaining an updatable file online on a server


Newb
 Share

Recommended Posts

Hi all,

I Would like to ask how to let my script read a file on a server on which I have access, and so read and modify it. The file is a text file on which I would like to periodically append some text.

I'm asking what you think is the best solution about where to hold that file, and about the AutoIt commands to use for this task.

For the script commands I think FileRead or InetGet would do the work. But I'm wondering how to do the server access. I have an account on a free hosting service, thus if I upload the file up there, I will need to login with my username and password, so I would like to know how to do this too in autoit, or, if you have an idea on how to store a file online (because it will need to be accessed by multiple instances of the script, from different users) without the need of a password or something, or any other solution would be fine.

(Since the script will be distributed to my friends only, it can be something which is password free, or with a shared password or something. Obviously I won't share the free hosting service password because I have some personal websites up there)

So what is the best solution in your opinion? And if this solution includes an authentication access (username and password), how I do it in AutoIt?

Thank you in advance for any reply.

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

Hello dude.

I'm asking what you think is the best solution about where to hold that file,

If it contains some confidential data such as logins || passwords etc. you'll need firstly encrypt it or at least you'll need to store that file on database such as MYSQL,Postgres etc.

So,it's your choise and your responcibility.

Ok hereis basic idea for you:

edit:

OMG somehow my post disappeared from forum.

Rolling back and copy/pasting it on pastebin:

http://pastebin.com/8tTmqq4T

[size="5"] [/size]
Link to comment
Share on other sites

Hi, thanks for the kind reply!

Why php is needed? I don't want to learn it because I think it's useless and a bad designed tecnology. There is a way to do it without php?

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

Why php is needed? There is a way to do it without php?

Hi,

The only way to avoid the use of php is to connect by ftp, which is not a good idea if your script is not for a personal use.

Here you go (php) :

//this is the page where you will do requests, named "toto.php" here.

if(isset($_GET['action'])) {
$sFileFullPath=$_GET['file'];

if(!empty($sFileFullPath)) {
switch($_GET['action']) { //?action=
case 'readfile':
$hFile=fopen($sFileFullPath, 'r');
echo fread($hFile, filesize($hFile)); //echo the content of the file
fclose($hFile);
break;
case 'editfile':
$hFile=fopen($sFileFullPath, 'w');
echo fwrite($hFile, $_GET['content']); //echo the result of the edit
fclose($hFile);
break;
case 'removefile':
echo unlink($sFileFullPath); //echo the result of the remove
break;
}
}

exit();
} else {
header('HTTP/1.1 403 Forbidden'); exit(); //forbid access to the page
}

//Examples:
//read: example.com/toto.php?action=readfile&file=test.txt
//edit: example.com/toto.php?action=editfile&file=test.txt&content=new%20content
//remove: example.com/toto.php?action=removefile&file=test.txt
?>

I don't want to learn it because I think it's useless and a bad designed tecnology.

You're wrong, but this isn't the right forum to discuss about it.

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...