Commit 2ff0adfd authored by Danny SMc's avatar Danny SMc

Amended most, added chat system with API

parent 8cad4fec
ew0KICB7DQogICAgZmlsZW5hbWUgPSAiZmlsZW1hbmFnZXIubHVhIiwNCiAgICBuYW1lID0gIkZpbGVNYW5hZ2VyIiwNCiAgICByZWxlYXNlZCA9ICIxOC8wNy8yMDE2IiwNCiAgfSwNCn0=
\ No newline at end of file
ewogIENvbmZpZyA9IHsKICAgIFVzZUJldGFVcGRhdGVTdHJlYW0gPSBmYWxzZSwKICAgIFBsdWdpbnNEaXJlY3RvcnkgPSAiL0RBX1BsdWdpbnMiLAogICAgRW5hYmxlUGx1Z2lucyA9IHRydWUsCiAgICBFeGFtcGxlU2V0dGluZyA9IHRydWUsCiAgICBDb25maWdGaWxlUGF0aCA9ICIuRGlzY292ZXJDb25maWciLAogICAgQmxvY2tUZXJtaW5hdGUgPSBmYWxzZSwKICAgIFBsdWdpbkNvbmZpZ0ZpbGUgPSAiLkRpc2NvdmVyQXBwUGx1Z2lucyIsCiAgICBBdXRvVXBkYXRlID0gZmFsc2UsCiAgfSwKICBBY2NvdW50ID0gewogICAgUGFzc3dvcmQgPSAiYWQ0ZmFhMjU2MzY3Y2EzZTc5ZGZiNDAwMGQyMWQ3ZTI4MzQwMGJiZjI4Y2YzMjhhNzA1MWRiYmZhNDU4YjdkOCIsCiAgICBVc2VybmFtZSA9ICJkYW5ueXNtYzk1IiwKICB9LAp9
\ No newline at end of file
--[[
Name: FileManager Plugin
Desc: A powerful file manager
Auth: DannySMc
]]
-- @base filemanager
-- @func entry
Plugin.filemanager = {};
function Plugin.filemanager.entry()
local filemanagericon = {
{"a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: "};
{"a:a: ","0:a:F","0:a:i","0:a:l","0:a:e","0:a: ","0:a: ","0:a: ","0:a: ","0:a: ","a:4: ","a:5: ","a:5: ","0:a: "};
{"a:a: ","0:a: ","0:a:M","0:a:a","0:a:n","0:a:a","0:a:g","0:a:e","0:a:r","0:a: ","0:4: ","a:4: ","a:4: ","a:a: "};
{"a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: ","a:a: "};
};
DiscoverApp.Register.MenuIcon("FileManager", filemanagericon);
DiscoverApp.Register.MenuEntry("FileManager", "filemanager", "main", "Files", false);
end
function program.filemanager.main()
base.screen.colour("white")
program.draw.menubar("Files: Main")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
local scroll = 0;
local path = "/";
local history = {};
local fileList = {};
base.draw.textl(" < >", 3, false, "lightBlue", "white")
base.draw.texta("::" .. tostring(path):sub(1, 42), 6, 3, false, "lightGrey", "white")
local function parse(path)
if fs.exists(path) then
table.insert(history, path)
end
local list = fs.list(path)
local new = {}
for _,v in ipairs(list) do
if fs.isDir(fs.combine(path, v)) then
table.insert(new, "+" .. tostring(v))
end
end
for _,v in ipairs(list) do
if not fs.isDir(fs.combine(path, v)) then
table.insert(new, "-" .. tostring(v))
end
end
fileList = new;
return new;
end
local function render(data)
base.draw.texta("::" .. tostring(path):sub(1, 42), 6, 3, false, "lightGrey", "white")
for i=1, 13 do
base.draw.box(1, 30, i+4, 1, " ", "white", "white")
if i+scroll <= #data then
if data[i+scroll]:sub(1,1) == "+" then
base.draw.textl(" " .. tostring(data[i+scroll]:sub(2)), i+4, false, "blue", "white")
elseif data[i+scroll]:sub(1,1) == "-" then
base.draw.textl(" " .. tostring(data[i+scroll]:sub(2)), i+4, false, "lightGrey", "white")
end
end
end
end
render(parse(path));
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Files: Main")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Files: Main", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and (args[4] == 19) then
base.thread.remove("Files")
base.thread.switch("Home")
elseif (args[3] >= 2 and args[3] <= 40) and (args[4] >= 5 and args[4] <= 17) then
local id = args[4] - 4 + scroll
if #fileList >= id then
local newpath = fs.combine(path, fileList[id])
if fs.isDir(newpath) then
path = newpath;
render(parse(path))
else
end
end
end
elseif args[1] == "mouse_scroll" then
if args[2] == -1 then
if scroll > 0 then
scroll = scroll - 1
render(parse(path))
end
elseif args[2] == 1 then
if scroll+13 < #fileList then
scroll = scroll + 1
render(parse(path))
end
end
end
end
end
\ No newline at end of file
Finder
-> Add click support
Help FAQ
-> Document everything
Chat Rooms
-> Add the screens into this
DAPI
-> Add FAQ/Help Insertions
-> Add Credits Insertions
PHP-API:
-> Check user account failure and callbacks
\ No newline at end of file
-> Add the screens into this
\ No newline at end of file
......@@ -55,7 +55,8 @@ function program.account.register()
elseif (args[3] >= 43 and args[3] <= 50) and (args[4] == 19) then
if username and password and email then
base.draw.textc("Requesting Authentication, Please Wait", 17, false, "lightGrey", "white")
if Discover.User:Register(username, password, email) then
local regok, errmsg = Discover.User:Register(username, password, email)
if regok then
base.gui.alert("Registered. Obtaining authkey, please wait")
sleep(0.5)
local status = Discover.User:Login(username, password)
......@@ -72,7 +73,7 @@ function program.account.register()
end
else
base.draw.box(1, 51, 17, 1, " ", "white", "white")
base.draw.textc(tostring(discover.data.errormsg), 17, false, "lightGrey", "white")
base.draw.textc(tostring(errmsg), 17, false, "lightGrey", "white")
sleep(1)
base.thread.remove("Account")
base.thread.switch("Home")
......
......@@ -47,7 +47,6 @@ local paths = {
"cloud/cloud.main.lua";
"mail/mail.main.lua";
"chat/chat.main.lua";
"chat/chat.personal.lua";
"chat/chat.group.lua";
"chat/chat.global.lua";
"chat/chat.info.lua";
......
......@@ -3,43 +3,24 @@
Desc: Main chat group viewer
--]]
function program.chat.group(screen)
if screen == "list" then
base.screen.colour("white")
program.draw.menubar("Chat: Group")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
function program.chat.group(gid)
base.screen.colour("white")
program.draw.menubar("Chat: Group")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Chat: Group")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Group", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Profile")
base.thread.switch("Home")
end
end
end
elseif screen == "view" then
base.screen.colour("white")
program.draw.menubar("Chat: Group::View")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
base.draw.textc(tostring(gid), 10, false, "red", "white")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Chat: Group::View")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Group::View", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Profile")
base.thread.switch("Home")
end
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Chat: Group")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Group", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Profile")
base.thread.switch("Home")
end
end
end
......
......@@ -10,8 +10,31 @@ function program.chat.main()
base.draw.textr("Exit ", 19, false, "red", "grey")
base.draw.textl(" About", 19, false, "orange", "grey")
local scroll = 0;
base.draw.textc("Downloading groups list ... ", 10, false, "red", "white")
local ok, group_list = Discover.Chat:List("group");
local function render()
for i=1, 14 do
if i+scroll <= #group_list then
base.draw.box(1, 51, i+3, 1, " ", "white", "white")
base.draw.texta(" " .. tostring(i+scroll).. ": " .. tostring(group_list[i+scroll]), 24, i+3, false, "cyan", "white")
end
end
end
if not ok then
base.draw.box(24, 27, 10, 1, " ", "white", "white")
base.draw.texta("Could not download groups", 27, 10, false, "red", "white")
downloaded_groups = false;
else
base.draw.box(1, 51, 10, 1, " ", "white", "white")
downloaded_groups = true;
render();
end
local count = 0;
local options = {"Global Chat", "Group Chat", "Personal Message"};
local options = {"Global Chat", "Group Chat"};
for i=1, 22 do base.draw.box(i, 1, 3, 16, false, "lightGrey", "lightGrey"); end
for i=1, (#options*2), 2 do
count = count + 1;
......@@ -34,9 +57,53 @@ function program.chat.main()
elseif (args[3] >= 2 and args[3] <= 21) and args[4] == 4 then
program.chat.global()
elseif (args[3] >= 2 and args[3] <= 21) and args[4] == 6 then
program.chat.group("list")
elseif (args[3] >= 2 and args[3] <= 21) and args[4] == 8 then
program.chat.personal("list")
local group_name = base.gui.input("Group name to join?")
local group_exists = false;
if group_name then
for _,v in ipairs(group_list) do
if v == group_name then
group_exists = true;
end
end
end
if not group_exists then
local ok = base.gui.confirm("Group not found, create it?")
if ok then
local ok, err = Discover.Chat:Send("group", group_name, "Group created by: " .. tostring(Discover.User.Data.Username), true)
if ok then
base.gui.alert("Created new group, joining...")
sleep(1)
program.chat.group(group_name)
else
base.gui.alert("Failed:" .. tostring(err))
sleep(1.5)
program.chat.main()
end
else
base.gui.alert("Not created, returning...")
sleep(0.5)
program.chat.main();
end
end
elseif (args[3] >= 23 and args[3] <= 51) and (args[4] >= 4 and args[4] <= 17) then
local id = args[4] - 3 + scroll
if id <= #group_list then
program.chat.group(group_list[id])
end
end
elseif args[1] == "mouse_scroll" then
if downloaded_groups then
if args[2] == -1 then
if scroll > 0 then
scroll = scroll - 1
render();
end
elseif args[2] == 1 then
if scroll+14 < #group_list then
scroll = scroll + 1
render();
end
end
end
end
end
......
--[[
Name: chat.personal
Desc: Main chat personal viewer
--]]
function program.chat.personal()
if screen == "list" then
base.screen.colour("white")
program.draw.menubar("Chat: Personal")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Chat: Personal")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Personal", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Profile")
base.thread.switch("Home")
end
end
end
elseif screen == "view" then
base.screen.colour("white")
program.draw.menubar("Chat: Personal::View")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Chat: Personal::View")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Personal::View", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Profile")
base.thread.switch("Home")
end
end
end
end
end
\ No newline at end of file
......@@ -217,10 +217,9 @@ Discover = {
req = textutils.unserialize(req.readAll())
if req.status then
self.Data.CMessage = tostring(req.message)
return true
return unpack({true,req.message});
else
self.Data.ErrorMsg = req.error
return false
return unpack({false,req.error});
end
else
self.Data.ErrorMsg = "Please supply a username, password and email!"
......@@ -366,11 +365,64 @@ Discover = {
end;
};
Chat = {
Send = function( self, ctype, cid, message )
-- ChatID can be username, group or 'global'
Send = function( self, ctype, cid, message, create )
if ctype == "global" then
local query = "cmd=chat-send&key=" .. textutils.urlEncode(tostring(Discover.User.Data.AuthKey)) .. "&ntype=global&message=" .. textutils.urlEncode(tostring(cid));
local req = http.post(Discover.Data.Urls.Store, query, Discover.Data.Headers)
local req = textutils.unserialize(req.readAll())
if req.status then
return unpack({true, req.data})
else
return unpack({false, req.error})
end
elseif ctype == "group" then
local query = "";
if create then
query = "cmd=chat-send&create=true&key=" .. textutils.urlEncode(tostring(Discover.User.Data.AuthKey)) .. "&ntype=group&cid=" .. textutils.urlEncode(tostring(cid)) .. "&message=" .. textutils.urlEncode(tostring(message));
else
query = "cmd=chat-send&key=" .. textutils.urlEncode(tostring(Discover.User.Data.AuthKey)) .. "&ntype=group&cid=" .. textutils.urlEncode(tostring(cid)) .. "&message=" .. textutils.urlEncode(tostring(message));
end
local req = http.post(Discover.Data.Urls.Store, query, Discover.Data.Headers)
local req = textutils.unserialize(req.readAll())
if req.status then
return unpack({true, req.data})
else
return unpack({false, req.error})
end
end
end;
View = function( self, ctype, cid )
-- ChatID can be username, group or 'global'
if ctype == "global" then
local query = "cmd=chat-list&key=" .. textutils.urlEncode(tostring(Discover.User.Data.AuthKey)) .. "&ntype=global";
local req = http.post(Discover.Data.Urls.Store, query, Discover.Data.Headers)
local req = textutils.unserialize(req.readAll())
if req.status then
return unpack({true, req.data})
else
return unpack({false, req.error})
end
elseif ctype == "group" then
local query = "cmd=chat-list&key=" .. textutils.urlEncode(tostring(Discover.User.Data.AuthKey)) .. "&ntype=group&cid=" .. textutils.urlEncode(tostring(cid));
local req = http.post(Discover.Data.Urls.Store, query, Discover.Data.Headers)
local req = textutils.unserialize(req.readAll())
if req.status then
return unpack({true, req.data})
else
return unpack({false, req.error})
end
end
end;
List = function( self, ntype )
if ntype == "group" then
local query = "cmd=chat-list-groups&key=" .. textutils.urlEncode(tostring(Discover.User.Data.AuthKey));
local req = http.post(Discover.Data.Urls.Store, query, Discover.Data.Headers)
local req = textutils.unserialize(req.readAll())
if req.status then
return unpack({true, req.data})
else
return unpack({false, req.error})
end
end
end;
};
Forums = {
......
......@@ -4968,8 +4968,31 @@ function program.chat.main()
base.draw.textr("Exit ", 19, false, "red", "grey")
base.draw.textl(" About", 19, false, "orange", "grey")
local scroll = 0;
base.draw.textc("Downloading groups list ... ", 10, false, "red", "white")
local ok, group_list = Discover.Chat:List("group");
local function render()
for i=1, 14 do
if i+scroll <= #group_list then
base.draw.box(1, 51, i+3, 1, " ", "white", "white")
base.draw.texta(" " .. tostring(i+scroll).. ": " .. tostring(group_list[i+scroll]), 24, i+3, false, "cyan", "white")
end
end
end
if not ok then
base.draw.box(24, 27, 10, 1, " ", "white", "white")
base.draw.texta("Could not download groups", 27, 10, false, "red", "white")
downloaded_groups = false;
else
base.draw.box(1, 51, 10, 1, " ", "white", "white")
downloaded_groups = true;
render();
end
local count = 0;
local options = {"Global Chat", "Group Chat", "Personal Message"};
local options = {"Global Chat", "Group Chat"};
for i=1, 22 do base.draw.box(i, 1, 3, 16, false, "lightGrey", "lightGrey"); end
for i=1, (#options*2), 2 do
count = count + 1;
......@@ -4992,55 +5015,52 @@ function program.chat.main()
elseif (args[3] >= 2 and args[3] <= 21) and args[4] == 4 then
program.chat.global()
elseif (args[3] >= 2 and args[3] <= 21) and args[4] == 6 then
program.chat.group("list")
elseif (args[3] >= 2 and args[3] <= 21) and args[4] == 8 then
program.chat.personal("list")
end
end
end
end
--[[
Name: chat.personal
Desc: Main chat personal viewer
--]]
function program.chat.personal()
if screen == "list" then
base.screen.colour("white")
program.draw.menubar("Chat: Personal")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Chat: Personal")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Personal", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Profile")
base.thread.switch("Home")
local group_name = base.gui.input("Group name to join?")
local group_exists = false;
if group_name then
for _,v in ipairs(group_list) do
if v == group_name then
group_exists = true;
end
end
end
if not group_exists then
local ok = base.gui.confirm("Group not found, create it?")
if ok then
local ok, err = Discover.Chat:Send("group", group_name, "Group created by: " .. tostring(Discover.User.Data.Username), true)
if ok then
base.gui.alert("Created new group, joining...")
sleep(1)
program.chat.group(group_name)
else
base.gui.alert("Failed:" .. tostring(err))
sleep(1.5)
program.chat.main()
end
else
base.gui.alert("Not created, returning...")
sleep(0.5)
program.chat.main();
end
end
elseif (args[3] >= 23 and args[3] <= 51) and (args[4] >= 4 and args[4] <= 17) then
local id = args[4] - 3 + scroll
if id <= #group_list then
program.chat.group(group_list[id])
end
end
end
elseif screen == "view" then
base.screen.colour("white")
program.draw.menubar("Chat: Personal::View")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Chat: Personal::View")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Personal::View", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Profile")
base.thread.switch("Home")
elseif args[1] == "mouse_scroll" then
if downloaded_groups then
if args[2] == -1 then
if scroll > 0 then
scroll = scroll - 1
render();
end
elseif args[2] == 1 then
if scroll+14 < #group_list then
scroll = scroll + 1
render();
end
end
end
end
......@@ -5052,43 +5072,24 @@ end
Desc: Main chat group viewer
--]]
function program.chat.group(screen)
if screen == "list" then
base.screen.colour("white")
program.draw.menubar("Chat: Group")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
function program.chat.group(gid)
base.screen.colour("white")
program.draw.menubar("Chat: Group")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Chat: Group")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Group", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Profile")
base.thread.switch("Home")
end
end
end
elseif screen == "view" then
base.screen.colour("white")
program.draw.menubar("Chat: Group::View")
base.draw.box(1, 51, 19, 1, " ", "grey", "grey")
base.draw.textr("Exit ", 19, false, "red", "grey")
base.draw.textc(tostring(gid), 10, false, "red", "white")
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Chat: Group::View")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Group::View", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Profile")
base.thread.switch("Home")
end
while true do
local args = { os.pullEvent() }
if args[1] == "timer" then
program.draw.menubar("Chat: Group")
elseif args[1] == "mouse_click" then
if args[4] >= 1 and args[4] <= 2 then
program.draw.menu.handler("Chat: Group", args[3], args[4])
elseif (args[3] >= 47 and args[3] <= 50) and args[4] == 19 then
base.thread.remove("Profile")
base.thread.switch("Home")
end
end
end
......@@ -5976,7 +5977,8 @@ function program.account.register()
elseif (args[3] >= 43 and args[3] <= 50) and (args[4] == 19) then
if username and password and email then
base.draw.textc("Requesting Authentication, Please Wait", 17, false, "lightGrey", "white")
if Discover.User:Register(username, password, email) then
local regok, errmsg = Discover.User:Register(username, password, email)
if regok then
base.gui.alert("Registered. Obtaining authkey, please wait")
sleep(0.5)
local status = Discover.User:Login(username, password)
......@@ -5993,7 +5995,7 @@ function program.account.register()
end
else
base.draw.box(1, 51, 17, 1, " ", "white", "white")
base.draw.textc(tostring(discover.data.errormsg), 17, false, "lightGrey", "white")
base.draw.textc(tostring(errmsg), 17, false, "lightGrey", "white")
sleep(1)
base.thread.remove("Account")
base.thread.switch("Home")
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -25,6 +25,8 @@
$profile = "cc__store_profiles";
$tickets = "cc__store_tickets";
$plugins = "cc__store_plugins";
$chat_global = "cc__store_chat";
$chat_group = "cc__store_chat_group";
// Get command
$cmd = checkString($_POST['cmd']);
......@@ -1214,6 +1216,137 @@
break;
case 'chat-send';
$key = checkString($_POST['key']);
$ntype = checkString($_POST['ntype']);
if (validatekey($key)) {
if ($ntype == "global") {
$message = base64_encode(checkString($_POST['message']));
$user = getfield($key, 'username');
$sent = date('H:i Y-m-d');
$sql = "INSERT INTO `$chat_global` (message, sender, sent_time) VALUES ('$message','$user','$sent')";
if ($conn->query($sql) === true) {
echo '{["status"]=true;["message"]="Message was successfully sent";}';
} else {
echo '{["status"]=false;["error"]="Could not send message";}';
}
} elseif ($ntype == "group") {
$message = base64_encode(checkString($_POST['message']));
$user = getfield($key, 'username');
$sent = date('H:i Y-m-d');
$chatid =