Skip to content

Instantly share code, notes, and snippets.

@dbernar1
Last active December 15, 2015 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbernar1/5330413 to your computer and use it in GitHub Desktop.
Save dbernar1/5330413 to your computer and use it in GitHub Desktop.
Some options in terms of making code self-documenting
<?php
// SHORTEST VERSION
if ( in_array( $_SERVER[ 'REMOTE_ADDR' ], array( '127.0.0.1', ) ) ) {
toughp_backup_site( $_GET[ 'home_url' ], $_GET[ 'key' ] );
}
// LONGEST VERSION
// Performing a backup is initiated through an http request
// We can not allow access to this action to arbitrary IP addresses
// So we whitelist IP addresses allowed to perform backups
$ip_addresses_allowed_to_initiate_backup = array( '127.0.0.1', );
$ip_address_trying_to_initiate_backup = $_SERVER[ 'REMOTE_ADDR' ];
$backup_is_being_initiated_by_an_allowed_ip_address = in_array( $ip_address_trying_to_initiate_backup, $ip_addresses_allowed_to_initiate_backup );
if ( $backup_is_being_initiated_by_an_allowed_ip_address ) {
$home_url = $_GET[ 'home_url' ];
$key = $_GET[ 'key' ];
toughp_backup_site( $home_url, $key );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment