Simple Machine Codes
March 19, 2010, 05:55:30 pm
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to SMC, the best place for your SMF For Free Codes
 
  Home Help Search Arcade Affiliates Code Index Staff List Calendar Members Login Register  

Certain Amount of Posts to View Board


Pages: [1]   Go Down
  Print  
Author Topic: Certain Amount of Posts to View Board  (Read 142 times)
0 Members and 1 Guest are viewing this topic.
Agent Moose
Administrator

Offline Offline

Gender: Male
Posts: 2,668



View Profile WWW
« on: May 10, 2008, 08:10:04 am »

Code:
<script>
var n = 0;
var NeedPosts = new Array();
NeedPosts[n++] = ["BOARD","POSTS"];

var span = document.getElementsByTagName("span");
for(r=0;r<span.length;r++){
if(span[r].innerHTML.match(/Hello <b>(.*)<\/b>/i)){
var username = RegExp.$1;
};};
if(username && document.getElementById("upshrinkHeaderIC")){
var find = document.getElementById("upshrinkHeaderIC").getElementsByTagName("a");
for(x=0;x<find.length;x++){
if(find[x].innerHTML.match(username) && find[x].href.match(/action=profile;u=(\d+)/i)){
var usernumber = RegExp.$1;
};};};
if(username && document.getElementById("upshrinkHeaderIC")){
function Request(){
if (window.XMLHttpRequest ) { return new XMLHttpRequest(); }
else if (window.ActiveXObject) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
return false;
}}}
};/*End Request();*/
var req = Request();
var main = document.location.href.split("/index.php")[0];
req.open("GET",main + "/index.php?action=profile;u=" + usernumber + ";sa=statPanel");
req.onreadystatechange = function(){
if(req.readyState == 4){
var text = document.createElement("div");
text.innerHTML = req.responseText;
var txtTD = text.getElementsByTagName("td");
for(s=0;s<txtTD.length;s++){
if(txtTD[s].align == "right" && txtTD[s].innerHTML.match(/(\d+) posts/i)){
var Posts = RegExp.$1;
for(x=0;x<NeedPosts.length;x++){
if(Posts < NeedPosts[x][1]){
var a = document.getElementsByTagName("a");
for(i=0;i<a.length;i++){
if(a[i].name == "b" + NeedPosts[x][0]){
a[i].parentNode.innerHTML = a[i].innerHTML;
};};};};};};};};
req.send(null);
};
</script>

This is a long code, but I didn't want to use Jquery AJAX, so it is all javascript.
With this code, if a user doesn't have a certain ammount of posts, they cannot click the link to get into a certain board.

There is an error with this though, if you know how, they still can get to the board.  Im not telling how cause then what fun would taht be?

BOARD = The Board ID (if you look up at the address bar, you will see something like this: board,1.  The 1 would be the ID)
POSTS = How much posts they need to get into that board.

To add more boards taht they have to access with a certain ammount of posts, add more of these lines:
NeedPosts[n++] = ["BOARD","POSTS"];

Enjoy Smiley
« Last Edit: May 10, 2008, 09:37:00 pm by Agent Moose Jr. » Share Report Spam   Logged



Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2006-2009, Simple Machines LLC
Hostgator Hosting