Skip to content

Instantly share code, notes, and snippets.

@daviz1982
daviz1982 / getRealIpAddr.php
Created October 6, 2016 19:51
Obtains the client IP address, even after a load balancer
<?php
function getRealIpAddr() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy
$ip = preg_replace('/(?:,.*)/', '',$_SERVER['HTTP_X_FORWARDED_FOR']);
}
else {
$ip = $_SERVER['REMOTE_ADDR'];
@daviz1982
daviz1982 / rem-mixin.scss
Last active December 25, 2015 06:39
Takes a property and a value, and writes it in pixels and rem, to ensure backward compatibility with (doomed) IE8 and lower
/**
Takes a property and a value, and writes it in pixels and rem, to ensure
backward compatibility with (doomed) IE8 and lower
@param $property A valid CSS property
@param $value A numeric value
Use: rem("width", 160) returns: width: 160px; width: 10rem; // Note the quotes in "width"
rem(padding, 10px 10px 0) returns: padding: 10px 10px 0; padding: 0.625rem 0.625rem 0; // note the units
*/