user1223912
user1223912

Reputation: 11

PHP exec is blocked by ISP

I am trying to implement the following chat-html5 from git hub: https://github.com/ivanph/Chat-HTML5

I have uploaded everything to my ISP but I have found that the ISP blocks exec for security reasons.

The file I am calling is :

<?php
/**
 * Main Script of phpWebSockets
 *
 * Run this file in a shell or windows cmd to start the socket server.
 * Sorry for calling this daemon but the goal is that this server run
 * as daemon in near future.
 *
 * @author Moritz Wutz <[email protected]>
 * @version 0.1
 * @package phpWebSockets
 */

    ob_implicit_flush(true);

    require 'socket.class.php';
    require 'socketWebSocket.class.php';
    require 'socketWebSocketTrigger.class.php';

    $ip = exec ("ifconfig|grep 'inet:'|grep -v '127.0.0.1' |cut -d: -f2 |awk '{ print $1}'");
    $WebSocket = new socketWebSocket($ip,8000);

?>

Is there an alternative way to do this ? Do all Isp's block this ?

What can I do?

Hi Guys thanks for the responses. I got a response from the script developer. I have changed the $ip to the ip address of our web site. I now get the following error:

--2013-08-13 12:07:01--  http://www.wilsea.com/websockets2/startDaemon.php
Resolving www.wilsea.com... 188.64.188.21
Connecting to www.wilsea.com|188.64.188.21|:80... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2013-08-13 12:07:12 ERROR 500: Internal Server Error.

The developer says this means that the port (8000) is in use so I tried 80 - 443 - 8080 but got the same error.

I have emailed the ISP and asked if websockets are blocked or if I need a port opening.

Anyone else had this issue or any insights into this problem?

Upvotes: 0

Views: 654

Answers (3)

user1223912
user1223912

Reputation: 11

The issue was the ISP blocks all port. They have now opened the port for me.

Cheers

SteveW

Upvotes: 0

Gordon
Gordon

Reputation: 317119

Is there an alternative way to do this ?

There also are system and shell_exec, but I'd assume this to be disabled for the same reasons.

Like pointed out in the comments, you could also just provide your server's static IP instead of having the script determine it. However, chances are sockets are disabled as well, so don't put your hopes too high.

Do all Isp's block this ?

Most Hosting Providers do. Obviously a hosting service doesn't want you to run arbitrary commands on the shell that could potentially reconfigure the machine.

What can I do?

Get paid hosting that allows you to exec. A VPS or a dedicated server comes to mind.

Upvotes: 2

sba
sba

Reputation: 2107

I could try to find a way to detect a good listening address in PHP to avoid this monstrosity. (The workaround would probably be $ip = '0';) Your next question would be: Fatal error: Call to undefined function socket_create() why is my ISP so mean?. exec() is blocked for good reasons on a shared hosting and you won't be allowed to create a socket with create_socket().

No hoster will want something like this on their shared server. You'll have to get your own system but then you wouldn't want this code to run on it. This is because you don't want to run this code anywhere unless you were trying to improve on it. But then you'd be improving on a solution which builds on the sand that is PHP. And that would be sad.

Get a cheap virtual server if you really want to use this. I don't recommend it. Looks like somebody is trying to use PHP for a task it's not designed to do. If you've gotten this far without understanding the issues involved I recommend you to stay far away from it. Try it on localhost if you must, so you're not harming other people.

Upvotes: 0

Related Questions