<%@ page language="java" pageEncoding="big5"%> <%@ page import = "com.dreye.idict.DLog" %> <%@ page import = "java.net.URLDecoder" %> <%@ page import = "java.net.URLEncoder" %> <%@ page import = "com.dreye.idict.EntryWord" %> <%@ page import = "com.dreye.idict.IDictService" %> <%@ page import = "com.dreye.idict.Base64" %> <%@ page import = "com.dreye.idict.Dict" %> <%@ page import = "java.util.Hashtable" %> <% String reurl = "dict_b5.jsp"; String webserver = "www.dreye.com"; String webpath = "/db/web/htdocs"; // vicky, audio, 2006/9/12 /******************************************************************************/ // get input parameters from end user int nType = 0; String account = null, password = null; String id, w, dod, ver, charset; String title_e, title_v, title_s, title_p, title_n; String nomatch, usererror; String strHistory = ""; String qword = ""; boolean isFindWord = false; String dictAU = null; /******************************************************************************/ id = request.getParameter("id"); w = request.getParameter("w"); dod = request.getParameter("dod"); ver = request.getParameter("ver"); if(dod == null || "".equals(dod)) dod = "0102"; if(id == null) id = "0"; if(w == null || "".equals(w)) w = "A"; if(ver == null){ ver = "big5"; charset = "big5"; }else{ if("gbk".equals(ver)) charset = "gbk"; else charset = "big5"; } response.setContentType("text/html;charset=" + charset); try { nType = Integer.parseInt(request.getParameter("type")); } catch(Exception e) { nType = 0; } String clientIP = request.getRemoteAddr(); StringBuffer slog = new StringBuffer(); slog.append("[").append(clientIP).append("] ").append(request.getMethod()).append(" ").append(request.getRequestURI()); if(request.getQueryString() != null) slog.append("?").append(new String(URLDecoder.decode(request.getQueryString()).getBytes("iso-8859-1"), charset)); DLog.log(slog.toString()); //Properties prop = MyResource.getInstance().getProperties(); title_e = "竡";//prop.getProperty("dict."+ver+".title_e"); title_v = "跑て";//prop.getProperty("dict."+ver+".title_v"); title_s = "竡迭/は竡迭";//prop.getProperty("dict."+ver+".title_s"); title_p = "虫迭";//prop.getProperty("dict."+ver+".title_p"); title_n = "虫迭";//prop.getProperty("dict."+ver+".title_n"); nomatch = "⊿Τтで皌虫迭,┪块才栋ぃタ絋!";//prop.getProperty("dict."+ver+".nomatch"); usererror = "礚眀腹㎝盞絏,叫穝祅魁!";//prop.getProperty("dict."+ver+".usererror"); String referer = request.getHeader("referer"); String extra_domain = "yahoo"; boolean adFlag = true; // 登录过后显示广告 if(referer != null && referer.length() > 7) { referer = referer.toLowerCase() + "/"; int pos = referer.indexOf("/", 7); if(pos > 0) { // host name & port referer = referer.substring(7, pos); if(referer.startsWith(webserver)){ // local domain account = "dreye"; password = "dreye4dict"; adFlag = false; // 第二次连接不再显示广告窗口 }else{ // special third partner domain pos = referer.indexOf(":"); if(pos > 0) referer = referer.substring(0, pos); } } //out.println(referer); } { // 首先通过登录获取用户信息 if(account == null || password == null) { account = (String)request.getParameter("account"); password = (String)request.getParameter("password"); } // 从session获得登录信息 if(account == null || password == null) { account = (String)session.getAttribute("USER_ACCOUNT"); password = (String)session.getAttribute("USER_PASSWORD"); } // 不是登录,则通过referer来获取用户信息 if(account == null || password == null) { if(referer != null) { // 通过referer得到可是用线上辞典服务的帐户信息 Dict dict = new Dict(); Hashtable ht = dict.getAccountByReferer(referer); dict.closedb(); if(ht != null) { account = (String)ht.get("account"); password = (String)ht.get("password"); } } } if(account != null) { // 特定第三方网址来的访问不显示广告窗口 if(account.equals(extra_domain)) adFlag = false; } } if(account == null || password == null) { // 显示登录窗口 %> online dictionary - Dr.eye iDictionary
">
Please login ...
Account:
Password:
<% }else{ session.setAttribute("USER_ACCOUNT", account); session.setAttribute("USER_PASSWORD", password); EntryWord ew = null; IDictService ids = new IDictService(); boolean newUserFlag = true; boolean newCookieFlag = true; Cookie[] cookies1 = request.getCookies(); if(cookies1 != null) { Cookie thisCookie; for(int i = 0; i < cookies1.length; i++) { thisCookie = cookies1[i]; if(thisCookie.getName().equals("cookie_user_enter")) { newUserFlag = (new Boolean(thisCookie.getValue())).booleanValue(); } else if(thisCookie.getName().equals("cookie_cookie_enter")) { newCookieFlag = (new Boolean(thisCookie.getValue())).booleanValue(); } } } if(newUserFlag) { // set cookie, stat users for online dictionary service Cookie cookie = new Cookie("cookie_user_enter", "false"); // available before user's browser closed response.addCookie(cookie); } if(newCookieFlag) { // set cookie, stat users for online dictionary service Cookie cookie = new Cookie("cookie_cookie_enter", "false"); cookie.setMaxAge(60*60*24*30); // one month response.addCookie(cookie); } ids.setUserStat(newUserFlag); ids.setCookieStat(newCookieFlag); w = new String(w.getBytes("iso-8859-1"), charset); switch(nType) { case 1: ew = ids.getQueryById(account, password, id, dod, ver, reurl); break; case 3: ew = ids.getVary(account, password, id, dod, ver, reurl); break; case 4: ew = ids.getAntSynonym(account, password, id, dod, ver, reurl); break; default: ew = ids.getQuery(account, password, w, dod, ver, reurl); break; } StringBuffer contentBuf = new StringBuffer(); StringBuffer menusb = new StringBuffer(); if( ew != null && ew.getError() == 0 ) { isFindWord = true; qword = ew.getQueryedWord(); if (qword==null||"".equals(qword)){ qword = w; } contentBuf.append(new String(Base64.decode(ew.getContent()), "utf-8")); contentBuf.append("
"); //----------------------------------------------------------------------menu if(ew.getContentFlag().equals("EXPLAIN")) { menusb.append("").append(title_e).append(" "); }else { menusb.append("") .append(title_e).append(" "); } if(ew.getContentFlag().equals("VARY")) { menusb.append("").append(title_v).append(" "); }else if (ew.getVaryFlag()) { menusb.append("") .append(title_v).append(" "); }else{ menusb.append("").append(title_v).append(" "); } if(ew.getContentFlag().equals("ANTSYNONYMS")) { menusb.append("").append(title_s).append(" "); }else if (ew.getSynonymsFlag()) { menusb.append("") .append(title_s).append(" "); }else{ menusb.append("").append(title_s).append(" "); } if (ew.getPrevId() > 0){ menusb.append("") .append(title_p).append(" "); }else{ menusb.append("").append(title_p).append(" "); } if (ew.getNextId() > 0){ menusb.append("") .append(title_n).append(" "); }else{ menusb.append("").append(title_n).append(" "); } // vicky, audio, 2006/9/12 -- start { String ww = "", wx = ""; String vm, vx; java.io.File vmFile, vxFile; String w0 = qword.substring(0,1).toUpperCase(); String word = qword; word = word.replaceAll("/", "+"); word = word.replaceAll("\"", "\'"); word = word.replaceAll(";", "+"); word = word.replaceAll("\\?", "~"); word = word.replaceAll(":", "+"); if ( !( (w0.charAt(0) >= 'A' && w0.charAt(0) <= 'Z') || (w0.charAt(0) >= 'a' && w0.charAt(0) <= 'z') ) ){ w0 = "0"; } for(int i=0; i= 'A' && word.charAt(i) <= 'Z') ww += "!"; ww += word.substring(i,i+1); } int pos = ww.indexOf("@"); if (pos > 0){ wx = ww.substring(0, pos); }else{ wx = ww + "@1"; } vm = "/dict/audio/" + w0 + "/" + ww + ".mp3"; vmFile = new java.io.File(webpath + vm); vx = "/dict/audio/" + w0 + "/" + wx + ".mp3"; vxFile = new java.io.File(webpath + vx); if (vmFile.exists()) dictAU = "http://"+webserver+vm; else if(vxFile.exists()) dictAU = "http://"+webserver+vx; //out.println(dictAU); //dictAU = "e:\\ND\\WebRoot\\audio\\0\\3!G.mp3"; if(dictAU != null) { menusb.append("") .append("痷祇").append(" "); contentBuf.append(""); }else{ menusb.append("").append("痷祇").append(" "); } } // vicky, audio, 2006/9/12 -- end String strIsCross = "0"; Cookie[] cookies = request.getCookies(); if (cookies!=null){ for (int i = 0; i < cookies.length; i++){ Cookie c = cookies[i]; if(c.getName().equalsIgnoreCase("iscross")){ strIsCross = c.getValue(); break; } } } if (strIsCross!=null&&"1".equals(strIsCross)){ menusb.append("").append("ユ琩高秨币").append(" "); }else{ menusb.append("").append("ユ琩高闽超").append(" "); } //----------------------------------------------------------------------menu }else if (ew != null && ew.getError() == 1){ qword = w; session.removeAttribute("USER_ACCOUNT"); session.removeAttribute("USER_PASSWORD"); contentBuf.append("

