Pages

phpSMSWhois

phpSMSWhois is a simple, single file php program designed to provide a domain availability check accessible from a SMS mobile phone.

Requirements:
Ability to pipe an email address to a php script (cpanel works)
PHP 5 (unchecked on php4)
Mobile Phone with TXT messaging

Installation
Step 1 – Upload phpsmswhois.php to your webserver.
Step 2 – Edit phpsmswhois.php at the bottom with your own email address. Replace all instances of phpsmswhois@patrickg.net with your email of choice.
Step 2 – Create email forwarder that pipes all incoming mail to your php script.
Step 4 – Use your mobile phone and send a text message to the email address above. Enter only 1 domain and 1 tld per message (eg: domain.com)
!IMPORTANT! – Do not include http:// or www in your message.

You can view the source below
Download the source phpSMSWhois (45)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/php -q
// read from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);

// handle email

$lines = explode("\n", $email);

// empty vars

$from = "";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;

for ($i=0; $i < count($lines); $i++) {
if ($splittingheaders) {
// this is a header
$headers .= $lines[$i]."\n";
// look out for special headers
if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
$subject = $matches[1];
}
if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
$from = $matches[1];
}
} else {
// not a header, but message
$message .= $lines[$i]."\n";
}

if (trim($lines[$i])=="") {
// empty line, header section has ended
$splittingheaders = false;
}
}

function checkDomain($domain,$server,$findText){
// Open a socket connection to the whois server
$con = fsockopen($server, 43);
if (!$con) return false;

// Send the requested doman name
fputs($con, $domain."\r\n");

// Read and store the server response
$response = ' :';
while(!feof($con)) {
$response .= fgets($con,128);
}

// Close the connection
fclose($con);

// Check the response stream whether the domain is available
if (strpos($response, $findText)){
return "available";
}
else {
return "unavailable";
}
}

$status = checkDomain("$message",'whois.crsnic.net','No match for');

$to = "$from";
$subject = "phpSMSWhois";
$body = "$message is $status";
$headers = "From: phpsmswhois@patrickg.net\r\n";
$headers .= "Reply-To: phpsmswhois@patrickg.net\r\n";
$headers .= "Return-Path: phpsmswhois@patrickg.net\r\n";
mail($to, $subject, $body, $headers);

?>
blog comments powered by Disqus