Author |
Message |
Gremmie
Former Moderator in Good Standing

Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA
|
Posted:
Thu Nov 29, 2007 3:18 pm |
|
CURL is a library for doing http type stuff. That's a really lame answer. They should be able to tell you immediately if fsockopen() is ok to use. Hint: get a new host.  |
_________________ Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module |
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Fri Nov 30, 2007 10:13 am |
|
|
|
 |
benson
Worker


Joined: May 15, 2004
Posts: 119
Location: Germany
|
Posted:
Tue Jan 01, 2008 6:32 am |
|
Hello,
first of all, HAPPY NEW YEAR to all of you!
Now my problem:
After updating to NukeSentinel(tm) 2.5.15 I can not access to the admin panel anymore.
I get this error:Code:Fatal error: Call to undefined function socket_create() in /srv/www/htdocs/nuke/admin/modules/nukesentinel.php on line 22
| and above mentioned scrip dies withCode:Fatal error: Call to undefined function socket_create() in /srv/www/htdocs/nuke/admin/modules/nukesentinel.php on line 22
|
That may have something to do with 'Ravens Improved socket testing. (Thanks to Raven)' ?
It does not work on my local OpenSuse system and even not on my vendor system. What can I do to get it fixed? |
_________________ Best regards, Norbert
Only registered users can see links on this board! Get registered or login! & Only registered users can see links on this board! Get registered or login! |
|
|
 |
evaders99
Former Moderator in Good Standing

Joined: Apr 30, 2004
Posts: 3221
|
Posted:
Tue Jan 01, 2008 6:51 am |
|
Hm socket_create is available for PHP 4.07 and higher. So it should work.
http://www.php.net/socket_create
One caveat is that the web server must be running as root. My guess your server, as is most servers, isn't. Not a fix, but at least an explaination |
_________________ - Only registered users can see links on this board! Get registered or login! -
Need help? Only registered users can see links on this board! Get registered or login! |
|
|
 |
benson

|
Posted:
Tue Jan 01, 2008 7:14 am |
|
evaders99 wrote: | Hm socket_create is available for PHP 4.07 and higher. So it should work. |
That is what the server shows to me:
* PHP Version 4.4.4
* MYSQL_SOCKET /var/lib/mysql/mysql.sock |
|
|
|
 |
Raven

|
Posted:
Tue Jan 01, 2008 12:47 pm |
|
|
|
 |
Raven

|
Posted:
Tue Jan 01, 2008 12:50 pm |
|
Evaders99 wrote: | One caveat is that the web server must be running as root |
This is dependent on how the socket_create function is being called. User scripts can also execute an equivalent operation. We (and/or Bob) need to look into this as I believe this was an issue before v2.5.15. |
|
|
|
 |
bobbyg
Worker


Joined: Dec 05, 2007
Posts: 212
Location: Tampa, Florida
|
Posted:
Mon Jan 07, 2008 2:29 am |
|
Gremmie wrote: | CURL is a library for doing http type stuff. That's a really lame answer. They should be able to tell you immediately if fsockopen() is ok to use. Hint: get a new host. |
To test Fopen and Curl
Code:<?PHP
// This script tests two methods of connecting to the feed server to see which are enabled
$data = getDataViaFopen("http://www.msn.com");
if (!empty($data1)) print "Fopen Works<br>";
$data = '';
$data = getDataViaFsockopen("http://www.msn.com/");
if (!empty($data)) print "Fsockopen Works<br>";
$data = '';
$data = getDataViaCURL("http://www.msn.com/");
if (!empty($data)) print "cURL Works (This is the prefered access method)<br>";
$data = '';
function getDataViaFopen($url){
$file_contents = '';
$file_handle = fopen ($url, "r");
if (!$file_handle) {
print "Fopen test failed.<br>";
exit;
}
while (!feof($file_handle)) {
$file_contents .= fread($file_handle, 8192);
}
fclose($file_handle);
return $file_contents;
}
function getDataViaFsockopen( $url ) {
$file_contents = '';
$url_parsed = parse_url($url);
$host = $url_parsed["host"];
$port = 80;
$path = $url_parsed["path"];
$query = isset($url_parsed["query"]) ? "?".$url_parsed["query"] : "";
//if url is http://example.com without final "/"
//I was getting a 400 error
if (empty($path)) $path="/";
$path .= $query;
$out = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";
$fp = fsockopen($host, $port, $errno, $errstr, 30);
if (!$fp) {
echo "Fsockopen test failed.";
} else {
fwrite($fp, $out);
$body = false;
while (!feof($fp)) {
$file_contents .= fgets($fp, 8192);
}
fclose($fp);
return $file_contents;
}
}
function getDataViaCURL($url){
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // Fail on errors
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_PORT, 80); //Set the port number
curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out
$file_contents = curl_exec($ch);
return $file_contents;
}
?>
|
|
|
|
|
 |
|