Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-05-2012, 11:08 AM
tblancha tblancha is offline
 
Join Date: Jun 2009
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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"


Thanks for any help you can provide.
Reply With Quote
  #2  
Old 11-05-2012, 12:31 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #3  
Old 11-05-2012, 12:51 PM
tblancha tblancha is offline
 
Join Date: Jun 2009
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>";


?>
Reply With Quote
  #4  
Old 11-05-2012, 01:02 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #5  
Old 11-05-2012, 01:45 PM
tblancha tblancha is offline
 
Join Date: Jun 2009
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 11-05-2012, 01:50 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where are you putting your script? I tested it in the same directory as the main vbulletin files.
Reply With Quote
  #7  
Old 11-05-2012, 02:31 PM
tblancha tblancha is offline
 
Join Date: Jun 2009
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Everything is at the main forum level. And once I log in, the code works as expected. Weird.
Reply With Quote
  #8  
Old 11-05-2012, 02:42 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 11-05-2012, 02:55 PM
tblancha tblancha is offline
 
Join Date: Jun 2009
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:43 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06636 seconds
  • Memory Usage 2,235KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete