in reply to CGI: Make one big program or lots of little ones?
and in your script, you'll want to do something like this... <input type="hidden" name="op" value="some_operation"> ...
of course, its possible that someone playing with your form could execute subs that you'd rather they not, so I suggest creating an array, with the names of subs that are "safe" to run: example:... #(generic code / beginning of HTML dumped here) &$op(); ... #(generic code / end of HTML dumped here)
Or something along those lines. I hold the mindset that a CGI is responsible for accomplishing a certain task, such as dealing with user administration, for instance. That one script should allow me to add, edit, and/or delete users at whim, without calling on other scripts to do the job. Besides, it keeps your cgi-bin a lot cleaner ;-)@safesubs = ("this_sub", "that_sub", "other_sub"); $ok = 0; #op is not okay to run until we say so ;-) foreach (@safesubs) { if($op eq $_) { $ok = 1; #if the op is safe, set $ok to true } } if($ok) { &$op(); } else { die("The op variable does not contain a valid definition"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: CGI: Make one big program or lots of little ones?
by tomhukins (Curate) on Feb 22, 2001 at 18:43 UTC | |
by DarkProphet (Novice) on Feb 23, 2001 at 21:01 UTC | |
by tomhukins (Curate) on Feb 23, 2001 at 21:25 UTC |