--- a/include/common.inc.php +++ b/include/common.inc.php @@ -1,62 +1,53 @@ centroid)) { - $geocoded = true; - $_SESSION['lat'] = $contents[0]->centroid->coordinates[0]; - $_SESSION['lon'] = $contents[0]->centroid->coordinates[1]; - } - else { - $_SESSION['lat'] = ""; - $_SESSION['lon'] = ""; - } - } - } -} -debug(print_r($_SESSION, true) , "session"); -function isDebugServer() + + +function isAnalyticsOn() { - return $_SERVER['SERVER_NAME'] == "10.0.1.154" || $_SERVER['SERVER_NAME'] == "localhost" || $_SERVER['SERVER_NAME'] == "127.0.0.1" || !$_SERVER['SERVER_NAME']; + return !isDebugServer(); } function isDebug($debugReason = "other") { @@ -69,28 +60,9 @@ } function isJQueryMobileDevice() { - // http://forum.jquery.com/topic/what-is-the-best-way-to-detect-all-useragents-which-can-handle-jquery-mobile#14737000002087897 - $user_agent = $_SERVER['HTTP_USER_AGENT']; - return preg_match('/iphone/i', $user_agent) - || preg_match('/android/i', $user_agent) - || preg_match('/webos/i', $user_agent) - || preg_match('/ios/i', $user_agent) - || preg_match('/bada/i', $user_agent) - || preg_match('/maemo/i', $user_agent) - || preg_match('/meego/i', $user_agent) - || preg_match('/fennec/i', $user_agent) - || (preg_match('/symbian/i', $user_agent) - && preg_match('/s60/i', $user_agent) - && $browser['majorver'] >= 5) - || (preg_match('/symbian/i', $user_agent) - && preg_match('/platform/i', $user_agent) - && $browser['majorver'] >= 3) - || (preg_match('/blackberry/i', $user_agent) - && $browser['majorver'] >= 5) - || (preg_match('/opera mobile/i', $user_agent) - && $browser['majorver'] >= 10) - || (preg_match('/opera mini/i', $user_agent) - && $browser['majorver'] >= 5); + // http://forum.jquery.com/topic/what-is-the-best-way-to-detect-all-useragents-which-can-handle-jquery-mobile#14737000002087897 + $user_agent = $_SERVER['HTTP_USER_AGENT']; + return preg_match('/iphone/i', $user_agent) || preg_match('/android/i', $user_agent) || preg_match('/webos/i', $user_agent) || preg_match('/ios/i', $user_agent) || preg_match('/bada/i', $user_agent) || preg_match('/maemo/i', $user_agent) || preg_match('/meego/i', $user_agent) || preg_match('/fennec/i', $user_agent) || (preg_match('/symbian/i', $user_agent) && preg_match('/s60/i', $user_agent) && $browser['majorver'] >= 5) || (preg_match('/symbian/i', $user_agent) && preg_match('/platform/i', $user_agent) && $browser['majorver'] >= 3) || (preg_match('/blackberry/i', $user_agent) && $browser['majorver'] >= 5) || (preg_match('/opera mobile/i', $user_agent) && $browser['majorver'] >= 10) || (preg_match('/opera mini/i', $user_agent) && $browser['majorver'] >= 5); } function isFastDevice() { @@ -143,6 +115,7 @@ } return (strcasecmp(substr($haystack, 0, strlen($needle)) , $needle) === 0); } + function endsWith($haystack, $needle, $case = true) { if ($case) { @@ -176,5 +149,42 @@ if ($sort_ascending) $array = array_reverse($temp_array); else $array = $temp_array; } +function sktimesort(&$array, $subkey = "id", $sort_ascending = false) +{ + if (count($array)) $temp_array[key($array) ] = array_shift($array); + foreach ($array as $key => $val) { + $offset = 0; + $found = false; + foreach ($temp_array as $tmp_key => $tmp_val) { + if (!$found and strtotime($val[$subkey]) > strtotime($tmp_val[$subkey])) { + $temp_array = array_merge((array)array_slice($temp_array, 0, $offset) , array( + $key => $val + ) , array_slice($temp_array, $offset)); + $found = true; + } + $offset++; + } + if (!$found) $temp_array = array_merge($temp_array, array( + $key => $val + )); + } + if ($sort_ascending && isset($temp_array)) $array = array_reverse($temp_array); + else $array = $temp_array; +} +function r_implode( $glue, $pieces ) +{ + foreach( $pieces as $r_pieces ) + { + if( is_array( $r_pieces ) ) + { + $retVal[] = r_implode( $glue, $r_pieces ); + } + else + { + $retVal[] = $r_pieces; + } + } + return implode( $glue, $retVal ); +} ?>