Added auto-select to displayed creds for easy copying on Mobile devices
Added auto-select to displayed creds for easy copying on Mobile devices

/* ************************************************************ /* ************************************************************
Author: Ben Tasker - BenTasker.co.uk Author: Ben Tasker - BenTasker.co.uk
Description: Main Javascript functions for PHPCredLocker. Most Description: Main Javascript functions for PHPCredLocker. Most
functions currently quick and dirty, will improve in future releases! functions currently quick and dirty, will improve in future releases!
   
License: GNU GPL V2 - See http://www.gnu.org/licenses/gpl-2.0.html License: GNU GPL V2 - See http://www.gnu.org/licenses/gpl-2.0.html
   
Repo: https://github.com/bentasker/PHPCredLocker/ Repo: https://github.com/bentasker/PHPCredLocker/
--------------------------------------------------------------- ---------------------------------------------------------------
Copyright (c) 2012 Ben Tasker Copyright (c) 2012 Ben Tasker
   
*/ */
   
   
var counter=false, cancel='', dispcred, interval,terms; var counter=false, cancel='', dispcred, interval,terms;
   
   
   
function genPwd(a,l){ function genPwd(a,l){
var i, var i,
p='', p='',
key="(=?)+.,abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; key="(=?)+.,abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   
for (i=0; i<l; i++){ for (i=0; i<l; i++){
p+=key.charAt(Math.floor(Math.random()*key.length)); p+=key.charAt(Math.floor(Math.random()*key.length));
} }
   
   
if (a =='r'){ return p; } if (a =='r'){ return p; }
document.getElementById(a).value = p; document.getElementById(a).value = p;
   
   
} }
   
   
   
function resizebkgrnd(){ function resizebkgrnd(){
var width = document.documentElement.clientHeight, height = width, img; var width = document.documentElement.clientHeight, height = width, img;
img = document.getElementById('ContentWrap'); img = document.getElementById('ContentWrap');
img.style.minHeight = eval(height * 0.8)+'px'; img.style.minHeight = eval(height * 0.8)+'px';
   
   
   
} }
   
   
function CreateMenuContent(menu,type,tbl,cellNr, limit, menucode){ function CreateMenuContent(menu,type,tbl,cellNr, limit, menucode){
var menuentry, ind, item, str, var menuentry, ind, item, str,
lim = 0, lim = 0,
menu = document.getElementById(menu), menu = document.getElementById(menu),
table = document.getElementById(tbl); table = document.getElementById(tbl);
if (!table){ return false; } if (!table){ return false; }
for (var r = 0; r < table.rows.length; r++){ for (var r = 0; r < table.rows.length; r++){
if ( lim == limit) { break; } if ( lim == limit) { break; }
ind = table.rows[r].cells[3].innerHTML; ind = table.rows[r].cells[3].innerHTML;
if (ind == type ){ if (ind == type ){
item = document.createElement('li'); item = document.createElement('li');
item.id = menucode + table.rows[r].cells[2].innerHTML; item.id = menucode + table.rows[r].cells[2].innerHTML;
item.innerHTML = "<a href='index.php?option="+table.rows[r].cells[5].innerHTML+"&id="+table.rows[r].cells[2].innerHTML+"'>"+table.rows[r].cells[cellNr].innerHTML+"</a>"; item.innerHTML = "<a href='index.php?option="+table.rows[r].cells[5].innerHTML+"&id="+table.rows[r].cells[2].innerHTML+"'>"+table.rows[r].cells[cellNr].innerHTML+"</a>";
menu.appendChild(item); menu.appendChild(item);
lim = lim + 1; lim = lim + 1;
} }
} }
} }
   
   
   
   
function Credtimer(id) function Credtimer(id)
{ {
var count, var count,
cnt = document.getElementById('PassCount'+id), cnt = document.getElementById('PassCount'+id),
field = document.getElementById('retrievePassword'+id); field = document.getElementById('retrievePassword'+id);
count=cnt.value-1; count=cnt.value-1;
cnt.value = count; cnt.value = count;
if (count <= 0 || cancel == 1) if (count <= 0 || cancel == 1)
{ {
clearInterval(counter); clearInterval(counter);
if (document.getElementById('credHidden'+id)){ if (document.getElementById('credHidden'+id)){
field.innerHTML = 'Display<span class="DisPwdText"> Username</span>'; field.innerHTML = 'Display<span class="DisPwdText"> Username</span>';
}else{ }else{
field.innerHTML = 'Display<span class="DisPwdText"> Password</span>'; field.innerHTML = 'Display<span class="DisPwdText"> Password</span>';
} }
document.getElementById('Address'+id).innerHTML = ''; document.getElementById('Address'+id).innerHTML = '';
document.getElementById('UserName'+id).innerHTML = ''; document.getElementById('UserName'+id).innerHTML = '';
document.getElementById('Password'+id).innerHTML = ''; document.getElementById('Password'+id).innerHTML = '';
document.getElementById('CredPluginOutput'+id).innerHTML = ''; document.getElementById('CredPluginOutput'+id).innerHTML = '';
document.getElementById("clickCount"+id).value = 0; document.getElementById("clickCount"+id).value = 0;
return; return;
} }
   
field.innerHTML = 'Displaying for ' +count+ ' seconds'; field.innerHTML = 'Displaying for ' +count+ ' seconds';
} }
   
   
   
   
   
function noCredTypes(){ function noCredTypes(){
$(document).ready(function(){ $(document).ready(function(){
var btntop; var btntop;
if (document.getElementById('AddCredBtnTop')){ if (document.getElementById('AddCredBtnTop')){
btntop = document.getElementById('AddCredBtnTop'); btntop = document.getElementById('AddCredBtnTop');
btntop.parentNode.removeChild(btntop); btntop.parentNode.removeChild(btntop);
} }
   
if (document.getElementById('AddCredBtnBottom')){ if (document.getElementById('AddCredBtnBottom')){
btntop = document.getElementById('AddCredBtnBottom'); btntop = document.getElementById('AddCredBtnBottom');
btntop.parentNode.removeChild(btntop); btntop.parentNode.removeChild(btntop);
} }
}); });
} }
   
   
   
   
   
   
/********* Validation Stuff ****/ /********* Validation Stuff ****/
   
   
   
