Re minified JS ready for release. See PHPCRED-15
Re minified JS ready for release. See PHPCRED-15

--- a/Resources/admin.min.js
+++ b/Resources/admin.min.js
@@ -10,4 +10,4 @@
 Copyright (c) 2012 Ben Tasker
 
 */
-function checkNewGroup(){var a=document.getElementById("frmName");if(a.value.length<=0){a.className+=" frmEntryMissed";return false}return true}function checkAddCredType(){var a=document.getElementById("frmName"),b=document.getElementById("ClickDiv").className.indexOf("EntropyGenerated");if(a.value.length<=0){a.className+=" frmEntryMissed";return false}if(b>=0){return true}alert("You must generate Entropy");return false}function validateUserAdd(){var a=0,c=document.getElementById("frmUsername"),b=document.getElementById("frmRName");if(c.value.length<=0){c.className="frmEntryMissed";a=1}if(b.value.length<=0){b.className="frmEntryMissed";a=1}if(!comparePwds()){a=1}if(a==1){alert("Please correct input errors and re-submit");return false}return true}function validateUserEdit(){var d=document.getElementById("frmUsername"),b=document.getElementById("frmRName"),c=document.getElementById("frmPass"),a=0;if(d.value.length<=0){d.className="frmEntryMissed";a=1}if(b.value.length<=0){b.className="frmEntryMissed";a=1}if(c.value.length>0){if(!comparePwds()){a=1}}if(a==1){alert("Please correct input errors and re-submit");return false}return true}function delGroup(h){var c,e,g,d,b=retKey(),f=document.getElementById("GroupDisp"+h),a=document.getElementById("NotificationArea");if(!confirm("Are you sure you want to delete this group (any credentials recorded against the group will be deleted)?")){return false}if(window.XMLHttpRequest){c=new XMLHttpRequest()}else{c=new ActiveXObject("Microsoft.XMLHTTP")}c.onreadystatechange=function(){if(c.readyState==4&&c.status==200){e=decryptAPIResp(c.responseText,b).split(getDivider());if(e[1]==2){return unknownAPICommand()}if(e[1]==0||e[2]==0){a.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}f.parentNode.removeChild(f);a.innerHTML+='<div class="alert alert-success">Group Deleted</div>'}};d=cryptReq("delGroup",b);c.open("POST","api.php",true);c.setRequestHeader("Content-type","application/x-www-form-urlencoded");c.send("option="+d+"&id="+h)}function delUser(h){var c,e,g,d,b=retKey(),f=document.getElementById("User"+h),a=document.getElementById("NotificationArea");if(!confirm("Are you sure you want to delete this user?")){return false}if(window.XMLHttpRequest){c=new XMLHttpRequest()}else{c=new ActiveXObject("Microsoft.XMLHTTP")}c.onreadystatechange=function(){if(c.readyState==4&&c.status==200){e=decryptAPIResp(c.responseText,b).split(getDivider());if(e[1]==2){return unknownAPICommand()}if(e[1]==0||e[2]==0){a.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}f.parentNode.removeChild(f);a.innerHTML+='<div class="alert alert-success">User Deleted</div>'}};d=cryptReq("delUser",b);c.open("POST","api.php",true);c.setRequestHeader("Content-type","application/x-www-form-urlencoded");c.send("option="+d+"&id="+h)}function delCredType(h){var c,e,g,d,b=retKey(),f=document.getElementById("CredType"+h),a=document.getElementById("NotificationArea");if(!confirm("Are you sure you want to delete this Credential Type (any associated credentials will be deleted)?")){return false}if(window.XMLHttpRequest){c=new XMLHttpRequest()}else{c=new ActiveXObject("Microsoft.XMLHTTP")}c.onreadystatechange=function(){if(c.readyState==4&&c.status==200){e=decryptAPIResp(c.responseText,b).split(getDivider());if(e[1]==2){return unknownAPICommand()}if(e[1]==0||e[2]==0){a.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}f.parentNode.removeChild(f);a.innerHTML+='<div class="alert alert-success">Credential Type Deleted</div>'}};d=cryptReq("delCredType",b);c.open("POST","api.php",true);c.setRequestHeader("Content-type","application/x-www-form-urlencoded");c.send("option="+d+"&id="+h)};
+function checkNewGroup(){var e=document.getElementById("frmName");if(e.value.length<=0){e.className+=" frmEntryMissed";return false}return true}function checkAddCredType(){var e=document.getElementById("frmName"),t=document.getElementById("ClickDiv").className.indexOf("EntropyGenerated");if(e.value.length<=0){e.className+=" frmEntryMissed";return false}if(t>=0){return true}alert("You must generate Entropy");return false}function validateUserAdd(){var e=0,t=document.getElementById("frmUsername"),n=document.getElementById("frmRName");if(t.value.length<=0){t.className="frmEntryMissed";e=1}if(n.value.length<=0){n.className="frmEntryMissed";e=1}if(!comparePwds()){e=1}if(e==1){alert("Please correct input errors and re-submit");return false}return true}function validateUserEdit(){var e=document.getElementById("frmUsername"),t=document.getElementById("frmRName"),n=document.getElementById("frmPass"),r=0;if(e.value.length<=0){e.className="frmEntryMissed";r=1}if(t.value.length<=0){t.className="frmEntryMissed";r=1}if(n.value.length>0){if(!comparePwds()){r=1}}if(r==1){alert("Please correct input errors and re-submit");return false}return true}function delGroup(e){var t,n,r,i,s=retKey(),o=document.getElementById("GroupDisp"+e),u=document.getElementById("NotificationArea");if(!confirm("Are you sure you want to delete this group (any credentials recorded against the group will be deleted)?")){return false}if(window.XMLHttpRequest){t=new XMLHttpRequest}else{t=new ActiveXObject("Microsoft.XMLHTTP")}t.onreadystatechange=function(){if(t.readyState==4&&t.status==200){n=decryptAPIResp(t.responseText,s).split(getDivider());if(n[1]==2){return unknownAPICommand()}if(n[1]==0||n[2]==0){u.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}o.parentNode.removeChild(o);u.innerHTML+='<div class="alert alert-success">Group Deleted</div>'}};i=cryptReq("delGroup",s);t.open("POST","api.php",true);t.setRequestHeader("Content-type","application/x-www-form-urlencoded");t.send("option="+i+"&id="+e)}function delUser(e){var t,n,r,i,s=retKey(),o=document.getElementById("User"+e),u=document.getElementById("NotificationArea");if(!confirm("Are you sure you want to delete this user?")){return false}if(window.XMLHttpRequest){t=new XMLHttpRequest}else{t=new ActiveXObject("Microsoft.XMLHTTP")}t.onreadystatechange=function(){if(t.readyState==4&&t.status==200){n=decryptAPIResp(t.responseText,s).split(getDivider());if(n[1]==2){return unknownAPICommand()}if(n[1]==0||n[2]==0){u.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}o.parentNode.removeChild(o);u.innerHTML+='<div class="alert alert-success">User Deleted</div>'}};i=cryptReq("delUser",s);t.open("POST","api.php",true);t.setRequestHeader("Content-type","application/x-www-form-urlencoded");t.send("option="+i+"&id="+e)}function delCredType(e){var t,n,r,i,s=retKey(),o=document.getElementById("CredType"+e),u=document.getElementById("NotificationArea");if(!confirm("Are you sure you want to delete this Credential Type (any associated credentials will be deleted)?")){return false}if(window.XMLHttpRequest){t=new XMLHttpRequest}else{t=new ActiveXObject("Microsoft.XMLHTTP")}t.onreadystatechange=function(){if(t.readyState==4&&t.status==200){n=decryptAPIResp(t.responseText,s).split(getDivider());if(n[1]==2){return unknownAPICommand()}if(n[1]==0||n[2]==0){u.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}o.parentNode.removeChild(o);u.innerHTML+='<div class="alert alert-success">Credential Type Deleted</div>'}};i=cryptReq("delCredType",s);t.open("POST","api.php",true);t.setRequestHeader("Content-type","application/x-www-form-urlencoded");t.send("option="+i+"&id="+e)}

