Post by Ross on Nov 8, 2005 12:55:04 GMT -8
Global Footer
This is basically just an updated version of the previous money hacks. However, it should stop users being able to change their own money and should also work with CrossFury or other Profile Codes
If you are unsure about the use of money on your forum, I'd recommend reading this thread
<script type="text/javascript">
<!--
/*
Money Hack v3 - Global footer
Created by Ross, Concept by Peter
This code cannot be reposted at anywhere other than ProBoards Support without permission.
This header must stay intact at all times.
*/
// The value of money a member should gain for each post
var MoneyPerPost = 5;
// What do you want to call your money?
var NameOfMoney = 'Money';
// The symbol that will appear next to the money
var SymbolOfMoney = '£';
// No need to edit below
var re = /\[M:(-)?(\d+)\]/im
function updateMon() {
var monChange = document.getElementById('monChange');
var curMon = document.getElementById('monDisplay');
var monType = document.getElementById('monType');
mon = parseInt(curMon.value.replace( SymbolOfMoney , '' ),10) + parseInt( ( ( monType.value == '-' ) ? '-' : '' ) + monChange.value, 10 )
monChange.value = 0;
if(isNaN(mon)) {
alert('You must enter a numerical value')
return false;
}
curMon.value = SymbolOfMoney + mon;
return true;
}
function fNum(num){
if(!isNaN(num)){
num = num.toLocaleString().replace(/\.\d+/, "");
} else {
num = 0;
}
return num;
}
function saveMon() {
updateMon();
var newMon = document.getElementById('monDisplay').value.replace( SymbolOfMoney , '' );
newMon -= (parseInt((document.modifyForm.posts.value) * MoneyPerPost, 10));
document.modifyForm.customtitle.value += '[M:'+newMon+']';
return true;
}
var td = document.getElementsByTagName('td');
for(i=0; i<td.length; i++) {
if(td.item(i).width == '20%' && td.item(i).vAlign == 'top' && td.item(i).parentNode.innerHTML.match(/Posts: (.+?)</)) {
curMon = (RegExp.$1.replace(/,/g,'') * MoneyPerPost);
curMon += td.item(i).innerHTML.match(re)? parseInt((RegExp.$1+RegExp.$2), 10) : 0;
if(td.item(i).lastChild.nodeName.toLowerCase() != 'br')
td.item(i).appendChild(document.createElement('br'));
td.item(i).appendChild(document.createTextNode(NameOfMoney +': '+ SymbolOfMoney + fNum(curMon)));
td.item(i).innerHTML = td.item(i).innerHTML.replace(/<br>\[M:(-)?(\d+)\](<br>member is)/i,'$3').replace(/(<br>(.+?))\[M:(-)?(\d+)\](<br>)/i,'$1$5').replace(/\[M:(-)?(\d+)\]/gim,'');
}
else if(location.href.match(/ion=viewpro/) && td.item(i).width == '25%' && td.item(i).innerHTML.match(/>Posts:</)) {
var monTitle = document.createElement('font');
monTitle.size = '2';
monTitle.appendChild(document.createTextNode(NameOfMoney+':'));
var userMon = document.createElement('font');
userMon.size = '2';
userMon.appendChild(document.createTextNode(SymbolOfMoney+fNum(curMon)));
monRow = td.item(i).parentNode.parentNode.insertRow(6);
monRow.insertCell(0).appendChild(monTitle);
monRow.insertCell(1).appendChild(userMon);
break;
}
}
if(document.modifyForm && document.modifyForm.customtitle) {
if(document.modifyForm.personaltext.value.match(re) && !document.modifyForm.customtitle.value.match(re))
{
document.modifyForm.customtitle.value += '[M:'+RegExp.$1+RegExp.$2+']';
document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace(re,'');
}
curMon = document.modifyForm.customtitle.value.match(re)? parseInt(RegExp.$1+RegExp.$2, 10) : 0;
Posts = document.modifyForm.posts.value.match(/(-)?(\d+)/)? parseInt((RegExp.$1+RegExp.$2), 10) : 0;
curMon += (Posts * MoneyPerPost)
document.modifyForm.customtitle.value = document.modifyForm.customtitle.value.replace(re,'');
document.modifyForm.customtitle.maxLength = 490;
var display = document.createElement('input');
display.type = 'text';
display.id = 'monDisplay';
display.size = parseInt(curMon.toString().length, 10) + 2;
display.disabled = true;
display.value = SymbolOfMoney + curMon;
var type = document.createElement('select');
type.id = 'monType';
type.appendChild(document.createElement('option'));
type.firstChild.appendChild(document.createTextNode('+'));
type.appendChild(document.createElement('option'));
type.lastChild.appendChild(document.createTextNode('-'));
type.lastChild.value = '-';
var mon = document.createElement('input');
mon.type = 'text';
mon.id = 'monChange';
mon.size = 5;
mon.value = 0;
var update = document.createElement('input');
update.type = 'button';
update.value = 'Update';
update.onclick = function(){ updateMon(); };
var editMon = document.createElement('font');
editMon.appendChild(type);
editMon.appendChild(document.createTextNode(' '));
editMon.appendChild(mon);
editMon.appendChild(document.createTextNode(' '));
editMon.appendChild(update);
var newTitle = document.createElement('font');
newTitle.size = '2';
newTitle.appendChild(document.createTextNode(NameOfMoney +': '));
newTitle.appendChild(display);
var newDes = document.createElement('font');
newDes.size = '1';
newDes.appendChild(document.createTextNode('Here you can edit the amount of '+NameOfMoney+' a member has. Just enter the value of ' +NameOfMoney+ ' to add or subtract.'));
var target = document.modifyForm.customtitle.parentNode.parentNode.parentNode.parentNode.insertRow(2);
target.insertCell(0).appendChild(newTitle);
target.insertCell(1).appendChild(editMon)
target.insertCell(2).appendChild(newDes);
document.getElementsByName('profileaction').item(0).onclick = function() { saveMon(); };
}
//-->
</script>
Note for When Removing this Code:
This code stores information in the "Custom Title" field of the users profile. If at some point you decide to remove this code or for whatever reason the code stops working then that information will remain visible in the custom title until you or the user removes it. This information would look something like: [M:100]
Edit: Bug Fix, 19th Nov '05
Edit: Security Update, 13th Jan '06
This is basically just an updated version of the previous money hacks. However, it should stop users being able to change their own money and should also work with CrossFury or other Profile Codes
If you are unsure about the use of money on your forum, I'd recommend reading this thread
<script type="text/javascript">
<!--
/*
Money Hack v3 - Global footer
Created by Ross, Concept by Peter
This code cannot be reposted at anywhere other than ProBoards Support without permission.
This header must stay intact at all times.
*/
// The value of money a member should gain for each post
var MoneyPerPost = 5;
// What do you want to call your money?
var NameOfMoney = 'Money';
// The symbol that will appear next to the money
var SymbolOfMoney = '£';
// No need to edit below
var re = /\[M:(-)?(\d+)\]/im
function updateMon() {
var monChange = document.getElementById('monChange');
var curMon = document.getElementById('monDisplay');
var monType = document.getElementById('monType');
mon = parseInt(curMon.value.replace( SymbolOfMoney , '' ),10) + parseInt( ( ( monType.value == '-' ) ? '-' : '' ) + monChange.value, 10 )
monChange.value = 0;
if(isNaN(mon)) {
alert('You must enter a numerical value')
return false;
}
curMon.value = SymbolOfMoney + mon;
return true;
}
function fNum(num){
if(!isNaN(num)){
num = num.toLocaleString().replace(/\.\d+/, "");
} else {
num = 0;
}
return num;
}
function saveMon() {
updateMon();
var newMon = document.getElementById('monDisplay').value.replace( SymbolOfMoney , '' );
newMon -= (parseInt((document.modifyForm.posts.value) * MoneyPerPost, 10));
document.modifyForm.customtitle.value += '[M:'+newMon+']';
return true;
}
var td = document.getElementsByTagName('td');
for(i=0; i<td.length; i++) {
if(td.item(i).width == '20%' && td.item(i).vAlign == 'top' && td.item(i).parentNode.innerHTML.match(/Posts: (.+?)</)) {
curMon = (RegExp.$1.replace(/,/g,'') * MoneyPerPost);
curMon += td.item(i).innerHTML.match(re)? parseInt((RegExp.$1+RegExp.$2), 10) : 0;
if(td.item(i).lastChild.nodeName.toLowerCase() != 'br')
td.item(i).appendChild(document.createElement('br'));
td.item(i).appendChild(document.createTextNode(NameOfMoney +': '+ SymbolOfMoney + fNum(curMon)));
td.item(i).innerHTML = td.item(i).innerHTML.replace(/<br>\[M:(-)?(\d+)\](<br>member is)/i,'$3').replace(/(<br>(.+?))\[M:(-)?(\d+)\](<br>)/i,'$1$5').replace(/\[M:(-)?(\d+)\]/gim,'');
}
else if(location.href.match(/ion=viewpro/) && td.item(i).width == '25%' && td.item(i).innerHTML.match(/>Posts:</)) {
var monTitle = document.createElement('font');
monTitle.size = '2';
monTitle.appendChild(document.createTextNode(NameOfMoney+':'));
var userMon = document.createElement('font');
userMon.size = '2';
userMon.appendChild(document.createTextNode(SymbolOfMoney+fNum(curMon)));
monRow = td.item(i).parentNode.parentNode.insertRow(6);
monRow.insertCell(0).appendChild(monTitle);
monRow.insertCell(1).appendChild(userMon);
break;
}
}
if(document.modifyForm && document.modifyForm.customtitle) {
if(document.modifyForm.personaltext.value.match(re) && !document.modifyForm.customtitle.value.match(re))
{
document.modifyForm.customtitle.value += '[M:'+RegExp.$1+RegExp.$2+']';
document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace(re,'');
}
curMon = document.modifyForm.customtitle.value.match(re)? parseInt(RegExp.$1+RegExp.$2, 10) : 0;
Posts = document.modifyForm.posts.value.match(/(-)?(\d+)/)? parseInt((RegExp.$1+RegExp.$2), 10) : 0;
curMon += (Posts * MoneyPerPost)
document.modifyForm.customtitle.value = document.modifyForm.customtitle.value.replace(re,'');
document.modifyForm.customtitle.maxLength = 490;
var display = document.createElement('input');
display.type = 'text';
display.id = 'monDisplay';
display.size = parseInt(curMon.toString().length, 10) + 2;
display.disabled = true;
display.value = SymbolOfMoney + curMon;
var type = document.createElement('select');
type.id = 'monType';
type.appendChild(document.createElement('option'));
type.firstChild.appendChild(document.createTextNode('+'));
type.appendChild(document.createElement('option'));
type.lastChild.appendChild(document.createTextNode('-'));
type.lastChild.value = '-';
var mon = document.createElement('input');
mon.type = 'text';
mon.id = 'monChange';
mon.size = 5;
mon.value = 0;
var update = document.createElement('input');
update.type = 'button';
update.value = 'Update';
update.onclick = function(){ updateMon(); };
var editMon = document.createElement('font');
editMon.appendChild(type);
editMon.appendChild(document.createTextNode(' '));
editMon.appendChild(mon);
editMon.appendChild(document.createTextNode(' '));
editMon.appendChild(update);
var newTitle = document.createElement('font');
newTitle.size = '2';
newTitle.appendChild(document.createTextNode(NameOfMoney +': '));
newTitle.appendChild(display);
var newDes = document.createElement('font');
newDes.size = '1';
newDes.appendChild(document.createTextNode('Here you can edit the amount of '+NameOfMoney+' a member has. Just enter the value of ' +NameOfMoney+ ' to add or subtract.'));
var target = document.modifyForm.customtitle.parentNode.parentNode.parentNode.parentNode.insertRow(2);
target.insertCell(0).appendChild(newTitle);
target.insertCell(1).appendChild(editMon)
target.insertCell(2).appendChild(newDes);
document.getElementsByName('profileaction').item(0).onclick = function() { saveMon(); };
}
//-->
</script>
Note for When Removing this Code:
This code stores information in the "Custom Title" field of the users profile. If at some point you decide to remove this code or for whatever reason the code stops working then that information will remain visible in the custom title until you or the user removes it. This information would look something like: [M:100]
Edit: Bug Fix, 19th Nov '05
Edit: Security Update, 13th Jan '06