php - Need information about file safety -


hello stackoverflow community! i've got question website security! i'm new in creating tvs want ask include file stuff. let's say, i've got index.php file has: include_once 'style/header.php'; , file header.php contains:

<html>     <head>         <title>some title!</title>         <meta charset="utf-8">         <meta name="viewport" content="width=device-width, initial-scale=1">         <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>         <link href="css/style.css" rel="stylesheet" type="text/css">         <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />     </head>     <body> 

so if 1 try directly access header.php see html tags. how can block access included file or encrypt them? or maby there other stuff programmers do?

you can insert line of code @ start of header file

<?php if(strtolower(__file__) == strtolower(realpath(".".$_server['script_name']))) { die("direct access not allowed."); } ?> 

this not allow direct access file allow including.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -