1 Star 0 Fork 0

NiceShuo / 简单利用网络阻塞实现实时通讯App

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fun.php 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
NiceShuo 提交于 2018-11-09 18:03 . 完善文件读取类V1.0.1
<?php
require __DIR__ . '/DB.php';
require __DIR__ . '/tools.php';//数据处理类
/**
* 链接数据库
*/
$db = new DB();
$db->__setup([
'dsn'=>'mysql:dbname=silent;host=den1.mysql4.gear.host',
'username'=>'silent',
'password'=>'Hj0ky28?-7TF',
'charset'=>'utf8'
]);
//实时查询有没有人往这个id发送消息
function selectNewData($id){
global $db;
$users = $db->fetchAll("SELECT text.id id,`name`,time,face,content FROM `text`
LEFT JOIN `user` ON text.user_id = user.id WHERE sh_user_id = $id AND state = 1 ORDER BY time ASC;");
if($users==""&&$users==null&&empty($users)){
return false;
}else{
return getArr("1",$users);
}
}
/**
* 消息被收到后进行状态变更
* @param id 消息id
*/
function sure($id){
global $db;
$parameters = ["state"=>"0"];
$condition = ["id"=>$id];
$db->update("text", $parameters, $condition);
}
/**
* 用户发送消息
* @param $fa_id 发送者
* @param $shou_id 接受者
* @param $conten 内容是
*
*/
function creat($fa_id,$shou_id,$conten){
global $db;
$time = time();
$parameters = ["user_id"=>$fa_id,"sh_user_id"=>$shou_id,"content"=>$conten,"time"=>$time,"state"=>"1"];
$res = $db->insert("text", $parameters);
if($res > 0){
echo upTime($time);
}
}
PHP
1
https://gitee.com/addcandy/chat.git
git@gitee.com:addcandy/chat.git
addcandy
chat
简单利用网络阻塞实现实时通讯App
master

搜索帮助