Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Problem 1</strong>: <code>curl_multi_exec</code> is not really necessary in your case. Keeping the curl handle open should suffice. </p> <p><strong>Problem 2</strong>: <code>sleep()</code> or <code>usleep()</code> works well for this purpose </p> <p><strong>Problem 3</strong>: You could just output html markup. Another option is to embed a flash file or video that plays an alarm sound automatically. Depends where this is running and for what purpose.</p> <p>Note, scripts like this are not best run in the browser. It's better to setup a cron script that checks urls at set intervals and does not use <code>do while</code> loops or <code>sleep</code>. </p> <p>Here's your code written with these corrections and a few examples.</p> <pre><code>&lt;?php set_time_limit(0); // this script will now run forever. but a safer value might be something like X hours or X number of minutes. $e = curl_init(); curl_setopt($e, CURLOPT_URL, 'http://example.com/Account/LogOn'); curl_setopt($e, CURLOPT_POST, true); curl_setopt($e, CURLOPT_POSTFIELDS, 'UserName=xxx@example.com&amp;Password=password'); // you'll need both CURLOPT_COOKIEJAR and CURLOPT_COOKIEFILE if you plan on NOT using curl's internal cookie handling curl_setopt($e, CURLOPT_COOKIEJAR, 'cookie.txt'); // this is where we write the cookie data curl_setopt($e, CURLOPT_COOKIEFILE, 'cookie.txt'); // this is where we read the cookie data to use curl_setopt($e, CURLOPT_REFERER, 'http://example.com/'); curl_setopt($e, CURLOPT_RETURNTRANSFER, true); // you can omit the next two lines if you think they won't be needed curl_setopt($e, CURLOPT_FOLLOWLOCATION, true); // in case the remote server does some kind of http redirection, like a 301 redirect curl_setopt($e, CURLOPT_MAXREDIRS, 3); // The maximum amount of HTTP redirections to follow, in case the remote server is badly configured and has an endless redirection loop curl_exec($e); $sizevalue = 2399; $maximum_checks = 30; // I've added this as a cap for the loop, so that you only run it this many times. $checks = 0; $seconds = 15; do { $checks++; curl_setopt($e, CURLOPT_URL, 'http://example.com/panel.php'); $content = curl_exec($e); $numberofchars = strlen($content); // optionally... instead of the strlen method above you could also use // http://php.net/manual/en/function.curl-getinfo.php if (!curl_errno($e)) { $info = curl_getinfo($e); echo 'content-length of download, read from Content-Length: field :' . $info['download_content_length']."&lt;br&gt;\n"; $numberofchars = $info['download_content_length']; } if ($checks === $maximum_checks) { exit('No changes after '.($seconds * $maximum_checks).' seconds&lt;br&gt;'.PHP_EOL); } sleep($seconds); // wait for 15 seconds } while ($numberofchars != $sizevalue); // fix up your TRUTH expression, don't forget it is != for proper comparison in your case. Without it you go into an infinite loop. curl_close($e); // if our php script got this far then echo ' &lt;audio controls="controls" autoplay="autoplay"&gt; &lt;source src="/path/to/your/audio.mp3" type="audio/mp3"&gt; &lt;source src="/path/to/your/audio.ogg" type="audio/ogg"&gt; &lt;embed src="/path/to/your/audio.mp3"&gt; &lt;/audio&gt;'; ?&gt; </code></pre>
    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.
 

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