This is a discussion on Stupid question of the day (Editing text file in $HOME via web) within the PHP General forums, part of the PHP Programming Forums category; I have a text file on a server that I want someone to be able to edit via the web. ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have a text file on a server that I want someone to be able to edit
via the web. I need it to have some modicum of security, but it's nothing particularly important and security is not the main concern. I am perfectly willing to simply http-auth it, if need be. But it need to be easily editable using some sort of simple web form. The file is unlikely to be much more than 20-100 lines of simple text, but there are a couple of things that are important. 1) it has to preserve spacing and 'extended' characters 2) it has to be kept readable to the uid of the directory it is in, and not just the webserver, however it can't be world readable without some authentication via the web. 3) the file is in $HOME and not in DocumentRoot, though it _could_ be moved. I don't want to install some fancy word-processing sort of engine just to give a user access to this file, nor does the file need to be html-ized or anything. It is a very simple file: (AAA) XXX-NNN, some descriptive text (AAA) XXX-NNN, some other descriptive text (AAA) XXX-NNN, some different descriptive text (AAA) XXX-NNN, John Smith etc. So, do I whack up something where I just load the file into a HTML Textarea and then write it back (simple enough, though possibly rather dangerous), or is there something straightforward I should go ahead and use that might find use elsewhere on the server? -- "Oh damn", said Maladict. |
|
|||
|
On Oct 30, 2006, at 11:34 PM, Google Kreme wrote: > So, do I whack up something where I just load the file into a HTML > Textarea and then write it back (simple enough, though possibly > rather dangerous), or is there something straightforward I should > go ahead and use that might find use elsewhere on the server? Playing Devils Advocate here, but why not store the text in a database? The text file should be somewhat secure if you're manually reading and writing to it in PHP, making sure that you're the one controlling the file name, the file extension (file type), the file permissions, and the file size. -Ed |
|
|||
|
On Tue, October 31, 2006 1:34 am, Google Kreme wrote:
> So, do I whack up something where I just load the file into a HTML > Textarea and then write it back (simple enough, though possibly > rather dangerous), or is there something straightforward I should go > ahead and use that might find use elsewhere on the server? The unanswered question is: How many people might try to edit it at once, and what will you do to resolve race conditions? Whipping up a TEXTAREA for a single admin person who is in charge of this file, and the only one to edit it under normal circumstances, would work fine. Doing that for a team of 100 people who have access to this file will end up with somebody very cranky when their 1000-entry addition got over-written by another user fixing a small typo. Other solutions to consider: 1. Put the "file" in a database as individual (AAA) XXX-NNNN records, and the "file" can be generated from the DB every time it changes with a trigger, or every day or something reasonable. Having individual records for each line reduces the damage of the race condition to a single entry needing to be re-done. You can also more easily find code to handle the race condition for the DB in a web environment. 2. Put the file into subversion or CVS, if all editors are developers. 3. Forget the web interface, because the file won't really change that often anyway, and just use 'vi' to make the rare change. :-) There likely *IS* a web tool "out there" just like you want... My first guess would be to check out the various "panel" solutions for having a web interface that webhosts provide to edit what is essentially a simple text file, which configures the web server, mail server, ftp server, etc. These all have all the exact same issues you will face, so there might be one that fits your needs. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? |
|
|||
|
On 31 Oct 2006, at 09:20 , Ed Lazor wrote:
> On Oct 30, 2006, at 11:34 PM, Google Kreme wrote: >> So, do I whack up something where I just load the file into a HTML >> Textarea and then write it back (simple enough, though possibly >> rather dangerous), or is there something straightforward I should >> go ahead and use that might find use elsewhere on the server? > > Playing Devils Advocate here, but why not store the text in a > database? Because the text file is used by egrep/procmail. > The text file should be somewhat secure if you're manually reading > and writing to it in PHP, making sure that you're the one > controlling the file name, the file extension (file type), the file > permissions, and the file size. Yeah, so just dump it into a textarea and go? On 31 Oct 2006, at 10:32 , Richard Lynch wrote: > On Tue, October 31, 2006 1:34 am, Google Kreme wrote: >> So, do I whack up something where I just load the file into a HTML >> Textarea and then write it back (simple enough, though possibly >> rather dangerous), or is there something straightforward I should go >> ahead and use that might find use elsewhere on the server? > > The unanswered question is: > > How many people might try to edit it at once, and what will you do to > resolve race conditions? There will be only one person able to access the file, but I will need to somehow 'time-out' a edit if it doesn't get committed. > 1. Put the "file" in a database as individual (AAA) XXX-NNNN records, > and the "file" can be generated from the DB every time it changes with > a trigger, or every day or something reasonable. Having individual > records for each line reduces the damage of the race condition to a > single entry needing to be re-done. You can also more easily find > code to handle the race condition for the DB in a web environment. That's not a bad idea. It might be worth the effort to setup the database and then simply have a php scriptlette generate the actual plaintext. Hmm. Worth considering, at least. Some way of generating the plain text only when the file changes would be needed though,a s I don't expect it to change all that often. > 2. Put the file into subversion or CVS, if all editors are developers. Nope, it needs to be luser friendly. > 3. Forget the web interface, because the file won't really change that > often anyway, and just use 'vi' to make the rare change. :-) See above. > There likely *IS* a web tool "out there" just like you want... Yeah, that's what I was thinking. > My first guess would be to check out the various "panel" solutions for > having a web interface that webhosts provide to edit what is > essentially a simple text file, which configures the web server, mail > server, ftp server, etc. These all have all the exact same issues you > will face, so there might be one that fits your needs. Any specific recommendations? The only one of these I am familiar with is the absurdly expensive cpanel. -- "You can think and you can fight, but the world's always movin', and if you wanna stay ahead you gotta dance." |
|
|||
|
On Tue, October 31, 2006 9:42 pm, Google Kreme wrote:
>> My first guess would be to check out the various "panel" solutions >> for >> having a web interface that webhosts provide to edit what is >> essentially a simple text file, which configures the web server, >> server, ftp server, etc. These all have all the exact same issues >> you >> will face, so there might be one that fits your needs. > > Any specific recommendations? The only one of these I am familiar > with is the absurdly expensive cpanel. Sorry. My "cpanel" is called "vi" :-) Google is your friend on this one. There are only a few thousand OpenSource "panels" out there, I'll bet... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? |