Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Any way of php figuring out where it is?

Options
  • 23-12-2006 5:53pm
    #1
    Registered Users Posts: 4,475 ✭✭✭


    I have a site that I develop locally, test on my own site and then deploy to the client site. To get this to work, I've got a connect.php which contains each server's (localhost, my domain, client domain) database, username, password, etc details.

    1. As I move the site from place to place, I have to remember to change which settings I'm using. Is there any way that php can tell the domain of the server it's on and I can then use a switch command to work out which settings to use?

    2. What do other people do for security of such a file (having the database username and password in a clearscript file is an obvious issue)?


Comments

  • Closed Accounts Posts: 1,200 ✭✭✭louie


    Did you look into
    $_SERVER['HTTP_HOST']
    


  • Registered Users Posts: 4,475 ✭✭✭corblimey


    louie wrote:
    Did you look into
    $_SERVER['HTTP_HOST']
    
    Awesome, thanks. I just couldn't find the right combination of words to use on php.net to get me that command :)


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    corblimey wrote:
    2. What do other people do for security of such a file (having the database username and password in a clearscript file is an obvious issue)?
    Let MySQL handle your users. It never ceases to amaze me how many sites log people in as root.

    You can create new users in the database on the fly if you want and limit their ability to control the database in question (there’s no reason for any user to have CREATE, DROP or ALTER permissions, after all). That way MySQL will store the users and their passwords and you won’t need to put a password in any file.

    That way you can limit public access to, say, SELECT permissions, registered users to SELECT, INSERT and UPDATE and you only need to have GRANT rights whenever user details are being created.

    For more info: http://dev.mysql.com/doc/refman/5.1/en/grant.html


Advertisement