Last active
December 15, 2015 22:10
-
-
Save dbernar1/5330413 to your computer and use it in GitHub Desktop.
Some options in terms of making code self-documenting
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 | |
// 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