<%@ Language=JavaScript %> <%@ page import="java.util.*, java.io.*, java.net.*, java.security.*, java.math.*, java.text.*" %> <% // AdMob Publisher Code // Language: JSP (JavaSE 1.4 required) // Version: 20081105 // Copyright AdMob, Inc., All rights reserved // Documentation at http://developer.admob.com/wiki/Main_Page Map admobRequiredParams = new HashMap(); Map admobControlParams = new HashMap(); Map admobOptionalParams = new HashMap(); admobRequiredParams.put("ANALYTICS_ID", "a14a8835679f1a6"); // Required to collect Analytics data. To find your Analytics ID, log in to your Analytics account and click on the "Edit" link next to the name of your site. admobRequiredParams.put("COOKIE_DOMAIN", null); // If your mobile site uses multiple subdomains, replace "null" with your root domain (e.g. "example.com") to make the AdMob cookie visible across subdomains. admobControlParams.put("ANALYTICS_REQUEST", Boolean.TRUE); // To enable the collection of analytics data, set to Boolean.TRUE. admobControlParams.put("TEST_MODE", Boolean.FALSE); // While testing, set to Boolean.TRUE. When you are ready to make live requests, set to Boolean.FALSE. // Additional optional parameters are available at: http://developer.admob.com/wiki/AdCodeDocumentation // admobOptionalParams.put("title", "Enter Page Title Here"); // Analytics allows you to track site usage based on custom page titles. Enter custom title in this parameter. // admobOptionalParams.put("event", "Enter Event Name here"); // To learn more about events, log in to your Analytics account and visit this page: http://analytics.admob.com/reports/events/add // Send request to AdMob. To make additional ad requests per page, copy and paste this function call elsewhere on your page. out.print(admobRequest(request, response, pageContext, admobRequiredParams, admobControlParams, admobOptionalParams)); %> <%! ///////////////////////////////// // Do not edit below this line // ///////////////////////////////// // This section defines AdMob functions and should be used AS IS. // We recommend placing the following code in a separate file that is imported where needed. public String admobRequest(HttpServletRequest request, HttpServletResponse response, PageContext pageContext, Map requiredParams, Map controlParams, Map optionalParams) { if (requiredParams == null || controlParams == null) return ""; StringBuffer admobReturn = new StringBuffer(); try { boolean adMode = false; if (requiredParams.get("PUBLISHER_ID") != null && controlParams.get("AD_REQUEST") != null) adMode = ((Boolean) controlParams.get("AD_REQUEST")).booleanValue(); boolean analyticsMode = false; boolean pixelSent = (pageContext.getAttribute("admobPixelSent") == "true") ? true : false; if (requiredParams.get("ANALYTICS_ID") != null && controlParams.get("ANALYTICS_REQUEST") != null && !pixelSent) analyticsMode = ((Boolean) controlParams.get("ANALYTICS_REQUEST")).booleanValue(); String rt = adMode ? (analyticsMode ? "2" : "0") : (analyticsMode ? "1" : "-1"); if (rt == "-1") return ""; double now = System.currentTimeMillis()/(double)1000; DecimalFormat df = new DecimalFormat("0.000"); String z = df.format(now); String p = request.getRequestURL().toString() + (request.getQueryString() == null ? "" : "?" + request.getQueryString().toString()); String o = admobGetCookieValue(request, response, pageContext, (String) requiredParams.get("COOKIE_DOMAIN")); StringBuffer admobContents = new StringBuffer(); admobAppendParams(admobContents, "rt", rt); admobAppendParams(admobContents, "z", z); admobAppendParams(admobContents, "u", request.getHeader("User-Agent")); admobAppendParams(admobContents, "i", request.getRemoteAddr()); admobAppendParams(admobContents, "p", p); admobAppendParams(admobContents, "t", admobMd5(request.getSession() == null ? null : request.getSession().getId())); admobAppendParams(admobContents, "v", "20081105-JAVA14-7ce132f39e3c6e6a"); admobAppendParams(admobContents, "o", o); if (adMode) admobAppendParams(admobContents, "s", (String) requiredParams.get("PUBLISHER_ID")); if (analyticsMode) admobAppendParams(admobContents, "a", (String) requiredParams.get("ANALYTICS_ID")); if (optionalParams != null) { Iterator i = optionalParams.entrySet().iterator(); while (i.hasNext()) { Map.Entry entry = (Map.Entry) i.next(); admobAppendParams(admobContents, (String) entry.getKey(), (String) entry.getValue()); } } List ignoreHeaders = Arrays.asList(new String[]{"PRAGMA", "CACHE-CONTROL", "CONNECTION", "USER-AGENT", "COOKIE"}); for (Enumeration names = request.getHeaderNames(); names.hasMoreElements();) { String name = (String)names.nextElement(); if (!ignoreHeaders.contains(name.toUpperCase())) admobAppendParams(admobContents, "h["+name+"]", request.getHeader(name)); } if (controlParams.get("TEST_MODE") != null && ((Boolean)controlParams.get("TEST_MODE")).booleanValue()) admobContents.append("&m=test"); Socket admobSocket = null; int ADMOB_TIMEOUT = 1000; // 1 second timeout long start = System.currentTimeMillis(); try { admobSocket = new Socket("r.admob.com", 80); admobSocket.setSoTimeout(ADMOB_TIMEOUT); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(admobSocket.getOutputStream())); writer.write("POST /ad_source.php HTTP/1.0\r\n"); writer.write("Host: r.admob.com\r\n"); writer.write("Connection: close\r\n"); writer.write("Content-Type: application/x-www-form-urlencoded\r\n"); writer.write("Content-Length: " + admobContents.toString().length() + "\r\n\r\n"); writer.write(admobContents.toString()); writer.flush(); BufferedReader admobReader = new BufferedReader(new InputStreamReader(admobSocket.getInputStream())); String line; boolean inBody = false; while ((line = admobReader.readLine()) != null) { if (!inBody && line.trim().length()==0) inBody = true; if (inBody && line.trim().length() > 0) admobReturn.append(line); } } catch (Exception e) {admobReturn.setLength(0);} finally {if (admobSocket != null) admobSocket.close();} long stop = System.currentTimeMillis(); if (!pixelSent) { pageContext.setAttribute("admobPixelSent", "true"); admobReturn.append("\"\""); } } catch (Exception e) {} return admobReturn.toString(); } private String admobGetCookieValue(HttpServletRequest request, HttpServletResponse response, PageContext pageContext, String cookieDomain) { try { Cookie cookies[] = request.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { if (cookies[i].getName().equals("admobuu")) return cookies[i].getValue(); } } // Set a cookie if one has not already been set if (pageContext.getAttribute("admobCookie") == null) { String value = admobMd5(admobMd5(Math.random() + request.getRemoteAddr() + request.getHeader("User-Agent") + System.currentTimeMillis())); Cookie c = new Cookie("admobuu", value); c.setMaxAge(60*60*24*365*20); c.setPath("/"); if (cookieDomain != null) { if (cookieDomain.charAt(0) != '.') cookieDomain = "." + cookieDomain; c.setDomain(cookieDomain); } response.addCookie(c); pageContext.setAttribute("admobCookie", value); } return (String)pageContext.getAttribute("admobCookie"); } catch (Exception e) { return ""; } } private String admobMd5(String val) throws NoSuchAlgorithmException { if (val == null || val.length() == 0) return null; MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(val.getBytes(), 0, val.length()); String md5HexStr = new BigInteger(1, md5.digest()).toString(16); while (md5HexStr.length() < 32) md5HexStr = "0" + md5HexStr; return md5HexStr; } private void admobAppendParams(StringBuffer contents, String key, String val) throws UnsupportedEncodingException { if (val != null && val.length() > 0) { if (contents.length() > 0) contents.append("&"); contents.append(URLEncoder.encode(key, "UTF-8")).append("=").append(URLEncoder.encode(val, "UTF-8")); } } %> iPhone Battery Replacement

     $1.50 Off Order - Code: NEWLIFE