Files
core/f_func/class._Chat.php
T
Hide_D d080e5ec2c \r\n을 \n으로 변경. 메모장에서 열 것도 아니고..
로그인 확인 등 몇몇 유틸 함수 새 db 라이브러리 기준으로 추가
ajax 기반 msgsubmit 작업중
2018-01-21 16:58:19 +09:00

28 lines
817 B
PHP

<?php
require_once('_common.php');
require_once(ROOT.'/f_config/config.php');
require_once(ROOT.W.F_FUNC.W.'class._DB.php');
require_once(ROOT.W.F_FUNC.W.'class._JSON.php');
class _Chat {
public static function SetChat($type, $name, $msg) {
$filename = ROOT.W.D_CHAT.W.$type."Chat.txt";
AppendToFile($filename, "{$name}: {$msg}\n");
}
public static function GetChat($type, $size=10) {
$filename = ROOT.W.D_CHAT.W.$type."Chat.txt";
$content = ReadToFileBackward($filename, $size*100);
$msgs = explode("\n", $content);
$count = count($msgs) - 1;
$start = $count - $size;
if($start < 0) $start = 0;
for($i = $start; $i < $count; $i++) {
$newMsg[] = htmlspecialchars($msgs[$i]);
}
return $newMsg;
}
}