vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Being forced to forum login page when accessing datamanager in code (https://vborg.vbsupport.ru/showthread.php?t=290174)

tblancha 11-05-2012 11:08 AM

Being forced to forum login page when accessing datamanager in code
 
Hello,

When trying to use $newuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
in code, I'm forced to the screen that has the message "You are not logged in or you do not have permission to access this page. This could be due to several reasons: " <blah> <blah>

Then if I log into my forum as admin then the code in my script runs.


But I'm attempting to write code to automatically work with users and their settings.

Why am I being forced to this "login" screen? I did make sure the setting to allow user registrations is set to "yes"
:confused:

Thanks for any help you can provide.

kh99 11-05-2012 12:31 PM

Are you sure it's the "datamanager_init()" line that's causing it? If it is, the only thing I can think of is to make sure $vbulletin is an object (if you're calling it inside a function, maybe you need a "global $vbulletin;" line).

tblancha 11-05-2012 12:51 PM

I'm not doing anything fancy and am not calling it inside a function. I did apply a security patch though yesterday. Not sure if that hosed anything.

Here is the code I'm using:

<?php
include_once("global.php");



$vbulletin;


$email = "userMom@myforum.com";

$useridq = $vbulletin->db->query_first_slave("SELECT userid FROM "
. TABLE_PREFIX . "user WHERE email='{$email}'");
$syd_userinfo = fetch_userinfo($useridq['userid'], 0, 0);

echo "<br> taya given the email, it found this as the user id: " . $useridq['userid'] . " <br>";


?>

kh99 11-05-2012 01:02 PM

OK, I tried that and I just got the message echoed at the end (and of course it says the userid is 0). But you said you were trying to use datamanager_init(), did you remove that code?

tblancha 11-05-2012 01:45 PM

I did remove the datamanager_init() code to rule out that was causing me to be sent to the login screen.

Even with that code removed and using the code that I posted and you've tested, I'm sent to the screen to login. I don't know what is causing that.

kh99 11-05-2012 01:50 PM

Where are you putting your script? I tested it in the same directory as the main vbulletin files.

tblancha 11-05-2012 02:31 PM

Everything is at the main forum level. And once I log in, the code works as expected. Weird.

kh99 11-05-2012 02:42 PM

I hadn't tried it while logged out, but I just did and it works OK for me. I know there are some scripts that redirect you to the login page if you're not logged in, but obviously that code isn't in yours. I was thinking you might have your script in admincp or modcp, since those use a different global.php that I believe does force you to log in.

tblancha 11-05-2012 02:55 PM

Thanks for your help. I think something is corrupt/confused since I applied the security patch. I'll revert back later today and try to see if the behaviour is the same. Again, thanks for your help.


All times are GMT. The time now is 05:39 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.01047 seconds
  • Memory Usage 1,723KB
  • 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)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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