473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Testing if a server is running with almost no permissions

Hi,

My webhost allows me to run php but no shell_execute(...), system(...) and
so on.

I am trying to get info from a site, the reply from the site is usually less
than 1 second.

I have tried

fsockopen("http://www.example.com", 80, $errno, $errstr, 1);
//and
file( "http://www.example.com")
//
fopen( ..., "r" );

But that does not work

according to php.net
"Depending on the environment, the Unix domain or the optional connect
timeout may not be available."

I cannot change "Set_time_limit(...)" because I have no access to the
php.ini file.

So, how can i test for a website and have a 1 second timeout?

Many thanks in advance.

Simon

Jan 12 '06 #1
7 1494
Simon wrote:
Hi,

My webhost allows me to run php but no shell_execute(...), system(...) and
so on.

I am trying to get info from a site, the reply from the site is usually
less than 1 second.

I have tried

fsockopen("http://www.example.com", 80, $errno, $errstr, 1);
//and
file( "http://www.example.com")
//
fopen( ..., "r" );

But that does not work

according to php.net
"Depending on the environment, the Unix domain or the optional connect
timeout may not be available."

I cannot change "Set_time_limit(...)" because I have no access to the
php.ini file.

So, how can i test for a website and have a 1 second timeout?

Many thanks in advance.

Simon


I think you cannot if your provider is so strick.
I wonder why they are so afraid of file() and fopen().
Maybe they have something to hide, like the fact that they don't know how to
set up PHP properly. :-/
You can always switch provider of course.

Regards,
Erwin Moller
Jan 12 '06 #2
>
I think you cannot if your provider is so strick.
I wonder why they are so afraid of file() and fopen().
Maybe they have something to hide, like the fact that they don't know how
to
set up PHP properly. :-/
You can always switch provider of course.

Regards,
Erwin Moller


I don't understand?
file() and fopen() has nothing to do with them, (i think).

That's just the way php works.

There must be a way of testing if a domain is "online" or "offline".

Simon
Jan 12 '06 #3
Simon wrote:

I think you cannot if your provider is so strick.
I wonder why they are so afraid of file() and fopen().
Maybe they have something to hide, like the fact that they don't know how
to
set up PHP properly. :-/
You can always switch provider of course.

Regards,
Erwin Moller


I don't understand?
file() and fopen() has nothing to do with them, (i think).

That's just the way php works.

There must be a way of testing if a domain is "online" or "offline".

Simon


Probably it is me who doesn't understand. :P

In your original post you wrote this:
------------------------------
I have tried

fsockopen("http://www.example.com", 80, $errno, $errstr, 1);
//and
file( "http://www.example.com")
//
fopen( ..., "r" );

But that does not work
------------------------------

So I thought your provider was blocking that functionality.

But You probably mean that they are working, but you cannot use the timeout
on them? right?

Nevermind, I am always slow on workingdays. :P

And sorry: If that is your problem, I don't know the answer.

However the manual says this:

http://nl3.php.net/manual/en/function.fsockopen.php
----------------------------------------------
Note: If you need to set a timeout for reading/writing data over the
socket, use stream_set_timeout(), as the timeout parameter to fsockopen()
only applies while connecting the socket.
-----------------------------------------------

Does that help?
Regards,
Erwin Moller
Jan 12 '06 #4
Erwin Moller wrote:
Simon wrote:
Hi,

My webhost allows me to run php but no shell_execute(...), system(...) and
so on.

I am trying to get info from a site, the reply from the site is usually
less than 1 second.

I have tried

fsockopen("http://www.example.com", 80, $errno, $errstr, 1);
//and
file( "http://www.example.com")
//
fopen( ..., "r" );

But that does not work

according to php.net
"Depending on the environment, the Unix domain or the optional connect
timeout may not be available."

I cannot change "Set_time_limit(...)" because I have no access to the
php.ini file.

So, how can i test for a website and have a 1 second timeout?

Many thanks in advance.

Simon


I think you cannot if your provider is so strick.
I wonder why they are so afraid of file() and fopen().
Maybe they have something to hide, like the fact that they don't know how to
set up PHP properly. :-/
You can always switch provider of course.

