Using $_SERVER[SERVER_ADDR] In SRC Url?

Aug 30, 2006

I've just begun exploring php and have a question about the $_SERVER[SERVER_ADDR] variable.

My dilemma is as follows. Recently i created a webpage that use an embedded php script to stream audio from my site. The trouble i have is that i'm on dynamic IP connection.

Whenever my IP changes the absolute adresses on my index.html page to the php components break and the site don't work properly until i've manually corrected this. Since this requires constant monitoring of the site i've been trying to find a solution to fix this.

My thought then went to using the $_SERVER[SERVER_ADDR] variable in these url' to update them automatically. However, it only worked partially.

In the following lines it was possible to change the IP number part in the url with a variable containing the $_SERVER[SERVER_ADDR] string........

ADVERTISEMENT

Cron With $_SERVER[REMOTE_ADDR] And $_SERVER[SERVER_ADDR]

Mar 28, 2011

I'm on HostMonster and I'm trying to setup cron to play nicely with a Drupal install I have running and I'm running into problems trying to code for a condition that says, "IF I'm the server and I'm making the request to do CRON, then do the following..."Basically (in layman's terms), I'm having a hard time trying to figure out how I should code for cron requests from the server, which brings me to the following questions:1.) Do cron jobs always execute from the host server? For example, if $_SERVER[SERVER_ADDR] is always "123.123.123.123", does this mean that the 583 bytes sent for cron jobs always come from the same IP address or are there exceptions to this? The reason I ask this is because I have a poor man's byte counter in this cron code I'm working with that sets up a file read and keeps you in the reading loop until the byte count reaches 583 (which, according to my IP logs, is the number of bytes sent with each cron "ping" that gets made.) The code isn't firing, however, because I'm having a hard time making the code run from either cron requests or else from an inconsistency between the IP comparison code I have.2.) Before any cron code gets executed, I have "ignore_user_abort(true);" called at the beginning of the page. Will this effectively process all proceeding code thereafter if cron pings the page? In other words, will using this make the page get processed as if someone traveled to the cron.php page in their browser?

View 7 Replies View Related

$_server['server_addr'] = '127.0.0.1';

Dec 28, 2005

Which is totally wrong as it should be the network IP address instead. What must I change and where to fix this, sorry I absolutely don't know and couldn't find it online anywhere.

View 3 Replies View Related

$_SERVER['SERVER_ADDR'] Isn't Returning Anthing?

Mar 4, 2007

Does anyone know why $_SERVER['SERVER_ADDR'] isn't returning anthing? and which global array i should use to return "localhost" and 127.0.0.1 (localhost default IP).

View 9 Replies View Related

Set The $SERVER Variable To $_SERVER['SERVER_ADDR'] In The Class?

Apr 18, 2011

I have a simple class like this:

<?php
class packet {
private $SERVER = "192.168.1.100";
}
?>

This works fine on localhost but on the server the $SERVER variable needs to be "72.20.32.58" instead. It's a pain having to keep changing this manually and using "localhost" doesn't work for some reason.I wanted to use $_SERVER['SERVER_ADDR'] but it errors when I use it. I have an issue with PHP/Apache which means I can't see the error that it returns.how I could set the $SERVER variable to $_SERVER['SERVER_ADDR'] in the class?

View 3 Replies View Related

SERVER_ADDR Undefined Index?

Jan 21, 2009

I am getting an undefined index on my config page and it reads:

Notice: Undefined index: SERVER_ADDR in inc/config
.inc.php on line 3

how I can fix that? I know its warning, but would still like to get at it. I am using it to check for the address whether to use my local or remote config settings.

View 4 Replies View Related

Opendir With $_SERVER['HTTP_HOST'] Or $_SERVER['DOCUMENT_ROOT']

Oct 20, 2003

Is there a way to use opendir() using some sort of absolute path?
I want a file to open the same directory on my site, no matter from what directory it is called.

For example, I have the following variables, but no combination seems to work for me.

Q: Does opendir() ONLY deal with relative paths?
Q: If opendir() works with absolute path, am I missing something?PHP Code:

View 1 Replies View Related

Setting A $_SERVER Value ($_SERVER['something']) Using Apache .htaccess?

Mar 4, 2009

Is it possible using .htaccess or other apache powers to set a custom server value in the php array $_SERVER.

