Jump to content

Check if word exsists in text string


rvdb86

Recommended Posts

Hi, I have been looking for a long time for a script that will allow me to check if a .co.il domain is availible or not. I have not succeeded :(

 

I have though found a script that successfully does a whois lookup on .co.il so i want to the text of the result and if the sentence "% No data was found to match the request criteria." is found i want the script to echo "Domain not found"

and if the sentence is not found the script should echo "domain found"

 

I no it is possible to search text in php with the str_replace() function, i just dont want to replace anything.

 

I hope someone has an idea that could help me!

 

My code:


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

/*Function whois which returns the data from the server given the domain name and server name*/

function whois($domain,$server)
{
    $port   = 43;
    $whois  = "[$server]\n\n";

    /*open socket on port 43 (default port for whois server) to query the server*/
    $socket = fsockopen($server, $port, $errno, $errstr, 30);

    if(!$socket)
    {
        return "$errstr ($errno).\n";
    }
    else
    {
        /*query the server about the given domain name*/
        fputs($socket, "$domain\r\n");
        while(!feof($socket))
        {
            /*get the server response*/
            $whois = $whois . fgets($socket,128);
        }

        fclose ($socket);
    }

    return $whois;
}
echo nl2br(whois($_POST['domain'],'whois.isoc.org.il'));
}


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="chek.php" method="post">
<input name="domain" type="text" />

<input name="submit" type="submit" /></form>
</body>
</html>

 

I need to search $whois for the sentence!

Link to comment
https://forums.phpfreaks.com/topic/143654-check-if-word-exsists-in-text-string/
Share on other sites

Thanks!

 

if anyone looks this thread up in the future this is what i did:

if(stristr(whois($_POST['domain'],'whois.isoc.org.il'), '% No data was found to match the request criteria') === FALSE) {
    echo 'Domain NOT Found';
  }
else{
echo 'Domain Found';
}

Archived

This topic is now archived and is closed to further replies.

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