PHP embedded variables

Questions about hosting a Website, using MySQL, PhP or MariaDB may be posted here.
Forum rules
1) This is a user forum for Synology users to share experience/help out each other: if you need direct assistance from the Synology technical support team, please use the following form:
https://myds.synology.com/support/suppo ... p?lang=enu
2) To avoid putting users' DiskStation at risk, please don't paste links to any patches provided by our Support team as we will systematically remove them. Our Support team will provide the correct patch for your DiskStation model.

PHP embedded variables

Postby axj » Sun Jan 16, 2011 12:51 am

Is there any way to read or get the external ip-address no matter which router you have?

I had for a long time a Belkin Router (N1 Vision), where the variable "REMOTE_ADDR" contained the exter IP!
Now after the Belkin is gone to the router-paradise I have tried 3 different routers and none of them sets that variable.

Do anybody know if there is a router which can read the correct external ip-address?
The DS-509+ knows that addess and the router too, but how to get it readable?
DS509+ 4*1TB Raid+1TB DSM 4.0-2219. Logitech BOOM+Duet 7.6.1, WebCam: Linksys WVC54GCA + TrendNet TV-IP121
DS212+ 1TB & D-Link DIR-685, HP C7280, Dell 3100cn. iPad3, Programming Pascal, Clarion 5.5, html/php. http://axj.dk
User avatar
axj
Specialist
Specialist
 
Posts: 1059
Joined: Fri Jan 02, 2009 10:59 am
Location: Esbjerg, Danmark

Re: PHP embedded variables

Postby HarryPotter » Sun Jan 16, 2011 12:51 pm

This has nothing to do with the router but with the apache configuration.

Did you try with $_SERVER['REMOTE_ADDR'] instead of $REMOTE_ADDR
*Please do not Private Message me for support questions; leave it on the forum so all members can learn. Thanks!*

DS713+ / DSM 5.1-5004 / 2 x HD204UI (RAID0) / LMS 7.7.3-039
DS712+ / DSM 5.1-5004 / 2 x HDS721010KLA330 (RAID0)
DS110+ / DSM 5.0-4493-5 / HD154UI
DS408 / DSM 4.0 2265 / 2 x ST31000340AS (RAID0) + 1 x HDS721010KLA330
DS207+ / DSM 3.1.1639 / ST31000340AS + WD5000KS

2 Squeezebox 3 + Boom
Rapsody N35

APC Smart UPS SUA750i
User avatar
HarryPotter
Honorary Moderator
Honorary Moderator
 
Posts: 14623
Joined: Mon Oct 23, 2006 12:48 pm
Location: Switzerland

Re: PHP embedded variables

Postby axj » Sun Jan 16, 2011 1:46 pm

That is the same! See the PHP-info using <? phpinfo(); ?>

We have a lot of variables in the form REMOTE_ADDR as an example and the $_SERVER['REMOTE_ADDR']
and getenv(REMOTE_ADDR) gives the same value.

With my old router the REMOTE_ADDR had the value of the routers external address while the new
router (TRENDNET TEW-&#)GR and LINKSYS E2000/E3000 - Cisco) gives 192.168.10.1 (internal ip).

I will do some more tests when my new DNS works again!

Do you know how the DS gets the external value ?
DS509+ 4*1TB Raid+1TB DSM 4.0-2219. Logitech BOOM+Duet 7.6.1, WebCam: Linksys WVC54GCA + TrendNet TV-IP121
DS212+ 1TB & D-Link DIR-685, HP C7280, Dell 3100cn. iPad3, Programming Pascal, Clarion 5.5, html/php. http://axj.dk
User avatar
axj
Specialist
Specialist
 
Posts: 1059
Joined: Fri Jan 02, 2009 10:59 am
Location: Esbjerg, Danmark

Re: PHP embedded variables

Postby axj » Sun Jan 16, 2011 3:03 pm

Now my DNS is working again!

And when I use http://axj.dk and look at the PHP Info, I can see:
SERVER_NAME: axj.dk
SERVER_ADDR: 192.168.10.107
REMOTE_ADDR: 192.168.10.1 which is my routers intern ip-address

Belkin gave here the extern ip-address when I use http://axj.dk
but the intern ip-address when I used http:/192.107.10.107.
and I did not change anything else but new router!!
DS509+ 4*1TB Raid+1TB DSM 4.0-2219. Logitech BOOM+Duet 7.6.1, WebCam: Linksys WVC54GCA + TrendNet TV-IP121
DS212+ 1TB & D-Link DIR-685, HP C7280, Dell 3100cn. iPad3, Programming Pascal, Clarion 5.5, html/php. http://axj.dk
User avatar
axj
Specialist
Specialist
 
Posts: 1059
Joined: Fri Jan 02, 2009 10:59 am
Location: Esbjerg, Danmark

Re: PHP embedded variables

Postby axj » Sun Jan 16, 2011 3:48 pm

I have found a usable solution: $ipAddress = gethostbyname($_SERVER['SERVER_NAME']);
which works as longs as DDNS is working
DS509+ 4*1TB Raid+1TB DSM 4.0-2219. Logitech BOOM+Duet 7.6.1, WebCam: Linksys WVC54GCA + TrendNet TV-IP121
DS212+ 1TB & D-Link DIR-685, HP C7280, Dell 3100cn. iPad3, Programming Pascal, Clarion 5.5, html/php. http://axj.dk
User avatar
axj
Specialist
Specialist
 
Posts: 1059
Joined: Fri Jan 02, 2009 10:59 am
Location: Esbjerg, Danmark

Re: PHP embedded variables

Postby HarryPotter » Sun Jan 16, 2011 5:50 pm

AFAIK the DS gets the external address from http://download.synology.com/
*Please do not Private Message me for support questions; leave it on the forum so all members can learn. Thanks!*

DS713+ / DSM 5.1-5004 / 2 x HD204UI (RAID0) / LMS 7.7.3-039
DS712+ / DSM 5.1-5004 / 2 x HDS721010KLA330 (RAID0)
DS110+ / DSM 5.0-4493-5 / HD154UI
DS408 / DSM 4.0 2265 / 2 x ST31000340AS (RAID0) + 1 x HDS721010KLA330
DS207+ / DSM 3.1.1639 / ST31000340AS + WD5000KS

2 Squeezebox 3 + Boom
Rapsody N35

APC Smart UPS SUA750i
User avatar
HarryPotter
Honorary Moderator
Honorary Moderator
 
Posts: 14623
Joined: Mon Oct 23, 2006 12:48 pm
Location: Switzerland

Re: PHP embedded variables

Postby axj » Sun Jan 16, 2011 10:05 pm

And that is maybe a little more useful because a domain-name isn't nessacary!
DS509+ 4*1TB Raid+1TB DSM 4.0-2219. Logitech BOOM+Duet 7.6.1, WebCam: Linksys WVC54GCA + TrendNet TV-IP121
DS212+ 1TB & D-Link DIR-685, HP C7280, Dell 3100cn. iPad3, Programming Pascal, Clarion 5.5, html/php. http://axj.dk
User avatar
axj
Specialist
Specialist
 
Posts: 1059
Joined: Fri Jan 02, 2009 10:59 am
Location: Esbjerg, Danmark

Re: PHP embedded variables

Postby axj » Sat Jan 22, 2011 5:29 pm

Does anybody know if the external IP is stored in some variable, which can be read/reached?
The external IP is read by DS in Network - DDNS!
DS509+ 4*1TB Raid+1TB DSM 4.0-2219. Logitech BOOM+Duet 7.6.1, WebCam: Linksys WVC54GCA + TrendNet TV-IP121
DS212+ 1TB & D-Link DIR-685, HP C7280, Dell 3100cn. iPad3, Programming Pascal, Clarion 5.5, html/php. http://axj.dk
User avatar
axj
Specialist
Specialist
 
Posts: 1059
Joined: Fri Jan 02, 2009 10:59 am
Location: Esbjerg, Danmark


Return to Web Server + PHP / MySQL + MariaDB

Who is online

Users browsing this forum: No registered users and 5 guests