Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question for settings.php #3

Open
robertjensen opened this issue Jul 8, 2022 · 3 comments
Open

Question for settings.php #3

robertjensen opened this issue Jul 8, 2022 · 3 comments

Comments

@robertjensen
Copy link
Member

Anybody remember the intended purpose of this line?

$settings[$s_key] = str_replace('{'.$p_key.'}', $p_value, $settings[$s_key]);

@KennethNielsen
Copy link
Member

No, and the git blame isn't particularly useful: "Initial commit"

https://github.com/CINF/cinfdata/blame/91eb29f8959df03499ff322a9af94fc63ea672bc/sym-files2/graphsettings.php#L80

It looks like some sort of transformation

@KennethNielsen
Copy link
Member

Searching for uses yield this: https://github.com/CINF/cinfdata/search?q=plot_settings

where we can see that e.g. one of the callers is passing in a "xscale" as the second argument, which gets turned into $params

@KennethNielsen
Copy link
Member

which is being generated by the line above, via date_xscale which is here:

function date_xscale($from="",$to="",$defaulthours=24){
... ahhhh yes, now I remember.

This is the line that does the trick of formatting user provided parameters into the settings to make it possible to write {param_name} type variables in the settings XML file. It's probably a huge security whole BTW, but 🤷🏻

so, if params is an array, like it is is there is a date_scale, the the array has from and to values and you then replace all occurrences in {from} and {to} in the settings XML file with those values.

Wow that was a trip down memory lane. I remember being very proud when I implemented that, and apparently a little too arrogant to include a comment. Better if I was the only one who knew 🙄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants