vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Graveyard (https://vborg.vbsupport.ru/forumdisplay.php?f=224)
-   -   Administrative and Maintenance Tools - Proxy to Real IP Conversion (https://vborg.vbsupport.ru/showthread.php?t=231873)

fly 06-17-2013 05:25 PM

Quote:

Originally Posted by 0verl0rd (Post 2428725)
It doesn't work with cloudflare.. :( helpppp

https://www.google.com/search?q=cloudflare+vbulletin

Second link.

0verl0rd 06-18-2013 02:01 PM

yeah i have seen that link already...

i also opened a ticket to cloudflare... and they are giving me those 2 options...

I already installed this add-on and the option 2 is somehow difficult because of the construction of code...



How to do this:

PHP Code:

Find: function fetch_ip() { return $_SERVER['REMOTE_ADDR']; }

replace with:

function 
fetch_ip() { if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { return $_SERVER['HTTP_CF_CONNECTING_IP']; } return $_SERVER['REMOTE_ADDR']; } 

with these:

PHP Code:

 /**
* Fetches the IP address of the current visitor
*
* @return string
*/
function fetch_ip()
{
return 
$_SERVER['REMOTE_ADDR'];
}

/**
* Fetches an alternate IP address of the current visitor, attempting to detect proxies etc.
*
* @return string
*/
function fetch_alt_ip()
{
$alt_ip $_SERVER['REMOTE_ADDR'];

if (isset(
$_SERVER['HTTP_X_FORWARDED_FOR']))
{
$altip $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else if (isset(
$_SERVER['HTTP_CLIENT_IP']))
{
$altip $_SERVER['HTTP_CLIENT_IP'];
}
else if (isset(
$_SERVER['HTTP_FROM']))
{
$altip $_SERVER['HTTP_FROM'];
}
else
{
$altip false;
}

if (
$altip AND $this->filter_ip($altip))
{
$alt_ip $altip;
}

return 
$alt_ip;



Bubble #5 08-13-2013 11:49 PM

THANK YOU for this excellent hack Paul!

boggseric 08-16-2013 12:33 AM

Paul, thanks for the hacks!

Question, I am upgrading my 3.8 forum to 4.2. the forum has quite a few posts (15mil) and modifying the post table on the uninstall of the old mod and then the install of the new version is quite a headache and server intensive.

I was looking at the code and it appears to me the only difference is that the old proxyip field was varchar(20) whereas the new one calls for varchar(15). I'm guessing modifying the product code to not drop this column wouldn't cause a problem right? Those extra 5 characters shouldn't be an issue in my opinion but my database skills are not super high.

So basically before uninstalling the old mod change the code to not drop the column and then modify the new plugin xml to not add the column. Note, I'm not asking for instruction of how to do that I can handle that part, just curious if you think this will break anything or cause problems.

Paul M 08-17-2013 07:49 PM

That sounds fine to me.

However - if you just install the new one, without uninstalling the old one, the new one will remove the old product without running the uninstall code anyway.

Same effect, less effort. :)

Bubble #5 08-17-2013 09:25 PM

Paul, how do we nominate this modification for the MOTM? I saw no link or directions...:confused:

djbaxter 08-17-2013 11:32 PM

Quote:

Originally Posted by Bubble #5 (Post 2439428)
Paul, how do we nominate this modification for the MOTM? I saw no link or directions...:confused:

It's currently in the running for the Mod of the Month so all you need to do is go vote for it: https://vborg.vbsupport.ru/portal.php or https://vborg.vbsupport.ru/showthread.php?t=300696

Paul M 08-18-2013 02:30 PM

LOL, so it is. I never noticed that. :)

Disco_Dave 08-19-2013 10:23 AM

Quote:

Originally Posted by Cybex (Post 2381859)
We fixed it ourselves by editing the class_core.php bit:

Code:

// Detect ALL.
      if ($registry->ipaddress == $registry->alt_ip)
      {
          define('PROXYIP','');
      }
      else
      {
          $proxy = true;
          define('PROXYIP',$registry->ipaddress);
      }
     
      if ($proxy)
      {
          define('ALT_IP', $this->ipaddress);
          define('IPADDRESS', $_SERVER['HTTP_X_FORWARDED_FOR']);
      }
      else
      {
          define('IPADDRESS', $_SERVER['HTTP_X_FORWARDED_FOR']);
          define('ALT_IP', $this->alt_ip);
      }

Now the proxy details aren't written properly, but that's not that important for me. At least I see the real IP addresses now.


Where would I place this in the class_core.php??

Dave

boggseric 08-20-2013 02:04 AM

Quote:

Originally Posted by Paul M (Post 2439397)
That sounds fine to me.

However - if you just install the new one, without uninstalling the old one, the new one will remove the old product without running the uninstall code anyway.

Same effect, less effort. :)

Yes, you are right. That does sound much easier. Thanks!


All times are GMT. The time now is 05:04 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.01222 seconds
  • Memory Usage 1,754KB
  • 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
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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