Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could achieve that by using curl and loading the script as a web resource so it can be executed. If that script needs to be protected from public, you can check if the request came from the same server:</p> <pre><code>if( $_SERVER['SERVER_NAME'] != 'localhost' || $_SERVER['REMOTE_ADDR'] != '127.0.0.1' || stripos( $_SERVER['HTTP_USER_AGENT'], 'wget' )===false ) { // Access Denied!! die(); } </code></pre> <p>Be sure to make an asynchronous request with curl, so if the script takes a lot of time to execute, doesn't hang the original user request (use <code>curl_setopt( $handle, CURLOPT_HEADER, false );</code></p> <p>So the plan is from the page where you know you need to execute the script, launch an Http request to the script (this is a very basic example of using curl library):</p> <pre><code>$handle = curl_init(); curl_setopt( $handle, CURLOPT_URL, 'http://localhost/your_script.php'); curl_setopt( $handle, CURLOPT_HEADER, false ); curl_exec( $handle ); curl_close( $handle ); </code></pre> <p>Then in your script, use the above script to protect requests not comming from current server, and do the job.</p> <p><strong>Updated</strong><br> As stated in this question: <a href="https://stackoverflow.com/questions/1555517/sending-a-non-blocking-http-post-request">sending a non-blocking HTTP POST request</a> In your script job you could send this header to close the connection as script is running:</p> <pre><code>// Send the response to the client header('Connection: Close'); // Do the background job: just don't output anything! </code></pre> <p><strong>Updated II</strong><br> Reviewing my own answer, I've checked that <code>curl_setopt( $handle, CURLOPT_HEADER, false );</code> does not create an asynchronous request. I still have not found how to do it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload