Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-08-2016, 08:22 PM
Necrophyte Necrophyte is offline
 
Join Date: Jul 2014
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PHP Module loses user session info on form submit

Creating a form inside the php module.+
The form calls itself.+
Quick little snippet example
Code:
global $vbulletin;
if (!empty($_POST['sbutton'])){
    Do some stuff, but we can't userid = 0 $vbulletin->userinfo['userid'] and even vB::getCurrentSession()->get('userid') returns 0
}else{
    <form class='block' action='/forum/SituationReport' method='post' id='sitrep' name='sitrep'>
    <input type='submit' class='button' name='sbutton' id='_save' value='Submit'>
}
On the submit. The session is lost.
I tried adding the normal loading scripts but I get
Couldn't read config file config.php
Which is typical if its already loaded (Or at least in my experience)
What else am I missing here. Script works outside of vbulletin as an external page.

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

@#%#@$%
Figure out cause I was calling ./global.php
I missed that.
Reply With Quote
  #2  
Old 09-08-2016, 10:29 PM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For a simple form submission, I wouldn't bother with a PHP module. Most all the user data you need to work with is in the JS pageData array and whatever is not is easy enough to pull with an ajax call. Not sure what you're working on, but JS for forms is easy and can usually be as sophisticated as you need it to be.
Reply With Quote
  #3  
Old 09-09-2016, 06:33 PM
Necrophyte Necrophyte is offline
 
Join Date: Jul 2014
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I wish my JS was decent. I barely scrape by using JS. I can do basic stuff like form validation, and manipulating variables. But other than that.
Was just a quick little Site Rep form that would post to the forum.
Reply With Quote
  #4  
Old 09-10-2016, 02:42 AM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You don't have to read or load config.php file or any file for that matter. What is exactly do you want to accomplish?

You can get all of the public vbulletin options by doing this:

Code:
$vboptions = vB5_Template_Options::instance()->getOptions();
$vboptions = $vboptions['options'];
var_dump($vboptions);
Reply With Quote
  #5  
Old 09-10-2016, 01:25 PM
Necrophyte Necrophyte is offline
 
Join Date: Jul 2014
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey Glenn,

So I run the forums of a gaming community. In Milsim style we have a sit rep report. If someone does something good, or something bad there is a report someone can fill out and only certain people can see it in the forums. All the posting and stuff I have working (Thank you). So I was creating the form in a php module. I have a link on the submenu that calls it.
However, I was so used to calling ./global.php from vb4 days I did it instinctively.
What I found out is. When you do call ./global.php. It actually kills the user session.
$vbulletin->userinfo['userid'] would = 0. I was losing my mind cause I was sure I fixed the posting code but it came up with no permissions. Well that was because it was having the userid, and session removed.
All I had to do was remove the ./global.php include and everything worked. But I'm finding the more I post in here after I can't figure it out, its usually a few min later I figure it out on my own.
Reply With Quote
  #6  
Old 09-10-2016, 11:57 PM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have not having done any php coding in vb4 but after looking at it, there looks to be far more effort required for a vb4 mod vs vb5. Am I crazy? probably, but that just what ity looks like to me.
Reply With Quote
  #7  
Old 09-11-2016, 12:55 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yep, you're crazy
Reply With Quote
Благодарность от:
Replicant
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 09:41 AM.


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.09661 seconds
  • Memory Usage 2,221KB
  • 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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (1)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete