Skip to content

Instantly share code, notes, and snippets.

@Tocacar
Created March 3, 2014 10:45
Show Gist options
  • Save Tocacar/9322525 to your computer and use it in GitHub Desktop.
Save Tocacar/9322525 to your computer and use it in GitHub Desktop.
<?php
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
))) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file.');
}
opcache_reset();
?>
@akrabat
Copy link

akrabat commented Mar 3, 2014

<?php

if (isset($_SERVER['REMOTE_ADDR']) && in_array($_SERVER['REMOTE_ADDR'], array(
    '127.0.0.1',
    '::1',
    )
        opcache_reset();
        exit;
)) {
}

header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file.');

@wjzijderveld
Copy link

<?php

if (!isset($_SERVER['REMOTE_ADDR']) || !in_array($_SERVER['REMOTE_ADDR'], array(
    '127.0.0.1',
    '::1',
    )
)) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file.');
}

opcache_reset();

Else people would get access when they don't have a IP address at all :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment