I have a C simulation for which I'm creating a graphical web interface. I used HTML with ajax to call PHP, which in turn calls the shell to run the simulation. The output is then passed back to the webpage.
The script generates an output file (with a link outputted to the webpage) as well as a graph (using a call to gnu plot and referencing the output file). The webpage also allows the user to upload an input file which is used in the C simulation. All of these files are user specific.
If there is only one user on the webpage at a time, there isn't any problem. However, if 5 people want to run the simulation at the same time, the user-specific files (output, graph, input) would all be getting overwritten and messed up.
I don't have any MySQL experience, and I also don't plan on saving the outputs or inputs for a given user (user can download them if he/she wishes), so I was hoping there might be a rather simple solution like, for example, generating a temporary directory on the server with some sort of identifying tag in the name based on the user's IP address or something. This folder could then be removed some number of minutes after the simulation runs. Anyone have any ideas about something like that?
Or will I have to resort to MySQL?
Edit: It would also be okay to have something like allowing a maximum of 5 users running at the same time and then create a queue for additional users, but that might be even more difficult.
Thanks, Josh
You can't do it without saving the output somewhere, so your temp dir plan is fine.
Each person will get their own output set, on an unguessable URL.
Perhaps you could use Threading in your C simulation. Alternatively, you could set up a MySQL database and store the data there using PHP Database Objects (PDO). If you can use C and are able to do ajax with PHP, mysql will probably the most time efficient solution to implement as opposed to threading in C (assuming the C simulation is relatively complex)
You can create a session identifier for a visiting user and pass that id as a parameter to your c program.
When your c program creates files for user to display it should generate name using your session identifier for that user.
From web page let users to view files that match their session identifier. This way they can see files they generated and also you can put a control for users if they have a file with their session identifier you don't need to do an unnecessary call to your c program.
Just serve the one which was already created. Control life time of that identifier as you wish.