--- a/Resources/main.min.js
+++ b/Resources/main.min.js
@@ -10,4 +10,4 @@
 Copyright (c) 2012 Ben Tasker
 
 */
-var counter=false,cancel="",dispcred,interval;function genPwd(c,b){var e,f="",d="(=?)+.,abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";for(e=0;e<b;e++){f+=d.charAt(Math.floor(Math.random()*d.length))}if(c=="r"){return f}document.getElementById(c).value=f}function resizebkgrnd(){var width=document.documentElement.clientHeight,height=width,img;img=document.getElementById("ContentWrap");img.style.minHeight=eval(height*0.8)+"px"}function CreateMenuContent(b,i,f,j,e,k){var g,d,m,h,c=0,b=document.getElementById(b),l=document.getElementById(f);if(!l){return false}for(var a=0;a<l.rows.length;a++){if(c==e){break}d=l.rows[a].cells[3].innerHTML;if(d==i){m=document.createElement("li");m.id=k+l.rows[a].cells[2].innerHTML;m.innerHTML="<a href='index.php?option="+l.rows[a].cells[5].innerHTML+"&id="+l.rows[a].cells[2].innerHTML+"'>"+l.rows[a].cells[j].innerHTML+"</a>";b.appendChild(m);c=c+1}}}function Credtimer(d){var b,a=document.getElementById("PassCount"+d),c=document.getElementById("retrievePassword"+d);b=a.value-1;a.value=b;if(b<=0||cancel==1){clearInterval(counter);c.innerHTML='Display<span class="DisPwdText"> Password</span>';document.getElementById("Address"+d).innerHTML="";document.getElementById("UserName"+d).innerHTML="";document.getElementById("Password"+d).innerHTML="";document.getElementById("CredPluginOutput"+d).innerHTML="";document.getElementById("clickCount"+d).value=0;return}c.innerHTML="Displaying Password for "+b+" seconds"}function noCredTypes(){$(document).ready(function(){var a;if(document.getElementById("AddCredBtnTop")){a=document.getElementById("AddCredBtnTop");a.parentNode.removeChild(a)}if(document.getElementById("AddCredBtnBottom")){a=document.getElementById("AddCredBtnBottom");a.parentNode.removeChild(a)}})}function loginReqProcess(){var c,b="",e=document.getElementById("FrmPassPlace"),d=document.getElementById("FrmPass");if(!enabledEncryption()){d.value=e.value;return true}d.value=Base64.encode(xorestr(e.value,retAuthKey()));for(c=0;c<e.length;c++){b+="a"}e.value=b;return true}function checkNewCust(){var d=document.getElementById("FrmName"),b=document.getElementById("frmGroup"),c=document.getElementById("FrmEmail");if(c.value.indexOf("@")==-1){c.className+=" frmEntryMissed";return false}if(b.options[b.selectedIndex].value=="null"){b.className+=" frmEntryMissed";return false}if(d.value==""){d.className+=" frmEntryMissed";return false}if(enabledEncryption()){var e=document.getElementById("FrmconName"),a=document.getElementById("FrmSurname");d.value=Base64.encode(xorestr(d.value,retKey()));c.value=Base64.encode(xorestr(c.value,retKey()));e.value=Base64.encode(xorestr(e.value,retKey()));a.value=Base64.encode(xorestr(a.value,retKey()))}return true}function checkNewCred(){var c=document.getElementById("frmCredential"),b=document.getElementById("frmUser"),d=document.getElementById("frmAddress"),a=document.getElementById("frmGroup");if(a.options[a.selectedIndex].value=="null"){a.className+=" frmEntryMissed";return false}if(c.value.indexOf("http")!==-1){if(confirm("Click OK to make this credential a hyperlink in the database, click cancel to set not clicky")){document.getElementById("frmClicky").value=1}}if(enabledEncryption()){c.value=Base64.encode(xorestr(c.value,retKey()));b.value=Base64.encode(xorestr(b.value,retKey()));d.value=Base64.encode(xorestr(d.value,retKey()))}return true}function checkEditCred(){var c=document.getElementById("frmCredential"),b=document.getElementById("frmUser"),d=document.getElementById("frmAddress"),a=document.getElementById("frmGroup");if(a.options[a.selectedIndex].value=="null"){a.className+=" frmEntryMissed";return false}if(c.value.indexOf("http")!==-1){if(confirm("Click OK to make this credential a hyperlink in the database, click cancel to set not clicky")){document.getElementById("frmClicky").value=1}}if(c.value==null||c.value==""){c.value=" "}if(b.value==null||b.value==""){b.value=" "}if(d.value==null||d.value==""){d.value=" "}if(enabledEncryption()){c.value=Base64.encode(xorestr(c.value,retKey()));b.value=Base64.encode(xorestr(b.value,retKey()));d.value=Base64.encode(xorestr(d.value,retKey()))}return true}function checkChngPwds(){if(!comparePwds()){return false}if(!enabledEncryption()){return true}var a=document.getElementById("frmPass"),b=document.getElementById("frmPassConf");a.value=Base64.encode(xorestr(a.value,retKey()));b.value=Base64.encode(xorestr(b.value,retKey()));return true}function comparePwds(){var f,g,d,c=document.getElementById("frmPass"),b=document.getElementById("PassNoMatch"),e=document.getElementById("passScore"),a=document.getElementById("minpassStrength");if(a){f=a.value;if(f.indexOf("+")>=0){if(parseInt(passScore.value)>45){g=true}else{g=false}}else{d=f.split("-");if((parseInt(passScore.value)>d[0])){g=true}else{g=false}}if(!g){b.innerHTML="Password is too weak";b.style.display="inline-block";return false}}if(c.value!=document.getElementById("frmPassConf").value){b.innerHTML="Passwords don't match";b.style.display="inline-block";return false}if(c.value==null||c.value==""){document.getElementById("PassNoMatch").innerHTML="You must set a password";b.style.display="inline-block";return false}b.style.display="none";return true}function getCreds(a){var b,e,f,d,i,g,k=document.getElementById("retrievePassword"+a),h=document.getElementById("Address"+a),l=document.getElementById("UserName"+a),c=document.getElementById("Password"+a),n=document.getElementById("CredPluginOutput"+a),m=retKey(),j=document.getElementById("clickCount"+a);if(j.value!=0){return}j.value=1;k.innerHTML="<i>Retrieving.....</i>";if(window.XMLHttpRequest){b=new XMLHttpRequest()}else{b=new ActiveXObject("Microsoft.XMLHTTP")}b.onreadystatechange=function(){if(b.readyState==4&&b.status==200){e=decryptAPIResp(b.responseText,m).split(getDivider());if(e[1]==2){return unknownAPICommand()}if(e[1]==0){k.innerHTML="Failed to retrieve credentials. Click to try again";return false}f=document.getElementById("defaultInterval").value;d=document.getElementById("PassCount"+a);d.value=f;i=f;h.innerHTML=e[3];c.innerHTML=e[2];l.innerHTML=e[4];n.innerHTML=e[5];k.innerHTML="Displaying Password for "+i+" seconds";if(counter){cancel=1;document.getElementById("clickCount"+dispcred).value=0;dispcred=a;setTimeout(function(){cancel=false;counter=setInterval("Credtimer('"+a+"')",1000)},1000);return}dispcred=a;counter=setInterval("Credtimer('"+a+"')",1000)}};g=cryptReq("retCred");b.open("POST","api.php",true);b.setRequestHeader("Content-type","application/x-www-form-urlencoded");b.send("option="+g+"&id="+a)}function checkSession(){var b,e,d,c,a=retKey();if(window.XMLHttpRequest){b=new XMLHttpRequest()}else{b=new ActiveXObject("Microsoft.XMLHTTP")}b.onreadystatechange=function(){if(b.readyState==4&&b.status==200){e=b.responseText.split(getDivider());if(e[1]==2){return unknownAPICommand()}if(e[1]==0){removeCurrKey(0);d=document.cookie.split(";");for(var f=0;f<d.length;f++){KillCookie(d[f].split("=")[0])}window.location.href="index.php?notif=InvalidSession";return false}}};c=cryptReq("checkSess");b.open("POST","api.php",true);b.setRequestHeader("Content-type","application/x-www-form-urlencoded");b.send("option="+c+"&id="+Math.floor((Math.random()*100)+1))}function DelCust(h){var c,f,g,b,d,a=retKey();if(!confirm("Are you sure you want to delete this customer and all associated credentials?")){return false}g=document.getElementById("CustDisp"+h);b=document.getElementById("NotificationArea");if(document.getElementById("Custmenu"+h)){var e=document.getElementById("Custmenu"+h)}if(window.XMLHttpRequest){c=new XMLHttpRequest()}else{c=new ActiveXObject("Microsoft.XMLHTTP")}c.onreadystatechange=function(){if(c.readyState==4&&c.status==200){f=decryptAPIResp(c.responseText,a).split(getDivider());if(f[1]==2){return unknownAPICommand()}if(f[1]==0||f[2]==0){b.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}g.parentNode.removeChild(g);b.innerHTML+='<div class="alert alert-success">Customer and all associated credentials Deleted</div>';if(e){e.parentNode.removeChild(e)}}};d=cryptReq("delCust");c.open("POST","api.php",true);c.setRequestHeader("Content-type","application/x-www-form-urlencoded");c.send("option="+d+"&id="+h)}function DelCred(g){var c,e,f,b,d,a=retKey();if(!confirm("Are you sure you want to delete this credential?")){return false}f=document.getElementById("CredDisp"+g);b=document.getElementById("NotificationArea");if(window.XMLHttpRequest){c=new XMLHttpRequest()}else{c=new ActiveXObject("Microsoft.XMLHTTP")}c.onreadystatechange=function(){if(c.readyState==4&&c.status==200){e=decryptAPIResp(c.responseText,a).split(getDivider());if(e[1]==2){return unknownAPICommand()}if(e[1]==0||e[2]==0){b.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}f.parentNode.removeChild(f);b.innerHTML+='<div class="alert alert-success">Credential Deleted</div>'}};d=cryptReq("delCred");c.open("POST","api.php",true);c.setRequestHeader("Content-type","application/x-www-form-urlencoded");c.send("option="+d+"&id="+g)}function positionResults(SearchBox,ResBox){var search=document.getElementById(SearchBox),res=document.getElementById(ResBox);res.style.left=search.offsetLeft+"px";res.style.top=eval(search.offsetTop+search.offsetHeight+6)+"px";res.style.width=search.offsetWidth+"px"}function SearchTable(c,f,d,k,i){var l,g,o,j,h=0,b,p,n,a,m=0;if(window.event){m=window.event.keyCode}else{if(i.which){m=i.which}}if(m===38){selectResult("up");return}if(m===40){selectResult("down");return}l=document.getElementById(d);l.innerHTML="";if(c.length<3){return}document.getElementById("SelectedValue").value=0;positionResults("SearchBox",d);g=c.toLowerCase();o=document.getElementById(f);for(a=0;a<o.rows.length;a++){p=o.rows[a].cells[k].innerHTML.replace(/<[^>]+>/g,"");if((p.toLowerCase().indexOf(g)>=0)||((g.indexOf(":")>=0)&&(o.rows[a].cells[1].innerHTML.toLowerCase().indexOf(g)>=0))){h=h+1;j=document.createElement("div");j.id="SearchResult"+h;j.className="SearchResult";j.setAttribute("link",o.rows[a].cells[5].innerHTML);j.setAttribute("entID",o.rows[a].cells[2].innerHTML);if(o.rows[a].cells[4].innerHTML!=null&&o.rows[a].cells[4].innerHTML!=""){b=o.rows[a].cells[4].innerHTML}else{b="id"}if(o.rows[a].cells[6]){n=o.rows[a].cells[6].innerHTML.split("=");j.setAttribute("entid2",n[0]);j.setAttribute("entid2val",n[1]);n="&"+o.rows[a].cells[6].innerHTML}else{n=""}j.setAttribute("onclick","window.location.href = 'index.php?option="+o.rows[a].cells[5].innerHTML+"&"+b+"="+o.rows[a].cells[2].innerHTML+n+"';");j.setAttribute("frmName",b);j.innerHTML=o.rows[a].cells[1].innerHTML+" "+o.rows[a].cells[k].innerHTML;l.appendChild(j);l.style.display="block"}}}function selectResult(dir){var ind,SearchResult,SelIndex=document.getElementById("SelectedValue"),SearchLength=document.getElementById("SearchResBox").childNodes.length;if(dir=="down"){if(SelIndex.value!=0){document.getElementById("SearchResult"+parseInt(SelIndex.value)).className="SearchResult"}if(SearchLength==SelIndex.value){SelIndex.value=0}ind=eval(parseInt(SelIndex.value)+1)}else{document.getElementById("SearchResult"+parseInt(SelIndex.value)).className="SearchResult";if(SelIndex.value==1){ind=SearchLength}else{ind=eval(parseInt(SelIndex.value)-1)}}SearchResult=document.getElementById("SearchResult"+ind);SearchResult.className="SearchResult SearchResultActive";SelIndex.value=ind;document.getElementById("SrchOpt").value=SearchResult.getAttribute("link");document.getElementById("SrchID").name=SearchResult.getAttribute("frmName");document.getElementById("SrchID").value=SearchResult.getAttribute("entID");document.getElementById("SrchID2").name=SearchResult.getAttribute("entid2");document.getElementById("SrchID2").value=SearchResult.getAttribute("entid2val");document.getElementById("SearchBox").focus()}function hideSearchDiv(a){var b=document.getElementById(a);for(opacity=10;opacity>0;opacity--){b.style.opacity="0."+opacity}b.style.display="none";b.style.opacity="1"}function checkExistingSearch(a,b){if(a.length>3){document.getElementById(b).style.display="block"}}function setUpMenus(){jQuery(document).ready(function(){if(!document.getElementById("SearchListing")){return}var b,a;CreateMenuContent("TypeDropDownMenu",2,"SearchListing",0,100,"TypeMenu");CreateMenuContent("CustDropDownMenu",1,"SearchListing",0,5,"Custmenu");b=document.getElementById("CustDropDownMenu");a=document.createElement("li");a.className="divider";b.appendChild(a);a=document.createElement("li");a.className="viewAll";a.innerHTML="<a href='index.php?option=viewCustomers'>View All</a></li>";b.appendChild(a)})}function xorestr(j,g){if(!enabledEncryption()){return j}var d,c,e="",h=0;for(var f=0;f<j.length;f++){d=j.charCodeAt(f);c=d^g.charCodeAt(h);e+=c.toString()+" ";h++;if(h>=g.length){h=0}}return e}function xordstr(j,g){if(!enabledEncryption()){return j}var d,c,e="",h=0,j=j.split(" ");for(var f=0;f<j.length;f++){if(j[f].length==0){continue}d=j[f];c=d^g.charCodeAt(h);e+=String.fromCharCode(c);h++;if(h>=g.length){h=0}}return e}function unknownAPICommand(){var a=document.getElementById("NotificationArea");clearInterval(sesscheck);a.innerHTML+="<div id='apiError' class='alert alert-error'>API Error Detected</div>";if(!enabledEncryption()){return}if(!confirm("The API reported an error, attempting to rectify. Click OK to try and rectify")){return}a.removeChild(document.getElementById("apiError"));a.innerHTML="<div id='apiError' class='alert alert-info'>Attempting to rectify API issue. Window will refresh when ready</div>";destroyKeys();removeCurrKey(1)}function removeCurrKey(e){var d,a=document.getElementById("kFile"),c=a.getAttribute("src"),b=a.parentNode;b.removeChild(a);d=document.createElement("iframe");d.setAttribute("id","kfile");d.setAttribute("src",c+"&forceload=y");d.style.width="0px";d.style.height="0px";d.style.border="0px";document.body.appendChild(d);interval=setInterval("reloadKeyf('"+c+"',"+e+")",500)}function reloadKeyf(c,e){var d,a,b;clearInterval(interval);d=document.getElementById("kfile");d.contentWindow.document.cookie="PHPCredLockerKeySet=0;";d.parentNode.removeChild(d);a=new Date();d=document.createElement("script");d.setAttribute("id","kFile");d.setAttribute("src",c+"&forceload=y&rand="+a.getTime());document.getElementsByTagName("head")[0].appendChild(d);if(window.getKey!=""&&e==1){b=document.getElementById("apiError");b.parentNode.removeChild(b);sesscheck=setInterval("checkSession()",120000)}}function decryptAPIResp(b,a){if(!enabledEncryption()){return b}return Base64.decode(xordstr(Base64.decode(b),a))}function getDivider(){return getDelimiter()}function getTerms(b){return Base64.decode(getTerminology(b))}function cryptReq(c){var a,b=retKey(),d=getDivider();a=genPadding()+d+getTerms(c)+d+genPadding();if(!enabledEncryption()){return a}return encodeURIComponent(Base64.encode(xorestr(Base64.encode(a),b)))}function genPadding(){if(!enabledEncryption()){return"a"}var d,e,b="";e=Math.random().toString(10).substring(2,3);for(d=0;d<e;d++){b+=Math.random().toString(10).substring(Math.random().toString(10).substring(2,3))}return b}function retAuthKey(){return Base64.decode(getAuthKey())}function retKey(){return Base64.decode(getKey())}function checkKeyAvailable(){if(typeof getKey!="function"){if(confirm("Key retrieval failed - Attempting to rectify, Click OK to continue - Screen may refresh")){var a,b=document.cookie.split(";");for(a=0;a<b.length;a++){KillCookie(b[a].split("=")[0])}removeCurrKey();if(typeof getKey=="function"){alert("Keys retrieved successfully");return true}window.location.reload(true);return false}}return true}function KillCookie(a){createCookie(a,"",-1)}function createCookie(d,e,b){var a,c;if(b){c=new Date();c.setTime(c.getTime()+(b*24*60*60*1000));a="; expires="+c.toGMTString()}else{a=""}document.cookie=d+"="+e+a+"; path=/"};
+function genPwd(e,t){var n,r="",i="(=?)+.,abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";for(n=0;n<t;n++){r+=i.charAt(Math.floor(Math.random()*i.length))}if(e=="r"){return r}document.getElementById(e).value=r}function resizebkgrnd(){var width=document.documentElement.clientHeight,height=width,img;img=document.getElementById("ContentWrap");img.style.minHeight=eval(height*.8)+"px"}function CreateMenuContent(e,t,n,r,i,s){var o,u,a,f,l=0,e=document.getElementById(e),c=document.getElementById(n);if(!c){return false}for(var h=0;h<c.rows.length;h++){if(l==i){break}u=c.rows[h].cells[3].innerHTML;if(u==t){a=document.createElement("li");a.id=s+c.rows[h].cells[2].innerHTML;a.innerHTML="<a href='index.php?option="+c.rows[h].cells[5].innerHTML+"&id="+c.rows[h].cells[2].innerHTML+"'>"+c.rows[h].cells[r].innerHTML+"</a>";e.appendChild(a);l=l+1}}}function Credtimer(e){var t,n=document.getElementById("PassCount"+e),r=document.getElementById("retrievePassword"+e);t=n.value-1;n.value=t;if(t<=0||cancel==1){clearInterval(counter);if(document.getElementById("credHidden"+e)){r.innerHTML='Display<span class="DisPwdText"> Username</span>'}else{r.innerHTML='Display<span class="DisPwdText"> Password</span>'}document.getElementById("Address"+e).innerHTML="";document.getElementById("UserName"+e).innerHTML="";document.getElementById("Password"+e).innerHTML="";document.getElementById("CredPluginOutput"+e).innerHTML="";document.getElementById("clickCount"+e).value=0;return}r.innerHTML="Displaying for "+t+" seconds"}function noCredTypes(){$(document).ready(function(){var e;if(document.getElementById("AddCredBtnTop")){e=document.getElementById("AddCredBtnTop");e.parentNode.removeChild(e)}if(document.getElementById("AddCredBtnBottom")){e=document.getElementById("AddCredBtnBottom");e.parentNode.removeChild(e)}})}function loginReqProcess(){var e,t="",n=document.getElementById("FrmPassPlace"),r=document.getElementById("FrmPass");if(!enabledEncryption()){r.value=n.value;return true}r.value=Base64.encode(xorestr(n.value,retAuthKey()));for(e=0;e<n.length;e++){t+="a"}n.value=t;return true}function checkNewCust(){var e=document.getElementById("FrmName"),t=document.getElementById("frmGroup"),n=document.getElementById("FrmEmail");if(n.value.indexOf("@")==-1){n.className+=" frmEntryMissed";return false}if(t.options[t.selectedIndex].value=="null"){t.className+=" frmEntryMissed";return false}if(e.value==""){e.className+=" frmEntryMissed";return false}if(enabledEncryption()){var r=document.getElementById("FrmconName"),i=document.getElementById("FrmSurname");e.value=Base64.encode(xorestr(e.value,retKey()));n.value=Base64.encode(xorestr(n.value,retKey()));r.value=Base64.encode(xorestr(r.value,retKey()));i.value=Base64.encode(xorestr(i.value,retKey()))}return true}function checkNewCred(){var e=document.getElementById("frmCredential"),t=document.getElementById("frmUser"),n=document.getElementById("frmAddress"),r=document.getElementById("frmGroup"),i=document.getElementById("frmComment");if(r.options[r.selectedIndex].value=="null"){r.className+=" frmEntryMissed";return false}if(e.value.indexOf("http")!==-1){if(confirm("Click OK to make this credential a hyperlink in the database, click cancel to set not clicky")){document.getElementById("frmClicky").value=1}}if(enabledEncryption()){e.value=Base64.encode(xorestr(e.value,retKey()));t.value=Base64.encode(xorestr(t.value,retKey()));n.value=Base64.encode(xorestr(n.value,retKey()));i.value=Base64.encode(xorestr(i.value,retKey()))}return true}function checkEditCred(){var e=document.getElementById("frmCredential"),t=document.getElementById("frmUser"),n=document.getElementById("frmAddress"),r=document.getElementById("frmGroup"),i=document.getElementById("frmComment");if(r.options[r.selectedIndex].value=="null"){r.className+=" frmEntryMissed";return false}if(e.value.indexOf("http")!==-1){if(confirm("Click OK to make this credential a hyperlink in the database, click cancel to set not clicky")){document.getElementById("frmClicky").value=1}}if(e.value==null||e.value==""){e.value=" "}if(i.value==null||i.value==""){i.value=" "}if(t.value==null||t.value==""){t.value=" "}if(n.value==null||n.value==""){n.value=" "}if(enabledEncryption()){e.value=Base64.encode(xorestr(e.value,retKey()));t.value=Base64.encode(xorestr(t.value,retKey()));n.value=Base64.encode(xorestr(n.value,retKey()));i.value=Base64.encode(xorestr(i.value,retKey()))}return true}function checkChngPwds(){if(!comparePwds()){return false}if(!enabledEncryption()){return true}var e=document.getElementById("frmPass"),t=document.getElementById("frmPassConf");e.value=Base64.encode(xorestr(e.value,retKey()));t.value=Base64.encode(xorestr(t.value,retKey()));return true}function comparePwds(){var e,t,n,r=document.getElementById("frmPass"),i=document.getElementById("PassNoMatch"),s=document.getElementById("passScore"),o=document.getElementById("minpassStrength");if(o){e=o.value;if(e.indexOf("+")>=0){if(parseInt(passScore.value)>45){t=true}else{t=false}}else{n=e.split("-");if(parseInt(passScore.value)>n[0]){t=true}else{t=false}}if(!t){i.innerHTML="Password is too weak";i.style.display="inline-block";return false}}if(r.value!=document.getElementById("frmPassConf").value){i.innerHTML="Passwords don't match";i.style.display="inline-block";return false}if(r.value==null||r.value==""){document.getElementById("PassNoMatch").innerHTML="You must set a password";i.style.display="inline-block";return false}i.style.display="none";return true}function getCreds(e){var t,n,r,i,s,o,u=document.getElementById("retrievePassword"+e),a=document.getElementById("Address"+e),f=document.getElementById("UserName"+e),l=document.getElementById("Password"+e),c=document.getElementById("CredPluginOutput"+e),h=retKey(),p=document.getElementById("clickCount"+e);if(p.value!=0){return}p.value=1;u.innerHTML="<i>Retrieving.....</i>";if(window.XMLHttpRequest){t=new XMLHttpRequest}else{t=new ActiveXObject("Microsoft.XMLHTTP")}t.onreadystatechange=function(){if(t.readyState==4&&t.status==200){n=decryptAPIResp(t.responseText,h).split(getDivider());if(n[1]==2){return unknownAPICommand()}if(n[1]==0){u.innerHTML="Failed to retrieve credentials. Click to try again";return false}r=document.getElementById("defaultInterval").value;i=document.getElementById("PassCount"+e);i.value=r;s=r;a.innerHTML=n[3];l.innerHTML='<input class="passDisp" onclick="this.select();" type="text" value="'+n[2]+'" title="Click to select" name="null"/>';f.innerHTML=n[4];c.innerHTML=n[5];u.innerHTML="Displaying Password for "+s+" seconds";if(counter){cancel=1;document.getElementById("clickCount"+dispcred).value=0;dispcred=e;setTimeout(function(){cancel=false;counter=setInterval("Credtimer('"+e+"')",1e3)},1e3);return}dispcred=e;counter=setInterval("Credtimer('"+e+"')",1e3)}};o=cryptReq("retCred");t.open("POST","api.php",true);t.setRequestHeader("Content-type","application/x-www-form-urlencoded");t.send("option="+o+"&id="+e)}function checkSession(){var e,t,n,r,i=retKey();if(window.XMLHttpRequest){e=new XMLHttpRequest}else{e=new ActiveXObject("Microsoft.XMLHTTP")}e.onreadystatechange=function(){if(e.readyState==4&&e.status==200){t=e.responseText.split(getDivider());if(t[1]==2){return unknownAPICommand()}if(t[1]==0){removeCurrKey(0);n=document.cookie.split(";");for(var r=0;r<n.length;r++){KillCookie(n[r].split("=")[0])}window.location.href="index.php?notif=InvalidSession";return false}}};r=cryptReq("checkSess");e.open("POST","api.php",true);e.setRequestHeader("Content-type","application/x-www-form-urlencoded");e.send("option="+r+"&id="+Math.floor(Math.random()*100+1))}function DelCust(e){var t,n,r,i,s,o=retKey();if(!confirm("Are you sure you want to delete this customer and all associated credentials?")){return false}r=document.getElementById("CustDisp"+e);i=document.getElementById("NotificationArea");if(document.getElementById("Custmenu"+e)){var u=document.getElementById("Custmenu"+e)}if(window.XMLHttpRequest){t=new XMLHttpRequest}else{t=new ActiveXObject("Microsoft.XMLHTTP")}t.onreadystatechange=function(){if(t.readyState==4&&t.status==200){n=decryptAPIResp(t.responseText,o).split(getDivider());if(n[1]==2){return unknownAPICommand()}if(n[1]==0||n[2]==0){i.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}r.parentNode.removeChild(r);i.innerHTML+='<div class="alert alert-success">Customer and all associated credentials Deleted</div>';if(u){u.parentNode.removeChild(u)}}};s=cryptReq("delCust");t.open("POST","api.php",true);t.setRequestHeader("Content-type","application/x-www-form-urlencoded");t.send("option="+s+"&id="+e)}function DelCred(e){var t,n,r,i,s,o=retKey();if(!confirm("Are you sure you want to delete this credential?")){return false}r=document.getElementById("CredDisp"+e);i=document.getElementById("NotificationArea");if(window.XMLHttpRequest){t=new XMLHttpRequest}else{t=new ActiveXObject("Microsoft.XMLHTTP")}t.onreadystatechange=function(){if(t.readyState==4&&t.status==200){n=decryptAPIResp(t.responseText,o).split(getDivider());if(n[1]==2){return unknownAPICommand()}if(n[1]==0||n[2]==0){i.innerHTML+='<div class="alert alert-error">Failed to Delete</div>';return false}r.parentNode.removeChild(r);i.innerHTML+='<div class="alert alert-success">Credential Deleted</div>'}};s=cryptReq("delCred");t.open("POST","api.php",true);t.setRequestHeader("Content-type","application/x-www-form-urlencoded");t.send("option="+s+"&id="+e)}function positionResults(SearchBox,ResBox){var search=document.getElementById(SearchBox),res=document.getElementById(ResBox);res.style.left=search.offsetLeft+"px";res.style.top=eval(search.offsetTop+search.offsetHeight+6)+"px";res.style.width=search.offsetWidth+"px"}function SearchTable(e,t,n,r,i){var s,o,u,a,f=0,l,c,h,p,d=0;if(window.event){d=window.event.keyCode}else if(i.which){d=i.which}if(d===38){selectResult("up");return}if(d===40){selectResult("down");return}s=document.getElementById(n);s.innerHTML="";if(e.length<3){return}document.getElementById("SelectedValue").value=0;positionResults("SearchBox",n);o=e.toLowerCase();u=document.getElementById(t);for(p=0;p<u.rows.length;p++){c=u.rows[p].cells[r].innerHTML.replace(/<[^>]+>/g,"");if(c.toLowerCase().indexOf(o)>=0||o.indexOf(":")>=0&&u.rows[p].cells[1].innerHTML.toLowerCase().indexOf(o)>=0){f=f+1;a=document.createElement("div");a.id="SearchResult"+f;a.className="SearchResult";a.setAttribute("link",u.rows[p].cells[5].innerHTML);a.setAttribute("entID",u.rows[p].cells[2].innerHTML);if(u.rows[p].cells[4].innerHTML!=null&&u.rows[p].cells[4].innerHTML!=""){l=u.rows[p].cells[4].innerHTML}else{l="id"}if(u.rows[p].cells[6]){h=u.rows[p].cells[6].innerHTML.split("=");a.setAttribute("entid2",h[0]);a.setAttribute("entid2val",h[1]);h="&"+u.rows[p].cells[6].innerHTML}else{h=""}a.setAttribute("onclick","window.location.href = 'index.php?option="+u.rows[p].cells[5].innerHTML+"&"+l+"="+u.rows[p].cells[2].innerHTML+h+"';");a.setAttribute("frmName",l);a.innerHTML=u.rows[p].cells[1].innerHTML+" "+u.rows[p].cells[r].innerHTML;s.appendChild(a);s.style.display="block"}}}function selectResult(dir){var ind,SearchResult,SelIndex=document.getElementById("SelectedValue"),SearchLength=document.getElementById("SearchResBox").childNodes.length;if(dir=="down"){if(SelIndex.value!=0){document.getElementById("SearchResult"+parseInt(SelIndex.value)).className="SearchResult"}if(SearchLength==SelIndex.value){SelIndex.value=0}ind=eval(parseInt(SelIndex.value)+1)}else{document.getElementById("SearchResult"+parseInt(SelIndex.value)).className="SearchResult";if(SelIndex.value==1){ind=SearchLength}else{ind=eval(parseInt(SelIndex.value)-1)}}SearchResult=document.getElementById("SearchResult"+ind);SearchResult.className="SearchResult SearchResultActive";SelIndex.value=ind;document.getElementById("SrchOpt").value=SearchResult.getAttribute("link");document.getElementById("SrchID").name=SearchResult.getAttribute("frmName");document.getElementById("SrchID").value=SearchResult.getAttribute("entID");document.getElementById("SrchID2").name=SearchResult.getAttribute("entid2");document.getElementById("SrchID2").value=SearchResult.getAttribute("entid2val");document.getElementById("SearchBox").focus()}function hideSearchDiv(e){var t=document.getElementById(e);for(opacity=10;opacity>0;opacity--){t.style.opacity="0."+opacity}t.style.display="none";t.style.opacity="1"}function checkExistingSearch(e,t){if(e.length>3){document.getElementById(t).style.display="block"}}function setUpMenus(){jQuery(document).ready(function(){if(!document.getElementById("SearchListing")){return}var e,t;CreateMenuContent("TypeDropDownMenu",2,"SearchListing",0,100,"TypeMenu");CreateMenuContent("CustDropDownMenu",1,"SearchListing",0,5,"Custmenu");e=document.getElementById("CustDropDownMenu");t=document.createElement("li");t.className="divider";e.appendChild(t);t=document.createElement("li");t.className="viewAll";t.innerHTML="<a href='index.php?option=viewCustomers'>View All</a></li>";e.appendChild(t)})}function inlineDeCrypt(){var e,t=document.getElementsByClassName("inlineTLS");for(e=0;e<t.length;e++){t[e].innerHTML=decryptAPIResp(t[e].innerHTML,retKey())}}function xorestr(e,t){if(!enabledEncryption()){return e}var n,r,i="",s=0,o=t.split(":");for(var u=0;u<e.length;u++){n=e.charCodeAt(u);r=n^o[0].charCodeAt(s)^o[1].charCodeAt(s);i+=r.toString()+" ";s++;if(s>=t.length){s=0}}return i}function xordstr(e,t){if(!enabledEncryption()){return e}var n,r,i="",s=0,e=e.split(" "),o=t.split(":");for(var u=0;u<e.length;u++){if(e[u].length==0){continue}n=e[u];r=n^o[1].charCodeAt(s)^o[0].charCodeAt(s);i+=String.fromCharCode(r);s++;if(s>=t.length){s=0}}return i}function unknownAPICommand(){var e=document.getElementById("NotificationArea");clearInterval(sesscheck);e.innerHTML+="<div id='apiError' class='alert alert-error'>API Error Detected</div>";if(!enabledEncryption()){return}if(!confirm("The API reported an error, attempting to rectify. Click OK to try and rectify")){return}e.removeChild(document.getElementById("apiError"));e.innerHTML="<div id='apiError' class='alert alert-info'>Attempting to rectify API issue. Window will refresh when ready</div>";destroyKeys();removeCurrKey(1)}function removeCurrKey(e){var t,n=document.getElementById("kFile"),r=n.getAttribute("src"),i=n.parentNode;i.removeChild(n);t=document.createElement("iframe");t.setAttribute("id","kfile");t.setAttribute("src",r+"&forceload=y");t.style.width="0px";t.style.height="0px";t.style.border="0px";document.body.appendChild(t);interval=setInterval("reloadKeyf('"+r+"',"+e+")",500)}function reloadKeyf(e,t){var n,r,i;clearInterval(interval);n=document.getElementById("kfile");n.contentWindow.document.cookie="PHPCredLockerKeySet=0;";n.parentNode.removeChild(n);r=new Date;n=document.createElement("script");n.setAttribute("id","kFile");n.setAttribute("src",e+"&forceload=y"+"&rand="+r.getTime());document.getElementsByTagName("head")[0].appendChild(n);if(window.getKey!=""&&t==1){i=document.getElementById("apiError");i.parentNode.removeChild(i);sesscheck=setInterval("checkSession()",12e4)}}function decryptAPIResp(e,t){if(!enabledEncryption()){return e}return Base64.decode(xordstr(Base64.decode(e),t))}function getDivider(){if(typeof Storage!=="undefined"&&sessionStorage.Delimiter){return sessionStorage.getItem("Delimiter")}return getDelimiter()}function getTerms(e){if(typeof Storage!=="undefined"){if(!terms){terms=JSON.parse(sessionStorage.getItem("Terminology"))}return Base64.decode(terms[e.toString()])}return Base64.decode(getTerminology(e))}function cryptReq(e){var t,n=retKey(),r=getDivider();t=genPadding()+r+getTerms(e)+r+genPadding();if(!enabledEncryption()){return t}return encodeURIComponent(Base64.encode(xorestr(Base64.encode(t),n)))}function genPadding(){if(!enabledEncryption()){return"a"}var e,t,n="";t=Math.random().toString(10).substring(2,3);for(e=0;e<t;e++){n+=Math.random().toString(10).substring(Math.random().toString(10).substring(2,3))}return n}function retAuthKey(){return Base64.decode(getAuthKey())}function retKey(){return Base64.decode(getKey())}function checkKeyAvailable(){if(!getKey&&typeof getTLSKey!="function"){if(confirm("Key retrieval failed - Attempting to rectify, Click OK to continue - Screen may refresh")){var e,t=document.cookie.split(";");for(e=0;e<t.length;e++){KillCookie(t[e].split("=")[0])}removeCurrKey();if(typeof getTLSKey=="function"){alert("Keys retrieved successfully");return true}window.location.reload(true);return false}}return true}function getKey(){if(typeof Storage!=="undefined"&&sessionStorage.key){return sessionStorage.getItem("key")}else{if(typeof getTLSKey!="function"){return false}return getTLSKey()}}function enabledEncryption(){if(typeof Storage!=="undefined"&&sessionStorage.CryptEnabled){return sessionStorage.getItem("CryptEnabled")}else{if(typeof enabledTLSEncryption!="function"){return false}return enabledTLSEncryption()}}function KillCookie(e){createCookie(e,"",-1)}function createCookie(e,t,n){var r,i;if(n){i=new Date;i.setTime(i.getTime()+n*24*60*60*1e3);r="; expires="+i.toGMTString()}else r="";document.cookie=e+"="+t+r+"; path=/"}var counter=false,cancel="",dispcred,interval,terms