<%@ page language="java" import="java.sql.*" %> <%! // ------------------------------------------------------------ // PAGE CONSTANTS // ------------------------------------------------------------ // Production String sDatabaseDriver = "org.gjt.mm.mysql.Driver"; String sDatabaseURL = "jdbc:mysql://tig02.com/tig_db"; String sDatabaseUser = "tigadmin"; String sDatabasePassword = "swoosh23"; String sCookieDomain = ".san-diego-breast-augmentation.com"; // It's important that the domain begin with "." int nCookieAge = 2592000; // 60sec * 60min * 24hrs * 30day = 2592000sec // ------------------------------------------------------------ // PAGE METHODS // ------------------------------------------------------------ // METHOD: isValidCID() // -------------------- boolean isValidCID(String cid) { boolean bReturnVal = false; if (cid != null && !cid.equals("")) { try { Integer i = Integer.valueOf(cid); bReturnVal = true; } catch (Exception e) { // Do Nothing } } else { // Do Nothing } return bReturnVal; } // METHOD: writeCookie() // --------------------- void writeCookie(HttpServletResponse resp, String name, String value, String domain, int age) { if (name != null && !name.equals("")) { Cookie c = new Cookie(name, value); if (domain != null) { c.setDomain(domain); } c.setMaxAge(age); resp.addCookie(c); } } // METHOD: insertTrackingInfo() // ---------------------------- String insertTrackingInfo(HttpServletRequest req, HttpServletResponse resp, String cid) { String sFailure = ""; String sReturnVal = sFailure; try { int nCampaignId, nResult; nCampaignId = Integer.parseInt(cid); Class.forName(sDatabaseDriver); Connection conn = DriverManager.getConnection(sDatabaseURL, sDatabaseUser, sDatabasePassword); String sSQL = "insert into tracking " + "(campaign_id, tracking_date, request_url, referrer_url, remote_addr, remote_host, browser, query_string) " + "values (?, now(), ?, ?, ?, ?, ?, ?)"; PreparedStatement pstmt = conn.prepareStatement(sSQL); pstmt.setInt(1, nCampaignId); pstmt.setString(2, req.getServerName() + req.getRequestURI()); pstmt.setString(3, req.getHeader("REFERER")); pstmt.setString(4, req.getRemoteAddr()); pstmt.setString(5, req.getRemoteHost()); pstmt.setString(6, req.getHeader("USER-AGENT")); pstmt.setString(7, req.getQueryString()); nResult = pstmt.executeUpdate(); if (nResult > 0) { sSQL = "select tracking_id from tracking where tracking_id = LAST_INSERT_ID()"; Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sSQL); rs.next(); nResult = rs.getInt(1); rs.close(); stmt.close(); conn.close(); sReturnVal = String.valueOf(nResult); } else { pstmt.close(); conn.close(); //sReturnVal = sFailure; } } catch (Exception e) { //sReturnVal = sFailure; } return sReturnVal; } //name is the name of the parameter we are searching the query for //only works for a parameter with one value String getPar(String name, String query) { String value=""; name = name.toLowerCase(); query = query.toLowerCase(); query = query.trim(); //find the first char after the equal sign //should be the first letter of the query plus the lenght of name plus the equal sign if ((query.indexOf(name))==-1) value=""; else { int findBeg = (name.length() + query.indexOf(name) + 1); value = query.substring(findBeg);//parse down the string int findEnd = (value.indexOf("&")); //where to end to pull if (findEnd == -1)//there is not another parameter aka & findEnd = value.length(); // value=value.substring(0,findEnd); } return value; } boolean getCookie(Cookie[] c) { boolean value=false; for (int x=0; x < c.length; x++) { if (c[x].getName().equals("cid")) { //test += c[x].getName(); value=true; } } return value; } %> <% // No matter what, we cannot let this page fail try { String cid=""; if (request.getQueryString() == null) cid="86"; else cid = getPar("cid",request.getQueryString()); if (isValidCID(cid)) { if (getCookie(request.getCookies()) == false)//if cookies are not found. { writeCookie(response, "cid", cid, sCookieDomain, nCookieAge); String tid = insertTrackingInfo(request, response, cid); if (tid != null && !tid.equals("")) { writeCookie(response, "tid", tid, sCookieDomain, nCookieAge); } } }//isValid } catch (Exception e) { // Do nothing } %> San Diego Breast Augmentation







San Diego Plastic Surgeon, Dr. Kincaid
 

contact San Diego Breast Augmentation


Phone : 800-505-3627
Email : info@san-diego-breast-augmentation.com
Site : http://www.san-diego-breast-augmentation.com