vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Displaying ip address of user (https://vborg.vbsupport.ru/showthread.php?t=318946)

Duckface 06-04-2015 03:04 PM

No worries man, thanks for your help. It should work...

kh99 06-04-2015 05:10 PM

Quote:

Originally Posted by Duckface (Post 2547138)
Strangely not as logical as it sounds... I even tried (in the template):

PHP Code:

<?php

echo($_SERVER['REMOTE_ADDR']);

?>

And still nothing.

I think that probably didn't work for you because you can't do that in a template.

I think you should really use the defined constant IPADDRESS, because it's been checked to make sure it contains an ipaddress and not something else (that you're then going to display), and also it uses the proxy settings to display the user's ip address instead of the proxy (if that applies to you).

Anyway, one possible reason for Mark's code not working would be if you're not setting THIS_SCRIPT to 'donate' in your custom script. If you have a custom php file, then you must be creating and rendering the template in there? Then instead of using a plugin you could edit your donate.php and add code to register the ip address to the template. I can't give you the exact code for that without seeing donate.php, but maybe you can figure it out if you look at donate.php. It would be something like this (with the create and render calls already existing in your code):

Code:

$templater = vB_Template::create('Donate');
    // You might have other calls to register here
    $templater->register('userip', IPADDRESS);
$templater->render();

Then in the template you'd use {vb:raw userip}.

If you don't want to change donate.php then you should be able to use a plugin like Mark suggested. Do you have a line something like
Code:

define('THIS_SCRIPT', 'donate');
in donate.php?


All times are GMT. The time now is 04:30 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.01156 seconds
  • Memory Usage 1,717KB
  • 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
  • (1)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
  • (2)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