Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Nuke Treasury
Author Message
Gremmie
Former Moderator in Good Standing


Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Thu Nov 29, 2007 3:18 pm Reply with quote

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

_________________
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 
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17086

PostPosted: Fri Nov 30, 2007 10:13 am Reply with quote

Try Only registered users can see links on this board! Get registered or login! and/or change hosts.
 
View user's profile Send private message
benson
Worker
Worker


Joined: May 15, 2004
Posts: 119
Location: Germany

PostPosted: Tue Jan 01, 2008 6:32 am Reply with quote

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 with
Code:
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)' Embarassed ?

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! 
View user's profile Send private message Visit poster's website
evaders99
Former Moderator in Good Standing


Joined: Apr 30, 2004
Posts: 3221

PostPosted: Tue Jan 01, 2008 6:51 am Reply with quote

Hm socket_create is available for PHP 4.07 and higher. So it should work.
Only registered users can see links on this board! Get registered or login!
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! 
View user's profile Send private message Visit poster's website
benson
PostPosted: Tue Jan 01, 2008 7:14 am Reply with quote

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
PostPosted: Tue Jan 01, 2008 12:47 pm Reply with quote

Also, please see these posts that might help. We will look into this further.
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!
 
Raven
PostPosted: Tue Jan 01, 2008 12:50 pm Reply with quote

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
Worker


Joined: Dec 05, 2007
Posts: 212
Location: Tampa, Florida

PostPosted: Mon Jan 07, 2008 2:29 am Reply with quote

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. Smile


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;
}

?>
 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Nuke Treasury

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©