vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Login Script (https://vborg.vbsupport.ru/showthread.php?t=64963)

Bone Head 05-10-2004 05:30 PM

Login Script
 
I posted this at Vbulletin.com and they said I should post it here :)

As I mentioned in the other thread we use Vbulletin as the back bone of our site as many folk do, since the upgrade to v3 we havent been able to log our users into the passworded areas of our site because I cant get the login page working.

The login page is created with PHAkt which is a dreamweaver MX extension, lame I know but I'm still learning php :ermm:

This is the script that PHAkt creates:

Code:

<?php
//Connection statement
require_once('../Connections/Comms.php');
//Aditional Functions
require_once('../includes/functions.inc.php');
// *** Start the session
session_start();
// *** Validate request to log in to this site.
$KT_LoginAction = $HTTP_SERVER_VARS["REQUEST_URI"];
if (isset($HTTP_POST_VARS["user"])) {
  $KT_valUsername = $HTTP_POST_VARS['user'];
  $KT_fldUserAuthorization = "";
  $KT_redirectLoginSuccess = "sucess.php";
  $KT_redirectLoginFailed = "failed.php";
  $KT_rsUser_Source = "SELECT username, password ";
  if ($KT_fldUserAuthorization != "") $KT_rsUser_Source .= "," . $KT_fldUserAuthorization;
  $KT_rsUser_Source .= " FROM user WHERE username='" . $KT_valUsername . "' AND password='" . $HTTP_POST_VARS['pass'] . "'";
  $KT_rsUser=$Comms->Execute($KT_rsUser_Source) or DIE($Comms->ErrorMsg());
  if (!$KT_rsUser->EOF) {
        // username and password match - this is a valid user
        $KT_Username=$KT_valUsername;
 
        KT_session_register("KT_Username");
        if ($KT_fldUserAuthorization != "") {
          $KT_userAuth=$KT_rsUser->Fields($KT_fldUserAuthorization);
        } else {
          $KT_userAuth="";
        }
 
        KT_session_register("KT_userAuth");
        if (isset($HTTP_GET_VARS['accessdenied']) && false) {
          $KT_redirectLoginSuccess = $HTTP_GET_VARS['accessdenied'];
        }
        $KT_rsUser->Close();
 
        KT_session_register("KT_login_failed");
        $KT_login_failed = false;
        // Add code here if you want to do something if login succeded
KT_redir($KT_redirectLoginSuccess);
  }
  $KT_rsUser->Close();
  $KT_login_failed = true;
 
  KT_session_register("KT_login_failed");
  // Add code here if you want to do something if login fails
KT_redir($KT_redirectLoginFailed);
}
 //PHP ADODB document - made with PHAkt 2.7.3?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="POST" action="<?php echo $KT_LoginAction?>">
Username:
<input name="user" type="text" id="user">
Password:
<input name="pass" type="password" id="pass">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>


Now I realsie I have to get something like: MD5(CONCAT(MD5($HTTP_POST_VARS['pass']), salt)) in this code and I have tried doing just that but it doesnt work. I would really appreciate some help fixing this code if anyone cares to help.

Fingers crossed TIA Bone

AlexanderT 05-10-2004 05:44 PM

Someone else asked me a similar question. I suggest you add the following to your own code:

PHP Code:

<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

// is user logged in?
if (!$bbuserinfo['userid']) {
    
print_no_permission();
}
else {
    
$url "index.php?$session[sessionurl]";
    eval(
print_standard_redirect('redirect_login'));
}
?>

In the code, you can replace 'index.php' with the script you want the user to be redirected to after a successful login.

Greets
Alex

Bone Head 05-10-2004 08:09 PM

Thanks for the input not sure if its going to work for me though. PHAkt creates pages that you can deny access to depending on teh users usergroup. The script I posted above is the login page for that, once a user is recognised they are sent to one of those pages.

Ill give it a go though.


All times are GMT. The time now is 08:40 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01199 seconds
  • Memory Usage 1,727KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete