paxnWo Posted December 21, 2009 Report Posted December 21, 2009 Am scris un script care verifica daca id-ul de yahoo cautat este online sau offline. Atunci cand un id este offline si devine online, esti atentionat printr-un bip ( si viceversa ). Scriptul se executa timp de X ore ( presupunem ca vrei sa-l prinzi pe respectivul cand devine online / offline ). Scriptul salveaza datele intr-un log.txt. Pot sa-l fac fie sa nu salveze in log.txt, fie sa afiseze doar cand un id isi schimba starea. L-am scris cum mi-a fost nevoie. Pentru feedback si idei, reply pl0x. Salvati codul de mai jos in ycheck.phpUsage: start > run > cmd: cd D:\xampp\phpd:php.exe ycheck.php <?php $id = 'paxnwo'; // id-ul de verificat$exec_time = 1; // timpul de executie in ore $date = date("g:i a (F j)");$status_on = "Status: ONLINE @ $date \n";$status_off = "Status: OFFLINE @ $date \n";$echo_check = "Checking id: $id\n";function beep ($int_beeps = 5) { for ($i = 0; $i < $int_beeps; $i++): $string_beeps .= "\x07"; endfor; isset ($_SERVER['SERVER_PROTOCOL']) ? false : print $string_beeps; }$url = "http://cn.opi.yahoo.com/online.php?users=$id&unq=".time(); $url_cont = file_get_contents($url); $offline = "var opi_user_status = new Array('0');";$pos = strpos($url_cont,$offline);echo $echo_check;$sec = $exec_time*3600; $once = 0;$once2 = 0;for($i=1;$i<=$sec;$i++){ if ($pos === false) { echo $status_on; if ($once != 1) { $fl = fopen('log.txt', 'a'); fwrite($fl, "$echo_check\r\n$status_on\r\n"); fclose($fl); $once = 1; beep(); } else { $fl = fopen('log.txt', 'a'); fwrite($fl, "$status_on\r\n"); fclose($fl); $bip1=1; if ($bip2 == 1) beep(); $bip2=0; } } else { echo $status_off; if ($once2 != 1) { $fl = fopen('log.txt', 'a'); fwrite($fl, "$echo_check\r\n$status_off\r\n"); fclose($fl); $once2 = 1; beep(); } else { $fl = fopen('log.txt', 'a'); fwrite($fl, "$status_off\r\n"); fclose($fl); $bip2 = 1; if ($bip1 == 1) beep(); $bip1=0; } }flush();sleep(1);$url_cont = file_get_contents($url); $pos = strpos($url_cont,$offline);} ?>also see http://rstcenter.com/forum/18702-php-time-loop.rst#post119809 Quote