Author |
Message |
Gremmie
Former Moderator in Good Standing
![](modules/Forums/images/avatars/0cd76dcf45da5de2cf864.jpg)
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. ![Smile](modules/Forums/images/smiles/icon_smile.gif) |
_________________ 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 |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
Site Admin/Owner
![](modules/Forums/images/avatars/45030c033f18773153cd2.gif)
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Fri Nov 30, 2007 10:13 am |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
benson
Worker
![Worker Worker](modules/Forums/images/ranks/3stars.gif)
![](modules/Forums/images/avatars/d565e607446586bbb82ae.jpg)
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! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
evaders99
Former Moderator in Good Standing
![](modules/Forums/images/avatars/803d73f6452557b947721.jpg)
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! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
benson
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Jan 01, 2008 12:47 pm |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
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. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
bobbyg
Worker
![Worker Worker](modules/Forums/images/ranks/3stars.gif)
![](modules/Forums/images/avatars/47640777475ce61275311.jpg)
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;
}
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|