1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Include() and Security

Discussion in 'PHP' started by danpadams, Mar 21, 2005.

  1. #1
    I was curious, is there any way to "include" a file, but to have it restricted to not allow PHP stuff to be executed? I am thinking of including from a PHP file and I don't want to allow any PHP stuff in the included file to be executed.
     
    danpadams, Mar 21, 2005 IP
  2. Juls

    Juls Well-Known Member

    Messages:
    1,867
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    170
    #2
    yep what i would do is instead of use include I would just open and read the file. It would all be read as text even if php code was included then you could just print it out and display it.

    hope that helps. stay away from include if you think someone will be able to access the file to add php code to it.
     
    Juls, Mar 21, 2005 IP
  3. danpadams

    danpadams Peon

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Any quick and dirty scripts to do just that, ie read a file in and print it out. That way it will avoid the include thing?
     
    danpadams, Mar 21, 2005 IP
  4. nullbit

    nullbit Peon

    Messages:
    489
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    echo file_get_contents('/path/to/file');
    
    Code (markup):
     
    nullbit, Mar 21, 2005 IP