Created
January 21, 2015 02:54
-
-
Save hatzopoulos/739fad080d455a5e757a to your computer and use it in GitHub Desktop.
IP White List Update Cron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
## ./ip-white-list-cron.php | |
$whitelist_json = __DIR__.'/whitelist.json'; | |
$cache_mtime = filemtime($whitelist_json); | |
$write_error = 'Write Error. This needs to be properly setup to be able to write to '.$whitelist_json.PHP_EOL; | |
if ( $cache_mtime === false ) { | |
if ( touch($whitelist_json) === false) { | |
trigger_error($write_error, E_USER_ERROR); | |
} | |
} | |
elseif (!is_writeable($whitelist_json)) { | |
trigger_error($write_error, E_USER_ERROR); | |
} | |
if (filemtime(__FILE__) >= $cache_mtime) { | |
$json = json_encode( array( | |
'111.222.333.444', ## Office One | |
'111.222.333.444', ## Office Two | |
'111.222.333.444', ## Office Three | |
'111.222.333.444', ## Remote User One | |
'111.222.333.444', ## Remote User Two | |
'111.222.333.444', ## Remote User Three | |
) ); | |
$bytes_written = file_put_contents( $whitelist_json, $json ); | |
if ($bytes_written === false) { | |
trigger_error($write_error, E_USER_ERROR); | |
} | |
} | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment