<?php
//****************
引數設定****************
//顯示
使用者$disonline = true;
//新登陸時顯示最近內容的條數(預設為30條)
$leastnum = 30;
//預設的房間名(預設是每天換乙個檔案),如果去掉d,則是每月換乙個檔案
$room = date("y-m-d");
//房間儲存路徑,必須以/結尾
$roomdir = "rooms/";
//編碼方式
$charset = "utf-8";
//客戶端最大顯示內容條數(
建議不要太大)
$maxdisplay = 300;
//語言
$lang = array(
//聊天室描述
"description"=>"
歡迎來到迷你ajax聊天室。email:
//聊天室標題
"title"=>"歡迎進入迷你聊天
系統",
//第乙個到聊天室的歡迎
"firstone"=>"系統廣播:",
//當資訊有禁止內容時顯示
"ban"=>"請使用文明用語!禁止發布非法資訊!",
//關鍵字
"keywords"=>"聊天室",
//發言
提示"hereyourwords" => "在這裡發言!"
);header("content-type:text/
html
; charset=utf-8");
$get_past_sec = 3; //如果發現丟話,可以適當調大這個值
$title = $lang["title"];
$earlier = 10;
$description = $lang["description"];
$origroom = $room;
$least = ($_
get["dis"])?intval($_get["dis"]):$leastnum;
$touchme = $_post['touchme'];
if (!is_dir($roomdir)) @mkdir($roomdir) or die("error when creating folder $roomdir");
$room = $_get['room'];
if (!$room) $room = $_post["room"];
$room = checkfilename($room);
if (!$room) $room = $origroom;
$filename = $roomdir.$room.".dat.php";
$datafile = $roomdir.$room.".php";
if (!file_exists($filename)) @file_put_contents($filename,'<?php die();?>'."\n".time()."|".$lang["firstone"]."\n");
if (!file_exists($datafile)) @file_put_contents($datafile,'<?php die();?>'."\n");
$action = $_post["action"];
if (!function_exists("file_get_contents"))
}if (!function_exists("file_put_contents"))
}function checkfilename($file)
function get_ip()
else
return $realip;
}function array2json($arr)
}$json = $space;
$json.= ($isarr)?"[":"
$json.= ($isarr)?"]":"}";
return $json;
}function keeponline()
||";
if (strpos($onlines,$s1) === false)
@fclose($fp);}}
else}}
if ($action == "write")
",$color) || $color == "#000000") $color = "";
$color = "#".$color;
$size = intval($_post["size"]);
$name = str_replace(array("\n","\r"),"",$_post['name']);
if (!$name) die("no name!!");
$ip = get_ip();
keeponline();
$s = "";
$style = "";
$font = $_post["font"];
if ($font == "songti") $font = "宋體";
else if ($font == "heiti") $font = "黑體";
else if ($font == "kaiti") $font = "楷體_gb2312";
else $font = "";
$style .= (!$font)?"":"font-family:".$font.";";
$style .= (!$_post["bold"])?"":"font-weight:bold;";
$style .= (!$color || $color == "#")?"":"color:;";
$style .= (!$size || $size == "16")?"":"font-size:px;";
$t = time();
$arr = explode("\n",$_post['content']);
for($i = 0;$i
":$content;
$s.= $t."|".$name.":".$content."\n";
}if (!$s) die("no content!!");
$fp = @fopen($filename,"a+");
if (!$fp) die("repeat");
$re_time = 0;
while(!@flock($fp, lock_ex))
if ($re_time <4)
else die("repeat");
@fclose($fp);
echo "ok";
}else if ($action == "read")}}
else if ($first)
$item = array_reverse($item);
}$s = "";
$nt = time();
$onlines = array();
if($disonline && $touchme)
$arr = explode("|",$l);
if ($nt - intval($arr[1]) < $touchs*3)
else $s.=$l."\n";
$onlines = $arr[2];}}
@file_put_contents($datafile,$s);
$json["onlines"] = $onlines;
}$json["lines"] = $item;
echo array2json($json);
}else if ($action == "keep" )
else if ($action == "quit")
$arr = explode("|",$l);
if (trim($name) == trim($arr[2])) continue;
else $s.=$l."\n";
}@file_put_contents($datafile,$s);
echo "ok";
}die();
}else
?>
即時聊天 環信
這一步把匯入檔案倒入到專案檔案中,記得要勾選上copy items if needed 噢!點選buide phases中的link binary with libraries 這一步真機和模擬器執行結果是不一樣的,要看清楚 5 真機錯誤修復 同第二步一樣,別忘記勾選 註冊都不用說了吧,使用的話可以...
即時聊天工具
聊天室客戶端 using system using system.collections.generic using system.componentmodel using system.data using system.drawing using system.linq using system...
環信即時聊天步驟
1 註冊賬號 3 匯入modle easeui 4 講model加入到主專案 5 登陸功能 如下 emclient.getinstance login username,password,new emcallback override public void onprogress int progr...