jjxweb = function(hostip, port) { // jjxwebajax.js version this.version = "2.5.2"; // jjxwebservlet version this.serverversion = ""; // debug flag this.debug = false; // target host ip this.hostip = hostip; // server port this.port = port; // paremeter delimeter this.dlm = unescape("%1f"); // server full url this.url = ""; // Modified by CWYOO at 2010.02.18 // Set current protocol from document.location // Modifed by CWYOO at 2009.07.07 if(this.port !=null && this.port != "" && this.port != "80") { if(this.hostip.indexOf(":")==-1) { this.url = document.location.protocol + "//" + this.hostip + ":" + this.port + "/jjxweb/jjxwebservlet"; // Added by CWYOO at 2010.03.15 for push this.url_send = document.location.protocol + "//" + this.hostip + ":" + this.port + "/jjxweb/chat"; this.url_poll = document.location.protocol + "//" + this.hostip + ":" + this.port + "/jjxweb/broadcaster"; } else { this.url = document.location.protocol + "//" + this.hostip + "/jjxweb/jjxwebservlet"; // Added by CWYOO at 2010.03.15 for push this.url_send = document.location.protocol + "//" + this.hostip + "/jjxweb/chat"; this.url_poll = document.location.protocol + "//" + this.hostip + "/jjxweb/broadcaster"; } } else { this.url = document.location.protocol + "//" + this.hostip + "/jjxweb/jjxwebservlet"; // Added by CWYOO at 2010.03.15 for push this.url_send = document.location.protocol + "//" + this.hostip + "/jjxweb/chat"; this.url_poll = document.location.protocol + "//" + this.hostip + "/jjxweb/broadcaster"; } // Added by CWYOO at 2008.05.09 this.rcvtext = ""; // Added by CWYOO at 2008.06.18 this.licenseMsg = "License is expired. Please contact site administrator"; // Added by CWYOO at 2008.05.19 for HR_PROXY this.httpStatusCode = ""; this.httpStatusText = ""; this.tmpresult = null; // array of two dimension this.fetchresult = [null,null,null,null,null,null,null,null,null,null]; // array of three dimension this.fetchrcnt = [0,0,0,0,0,0,0,0,0,0]; this.fetchidx = [0,0,0,0,0,0,0,0,0,0]; this.arrsize = [0,0,0,0,0,0,0,0,0,0]; this.errcode = null; this.errmsg = null; this.result = null; //array of one dimension SQLEXECUTE or EXECPGM, GETCLOB this.results = null; //array of two dimension SELECTINTO this.resultone = [null,null,null,null,null,null,null,null,null,null]; // array of two dimension,FETCH this.cursor = -1; this.rcnt = 0; this.sessvarvalue = null; this.sessionid = null; this.remote_addr = ""; } jjxweb.prototype = { /** * retrieve jjxwebajax.js version */ HR_VERSION: function() { return this.version; }, /** * retrieve server version */ HR_SERVERVERSION: function() { var parm = "v" + this.dlm; var parms = "kind=2&data=" + parm; this.jjajaxRequest(this.url, parms, false); if (this.errcode=='0000000') this.serverversion = this.errmsg; else this.serverversion = null; if (this.errcode=="0000000") return 0; else return -1; }, /** * retrieve client ip address */ HR_REMOTEADDR: function() { var parm = "z" + this.dlm; var parms = "kind=2&data=" + parm; this.jjajaxRequest(this.url, parms, false); if (this.errcode=='0000000') this.remote_addr = this.errmsg; else this.remote_addr = null; if (this.errcode=="0000000") return 0; else return -1; }, /** * Modified by CWYOO at 2010.03.26 * Added parameter pool, userid, password * create user session * @param forced: true:create, false:don't create * @param pool: db pool name * @param userid user id * @param password: user password * @return result 0: success */ HR_SESSIONOPEN: function(forced, pool, userid, password, authClass) { this.errcode = null; this.errmsg = null; this.sessionid = null; if (forced==false) var parm = "a" + this.dlm + "false"; else var parm = "a" + this.dlm + "true"; // Added by CWYOO at 2010.03.26 parm += this.dlm + pool + this.dlm + userid + this.dlm + password + this.dlm + authClass; var parms = "kind=2&data=" + window.encodeURIComponent(parm); this.jjajaxRequest(this.url, parms, false); // Modified by CWYOO at 2010.04.12 // Changed HR_SESSIONOPEN spec //if (this.errcode=='0000000') this.sessionid = this.errmsg; if (this.errcode=='0000000' || this.errcode=='0000001') this.sessionid = this.errmsg; else this.sessionid = null; if (this.errcode=="0000000") return 0; // Added by CWYOO at 2010.04.12 else if (this.errcode=="0000001") return 1; else return -1; }, /** * close user session * @return result 0:success */ HR_SESSIONCLOSE: function() { this.errcode = null; this.errmsg = null; var parm = "b" + this.dlm; var parms = "kind=2&data=" + window.encodeURIComponent(parm); this.jjajaxRequest(this.url, parms, false); if (this.errcode=="0000000") return 0; else return -1; }, /** * set session variable * @param sessvarname: session variable name * @param sessvarvalue: session variable value * @return result 0:success */ HR_PUTSESSVAR: function(sessvarname,sessvarvalue) { this.errcode = null; this.errmsg = null; var parm = "c" + this.dlm + sessvarname + this.dlm + sessvarvalue; var parms = "kind=2&data=" + window.encodeURIComponent(parm); this.jjajaxRequest(this.url, parms, false); if (this.errcode=="0000000") return 0; else return -1; }, /** * retrieve session variable * @param sessvarname: session variable name * @return result 0:success */ HR_GETSESSVAR: function(sessvarname) { this.errcode = null; this.errmsg = null; this.sessvarvalue = null; var parm = "d" + this.dlm + sessvarname; var parms = "kind=2&data=" + window.encodeURIComponent(parm); this.jjajaxRequest(this.url, parms, false); if (this.errcode=='0000000') this.sessvarvalue = this.errmsg; else this.sessvarvalue = null; if (this.errcode=="0000000") return 0; else return -1; }, /** * execute command on target server * @param command: command for execute * @return result 0:success */ HR_EXECPGM: function(command) { this.errcode = null; this.errmsg = null; this.result = null; var parm = "t" + this.dlm + command; var parms = "kind=2&data=" + window.encodeURIComponent(parm); this.jjajaxRequest(this.url, parms, false); if (this.errcode=='0000000') this.result = this.errmsg; else this.result = null; if (this.errcode=="0000000") return 0; else return -1; }, /** * execute shell command on target server * @param command: shell command * @return result 0:success */ HR_SHELL: function(command) { this.errcode = null; this.errmsg = null; this.result = null; var parm = "u" + this.dlm + command; var parms = "kind=2&data=" + window.encodeURIComponent(parm); this.jjajaxRequest(this.url, parms, false); if (this.errcode=='0000000') this.result = this.errmsg; else this.result = null; if (this.errcode=="0000000") return 0; else return -1; }, /** * Added by CWYOO at 2010.03.23 */ HR_SELECT: function(dbname, sqlstring, sqlparamarray, usesqlid, useXml) { return this.HR_SELECTINTO(dbname, sqlstring, sqlparamarray, usesqlid, useXml); }, /** * retrieve from dbms * Modified by CWYOO at 2008.12.09 * Added useXml parameter * 0 : retrieve data by TEXT format * 1 : retrieve data by JSON format * @param dbname: pool * @param sqlstring: SQLID / SQL * @param sqlparamarray: parameter list * @param usesqlid: flag for use SQLID * @return result 0:success */ HR_SELECTINTO: function(dbname, sqlstring, sqlparamarray, usesqlid, useXml) { if(useXml==null || useXml.split(" ").join("")=="") useXml = "1"; //alert("useXml : " + useXml); this.rcnt = 0; this.result = null; this.results = null; this.errcode = null; this.errmsg = null; for (i=0,sqlparamarray_str="";i0) { firstRow = sqlparamarray[0]; if(firstRow instanceof Array) { multiRow = true; } } if(multiRow==true) { for(var idx=0; idx= 0xDC00 && c < 0xE000) continue; if (c >= 0xD800 && c < 0xDC00) { if (i >= wide.length) continue; s = wide.charCodeAt(i++); if (s < 0xDC00 || c >= 0xDE00) continue; c = ((c - 0xD800) << 10) + (s - 0xDC00) + 0x10000; } // output value if (c < 0x80) { enc += String.fromCharCode(c); } else if (c < 0x800) { enc += String.fromCharCode(0xC0 + (c >> 6), 0x80 + (c & 0x3F)); } else if (c < 0x10000) { enc += String.fromCharCode(0xE0 + (c >> 12), 0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F)); } else { enc += String.fromCharCode(0xF0 + (c >> 18), 0x80 + (c >> 12 & 0x3F), 0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F)); } } return enc; } DWREngine._hexchars = "0123456789ABCDEF"; DWREngine._toHex = function(n) { return DWREngine._hexchars.charAt(n >> 4) + DWREngine._hexchars.charAt(n & 0xF); } DWREngine._okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.!~*'()"; window.encodeURIComponent = function(s) { s = DWREngine._utf8(s); var c; var enc = ""; for (var i= 0; i