Bones
Code Helper
Posts: 131
Bones said 0 great things
|
Post by Bones on Jul 23, 2011 22:11:35 GMT -8
Browsers Tested: Firefox 3.6, IE9, Chrome 12 Description: This code was born from a request in Proboards Request. It offers the option to save the pending accounts data (email, IP, etc.) for future reference. Due to TOS restrictions on auto redirects this is a two-click process rather than one. <script type="text/javascript"> (function(opts){ var f,t,u if(!opts)opts={}; if(!opts.action || !/^(deny|approve|both)$/i.test(opts.action))opts.action="both"; opts.action2 = {deny:'Denied',approve:'Approved',both:'Approved and denied'}[opts.action.toLowerCase()] opts.to = "string" == typeof(opts.to)?opts.to.toLowerCase().split(',').concat([pb_username]):[pb_username] if(document.pendingForm && pb_action=="pendingmembers"){ f = document.getElementById('forumjump'); f = f.parentNode.insertBefore(document.createElement('span'),f); f.innerHTML = '<form method="post" action="/index.cgi?pendinglog='+(+new Date)+'" name="stingForm" id="stingForm" >' +'<input type="hidden" name="subject" value="Pending Members Log">' +'<input type="hidden" name="message" value="">' +'<input type="hidden" name="action" value="pmsend">' +'<input type="hidden" name="to" value="'+opts.to.join(',')+'" >' +'<input type="hidden" name="board" value="" disabled >' +'<input type="hidden" name="thread" value="" disabled >' +'</form>'; document.pendingForm.appendChild(document.createElement('span')).innerHTML = '<font size="1"> *'+ opts.action2 +' accounts will be logged to ' +(opts.board?'<a href="/?board=' +opts.board+(opts.thread?'&thread='+opts.thread:'') +'">'+opts.board+'</a>':'Instant Message') +'</font>'; document.stingForm.hSubmit = function(evbtn){ var t = (new Date()).toString() +"[table][tr][td][center][b]Name[/b][/center][/td][td][center][b]Email[/b][/center][/td][td] [center][b] Age [/b][/center][/td][td][center][b]IP[/b][/center][/td][td][center][b]Register Date[/b][/center][/td][/tr]" , u="",a,b,c=new Date(), d=new Date(), f=document.pendingForm; d.setDate(d.getDate()-1); for(a=0;a<f.elements.length;a++){ if(/user-(\w+)/.test(f.elements[a].name) && f.elements[a].checked && (b=f.elements[a].offsetParent.parentNode)){ u += "[tr][td] [link=http://"+ location.hostname + "/?action=viewprofile&user=" + RegExp.$1 + "]"+ RegExp.$1 +"[/link][/td]" +"[td] [email]" + b.cells[1].getElementsByTagName('a')[0].innerHTML + "[/email] [/td]" +"[td]" + (b.cells[2].innerText||b.cells[2].textContent) + "[/td]" +"[td]" + (b.cells[3].innerText||b.cells[3].textContent) + "[/td]" + "[td]" + (/(Yester|To)day/i.test(b.cells[4].innerHTML)? ((RegExp.$1=="To"?c.toLocaleDateString():d.toLocaleDateString())+ " at " + (b.cells[4].innerText||b.cells[4].textContent).split(" at ")[1]): (b.cells[4].innerText||b.cells[4].textContent)) +"[/td][/tr]"; f.elements[a].name.disabled=true; } } if(u.length){ a = this; a.message.value = (t + u + "[/table]" + (document.pendingForm.reason.value.length?"[quote" + ( opts.board && opts.thread?" author=Deny Reason board="+opts.board+" thread="+opts.thread+" post="+opts.thread+" time="+ (""+(+new Date)).substr(0,10):"") + "]" + pendingForm.reason.value + "[/quote]":"")); if(opts.board){ a.action.value="post"; a.board.disabled=false; a.board.value = opts.board; a.to.disabled = true; if(opts.thread){ a.thread.disabled = false; a.thread.value= opts.thread;} }else{a.board.disabled=true; a.thread.disabled=true; a.action.value = "pmsend"; } if(u.split(/\[tr\]/).length==2)a.subject.value = u.match(/(\w+)\[\/link\]/)[1] + " - " + (/(Yester|To)day/i.test(b.cells[4].innerHTML)? ((RegExp.$1=="To"?c.toLocaleDateString():d.toLocaleDateString())+ " at " + (b.cells[4].innerText||b.cells[4].textContent).split(" at ")[1]): (b.cells[4].innerText||b.cells[4].textContent)); a.subject.value = '['+(evbtn.target||evbtn.srcElement).value.split(' ')[0]+'] '+ a.subject.value; //workaround for chrome bug 30907 a.target = 'log'+(+new Date); if(window.open('',a.target)){ a.submit(); }else{if(!confirm('Log window failed to open, continue without saving log?')){ evbtn.returnValue=false; if(evbtn.preventDefault)evbtn.preventDefault(); if(evbtn.stopPropagation)evbtn.stopPropagation(); document.pendingForm.parentNode.insertBefore(document.createElement('div'),document.pendingForm.nextSibling).innerHTML = '<b>UBBC Log:</b><br><textarea>'+ a.message.value +'</textarea>' ; alert('The log has been copied to the page, copy and manually save before approving or denying the seleted account(s)') }} } } for(t = document.pendingForm.elements,u = t.length-1;u>0;u=u-1) if(t[u].type == "submit" ){ if(t[u].value.indexOf(opts.action.substr(0,1).toUpperCase() + opts.action.substr(1).toLowerCase())==0 || /both/.test(opts.action)) if(t[u].addEventListener)t[u].addEventListener('click',function(event){document.stingForm.hSubmit.call(document.stingForm,event)},false); else t[u].attachEvent('onclick', function(){document.stingForm.hSubmit.call(document.stingForm,window.event)}); } }else if(/\bpendinglog=\d+/.test(location.href) && document.postForm){ f=document.postForm; f.style.display = "none"; document.title="Log Pending Accounts"; t = f.parentNode.insertBefore(document.createElement('div'),f); t.innerHTML = '<table class="bordercolor" cellspacing="0" cellpadding="0" border="0" width="100%" ><tr><td>' +'<table width="100%" border="0" cellspacing="1" cellpadding="4">' +'<tr><td class="titlebg">Log Pending Account(s) '+(/^(\[\w+\])/.test(document.postForm.subject.value)?RegExp.$1:"")+'</td></tr>' +'<tr><td align="center" class="windowbg">This request will be logged<br><input type="button" value="OK" onclick="document.postForm.submit()"></td></tr>' +'</table></td></tr></table>'; if(f.thread && f.thread.enabled!=false){ u=f; while(u = u.nextSibling){if(u.nodeName == "TABLE" && u.className=="bordercolor" && /Topic Summary/.test(u.getElementsByTagName('td')[1].innerHTML)){u.style.display="none";break;}}} document.getElementById('forumjump').style.display="none"; } })(); </script> Usage: Install in global footer. If not edited then it will log all approved and denied accounts to your PM box. There are however options that can be added to make it log to a board as well as a specific thread as well as log only denials or approvals or both. the options are added to the last line like so })({board:'ssbtester',thread:84,action:'deny'});the above example would send all logs to thread 84 in the ssbtester board, logging only denied accounts. - if only the board id is specified then a new thread is created in that board [creates new thread]
- if the board id and the thread id is specified then a new reply is added to the specified thread. [replies to an existing thread]
- if the board id is not specified then log is instead sent to PM regardless of whatever else is specified, specifying nothing (no options added) will default to PM.
- the action can be used to specify which action to log, values can be "deny", "approve" or "both". If no action is specified or action is set to something other than the allowed three values then "both" will be used by default.
- if PM system is used for logging then a to can be added to specify multiple recipients to whom the PM will be sent. This will be a comma separated string of usernames:
})({to:"staff1, staff2,gmod", action:"deny"}) Make sure all entered user names are correct or the PM will fail to send
Notes: It is recommended if sending logs to a board or thread that the board be made staff-only since the logs will contain sensitive data. Edits:
- Aug, 6, 2011 - added a new "to" option so if PM system is used for logging then multiple recipients can be specified
- Mar 5, 2012 - added clearer info on log destination
'<font size="1"> *'+ opts.action2 +' accounts will be logged</font>';
becomes
'<font size="1"> *'+ opts.action2 +' accounts will be logged to ' +(opts.board?'<a href="/?board=' +opts.board+(opts.thread?'&thread='+opts.thread:'') +'">'+opts.board+'</a>':'Instant Message') +'</font>';
|
|