I maintain a website that has a simple form that users fill out with simple engineering data. They press
Submit, and the PHP code takes over and does various basic arithmetic on those numbers, according to the hardcoded formulas.
Every time there is a change, user has to talk to me, and I have to change the formulas in the code, and then update the repository.
User requested control over formulas. I could give them access to code, but they are not a programmer and changes are sufficiently rare to where most likely I will end up helping them anyways. As in, I might as well keep code access myself.
Excel on the Web approach
Another way I could do so is to implement subset of "Excel On the Web", as essentially that's the functionality that's requested. How though I am not sure. Also, output of formulas is used in several mission-critical code pieces, so it's not just excel on the web where you enter formulas and see results without further action. The output of the formulas is used in critical code used to drive various other functionality. Aka, I need an user-editable code, results of which I can plug back into the main source code.
I could have free-form box where user enters specific PHP code and then I just use
eval to get the desired result, but
eval opens huge security hole on the website.
I could do like above but instead of
eval, implement a full blown parser that does the limited excel functionality for me. I am leaning towards this way but I really don't know how to set it up best, as writing my own parser I may end up doing a lot of work. For example, should the interface be "per line" or "free form box"? Coding up the interface can become a significant amount of work in itself. Coding up improper interface can be even more work if later it will have to be tore down, in order to implement a better one.
What's a good way to allow user-edit-control over formulas that are currently hardcoded in the code, but without it becoming a huge project?
Just to give scale, perhaps something that can be implemented within one or max two week, including testing.