function isString(item) {return typeof item=='string' && item!=null;} //function escapeHtml($str='') {$str = !is_array($str) ? $str : json_encode($str); return htmlspecialchars((string) $str);} function escapeHtml(str) { var map = { "&": "&", "<": "<", ">": ">", "\"": """, "'": "'" }; return isString(str) ? str.replace(/[&<>"']/g, function(m) { return map[m]; }) : ''; } function unEscapeHtml(str) { var map = { "&": "&", "<": "<", ">": ">", """: "\"", "'": "'" }; return str.replace(/(&|<|>|"|')/g, function(m) { return map[m]; }); } function escapeUrl(str) { var func; func = encodeURIComponent || encodeURI || escape; return func(str); //encodeURIComponent(value).replace(/!/g,'%21').replace(/'/g,'%27').replace(/\(/g,'%28').replace(/\)/g,'%29').replace(/\*/g,'%2A').replace(/%20/g,'+'); } function unEscapeUrl(str) { var func; func = decodeURIComponent || decodeURI || unescape; return func(str); } function regexpEscape(str) { var reg, symbols; spc = ('['+'\\^$*+?.()|{}[]'.split('').join('\\'))+']'; reg = new RegExp(spc,'g'); return str.replace(reg,'\\$&'); } function render(tpl,data) //tpl = "{telo}{radek}"; data = {telo:'body',radek:'tr'}; { str = tpl; for (i in data) { reg = new RegExp(regexpEscape('{'+i+'}'),'g'); str = str.replace(reg,data[i]); } return str; } /* function htmlspecialchars(str) { var map = { "&": "&", "<": "<", ">": ">", "\"": """, "'": "'" // ' -> ' for XML only }; return str.replace(/[&<>"']/g, function(m) { return map[m]; }); } function htmlspecialchars_decode(str) { var map = { "&": "&", "<": "<", ">": ">", """: "\"", "'": "'" }; return str.replace(/(&|<|>|"|')/g, function(m) { return map[m]; }); } down vote function encode(r) { return r.replace(/[\x26\x0A\x3c\x3e\x22\x27]/g, function(r) { return "&#" + r.charCodeAt(0) + ";"; }); } */ function escapeRegexp(str) { var reg, symbols; spc = ('(['+'\\^$*+?.()|{}[]'.split('').join('\\'))+'])'; reg = new RegExp(spc,'g'); //alert(str) return str.replace(reg,'\\$1'); } function escapeRegexp(str) { var reg, symbols; spc = ('['+'\\^$*+?.()|{}[]'.split('').join('\\'))+']'; reg = new RegExp(spc,'g'); //alert(str) return str.replace(reg,'\\$1'); } function escapePath($str) {return preg_replace('~^\.+\/+()|\.+(\/)+|(\/)\/+~',"$2",$url);} // odstran ./ ../ /// function jsEscapeString($str) { $str = preg_replace('~[\']~' ,'\\$1',$str); $str = preg_replace('~[\\n]~','\\$1',$str); return $str; } function urlEscape(str) { var func; func = encodeURIComponent || encodeURI || escape; return func(str); //encodeURIComponent(value).replace(/!/g,'%21').replace(/'/g,'%27').replace(/\(/g,'%28').replace(/\)/g,'%29').replace(/\*/g,'%2A').replace(/%20/g,'+'); } ENG.func.escapeCsvValue = function(str) { var reg, spc, repl, csv; csv = ENG.csv; spc = '(['+escapeRegexp(csv.enclosure)+'])'; re = new RegExp(spc,'g'); str = str.replace(re,csv.escape+'$1'); spc = '['+escapeRegexp(csv.sep_col)+escapeRegexp(csv.sep_row)+']'; re = new RegExp(spc,'g'); str = str.search(re)!=-1 ? csv.escape + str + csv.escape : str; // ignore RFC 4180 return str; } function htmlescape($str) {return htmlspecialchars($str);} function urlescape($str) {return urlencode($str);} function escapeHtml($str) {return htmlspecialchars($str);} //function escapeUrl($str) {return urlencode($str);} function escapeUrl($str) {return rawurlencode($str);}// urlencode function unescapeUrl($str) {return urldecode($str);} function validateSqlKey($str){return preg_replace('/~[a-z_]/', '', $str);} function escapeJs($str) { $str = preg_replace('~[\']~' ,'\\$1',$str); $str = preg_replace('~[\\n]~','\\$1',$str); // $str = preg_replace('~[/]~','\\$1',$str); // resi stringy '' -> '<\/aaa>' return $str; } function jsEscapeString($str) { $str = preg_replace('~[\']~' ,'\\$1',$str); $str = preg_replace('~[\\n]~','\\$1',$str); return $str; }