| [reply] |
There is a special directory /tmp - thats writeable by anyone. When apache itself need to create some files it uses /tmp, because its running as user nobody and can't write neither in root directories nor any home dir.
And your scripts should act that way. | [reply] |
thanx for giving me the clue, will try again and revert back to you for help :)
good day!
| [reply] |
Your question had two parts -- neither of which is particularly a Perl question, but the second one at least a programming question. (For the first part, you'll want to take a look at your webserver's documentation. For dealing with security, you might want to take a look at suExec for apache, or cgiwrap for any other server.
Now -- for graphing -- I don't know exactly what you're trying to do, but overwriting the same file over and over again based on the input from the user just seems to be asking for trouble. If you have users A & B asking for the same page, but with different input, at almost the same time, it's possible that one of them will be given the wrong image. You also have to make sure to send the necessary cache-control headers in case the user tries revisiting the page with new parameters.
Instead, I see two main options:
- Give each image a unique name. The problem is, you need a routine to periodically go through and clean up the older images, so you don't fill your disk.
Generate the images as they are requested. Images don't need to be static files ... they can be generated from CGIs as well. So, as you take the parameters from the user, you can then pass the relevent ones onto the image generating CGI, either through the QUERY_STRING, or PATH_INFO:
<img src='/cgi-bin/script?param=value;param2=value2' alt='whatever' height='x' width='y'>
The whole page will take a little longer to load, as you don't start generating the image 'till the image is requested, rather than the page being requested, but I find it to be easier to maintain, as you don't need to worry about temp directories. If you're worried about other people making use of the image generating routine, you can add some sort of checksum to the parameters passed in, so it's less likely that someone will bypass the first page.
Note -- I've made a possibly incorrect assumption that the images vary with the parameters passed in and some sort of internal state, and that each image generated is most likely to be unique, or at the very least repeat so infrequently as to be not worthwhile to cache. If this isn't the case, you'll need to provide more details about what you're trying to do.
| [reply] [d/l] |