for example
if($_SERVER['is_special']) {
echo "Yeah for us!";
} else {
[code]...

I realize I ask a lot of questions that the answer is no so feel free to say so.

View 2 Replies View Related

Apache - $_SERVER PATH_INFO And $_SERVER PORIG_PATH_INFO'?

Apr 12, 2011

what's the difference between them? how to use them. i print_r($_SERVER). there is no result of $_SERVER['PATH_INFO'] and $_SERVER['PORIG_PATH_INFO'] .why? how to enable it.i have read the php manual on them, but still don't understand them.

View 2 Replies View Related

Difference Between: $_SERVER SCRIPT_NAME And $_SERVER PHP_SELF?

Jun 24, 2011

What is the difference between:

$_SERVER['SCRIPT_NAME']
and
$_SERVER['PHP_SELF']

View 3 Replies View Related

$_SERVER['PHP_SELF'] Or $_SERVER['HTTP_REFERER']?

Jan 11, 2005

If i need to fix the page name from which the click was originated, what is better to fix: $_SERVER['PHP_SELF'] or $_SERVER['HTTP_REFERER']? I mean the click to an external resource.

View 1 Replies View Related

Get Value $_SERVER['REMOTE_ADDR'] And/or $_SERVER REMOTE_HOST?

Dec 28, 2009

I simply love this site! Hope you all have a great Christmas holiday, and wish everyone have a prosperous 2010!

Anyway, I have a quick question regarding the global variables
$_SERVER['REMOTE_ADDR'] and/or $_SERVER['REMOTE_HOST']
[code]...........

View 5 Replies View Related

$_SERVER['PATH_INFO'] And $_SERVER['PORIG_PATH_INFO']?

Apr 11, 2011

what's the difference between them? how to use them. i [ICODE]print_r($_SERVER).[/ICODE] there are no result of $_SERVER['PATH_INFO'] and $_SERVER['PORIG_PATH_INFO'] .why? how to enable it.i have read the php manual about them, but still don't understand

View 1 Replies View Related

$_server

Jan 28, 2005

I am having trouble with this line:

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" >

I get this error:

Parse error: parse error, unexpected '?'

View 1 Replies View Related

$_SERVER?

Jul 18, 2007

I have a file called index.php (localhost/blabla/index.php), and my mind has just gone blank and I cant remember how to get the file path without the file info... for example I need to get

localhost/blabla/

I am sure it is using $_SERVER but which argument =/

View 4 Replies View Related

$_SERVER[' ?? ']

May 13, 2007

if i go:
$homePage = $_SERVER['REQUEST_URI'];
i get:
home page = /indie/index.php?list=top

if i go:
$homePage = basename($_SERVER[PHP_SELF]);
i get:
home page = index.php

what i want is something in the middle:

home page = index.php?list=top

so it only shows the base script name, but also includes the parameters.

View 4 Replies View Related

$_SERVER Get Just The Url?

Mar 21, 2007

is there a way to get just the url?

for instance if I have an address such as Domain Name/Oilers/oilers.html

in every instance I do $path = $_SERVER['SCRIPT_NAME']; I get /Oilers/oilers.html

If i just want /Oilers/ with the file running name at the end, how would I go about?

View 4 Replies View Related

Using $_SERVER['http_referer']

Jun 27, 2007

I'm using $_SERVER['http_referer'] to see which site the visitors on my site
is coming from. It works OK, but as we all now, not all sites give
http_referer a value, i.e. miniclip.com.
What I DON'T understand is how my web-statistics program (awstats) can tell
me that a lot of the visitors on my site comes from miniclip.com. How can
awstats know, and http_referer don't?

View 3 Replies View Related

$_SERVER['HTTP_USER_AGENT']

Jul 21, 2005

what is exact sense of $_SERVER['HTTP_USER_AGENT'] output?

View 1 Replies View Related

$_SERVER Not Working

Jun 15, 2006

I really loosing sleep over this one. I have php 4.4 running on Apache
2.... php works fine. phpinfo() retuns everything as it should..
However when I try to print anything using $_SERVER e.g $_SERVER
['HTTP_HOST']... it returns nothing. Then I realized that even $_GET
and $_POST are not working. All the uper globals are not working. They
just come back with e.g Array ['HTTP_HOST']...

View 7 Replies View Related

JSP Equivalent To PHP $_SERVER?

Jan 16, 2006

I looked up System.getProperties, but to be honest, I have no clue how
to use it in light of what I can do in PHP, which is this:

<?php echo $_SERVER['HTTP_USER_AGENT'] . ' ' . $_SERVER['SERVER_URI'];
?>

it would be very nice to find the JSP equivalent of <? phpinfo(); ?>
(anyone know who knows both PHP and JSP?) but until then, what on earth
do I do?

View 2 Replies View Related

$_SERVER['PATH_INFO'] Where Is It Under Php 4.3.8 ?????

Jul 17, 2005

I compiled a recent version of php 4.3.8 on Suse 9.0 Pro with apache
1.3.28 that was a precompiled for Suse as an rpm. When I look at
phpinfo(), I do not see the environment setting $_SERVER['PATH_INFO']
however, I can see this setting on a different box running windows
and on yet another box running linux. Is there something I have to
set in the configuration for the value to show up?

View 2 Replies View Related

$_SERVER['SCRIPT_FILENAME'] = '/php/php.exe'?

Jul 17, 2005

I am trying to use script filename to give me the entire path and
filename of the current page. For some reason though it is giving me
the value of '/php/php.exe'. Why might this be?

In my Apache http.conf file I do have the line:

Action application/x-httpd-php "/php/php.exe"

Might this have something to do with it?

View 1 Replies View Related

$_SERVER[PHP_self]

Jun 6, 2007

can someone explain me with an easy example what the function for?

I've read on the php.net,

View 4 Replies View Related

Use Of $_SERVER['DOCUMENT_ROOT'].

May 10, 2006

I'm working on a large intranet group site with a lot of pages, file types,
folders, subfolders, etc. I am using the include ('../includes/file.php') ,
but I would like to have a single snippet that will work for all .php/.html
pages in all subfolders. I have seen the $_SERVER['DOCUMENT_ROOT']
indicated as a way to access the root of the website without using ../ for
each folder you have to pass up through. However, I cannot get this to work
for me. I've seen recommendations for it's use in FAQs, etc. online, they
all seem to be a little bit different, but none of the formats (assign to a
variable, etc.) work for me. We're using PHP 4.3.2

View 4 Replies View Related

$_SERVER['HTTP_REFERER']

Apr 11, 2007

I was wondering, is there a safer alternative to $_SERVER['HTTP_REFERER']? As I understand, $_SERVER['HTTP_REFERER'] can easily be surpassed by hackers.

View 1 Replies View Related

$_SERVER['FULL_URL']

Jul 24, 2006

This is my current code:

<a href='.$_SERVER['FULL_URL'].'>Here</a>

It works with no problems the link becomes the full url including arguments. However when I change the code to this the link becomes wrong ( I want to add some arguments to the link):

$newarg = '&newarg=egfesgseg'
<a href='.$_SERVER['FULL_URL'].$newarg.'> Here</a>

how to fix this?

View 3 Replies View Related

Use Of $_SERVER['QUERY_STRING']

Jan 30, 2007

I want to know when we should use $_SERVER['QUERY_STRING'] and how it works.. and the difference with $_SERVER['PHP_SELF'] also ?

View 1 Replies View Related

$_server['http_referer']

Dec 22, 2005

I want to check to see if my webpage was directly accessed or to see where it was linked from, but if I use this variable($_SERVER['HTTP_REFERER']) it gives me an error when it was directly accessed. I want to be able to either catch the error or check to see if it exsists first before I use it. How do I do it? Either one is fine.

View 3 Replies View Related

$_server['redirect_url'];

May 19, 2006

I have made a .htaccsess file with the following in it:

ErrorDocument 404 /status/status.php

And the status.php has the code:

$url = $_SERVER['REDIRECT_URL'];

Now I read: In the folder on the server if I make up a filename it would redirect to the status.php

Now if i make up a file name (eg. fake.php) it redirects to the status.php fine but the $url variable comes up with status.php and not the fake.php

Anything I am doing wrong?

View 3 Replies View Related

$_SERVER['HTTP_REFERER'];

Sep 27, 2006

I'm having a problem using $_SERVER['HTTP_REFERER']; I have a website and I want to know where new members are coming from before they click on my home page. The home page of my site does have a .php extension. I am using $page = $_SERVER['HTTP_REFERER']; but for some reason it will not register the information I need. I have tried other variables such as $_SERVER['REMOTE_ADDR'] and $_SERVER['HTTP_USER_AGENT'] and these work perfectly. Any ideas on why $_SERVER['HTTP_REFERER'] won't work. Yes, I have tried going to the home page from a link outside of my site. I've tried this function using javascript and it works, only problem is I don't know how to change a javascript variable into a php variable. Any ideas on that one too?

View 6 Replies View Related

Getenv Vs. $_SERVER

May 15, 2006

HTTP_USER_AGENT, REMOTE_ADDR, HTTP_REFERER

I am trying to get these values, I will use $_SERVER to get them. But what is the difference to use getenv or $_SERVER to get the above values? Some notes said use $_SERVER due to getenv not works in all cases. So should we drop getenv and use $_SERVER, that is the advice?

View 1 Replies View Related

$_SERVER And Mod_rewrite

Oct 21, 2004

I already tried the fellows in the Apache forum, but Im thinking this is more of a quirk in PHP than Apache

Searching this forum I found great help to generating rewrite rules to make a dynamic request appear as static search engine friendly URLs. For example :?cat1=foo&cat2 => bar /foo/bar.

My php seems like its being ornery.

Here are my rewrite rules. This is inside of a directory directive:

RewriteRule ^([^/]+)/([^/]+) index.php?state=$1&city=$2 [L]
RewriteRule ^([^/]+) index.php?state=$1 [L]

Now after accessing somehting like http://mysite.com/directory/AK, in PHP when I print out the $_SERVER variable I get two interesting bits of output:

[REDIRECT_QUERY_STRING] => state=AK
[QUERY_STRING] => state=index.php

How on Earth did state get assigned to be index.php in QUERY_STRING? Its not in the original query at all. Do you think some other directive higher up in the site is fiddling with things? I think REDRIECT_QUERY_STRING is an apache variable. Did apache work correctly and PHP is goofing up?

View 1 Replies View Related

{$_server['document_root']}

Oct 10, 2005

I am trying to import my css file in my header which uses a browser detector and works fine in both ie and mozilla with this code:

<style type="text/css" media="screen">
<?php
if ($browser == 'ns6') {
echo '@import "includes/layout2.css";'
} else {
echo "@import "{$_SERVER['DOCUMENT_ROOT']}/123/includes/layout1.css";";
}
?>
</style>

however i would like to now change to {$_SERVER['DOCUMENT_ROOT']} so that i can call it from sub directories but now only works in ie and not mozilla:

<style type="text/css" media="screen">
<?php
if ($browser == 'ns6') {
echo "@import "{$_SERVER['DOCUMENT_ROOT']}/123/includes/layout2.css";";
} else {
echo "@import "{$_SERVER['DOCUMENT_ROOT']}/123/includes/layout1.css";";
}
?>
</style>

View 1 Replies View Related

$_server['php_self']

Apr 25, 2006

what is this variable means? and what does it do? BTW, this is my first time posting in this forum. My name is Neneng and i am glad i joined phpbuilder forum. Thanks for the great site.

View 2 Replies View Related

$_server['auth_user']

Nov 13, 2006

I've found several PHP server-variables (phpinfo()), which contents the actual domain and username of the actual user (e.g. $_SERVER['AUTH_USER']=domainusername) on a WindowsXP Client.

What I want to do is to set up a kind of Single-Sign-On-Website. A user, which could then authenticated automatically, should be able to change his own entries in a telephone book, but not these of other people, as an example...

How can I trust the content of this variable? Where comes that information from? Can a normal user change this?

At least, what I want to really know: Is there a secure way to retrieve the information of the currently logged on user from the client computer?

View 3 Replies View Related

&lt;?=$_SERVER['PHP_SELF']?&gt;

Sep 9, 2005

as we know <?=$_SERVER['PHP_SELF']?> will let the php load the same page, let say index.php itself.
anyway if my current url is 'index.php?sort=3' how can i load the page itself since the <?=$_SERVER['PHP_SELF']?> will only load 'index.php' without '?sort=3'.

View 5 Replies View Related

$_SERVER['HTTP_REFERRER']

Mar 14, 2004

Here is a snippet of code which I have rediced the proble to and worked with to demonstrate the problem.
<?

$ipaddress=$_SERVER['REMOTE_ADDR'];
$referrer=$_SERVER['HTTP_REFERRER'];
print "Ipaddress ".$ipaddress."<br>";
print "Referrer ".$referrer."<br>";
?>

When run there is consistently nothing being printed for the referrer address. (The ip address is fine.) This occurs even when I put a test link on a page on a different unconnected server on the other side of the Atlantic Ocean.

Is there something wrong with the server set up ( out of my direct control.) or is there something I am doing wrong?

View 1 Replies View Related

$_server['document_root'];

Jun 29, 2005

I am trying to use $_SERVER['DOCUMENT_ROOT']; but I get the following error:

Notice: Undefined index: DOCUMENT_ROOT in c:inetpubwwwroothkpTest2.php on line 10

I am using IIS on my XP Pro machine.

Here is the entire program: (Can anyone tell me what I am doing wrong?)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
echo $_SERVER['DOCUMENT_ROOT'];
?>

</body>
</html>

View 1 Replies View Related

$_SERVER['REMOTE_ADDR']

Oct 21, 2006

On my website i use the users IP address to detect whether they have loggedin or not but when i try to login in myself it returns an error.

you can see what happen at http://www.clivesden.co.uk/members.php?action=login

It shows me as having two different IP Addresses How is this possible

View 8 Replies View Related

What Does This Do? $_SERVER['PHP_SELF']

Jan 4, 2007

From what I can see $_SERVER['PHP_SELF'] is supposed to keep the same page in the browser when a form sends. If you use it in the form action= area.

What I don't understand is usually in a form action you have to connect with what else you need the form to do. Such as sending form fields to something else. A database or an email or something. So if $_SERVER['PHP_SELF'] takes up the form action slot, how can you send the form fields?

View 13 Replies View Related

$_SERVER Variables

Jul 17, 2005

I have a login that uses header information to authenticate users.

header('WWW-Authenticate: Basic realm="my site", FALSE');

These values go into the php_auth_user and PHP_AUTH_PW in $_SERVER work just fine. But when I try to unset($_SERVER['PHP_AUTH_USER']) or PW and go to a different page they are just reset to the way they were before.

If you need more information let me know. Do I have to do more than just unset to reset them to null or to blank?

View 3 Replies View Related

_SERVER['HTTP_USER_AGENT']

Jan 23, 2006

are

$_SERVER['HTTP_USER_AGENT'] in php and navigator.userAgent in js

the same thing? always? I just need to determine if the browser is IE5+ on win32 (.png issues). I need to know that on the server (php needs to know) and on the client.

View 1 Replies View Related

$_SERVER['DOCUMENT_ROOT'] Not Set?

Nov 19, 2009

Im currently in the process of changing web hosts .Our old server was running Windows 2003 IIS 6.0 with PHP 5.0. Our new server is also running Windows 2003 IIS 6.0 with PHP 5.0.However, i use $_SERVER['DOCUMENT_ROOT'] in my scripts and the new server is throwing errors.
I put a phpinfo file on each server and found that under "PHP Variables" that the old server was setting $_SERVER['DOCUMENT_ROOT'] but the new server does not set that variable.

I checked the php.ini configuration file on the old server (in which $_SERVER['DOCUMENT_ROOT'] was being set, but the "doc_root" setting was empty which i found odd. Surely the $_SERVER['DOCUMENT_ROOT'] setting is set in this file?Its surely not being set as an environment variable otherwise how would $_SERVER['DOCUMENT_ROOT'] be appearing under "PHP Variables" on a phpinfo page?

Ideally, id like $_SERVER['DOCUMENT_ROOT'] set in php.ini (as opposed to writing PHP code) as it is a cleaner solution.

View 6 Replies View Related

$_SERVER['PHP_SELF'] On IIS

Aug 23, 2007

I'm testing some code on IIS. The form submission is not working on IIS but works fine on Apache. This is the form code:

<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
This is appearing in the browser address bar when submitting the form:
http://192.168.10.89/multiple_select/%3C?=$_SERVER['PHP_SELF']?>

On IIS a "HTTP 405 - Resource not allowed" error is returned because of the garbage in the adress bar.

View 2 Replies View Related

ADVERTISEMENT