vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Howto include() my.php in Vbulletin if no output Display (https://vborg.vbsupport.ru/showthread.php?t=188265)

megatrue 08-15-2008 10:27 PM

Howto include() my.php in Vbulletin if no output Display
 
I have a php script, it needs to included at the very PHP script this Vbulletin.

Code:

<IfModule mod_php5.c>
  php_value auto_prepend_file "/my.php"
</IfModule>

but this script can't get _SERVER["REMOTE_ADDR"], only if i tun register_globals = On
anyone knows, how to fix this problem.

Marco van Herwaarden 08-16-2008 09:52 AM

$_SERVER['REMOTE_ADDR'] should be available even with register globals turned off. Otherwise some things in vBulletin would also not work.

But if it will work as an auto_prepend_file like you are trying i don't know.

megatrue 08-16-2008 11:55 AM

Quote:

Originally Posted by Marco van Herwaarden (Post 1599878)
$_SERVER['REMOTE_ADDR'] should be available even with register globals turned off. Otherwise some things in vBulletin would also not work.

But if it will work as an auto_prepend_file like you are trying i don't know.

Thanks for response

shown me please simply way to inculude() my.php at the very PHP script this Vbulletin and get $_SERVER['REMOTE_ADDR'].

I have a test script geschieben. It can get $_SERVER['REMOTE_ADDR'].
in browser: http://mysite.com/test.php

test script:

Code:

<?php
$ip = $_SERVER['REMOTE_ADDR'];
echo "$ip";
?>

but if 'require_once('my.php')' filled in showthread.php throw errors.

Code:

PHP Notice:  Undefined index:  REMOTE_ADDR in my.php on line XX
Why??

i have read
http://www.vbulletin.com/docs/html/t..._externalfiles
if i want only to run a php script at top of every php script this vbulletin.
It is nothing with output Display.
below code is correct for this thing? Howto test it?

Create a Plug-in for global_start
Code:

ob_start();
require_once(DIR.'my.php');
ob_end_clean();


MoT3rror 08-17-2008 03:52 AM

Well for one this line will output $ip not xx.xx.xx.xx.
PHP Code:

echo '$ip'

Also if you are including the file at the global_start hook you can use IPADDRESS constant for the user IP address.

You might just have found a bug in PHP with php_value auto_prepend_file so you report the bug and see what the PHP developers say.

megatrue 08-17-2008 11:20 AM

Quote:

Originally Posted by MoT3rror (Post 1600482)
Well for one this line will output $ip not xx.xx.xx.xx.
PHP Code:

echo '$ip'

Also if you are including the file at the global_start hook you can use IPADDRESS constant for the user IP address.

You might just have found a bug in PHP with php_value auto_prepend_file so you report the bug and see what the PHP developers say.

my fool, I have corrected. in my test.php is echo "$ip";
thank you for response.


All times are GMT. The time now is 09:07 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.01309 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
  • (4)bbcode_code_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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