function loginReqProcess(){ function loginReqProcess(){
var i, var i,
a='', a='',
entered = document.getElementById('FrmPassPlace'), entered = document.getElementById('FrmPassPlace'),
pass = document.getElementById('FrmPass'); pass = document.getElementById('FrmPass');
if (!enabledEncryption()){ pass.value = entered.value; return true;} if (!enabledEncryption()){ pass.value = entered.value; return true;}
// Calculate the encrypted value // Calculate the encrypted value
pass.value = Base64.encode(xorestr(entered.value,retAuthKey())); pass.value = Base64.encode(xorestr(entered.value,retAuthKey()));
// Update the placeholder so we're not accompanying our encrypted text with the plaintext value // Update the placeholder so we're not accompanying our encrypted text with the plaintext value
for (i = 0;i < entered.length; i++){ for (i = 0;i < entered.length; i++){
a += "a"; a += "a";
} }
entered.value = a; entered.value = a;
return true; return true;
} }
   
   
function checkNewCust(){ function checkNewCust(){
var nme = document.getElementById('FrmName'), var nme = document.getElementById('FrmName'),
grp = document.getElementById('frmGroup'), grp = document.getElementById('frmGroup'),
email = document.getElementById('FrmEmail'); email = document.getElementById('FrmEmail');
if (email.value.indexOf('@') == -1){ if (email.value.indexOf('@') == -1){
email.className += ' frmEntryMissed'; email.className += ' frmEntryMissed';
return false; return false;
} }
if (grp.options[grp.selectedIndex].value == 'null'){ if (grp.options[grp.selectedIndex].value == 'null'){
grp.className += ' frmEntryMissed'; grp.className += ' frmEntryMissed';
return false; return false;
} }
if (nme.value == ''){ if (nme.value == ''){
nme.className += ' frmEntryMissed'; nme.className += ' frmEntryMissed';
return false; return false;
} }
if (enabledEncryption()){ if (enabledEncryption()){
var fname = document.getElementById('FrmconName'), var fname = document.getElementById('FrmconName'),
sname = document.getElementById('FrmSurname'); sname = document.getElementById('FrmSurname');
// Calculate the encrypted value // Calculate the encrypted value
nme.value = Base64.encode(xorestr(nme.value,retKey())); nme.value = Base64.encode(xorestr(nme.value,retKey()));
email.value = Base64.encode(xorestr(email.value,retKey())); email.value = Base64.encode(xorestr(email.value,retKey()));
fname.value = Base64.encode(xorestr(fname.value,retKey())); fname.value = Base64.encode(xorestr(fname.value,retKey()));
sname.value = Base64.encode(xorestr(sname.value,retKey())); sname.value = Base64.encode(xorestr(sname.value,retKey()));
} }
return true; return true;
} }
   
   
   
function checkNewCred(){ function checkNewCred(){
   
var cred = document.getElementById('frmCredential'), var cred = document.getElementById('frmCredential'),
user = document.getElementById('frmUser'), user = document.getElementById('frmUser'),
addr = document.getElementById('frmAddress'), addr = document.getElementById('frmAddress'),
grp = document.getElementById('frmGroup'), grp = document.getElementById('frmGroup'),
comment = document.getElementById('frmComment'); comment = document.getElementById('frmComment');
if (grp.options[grp.selectedIndex].value == 'null'){ if (grp.options[grp.selectedIndex].value == 'null'){
grp.className += ' frmEntryMissed'; grp.className += ' frmEntryMissed';
return false; return false;
} }
if (cred.value.indexOf("http") !== -1){ if (cred.value.indexOf("http") !== -1){
   
   
if (confirm("Click OK to make this credential a hyperlink in the database, click cancel to set not clicky")){ if (confirm("Click OK to make this credential a hyperlink in the database, click cancel to set not clicky")){
   
document.getElementById('frmClicky').value = 1; document.getElementById('frmClicky').value = 1;
} }
} }
   
if (enabledEncryption()){ if (enabledEncryption()){
// Calculate the encrypted value // Calculate the encrypted value
cred.value = Base64.encode(xorestr(cred.value,retKey())); cred.value = Base64.encode(xorestr(cred.value,retKey()));
user.value = Base64.encode(xorestr(user.value,retKey())); user.value = Base64.encode(xorestr(user.value,retKey()));
addr.value = Base64.encode(xorestr(addr.value,retKey())); addr.value = Base64.encode(xorestr(addr.value,retKey()));
comment.value = Base64.encode(xorestr(comment.value,retKey())); comment.value = Base64.encode(xorestr(comment.value,retKey()));
} }
return true; return true;
   
} }
   
   
   
   
function checkEditCred(){ function checkEditCred(){
   
var cred = document.getElementById('frmCredential'), var cred = document.getElementById('frmCredential'),
user = document.getElementById('frmUser'), user = document.getElementById('frmUser'),
addr = document.getElementById('frmAddress'), addr = document.getElementById('frmAddress'),
grp = document.getElementById('frmGroup'), grp = document.getElementById('frmGroup'),
comment = document.getElementById('frmComment'); comment = document.getElementById('frmComment');
if (grp.options[grp.selectedIndex].value == 'null'){ if (grp.options[grp.selectedIndex].value == 'null'){
grp.className += ' frmEntryMissed'; grp.className += ' frmEntryMissed';
return false; return false;
} }
if (cred.value.indexOf("http") !== -1){ if (cred.value.indexOf("http") !== -1){
   
   
if (confirm("Click OK to make this credential a hyperlink in the database, click cancel to set not clicky")){ if (confirm("Click OK to make this credential a hyperlink in the database, click cancel to set not clicky")){
   
document.getElementById('frmClicky').value = 1; document.getElementById('frmClicky').value = 1;
} }
   
} }
   
   
// See if any have been blanked // See if any have been blanked
   
if (cred.value == null || cred.value == ''){ if (cred.value == null || cred.value == ''){
cred.value = ' '; cred.value = ' ';
} }
if (comment.value == null || comment.value == ''){ if (comment.value == null || comment.value == ''){
comment.value = ' '; comment.value = ' ';
} }
   
if (user.value == null || user.value == ''){ if (user.value == null || user.value == ''){
user.value = ' '; user.value = ' ';
} }
   
if (addr.value == null || addr.value == ''){ if (addr.value == null || addr.value == ''){
addr.value = ' '; addr.value = ' ';
} }
   
   
if (enabledEncryption()){ if (enabledEncryption()){
// Calculate the encrypted value // Calculate the encrypted value
cred.value = Base64.encode(xorestr(cred.value,retKey())); cred.value = Base64.encode(xorestr(cred.value,retKey()));
user.value = Base64.encode(xorestr(user.value,retKey())); user.value = Base64.encode(xorestr(user.value,retKey()));
addr.value = Base64.encode(xorestr(addr.value,retKey())); addr.value = Base64.encode(xorestr(addr.value,retKey()));
comment.value = Base64.encode(xorestr(comment.value,retKey())); comment.value = Base64.encode(xorestr(comment.value,retKey()));
} }
   
return true; return true;
} }
   
   
   
