Login   Register  
PHP Classes
elePHPant
Icontem

File: status_checker.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of philongxp  >  YMSG16  >  status_checker.php  >  Download  
File: status_checker.php
Role: Example script
Content type: text/plain
Description: Checking Yahoo Status
Class: YMSG16
YMSG16 send message, deny buddy, status checker
Author: By
Last change: send_message.phpChange port 5050 to 80
Date: 2010-05-11 23:29
Size: 4,588 bytes
 

Contents

Class file image Download
<?php
    
include 'YMSG.class.php';
    
$ymsg = new YMSG();

    
$uid    "";    // BOT ID
    
$pwd    "";    // BOT Password    
    
$target    "";    // Target
    
    
if(isset($_GET['target']))
    {
        
$target $_GET['target'];
        
        
// Start time
        
$time_start microtime();
        
        
$opi    file_get_contents('http://opi.yahoo.com/online?m&u='.$target);
        
$stat    substr($opistrpos($opi'is') + 3);    
        
        if(
$stat == 'ONLINE')
        {
            
// End time
            
$time_end microtime();
            
$time $ymsg->timeFormat($time_start$time_end);
                        
            
//print $target." is ONLINE";
            
print '{"status":"ONLINE","time":"'.$time.'","error":""}';
        }
        else
        {
            
$server    file_get_contents('http://vcs1.msg.yahoo.com/capacity');
            
$server    substr($serverstrpos($server"CS_IP_ADDRESS=") + strlen("CS_IP_ADDRESS="));
            
$fp fsockopen($server80$errno$errstr2) or die('Cannot connect!!!');    
            if (
$fp != null)
            {
                
stream_set_timeout($fp1); 
            }
            else
            {
                
// End time
                
$time_end microtime();
                
$time $ymsg->timeFormat($time_start$time_end);    
                
                print 
'{"status":"ERROR","time":"'.$time.'","error":"Server is busy"}';
                return 
false;
            }
            
            
// Check status packet
            
$inviChk $ymsg->normalCheck($uid$target);
            
            
// Preconnect
            
$preChk $ymsg->preCheck();
            
fwrite($fp$preChk);    
            
$chkStr fread($fp20);
            
            
// Open connection success
            
if ($ymsg->getPacketType($chkStr) == 'L')
            {
                
#print 'Precheck success!!!<br/>';                    
                
$chkStr $ymsg->getChallenge($uid);
                
fwrite($fp$chkStr);
                
$chlStr fread($fp150);
            }
            
// Request challenge success
            
if ($ymsg->getPacketType($chkStr) == 'W')
            {
                
#print 'Challenge Succes!!!<br/>';                
                
$challenge     $ymsg->parseToken($chlStr"94".$ymsg->sepStrchr(0xC0));
                
                
// Saving cookie to file
                
if (!file_exists('cookie.txt'))
                {
                    
$file fopen('cookie.txt''w');
                    
$time time();
                    
                    
// Get and Parse Login Cookie Info
                    
$info        $ymsg->getLoginInfo($uid$pwd$challenge);
                    
$crumb        $ymsg->parseToken($info"crumb="chr(0xD));
                    
$T            $ymsg->parseToken($info"T="chr(0xD));
                    
$Y            $ymsg->parseToken($info"Y="chr(0xD));
                    
                    
$data    $time."#".trim($crumb)."#".trim($T)."#".trim($Y);
                    
fwrite($file$data);
                    
fclose($file);
                }
                else
                {
                    
$filename    'cookie.txt';
                    
$now        time();
                    
                    
// Reading cookie file
                    
$file fopen('cookie.txt''r');
                    
$info fread($filefilesize($filename));
                    
$info split('#'$info);
                    
                    
$time $info[0];
                    
// Cookie is alive
                    
if (($now $time) < 86400)
                    {
                        
$crumb    $info[1];
                        
$T        $info[2];
                        
$Y        $info[3];
                    }
                    else
                    {
                        
$file fopen('cookie.txt''w');
                        
$time time();
                        
                        
// Get and Parse Login Cookie Info
                        
$info        $ymsg->getLoginInfo($uid$pwd$challenge);
                        
$crumb        $ymsg->parseToken($info"crumb="chr(0xD));
                        
$T            $ymsg->parseToken($info"T="chr(0xD));
                        
$Y            $ymsg->parseToken($info"Y="chr(0xD));
                        
                        
$data    $time."#".trim($crumb)."#".trim($T)."#".trim($Y);
                        
fwrite($file$data);
                        
fclose($file);
                    }
                }
                
                
$loginStr    $ymsg->Login($uid$challenge$Y$T$crumbfalse);
                
                
// Send Login Packet
                
fwrite($fp$loginStr);
                
$loginRes    fread($fp1024);
            }
            
// Load account info, friend list, deny list, etc...
            
if ($ymsg->getPacketType($loginRes) == 'U')
            {
                
// Account info: Friend List, Ignore List, etc...
                
$nextData '';
                do {
                    
$nextData fread($fp500);
                } while (
strlen($nextData) > 0);             
            }            
            
// Login complete
            // Start checking status when login complete
            
fwrite($fp$inviChk);
                
            
// End time
            
$time_end microtime();
            
$time $ymsg->timeFormat($time_start$time_end);    
                
            
$result fread($fp1024);    
            
            
// Return status        
            
if (strlen($result) > 0)
            {
                if (
$ymsg->getPacketType($result) == chr(0xBE))
                {
                    
//print $target." is INVISIBLE";                    
                    
print '{"status":"INVISIBLE","time":"'.$time.'","error":""}';
                }
                else
                {
                    print 
'{"status":"ERROR","time":"'.$time.'","error":"Server is busy"}';
                }
            }
            else
            {
                
//print $target." is OFFLINE";
                
print '{"status":"OFFLINE","time":"'.$time.'","error":""}';
            }
        }
    }
    else
    {    
        
// print "There's an error";
        
print '{"status":"error","ERROR":"The ID is not valid."}';
    }
?>