Reputation: 285
I don't understand why in each folder I find the same index.php file.
They look like this:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Location: ../");
exit;
In particular, I don't understand why is declared the "Location: ../"
.
I use Prestashop, and I don't understand how the variables can work on others files.
Example: I have a new module, I want to display the text "You are logged!" only for logged customers and I can do it using {if} $logged {/if}
variable.
Maybe because it's on the same parent folder or something else?
Upvotes: 2
Views: 2051
Reputation: 178
I don't understand why in each folder I find the same index.php file.
This is the method to prevent directory observing by a "hacker". Without this file, someone can observe every directory to view its contents, i.e. files and subdirectories. Some of these files can be accessible for viewing and execution. So, this method is intended against directory observing security vulnerability and it is not using only in PrestaShop.
In particular, I don't understand why is declared the "Location: ../".
Because of this, the index.php
file should be in each directory for recursively redirection to previous directory, while the root directory will not reached (i.e., for display a homepage of a site).
But there are another solutions of this method, for example: show error 404
- a page not found.
For the security reason, every developer should add index.php
files into each directory of a module, a theme or another directory and subdirectories. To automate this task there is a special command line program. For example, this one: Tool against directory traversal security vulnerability (this one on GitHub).
Upvotes: 0
Reputation: 4337
FrontController
in init()
method sets a smarty variable $logged
. Every controller which inherits from this class (which is every controller except backoffice section) calls this method, thats why it is available in every front page template.You need to learn about OOP and MVC principles if you're gonna work with PrestaShop.
Upvotes: 4