Jump to content

Recommended Posts

Hi all, I have a problem to ping a website link. I have to ping many links placed in my textarea. Below is the code :

<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() 
{

$("#content").focus(function()
{
$(this).animate({"height": "85px",}, "fast" );
$("#button_block").slideDown("fast");
return false;
});

$("#cancel").click(function()
{
$("#content").animate({"height": "30px",}, "fast" );
$("#button_block").slideUp("fast");
return false;
});

});
</script>



<form method="post" action="con1.php">

Enter Keywords:
<input name="keywords" type="text" value=""><br/><br/>
Enter Your Links :
<textarea name="contents" rows="3" cols="20"></textarea>
<div id="button_block">
<input type="submit" id="button" value=" Submit "/>
<input type="submit" id='cancel' value=" cancel" />
</div>
</form>


Now this code is the complete design.
aftr submit it should ping all my links placed in my text area.
I Tried with google bt dint get the right solution. Can some one please help me out?
Thanks in advance. 

 

Link to comment
https://forums.phpfreaks.com/topic/284514-how-to-ping-a-website-link-in-php/
Share on other sites

Have a look at example and apply to your wishes:

 

Next URL's will be matched:

 

 

The script:

<?php

if (isset($_POST['Submit'])) {

    $target = stripslashes($_POST['ip']);

    $pattern = '~^(https?://)?(([a-zA-Z\d-_.]+\.[a-zA-Z]{2,4})||(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))/?$~';

    if (!preg_match($pattern, $target, $matches)) {
        echo '<pre>ERROR: You have entered an invalid IP or domain name</pre>';
    } else {
        
        // Determine OS and execute the ping command.
        if (stristr(php_uname('s'), 'Windows NT')) {

            $cmd = shell_exec('ping ' . $matches[2]);
            echo '<pre>' . $cmd . '</pre>';
        } else {

            $cmd = shell_exec('ping  -c 4 ' . $matches[2]);
            echo '<pre>' . $cmd . '</pre>';
        }
    }
}
?>

<h2>Ping Command Execution</h2>

<p>Enter an IP address or domain name below:</p>
<form name="ping" action="#" method="post">
    <input type="text" name="ip" size="30">
    <input type="submit" value="Go!" name="Submit">
</form>

Results:

 

PING phpfreaks.com (199.119.180.52) 56(84) bytes of data.64 bytes from phpfreaks.com (199.119.180.52): icmp_seq=1 ttl=50 time=137 ms64 bytes from phpfreaks.com (199.119.180.52): icmp_seq=2 ttl=50 time=234 ms64 bytes from phpfreaks.com (199.119.180.52): icmp_seq=3 ttl=50 time=133 ms64 bytes from phpfreaks.com (199.119.180.52): icmp_seq=4 ttl=50 time=141 ms--- phpfreaks.com ping statistics ---4 packets transmitted, 4 received, 0% packet loss, time 3145msrtt min/avg/max/mdev = 133.385/161.583/234.435/42.158 ms
Edited by jazzman1

Thanx for the help 

jazzman1

I really appreciate it. I had run the code and its working for domians. But i want it to ping all my SEO links. The is is'nt  working for my SEO links.

Can some one please help or can please suggest me for it???

 

And thnx for the rest who replied.

But i want it to ping all my SEO links

You can use the ping command to check the destination IP address or domain names that you want to reach and record the results. To reach the content of your links (seo or not) which belong to some particular domain you would use a telnet command.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.