Results 1 to 2 of 2
  1. #1

    Shared-host php scripts + CLI


    Im new here but I was told you people might be able to offer some advice. Im currently writing a customer support system for a client of mine who wants to sell it on to other companies and I have run accross a problem.

    I will be using a mixture of web-based and client-based software, in that the support staff will have a client running on their machines while the server handles all of the messages sent back and forth (customers requesting support have an HTML+javascript interface: a kind of semi-realistic realtime using message polling etc...)

    Anyway my problem is this, I want the support staff to get messages from the server as quickly as possible so when evaluating whether to have the support staff client request updates at regular intervals (polling) or hold a direct connection whenever new data is available, I felt the second was far more appropriate.

    Ideally this would be done in perl or the like but as I dont know perl at the moment and due to time constaints I will need to be doing this in php, so I decided to begin with the client software should hold the server socket for this communication (as hosts may not like additional servers run on their machines) while the webserver would use the php socket functions to connect to it when necessary and upload data.

    This is all well and good but it would appear persistant connections would not be ideal for me so I am left with the normal socket connections, so every time a message is sent a connection must be made. However (and this is where the problem lies) under this setup, if the support staff goes offline or there is no method of contacting them in a timely manner ... the customer (who is patiently waiting for help) must wait until the fsockopen function times out, if this message is going out to more than one member of staff this could take a LONG time and so the page will take a long time to load (not ideal).

    So far my idea has been to execute a seperate script in a seperate process which will send these messages one by one. that way this can run in the background while the page loads. Since there is no fork in php and I want cross-platform functionality this has so-far been the most appropriate solution:

    function execInBackground($path, $exe, $args = "") {
    global $conf;

    if (file_exists($path . $exe)) {
    if (substr(php_uname(), 0, 7) == "Windows"){
    pclose(popen("start \"bla\" \"" . $exe . "\" " . escapeshellarg($args), "r"));
    } else {
    exec("./" . $exe . " " . escapeshellarg($args) . " > /dev/null &"); }

    BUT... this would mean that we need to know where the php CLI (command-line interpreter) is, and have permission to execute it. (I figured this would be more likely to be allowed by a server admin than running an entire server with open ports on their machines).

    Can you think of any better alternatives? and can you offer advice as to whether many hosts would allow their customers to use the php CLI?

  2. #2
    n/m , found out for myself, seems all the exec/system/etc.. routines are restricted in safe-mode (which is used by most ISPs) had to find an alternative.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts