[RELEASE v2] Homepage Login on non-vB page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RobAC
    Senior Member
    • Jan 2001
    • 1414
    • 3.8.x

    [RELEASE v2] Homepage Login on non-vB page

    Ok....this is my first hack. It's small and should be very straight forward.

    The source of this hack is a thread that started in the main Code Hacks forum by a user looking for a hack that would allow their members to log in from the main home page of their site. Once logged in, it would display a Welcome message when the logged in member returned to the home page.

    The original source was provided by Demolition, but members were having problems with getting the hack to run.

    Warning/Disclaimer: I am not a well seasoned PHP programmer. I get by as best I can, but usually learn from example and tinkering. I have changed the PHP coding around slightly, and added much more HTML in order to format the input fields etc. This hack was tested using Internet Explorer 5.5 and Netscat 4.7. I have verified that it works in both OS's several times. I am also running the latest version of PHP on my server, so I'm not sure how to help those of you that are running PHP3, but I'll do the best I can. I won't make any promises though. I plan on continuing to work on this as well as add a few more features to it as time permits.

    Download the attached file and edit it using a text editor of your choice. Add the pathway to your forums directory where noted. Save the file as a PHP file to your main forums directory. If your site's home page is an HTML document you will have to call the PHP file using a server side include. If you're not sure how to do this, you should search the forums here as this topic has already been covered several times.
    Last edited by RobAC; Mon 23 Jul '01, 10:47pm.
    Rob
  • _
    Member
    • Sep 2000
    • 57

    #2
    <form action="http://www.corvetteactioncenter.com/forums/member.php" method="post" />

    You should really change that

    But nice hack for us html/php impaired

    I'm just lazy.

    Comment

    • RobAC
      Senior Member
      • Jan 2001
      • 1414
      • 3.8.x

      #3
      Sorry.....here it is.
      Rob

      Comment

      • Ruth
        Senior Member
        • Apr 2001
        • 360

        #4
        RobAC, thanks

        but i wasn't looking exactly for this, i was looking for a code to welcome the user in non-vB pages, when s/he logs in using login box in non vb pages, and this one doesnt work like this

        Comment

        • Robert Basil
          Senior Member
          • Sep 2000
          • 242
          • 2.0.x

          #5
          Rob,

          I just added this hack to our community and it works great! Thanks!

          Comment

          • RobAC
            Senior Member
            • Jan 2001
            • 1414
            • 3.8.x

            #6
            Originally posted by Ruth
            RobAC, thanks

            but i wasn't looking exactly for this, i was looking for a code to welcome the user in non-vB pages, when s/he logs in using login box in non vb pages, and this one doesnt work like this
            Ruth,

            Can you explain further? So you want it to say "Welcome back.....member on each non forum page? You don't want the login fields?

            -Rob
            Rob

            Comment

            • BradC
              Senior Member
              • May 2001
              • 510

              #7
              By Definition Rob, I think what is wanted is lets say on the index.html or index page, it welcomes them to the site.

              kind of like using a very basic phpportals

              that is what I get out of it.

              Comment

              • Rostor
                Member
                • Jun 2001
                • 80
                • 4.1.x

                #8
                Hi Rob, i try your hack but nothing works sorry it will be for the next time
                Renato

                Comment

                • Steve Machol
                  Former Customer Support Manager
                  • Jul 2000
                  • 154488

                  #9
                  Originally posted by Ruth
                  RobAC, thanks

                  but i wasn't looking exactly for this, i was looking for a code to welcome the user in non-vB pages, when s/he logs in using login box in non vb pages, and this one doesnt work like this
                  Try this:

                  PHP Code:
                  <?

                  require("./global.php");

                  if (
                  $bbuserinfo['userid']!=0) {
                  $username=$bbuserinfo['username'];

                  echo
                  "Welcome back, <b>$username</b>";

                  }
                  ?>
                  Here's a test page that has it in action. I don't know what it says if you're not a Member of OptiBoard though. Let me know.

                  Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
                  Change CKEditor Colors to Match Style (for 4.1.4 and above)

                  Steve Machol Photography


                  Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


                  Comment

                  • Ruth
                    Senior Member
                    • Apr 2001
                    • 360

                    #10
                    smachol, thanks, but i tried that it doesn't work...

                    RobAC, this is what i am trying to do...

                    i need to do the following in non-vB pages:

                    (1) if the user already logged use their cookies and display a welcome $username + logout link

                    (2) if the user is not logged use the login form before displaying the page content.

                    (3) prevent access to users awaiting confirmation (3) and users awaiting moderation (4)



                    PHP Code:
                    <?

                    require("path-to/global.php");

                    if (!
                    $bbuserinfo[userid] || $bbuserinfo[usergroupid]==|| $bbuserinfo[usergroupid]==4) {
                    show_nopermission();
                    eval(
                    "dooutput(\"".gettemplate("error_wrongpassword")."\");");
                    }

                    if (
                    $bbuserinfo['userid']!=0) {
                    $username=$bbuserinfo['username'];

                    echo
                    "Welcome Back, <b>$username</b>";

                    } else {

                    ?>

                    <table border="0" cellpadding="0" cellspacing="0" height="99">
                    <form action="http://path-to/forums/member3.php" method="post">
                    <tr>
                    <td nowrap height="13" colspan="2">
                    <p align="center"><font face="verdana,arial,helvetica" size="1" ><b>Login with username and password:</b></font></p>
                    </td>
                    </tr><tr>
                    <td nowrap height="25"><font size="2">User Name</font>
                    </td>
                    <td nowrap height="25"><input type="text" class="bginput" name="username" size="13">
                    </td>
                    </tr>
                    <tr>
                    <td nowrap height="27"><font size="2">Password</font></td>
                    <td nowrap height="27"><input type="hidden" name="s" value="$session[sessionhash]">
                    <input type="hidden" name="action" value="login"><input type="password" class="bginput" name="password" size="13">
                    <input type="submit" class="bginput" value="Login!"></td>
                    </tr>
                    </table>

                    <?

                    }

                    ?>
                    i get error almost everywhere except for the login box, there is an error on show_nopermission line, and the user is not welcomed in non-vb pages. (i changed member.php to member3.php and alreasy set the redirect to the index of my main site (non-vB) )

                    please help

                    Comment

                    • Steve Machol
                      Former Customer Support Manager
                      • Jul 2000
                      • 154488

                      #11
                      Originally posted by Ruth
                      smachol, thanks, but i tried that it doesn't work...
                      Ruth, what doesn't work exactly? Make sure the script is in the same directory as your global.php file. This code works perfectly on my site.
                      Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
                      Change CKEditor Colors to Match Style (for 4.1.4 and above)

                      Steve Machol Photography


                      Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


                      Comment

                      • RobAC
                        Senior Member
                        • Jan 2001
                        • 1414
                        • 3.8.x

                        #12
                        Ruth,

                        Can you be more specific when you say it doesn't work? Are you getting warning messages back? What version of PHP are you running? Is the pathway to the global.php file correct?
                        Rob

                        Comment

                        • RobAC
                          Senior Member
                          • Jan 2001
                          • 1414
                          • 3.8.x

                          #13
                          Originally posted by Ruth
                          smachol, thanks, but i tried that it doesn't work...

                          RobAC, this is what i am trying to do...

                          i need to do the following in non-vB pages:

                          (1) if the user already logged use their cookies and display a welcome $username + logout link

                          (2) if the user is not logged use the login form before displaying the page content.

                          (3) prevent access to users awaiting confirmation (3) and users awaiting moderation (4)

                          i get error almost everywhere except for the login box, there is an error on show_nopermission line, and the user is not welcomed in non-vb pages. (i changed member.php to member3.php and alreasy set the redirect to the index of my main site (non-vB) )

                          please help

                          Is the main index page of your site an HTML document on PHP? So in other words, when someone clicks the link to go to your site....if they are a member, you want them to automatically be logged in....if they're cookies are set properly and have direct access to the site. If they aren't logged in, you want to be brought to a page that has nothing on it, other than the log in fields? It sounds like this is a little beyond my capability and I'm not sure I can help.
                          Rob

                          Comment

                          • Ruth
                            Senior Member
                            • Apr 2001
                            • 360

                            #14
                            Ruth, what doesn't work exactly?
                            Test 1
                            when i use that code without show_nopermission code, it only shows the login box in my index.php (non vB), when i try to login using the box, and it redirects me to the same page (index.php) it doesnt show the welcome screen, it shows the login box again (like if i'm not using cookies or not looged in)

                            Test 2
                            when i change number 0 to 1 in

                            if ($bbuserinfo['userid']!=0) {
                            $username=$bbuserinfo['username'];

                            echo"Welcome Back, <b>$username</b>";
                            i get the welcome screen only "Welcome Back" and not $username
                            but when i logout and come back it doesnt show the login box at all.


                            Test 3
                            when i add this to the code
                            PHP Code:
                            if (!$bbuserinfo[userid] || $bbuserinfo[usergroupid]==|| $bbuserinfo[usergroupid]==4) {
                            show_nopermission();
                            eval(
                            "dooutput(\"".gettemplate("error_wrongpassword")."\");");

                            i get error in show_nopermission(); line


                            Make sure the script is in the same directory as your global.php file. This code works perfectly on my site
                            the path to global.php works fine, and didnt have problem with it, however it is not in the same directory as the global.php, because i am trying to put this code in every non-vB page to protect it.

                            What version of PHP are you running?
                            PHP4 with Zend Optimizer

                            Is the main index page of your site an HTML document on PHP?
                            it is *.php

                            thanks for your help

                            Comment

                            • Steve Machol
                              Former Customer Support Manager
                              • Jul 2000
                              • 154488

                              #15
                              Ruth,

                              For what it's worth I believe I also had a problem using this unless the script was in the same directory as the global.php file. Sorry, I don't know what to recommend.
                              Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
                              Change CKEditor Colors to Match Style (for 4.1.4 and above)

                              Steve Machol Photography


                              Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...