SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist vhogarth's Avatar
    Join Date
    Nov 2003
    Location
    Taxachussets
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Your thoughts on structuring my config file

    Hey,

    Its been awhile since i've last posted, I took a 'break' (aka got lazy) from developing. But i've been brainstorming a basic configuration page and how I'm going to go about implementing it and would like people's advice on some possible draw back.

    Basically, i'm going (started already) to create a config file that i'm going to include with each site I make. Calling it config.inc. In that file its going to store a bunch of variables that are going to affect the output of the site. I.E color scheme, layout, display properties, etc.

    When an admin logs in and goes into the configure my site option it'll bring up a mysetup.php page where they adjust the parameters the way they want. Then they submit the form which writes over the config.inc file with the new information.

    When the site loads up, it'll read the config.inc file and act accordingly given whatever was changed. Is this a good way to go about using a config file.

    I'm a complete novice, i.e never even tried, using OOP so i dont know about classes, inheritence and all that malarky. Im using a simple file that stores variable that are read and applied when visitors browse the site.

    Is this a good way, do you foresee any problems? Any advice early on would help before i get knee deep and realize that there's a major flaw. Thanks again, and its great to be back.
    Last edited by vhogarth; Jan 5, 2005 at 14:47. Reason: edited title

  2. #2
    SitePoint Member
    Join Date
    Jan 2005
    Location
    San Francisco
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your methodology is fine, but some details may trip you up:

    - Make sure your configuration file is not accessible from a web browser, because a .inc filename will be parsed as plain text and your configuration information will be viewable to anyone. If you need to place it in an area that is publicly accessible, name the file something like "config.inc.php". If it is loaded directly, nothing will execute and your information will be hidden (although keep in mind, if PHP fails for whatever reason, your webserver may still display it as plain text).

    - If you have multiple administrators writing to a single file with no history, changelog, or version control, it may cause confusion.

    - You'll need to change the file permissions on your configuration file to allow the webserver to write to it. This may introduce security holes, especially if your site is on a shared virtual host, because you may need to "up" the permissions to allow anyone on the server to over-write your file.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    texas
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sounds like you're using the config file to store preference stuff. i assume your customer isn't going to be changing the databsae host etc once the site is live....

    i prefer to save preference data in mysql. mostly b/c i'm hesitant to regenerate a file with a script. what if the new script it creates has a syntax error for some reason? then they can't even load the mysetup.php to fix it... if the preference info is in mysql, then if it's an illegal value (somehow, hopefully i'm validating input so it doesn't happen, but i always seem to miss just 1 case...) i can use the default value in the config file that i *know* is correct.

    just a thought.
    free online calendar: http://inversiondesigns.com
    includes multiple calendars/users/groups, task manager,
    email and sms reminders, permissions (sharing), etc.

  4. #4
    SitePoint Evangelist vhogarth's Avatar
    Join Date
    Nov 2003
    Location
    Taxachussets
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Parts of the config will be stored in mysql for the site wide prefrences so i can run reports on all the sites via sql queries. The rest of the stuff is really about how the site will display certain things, colors, etc. Stuff i dont really need to keep stored in a DB.

    As far as teh suggestion to change the inc_config file to a .php extension, i'll def take care of that so that if something does occur it wont display any output, unless some major issue arises. Even so the data isnt really sensitive so it doesnt matter much to me.

    Thanks for the feedback


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •