linux - PHP domain availability script exec() function alternative -
i want install php whois domain availability check script on website found somewhere.
it has whois_class.php
file allows switch between "win" & "linux" mode.
when switch on "win" mode works fine in localhost using windows os.
but when upload server stops working server linux server.
so have switch "linux" mode , re-upload whois_class.php
. expected work fine linux mode developer of script has used exec()
function host has disabled security purposes.
so, option guess if change server platform linux windows. but, mess.
i looking way how can use script run smoothly on linux server runs on localhost in windows os. change or modification script make run appreciated.
whois_class.php
:
<?php class whois_domain { var $possible_tlds; var $whois_server; var $free_string; var $whois_param; var $domain; var $tld; var $compl_domain; var $full_info; var $msg; var $info; var $os_system = "win"; // switch between "linux" , "win" function whois_domain() { $this->info = ""; $this->msg = ""; } function process() { if ($this->create_domain()) { if ($this->full_info == "yes") { $this->get_domain_info(); } else { if ($this->check_only() == 1) { $this->msg = "<p style='font-size: 16px'>the domain name: <font color='#000'>".$this->compl_domain."</font> <font color='#2ec62e'>available</font>.</p>"; return true; } elseif ($this->check_only() == 0) { $this->msg = "<p style='font-size: 16px'>the domain name: <font color='#000'>".$this->compl_domain."</font> <font color='red'>registered</font>.</p>"; return false; } else { $this->msg = "<p style='font-size: 16px'>there wrong, try again.</p>"; } } } else { $this->msg = "<p style='font-size: 16px'>only letters, numbers , hyphens (-) valid!</p>"; } } function check_entry() { if (preg_match("/^([a-z0-9]+(\-?[a-z0-9]*)){2,63}$/i", $this->domain)) { return true; } else { return false; } } function create_tld_select() { $menu = "<select id=\"tld\" name=\"tld\" style=\"margin-left:0; width: 100px; margin-top: 20px; border-radius: 5px\">\n"; foreach ($this->possible_tlds $val) { $menu .= " <option value=\"".$val."\""; $menu .= (isset($_post['tld']) && $_post['tld'] == $val) ? " selected=\"selected\">" : ">"; $menu .= $val."</option>\n"; } $menu .= "</select>\n"; return $menu; } function create_domain() { if ($this->check_entry()) { $this->domain = strtolower($this->domain); $this->compl_domain = $this->domain.".".$this->tld; return true; } else { return false; } } function check_only() { $data = $this->get_whois_data(); if (is_array($data)) { $found = 0; foreach ($data $val) { if (preg_match('/'.$this->free_string.'/', $val)) { $found = 1; } } return $found; } else { $this->msg = "<p style='font-size: 16px'>error, please try again.</p>"; } } function get_domain_info() { if ($this->create_domain()) { $data = ($this->tld == "nl") ? $this->get_whois_data(true) : $this->get_whois_data(); //print_r($data); if (is_array($data)) { foreach ($data $val) { if (eregi($this->free_string, $val)) { $this->msg = "<p style='font-size: 16px'>the domain name: <font color='#000'>".$this->compl_domain."</font> <font color='#2ec62e'>available</font>.</p>"; $this->info = ""; break; } $this->info .= $val; } } else { $this->msg = "<p style='font-size: 16px'>error, please try again.</p>"; } } else { $this->msg = "<p style='font-size: 16px'>only letters, numbers , hyphens (-) valid!</p>"; } } function get_whois_data($empty_param = false) { // parameter new since version 1.20 , used .nl (dutch) domains if ($empty_param) { $this->whois_param = ""; } if ($this->tld == "de") $this->os_system = "win"; // tld must queried fsock otherwise not work if ($this->os_system == "win") { $connection = @fsockopen($this->whois_server, 43); if (!$connection) { unset($connection); $this->msg = "<p style='font-size: 16px'>can't connect server!</p>"; return; } else { sleep(2); fputs($connection, $this->whois_param.$this->compl_domain."\r\n"); while (!feof($connection)) { $buffer[] = fgets($connection, 4096); } fclose($connection); } } else { $string = "whois -h ".$this->whois_server." \"".$this->whois_param.$this->compl_domain."\""; $string = str_replace (";", "", $string).";"; exec($string, $buffer); } if (isset($buffer)) { //print_r($buffer); return $buffer; } else { $this->msg = "<p style='font-size: 16px'>can't retrieve data server!</p>"; } } } ?>
the problem here
if ($this->os_system == "win") { $connection = @fsockopen($this->whois_server, 43); if (!$connection) { unset($connection); $this->msg = "<p style='font-size: 16px'>can't connect server!</p>"; return; } else { sleep(2); fputs($connection, $this->whois_param.$this->compl_domain."\r\n"); while (!feof($connection)) { $buffer[] = fgets($connection, 4096); } fclose($connection); } } else { $string = "whois -h ".$this->whois_server." \"".$this->whois_param.$this->compl_domain."\""; $string = str_replace (";", "", $string).";"; exec($string, $buffer); }
disabled functions host
system,exec,shell_exec,passthru,popen,proc_open,pcntl_exec,highlight_file,show_source,symlink,link,posix_getpwuid,posix_getpwnam,posix_getgrgid,posix_getgrnam,posix_kill,posix_mkfifo,posix_getrlimit
there plenty of functions related program execution. should check other functions disabled on setup:
var_dump(ini_get("disable_functions"));
Comments
Post a Comment