vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Can't get plugin code to work (https://vborg.vbsupport.ru/showthread.php?t=199854)

Marco van Herwaarden 12-27-2008 03:31 PM

If the script is local, then you should also include it clocally:

Do not:
PHP Code:

include('http://www.mysite.com/myscript.php'); 

But:
PHP Code:

include('./myscript.php'); 

With the 2nd option you will run the script inside the scope of the calling script, meaning that all variables (within scope) are already available in the included script. No need to pass parameters or set an environment.

pianoman993 12-27-2008 03:37 PM

Thanks for your post.

So your saying that this: (below) is unnecessary? Would I create a simple variable in the page that calls the CGI script, or would I do it in the vbulletin plugin? Also, what would the CGI variable look like? Would it look like $ENV{username}; ?

Code:

#        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.

Your help is much appreciated, thanks!
- Pianoman993

Marco van Herwaarden 12-27-2008 03:50 PM

You would call it from a plugin, you can not execute PHP code in a template (HTML).

There is no "CGI variable". They are just simple PHP variables as used anywhere in a PHP-script.

Consider the following 2 scripts:
Main script "test.php"
PHP Code:

<?php
// Main test script test.php
$mainvar "local set in test.php";
include(
'./sub.php');
echo 
"<br />test.php: Var set in sub: " $subvar;

?>

And the 2nd script "sub.php" (store in the same directory as test.php):
PHP Code:

<?php
// sub.php
echo "<br />sub.php: Value for \$mainvar: " $mainvar;
global 
$subvar;
$subvar "This value was set in sub";
?>

Now point your browser to test.php.

You will see that the variable $mainvar that was set in "test.php" is also available in "sub.php" without any variable passing or such. The same goes for $subvar, set in sub.php and still available when returning in test.php.

pianoman993 12-27-2008 04:31 PM

Alright so here is my new plugin code:

PHP Code:

ob_start();

print 
$vbulletin->userinfo['username'];
global 
$username;
$username ob_get_contents();

ob_end_clean(); 

And here is my CGI File

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}                = 'no';
$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}                        = 'anderma';
#
$PREF{enable_username_from_php_session}                        = 'yes';

Do I set $PREF{member_username_cookie_name} to $username?

Dismounted 12-28-2008 03:18 AM

Quote:

Originally Posted by pianoman993 (Post 1694778)
That could easily be hacked. I was originally trying to deala with session variable since they were the most secure.

You can pass the string and add another item with the string hashed with a salt that only the scripts know. The other script can always verify this hash to make sure.

pianoman993 12-28-2008 04:56 AM

Gotcha, that'll work. Thanks!


All times are GMT. The time now is 03:43 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.01894 seconds
  • Memory Usage 1,746KB
  • 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
  • (2)bbcode_code_printable
  • (5)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete