vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Force All Guests to a Custom Login (https://vborg.vbsupport.ru/showthread.php?t=283930)

firebrand media 06-04-2012 01:11 PM

Force All Guests to a Custom Login
 
I see this question asked many times for vBulletin4.x, but I can't find clear answers.
We're building a site that is a totally closed community. All guests must login through a page with ONLY the login fields.
The login page cannot display the regular site navigation.

It's OK if the error handling goes to the regular login, but it would be preferred if we could do that on a screen without the navigation as well.

So I need three things:
1) How to force all guests to the custom login screen.
I tried this into global_start:
Code:

if ($vbulletin->userinfo['usergroupid'] == 1)
{
$templater = vB_Template::create('my_custom_login');
print_output( $templater->render());
}

It shows my custom login template to guests, but logged in users don't get stylesheets.
I also tried a version that does a Location (also on global_start)
Code:

$vbulletin->url = $thisserverprotocol.$_SERVER['SERVER_NAME'].'/xlogin.html';
But that didn't work at all.


1a) What's the best way to check for non-logged in users?
1b) If I want to do location:, where should I hook?


2) How to submit that login form to vBulletin
I got a form to work by copying the rendered html from the cpanel login, and modifying the paths.
But that's bringing in a bunch of JavaScript seems like overkill. Is there a simple way to have a form submit to login?

3) An abbreviated custom registration form.
The email address will be passed in the URL, so I'll just have them fill in a handle and password.
I can write a record to the DB myself, but i"m sure there's a nice call I can make to create a user.
Could someone point me in the right direction?

These are the final features needed for this site, and need to be resolved ASAP.
Any help is appreciated.

kh99 06-04-2012 01:32 PM

I don't know if this is the best way, but you might try using your global_start plugin but surround the code with:

Code:

if (!defined('SKIP_SESSIONCREATE'))
{
// code here
}

I don't know how you'd use location:.


I think a form like this should work:

Code:

<form action="login.php" method="post">
<input type="hidden" name="do" value="login">
<input type="text" name="vb_login_username">
<input type="text" name="vb_login_password">
</form>


(obviously that's simplified and you'd want some formatting). If you want to send the password as an md5 hash (which vb noramally does) then you'd need to include some javascript.

firebrand media 06-04-2012 04:11 PM

Thanks so much kh99.
The simplified login form worked fine.
Just had to add a hidden field to prevent it from coming back to the login form:

Code:

<input type="hidden" name="url" value="/homepage.php">
--------------- Added [DATE]1338847450[/DATE] at [TIME]1338847450[/TIME] ---------------

Moving the hook to global_state_check solved my problem with the vanishing CSS.
Moving the form from the external HTML page to the template is causing some wackiness in that I think we're intercepting the processing at login.php and showing the login template.

I tried incorporating the SKIP_SESSIONCREATE, but that didn't seem to help.
Anyone have further thoughts?

firebrand media 06-07-2012 01:22 PM

I'm oh so close.

Created a plugin hooked on global_state_check

Code:

if ($vbulletin->userinfo['usergroupid'] == 1)
{
  if ((THIS_SCRIPT == 'login') or ($_POST['do'] == 'login'))
  {
 
  } else {
  $templater = vB_Template::create('custom_login');
  print_output( $templater->render());
  }
}

Appears to work exactly as intended with one very odd exception:
Youtube videos aren't rendering on Chrome.
Don't understand how that could be related, but there it is....

Thoughts?

--------------- Added [DATE]1339079659[/DATE] at [TIME]1339079659[/TIME] ---------------

Nevermind.
Just had to relaunch Chrome. :)


All times are GMT. The time now is 08:17 PM.

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.01045 seconds
  • Memory Usage 1,722KB
  • 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
  • (6)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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