Skip to content

Instantly share code, notes, and snippets.

@KalleZ
Created September 4, 2017 20:19
Show Gist options
  • Select an option

  • Save KalleZ/6d229b58bf3b97eba5b28469409845a8 to your computer and use it in GitHub Desktop.

Select an option

Save KalleZ/6d229b58bf3b97eba5b28469409845a8 to your computer and use it in GitHub Desktop.
<?php
/* ... */
protected static getRemoteIP() : string
{
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'])
{
return($_SERVER['HTTP_X_FORWARDED_FOR']);
}
elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'])
{
return($_SERVER['REMOTE_ADDR']);
}
throw new reCAPTCHAException('Unable to fetch remote IP.');
}
/* ... */
/* ... */
$ip = $this->ip ? $this->ip : self::getRemoteIP();
/* ... */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment