[php] Bestaat de url?

Gestart doorWiitse3 reacties43 weergaven

4 berichten · pagina 1 van 1

Wiitse

Lid · Topicstarter

Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik zoek een scriptje waarmee je kunt controleren of de url die is ingevoerd wel werkend is. Zoals op downforeveryoneorjustme.com Op google kan ik geen werkenden vinden. confusedIk wil graag dat het word gecheckt met een function. Als iemand zon function kan vinden/maken red ik me er verder wel mee. smile
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]//Controleren of er een post is gedaan:[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]]))
{[/COLOR]

    [COLOR= #FF8000]//Controleren of pagina opgevraagd kan worden ZONDER errors:[/COLOR]
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](@[/COLOR][URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]url[/COLOR][COLOR= #007700]]))
    {[/COLOR]
        
        [COLOR= #FF8000]//Weergeven dat site online is[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Site is online[/COLOR][COLOR= #007700];[/COLOR]
        
    [COLOR= #FF8000]//Site is waarschijnlijk niet online:[/COLOR]
    [COLOR= #007700]}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
        
        [COLOR= #FF8000]//Weergeven dat site offline is:[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Site is offline[/COLOR][COLOR= #007700];
        
    }[/COLOR]

[COLOR= #FF8000]//Er is geen post gedaan dus formulier weergeven:[/COLOR]
[COLOR= #007700]}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<form action="" method="post">
    Url:<br />
    <input type="text" name="url" /><br />
    <input type="submit" name="submit" value="CHECK!" />[/COLOR][COLOR= #007700];

}[/COLOR]

?>
0
Berichten
515
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Uhm...

Google -> php ping check
php ping check -> eerste link

Uitkomst:

[COLOR= #0000BB]<?php[/COLOR] 

[COLOR= #FF8000]// Function to check response time[/COLOR]
[COLOR= #007700]function[/COLOR] pingDomain[COLOR= #007700]([/COLOR][COLOR= #0000BB]$domain[/COLOR][COLOR= #007700]){[/COLOR]
    [COLOR= #0000BB]$starttime[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/microtime"]microtime[/URL][COLOR= #007700]([/COLOR]true[COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$file[/COLOR]      [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/fsockopen"]fsockopen[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$domain[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]80[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$errno[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$errstr[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]10[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$stoptime[/COLOR]  [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/microtime"]microtime[/URL][COLOR= #007700]([/COLOR]true[COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$status[/COLOR]    [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]

    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$file[/COLOR][COLOR= #007700])[/COLOR] [COLOR= #0000BB]$status[/COLOR] [COLOR= #007700]= -[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]  [COLOR= #FF8000]// Site is down[/COLOR]
    [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/fclose"]fclose[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$file[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$status[/COLOR] [COLOR= #007700]= ([/COLOR][COLOR= #0000BB]$stoptime[/COLOR] [COLOR= #007700]-[/COLOR] [COLOR= #0000BB]$starttime[/COLOR][COLOR= #007700]) *[/COLOR] [COLOR= #0000BB]1000[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$status[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/floor"]floor[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$status[/COLOR][COLOR= #007700]);
    }[/COLOR]
    [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$status[/COLOR][COLOR= #007700];
}[/COLOR]
?>


http://www.phptoys.com/e107_plugins/content/content.php?content.41
0
Wiitse

Lid · Topicstarter

Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb die van Milan wat aangepast en hij werkt. smile Beide bedankt iig. smile
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren