Status
Not open for further replies.

cgworld

Active Member
566
2010
9
0
hi guyz
just for practice i started to code a small script which checks if the remote host or site is online ... and then it gives back the result ... here :

http://isonline.warezsociety.org/index.php

when i test it on my pc with easyphp everything goes well , but i uploaded the script to my host and many times when i submit a website which doesnt exist it says its online ... on my pc everything was ok never got wrong answer ....

any idea ??
 
30 comments
Will be good can check source code to make an idea about how the script works.

It should make a http request and check status code... hard guess what happens without php code.
 
Still need more info and need to see your script.

Sorta on topic. If you wanna see another script (which is always useful to get ideas and see how other people did it) check out http://isitup.org/ it's based on downforeveryoneorjustme.com but the guy is giving away the source code for free. You should check it out.
 
the code is simple as i said

2vmzf3m.png
 
Still need more info and need to see your script.

Sorta on topic. If you wanna see another script (which is always useful to get ideas and see how other people did it) check out http://isitup.org/ it's based on downforeveryoneorjustme.com but the guy is giving away the source code for free. You should check it out.

Ya there are many other ready scripts out there, i just want to do something different ... and much simpler =)
 
Turn on error reporting. You have it turned off error_reporting(0).
Make it error_reporting(E_ALL);
If it's not a valid domain then it returns an E_WARNING.

At the moment if I enter something stupid like cornflakes it tells me it's online as your not allowing it to check if it's a valid domain first.
 
thanks for helping mr happy, but i think the problem is with my hosting ...
because the script works well on my localhost with easyphp
 
error reporting is on right now ...
but still if you try a valid domain which doesnt exist e.g :

smmdkkhfjvdhvk.com

the result is online !!!
 
Your script is flawed. First off, it does not validate whether the input is actually a domain or not. You could google for that, and you'll find answers on how to do that.

Second, have you tried using another method, other than fsockopen? Maybe try file_get_contents => http://php.net/file_get_contents
 
Man my problem right now is not validation ... i am saying that it works fine on my http://localhost/script/ but on isonline.warezsociety.org it gives errors.
even if i do validation i will get errors, for example see this one :

pkvjjfhjejfdvdfv.com this one doesnt exists

the result on my server and localhost are :

4rc67d.jpg



on local :

wkh108.jpg
 
Check php version runing into your localhost and php version runing into your hosting.

You have to code the script a little bit complex...
 
add this to your code at start after opening <?php

Code:
error_reporting(E_ALL);
ini_set("display_errors", 1);

and see what u gets
 
it does not go a miss to make your code less error prone and more specific.

PHP:
function track($host, $port = 80, $timeout = 30)
{
    try
    {
        $socket = fsockopen($host,$port,$e_number,$e_string,$timeout);
    }catch(Exception $e)
    {
        //Not a valid domain more than likly!
        return false;
    }

    if($socket === false)
    {
        //No socket so unable to connect
        return false;
    }

    if($e_number != 0)
    {
        //There was an error, use the $e_number to track what type of error.
        return false;
    }

    //If all the  above is ok we return false as a positive connection was made.
    return true;
}

if(track('google.com'))
{
    echo 'google is awake';
}else
{
    echo 'google is asleep';
}

also another note is that functions are meant to be reused throughout an application so i advice you always make your functions return a datatype such as bools,ints etc so that no matter where you run the code you can always change the output.

Peace, hope that fixes your prob.
 
Status
Not open for further replies.
Back
Top