|
|
|
ขอ code เช็คสถานะ status MSN online/offline ของ php... |
|
|
|
|
|
|
|
ผมก็ไม่แน่ใจเหมือนกันครับ
แต่ที่แน่ๆ คุณควรระวังเรื่องการ เช็คเงื่อนไง เพราะคุณ
Code (PHP)
if($status == " presence/Offline "){
เว้นวรรคทำไม หรือต้องการเช็คว่าเท่ากับ _presence/Offline_
Code (PHP)
if($status == "presence/Offline"){
หรือแบบนี้ presence/Offline
|
ประวัติการแก้ไข 2010-07-30 16:26:29 2010-07-30 16:27:01
|
|
|
|
Date :
2010-07-30 16:26:04 |
By :
50121680 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?
$msn[Host] = "207.46.106.175"; //MSN server
$msn[Port] = 1863; // MSN port
$msn[user] = ""; // ãËéàá¡éä¢à»ç¹ E-mail MSN ·Õè¨Ðãªé㹡Òà àªç¤ status ¤ÃѺ
$msn[Pass] = ""; // password ¢Í§ E-mail ¹Ñé¹
$pic[offline] = "msnoff.png"; // Relative path to msnoff.png
$pic[online] = "msnon.png"; // Relative path to msnon.png
if (!$get){?>
<html>
<head>
</head>
<body>
<img src="<? echo $pic[offline]; ?>" border="0" name="msn">
</body>
</html>
<?
exit;
}
msn_connect();
function msn_connect() {
global $debug, $msn, $nr, $fp; $nr = 0;
if($debug) {
echo "<p><b>Connecting to msn $msn[Host]:$msn[Port]</b><br>";
}
if($fp = fsockopen ($msn[Host], $msn[Port], $errno, $errstr, 30))
{msn_send("VER $nr MSNP7 CVRO",$fp);
while (!feof($fp)) {
usleep(1);
if (msn_get(ereg_replace("\r\n", "", fgets($fp,128))) == "1") {
die(blieb);
};
}}
else {
die("cannot connect to msn server");
}}
function msn_send($text, $conn) {
global $debug;
if ($debug) {
echo "<font color=\"red\">$text</font><br>\n";
}
fputs ($conn, "$text\r\n");
global $nr;$nr++; }
function msn_get($msg) {
global $fp, $nr, $msn, $debug, $fp2;
if ($debug) {
echo "<font color=\"blue\">$msg</font><br>\n";
}
$msg = explode(" ", $msg);
if (strtolower($msg[0]) == "ver") {
msn_send("INF $nr", $fp);
}
elseif(strtolower($msg[0]) == "inf") {
msn_send("USR $nr MD5 I $msn[user]", $fp);
}
elseif (strtolower($msg[0]) == "usr" AND strtolower($msg[2]) == "md5") {
msn_send("USR $nr MD5 S ".MD5(trim($msg[4].$msn[Pass])), $fp);
}
elseif (strtolower($msg[0]) == "usr" AND strtolower($msg[2]) == "ok") {
msn_send("CHG $nr BSY", $fp);
msn_send("XFR $nr SB", $fp);
}
elseif (strtolower($msg[0]) == "xfr" AND strtolower($msg[2]) == "ns") {
$tmp = explode(":", $msg[3]);
$msn[Host] = $tmp[0];
$msn[Port] = $tmp[1];
fclose($fp);
msn_connect();
}
elseif (strtolower($msg[0]) == "xfr" AND strtolower($msg[2]) == "sb") {
$tmp = explode(":", $msg[3]);
$msn[sb_host] = $tmp[0];
$msn[sb_port] = $tmp[1];
$msn[sb_cki] = $msg[5];
fclose($fp);
if($debug) {
echo "<p><b>Connecting to sb $msn[sb_host]:$msn[sb_port]</b><br>";
}
if($fp2 = fsockopen ($msn[sb_host], $msn[sb_port], $errno, $errstr, 30)){
$start = time()+5;
msn_send("USR $nr $msn[user] $msn[sb_cki]",$fp2);
while (!feof($fp2)) {
if (time() >= $start) {
showstatus(0);
exit;
}
usleep(1);
msn_sb_get(ereg_replace("\r\n", "", fgets($fp2,128)));
} }
else { die("cannot connect to sb"); }
}}
function msn_sb_get($msg) {
global $fp2, $nr, $msn, $debug, $get;
if ($debug) {
echo "<font color=\"green\">$msg</font><br>\n";
}
$msg = explode(" ", $msg);
if (strtolower($msg[0]) == "usr" AND strtolower($msg[2]) == "ok") {
msn_send("CAL $nr $get",$fp2);
}
elseif (strtolower($msg[0]) == "217") {
showstatus(0);
fclose($fp2);
exit;
}
elseif (strtolower($msg[0]) == "joi") {
showstatus(1);
fclose($fp2);
exit;
} }
function showstatus($status) {
global $pic,$get;
if ($status) {
Header("Content-Type: image/png");
$fn=fopen("$pic[online]","r");
fpassthru($fn);
fclose($fn);
} else {
Header("Content-Type: image/png");
$fn=fopen("$pic[offline]","r");
fpassthru($fn);
fclose($fn);
}
}?>
|
|
|
|
|
Date :
2010-09-05 23:45:42 |
By :
sek |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|