").append(usererror).append("

"); }else{ qword = w; contentBuf.append("

").append(nomatch).append("

"); } //----------------------------------------------------------------write Cookie Cookie[] cookies = request.getCookies(); String strDict = ""; String strID = ""; if (isFindWord){ strDict = ew.getDod(); strID = String.valueOf(ew.getWordId()); } if (cookies==null){ if (isFindWord){ strHistory = qword+"~!"+strID+"~!"+strDict+"~!"+nType+"^#&"; }else{ strHistory = qword+"~!"+"0"+"~!"+strDict+"~!"+"9"+"^#&"; } Cookie c_big5 = new Cookie("history_big5",URLEncoder.encode(strHistory)); // Cookie c_big5 = new Cookie("history_big5",URLEncoder.encode(new String(strHistory.getBytes(charset), "ISO-8859-1"))); c_big5.setMaxAge(60*60*24*30); response.addCookie(c_big5); }else{ boolean isExistCookie = false; String strTemp = ""; for (int i = 0; i < cookies.length; i++){ Cookie c = cookies[i]; if(c.getName().equalsIgnoreCase("history_big5")){ isExistCookie = true; strTemp = URLDecoder.decode(c.getValue()); // strTemp = new String(URLDecoder.decode(c.getValue()).getBytes(), charset); break; } } if (isExistCookie){ if (!isFindWord){ nType = 9; strID = "0"; } strHistory = qword+"~!"+strID+"~!"+strDict+"~!"+nType; String strHistory2 = qword+"~!"+strID+"~!"+strDict+"~!"; if (nType==1){ strHistory2 = strHistory2 + 0; } if (nType==0){ strHistory2 = strHistory2 + 1; } String[] tempList = strTemp.split("\\^\\#\\&"); strTemp = ""; for (int i=0;i8){ strHistory = ""; for (int j=0;j<8;j++){ strHistory += historyList[j] + "^#&"; } } Cookie c_big5 = new Cookie("history_big5",URLEncoder.encode(strHistory)); // Cookie c_big5 = new Cookie("history_big5",URLEncoder.encode(new String(strHistory.getBytes(charset), "ISO-8859-1"))); c_big5.setMaxAge(60*60*24*30); response.addCookie(c_big5); }else{ if (isFindWord){ strHistory = qword+"~!"+strID+"~!"+strDict+"~!"+nType+"^#&"; }else{ strHistory = qword+"~!"+"0"+"~!"+strDict+"~!"+"9"+"^#&"; } Cookie c_big5 = new Cookie("history_big5",URLEncoder.encode(strHistory)); // Cookie c_big5 = new Cookie("history_big5",URLEncoder.encode(new String(strHistory.getBytes(charset), "ISO-8859-1"))); c_big5.setMaxAge(60*60*24*30); response.addCookie(c_big5); } } //----------------------------------------------------------------write Cookie //-----------------------------------------------------------------read Cookie StringBuffer historysb = new StringBuffer(); if (strHistory!=null&&!"".equals(strHistory)){ String[] historyList = strHistory.split("\\^\\#\\&"); for (int j=0;j1"); strShowWord = strShowWord.replaceAll("@2","2"); strShowWord = strShowWord.replaceAll("@3","3"); strShowWord = strShowWord.replaceAll("@4","4"); strShowWord = strShowWord.replaceAll("@5","5"); if (strShowDict != null && "0201".equals(strShowDict)){ strShowDict = "簙璣迭ㄥ"; }else{ strShowDict = "璣簙迭ㄥ"; } if (strShowTip!=null&&"1".equals(strShowTip)){ strShowTip = title_e; }else if (strShowTip!=null&&"3".equals(strShowTip)){ strShowTip = title_v; }else if (strShowTip!=null&&"4".equals(strShowTip)){ strShowTip = title_s; }else if (strShowTip!=null&&"0".equals(strShowTip)){ strShowTip = title_e; }else if (strShowTip!=null&&"9".equals(strShowTip)){ strShowTip = "ゼ琩高赣虫迭"; strShowDict = ""; strShowClass = "font_history_nofound"; strShowSplit = ""; }else{ strShowTip = "ゼ琩高赣虫迭"; strShowDict = ""; strShowClass = "font_history_nofound"; strShowSplit = ""; } String str1= wordList[0].replaceAll("'","\\\\'").replaceAll("\"","~"); historysb.append(" ").append(strShowWord) .append(" ").append(strShowDict).append(strShowSplit) .append(strShowTip).append(""); } }else{ } //-----------------------------------------------------------------read Cookie //menu show String strMenuDict = "璣簙迭ㄥ"; if (strDict != null && "0201".equals(strDict)){ strMenuDict = "簙璣迭ㄥ"; } %> 亩ㄥ硄呼
舦琩  硁砰  璣粂贾堕  

Dr.eye
">
 
<%=strMenuDict%>
 
<%=menusb.toString()%>
 
 
 
  <%=contentBuf.toString()%>
  琩高菌  
  <%=historysb.toString()%>
 
 

闽亩ㄥ硄 | 羛蹈и | 呼瓜 | 呼羛幅
Copyright © 2008 Inventec 舦┮Τ ぃ眔锣更
<% } %>