fsockopen() Premission denied 13

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

fsockopen() Premission denied 13

Post by kendall »

Hey guys,

on a local server of mines im doing a whois is look up using the fsockopen function which returns successfully. However, on trying to use it on a live site. I get a PHP warning saying that it was unable to connect and also return the error string 'Permission denied' and the #13

any explanations on this? any work arounds?

Kendall
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

Post by akimm »

Make sure you're CHMOD 755 at least.

What is your exact purpose for the whois search, are you searching a DB or a flatfile, searching the web pages, or what?
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

Make sure you're CHMOD 755 at least.
what do you mean?

I'm running a whois search on a web page i think... it's the typically way they go about doing this whois thing

Kendall
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I don't think whois services query (via a page) other services, most will use the system level request to a DNS server.

shell_exec() et al.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

I don't think whois services query (via a page) other services, most will use the system level request to a DNS server.

shell_exec() et al.
Ok you've thrown me off the track with that one man....what r you trying to say here? I don't know but I use fsockopen() as a tool to get whois information from a whois server. Its working on my local server but not on my live server. what does shell_exe() have to do with this?

Kendall
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Please post your code and the exact error message(s).
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

Code: Select all

$TLDservers = array("com"=>"whois.crsnic.net","net"=>"whois.crsnic.net","org"=>"whois.publicinterestregistry.net","info"=>"whois.afilias.info","biz"=>"whois.neulevel.biz");
//whois query
function LOOK_UP($server = false,$domain,$record = false){
	$errno = 0;
	$errstr = '';
	// if look up record only
	if($record == true){
		//look up domain records
		$record = checkdnsrr($domain);
		return $record;
	}else{
		// look up domain registrants	
		$port = 43;
		$fp = fsockopen($server,$port,$errno,$errstr,30);
		if(!$fp){
			//return $errstr.' '.$errno;
			return false;
		}else{
			fputs($fp, "$domain\r\n");
				while(!feof($fp)) {
               	 $data .= fgets($fp,128);	
            	}
       		 fclose($fp);
		}
		//echo $data;
		if($data != false)
			return strstr($data,'Domain Name');
		else
			return false;
	}
}
//print(LOOK_UP($_GET['server'],$_GET['domain'],$record = false));
?>
PHP Warning: fsockopen(): unable to connect to whois.crsnic.net:43 in
and i get that
return $errstr.' '.$errno; //prints out Permission denied 13
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I think you have to ask the provider why the connection is blocked.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

Wait, this works on your local machine, but not on your hosting? If so there are some restrictions on remote connections on your hosting. I don't remember what the relevant settings are - but you can see if there is something apparent in phpinfo(). Does somebody know what hostings do to forbid socket operations and how to check if this is the case?
User avatar
Cameri
Forum Commoner
Posts: 87
Joined: Tue Apr 12, 2005 4:12 pm
Location: Santo Domingo, Dominican Republic

Post by Cameri »

I've run in to those kind of problems before... the thing is that the webserver usually has all the ports closed except those like 80, 21, etc. But I'm not sure if this is the cause of your problem.

Contact your web host and ask them to enable port 43 for you.
Post Reply