function checkChngPwds(){ function checkChngPwds(){
if(!comparePwds() ){ return false; } if(!comparePwds() ){ return false; }
if (!enabledEncryption()){ return true; } if (!enabledEncryption()){ return true; }
   
var pass = document.getElementById('frmPass'), var pass = document.getElementById('frmPass'),
passconf = document.getElementById('frmPassConf'); passconf = document.getElementById('frmPassConf');
pass.value = Base64.encode(xorestr(pass.value,retKey())); pass.value = Base64.encode(xorestr(pass.value,retKey()));
passconf.value = Base64.encode(xorestr(passconf.value,retKey())); passconf.value = Base64.encode(xorestr(passconf.value,retKey()));
return true; return true;
} }
   
   
function comparePwds(){ function comparePwds(){
var strength, test,testvars, var strength, test,testvars,
pass = document.getElementById('frmPass'), pass = document.getElementById('frmPass'),
nomatch = document.getElementById('PassNoMatch'), nomatch = document.getElementById('PassNoMatch'),
passscore = document.getElementById('passScore'), passscore = document.getElementById('passScore'),
minpass = document.getElementById('minpassStrength'); minpass = document.getElementById('minpassStrength');
if (minpass){ if (minpass){
strength = minpass.value; strength = minpass.value;
if (strength.indexOf("+") >= 0){ if (strength.indexOf("+") >= 0){
if (parseInt(passScore.value) > 45){ if (parseInt(passScore.value) > 45){
test = true; test = true;
}else{ }else{
test = false; test = false;
} }
}else{ }else{
testvars = strength.split("-"); testvars = strength.split("-");
if ((parseInt(passScore.value) > testvars[0])){ if ((parseInt(passScore.value) > testvars[0])){
test = true; test = true;
}else{ }else{
test = false; test = false;
} }
} }
if (!test){ if (!test){
nomatch.innerHTML = "Password is too weak"; nomatch.innerHTML = "Password is too weak";
nomatch.style.display = 'inline-block'; nomatch.style.display = 'inline-block';
return false; return false;
} }
} }
if (pass.value != document.getElementById('frmPassConf').value){ if (pass.value != document.getElementById('frmPassConf').value){
nomatch.innerHTML = "Passwords don't match"; nomatch.innerHTML = "Passwords don't match";
nomatch.style.display = 'inline-block'; nomatch.style.display = 'inline-block';
return false; return false;
} }
if (pass.value == null || pass.value == ''){ if (pass.value == null || pass.value == ''){
document.getElementById('PassNoMatch').innerHTML = "You must set a password"; document.getElementById('PassNoMatch').innerHTML = "You must set a password";
nomatch.style.display = 'inline-block'; nomatch.style.display = 'inline-block';
return false; return false;
} }
nomatch.style.display = 'none'; nomatch.style.display = 'none';
return true; return true;
} }
/********** AJAX *****/ /********** AJAX *****/
function getCreds(id){ function getCreds(id){
   
var xmlhttp, resp, limit, cnt, count, option, var xmlhttp, resp, limit, cnt, count, option,
clicky = document.getElementById('retrievePassword'+id), clicky = document.getElementById('retrievePassword'+id),
Address = document.getElementById('Address'+id), Address = document.getElementById('Address'+id),
User = document.getElementById('UserName'+id), User = document.getElementById('UserName'+id),
Pass = document.getElementById('Password'+id), Pass = document.getElementById('Password'+id),
Pluginout = document.getElementById('CredPluginOutput'+id), Pluginout = document.getElementById('CredPluginOutput'+id),
key = retKey(), key = retKey(),
clickcount = document.getElementById("clickCount"+id); clickcount = document.getElementById("clickCount"+id);
   
if (clickcount.value != 0){ if (clickcount.value != 0){
return; return;
} }
clickcount.value = 1; clickcount.value = 1;
clicky.innerHTML = '<i>Retrieving.....</i>'; clicky.innerHTML = '<i>Retrieving.....</i>';
   
   
if (window.XMLHttpRequest) if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest(); xmlhttp=new XMLHttpRequest();
} }
else else
{// code for IE6, IE5 {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} }
xmlhttp.onreadystatechange=function() xmlhttp.onreadystatechange=function()
{ {
if (xmlhttp.readyState==4 && xmlhttp.status==200) if (xmlhttp.readyState==4 && xmlhttp.status==200)
{ {
resp = decryptAPIResp(xmlhttp.responseText,key).split(getDivider()); resp = decryptAPIResp(xmlhttp.responseText,key).split(getDivider());
// Check for an invalid verb response // Check for an invalid verb response
if (resp[1] == 2){ if (resp[1] == 2){
return unknownAPICommand(); return unknownAPICommand();
} }
if (resp[1] == 0){ if (resp[1] == 0){
// Request failed, authentication issue maybe? // Request failed, authentication issue maybe?
clicky.innerHTML = 'Failed to retrieve credentials. Click to try again'; clicky.innerHTML = 'Failed to retrieve credentials. Click to try again';
return false; return false;
} }
limit = document.getElementById('defaultInterval').value; limit = document.getElementById('defaultInterval').value;
cnt = document.getElementById('PassCount'+id); cnt = document.getElementById('PassCount'+id);
cnt.value = limit; cnt.value = limit;
count = limit; count = limit;
Address.innerHTML = resp[3]; Address.innerHTML = resp[3];
Pass.innerHTML = resp[2]; Pass.innerHTML = '<input class="passDisp" onclick="this.select();" type="text" value="'+resp[2]+'" title="Click to select" name="null"/>';
User.innerHTML = resp[4]; User.innerHTML = resp[4];
Pluginout.innerHTML = resp[5]; Pluginout.innerHTML = resp[5];
clicky.innerHTML = 'Displaying Password for ' +count+ ' seconds'; clicky.innerHTML = 'Displaying Password for ' +count+ ' seconds';
if (counter){ if (counter){
cancel=1; cancel=1;
document.getElementById("clickCount"+dispcred).value = 0; document.getElementById("clickCount"+dispcred).value = 0;
dispcred=id; dispcred=id;
setTimeout(function() {cancel=false; counter=setInterval("Credtimer('"+id+"')", 1000);},1000); setTimeout(function() {cancel=false; counter=setInterval("Credtimer('"+id+"')", 1000);},1000);
return; return;
} }
dispcred=id; dispcred=id;
counter=setInterval("Credtimer('"+id+"')", 1000); counter=setInterval("Credtimer('"+id+"')", 1000);
} }
   
} }
option = cryptReq('retCred'); option = cryptReq('retCred');
xmlhttp.open("POST","api.php",true); xmlhttp.open("POST","api.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send('option='+option+'&id='+id); xmlhttp.send('option='+option+'&id='+id);
} }
   
   
   
   
   
   
function checkSession(){ function checkSession(){
   
var xmlhttp, resp, cookies, option, key = retKey(); var xmlhttp, resp, cookies, option, key = retKey();
   
   
   
if (window.XMLHttpRequest) if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest(); xmlhttp=new XMLHttpRequest();
} }
else else
{// code for IE6, IE5 {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} }
xmlhttp.onreadystatechange=function() xmlhttp.onreadystatechange=function()
{ {
if (xmlhttp.readyState==4 && xmlhttp.status==200) if (xmlhttp.readyState==4 && xmlhttp.status==200)
{ {
resp = xmlhttp.responseText.split(getDivider()); resp = xmlhttp.responseText.split(getDivider());
// Check for an invalid verb response // Check for an invalid verb response
if (resp[1] == 2){ if (resp[1] == 2){
return unknownAPICommand(); return unknownAPICommand();
} }
if (resp[1] == 0){ if (resp[1] == 0){
// Session Invalid // Session Invalid
removeCurrKey(0); removeCurrKey(0);
cookies = document.cookie.split(";"); cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++){ for (var i = 0; i < cookies.length; i++){
KillCookie(cookies[i].split("=")[0]); KillCookie(cookies[i].split("=")[0]);
} }
window.location.href = "index.php?notif=InvalidSession"; window.location.href = "index.php?notif=InvalidSession";
return false; return false;
} }
} }
   
} }
option = cryptReq('checkSess'); option = cryptReq('checkSess');
// Add an id, it's completely pointless but sessioncheck requests are the only ones not specifying an id - bit easy to check // Add an id, it's completely pointless but sessioncheck requests are the only ones not specifying an id - bit easy to check
xmlhttp.open("POST","api.php",true); xmlhttp.open("POST","api.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send('option='+option+'&id='+Math.floor((Math.random()*100)+1)); xmlhttp.send('option='+option+'&id='+Math.floor((Math.random()*100)+1));
} }
   
   
function DelCust(id){ function DelCust(id){
   
var xmlhttp, resp, credrow, notify, option, key = retKey(); var xmlhttp, resp, credrow, notify, option, key = retKey();
   
   
if (!confirm("Are you sure you want to delete this customer and all associated credentials?")){ if (!confirm("Are you sure you want to delete this customer and all associated credentials?")){
return false; return false;
} }
   
   
credrow = document.getElementById('CustDisp'+id); credrow = document.getElementById('CustDisp'+id);
notify = document.getElementById('NotificationArea'); notify = document.getElementById('NotificationArea');
if (document.getElementById('Custmenu'+id)){ if (document.getElementById('Custmenu'+id)){
var menu = document.getElementById('Custmenu'+id); var menu = document.getElementById('Custmenu'+id);
} }
   
   
if (window.XMLHttpRequest) if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest(); xmlhttp=new XMLHttpRequest();
} }
else else
{// code for IE6, IE5 {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} }
xmlhttp.onreadystatechange=function() xmlhttp.onreadystatechange=function()
{ {
if (xmlhttp.readyState==4 && xmlhttp.status==200) if (xmlhttp.readyState==4 && xmlhttp.status==200)
{ {
resp = decryptAPIResp(xmlhttp.responseText,key).split(getDivider()); resp = decryptAPIResp(xmlhttp.responseText,key).split(getDivider());
// Check for an invalid verb response // Check for an invalid verb response
if (resp[1] == 2){ if (resp[1] == 2){
return unknownAPICommand(); return unknownAPICommand();
} }
if (resp[1] == 0 || resp[2] == 0){ if (resp[1] == 0 || resp[2] == 0){
// Request failed, authentication issue maybe? // Request failed, authentication issue maybe?
notify.innerHTML += '<div class="alert alert-error">Failed to Delete</div>'; notify.innerHTML += '<div class="alert alert-error">Failed to Delete</div>';
return false; return false;
} }
credrow.parentNode.removeChild(credrow); credrow.parentNode.removeChild(credrow);
notify.innerHTML += '<div class="alert alert-success">Customer and all associated credentials Deleted</div>'; notify.innerHTML += '<div class="alert alert-success">Customer and all associated credentials Deleted</div>';
   
   
if (menu){ if (menu){
menu.parentNode.removeChild(menu); menu.parentNode.removeChild(menu);
} }
} }
   
} }
option = cryptReq('delCust'); option = cryptReq('delCust');
xmlhttp.open("POST","api.php",true); xmlhttp.open("POST","api.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send('option='+option+'&id='+id); xmlhttp.send('option='+option+'&id='+id);
} }
   
   
function DelCred(id){ function DelCred(id){
   
var xmlhttp, resp, credrow, notify, option, key = retKey(); var xmlhttp, resp, credrow, notify, option, key = retKey();
   
   
if (!confirm("Are you sure you want to delete this credential?")){ if (!confirm("Are you sure you want to delete this credential?")){
return false; return false;
} }
   
   
credrow = document.getElementById('CredDisp'+id); credrow = document.getElementById('CredDisp'+id);
notify = document.getElementById('NotificationArea'); notify = document.getElementById('NotificationArea');
   
   
if (window.XMLHttpRequest) if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest(); xmlhttp=new XMLHttpRequest();
} }
else else
{// code for IE6, IE5 {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} }
xmlhttp.onreadystatechange=function() xmlhttp.onreadystatechange=function()
{ {
if (xmlhttp.readyState==4 && xmlhttp.status==200) if (xmlhttp.readyState==4 && xmlhttp.status==200)
{ {
resp = decryptAPIResp(xmlhttp.responseText,key).split(getDivider()); resp = decryptAPIResp(xmlhttp.responseText,key).split(getDivider());
// Check for an invalid verb response // Check for an invalid verb response
if (resp[1] == 2){ if (resp[1] == 2){
return unknownAPICommand(); return unknownAPICommand();
} }
if (resp[1] == 0 || resp[2] == 0){ if (resp[1] == 0 || resp[2] == 0){
// Request failed, authentication issue maybe? // Request failed, authentication issue maybe?
notify.innerHTML += '<div class="alert alert-error">Failed to Delete</div>'; notify.innerHTML += '<div class="alert alert-error">Failed to Delete</div>';
return false; return false;
} }
credrow.parentNode.removeChild(credrow); credrow.parentNode.removeChild(credrow);
notify.innerHTML += '<div class="alert alert-success">Credential Deleted</div>'; notify.innerHTML += '<div class="alert alert-success">Credential Deleted</div>';
} }
   
} }
option = cryptReq('delCred'); option = cryptReq('delCred');
xmlhttp.open("POST","api.php",true); xmlhttp.open("POST","api.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send('option='+option+'&id='+id); xmlhttp.send('option='+option+'&id='+id);
} }
   
   
   
   
   
   
   
   
/**** SEARCH FUNCTIONS *******/ /**** SEARCH FUNCTIONS *******/
   
   
function positionResults(SearchBox,ResBox){ function positionResults(SearchBox,ResBox){
var search = document.getElementById(SearchBox), var search = document.getElementById(SearchBox),
res = document.getElementById(ResBox); res = document.getElementById(ResBox);
res.style.left = search.offsetLeft +'px'; res.style.left = search.offsetLeft +'px';
// Set the position, but account for bootstrap's border and padding // Set the position, but account for bootstrap's border and padding
res.style.top = eval( search.offsetTop + search.offsetHeight + 6 )+'px'; res.style.top = eval( search.offsetTop + search.offsetHeight + 6 )+'px';
res.style.width = search.offsetWidth +'px'; res.style.width = search.offsetWidth +'px';
} }
   
   
function SearchTable(val,tbl,dispdiv,cellNr,e){ function SearchTable(val,tbl,dispdiv,cellNr,e){
// Many thanks to http://www.vonloesch.de/node/23 for the headstart on this function! // Many thanks to http://www.vonloesch.de/node/23 for the headstart on this function!
   
var disp, suche, table, res, num=0, id, ele, add, r, var disp, suche, table, res, num=0, id, ele, add, r,
keynum = 0; keynum = 0;
   
if(window.event) { keynum = window.event.keyCode; } // IE (sucks) if(window.event) { keynum = window.event.keyCode; } // IE (sucks)
else if(e.which) { keynum = e.which; } // Netscape/Firefox/Opera else if(e.which) { keynum = e.which; } // Netscape/Firefox/Opera
   
if(keynum === 38) { // up if(keynum === 38) { // up
//Move selection up //Move selection up
selectResult('up'); selectResult('up');
return; return;
} }
   
if(keynum === 40) { // down if(keynum === 40) { // down
//Move selection down //Move selection down
selectResult('down'); selectResult('down');
return; return;
} }
   
   
   
