Professional Web Applications Themes

how do I hide database connection files using PHP include files? - PHP Development

I have the following at the beginning of the PHP page: <?php require_once('Connections/conn.php'); ?> I want to hide the connection file, "conn.php", so it's out of the web accessible file structure. I understand putting them in the php include directory shoudl do this. For example, let's say the directory I put them in is /www/phpIN/, and /www/ht/ is the root web directory. So I put "conn.php" in the inlcude directory (/www/phpIN/conn.php) and removed it form CONNECTIONS directory. Now it doesn't work. What do I need to change? Thanks....

  1. #1

    Default how do I hide database connection files using PHP include files?

    I have the following at the beginning of the PHP page:

    <?php require_once('Connections/conn.php'); ?>

    I want to hide the connection file, "conn.php", so it's out of the web
    accessible file structure. I understand putting them in the php include
    directory shoudl do this. For example, let's say the directory I put them
    in is /www/phpIN/, and /www/ht/ is the root web directory.

    So I put "conn.php" in the inlcude directory (/www/phpIN/conn.php) and
    removed it form CONNECTIONS directory.

    Now it doesn't work.

    What do I need to change?

    Thanks.


    NotGiven Guest

  2. #2

    Default Re: how do I hide database connection files using PHP include files?

    NotGiven wrote:
    > I have the following at the beginning of the PHP page:
    >
    ><?php require_once('Connections/conn.php'); ?>
    > [...]
    > So I put "conn.php" in the inlcude directory (/www/phpIN/conn.php) and
    > removed it form CONNECTIONS directory.
    >
    > Now it doesn't work.
    >
    > What do I need to change?
    Try

    <?php require_once '/www/phpIN/conn.php'; ?>

    --
    ..sig
    Pedro Graca Guest

  3. #3

    Default how do I hide database connection files using PHP include files?

    I have the following at the beginning of the PHP page:

    <?php require_once('Connections/conn.php'); ?>

    I want to hide the connection file, "conn.php", so it's out of the web
    accessible file structure. I understand putting them in the php include
    directory shoudl do this. For example, let's say the directory I put them
    in is /www/phpIN/, and /www/ht/ is the root web directory.

    So I put "conn.php" in the inlcude directory (/www/phpIN/conn.php) and
    removed it form CONNECTIONS directory.

    Now it doesn't work.

    What do I need to change?

    Thanks.



    NotGiven Guest

  4. #4

    Default Re: how do I hide database connection files using PHP include files?

    On Tue, 18 Nov 2003 15:46:41 -0500, NotGiven wrote:
    > I have the following at the beginning of the PHP page:
    >
    > <?php require_once('Connections/conn.php'); ?>
    >
    > I want to hide the connection file, "conn.php", so it's out of the web
    > accessible file structure. I understand putting them in the php include
    > directory shoudl do this. For example, let's say the directory I put them
    > in is /www/phpIN/, and /www/ht/ is the root web directory.
    >
    > So I put "conn.php" in the inlcude directory (/www/phpIN/conn.php) and
    > removed it form CONNECTIONS directory.
    >
    > Now it doesn't work.
    >
    > What do I need to change?
    >
    > Thanks.

    Here's how I do it, using Apache directives. First of all, I name all
    include files "*.inc" Then I use an Apache directive to prevent download
    of those files. You can put the following in a .htaccess file (I think it
    can go in .htaccess but if I'm wrong, coordinate with your Webserver
    administrator):

    <Files ~ "^.*\.inc$">
    Order allow,deny
    Deny from all
    </Files>

    This prevents access to all files that end in .inc

    Try this link, for example:
    [url]http://www.wse.jhu.edu/include/news.inc[/url]

    You should get a "Forbidden" error message. (I hope you do!)

    If you use another Web Server, It may have a slightly different mechanism,
    but it should have the same feature.

    --
    Jeffrey D. Silverman | jeffrey AT jhu DOT edu
    Website | [url]http://www.wse.jhu.edu/newtnotes/[/url]

    Jeffrey Silverman Guest

  5. #5

    Default Re: how do I hide database connection files using PHP include files?

    "Jeffrey Silverman" a écrit le 18/11/2003 :
    > Here's how I do it, using Apache directives. First of all, I name all
    > include files "*.inc" Then I use an Apache directive to prevent download
    > of those files. You can put the following in a .htaccess file (I think it
    > can go in .htaccess but if I'm wrong, coordinate with your Webserver
    > administrator):
    >
    > <Files ~ "^.*\.inc$">
    > Order allow,deny
    > Deny from all
    > </Files>
    >
    > This prevents access to all files that end in .inc
    I prefer to name them .inc.php so even if people get access to them,
    they're processed by PHP and don't return anything.
    I put all of them in a specific dir with a Deny All statement in an
    ..htaccess file (because I don't manage the structure outside the web
    dir on the free host I use).


    Jedi121 Guest

Similar Threads

  1. Help! include pdf files in flash
    By mdondero webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: September 20th, 08:29 AM
  2. Include Files (Part 2)
    By Colm in forum ASP.NET General
    Replies: 1
    Last Post: August 5th, 10:13 PM
  3. Include files in .NET
    By Colm in forum ASP.NET General
    Replies: 1
    Last Post: August 5th, 09:14 PM
  4. DM MX and Include files
    By Intravler webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 17th, 05:53 AM
  5. include files
    By Neil Steventon in forum ASP.NET General
    Replies: 8
    Last Post: July 15th, 08:35 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139