vBulletin 4.x外部页面登录和变量

时间:2011-08-19 17:07:44

标签: login vbulletin

我一直在寻找并试验这几个小时,没有成功。

我正在尝试从外部网页登录vBulletin。我设法让这个工作。然而,我无法工作的是显示用户名和任何$ vbulletin变量。

我已将global.php chdir()包含在论坛等中,但我无法让它工作。

有谁知道如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

这是我正在使用它的工作示例。它的工作正常。它在外部页面上显示用户名和注销按钮。

我不知道为什么 - 投票。

<?php
    $curdir = getcwd();
    #Add your root dir below where it says "ADD ROOT" Example: /home/server/public_html/mainsite/forums
    #Do not end with a "/" leave it open like above example.
    chdir('ADD ROOT');
    require_once('ADD ROOT/global.php');
    chdir($curdir);
    if ($vbulletin->userinfo['userid'] == 0) {
    #Form Display Code, You can edit the way the Form is layed out here.
      echo "<form id=\"login\" action=\"/forums/login.php?do=login\" method=\"post\" onsubmit=\"md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)\">
    <script type=\"text/javascript\" src=\"clientscript/vbulletin_md5.js?v=364\"></script>
    <a href=\"/forums/register.php\">Register</a>
    <label for=\"navbar_username\">Username</label>
    <input type=\"text\" class=\"bginput\" style=\"font-size: 11px\" name=\"vb_login_username\" id=\"navbar_username\" size=\"10\" accesskey=\"u\" tabindex=\"101\" onfocus=\"if (this.value == 'User Name') this.value = '';\" />
    <label for=\"navbar_password\">Password</label>
    <input type=\"password\" class=\"bginput\" style=\"font-size: 11px\" name=\"vb_login_password\" id=\"navbar_password\" size=\"10\" tabindex=\"102\" />
    <label for=\"cb_cookieuser_navbar\"><input type=\"checkbox\" name=\"cookieuser\" value=\"1\" tabindex=\"103\" id=\"cb_cookieuser_navbar\" accesskey=\"c\" />Remember Me?</label>
    <input type=\"submit\" class=\"button\" value=\"Login\" tabindex=\"104\" title=\"Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself.\" accesskey=\"s\" />
    <input type=\"hidden\" name=\"s\" value=\"\" />
    <input type=\"hidden\" name=\"do\" value=\"login\" />        
    <input type=\"hidden\" name=\"vb_login_md5password\" />
    <input type=\"hidden\" name=\"vb_login_md5password_utf\" />
    </form>";
    #End Form Display Code
    } else {
    #Display after login completed
      echo "Welcome Back, <b>".$vbulletin->userinfo['username']."</b>";
      if ($vbulletin->userinfo['usergroupid'] == '6' ) {
      echo "&nbsp;|&nbsp;<a href=\"/forums/member.php?1-".$vbulletin->userinfo['username']."\">My Profile</a>";
      echo "&nbsp;|&nbsp;<a href=\"/forums/egncadmincp/index.php\">AdminCP</a>";
      echo "&nbsp;|&nbsp;<a href=\"/forums/egncmodcp/index.php\">ModCP</a>";
      }
    }
    ?>