// Reset the display div // Reset the display div
disp = document.getElementById(dispdiv); disp = document.getElementById(dispdiv);
disp.innerHTML = ''; disp.innerHTML = '';
   
// Only search after 3 chars have been entered // Only search after 3 chars have been entered
if (val.length < 3){ if (val.length < 3){
return; return;
} }
document.getElementById('SelectedValue').value=0; document.getElementById('SelectedValue').value=0;
positionResults("SearchBox",dispdiv); positionResults("SearchBox",dispdiv);
suche = val.toLowerCase(); suche = val.toLowerCase();
table = document.getElementById(tbl); table = document.getElementById(tbl);
   
for ( r = 0; r < table.rows.length; r++){ for ( r = 0; r < table.rows.length; r++){
ele = table.rows[r].cells[cellNr].innerHTML.replace(/<[^>]+>/g,""); ele = table.rows[r].cells[cellNr].innerHTML.replace(/<[^>]+>/g,"");
if ((ele.toLowerCase().indexOf(suche)>=0 ) || ((suche.indexOf(":") >= 0) && (table.rows[r].cells[1].innerHTML.toLowerCase().indexOf(suche)>=0))){ if ((ele.toLowerCase().indexOf(suche)>=0 ) || ((suche.indexOf(":") >= 0) && (table.rows[r].cells[1].innerHTML.toLowerCase().indexOf(suche)>=0))){
num=num+1; num=num+1;
// Work out how to display // Work out how to display
res = document.createElement('div'); res = document.createElement('div');
res.id = 'SearchResult'+num; res.id = 'SearchResult'+num;
res.className = 'SearchResult'; res.className = 'SearchResult';
res.setAttribute('link',table.rows[r].cells[5].innerHTML); res.setAttribute('link',table.rows[r].cells[5].innerHTML);
res.setAttribute('entID',table.rows[r].cells[2].innerHTML); res.setAttribute('entID',table.rows[r].cells[2].innerHTML);
if (table.rows[r].cells[4].innerHTML != null && table.rows[r].cells[4].innerHTML != ''){ if (table.rows[r].cells[4].innerHTML != null && table.rows[r].cells[4].innerHTML != ''){
id = table.rows[r].cells[4].innerHTML; id = table.rows[r].cells[4].innerHTML;
}else{ }else{
id = 'id'; id = 'id';
} }
if (table.rows[r].cells[6]){ if (table.rows[r].cells[6]){
add = table.rows[r].cells[6].innerHTML.split("="); add = table.rows[r].cells[6].innerHTML.split("=");
res.setAttribute('entid2',add[0]); res.setAttribute('entid2',add[0]);
res.setAttribute('entid2val',add[1]); res.setAttribute('entid2val',add[1]);
add = "&"+ table.rows[r].cells[6].innerHTML; add = "&"+ table.rows[r].cells[6].innerHTML;
}else{ }else{
add = ''; add = '';
} }
res.setAttribute('onclick',"window.location.href = 'index.php?option="+table.rows[r].cells[5].innerHTML + "&"+id+"="+table.rows[r].cells[2].innerHTML+add+"';"); res.setAttribute('onclick',"window.location.href = 'index.php?option="+table.rows[r].cells[5].innerHTML + "&"+id+"="+table.rows[r].cells[2].innerHTML+add+"';");
res.setAttribute('frmName',id); res.setAttribute('frmName',id);
res.innerHTML = table.rows[r].cells[1].innerHTML + " " +table.rows[r].cells[cellNr].innerHTML; res.innerHTML = table.rows[r].cells[1].innerHTML + " " +table.rows[r].cells[cellNr].innerHTML;
disp.appendChild(res); disp.appendChild(res);
disp.style.display = 'block'; disp.style.display = 'block';
   
} }
} }
} }
   
   
function selectResult(dir){ function selectResult(dir){
var ind, SearchResult, var ind, SearchResult,
SelIndex = document.getElementById('SelectedValue'), SelIndex = document.getElementById('SelectedValue'),
SearchLength = document.getElementById('SearchResBox').childNodes.length; SearchLength = document.getElementById('SearchResBox').childNodes.length;
   
if (dir == 'down'){ if (dir == 'down'){
if (SelIndex.value != 0){ if (SelIndex.value != 0){
document.getElementById("SearchResult" + parseInt(SelIndex.value)).className = 'SearchResult'; document.getElementById("SearchResult" + parseInt(SelIndex.value)).className = 'SearchResult';
} }
if (SearchLength == SelIndex.value){ if (SearchLength == SelIndex.value){
SelIndex.value=0; SelIndex.value=0;
} }
ind = eval(parseInt(SelIndex.value) + 1); ind = eval(parseInt(SelIndex.value) + 1);
   
}else{ }else{
document.getElementById("SearchResult" + parseInt(SelIndex.value)).className = 'SearchResult'; document.getElementById("SearchResult" + parseInt(SelIndex.value)).className = 'SearchResult';
if (SelIndex.value == 1){ if (SelIndex.value == 1){
ind = SearchLength; ind = SearchLength;
}else{ }else{
ind = eval(parseInt(SelIndex.value) - 1); ind = eval(parseInt(SelIndex.value) - 1);
} }
} }
SearchResult = document.getElementById('SearchResult'+ind); SearchResult = document.getElementById('SearchResult'+ind);
SearchResult.className = 'SearchResult SearchResultActive'; SearchResult.className = 'SearchResult SearchResultActive';
SelIndex.value = ind; SelIndex.value = ind;
document.getElementById('SrchOpt').value = SearchResult.getAttribute('link'); document.getElementById('SrchOpt').value = SearchResult.getAttribute('link');
document.getElementById('SrchID').name = SearchResult.getAttribute('frmName'); document.getElementById('SrchID').name = SearchResult.getAttribute('frmName');
document.getElementById('SrchID').value = SearchResult.getAttribute('entID'); document.getElementById('SrchID').value = SearchResult.getAttribute('entID');
document.getElementById('SrchID2').name = SearchResult.getAttribute('entid2'); document.getElementById('SrchID2').name = SearchResult.getAttribute('entid2');
document.getElementById('SrchID2').value = SearchResult.getAttribute('entid2val'); document.getElementById('SrchID2').value = SearchResult.getAttribute('entid2val');
document.getElementById('SearchBox').focus(); document.getElementById('SearchBox').focus();
} }
   
   
function hideSearchDiv(dispdiv){ function hideSearchDiv(dispdiv){
var div = document.getElementById(dispdiv); var div = document.getElementById(dispdiv);
for (opacity = 10; opacity > 0; opacity--){ for (opacity = 10; opacity > 0; opacity--){
div.style.opacity = '0.'+opacity; div.style.opacity = '0.'+opacity;
} }
div.style.display = 'none'; div.style.display = 'none';
div.style.opacity = '1'; div.style.opacity = '1';
} }
   
   
function checkExistingSearch(val,div){ function checkExistingSearch(val,div){
if (val.length > 3){ if (val.length > 3){
document.getElementById(div).style.display = 'block'; document.getElementById(div).style.display = 'block';
} }
} }
   
   
function setUpMenus(){ function setUpMenus(){
   
jQuery(document).ready(function() { jQuery(document).ready(function() {
   
if (!document.getElementById('SearchListing')){ return; } if (!document.getElementById('SearchListing')){ return; }
var menu,ele; var menu,ele;
CreateMenuContent('TypeDropDownMenu',2,'SearchListing',0, 100, 'TypeMenu'); CreateMenuContent('TypeDropDownMenu',2,'SearchListing',0, 100, 'TypeMenu');
CreateMenuContent('CustDropDownMenu',1,'SearchListing',0, 5, 'Custmenu'); CreateMenuContent('CustDropDownMenu',1,'SearchListing',0, 5, 'Custmenu');
menu = document.getElementById('CustDropDownMenu'); menu = document.getElementById('CustDropDownMenu');
ele = document.createElement('li'); ele = document.createElement('li');
ele.className='divider'; ele.className='divider';
   
menu.appendChild(ele); menu.appendChild(ele);
   
ele = document.createElement('li'); ele = document.createElement('li');
ele.className = 'viewAll'; ele.className = 'viewAll';
ele.innerHTML = "<a href='index.php?option=viewCustomers'>View All</a></li>"; ele.innerHTML = "<a href='index.php?option=viewCustomers'>View All</a></li>";
menu.appendChild(ele); menu.appendChild(ele);
}); });
   
   
   
} }
   
   
/***** Crypto Functions ******/ /***** Crypto Functions ******/
   
   
/** Use bitwise Xor to encrypt the supplied string with the supplied key and return a base64 encoded representation of the character codes /** Use bitwise Xor to encrypt the supplied string with the supplied key and return a base64 encoded representation of the character codes
* Did try converting back to char, but things broke quite monumentally. Realistically makes little difference to an attacker, though it is a pain * Did try converting back to char, but things broke quite monumentally. Realistically makes little difference to an attacker, though it is a pain
* as it means a longer request. * as it means a longer request.
* *
*/ */
   
   
function inlineDeCrypt(){ function inlineDeCrypt(){
var i, eles = document.getElementsByClassName('inlineTLS'); var i, eles = document.getElementsByClassName('inlineTLS');
for (i=0;i < eles.length;i++){ for (i=0;i < eles.length;i++){
eles[i].innerHTML = decryptAPIResp(eles[i].innerHTML,retKey()); eles[i].innerHTML = decryptAPIResp(eles[i].innerHTML,retKey());
} }
} }
   
   
function xorestr(str,key){ function xorestr(str,key){
if (!enabledEncryption()){ return str; } if (!enabledEncryption()){ return str; }
var a, b, var a, b,
enc='', enc='',
keypos = 0, keypos = 0,
k = key.split(":"); k = key.split(":");
   
for (var i=0; i<str.length;i++) { for (var i=0; i<str.length;i++) {
   
   
a = str.charCodeAt(i); a = str.charCodeAt(i);
b = (a ^ k[0].charCodeAt(keypos)) ^ k[1].charCodeAt(keypos) ; b = (a ^ k[0].charCodeAt(keypos)) ^ k[1].charCodeAt(keypos) ;
enc += b.toString()+" "; enc += b.toString()+" ";
   
keypos++; keypos++;
if (keypos >= key.length){ keypos = 0;} if (keypos >= key.length){ keypos = 0;}
} }
   
   
   
   
   
return enc; return enc;
} }
   
   
function xordstr(str,key){ function xordstr(str,key){
   
if (!enabledEncryption()){ return str; } if (!enabledEncryption()){ return str; }
var a, b, var a, b,
enc='', enc='',
keypos = 0, keypos = 0,
str = str.split(" "), str = str.split(" "),
k = key.split(":"); k = key.split(":");
for (var i=0; i<str.length;i++) { for (var i=0; i<str.length;i++) {
   
if (str[i].length == 0){ continue; } if (str[i].length == 0){ continue; }
a = str[i]; a = str[i];
b = (a ^ k[1].charCodeAt(keypos)) ^ k[0].charCodeAt(keypos) ; b = (a ^ k[1].charCodeAt(keypos)) ^ k[0].charCodeAt(keypos) ;
enc += String.fromCharCode(b); enc += String.fromCharCode(b);
   
keypos++; keypos++;
if (keypos >= key.length){ keypos = 0;} if (keypos >= key.length){ keypos = 0;}
} }
   
return enc; return enc;
} }
   
   
function unknownAPICommand(){ function unknownAPICommand(){
// The API reports that the verb used wasn't recognised. We need to refresh the key file // The API reports that the verb used wasn't recognised. We need to refresh the key file
var notify = document.getElementById('NotificationArea'); var notify = document.getElementById('NotificationArea');
clearInterval(sesscheck); clearInterval(sesscheck);
notify.innerHTML += "<div id='apiError' class='alert alert-error'>API Error Detected</div>"; notify.innerHTML += "<div id='apiError' class='alert alert-error'>API Error Detected</div>";
if (!enabledEncryption()){ return; } if (!enabledEncryption()){ return; }
if(!confirm("The API reported an error, attempting to rectify. Click OK to try and rectify")){ if(!confirm("The API reported an error, attempting to rectify. Click OK to try and rectify")){
return; return;
} }
notify.removeChild(document.getElementById('apiError')); notify.removeChild(document.getElementById('apiError'));
notify.innerHTML = "<div id='apiError' class='alert alert-info'>Attempting to rectify API issue. Window will refresh when ready</div>"; notify.innerHTML = "<div id='apiError' class='alert alert-info'>Attempting to rectify API issue. Window will refresh when ready</div>";
destroyKeys(); destroyKeys();
removeCurrKey(1); removeCurrKey(1);
} }
   
   
   
