Post by Isa The Great on Oct 9, 2010 21:15:01 GMT -5
BOTTOM OF GLOBAL FOOTER
<script type="text/javascript">
<!--
/* Post as Alias v1.3 - Eton Bones */
function saveLogin(event){
var minutes=document.getElementsByName('minutes');
var user=document.getElementsByName('username')[0];
var now=new Date();
try{
minutes=parseInt(minutes[0].options[minutes[0].options.selectedIndex].value);
minutes=(minutes==-1)?35788933-now.getTime()/1000/60:minutes;
var expires=minutes*1000*60+now.getTime();
if( Boolean(document.getElementById('saveLogin').checked)==true||(user.value.length && user.value in logins))
sdc("litmp",expires)
else
sdc("litemp",expires)
}catch(err){
errH(err)
}finally{
return true;
}
}
function setAlias(){
var u = Boolean(user.value.length && (user.value in logins));
document.getElementById('saveLogin').checked= u
if(u){
document.getElementById('nopass').checked= (logins[user.value].password=='')
if(document.getElementById('nopass').checked){sdc("linopass","1","Sun, 17 Jan 2038 00:00:02 GMT")}else{sdc("linopass")}
}else if(document.getElementById('saveLogin').checked){
document.getElementById('nopass').checked=(gdc('linopass')=='1')
}else{
document.getElementById('nopass').checked=false
}
}
function sdc(name,val,expire){
if('undefined'==typeof val){val='';if('undefined'==typeof expire)expire=new Date(document.lastModified).toGMTString()}
document.cookie= name+'='+val +';'+(expire?' ;expires='+expire+';':'')
}
function gdc(name){
if('undefined'==typeof name)return ''
var t= document.cookie.match(new RegExp('\\b'+name+'=([^;]+)','i'))
return (t&&t.length>1)?t[1]:''
}
function edc(){
if(!confirm('All cookies associated with '+location.host+' are about to be deleted\n Select OK to continue or CANCEL to abort this action'))return
C=document.cookie.split("; ");
for(d="."+location.host;d;d=(""+d).substr(1).match(/\..*$/))
for(sl=0;sl<2;++sl)
for(p="/"+ location.pathname;p;p=p.substring(0,p.lastIndexOf('/')))
for(i in C)
if(c=C[i]){
document.cookie=c+"; domain="+d.slice(sl)+"; path="+p.slice(1)+"/"+"; expires="+new Date((new Date).getTime()-1e11).toGMTString()
}
}
function errH(e){
if(window['debugAlias'])debugAlias(e)
}
function protectPost(){
if(document.getElementById('accounts'))
document.getElementById('accounts').disabled=true;
var msg=document.getElementsByName('message')
if(msg.length){
msg=msg[0]
for(var count=0;count<msg.form.elements.length;count++){
var inp=msg.form.elements[count]
if(inp.tagName && ((inp.tagName.match(/input/i) && !inp.type.match(/hidden|submit/i))||inp.tagName.match(/textarea/i))){
addEvent(inp,"propertychange",protectPost,false,true);
addEvent(inp,"input",protectPost,false,true);
}
}
}
}
function showAccounts(cell,pos,frm){
var opts= document.createElement('div'); opts.id="logonalias"
cell.insertBefore(opts, cell.firstChild)
opts=document.createElement('select');
opts.id="accounts";opts.frm=frm
opts.onchange=function(){
var logal=document.getElementById('logonalias')
if(pb_username==this.options[this.selectedIndex].value){logal.innerHTML=''; return}
if(logins[this.options[this.selectedIndex].value].password.length){
logal.innerHTML=''
if(pb_username!="Guest"){sdc("li_prev",pb_username);if((pb_username in logins)&&logins[pb_username].password.length==0)sdc('li_pass',gdc('pass'));}
logins.setUser(this.options[this.selectedIndex].value);
}else{
var ht = '<form onsubmit="disable(this);saveLogin();sdc(\'li_prev\',pb_username);sdc(\'li_pass\',gdc(\'pass\'))" name="loginaliasform" method="post" action="/index.cgi">'
ht+= '<input type="hidden" value="login2" name="action"/><input type="hidden" value="alias='+this.options[this.selectedIndex].value+'&'+location.search.replace(/\?/,'')+'" name="redirect"/>'
ht+= '<center><table width="500" cellspacing="3" cellpadding="0" border="0"><tbody><tr><td width="500" colspan="2">'
ht+= '<b>Error:</b> No password saved for the '+this.options[this.selectedIndex].value+' alias. Please login below<br/>'
ht+='<b>Note:</b>The logon duration for this alias will change depending on the time period selected below<br /><br /><br/></td></tr>'
ht+= '<tr><td width="35%">Username:</td><td width="35%"><input type="text" maxlength="18" tabindex="1" size="20" name="username" value="'+this.options[this.selectedIndex].value+'" readonly /></td><td width="30%"><a href="/index.cgi?action=register">Create New Account</a></td></tr>'
ht+= '<tr><td width="35%">Password:</td><td width="35%"><input type="password" tabindex="2" size="20" name="password"/></td><td width="30%"><a href="/index.cgi?action=forgotpassword">Forgot Your Password?</a></td></tr>'
ht+= '<tr><td width="35%">Stay logged in for:</td><td width="35%"><select tabindex="3" name="minutes"><option value="15">15 minutes</option><option value="30">30 minutes</option><option value="60">1 hour</option>'
ht+= '<option value="120">2 hours</option><option value="240">4 hours</option><option value="360">6 hours</option><option value="720">12 hours</option><option value="1440">1 day</option>'
ht+= '<option value="10080">1 week</option><option selected="1" value="-1">Forever</option></select></td><td width="30%"/></tr><tr><td width="35%"/><td width="35%"><input type="submit" tabindex="4" value=" Login "/></td>'
ht+= '<td width="30%"/></tr></tbody></table></center></form>'
logal.innerHTML = ht
logal.innerHTML+= '<input type="checkbox" value="true" id="saveLogin" style="display:none;"/>'
}
}
if(!(pb_username in logins)){
opts.options[opts.options.length]=new Option("Current User",pb_username);
opts.options[opts.options.length-1].selected=true;
}
for(key in logins){
if(key.substr(0,3)!="li_" && typeof(logins[key])!="function"){
opts.options[opts.options.length]=new Option(logins[key].displayname+" (username:"+key+")",key);
if(key==pb_username) opts.options[opts.options.length-1].selected=true;
}
}
var accountInfo=document.createElement('a');
accountInfo.appendChild(document.createTextNode('more details...'));
var f=document.createElement('sub');
accountInfo.href="javascript:void(0)";accountInfo.onclick=accountDetails;
cell.appendChild(opts);
f.appendChild(document.createTextNode(' available accounts:'+logins.li_userCount+' ('));
f.appendChild(accountInfo);f.appendChild(document.createTextNode(')'));
cell.appendChild(f);
for(var count=0;count< frm.elements.length;count++){
var inp=frm.elements[count];
if(inp.tagName && ((inp.tagName.match(/input/i) && !inp.type.match(/hidden|submit/i))||inp.tagName.match(/textarea/i))){
addEvent(inp,"propertychange",protectPost,false);
addEvent(inp,"input",protectPost,false);
}
}
if(gdc('li_prev')!=''){
var inp=document.createElement('input')
inp.type='button';inp.id="prevaccount"
inp.value='Return to '+gdc('li_prev')+' account'
inp.onclick=function(){logins.setUser(gdc('li_prev'),false);sdc('li_prev');sdc('li_pass')}
document.getElementById('accounts').parentNode.replaceChild(inp,document.getElementById('accounts'))
}
}
function accountDetails(){
if(pa_popWin && pa_popWin.closed) {pa_popWin=null;}
if(pa_popWin && pa_popWin.document.getElementsByTagName('table').length>2) {
pa_popWin.close();
pa_popWin=null;
}
if(pa_popWin==null ){
pa_popWin=window.open("/index.cgi?action=viewthreadposts","popWindow","directories=0,location=0,menubar=0,resizable=1 , scrollbars=1,status=1,toolbar=0,top=100,left=100,width=400,height=275");
if(pa_popWin==null){
alert("This feature won't function correctly with a popup blocker active. Try disabling any popup blockers or try holding CTRL key while clicking link to bypass blocker");
return false;
}
if(document.attachEvent){
var bool=false;
do{
try{pa_popWin.document.body.getElementsByTagName('table');bool=true;}catch(e){}
}while(!bool)
}else{
pa_popWin.onload=arguments.callee;
return true;
}
}
var y="";var d=new Date();
try{
var source=pa_popWin.document.body.getElementsByTagName('table');
}catch(e){
alert('Unable to display available accounts info');
errH({message:'WARNING:Unable to display available accounts info'})
pa_popWin.close(); pa_popWin=null;
return false;
}
pa_popWin.opener.name="paaccounts"; pa_popWin.document.title="Available Accounts";
source[1].getElementsByTagName('b')[0].innerHTML="Available Accounts";
source=source[1].rows[1].cells[0];
var tdS1=document.createElement('td');
var tdS2=document.createElement('td');
for(key in logins){
if(key.substr(0,3)!="li_" && typeof(logins[key])!="function"){
d.setTime(logins[key].expire);var dname;
dname=document.createElement('a');dname.href='index.cgi?action=viewprofile&user='+key;
dname.appendChild(document.createTextNode(logins[key].displayname));
dname.setAttribute("target","paaccounts");dname.onClick='opener.focus();setTimeout("self.close()",1);';
tdS1.appendChild(document.createElement('br'));tdS2.appendChild(document.createElement('br'));
tdS1.appendChild(dname);tdS2.appendChild(document.createTextNode(timeLeft(logins[key].expire)));
}
}
var w1=tdS1.innerHTML.replace(/target=/gim,"onClick='opener.focus(); setTimeout(\042self.close()\042,1);' target=").split(/<br\/?>/i);
var w2=tdS2.innerHTML.split(/<br\/?>/i);
for(var count=0;count<w1.length;count++){
if(w1[count].match(/href=/i))
y+="<tr><td width='40%' align='right'>"+w1[count]+"</td><td width='60%' align='center'>"+w2[count]+"</td></tr>";
}
if(y.length){
z="<span align='center'><br/><br/><a href='javascript:opener.logins.clearAllUsers();";
z+="opener.location.href=opener.location.href;opener.focus();setTimeout(\042self.close()\042,1);' >Clear all saved account(s)</a></span>";
}else{
z="";
}
source.innerHTML='<center><font size="2">Total accounts:'+logins.li_userCount+'<br><table width="70%" cellspacing="0" cellpadding="3" border="0" _base_target="paaccounts"><tbody ><tr _base_target="paaccounts"><td width="40%" align="right" _base_target="paaccounts"><font size="2"><u><i>User</i></u></font></td><td width="60%" align="center" _base_target="paaccounts"><font size="2"><u><i>Account Expiration</i></u></font></td></tr>'+y+'</tbody></table></font>'+z+'</center>';
setTimeout('pa_popWin.focus()',1);
addEvent(window,"unload",cleanScreen,true);
}
function cleanScreen(){if(pa_popWin!=null)pa_popWin.close();pa_popWin=null;}
function timeLeft(m){
var years,months,weeks,days,hours,minutes,tmp3;
years=months=weeks=days=hours=minutes=0; tmp3="";
var Now=new Date();var date=new Date(); date.setTime(m);
var hour=1000*60*60; var day=hour*24;
var ms=date-Now;
if(ms<0){ms=Math.abs(ms); tmp3+="-";}
years=Math.floor(ms/(day*365)); ms-=day*365*years;
months=Math.floor(ms/(day*30)); ms-=day*30*months;
if(months==12){months=0;years++}
weeks=Math.floor(ms/(day*7)); ms-=day*7*weeks;
days=Math.floor(ms/day); ms=ms-day*days;
if(years==0 && months==0 && weeks==0 && days==0){
hours=Math.floor(ms/hour); ms=ms-hour*hours;
minutes=Math.ceil(ms/(hour/60)); ms=ms-minutes*hour/60;
if(minutes==60){minutes=0;hours++}
if(hours==24){hours=0;days++}
}
years=(years)?years+" year"+((years!=1)?"s ":' '):'';
months=(months)?months+" month"+((months!=1)?"s ":' '):'';
weeks=(weeks)?weeks+" week"+((weeks!=1)?"s ":' '):'';
days=(days)?days+" day"+((days!=1)?"s ":' '):'';
hours=(hours)?hours+" hour"+((hours!=1)?"s ":' '):'';
minutes=(minutes)?minutes+" minute"+((minutes!=1)?"s ":' '):'';
if(String(minutes+hours+days+weeks+months+years).length==0)
minutes="less than 1 minute ";
if(years.length)weeks=days=hours=minutes="";
return tmp3+years+months+weeks+days+hours+minutes;
}
function addEvent(node,evName,func,capture,remove){
capture=(capture)?capture:false;
remove=(remove)?remove:false
if(node.attachEvent){
if(remove)
node.detachEvent("on"+evName,func);
else
node.attachEvent("on"+evName,func);
}else if(node.addEventListener){
if(remove)
node.removeEventListener(evName,func,capture);
else
node.addEventListener(evName,func,capture);
}else{
if(remove)
eval("node.on"+evName+"=null");
else
eval("node.on"+evName+"=func");
}
}
function LoginInfo(){
this.li_noAlias={count:0};
this.li_cookies=["liuser","litime","lipass","lidn","li_prev","li_pass","litmp","litemp","lisession","linopass"]
this.clearAllUsers=function(){
this.li_count=0; var p= new Date(document.lastModified).toGMTString()+";";
for(var t in this.li_cookies)
sdc(this.li_cookies[t]);
}
this.save=function(){
if(this.li_userCount || this.li_noAlias.count){
var users,expires,passwords,dnames;
users=expires=passwords=dnames="";
var cookieExpire=0; var session=(gdc('lisession')=='1')?true:false
for(var k in this){
if((k.substr(0,3)!="li_" || k.match(/li_noAlias/)) && typeof(this[k])!="function"){
var na=k.match(/li_noAlias/)
if(na){
for(var j in this.li_noAlias){
if(j!="count" && !(j in this)){
users+="\n\x07"+j;
expires+="\n"+this.li_noAlias[j].expire;
if(parseInt(this.li_noAlias[j].expire)>cookieExpire)cookieExpire= parseInt(this.li_noAlias[j].expire);
passwords+="\n"+this.li_noAlias[j].password;
dnames+="\n"+this.li_noAlias[j].displayname;
}
}
}else{
users+="\n"+k;
expires+="\n"+this[k].expire;
if(parseInt(this[k].expire)>cookieExpire)cookieExpire= parseInt(this[k].expire);
passwords+="\n"+this[k].password;
dnames+="\n"+this[k].displayname;
}
}
}
cookieExpiry=new Date();cookieExpiry.setTime(cookieExpire); cookieExpiry=cookieExpiry.toGMTString()
sdc("liuser", escape(users.replace(/^\n/,"")),((!session)?cookieExpiry:void(0)))
sdc("litime", escape(expires.replace(/^\n/,"")),((!session)?cookieExpiry:void(0)))
sdc("lipass", escape(passwords.replace(/^\n/,"")),((!session)?cookieExpiry:void(0)))
sdc("lidn", escape(dnames.replace(/^\n/,"")),((!session)?cookieExpiry:void(0)))
}else{
this.clearAllUsers();
}
}
var usertmp=gdc('litmp');
var usertemp=gdc('litemp');
var usersdn=gdc('lidn');
var users=gdc('liuser');
var userstime=gdc('litime');
var userspass=gdc('lipass');
var now=new Date();
this.li_userCount=0;
if(users.length){
users=unescape(users).split('\n');
userstime=unescape(userstime).split('\n');
userspass=unescape(userspass).split('\n');
usersdn=unescape(usersdn).split('\n');
for(count=0;count<users.length;count++){
if(now.getTime() < userstime[count]){
if(users[count].indexOf("\x07")==0){
if(!(users[count] in this.li_noAlias))this.li_noAlias.count++;
this.li_noAlias[users[count].substr(1)]= {expire:userstime[count],password:userspass[count],displayname:usersdn[count]}
}else{
if(!(users[count] in this))this.li_userCount++;
this[users[count]]= {expire:userstime[count],password:((userspass[count] && userspass[count].length)?userspass[count]:''),displayname:usersdn[count]}
}
}else if(pb_username!="Guest" && pb_username!=users[count]){
alert('The logon for account '+users[count]+' has expired.\nIf you wish to have that account available for posting\nyou must log back into that account');
errH({message:'WARNING:The logon for account '+users[count]+' has expired.<br>Time:'+new Date()+'<br>Auto-logout:'+new Date(parseInt(userstime[count]))})
}
}
}
if(pb_username!="Guest"){
if(usertmp){
if(!(pb_username in this))this.li_userCount++;
this[pb_username]= {expire:usertmp,password:((gdc('linopass')=='1')?'':unescape(gdc('pass'))),displayname:pb_displayname}
sdc("litmp")
}else if(usertemp){
if(!(pb_username in this.li_noAlias))this.li_noAlias.count++;
this.li_noAlias[pb_username]= {expire:usertemp,password:unescape(gdc('pass')),displayname:pb_displayname}
sdc("litemp")
}
}else{
if(!(document.loginform && document.loginform.redirect && document.loginform.redirect.value.indexOf('alias=')==0))
{sdc("li_prev");sdc('li_pass');}
}
this.save();
this.setUser=function(username,isAlias){
if(username==pb_username)return;
function nocred(){
alert("Error!\nCould not find login credentials for "+username+".\nUnable to set requested login");
errH({message:'WARNING:Could not find login credentials for '+username+'. Unable to set requested login'})
if(gdc("li_prev")==username) sdc("li_prev")
}
var pass,exp;
isAlias=("undefined"==typeof isAlias)?true:false;
if(!(username in this)){
if(!(username in this.li_noAlias)){
nocred();return
}else{
pass=this.li_noAlias[username].password
exp=this.li_noAlias[username].expire
}
}else{
exp=this[username].expire
if(this[username].password.length==0){
if(gdc('li_pass').length){pass=gdc('li_pass');}else{nocred();return}
}else{
pass=this[username].password
}
}
sdc('li_pass')
var xdate=new Date(); xdate.setTime(exp);
sdc("user",username,xdate.toGMTString())
sdc("pass",pass,xdate.toGMTString())
window.location.href=window.location.href.replace(/(alias=\w+)/,((isAlias)?'$1':'')).replace(/\?/,"?"+((isAlias)?"ali as= "+username+"&":""))
}
}
function createCheck(tr,checked,id,caption,title){
var chk=document.createElement('input');chk.type="checkbox";
checked=(('function'==typeof checked)?checked():checked)
chk.checked=chk.value=checked; chk.id=id;
if(tr.firstChild.nextSibling.getElementsByTagName('input').length)
tr.firstChild.nextSibling.appendChild(document.createElement('br'));
tr.firstChild.nextSibling.appendChild(chk);
chk.parentNode.appendChild(document.createElement('span'));
chk.parentNode.lastChild.appendChild(document.createTextNode(caption));
chk.title=chk.alt=title;
chk.nextSibling.title=chk.nextSibling.alt=title;
return chk
}
try{
var logins=new LoginInfo(); var pa_popWin=null;
var xWin=null;
if(document.loginform){
var minutes=document.getElementsByName('minutes')[0];
var user=document.getElementsByName('username')[0];
var tr=minutes.parentNode.parentNode.parentNode.parentNode.insertRow(minutes.parentNode.parentNode.rowIndex+1);
while(tr.cells.length<3){tr.insertCell(-1);tr.lastChild.width=tr.previousSibling.cells[tr.cells.length-1].width;}
createCheck(tr,false,'saveLogin','Include as Alias','Include this login in my list of aliases').onclick=function(){
if(Boolean(this.checked)==false && (user.value.length && (user.value in logins))){
delete logins[user.value];logins.li_userCount--;logins.save();
this.parentNode.nextSibling.firstChild.innerHTML = 'Clear aliases now['+logins.li_userCount+']';
this.parentNode.nextSibling.firstChild.style.display.style=(logins.li_userCount)?'':'none';
this.parentNode.nextSibling.firstChild.title= "Aliases: "+unescape(gdc('liuser')).split('\n').join();
}
}
var cl=document.createElement('a');
cl.href="javascript:void(0)";cl.onclick=function(){logins.clearAllUsers();this.style.display='none';}
cl.appendChild(document.createTextNode('Clear aliases now['+logins.li_userCount+']'))
tr.lastChild.appendChild(cl);
if(logins.li_userCount<1){
cl.style.display="none";
}else{
cl.title="Aliases: "+unescape(gdc('liuser')).split('\n').join();
cl.title=cl.title.replace(/\07[^,]+,?/g,"")
}
createCheck(tr,function(){return (gdc('lisession')!='')},'sessionOnly','Clear aliases on close', 'Clear all aliases when browser closes').onclick=function(){
if(this.checked)
sdc("lisession","1")
else
sdc("lisession")
}
createCheck(tr,function(){return (gdc('linopass')!='')},'nopass','Require alias password', 'Require password each time this alias is to be used (extra security for those on a shared computer)').onclick=function(){
if(this.checked)
sdc("linopass","1","Sun, 17 Jan 2038 00:00:02 GMT")
else
sdc("linopass")
}
addEvent(document.loginform,"submit",saveLogin)
addEvent(user,"change",setAlias)
addEvent(user,"keyup",setAlias)
}
if((logins.li_userCount>1 || (logins.li_userCount==1 && (pb_username in logins.li_noAlias)) || gdc('li_prev').length)){
if(document.postForm ){
var row=document.postForm.subject.parentNode.parentNode;
var newrow=row.cloneNode(true);
if(!document.postForm.guestname){
row.parentNode.insertBefore(newrow,row);
newrow.cells[0].innerHTML="<b>Post as...<\/b>";
newrow.cells[1].innerHTML="<\!-- -\->";
showAccounts(newrow.cells[1],0,document.postForm);
}
}else if(document.getElementsByName('message').length ){
var qrmsg=document.getElementsByName('message')[0];
var acct=qrmsg.form.parentNode.parentNode.parentNode;
acct=acct.parentNode.insertRow(1);
acct=acct.insertCell(-1); acct.className="windowbg";
acct.innerHTML="<b>Post as...<\/b>";
showAccounts(acct,1,qrmsg.form);
var userprevious=gdc('li_prev');
if(userprevious.length>0 && (document.getElementById('accounts')||document.getElementById('prevaccount'))&& document.getElementsByName('message').length){
document.getElementsByName('message')[0].focus();
if(location.href.match(/\?alias=/)){
timeleft= timeLeft(logins[pb_username].expire)
if(!timeleft.match(/years?|months?|weeks?|days?|hours?/))
if(timeleft.match(/(\d+)\s+minutes?/) && RegExp.$1<5)
alert('WARNING!\nThe '+pb_displayname+'('+pb_username+') account has '+timeLeft(logins[pb_username].expire)+' left before logon expires')
delete timeleft
}
}
}
}
if("undefined"==typeof(document.postForm) && !location.href.match(/\?alias=/)){
var userprevious=unescape(gdc('li_prev'));
if(userprevious.length){
sdc("li_prev")
if(pb_username!="Guest" && pb_username!=userprevious)
doConfirm('You will now be returned to the '+userprevious+' account.\n Select OK to continue or CANCEL to remain logged in as '+pb_username,"javascript:logins.setUser(userprevious,false)");
sdc('li_prev');sdc('li_pass');
}
}
}catch(e){
errH(e)
}
/* CHANGE LOG:
v1.1
-------------------------------------------
-Removed unhandled error alerts since they were annoying. An optional debug script must now be inserted in global header to collect any errors generated by the main script.
+Fixed bug where typing a username that was already an alias didn't auto-checkmark the "include as alias" if the browser's password auto-fill feature was enabled
+Unchecking the "include as alias" while logging in an account already in the alias list will now remove that account from the list of aliases
+Fixed bug where typing in subject or message field did not auto-disable the account selector
+Added a button to return to previous account if user changed their mind and decided not to make the post.
v1.2
-------------------------------------------
+Added option to require password when when logging on an alias (security on shared computer)
v1.3
-------------------------------------------
+added notification if switching to an alias with less than 5 minutes left on logon
+tweaked code structure and optimization
*/
//-->
</script>