php site - inc and tpl - for php experts

Discussion in 'PHP' started by mdrobiul, May 3, 2009.

  1. #1
    Can you please tell me why we include database configuration in a file where extension "inc" is used and why we make templates using TPL extension ??
     
    mdrobiul, May 3, 2009 IP
  2. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    #2
    well, for starters they are not required on php, .tpl files are used by smarty, and a config file with a .inc extension is a security threat if your server is not configured to process them as php files because, they will be outputted as plain text when accessed through a browser
     
    creativeGenius, May 3, 2009 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    Well. It doesn't really matter what type of fileextension you use, as long as the parser, and the server you're running it on, understands what to do with the files. Any file can contain any type of code, it's the parsing of the file that makes it do whatever it's meant to do.

    For instance, putting the database config in a .inc file doesn't really make all that much sense - however, if you do, make sure you have a .htaccess file in the root folder containing the following:
    
    <FilesMatch "\.(inc)$">
    order allow,deny
    deny from all
    </FilesMatch>
    
    Code (markup):
    which will disallow access to any files with the .inc file-extension from external nodes. It will still be fully processable by PHP.

    You can also add different types of file-extensions to the above rule, if you want. So, for instance you could have:
    
    <FilesMatch "\.(inc|txt|csv|old)$">
    order allow,deny
    deny from all
    </FilesMatch>
    
    Code (markup):
    to prevent access to all .inc, .csv, .txt and .old files on the server.
     
    PoPSiCLe, May 3, 2009 IP
  4. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #4
    .tpl extensions are used where Smarty Template Engine is used. Have a look http://www.smarty.net/ if a coder uses this for a script it makes it easy for the user to edit as its user friendly . Template part is differentiated from coding part
     
    Bohra, May 3, 2009 IP
  5. mdrobiul

    mdrobiul Peon

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    well done. thank you my genius brothers..
     
    mdrobiul, May 4, 2009 IP