Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Prevent direct url access to php file

<?php
    /* at the top of 'check.php' */
    if ( $_SERVER['REQUEST_METHOD']=='GET' && realpath(__FILE__) == realpath( $_SERVER['SCRIPT_FILENAME'] ) ) {
        /* 
           Up to you which header to send, some prefer 404 even if 
           the files does exist for security
        */
        header( 'HTTP/1.0 403 Forbidden', TRUE, 403 );

        /* choose the appropriate page to redirect users */
        die( header( 'location: /error.php' ) );

    }
?>
Comment

PREVIOUS NEXT
Code Example
Php :: array_merge 
Php :: php xml to json 
Php :: strrev php 
Php :: mysqli real escape string 
Php :: laravel filesystem link 
Php :: merge array in php 
Php :: substr php 
Php :: php pdo 
Php :: php get last index of array 
Php :: PHP 2-Dimentional array 
Php :: remove all items of an array except the last 5 in php 
Php :: laravel copy data 
Php :: php flatten array 
Php :: laravel set date format 
Php :: foreach smarty 
Php :: fillable vs guarded laravel 
Php :: display all files in a directory php 
Php :: php get html tags from string 
Php :: laravel eloquent update multiple records 
Php :: ternary in php 
Php :: laravel datatable render html 
Php :: laravel PageController.php 
Php :: php array current 
Php :: spatie activity log 
Php :: laravel crud 
Php :: laravel sanctum 
Php :: php into javascript 
Php :: how check the time of operation in laravel 
Php :: catch warning php 
Php :: Eager realationship in laravel 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =