<%@ page import="java.net.*, java.io.*, java.security.*" %>
<%
final String MOBILE_SITE = "m.alertlocksmiths.co.uk";
final boolean DA_USE_COOKIES = true;
final boolean DA_USE_CACHE = true;
final String DA_CACHE_DIR = System.getProperty("java.io.tmpdir")+ System.getProperty("file.separator")+"DeviceAtlasCache"+System.getProperty("file.separator");
final String DA_URI = "http://detect.deviceatlas.com/query";
final int COOKIE_EXPIRY_TIME = 21600;
String source = "none";
String error = "";
String daJson = null;
String redirectParam = request.getParameter("redirect");
//If redirect permitted (not explicitly prevented via redirect=false param)
if((null!=redirectParam && !redirectParam.equals("false")) || redirectParam==null) {
boolean preventRedirect = false;
if (DA_USE_COOKIES && null!=getCookieValue("Mobi_Mtld_DA_Prevent_Redirect", request.getCookies())) {
//Clear the redirect-prevention cookie if we see redirect=true parameter
if(null!=redirectParam && redirectParam.equals("true")) {
Cookie cookie = getCookie("Mobi_Mtld_DA_Prevent_Redirect", request.getCookies());
if(null!=cookie) {
cookie.setMaxAge(0);
//Do we need to add it back to the response like this?
response.addCookie(cookie);
}
}
else {
preventRedirect = Boolean.parseBoolean(getCookieValue("Mobi_Mtld_DA_Prevent_Redirect", request.getCookies()));
//If prevent cookie has value true then stop the redirect
if(preventRedirect) {
source = "prevent_redirect";
}
}
}
//Grab the user-agent
String userAgent = request.getHeader("user-agent");
//Look up cookies
if(DA_USE_COOKIES) {
daJson = getCookieValue("Mobi_Mtld_DA_Properties", request.getCookies());
if(daJson != null && !daJson.equals("null")) {
source = "cookie";
}
}
//Look up cache
if(DA_USE_CACHE && source.equals("none")) {
String filename = DA_CACHE_DIR + md5(userAgent) + ".json";
File dir = new File(DA_CACHE_DIR);
if(!dir.exists() && !dir.mkdirs()) {
error = "Unable to create cache directory: " + DA_CACHE_DIR + "\n";
}
else {
//Read the cache file if it exists
daJson = readFileAsString(filename);
if(daJson!=null && !daJson.trim().equals("null") && !daJson.trim().equals("")) source = "cache";
}
}
//Look up DA webservice if we need to
if(source.equals("none")) {
URL DA = new URL("http://detect.deviceatlas.com/query?User-Agent=" + URLEncoder.encode(userAgent));
URLConnection conn = DA.openConnection();
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = null;
line = br.readLine();
while (line != null) {
daJson += line;
line = br.readLine();
}
br.close();
if(null!=daJson) {
source = "webservice";
if(DA_USE_COOKIES) {
Cookie cookie = new Cookie("Mobi_Mtld_DA_Properties", daJson);
response.addCookie(cookie);
}
if(DA_USE_CACHE) {
String filename = DA_CACHE_DIR + md5(userAgent) + ".json";
writeFile(filename, daJson);
}
}
}
String isMobile = parseJson(daJson, "mobileDevice");
//Do the redirect
if(null!=isMobile && isMobile.equals("true") && !preventRedirect) response.sendRedirect(MOBILE_SITE);
}
else {
//Create a cookie to prevent redirect for subsequent requests
if (DA_USE_COOKIES && null==getCookieValue("Mobi_Mtld_DA_Prevent_Redirect", request.getCookies())) {
Cookie cookie = new Cookie("Mobi_Mtld_DA_Prevent_Redirect", "true");
cookie.setMaxAge(COOKIE_EXPIRY_TIME);
response.addCookie(cookie);
}
}
%>
<%!
//Some helper functions
//Parse json for property - really basic & assumes flat json file as returned by DA service
static final String parseJson(String json, String property) {
if(null==json) return null;
String[] tokens = json.split(",\\s\"|\":|\\{\"|:\\s|,\\s|\\}");
for(int i=0;i
Call NOW on:- 01420 501999

Lock Changes in Bordon.Alert Locksmiths carry a wide selection of equipment
and stock which enables us to provide a one stop solution to most situations both commercial and residential. We will
provide up-front costs with no hidden charges. We can also cut spare keys on site that will be tested to work first time.

 |
 |
Bordon Locksmith - Independant, Family Run Business
- Local 24 hour Emergency Locksmith
- No Call Out Charge
- Free Estimates and Advice
- UPVC Door and Window Specialist
- "Insurance Approved" Locks Supplied and fitted
- Domestic and Commercial work including burglary repairs
- Mobile Key
cutting
- Fast, Friendly, Reliable Service
- Fully CRB Checked for your peace of mind
Emergency Locksmith in Bordon.Alert Locksmiths provide 24 hour cover for
emergency situations.
UPVC door lock Repairs in Bordon.Alert Locksmiths have also undergone extensive training in uPVC repairs. We can repair, replace or upgrade your existing
uPVC door locks as well as repair any cosmetic damage, leaving your uPVC door looking and working like new.
Locksmith Bordon: No Problem too Big or too SmallSo
if you live in or around Bordon and need a lock changed, repairs to your UPVC door lock or require the
services of an Emergency Locksmith in GU35, give your local locksmith a call on :
01420 501999
 |
 |
Mobile Locksmith Services.Alert Locksmiths provide full mobile locksmith
services to Bordon, and all surrounding areas.

 What customers say about Alert Locksmiths:-
Excellent service. Very courteous and advised me of all options and costs and came up with a suitable
solution. I would recommend this company. Customer
in Bordon, 2 November 2011
Repair to front door lock after key broke in lock
Excellent service, on time and at a good price, also adjusted door hanging so locks
worked more efficiently. Customer in
Bordon, 25 October 2011 New locking mechanism for front door We
are so impressed, it is like the whole door has been replaced. Customer in Bordon, 11 July 2011
Replacement of jammed UPVC window locks.
Outstanding in attitude and operation and excellent price. Customer in Bordon, 1
June 2011
 |
|
 |