Jump to content
paxnWo

yahoo status check

Recommended Posts

Posted

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.php

Usage: start > run > cmd:

cd D:\xampp\php
d:
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...