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 "", 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



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

View 5 Replies

$_server['server_addr'] = '';

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


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........

View 2 Replies

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

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

View 9 Replies

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

I have a simple class like this:

class packet {
private $SERVER = "";

This works fine on localhost but on the server the $SERVER variable needs to be "" 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 I could set the $SERVER variable to $_SERVER['SERVER_ADDR'] in the class?

View 3 Replies


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

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

View 8 Replies

Set Wildcard In $_SERVER['REMOTE_ADDR'] ?

is it possible to set $_SERVER['REMOTE_ADDR'] to a wildcard, so that anyone on the network can see this?

if($_SERVER['REMOTE_ADDR'] == ""){
<a href="" target="_blank" title="free hit counter"><img border="0" alt="free hit counter" src=""></a>

but i want the network can see the counter... so it would look like this?

if($_SERVER['REMOTE_ADDR'] == "112.200.150.%")

View 2 Replies

Get An IP Address Using $_SERVER ['REMOTE_ADDR']

so I know how to get an IP address using $_SERVER['REMOTE_ADDR'], however, I need to get an IP a little different. How would I get the IP of the visitor on a remote site loading MY site using file_get_contents()? It just returns that remote websites server IP...

View 7 Replies


I have a website where only a couple of people can access it, so the number of IPs logged in is very limited. Everything submitted by the 'admins' logged in is sent to a specific folder dependent of their IP Address. Again they can't access the website through a proxy or anything because there's a limited range of IPs that is allowed. Can I trust $_SERVER['REMOTE_ADDR'] to give a valid IP so the log-system would be 100 % stable and efficient?

View 5 Replies

Format Of Session Id And $_SERVER['REMOTE_ADDR']

In cases where I need to store the session id and/or the remote host in
a database I used to choose tinytext fields so far. Anyway the usual
values for session ids are of 32 characters length, and IP addresses not
longer than 15 characters - so using char(32) resp. char(15) would
actually improve the database performance. But I did not find
informations whether this is safe or not.

So my questions are:
- Is a PHP session id always 32 characters long (if it is generated
normally with session_start() of course), or can it's format vary due to
PHP versions or configurations (I work in shared hosting envirnoments)?
- Can I safely expect $_SERVER['REMOTE_ADDR'] to deliver an IP address
of the format, or can this also be an IPV6 address or other?

View 9 Replies

Ip Address - Alternative To $_SERVER['REMOTE_ADDR'] ?

Is there any alternative to the $_SERVER['REMOTE_ADDR']. Which returns the ip address of the computer accessing a site.I'm trying to search about same external ip assigned by router, and got into this:How do two computers connect to same external address through NAT?And found out that the same external ip is assigned if the computers are connected to the same modem.I'm creating a simple login program in php which uses $_SERVER['REMOTE_ADDR'] to determine if a user is already logged in somewhere else in the same network. And this won't actually work if those computers are connected to the same modem through the router.

View 2 Replies

Suddenly $_SERVER['REMOTE_ADDR'] Is Started Returning

On my production site, I'm keeping the log for users when they visited my site (ie login, logout) with their IP address.I'm using $_SERVER['REMOTE_ADDR'] to get IP. It was storing accurate IP of visitor before but suddenly this variable started returning for all of my customers. It is happening from 01-31-2011. Now I have below function which is also returning same

function GetIP()
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"),
$ip = getenv("HTTP_CLIENT_IP");.........

View 2 Replies

$_SERVER['REMOTE_ADDR'] Doesn't Work With Php-fpm And Nginx?

I don't know why with nginx this variable $_SERVER['REMOTE_ADDR'] doesn't echo an IP. On every other web server it works as it should.

View 3 Replies

$_SERVER['REMOTE_ADDR'] Sometimes Resolves To Empty String?

When accessing my site from a number of machines $_SERVER['REMOTE_ADDR'] always resolves to an empty string. What can be the cause of this?Additional info:One of the machines is running the site on localhost. Shouldn't a machine on localhost always resolve to set up is LAMP. One dev. machine that runs the site localhost and that has the problem is a Mac and runs XAMPP. I think our live staging environment is CentOS (shared host).

View 2 Replies

Apache - $_SERVER['REMOTE_ADDR'] Not Working Correctly On Windows 7?

I have a problem and this only happens on my PC (windows 7 64bits), if I echo the following:


I get : ::1

same thing if i insert in database.

View 1 Replies

Find IPV6 Address Similar To $_SERVER['REMOTE_ADDR'];

Is it possible to use PHP to find out peoples IPV6 address similar to $_SERVER['REMOTE_ADDR'];

View 4 Replies

Incoming Traffic Domain Detect - Use Gethostbyaddr($_SERVER['REMOTE_ADDR'])?

if I have a page only allow incoming traffic from certain domain, how should I do that?

use gethostbyaddr($_SERVER['REMOTE_ADDR'])?

What else should I know if I use gethostbyaddr($_SERVER['REMOTE_ADDR']) to detect the incoming traffic is from the domain allowed or not?

View 2 Replies

Apache / Assume That $_SERVER['REMOTE_ADDR'] Always Returns A IPv4 Address?

Is it safe to assume that $_SERVER['REMOTE_ADDR'] always returns a IPv4 address?

View 1 Replies

Capture The Users IP Adress Using The $_SERVER['REMOTE_ADDR'] Method Via Ajax?

I need to capture the users IP Adress. I am using the $_SERVER['REMOTE_ADDR'] method via PHP.

My question is, will this still pull the users IP if it is a request via ajax? I have users on a page, they click a button, it makes a call to a php script via ajax, does not pass the users ip, and I call the $_SERVER['REMOTE_ADDR'] global var. Will that still work? Since the user technically isn't visiting the script?

View 6 Replies


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

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

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 {

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

View 2 Replies


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


What is the difference between:


View 3 Replies

Why Is $_SERVER["REMOTE_ADDR"] Returning Multiple IP Addresses?

Why is $_SERVER["REMOTE_ADDR"] returning multiple IP Addresses?

Actually, I'm not sure if it's $_SERVER["REMOTE_ADDR"] -- or which if/else statement -- that's the problem, but what I'm getting as a value for $visip looks like this:,

Why am I getting more than one IP Address? Which IP is the originating IP Address? Is there a way to get only the originating IP?

Here's the code: ....

View 7 Replies

$_SERVER['DOCUMENT_ROOT'] Does Not Work In The Script Running Through Cron?

I use $_SERVER['DOCUMENT_ROOT']."/lib/sft_required.php"; to include the 'sft_required' file in a PHP script. When I run this file using browser, it works fine but when I run this as a cron job job, it does not work. It seems that the file is not included when we run the script through cron.

View 5 Replies

Copyrights 2005-15, All rights reserved