PDA

View Full Version : PHP socket functions DISABLED


korben_dallas
03-06-2005, 01:50 PM
Hi!

It seems that PHP socket functions were not enabled at compile time:

suff like socket_create() complains about being a "Call to undefined function:"

A quick check of my phpinfo() reveals no trace of "--enable-sockets"

Is there any workaround for this, or alternatively an explanation of why it is disabled (not enabled) if you are aware of one?

Thanks!

Eric
03-06-2005, 07:32 PM
You could use fead, fsockopen, fread, fwrite, etc. But I must caution you that we do not allow this on an account that does not have a unique IP address.

What is it you are trying to do, maybe we have a solution for you.

korben_dallas
03-06-2005, 09:02 PM
You could use fead, fsockopen, fread, fwrite, etc

Yup, all those functions work, but not for this...

I want to obtain the host server IP address without using a PHP system(), or exec() or shell_exec() command when using PHP via the CLI. Most of the good system vars I could ordinarily use to derive the IP are generated by APACHE which is totally bypassed when using the CLI.

So, I desire a purely PHP solution. I can do this, (not elegantly) utilizing PHP's socket functions.

note: the account in question has a static IP..

Eric
03-07-2005, 04:19 PM
Call /etc/vds_ip . It will give you what you want.

Actually its /bin/vds_ip . But actually it is just a shell script that echo's your ip address. You can count on it being there in every account.

I'm sure there are other php ways to do the same thing.

korben_dallas
03-09-2005, 10:26 PM
Call /etc/vds_ip . It will give you what you want.

Actually its /bin/vds_ip . But actually it is just a shell script that echo's your ip address. You can count on it being there in every account.

I'm sure there are other php ways to do the same thing.

Yup, I saw that already but it is something completely proprietary to HHH's system, and our application is used elsewhere, so we can't count on that feature of yours being available at other hosts like we can the built-in PHP socket functions. Also, I would have to use a system() or like function that accesses the shell in order to use the shell script, and this is disabled at other hosts more often than the native php socket functions are.

The only way I have been able to do this elsewhere is via the socket functions. There may be another way to do this via PHP, but I haven't found one. It has just been my experience that hosts that offer root access type accounts usually have the PHP socket functions turned on.

Chris
03-10-2005, 12:12 AM
korben_dallas,

I may have a solution for you. A while back, Eric compiled PHP with some extra extensions. I do believe the PHP version was 4.3.8, so using this is at YOUR OWN RISK. No guarantees... Also, I am not sure every one of these extensions works.

First, download this file:
http://www.hardhathosting.com/docs/php-shared.tar.gz

Upload this file to the root(/) of your VDS account. Make sure you have the GNU compiler collection ValueApp installed. Untar the php-shared.tar.gz file in the root(/) of your VDS. Then add the appropriate lines below to your /ftp/lib/php.ini file, add /usr/mylib to the /etc/ld.so.conf file and run the command "ldconfig" from SSH, sans quotes.

extension=calendar.so
extension=mhash.so
extension=pspell.so
extension=zip.so
extension=bz2.so
extension=exif.so
extension=mime_magic.so
extension=openssl.so
extension=sockets.so
extension=xmlrpc.so
extension=yp.soRestart Apache and you are ready. Make sure that you tail the apache error log upon restart to make sure there were no errors on startup.

Good luck...

seriouslistings
04-01-2005, 08:39 AM
I thought this might be the place to post this. Here is my reference from the PHP manual:

As of PHP 4.3.0, if you have compiled in OpenSSL support, you may prefix the hostname with either 'ssl://' or 'tls://' to use an SSL or TLS client connection over TCP/IP to connect to the remote host.

The problem I have is I cannot make the connection prefixed w/ ssl://. I wrote a test script after a script I wrote for a client failed when I ran it on my server. I know the script works correctly because I have run it on other servers. Without the ssl:// i can make the socket connection. Lack of this functionality causes transactions with authorize.net impossible.

Anyone?

Chris
04-15-2005, 11:07 AM
Here is a PHP Sockets extension that you can drop into your VDS.

Download this file:
http://www.hardhathosting.com/docs/sockets.tar.gz

Upload the file to your VDS inside this directory:
/usr/lib/apache/modules

Untar the file:
tar -xzvf sockets.tar.gz

Add this line to your "/usr/lib/php.ini" file:
extension=sockets.so

Restart Apache:
/etc/rc.d/init.d/apachectl restart

Enjoy!