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

Reply
 
Thread Tools Display Modes
  #1  
Old 12-26-2008, 09:23 PM
pianoman993 pianoman993 is offline
 
Join Date: Oct 2008
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Can't get plugin code to work

Hey everyone, I need some help on a short bit of code I want to put in a plugin. The code looks like this:

PHP Code:
putenv("PHP_ENC_USERNAME=$bbuserinfo[username]");    # where $username is your PHP user variable.
putenv("PHP_ENC_ISADMIN=1");        # where $X is a 0 or a 1. 
And I am trying to put it togather with some code I already have in the plugin like this:

PHP Code:
putenv("PHP_ENC_USERNAME=$bbuserinfo[username]");    # where $username is your PHP user variable.
putenv("PHP_ENC_ISADMIN=1");        # where $X is a 0 or a 1.

ob_start();

include(
"http://mysite.com?" $_SERVER['QUERY_STRING']);
$file ob_get_contents();
ob_end_clean(); 
Am I doing it right? I'm not sure because I never get the result I'm supposed to. Perhaps it is not rendering the putenv()?

Any help would be greatly appreciated! Thanks!

- Pianoman993
Reply With Quote
  #2  
Old 12-27-2008, 02:57 AM
Deceptor's Avatar
Deceptor Deceptor is offline
 
Join Date: Dec 2008
Location: England
Posts: 514
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should use $vbulletin->userinfo instead of $bbuserinfo now

Try:
PHP Code:
putenv("PHP_ENC_USERNAME=" $vbulletin->userinfo['username']); 
Reply With Quote
  #3  
Old 12-27-2008, 03:18 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What are you trying to do there? Why do you need to use putenv()?
Reply With Quote
  #4  
Old 12-27-2008, 03:41 AM
pianoman993 pianoman993 is offline
 
Join Date: Oct 2008
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm trying to get variables into a CGI script via putenv().

However, I may try to just use $_ENV

Thanks for all the help!

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

Alright. Hold the phone.

Alright, so I've got this CGI script and I've got 2 variables in there.

One wants a session ID
The other wants the Username

So I'm trying to communicate with this CGI Script through vbullitan's plugin system and it's killing me to no end. I can't take it! I can't for the life of me figure it out!!

HOW DO YOU PASS PHP VARIABLES INTO CGI SCRIPTS!!!! AHHH!!!
*heavy breathing, high blood pressure*

I know it is most likely a newby question. But if ANYONE! out there can help me out I would SOOOOOOOOOOOOO greatly appreciate their GODLY help.

"Help me Obi-Wan-Kenobi, your my only hope"
- Pianoman993
Reply With Quote
  #5  
Old 12-27-2008, 08:09 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can't you add another item on your query string?
Reply With Quote
  #6  
Old 12-27-2008, 02:17 PM
pianoman993 pianoman993 is offline
 
Join Date: Oct 2008
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That could easily be hacked. I was originally trying to deala with session variable since they were the most secure.
Reply With Quote
  #7  
Old 12-27-2008, 02:39 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Please note that putenv() might not function as expected in Safe Mode for example.

Is the included script on the same server?

If yes, then why do you include it with an URL instead of a local path. If oncluded locally it can inherit environment, and even variables defined in the local scope of the calling script.

If on another server, then you can never pass environment variables, as each server will have it's own environment. The only way to pass parameters is in the request string.
Reply With Quote
  #8  
Old 12-27-2008, 03:13 PM
pianoman993 pianoman993 is offline
 
Join Date: Oct 2008
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks so far for all your useful information.

Marco, would it be possible for you to show me a code example of how to pass information such as the username ($vbulletin->userinfo['username']) into a secure string that I could pass into a CGI script? And also, where would I do that, in the global.php file, a plugin?

Much thanks!

- Pianoman993

Also, just to give you some frame of reference so you know where I'm coming from, this is part of the CGI script.

Code:
# PREFs Section 03: Security.
############################################################################
# Password Protection, Option 3 of 5 (use your site's existing login system):
#
# If your site already has a login system, either cookie-based or based on
# PHP sessions, you can make FileChucker integrate with it.
#
# If using the PHP session method, you must set the following environment
# variables from PHP just before calling filechucker.cgi from PHP:
#f
# 	putenv("PHP_ENC_USERNAME=$username");	# where $username is your PHP user variable.
# 	putenv("PHP_ENC_ISADMIN=$X");		# where $X is a 0 or a 1.
#
# This option is mutually exclusive with the integrate_with_userbase option.
#
$PREF{integrate_with_existing_login_system}		= 'yes';
$PREF{login_error_message}				= qq`Error: not logged in.&nbsp; Perhaps you need to <a href="/">go home</a> and log in first?`;
#$PREF{logout_url}					= '/logout/';
#$PREF{login_url}					= '/login/';
#$PREF{forced_logout_link}				= qq`<p>Logging out; <a href="%%logout_url%%">click here</a> to continue.</p>\n`;
#
$PREF{enable_username_from_cookie}			= 'no';
$PREF{member_username_cookie_name}			= 'username';
$PREF{admin_username_cookie_name}			= 'admin';
#
$PREF{enable_username_from_php_session}			= 'yes';
Code:
# PREFs Section 04: User-directories.
############################################################################
# If you are already storing a username/userdir variable in PHP sessions on
# your server, you can make FileChucker use that.
#
# For Method 1, you'll need to be calling FileChucker from an /upload/index.php
# file like this:
#
#	<?php
#		# set an environment variable from your PHP username variable:
#		session_start(); putenv("PHP_ENC_USERDIR=$username");
#		require("call_filechucker.php");
#	?>
#
# To get the call_filechucker.php file, see step #5 in the instructions:
#
#	http://encodable.com/filechucker/#instructions
#
# For Method 2, you don't necessarily need to call FileChucker exactly that
# way; instead, you'll need to have the PHP::Session Perl module installed on
# your server, and PHP's save_path will need to be readable from Perl.
#
$PREF{enable_userdir_from_php_session__method1}		= 'no';
$PREF{php_session_cookie_name}				= 'PHPSESSID';
$PREF{php_session_cache_ttl}				= 60*60*24; # in seconds.
#
$PREF{enable_userdir_from_php_session__method2}		= 'no';
$PREF{php_session_cookie_name}				= 'PHPSESSID';
$PREF{php_session_save_path}				= '/var/lib/php/session'; # or perhaps '/tmp';
$PREF{php_session_username_variable}			= 'username';
Reply With Quote
  #9  
Old 12-27-2008, 03:16 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why not start by answering the question i posted in my previous post.

No answer = no good answer from me.
Reply With Quote
  #10  
Old 12-27-2008, 03:18 PM
pianoman993 pianoman993 is offline
 
Join Date: Oct 2008
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry. My fault. The included script IS on the server. There you are. I have to use the full filename to include it or else it does not work.

In essence, I am trying to integrate with vbulletin's login.
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 10:52 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.04521 seconds
  • Memory Usage 2,262KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete