1
shashi_bi
how to map the XOOPS_URL to two ip addresses?
  • 2006/12/12 14:54

  • shashi_bi

  • Just popping in

  • Posts: 28

  • Since: 2006/4/24


Hi

we have two types of users 1) internal 2) customers.

internal users access the site from local ip.

external users acces the same site from public ip.

in mainfile.php we have variable XOOPS_URL,

how to set two ip addresses for single instance.

regards
bsk

2
blueteen
Re: how to map the XOOPS_URL to two ip addresses?
  • 2006/12/12 16:01

  • blueteen

  • Quite a regular

  • Posts: 379

  • Since: 2004/7/16


hello,
maybe something like this ?
in mainfile.php, i changed:
define('XOOPS_URL''http://domain.com');

to:
$hote=getenv("HTTP_HOST"); //domain name used

if ($hote == "1stdomain.com")
$hote "http://1stdomain.com";
else
if (
$hote == "2nddomain.com")
$hote "http://2nddomain.com";

define('XOOPS_URL'$hote);


i'me using this for my intranet, which is also accessible from the internet.
I think that you can adapt this, to test members IP.
If local_ip, then, use local domain, else, use public domain.

3
Opterongeek
Re: how to map the XOOPS_URL to two ip addresses?

So would this still apply today with the newer versions?

I'm trying to set something up on a local system so that I can browse it locally on my intranet, but the problem is that because I'm hosting it locally (windows 2000 using Wampp) I have to set it up "either-or".

I can set it up for the domain name I'm using, works great - except because of the behavior of my Router, I can't edit or view the site internally (I have to use a proxy server or some other work-around which is slow, and could be a potential security risk) or I can set it up to work only internally, but then I can't get to the site from the WWW.

I tried this suggestion in the post above mine, but I don't know php all that well, I am not sure how to edit it, or which fields to edit.

4
skenow
Re: how to map the XOOPS_URL to two ip addresses?
  • 2006/12/29 14:35

  • skenow

  • Home away from home

  • Posts: 993

  • Since: 2004/11/17


The way I got around this in my old intranet is to add an entry in the hosts file on each internal computer routing the domain to a local address. Setting rules on the router didn't work for me.

c:\windows\system32\drivers\etc\hosts (file with no extension)

1.2.3.4 www.yourdomain.com

1.2.3.4 = the local address of your WAMPP server

5
Dave_L
Re: how to map the XOOPS_URL to two ip addresses?
  • 2006/12/29 16:31

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


I do it like this:


define('XOOPS_URL', ((isset($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) === 'on') ? 'https' 'http') . "://{$_SERVER['HTTP_HOST']}/xoops");


That works for both http and https.

"/xoops" should be changed to your actual directory name, or omitted if you installed XOOPS in the web root.

6
Opterongeek
Re: how to map the XOOPS_URL to two ip addresses?

Quote:

Dave_L wrote:
I do it like this:


define('XOOPS_URL', ((isset($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) === 'on') ? 'https' 'http') . "://{$_SERVER['HTTP_HOST']}/xoops");


That works for both http and https.

"/xoops" should be changed to your actual directory name, or omitted if you installed XOOPS in the web root.


You are... awesome. Thank you. Now I get to "play" at home. ;)

7
Opterongeek
Re: how to map the XOOPS_URL to two ip addresses?

nevermind, my bad.

8
sohrab
Re: how to map the XOOPS_URL to two ip addresses?
  • 2007/5/25 2:26

  • sohrab

  • Just popping in

  • Posts: 9

  • Since: 2007/3/17


Yet a bit different way,

<?php
// XOOPS Virtual Path (URL)
// Virtual path to your main XOOPS directory WITHOUT trailing slash
// Example: define('XOOPS_URL', 'http://localhost');
// auto change the host name for local or remote access

$itxx_local_host_ip = gethostbyname("FQDN"); // Use host name part only for win32
$itxx_user_ip = $_SERVER['REMOTE_ADDR'];

$itsl_pattern = "'(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})'";
$itsl_is_local = ((preg_replace($itsl_pattern,"\\1.\\2.\\3",$itxx_user_ip)==preg_replace($itsl_pattern,"\\1.\\2.\\3",$itxx_local_host_ip)))?true:false;


if ($itsl_is_local) {
define('XOOPS_URL', 'http://local.i.p.x');// use local ip 192.168.x.x
} else {
define('XOOPS_URL', 'http://www.itslbd.com');
}
?>

Hope this helps, Note: this is originally from sourceforge.

9
sohrab
Re: how to map the XOOPS_URL to two ip addresses?
  • 2007/5/25 2:45

  • sohrab

  • Just popping in

  • Posts: 9

  • Since: 2007/3/17


forgot to mention,if u setup your browser to not go to ur isp proxy, above method shall only allow u to use your server locally, shall not use ISP proxy for local access, much secure.

I believe it is secure as it checks for IP of local user. Prevents IP spoofing...

10
attock
Re: how to map the XOOPS_URL to two ip addresses?
  • 2007/5/25 13:34

  • attock

  • Not too shy to talk

  • Posts: 138

  • Since: 2006/8/20


I would agree with skenow on this one - the best approach indeed.

Login

Who's Online

213 user(s) are online (133 user(s) are browsing Support Forums)


Members: 0


Guests: 213


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits