The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

View Limit for Guests Code Help

3 posters

Go down

Solved View Limit for Guests Code Help

Post by FrOsTyXi May 18th 2015, 1:17 am

Hello, I found this code to limit the views on the forum for guests but on some reloads i get a null page then is automatically redirects to the index, does this while logged in. Can this be fixed?

Code:
Code:
      $(function(){
    themsg = "You Have Reached The View Limit You Must Signup To Continue Viewing";
                var x = "/login /register";
            var y = x.split(" ");
        for (var i = 0; i < y.length; i++) {
              if (window.location.pathname == y[i]) return; 
        };


            if(_userdata.session_logged_in <= 0) {
           
                count = parseInt(my_getcookie("count")) || 0;
                if(count < 10){
                    my_setcookie("count",++count, 10000);
               
                }else{
                      alert(themsg);
                          var hhh = location.href;
            my_setcookie("mylasturl",hhh, 10000);
                  location.href='/login';
        };
            }else{
            lastur = my_getcookie("mylasturl");
            if (lastur == ""){}else{
                  location.href=lastur;
        my_setcookie("mylasturl","", 10000);
                };
            };
        });


punbb

Forum Link: http://www.team-psn.net/

Thank you in advance!

Regards
FrOsTyXi
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: View Limit for Guests Code Help

Post by SLGray May 18th 2015, 6:46 am

Where did you get that code?


View Limit for Guests Code Help Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51569
Reputation : 3525
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Solved Re: View Limit for Guests Code Help

Post by FrOsTyXi May 18th 2015, 12:47 pm

@SLGray @_Twisted_Mods_ Made the code
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: View Limit for Guests Code Help

Post by Ange Tuteur May 18th 2015, 6:23 pm

Try replacing it with this :
Code:
!/\/login|\/register/.test(window.location.pathname) && $(function(){
  if (_userdata.session_logged_in) return;
 
  var msg = "You Have Reached The View Limit You Must Signup To Continue Viewing",
      count = Number(my_getcookie("count")) || 0,
      href = window.location.href;
 
    if (count < 10) my_setcookie("count", ++count, 10000);
    else {
      alert(msg);
      my_setcookie("mylasturl", href, 10000);
      location.href = '/login';
    };
});
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: View Limit for Guests Code Help

Post by FrOsTyXi May 18th 2015, 6:42 pm

@Ange Tuteur Ok i replaced the code with yours and tested as a guest now i do not get the message, i have added the old code back for now.
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: View Limit for Guests Code Help

Post by Ange Tuteur May 18th 2015, 6:45 pm

Weird, try installing it again, in all the pages.
Code:
!/\/login|\/register/.test(window.location.pathname) && $(function(){
  if (_userdata.session_logged_in) return;
 
  var msg = "You Have Reached The View Limit You Must Signup To Continue Viewing",
      count = Number(my_getcookie("count")) || 0,
      href = window.location.href;

    if (count < 10) my_setcookie("count", ++count, 10000);
    else {
      alert(msg);
      my_setcookie("mylasturl", href, 10000);
      location.href = '/login';
    };
});
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: View Limit for Guests Code Help

Post by FrOsTyXi May 18th 2015, 6:54 pm

@Ange Tuteur I have no idea what happened but, that worked! thank you sir for all the help today!
FrOsTyXi
FrOsTyXi
Forumember

Male Posts : 460
Reputation : 12
Language : english

http://team-psn.forum-board.net/

Back to top Go down

Solved Re: View Limit for Guests Code Help

Post by Ange Tuteur May 18th 2015, 8:19 pm

You're welcome ^^

Topic archived
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum