Last active
August 29, 2015 14:00
-
-
Save rinsuki/11306628 to your computer and use it in GitHub Desktop.
かにチャットのログ取得
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$roomを取得したいroomidに合わせること | |
ログは1時間ごとに区切られて、 | |
log-年-月-日-時.txt | |
で保存される |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$room="lobby"; | |
echo "createNewId"; | |
$a=file_get_contents("http://xx.comet.kanichat.com/rent/CometServlet?mode=createNewId&roomid=".$room."&_=time"); | |
echo $a; | |
$b=json_decode($a); | |
$id=$b->session->id; | |
$c=file_get_contents("http://xx.comet.kanichat.com/rent/CometServlet?mode=loggetSoon&roomid=".$room."&_=time&id=".$id); | |
$d=json_decode($c); | |
$lt=0; | |
$max=intval(file_get_contents("chatmax.txt")); | |
foreach($d->chatlog as $e) { | |
$logtime=($e->logtime/1000)+(13*60*60); | |
$logtime2=$logtime-(1*60*60); | |
if ($max<$logtime) { | |
if (floor($logtime/(60*60))>floor($lt/(60*60))) { | |
if ($lt==0) { | |
$pp=file_get_contents("log-".date("Y-m-d-H",$logtime).".txt").$pp; | |
} else { | |
file_put_contents("log-".date("Y-m-d-H",$lt).".txt",$pp); | |
$pp=""; | |
} | |
$lt=$logtime; | |
} | |
} | |
$put=$e->name." ".$e->message."(".date("Y/m/d H:i:s", ($e->logtime/1000)+(13*60*60)).")\n"; | |
$pp=$pp.$put; | |
$max=$logtime; | |
file_put_contents("chatmax.txt",$max); | |
} | |
file_put_contents("log-".date("Y-m-d-H",$logtime).".txt",$pp); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment