Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Environment variables for install script.

Bear with me as PHP is just not my strong suit, I have been looking at making a really simple install for the community.

I was looking at class.setupcontroller.php as it looks like where you input the DB connections.

If I try to set those as an Environment Variable there, it doesn't take.

Any Ideas on how I might do this? There wouldn't need to be form validation or anything. Just straight code.

Thanks in advance.

Comments

  • This is the first time I have really dug into any of the Garden code, and I'd like to compliment you all on how well commented this is.

    I'd still like your help if you know a quick way of handling this idea, but still, its pretty awesome. :D

  • Never mind, I figured it out!!!

    Seriously you guys, your code commenting is friggin great.

    I'll finish it up in the next few days, but I have a git based, super secure, 2 minute install. WOOT.

    It might not be all that exciting, but I hope it helps give back to this community just a little bit.

  • hgtonighthgtonight ∞ · New Moderator

    @LucasKA said:
    Never mind, I figured it out!!!

    Mind sharing?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight

    Sure, I in class.setupcontroller.php I found

    $ConfigurationModel->Data['Database.Host'] = 'localhost'; $this->Form->SetData($ConfigurationModel->Data);

    Setting that data fills out the server host part of the form, so I just made new ones with my server variables. e.g.

    $ConfigurationModel->Data['Database.Host'] = $_SERVER["DB1_HOST"]; $this->Form->SetData($ConfigurationModel->Data); $ConfigurationModel->Data['Database.Name'] = $_SERVER["DB1_NAME"]; $this->Form->SetData($ConfigurationModel->Data); $ConfigurationModel->Data['Database.User'] = $_SERVER["DB1_USER"]; $this->Form->SetData($ConfigurationModel->Data); $ConfigurationModel->Data['Database.Password'] = $_SERVER["DB1_PASS"]; $this->Form->SetData($ConfigurationModel->Data);
    And that auto injects the correct credentials into the install script.

    I'd love to be able to set those form fields to uneditable, if anyone knows how to do that right quick. I can live without it though.

  • hgtonighthgtonight ∞ · New Moderator

    Just edit the appropriate view. In this case, you are looking at /applications/dashboard/views/setup/configure.php.

    Find the lines that echo the form text box for the db information and pass in the disabled attribute. E.g. echo $this->Form->TextBox('Database.Host', array('disabled' => TRUE));.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • I knew it was simple, I just didn't know the syntax. I think I'll implement that.

  • Thank you

  • @hgtonight Turns out that basically makes it unusable to the install script and the script errors out. It's not a big deal, it still functions correctly. I just added a warning at top that people don't need to change anything.

  • hgtonighthgtonight ∞ · New Moderator

    My interest is piqued, what error does it spit out?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • I don't recall exactly, but it seemed to act like the form field was empty.

  • hgtonighthgtonight ∞ · New Moderator

    Ah... when I used the disabled attribute, I didn't even check for the existence of the underlying inputs. You should use the readonly attribute. E.g. echo $this->Form->TextBox('Database.Host', array('readonly' => 'readonly'));

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.