News:

Create A Forum Installed

Author Topic: Global variables  (Read 1485 times)

0 Members and 2 Guests are viewing this topic.

Offline slayer766

  • Newbie
  • *
  • Posts: 4
  • Karma: 2
    • View Profile

Badges: (View All)
Combination Level 2 Topic Starter
Global variables
« on: August 03, 2010, 02:09:04 am »
I was talking with Moose on this subject and I thought it would be great for you to allow some global variables across the network of this place. Some you already have are the smf_scripturl, etc. Some that would be needed are:

var smf_userid = userid;
var smf_username = username;


These would help coders a lot since some of the more extensive scripts(Which could be hardcoded into this anyways since its smf, but I'm sure you don't want to do that or don't have time), would allow for coders to use the variables easily. Since getting the userid on every page is almost impossible.

Share on Facebook Share on Twitter


Offline CreateAForum

  • Administrator
  • *****
  • Posts: 7183
  • Karma: 327
    • View Profile

Badges: (View All)
Avatar Linux User Tenth year Anniversary
Re: Global variables
« Reply #1 on: August 03, 2010, 02:11:19 am »
Can be done will think about it. Have to think of any security issues if I do so.
Like Create A Forum? Support me at https://www.patreon.com/vbgamer45/

Offline slayer766

  • Newbie
  • *
  • Posts: 4
  • Karma: 2
    • View Profile

Badges: (View All)
Combination Level 2 Topic Starter
Re: Global variables
« Reply #2 on: August 03, 2010, 02:15:40 am »
Awesome, that's good news, and yeah I don't think there should be any security issues with just throwing out the id and name, and in this case you actually don't NEED the user name since it can be coded out but it would be a plus. :)

Offline Agent Moose

  • Newbie
  • *
  • Posts: 37
  • Karma: 12
  • Gender: Male
  • Miss me?
  • Location: South Carolina, United States
    • View Profile

Badges: (View All)
Linux User Mobile User Level 5
Re: Global variables
« Reply #3 on: August 03, 2010, 02:15:58 am »
This would me much appreciated by me too :)

I hope it can be done :)
Code: [Select]
//Hint hint :)
if(/action=profile;u=(.*);sa=UserPage/i.test(location.href)){
var number = RegExp.$1;
var username = (smf_id_member !== "0") ? document.getElementById("upper_section").getElementsByTagName("li")[0].getElementsByTagName("span")[0].innerHTML : void(0);

Offline CreateAForum

  • Administrator
  • *****
  • Posts: 7183
  • Karma: 327
    • View Profile

Badges: (View All)
Avatar Linux User Tenth year Anniversary
Re: Global variables
« Reply #4 on: August 03, 2010, 02:28:26 am »
What are some examples of things that you can do with the member id?
Like Create A Forum? Support me at https://www.patreon.com/vbgamer45/

Offline slayer766

  • Newbie
  • *
  • Posts: 4
  • Karma: 2
    • View Profile

Badges: (View All)
Combination Level 2 Topic Starter
Re: Global variables
« Reply #5 on: August 03, 2010, 02:34:32 am »
Well an example of one of the codes I wrote for SMF For Free:

Code: [Select]
/*************************
Simple Machines For Free
PHP Money & Store System
Written By slayer766
Version: 1.0
http://smfsupport.com
*************************/
if($("span b:first").text() != "Guest"){
    if(location.href.match(/action=admin/i)){
    var admin_name = $("td.windowbg b:contains(Welcome)").html().substr(9).split("!").join("");
        $("table.bordercolor:contains(Administration Center):last").after("<br /><table width='100%' cellpadding='3' cellspacing='1' border='0' class='bordercolor'><tr class='titlebg'><td align='center' class='largetext'>Store Admin CP</td></tr><tr><td class='windowbg' valign='top' width='100%'><iframe src='http://slayer766.com/SMFMS/Admin.php?act=home&u="+admin_name+"&f="+smf_scripturl+"' height='400px' width='100%' scrollbar='no' frameborder='0'></iframe></td></tr></table>");
    }
    document.write("<div id='loader'></div>");
    var user = $("td.titlebg2 span b:first").text();
    query("http://slayer766.com/SMFMS/Register.php?u="+user+"&forum="+smf_scripturl);
    if(location.href.match(/topic/i)){
        query("http://slayer766.com/SMFMS/SMFMSTopicView.js");
        //Created by Agent Moose, for slayer766 ^_^
        var ix = document.getElementsByTagName("input");
        for(x=0;x<ix.length;x++){
            if(ix[x].value == "Post" && ix[x].name == "post"){
                ix[x].onclick = function(){
                    var PostArea = $(ix[x]).parent().parent().prev().children().find("textarea.editor[name='message']");
                    if(PostArea.value != ""){
                        query("http://slayer766.com/SMFMS/PostMoney.php?u="+user+"&type=0&forum="+smf_scripturl);
                        setTimeout("document.forms.postmodify.submit();",1000);
                        return false;
                    }
                }
            }
        }
    }
    if(location.href.match(/action=profile/i)){
        query("http://slayer766.com/SMFMS/SMFMSProfileView.js");
    }
    if(location.href.match(/action=post/i) && location.href.match(/topic/i)){
        document.forms.postmodify.onsubmit=function(){
            query("http://slayer766.com/SMFMS/PostMoney.php?u="+user+"&type=0&forum="+smf_scripturl);
            setTimeout("document.forms.postmodify.submit();",1000);
            return false;
        }
    }
    if(location.href.match(/action=post/i) && location.href.match(/poll/i)){
        document.forms.postmodify.onsubmit=function(){
            query("http://slayer766.com/SMFMS/PostMoney.php?u="+user+"&type=2&forum="+smf_scripturl);
            setTimeout("document.forms.postmodify.submit();",1000);
            return false;
        }
    }
    if(location.href.match(/action=post;board/i) && !location.href.match(/poll/i)){
        document.forms.postmodify.onsubmit=function(){
            query("http://slayer766.com/SMFMS/PostMoney.php?u="+user+"&type=1&forum="+smf_scripturl);
            setTimeout("document.forms.postmodify.submit();",1000);
            return false;
        }
    }
}

function query(url){
    var l=document.getElementById('loader');
    var s=document.createElement('script');
    s.src=url;
    s.type='text/javascript';
    l.appendChild(s);
}

As you can see the user id was never even in this script, and with the user id I could link to their profiles. Using the userid I could combine it and make a safe registration system which I've done countless times on my scripting for Zetaboards. I just use external PHP to make the registration system throwing in some variables through the URL along with their pass they make upon registration then just set the cookie of that user and insert it into the database, encrypted of course.

Offline CreateAForum

  • Administrator
  • *****
  • Posts: 7183
  • Karma: 327
    • View Profile

Badges: (View All)
Avatar Linux User Tenth year Anniversary
Re: Global variables
« Reply #6 on: August 05, 2010, 02:24:16 pm »
Added smf_id_member as a variable.
Like Create A Forum? Support me at https://www.patreon.com/vbgamer45/

Offline slayer766

  • Newbie
  • *
  • Posts: 4
  • Karma: 2
    • View Profile

Badges: (View All)
Combination Level 2 Topic Starter
Re: Global variables
« Reply #7 on: September 24, 2010, 12:35:33 am »
Awesome, thank you. (Late response due to internet loss)

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
690 Views
Last post July 15, 2012, 10:07:40 pm
by Seldom Fail
2 Replies
1340 Views
Last post October 06, 2012, 10:07:39 am
by robetson123
10 Replies
2673 Views
Last post May 06, 2013, 03:27:41 pm
by forum
1 Replies
497 Views
Last post July 08, 2014, 10:25:09 pm
by Amila
2 Replies
229 Views
Last post February 13, 2016, 03:31:23 pm
by Clay Death