PDA

View Full Version : Howto include() my.php in Vbulletin if no output Display


megatrue
08-15-2008, 10:27 PM
I have a php script, it needs to included at the very PHP script this Vbulletin.

<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
$_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:

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

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

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

Why??

i have read
http://www.vbulletin.com/docs/html/templates_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
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.
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
Well for one this line will output $ip not xx.xx.xx.xx.
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.