function removeCurrKey(n){ function removeCurrKey(n){
var frm, var frm,
sess = document.getElementById("kFile"), sess = document.getElementById("kFile"),
sessid = sess.getAttribute('src'), sessid = sess.getAttribute('src'),
parent = sess.parentNode; parent = sess.parentNode;
parent.removeChild(sess); parent.removeChild(sess);
// We need to delete the cookie, but can't do that from the current location // We need to delete the cookie, but can't do that from the current location
frm = document.createElement('iframe'); frm = document.createElement('iframe');
frm.setAttribute('id','kfile'); frm.setAttribute('id','kfile');
frm.setAttribute('src',sessid+'&forceload=y'); frm.setAttribute('src',sessid+'&forceload=y');
frm.style.width = '0px'; frm.style.width = '0px';
frm.style.height = '0px'; frm.style.height = '0px';
frm.style.border = '0px'; frm.style.border = '0px';
document.body.appendChild(frm); document.body.appendChild(frm);
// Wait 500 milliseconds so we can be sure it's loaded // Wait 500 milliseconds so we can be sure it's loaded
interval = setInterval("reloadKeyf('"+sessid+"',"+n+")",500); interval = setInterval("reloadKeyf('"+sessid+"',"+n+")",500);
} }
   
   
   
function reloadKeyf(sessid,n){ function reloadKeyf(sessid,n){
var frm, date, notify; var frm, date, notify;
clearInterval(interval); clearInterval(interval);
frm = document.getElementById('kfile'); frm = document.getElementById('kfile');
frm.contentWindow.document.cookie = 'PHPCredLockerKeySet=0;'; frm.contentWindow.document.cookie = 'PHPCredLockerKeySet=0;';
frm.parentNode.removeChild(frm); frm.parentNode.removeChild(frm);
date = new Date(); date = new Date();
frm = document.createElement('script'); frm = document.createElement('script');
frm.setAttribute('id','kFile'); frm.setAttribute('id','kFile');
// Append a string to ensure the browser doesn't use the cache. // Append a string to ensure the browser doesn't use the cache.
frm.setAttribute('src',sessid+'&forceload=y'+'&rand='+date.getTime()); frm.setAttribute('src',sessid+'&forceload=y'+'&rand='+date.getTime());
document.getElementsByTagName("head")[0].appendChild(frm); document.getElementsByTagName("head")[0].appendChild(frm);
if (window.getKey != '' && n == 1){ if (window.getKey != '' && n == 1){
notify = document.getElementById('apiError'); notify = document.getElementById('apiError');
notify.parentNode.removeChild(notify); notify.parentNode.removeChild(notify);
sesscheck = setInterval("checkSession()",120000); sesscheck = setInterval("checkSession()",120000);
} }
} }
   
   
   
   
   
   
   
function decryptAPIResp(str,key){ function decryptAPIResp(str,key){
if (!enabledEncryption()){ return str; } if (!enabledEncryption()){ return str; }
return Base64.decode(xordstr(Base64.decode(str),key)); return Base64.decode(xordstr(Base64.decode(str),key));
} }
   
   
function getDivider(){ function getDivider(){
if(typeof(Storage)!=="undefined" && sessionStorage.Delimiter){ if(typeof(Storage)!=="undefined" && sessionStorage.Delimiter){
return sessionStorage.getItem('Delimiter'); return sessionStorage.getItem('Delimiter');
} }
return getDelimiter(); return getDelimiter();
} }
   
   
function getTerms(a){ function getTerms(a){
if(typeof(Storage)!=="undefined"){ if(typeof(Storage)!=="undefined"){
if (!terms){ if (!terms){
terms = JSON.parse(sessionStorage.getItem('Terminology')) terms = JSON.parse(sessionStorage.getItem('Terminology'))
} }
return Base64.decode(terms[a.toString()]); return Base64.decode(terms[a.toString()]);
} }
return Base64.decode(getTerminology(a)); return Base64.decode(getTerminology(a));
} }
   
   
function cryptReq(str){ function cryptReq(str){
/* We retrieve the key here (even though it's available to the parent) /* We retrieve the key here (even though it's available to the parent)
* because we may want to implement a second key used for sending requests, * because we may want to implement a second key used for sending requests,
* whether that's a symmetric or asymetric key. * whether that's a symmetric or asymetric key.
*/ */
var ciphert,key = retKey(), var ciphert,key = retKey(),
div = getDivider(); div = getDivider();
ciphert = genPadding() + div + getTerms(str) + div + genPadding(); ciphert = genPadding() + div + getTerms(str) + div + genPadding();
if (!enabledEncryption()){ return ciphert; } if (!enabledEncryption()){ return ciphert; }
return encodeURIComponent(Base64.encode(xorestr(Base64.encode(ciphert),key))); return encodeURIComponent(Base64.encode(xorestr(Base64.encode(ciphert),key)));
} }
   
   
/** Really not that familiar with random string generation in JS, but this seems to work! */ /** Really not that familiar with random string generation in JS, but this seems to work! */
function genPadding(){ function genPadding(){
if (!enabledEncryption()){ return 'a'; } if (!enabledEncryption()){ return 'a'; }
var i,c, var i,c,
a=''; a='';
   
c = Math.random().toString(10).substring(2,3); c = Math.random().toString(10).substring(2,3);
for (i=0;i < c;i++){ for (i=0;i < c;i++){
a += Math.random().toString(10).substring(Math.random().toString(10).substring(2,3)); a += Math.random().toString(10).substring(Math.random().toString(10).substring(2,3));
} }
   
return a; return a;
} }
   
   
function retAuthKey(){ function retAuthKey(){
return Base64.decode(getAuthKey()); return Base64.decode(getAuthKey());
} }
   
function retKey(){ function retKey(){
return Base64.decode(getKey()); return Base64.decode(getKey());
} }
   
   
function checkKeyAvailable(){ function checkKeyAvailable(){
if(!getKey && typeof getTLSKey != 'function') { if(!getKey && typeof getTLSKey != 'function') {
if (confirm("Key retrieval failed - Attempting to rectify, Click OK to continue - Screen may refresh")){ if (confirm("Key retrieval failed - Attempting to rectify, Click OK to continue - Screen may refresh")){
var i, var i,
cookies = document.cookie.split(";"); cookies = document.cookie.split(";");
for (i = 0; i < cookies.length; i++){ for (i = 0; i < cookies.length; i++){
KillCookie(cookies[i].split("=")[0]); KillCookie(cookies[i].split("=")[0]);
} }
removeCurrKey(); removeCurrKey();
if(typeof getTLSKey == 'function') { if(typeof getTLSKey == 'function') {
alert("Keys retrieved successfully"); alert("Keys retrieved successfully");
return true; return true;
} }
window.location.reload(true); window.location.reload(true);
return false; return false;
} }
} }
return true; return true;
} }
   
function getKey(){ function getKey(){
if(typeof(Storage)!=="undefined" && sessionStorage.key){ if(typeof(Storage)!=="undefined" && sessionStorage.key){
return sessionStorage.getItem('key'); return sessionStorage.getItem('key');
}else{ }else{
if(typeof getTLSKey != 'function'){ if(typeof getTLSKey != 'function'){
return false; return false;
} }
return getTLSKey(); return getTLSKey();
} }
} }
   
function enabledEncryption(){ function enabledEncryption(){
if(typeof(Storage)!=="undefined" && sessionStorage.CryptEnabled){ if(typeof(Storage)!=="undefined" && sessionStorage.CryptEnabled){
return sessionStorage.getItem('CryptEnabled'); return sessionStorage.getItem('CryptEnabled');
}else{ }else{
if(typeof enabledTLSEncryption != 'function'){ if(typeof enabledTLSEncryption != 'function'){
return false; return false;
} }
return enabledTLSEncryption(); return enabledTLSEncryption();
} }
   
} }
   
   
   
   
/********* MMMMMMMMMMMM COOKIES! ******/ /********* MMMMMMMMMMMM COOKIES! ******/
   
   
function KillCookie(name) { function KillCookie(name) {
createCookie(name,"",-1); createCookie(name,"",-1);
} }
   
   
   
function createCookie(nme,val,expire) { function createCookie(nme,val,expire) {
var expires, date; var expires, date;
if (expire) { if (expire) {
date = new Date(); date = new Date();
date.setTime(date.getTime()+(expire*24*60*60*1000)); date.setTime(date.getTime()+(expire*24*60*60*1000));
expires = "; expires="+date.toGMTString(); expires = "; expires="+date.toGMTString();
} }
else expires = ""; else expires = "";
document.cookie = nme+"="+val+expires+"; path=/"; document.cookie = nme+"="+val+expires+"; path=/";
} }
   
   
   
   
   
.viewAll a {font-weight: bold; font-size: 1.2em;} .viewAll a {font-weight: bold; font-size: 1.2em;}
.viewButtons {text-align: center; padding-bottom: 20px; padding-top: 20px;} .viewButtons {text-align: center; padding-bottom: 20px; padding-top: 20px;}
   
.CredDisp td {vertical-align: middle;} .CredDisp td {vertical-align: middle;}
.content {width: 80%; margin: auto; margin-bottom: 20px; margin-top: 20px;} .content {width: 80%; margin: auto; margin-bottom: 20px; margin-top: 20px;}
   
.testPass {color: green;} .testPass {color: green;}
.testFail {color: red; font-weight: bold;} .testFail {color: red; font-weight: bold;}
   
body { background-color: #339;} body { background-color: #339;}
.pgbackground { height: 100%} .pgbackground { height: 100%}
#Sidebar {float: right; padding-right: 80px;} #Sidebar {float: right; padding-right: 80px;}
.settings-menu {float: right;} .settings-menu {float: right;}
.pluginDetails {font-size: smaller;} .pluginDetails {font-size: smaller;}
#FFContainer {height: 100%;} #FFContainer {height: 100%;}
#contentArea {min-height: 100%; position: relative; padding: 0px; padding-bottom: 50px;} #contentArea {min-height: 100%; position: relative; padding: 0px; padding-bottom: 50px;}
#ContentWrap {width: 80%; margin: auto; background-color: white; border-radius: 5px; padding: 20px; box-shadow: 3px 3px #ccc; min-height: 70%; display: block; margin-bottom: 20px; } #ContentWrap {width: 80%; margin: auto; background-color: white; border-radius: 5px; padding: 20px; box-shadow: 3px 3px #ccc; min-height: 70%; display: block; margin-bottom: 20px; }
.navbar {margin-bottom: 0px !important; width: 100%; margin-left: 0px;} .navbar {margin-bottom: 0px !important; width: 100%; margin-left: 0px;}
.navbar-inner {margin-right:0px;} .navbar-inner {margin-right:0px;}
#NavContent {width: 80%; margin: auto;} #NavContent {width: 80%; margin: auto;}
.BreadCrumbs {display: block; margin: auto; font-size: smaller; width: 50%;} .BreadCrumbs {display: block; margin: auto; font-size: smaller; width: 50%;}
.NotificationArea {width: 60%; margin: auto; padding-bottom: 20px;} .NotificationArea {width: 60%; margin: auto; padding-bottom: 20px;}
.login-module {background-color: white; border-radius: 5px; padding: 20px; box-shadow: 3px 3px #ccc; margin-left: 20px; width: 70%;} .login-module {background-color: white; border-radius: 5px; padding: 20px; box-shadow: 3px 3px #ccc; margin-left: 20px; width: 70%;}
#mod_login input[type="text"], input[type="password"] {width: 100px;} #mod_login input[type="text"], input[type="password"] {width: 100px;}
#Sidebar {width: 18%; display: inline-block;} #Sidebar {width: 18%; display: inline-block;}
#PluginReadme h3 {margin-top: 50px;} #PluginReadme h3 {margin-top: 50px;}
#PluginReadme {margin-bottom: 20px;} #PluginReadme {margin-bottom: 20px;}
td.editicon {width:2%;} td.editicon {width:2%;}
td.delicon {width:2%;} td.delicon {width:2%;}
.blankCol {display: inline-block;} .blankCol {display: inline-block;}
   
#groupsMultiSelect input[type="checkbox"] {float: none; margin-left: 20px;} #groupsMultiSelect input[type="checkbox"] {float: none; margin-left: 20px;}
#FrmUsername {width: 100px;} #FrmUsername {width: 100px;}
#NavBarLoginForm input {margin-top: 0px; margin-bottom: 10px;} #NavBarLoginForm input {margin-top: 0px; margin-bottom: 10px;}
   
.frmEntryMissed {border: 1px red solid !important;} .frmEntryMissed {border: 1px red solid !important;}
   
.DisPwdTextMob {display: none;} .DisPwdTextMob {display: none;}
   
.strongPass {color: Green;} .strongPass {color: Green;}
.strongerPass {color: Green;} .strongerPass {color: Green;}
.mediocrePass {color: orange;} .mediocrePass {color: orange;}
.weakPass {color: red;} .weakPass {color: red;}
.veryweakPass {color: red;} .veryweakPass {color: red;}
   
   
.passViewNotif {font-size: small;} .passViewNotif {font-size: small;}
   
#SearchResBox {position: absolute; z-index: 9999; background-color: white; border: 1px solid; padding: 0px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; box-shadow: 1px 1px grey;} #SearchResBox {position: absolute; z-index: 9999; background-color: white; border: 1px solid; padding: 0px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; box-shadow: 1px 1px grey;}
.SearchResult {padding-left: 10px; padding-right: 2px; padding-bottom: 5px; padding-top: 5px;} .SearchResult {padding-left: 10px; padding-right: 2px; padding-bottom: 5px; padding-top: 5px;}
.SearchResult:hover {background-color: grey; color: white} .SearchResult:hover {background-color: grey; color: white}
.SearchResultActive {background-color: grey; color: white} .SearchResultActive {background-color: grey; color: white}
   
  input.passDisp, input.passDisp:focus {border: 0px; box-shadow: 0 0 0 0px; background: transparent; cursor: pointer; width: auto; padding: 0px; margin-bottom: 0px; height: auto; max-width: 100px;}