Skip to content

Instantly share code, notes, and snippets.

@nonbreakingspace
nonbreakingspace / functions.strposa.php
Created April 28, 2014 02:50
Function :: strposa
function strposa($haystack, $needles=array(), $offset=0) {
$chr = array();
foreach($needles as $needle) {
$res = strpos($haystack, $needle, $offset);
if ($res !== false)
$chr[$needle] = $res;
}
@nonbreakingspace
nonbreakingspace / function.GetIP.php
Last active August 29, 2015 14:00
Function :: GetIP
function GetIP() {
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
$ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
$ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
$ip = $_SERVER['REMOTE_ADDR'];
else

Keybase proof

I hereby claim:

  • I am nonbreakingspace on github.
  • I am nbsp (https://keybase.io/nbsp) on keybase.
  • I have a public key whose fingerprint is FDD6 8305 0EE4 9004 4F80 0066 F7D1 3CF8 6372 92D3

To claim this, I am signing this object:

@nonbreakingspace
nonbreakingspace / gist:5616832
Last active December 17, 2015 13:19
Add a session ID to a URL
<script type="text/javascript">
/*
var session = getParameterByName( 'session' );
if ( !session || session == '' ) {
var date = new Date();
var url = window.location.origin + window.location.pathname + '?session=' + date.getTime();
window.location.replace( url );