Skip to content

Instantly share code, notes, and snippets.

@markbalt
Created June 1, 2015 15:28
Show Gist options
  • Save markbalt/ad9d320c49b371c123aa to your computer and use it in GitHub Desktop.
Save markbalt/ad9d320c49b371c123aa to your computer and use it in GitHub Desktop.
Log IP Keys (Symfony)
<?php
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR');
foreach ($ip_keys as $key) {
foreach (explode(',', $_SERVER[$key]) as $ip) {
$ip = trim($ip);
sfContext::getInstance()->getLogger()->err(sprintf('%s %s', $key, $ip));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment