| Server IP : 61.19.30.66 / Your IP : 216.73.216.59 Web Server : Apache/2.2.22 (Ubuntu) System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 User : www-data ( 33) PHP Version : 5.3.10-1ubuntu3.48 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/gpa/chat/ |
Upload File : |
<?
header("Expires: Sat, 1 Jan 2005 00:00:00 GMT");
header("Last-Modified: ".gmdate( "D, d M Y H:i:s")."GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("content-type: application/x-javascript; charset=tis-620");
$user=$_GET["user"]; //user
$index=$_GET["id"]; //session id
$txt=$_GET["txt"]; //ข้อความ
$roomname=$_GET["room"]; //ชื่อห้อง
include("config.php"); //ค่า settings
$timedat="$data$roomname.time.php"; //ไฟล์บันทึกเวลา cache usertime|contenttime
$contentdat="$data$roomname.dat.php"; //ไฟล์ข้อมูล sender|id|reciver|event|content
$usersfile="$data$roomname.user.php"; //ไฟล์บันทึกรายชื่อ user ในห้อง user|ip|id|time
$txt=trim($txt);
if (stristr($txt, '/pm')) { //ตรวจสอบว่าเป็น private message หรือไม่
$txts=explode(' ', $txt);
if (count($txts)<3) exit();
$reciever=$txts[1];
unset($txts[1]);
unset($txts[0]);
$txt=implode(" ", $txts);
} else $reciever="0";
$userok=false;
$ip = $_SERVER["REMOTE_ADDR"]; //าค่า IP Address
$fr=file($usersfile);
for ($i=0; $i<count($fr) && $userok==false; $i++) { //ตรวจสอบ IP และ User ให้ตรงกับ ฐานข้อมูล
$datas=explode("|", $fr[$i]);
$userok=($datas[1]==$ip && $user==$datas[0]);
}
if ($userok==true) {
$txt = str_replace ("<" , "<" , $txt); //เครื่องหมาย <
$txt = str_replace (">" , ">" , $txt); //เครื่องหมาย >
$txt = str_replace ('\"' , '"' , $txt); //เครื่องหมาย \"
$txt = str_replace ("\'" , "'", $txt); //เครื่องหมาย \'
$patterns = array ( "/(http\:\/\/[^\s]+)/i",
"/(ftp\:\/\/[^\s]+)/i",
"#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#is",
"#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i");
$replace = array ( "<a href=\"\\1\" target=\"_blank\">\\1</a>",
"<a href=\"\\1\" target=\"_blank\">\\1</a>",
"\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>",
"\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>");
$txt = preg_replace($patterns, $replace, $txt);
//มีจำนวนไม่เกิน $linecount บรรทัด
//sender|id|reciver|event|content|date, time
$data=$user.chr(4).$index.chr(4).$reciever.chr(4)."3".chr(4).$txt.chr(4)."$mtime\n"; //ข้อความที่จะแสดง
$contents=file($contentdat); //อ่านข้อมูลจากไฟล์ content
$contents[]=$data; //เพิ่มข้อมูลใหม่
$count=count($contents); //จำนวนข้อมูลทั้งหมด
$newdata="";
$n=$count-$linecount; //ตัดข้อมูลไม่เกินที่กำหนด
if ($n<0) $n=0;
for ($i=$n; $i<$count; $i++) {
$newdata.=$contents[$i];
}
$f=fopen($contentdat, "w"); //บันทึกข้อมูลลงบนไฟล์ content
fputs($f, $newdata);
fclose($f);
$times=file($timedat);
$usertime=(int)$times[0];
$contenttime=(int)$times[1];
$contenttime++;
if ($contenttime>99) $contenttime=1;
$f=fopen($timedat, "w"); //บันทึกเวลาล่าสุดลงบนฐานข้อมูล
fputs($f, $usertime."\n".$contenttime);
fclose($f);
echo "1"; //ถ้า post สำเร็จคืนค่า 1
}
?>