Regards,
Erwin Moller


The problem isn't file() or fopen(), but include() and require().
Remote inclusion is the typical way a PHP worm deploys its payload.
Currently the only way to disable that is allow_url_fopen, which of
course disables everything. The good news is that a separate option
will be added sometime in the future and it'll be off by default.

Jan 12 '06 #5
>
The problem isn't file() or fopen(), but include() and require().
Remote inclusion is the typical way a PHP worm deploys its payload.
Currently the only way to disable that is allow_url_fopen, which of
course disables everything. The good news is that a separate option
will be added sometime in the future and it'll be off by default.


No, it has nothing to do with include() or require().
They are not even used for the same thing.

The problem is that I am trying to use fopen(...) or file(...) to read the
content of another site but if that site is down then they simply don't
return.

I want a way, (other than system(...) and shell_execute(...)), to test if a
domain is up.

Simon
Jan 12 '06 #6

So I thought your provider was blocking that functionality.

But You probably mean that they are working, but you cannot use the
timeout
on them? right?
Right,

Nevermind, I am always slow on workingdays. :P

And sorry: If that is your problem, I don't know the answer.

However the manual says this:

http://nl3.php.net/manual/en/function.fsockopen.php
----------------------------------------------
Note: If you need to set a timeout for reading/writing data over the
socket, use stream_set_timeout(), as the timeout parameter to fsockopen()
only applies while connecting the socket.
-----------------------------------------------

Does that help?
Thanks a lot, you were right.

My fsockopen(...) was returning ok even if there was no connection

but adding stream_set_timeout($fp, 2); did the trick.

Thanks.


Regards,
Erwin Moller


Simon
Jan 12 '06 #7
Simon wrote:

The problem isn't file() or fopen(), but include() and require().
No, it has nothing to do with include() or require().
They are not even used for the same thing.


Yes it does - they all use the same underlying code for reading files.

The best solution would be to use curl lib fns in PHP (you can set a
timeout).
The problem is that I am trying to use fopen(...) or file(...) to read the
content of another site but if that site is down then they simply don't
return.

So decouple this process from the process which presents the results. Spawn
it off in the back ground and set it to communicate with the reporting
process (e.g. by dropping a copy of the data on the local filesystem) when
succesful
I want a way, (other than system(...) and shell_execute(...)), to test if
a domain is up.


A domain? Are you sure that is what you mean?

C.
Jan 12 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bill | last post by:
I used to be able to run the following ASP code on our corp machine (W2K Server Edition and IIS-5) and successfully send a net-msg to anyone on our intranet. Last week it stopped working... and...
1
by: Keith | last post by:
All, I have been told this is an ASP.NET issue and not an IIS issue, so I am posting this here. I have a problem with ASP.NET returning an HTTP 500 error when trying to run ASPX pages on...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
1
by: Jody Gelowitz | last post by:
We are having an issue in that when trying to read a file that is on Server2 from Server1 (through our ASP.NET project), we receive the error: Access to the path "\\Server2\MyShare\MyFile.tif" is...
2
by: Simon | last post by:
Hi, My webhost allows me to run php but no shell_execute(...), system(...) and so on. I am trying to get info from a site, the reply from the site is usually less than 1 second. I have...
4
by: casper | last post by:
Hi, I created an asp.net 2.0 website with VWD and made it an application in IIS. It was created on a ntfs disc (my documents...). The directory permissions are set on 'anonymous allowed' using...
17
by: Jon B | last post by:
Hi All! I have a ASP.NET 2.0 site that works on the Windows 2000 Server. However, when I tried to view this site on my local Windows XP machine, I get "Server Unavailable". If I switch the...
7
by: Aryan | last post by:
Hi Everybody, I am facing "Server Application Unavailable" problem with .NET Framework 2.0 Earlier Framework was working fine, but one fine day it stopped working for particular application....
13
by: Kevin Liebowicz | last post by:
Yes, I wasted the past two days trying to fix this. Yes, this is on a Win2003 Server. Yes, this machine is a domain controller. Yes, I seen the dozens of KB articles like this one:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.