<%@page import="com.hanweb.jcms.util.FilterUtil"%> <%@page import="com.hanweb.common.util.StringUtil"%> <%@page import="com.hanweb.common.util.NumberUtil"%> <%@page import="com.hanweb.common.util.mvc.Script"%> <%@page contentType="text/html;charset=UTF-8" %> <%@page import="java.util.*"%> <%@page import="java.io.File"%> <%@page import="com.hanweb.jcms.sys.service.SysInfo"%> <%@page import="com.hanweb.jcms.plugins.voting.service.Jcms_Voting_KindBLF" %> <%@page import="com.hanweb.jcms.plugins.voting.service.Jcms_Voting_AnswerBLF"%> <%@page import="com.hanweb.jcms.util.AccessUtil"%> <%@page import="com.hanweb.jcms.plugins.voting.entity.Jcms_Voting_KindEntity"%> <%@page import="com.hanweb.jcms.plugins.voting.service.VotingFun" %> <%@ include file="./config.jsp" %> <% Script script = Script.getInstanceOnly(); if(!AccessUtil.checkAccess(request)){ //阻止跨站点请求伪造 out.print(script.addScript("location.href='../../';").getScript()); return; } /* CSRF防御 */ String crumb = UUID.randomUUID().toString(); session.setAttribute("crumb", crumb); int tempWebId = NumberUtil.getInt(request.getParameter("webid"),0); if(tempWebId > 0) strWebID = ""+tempWebId; String strPath = VotingFun.getPath(application.getRealPath(""), strAppID, NumberUtil.getInt(strWebID)); // 得到调查类别的ID int kindid = NumberUtil.getInt(request.getParameter("classid"), 0); // 问题ID int queId = NumberUtil.getInt(request.getParameter("queid"), 0); int nScope = 0; // 是否带答案显示 1=显示;0=不显示 int isAnswer = NumberUtil.getInt(request.getParameter("answer"), 0); //调用方式:是嵌入在单元中显示 yes;通过URL直接调用 no String strInlay =StringUtil.getSafeString(request.getParameter("inlay")); if(StringUtil.equals(strInlay, "")){ strInlay = "yes"; } boolean blModal = true; if(isAnswer == 1){ blModal = false; } String strUnitPath = ""; if(kindid > 0){ strUnitPath = strPath + "config" + File.separator + "init"+kindid+".xml"; }else{ strUnitPath = strPath + "config" + File.separator + "init.xml"; } String strConfigPath = strPath + "config" + File.separator + "config.xml"; String strwebtype = xmlFile.getContent( "webtype", strConfigPath ); strwebtype = StringUtil.getString(strwebtype); String strWebServerName = xmlFile.getContent( "web_in_servername", strConfigPath ); strWebServerName = StringUtil.getString(strWebServerName); Jcms_Voting_KindBLF vBLF = Jcms_Voting_KindBLF.getInstance().init(strAppID, NumberUtil.getInt(strWebID)); Jcms_Voting_KindEntity vkEn = vBLF.getEntity(kindid); if(vkEn == null) return; int b_showresult = vkEn.getB_showresult(); // 0 a.vc_question, 1 a.i_type, 2 b.vc_name, 3 a.i_id, 4 a.b_feedback, // 5 b.i_timescope, 6 b.vc_sparefield, 7 a.i_sparefield1, 8 b.i_type, 9 b.c_endtime String[][] strData = vBLF.getUnitData(kindid,-1); if( strData == null || strData.length == 0 ){ out.println("查询记录为空,请检查问题是否已创建!"); return; } if( StringUtil.getString(strData[0][8]).equals("1") ) { nScope = VotingFun.getScope( StringUtil.getString(strData[0][9])); } //系统路径 String strSysPath = "/"; if(strwebtype.equals("1")){ strSysPath = request.getContextPath() + "/jcms_files/jcms"+strAppID+"/web"+strWebID+"/site/"; } if(strwebtype.equals("2")){ strSysPath = "/"; } String strForTr = ""; String strHead = ""; String strEnd = ""; String strContent = ""; String strAnswer = ""; String strHidden = ""; String strTextHight = ""; String strTextWidth = ""; String strCols = ""; String strScript = ""; String strDepiction = ""; String strRandomCode = "";//随机码的html代码 StringBuffer scriptBuf = new StringBuffer(); int nColumns = 1; String strDisplay = nScope==1?"none":""; String strDisplayView = b_showresult==1?"":"none"; strHidden += ""; strHidden += ""; StringBuffer sbContent = new StringBuffer( 256 ); Vector v_label = new Vector(5); v_label.add( ""); v_label.add( "" ); v_label.add( ""); v_label.add( "" ); v_label.add( ""); Vector v_label_value = new Vector(5); strScript = xmlFile.getContent( "scriptcode",strUnitPath ); strTextHight = xmlFile.getContent( "texthight", strUnitPath ); strTextWidth = xmlFile.getContent( "textwidth", strUnitPath ); String strqyHeight = xmlFile.getContent( "qyheight", strUnitPath ); String strqyWidth = xmlFile.getContent( "qywidth", strUnitPath ); strScript = strScript.replaceAll("",""+kindid); strScript = strScript.replaceAll("",""+queId); strCols = xmlFile.getContent("column", strUnitPath); strCols = StringUtil.getString(strCols); int nCols = NumberUtil.getInt(strCols,1); int nStart = strScript.indexOf( "" ); int nEnd = strScript.indexOf( "" ); String strBgColor = ""; int nRadom = (int)Math.ceil(Math.random()*100); if( nStart != -1 && nEnd != -1 && nEnd > nStart ) { strHead = strScript.substring(0,nStart ); strForTr = strScript.substring( nStart+10,nEnd ); strEnd = strScript.substring( nEnd+11 ); sbContent.append( " " ); int nNum = 0; Jcms_Voting_AnswerBLF blf = Jcms_Voting_AnswerBLF.getInstance().init(strAppID); for( int i=0;i"); strContent = strForTr; try{ nColumns = NumberUtil.getInt( strData[i][7] ); nColumns = nColumns==0?1:nColumns; }catch( Exception e ) { nColumns = 1; } /*添加随机验证码*/ Random random = new Random(); strRandomCode = " " + ""+ ""; strAnswer = blf.getAnswer( NumberUtil.getInt( strData[i][3]), StringUtil.getString( strData[i][0]), NumberUtil.getInt( strData[i][1]), NumberUtil.getInt( strData[i][4] ), nColumns,strTextHight, strTextWidth,strAppID, NumberUtil.getInt( strData[i][10] ), nRadom ); scriptBuf.append(blf.getStrScript()); // 必填项的js v_label_value.add(StringUtil.getString(strData[i][2])); if(NumberUtil.getInt( strData[i][10] ) == 1){ v_label_value.add( StringUtil.getString(strData[i][0]) +"  *(必填)"); }else{ v_label_value.add(StringUtil.getString(strData[i][0])); } v_label_value.add(strAnswer); v_label_value.add(String.valueOf(i+1)); v_label_value.add(strRandomCode); strDepiction = StringUtil.getString(strData[i][6]); for( int j=0;j
"+strContent+"
" ); nNum ++ ; if( nNum==nCols ) { sbContent.append( ""); nNum = 0; } v_label_value.clear(); } sbContent.append( "" ); strScript = strHead + sbContent.toString() + strEnd; v_label_value.add( strData[0][2] ); v_label_value.add(""); v_label_value.add(""); v_label_value.add(""); v_label_value.add(strRandomCode); } else{ v_label_value.add(StringUtil.getString(strData[0][2])); v_label_value.add(StringUtil.getString(strData[0][0])); v_label_value.add( "answer" ); v_label_value.add( "1"); v_label_value.add(""); } String temp=""; int height = NumberUtil.getInt(request.getParameter("height"),0); int width = NumberUtil.getInt(request.getParameter("width"),0); if (height > 0){ temp = "height='"+strqyHeight+"'"; } else { if(NumberUtil.getInt(strqyHeight)>0){ temp = "height='"+strqyHeight+"'"; } } if (width > 0){ temp += " width='"+strqyWidth+"'"; } else { if(NumberUtil.getInt(strqyWidth)>0){ temp += " width='"+strqyWidth+"'"; } } for( int j=0;j",""); } strScript = StringUtil.replace( strScript,"\n",""); strScript = StringUtil.replace( strScript,"",strDisplay); strScript = StringUtil.replace( strScript,"",strDisplayView); strScript = StringUtil.replace( strScript,"",strDepiction); String funScript = ""; funScript = "" +""; if(scriptBuf != null) scriptBuf.delete(0, scriptBuf.length()); String str = funScript+ "
" + strScript.trim()+strHidden.trim()+"
"; String strModal = ""; if( blModal ) { strModal = VotingFun.getModal(NumberUtil.getInt(strWebID), strAppID, application.getRealPath(""), strwebtype, strWebServerName); String strFrom1 = ""; int nPos1 = strModal.indexOf( strFrom1 ); int nPos2 = strModal.indexOf( strFrom2, nPos1 ); if( nPos1!=-1 && nPos2!=-1 && nPos2>nPos1 ) str = strModal.substring(0,nPos1) + str + strModal.substring( nPos2+strFrom2.length() ); out.println( str ); out.println( ""); } else { str = StringUtil.replace( str,"\"","\\\\\""); if(strInlay.equals("yes")){ // 嵌入到单元 out.println( "document.write(\""+ str +"\");" ); out.println( "document.write(\"\");"); }else{ // 未设置模板,也未嵌入到单元 out.println(""); out.println(str); out.println( ""); } } %>