/** * конвертирует строковые значения полей в заданный тип * * @param string $value значение переменной * @param string $type тип переменной ('bool','date') * @return mixed значение нужного типа */ function type_cast($value, $type) { switch ($type) { case "bool": return $value == "true"; case 'float': return get_float(trim($value)); case 'int': case 'integer': return get_integer(trim($value)); case "date": $date_parts = strptime($value, get_date_input()); return mktime(0, 0, 0, $date_parts["tm_mon"] + 1, $date_parts["tm_mday"], 1900 + $date_parts["tm_year"]); case 'textcode': $num = 0; for ($i = strlen($value) - 1; $i >= 0; $i--) { $num = $num * 26 + (ord($value[$i]) - ord('a')); } return (int) $num ^ 67894523; default: return $value; } }
$fsq_user = foursquare_users_get_by_foursquare_id($fsq_id); if (!$fsq_user) { error_404(); } $owner = users_get_by_id($fsq_user['user_id']); $is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0; # for now... if (!$is_own) { error_403(); } $lat = get_float('latitude'); $lon = get_float('longitude'); if ($lat && $lon) { $more = array(); if (get_float('dist')) { $more['dist'] = get_float('dist'); } if (get_str('unit')) { $more['unit'] = get_str('unit'); } $rsp = privatesquare_checkins_for_user_nearby($owner, $lat, $lon, $more); $geo_stats = privatesquare_checkins_utils_geo_stats($rsp['rows']); $GLOBALS['smarty']->assign_by_ref("geo_stats", $geo_stats); $GLOBALS['smarty']->assign_by_ref("owner", $owner); $GLOBALS['smarty']->assign_by_ref("is_own", $is_own); $GLOBALS['smarty']->assign_by_ref("venues", $rsp['rows']); $GLOBALS['smarty']->assign("latitude", $lat); $GLOBALS['smarty']->assign("longitude", $lon); } $GLOBALS['smarty']->display("page_user_history_nearby.txt"); exit;