当前位置: 首页 > 软件库 > 数据库相关 > >

Ajax-Chat

授权协议 Readme
开发语言 PHP
所属分类 数据库相关
软件类型 开源软件
地区 不详
投 递 者 桓深
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Ajax Chat

Ajax Chat is a complete web chat in javascript, ajax, php and mysql compatible with Phonegap

Screenshots

chat sample

Features

  1. Create new chat, send message, read messagge etc... (obviously :D)
  2. Search chat, user, and messages
  3. Edit profile (name, personal message, personal photo
  4. Block user
  5. Choose colors
  6. Choose languages (English and Italian)
  7. Choose messages storage (local or remote)
  8. Add custom menu
  9. When you add a new chat you can view the users in a list or in a map
  10. End to end encryption
  11. We have many smiles ;)
  12. Messages status (sent, delivered, read. like whatsapp)
  13. Load old messages when you scroll up

Installation

1. Database

Create a new table in your database

CREATE TABLE IF NOT EXISTS chat_messages (
	id_mex BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
	id_pair BIGINT NOT NULL,
	from_user BIGINT NOT NULL,
	to_user BIGINT NOT NULL,
	user_chat BIGINT NOT NULL,
	message TEXT NOT NULL,
	status INT(1) NOT NULL,
	`date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
	`date2` TIMESTAMP NOT NULL,
	`date3` TIMESTAMP NOT NULL
);

2. Server

Upload "server" folder on your remote server, then open the file Server/chat.php and edit these lines for database connection:

$col = 'mysql:host=XXXXXXXXXXXXXXXXXX;dbname=XXXXXXXXXXXXXXXXXX';
$username = "XXXXXXXXXXXXXXXXXX";
$password = "XXXXXXXXXXXXXXXXXX";

3. Client

Open Client/index.html and Client/test.html and change these line for point to remote php file just uploaded

server: "http://XXXXXXXXXXXXXXXXXX/chat.php",

Now you can open Client/index.html and Client/test.html and start to chat :)

Method

Method Params Description
change_list userlist, [latitude, longitude] When the user list or geoposition (optional) is changed you can launch this function to update it
chat_open chat_id When user open a chat, here you can hide a notification (in phonegap for example)
new_mex message When arrive a new message, here you can show a notification (in phonegap for example)
profile_update profile When profile is updated, here you can save user data
send_message user_id When user send message to user_id
send_new_message to_user, display_name, message useful for create a chatbot, if you want send "hello" to user 54 from "AppBot" set: (54, "AppBot", "hello"
set_public_key public_key When the public key is generated, here you can save the key
updated_messages messages, success When messages are read and "locale" is true, here you can save the messages and launch success(messages), for remove data from database, example

Property

Property Default Description
color ["#2ecc71","#3498db","#e2ffc4","#eee"] colors of the chat
current_user Current user info: structure
custom_head Here you can add the html code to add to the head
custom_item_menu ["Info", "About
Lorem ipsum...."]
This add a new item menu "Info" when write inside "About
Lorem ipsum...."
debug false if you want to see console.log for debug
height 500px height of the chat
lang en languages available english (en) and italian (it)
list List of chat users, structure
locale true if you want to storage the message in locale set true, if you want all messages in the remote database set false
load_message 10 Number of messages to load when you scroll up
messages if "locale" is true and with "updated_messages" method you have saved the messages, you can restore it in this property
path chat If you rename the path "Client/chat" you have to change also here
server http://XXXXXXXXXXXXXXXXXX/chat.php This is the remote url (file Server/chat.php see the installation)
view list you can view the user like a "list" or in a "map" (for this you have to set "lat" and "lon" in "list" property)

Structures

Current user

{
	id: "number", //user's id
	name: "string", //user's name
	img: "data:image/*;base64", //user's image in base64
	phrase: "string", //user's personal phrase
	key: "string" //key for generate the encryption key
}

List users

{
	"number": //user's id
	{
		id: "number", //user's id
		name: "string", //user's name
		available: true, //if user is available
		img: "data:image/*;base64", //user's image in base64
		phrase: "string", //user's personal phrase
		lat: float, //user's latitude (you have to use if "view" is set like "map")
		lon: float, //user's longitude (you have to use if "view" is set like "map")
		public_key: "string" //user's public key for crittography generate from "set_public_key" method
	},
	"number": { ....... },
	"number": { ....... },
	"number": { ....... },
	.......
}

Update messages

updated_messages: function(messages, success){
	$.ajax({
		url: "http://localhost/savechat.php",
		method: "POST",
		data: {set: messages]},
		success: function(){
			success(messages);
		}
	});
}

TODO

  • Create groups (Work in progress 20/08/2020)
  • Change status (online, writing, last login)
  • Send file
  • Share messages / contents (inside and outside chat)
  • Delete, copy, info, star icone the message

Libraries of this project

  • Goolge提供很多的例程,挑选了simple-ajax-chat,不为别的就因为一看名字就知道大概要做点什么,其他的一些基本不知道做什么用。 代码位置:http://code.google.com/p/google-app-engine-samples/source/browse/trunk/simple-ajax-chat 代码不多,只有188行(如下): 1 import cgi 2 imp

 相关资料
  • Ajax Chat 是一种用 JavaScript、PHP 和 MySQL 实现的开源 Web 聊天软件,在 GNU Affero General Public License 下发布。您可以使用自己的代码定制聊天的外观和感受以及它向服务器上的数据库发送消息的方式。 Ajax Chat 有两种版本 — 独立版和论坛集成版。您可以随心所欲地添加或减少频道。只要不影响现有资源,在所托管的环境内就没有最

  • 上文(AJAX(一)AJAX的简介和基础)对ajax异步请求服务器做了详细的介绍和基础应用,可以看出,ajax的一些过程是相对不变的。不必要每次发送请求都写一遍发送代码,一些ajax开发人员已经把他们的过程封装成ajax框架。 本节主要介绍ajaxLib和ajaxGold两款框架。 1.ajaxLib ajaxLib是一个非常小巧的ajax框架。 使用它首先将文件使用引入到页面中。改框架是一个直接

  • AJAX代表Asynchronous JavaScript and XML 。 它是一种借助XML, JSON, HTML, CSS,和JavaScript创建更好,更快,更交互的Web应用程序的技术。 AJAX允许您在不重新加载网页的情况下异步发送和接收数据,因此速度很快。 区域组件 区域组件用于提供内容(标记)以及内容本身的位置。 Tape Component内部使用Zone Componen

  • AJAX代表异步JavaScript和XML。 这是一种跨平台技术,可加快响应时间。 AJAX服务器控制将脚本添加到由浏览器执行和处理的页面。 但是,与其他ASP.NET服务器控件一样,这些AJAX服务器控件也可以具有与它们关联的方法和事件处理程序,这些处理程序在服务器端进行处理。 Visual Studio IDE中的控件工具箱包含一组名为“AJAX Extensions”的控件 ScriptM

  • Struts使用DOJO框架进行AJAX标记实现。 首先,要继续此示例,您需要将struts2-dojo-plugin-2.2.3.jar添加到类路径中。 您可以从struts2下载的lib文件夹中获取此文件(C:\struts-2.2.3all\struts-2.2.3\lib\struts2-dojo-plugin-2.2.3.jar) 对于这个练习,让我们修改HelloWorld.jsp如下

  • 组件 触发字符 mui.ajax() majax mui.post() mpost mui.get() mget mui.getJSON() mjson