--- a/include/common.inc.php +++ b/include/common.inc.php @@ -1,19 +1,15 @@ <?php date_default_timezone_set('Australia/ACT'); -$APIurl = "http://localhost:8765"; $debugOkay = Array( "session", "json", "phperror", - //"awsgtfs", "awsotp", //"squallotp", //"vanilleotp", + "database", "other" ); -if (isDebug("awsgtfs")) { - $APIurl = "http://bus-main.lambdacomplex.org:8765"; -} $cloudmadeAPIkey = "daa03470bb8740298d4b10e3f03d63e6"; $googleMapsAPIkey = "ABQIAAAA95XYXN0cki3Yj_Sb71CFvBTPaLd08ONybQDjcH_VdYtHHLgZvRTw2INzI_m17_IoOUqH3RNNmlTk1Q"; $otpAPIurl = 'http://localhost:8080/opentripplanner-api-webapp/'; @@ -31,8 +27,8 @@ include_once ("common-geo.inc.php"); include_once ("common-net.inc.php"); include_once ("common-transit.inc.php"); - include_once ("common-session.inc.php"); +include_once ("common-db.inc.php"); include_once ("common-template.inc.php"); function isDebugServer() @@ -143,5 +139,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) $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 ); +} ?>