jjxweb = function(hostip, port) { // jjxwebajax.js version this.version = "2.5.5"; // 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 = ""; // Added by CWYOO at 2010.09.17 // Flag for encode data // since 2.5.5 this.encode_base64 = false; // 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=" + encodeBase64(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=" + encodeBase64(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(encodeBase64(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(encodeBase64(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(encodeBase64(parm)); var parms = "kind=2&data=" + window.encodeURIComponent(encodeBase64(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(encodeBase64(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(encodeBase64(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(encodeBase64(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> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4); } return output; } // public method for decoding function decodeBase64(input) { var _keyStr = getBase64KeyString(); var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = _keyStr.indexOf(input.charAt(i++)); enc2 = _keyStr.indexOf(input.charAt(i++)); enc3 = _keyStr.indexOf(input.charAt(i++)); enc4 = _keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = _utf8_decode(output); return output; } // private method for UTF-8 encoding function _utf8_encode(string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; } // private method for UTF-8 decoding function _utf8_decode(utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } //---------------------------------------- document.onload = setReady();