// File Security Check
if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && basename( __FILE__ ) == basename($_SERVER['SCRIPT_FILENAME'] ) ) {
    die ( 'You do not have sufficient permissions to access this page' );

I see this at the top of every php file in WooCommerce. Can this be used in every theme file or plugin file as well? Does that make any sense to even use it this way? In what way would you use this block of code mostly? Thanks!


I don't see any security related value in that code, why do you assume it is security related?

i don't intend to flame woothemes, but you have no way to know what kind of security auditing their products undergo (I am on their mailing list and I get notifications about new products but they never mention who audited them for security, which doesn't mean they haven't been audited just that I can't trust that they were).

Never look for plugins to learn how to secure you code, look at the core and the published best practices, but the most important thing is to understand what are the security risks associated with the type of code that you write and then find ways to mitigate them. you should copy/paste random security code only after that.

Not the answer you're looking for? Browse other questions tagged or ask your own question.